From: Tom Hughes Date: Thu, 10 Apr 2025 18:22:36 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/pull/5917' X-Git-Tag: live X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/HEAD?ds=sidebyside;hp=2b1741b9e6ac41e41eabb0f51cc913b0b5949280 Merge remote-tracking branch 'upstream/pull/5917' --- diff --git a/Dockerfile b/Dockerfile index 5df13d717..884d69ef1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,10 +42,10 @@ RUN mkdir -p /app WORKDIR /app # Install Ruby packages -ADD Gemfile Gemfile.lock /app/ +COPY Gemfile Gemfile.lock /app/ RUN bundle install # Install NodeJS packages using yarn -ADD package.json yarn.lock /app/ -ADD bin/yarn /app/bin/ +COPY package.json yarn.lock /app/ +COPY bin/yarn /app/bin/ RUN bundle exec bin/yarn install diff --git a/Gemfile.lock b/Gemfile.lock index 925eebe3c..fd96ed5ee 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,8 +96,8 @@ GEM autoprefixer-rails (10.4.19.0) execjs (~> 2) aws-eventstream (1.3.2) - aws-partitions (1.1073.0) - aws-sdk-core (3.221.0) + aws-partitions (1.1082.0) + aws-sdk-core (3.222.1) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.992.0) aws-sigv4 (~> 1.9) @@ -107,7 +107,7 @@ GEM aws-sdk-kms (1.99.0) aws-sdk-core (~> 3, >= 3.216.0) aws-sigv4 (~> 1.5) - aws-sdk-s3 (1.182.0) + aws-sdk-s3 (1.183.0) aws-sdk-core (~> 3, >= 3.216.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.5) @@ -137,7 +137,7 @@ GEM bootstrap_form (5.4.0) actionpack (>= 6.1) activemodel (>= 6.1) - brakeman (7.0.0) + brakeman (7.0.2) racc brotli (0.6.0) builder (3.3.0) @@ -213,7 +213,7 @@ GEM activerecord (>= 3.0, < 9.0) delayed_job (>= 3.0, < 5) docile (1.4.1) - doorkeeper (5.8.1) + doorkeeper (5.8.2) railties (>= 5) doorkeeper-i18n (5.2.7) doorkeeper (>= 5.2) @@ -272,7 +272,7 @@ GEM factory_bot_rails (6.4.4) factory_bot (~> 6.5) railties (>= 5.0.0) - faraday (2.12.2) + faraday (2.12.3) faraday-net_http (>= 2.0, < 3.5) json logger @@ -338,7 +338,7 @@ GEM in_threads (1.6.0) iniparse (1.5.0) io-console (0.8.0) - irb (1.15.1) + irb (1.15.2) pp (>= 0.6.0) rdoc (>= 4.0.0) reline (>= 0.4.2) @@ -365,7 +365,7 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - logger (1.6.6) + logger (1.7.0) logstasher (2.1.5) activesupport (>= 5.2) request_store @@ -407,7 +407,7 @@ GEM net-smtp (0.5.1) net-protocol nio4r (2.7.4) - nokogiri (1.18.6) + nokogiri (1.18.7) mini_portile2 (~> 2.8.2) racc (~> 1.4) oauth (1.1.0) @@ -469,7 +469,7 @@ GEM iniparse (~> 1.4) rexml (>= 3.3.9) parallel (1.26.3) - parser (3.3.7.2) + parser (3.3.7.4) ast (~> 2.4.1) racc pg (1.5.9) @@ -550,10 +550,10 @@ GEM rb-inotify (0.11.1) ffi (~> 1.0) rchardet (1.9.0) - rdoc (6.13.0) + rdoc (6.13.1) psych (>= 4.0.0) regexp_parser (2.10.0) - reline (0.6.0) + reline (0.6.1) io-console (~> 0.5) request_store (1.7.0) rack (>= 1.4) @@ -563,7 +563,7 @@ GEM rouge (4.5.1) rtlcss (0.2.1) mini_racer (>= 0.6.3) - rubocop (1.74.0) + rubocop (1.75.2) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -571,10 +571,10 @@ GEM parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.38.0, < 2.0) + rubocop-ast (>= 1.44.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.43.0) + rubocop-ast (1.44.0) parser (>= 3.3.7.2) prism (~> 1.4) rubocop-capybara (2.22.1) @@ -583,19 +583,19 @@ GEM rubocop-factory_bot (2.27.1) lint_roller (~> 1.1) rubocop (~> 1.72, >= 1.72.1) - rubocop-minitest (0.37.1) + rubocop-minitest (0.38.0) lint_roller (~> 1.1) - rubocop (>= 1.72.1, < 2.0) + rubocop (>= 1.75.0, < 2.0) rubocop-ast (>= 1.38.0, < 2.0) - rubocop-performance (1.24.0) + rubocop-performance (1.25.0) lint_roller (~> 1.1) - rubocop (>= 1.72.1, < 2.0) + rubocop (>= 1.75.0, < 2.0) rubocop-ast (>= 1.38.0, < 2.0) - rubocop-rails (2.30.3) + rubocop-rails (2.31.0) activesupport (>= 4.2.0) lint_roller (~> 1.1) rack (>= 1.1) - rubocop (>= 1.72.1, < 2.0) + rubocop (>= 1.75.0, < 2.0) rubocop-ast (>= 1.38.0, < 2.0) rubocop-rake (0.7.1) lint_roller (~> 1.1) @@ -616,7 +616,7 @@ GEM addressable (>= 2.3.5) faraday (>= 0.17.3, < 3) securerandom (0.4.1) - selenium-webdriver (4.30.1) + selenium-webdriver (4.31.0) base64 (~> 0.2) logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) @@ -645,7 +645,7 @@ GEM activesupport (>= 6.1) sprockets (>= 3.0.0) stringio (3.1.6) - strong_migrations (2.2.1) + strong_migrations (2.3.0) activerecord (>= 7) teaspoon (1.4.0) railties (>= 5.0) diff --git a/app/assets/javascripts/diary_entry.js b/app/assets/javascripts/diary_entry.js index bfc3fc012..041e49f7e 100644 --- a/app/assets/javascripts/diary_entry.js +++ b/app/assets/javascripts/diary_entry.js @@ -11,7 +11,7 @@ $(function () { map.removeLayer(marker); } - marker = L.marker(e.latlng, { icon: OSM.getUserIcon() }).addTo(map) + marker = L.marker(e.latlng, { icon: OSM.getMarker({}) }).addTo(map) .bindPopup(OSM.i18n.t("diary_entries.edit.marker_text")); } @@ -30,13 +30,12 @@ $(function () { zoomControl: false }).addLayer(new L.OSM.Mapnik()); - L.OSM.zoom({ position: position }) - .addTo(map); + L.OSM.zoom({ position }).addTo(map); map.setView(centre, params.zoom); if ($("#latitude").val() && $("#longitude").val()) { - marker = L.marker(centre, { icon: OSM.getUserIcon() }).addTo(map) + marker = L.marker(centre, { icon: OSM.getMarker({}) }).addTo(map) .bindPopup(OSM.i18n.t("diary_entries.edit.marker_text")); } diff --git a/app/assets/javascripts/id.js b/app/assets/javascripts/id.js index d60d4b82d..b5c8a4153 100644 --- a/app/assets/javascripts/id.js +++ b/app/assets/javascripts/id.js @@ -76,5 +76,10 @@ document.addEventListener("DOMContentLoaded", function () { const data = parent.OSM.mapParams(); goToLocation(data); }); + + const projectTitle = parent.document.title; + new MutationObserver(() => + parent.document.title = [document.title, projectTitle].filter(t => t).join(" | ") + ).observe(document.querySelector("title"), { childList: true, subtree: true, characterData: true }); } }); diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index b3ec71b92..7ff8a40d1 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -1,7 +1,6 @@ //= require_self //= require leaflet.sidebar //= require leaflet.sidebar-pane -//= require leaflet.locatecontrol/dist/L.Control.Locate.umd //= require leaflet.locate //= require leaflet.layers //= require leaflet.key @@ -111,39 +110,30 @@ $(function () { } addControlGroup([ - L.OSM.zoom({ position: position }), - L.OSM.locate({ position: position }) + L.OSM.zoom({ position }), + L.OSM.locate({ position }) ]); addControlGroup([ L.OSM.layers({ - position: position, - layers: map.baseLayers, - sidebar: sidebar - }), - L.OSM.key({ - position: position, - sidebar: sidebar + position, + sidebar, + layers: map.baseLayers }), + L.OSM.key({ position, sidebar }), L.OSM.share({ - "position": position, - "sidebar": sidebar, + position, + sidebar, "short": true }) ]); addControlGroup([ - L.OSM.note({ - position: position, - sidebar: sidebar - }) + L.OSM.note({ position, sidebar }) ]); addControlGroup([ - L.OSM.query({ - position: position, - sidebar: sidebar - }) + L.OSM.query({ position, sidebar }) ]); L.control.scale() @@ -288,9 +278,6 @@ $(function () { if (params.has("query")) { $("#sidebar .search_form input[name=query]").value(params.get("query")); } - if (!("autofocus" in document.createElement("input"))) { - $("#sidebar .search_form input[name=query]").focus(); - } return map.getState(); }; diff --git a/app/assets/javascripts/index/contextmenu.js b/app/assets/javascripts/index/contextmenu.js index 4c157e6e0..dcdfc9e44 100644 --- a/app/assets/javascripts/index/contextmenu.js +++ b/app/assets/javascripts/index/contextmenu.js @@ -35,9 +35,10 @@ OSM.initializeContextMenu = function (map) { map.contextmenu.addItem({ text: OSM.i18n.t("javascripts.context.show_address"), callback: function describeLocation(e) { - const [lat, lon] = OSM.cropLocation(e.latlng, map.getZoom()); + const zoom = map.getZoom(); + const [lat, lon] = OSM.cropLocation(e.latlng, zoom); - OSM.router.route("/search?" + new URLSearchParams({ lat, lon })); + OSM.router.route("/search?" + new URLSearchParams({ lat, lon, zoom })); } }); diff --git a/app/assets/javascripts/index/directions-endpoint.js b/app/assets/javascripts/index/directions-endpoint.js index a4b3a928b..97b841f14 100644 --- a/app/assets/javascripts/index/directions-endpoint.js +++ b/app/assets/javascripts/index/directions-endpoint.js @@ -1,15 +1,8 @@ -OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, changeCallback) { +OSM.DirectionsEndpoint = function Endpoint(map, input, marker, dragCallback, changeCallback) { const endpoint = {}; endpoint.marker = L.marker([0, 0], { - icon: L.icon({ - iconUrl: iconUrl, - iconSize: [25, 41], - iconAnchor: [12, 41], - popupAnchor: [1, -34], - shadowUrl: OSM.MARKER_SHADOW, - shadowSize: [41, 41] - }), + icon: OSM.getMarker(marker), draggable: true, autoPan: true }); diff --git a/app/assets/javascripts/index/directions-route-output.js b/app/assets/javascripts/index/directions-route-output.js new file mode 100644 index 000000000..84bcc87a8 --- /dev/null +++ b/app/assets/javascripts/index/directions-route-output.js @@ -0,0 +1,142 @@ +OSM.DirectionsRouteOutput = function (map) { + const popup = L.popup({ autoPanPadding: [100, 100] }); + + const polyline = L.polyline([], { + color: "#03f", + opacity: 0.3, + weight: 10 + }); + + const highlight = L.polyline([], { + color: "#ff0", + opacity: 0.5, + weight: 12 + }); + + let downloadURL = null; + + function formatTotalDistance(m) { + if (m < 1000) { + return OSM.i18n.t("javascripts.directions.distance_m", { distance: Math.round(m) }); + } else if (m < 10000) { + return OSM.i18n.t("javascripts.directions.distance_km", { distance: (m / 1000.0).toFixed(1) }); + } else { + return OSM.i18n.t("javascripts.directions.distance_km", { distance: Math.round(m / 1000) }); + } + } + + function formatStepDistance(m) { + if (m < 5) { + return ""; + } else if (m < 200) { + return OSM.i18n.t("javascripts.directions.distance_m", { distance: String(Math.round(m / 10) * 10) }); + } else if (m < 1500) { + return OSM.i18n.t("javascripts.directions.distance_m", { distance: String(Math.round(m / 100) * 100) }); + } else if (m < 5000) { + return OSM.i18n.t("javascripts.directions.distance_km", { distance: String(Math.round(m / 100) / 10) }); + } else { + return OSM.i18n.t("javascripts.directions.distance_km", { distance: String(Math.round(m / 1000)) }); + } + } + + function formatHeight(m) { + return OSM.i18n.t("javascripts.directions.distance_m", { distance: Math.round(m) }); + } + + function formatTime(s) { + let m = Math.round(s / 60); + const h = Math.floor(m / 60); + m -= h * 60; + return h + ":" + (m < 10 ? "0" : "") + m; + } + + const routeOutput = {}; + + routeOutput.write = function (content, route) { + polyline + .setLatLngs(route.line) + .addTo(map); + + const distanceText = $("

").append( + OSM.i18n.t("javascripts.directions.distance") + ": " + formatTotalDistance(route.distance) + ". " + + OSM.i18n.t("javascripts.directions.time") + ": " + formatTime(route.time) + "."); + if (typeof route.ascend !== "undefined" && typeof route.descend !== "undefined") { + distanceText.append( + $("
"), + OSM.i18n.t("javascripts.directions.ascend") + ": " + formatHeight(route.ascend) + ". " + + OSM.i18n.t("javascripts.directions.descend") + ": " + formatHeight(route.descend) + "."); + } + + const turnByTurnTable = $("") + .append($("")); + + content + .empty() + .append( + distanceText, + turnByTurnTable + ); + + for (const [i, [direction, instruction, dist, lineseg]] of route.steps.entries()) { + const row = $("").appendTo(turnByTurnTable); + + if (direction) { + row.append(""); + } else { + row.append(" +${text} +`; } - if (token = this.tokenizer.blockquote(src)) { - src = src.substring(token.raw.length); - tokens.push(token); - continue; + tablecell(token) { + const content = this.parser.parseInline(token.tokens); + const type2 = token.header ? "th" : "td"; + const tag2 = token.align ? `<${type2} align="${token.align}">` : `<${type2}>`; + return tag2 + content + ` +`; } - if (token = this.tokenizer.list(src)) { - src = src.substring(token.raw.length); - tokens.push(token); - continue; + /** + * span level renderer + */ + strong({ tokens }) { + return `${this.parser.parseInline(tokens)}`; } - if (token = this.tokenizer.html(src)) { - src = src.substring(token.raw.length); - tokens.push(token); - continue; + em({ tokens }) { + return `${this.parser.parseInline(tokens)}`; } - if (token = this.tokenizer.def(src)) { - src = src.substring(token.raw.length); - const lastToken = tokens.at(-1); - if ((lastToken == null ? void 0 : lastToken.type) === "paragraph" || (lastToken == null ? void 0 : lastToken.type) === "text") { - lastToken.raw += "\n" + token.raw; - lastToken.text += "\n" + token.raw; - this.inlineQueue.at(-1).src = lastToken.text; - } else if (!this.tokens.links[token.tag]) { - this.tokens.links[token.tag] = { - href: token.href, - title: token.title - }; - } - continue; + codespan({ text }) { + return `${escape4(text, true)}`; } - if (token = this.tokenizer.table(src)) { - src = src.substring(token.raw.length); - tokens.push(token); - continue; + br(token) { + return "
"; } - if (token = this.tokenizer.lheading(src)) { - src = src.substring(token.raw.length); - tokens.push(token); - continue; + del({ tokens }) { + return `${this.parser.parseInline(tokens)}`; } - let cutSrc = src; - if ((_c2 = this.options.extensions) == null ? void 0 : _c2.startBlock) { - let startIndex = Infinity; - const tempSrc = src.slice(1); - let tempStart; - this.options.extensions.startBlock.forEach((getStartIndex) => { - tempStart = getStartIndex.call({ lexer: this }, tempSrc); - if (typeof tempStart === "number" && tempStart >= 0) { - startIndex = Math.min(startIndex, tempStart); - } - }); - if (startIndex < Infinity && startIndex >= 0) { - cutSrc = src.substring(0, startIndex + 1); + link({ href, title, tokens }) { + const text = this.parser.parseInline(tokens); + const cleanHref = cleanUrl(href); + if (cleanHref === null) { + return text; } - } - if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) { - const lastToken = tokens.at(-1); - if (lastParagraphClipped && (lastToken == null ? void 0 : lastToken.type) === "paragraph") { - lastToken.raw += "\n" + token.raw; - lastToken.text += "\n" + token.text; - this.inlineQueue.pop(); - this.inlineQueue.at(-1).src = lastToken.text; - } else { - tokens.push(token); + href = cleanHref; + let out = '"; + return out; } - if (token = this.tokenizer.text(src)) { - src = src.substring(token.raw.length); - const lastToken = tokens.at(-1); - if ((lastToken == null ? void 0 : lastToken.type) === "text") { - lastToken.raw += "\n" + token.raw; - lastToken.text += "\n" + token.text; - this.inlineQueue.pop(); - this.inlineQueue.at(-1).src = lastToken.text; - } else { - tokens.push(token); + image({ href, title, text }) { + const cleanHref = cleanUrl(href); + if (cleanHref === null) { + return escape4(text); } - continue; - } - if (src) { - const errMsg = "Infinite loop on byte: " + src.charCodeAt(0); - if (this.options.silent) { - console.error(errMsg); - break; - } else { - throw new Error(errMsg); + href = cleanHref; + let out = `${text} 0) { - while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) { - if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) { - maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex); - } - } + text(token) { + return "tokens" in token && token.tokens ? this.parser.parseInline(token.tokens) : "escaped" in token && token.escaped ? token.text : escape4(token.text); } - } - while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) { - maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex); - } - while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) { - maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex); - } - let keepPrevChar = false; - let prevChar = ""; - while (src) { - if (!keepPrevChar) { - prevChar = ""; + }; + _TextRenderer = class { + // no need for block level renderers + strong({ text }) { + return text; } - keepPrevChar = false; - let token; - if ((_b3 = (_a4 = this.options.extensions) == null ? void 0 : _a4.inline) == null ? void 0 : _b3.some((extTokenizer) => { - if (token = extTokenizer.call({ lexer: this }, src, tokens)) { - src = src.substring(token.raw.length); - tokens.push(token); - return true; - } - return false; - })) { - continue; + em({ text }) { + return text; } - if (token = this.tokenizer.escape(src)) { - src = src.substring(token.raw.length); - tokens.push(token); - continue; + codespan({ text }) { + return text; } - if (token = this.tokenizer.tag(src)) { - src = src.substring(token.raw.length); - tokens.push(token); - continue; + del({ text }) { + return text; } - if (token = this.tokenizer.link(src)) { - src = src.substring(token.raw.length); - tokens.push(token); - continue; + html({ text }) { + return text; } - if (token = this.tokenizer.reflink(src, this.tokens.links)) { - src = src.substring(token.raw.length); - const lastToken = tokens.at(-1); - if (token.type === "text" && (lastToken == null ? void 0 : lastToken.type) === "text") { - lastToken.raw += token.raw; - lastToken.text += token.text; - } else { - tokens.push(token); - } - continue; + text({ text }) { + return text; } - if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) { - src = src.substring(token.raw.length); - tokens.push(token); - continue; + link({ text }) { + return "" + text; } - if (token = this.tokenizer.codespan(src)) { - src = src.substring(token.raw.length); - tokens.push(token); - continue; + image({ text }) { + return "" + text; } - if (token = this.tokenizer.br(src)) { - src = src.substring(token.raw.length); - tokens.push(token); - continue; + br() { + return ""; } - if (token = this.tokenizer.del(src)) { - src = src.substring(token.raw.length); - tokens.push(token); - continue; + }; + _Parser = class __Parser { + constructor(options2) { + __publicField(this, "options"); + __publicField(this, "renderer"); + __publicField(this, "textRenderer"); + this.options = options2 || _defaults; + this.options.renderer = this.options.renderer || new _Renderer(); + this.renderer = this.options.renderer; + this.renderer.options = this.options; + this.renderer.parser = this; + this.textRenderer = new _TextRenderer(); } - if (token = this.tokenizer.autolink(src)) { - src = src.substring(token.raw.length); - tokens.push(token); - continue; + /** + * Static Parse Method + */ + static parse(tokens, options2) { + const parser3 = new __Parser(options2); + return parser3.parse(tokens); } - if (!this.state.inLink && (token = this.tokenizer.url(src))) { - src = src.substring(token.raw.length); - tokens.push(token); - continue; + /** + * Static Parse Inline Method + */ + static parseInline(tokens, options2) { + const parser3 = new __Parser(options2); + return parser3.parseInline(tokens); } - let cutSrc = src; - if ((_c2 = this.options.extensions) == null ? void 0 : _c2.startInline) { - let startIndex = Infinity; - const tempSrc = src.slice(1); - let tempStart; - this.options.extensions.startInline.forEach((getStartIndex) => { - tempStart = getStartIndex.call({ lexer: this }, tempSrc); - if (typeof tempStart === "number" && tempStart >= 0) { - startIndex = Math.min(startIndex, tempStart); + /** + * Parse Loop + */ + parse(tokens, top = true) { + var _a3, _b2; + let out = ""; + for (let i3 = 0; i3 < tokens.length; i3++) { + const anyToken = tokens[i3]; + if ((_b2 = (_a3 = this.options.extensions) == null ? void 0 : _a3.renderers) == null ? void 0 : _b2[anyToken.type]) { + const genericToken = anyToken; + 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; + } + } + const token = anyToken; + switch (token.type) { + case "space": { + out += this.renderer.space(token); + continue; + } + case "hr": { + out += this.renderer.hr(token); + continue; + } + case "heading": { + out += this.renderer.heading(token); + continue; + } + case "code": { + out += this.renderer.code(token); + continue; + } + case "table": { + out += this.renderer.table(token); + continue; + } + case "blockquote": { + out += this.renderer.blockquote(token); + continue; + } + case "list": { + out += this.renderer.list(token); + continue; + } + case "html": { + out += this.renderer.html(token); + continue; + } + case "paragraph": { + out += this.renderer.paragraph(token); + continue; + } + case "text": { + let textToken = token; + let body = this.renderer.text(textToken); + while (i3 + 1 < tokens.length && tokens[i3 + 1].type === "text") { + textToken = tokens[++i3]; + body += "\n" + this.renderer.text(textToken); + } + if (top) { + out += this.renderer.paragraph({ + type: "paragraph", + raw: body, + text: body, + tokens: [{ type: "text", raw: body, text: body, escaped: true }] + }); + } else { + out += body; + } + continue; + } + default: { + const errMsg = 'Token with "' + token.type + '" type was not found.'; + if (this.options.silent) { + console.error(errMsg); + return ""; + } else { + throw new Error(errMsg); + } + } } - }); - if (startIndex < Infinity && startIndex >= 0) { - cutSrc = src.substring(0, startIndex + 1); } + return out; } - if (token = this.tokenizer.inlineText(cutSrc)) { - src = src.substring(token.raw.length); - if (token.raw.slice(-1) !== "_") { - prevChar = token.raw.slice(-1); - } - keepPrevChar = true; - const lastToken = tokens.at(-1); - if ((lastToken == null ? void 0 : lastToken.type) === "text") { - lastToken.raw += token.raw; - lastToken.text += token.text; - } else { - tokens.push(token); + /** + * Parse Inline Tokens + */ + parseInline(tokens, renderer = this.renderer) { + var _a3, _b2; + let out = ""; + for (let i3 = 0; i3 < tokens.length; i3++) { + const anyToken = tokens[i3]; + if ((_b2 = (_a3 = this.options.extensions) == null ? void 0 : _a3.renderers) == null ? void 0 : _b2[anyToken.type]) { + const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken); + if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(anyToken.type)) { + out += ret || ""; + continue; + } + } + const token = anyToken; + switch (token.type) { + case "escape": { + out += renderer.text(token); + break; + } + case "html": { + out += renderer.html(token); + break; + } + case "link": { + out += renderer.link(token); + break; + } + case "image": { + out += renderer.image(token); + break; + } + case "strong": { + out += renderer.strong(token); + break; + } + case "em": { + out += renderer.em(token); + break; + } + case "codespan": { + out += renderer.codespan(token); + break; + } + case "br": { + out += renderer.br(token); + break; + } + case "del": { + out += renderer.del(token); + break; + } + case "text": { + out += renderer.text(token); + break; + } + default: { + const errMsg = 'Token with "' + token.type + '" type was not found.'; + if (this.options.silent) { + console.error(errMsg); + return ""; + } else { + throw new Error(errMsg); + } + } + } } - continue; + return out; } - if (src) { - const errMsg = "Infinite loop on byte: " + src.charCodeAt(0); - if (this.options.silent) { - console.error(errMsg); - break; - } else { - throw new Error(errMsg); - } + }; + _Hooks = class { + constructor(options2) { + __publicField(this, "options"); + __publicField(this, "block"); + this.options = options2 || _defaults; } - } - return tokens; - } - }; - var _Renderer = class { - // set by the parser - constructor(options2) { - __publicField(this, "options"); - __publicField(this, "parser"); - this.options = options2 || _defaults; - } - space(token) { - return ""; - } - code({ text, lang, escaped }) { - var _a4; - const langString = (_a4 = (lang || "").match(other.notSpaceStart)) == null ? void 0 : _a4[0]; - const code = text.replace(other.endingNewline, "") + "\n"; - if (!langString) { - return "
" + (escaped ? code : escape4(code, true)) + "
\n"; - } - return '
' + (escaped ? code : escape4(code, true)) + "
\n"; - } - blockquote({ tokens }) { - const body = this.parser.parse(tokens); - return "
\n".concat(body, "
\n"); - } - html({ text }) { - return text; - } - heading({ tokens, depth }) { - return "").concat(this.parser.parseInline(tokens), "\n"); - } - hr(token) { - return "
\n"; - } - list(token) { - const ordered = token.ordered; - const start2 = token.start; - let body = ""; - for (let j2 = 0; j2 < token.items.length; j2++) { - const item = token.items[j2]; - body += this.listitem(item); - } - const type2 = ordered ? "ol" : "ul"; - const startAttr = ordered && start2 !== 1 ? ' start="' + start2 + '"' : ""; - return "<" + type2 + startAttr + ">\n" + body + "\n"; - } - listitem(item) { - var _a4; - let itemBody = ""; - if (item.task) { - const checkbox = this.checkbox({ checked: !!item.checked }); - if (item.loose) { - if (((_a4 = item.tokens[0]) == null ? void 0 : _a4.type) === "paragraph") { - item.tokens[0].text = checkbox + " " + item.tokens[0].text; - if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") { - item.tokens[0].tokens[0].text = checkbox + " " + escape4(item.tokens[0].tokens[0].text); - item.tokens[0].tokens[0].escaped = true; - } - } else { - item.tokens.unshift({ - type: "text", - raw: checkbox + " ", - text: checkbox + " ", - escaped: true - }); - } - } else { - itemBody += checkbox + " "; + /** + * Process markdown before marked + */ + preprocess(markdown) { + return markdown; } - } - itemBody += this.parser.parse(item.tokens, !!item.loose); - return "
  • ".concat(itemBody, "
  • \n"); - } - checkbox({ checked }) { - return "'; - } - paragraph({ tokens }) { - return "

    ".concat(this.parser.parseInline(tokens), "

    \n"); - } - table(token) { - let header = ""; - let cell = ""; - for (let j2 = 0; j2 < token.header.length; j2++) { - cell += this.tablecell(token.header[j2]); - } - header += this.tablerow({ text: cell }); - let body = ""; - for (let j2 = 0; j2 < token.rows.length; j2++) { - const row = token.rows[j2]; - cell = ""; - for (let k2 = 0; k2 < row.length; k2++) { - cell += this.tablecell(row[k2]); + /** + * Process HTML after marked is finished + */ + postprocess(html3) { + return html3; } - body += this.tablerow({ text: cell }); - } - if (body) - body = "
    ".concat(body, ""); - return "
    "); + } + row.append(`${i + 1}. ${instruction}`); + row.append("" + formatStepDistance(dist)); + + row.on("click", function () { + popup + .setLatLng(lineseg[0]) + .setContent(`

    ${i + 1}. ${instruction}

    `) + .openOn(map); + }); + + row + .on("mouseenter", function () { + highlight + .setLatLngs(lineseg) + .addTo(map); + }) + .on("mouseleave", function () { + map.removeLayer(highlight); + }); + } + + const blob = new Blob([JSON.stringify(polyline.toGeoJSON())], { type: "application/json" }); + URL.revokeObjectURL(downloadURL); + downloadURL = URL.createObjectURL(blob); + + content.append(`

    ${ + OSM.i18n.t("javascripts.directions.download") + }

    `); + + content.append("

    " + + OSM.i18n.t("javascripts.directions.instructions.courtesy", { + link: `${route.credit}` + }) + + "

    "); + }; + + routeOutput.fit = function () { + map.fitBounds(polyline.getBounds().pad(0.05)); + }; + + routeOutput.isVisible = function () { + return map.hasLayer(polyline); + }; + + routeOutput.remove = function (content) { + content.empty(); + map + .removeLayer(popup) + .removeLayer(polyline); + }; + + return routeOutput; +}; diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index 057933453..c5d5cce15 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -1,4 +1,5 @@ //= require ./directions-endpoint +//= require ./directions-route-output //= require_self //= require_tree ./directions @@ -7,22 +8,10 @@ OSM.Directions = function (map) { let lastLocation = []; let chosenEngine; - const popup = L.popup({ autoPanPadding: [100, 100] }); - - const polyline = L.polyline([], { - color: "#03f", - opacity: 0.3, - weight: 10 - }); - - const highlight = L.polyline([], { - color: "#ff0", - opacity: 0.5, - weight: 12 - }); + const routeOutput = OSM.DirectionsRouteOutput(map); const endpointDragCallback = function (dragging) { - if (!map.hasLayer(polyline)) return; + if (!routeOutput.isVisible()) return; if (dragging && !chosenEngine.draggable) return; if (dragging && controller) return; @@ -33,12 +22,10 @@ OSM.Directions = function (map) { }; const endpoints = [ - OSM.DirectionsEndpoint(map, $("input[name='route_from']"), OSM.MARKER_GREEN, endpointDragCallback, endpointChangeCallback), - OSM.DirectionsEndpoint(map, $("input[name='route_to']"), OSM.MARKER_RED, endpointDragCallback, endpointChangeCallback) + OSM.DirectionsEndpoint(map, $("input[name='route_from']"), { icon: "MARKER_GREEN" }, endpointDragCallback, endpointChangeCallback), + OSM.DirectionsEndpoint(map, $("input[name='route_to']"), { icon: "MARKER_RED" }, endpointDragCallback, endpointChangeCallback) ]; - let downloadURL = null; - const expiry = new Date(); expiry.setYear(expiry.getFullYear() + 10); @@ -70,41 +57,6 @@ OSM.Directions = function (map) { OSM.router.route("/" + OSM.formatHash(map)); }); - function formatTotalDistance(m) { - if (m < 1000) { - return OSM.i18n.t("javascripts.directions.distance_m", { distance: Math.round(m) }); - } else if (m < 10000) { - return OSM.i18n.t("javascripts.directions.distance_km", { distance: (m / 1000.0).toFixed(1) }); - } else { - return OSM.i18n.t("javascripts.directions.distance_km", { distance: Math.round(m / 1000) }); - } - } - - function formatStepDistance(m) { - if (m < 5) { - return ""; - } else if (m < 200) { - return OSM.i18n.t("javascripts.directions.distance_m", { distance: String(Math.round(m / 10) * 10) }); - } else if (m < 1500) { - return OSM.i18n.t("javascripts.directions.distance_m", { distance: String(Math.round(m / 100) * 100) }); - } else if (m < 5000) { - return OSM.i18n.t("javascripts.directions.distance_km", { distance: String(Math.round(m / 100) / 10) }); - } else { - return OSM.i18n.t("javascripts.directions.distance_km", { distance: String(Math.round(m / 1000)) }); - } - } - - function formatHeight(m) { - return OSM.i18n.t("javascripts.directions.distance_m", { distance: Math.round(m) }); - } - - function formatTime(s) { - let m = Math.round(s / 60); - const h = Math.floor(m / 60); - m -= h * 60; - return h + ":" + (m < 10 ? "0" : "") + m; - } - function setEngine(id) { const engines = OSM.Directions.engines; const desired = engines.find(engine => engine.id === id); @@ -155,80 +107,12 @@ OSM.Directions = function (map) { map.setSidebarOverlaid(false); controller = new AbortController(); chosenEngine.getRoute(points, controller.signal).then(function (route) { - polyline - .setLatLngs(route.line) - .addTo(map); - + routeOutput.write($("#directions_content"), route); if (fitRoute) { - map.fitBounds(polyline.getBounds().pad(0.05)); - } - - const distanceText = $("

    ").append( - OSM.i18n.t("javascripts.directions.distance") + ": " + formatTotalDistance(route.distance) + ". " + - OSM.i18n.t("javascripts.directions.time") + ": " + formatTime(route.time) + "."); - if (typeof route.ascend !== "undefined" && typeof route.descend !== "undefined") { - distanceText.append( - $("
    "), - OSM.i18n.t("javascripts.directions.ascend") + ": " + formatHeight(route.ascend) + ". " + - OSM.i18n.t("javascripts.directions.descend") + ": " + formatHeight(route.descend) + "."); + routeOutput.fit(); } - - const turnByTurnTable = $("") - .append($("")); - - $("#directions_content") - .empty() - .append( - distanceText, - turnByTurnTable - ); - - // Add each row - route.steps.forEach(function (step) { - const [ll, direction, instruction, dist, lineseg] = step; - - const row = $(""); - if (direction) { - row.append(""); - } else { - row.append("${body}`; + return "
    "); - } - row.append("" + instruction); - row.append("" + formatStepDistance(dist)); - - row.on("click", function () { - popup - .setLatLng(ll) - .setContent("

    " + instruction + "

    ") - .openOn(map); - }); - - row.hover(function () { - highlight - .setLatLngs(lineseg) - .addTo(map); - }, function () { - map.removeLayer(highlight); - }); - - turnByTurnTable.append(row); - }); - - const blob = new Blob([JSON.stringify(polyline.toGeoJSON())], { type: "application/json" }); - URL.revokeObjectURL(downloadURL); - downloadURL = URL.createObjectURL(blob); - - $("#directions_content").append(`

    ${ - OSM.i18n.t("javascripts.directions.download") - }

    `); - - $("#directions_content").append("

    " + - OSM.i18n.t("javascripts.directions.instructions.courtesy", { link: chosenEngine.creditline }) + - "

    "); }).catch(function () { - map.removeLayer(polyline); + routeOutput.remove($("#directions_content")); if (reportErrors) { $("#directions_content").html("
    " + OSM.i18n.t("javascripts.directions.errors.no_route") + "
    "); } @@ -237,11 +121,9 @@ OSM.Directions = function (map) { }); } - function hideRoute(e) { + function closeButtonListener(e) { e.stopPropagation(); - map.removeLayer(polyline); - $("#directions_content").html(""); - popup.close(); + routeOutput.remove($("#directions_content")); map.setSidebarOverlaid(true); // TODO: collapse width of sidebar back to previous } @@ -303,7 +185,7 @@ OSM.Directions = function (map) { } function enableListeners() { - $("#sidebar .sidebar-close-controls button").on("click", hideRoute); + $("#sidebar .sidebar-close-controls button").on("click", closeButtonListener); $("#map").on("dragend dragover", function (e) { e.preventDefault(); @@ -359,7 +241,7 @@ OSM.Directions = function (map) { $(".search_form").show(); $(".directions_form").hide(); - $("#sidebar .sidebar-close-controls button").off("click", hideRoute); + $("#sidebar .sidebar-close-controls button").off("click", closeButtonListener); $("#map").off("dragend dragover drop"); map.off("locationfound", sendstartinglocation); @@ -369,9 +251,7 @@ OSM.Directions = function (map) { endpoints[0].clearValue(); endpoints[1].clearValue(); - map - .removeLayer(popup) - .removeLayer(polyline); + routeOutput.remove($("#directions_content")); }; return page; diff --git a/app/assets/javascripts/index/directions/fossgis_osrm.js b/app/assets/javascripts/index/directions/fossgis_osrm.js index b2586e68e..53043e06d 100644 --- a/app/assets/javascripts/index/directions/fossgis_osrm.js +++ b/app/assets/javascripts/index/directions/fossgis_osrm.js @@ -5,7 +5,7 @@ function FOSSGISOSRMEngine(modeId, vehicleType) { let cachedHints = []; - function _processDirections(route) { + function getInstructionText(step) { const INSTRUCTION_TEMPLATE = { "continue": "continue", "merge right": "merge_right", @@ -33,36 +33,54 @@ "depart": "start", "arrive": "destination" }; - const ICON_MAP = { - "continue": "straight", - "merge right": "merge-right", - "merge left": "merge-left", - "off ramp right": "exit-right", - "off ramp left": "exit-left", - "on ramp right": "right", - "on ramp left": "left", - "fork right": "fork-right", - "fork left": "fork-left", - "end of road right": "end-of-road-right", - "end of road left": "end-of-road-left", - "turn straight": "straight", - "turn slight right": "slight-right", - "turn right": "right", - "turn sharp right": "sharp-right", - "turn uturn": "u-turn-left", - "turn slight left": "slight-left", - "turn left": "left", - "turn sharp left": "sharp-left", - "roundabout": "roundabout", - "rotary": "roundabout", - "exit roundabout": "roundabout", - "exit rotary": "roundabout", - "depart": "start", - "arrive": "destination" - }; function numToWord(num) { return ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth"][num - 1]; } + + const instrPrefix = "javascripts.directions.instructions."; + let template = instrPrefix + INSTRUCTION_TEMPLATE[step.maneuverId]; + + const destinations = "" + step.destinations + ""; + let namedRoad = true; + let name; + + if (step.name && step.ref) { + name = "" + step.name + " (" + step.ref + ")"; + } else if (step.name) { + name = "" + step.name + ""; + } else if (step.ref) { + name = "" + step.ref + ""; + } else { + name = OSM.i18n.t(instrPrefix + "unnamed"); + namedRoad = false; + } + + if (step.maneuver.type.match(/^exit (rotary|roundabout)$/)) { + return OSM.i18n.t(template, { name: name }); + } + if (step.maneuver.type.match(/^(rotary|roundabout)$/)) { + if (!step.maneuver.exit) { + return OSM.i18n.t(template + "_without_exit", { name: name }); + } + if (step.maneuver.exit > 10) { + return OSM.i18n.t(template + "_with_exit", { exit: step.maneuver.exit, name: name }); + } + return OSM.i18n.t(template + "_with_exit_ordinal", { exit: OSM.i18n.t(instrPrefix + "exit_counts." + numToWord(step.maneuver.exit)), name: name }); + } + if (!step.maneuver.type.match(/^(on ramp|off ramp)$/)) { + return OSM.i18n.t(template + "_without_exit", { name: name }); + } + const params = {}; + if (step.exits && step.maneuver.type.match(/^(off ramp)$/)) params.exit = step.exits; + if (step.destinations) params.directions = destinations; + if (namedRoad) params.directions = name; + if (Object.keys(params).length > 0) { + template = template + "_with_" + Object.keys(params).join("_"); + } + return OSM.i18n.t(template, params); + } + + function _processDirections(leg) { function getManeuverId(maneuver) { // special case handling switch (maneuver.type) { @@ -87,72 +105,56 @@ return "turn " + maneuver.modifier; } } + const ICON_MAP = { + "continue": "straight", + "merge right": "merge-right", + "merge left": "merge-left", + "off ramp right": "exit-right", + "off ramp left": "exit-left", + "on ramp right": "right", + "on ramp left": "left", + "fork right": "fork-right", + "fork left": "fork-left", + "end of road right": "end-of-road-right", + "end of road left": "end-of-road-left", + "turn straight": "straight", + "turn slight right": "slight-right", + "turn right": "right", + "turn sharp right": "sharp-right", + "turn uturn": "u-turn-left", + "turn slight left": "slight-left", + "turn left": "left", + "turn sharp left": "sharp-left", + "roundabout": "roundabout", + "rotary": "roundabout", + "exit roundabout": "roundabout", + "exit rotary": "roundabout", + "depart": "start", + "arrive": "destination" + }; + + for (const step of leg.steps) step.maneuverId = getManeuverId(step.maneuver); - const steps = route.legs.flatMap( - leg => leg.steps.map(function (step, idx) { - const maneuver_id = getManeuverId(step.maneuver); - - const instrPrefix = "javascripts.directions.instructions."; - let template = instrPrefix + INSTRUCTION_TEMPLATE[maneuver_id]; - - const step_geometry = L.PolylineUtil.decode(step.geometry, { precision: 5 }).map(L.latLng); - - let instText = "" + (idx + 1) + ". "; - const destinations = "" + step.destinations + ""; - let namedRoad = true; - let name; - - if (step.name && step.ref) { - name = "" + step.name + " (" + step.ref + ")"; - } else if (step.name) { - name = "" + step.name + ""; - } else if (step.ref) { - name = "" + step.ref + ""; - } else { - name = OSM.i18n.t(instrPrefix + "unnamed"); - namedRoad = false; - } - - if (step.maneuver.type.match(/^exit (rotary|roundabout)$/)) { - instText += OSM.i18n.t(template, { name: name }); - } else if (step.maneuver.type.match(/^(rotary|roundabout)$/)) { - if (step.maneuver.exit) { - if (step.maneuver.exit <= 10) { - instText += OSM.i18n.t(template + "_with_exit_ordinal", { exit: OSM.i18n.t(instrPrefix + "exit_counts." + numToWord(step.maneuver.exit)), name: name }); - } else { - instText += OSM.i18n.t(template + "_with_exit", { exit: step.maneuver.exit, name: name }); - } - } else { - instText += OSM.i18n.t(template + "_without_exit", { name: name }); - } - } else if (step.maneuver.type.match(/^(on ramp|off ramp)$/)) { - const params = {}; - if (step.exits && step.maneuver.type.match(/^(off ramp)$/)) params.exit = step.exits; - if (step.destinations) params.directions = destinations; - if (namedRoad) params.directions = name; - if (Object.keys(params).length > 0) { - template = template + "_with_" + Object.keys(params).join("_"); - } - instText += OSM.i18n.t(template, params); - } else { - instText += OSM.i18n.t(template + "_without_exit", { name: name }); - } - return [[step.maneuver.location[1], step.maneuver.location[0]], ICON_MAP[maneuver_id], instText, step.distance, step_geometry]; - }) - ); + const steps = leg.steps.map(step => [ + ICON_MAP[step.maneuverId], + getInstructionText(step), + step.distance, + L.PolylineUtil.decode(step.geometry, { precision: 5 }) + ]); return { - line: steps.flatMap(step => step[4]), + line: steps.flatMap(step => step[3]), steps, - distance: route.distance, - time: route.duration + distance: leg.distance, + time: leg.duration, + credit: "OSRM (FOSSGIS)", + creditlink: "https://routing.openstreetmap.de/about.html" }; } return { mode: modeId, provider: "fossgis_osrm", - creditline: "OSRM (FOSSGIS)", draggable: true, getRoute: function (points, signal) { @@ -176,7 +178,7 @@ .then(response => { if (response.code !== "Ok") throw new Error(); cachedHints = response.waypoints.map(wp => wp.hint); - return _processDirections(response.routes[0]); + return _processDirections(response.routes[0].legs[0]); }); } }; diff --git a/app/assets/javascripts/index/directions/fossgis_valhalla.js b/app/assets/javascripts/index/directions/fossgis_valhalla.js index d5e781e4a..7354e5d65 100644 --- a/app/assets/javascripts/index/directions/fossgis_valhalla.js +++ b/app/assets/javascripts/index/directions/fossgis_valhalla.js @@ -42,50 +42,29 @@ "merge-left" // kMergeLeft = 38; ]; - function _processDirections(tripLegs) { - let line = []; - let steps = []; - let distance = 0; - let time = 0; + function _processDirections(leg) { + const line = L.PolylineUtil.decode(leg.shape, { precision: 6 }); - for (const leg of tripLegs) { - const legLine = L.PolylineUtil.decode(leg.shape, { - precision: 6 - }); - - const legSteps = leg.maneuvers.map(function (manoeuvre, idx) { - const num = `${idx + 1}. `; - const lineseg = legLine - .slice(manoeuvre.begin_shape_index, manoeuvre.end_shape_index + 1) - .map(([lat, lng]) => ({ lat, lng })); - return [ - lineseg[0], - INSTR_MAP[manoeuvre.type], - num + manoeuvre.instruction, - manoeuvre.length * 1000, - lineseg - ]; - }); - - line = line.concat(legLine); - steps = steps.concat(legSteps); - distance += leg.summary.length; - time += leg.summary.time; - } + const steps = leg.maneuvers.map(manoeuvre => [ + INSTR_MAP[manoeuvre.type], + manoeuvre.instruction, + manoeuvre.length * 1000, + line.slice(manoeuvre.begin_shape_index, manoeuvre.end_shape_index + 1) + ]); return { - line: line, - steps: steps, - distance: distance * 1000, - time: time + line, + steps, + distance: leg.summary.length * 1000, + time: leg.summary.time, + credit: "Valhalla (FOSSGIS)", + creditlink: "https://gis-ops.com/global-open-valhalla-server-online/" }; } return { mode: modeId, provider: "fossgis_valhalla", - creditline: - "Valhalla (FOSSGIS)", draggable: false, getRoute: function (points, signal) { @@ -105,7 +84,7 @@ .then(response => response.json()) .then(({ trip }) => { if (trip.status !== 0) throw new Error(); - return _processDirections(trip.legs); + return _processDirections(trip.legs[0]); }); } }; diff --git a/app/assets/javascripts/index/directions/graphhopper.js b/app/assets/javascripts/index/directions/graphhopper.js index b11c49472..dd79a4671 100644 --- a/app/assets/javascripts/index/directions/graphhopper.js +++ b/app/assets/javascripts/index/directions/graphhopper.js @@ -21,35 +21,29 @@ function _processDirections(path) { const line = L.PolylineUtil.decode(path.points); - const steps = path.instructions.map(function (instr, i) { - const num = `${i + 1}. `; - const lineseg = line - .slice(instr.interval[0], instr.interval[1] + 1) - .map(([lat, lng]) => ({ lat, lng })); - return [ - lineseg[0], - GH_INSTR_MAP[instr.sign], - num + instr.text, - instr.distance, - lineseg - ]; // TODO does graphhopper map instructions onto line indices? - }); - steps.at(-1)[1] = "destination"; + const steps = path.instructions.map(instr => [ + GH_INSTR_MAP[instr.sign], + instr.text, + instr.distance, + line.slice(instr.interval[0], instr.interval[1] + 1) + ]); + steps.at(-1)[0] = "destination"; return { - line: line, - steps: steps, + line, + steps, distance: path.distance, time: path.time / 1000, ascend: path.ascend, - descend: path.descend + descend: path.descend, + credit: "GraphHopper", + creditlink: "https://www.graphhopper.com/" }; } return { mode: modeId, provider: "graphhopper", - creditline: "GraphHopper", draggable: false, getRoute: function (points, signal) { diff --git a/app/assets/javascripts/index/history-changesets-layer.js b/app/assets/javascripts/index/history-changesets-layer.js new file mode 100644 index 000000000..37a458737 --- /dev/null +++ b/app/assets/javascripts/index/history-changesets-layer.js @@ -0,0 +1,76 @@ +OSM.HistoryChangesetsLayer = L.FeatureGroup.extend({ + _changesets: [], + + updateChangesets: function (map, changesets) { + this._changesets = changesets; + this.updateChangesetShapes(map); + }, + + updateChangesetShapes: function (map) { + this.clearLayers(); + + for (const changeset of this._changesets) { + const bottomLeft = map.project(L.latLng(changeset.bbox.minlat, changeset.bbox.minlon)), + topRight = map.project(L.latLng(changeset.bbox.maxlat, changeset.bbox.maxlon)), + width = topRight.x - bottomLeft.x, + height = bottomLeft.y - topRight.y, + minSize = 20; // Min width/height of changeset in pixels + + if (width < minSize) { + bottomLeft.x -= ((minSize - width) / 2); + topRight.x += ((minSize - width) / 2); + } + + if (height < minSize) { + bottomLeft.y += ((minSize - height) / 2); + topRight.y -= ((minSize - height) / 2); + } + + changeset.bounds = L.latLngBounds(map.unproject(bottomLeft), + map.unproject(topRight)); + } + + this._changesets.sort(function (a, b) { + return b.bounds.getSize() - a.bounds.getSize(); + }); + + this.updateChangesetLocations(map); + + for (const changeset of this._changesets) { + const rect = L.rectangle(changeset.bounds, + { weight: 2, color: "#FF9500", opacity: 1, fillColor: "#FFFFAF", fillOpacity: 0 }); + rect.id = changeset.id; + rect.addTo(this); + } + }, + + updateChangesetLocations: function (map) { + const mapCenterLng = map.getCenter().lng; + + for (const changeset of this._changesets) { + const changesetSouthWest = changeset.bounds.getSouthWest(); + const changesetNorthEast = changeset.bounds.getNorthEast(); + const changesetCenterLng = (changesetSouthWest.lng + changesetNorthEast.lng) / 2; + const shiftInWorldCircumferences = Math.round((changesetCenterLng - mapCenterLng) / 360); + + if (shiftInWorldCircumferences) { + changesetSouthWest.lng -= shiftInWorldCircumferences * 360; + changesetNorthEast.lng -= shiftInWorldCircumferences * 360; + + this.getLayer(changeset.id)?.setBounds(changeset.bounds); + } + } + }, + + highlightChangeset: function (id) { + this.getLayer(id)?.setStyle({ fillOpacity: 0.3, color: "#FF6600", weight: 3 }); + }, + + unHighlightChangeset: function (id) { + this.getLayer(id)?.setStyle({ fillOpacity: 0, color: "#FF9500", weight: 2 }); + }, + + getLayerId: function (layer) { + return layer.id; + } +}); diff --git a/app/assets/javascripts/index/history.js b/app/assets/javascripts/index/history.js index 9f883367a..289081ca1 100644 --- a/app/assets/javascripts/index/history.js +++ b/app/assets/javascripts/index/history.js @@ -1,4 +1,5 @@ //= require jquery-simulate/jquery.simulate +//= require ./history-changesets-layer OSM.History = function (map) { const page = {}; @@ -12,7 +13,7 @@ OSM.History = function (map) { unHighlightChangeset($(this).data("changeset").id); }); - const group = L.featureGroup() + const changesetsLayer = new OSM.HistoryChangesetsLayer() .on("mouseover", function (e) { highlightChangeset(e.layer.id); }) @@ -23,10 +24,6 @@ OSM.History = function (map) { clickChangeset(e.layer.id, e.originalEvent); }); - group.getLayerId = function (layer) { - return layer.id; - }; - let changesetIntersectionObserver; function disableChangesetIntersectionObserver() { @@ -87,14 +84,12 @@ OSM.History = function (map) { } function highlightChangeset(id) { - const layer = group.getLayer(id); - if (layer) layer.setStyle({ fillOpacity: 0.3, color: "#FF6600", weight: 3 }); + changesetsLayer.highlightChangeset(id); $("#changeset_" + id).addClass("selected"); } function unHighlightChangeset(id) { - const layer = group.getLayer(id); - if (layer) layer.setStyle({ fillOpacity: 0, color: "#FF9500", weight: 2 }); + changesetsLayer.unHighlightChangeset(id); $("#changeset_" + id).removeClass("selected"); } @@ -104,6 +99,10 @@ OSM.History = function (map) { function displayFirstChangesets(html) { $("#sidebar_content .changesets").html(html); + + if (location.pathname === "/history") { + setPaginationMapHashes(); + } } function displayMoreChangesets(div, html) { @@ -130,29 +129,34 @@ OSM.History = function (map) { nextNewList.children().appendTo(oldList); nextNewList.remove(); } + + if (location.pathname === "/history") { + setPaginationMapHashes(); + } + } + + function setPaginationMapHashes() { + $("#sidebar .pagination a").each(function () { + $(this).prop("hash", OSM.formatHash({ + center: map.getCenter(), + zoom: map.getZoom() + })); + }); } function loadFirstChangesets() { const data = new URLSearchParams(); - const params = new URLSearchParams(location.search); disableChangesetIntersectionObserver(); if (location.pathname === "/history") { - data.set("bbox", map.getBounds().wrap().toBBoxString()); + setBboxFetchData(data); const feedLink = $("link[type=\"application/atom+xml\"]"), feedHref = feedLink.attr("href").split("?")[0]; feedLink.attr("href", feedHref + "?" + data); } - data.set("list", "1"); - - if (params.has("before")) { - data.set("before", params.get("before")); - } - if (params.has("after")) { - data.set("after", params.get("after")); - } + setListFetchData(data, location); fetch(location.pathname + "?" + data) .then(response => response.text()) @@ -160,13 +164,15 @@ OSM.History = function (map) { displayFirstChangesets(html); enableChangesetIntersectionObserver(); - if (params.has("before")) { + if (data.has("before")) { const [firstItem] = $("#sidebar_content .changesets ol").children().first(); firstItem?.scrollIntoView(); - } - if (params.has("after")) { + } else if (data.has("after")) { const [lastItem] = $("#sidebar_content .changesets ol").children().last(); lastItem?.scrollIntoView(false); + } else { + const [sidebar] = $("#sidebar"); + sidebar.scrollTop = 0; } updateMap(); @@ -179,70 +185,77 @@ OSM.History = function (map) { const div = $(this).parents(".changeset_more"); - $(this).hide(); - div.find(".loader").show(); - - $.get($(this).attr("href"), function (html) { - displayMoreChangesets(div, html); - enableChangesetIntersectionObserver(); - updateMap(); - }); - } + div.find(".pagination").addClass("invisible"); + div.find("[hidden]").prop("hidden", false); - function reloadChangesetsBecauseOfMapMovement() { - OSM.router.replace("/history" + window.location.hash); - loadFirstChangesets(); - } + const data = new URLSearchParams(); - let changesets = []; + if (location.pathname === "/history") { + setBboxFetchData(data); + } - function updateBounds() { - group.clearLayers(); + const url = new URL($(this).attr("href"), location); + setListFetchData(data, url); - for (const changeset of changesets) { - const bottomLeft = map.project(L.latLng(changeset.bbox.minlat, changeset.bbox.minlon)), - topRight = map.project(L.latLng(changeset.bbox.maxlat, changeset.bbox.maxlon)), - width = topRight.x - bottomLeft.x, - height = bottomLeft.y - topRight.y, - minSize = 20; // Min width/height of changeset in pixels + fetch(url.pathname + "?" + data) + .then(response => response.text()) + .then(function (html) { + displayMoreChangesets(div, html); + enableChangesetIntersectionObserver(); - if (width < minSize) { - bottomLeft.x -= ((minSize - width) / 2); - topRight.x += ((minSize - width) / 2); - } + updateMap(); + }); + } - if (height < minSize) { - bottomLeft.y += ((minSize - height) / 2); - topRight.y -= ((minSize - height) / 2); - } + function setBboxFetchData(data) { + const crs = map.options.crs; + const sw = map.getBounds().getSouthWest(); + const ne = map.getBounds().getNorthEast(); + const swClamped = crs.unproject(crs.project(sw)); + const neClamped = crs.unproject(crs.project(ne)); - changeset.bounds = L.latLngBounds(map.unproject(bottomLeft), - map.unproject(topRight)); + if (sw.lat >= swClamped.lat || ne.lat <= neClamped.lat || ne.lng - sw.lng < 360) { + data.set("bbox", map.getBounds().toBBoxString()); } + } - changesets.sort(function (a, b) { - return b.bounds.getSize() - a.bounds.getSize(); - }); + function setListFetchData(data, url) { + const params = new URLSearchParams(url.search); + + data.set("list", "1"); + + if (params.has("before")) { + data.set("before", params.get("before")); + } + if (params.has("after")) { + data.set("after", params.get("after")); + } + } - for (const changeset of changesets) { - const rect = L.rectangle(changeset.bounds, - { weight: 2, color: "#FF9500", opacity: 1, fillColor: "#FFFFAF", fillOpacity: 0 }); - rect.id = changeset.id; - rect.addTo(group); + function moveEndListener() { + if (location.pathname === "/history") { + OSM.router.replace("/history" + window.location.hash); + loadFirstChangesets(); + } else { + changesetsLayer.updateChangesetLocations(map); } } + function zoomEndListener() { + changesetsLayer.updateChangesetShapes(map); + } + function updateMap() { - changesets = $("[data-changeset]").map(function (index, element) { + const changesets = $("[data-changeset]").map(function (index, element) { return $(element).data("changeset"); }).get().filter(function (changeset) { return changeset.bbox; }); - updateBounds(); + changesetsLayer.updateChangesets(map, changesets); if (location.pathname !== "/history") { - const bounds = group.getBounds(); + const bounds = changesetsLayer.getBounds(); if (bounds.isValid()) map.fitBounds(bounds); } } @@ -252,21 +265,16 @@ OSM.History = function (map) { }; page.load = function () { - map.addLayer(group); - - if (location.pathname === "/history") { - map.on("moveend", reloadChangesetsBecauseOfMapMovement); - } - - map.on("zoomend", updateBounds); - + map.addLayer(changesetsLayer); + map.on("moveend", moveEndListener); + map.on("zoomend", zoomEndListener); loadFirstChangesets(); }; page.unload = function () { - map.removeLayer(group); - map.off("moveend", reloadChangesetsBecauseOfMapMovement); - map.off("zoomend", updateBounds); + map.removeLayer(changesetsLayer); + map.off("moveend", moveEndListener); + map.off("zoomend", zoomEndListener); disableChangesetIntersectionObserver(); }; diff --git a/app/assets/javascripts/index/home.js b/app/assets/javascripts/index/home.js index 597b68eff..1cc644cf2 100644 --- a/app/assets/javascripts/index/home.js +++ b/app/assets/javascripts/index/home.js @@ -17,7 +17,7 @@ OSM.Home = function (map) { map.setView(OSM.home, 15, { reset: true }); }); marker = L.marker(OSM.home, { - icon: OSM.getUserIcon(), + icon: OSM.getMarker({}), title: OSM.i18n.t("javascripts.home.marker_title") }).addTo(map); } else { diff --git a/app/assets/javascripts/index/layers/data.js b/app/assets/javascripts/index/layers/data.js index 6452c2a41..6c8bdc025 100644 --- a/app/assets/javascripts/index/layers/data.js +++ b/app/assets/javascripts/index/layers/data.js @@ -2,21 +2,6 @@ OSM.initializeDataLayer = function (map) { let dataLoader, loadedBounds; const dataLayer = map.dataLayer; - dataLayer.setStyle({ - way: { - weight: 3, - color: "#000000", - opacity: 0.4 - }, - area: { - weight: 3, - color: "#ff0000" - }, - node: { - color: "#00ff00" - } - }); - dataLayer.isWayArea = function () { return false; }; @@ -132,6 +117,8 @@ OSM.initializeDataLayer = function (map) { if (map._objectLayer) { map._objectLayer.bringToFront(); } + + dataLoader = null; }) .catch(function (error) { if (error.name === "AbortError") return; @@ -139,9 +126,10 @@ OSM.initializeDataLayer = function (map) { displayLoadError(error?.message, () => { $("#browse_status").empty(); }); + + dataLoader = null; }) .finally(() => { - dataLoader = null; spanLoading.remove(); }); } diff --git a/app/assets/javascripts/index/layers/notes.js b/app/assets/javascripts/index/layers/notes.js index 104f6f2f2..00f1fb4e9 100644 --- a/app/assets/javascripts/index/layers/notes.js +++ b/app/assets/javascripts/index/layers/notes.js @@ -3,24 +3,6 @@ OSM.initializeNotesLayer = function (map) { const noteLayer = map.noteLayer; let notes = {}; - const noteIcons = { - "new": L.icon({ - iconUrl: OSM.NEW_NOTE_MARKER, - iconSize: [25, 40], - iconAnchor: [12, 40] - }), - "open": L.icon({ - iconUrl: OSM.OPEN_NOTE_MARKER, - iconSize: [25, 40], - iconAnchor: [12, 40] - }), - "closed": L.icon({ - iconUrl: OSM.CLOSED_NOTE_MARKER, - iconSize: [25, 40], - iconAnchor: [12, 40] - }) - }; - noteLayer.on("add", () => { loadNotes(); map.on("moveend", loadNotes); @@ -41,7 +23,7 @@ OSM.initializeNotesLayer = function (map) { function updateMarker(old_marker, feature) { let marker = old_marker; if (marker) { - marker.setIcon(noteIcons[feature.properties.status]); + marker.setIcon(OSM.getMarker({ icon: `${feature.properties.status}_NOTE_MARKER`, shadow: false, height: 40 })); } else { let title; const description = feature.properties.comments[0]; @@ -51,7 +33,7 @@ OSM.initializeNotesLayer = function (map) { } marker = L.marker(feature.geometry.coordinates.reverse(), { - icon: noteIcons[feature.properties.status], + icon: OSM.getMarker({ icon: `${feature.properties.status}_NOTE_MARKER`, shadow: false, height: 40 }), title, opacity: 0.8, interactive: true diff --git a/app/assets/javascripts/index/new_note.js b/app/assets/javascripts/index/new_note.js index b1457d10b..ff4a44126 100644 --- a/app/assets/javascripts/index/new_note.js +++ b/app/assets/javascripts/index/new_note.js @@ -6,24 +6,6 @@ OSM.NewNote = function (map) { let newNoteMarker, halo; - const noteIcons = { - "new": L.icon({ - iconUrl: OSM.NEW_NOTE_MARKER, - iconSize: [25, 40], - iconAnchor: [12, 40] - }), - "open": L.icon({ - iconUrl: OSM.OPEN_NOTE_MARKER, - iconSize: [25, 40], - iconAnchor: [12, 40] - }), - "closed": L.icon({ - iconUrl: OSM.CLOSED_NOTE_MARKER, - iconSize: [25, 40], - iconAnchor: [12, 40] - }) - }; - addNoteButton.on("click", function (e) { e.preventDefault(); e.stopPropagation(); @@ -49,7 +31,7 @@ OSM.NewNote = function (map) { function addCreatedNoteMarker(feature) { const marker = L.marker(feature.geometry.coordinates.reverse(), { - icon: noteIcons[feature.properties.status], + icon: OSM.getMarker({ icon: `${feature.properties.status}_NOTE_MARKER`, shadow: false, height: 40 }), opacity: 0.9, interactive: true }); @@ -79,7 +61,7 @@ OSM.NewNote = function (map) { if (newNoteMarker) map.removeLayer(newNoteMarker); newNoteMarker = L.marker(latlng, { - icon: noteIcons.new, + icon: OSM.getMarker({ icon: "NEW_NOTE_MARKER", shadow: false, height: 40 }), opacity: 0.9, draggable: true }); @@ -95,7 +77,7 @@ OSM.NewNote = function (map) { addHalo(newNoteMarker.getLatLng()); newNoteMarker.on("dragend", function () { - content.find("textarea").focus(); + content.find("textarea").trigger("focus"); }); } @@ -105,10 +87,10 @@ OSM.NewNote = function (map) { newNoteMarker = null; } - function moveNewNotMarkerToClick(e) { + function moveNewNoteMarkerToClick(e) { if (newNoteMarker) newNoteMarker.setLatLng(e.latlng); if (halo) halo.setLatLng(e.latlng); - content.find("textarea").focus(); + content.find("textarea").trigger("focus"); } function updateControls() { @@ -148,7 +130,9 @@ OSM.NewNote = function (map) { content.find("textarea") .on("input", updateControls) - .focus(); + .attr("readonly", "readonly") // avoid virtual keyboard popping up on focus + .trigger("focus") + .removeAttr("readonly"); content.find("input[type=submit]").on("click", function (e) { const location = newNoteMarker.getLatLng().wrap(); @@ -170,7 +154,7 @@ OSM.NewNote = function (map) { }); }); - map.on("click", moveNewNotMarkerToClick); + map.on("click", moveNewNoteMarkerToClick); addNoteButton.on("disabled enabled", updateControls); updateControls(); @@ -178,7 +162,7 @@ OSM.NewNote = function (map) { }; page.unload = function () { - map.off("click", moveNewNotMarkerToClick); + map.off("click", moveNewNoteMarkerToClick); addNoteButton.off("disabled enabled", updateControls); removeNewNoteMarker(); addNoteButton.removeClass("active"); diff --git a/app/assets/javascripts/index/note.js b/app/assets/javascripts/index/note.js index f0b7dae27..a77735c95 100644 --- a/app/assets/javascripts/index/note.js +++ b/app/assets/javascripts/index/note.js @@ -2,24 +2,6 @@ OSM.Note = function (map) { const content = $("#sidebar_content"), page = {}; - const noteIcons = { - "new": L.icon({ - iconUrl: OSM.NEW_NOTE_MARKER, - iconSize: [25, 40], - iconAnchor: [12, 40] - }), - "open": L.icon({ - iconUrl: OSM.OPEN_NOTE_MARKER, - iconSize: [25, 40], - iconAnchor: [12, 40] - }), - "closed": L.icon({ - iconUrl: OSM.CLOSED_NOTE_MARKER, - iconSize: [25, 40], - iconAnchor: [12, 40] - }) - }; - page.pushstate = page.popstate = function (path, id) { OSM.loadSidebarContent(path, function () { const data = $(".details").data(); @@ -87,7 +69,7 @@ OSM.Note = function (map) { type: "note", id: parseInt(id, 10), latLng: L.latLng(data.coordinates.split(",")), - icon: noteIcons[data.status] + icon: OSM.getMarker({ icon: `${data.status}_NOTE_MARKER`, shadow: false, height: 40 }) }, function () { if (!hashParams.center && !skipMoveToNote) { const latLng = L.latLng(data.coordinates.split(",")); diff --git a/app/assets/javascripts/index/search.js b/app/assets/javascripts/index/search.js index b3ef3ceb3..84f0d3ab4 100644 --- a/app/assets/javascripts/index/search.js +++ b/app/assets/javascripts/index/search.js @@ -18,18 +18,25 @@ OSM.Search = function (map) { $(".search_form").on("submit", function (e) { e.preventDefault(); $("header").addClass("closed"); - const query = $(this).find("input[name=query]").val(); - let search = "/"; - if (query) search = "/search?" + new URLSearchParams({ query }); + const params = new URLSearchParams({ + query: this.elements.query.value, + zoom: map.getZoom(), + minlon: map.getBounds().getWest(), + minlat: map.getBounds().getSouth(), + maxlon: map.getBounds().getEast(), + maxlat: map.getBounds().getNorth() + }); + const search = params.get("query") ? `/search?${params}` : "/"; OSM.router.route(search + OSM.formatHash(map)); }); $(".describe_location").on("click", function (e) { e.preventDefault(); $("header").addClass("closed"); - const [lat, lon] = OSM.cropLocation(map.getCenter(), map.getZoom()); + const zoom = map.getZoom(); + const [lat, lon] = OSM.cropLocation(map.getCenter(), zoom); - OSM.router.route("/search?" + new URLSearchParams({ lat, lon })); + OSM.router.route("/search?" + new URLSearchParams({ lat, lon, zoom })); }); $("#sidebar_content") @@ -63,7 +70,7 @@ OSM.Search = function (map) { if (!marker) { const data = $(this).find("a.set_position").data(); - marker = L.marker([data.lat, data.lon], { icon: OSM.getUserIcon() }); + marker = L.marker([data.lat, data.lon], { icon: OSM.getMarker({}) }); $(this).data("marker", marker); } @@ -118,14 +125,7 @@ OSM.Search = function (map) { const entry = $(this); fetch(entry.data("href"), { method: "POST", - body: new URLSearchParams({ - zoom: map.getZoom(), - minlon: map.getBounds().getWest(), - minlat: map.getBounds().getSouth(), - maxlon: map.getBounds().getEast(), - maxlat: map.getBounds().getNorth(), - ...OSM.csrf - }) + body: new URLSearchParams(OSM.csrf) }) .then(response => response.text()) .then(function (html) { diff --git a/app/assets/javascripts/leaflet.locate.js b/app/assets/javascripts/leaflet.locate.js index d270d6499..8fc182f38 100644 --- a/app/assets/javascripts/leaflet.locate.js +++ b/app/assets/javascripts/leaflet.locate.js @@ -1,3 +1,5 @@ +//= require leaflet.locatecontrol/dist/L.Control.Locate.umd + L.OSM.locate = function (options) { const control = L.control.locate({ icon: "icon geolocate", diff --git a/app/assets/javascripts/leaflet.map.js b/app/assets/javascripts/leaflet.map.js index ac31f7941..2488a9db5 100644 --- a/app/assets/javascripts/leaflet.map.js +++ b/app/assets/javascripts/leaflet.map.js @@ -13,37 +13,27 @@ L.OSM.Map = L.Map.extend({ initialize: function (id, options) { L.Map.prototype.initialize.call(this, id, options); - this.baseLayers = []; - - for (const layerDefinition of OSM.LAYER_DEFINITIONS) { - let layerConstructor = L.OSM.TileLayer; - const layerOptions = {}; - - for (const [property, value] of Object.entries(layerDefinition)) { - if (property === "credit") { - layerOptions.attribution = makeAttribution(value); - } else if (property === "nameId") { - layerOptions.name = OSM.i18n.t(`javascripts.map.base.${value}`); - } else if (property === "leafletOsmId") { - layerConstructor = L.OSM[value]; - } else if (property === "leafletOsmDarkId" && OSM.isDarkMap() && L.OSM[value]) { - layerConstructor = L.OSM[value]; - } else { - layerOptions[property] = value; - } - } + this.baseLayers = OSM.LAYER_DEFINITIONS.map(( + { credit, nameId, leafletOsmId, leafletOsmDarkId, ...layerOptions } + ) => { + if (credit) layerOptions.attribution = makeAttribution(credit); + if (nameId) layerOptions.name = OSM.i18n.t(`javascripts.map.base.${nameId}`); + const layerConstructor = + (OSM.isDarkMap() && L.OSM[leafletOsmDarkId]) || + L.OSM[leafletOsmId] || + L.OSM.TileLayer; const layer = new layerConstructor(layerOptions); layer.on("add", () => { this.fire("baselayerchange", { layer: layer }); }); - this.baseLayers.push(layer); - } + return layer; + }); this.noteLayer = new L.FeatureGroup(); this.noteLayer.options = { code: "N" }; - this.dataLayer = new L.OSM.DataLayer(null, { asynchronous: true }); + this.dataLayer = new L.OSM.DataLayer(null); this.dataLayer.options.code = "D"; this.gpsLayer = new L.OSM.GPS({ @@ -391,13 +381,17 @@ OSM.isDarkMap = function () { return window.matchMedia("(prefers-color-scheme: dark)").matches; }; -OSM.getUserIcon = function (url) { - return L.icon({ - iconUrl: url || OSM.MARKER_RED, - iconSize: [25, 41], - iconAnchor: [12, 41], - popupAnchor: [1, -34], - shadowUrl: OSM.MARKER_SHADOW, - shadowSize: [41, 41] - }); +OSM.getMarker = function ({ icon = "MARKER_RED", shadow = true, height = 41 }) { + const options = { + iconUrl: OSM[icon.toUpperCase()] || OSM.MARKER_RED, + iconSize: [25, height], + iconAnchor: [12, height], + popupAnchor: [1, -34] + }; + if (shadow) { + options.shadowUrl = OSM.MARKER_SHADOW; + options.shadowSize = [41, 41]; + options.shadowAnchor = [12, 41]; + } + return L.icon(options); }; diff --git a/app/assets/javascripts/osm.js.erb b/app/assets/javascripts/osm.js.erb index 4f0bd8f77..d73d1c163 100644 --- a/app/assets/javascripts/osm.js.erb +++ b/app/assets/javascripts/osm.js.erb @@ -30,6 +30,7 @@ OSM = { LAYER_DEFINITIONS: <%= MapLayers::full_definitions("config/layers.yml").to_json %>, LAYERS_WITH_MAP_KEY: <%= YAML.load_file(Rails.root.join("config/key.yml")).keys.to_json %>, + MARKER_BLUE: <%= image_path("marker-blue.png").to_json %>, MARKER_GREEN: <%= image_path("marker-green.png").to_json %>, MARKER_RED: <%= image_path("marker-red.png").to_json %>, @@ -157,11 +158,11 @@ OSM = { layers = args.getLayersCode(); } else if (args instanceof URLSearchParams) { center = args.get("center") || L.latLng(args.get("lat"), args.get("lon")); - zoom = args.get("zoom"); + zoom = Number(args.get("zoom")); layers = args.get("layers") || ""; } else { center = args.center || L.latLng(args.lat, args.lon); - zoom = args.zoom; + zoom = Number(args.zoom); layers = args.layers || ""; } diff --git a/app/assets/javascripts/user.js b/app/assets/javascripts/user.js index 77a71097b..5f8a931e3 100644 --- a/app/assets/javascripts/user.js +++ b/app/assets/javascripts/user.js @@ -1,4 +1,4 @@ -//= require leaflet.locatecontrol/dist/L.Control.Locate.umd +//= require leaflet.locate (function () { $(document).on("change", "#user_all", function () { @@ -18,30 +18,9 @@ $(function () { const position = $("html").attr("dir") === "rtl" ? "topleft" : "topright"; - L.OSM.zoom({ position: position }) - .addTo(map); - - const locate = L.control.locate({ - position: position, - icon: "icon geolocate", - iconLoading: "icon geolocate", - strings: { - title: OSM.i18n.t("javascripts.map.locate.title"), - popup: function (options) { - return OSM.i18n.t("javascripts.map.locate." + options.unit + "Popup", { count: options.distance }); - } - } - }).addTo(map); - - const locateContainer = locate.getContainer(); + L.OSM.zoom({ position }).addTo(map); - $(locateContainer) - .removeClass("leaflet-control-locate leaflet-bar") - .addClass("control-locate") - .children("a") - .attr("href", "#") - .removeClass("leaflet-bar-part leaflet-bar-part-single") - .addClass("control-button"); + L.OSM.locate({ position }).addTo(map); if (OSM.home) { map.setView([OSM.home.lat, OSM.home.lon], defaultHomeZoom); @@ -51,7 +30,7 @@ $(function () { if ($("#map").hasClass("set_location")) { marker = L.marker([0, 0], { - icon: OSM.getUserIcon(), + icon: OSM.getMarker({}), keyboard: false, interactive: false }); @@ -124,7 +103,7 @@ $(function () { $("[data-user]").each(function () { const user = $(this).data("user"); if (user.lon && user.lat) { - L.marker([user.lat, user.lon], { icon: OSM.getUserIcon(user.icon) }).addTo(map) + L.marker([user.lat, user.lon], { icon: OSM.getMarker({ icon: user.icon }) }).addTo(map) .bindPopup(user.description, { minWidth: 200 }); } }); diff --git a/app/assets/javascripts/welcome.js b/app/assets/javascripts/welcome.js index 5ce6afdcc..dc269a310 100644 --- a/app/assets/javascripts/welcome.js +++ b/app/assets/javascripts/welcome.js @@ -15,10 +15,6 @@ $(function () { $(".start-mapping").addClass("loading"); if (navigator.geolocation) { - // handle firefox's weird implementation - // https://bugzilla.mozilla.org/show_bug.cgi?id=675533 - window.setTimeout(manualEdit, 4000); - navigator.geolocation.getCurrentPosition(geoSuccess, manualEdit); } else { manualEdit(); diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 27d58f84e..9fff025d0 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -620,11 +620,6 @@ tr.turn { z-index: 2; /* needs to be higher than Bootstrap's stretched link ::after z-index */ } } - - .changeset_more .loader { - display: none; - width: 100%; - } } /* Rules for the browse sidebar */ @@ -679,12 +674,6 @@ tr.turn { > * { margin: -1px; } - #minlon { - /*rtl:ignore*/ float: left; - } - #maxlon { - /*rtl:ignore*/ float: right; - } } } diff --git a/app/controllers/changesets_controller.rb b/app/controllers/changesets_controller.rb index 5e79f4da6..07e7a365f 100644 --- a/app/controllers/changesets_controller.rb +++ b/app/controllers/changesets_controller.rb @@ -54,7 +54,10 @@ class ChangesetsController < ApplicationController changesets.where("false") end elsif @params[:bbox] - changesets = conditions_bbox(changesets, BoundingBox.from_bbox_params(params)) + bbox_array = @params[:bbox].split(",").map(&:to_f) + raise OSM::APIBadUserInput, "The parameter bbox must be of the form min_lon,min_lat,max_lon,max_lat" unless bbox_array.count == 4 + + changesets = conditions_bbox(changesets, *bbox_array) elsif @params[:friends] && current_user changesets = changesets.where(:user => current_user.followings.identifiable) elsif @params[:nearby] && current_user @@ -113,21 +116,37 @@ class ChangesetsController < ApplicationController #------------------------------------------------------------ ## - # if a bounding box was specified do some sanity checks. # restrict changesets to those enclosed by a bounding box - def conditions_bbox(changesets, bbox) - if bbox - bbox.check_boundaries - bbox = bbox.to_scaled - - changesets.where("min_lon < ? and max_lon > ? and min_lat < ? and max_lat > ?", - bbox.max_lon.to_i, bbox.min_lon.to_i, - bbox.max_lat.to_i, bbox.min_lat.to_i) - else + def conditions_bbox(changesets, min_lon, min_lat, max_lon, max_lat) + db_min_lat = (min_lat * GeoRecord::SCALE).to_i + db_max_lat = (max_lat * GeoRecord::SCALE).to_i + db_min_lon = (wrap_lon(min_lon) * GeoRecord::SCALE).to_i + db_max_lon = (wrap_lon(max_lon) * GeoRecord::SCALE).to_i + + changesets = changesets.where("min_lat < ? and max_lat > ?", db_max_lat, db_min_lat) + + if max_lon - min_lon >= 360 + # the query bbox spans the entire world, therefore no lon checks are necessary changesets + elsif db_min_lon <= db_max_lon + # the normal case when the query bbox doesn't include the antimeridian + changesets.where("min_lon < ? and max_lon > ?", db_max_lon, db_min_lon) + else + # the query bbox includes the antimeridian + # this case works as if there are two query bboxes: + # [-180*SCALE .. db_max_lon], [db_min_lon .. 180*SCALE] + # it would be necessary to check if changeset bboxes intersect with either of the query bboxes: + # (changesets.min_lon < db_max_lon and changesets.max_lon > -180*SCALE) or (changesets.min_lon < 180*SCALE and changesets.max_lon > db_min_lon) + # but the comparisons with -180*SCALE and 180*SCALE are unnecessary: + # (changesets.min_lon < db_max_lon) or (changesets.max_lon > db_min_lon) + changesets.where("min_lon < ? or max_lon > ?", db_max_lon, db_min_lon) end end + def wrap_lon(lon) + ((lon + 180) % 360) - 180 + end + ## # eliminate empty changesets (where the bbox has not been set) # this should be applied to all changeset list displays diff --git a/app/controllers/geocoder_controller.rb b/app/controllers/geocoder_controller.rb index f23448bff..81c179a67 100644 --- a/app/controllers/geocoder_controller.rb +++ b/app/controllers/geocoder_controller.rb @@ -6,17 +6,22 @@ class GeocoderController < ApplicationController before_action :authorize_web before_action :set_locale before_action :require_oauth, :only => [:search] + authorize_resource :class => false + before_action :normalize_params, :only => [:search] + def search - @params = normalize_params @sources = [] - if @params[:lat] && @params[:lon] - @sources.push(:name => "latlon", :url => root_path) - @sources.push(:name => "osm_nominatim_reverse", :url => nominatim_reverse_url(:format => "html")) - elsif @params[:query] - @sources.push(:name => "osm_nominatim", :url => nominatim_url(:format => "html")) + if params[:lat] && params[:lon] + @sources.push(:name => "latlon", :url => root_path, + :fetch_url => url_for(params.permit(:lat, :lon, :latlon_digits, :zoom).merge(:action => "search_latlon"))) + @sources.push(:name => "osm_nominatim_reverse", :url => nominatim_reverse_url(:format => "html"), + :fetch_url => url_for(params.permit(:lat, :lon, :zoom).merge(:action => "search_osm_nominatim_reverse"))) + elsif params[:query] + @sources.push(:name => "osm_nominatim", :url => nominatim_url(:format => "html"), + :fetch_url => url_for(params.permit(:query, :minlat, :minlon, :maxlat, :maxlon).merge(:action => "search_osm_nominatim"))) end if @sources.empty? @@ -221,8 +226,6 @@ class GeocoderController < ApplicationController params[:latlon_digits] = true end end - - params.permit(:query, :lat, :lon, :latlon_digits, :zoom, :minlat, :minlon, :maxlat, :maxlon) end def dms_regexp(name_prefix) diff --git a/app/models/issue.rb b/app/models/issue.rb index 970426715..d628f7ae8 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -37,7 +37,7 @@ class Issue < ApplicationRecord belongs_to :user_updated, :class_name => "User", :foreign_key => :updated_by, :optional => true has_many :reports, -> { order(:id) }, :dependent => :destroy - has_many :comments, :class_name => "IssueComment", :dependent => :destroy + has_many :comments, -> { order(:id) }, :class_name => "IssueComment", :dependent => :destroy validates :reportable_id, :uniqueness => { :scope => [:reportable_type] } diff --git a/app/views/changesets/index.html.erb b/app/views/changesets/index.html.erb index 3f25cf134..cd59d14c8 100644 --- a/app/views/changesets/index.html.erb +++ b/app/views/changesets/index.html.erb @@ -1,11 +1,15 @@ <% if @newer_changesets_id %> -
    - <%= link_to t(".load_more"), url_for(@params.merge(:before => nil, :after => @newer_changesets_id)), :class => "btn btn-primary" %> -
    +
    + +
      +
    • + <%= link_to t(".newer_changesets"), url_for(:after => @newer_changesets_id), :class => "page-link" %> +
    • +
    <% end %> <% if @changesets.present? %> @@ -20,12 +24,16 @@

    <%= params[:before] ? t(".no_more") : t(".empty") %>

    <% end %> <% if @older_changesets_id -%> -
    - <%= link_to t(".load_more"), url_for(@params.merge(:before => @older_changesets_id, :after => nil)), :class => "btn btn-primary" %> -
    +
    + +
      +
    • + <%= link_to t(".older_changesets"), url_for(:before => @older_changesets_id), :class => "page-link" %> +
    • +
    <% end -%> diff --git a/app/views/dashboards/_contact.html.erb b/app/views/dashboards/_contact.html.erb index 0dda0b354..cea6c2b29 100644 --- a/app/views/dashboards/_contact.html.erb +++ b/app/views/dashboards/_contact.html.erb @@ -1,10 +1,10 @@ <% user_data = { :lon => contact.home_lon, :lat => contact.home_lat, - :icon => image_path(type == "following" ? "marker-blue.png" : "marker-green.png"), + :icon => type == "following" ? "MARKER_BLUE" : "MARKER_GREEN", :description => render(:partial => "popup", :object => contact, :locals => { :type => type }) } %> -<%= tag.div :class => "clearfix row", :data => { :user => user_data } do %> +<%= tag.div :class => "row", :data => { :user => user_data } do %>
    <%= user_thumbnail contact %>
    @@ -32,7 +32,7 @@

    \n\n" + header + "\n" + body + "
    \n"; } - if (token = this.tokenizer.hr(src)) { - src = src.substring(token.raw.length); - tokens.push(token); - continue; + tablerow({ text }) { + return `

    \n\n" + header + "\n" + body + "
    \n"; - } - tablerow({ text }) { - return "\n".concat(text, "\n"); - } - tablecell(token) { - const content = this.parser.parseInline(token.tokens); - const type2 = token.header ? "th" : "td"; - const tag2 = token.align ? "<".concat(type2, ' align="').concat(token.align, '">') : "<".concat(type2, ">"); - return tag2 + content + "\n"); - } - /** - * span level renderer - */ - strong({ tokens }) { - return "".concat(this.parser.parseInline(tokens), ""); - } - em({ tokens }) { - return "".concat(this.parser.parseInline(tokens), ""); - } - codespan({ text }) { - return "".concat(escape4(text, true), ""); - } - br(token) { - return "
    "; - } - del({ tokens }) { - return "".concat(this.parser.parseInline(tokens), ""); - } - link({ href, title, tokens }) { - const text = this.parser.parseInline(tokens); - const cleanHref = cleanUrl(href); - if (cleanHref === null) { - return text; - } - href = cleanHref; - let out = '
    "; - return out; - } - image({ href, title, text }) { - const cleanHref = cleanUrl(href); - if (cleanHref === null) { - return escape4(text); - } - href = cleanHref; - let out = '').concat(text, ' { + const tokens2 = genericToken[childTokens].flat(Infinity); + values = values.concat(this.walkTokens(tokens2, callback)); + }); + } else if (genericToken.tokens) { + values = values.concat(this.walkTokens(genericToken.tokens, callback)); + } } } - break; - } - case "list": { - const listToken = token; - values = values.concat(this.walkTokens(listToken.items, callback)); - break; } - default: { - const genericToken = token; - if ((_b3 = (_a4 = this.defaults.extensions) == null ? void 0 : _a4.childTokens) == null ? void 0 : _b3[genericToken.type]) { - this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => { - const tokens2 = genericToken[childTokens].flat(Infinity); - values = values.concat(this.walkTokens(tokens2, callback)); + return values; + } + use(...args) { + const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} }; + args.forEach((pack) => { + const opts = { ...pack }; + opts.async = this.defaults.async || opts.async || false; + if (pack.extensions) { + pack.extensions.forEach((ext) => { + if (!ext.name) { + throw new Error("extension name required"); + } + if ("renderer" in ext) { + const prevRenderer = extensions.renderers[ext.name]; + if (prevRenderer) { + extensions.renderers[ext.name] = function(...args2) { + let ret = ext.renderer.apply(this, args2); + if (ret === false) { + ret = prevRenderer.apply(this, args2); + } + return ret; + }; + } else { + extensions.renderers[ext.name] = ext.renderer; + } + } + if ("tokenizer" in ext) { + if (!ext.level || ext.level !== "block" && ext.level !== "inline") { + throw new Error("extension level must be 'block' or 'inline'"); + } + const extLevel = extensions[ext.level]; + if (extLevel) { + extLevel.unshift(ext.tokenizer); + } else { + extensions[ext.level] = [ext.tokenizer]; + } + if (ext.start) { + if (ext.level === "block") { + if (extensions.startBlock) { + extensions.startBlock.push(ext.start); + } else { + extensions.startBlock = [ext.start]; + } + } else if (ext.level === "inline") { + if (extensions.startInline) { + extensions.startInline.push(ext.start); + } else { + extensions.startInline = [ext.start]; + } + } + } + } + if ("childTokens" in ext && ext.childTokens) { + extensions.childTokens[ext.name] = ext.childTokens; + } }); - } else if (genericToken.tokens) { - values = values.concat(this.walkTokens(genericToken.tokens, callback)); + opts.extensions = extensions; } - } - } - } - return values; - } - use(...args) { - const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} }; - args.forEach((pack) => { - const opts = __spreadValues({}, pack); - opts.async = this.defaults.async || opts.async || false; - if (pack.extensions) { - pack.extensions.forEach((ext) => { - if (!ext.name) { - throw new Error("extension name required"); - } - if ("renderer" in ext) { - const prevRenderer = extensions.renderers[ext.name]; - if (prevRenderer) { - extensions.renderers[ext.name] = function(...args2) { - let ret = ext.renderer.apply(this, args2); + if (pack.renderer) { + const renderer = this.defaults.renderer || new _Renderer(this.defaults); + for (const prop in pack.renderer) { + if (!(prop in renderer)) { + throw new Error(`renderer '${prop}' does not exist`); + } + if (["options", "parser"].includes(prop)) { + 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(this, args2); + ret = prevRenderer.apply(renderer, args2); } - return ret; + return ret || ""; }; - } else { - extensions.renderers[ext.name] = ext.renderer; } + opts.renderer = renderer; } - if ("tokenizer" in ext) { - if (!ext.level || ext.level !== "block" && ext.level !== "inline") { - throw new Error("extension level must be 'block' or 'inline'"); - } - const extLevel = extensions[ext.level]; - if (extLevel) { - extLevel.unshift(ext.tokenizer); - } else { - extensions[ext.level] = [ext.tokenizer]; - } - if (ext.start) { - if (ext.level === "block") { - if (extensions.startBlock) { - extensions.startBlock.push(ext.start); - } else { - extensions.startBlock = [ext.start]; - } - } else if (ext.level === "inline") { - if (extensions.startInline) { - extensions.startInline.push(ext.start); - } else { - extensions.startInline = [ext.start]; - } + if (pack.tokenizer) { + const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults); + for (const prop in pack.tokenizer) { + if (!(prop in tokenizer)) { + throw new Error(`tokenizer '${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); + } + return ret; + }; } + opts.tokenizer = tokenizer; } - if ("childTokens" in ext && ext.childTokens) { - extensions.childTokens[ext.name] = ext.childTokens; + if (pack.hooks) { + const hooks = this.defaults.hooks || new _Hooks(); + for (const prop in pack.hooks) { + if (!(prop in hooks)) { + throw new Error(`hook '${prop}' does not exist`); + } + if (["options", "block"].includes(prop)) { + continue; + } + const hooksProp = prop; + const hooksFunc = pack.hooks[hooksProp]; + const prevHook = hooks[hooksProp]; + if (_Hooks.passThroughHooks.has(prop)) { + hooks[hooksProp] = (arg) => { + if (this.defaults.async) { + return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => { + return prevHook.call(hooks, ret2); + }); + } + const ret = hooksFunc.call(hooks, arg); + return prevHook.call(hooks, ret); + }; + } else { + hooks[hooksProp] = (...args2) => { + let ret = hooksFunc.apply(hooks, args2); + if (ret === false) { + ret = prevHook.apply(hooks, args2); + } + return ret; + }; + } + } + opts.hooks = hooks; + } + if (pack.walkTokens) { + const walkTokens2 = this.defaults.walkTokens; + const packWalktokens = pack.walkTokens; + opts.walkTokens = function(token) { + let values = []; + values.push(packWalktokens.call(this, token)); + if (walkTokens2) { + values = values.concat(walkTokens2.call(this, token)); + } + return values; + }; } + this.defaults = { ...this.defaults, ...opts }; }); - opts.extensions = extensions; + return this; + } + setOptions(opt) { + this.defaults = { ...this.defaults, ...opt }; + return this; + } + lexer(src, options2) { + return _Lexer.lex(src, options2 != null ? options2 : this.defaults); } - if (pack.renderer) { - const renderer = this.defaults.renderer || new _Renderer(this.defaults); - for (const prop in pack.renderer) { - if (!(prop in renderer)) { - throw new Error("renderer '".concat(prop, "' does not exist")); + parser(tokens, options2) { + return _Parser.parse(tokens, options2 != null ? options2 : this.defaults); + } + parseMarkdown(blockType) { + const parse = (src, options2) => { + const origOpt = { ...options2 }; + const opt = { ...this.defaults, ...origOpt }; + const throwError = this.onError(!!opt.silent, !!opt.async); + if (this.defaults.async === true && origOpt.async === false) { + return throwError(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.")); } - if (["options", "parser"].includes(prop)) { - continue; + if (typeof src === "undefined" || src === null) { + return throwError(new Error("marked(): input parameter is undefined or null")); } - 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); - } - return ret || ""; - }; - } - opts.renderer = renderer; - } - if (pack.tokenizer) { - const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults); - for (const prop in pack.tokenizer) { - if (!(prop in tokenizer)) { - throw new Error("tokenizer '".concat(prop, "' does not exist")); + if (typeof src !== "string") { + return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected")); } - if (["options", "rules", "lexer"].includes(prop)) { - continue; + if (opt.hooks) { + opt.hooks.options = opt; + opt.hooks.block = blockType; } - 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); - } - return ret; - }; - } - opts.tokenizer = tokenizer; - } - if (pack.hooks) { - const hooks = this.defaults.hooks || new _Hooks(); - for (const prop in pack.hooks) { - if (!(prop in hooks)) { - throw new Error("hook '".concat(prop, "' does not exist")); + const lexer2 = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline; + const parser3 = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline; + if (opt.async) { + 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); } - if (["options", "block"].includes(prop)) { - continue; + try { + if (opt.hooks) { + src = opt.hooks.preprocess(src); + } + let tokens = lexer2(src, opt); + if (opt.hooks) { + tokens = opt.hooks.processAllTokens(tokens); + } + if (opt.walkTokens) { + this.walkTokens(tokens, opt.walkTokens); + } + let html3 = parser3(tokens, opt); + if (opt.hooks) { + html3 = opt.hooks.postprocess(html3); + } + return html3; + } catch (e3) { + return throwError(e3); } - const hooksProp = prop; - const hooksFunc = pack.hooks[hooksProp]; - const prevHook = hooks[hooksProp]; - if (_Hooks.passThroughHooks.has(prop)) { - hooks[hooksProp] = (arg) => { - if (this.defaults.async) { - return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => { - return prevHook.call(hooks, ret2); - }); - } - const ret = hooksFunc.call(hooks, arg); - return prevHook.call(hooks, ret); - }; - } else { - hooks[hooksProp] = (...args2) => { - let ret = hooksFunc.apply(hooks, args2); - if (ret === false) { - ret = prevHook.apply(hooks, args2); - } - return ret; - }; + }; + return parse; + } + onError(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) + "
    "; + if (async) { + return Promise.resolve(msg); + } + return msg; } - } - opts.hooks = hooks; - } - if (pack.walkTokens) { - const walkTokens2 = this.defaults.walkTokens; - const packWalktokens = pack.walkTokens; - opts.walkTokens = function(token) { - let values = []; - values.push(packWalktokens.call(this, token)); - if (walkTokens2) { - values = values.concat(walkTokens2.call(this, token)); + if (async) { + return Promise.reject(e3); } - return values; + throw e3; }; } - this.defaults = __spreadValues(__spreadValues({}, this.defaults), opts); - }); - return this; - } - setOptions(opt) { - this.defaults = __spreadValues(__spreadValues({}, 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(blockType) { - const parse = (src, options2) => { - const origOpt = __spreadValues({}, options2); - const opt = __spreadValues(__spreadValues({}, this.defaults), origOpt); - const throwError = this.onError(!!opt.silent, !!opt.async); - if (this.defaults.async === true && origOpt.async === false) { - return throwError(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.")); - } - 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")); - } - if (opt.hooks) { - opt.hooks.options = opt; - opt.hooks.block = blockType; - } - const lexer2 = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline; - const parser3 = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline; - if (opt.async) { - 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); - } - let tokens = lexer2(src, opt); - if (opt.hooks) { - tokens = opt.hooks.processAllTokens(tokens); - } - if (opt.walkTokens) { - this.walkTokens(tokens, opt.walkTokens); - } - let html3 = parser3(tokens, opt); - if (opt.hooks) { - html3 = opt.hooks.postprocess(html3); - } - return html3; - } catch (e3) { - return throwError(e3); - } }; - return parse; - } - onError(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) + "
    "; - if (async) { - return Promise.resolve(msg); - } - return msg; - } - if (async) { - return Promise.reject(e3); - } - throw e3; + markedInstance = new Marked(); + marked.options = marked.setOptions = function(options2) { + markedInstance.setOptions(options2); + marked.defaults = markedInstance.defaults; + changeDefaults(marked.defaults); + return marked; + }; + marked.getDefaults = _getDefaults; + marked.defaults = _defaults; + marked.use = function(...args) { + markedInstance.use(...args); + marked.defaults = markedInstance.defaults; + changeDefaults(marked.defaults); + return marked; + }; + marked.walkTokens = function(tokens, callback) { + return markedInstance.walkTokens(tokens, callback); }; + marked.parseInline = markedInstance.parseInline; + marked.Parser = _Parser; + marked.parser = _Parser.parse; + marked.Renderer = _Renderer; + marked.TextRenderer = _TextRenderer; + marked.Lexer = _Lexer; + marked.lexer = _Lexer.lex; + marked.Tokenizer = _Tokenizer; + marked.Hooks = _Hooks; + marked.parse = marked; + options = marked.options; + setOptions = marked.setOptions; + use = marked.use; + walkTokens = marked.walkTokens; + parseInline = marked.parseInline; + parser2 = _Parser.parse; + lexer = _Lexer.lex; } - }; - var markedInstance = new Marked(); - function marked(src, opt) { - return markedInstance.parse(src, opt); - } - marked.options = marked.setOptions = function(options2) { - markedInstance.setOptions(options2); - marked.defaults = markedInstance.defaults; - changeDefaults(marked.defaults); - return marked; - }; - marked.getDefaults = _getDefaults; - marked.defaults = _defaults; - marked.use = function(...args) { - markedInstance.use(...args); - marked.defaults = markedInstance.defaults; - changeDefaults(marked.defaults); - return marked; - }; - marked.walkTokens = function(tokens, callback) { - return markedInstance.walkTokens(tokens, callback); - }; - marked.parseInline = markedInstance.parseInline; - marked.Parser = _Parser; - marked.parser = _Parser.parse; - marked.Renderer = _Renderer; - marked.TextRenderer = _TextRenderer; - marked.Lexer = _Lexer; - marked.lexer = _Lexer.lex; - marked.Tokenizer = _Tokenizer; - marked.Hooks = _Hooks; - marked.parse = marked; - var options = marked.options; - var setOptions = marked.setOptions; - var use = marked.use; - var walkTokens = marked.walkTokens; - var parseInline = marked.parseInline; - var parser2 = _Parser.parse; - var lexer = _Lexer.lex; + }); // modules/services/osmose.js - var tiler2 = utilTiler(); - var dispatch3 = dispatch_default("loaded"); - var _tileZoom2 = 14; - var _osmoseUrlRoot = "https://osmose.openstreetmap.fr/api/0.3"; - var _osmoseData = { icons: {}, items: [] }; - var _cache2; + var osmose_exports = {}; + __export(osmose_exports, { + default: () => osmose_default + }); function abortRequest2(controller) { if (controller) { controller.abort(); @@ -39762,668 +39953,214 @@ } while (coincident); return loc; } - var osmose_default = { - title: "osmose", - init() { - _mainFileFetcher.get("qa_data").then((d2) => { - _osmoseData = d2.osmose; - _osmoseData.items = Object.keys(d2.osmose.icons).map((s2) => s2.split("-")[0]).reduce((unique, item) => unique.indexOf(item) !== -1 ? unique : [...unique, item], []); - }); - if (!_cache2) { - this.reset(); - } - this.event = utilRebind(this, dispatch3, "on"); - }, - reset() { - let _strings = {}; - let _colors = {}; - if (_cache2) { - Object.values(_cache2.inflightTile).forEach(abortRequest2); - _strings = _cache2.strings; - _colors = _cache2.colors; - } - _cache2 = { - data: {}, - loadedTile: {}, - inflightTile: {}, - inflightPost: {}, - closed: {}, - rtree: new RBush(), - strings: _strings, - colors: _colors - }; - }, - loadIssues(projection2) { - let params = { - // Tiles return a maximum # of issues - // So we want to filter our request for only types iD supports - item: _osmoseData.items - }; - let tiles = tiler2.zoomExtent([_tileZoom2, _tileZoom2]).getTiles(projection2); - abortUnwantedRequests2(_cache2, tiles); - tiles.forEach((tile) => { - if (_cache2.loadedTile[tile.id] || _cache2.inflightTile[tile.id]) return; - let [x2, y2, z2] = tile.xyz; - let url = "".concat(_osmoseUrlRoot, "/issues/").concat(z2, "/").concat(x2, "/").concat(y2, ".geojson?") + utilQsString(params); - let controller = new AbortController(); - _cache2.inflightTile[tile.id] = controller; - json_default(url, { signal: controller.signal }).then((data) => { - delete _cache2.inflightTile[tile.id]; - _cache2.loadedTile[tile.id] = true; - if (data.features) { - data.features.forEach((issue) => { - const { item, class: cl, uuid: id2 } = issue.properties; - const itemType = "".concat(item, "-").concat(cl); - if (itemType in _osmoseData.icons) { - let loc = issue.geometry.coordinates; - loc = preventCoincident(loc); - let d2 = new QAItem(loc, this, itemType, id2, { item }); - if (item === 8300 || item === 8360) { - d2.elems = []; - } - _cache2.data[d2.id] = d2; - _cache2.rtree.insert(encodeIssueRtree2(d2)); + var tiler2, dispatch3, _tileZoom2, _osmoseUrlRoot, _osmoseData, _cache2, osmose_default; + var init_osmose = __esm({ + "modules/services/osmose.js"() { + "use strict"; + init_rbush(); + init_src4(); + init_src18(); + init_marked_esm(); + init_file_fetcher(); + init_localizer(); + init_geo2(); + init_osm(); + init_util(); + tiler2 = utilTiler(); + dispatch3 = dispatch_default("loaded"); + _tileZoom2 = 14; + _osmoseUrlRoot = "https://osmose.openstreetmap.fr/api/0.3"; + _osmoseData = { icons: {}, items: [] }; + osmose_default = { + title: "osmose", + init() { + _mainFileFetcher.get("qa_data").then((d2) => { + _osmoseData = d2.osmose; + _osmoseData.items = Object.keys(d2.osmose.icons).map((s2) => s2.split("-")[0]).reduce((unique, item) => unique.indexOf(item) !== -1 ? unique : [...unique, item], []); + }); + if (!_cache2) { + this.reset(); + } + this.event = utilRebind(this, dispatch3, "on"); + }, + reset() { + let _strings = {}; + let _colors = {}; + if (_cache2) { + Object.values(_cache2.inflightTile).forEach(abortRequest2); + _strings = _cache2.strings; + _colors = _cache2.colors; + } + _cache2 = { + data: {}, + loadedTile: {}, + inflightTile: {}, + inflightPost: {}, + closed: {}, + rtree: new RBush(), + strings: _strings, + colors: _colors + }; + }, + loadIssues(projection2) { + let params = { + // Tiles return a maximum # of issues + // So we want to filter our request for only types iD supports + item: _osmoseData.items + }; + let tiles = tiler2.zoomExtent([_tileZoom2, _tileZoom2]).getTiles(projection2); + abortUnwantedRequests2(_cache2, tiles); + tiles.forEach((tile) => { + if (_cache2.loadedTile[tile.id] || _cache2.inflightTile[tile.id]) return; + let [x2, y2, z2] = tile.xyz; + let url = `${_osmoseUrlRoot}/issues/${z2}/${x2}/${y2}.geojson?` + utilQsString(params); + let controller = new AbortController(); + _cache2.inflightTile[tile.id] = controller; + json_default(url, { signal: controller.signal }).then((data) => { + delete _cache2.inflightTile[tile.id]; + _cache2.loadedTile[tile.id] = true; + if (data.features) { + data.features.forEach((issue) => { + const { item, class: cl, uuid: id2 } = issue.properties; + const itemType = `${item}-${cl}`; + if (itemType in _osmoseData.icons) { + let loc = issue.geometry.coordinates; + loc = preventCoincident(loc); + let d2 = new QAItem(loc, this, itemType, id2, { item }); + if (item === 8300 || item === 8360) { + d2.elems = []; + } + _cache2.data[d2.id] = d2; + _cache2.rtree.insert(encodeIssueRtree2(d2)); + } + }); } + dispatch3.call("loaded"); + }).catch(() => { + delete _cache2.inflightTile[tile.id]; + _cache2.loadedTile[tile.id] = true; }); + }); + }, + loadIssueDetail(issue) { + if (issue.elems !== void 0) { + return Promise.resolve(issue); } - dispatch3.call("loaded"); - }).catch(() => { - delete _cache2.inflightTile[tile.id]; - _cache2.loadedTile[tile.id] = true; - }); - }); - }, - loadIssueDetail(issue) { - if (issue.elems !== void 0) { - return Promise.resolve(issue); - } - const url = "".concat(_osmoseUrlRoot, "/issue/").concat(issue.id, "?langs=").concat(_mainLocalizer.localeCode()); - const cacheDetails = (data) => { - issue.elems = data.elems.map((e3) => e3.type.substring(0, 1) + e3.id); - issue.detail = data.subtitle ? marked(data.subtitle.auto) : ""; - this.replaceItem(issue); - }; - return json_default(url).then(cacheDetails).then(() => issue); - }, - loadStrings(locale2 = _mainLocalizer.localeCode()) { - const items = Object.keys(_osmoseData.icons); - if (locale2 in _cache2.strings && Object.keys(_cache2.strings[locale2]).length === items.length) { - return Promise.resolve(_cache2.strings[locale2]); - } - if (!(locale2 in _cache2.strings)) { - _cache2.strings[locale2] = {}; - } - const allRequests = items.map((itemType) => { - if (itemType in _cache2.strings[locale2]) return null; - const cacheData = (data) => { - const [cat = { items: [] }] = data.categories; - const [item2 = { class: [] }] = cat.items; - const [cl2 = null] = item2.class; - if (!cl2) { - console.log("Osmose strings request (".concat(itemType, ") had unexpected data")); - return; - } - const { item: itemInt, color: color2 } = item2; - if (/^#[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/.test(color2)) { - _cache2.colors[itemInt] = color2; - } - const { title, detail, fix, trap } = cl2; - let issueStrings = {}; - if (title) issueStrings.title = title.auto; - if (detail) issueStrings.detail = marked(detail.auto); - if (trap) issueStrings.trap = marked(trap.auto); - if (fix) issueStrings.fix = marked(fix.auto); - _cache2.strings[locale2][itemType] = issueStrings; - }; - const [item, cl] = itemType.split("-"); - const url = "".concat(_osmoseUrlRoot, "/items/").concat(item, "/class/").concat(cl, "?langs=").concat(locale2); - return json_default(url).then(cacheData); - }).filter(Boolean); - return Promise.all(allRequests).then(() => _cache2.strings[locale2]); - }, - getStrings(itemType, locale2 = _mainLocalizer.localeCode()) { - return locale2 in _cache2.strings ? _cache2.strings[locale2][itemType] : {}; - }, - getColor(itemType) { - return itemType in _cache2.colors ? _cache2.colors[itemType] : "#FFFFFF"; - }, - postUpdate(issue, callback) { - if (_cache2.inflightPost[issue.id]) { - return callback({ message: "Issue update already inflight", status: -2 }, issue); - } - const url = "".concat(_osmoseUrlRoot, "/issue/").concat(issue.id, "/").concat(issue.newStatus); - const controller = new AbortController(); - const after = () => { - delete _cache2.inflightPost[issue.id]; - this.removeItem(issue); - if (issue.newStatus === "done") { - if (!(issue.item in _cache2.closed)) { - _cache2.closed[issue.item] = 0; - } - _cache2.closed[issue.item] += 1; - } - if (callback) callback(null, issue); + const url = `${_osmoseUrlRoot}/issue/${issue.id}?langs=${_mainLocalizer.localeCode()}`; + const cacheDetails = (data) => { + issue.elems = data.elems.map((e3) => e3.type.substring(0, 1) + e3.id); + issue.detail = data.subtitle ? marked(data.subtitle.auto) : ""; + this.replaceItem(issue); + }; + return json_default(url).then(cacheDetails).then(() => issue); + }, + loadStrings(locale3 = _mainLocalizer.localeCode()) { + const items = Object.keys(_osmoseData.icons); + if (locale3 in _cache2.strings && Object.keys(_cache2.strings[locale3]).length === items.length) { + return Promise.resolve(_cache2.strings[locale3]); + } + if (!(locale3 in _cache2.strings)) { + _cache2.strings[locale3] = {}; + } + const allRequests = items.map((itemType) => { + if (itemType in _cache2.strings[locale3]) return null; + const cacheData = (data) => { + const [cat = { items: [] }] = data.categories; + const [item2 = { class: [] }] = cat.items; + const [cl2 = null] = item2.class; + if (!cl2) { + console.log(`Osmose strings request (${itemType}) had unexpected data`); + return; + } + const { item: itemInt, color: color2 } = item2; + if (/^#[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/.test(color2)) { + _cache2.colors[itemInt] = color2; + } + const { title, detail, fix, trap } = cl2; + let issueStrings = {}; + if (title) issueStrings.title = title.auto; + if (detail) issueStrings.detail = marked(detail.auto); + if (trap) issueStrings.trap = marked(trap.auto); + if (fix) issueStrings.fix = marked(fix.auto); + _cache2.strings[locale3][itemType] = issueStrings; + }; + const [item, cl] = itemType.split("-"); + const url = `${_osmoseUrlRoot}/items/${item}/class/${cl}?langs=${locale3}`; + return json_default(url).then(cacheData); + }).filter(Boolean); + return Promise.all(allRequests).then(() => _cache2.strings[locale3]); + }, + getStrings(itemType, locale3 = _mainLocalizer.localeCode()) { + return locale3 in _cache2.strings ? _cache2.strings[locale3][itemType] : {}; + }, + getColor(itemType) { + return itemType in _cache2.colors ? _cache2.colors[itemType] : "#FFFFFF"; + }, + postUpdate(issue, callback) { + if (_cache2.inflightPost[issue.id]) { + return callback({ message: "Issue update already inflight", status: -2 }, issue); + } + const url = `${_osmoseUrlRoot}/issue/${issue.id}/${issue.newStatus}`; + const controller = new AbortController(); + const after = () => { + delete _cache2.inflightPost[issue.id]; + this.removeItem(issue); + if (issue.newStatus === "done") { + if (!(issue.item in _cache2.closed)) { + _cache2.closed[issue.item] = 0; + } + _cache2.closed[issue.item] += 1; + } + if (callback) callback(null, issue); + }; + _cache2.inflightPost[issue.id] = controller; + fetch(url, { signal: controller.signal }).then(after).catch((err) => { + delete _cache2.inflightPost[issue.id]; + if (callback) callback(err.message); + }); + }, + // Get all cached QAItems covering the viewport + getItems(projection2) { + const viewport = projection2.clipExtent(); + const min3 = [viewport[0][0], viewport[1][1]]; + const max3 = [viewport[1][0], viewport[0][1]]; + const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox(); + return _cache2.rtree.search(bbox2).map((d2) => d2.data); + }, + // Get a QAItem from cache + // NOTE: Don't change method name until UI v3 is merged + getError(id2) { + return _cache2.data[id2]; + }, + // get the name of the icon to display for this item + getIcon(itemType) { + return _osmoseData.icons[itemType]; + }, + // Replace a single QAItem in the cache + replaceItem(item) { + if (!(item instanceof QAItem) || !item.id) return; + _cache2.data[item.id] = item; + updateRtree2(encodeIssueRtree2(item), true); + return item; + }, + // Remove a single QAItem from the cache + removeItem(item) { + if (!(item instanceof QAItem) || !item.id) return; + delete _cache2.data[item.id]; + updateRtree2(encodeIssueRtree2(item), false); + }, + // Used to populate `closed:osmose:*` changeset tags + getClosedCounts() { + return _cache2.closed; + }, + itemURL(item) { + return `https://osmose.openstreetmap.fr/en/error/${item.id}`; + } }; - _cache2.inflightPost[issue.id] = controller; - fetch(url, { signal: controller.signal }).then(after).catch((err) => { - delete _cache2.inflightPost[issue.id]; - if (callback) callback(err.message); - }); - }, - // Get all cached QAItems covering the viewport - getItems(projection2) { - const viewport = projection2.clipExtent(); - const min3 = [viewport[0][0], viewport[1][1]]; - const max3 = [viewport[1][0], viewport[0][1]]; - const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox(); - return _cache2.rtree.search(bbox2).map((d2) => d2.data); - }, - // Get a QAItem from cache - // NOTE: Don't change method name until UI v3 is merged - getError(id2) { - return _cache2.data[id2]; - }, - // get the name of the icon to display for this item - getIcon(itemType) { - return _osmoseData.icons[itemType]; - }, - // Replace a single QAItem in the cache - replaceItem(item) { - if (!(item instanceof QAItem) || !item.id) return; - _cache2.data[item.id] = item; - updateRtree2(encodeIssueRtree2(item), true); - return item; - }, - // Remove a single QAItem from the cache - removeItem(item) { - if (!(item instanceof QAItem) || !item.id) return; - delete _cache2.data[item.id]; - updateRtree2(encodeIssueRtree2(item), false); - }, - // Used to populate `closed:osmose:*` changeset tags - getClosedCounts() { - return _cache2.closed; - }, - itemURL(item) { - return "https://osmose.openstreetmap.fr/en/error/".concat(item.id); } - }; + }); // node_modules/pbf/index.js - var SHIFT_LEFT_32 = (1 << 16) * (1 << 16); - var SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32; - var TEXT_DECODER_MIN_LENGTH = 12; - var utf8TextDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder("utf-8"); - var PBF_VARINT = 0; - var PBF_FIXED64 = 1; - var PBF_BYTES = 2; - var PBF_FIXED32 = 5; - var Pbf = class { - /** - * @param {Uint8Array | ArrayBuffer} [buf] - */ - constructor(buf = new Uint8Array(16)) { - this.buf = ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf); - this.dataView = new DataView(this.buf.buffer); - this.pos = 0; - this.type = 0; - this.length = this.buf.length; - } - // === READING ================================================================= - /** - * @template T - * @param {(tag: number, result: T, pbf: Pbf) => void} readField - * @param {T} result - * @param {number} [end] - */ - readFields(readField, result, end = this.length) { - while (this.pos < end) { - const val = this.readVarint(), tag2 = val >> 3, startPos = this.pos; - this.type = val & 7; - readField(tag2, result, this); - if (this.pos === startPos) this.skip(val); - } - return result; - } - /** - * @template T - * @param {(tag: number, result: T, pbf: Pbf) => void} readField - * @param {T} result - */ - readMessage(readField, result) { - return this.readFields(readField, result, this.readVarint() + this.pos); - } - readFixed32() { - const val = this.dataView.getUint32(this.pos, true); - this.pos += 4; - return val; - } - readSFixed32() { - const val = this.dataView.getInt32(this.pos, true); - this.pos += 4; - return val; - } - // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed) - readFixed64() { - const val = this.dataView.getUint32(this.pos, true) + this.dataView.getUint32(this.pos + 4, true) * SHIFT_LEFT_32; - this.pos += 8; - return val; - } - readSFixed64() { - const val = this.dataView.getUint32(this.pos, true) + this.dataView.getInt32(this.pos + 4, true) * SHIFT_LEFT_32; - this.pos += 8; - return val; - } - readFloat() { - const val = this.dataView.getFloat32(this.pos, true); - this.pos += 4; - return val; - } - readDouble() { - const val = this.dataView.getFloat64(this.pos, true); - this.pos += 8; - return val; - } - /** - * @param {boolean} [isSigned] - */ - readVarint(isSigned) { - const buf = this.buf; - let val, b2; - b2 = buf[this.pos++]; - val = b2 & 127; - if (b2 < 128) return val; - b2 = buf[this.pos++]; - val |= (b2 & 127) << 7; - if (b2 < 128) return val; - b2 = buf[this.pos++]; - val |= (b2 & 127) << 14; - if (b2 < 128) return val; - b2 = buf[this.pos++]; - val |= (b2 & 127) << 21; - if (b2 < 128) return val; - b2 = buf[this.pos]; - val |= (b2 & 15) << 28; - return readVarintRemainder(val, isSigned, this); - } - readVarint64() { - return this.readVarint(true); - } - readSVarint() { - const num = this.readVarint(); - return num % 2 === 1 ? (num + 1) / -2 : num / 2; - } - readBoolean() { - return Boolean(this.readVarint()); - } - readString() { - const end = this.readVarint() + this.pos; - const pos = this.pos; - this.pos = end; - if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) { - return utf8TextDecoder.decode(this.buf.subarray(pos, end)); - } - return readUtf8(this.buf, pos, end); - } - readBytes() { - const end = this.readVarint() + this.pos, buffer = this.buf.subarray(this.pos, end); - this.pos = end; - return buffer; - } - // verbose for performance reasons; doesn't affect gzipped size - /** - * @param {number[]} [arr] - * @param {boolean} [isSigned] - */ - readPackedVarint(arr = [], isSigned) { - const end = this.readPackedEnd(); - while (this.pos < end) arr.push(this.readVarint(isSigned)); - return arr; - } - /** @param {number[]} [arr] */ - readPackedSVarint(arr = []) { - const end = this.readPackedEnd(); - while (this.pos < end) arr.push(this.readSVarint()); - return arr; - } - /** @param {boolean[]} [arr] */ - readPackedBoolean(arr = []) { - const end = this.readPackedEnd(); - while (this.pos < end) arr.push(this.readBoolean()); - return arr; - } - /** @param {number[]} [arr] */ - readPackedFloat(arr = []) { - const end = this.readPackedEnd(); - while (this.pos < end) arr.push(this.readFloat()); - return arr; - } - /** @param {number[]} [arr] */ - readPackedDouble(arr = []) { - const end = this.readPackedEnd(); - while (this.pos < end) arr.push(this.readDouble()); - return arr; - } - /** @param {number[]} [arr] */ - readPackedFixed32(arr = []) { - const end = this.readPackedEnd(); - while (this.pos < end) arr.push(this.readFixed32()); - return arr; - } - /** @param {number[]} [arr] */ - readPackedSFixed32(arr = []) { - const end = this.readPackedEnd(); - while (this.pos < end) arr.push(this.readSFixed32()); - return arr; - } - /** @param {number[]} [arr] */ - readPackedFixed64(arr = []) { - const end = this.readPackedEnd(); - while (this.pos < end) arr.push(this.readFixed64()); - return arr; - } - /** @param {number[]} [arr] */ - readPackedSFixed64(arr = []) { - const end = this.readPackedEnd(); - while (this.pos < end) arr.push(this.readSFixed64()); - return arr; - } - readPackedEnd() { - return this.type === PBF_BYTES ? this.readVarint() + this.pos : this.pos + 1; - } - /** @param {number} val */ - skip(val) { - const type2 = val & 7; - if (type2 === PBF_VARINT) while (this.buf[this.pos++] > 127) { - } - else if (type2 === PBF_BYTES) this.pos = this.readVarint() + this.pos; - else if (type2 === PBF_FIXED32) this.pos += 4; - else if (type2 === PBF_FIXED64) this.pos += 8; - else throw new Error("Unimplemented type: ".concat(type2)); - } - // === WRITING ================================================================= - /** - * @param {number} tag - * @param {number} type - */ - writeTag(tag2, type2) { - this.writeVarint(tag2 << 3 | type2); - } - /** @param {number} min */ - realloc(min3) { - let length2 = this.length || 16; - while (length2 < this.pos + min3) length2 *= 2; - if (length2 !== this.length) { - const buf = new Uint8Array(length2); - buf.set(this.buf); - this.buf = buf; - this.dataView = new DataView(buf.buffer); - this.length = length2; - } - } - finish() { - this.length = this.pos; - this.pos = 0; - return this.buf.subarray(0, this.length); - } - /** @param {number} val */ - writeFixed32(val) { - this.realloc(4); - this.dataView.setInt32(this.pos, val, true); - this.pos += 4; - } - /** @param {number} val */ - writeSFixed32(val) { - this.realloc(4); - this.dataView.setInt32(this.pos, val, true); - this.pos += 4; - } - /** @param {number} val */ - writeFixed64(val) { - this.realloc(8); - this.dataView.setInt32(this.pos, val & -1, true); - this.dataView.setInt32(this.pos + 4, Math.floor(val * SHIFT_RIGHT_32), true); - this.pos += 8; - } - /** @param {number} val */ - writeSFixed64(val) { - this.realloc(8); - this.dataView.setInt32(this.pos, val & -1, true); - this.dataView.setInt32(this.pos + 4, Math.floor(val * SHIFT_RIGHT_32), true); - this.pos += 8; - } - /** @param {number} val */ - writeVarint(val) { - val = +val || 0; - if (val > 268435455 || val < 0) { - writeBigVarint(val, this); - return; - } - this.realloc(4); - this.buf[this.pos++] = val & 127 | (val > 127 ? 128 : 0); - if (val <= 127) return; - this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0); - if (val <= 127) return; - this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0); - if (val <= 127) return; - this.buf[this.pos++] = val >>> 7 & 127; - } - /** @param {number} val */ - writeSVarint(val) { - this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2); - } - /** @param {boolean} val */ - writeBoolean(val) { - this.writeVarint(+val); - } - /** @param {string} str */ - writeString(str) { - str = String(str); - this.realloc(str.length * 4); - this.pos++; - const startPos = this.pos; - this.pos = writeUtf8(this.buf, str, this.pos); - const len = this.pos - startPos; - if (len >= 128) makeRoomForExtraLength(startPos, len, this); - this.pos = startPos - 1; - this.writeVarint(len); - this.pos += len; - } - /** @param {number} val */ - writeFloat(val) { - this.realloc(4); - this.dataView.setFloat32(this.pos, val, true); - this.pos += 4; - } - /** @param {number} val */ - writeDouble(val) { - this.realloc(8); - this.dataView.setFloat64(this.pos, val, true); - this.pos += 8; - } - /** @param {Uint8Array} buffer */ - writeBytes(buffer) { - const len = buffer.length; - this.writeVarint(len); - this.realloc(len); - for (let i3 = 0; i3 < len; i3++) this.buf[this.pos++] = buffer[i3]; - } - /** - * @template T - * @param {(obj: T, pbf: Pbf) => void} fn - * @param {T} obj - */ - writeRawMessage(fn, obj) { - this.pos++; - const startPos = this.pos; - fn(obj, this); - const len = this.pos - startPos; - if (len >= 128) makeRoomForExtraLength(startPos, len, this); - this.pos = startPos - 1; - this.writeVarint(len); - this.pos += len; - } - /** - * @template T - * @param {number} tag - * @param {(obj: T, pbf: Pbf) => void} fn - * @param {T} obj - */ - writeMessage(tag2, fn, obj) { - this.writeTag(tag2, PBF_BYTES); - this.writeRawMessage(fn, obj); - } - /** - * @param {number} tag - * @param {number[]} arr - */ - writePackedVarint(tag2, arr) { - if (arr.length) this.writeMessage(tag2, writePackedVarint, arr); - } - /** - * @param {number} tag - * @param {number[]} arr - */ - writePackedSVarint(tag2, arr) { - if (arr.length) this.writeMessage(tag2, writePackedSVarint, arr); - } - /** - * @param {number} tag - * @param {boolean[]} arr - */ - writePackedBoolean(tag2, arr) { - if (arr.length) this.writeMessage(tag2, writePackedBoolean, arr); - } - /** - * @param {number} tag - * @param {number[]} arr - */ - writePackedFloat(tag2, arr) { - if (arr.length) this.writeMessage(tag2, writePackedFloat, arr); - } - /** - * @param {number} tag - * @param {number[]} arr - */ - writePackedDouble(tag2, arr) { - if (arr.length) this.writeMessage(tag2, writePackedDouble, arr); - } - /** - * @param {number} tag - * @param {number[]} arr - */ - writePackedFixed32(tag2, arr) { - if (arr.length) this.writeMessage(tag2, writePackedFixed32, arr); - } - /** - * @param {number} tag - * @param {number[]} arr - */ - writePackedSFixed32(tag2, arr) { - if (arr.length) this.writeMessage(tag2, writePackedSFixed32, arr); - } - /** - * @param {number} tag - * @param {number[]} arr - */ - writePackedFixed64(tag2, arr) { - if (arr.length) this.writeMessage(tag2, writePackedFixed64, arr); - } - /** - * @param {number} tag - * @param {number[]} arr - */ - writePackedSFixed64(tag2, arr) { - if (arr.length) this.writeMessage(tag2, writePackedSFixed64, arr); - } - /** - * @param {number} tag - * @param {Uint8Array} buffer - */ - writeBytesField(tag2, buffer) { - this.writeTag(tag2, PBF_BYTES); - this.writeBytes(buffer); - } - /** - * @param {number} tag - * @param {number} val - */ - writeFixed32Field(tag2, val) { - this.writeTag(tag2, PBF_FIXED32); - this.writeFixed32(val); - } - /** - * @param {number} tag - * @param {number} val - */ - writeSFixed32Field(tag2, val) { - this.writeTag(tag2, PBF_FIXED32); - this.writeSFixed32(val); - } - /** - * @param {number} tag - * @param {number} val - */ - writeFixed64Field(tag2, val) { - this.writeTag(tag2, PBF_FIXED64); - this.writeFixed64(val); - } - /** - * @param {number} tag - * @param {number} val - */ - writeSFixed64Field(tag2, val) { - this.writeTag(tag2, PBF_FIXED64); - this.writeSFixed64(val); - } - /** - * @param {number} tag - * @param {number} val - */ - writeVarintField(tag2, val) { - this.writeTag(tag2, PBF_VARINT); - this.writeVarint(val); - } - /** - * @param {number} tag - * @param {number} val - */ - writeSVarintField(tag2, val) { - this.writeTag(tag2, PBF_VARINT); - this.writeSVarint(val); - } - /** - * @param {number} tag - * @param {string} str - */ - writeStringField(tag2, str) { - this.writeTag(tag2, PBF_BYTES); - this.writeString(str); - } - /** - * @param {number} tag - * @param {number} val - */ - writeFloatField(tag2, val) { - this.writeTag(tag2, PBF_FIXED32); - this.writeFloat(val); - } - /** - * @param {number} tag - * @param {number} val - */ - writeDoubleField(tag2, val) { - this.writeTag(tag2, PBF_FIXED64); - this.writeDouble(val); - } - /** - * @param {number} tag - * @param {boolean} val - */ - writeBooleanField(tag2, val) { - this.writeVarintField(tag2, +val); - } - }; function readVarintRemainder(l2, s2, p2) { const buf = p2.buf; let h2, b2; @@ -40633,427 +40370,780 @@ } return pos; } + var SHIFT_LEFT_32, SHIFT_RIGHT_32, TEXT_DECODER_MIN_LENGTH, utf8TextDecoder, PBF_VARINT, PBF_FIXED64, PBF_BYTES, PBF_FIXED32, Pbf; + var init_pbf = __esm({ + "node_modules/pbf/index.js"() { + SHIFT_LEFT_32 = (1 << 16) * (1 << 16); + SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32; + TEXT_DECODER_MIN_LENGTH = 12; + utf8TextDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder("utf-8"); + PBF_VARINT = 0; + PBF_FIXED64 = 1; + PBF_BYTES = 2; + PBF_FIXED32 = 5; + Pbf = class { + /** + * @param {Uint8Array | ArrayBuffer} [buf] + */ + constructor(buf = new Uint8Array(16)) { + this.buf = ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf); + this.dataView = new DataView(this.buf.buffer); + this.pos = 0; + this.type = 0; + this.length = this.buf.length; + } + // === READING ================================================================= + /** + * @template T + * @param {(tag: number, result: T, pbf: Pbf) => void} readField + * @param {T} result + * @param {number} [end] + */ + readFields(readField, result, end = this.length) { + while (this.pos < end) { + const val = this.readVarint(), tag2 = val >> 3, startPos = this.pos; + this.type = val & 7; + readField(tag2, result, this); + if (this.pos === startPos) this.skip(val); + } + return result; + } + /** + * @template T + * @param {(tag: number, result: T, pbf: Pbf) => void} readField + * @param {T} result + */ + readMessage(readField, result) { + return this.readFields(readField, result, this.readVarint() + this.pos); + } + readFixed32() { + const val = this.dataView.getUint32(this.pos, true); + this.pos += 4; + return val; + } + readSFixed32() { + const val = this.dataView.getInt32(this.pos, true); + this.pos += 4; + return val; + } + // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed) + readFixed64() { + const val = this.dataView.getUint32(this.pos, true) + this.dataView.getUint32(this.pos + 4, true) * SHIFT_LEFT_32; + this.pos += 8; + return val; + } + readSFixed64() { + const val = this.dataView.getUint32(this.pos, true) + this.dataView.getInt32(this.pos + 4, true) * SHIFT_LEFT_32; + this.pos += 8; + return val; + } + readFloat() { + const val = this.dataView.getFloat32(this.pos, true); + this.pos += 4; + return val; + } + readDouble() { + const val = this.dataView.getFloat64(this.pos, true); + this.pos += 8; + return val; + } + /** + * @param {boolean} [isSigned] + */ + readVarint(isSigned) { + const buf = this.buf; + let val, b2; + b2 = buf[this.pos++]; + val = b2 & 127; + if (b2 < 128) return val; + b2 = buf[this.pos++]; + val |= (b2 & 127) << 7; + if (b2 < 128) return val; + b2 = buf[this.pos++]; + val |= (b2 & 127) << 14; + if (b2 < 128) return val; + b2 = buf[this.pos++]; + val |= (b2 & 127) << 21; + if (b2 < 128) return val; + b2 = buf[this.pos]; + val |= (b2 & 15) << 28; + return readVarintRemainder(val, isSigned, this); + } + readVarint64() { + return this.readVarint(true); + } + readSVarint() { + const num = this.readVarint(); + return num % 2 === 1 ? (num + 1) / -2 : num / 2; + } + readBoolean() { + return Boolean(this.readVarint()); + } + readString() { + const end = this.readVarint() + this.pos; + const pos = this.pos; + this.pos = end; + if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) { + return utf8TextDecoder.decode(this.buf.subarray(pos, end)); + } + return readUtf8(this.buf, pos, end); + } + readBytes() { + const end = this.readVarint() + this.pos, buffer = this.buf.subarray(this.pos, end); + this.pos = end; + return buffer; + } + // verbose for performance reasons; doesn't affect gzipped size + /** + * @param {number[]} [arr] + * @param {boolean} [isSigned] + */ + readPackedVarint(arr = [], isSigned) { + const end = this.readPackedEnd(); + while (this.pos < end) arr.push(this.readVarint(isSigned)); + return arr; + } + /** @param {number[]} [arr] */ + readPackedSVarint(arr = []) { + const end = this.readPackedEnd(); + while (this.pos < end) arr.push(this.readSVarint()); + return arr; + } + /** @param {boolean[]} [arr] */ + readPackedBoolean(arr = []) { + const end = this.readPackedEnd(); + while (this.pos < end) arr.push(this.readBoolean()); + return arr; + } + /** @param {number[]} [arr] */ + readPackedFloat(arr = []) { + const end = this.readPackedEnd(); + while (this.pos < end) arr.push(this.readFloat()); + return arr; + } + /** @param {number[]} [arr] */ + readPackedDouble(arr = []) { + const end = this.readPackedEnd(); + while (this.pos < end) arr.push(this.readDouble()); + return arr; + } + /** @param {number[]} [arr] */ + readPackedFixed32(arr = []) { + const end = this.readPackedEnd(); + while (this.pos < end) arr.push(this.readFixed32()); + return arr; + } + /** @param {number[]} [arr] */ + readPackedSFixed32(arr = []) { + const end = this.readPackedEnd(); + while (this.pos < end) arr.push(this.readSFixed32()); + return arr; + } + /** @param {number[]} [arr] */ + readPackedFixed64(arr = []) { + const end = this.readPackedEnd(); + while (this.pos < end) arr.push(this.readFixed64()); + return arr; + } + /** @param {number[]} [arr] */ + readPackedSFixed64(arr = []) { + const end = this.readPackedEnd(); + while (this.pos < end) arr.push(this.readSFixed64()); + return arr; + } + readPackedEnd() { + return this.type === PBF_BYTES ? this.readVarint() + this.pos : this.pos + 1; + } + /** @param {number} val */ + skip(val) { + const type2 = val & 7; + if (type2 === PBF_VARINT) while (this.buf[this.pos++] > 127) { + } + else if (type2 === PBF_BYTES) this.pos = this.readVarint() + this.pos; + else if (type2 === PBF_FIXED32) this.pos += 4; + else if (type2 === PBF_FIXED64) this.pos += 8; + else throw new Error(`Unimplemented type: ${type2}`); + } + // === WRITING ================================================================= + /** + * @param {number} tag + * @param {number} type + */ + writeTag(tag2, type2) { + this.writeVarint(tag2 << 3 | type2); + } + /** @param {number} min */ + realloc(min3) { + let length2 = this.length || 16; + while (length2 < this.pos + min3) length2 *= 2; + if (length2 !== this.length) { + const buf = new Uint8Array(length2); + buf.set(this.buf); + this.buf = buf; + this.dataView = new DataView(buf.buffer); + this.length = length2; + } + } + finish() { + this.length = this.pos; + this.pos = 0; + return this.buf.subarray(0, this.length); + } + /** @param {number} val */ + writeFixed32(val) { + this.realloc(4); + this.dataView.setInt32(this.pos, val, true); + this.pos += 4; + } + /** @param {number} val */ + writeSFixed32(val) { + this.realloc(4); + this.dataView.setInt32(this.pos, val, true); + this.pos += 4; + } + /** @param {number} val */ + writeFixed64(val) { + this.realloc(8); + this.dataView.setInt32(this.pos, val & -1, true); + this.dataView.setInt32(this.pos + 4, Math.floor(val * SHIFT_RIGHT_32), true); + this.pos += 8; + } + /** @param {number} val */ + writeSFixed64(val) { + this.realloc(8); + this.dataView.setInt32(this.pos, val & -1, true); + this.dataView.setInt32(this.pos + 4, Math.floor(val * SHIFT_RIGHT_32), true); + this.pos += 8; + } + /** @param {number} val */ + writeVarint(val) { + val = +val || 0; + if (val > 268435455 || val < 0) { + writeBigVarint(val, this); + return; + } + this.realloc(4); + this.buf[this.pos++] = val & 127 | (val > 127 ? 128 : 0); + if (val <= 127) return; + this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0); + if (val <= 127) return; + this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0); + if (val <= 127) return; + this.buf[this.pos++] = val >>> 7 & 127; + } + /** @param {number} val */ + writeSVarint(val) { + this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2); + } + /** @param {boolean} val */ + writeBoolean(val) { + this.writeVarint(+val); + } + /** @param {string} str */ + writeString(str) { + str = String(str); + this.realloc(str.length * 4); + this.pos++; + const startPos = this.pos; + this.pos = writeUtf8(this.buf, str, this.pos); + const len = this.pos - startPos; + if (len >= 128) makeRoomForExtraLength(startPos, len, this); + this.pos = startPos - 1; + this.writeVarint(len); + this.pos += len; + } + /** @param {number} val */ + writeFloat(val) { + this.realloc(4); + this.dataView.setFloat32(this.pos, val, true); + this.pos += 4; + } + /** @param {number} val */ + writeDouble(val) { + this.realloc(8); + this.dataView.setFloat64(this.pos, val, true); + this.pos += 8; + } + /** @param {Uint8Array} buffer */ + writeBytes(buffer) { + const len = buffer.length; + this.writeVarint(len); + this.realloc(len); + for (let i3 = 0; i3 < len; i3++) this.buf[this.pos++] = buffer[i3]; + } + /** + * @template T + * @param {(obj: T, pbf: Pbf) => void} fn + * @param {T} obj + */ + writeRawMessage(fn, obj) { + this.pos++; + const startPos = this.pos; + fn(obj, this); + const len = this.pos - startPos; + if (len >= 128) makeRoomForExtraLength(startPos, len, this); + this.pos = startPos - 1; + this.writeVarint(len); + this.pos += len; + } + /** + * @template T + * @param {number} tag + * @param {(obj: T, pbf: Pbf) => void} fn + * @param {T} obj + */ + writeMessage(tag2, fn, obj) { + this.writeTag(tag2, PBF_BYTES); + this.writeRawMessage(fn, obj); + } + /** + * @param {number} tag + * @param {number[]} arr + */ + writePackedVarint(tag2, arr) { + if (arr.length) this.writeMessage(tag2, writePackedVarint, arr); + } + /** + * @param {number} tag + * @param {number[]} arr + */ + writePackedSVarint(tag2, arr) { + if (arr.length) this.writeMessage(tag2, writePackedSVarint, arr); + } + /** + * @param {number} tag + * @param {boolean[]} arr + */ + writePackedBoolean(tag2, arr) { + if (arr.length) this.writeMessage(tag2, writePackedBoolean, arr); + } + /** + * @param {number} tag + * @param {number[]} arr + */ + writePackedFloat(tag2, arr) { + if (arr.length) this.writeMessage(tag2, writePackedFloat, arr); + } + /** + * @param {number} tag + * @param {number[]} arr + */ + writePackedDouble(tag2, arr) { + if (arr.length) this.writeMessage(tag2, writePackedDouble, arr); + } + /** + * @param {number} tag + * @param {number[]} arr + */ + writePackedFixed32(tag2, arr) { + if (arr.length) this.writeMessage(tag2, writePackedFixed32, arr); + } + /** + * @param {number} tag + * @param {number[]} arr + */ + writePackedSFixed32(tag2, arr) { + if (arr.length) this.writeMessage(tag2, writePackedSFixed32, arr); + } + /** + * @param {number} tag + * @param {number[]} arr + */ + writePackedFixed64(tag2, arr) { + if (arr.length) this.writeMessage(tag2, writePackedFixed64, arr); + } + /** + * @param {number} tag + * @param {number[]} arr + */ + writePackedSFixed64(tag2, arr) { + if (arr.length) this.writeMessage(tag2, writePackedSFixed64, arr); + } + /** + * @param {number} tag + * @param {Uint8Array} buffer + */ + writeBytesField(tag2, buffer) { + this.writeTag(tag2, PBF_BYTES); + this.writeBytes(buffer); + } + /** + * @param {number} tag + * @param {number} val + */ + writeFixed32Field(tag2, val) { + this.writeTag(tag2, PBF_FIXED32); + this.writeFixed32(val); + } + /** + * @param {number} tag + * @param {number} val + */ + writeSFixed32Field(tag2, val) { + this.writeTag(tag2, PBF_FIXED32); + this.writeSFixed32(val); + } + /** + * @param {number} tag + * @param {number} val + */ + writeFixed64Field(tag2, val) { + this.writeTag(tag2, PBF_FIXED64); + this.writeFixed64(val); + } + /** + * @param {number} tag + * @param {number} val + */ + writeSFixed64Field(tag2, val) { + this.writeTag(tag2, PBF_FIXED64); + this.writeSFixed64(val); + } + /** + * @param {number} tag + * @param {number} val + */ + writeVarintField(tag2, val) { + this.writeTag(tag2, PBF_VARINT); + this.writeVarint(val); + } + /** + * @param {number} tag + * @param {number} val + */ + writeSVarintField(tag2, val) { + this.writeTag(tag2, PBF_VARINT); + this.writeSVarint(val); + } + /** + * @param {number} tag + * @param {string} str + */ + writeStringField(tag2, str) { + this.writeTag(tag2, PBF_BYTES); + this.writeString(str); + } + /** + * @param {number} tag + * @param {number} val + */ + writeFloatField(tag2, val) { + this.writeTag(tag2, PBF_FIXED32); + this.writeFloat(val); + } + /** + * @param {number} tag + * @param {number} val + */ + writeDoubleField(tag2, val) { + this.writeTag(tag2, PBF_FIXED64); + this.writeDouble(val); + } + /** + * @param {number} tag + * @param {boolean} val + */ + writeBooleanField(tag2, val) { + this.writeVarintField(tag2, +val); + } + }; + } + }); // node_modules/@mapbox/point-geometry/index.js function Point(x2, y2) { this.x = x2; this.y = y2; } - Point.prototype = { - /** - * Clone this point, returning a new point that can be modified - * without affecting the old one. - * @return {Point} the clone - */ - clone() { - return new Point(this.x, this.y); - }, - /** - * Add this point's x & y coordinates to another point, - * yielding a new point. - * @param {Point} p the other point - * @return {Point} output point - */ - add(p2) { - return this.clone()._add(p2); - }, - /** - * Subtract this point's x & y coordinates to from point, - * yielding a new point. - * @param {Point} p the other point - * @return {Point} output point - */ - sub(p2) { - return this.clone()._sub(p2); - }, - /** - * Multiply this point's x & y coordinates by point, - * yielding a new point. - * @param {Point} p the other point - * @return {Point} output point - */ - multByPoint(p2) { - return this.clone()._multByPoint(p2); - }, - /** - * Divide this point's x & y coordinates by point, - * yielding a new point. - * @param {Point} p the other point - * @return {Point} output point - */ - divByPoint(p2) { - return this.clone()._divByPoint(p2); - }, - /** - * Multiply this point's x & y coordinates by a factor, - * yielding a new point. - * @param {number} k factor - * @return {Point} output point - */ - mult(k2) { - return this.clone()._mult(k2); - }, - /** - * Divide this point's x & y coordinates by a factor, - * yielding a new point. - * @param {number} k factor - * @return {Point} output point - */ - div(k2) { - return this.clone()._div(k2); - }, - /** - * Rotate this point around the 0, 0 origin by an angle a, - * given in radians - * @param {number} a angle to rotate around, in radians - * @return {Point} output point - */ - rotate(a2) { - return this.clone()._rotate(a2); - }, - /** - * Rotate this point around p point by an angle a, - * given in radians - * @param {number} a angle to rotate around, in radians - * @param {Point} p Point to rotate around - * @return {Point} output point - */ - rotateAround(a2, p2) { - return this.clone()._rotateAround(a2, p2); - }, - /** - * Multiply this point by a 4x1 transformation matrix - * @param {[number, number, number, number]} m transformation matrix - * @return {Point} output point - */ - matMult(m2) { - return this.clone()._matMult(m2); - }, - /** - * Calculate this point but as a unit vector from 0, 0, meaning - * that the distance from the resulting point to the 0, 0 - * coordinate will be equal to 1 and the angle from the resulting - * point to the 0, 0 coordinate will be the same as before. - * @return {Point} unit vector point - */ - unit() { - return this.clone()._unit(); - }, - /** - * Compute a perpendicular point, where the new y coordinate - * is the old x coordinate and the new x coordinate is the old y - * coordinate multiplied by -1 - * @return {Point} perpendicular point - */ - perp() { - return this.clone()._perp(); - }, - /** - * Return a version of this point with the x & y coordinates - * rounded to integers. - * @return {Point} rounded point - */ - round() { - return this.clone()._round(); - }, - /** - * Return the magnitude of this point: this is the Euclidean - * distance from the 0, 0 coordinate to this point's x and y - * coordinates. - * @return {number} magnitude - */ - mag() { - return Math.sqrt(this.x * this.x + this.y * this.y); - }, - /** - * Judge whether this point is equal to another point, returning - * true or false. - * @param {Point} other the other point - * @return {boolean} whether the points are equal - */ - equals(other2) { - return this.x === other2.x && this.y === other2.y; - }, - /** - * Calculate the distance from this point to another point - * @param {Point} p the other point - * @return {number} distance - */ - dist(p2) { - return Math.sqrt(this.distSqr(p2)); - }, - /** - * Calculate the distance from this point to another point, - * without the square root step. Useful if you're comparing - * relative distances. - * @param {Point} p the other point - * @return {number} distance - */ - distSqr(p2) { - const dx = p2.x - this.x, dy = p2.y - this.y; - return dx * dx + dy * dy; - }, - /** - * Get the angle from the 0, 0 coordinate to this point, in radians - * coordinates. - * @return {number} angle - */ - angle() { - return Math.atan2(this.y, this.x); - }, - /** - * Get the angle from this point to another point, in radians - * @param {Point} b the other point - * @return {number} angle - */ - angleTo(b2) { - return Math.atan2(this.y - b2.y, this.x - b2.x); - }, - /** - * Get the angle between this point and another point, in radians - * @param {Point} b the other point - * @return {number} angle - */ - angleWith(b2) { - return this.angleWithSep(b2.x, b2.y); - }, - /** - * Find the angle of the two vectors, solving the formula for - * the cross product a x b = |a||b|sin(θ) for θ. - * @param {number} x the x-coordinate - * @param {number} y the y-coordinate - * @return {number} the angle in radians - */ - angleWithSep(x2, y2) { - return Math.atan2( - this.x * y2 - this.y * x2, - this.x * x2 + this.y * y2 - ); - }, - /** @param {[number, number, number, number]} m */ - _matMult(m2) { - const x2 = m2[0] * this.x + m2[1] * this.y, y2 = m2[2] * this.x + m2[3] * this.y; - this.x = x2; - this.y = y2; - return this; - }, - /** @param {Point} p */ - _add(p2) { - this.x += p2.x; - this.y += p2.y; - return this; - }, - /** @param {Point} p */ - _sub(p2) { - this.x -= p2.x; - this.y -= p2.y; - return this; - }, - /** @param {number} k */ - _mult(k2) { - this.x *= k2; - this.y *= k2; - return this; - }, - /** @param {number} k */ - _div(k2) { - this.x /= k2; - this.y /= k2; - return this; - }, - /** @param {Point} p */ - _multByPoint(p2) { - this.x *= p2.x; - this.y *= p2.y; - return this; - }, - /** @param {Point} p */ - _divByPoint(p2) { - this.x /= p2.x; - this.y /= p2.y; - return this; - }, - _unit() { - this._div(this.mag()); - return this; - }, - _perp() { - const y2 = this.y; - this.y = this.x; - this.x = -y2; - return this; - }, - /** @param {number} angle */ - _rotate(angle2) { - const cos2 = Math.cos(angle2), sin2 = Math.sin(angle2), x2 = cos2 * this.x - sin2 * this.y, y2 = sin2 * this.x + cos2 * this.y; - this.x = x2; - this.y = y2; - return this; - }, - /** - * @param {number} angle - * @param {Point} p - */ - _rotateAround(angle2, p2) { - const cos2 = Math.cos(angle2), sin2 = Math.sin(angle2), x2 = p2.x + cos2 * (this.x - p2.x) - sin2 * (this.y - p2.y), y2 = p2.y + sin2 * (this.x - p2.x) + cos2 * (this.y - p2.y); - this.x = x2; - this.y = y2; - return this; - }, - _round() { - this.x = Math.round(this.x); - this.y = Math.round(this.y); - return this; - }, - constructor: Point - }; - Point.convert = function(p2) { - if (p2 instanceof Point) { - return ( - /** @type {Point} */ - p2 - ); - } - if (Array.isArray(p2)) { - return new Point(+p2[0], +p2[1]); - } - if (p2.x !== void 0 && p2.y !== void 0) { - return new Point(+p2.x, +p2.y); + var init_point_geometry = __esm({ + "node_modules/@mapbox/point-geometry/index.js"() { + Point.prototype = { + /** + * Clone this point, returning a new point that can be modified + * without affecting the old one. + * @return {Point} the clone + */ + clone() { + return new Point(this.x, this.y); + }, + /** + * Add this point's x & y coordinates to another point, + * yielding a new point. + * @param {Point} p the other point + * @return {Point} output point + */ + add(p2) { + return this.clone()._add(p2); + }, + /** + * Subtract this point's x & y coordinates to from point, + * yielding a new point. + * @param {Point} p the other point + * @return {Point} output point + */ + sub(p2) { + return this.clone()._sub(p2); + }, + /** + * Multiply this point's x & y coordinates by point, + * yielding a new point. + * @param {Point} p the other point + * @return {Point} output point + */ + multByPoint(p2) { + return this.clone()._multByPoint(p2); + }, + /** + * Divide this point's x & y coordinates by point, + * yielding a new point. + * @param {Point} p the other point + * @return {Point} output point + */ + divByPoint(p2) { + return this.clone()._divByPoint(p2); + }, + /** + * Multiply this point's x & y coordinates by a factor, + * yielding a new point. + * @param {number} k factor + * @return {Point} output point + */ + mult(k2) { + return this.clone()._mult(k2); + }, + /** + * Divide this point's x & y coordinates by a factor, + * yielding a new point. + * @param {number} k factor + * @return {Point} output point + */ + div(k2) { + return this.clone()._div(k2); + }, + /** + * Rotate this point around the 0, 0 origin by an angle a, + * given in radians + * @param {number} a angle to rotate around, in radians + * @return {Point} output point + */ + rotate(a2) { + return this.clone()._rotate(a2); + }, + /** + * Rotate this point around p point by an angle a, + * given in radians + * @param {number} a angle to rotate around, in radians + * @param {Point} p Point to rotate around + * @return {Point} output point + */ + rotateAround(a2, p2) { + return this.clone()._rotateAround(a2, p2); + }, + /** + * Multiply this point by a 4x1 transformation matrix + * @param {[number, number, number, number]} m transformation matrix + * @return {Point} output point + */ + matMult(m2) { + return this.clone()._matMult(m2); + }, + /** + * Calculate this point but as a unit vector from 0, 0, meaning + * that the distance from the resulting point to the 0, 0 + * coordinate will be equal to 1 and the angle from the resulting + * point to the 0, 0 coordinate will be the same as before. + * @return {Point} unit vector point + */ + unit() { + return this.clone()._unit(); + }, + /** + * Compute a perpendicular point, where the new y coordinate + * is the old x coordinate and the new x coordinate is the old y + * coordinate multiplied by -1 + * @return {Point} perpendicular point + */ + perp() { + return this.clone()._perp(); + }, + /** + * Return a version of this point with the x & y coordinates + * rounded to integers. + * @return {Point} rounded point + */ + round() { + return this.clone()._round(); + }, + /** + * Return the magnitude of this point: this is the Euclidean + * distance from the 0, 0 coordinate to this point's x and y + * coordinates. + * @return {number} magnitude + */ + mag() { + return Math.sqrt(this.x * this.x + this.y * this.y); + }, + /** + * Judge whether this point is equal to another point, returning + * true or false. + * @param {Point} other the other point + * @return {boolean} whether the points are equal + */ + equals(other2) { + return this.x === other2.x && this.y === other2.y; + }, + /** + * Calculate the distance from this point to another point + * @param {Point} p the other point + * @return {number} distance + */ + dist(p2) { + return Math.sqrt(this.distSqr(p2)); + }, + /** + * Calculate the distance from this point to another point, + * without the square root step. Useful if you're comparing + * relative distances. + * @param {Point} p the other point + * @return {number} distance + */ + distSqr(p2) { + const dx = p2.x - this.x, dy = p2.y - this.y; + return dx * dx + dy * dy; + }, + /** + * Get the angle from the 0, 0 coordinate to this point, in radians + * coordinates. + * @return {number} angle + */ + angle() { + return Math.atan2(this.y, this.x); + }, + /** + * Get the angle from this point to another point, in radians + * @param {Point} b the other point + * @return {number} angle + */ + angleTo(b2) { + return Math.atan2(this.y - b2.y, this.x - b2.x); + }, + /** + * Get the angle between this point and another point, in radians + * @param {Point} b the other point + * @return {number} angle + */ + angleWith(b2) { + return this.angleWithSep(b2.x, b2.y); + }, + /** + * Find the angle of the two vectors, solving the formula for + * the cross product a x b = |a||b|sin(θ) for θ. + * @param {number} x the x-coordinate + * @param {number} y the y-coordinate + * @return {number} the angle in radians + */ + angleWithSep(x2, y2) { + return Math.atan2( + this.x * y2 - this.y * x2, + this.x * x2 + this.y * y2 + ); + }, + /** @param {[number, number, number, number]} m */ + _matMult(m2) { + const x2 = m2[0] * this.x + m2[1] * this.y, y2 = m2[2] * this.x + m2[3] * this.y; + this.x = x2; + this.y = y2; + return this; + }, + /** @param {Point} p */ + _add(p2) { + this.x += p2.x; + this.y += p2.y; + return this; + }, + /** @param {Point} p */ + _sub(p2) { + this.x -= p2.x; + this.y -= p2.y; + return this; + }, + /** @param {number} k */ + _mult(k2) { + this.x *= k2; + this.y *= k2; + return this; + }, + /** @param {number} k */ + _div(k2) { + this.x /= k2; + this.y /= k2; + return this; + }, + /** @param {Point} p */ + _multByPoint(p2) { + this.x *= p2.x; + this.y *= p2.y; + return this; + }, + /** @param {Point} p */ + _divByPoint(p2) { + this.x /= p2.x; + this.y /= p2.y; + return this; + }, + _unit() { + this._div(this.mag()); + return this; + }, + _perp() { + const y2 = this.y; + this.y = this.x; + this.x = -y2; + return this; + }, + /** @param {number} angle */ + _rotate(angle2) { + const cos2 = Math.cos(angle2), sin2 = Math.sin(angle2), x2 = cos2 * this.x - sin2 * this.y, y2 = sin2 * this.x + cos2 * this.y; + this.x = x2; + this.y = y2; + return this; + }, + /** + * @param {number} angle + * @param {Point} p + */ + _rotateAround(angle2, p2) { + const cos2 = Math.cos(angle2), sin2 = Math.sin(angle2), x2 = p2.x + cos2 * (this.x - p2.x) - sin2 * (this.y - p2.y), y2 = p2.y + sin2 * (this.x - p2.x) + cos2 * (this.y - p2.y); + this.x = x2; + this.y = y2; + return this; + }, + _round() { + this.x = Math.round(this.x); + this.y = Math.round(this.y); + return this; + }, + constructor: Point + }; + Point.convert = function(p2) { + if (p2 instanceof Point) { + return ( + /** @type {Point} */ + p2 + ); + } + if (Array.isArray(p2)) { + return new Point(+p2[0], +p2[1]); + } + if (p2.x !== void 0 && p2.y !== void 0) { + return new Point(+p2.x, +p2.y); + } + throw new Error("Expected [x, y] or {x, y} point format"); + }; } - throw new Error("Expected [x, y] or {x, y} point format"); - }; + }); // node_modules/@mapbox/vector-tile/index.js - var VectorTileFeature = class { - /** - * @param {Pbf} pbf - * @param {number} end - * @param {number} extent - * @param {string[]} keys - * @param {unknown[]} values - */ - constructor(pbf, end, extent, keys2, values) { - this.properties = {}; - this.extent = extent; - this.type = 0; - this.id = void 0; - this._pbf = pbf; - this._geometry = -1; - this._keys = keys2; - this._values = values; - pbf.readFields(readFeature, this, end); - } - loadGeometry() { - const pbf = this._pbf; - pbf.pos = this._geometry; - const end = pbf.readVarint() + pbf.pos; - const lines = []; - let line; - let cmd = 1; - let length2 = 0; - let x2 = 0; - let y2 = 0; - while (pbf.pos < end) { - if (length2 <= 0) { - const 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 = []; - } - if (line) line.push(new Point(x2, y2)); - } else if (cmd === 7) { - if (line) { - line.push(line[0].clone()); - } - } else { - throw new Error("unknown command ".concat(cmd)); - } - } - if (line) lines.push(line); - return lines; - } - bbox() { - const pbf = this._pbf; - pbf.pos = this._geometry; - const end = pbf.readVarint() + pbf.pos; - let cmd = 1, length2 = 0, x2 = 0, y2 = 0, x12 = Infinity, x22 = -Infinity, y12 = Infinity, y22 = -Infinity; - while (pbf.pos < end) { - if (length2 <= 0) { - const 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 ".concat(cmd)); - } - } - return [x12, y12, x22, y22]; - } - /** - * @param {number} x - * @param {number} y - * @param {number} z - * @return {Feature} - */ - toGeoJSON(x2, y2, z2) { - const size = this.extent * Math.pow(2, z2), x05 = this.extent * x2, y05 = this.extent * y2, vtCoords = this.loadGeometry(); - function projectPoint(p2) { - return [ - (p2.x + x05) * 360 / size - 180, - 360 / Math.PI * Math.atan(Math.exp((1 - (p2.y + y05) * 2 / size) * Math.PI)) - 90 - ]; - } - function projectLine(line) { - return line.map(projectPoint); - } - let geometry; - if (this.type === 1) { - const points = []; - for (const line of vtCoords) { - points.push(line[0]); - } - const coordinates = projectLine(points); - geometry = points.length === 1 ? { type: "Point", coordinates: coordinates[0] } : { type: "MultiPoint", coordinates }; - } else if (this.type === 2) { - const coordinates = vtCoords.map(projectLine); - geometry = coordinates.length === 1 ? { type: "LineString", coordinates: coordinates[0] } : { type: "MultiLineString", coordinates }; - } else if (this.type === 3) { - const polygons = classifyRings(vtCoords); - const coordinates = []; - for (const polygon2 of polygons) { - coordinates.push(polygon2.map(projectLine)); - } - geometry = coordinates.length === 1 ? { type: "Polygon", coordinates: coordinates[0] } : { type: "MultiPolygon", coordinates }; - } else { - throw new Error("unknown feature type"); - } - const result = { - type: "Feature", - geometry, - properties: this.properties - }; - if (this.id != null) { - result.id = this.id; - } - return result; - } - }; - VectorTileFeature.types = ["Unknown", "Point", "LineString", "Polygon"]; function readFeature(tag2, feature3, pbf) { if (tag2 === 1) feature3.id = pbf.readVarint(); else if (tag2 === 2) readTag(pbf, feature3); @@ -41096,33 +41186,6 @@ } return sum; } - var VectorTileLayer = class { - /** - * @param {Pbf} pbf - * @param {number} [end] - */ - constructor(pbf, end) { - this.version = 1; - this.name = ""; - 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; - } - /** return feature `i` from this layer as a `VectorTileFeature` - * @param {number} i - */ - feature(i3) { - if (i3 < 0 || i3 >= this._features.length) throw new Error("feature index out of bounds"); - this._pbf.pos = this._features[i3]; - const end = this._pbf.readVarint() + this._pbf.pos; - return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values); - } - }; function readLayer(tag2, layer, pbf) { if (tag2 === 15) layer.version = pbf.readVarint(); else if (tag2 === 1) layer.name = pbf.readString(); @@ -41140,43 +41203,190 @@ } return value; } - var VectorTile = class { - /** - * @param {Pbf} pbf - * @param {number} [end] - */ - constructor(pbf, end) { - this.layers = pbf.readFields(readTile, {}, end); - } - }; function readTile(tag2, layers, pbf) { if (tag2 === 3) { const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos); if (layer.length) layers[layer.name] = layer; } } + var VectorTileFeature, VectorTileLayer, VectorTile; + var init_vector_tile = __esm({ + "node_modules/@mapbox/vector-tile/index.js"() { + init_point_geometry(); + VectorTileFeature = class { + /** + * @param {Pbf} pbf + * @param {number} end + * @param {number} extent + * @param {string[]} keys + * @param {unknown[]} values + */ + constructor(pbf, end, extent, keys2, values) { + this.properties = {}; + this.extent = extent; + this.type = 0; + this.id = void 0; + this._pbf = pbf; + this._geometry = -1; + this._keys = keys2; + this._values = values; + pbf.readFields(readFeature, this, end); + } + loadGeometry() { + const pbf = this._pbf; + pbf.pos = this._geometry; + const end = pbf.readVarint() + pbf.pos; + const lines = []; + let line; + let cmd = 1; + let length2 = 0; + let x2 = 0; + let y2 = 0; + while (pbf.pos < end) { + if (length2 <= 0) { + const 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 = []; + } + if (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; + } + bbox() { + const pbf = this._pbf; + pbf.pos = this._geometry; + const end = pbf.readVarint() + pbf.pos; + let cmd = 1, length2 = 0, x2 = 0, y2 = 0, x12 = Infinity, x22 = -Infinity, y12 = Infinity, y22 = -Infinity; + while (pbf.pos < end) { + if (length2 <= 0) { + const 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]; + } + /** + * @param {number} x + * @param {number} y + * @param {number} z + * @return {Feature} + */ + toGeoJSON(x2, y2, z2) { + const size = this.extent * Math.pow(2, z2), x05 = this.extent * x2, y05 = this.extent * y2, vtCoords = this.loadGeometry(); + function projectPoint(p2) { + return [ + (p2.x + x05) * 360 / size - 180, + 360 / Math.PI * Math.atan(Math.exp((1 - (p2.y + y05) * 2 / size) * Math.PI)) - 90 + ]; + } + function projectLine(line) { + return line.map(projectPoint); + } + let geometry; + if (this.type === 1) { + const points = []; + for (const line of vtCoords) { + points.push(line[0]); + } + const coordinates = projectLine(points); + geometry = points.length === 1 ? { type: "Point", coordinates: coordinates[0] } : { type: "MultiPoint", coordinates }; + } else if (this.type === 2) { + const coordinates = vtCoords.map(projectLine); + geometry = coordinates.length === 1 ? { type: "LineString", coordinates: coordinates[0] } : { type: "MultiLineString", coordinates }; + } else if (this.type === 3) { + const polygons = classifyRings(vtCoords); + const coordinates = []; + for (const polygon2 of polygons) { + coordinates.push(polygon2.map(projectLine)); + } + geometry = coordinates.length === 1 ? { type: "Polygon", coordinates: coordinates[0] } : { type: "MultiPolygon", coordinates }; + } else { + throw new Error("unknown feature type"); + } + const result = { + type: "Feature", + geometry, + properties: this.properties + }; + if (this.id != null) { + result.id = this.id; + } + return result; + } + }; + VectorTileFeature.types = ["Unknown", "Point", "LineString", "Polygon"]; + VectorTileLayer = class { + /** + * @param {Pbf} pbf + * @param {number} [end] + */ + constructor(pbf, end) { + this.version = 1; + this.name = ""; + 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; + } + /** return feature `i` from this layer as a `VectorTileFeature` + * @param {number} i + */ + feature(i3) { + if (i3 < 0 || i3 >= this._features.length) throw new Error("feature index out of bounds"); + this._pbf.pos = this._features[i3]; + const end = this._pbf.readVarint() + this._pbf.pos; + return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values); + } + }; + VectorTile = class { + /** + * @param {Pbf} pbf + * @param {number} [end] + */ + constructor(pbf, end) { + this.layers = pbf.readFields(readTile, {}, end); + } + }; + } + }); // modules/services/mapillary.js - var accessToken = "MLY|4100327730013843|5bb78b81720791946a9a7b956c57b7cf"; - var apiUrl = "https://graph.mapillary.com/"; - var baseTileUrl = "https://tiles.mapillary.com/maps/vtp"; - var mapFeatureTileUrl = "".concat(baseTileUrl, "/mly_map_feature_point/2/{z}/{x}/{y}?access_token=").concat(accessToken); - var tileUrl = "".concat(baseTileUrl, "/mly1_public/2/{z}/{x}/{y}?access_token=").concat(accessToken); - var trafficSignTileUrl = "".concat(baseTileUrl, "/mly_map_feature_traffic_sign/2/{z}/{x}/{y}?access_token=").concat(accessToken); - var viewercss = "mapillary-js/mapillary.css"; - var viewerjs = "mapillary-js/mapillary.js"; - var minZoom = 14; - var dispatch4 = dispatch_default("change", "loadedImages", "loadedSigns", "loadedMapFeatures", "bearingChanged", "imageChanged"); - var _loadViewerPromise; - var _mlyActiveImage; - var _mlyCache; - var _mlyFallback = false; - var _mlyHighlightedDetection; - var _mlyShowFeatureDetections = false; - var _mlyShowSignDetections = false; - var _mlyViewer; - var _mlyViewerFilter = ["all"]; - var _isViewerOpen = false; + var mapillary_exports = {}; + __export(mapillary_exports, { + default: () => mapillary_default + }); function loadTiles(which, url, maxZoom2, projection2) { const tiler8 = utilTiler().zoomExtent([minZoom, maxZoom2]).skipNullIsland(true); const tiles = tiler8.getTiles(projection2); @@ -41186,7 +41396,7 @@ } function loadTile(which, url, tile) { const cache = _mlyCache.requests; - const tileId = "".concat(tile.id, "-").concat(which); + const tileId = `${tile.id}-${which}`; if (cache.loaded[tileId] || cache.inflight[tileId]) return; const controller = new AbortController(); cache.inflight[tileId] = controller; @@ -41342,400 +41552,433 @@ return found.length ? result.concat(found) : result; }, []); } - var mapillary_default = { - // Initialize Mapillary - init: function() { - if (!_mlyCache) { - this.reset(); - } - this.event = utilRebind(this, dispatch4, "on"); - }, - // Reset cache and state - reset: function() { - if (_mlyCache) { - Object.values(_mlyCache.requests.inflight).forEach(function(request3) { - request3.abort(); - }); - } - _mlyCache = { - images: { rtree: new RBush(), forImageId: {} }, - image_detections: { forImageId: {} }, - signs: { rtree: new RBush() }, - points: { rtree: new RBush() }, - sequences: { rtree: new RBush(), lineString: {} }, - requests: { loaded: {}, inflight: {} } - }; - _mlyActiveImage = null; - }, - // Get visible images - images: function(projection2) { - const limit = 5; - return searchLimited(limit, projection2, _mlyCache.images.rtree); - }, - // Get visible traffic signs - signs: function(projection2) { - const limit = 5; - return searchLimited(limit, projection2, _mlyCache.signs.rtree); - }, - // Get visible map (point) features - mapFeatures: function(projection2) { - const limit = 5; - return searchLimited(limit, projection2, _mlyCache.points.rtree); - }, - // Get cached image by id - cachedImage: function(imageId) { - return _mlyCache.images.forImageId[imageId]; - }, - // Get visible sequences - sequences: function(projection2) { - const viewport = projection2.clipExtent(); - const min3 = [viewport[0][0], viewport[1][1]]; - const max3 = [viewport[1][0], viewport[0][1]]; - const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox(); - const sequenceIds = {}; - let lineStrings = []; - _mlyCache.images.rtree.search(bbox2).forEach(function(d2) { - if (d2.data.sequence_id) { - sequenceIds[d2.data.sequence_id] = true; - } - }); - Object.keys(sequenceIds).forEach(function(sequenceId) { - if (_mlyCache.sequences.lineString[sequenceId]) { - lineStrings = lineStrings.concat(_mlyCache.sequences.lineString[sequenceId]); - } - }); - return lineStrings; - }, - // Load images in the visible area - loadImages: function(projection2) { - loadTiles("images", tileUrl, 14, projection2); - }, - // Load traffic signs in the visible area - loadSigns: function(projection2) { - loadTiles("signs", trafficSignTileUrl, 14, projection2); - }, - // Load map (point) features in the visible area - loadMapFeatures: function(projection2) { - loadTiles("points", mapFeatureTileUrl, 14, projection2); - }, - // Return a promise that resolves when the image viewer (Mapillary JS) library has finished loading - ensureViewerLoaded: function(context) { - if (_loadViewerPromise) return _loadViewerPromise; - const wrap2 = context.container().select(".photoviewer").selectAll(".mly-wrapper").data([0]); - wrap2.enter().append("div").attr("id", "ideditor-mly").attr("class", "photo-wrapper mly-wrapper").classed("hide", true); - const that = this; - _loadViewerPromise = new Promise((resolve, reject) => { - let loadedCount = 0; - function loaded() { - loadedCount += 1; - if (loadedCount === 2) resolve(); - } - const head = select_default2("head"); - head.selectAll("#ideditor-mapillary-viewercss").data([0]).enter().append("link").attr("id", "ideditor-mapillary-viewercss").attr("rel", "stylesheet").attr("crossorigin", "anonymous").attr("href", context.asset(viewercss)).on("load.serviceMapillary", loaded).on("error.serviceMapillary", function() { - reject(); - }); - head.selectAll("#ideditor-mapillary-viewerjs").data([0]).enter().append("script").attr("id", "ideditor-mapillary-viewerjs").attr("crossorigin", "anonymous").attr("src", context.asset(viewerjs)).on("load.serviceMapillary", loaded).on("error.serviceMapillary", function() { - reject(); - }); - }).catch(function() { - _loadViewerPromise = null; - }).then(function() { - that.initViewer(context); - }); - return _loadViewerPromise; - }, - // Load traffic sign image sprites - loadSignResources: function(context) { - context.ui().svgDefs.addSprites( - ["mapillary-sprite"], - false - /* don't override colors */ - ); - return this; - }, - // Load map (point) feature image sprites - loadObjectResources: function(context) { - context.ui().svgDefs.addSprites( - ["mapillary-object-sprite"], - false - /* don't override colors */ - ); - return this; - }, - // Remove previous detections in image viewer - resetTags: function() { - if (_mlyViewer && !_mlyFallback) { - _mlyViewer.getComponent("tag").removeAll(); - } - }, - // Show map feature detections in image viewer - showFeatureDetections: function(value) { - _mlyShowFeatureDetections = value; - if (!_mlyShowFeatureDetections && !_mlyShowSignDetections) { - this.resetTags(); - } - }, - // Show traffic sign detections in image viewer - showSignDetections: function(value) { - _mlyShowSignDetections = value; - if (!_mlyShowFeatureDetections && !_mlyShowSignDetections) { - this.resetTags(); - } - }, - // Apply filter to image viewer - filterViewer: function(context) { - const showsPano = context.photos().showsPanoramic(); - const showsFlat = context.photos().showsFlat(); - const fromDate = context.photos().fromDate(); - const toDate = context.photos().toDate(); - const filter2 = ["all"]; - if (!showsPano) filter2.push(["!=", "cameraType", "spherical"]); - if (!showsFlat && showsPano) filter2.push(["==", "pano", true]); - if (fromDate) { - filter2.push([">=", "capturedAt", new Date(fromDate).getTime()]); - } - if (toDate) { - filter2.push([">=", "capturedAt", new Date(toDate).getTime()]); - } - if (_mlyViewer) { - _mlyViewer.setFilter(filter2); - } - _mlyViewerFilter = filter2; - return filter2; - }, - // Make the image viewer visible - showViewer: function(context) { - const wrap2 = context.container().select(".photoviewer").classed("hide", false); - const isHidden = wrap2.selectAll(".photo-wrapper.mly-wrapper.hide").size(); - if (isHidden && _mlyViewer) { - wrap2.selectAll(".photo-wrapper:not(.mly-wrapper)").classed("hide", true); - wrap2.selectAll(".photo-wrapper.mly-wrapper").classed("hide", false); - _mlyViewer.resize(); - } - _isViewerOpen = true; - return this; - }, - // Hide the image viewer and resets map markers - hideViewer: function(context) { - _mlyActiveImage = null; - if (!_mlyFallback && _mlyViewer) { - _mlyViewer.getComponent("sequence").stop(); - } - const viewer = context.container().select(".photoviewer"); - if (!viewer.empty()) viewer.datum(null); - viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true); - this.updateUrlImage(null); - dispatch4.call("imageChanged"); - dispatch4.call("loadedMapFeatures"); - dispatch4.call("loadedSigns"); + var accessToken, apiUrl, baseTileUrl, mapFeatureTileUrl, tileUrl, trafficSignTileUrl, viewercss, viewerjs, minZoom, dispatch4, _loadViewerPromise, _mlyActiveImage, _mlyCache, _mlyFallback, _mlyHighlightedDetection, _mlyShowFeatureDetections, _mlyShowSignDetections, _mlyViewer, _mlyViewerFilter, _isViewerOpen, mapillary_default; + var init_mapillary = __esm({ + "modules/services/mapillary.js"() { + "use strict"; + init_src4(); + init_src5(); + init_pbf(); + init_rbush(); + init_vector_tile(); + init_geo2(); + init_util(); + accessToken = "MLY|4100327730013843|5bb78b81720791946a9a7b956c57b7cf"; + apiUrl = "https://graph.mapillary.com/"; + baseTileUrl = "https://tiles.mapillary.com/maps/vtp"; + mapFeatureTileUrl = `${baseTileUrl}/mly_map_feature_point/2/{z}/{x}/{y}?access_token=${accessToken}`; + tileUrl = `${baseTileUrl}/mly1_public/2/{z}/{x}/{y}?access_token=${accessToken}`; + trafficSignTileUrl = `${baseTileUrl}/mly_map_feature_traffic_sign/2/{z}/{x}/{y}?access_token=${accessToken}`; + viewercss = "mapillary-js/mapillary.css"; + viewerjs = "mapillary-js/mapillary.js"; + minZoom = 14; + dispatch4 = dispatch_default("change", "loadedImages", "loadedSigns", "loadedMapFeatures", "bearingChanged", "imageChanged"); + _mlyFallback = false; + _mlyShowFeatureDetections = false; + _mlyShowSignDetections = false; + _mlyViewerFilter = ["all"]; _isViewerOpen = false; - return this.setStyles(context, null); - }, - // Get viewer status - isViewerOpen: function() { - return _isViewerOpen; - }, - // Update the URL with current image id - updateUrlImage: function(imageId) { - if (!window.mocha) { - const hash2 = utilStringQs(window.location.hash); - if (imageId) { - hash2.photo = "mapillary/" + imageId; - } else { - delete hash2.photo; - } - window.location.replace("#" + utilQsString(hash2, true)); - } - }, - // Highlight the detection in the viewer that is related to the clicked map feature - highlightDetection: function(detection) { - if (detection) { - _mlyHighlightedDetection = detection.id; - } - return this; - }, - // Initialize image viewer (Mapillar JS) - initViewer: function(context) { - const that = this; - if (!window.mapillary) return; - const opts = { - accessToken, - component: { - cover: false, - keyboard: false, - tag: true - }, - container: "ideditor-mly" - }; - if (!mapillary.isSupported() && mapillary.isFallbackSupported()) { - _mlyFallback = true; - opts.component = { - cover: false, - direction: false, - imagePlane: false, - keyboard: false, - mouse: false, - sequence: false, - tag: false, - image: true, - // fallback - navigation: true - // fallback - }; - } - _mlyViewer = new mapillary.Viewer(opts); - _mlyViewer.on("image", imageChanged); - _mlyViewer.on("bearing", bearingChanged); - if (_mlyViewerFilter) { - _mlyViewer.setFilter(_mlyViewerFilter); - } - context.ui().photoviewer.on("resize.mapillary", function() { - if (_mlyViewer) _mlyViewer.resize(); - }); - function imageChanged(node) { - that.resetTags(); - const image = node.image; - that.setActiveImage(image); - that.setStyles(context, null); - const loc = [image.originalLngLat.lng, image.originalLngLat.lat]; - context.map().centerEase(loc); - that.updateUrlImage(image.id); - if (_mlyShowFeatureDetections || _mlyShowSignDetections) { - that.updateDetections(image.id, "".concat(apiUrl, "/").concat(image.id, "/detections?access_token=").concat(accessToken, "&fields=id,image,geometry,value")); - } - dispatch4.call("imageChanged"); - } - function bearingChanged(e3) { - dispatch4.call("bearingChanged", void 0, e3); - } - }, - // Move to an image - selectImage: function(context, imageId) { - if (_mlyViewer && imageId) { - _mlyViewer.moveTo(imageId).catch(function(e3) { - console.error("mly3", e3); - }); - } - return this; - }, - // Return the currently displayed image - getActiveImage: function() { - return _mlyActiveImage; - }, - // Return a list of detection objects for the given id - getDetections: function(id2) { - return loadData("".concat(apiUrl, "/").concat(id2, "/detections?access_token=").concat(accessToken, "&fields=id,value,image")); - }, - // Set the currently visible image - setActiveImage: function(image) { - if (image) { - _mlyActiveImage = { - ca: image.originalCompassAngle, - id: image.id, - loc: [image.originalLngLat.lng, image.originalLngLat.lat], - is_pano: image.cameraType === "spherical", - sequence_id: image.sequenceId - }; - } else { - _mlyActiveImage = null; - } - }, - // Update the currently highlighted sequence and selected bubble. - setStyles: function(context, hovered) { - const hoveredImageId = hovered && hovered.id; - const hoveredSequenceId = hovered && hovered.sequence_id; - const selectedSequenceId = _mlyActiveImage && _mlyActiveImage.sequence_id; - context.container().selectAll(".layer-mapillary .viewfield-group").classed("highlighted", function(d2) { - return d2.sequence_id === selectedSequenceId || d2.id === hoveredImageId; - }).classed("hovered", function(d2) { - return d2.id === hoveredImageId; - }); - context.container().selectAll(".layer-mapillary .sequence").classed("highlighted", function(d2) { - return d2.properties.id === hoveredSequenceId; - }).classed("currentView", function(d2) { - return d2.properties.id === selectedSequenceId; - }); - return this; - }, - // Get detections for the current image and shows them in the image viewer - updateDetections: function(imageId, url) { - if (!_mlyViewer || _mlyFallback) return; - if (!imageId) return; - const cache = _mlyCache.image_detections; - if (cache.forImageId[imageId]) { - showDetections(_mlyCache.image_detections.forImageId[imageId]); - } else { - loadData(url).then((detections) => { - detections.forEach(function(detection) { - if (!cache.forImageId[imageId]) { - cache.forImageId[imageId] = []; - } - cache.forImageId[imageId].push({ - geometry: detection.geometry, - id: detection.id, - image_id: imageId, - value: detection.value + mapillary_default = { + // Initialize Mapillary + init: function() { + if (!_mlyCache) { + this.reset(); + } + this.event = utilRebind(this, dispatch4, "on"); + }, + // Reset cache and state + reset: function() { + if (_mlyCache) { + Object.values(_mlyCache.requests.inflight).forEach(function(request3) { + request3.abort(); + }); + } + _mlyCache = { + images: { rtree: new RBush(), forImageId: {} }, + image_detections: { forImageId: {} }, + signs: { rtree: new RBush() }, + points: { rtree: new RBush() }, + sequences: { rtree: new RBush(), lineString: {} }, + requests: { loaded: {}, inflight: {} } + }; + _mlyActiveImage = null; + }, + // Get visible images + images: function(projection2) { + const limit = 5; + return searchLimited(limit, projection2, _mlyCache.images.rtree); + }, + // Get visible traffic signs + signs: function(projection2) { + const limit = 5; + return searchLimited(limit, projection2, _mlyCache.signs.rtree); + }, + // Get visible map (point) features + mapFeatures: function(projection2) { + const limit = 5; + return searchLimited(limit, projection2, _mlyCache.points.rtree); + }, + // Get cached image by id + cachedImage: function(imageId) { + return _mlyCache.images.forImageId[imageId]; + }, + // Get visible sequences + sequences: function(projection2) { + const viewport = projection2.clipExtent(); + const min3 = [viewport[0][0], viewport[1][1]]; + const max3 = [viewport[1][0], viewport[0][1]]; + const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox(); + const sequenceIds = {}; + let lineStrings = []; + _mlyCache.images.rtree.search(bbox2).forEach(function(d2) { + if (d2.data.sequence_id) { + sequenceIds[d2.data.sequence_id] = true; + } + }); + Object.keys(sequenceIds).forEach(function(sequenceId) { + if (_mlyCache.sequences.lineString[sequenceId]) { + lineStrings = lineStrings.concat(_mlyCache.sequences.lineString[sequenceId]); + } + }); + return lineStrings; + }, + // Load images in the visible area + loadImages: function(projection2) { + loadTiles("images", tileUrl, 14, projection2); + }, + // Load traffic signs in the visible area + loadSigns: function(projection2) { + loadTiles("signs", trafficSignTileUrl, 14, projection2); + }, + // Load map (point) features in the visible area + loadMapFeatures: function(projection2) { + loadTiles("points", mapFeatureTileUrl, 14, projection2); + }, + // Return a promise that resolves when the image viewer (Mapillary JS) library has finished loading + ensureViewerLoaded: function(context) { + if (_loadViewerPromise) return _loadViewerPromise; + const wrap2 = context.container().select(".photoviewer").selectAll(".mly-wrapper").data([0]); + wrap2.enter().append("div").attr("id", "ideditor-mly").attr("class", "photo-wrapper mly-wrapper").classed("hide", true); + const that = this; + _loadViewerPromise = new Promise((resolve, reject) => { + let loadedCount = 0; + function loaded() { + loadedCount += 1; + if (loadedCount === 2) resolve(); + } + const head = select_default2("head"); + head.selectAll("#ideditor-mapillary-viewercss").data([0]).enter().append("link").attr("id", "ideditor-mapillary-viewercss").attr("rel", "stylesheet").attr("crossorigin", "anonymous").attr("href", context.asset(viewercss)).on("load.serviceMapillary", loaded).on("error.serviceMapillary", function() { + reject(); }); + head.selectAll("#ideditor-mapillary-viewerjs").data([0]).enter().append("script").attr("id", "ideditor-mapillary-viewerjs").attr("crossorigin", "anonymous").attr("src", context.asset(viewerjs)).on("load.serviceMapillary", loaded).on("error.serviceMapillary", function() { + reject(); + }); + }).catch(function() { + _loadViewerPromise = null; + }).then(function() { + that.initViewer(context); }); - showDetections(_mlyCache.image_detections.forImageId[imageId] || []); - }); - } - function showDetections(detections) { - const tagComponent = _mlyViewer.getComponent("tag"); - detections.forEach(function(data) { - const tag2 = makeTag(data); - if (tag2) { - tagComponent.add([tag2]); + return _loadViewerPromise; + }, + // Load traffic sign image sprites + loadSignResources: function(context) { + context.ui().svgDefs.addSprites( + ["mapillary-sprite"], + false + /* don't override colors */ + ); + return this; + }, + // Load map (point) feature image sprites + loadObjectResources: function(context) { + context.ui().svgDefs.addSprites( + ["mapillary-object-sprite"], + false + /* don't override colors */ + ); + return this; + }, + // Remove previous detections in image viewer + resetTags: function() { + if (_mlyViewer && !_mlyFallback) { + _mlyViewer.getComponent("tag").removeAll(); + } + }, + // Show map feature detections in image viewer + showFeatureDetections: function(value) { + _mlyShowFeatureDetections = value; + if (!_mlyShowFeatureDetections && !_mlyShowSignDetections) { + this.resetTags(); + } + }, + // Show traffic sign detections in image viewer + showSignDetections: function(value) { + _mlyShowSignDetections = value; + if (!_mlyShowFeatureDetections && !_mlyShowSignDetections) { + this.resetTags(); + } + }, + // Apply filter to image viewer + filterViewer: function(context) { + const showsPano = context.photos().showsPanoramic(); + const showsFlat = context.photos().showsFlat(); + const fromDate = context.photos().fromDate(); + const toDate = context.photos().toDate(); + const filter2 = ["all"]; + if (!showsPano) filter2.push(["!=", "cameraType", "spherical"]); + if (!showsFlat && showsPano) filter2.push(["==", "pano", true]); + if (fromDate) { + filter2.push([">=", "capturedAt", new Date(fromDate).getTime()]); + } + if (toDate) { + filter2.push([">=", "capturedAt", new Date(toDate).getTime()]); + } + if (_mlyViewer) { + _mlyViewer.setFilter(filter2); + } + _mlyViewerFilter = filter2; + return filter2; + }, + // Make the image viewer visible + showViewer: function(context) { + const wrap2 = context.container().select(".photoviewer").classed("hide", false); + const isHidden = wrap2.selectAll(".photo-wrapper.mly-wrapper.hide").size(); + if (isHidden && _mlyViewer) { + wrap2.selectAll(".photo-wrapper:not(.mly-wrapper)").classed("hide", true); + wrap2.selectAll(".photo-wrapper.mly-wrapper").classed("hide", false); + _mlyViewer.resize(); + } + _isViewerOpen = true; + return this; + }, + // Hide the image viewer and resets map markers + hideViewer: function(context) { + _mlyActiveImage = null; + if (!_mlyFallback && _mlyViewer) { + _mlyViewer.getComponent("sequence").stop(); + } + const viewer = context.container().select(".photoviewer"); + if (!viewer.empty()) viewer.datum(null); + viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true); + this.updateUrlImage(null); + dispatch4.call("imageChanged"); + dispatch4.call("loadedMapFeatures"); + dispatch4.call("loadedSigns"); + _isViewerOpen = false; + return this.setStyles(context, null); + }, + // Get viewer status + isViewerOpen: function() { + return _isViewerOpen; + }, + // Update the URL with current image id + updateUrlImage: function(imageId) { + if (!window.mocha) { + const hash2 = utilStringQs(window.location.hash); + if (imageId) { + hash2.photo = "mapillary/" + imageId; + } else { + delete hash2.photo; + } + window.location.replace("#" + utilQsString(hash2, true)); } - }); - } - function makeTag(data) { - const valueParts = data.value.split("--"); - if (!valueParts.length) return; - let tag2; - let text; - let color2 = 16777215; - if (_mlyHighlightedDetection === data.id) { - color2 = 16776960; - text = valueParts[1]; - if (text === "flat" || text === "discrete" || text === "sign") { - text = valueParts[2]; - } - text = text.replace(/-/g, " "); - text = text.charAt(0).toUpperCase() + text.slice(1); - _mlyHighlightedDetection = null; - } - var decodedGeometry = window.atob(data.geometry); - var uintArray = new Uint8Array(decodedGeometry.length); - for (var i3 = 0; i3 < decodedGeometry.length; i3++) { - uintArray[i3] = decodedGeometry.charCodeAt(i3); - } - const tile = new VectorTile(new Pbf(uintArray.buffer)); - const layer = tile.layers["mpy-or"]; - const geometries = layer.feature(0).loadGeometry(); - const polygon2 = geometries.map((ring) => ring.map((point) => [point.x / layer.extent, point.y / layer.extent])); - tag2 = new mapillary.OutlineTag( - data.id, - new mapillary.PolygonGeometry(polygon2[0]), - { - text, - textColor: color2, - lineColor: color2, - lineWidth: 2, - fillColor: color2, - fillOpacity: 0.3 + }, + // Highlight the detection in the viewer that is related to the clicked map feature + highlightDetection: function(detection) { + if (detection) { + _mlyHighlightedDetection = detection.id; } - ); - return tag2; - } - }, - // Return the current cache - cache: function() { - return _mlyCache; + return this; + }, + // Initialize image viewer (Mapillar JS) + initViewer: function(context) { + const that = this; + if (!window.mapillary) return; + const opts = { + accessToken, + component: { + cover: false, + keyboard: false, + tag: true + }, + container: "ideditor-mly" + }; + if (!mapillary.isSupported() && mapillary.isFallbackSupported()) { + _mlyFallback = true; + opts.component = { + cover: false, + direction: false, + imagePlane: false, + keyboard: false, + mouse: false, + sequence: false, + tag: false, + image: true, + // fallback + navigation: true + // fallback + }; + } + _mlyViewer = new mapillary.Viewer(opts); + _mlyViewer.on("image", imageChanged); + _mlyViewer.on("bearing", bearingChanged); + if (_mlyViewerFilter) { + _mlyViewer.setFilter(_mlyViewerFilter); + } + context.ui().photoviewer.on("resize.mapillary", function() { + if (_mlyViewer) _mlyViewer.resize(); + }); + function imageChanged(node) { + that.resetTags(); + const image = node.image; + that.setActiveImage(image); + that.setStyles(context, null); + const loc = [image.originalLngLat.lng, image.originalLngLat.lat]; + context.map().centerEase(loc); + that.updateUrlImage(image.id); + if (_mlyShowFeatureDetections || _mlyShowSignDetections) { + that.updateDetections(image.id, `${apiUrl}/${image.id}/detections?access_token=${accessToken}&fields=id,image,geometry,value`); + } + dispatch4.call("imageChanged"); + } + function bearingChanged(e3) { + dispatch4.call("bearingChanged", void 0, e3); + } + }, + // Move to an image + selectImage: function(context, imageId) { + if (_mlyViewer && imageId) { + _mlyViewer.moveTo(imageId).catch(function(e3) { + console.error("mly3", e3); + }); + } + return this; + }, + // Return the currently displayed image + getActiveImage: function() { + return _mlyActiveImage; + }, + // Return a list of detection objects for the given id + getDetections: function(id2) { + return loadData(`${apiUrl}/${id2}/detections?access_token=${accessToken}&fields=id,value,image`); + }, + // Set the currently visible image + setActiveImage: function(image) { + if (image) { + _mlyActiveImage = { + ca: image.originalCompassAngle, + id: image.id, + loc: [image.originalLngLat.lng, image.originalLngLat.lat], + is_pano: image.cameraType === "spherical", + sequence_id: image.sequenceId + }; + } else { + _mlyActiveImage = null; + } + }, + // Update the currently highlighted sequence and selected bubble. + setStyles: function(context, hovered) { + const hoveredImageId = hovered && hovered.id; + const hoveredSequenceId = hovered && hovered.sequence_id; + const selectedSequenceId = _mlyActiveImage && _mlyActiveImage.sequence_id; + context.container().selectAll(".layer-mapillary .viewfield-group").classed("highlighted", function(d2) { + return d2.sequence_id === selectedSequenceId || d2.id === hoveredImageId; + }).classed("hovered", function(d2) { + return d2.id === hoveredImageId; + }); + context.container().selectAll(".layer-mapillary .sequence").classed("highlighted", function(d2) { + return d2.properties.id === hoveredSequenceId; + }).classed("currentView", function(d2) { + return d2.properties.id === selectedSequenceId; + }); + return this; + }, + // Get detections for the current image and shows them in the image viewer + updateDetections: function(imageId, url) { + if (!_mlyViewer || _mlyFallback) return; + if (!imageId) return; + const cache = _mlyCache.image_detections; + if (cache.forImageId[imageId]) { + showDetections(_mlyCache.image_detections.forImageId[imageId]); + } else { + loadData(url).then((detections) => { + detections.forEach(function(detection) { + if (!cache.forImageId[imageId]) { + cache.forImageId[imageId] = []; + } + cache.forImageId[imageId].push({ + geometry: detection.geometry, + id: detection.id, + image_id: imageId, + value: detection.value + }); + }); + showDetections(_mlyCache.image_detections.forImageId[imageId] || []); + }); + } + function showDetections(detections) { + const tagComponent = _mlyViewer.getComponent("tag"); + detections.forEach(function(data) { + const tag2 = makeTag(data); + if (tag2) { + tagComponent.add([tag2]); + } + }); + } + function makeTag(data) { + const valueParts = data.value.split("--"); + if (!valueParts.length) return; + let tag2; + let text; + let color2 = 16777215; + if (_mlyHighlightedDetection === data.id) { + color2 = 16776960; + text = valueParts[1]; + if (text === "flat" || text === "discrete" || text === "sign") { + text = valueParts[2]; + } + text = text.replace(/-/g, " "); + text = text.charAt(0).toUpperCase() + text.slice(1); + _mlyHighlightedDetection = null; + } + var decodedGeometry = window.atob(data.geometry); + var uintArray = new Uint8Array(decodedGeometry.length); + for (var i3 = 0; i3 < decodedGeometry.length; i3++) { + uintArray[i3] = decodedGeometry.charCodeAt(i3); + } + const tile = new VectorTile(new Pbf(uintArray.buffer)); + const layer = tile.layers["mpy-or"]; + const geometries = layer.feature(0).loadGeometry(); + const polygon2 = geometries.map((ring) => ring.map((point) => [point.x / layer.extent, point.y / layer.extent])); + tag2 = new mapillary.OutlineTag( + data.id, + new mapillary.PolygonGeometry(polygon2[0]), + { + text, + textColor: color2, + lineColor: color2, + lineWidth: 2, + fillColor: color2, + fillOpacity: 0.3 + } + ); + return tag2; + } + }, + // Return the current cache + cache: function() { + return _mlyCache; + } + }; } - }; + }); // modules/core/validation/models.js + var models_exports = {}; + __export(models_exports, { + validationIssue: () => validationIssue, + validationIssueFix: () => validationIssueFix + }); function validationIssue(attrs) { this.type = attrs.type; this.subtype = attrs.subtype; @@ -41809,224 +42052,260 @@ this.autoArgs = attrs.autoArgs; this.issue = null; } + var init_models = __esm({ + "modules/core/validation/models.js"() { + "use strict"; + init_geo2(); + init_localizer(); + } + }); + + // modules/core/validation/index.js + var validation_exports = {}; + __export(validation_exports, { + validationIssue: () => validationIssue, + validationIssueFix: () => validationIssueFix + }); + var init_validation = __esm({ + "modules/core/validation/index.js"() { + "use strict"; + init_models(); + } + }); // modules/services/maprules.js - var buildRuleChecks = function() { - return { - equals: function(equals) { - return function(tags) { - return Object.keys(equals).every(function(k2) { - return equals[k2] === tags[k2]; - }); - }; - }, - notEquals: function(notEquals) { - return function(tags) { - return Object.keys(notEquals).some(function(k2) { - return notEquals[k2] !== tags[k2]; - }); - }; - }, - absence: function(absence) { - return function(tags) { - return Object.keys(tags).indexOf(absence) === -1; - }; - }, - presence: function(presence) { - return function(tags) { - return Object.keys(tags).indexOf(presence) > -1; - }; - }, - greaterThan: function(greaterThan) { - var key = Object.keys(greaterThan)[0]; - var value = greaterThan[key]; - return function(tags) { - return tags[key] > value; - }; - }, - greaterThanEqual: function(greaterThanEqual) { - var key = Object.keys(greaterThanEqual)[0]; - var value = greaterThanEqual[key]; - return function(tags) { - return tags[key] >= value; - }; - }, - lessThan: function(lessThan) { - var key = Object.keys(lessThan)[0]; - var value = lessThan[key]; - return function(tags) { - return tags[key] < value; - }; - }, - lessThanEqual: function(lessThanEqual) { - var key = Object.keys(lessThanEqual)[0]; - var value = lessThanEqual[key]; - return function(tags) { - return tags[key] <= value; - }; - }, - positiveRegex: function(positiveRegex) { - var tagKey = Object.keys(positiveRegex)[0]; - var expression = positiveRegex[tagKey].join("|"); - var regex = new RegExp(expression); - return function(tags) { - return regex.test(tags[tagKey]); - }; - }, - negativeRegex: function(negativeRegex) { - var tagKey = Object.keys(negativeRegex)[0]; - var expression = negativeRegex[tagKey].join("|"); - var regex = new RegExp(expression); - return function(tags) { - return !regex.test(tags[tagKey]); + var maprules_exports = {}; + __export(maprules_exports, { + default: () => maprules_default + }); + var buildRuleChecks, buildLineKeys, maprules_default; + var init_maprules = __esm({ + "modules/services/maprules.js"() { + "use strict"; + init_tags(); + init_util(); + init_validation(); + buildRuleChecks = function() { + return { + equals: function(equals) { + return function(tags) { + return Object.keys(equals).every(function(k2) { + return equals[k2] === tags[k2]; + }); + }; + }, + notEquals: function(notEquals) { + return function(tags) { + return Object.keys(notEquals).some(function(k2) { + return notEquals[k2] !== tags[k2]; + }); + }; + }, + absence: function(absence) { + return function(tags) { + return Object.keys(tags).indexOf(absence) === -1; + }; + }, + presence: function(presence) { + return function(tags) { + return Object.keys(tags).indexOf(presence) > -1; + }; + }, + greaterThan: function(greaterThan) { + var key = Object.keys(greaterThan)[0]; + var value = greaterThan[key]; + return function(tags) { + return tags[key] > value; + }; + }, + greaterThanEqual: function(greaterThanEqual) { + var key = Object.keys(greaterThanEqual)[0]; + var value = greaterThanEqual[key]; + return function(tags) { + return tags[key] >= value; + }; + }, + lessThan: function(lessThan) { + var key = Object.keys(lessThan)[0]; + var value = lessThan[key]; + return function(tags) { + return tags[key] < value; + }; + }, + lessThanEqual: function(lessThanEqual) { + var key = Object.keys(lessThanEqual)[0]; + var value = lessThanEqual[key]; + return function(tags) { + return tags[key] <= value; + }; + }, + positiveRegex: function(positiveRegex) { + var tagKey = Object.keys(positiveRegex)[0]; + var expression = positiveRegex[tagKey].join("|"); + var regex = new RegExp(expression); + return function(tags) { + return regex.test(tags[tagKey]); + }; + }, + negativeRegex: function(negativeRegex) { + var tagKey = Object.keys(negativeRegex)[0]; + var expression = negativeRegex[tagKey].join("|"); + var regex = new RegExp(expression); + return function(tags) { + return !regex.test(tags[tagKey]); + }; + } }; - } - }; - }; - var buildLineKeys = function() { - return { - highway: { - rest_area: true, - services: true - }, - railway: { - roundhouse: true, - station: true, - traverser: true, - turntable: true, - wash: true - } - }; - }; - var maprules_default = { - init: function() { - this._ruleChecks = buildRuleChecks(); - this._validationRules = []; - this._areaKeys = osmAreaKeys; - this._lineKeys = buildLineKeys(); - }, - // list of rules only relevant to tag checks... - filterRuleChecks: function(selector) { - var _ruleChecks = this._ruleChecks; - return Object.keys(selector).reduce(function(rules, key) { - if (["geometry", "error", "warning"].indexOf(key) === -1) { - rules.push(_ruleChecks[key](selector[key])); - } - return rules; - }, []); - }, - // builds tagMap from mapcss-parse selector object... - buildTagMap: function(selector) { - var getRegexValues = function(regexes) { - return regexes.map(function(regex) { - return regex.replace(/\$|\^/g, ""); - }); }; - var tagMap = Object.keys(selector).reduce(function(expectedTags, key) { - var values; - var isRegex = /regex/gi.test(key); - var isEqual5 = /equals/gi.test(key); - if (isRegex || isEqual5) { - Object.keys(selector[key]).forEach(function(selectorKey) { - values = isEqual5 ? [selector[key][selectorKey]] : getRegexValues(selector[key][selectorKey]); - if (expectedTags.hasOwnProperty(selectorKey)) { - values = values.concat(expectedTags[selectorKey]); - } - expectedTags[selectorKey] = values; - }); - } else if (/(greater|less)Than(Equal)?|presence/g.test(key)) { - var tagKey = /presence/.test(key) ? selector[key] : Object.keys(selector[key])[0]; - values = [selector[key][tagKey]]; - if (expectedTags.hasOwnProperty(tagKey)) { - values = values.concat(expectedTags[tagKey]); + buildLineKeys = function() { + return { + highway: { + rest_area: true, + services: true + }, + railway: { + roundhouse: true, + station: true, + traverser: true, + turntable: true, + wash: true } - expectedTags[tagKey] = values; - } - return expectedTags; - }, {}); - return tagMap; - }, - // inspired by osmWay#isArea() - inferGeometry: function(tagMap) { - var _lineKeys = this._lineKeys; - var _areaKeys = this._areaKeys; - var keyValueDoesNotImplyArea = function(key2) { - return utilArrayIntersection(tagMap[key2], Object.keys(_areaKeys[key2])).length > 0; - }; - var keyValueImpliesLine = function(key2) { - return utilArrayIntersection(tagMap[key2], Object.keys(_lineKeys[key2])).length > 0; + }; }; - if (tagMap.hasOwnProperty("area")) { - if (tagMap.area.indexOf("yes") > -1) { - return "area"; - } - if (tagMap.area.indexOf("no") > -1) { + maprules_default = { + init: function() { + this._ruleChecks = buildRuleChecks(); + this._validationRules = []; + this._areaKeys = osmAreaKeys; + this._lineKeys = buildLineKeys(); + }, + // list of rules only relevant to tag checks... + filterRuleChecks: function(selector) { + var _ruleChecks = this._ruleChecks; + return Object.keys(selector).reduce(function(rules, key) { + if (["geometry", "error", "warning"].indexOf(key) === -1) { + rules.push(_ruleChecks[key](selector[key])); + } + return rules; + }, []); + }, + // builds tagMap from mapcss-parse selector object... + buildTagMap: function(selector) { + var getRegexValues = function(regexes) { + return regexes.map(function(regex) { + return regex.replace(/\$|\^/g, ""); + }); + }; + var tagMap = Object.keys(selector).reduce(function(expectedTags, key) { + var values; + var isRegex = /regex/gi.test(key); + var isEqual5 = /equals/gi.test(key); + if (isRegex || isEqual5) { + Object.keys(selector[key]).forEach(function(selectorKey) { + values = isEqual5 ? [selector[key][selectorKey]] : getRegexValues(selector[key][selectorKey]); + if (expectedTags.hasOwnProperty(selectorKey)) { + values = values.concat(expectedTags[selectorKey]); + } + expectedTags[selectorKey] = values; + }); + } else if (/(greater|less)Than(Equal)?|presence/g.test(key)) { + var tagKey = /presence/.test(key) ? selector[key] : Object.keys(selector[key])[0]; + values = [selector[key][tagKey]]; + if (expectedTags.hasOwnProperty(tagKey)) { + values = values.concat(expectedTags[tagKey]); + } + expectedTags[tagKey] = values; + } + return expectedTags; + }, {}); + return tagMap; + }, + // inspired by osmWay#isArea() + inferGeometry: function(tagMap) { + var _lineKeys = this._lineKeys; + var _areaKeys = this._areaKeys; + var keyValueDoesNotImplyArea = function(key2) { + return utilArrayIntersection(tagMap[key2], Object.keys(_areaKeys[key2])).length > 0; + }; + var keyValueImpliesLine = function(key2) { + return utilArrayIntersection(tagMap[key2], Object.keys(_lineKeys[key2])).length > 0; + }; + if (tagMap.hasOwnProperty("area")) { + if (tagMap.area.indexOf("yes") > -1) { + return "area"; + } + if (tagMap.area.indexOf("no") > -1) { + return "line"; + } + } + for (var key in tagMap) { + if (key in _areaKeys && !keyValueDoesNotImplyArea(key)) { + return "area"; + } + if (key in _lineKeys && keyValueImpliesLine(key)) { + return "area"; + } + } return "line"; - } - } - for (var key in tagMap) { - if (key in _areaKeys && !keyValueDoesNotImplyArea(key)) { - return "area"; - } - if (key in _lineKeys && keyValueImpliesLine(key)) { - return "area"; - } - } - return "line"; - }, - // adds from mapcss-parse selector check... - addRule: function(selector) { - var rule = { - // checks relevant to mapcss-selector - checks: this.filterRuleChecks(selector), - // true if all conditions for a tag error are true.. - matches: function(entity) { - return this.checks.every(function(check) { - return check(entity.tags); - }); }, - // borrowed from Way#isArea() - inferredGeometry: this.inferGeometry(this.buildTagMap(selector), this._areaKeys), - geometryMatches: function(entity, graph) { - if (entity.type === "node" || entity.type === "relation") { - return selector.geometry === entity.type; - } else if (entity.type === "way") { - return this.inferredGeometry === entity.geometry(graph); - } + // adds from mapcss-parse selector check... + addRule: function(selector) { + var rule = { + // checks relevant to mapcss-selector + checks: this.filterRuleChecks(selector), + // true if all conditions for a tag error are true.. + matches: function(entity) { + return this.checks.every(function(check) { + return check(entity.tags); + }); + }, + // borrowed from Way#isArea() + inferredGeometry: this.inferGeometry(this.buildTagMap(selector), this._areaKeys), + geometryMatches: function(entity, graph) { + if (entity.type === "node" || entity.type === "relation") { + return selector.geometry === entity.type; + } else if (entity.type === "way") { + return this.inferredGeometry === entity.geometry(graph); + } + }, + // when geometries match and tag matches are present, return a warning... + findIssues: function(entity, graph, issues) { + if (this.geometryMatches(entity, graph) && this.matches(entity)) { + var severity = Object.keys(selector).indexOf("error") > -1 ? "error" : "warning"; + var message = selector[severity]; + issues.push(new validationIssue({ + type: "maprules", + severity, + message: function() { + return message; + }, + entityIds: [entity.id] + })); + } + } + }; + this._validationRules.push(rule); }, - // when geometries match and tag matches are present, return a warning... - findIssues: function(entity, graph, issues) { - if (this.geometryMatches(entity, graph) && this.matches(entity)) { - var severity = Object.keys(selector).indexOf("error") > -1 ? "error" : "warning"; - var message = selector[severity]; - issues.push(new validationIssue({ - type: "maprules", - severity, - message: function() { - return message; - }, - entityIds: [entity.id] - })); - } + clearRules: function() { + this._validationRules = []; + }, + // returns validationRules... + validationRules: function() { + return this._validationRules; + }, + // returns ruleChecks + ruleChecks: function() { + return this._ruleChecks; } }; - this._validationRules.push(rule); - }, - clearRules: function() { - this._validationRules = []; - }, - // returns validationRules... - validationRules: function() { - return this._validationRules; - }, - // returns ruleChecks - ruleChecks: function() { - return this._ruleChecks; } - }; + }); // modules/core/difference.js - var import_fast_deep_equal3 = __toESM(require_fast_deep_equal()); + var difference_exports = {}; + __export(difference_exports, { + coreDifference: () => coreDifference + }); function coreDifference(base, head) { var _changes = {}; var _didChange = {}; @@ -42231,8 +42510,21 @@ }; return _diff; } + var import_fast_deep_equal3; + var init_difference = __esm({ + "modules/core/difference.js"() { + "use strict"; + import_fast_deep_equal3 = __toESM(require_fast_deep_equal()); + init_geo2(); + init_array3(); + } + }); // modules/core/tree.js + var tree_exports = {}; + __export(tree_exports, { + coreTree: () => coreTree + }); function coreTree(head) { var _rtree = new RBush(); var _bboxes = {}; @@ -42353,15 +42645,35 @@ }; return tree; } + var init_tree = __esm({ + "modules/core/tree.js"() { + "use strict"; + init_rbush(); + init_difference(); + } + }); // modules/svg/icon.js + var icon_exports = {}; + __export(icon_exports, { + svgIcon: () => svgIcon + }); function svgIcon(name, svgklass, useklass) { return function drawIcon(selection2) { selection2.selectAll("svg.icon" + (svgklass ? "." + svgklass.split(" ")[0] : "")).data([0]).enter().append("svg").attr("class", "icon " + (svgklass || "")).append("use").attr("xlink:href", name).attr("class", useklass); }; } + var init_icon = __esm({ + "modules/svg/icon.js"() { + "use strict"; + } + }); // modules/ui/modal.js + var modal_exports = {}; + __export(modal_exports, { + uiModal: () => uiModal + }); function uiModal(selection2, blocking) { let keybinding = utilKeybinding("modal"); let previous = selection2.select("div.modal"); @@ -42410,8 +42722,21 @@ } } } + var init_modal = __esm({ + "modules/ui/modal.js"() { + "use strict"; + init_src5(); + init_localizer(); + init_icon(); + init_util(); + } + }); // modules/ui/loading.js + var loading_exports = {}; + __export(loading_exports, { + uiLoading: () => uiLoading + }); function uiLoading(context) { let _modalSelection = select_default2(null); let _message = ""; @@ -42442,8 +42767,19 @@ }; return loading; } + var init_loading = __esm({ + "modules/ui/loading.js"() { + "use strict"; + init_src5(); + init_modal(); + } + }); // modules/core/history.js + var history_exports = {}; + __export(history_exports, { + coreHistory: () => coreHistory + }); function coreHistory(context) { var dispatch14 = dispatch_default("reset", "change", "merge", "restore", "undone", "redone", "storage_error"); var lock = utilSessionMutex("lock"); @@ -42981,31 +43317,27 @@ history.reset(); return utilRebind(history, dispatch14, "on"); } - - // modules/validations/index.js - var validations_exports = {}; - __export(validations_exports, { - validationAlmostJunction: () => validationAlmostJunction, - validationCloseNodes: () => validationCloseNodes, - validationCrossingWays: () => validationCrossingWays, - validationDisconnectedWay: () => validationDisconnectedWay, - validationFormatting: () => validationFormatting, - validationHelpRequest: () => validationHelpRequest, - validationImpossibleOneway: () => validationImpossibleOneway, - validationIncompatibleSource: () => validationIncompatibleSource, - validationMaprules: () => validationMaprules, - validationMismatchedGeometry: () => validationMismatchedGeometry, - validationMissingRole: () => validationMissingRole, - validationMissingTag: () => validationMissingTag, - validationMutuallyExclusiveTags: () => validationMutuallyExclusiveTags, - validationOsmApiLimits: () => validationOsmApiLimits, - validationOutdatedTags: () => validationOutdatedTags, - validationPrivateData: () => validationPrivateData, - validationSuspiciousName: () => validationSuspiciousName, - validationUnsquareWay: () => validationUnsquareWay + var init_history = __esm({ + "modules/core/history.js"() { + "use strict"; + init_src4(); + init_src10(); + init_src5(); + init_preferences(); + init_difference(); + init_graph(); + init_tree(); + init_entity(); + init_loading(); + init_util(); + } }); // modules/util/utilDisplayLabel.js + var utilDisplayLabel_exports = {}; + __export(utilDisplayLabel_exports, { + utilDisplayLabel: () => utilDisplayLabel + }); function utilDisplayLabel(entity, graphOrGeometry, verbose) { var result; var displayName = utilDisplayName(entity); @@ -43018,8 +43350,19 @@ } return result || utilDisplayType(entity.id); } + var init_utilDisplayLabel = __esm({ + "modules/util/utilDisplayLabel.js"() { + "use strict"; + init_presets(); + init_util2(); + } + }); // modules/validations/almost_junction.js + var almost_junction_exports = {}; + __export(almost_junction_exports, { + validationAlmostJunction: () => validationAlmostJunction + }); function validationAlmostJunction(context) { const type2 = "almost_junction"; const EXTEND_TH_METERS = 5; @@ -43248,8 +43591,26 @@ validation.type = type2; return validation; } + var init_almost_junction = __esm({ + "modules/validations/almost_junction.js"() { + "use strict"; + init_geo2(); + init_add_midpoint(); + init_change_tags(); + init_merge_nodes(); + init_localizer(); + init_utilDisplayLabel(); + init_tags(); + init_validation(); + init_services(); + } + }); // modules/validations/close_nodes.js + var close_nodes_exports = {}; + __export(close_nodes_exports, { + validationCloseNodes: () => validationCloseNodes + }); function validationCloseNodes(context) { var type2 = "close_nodes"; var pointThresholdMeters = 0.2; @@ -43454,9 +43815,24 @@ validation.type = type2; return validation; } + var init_close_nodes = __esm({ + "modules/validations/close_nodes.js"() { + "use strict"; + init_merge_nodes(); + init_utilDisplayLabel(); + init_localizer(); + init_validation(); + init_tags(); + init_geo(); + init_extent(); + } + }); // modules/validations/crossing_ways.js - var import_lodash3 = __toESM(require_lodash()); + var crossing_ways_exports = {}; + __export(crossing_ways_exports, { + validationCrossingWays: () => validationCrossingWays + }); function validationCrossingWays(context) { var type2 = "crossing_ways"; function getFeatureWithFeatureTypeTagsForWay(way, graph) { @@ -44051,8 +44427,30 @@ validation.type = type2; return validation; } + var import_lodash3; + var init_crossing_ways = __esm({ + "modules/validations/crossing_ways.js"() { + "use strict"; + import_lodash3 = __toESM(require_lodash()); + init_add_midpoint(); + init_change_tags(); + init_merge_nodes(); + init_split(); + init_select5(); + init_geo2(); + init_node2(); + init_tags(); + init_localizer(); + init_utilDisplayLabel(); + init_validation(); + } + }); // modules/behavior/draw_way.js + var draw_way_exports = {}; + __export(draw_way_exports, { + behaviorDrawWay: () => behaviorDrawWay + }); function behaviorDrawWay(context, wayID, mode, startGraph) { const keybinding = utilKeybinding("drawWay"); var dispatch14 = dispatch_default("rejectedSelfIntersection"); @@ -44298,11 +44696,11 @@ const secondLastNodesParents = historyGraph.parentWays(historyGraph.entity(secondLastNodeId)).filter((w2) => w2.id !== wayID); const featureType = getFeatureType(lastNodesParents); if (lastNodesParents.length !== 1 || secondLastNodesParents.length === 0) { - context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.intersection_of_multiple_ways.".concat(featureType)))(); + context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append(`operations.follow.error.intersection_of_multiple_ways.${featureType}`))(); return; } if (!secondLastNodesParents.some((n3) => n3.id === lastNodesParents[0].id)) { - context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.intersection_of_different_ways.".concat(featureType)))(); + context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append(`operations.follow.error.intersection_of_different_ways.${featureType}`))(); return; } const way = lastNodesParents[0]; @@ -44317,7 +44715,7 @@ id: nextNode.id, properties: { target: true, entity: nextNode } }); - } catch (e3) { + } catch { context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.unknown"))(); } } @@ -44368,8 +44766,31 @@ }; return utilRebind(drawWay, dispatch14, "on"); } + var init_draw_way = __esm({ + "modules/behavior/draw_way.js"() { + "use strict"; + init_src4(); + init_src5(); + init_presets(); + init_localizer(); + init_add_midpoint(); + init_move_node(); + init_noop2(); + init_draw(); + init_geo2(); + init_browse(); + init_select5(); + init_node2(); + init_rebind(); + init_util(); + } + }); // modules/modes/draw_line.js + var draw_line_exports = {}; + __export(draw_line_exports, { + modeDrawLine: () => modeDrawLine + }); function modeDrawLine(context, wayID, startGraph, button, affix, continuing) { var mode = { button, @@ -44395,8 +44816,19 @@ }; return mode; } + var init_draw_line = __esm({ + "modules/modes/draw_line.js"() { + "use strict"; + init_localizer(); + init_draw_way(); + } + }); // modules/validations/disconnected_way.js + var disconnected_way_exports = {}; + __export(disconnected_way_exports, { + validationDisconnectedWay: () => validationDisconnectedWay + }); function validationDisconnectedWay() { var type2 = "disconnected_way"; function isTaggedAsHighway(entity) { @@ -44542,8 +44974,24 @@ validation.type = type2; return validation; } + var init_disconnected_way = __esm({ + "modules/validations/disconnected_way.js"() { + "use strict"; + init_localizer(); + init_draw_line(); + init_delete(); + init_utilDisplayLabel(); + init_tags(); + init_validation(); + init_services(); + } + }); // modules/validations/invalid_format.js + var invalid_format_exports = {}; + __export(invalid_format_exports, { + validationFormatting: () => validationFormatting + }); function validationFormatting() { var type2 = "invalid_format"; var validation = function(entity) { @@ -44585,8 +45033,20 @@ validation.type = type2; return validation; } + var init_invalid_format = __esm({ + "modules/validations/invalid_format.js"() { + "use strict"; + init_localizer(); + init_utilDisplayLabel(); + init_validation(); + } + }); // modules/validations/help_request.js + var help_request_exports = {}; + __export(help_request_exports, { + validationHelpRequest: () => validationHelpRequest + }); function validationHelpRequest(context) { var type2 = "help_request"; var validation = function checkFixmeTag(entity) { @@ -44628,8 +45088,20 @@ validation.type = type2; return validation; } + var init_help_request = __esm({ + "modules/validations/help_request.js"() { + "use strict"; + init_localizer(); + init_utilDisplayLabel(); + init_validation(); + } + }); // modules/validations/impossible_oneway.js + var impossible_oneway_exports = {}; + __export(impossible_oneway_exports, { + validationImpossibleOneway: () => validationImpossibleOneway + }); function validationImpossibleOneway() { var type2 = "impossible_oneway"; var validation = function checkImpossibleOneway(entity, graph) { @@ -44780,8 +45252,24 @@ validation.type = type2; return validation; } + var init_impossible_oneway = __esm({ + "modules/validations/impossible_oneway.js"() { + "use strict"; + init_localizer(); + init_draw_line(); + init_reverse(); + init_utilDisplayLabel(); + init_tags(); + init_validation(); + init_services(); + } + }); // modules/validations/incompatible_source.js + var incompatible_source_exports = {}; + __export(incompatible_source_exports, { + validationIncompatibleSource: () => validationIncompatibleSource + }); function validationIncompatibleSource() { const type2 = "incompatible_source"; const incompatibleRules = [ @@ -44837,15 +45325,27 @@ }).filter(Boolean); function getReference(id2) { return function showReference(selection2) { - selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.incompatible_source.reference.".concat(id2))); + selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append(`issues.incompatible_source.reference.${id2}`)); }; } }; validation.type = type2; return validation; } + var init_incompatible_source = __esm({ + "modules/validations/incompatible_source.js"() { + "use strict"; + init_localizer(); + init_utilDisplayLabel(); + init_validation(); + } + }); // modules/validations/maprules.js + var maprules_exports2 = {}; + __export(maprules_exports2, { + validationMaprules: () => validationMaprules + }); function validationMaprules() { var type2 = "maprules"; var validation = function checkMaprules(entity, graph) { @@ -44861,9 +45361,18 @@ validation.type = type2; return validation; } + var init_maprules2 = __esm({ + "modules/validations/maprules.js"() { + "use strict"; + init_services(); + } + }); // modules/validations/mismatched_geometry.js - var import_fast_deep_equal4 = __toESM(require_fast_deep_equal()); + var mismatched_geometry_exports = {}; + __export(mismatched_geometry_exports, { + validationMismatchedGeometry: () => validationMismatchedGeometry + }); function validationMismatchedGeometry() { var type2 = "mismatched_geometry"; function tagSuggestingLineIsArea(entity) { @@ -45191,8 +45700,32 @@ validation.type = type2; return validation; } + var import_fast_deep_equal4; + var init_mismatched_geometry = __esm({ + "modules/validations/mismatched_geometry.js"() { + "use strict"; + import_fast_deep_equal4 = __toESM(require_fast_deep_equal()); + init_add_vertex(); + init_change_tags(); + init_merge_nodes(); + init_extract(); + init_select5(); + init_multipolygon(); + init_tags(); + init_presets(); + init_geo2(); + init_localizer(); + init_util(); + init_utilDisplayLabel(); + init_validation(); + } + }); // modules/validations/missing_role.js + var missing_role_exports = {}; + __export(missing_role_exports, { + validationMissingRole: () => validationMissingRole + }); function validationMissingRole() { var type2 = "missing_role"; var validation = function checkMissingRole(entity, graph) { @@ -45276,8 +45809,22 @@ validation.type = type2; return validation; } + var init_missing_role = __esm({ + "modules/validations/missing_role.js"() { + "use strict"; + init_change_member(); + init_delete_member(); + init_localizer(); + init_utilDisplayLabel(); + init_validation(); + } + }); // modules/validations/missing_tag.js + var missing_tag_exports = {}; + __export(missing_tag_exports, { + validationMissingTag: () => validationMissingTag + }); function validationMissingTag(context) { var type2 = "missing_tag"; function hasDescriptiveTags(entity) { @@ -45375,8 +45922,22 @@ validation.type = type2; return validation; } + var init_missing_tag = __esm({ + "modules/validations/missing_tag.js"() { + "use strict"; + init_delete(); + init_tags(); + init_localizer(); + init_utilDisplayLabel(); + init_validation(); + } + }); // modules/validations/mutually_exclusive_tags.js + var mutually_exclusive_tags_exports = {}; + __export(mutually_exclusive_tags_exports, { + validationMutuallyExclusiveTags: () => validationMutuallyExclusiveTags + }); function validationMutuallyExclusiveTags() { const type2 = "mutually_exclusive_tags"; const tagKeyPairs = osmMutuallyExclusiveTagPairs; @@ -45406,7 +45967,7 @@ severity: "warning", message: function(context) { let entity2 = context.hasEntity(this.entityIds[0]); - return entity2 ? _t.append("issues.".concat(type2, ".").concat(subtype, ".message"), { + return entity2 ? _t.append(`issues.${type2}.${subtype}.message`, { feature: utilDisplayLabel(entity2, context.graph()), tag1: pair3[0], tag2: pair3[1] @@ -45434,15 +45995,29 @@ }); } 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] })); + selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append(`issues.${type2}.${subtype}.reference`, { tag1: pair3[0], tag2: pair3[1] })); } return issues; }; validation.type = type2; return validation; } + var init_mutually_exclusive_tags = __esm({ + "modules/validations/mutually_exclusive_tags.js"() { + "use strict"; + init_change_tags(); + init_localizer(); + init_utilDisplayLabel(); + init_validation(); + init_tags(); + } + }); // modules/operations/split.js + var split_exports2 = {}; + __export(split_exports2, { + operationSplit: () => operationSplit + }); function operationSplit(context, selectedIDs) { var _vertexIds = selectedIDs.filter(function(id2) { return context.graph().geometry(id2) === "vertex"; @@ -45511,8 +46086,21 @@ operation2.behavior = behaviorOperation(context).which(operation2); return operation2; } + var init_split2 = __esm({ + "modules/operations/split.js"() { + "use strict"; + init_localizer(); + init_split(); + init_operation(); + init_select5(); + } + }); // modules/validations/osm_api_limits.js + var osm_api_limits_exports = {}; + __export(osm_api_limits_exports, { + validationOsmApiLimits: () => validationOsmApiLimits + }); function validationOsmApiLimits(context) { const type2 = "osm_api_limits"; const validation = function checkOsmApiLimits(entity) { @@ -45579,8 +46167,97 @@ validation.type = type2; return validation; } + var init_osm_api_limits = __esm({ + "modules/validations/osm_api_limits.js"() { + "use strict"; + init_localizer(); + init_validation(); + init_split2(); + } + }); + + // modules/osm/deprecated.js + var deprecated_exports = {}; + __export(deprecated_exports, { + deprecatedTagValuesByKey: () => deprecatedTagValuesByKey, + getDeprecatedTags: () => getDeprecatedTags + }); + function getDeprecatedTags(tags, dataDeprecated) { + if (Object.keys(tags).length === 0) return []; + var deprecated = []; + dataDeprecated.forEach((d2) => { + var oldKeys = Object.keys(d2.old); + if (d2.replace) { + var hasExistingValues = Object.keys(d2.replace).some((replaceKey) => { + if (!tags[replaceKey] || d2.old[replaceKey]) return false; + var replaceValue = d2.replace[replaceKey]; + if (replaceValue === "*") return false; + if (replaceValue === tags[replaceKey]) return false; + return true; + }); + if (hasExistingValues) return; + } + var matchesDeprecatedTags = oldKeys.every((oldKey) => { + if (!tags[oldKey]) return false; + if (d2.old[oldKey] === "*") return true; + if (d2.old[oldKey] === tags[oldKey]) return true; + var vals = tags[oldKey].split(";").filter(Boolean); + if (vals.length === 0) { + return false; + } else if (vals.length > 1) { + return vals.indexOf(d2.old[oldKey]) !== -1; + } else { + if (tags[oldKey] === d2.old[oldKey]) { + if (d2.replace && d2.old[oldKey] === d2.replace[oldKey]) { + var replaceKeys = Object.keys(d2.replace); + return !replaceKeys.every((replaceKey) => { + return tags[replaceKey] === d2.replace[replaceKey]; + }); + } else { + return true; + } + } + } + return false; + }); + if (matchesDeprecatedTags) { + deprecated.push(d2); + } + }); + return deprecated; + } + function deprecatedTagValuesByKey(dataDeprecated) { + if (!_deprecatedTagValuesByKey) { + _deprecatedTagValuesByKey = {}; + dataDeprecated.forEach((d2) => { + var oldKeys = Object.keys(d2.old); + if (oldKeys.length === 1) { + var oldKey = oldKeys[0]; + var oldValue = d2.old[oldKey]; + if (oldValue !== "*") { + if (!_deprecatedTagValuesByKey[oldKey]) { + _deprecatedTagValuesByKey[oldKey] = [oldValue]; + } else { + _deprecatedTagValuesByKey[oldKey].push(oldValue); + } + } + } + }); + } + return _deprecatedTagValuesByKey; + } + var _deprecatedTagValuesByKey; + var init_deprecated = __esm({ + "modules/osm/deprecated.js"() { + "use strict"; + } + }); // modules/validations/outdated_tags.js + var outdated_tags_exports = {}; + __export(outdated_tags_exports, { + validationOutdatedTags: () => validationOutdatedTags + }); function validationOutdatedTags() { const type2 = "outdated_tags"; let _waitingForDeprecated = true; @@ -45604,8 +46281,19 @@ entity = graph.entity(entity.id); preset = newPreset; } + const nsi = services.nsi; + let waitingForNsi = false; + let nsiResult; + if (nsi) { + waitingForNsi = nsi.status() === "loading"; + if (!waitingForNsi) { + const loc = entity.extent(graph).center(); + nsiResult = nsi.upgradeTags(oldTags, loc); + } + } + const nsiDiff = nsiResult ? utilTagDiff(oldTags, nsiResult.newTags) : []; if (_dataDeprecated) { - const deprecatedTags = entity.deprecatedTags(_dataDeprecated); + const deprecatedTags = getDeprecatedTags(entity.tags, _dataDeprecated); if (entity.type === "way" && entity.isClosed() && entity.tags.traffic_calming === "island" && !entity.tags.highway) { deprecatedTags.push({ old: { traffic_calming: "island" }, @@ -45621,7 +46309,9 @@ } let newTags = Object.assign({}, entity.tags); if (preset.tags !== preset.addTags) { - Object.keys(preset.addTags).forEach((k2) => { + Object.keys(preset.addTags).filter((k2) => { + return !(nsiResult == null ? void 0 : nsiResult.newTags[k2]); + }).forEach((k2) => { if (!newTags[k2]) { if (preset.addTags[k2] === "*") { newTags[k2] = "yes"; @@ -45632,17 +46322,6 @@ }); } const deprecationDiff = utilTagDiff(oldTags, newTags); - const nsi = services.nsi; - let waitingForNsi = false; - let nsiResult; - if (nsi) { - waitingForNsi = nsi.status() === "loading"; - if (!waitingForNsi) { - const loc = entity.extent(graph).center(); - nsiResult = nsi.upgradeTags(oldTags, loc); - } - } - const nsiDiff = nsiResult ? utilTagDiff(oldTags, nsiResult.newTags) : []; let issues = []; issues.provisional = _waitingForDeprecated || waitingForNsi; if (deprecationDiff.length) { @@ -45661,11 +46340,11 @@ /* verbose */ true ); - return _t.append("issues.outdated_tags.".concat(prefix, "message"), { feature: feature3 }); + return _t.append(`issues.outdated_tags.${prefix}message`, { feature: feature3 }); }, reference: (selection2) => showReference( selection2, - _t.append("issues.outdated_tags.".concat(prefix, "reference")), + _t.append(`issues.outdated_tags.${prefix}reference`), deprecationDiff ), entityIds: [entity.id], @@ -45747,7 +46426,7 @@ if (!item) return graph2; let newTags2 = Object.assign({}, currEntity.tags); const wd = item.mainTag; - const notwd = "not:".concat(wd); + const notwd = `not:${wd}`; const qid = item.tags[wd]; newTags2[notwd] = qid; if (newTags2[wd] === qid) { @@ -45763,7 +46442,7 @@ enter.append("strong").call(_t.append("issues.suggested")); enter.append("table").attr("class", "tagDiff-table").selectAll(".tagDiff-row").data(tagDiff).enter().append("tr").attr("class", "tagDiff-row").append("td").attr("class", (d2) => { let klass = d2.type === "+" ? "add" : "remove"; - return "tagDiff-cell tagDiff-cell-".concat(klass); + return `tagDiff-cell tagDiff-cell-${klass}`; }).html((d2) => d2.display); } } @@ -45771,8 +46450,28 @@ validation.type = type2; return validation; } + var init_outdated_tags = __esm({ + "modules/validations/outdated_tags.js"() { + "use strict"; + init_localizer(); + init_change_preset(); + init_change_tags(); + init_upgrade_tags(); + init_core(); + init_presets(); + init_services(); + init_util(); + init_utilDisplayLabel(); + init_validation(); + init_deprecated(); + } + }); // modules/validations/private_data.js + var private_data_exports = {}; + __export(private_data_exports, { + validationPrivateData: () => validationPrivateData + }); function validationPrivateData() { var type2 = "private_data"; var privateBuildingValues = { @@ -45868,8 +46567,22 @@ validation.type = type2; return validation; } + var init_private_data = __esm({ + "modules/validations/private_data.js"() { + "use strict"; + init_change_tags(); + init_localizer(); + init_util(); + init_utilDisplayLabel(); + init_validation(); + } + }); // modules/validations/suspicious_name.js + var suspicious_name_exports = {}; + __export(suspicious_name_exports, { + validationSuspiciousName: () => validationSuspiciousName + }); function validationSuspiciousName(context) { const type2 = "suspicious_name"; const keysToTestForGenericValues = [ @@ -45887,6 +46600,11 @@ "tourism", "waterway" ]; + const ignoredPresets = /* @__PURE__ */ new Set([ + "amenity/place_of_worship/christian/jehovahs_witness", + "__test__ignored_preset" + // for unit tests + ]); let _waitingForNsi = false; function isGenericMatchInNsi(tags) { const nsi = services.nsi; @@ -45911,13 +46629,15 @@ } return false; } - function nameMatchesPresetName(name, presetName) { - if (!presetName) return false; - return name.toLowerCase() === presetName.toLowerCase(); + function nameMatchesPresetName(name, preset) { + if (!preset) return false; + if (ignoredPresets.has(preset.id)) return false; + name = name.toLowerCase(); + return name === preset.name().toLowerCase() || preset.aliases().some((alias) => name === alias.toLowerCase()); } - function isGenericName(name, tags, presetName) { + function isGenericName(name, tags, preset) { name = name.toLowerCase(); - return nameMatchesRawTag(name, tags) || nameMatchesPresetName(name, presetName) || isGenericMatchInNsi(tags); + return nameMatchesRawTag(name, tags) || nameMatchesPresetName(name, preset) || isGenericMatchInNsi(tags); } function makeGenericNameIssue(entityId, nameKey, genericName, langCode) { return new validationIssue({ @@ -45936,7 +46656,7 @@ }, reference: showReference, entityIds: [entityId], - hash: "".concat(nameKey, "=").concat(genericName), + hash: `${nameKey}=${genericName}`, dynamicFixes: function() { return [ new validationIssueFix({ @@ -45965,13 +46685,13 @@ const hasWikidata = !!tags.wikidata || !!tags["brand:wikidata"] || !!tags["operator:wikidata"]; if (hasWikidata) return []; let issues = []; - const presetName = _mainPresetIndex.match(entity, context.graph()).name(); + const preset = _mainPresetIndex.match(entity, context.graph()); 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 (isGenericName(value, tags, presetName)) { + if (isGenericName(value, tags, preset)) { issues.provisional = _waitingForNsi; issues.push(makeGenericNameIssue(entity.id, key, value, langCode)); } @@ -45981,8 +46701,22 @@ validation.type = type2; return validation; } + var init_suspicious_name = __esm({ + "modules/validations/suspicious_name.js"() { + "use strict"; + init_change_tags(); + init_presets(); + init_services(); + init_localizer(); + init_validation(); + } + }); // modules/validations/unsquare_way.js + var unsquare_way_exports = {}; + __export(unsquare_way_exports, { + validationUnsquareWay: () => validationUnsquareWay + }); function validationUnsquareWay(context) { var type2 = "unsquare_way"; var DEFAULT_DEG_THRESHOLD = 5; @@ -46080,8 +46814,70 @@ validation.type = type2; return validation; } + var init_unsquare_way = __esm({ + "modules/validations/unsquare_way.js"() { + "use strict"; + init_preferences(); + init_localizer(); + init_orthogonalize(); + init_ortho(); + init_utilDisplayLabel(); + init_validation(); + init_services(); + } + }); + + // modules/validations/index.js + var validations_exports = {}; + __export(validations_exports, { + validationAlmostJunction: () => validationAlmostJunction, + validationCloseNodes: () => validationCloseNodes, + validationCrossingWays: () => validationCrossingWays, + validationDisconnectedWay: () => validationDisconnectedWay, + validationFormatting: () => validationFormatting, + validationHelpRequest: () => validationHelpRequest, + validationImpossibleOneway: () => validationImpossibleOneway, + validationIncompatibleSource: () => validationIncompatibleSource, + validationMaprules: () => validationMaprules, + validationMismatchedGeometry: () => validationMismatchedGeometry, + validationMissingRole: () => validationMissingRole, + validationMissingTag: () => validationMissingTag, + validationMutuallyExclusiveTags: () => validationMutuallyExclusiveTags, + validationOsmApiLimits: () => validationOsmApiLimits, + validationOutdatedTags: () => validationOutdatedTags, + validationPrivateData: () => validationPrivateData, + validationSuspiciousName: () => validationSuspiciousName, + validationUnsquareWay: () => validationUnsquareWay + }); + var init_validations = __esm({ + "modules/validations/index.js"() { + "use strict"; + init_almost_junction(); + init_close_nodes(); + init_crossing_ways(); + init_disconnected_way(); + init_invalid_format(); + init_help_request(); + init_impossible_oneway(); + init_incompatible_source(); + init_maprules2(); + init_mismatched_geometry(); + init_missing_role(); + init_missing_tag(); + init_mutually_exclusive_tags(); + init_osm_api_limits(); + init_outdated_tags(); + init_private_data(); + init_suspicious_name(); + init_unsquare_way(); + } + }); // modules/core/validator.js + var validator_exports = {}; + __export(validator_exports, { + coreValidator: () => coreValidator + }); function coreValidator(context) { let dispatch14 = dispatch_default("validated", "focusedIssue"); const validator = {}; @@ -46338,7 +47134,7 @@ const addConnectedWays = (graph) => diff.filter((entityID) => graph.hasEntity(entityID)).map((entityID) => graph.entity(entityID)).flatMap((entity) => graph.childNodes(entity)).flatMap((vertex) => graph.parentWays(vertex)).forEach((way) => entityIDs.add(way.id)); addConnectedWays(currGraph); addConnectedWays(prevGraph); - Object.values(__spreadValues(__spreadValues({}, incrementalDiff.created()), incrementalDiff.deleted())).filter((e3) => e3.type === "relation").flatMap((r2) => r2.members).forEach((m2) => entityIDs.add(m2.id)); + Object.values({ ...incrementalDiff.created(), ...incrementalDiff.deleted() }).filter((e3) => e3.type === "relation").flatMap((r2) => r2.members).forEach((m2) => entityIDs.add(m2.id)); Object.values(incrementalDiff.modified()).filter((e3) => e3.type === "relation").map((r2) => ({ baseEntity: prevGraph.entity(r2.id), headEntity: r2 })).forEach(({ baseEntity, headEntity }) => { const bm = baseEntity.members.map((m2) => m2.id); const hm = headEntity.members.map((m2) => m2.id); @@ -46548,8 +47344,24 @@ }; return cache; } + var init_validator = __esm({ + "modules/core/validator.js"() { + "use strict"; + init_src4(); + init_preferences(); + init_difference(); + init_extent(); + init_select5(); + init_util(); + init_validations(); + } + }); // modules/core/uploader.js + var uploader_exports = {}; + __export(uploader_exports, { + coreUploader: () => coreUploader + }); function coreUploader(context) { var dispatch14 = dispatch_default( // Start and end events are dispatched exactly once each per legitimate outside call to `save` @@ -46855,8 +47667,27 @@ }; return utilRebind(uploader, dispatch14, "on"); } + var init_uploader = __esm({ + "modules/core/uploader.js"() { + "use strict"; + init_src4(); + init_lodash(); + init_file_fetcher(); + init_discard_tags(); + init_merge_remote_changes(); + init_noop2(); + init_revert(); + init_graph(); + init_localizer(); + init_util(); + } + }); // modules/modes/draw_area.js + var draw_area_exports = {}; + __export(draw_area_exports, { + modeDrawArea: () => modeDrawArea + }); function modeDrawArea(context, wayID, startGraph, button) { var mode = { button, @@ -46880,8 +47711,19 @@ }; return mode; } + var init_draw_area = __esm({ + "modules/modes/draw_area.js"() { + "use strict"; + init_localizer(); + init_draw_way(); + } + }); // modules/modes/add_area.js + var add_area_exports = {}; + __export(add_area_exports, { + modeAddArea: () => modeAddArea + }); function modeAddArea(context, mode) { mode.id = "add-area"; var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode); @@ -46938,8 +47780,23 @@ }; return mode; } + var init_add_area = __esm({ + "modules/modes/add_area.js"() { + "use strict"; + init_add_entity(); + init_add_midpoint(); + init_add_vertex(); + init_add_way(); + init_draw_area(); + init_osm(); + } + }); // modules/modes/add_line.js + var add_line_exports = {}; + __export(add_line_exports, { + modeAddLine: () => modeAddLine + }); function modeAddLine(context, mode) { mode.id = "add-line"; var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode); @@ -46988,8 +47845,23 @@ }; return mode; } + var init_add_line = __esm({ + "modules/modes/add_line.js"() { + "use strict"; + init_add_entity(); + init_add_midpoint(); + init_add_vertex(); + init_add_way(); + init_draw_line(); + init_osm(); + } + }); // modules/modes/add_point.js + var add_point_exports = {}; + __export(add_point_exports, { + modeAddPoint: () => modeAddPoint + }); 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); @@ -47046,8 +47918,25 @@ }; return mode; } + var init_add_point = __esm({ + "modules/modes/add_point.js"() { + "use strict"; + init_localizer(); + init_draw(); + init_browse(); + init_select5(); + init_node2(); + init_add_entity(); + init_change_tags(); + init_add_midpoint(); + } + }); // modules/ui/note_comments.js + var note_comments_exports = {}; + __export(note_comments_exports, { + uiNoteComments: () => uiNoteComments + }); function uiNoteComments() { var _note; function noteComments(selection2) { @@ -47110,8 +47999,22 @@ }; return noteComments; } + var init_note_comments = __esm({ + "modules/ui/note_comments.js"() { + "use strict"; + init_src5(); + init_preferences(); + init_localizer(); + init_icon(); + init_services(); + } + }); // modules/ui/note_header.js + var note_header_exports = {}; + __export(note_header_exports, { + uiNoteHeader: () => uiNoteHeader + }); function uiNoteHeader() { var _note; function noteHeader(selection2) { @@ -47154,8 +48057,19 @@ }; return noteHeader; } + var init_note_header = __esm({ + "modules/ui/note_header.js"() { + "use strict"; + init_localizer(); + init_icon(); + } + }); // modules/ui/note_report.js + var note_report_exports = {}; + __export(note_report_exports, { + uiNoteReport: () => uiNoteReport + }); function uiNoteReport() { var _note; function noteReport(selection2) { @@ -47177,8 +48091,21 @@ }; return noteReport; } + var init_note_report = __esm({ + "modules/ui/note_report.js"() { + "use strict"; + init_localizer(); + init_osm(); + init_services(); + init_icon(); + } + }); // modules/ui/view_on_osm.js + var view_on_osm_exports = {}; + __export(view_on_osm_exports, { + uiViewOnOSM: () => uiViewOnOSM + }); function uiViewOnOSM(context) { var _what; function viewOnOSM(selection2) { @@ -47203,8 +48130,20 @@ }; return viewOnOSM; } + var init_view_on_osm = __esm({ + "modules/ui/view_on_osm.js"() { + "use strict"; + init_localizer(); + init_osm(); + init_icon(); + } + }); // modules/ui/note_editor.js + var note_editor_exports = {}; + __export(note_editor_exports, { + uiNoteEditor: () => uiNoteEditor + }); function uiNoteEditor(context) { var dispatch14 = dispatch_default("change"); var noteComments = uiNoteComments(context); @@ -47390,8 +48329,28 @@ }; return utilRebind(noteEditor, dispatch14, "on"); } + var init_note_editor = __esm({ + "modules/ui/note_editor.js"() { + "use strict"; + init_src4(); + init_src5(); + init_localizer(); + init_services(); + init_browse(); + init_icon(); + init_note_comments(); + init_note_header(); + init_note_report(); + init_view_on_osm(); + init_util(); + } + }); // modules/modes/select_note.js + var select_note_exports = {}; + __export(select_note_exports, { + modeSelectNote: () => modeSelectNote + }); function modeSelectNote(context, selectedNoteID) { var mode = { id: "select-note", @@ -47472,8 +48431,29 @@ }; return mode; } + var init_select_note = __esm({ + "modules/modes/select_note.js"() { + "use strict"; + init_src5(); + init_breathe(); + init_hover(); + init_lasso2(); + init_select4(); + init_localizer(); + init_browse(); + init_drag_node(); + init_drag_note(); + init_services(); + init_note_editor(); + init_util(); + } + }); // modules/modes/add_note.js + var add_note_exports = {}; + __export(add_note_exports, { + modeAddNote: () => modeAddNote + }); function modeAddNote(context) { var mode = { id: "add-note", @@ -47501,153 +48481,178 @@ }; return mode; } + var init_add_note = __esm({ + "modules/modes/add_note.js"() { + "use strict"; + init_localizer(); + init_draw(); + init_browse(); + init_select_note(); + init_osm(); + init_services(); + } + }); // modules/util/jxon.js - var JXON = new function() { - var sValueProp = "keyValue", sAttributesProp = "keyAttributes", sAttrPref = "@", aCache = [], rIsNull = /^\s*$/, rIsBool = /^(?:true|false)$/i; - function parseText(sValue) { - if (rIsNull.test(sValue)) { - return null; - } - if (rIsBool.test(sValue)) { - return sValue.toLowerCase() === "true"; - } - if (isFinite(sValue)) { - return parseFloat(sValue); - } - if (isFinite(Date.parse(sValue))) { - return new Date(sValue); - } - return sValue; - } - function EmptyTree() { - } - EmptyTree.prototype.toString = function() { - return "null"; - }; - EmptyTree.prototype.valueOf = function() { - return null; - }; - function objectify(vValue) { - return vValue === null ? new EmptyTree() : vValue instanceof Object ? vValue : new vValue.constructor(vValue); - } - function createObjTree(oParentNode, nVerb, bFreeze, bNesteAttr) { - var nLevelStart = aCache.length, bChildren = oParentNode.hasChildNodes(), bAttributes = oParentNode.hasAttributes(), bHighVerb = Boolean(nVerb & 2); - var sProp, vContent, nLength = 0, sCollectedTxt = "", vResult = bHighVerb ? {} : ( - /* put here the default value for empty nodes: */ - true - ); - if (bChildren) { - for (var oNode, nItem = 0; nItem < oParentNode.childNodes.length; nItem++) { - oNode = oParentNode.childNodes.item(nItem); - if (oNode.nodeType === 4) { - sCollectedTxt += oNode.nodeValue; - } else if (oNode.nodeType === 3) { - sCollectedTxt += oNode.nodeValue.trim(); - } else if (oNode.nodeType === 1 && !oNode.prefix) { - aCache.push(oNode); - } - } - } - var nLevelEnd = aCache.length, vBuiltVal = parseText(sCollectedTxt); - if (!bHighVerb && (bChildren || bAttributes)) { - vResult = nVerb === 0 ? objectify(vBuiltVal) : {}; - } - for (var nElId = nLevelStart; nElId < nLevelEnd; nElId++) { - sProp = aCache[nElId].nodeName.toLowerCase(); - vContent = createObjTree(aCache[nElId], nVerb, bFreeze, bNesteAttr); - if (vResult.hasOwnProperty(sProp)) { - if (vResult[sProp].constructor !== Array) { - vResult[sProp] = [vResult[sProp]]; - } - vResult[sProp].push(vContent); - } else { - vResult[sProp] = vContent; - nLength++; - } - } - if (bAttributes) { - var nAttrLen = oParentNode.attributes.length, sAPrefix = bNesteAttr ? "" : sAttrPref, oAttrParent = bNesteAttr ? {} : vResult; - for (var oAttrib, nAttrib = 0; nAttrib < nAttrLen; nLength++, nAttrib++) { - oAttrib = oParentNode.attributes.item(nAttrib); - oAttrParent[sAPrefix + oAttrib.name.toLowerCase()] = parseText(oAttrib.value.trim()); - } - if (bNesteAttr) { - if (bFreeze) { - Object.freeze(oAttrParent); + var jxon_exports = {}; + __export(jxon_exports, { + JXON: () => JXON + }); + var JXON; + var init_jxon = __esm({ + "modules/util/jxon.js"() { + "use strict"; + JXON = new function() { + var sValueProp = "keyValue", sAttributesProp = "keyAttributes", sAttrPref = "@", aCache = [], rIsNull = /^\s*$/, rIsBool = /^(?:true|false)$/i; + function parseText(sValue) { + if (rIsNull.test(sValue)) { + return null; + } + if (rIsBool.test(sValue)) { + return sValue.toLowerCase() === "true"; + } + if (isFinite(sValue)) { + return parseFloat(sValue); } - vResult[sAttributesProp] = oAttrParent; - nLength -= nAttrLen - 1; + if (isFinite(Date.parse(sValue))) { + return new Date(sValue); + } + return sValue; } - } - if (nVerb === 3 || (nVerb === 2 || nVerb === 1 && nLength > 0) && sCollectedTxt) { - vResult[sValueProp] = vBuiltVal; - } else if (!bHighVerb && nLength === 0 && sCollectedTxt) { - vResult = vBuiltVal; - } - if (bFreeze && (bHighVerb || nLength > 0)) { - Object.freeze(vResult); - } - aCache.length = nLevelStart; - return vResult; - } - function loadObjTree(oXMLDoc, oParentEl, oParentObj) { - var vValue, oChild; - if (oParentObj instanceof String || oParentObj instanceof Number || oParentObj instanceof Boolean) { - oParentEl.appendChild(oXMLDoc.createTextNode(oParentObj.toString())); - } else if (oParentObj.constructor === Date) { - oParentEl.appendChild(oXMLDoc.createTextNode(oParentObj.toGMTString())); - } - for (var sName in oParentObj) { - vValue = oParentObj[sName]; - if (isFinite(sName) || vValue instanceof Function) { - continue; + function EmptyTree() { + } + EmptyTree.prototype.toString = function() { + return "null"; + }; + EmptyTree.prototype.valueOf = function() { + return null; + }; + function objectify(vValue) { + return vValue === null ? new EmptyTree() : vValue instanceof Object ? vValue : new vValue.constructor(vValue); } - if (sName === sValueProp) { - if (vValue !== null && vValue !== true) { - oParentEl.appendChild(oXMLDoc.createTextNode(vValue.constructor === Date ? vValue.toGMTString() : String(vValue))); + function createObjTree(oParentNode, nVerb, bFreeze, bNesteAttr) { + var nLevelStart = aCache.length, bChildren = oParentNode.hasChildNodes(), bAttributes = oParentNode.hasAttributes(), bHighVerb = Boolean(nVerb & 2); + var sProp, vContent, nLength = 0, sCollectedTxt = "", vResult = bHighVerb ? {} : ( + /* put here the default value for empty nodes: */ + true + ); + if (bChildren) { + for (var oNode, nItem = 0; nItem < oParentNode.childNodes.length; nItem++) { + oNode = oParentNode.childNodes.item(nItem); + if (oNode.nodeType === 4) { + sCollectedTxt += oNode.nodeValue; + } else if (oNode.nodeType === 3) { + sCollectedTxt += oNode.nodeValue.trim(); + } else if (oNode.nodeType === 1 && !oNode.prefix) { + aCache.push(oNode); + } + } + } + var nLevelEnd = aCache.length, vBuiltVal = parseText(sCollectedTxt); + if (!bHighVerb && (bChildren || bAttributes)) { + vResult = nVerb === 0 ? objectify(vBuiltVal) : {}; } - } else if (sName === sAttributesProp) { - for (var sAttrib in vValue) { - oParentEl.setAttribute(sAttrib, vValue[sAttrib]); + for (var nElId = nLevelStart; nElId < nLevelEnd; nElId++) { + sProp = aCache[nElId].nodeName.toLowerCase(); + vContent = createObjTree(aCache[nElId], nVerb, bFreeze, bNesteAttr); + if (vResult.hasOwnProperty(sProp)) { + if (vResult[sProp].constructor !== Array) { + vResult[sProp] = [vResult[sProp]]; + } + vResult[sProp].push(vContent); + } else { + vResult[sProp] = vContent; + nLength++; + } } - } else if (sName.charAt(0) === sAttrPref) { - oParentEl.setAttribute(sName.slice(1), vValue); - } else if (vValue.constructor === Array) { - for (var nItem = 0; nItem < vValue.length; nItem++) { - oChild = oXMLDoc.createElement(sName); - loadObjTree(oXMLDoc, oChild, vValue[nItem]); - oParentEl.appendChild(oChild); + if (bAttributes) { + var nAttrLen = oParentNode.attributes.length, sAPrefix = bNesteAttr ? "" : sAttrPref, oAttrParent = bNesteAttr ? {} : vResult; + for (var oAttrib, nAttrib = 0; nAttrib < nAttrLen; nLength++, nAttrib++) { + oAttrib = oParentNode.attributes.item(nAttrib); + oAttrParent[sAPrefix + oAttrib.name.toLowerCase()] = parseText(oAttrib.value.trim()); + } + if (bNesteAttr) { + if (bFreeze) { + Object.freeze(oAttrParent); + } + vResult[sAttributesProp] = oAttrParent; + nLength -= nAttrLen - 1; + } } - } else { - oChild = oXMLDoc.createElement(sName); - if (vValue instanceof Object) { - loadObjTree(oXMLDoc, oChild, vValue); - } else if (vValue !== null && vValue !== true) { - oChild.appendChild(oXMLDoc.createTextNode(vValue.toString())); + if (nVerb === 3 || (nVerb === 2 || nVerb === 1 && nLength > 0) && sCollectedTxt) { + vResult[sValueProp] = vBuiltVal; + } else if (!bHighVerb && nLength === 0 && sCollectedTxt) { + vResult = vBuiltVal; } - oParentEl.appendChild(oChild); + if (bFreeze && (bHighVerb || nLength > 0)) { + Object.freeze(vResult); + } + aCache.length = nLevelStart; + return vResult; } - } + function loadObjTree(oXMLDoc, oParentEl, oParentObj) { + var vValue, oChild; + if (oParentObj instanceof String || oParentObj instanceof Number || oParentObj instanceof Boolean) { + oParentEl.appendChild(oXMLDoc.createTextNode(oParentObj.toString())); + } else if (oParentObj.constructor === Date) { + oParentEl.appendChild(oXMLDoc.createTextNode(oParentObj.toGMTString())); + } + for (var sName in oParentObj) { + vValue = oParentObj[sName]; + if (isFinite(sName) || vValue instanceof Function) { + continue; + } + if (sName === sValueProp) { + if (vValue !== null && vValue !== true) { + oParentEl.appendChild(oXMLDoc.createTextNode(vValue.constructor === Date ? vValue.toGMTString() : String(vValue))); + } + } else if (sName === sAttributesProp) { + for (var sAttrib in vValue) { + oParentEl.setAttribute(sAttrib, vValue[sAttrib]); + } + } else if (sName.charAt(0) === sAttrPref) { + oParentEl.setAttribute(sName.slice(1), vValue); + } else if (vValue.constructor === Array) { + for (var nItem = 0; nItem < vValue.length; nItem++) { + oChild = oXMLDoc.createElement(sName); + loadObjTree(oXMLDoc, oChild, vValue[nItem]); + oParentEl.appendChild(oChild); + } + } else { + oChild = oXMLDoc.createElement(sName); + if (vValue instanceof Object) { + loadObjTree(oXMLDoc, oChild, vValue); + } else if (vValue !== null && vValue !== true) { + oChild.appendChild(oXMLDoc.createTextNode(vValue.toString())); + } + oParentEl.appendChild(oChild); + } + } + } + this.build = function(oXMLParent, nVerbosity, bFreeze, bNesteAttributes) { + var _nVerb = arguments.length > 1 && typeof nVerbosity === "number" ? nVerbosity & 3 : ( + /* put here the default verbosity level: */ + 1 + ); + return createObjTree(oXMLParent, _nVerb, bFreeze || false, arguments.length > 3 ? bNesteAttributes : _nVerb === 3); + }; + this.unbuild = function(oObjTree) { + var oNewDoc = document.implementation.createDocument("", "", null); + loadObjTree(oNewDoc, oNewDoc, oObjTree); + return oNewDoc; + }; + this.stringify = function(oObjTree) { + return new XMLSerializer().serializeToString(JXON.unbuild(oObjTree)); + }; + }(); } - this.build = function(oXMLParent, nVerbosity, bFreeze, bNesteAttributes) { - var _nVerb = arguments.length > 1 && typeof nVerbosity === "number" ? nVerbosity & 3 : ( - /* put here the default verbosity level: */ - 1 - ); - return createObjTree(oXMLParent, _nVerb, bFreeze || false, arguments.length > 3 ? bNesteAttributes : _nVerb === 3); - }; - this.unbuild = function(oObjTree) { - var oNewDoc = document.implementation.createDocument("", "", null); - loadObjTree(oNewDoc, oNewDoc, oObjTree); - return oNewDoc; - }; - this.stringify = function(oObjTree) { - return new XMLSerializer().serializeToString(JXON.unbuild(oObjTree)); - }; - }(); + }); // modules/ui/conflicts.js + var conflicts_exports = {}; + __export(conflicts_exports, { + uiConflicts: () => uiConflicts + }); function uiConflicts(context) { var dispatch14 = dispatch_default("cancel", "save"); var keybinding = utilKeybinding("conflicts"); @@ -47797,8 +48802,25 @@ }; return utilRebind(conflicts, dispatch14, "on"); } + var init_conflicts = __esm({ + "modules/ui/conflicts.js"() { + "use strict"; + init_src4(); + init_src5(); + init_localizer(); + init_jxon(); + init_geo2(); + init_osm(); + init_icon(); + init_util(); + } + }); // modules/ui/confirm.js + var confirm_exports = {}; + __export(confirm_exports, { + uiConfirm: () => uiConfirm + }); function uiConfirm(selection2) { var modalSelection = uiModal(selection2); modalSelection.select(".modal").classed("modal-alert", true); @@ -47814,12 +48836,19 @@ }; return modalSelection; } - - // modules/ui/commit.js - var import_fast_deep_equal10 = __toESM(require_fast_deep_equal()); + var init_confirm = __esm({ + "modules/ui/confirm.js"() { + "use strict"; + init_localizer(); + init_modal(); + } + }); // modules/ui/popover.js - var _popoverID = 0; + var popover_exports = {}; + __export(popover_exports, { + uiPopover: () => uiPopover + }); function uiPopover(klass) { var _id = _popoverID++; var _anchorSelection = select_default2(null); @@ -48076,8 +49105,21 @@ } return popover; } + var _popoverID; + var init_popover = __esm({ + "modules/ui/popover.js"() { + "use strict"; + init_src5(); + init_util2(); + _popoverID = 0; + } + }); // modules/ui/tooltip.js + var tooltip_exports = {}; + __export(tooltip_exports, { + uiTooltip: () => uiTooltip + }); function uiTooltip(klass) { var tooltip = uiPopover((klass || "") + " tooltip").displayType("hover"); var _title = function() { @@ -48133,9 +49175,20 @@ }); return tooltip; } + var init_tooltip = __esm({ + "modules/ui/tooltip.js"() { + "use strict"; + init_util2(); + init_localizer(); + init_popover(); + } + }); // modules/ui/combobox.js - var _comboHideTimerID; + var combobox_exports = {}; + __export(combobox_exports, { + uiCombobox: () => uiCombobox + }); function uiCombobox(context, klass) { var dispatch14 = dispatch_default("accept", "cancel", "update"); var container = context.container(); @@ -48322,7 +49375,7 @@ ensureVisible(); } function ensureVisible() { - var _a4; + var _a3; var combo = container.selectAll(".combobox"); if (combo.empty()) return; var containerRect = container.node().getBoundingClientRect(); @@ -48334,7 +49387,7 @@ } var selected = combo.selectAll(".combobox-option.selected").node(); if (selected) { - (_a4 = selected.scrollIntoView) == null ? void 0 : _a4.call(selected, { behavior: "smooth", block: "nearest" }); + (_a3 = selected.scrollIntoView) == null ? void 0 : _a3.call(selected, { behavior: "smooth", block: "nearest" }); } } function value() { @@ -48493,13 +49546,34 @@ container.selectAll(".combobox").remove(); container.on("scroll.combo-scroll", null); } - uiCombobox.off = function(input, context) { - _hide(context.container()); - input.on("focus.combo-input", null).on("blur.combo-input", null).on("keydown.combo-input", null).on("keyup.combo-input", null).on("input.combo-input", null).on("mousedown.combo-input", null).on("mouseup.combo-input", null); - context.container().on("scroll.combo-scroll", null); - }; + var _comboHideTimerID; + var init_combobox = __esm({ + "modules/ui/combobox.js"() { + "use strict"; + init_src4(); + init_src5(); + init_util(); + uiCombobox.off = function(input, context) { + _hide(context.container()); + input.on("focus.combo-input", null).on("blur.combo-input", null).on("keydown.combo-input", null).on("keyup.combo-input", null).on("input.combo-input", null).on("mousedown.combo-input", null).on("mouseup.combo-input", null); + context.container().on("scroll.combo-scroll", null); + }; + } + }); // modules/ui/intro/helper.js + var helper_exports = {}; + __export(helper_exports, { + helpHtml: () => helpHtml, + icon: () => icon, + isMostlySquare: () => isMostlySquare, + localize: () => localize, + missingStrings: () => missingStrings, + pad: () => pad2, + pointBox: () => pointBox, + selectMenuItem: () => selectMenuItem, + transitionTime: () => transitionTime + }); function pointBox(loc, context) { var rect = context.surfaceRect(); var point = context.curtainProjection(loc); @@ -48510,7 +49584,7 @@ height: 90 }; } - function pad(locOrBox, padding, context) { + function pad2(locOrBox, padding, context) { var box; if (locOrBox instanceof Array) { var rect = context.surfaceRect(); @@ -48532,7 +49606,6 @@ function icon(name, svgklass, useklass) { return '"; } - var helpStringReplacements; function helpHtml(id2, replacements) { if (!helpStringReplacements) { helpStringReplacements = { @@ -48640,7 +49713,6 @@ function slugify(text) { return text.toString().toLowerCase().replace(/\s+/g, "-").replace(/[^\w\-]+/g, "").replace(/\-\-+/g, "-").replace(/^-+/, "").replace(/-+$/, ""); } - var missingStrings = {}; function checkKey(key, text) { if (_t(key, { default: void 0 }) === void 0) { if (missingStrings.hasOwnProperty(key)) return; @@ -48721,8 +49793,22 @@ return 1e3; } } + var helpStringReplacements, missingStrings; + var init_helper = __esm({ + "modules/ui/intro/helper.js"() { + "use strict"; + init_localizer(); + init_geo2(); + init_cmd(); + missingStrings = {}; + } + }); // modules/ui/field_help.js + var field_help_exports = {}; + __export(field_help_exports, { + uiFieldHelp: () => uiFieldHelp + }); function uiFieldHelp(context, fieldName) { var fieldHelp = {}; var _inspector = select_default2(null); @@ -48863,8 +49949,24 @@ }; return fieldHelp; } + var init_field_help = __esm({ + "modules/ui/field_help.js"() { + "use strict"; + init_src5(); + init_marked_esm(); + init_localizer(); + init_icon(); + init_helper(); + } + }); // modules/ui/fields/check.js + var check_exports = {}; + __export(check_exports, { + uiFieldCheck: () => uiFieldCheck, + uiFieldDefaultCheck: () => uiFieldCheck, + uiFieldOnewayCheck: () => uiFieldCheck + }); function uiFieldCheck(field, context) { var dispatch14 = dispatch_default("change"); var options2 = field.options; @@ -49001,11 +50103,28 @@ }; return utilRebind(check, dispatch14, "on"); } - - // modules/svg/areas.js - var import_fast_deep_equal5 = __toESM(require_fast_deep_equal()); + var init_check = __esm({ + "modules/ui/fields/check.js"() { + "use strict"; + init_src4(); + init_src5(); + init_rebind(); + init_localizer(); + init_reverse(); + init_icon(); + } + }); // modules/svg/helpers.js + var helpers_exports = {}; + __export(helpers_exports, { + svgMarkerSegments: () => svgMarkerSegments, + svgPassiveVertex: () => svgPassiveVertex, + svgPath: () => svgPath, + svgPointTransform: () => svgPointTransform, + svgRelationMemberTags: () => svgRelationMemberTags, + svgSegmentWay: () => svgSegmentWay + }); function svgPassiveVertex(node, graph, activeID) { if (!activeID) return 1; if (activeID === node.id) return 0; @@ -49037,19 +50156,18 @@ } return 1; } - function svgMarkerSegments(projection2, graph, dt2, shouldReverse, bothDirections) { + function svgMarkerSegments(projection2, graph, dt2, shouldReverse = () => false, bothDirections = () => false) { return function(entity) { - var i3 = 0; - var offset = dt2; - var segments = []; - var clip = identity_default2().clipExtent(projection2.clipExtent()).stream; - var coordinates = graph.childNodes(entity).map(function(n3) { + let i3 = 0; + let offset = dt2 / 2; + const segments = []; + const clip = paddedClipExtent(projection2); + const coordinates = graph.childNodes(entity).map(function(n3) { return n3.loc; }); - var a2, b2; - if (shouldReverse(entity)) { - coordinates.reverse(); - } + let a2, b2; + const _shouldReverse = shouldReverse(entity); + const _bothDirections = bothDirections(entity); stream_default({ type: "LineString", coordinates @@ -49062,30 +50180,31 @@ point: function(x2, y2) { b2 = [x2, y2]; if (a2) { - var span = geoVecLength(a2, b2) - offset; + let span = geoVecLength(a2, b2) - offset; if (span >= 0) { - var heading2 = geoVecAngle(a2, b2); - var dx = dt2 * Math.cos(heading2); - var dy = dt2 * Math.sin(heading2); - var p2 = [ + const heading2 = geoVecAngle(a2, b2); + const dx = dt2 * Math.cos(heading2); + const dy = dt2 * Math.sin(heading2); + let p2 = [ a2[0] + offset * Math.cos(heading2), a2[1] + offset * Math.sin(heading2) ]; - var coord2 = [a2, p2]; + const coord2 = [a2, p2]; for (span -= dt2; span >= 0; span -= dt2) { p2 = geoVecAdd(p2, [dx, dy]); coord2.push(p2); } coord2.push(b2); - var segment = ""; - var j2; - for (j2 = 0; j2 < coord2.length; j2++) { - segment += (j2 === 0 ? "M" : "L") + coord2[j2][0] + "," + coord2[j2][1]; + let segment = ""; + if (!_shouldReverse || _bothDirections) { + for (let 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 }); } - segments.push({ id: entity.id, index: i3++, d: segment }); - if (bothDirections(entity)) { + if (_shouldReverse || _bothDirections) { segment = ""; - for (j2 = coord2.length - 1; j2 >= 0; j2--) { + for (let 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 }); @@ -49100,19 +50219,13 @@ }; } function svgPath(projection2, graph, isArea) { - var cache = {}; - var padding = isArea ? 65 : 5; - var viewport = projection2.clipExtent(); - var paddedExtent = [ - [viewport[0][0] - padding, viewport[0][1] - padding], - [viewport[1][0] + padding, viewport[1][1] + padding] - ]; - var clip = identity_default2().clipExtent(paddedExtent).stream; - var project = projection2.stream; - var path = path_default().projection({ stream: function(output) { + const cache = {}; + const project = projection2.stream; + const clip = paddedClipExtent(projection2, isArea); + const path = path_default().projection({ stream: function(output) { return project(clip(output)); } }); - var svgpath = function(entity) { + const svgpath = function(entity) { if (entity.id in cache) { return cache[entity.id]; } else { @@ -49219,8 +50332,28 @@ } } } + function paddedClipExtent(projection2, isArea = false) { + var padding = isArea ? 65 : 5; + var viewport = projection2.clipExtent(); + var paddedExtent = [ + [viewport[0][0] - padding, viewport[0][1] - padding], + [viewport[1][0] + padding, viewport[1][1] + padding] + ]; + return identity_default2().clipExtent(paddedExtent).stream; + } + var init_helpers = __esm({ + "modules/svg/helpers.js"() { + "use strict"; + init_src2(); + init_geo2(); + } + }); // modules/svg/tag_classes.js + var tag_classes_exports = {}; + __export(tag_classes_exports, { + svgTagClasses: () => svgTagClasses + }); function svgTagClasses() { var primaries = [ "building", @@ -49384,85 +50517,19 @@ }; return tagClasses; } + var init_tag_classes = __esm({ + "modules/svg/tag_classes.js"() { + "use strict"; + init_src5(); + init_tags(); + } + }); // modules/svg/tag_pattern.js - var patterns = { - // tag - pattern name - // -or- - // tag - value - pattern name - // -or- - // tag - value - rules (optional tag-values, pattern name) - // (matches earlier rules first, so fallback should be last entry) - amenity: { - grave_yard: "cemetery", - fountain: "water_standing" - }, - landuse: { - cemetery: [ - { religion: "christian", pattern: "cemetery_christian" }, - { religion: "buddhist", pattern: "cemetery_buddhist" }, - { religion: "muslim", pattern: "cemetery_muslim" }, - { religion: "jewish", pattern: "cemetery_jewish" }, - { pattern: "cemetery" } - ], - construction: "construction", - farmland: "farmland", - farmyard: "farmyard", - forest: [ - { leaf_type: "broadleaved", pattern: "forest_broadleaved" }, - { leaf_type: "needleleaved", pattern: "forest_needleleaved" }, - { leaf_type: "leafless", pattern: "forest_leafless" }, - { pattern: "forest" } - // same as 'leaf_type:mixed' - ], - grave_yard: "cemetery", - grass: "grass", - landfill: "landfill", - meadow: "meadow", - military: "construction", - orchard: "orchard", - quarry: "quarry", - vineyard: "vineyard" - }, - leisure: { - horse_riding: "farmyard" - }, - natural: { - beach: "beach", - grassland: "grass", - sand: "beach", - scrub: "scrub", - water: [ - { water: "pond", pattern: "pond" }, - { water: "reservoir", pattern: "water_standing" }, - { pattern: "waves" } - ], - wetland: [ - { wetland: "marsh", pattern: "wetland_marsh" }, - { wetland: "swamp", pattern: "wetland_swamp" }, - { wetland: "bog", pattern: "wetland_bog" }, - { wetland: "reedbed", pattern: "wetland_reedbed" }, - { pattern: "wetland" } - ], - wood: [ - { leaf_type: "broadleaved", pattern: "forest_broadleaved" }, - { leaf_type: "needleleaved", pattern: "forest_needleleaved" }, - { leaf_type: "leafless", pattern: "forest_leafless" }, - { pattern: "forest" } - // same as 'leaf_type:mixed' - ] - }, - golf: { - green: "golf_green", - tee: "grass", - fairway: "grass", - rough: "scrub" - }, - surface: { - grass: "grass", - sand: "beach" - } - }; + var tag_pattern_exports = {}; + __export(tag_pattern_exports, { + svgTagPattern: () => svgTagPattern + }); function svgTagPattern(tags) { if (tags.building && tags.building !== "no") { return null; @@ -49501,8 +50568,95 @@ } return null; } + var patterns; + var init_tag_pattern = __esm({ + "modules/svg/tag_pattern.js"() { + "use strict"; + patterns = { + // tag - pattern name + // -or- + // tag - value - pattern name + // -or- + // tag - value - rules (optional tag-values, pattern name) + // (matches earlier rules first, so fallback should be last entry) + amenity: { + grave_yard: "cemetery", + fountain: "water_standing" + }, + landuse: { + cemetery: [ + { religion: "christian", pattern: "cemetery_christian" }, + { religion: "buddhist", pattern: "cemetery_buddhist" }, + { religion: "muslim", pattern: "cemetery_muslim" }, + { religion: "jewish", pattern: "cemetery_jewish" }, + { pattern: "cemetery" } + ], + construction: "construction", + farmland: "farmland", + farmyard: "farmyard", + forest: [ + { leaf_type: "broadleaved", pattern: "forest_broadleaved" }, + { leaf_type: "needleleaved", pattern: "forest_needleleaved" }, + { leaf_type: "leafless", pattern: "forest_leafless" }, + { pattern: "forest" } + // same as 'leaf_type:mixed' + ], + grave_yard: "cemetery", + grass: "grass", + landfill: "landfill", + meadow: "meadow", + military: "construction", + orchard: "orchard", + quarry: "quarry", + vineyard: "vineyard" + }, + leisure: { + horse_riding: "farmyard" + }, + natural: { + beach: "beach", + grassland: "grass", + sand: "beach", + scrub: "scrub", + water: [ + { water: "pond", pattern: "pond" }, + { water: "reservoir", pattern: "water_standing" }, + { pattern: "waves" } + ], + wetland: [ + { wetland: "marsh", pattern: "wetland_marsh" }, + { wetland: "swamp", pattern: "wetland_swamp" }, + { wetland: "bog", pattern: "wetland_bog" }, + { wetland: "reedbed", pattern: "wetland_reedbed" }, + { pattern: "wetland" } + ], + wood: [ + { leaf_type: "broadleaved", pattern: "forest_broadleaved" }, + { leaf_type: "needleleaved", pattern: "forest_needleleaved" }, + { leaf_type: "leafless", pattern: "forest_leafless" }, + { pattern: "forest" } + // same as 'leaf_type:mixed' + ] + }, + golf: { + green: "golf_green", + tee: "grass", + fairway: "grass", + rough: "scrub" + }, + surface: { + grass: "grass", + sand: "beach" + } + }; + } + }); // modules/svg/areas.js + var areas_exports = {}; + __export(areas_exports, { + svgAreas: () => svgAreas + }); function svgAreas(projection2, context) { function getPatternStyle(tags) { var imageID = svgTagPattern(tags); @@ -49629,16 +50783,81 @@ } return drawAreas; } + var import_fast_deep_equal5; + var init_areas = __esm({ + "modules/svg/areas.js"() { + "use strict"; + import_fast_deep_equal5 = __toESM(require_fast_deep_equal()); + init_src(); + init_osm(); + init_helpers(); + init_tag_classes(); + init_tag_pattern(); + } + }); - // modules/svg/data.js - var import_fast_json_stable_stringify = __toESM(require_fast_json_stable_stringify()); + // 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/@tmcw/togeojson/dist/togeojson.es.mjs function $(element, tagName) { return Array.from(element.getElementsByTagName(tagName)); } function normalizeId(id2) { - return id2[0] === "#" ? id2 : "#".concat(id2); + return id2[0] === "#" ? id2 : `#${id2}`; } function $ns(element, tagName, ns) { return Array.from(element.getElementsByTagNameNS(ns, tagName)); @@ -49744,7 +50963,7 @@ function getLineStyle(node) { return get3(node, "line", (lineStyle) => { const val = Object.assign({}, val1(lineStyle, "color", (color2) => { - return { stroke: "#".concat(color2) }; + return { stroke: `#${color2}` }; }), $num(lineStyle, "opacity", (opacity) => { return { "stroke-opacity": opacity }; }), $num(lineStyle, "width", (width) => { @@ -49754,7 +50973,7 @@ }); } function extractProperties(ns, node) { - var _a4; + var _a3; const properties = getMulti(node, [ "name", "cmt", @@ -49765,7 +50984,7 @@ ]); for (const [n3, url] of ns) { for (const child of Array.from(node.getElementsByTagNameNS(url, "*"))) { - properties[child.tagName.replace(":", "_")] = (_a4 = nodeVal(child)) == null ? void 0 : _a4.trim(); + properties[child.tagName.replace(":", "_")] = (_a3 = nodeVal(child)) == null ? void 0 : _a3.trim(); } } const links = $(node, "link"); @@ -49788,7 +51007,7 @@ if (c2.time) times.push(c2.time); for (const [name, val] of c2.extendedValues) { - const plural = name === "heart" ? name : "".concat(name.replace("gpxtpx:", ""), "s"); + const plural = name === "heart" ? name : `${name.replace("gpxtpx:", "")}s`; if (!extendedValues[plural]) { extendedValues[plural] = Array(pts.length).fill(null); } @@ -49817,7 +51036,7 @@ }; } function getTrack(ns, node) { - var _a4; + var _a3; const segments = $(node, "trkseg"); const track = []; const times = []; @@ -49826,7 +51045,7 @@ const line = getPoints$1(segment, "trkpt"); if (line) { extractedLines.push(line); - if ((_a4 = line.times) == null ? void 0 : _a4.length) + if ((_a3 = line.times) == null ? void 0 : _a3.length) times.push(line.times); } } @@ -49884,29 +51103,30 @@ }; } function* gpxGen(node) { - var _a4, _b3; + var _a3, _b2; + const n3 = node; const GPXX = "gpxx"; const GPXX_URI = "http://www.garmin.com/xmlschemas/GpxExtensions/v3"; const ns = [[GPXX, GPXX_URI]]; - const attrs = (_a4 = node.getElementsByTagName("gpx")[0]) == null ? void 0 : _a4.attributes; + const attrs = (_a3 = n3.getElementsByTagName("gpx")[0]) == null ? void 0 : _a3.attributes; if (attrs) { for (const attr of Array.from(attrs)) { - if (((_b3 = attr.name) == null ? void 0 : _b3.startsWith("xmlns:")) && attr.value !== GPXX_URI) { + if (((_b2 = attr.name) == null ? void 0 : _b2.startsWith("xmlns:")) && attr.value !== GPXX_URI) { ns.push([attr.name, attr.value]); } } } - for (const track of $(node, "trk")) { + for (const track of $(n3, "trk")) { const feature3 = getTrack(ns, track); if (feature3) yield feature3; } - for (const route of $(node, "rte")) { + for (const route of $(n3, "rte")) { const feature3 = getRoute(ns, route); if (feature3) yield feature3; } - for (const waypoint of $(node, "wpt")) { + for (const waypoint of $(n3, "wpt")) { const point = getPoint(ns, waypoint); if (point) yield point; @@ -49920,15 +51140,15 @@ } function fixColor(v2, prefix) { const properties = {}; - const colorProp = prefix === "stroke" || prefix === "fill" ? prefix : "".concat(prefix, "-color"); + const colorProp = prefix === "stroke" || prefix === "fill" ? prefix : `${prefix}-color`; if (v2[0] === "#") { v2 = v2.substring(1); } if (v2.length === 6 || v2.length === 3) { - properties[colorProp] = "#".concat(v2); + properties[colorProp] = `#${v2}`; } else if (v2.length === 8) { - properties["".concat(prefix, "-opacity")] = Number.parseInt(v2.substring(0, 2), 16) / 255; - properties[colorProp] = "#".concat(v2.substring(6, 8)).concat(v2.substring(4, 6)).concat(v2.substring(2, 4)); + properties[`${prefix}-opacity`] = Number.parseInt(v2.substring(0, 2), 16) / 255; + properties[colorProp] = `#${v2.substring(6, 8)}${v2.substring(4, 6)}${v2.substring(2, 4)}`; } return properties; } @@ -49990,9 +51210,6 @@ function extractStyle(node) { return Object.assign({}, extractPoly(node), extractLine(node), extractLabel(node), extractIcon(node)); } - var removeSpace = /\s*/g; - var trimSpace = /^\s*|\s*$/g; - var splitSpace = /\s+/; function coord1(value) { return value.replace(removeSpace, "").split(",").map(Number.parseFloat).filter((num) => !Number.isNaN(num)).slice(0, 3); } @@ -50114,17 +51331,6 @@ coordTimes }; } - var toNumber2 = (x2) => Number(x2); - var typeConverters = { - string: (x2) => x2, - int: toNumber2, - uint: toNumber2, - short: toNumber2, - ushort: toNumber2, - float: toNumber2, - double: toNumber2, - bool: (x2) => Boolean(x2) - }; function extractExtendedData(node, schema) { return get3(node, "ExtendedData", (extendedData, properties) => { for (const data of $(extendedData, "Data")) { @@ -50189,7 +51395,6 @@ } return getLatLonBox(node); } - var DEGREES_TO_RADIANS = Math.PI / 180; function rotateBox(bbox2, coordinates, rotation) { const center = [(bbox2[0] + bbox2[2]) / 2, (bbox2[1] + bbox2[3]) / 2]; return [ @@ -50244,7 +51449,7 @@ return null; } function getGroundOverlay(node, styleMap, schema, options2) { - var _a4; + var _a3; const box = getGroundOverlayBox(node); const geometry = (box == null ? void 0 : box.geometry) || null; if (!geometry && options2.skipNullGeometry) { @@ -50279,7 +51484,7 @@ if (box == null ? void 0 : box.bbox) { feature3.bbox = box.bbox; } - if (((_a4 = feature3.properties) == null ? void 0 : _a4.visibility) !== void 0) { + if (((_a3 = feature3.properties) == null ? void 0 : _a3.visibility) !== void 0) { feature3.properties.visibility = feature3.properties.visibility !== "0"; } const id2 = node.getAttribute("id"); @@ -50294,7 +51499,7 @@ }; } function getPlacemark(node, styleMap, schema, options2) { - var _a4; + var _a3; const { coordTimes, geometries } = getGeometry(node); const geometry = geometryListToGeometry(geometries); if (!geometry && options2.skipNullGeometry) { @@ -50316,7 +51521,7 @@ } } : {}) }; - if (((_a4 = feature3.properties) == null ? void 0 : _a4.visibility) !== void 0) { + if (((_a3 = feature3.properties) == null ? void 0 : _a3.visibility) !== void 0) { feature3.properties.visibility = feature3.properties.visibility !== "0"; } const id2 = node.getAttribute("id"); @@ -50358,14 +51563,15 @@ function* kmlGen(node, options2 = { skipNullGeometry: false }) { - const styleMap = buildStyleMap(node); - const schema = buildSchema(node); - for (const placemark of $(node, "Placemark")) { + const n3 = node; + const styleMap = buildStyleMap(n3); + const schema = buildSchema(n3); + for (const placemark of $(n3, "Placemark")) { const feature3 = getPlacemark(placemark, styleMap, schema, options2); if (feature3) yield feature3; } - for (const groundOverlay of $(node, "GroundOverlay")) { + for (const groundOverlay of $(n3, "GroundOverlay")) { const feature3 = getGroundOverlay(groundOverlay, styleMap, schema, options2); if (feature3) yield feature3; @@ -50379,11 +51585,32 @@ features: Array.from(kmlGen(node, options2)) }; } + var removeSpace, trimSpace, splitSpace, toNumber2, typeConverters, DEGREES_TO_RADIANS; + var init_togeojson_es = __esm({ + "node_modules/@tmcw/togeojson/dist/togeojson.es.mjs"() { + removeSpace = /\s*/g; + trimSpace = /^\s*|\s*$/g; + splitSpace = /\s+/; + toNumber2 = (x2) => Number(x2); + typeConverters = { + string: (x2) => x2, + int: toNumber2, + uint: toNumber2, + short: toNumber2, + ushort: toNumber2, + float: toNumber2, + double: toNumber2, + bool: (x2) => Boolean(x2) + }; + DEGREES_TO_RADIANS = Math.PI / 180; + } + }); // modules/svg/data.js - var _initialized = false; - var _enabled = false; - var _geojson; + var data_exports = {}; + __export(data_exports, { + svgData: () => svgData + }); function svgData(projection2, context, dispatch14) { var throttledRedraw = throttle_default(function() { dispatch14.call("change"); @@ -50743,8 +51970,31 @@ init2(); return drawData; } + var import_fast_json_stable_stringify, _initialized, _enabled, _geojson; + var init_data2 = __esm({ + "modules/svg/data.js"() { + "use strict"; + init_throttle(); + init_src2(); + init_src18(); + init_src5(); + import_fast_json_stable_stringify = __toESM(require_fast_json_stable_stringify()); + init_togeojson_es(); + init_geo2(); + init_services(); + init_helpers(); + init_detect(); + init_util(); + _initialized = false; + _enabled = false; + } + }); // modules/svg/debug.js + var debug_exports = {}; + __export(debug_exports, { + svgDebug: () => svgDebug + }); function svgDebug(projection2, context) { function drawDebug(selection2) { const showTile = context.getDebug("tile"); @@ -50773,7 +52023,7 @@ legend = legend.enter().append("div").attr("class", "fillD debug-legend").merge(legend); let legendItems = legend.selectAll(".debug-legend-item").data(debugData, (d2) => d2.label); legendItems.exit().remove(); - legendItems.enter().append("span").attr("class", (d2) => "debug-legend-item ".concat(d2.class)).text((d2) => d2.label); + legendItems.enter().append("span").attr("class", (d2) => `debug-legend-item ${d2.class}`).text((d2) => d2.label); let layer = selection2.selectAll(".layer-debug").data(showImagery || showDownloaded ? [0] : []); layer.exit().remove(); layer = layer.enter().append("g").attr("class", "layer-debug").merge(layer); @@ -50821,8 +52071,19 @@ }; return drawDebug; } + var init_debug = __esm({ + "modules/svg/debug.js"() { + "use strict"; + init_file_fetcher(); + init_helpers(); + } + }); // modules/svg/defs.js + var defs_exports = {}; + __export(defs_exports, { + svgDefs: () => svgDefs + }); function svgDefs(context) { var _defsSelection = select_default2(null); var _spritesheetIds = [ @@ -50836,11 +52097,11 @@ function drawDefs(selection2) { _defsSelection = selection2.append("defs"); function addOnewayMarker(name, colour) { - _defsSelection.append("marker").attr("id", "ideditor-oneway-marker-".concat(name)).attr("viewBox", "0 0 10 5").attr("refX", 2.5).attr("refY", 2.5).attr("markerWidth", 2).attr("markerHeight", 2).attr("markerUnits", "strokeWidth").attr("orient", "auto").append("path").attr("class", "oneway-marker-path").attr("d", "M 5,3 L 0,3 L 0,2 L 5,2 L 5,0 L 10,2.5 L 5,5 z").attr("stroke", "none").attr("fill", colour).attr("opacity", "0.75"); + _defsSelection.append("marker").attr("id", `ideditor-oneway-marker-${name}`).attr("viewBox", "0 0 10 5").attr("refX", 4).attr("refY", 2.5).attr("markerWidth", 2).attr("markerHeight", 2).attr("markerUnits", "strokeWidth").attr("orient", "auto").append("path").attr("class", "oneway-marker-path").attr("d", "M 6,3 L 0,3 L 0,2 L 6,2 L 5,0 L 10,2.5 L 5,5 z").attr("stroke", "none").attr("fill", colour).attr("opacity", "1"); } - addOnewayMarker("black", "#000"); + addOnewayMarker("black", "#333"); addOnewayMarker("white", "#fff"); - addOnewayMarker("pink", "#eaf"); + addOnewayMarker("gray", "#eee"); function addSidedMarker(name, color2, offset) { _defsSelection.append("marker").attr("id", "ideditor-sided-marker-" + name).attr("viewBox", "0 0 2 2").attr("refX", 1).attr("refY", -offset).attr("markerWidth", 1.5).attr("markerHeight", 1.5).attr("markerUnits", "strokeWidth").attr("orient", "auto").append("path").attr("class", "sided-marker-path sided-marker-" + name + "-path").attr("d", "M 0,0 L 1,1 L 2,0 z").attr("stroke", "none").attr("fill", color2); } @@ -50929,10 +52190,20 @@ drawDefs.addSprites = addSprites; return drawDefs; } + var init_defs = __esm({ + "modules/svg/defs.js"() { + "use strict"; + init_src18(); + init_src5(); + init_util(); + } + }); // modules/svg/keepRight.js - var _layerEnabled = false; - var _qaService; + var keepRight_exports2 = {}; + __export(keepRight_exports2, { + svgKeepRight: () => svgKeepRight + }); function svgKeepRight(projection2, context, dispatch14) { const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3); const minZoom5 = 12; @@ -50986,7 +52257,7 @@ const getTransform = svgPointTransform(projection2); const markers = drawLayer.selectAll(".qaItem.keepRight").data(data, (d2) => d2.id); markers.exit().remove(); - const markersEnter = markers.enter().append("g").attr("class", (d2) => "qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.parentIssueType)); + const markersEnter = markers.enter().append("g").attr("class", (d2) => `qaItem ${d2.service} itemId-${d2.id} itemType-${d2.parentIssueType}`); markersEnter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke"); markersEnter.append("path").call(markerPath, "shadow"); markersEnter.append("use").attr("class", "qaItem-fill").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").attr("xlink:href", "#iD-icon-bolt"); @@ -50995,7 +52266,7 @@ const fillClass = context.getDebug("target") ? "pink " : "nocolor "; const targets = touchLayer.selectAll(".qaItem.keepRight").data(data, (d2) => d2.id); targets.exit().remove(); - targets.enter().append("rect").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").merge(targets).sort(sortY).attr("class", (d2) => "qaItem ".concat(d2.service, " target ").concat(fillClass, " itemId-").concat(d2.id)).attr("transform", getTransform); + targets.enter().append("rect").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").merge(targets).sort(sortY).attr("class", (d2) => `qaItem ${d2.service} target ${fillClass} itemId-${d2.id}`).attr("transform", getTransform); function sortY(a2, b2) { return a2.id === selectedID ? 1 : b2.id === selectedID ? -1 : a2.severity === "error" && b2.severity !== "error" ? 1 : b2.severity === "error" && a2.severity !== "error" ? -1 : b2.loc[1] - a2.loc[1]; } @@ -51036,8 +52307,24 @@ drawKeepRight.supported = () => !!getService(); return drawKeepRight; } + var _layerEnabled, _qaService; + var init_keepRight2 = __esm({ + "modules/svg/keepRight.js"() { + "use strict"; + init_throttle(); + init_src5(); + init_browse(); + init_helpers(); + init_services(); + _layerEnabled = false; + } + }); // modules/svg/geolocate.js + var geolocate_exports = {}; + __export(geolocate_exports, { + svgGeolocate: () => svgGeolocate + }); function svgGeolocate(projection2) { var layer = select_default2(null); var _position; @@ -51103,8 +52390,20 @@ init2(); return drawLocation; } + var init_geolocate = __esm({ + "modules/svg/geolocate.js"() { + "use strict"; + init_src5(); + init_helpers(); + init_geo2(); + } + }); // modules/svg/labels.js + var labels_exports = {}; + __export(labels_exports, { + svgLabels: () => svgLabels + }); function svgLabels(projection2, context) { var path = path_default(projection2); var detected = utilDetect(); @@ -51513,2022 +52812,3162 @@ return p3; } } - function addIcon() { - var iconX = centroid[0] - iconSize / 2; - var iconY = centroid[1] - iconSize / 2; - var bbox3 = { - minX: iconX, - minY: iconY, - maxX: iconX + iconSize, - maxY: iconY + iconSize - }; - if (tryInsert([bbox3], entity2.id + "I", true)) { - p3.transform = "translate(" + iconX + "," + iconY + ")"; - return true; + function addIcon() { + var iconX = centroid[0] - iconSize / 2; + var iconY = centroid[1] - iconSize / 2; + var bbox3 = { + minX: iconX, + minY: iconY, + maxX: iconX + iconSize, + maxY: iconY + iconSize + }; + if (tryInsert([bbox3], entity2.id + "I", true)) { + p3.transform = "translate(" + iconX + "," + iconY + ")"; + return true; + } + return false; + } + function addLabel(yOffset) { + if (width2 && areaWidth >= width2 + 20) { + var labelX = centroid[0]; + var labelY = centroid[1] + yOffset; + var bbox3 = { + minX: labelX - width2 / 2 - padding, + minY: labelY - height / 2 - padding, + maxX: labelX + width2 / 2 + padding, + maxY: labelY + height / 2 + padding + }; + if (tryInsert([bbox3], entity2.id, true)) { + p3.x = labelX; + p3.y = labelY; + p3.textAnchor = "middle"; + p3.height = height; + return true; + } + } + return false; + } + } + function doInsert(bbox3, id2) { + bbox3.id = id2; + var oldbox = _entitybboxes[id2]; + if (oldbox) { + _rdrawn.remove(oldbox); + } + _entitybboxes[id2] = bbox3; + _rdrawn.insert(bbox3); + } + function tryInsert(bboxes, id2, saveSkipped) { + var skipped = false; + for (var i4 = 0; i4 < bboxes.length; i4++) { + var bbox3 = bboxes[i4]; + bbox3.id = id2; + if (bbox3.minX < 0 || bbox3.minY < 0 || bbox3.maxX > dimensions[0] || bbox3.maxY > dimensions[1]) { + skipped = true; + break; + } + if (_rdrawn.collides(bbox3)) { + skipped = true; + break; + } + } + _entitybboxes[id2] = bboxes; + if (skipped) { + if (saveSkipped) { + _rskipped.load(bboxes); + } + } else { + _rdrawn.load(bboxes); + } + return !skipped; + } + var layer = selection2.selectAll(".layer-osm.labels"); + layer.selectAll(".labels-group").data(["halo", "label", "debug"]).enter().append("g").attr("class", function(d2) { + return "labels-group " + d2; + }); + var halo = layer.selectAll(".labels-group.halo"); + var label = layer.selectAll(".labels-group.label"); + var debug2 = layer.selectAll(".labels-group.debug"); + drawPointLabels(label, labelled.point, filter2, "pointlabel", positions.point); + drawPointLabels(halo, labelled.point, filter2, "pointlabel-halo", positions.point); + drawLinePaths(layer, labelled.line, filter2, "", positions.line); + drawLineLabels(label, labelled.line, filter2, "linelabel", positions.line); + drawLineLabels(halo, labelled.line, filter2, "linelabel-halo", positions.line); + drawAreaLabels(label, labelled.area, filter2, "arealabel", positions.area); + drawAreaLabels(halo, labelled.area, filter2, "arealabel-halo", positions.area); + drawAreaIcons(label, labelled.area, filter2, "areaicon", positions.area); + drawAreaIcons(halo, labelled.area, filter2, "areaicon-halo", positions.area); + drawCollisionBoxes(debug2, _rskipped, "debug-skipped"); + drawCollisionBoxes(debug2, _rdrawn, "debug-drawn"); + layer.call(filterLabels); + } + function filterLabels(selection2) { + var drawLayer = selection2.selectAll(".layer-osm.labels"); + var layers = drawLayer.selectAll(".labels-group.halo, .labels-group.label"); + layers.selectAll(".nolabel").classed("nolabel", false); + var mouse = context.map().mouse(); + var graph = context.graph(); + var selectedIDs = context.selectedIDs(); + var ids = []; + var pad3, bbox2; + if (mouse) { + pad3 = 20; + bbox2 = { minX: mouse[0] - pad3, minY: mouse[1] - pad3, maxX: mouse[0] + pad3, maxY: mouse[1] + pad3 }; + var nearMouse = _rdrawn.search(bbox2).map(function(entity2) { + return entity2.id; + }); + ids.push.apply(ids, nearMouse); + } + for (var i3 = 0; i3 < selectedIDs.length; i3++) { + var entity = graph.hasEntity(selectedIDs[i3]); + if (entity && entity.type === "node") { + ids.push(selectedIDs[i3]); + } + } + layers.selectAll(utilEntitySelector(ids)).classed("nolabel", true); + var debug2 = selection2.selectAll(".labels-group.debug"); + var gj = []; + if (context.getDebug("collision")) { + gj = bbox2 ? [{ + type: "Polygon", + coordinates: [[ + [bbox2.minX, bbox2.minY], + [bbox2.maxX, bbox2.minY], + [bbox2.maxX, bbox2.maxY], + [bbox2.minX, bbox2.maxY], + [bbox2.minX, bbox2.minY] + ]] + }] : []; + } + var box = debug2.selectAll(".debug-mouse").data(gj); + box.exit().remove(); + box.enter().append("path").attr("class", "debug debug-mouse yellow").merge(box).attr("d", path_default()); + } + var throttleFilterLabels = throttle_default(filterLabels, 100); + drawLabels.observe = function(selection2) { + var listener = function() { + throttleFilterLabels(selection2); + }; + selection2.on("mousemove.hidelabels", listener); + context.on("enter.hidelabels", listener); + }; + drawLabels.off = function(selection2) { + throttleFilterLabels.cancel(); + selection2.on("mousemove.hidelabels", null); + context.on("enter.hidelabels", null); + }; + return drawLabels; + } + var init_labels = __esm({ + "modules/svg/labels.js"() { + "use strict"; + init_throttle(); + init_src2(); + init_rbush(); + init_localizer(); + init_geo2(); + init_presets(); + init_osm(); + init_detect(); + init_util(); + } + }); + + // node_modules/exifr/dist/full.esm.mjs + function l(e3, t2 = o) { + if (n2) try { + return "function" == typeof __require ? Promise.resolve(t2(__require(e3))) : import( + /* webpackIgnore: true */ + e3 + ).then(t2); + } catch (t3) { + console.warn(`Couldn't load ${e3}`); + } + } + 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; + } + function p(e3) { + return void 0 === e3 || (e3 instanceof Map ? 0 === e3.size : 0 === Object.values(e3).filter(d).length); + } + function g2(e3) { + let t2 = new Error(e3); + throw delete t2.stack, t2; + } + function m(e3) { + return "" === (e3 = function(e4) { + for (; e4.endsWith("\0"); ) e4 = e4.slice(0, -1); + return e4; + }(e3).trim()) ? void 0 : e3; + } + function S(e3) { + let t2 = function(e4) { + let t3 = 0; + return e4.ifd0.enabled && (t3 += 1024), e4.exif.enabled && (t3 += 2048), e4.makerNote && (t3 += 2048), e4.userComment && (t3 += 1024), e4.gps.enabled && (t3 += 512), e4.interop.enabled && (t3 += 100), e4.ifd1.enabled && (t3 += 1024), t3 + 2048; + }(e3); + return e3.jfif.enabled && (t2 += 50), e3.xmp.enabled && (t2 += 2e4), e3.iptc.enabled && (t2 += 14e3), e3.icc.enabled && (t2 += 6e3), t2; + } + function b(e3) { + return y ? y.decode(e3) : a ? Buffer.from(e3).toString("utf8") : decodeURIComponent(escape(C(e3))); + } + function P(e3, t2) { + g2(`${e3} '${t2}' was not loaded, try using full build of exifr.`); + } + function D(e3, n3) { + return "string" == typeof e3 ? O(e3, n3) : t && !i2 && e3 instanceof HTMLImageElement ? O(e3.src, n3) : e3 instanceof Uint8Array || e3 instanceof ArrayBuffer || e3 instanceof DataView ? new I(e3) : t && e3 instanceof Blob ? x(e3, n3, "blob", R) : void g2("Invalid input argument"); + } + function O(e3, i3) { + return (s2 = e3).startsWith("data:") || s2.length > 1e4 ? v(e3, i3, "base64") : n2 && e3.includes("://") ? x(e3, i3, "url", M) : n2 ? v(e3, i3, "fs") : t ? x(e3, i3, "url", M) : void g2("Invalid input argument"); + var s2; + } + async function x(e3, t2, i3, n3) { + return A.has(i3) ? v(e3, t2, i3) : n3 ? async function(e4, t3) { + let i4 = await t3(e4); + return new I(i4); + }(e3, n3) : void g2(`Parser ${i3} is not loaded`); + } + async function v(e3, t2, i3) { + let n3 = new (A.get(i3))(e3, t2); + return await n3.read(), n3; + } + function U(e3, t2, i3) { + let n3 = new L(); + for (let [e4, t3] of i3) n3.set(e4, t3); + if (Array.isArray(t2)) for (let i4 of t2) e3.set(i4, n3); + else e3.set(t2, n3); + return n3; + } + function F(e3, t2, i3) { + let n3, s2 = e3.get(t2); + for (n3 of i3) s2.set(n3[0], n3[1]); + } + function Q(e3, t2) { + let i3, n3, s2, r2, a2 = []; + for (s2 of t2) { + for (r2 of (i3 = E.get(s2), n3 = [], i3)) (e3.includes(r2[0]) || e3.includes(r2[1])) && n3.push(r2[0]); + n3.length && a2.push([s2, n3]); + } + return a2; + } + function Z(e3, t2) { + return void 0 !== e3 ? e3 : void 0 !== t2 ? t2 : void 0; + } + function ee(e3, t2) { + for (let i3 of t2) e3.add(i3); + } + async function ie(e3, t2) { + let i3 = new te(t2); + return await i3.read(e3), i3.parse(); + } + function ae(e3) { + return 192 === e3 || 194 === e3 || 196 === e3 || 219 === e3 || 221 === e3 || 218 === e3 || 254 === e3; + } + function oe(e3) { + return e3 >= 224 && e3 <= 239; + } + function le(e3, t2, i3) { + for (let [n3, s2] of T) if (s2.canHandle(e3, t2, i3)) return n3; + } + function de(e3, t2, i3, n3) { + var s2 = e3 + t2 / 60 + i3 / 3600; + return "S" !== n3 && "W" !== n3 || (s2 *= -1), s2; + } + async function Se(e3) { + let t2 = new te(me); + await t2.read(e3); + let i3 = await t2.parse(); + if (i3 && i3.gps) { + let { latitude: e4, longitude: t3 } = i3.gps; + return { latitude: e4, longitude: t3 }; + } + } + async function ye(e3) { + let t2 = new te(Ce); + await t2.read(e3); + let i3 = await t2.extractThumbnail(); + return i3 && a ? s.from(i3) : i3; + } + async function be(e3) { + let t2 = await this.thumbnail(e3); + if (void 0 !== t2) { + let e4 = new Blob([t2]); + return URL.createObjectURL(e4); + } + } + async function Pe(e3) { + let t2 = new te(Ie); + await t2.read(e3); + let i3 = await t2.parse(); + if (i3 && i3.ifd0) return i3.ifd0[274]; + } + async function Ae(e3) { + let t2 = await Pe(e3); + return Object.assign({ canvas: we, css: Te }, ke[t2]); + } + function xe(e3, t2, i3) { + return e3 <= t2 && t2 <= i3; + } + function Ge(e3) { + return "object" == typeof e3 && void 0 !== e3.length ? e3[0] : e3; + } + function Ve(e3) { + let t2 = Array.from(e3).slice(1); + return t2[1] > 15 && (t2 = t2.map((e4) => String.fromCharCode(e4))), "0" !== t2[2] && 0 !== t2[2] || t2.pop(), t2.join("."); + } + function ze(e3) { + if ("string" == typeof e3) { + var [t2, i3, n3, s2, r2, a2] = e3.trim().split(/[-: ]/g).map(Number), o2 = new Date(t2, i3 - 1, n3); + return Number.isNaN(s2) || Number.isNaN(r2) || Number.isNaN(a2) || (o2.setHours(s2), o2.setMinutes(r2), o2.setSeconds(a2)), Number.isNaN(+o2) ? e3 : o2; + } + } + function He(e3) { + if ("string" == typeof e3) return e3; + let t2 = []; + if (0 === e3[1] && 0 === e3[e3.length - 1]) for (let i3 = 0; i3 < e3.length; i3 += 2) t2.push(je(e3[i3 + 1], e3[i3])); + else for (let i3 = 0; i3 < e3.length; i3 += 2) t2.push(je(e3[i3], e3[i3 + 1])); + return m(String.fromCodePoint(...t2)); + } + function je(e3, t2) { + return e3 << 8 | t2; + } + function _e(e3, t2) { + let i3 = e3.serialize(); + void 0 !== i3 && (t2[e3.name] = i3); + } + function qe(e3, t2) { + let i3, n3 = []; + if (!e3) return n3; + for (; null !== (i3 = t2.exec(e3)); ) n3.push(i3); + return n3; + } + function Qe(e3) { + if (function(e4) { + return null == e4 || "null" === e4 || "undefined" === e4 || "" === e4 || "" === e4.trim(); + }(e3)) return; + let t2 = Number(e3); + if (!Number.isNaN(t2)) return t2; + let i3 = e3.toLowerCase(); + return "true" === i3 || "false" !== i3 && e3.trim(); + } + function mt(e3, t2) { + return m(e3.getString(t2, 4)); + } + var e, t, i2, n2, s, r, a, o, h, u, f, d, C, y, I, k, w, T, A, M, R, L, E, B, N, G, V, z, H, j, W, K, X, _, Y, $2, J, q, te, ne, se, re2, he, ue, ce, fe, pe, ge, me, Ce, Ie, ke, we, Te, De, Oe, ve, Me, Re, Le, Ue, Fe, Ee, Be, Ne, We, Ke, Xe, Ye, $e, Je, Ze, et, tt, at, ot, lt, ht, ut, ct, ft, dt, pt, gt, St, Ct, yt, full_esm_default; + var init_full_esm = __esm({ + "node_modules/exifr/dist/full.esm.mjs"() { + e = "undefined" != typeof self ? self : global; + t = "undefined" != typeof navigator; + i2 = t && "undefined" == typeof HTMLImageElement; + n2 = !("undefined" == typeof global || "undefined" == typeof process || !process.versions || !process.versions.node); + s = e.Buffer; + r = e.BigInt; + a = !!s; + o = (e3) => e3; + h = e.fetch; + u = (e3) => h = e3; + 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 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); + } + r2({ status: e4.statusCode, arrayBuffer: () => new Promise((t3) => { + let i4 = []; + e4.on("data", (e6) => i4.push(e6)), e4.on("end", () => t3(Buffer.concat(i4))); + }) }); + }); + d2.on("error", a2), d2.end(); + }); + u(i3); + } + f = (e3) => p(e3) ? void 0 : e3; + d = (e3) => void 0 !== e3; + C = (e3) => String.fromCharCode.apply(null, e3); + y = "undefined" != typeof TextDecoder ? new TextDecoder("utf-8") : void 0; + I = class _I { + static from(e3, t2) { + return e3 instanceof this && e3.le === t2 ? e3 : new _I(e3, void 0, void 0, t2); + } + constructor(e3, t2 = 0, i3, n3) { + if ("boolean" == typeof n3 && (this.le = n3), Array.isArray(e3) && (e3 = new Uint8Array(e3)), 0 === e3) this.byteOffset = 0, this.byteLength = 0; + else if (e3 instanceof ArrayBuffer) { + void 0 === i3 && (i3 = e3.byteLength - t2); + let n4 = new DataView(e3, t2, i3); + this._swapDataView(n4); + } else if (e3 instanceof Uint8Array || e3 instanceof DataView || e3 instanceof _I) { + void 0 === i3 && (i3 = e3.byteLength - t2), (t2 += e3.byteOffset) + i3 > e3.byteOffset + e3.byteLength && g2("Creating view outside of available memory in ArrayBuffer"); + let n4 = new DataView(e3.buffer, t2, i3); + this._swapDataView(n4); + } else if ("number" == typeof e3) { + let t3 = new DataView(new ArrayBuffer(e3)); + this._swapDataView(t3); + } else g2("Invalid input argument for BufferView: " + e3); + } + _swapArrayBuffer(e3) { + this._swapDataView(new DataView(e3)); + } + _swapBuffer(e3) { + this._swapDataView(new DataView(e3.buffer, e3.byteOffset, e3.byteLength)); + } + _swapDataView(e3) { + this.dataView = e3, this.buffer = e3.buffer, this.byteOffset = e3.byteOffset, this.byteLength = e3.byteLength; + } + _lengthToEnd(e3) { + return this.byteLength - e3; + } + set(e3, t2, i3 = _I) { + return e3 instanceof DataView || e3 instanceof _I ? e3 = new Uint8Array(e3.buffer, e3.byteOffset, e3.byteLength) : e3 instanceof ArrayBuffer && (e3 = new Uint8Array(e3)), e3 instanceof Uint8Array || g2("BufferView.set(): Invalid data argument."), this.toUint8().set(e3, t2), new i3(this, t2, e3.byteLength); + } + subarray(e3, t2) { + return t2 = t2 || this._lengthToEnd(e3), new _I(this, e3, t2); + } + toUint8() { + return new Uint8Array(this.buffer, this.byteOffset, this.byteLength); + } + getUint8Array(e3, t2) { + return new Uint8Array(this.buffer, this.byteOffset + e3, t2); + } + getString(e3 = 0, t2 = this.byteLength) { + return b(this.getUint8Array(e3, t2)); + } + getLatin1String(e3 = 0, t2 = this.byteLength) { + let i3 = this.getUint8Array(e3, t2); + return C(i3); + } + getUnicodeString(e3 = 0, t2 = this.byteLength) { + const i3 = []; + for (let n3 = 0; n3 < t2 && e3 + n3 < this.byteLength; n3 += 2) i3.push(this.getUint16(e3 + n3)); + return C(i3); + } + getInt8(e3) { + return this.dataView.getInt8(e3); + } + getUint8(e3) { + return this.dataView.getUint8(e3); + } + getInt16(e3, t2 = this.le) { + return this.dataView.getInt16(e3, t2); + } + getInt32(e3, t2 = this.le) { + return this.dataView.getInt32(e3, t2); + } + getUint16(e3, t2 = this.le) { + return this.dataView.getUint16(e3, t2); + } + getUint32(e3, t2 = this.le) { + return this.dataView.getUint32(e3, t2); + } + getFloat32(e3, t2 = this.le) { + return this.dataView.getFloat32(e3, t2); + } + getFloat64(e3, t2 = this.le) { + return this.dataView.getFloat64(e3, t2); + } + getFloat(e3, t2 = this.le) { + return this.dataView.getFloat32(e3, t2); + } + getDouble(e3, t2 = this.le) { + return this.dataView.getFloat64(e3, t2); + } + getUintBytes(e3, t2, i3) { + switch (t2) { + case 1: + return this.getUint8(e3, i3); + case 2: + return this.getUint16(e3, i3); + case 4: + return this.getUint32(e3, i3); + case 8: + return this.getUint64 && this.getUint64(e3, i3); + } + } + getUint(e3, t2, i3) { + switch (t2) { + case 8: + return this.getUint8(e3, i3); + case 16: + return this.getUint16(e3, i3); + case 32: + return this.getUint32(e3, i3); + case 64: + return this.getUint64 && this.getUint64(e3, i3); + } + } + toString(e3) { + return this.dataView.toString(e3, this.constructor.name); + } + ensureChunk() { + } + }; + k = class extends Map { + constructor(e3) { + super(), this.kind = e3; + } + get(e3, t2) { + return this.has(e3) || P(this.kind, e3), t2 && (e3 in t2 || function(e4, t3) { + g2(`Unknown ${e4} '${t3}'.`); + }(this.kind, e3), t2[e3].enabled || P(this.kind, e3)), super.get(e3); + } + keyList() { + return Array.from(this.keys()); + } + }; + w = new k("file parser"); + T = new k("segment parser"); + A = new k("file reader"); + M = (e3) => h(e3).then((e4) => e4.arrayBuffer()); + R = (e3) => new Promise((t2, i3) => { + let n3 = new FileReader(); + n3.onloadend = () => t2(n3.result || new ArrayBuffer()), n3.onerror = i3, n3.readAsArrayBuffer(e3); + }); + L = class extends Map { + get tagKeys() { + return this.allKeys || (this.allKeys = Array.from(this.keys())), this.allKeys; + } + get tagValues() { + return this.allValues || (this.allValues = Array.from(this.values())), this.allValues; + } + }; + E = /* @__PURE__ */ new Map(); + B = /* @__PURE__ */ new Map(); + N = /* @__PURE__ */ new Map(); + G = ["chunked", "firstChunkSize", "firstChunkSizeNode", "firstChunkSizeBrowser", "chunkSize", "chunkLimit"]; + V = ["jfif", "xmp", "icc", "iptc", "ihdr"]; + z = ["tiff", ...V]; + H = ["ifd0", "ifd1", "exif", "gps", "interop"]; + j = [...z, ...H]; + W = ["makerNote", "userComment"]; + K = ["translateKeys", "translateValues", "reviveValues", "multiSegment"]; + X = [...K, "sanitize", "mergeOutput", "silentErrors"]; + _ = class { + get translate() { + return this.translateKeys || this.translateValues || this.reviveValues; + } + }; + Y = class extends _ { + get needed() { + return this.enabled || this.deps.size > 0; + } + constructor(e3, t2, i3, n3) { + if (super(), c(this, "enabled", false), c(this, "skip", /* @__PURE__ */ new Set()), c(this, "pick", /* @__PURE__ */ new Set()), c(this, "deps", /* @__PURE__ */ new Set()), c(this, "translateKeys", false), c(this, "translateValues", false), c(this, "reviveValues", false), this.key = e3, this.enabled = t2, this.parse = this.enabled, this.applyInheritables(n3), this.canBeFiltered = H.includes(e3), this.canBeFiltered && (this.dict = E.get(e3)), void 0 !== i3) if (Array.isArray(i3)) this.parse = this.enabled = true, this.canBeFiltered && i3.length > 0 && this.translateTagSet(i3, this.pick); + else if ("object" == typeof i3) { + if (this.enabled = true, this.parse = false !== i3.parse, this.canBeFiltered) { + let { pick: e4, skip: t3 } = i3; + e4 && e4.length > 0 && this.translateTagSet(e4, this.pick), t3 && t3.length > 0 && this.translateTagSet(t3, this.skip); + } + this.applyInheritables(i3); + } else true === i3 || false === i3 ? this.parse = this.enabled = i3 : g2(`Invalid options argument: ${i3}`); + } + applyInheritables(e3) { + let t2, i3; + for (t2 of K) i3 = e3[t2], void 0 !== i3 && (this[t2] = i3); + } + translateTagSet(e3, t2) { + if (this.dict) { + let i3, n3, { tagKeys: s2, tagValues: r2 } = this.dict; + for (i3 of e3) "string" == typeof i3 ? (n3 = r2.indexOf(i3), -1 === n3 && (n3 = s2.indexOf(Number(i3))), -1 !== n3 && t2.add(Number(s2[n3]))) : t2.add(i3); + } else for (let i3 of e3) t2.add(i3); + } + finalizeFilters() { + !this.enabled && this.deps.size > 0 ? (this.enabled = true, ee(this.pick, this.deps)) : this.enabled && this.pick.size > 0 && ee(this.pick, this.deps); + } + }; + $2 = { jfif: false, tiff: true, xmp: false, icc: false, iptc: false, ifd0: true, ifd1: false, exif: true, gps: true, interop: false, ihdr: void 0, makerNote: false, userComment: false, multiSegment: false, skip: [], pick: [], translateKeys: true, translateValues: true, reviveValues: true, sanitize: true, mergeOutput: true, silentErrors: true, chunked: true, firstChunkSize: void 0, firstChunkSizeNode: 512, firstChunkSizeBrowser: 65536, chunkSize: 65536, chunkLimit: 5 }; + J = /* @__PURE__ */ new Map(); + q = class extends _ { + static useCached(e3) { + let t2 = J.get(e3); + return void 0 !== t2 || (t2 = new this(e3), J.set(e3, t2)), t2; + } + constructor(e3) { + super(), true === e3 ? this.setupFromTrue() : void 0 === e3 ? this.setupFromUndefined() : Array.isArray(e3) ? this.setupFromArray(e3) : "object" == typeof e3 ? this.setupFromObject(e3) : g2(`Invalid options argument ${e3}`), void 0 === this.firstChunkSize && (this.firstChunkSize = t ? this.firstChunkSizeBrowser : this.firstChunkSizeNode), this.mergeOutput && (this.ifd1.enabled = false), this.filterNestedSegmentTags(), this.traverseTiffDependencyTree(), this.checkLoadedPlugins(); + } + setupFromUndefined() { + let e3; + for (e3 of G) this[e3] = $2[e3]; + for (e3 of X) this[e3] = $2[e3]; + for (e3 of W) this[e3] = $2[e3]; + for (e3 of j) this[e3] = new Y(e3, $2[e3], void 0, this); + } + setupFromTrue() { + let e3; + for (e3 of G) this[e3] = $2[e3]; + for (e3 of X) this[e3] = $2[e3]; + for (e3 of W) this[e3] = true; + for (e3 of j) this[e3] = new Y(e3, true, void 0, this); + } + setupFromArray(e3) { + let t2; + for (t2 of G) this[t2] = $2[t2]; + for (t2 of X) this[t2] = $2[t2]; + for (t2 of W) this[t2] = $2[t2]; + for (t2 of j) this[t2] = new Y(t2, false, void 0, this); + this.setupGlobalFilters(e3, void 0, H); + } + setupFromObject(e3) { + let t2; + for (t2 of (H.ifd0 = H.ifd0 || H.image, H.ifd1 = H.ifd1 || H.thumbnail, Object.assign(this, e3), G)) this[t2] = Z(e3[t2], $2[t2]); + for (t2 of X) this[t2] = Z(e3[t2], $2[t2]); + for (t2 of W) this[t2] = Z(e3[t2], $2[t2]); + for (t2 of z) 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, 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) this[i3].enabled = t2; + } + batchEnableWithUserValue(e3, t2) { + for (let i3 of e3) { + let e4 = t2[i3]; + this[i3].enabled = false !== e4 && void 0 !== e4; + } + } + setupGlobalFilters(e3, t2, i3, n3 = i3) { + if (e3 && e3.length) { + for (let e4 of n3) this[e4].enabled = false; + let t3 = Q(e3, i3); + for (let [e4, i4] of t3) ee(this[e4].pick, i4), this[e4].enabled = true; + } else if (t2 && t2.length) { + let e4 = Q(t2, i3); + for (let [t3, i4] of e4) ee(this[t3].skip, i4); + } + } + filterNestedSegmentTags() { + let { ifd0: e3, exif: t2, xmp: i3, iptc: n3, icc: s2 } = this; + this.makerNote ? t2.deps.add(37500) : t2.skip.add(37500), this.userComment ? t2.deps.add(37510) : t2.skip.add(37510), i3.enabled || e3.skip.add(700), n3.enabled || e3.skip.add(33723), s2.enabled || e3.skip.add(34675); + } + traverseTiffDependencyTree() { + let { ifd0: e3, exif: t2, gps: i3, interop: n3 } = this; + n3.needed && (t2.deps.add(40965), e3.deps.add(40965)), t2.needed && e3.deps.add(34665), i3.needed && e3.deps.add(34853), this.tiff.enabled = H.some((e4) => true === this[e4].enabled) || this.makerNote || this.userComment; + for (let e4 of H) this[e4].finalizeFilters(); + } + get onlyTiff() { + return !V.map((e3) => this[e3].enabled).some((e3) => true === e3) && this.tiff.enabled; + } + checkLoadedPlugins() { + for (let e3 of z) this[e3].enabled && !T.has(e3) && P("segment parser", e3); + } + }; + c(q, "default", $2); + te = class { + constructor(e3) { + c(this, "parsers", {}), c(this, "output", {}), c(this, "errors", []), c(this, "pushToErrors", (e4) => this.errors.push(e4)), this.options = q.useCached(e3); + } + async read(e3) { + this.file = await D(e3, this.options); + } + setup() { + if (this.fileParser) return; + let { file: e3 } = this, t2 = e3.getUint16(0); + for (let [i3, n3] of w) if (n3.canHandle(e3, t2)) return this.fileParser = new n3(this.options, this.file, this.parsers), e3[i3] = true; + this.file.close && this.file.close(), g2("Unknown file format"); + } + 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), f(e3); + } + async executeParsers() { + let { output: e3 } = this; + await this.fileParser.parse(); + let t2 = Object.values(this.parsers).map(async (t3) => { + let i3 = await t3.parse(); + t3.assignToOutput(e3, i3); + }); + this.options.silentErrors && (t2 = t2.map((e4) => e4.catch(this.pushToErrors))), await Promise.all(t2); + } + async extractThumbnail() { + this.setup(); + let { options: e3, file: t2 } = this, i3 = T.get("tiff", e3); + var n3; + if (t2.tiff ? n3 = { start: 0, type: "tiff" } : t2.jpeg && (n3 = await this.fileParser.getOrFindSegment("tiff")), void 0 === n3) return; + let s2 = await this.fileParser.ensureSegmentChunk(n3), r2 = this.parsers.tiff = new i3(s2, e3, t2), a2 = await r2.extractThumbnail(); + return t2.close && t2.close(), a2; + } + }; + 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 }); + se = class { + constructor(e3, t2, i3) { + c(this, "errors", []), c(this, "ensureSegmentChunk", async (e4) => { + let t3 = e4.start, i4 = e4.size || 65536; + if (this.file.chunked) if (this.file.available(t3, i4)) e4.chunk = this.file.subarray(t3, i4); + else try { + e4.chunk = await this.file.readChunk(t3, i4); + } catch (t4) { + g2(`Couldn't read segment: ${JSON.stringify(e4)}. ${t4.message}`); + } + else this.file.byteLength > t3 + i4 ? e4.chunk = this.file.subarray(t3, i4) : void 0 === e4.size ? e4.chunk = this.file.subarray(t3) : g2("Segment unreachable: " + JSON.stringify(e4)); + return e4.chunk; + }), this.extendOptions && this.extendOptions(e3), this.options = e3, this.file = t2, this.parsers = i3; + } + injectSegment(e3, t2) { + this.options[e3].enabled && this.createParser(e3, t2); + } + createParser(e3, t2) { + let i3 = new (T.get(e3))(t2, this.options, this.file); + return this.parsers[e3] = i3; + } + createParsers(e3) { + for (let t2 of e3) { + let { type: e4, chunk: i3 } = t2, n3 = this.options[e4]; + if (n3 && n3.enabled) { + let t3 = this.parsers[e4]; + t3 && t3.append || t3 || this.createParser(e4, i3); + } + } + } + async readSegments(e3) { + let t2 = e3.map(this.ensureSegmentChunk); + await Promise.all(t2); + } + }; + re2 = class { + static findPosition(e3, t2) { + let i3 = e3.getUint16(t2 + 2) + 2, n3 = "function" == typeof this.headerLength ? this.headerLength(e3, t2, i3) : this.headerLength, s2 = t2 + n3, r2 = i3 - n3; + return { offset: t2, length: i3, headerLength: n3, start: s2, size: r2, end: s2 + r2 }; + } + static parse(e3, t2 = {}) { + return new this(e3, new q({ [this.type]: t2 }), e3).parse(); + } + normalizeInput(e3) { + return e3 instanceof I ? e3 : new I(e3); + } + constructor(e3, t2 = {}, i3) { + c(this, "errors", []), c(this, "raw", /* @__PURE__ */ new Map()), c(this, "handleError", (e4) => { + if (!this.options.silentErrors) throw e4; + this.errors.push(e4.message); + }), this.chunk = this.normalizeInput(e3), this.file = i3, this.type = this.constructor.type, this.globalOptions = this.options = t2, this.localOptions = t2[this.type], this.canTranslate = this.localOptions && this.localOptions.translate; + } + translate() { + this.canTranslate && (this.translated = this.translateBlock(this.raw, this.type)); + } + get output() { + return this.translated ? this.translated : this.raw ? Object.fromEntries(this.raw) : void 0; + } + translateBlock(e3, t2) { + let i3 = N.get(t2), n3 = B.get(t2), s2 = E.get(t2), r2 = this.options[t2], a2 = r2.reviveValues && !!i3, o2 = r2.translateValues && !!n3, l2 = r2.translateKeys && !!s2, h2 = {}; + for (let [t3, r3] of e3) a2 && i3.has(t3) ? r3 = i3.get(t3)(r3) : o2 && n3.has(t3) && (r3 = this.translateValue(r3, n3.get(t3))), l2 && s2.has(t3) && (t3 = s2.get(t3) || t3), h2[t3] = r3; + return h2; + } + translateValue(e3, t2) { + return t2[e3] || t2.DEFAULT || e3; + } + assignToOutput(e3, t2) { + this.assignObjectToOutput(e3, this.constructor.type, t2); + } + assignObjectToOutput(e3, t2, i3) { + if (this.globalOptions.mergeOutput) return Object.assign(e3, i3); + e3[t2] ? Object.assign(e3[t2], i3) : e3[t2] = i3; + } + }; + c(re2, "headerLength", 4), c(re2, "type", void 0), c(re2, "multiSegment", false), c(re2, "canHandle", () => false); + he = class extends se { + constructor(...e3) { + super(...e3), c(this, "appSegments", []), c(this, "jpegSegments", []), c(this, "unknownSegments", []); + } + static canHandle(e3, t2) { + return 65496 === t2; + } + async parse() { + await this.findAppSegments(), await this.readSegments(this.appSegments), this.mergeMultiSegments(), this.createParsers(this.mergedAppSegments || this.appSegments); + } + setupSegmentFinderArgs(e3) { + true === e3 ? (this.findAll = true, this.wanted = new Set(T.keyList())) : (e3 = void 0 === e3 ? T.keyList().filter((e4) => this.options[e4].enabled) : e3.filter((e4) => this.options[e4].enabled && T.has(e4)), this.findAll = false, this.remaining = new Set(e3), this.wanted = new Set(e3)), this.unfinishedMultiSegment = false; + } + async findAppSegments(e3 = 0, t2) { + this.setupSegmentFinderArgs(t2); + let { file: i3, findAll: n3, wanted: s2, remaining: r2 } = this; + if (!n3 && this.file.chunked && (n3 = Array.from(s2).some((e4) => { + let t3 = T.get(e4), i4 = this.options[e4]; + return t3.multiSegment && i4.multiSegment; + }), n3 && await this.file.readWhole()), e3 = this.findAppSegmentsInRange(e3, i3.byteLength), !this.options.onlyTiff && i3.chunked) { + let t3 = false; + for (; r2.size > 0 && !t3 && (i3.canReadNextChunk || this.unfinishedMultiSegment); ) { + let { nextChunkOffset: n4 } = i3, s3 = this.appSegments.some((e4) => !this.file.available(e4.offset || e4.start, e4.length || e4.size)); + if (t3 = e3 > n4 && !s3 ? !await i3.readNextChunk(e3) : !await i3.readNextChunk(n4), void 0 === (e3 = this.findAppSegmentsInRange(e3, i3.byteLength))) return; + } + } + } + findAppSegmentsInRange(e3, t2) { + t2 -= 2; + 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 = 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; + 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 !== f2.stopAfterSos) return; + f2.recordJpegSegments && this.jpegSegments.push({ offset: e3, length: n3, marker: i3 }), e3 += n3 + 1; + } + } + return e3; + } + mergeMultiSegments() { + if (!this.appSegments.some((e4) => e4.multiSegment)) return; + let e3 = function(e4, t2) { + let i3, n3, s2, r2 = /* @__PURE__ */ new Map(); + for (let a2 = 0; a2 < e4.length; a2++) i3 = e4[a2], n3 = i3[t2], r2.has(n3) ? s2 = r2.get(n3) : r2.set(n3, s2 = []), s2.push(i3); + return Array.from(r2); + }(this.appSegments, "type"); + this.mergedAppSegments = e3.map(([e4, t2]) => { + let i3 = T.get(e4, this.options); + if (i3.handleMultiSegments) { + return { type: e4, chunk: i3.handleMultiSegments(t2) }; + } + return t2[0]; + }); + } + getSegment(e3) { + return this.appSegments.find((t2) => t2.type === e3); + } + async getOrFindSegment(e3) { + let t2 = this.getSegment(e3); + return void 0 === t2 && (await this.findAppSegments(0, [e3]), t2 = this.getSegment(e3)), t2; + } + }; + c(he, "type", "jpeg"), w.set("jpeg", he); + ue = [void 0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 4]; + ce = class extends re2 { + parseHeader() { + var e3 = this.chunk.getUint16(); + 18761 === e3 ? this.le = true : 19789 === e3 && (this.le = false), this.chunk.le = this.le, this.headerParsed = true; + } + parseTags(e3, t2, i3 = /* @__PURE__ */ new Map()) { + let { pick: n3, skip: s2 } = this.options[t2]; + n3 = new Set(n3); + let r2 = n3.size > 0, a2 = 0 === s2.size, o2 = this.chunk.getUint16(e3); + e3 += 2; + for (let l2 = 0; l2 < o2; l2++) { + let o3 = this.chunk.getUint16(e3); + if (r2) { + if (n3.has(o3) && (i3.set(o3, this.parseTag(e3, o3, t2)), n3.delete(o3), 0 === n3.size)) break; + } else !a2 && s2.has(o3) || i3.set(o3, this.parseTag(e3, o3, t2)); + e3 += 12; + } + return i3; + } + parseTag(e3, t2, i3) { + let { chunk: n3 } = this, s2 = n3.getUint16(e3 + 2), r2 = n3.getUint32(e3 + 4), a2 = ue[s2]; + if (a2 * r2 <= 4 ? e3 += 8 : e3 = n3.getUint32(e3 + 8), (s2 < 1 || s2 > 13) && g2(`Invalid TIFF value type. block: ${i3.toUpperCase()}, tag: ${t2.toString(16)}, type: ${s2}, offset ${e3}`), e3 > n3.byteLength && g2(`Invalid TIFF value offset. block: ${i3.toUpperCase()}, tag: ${t2.toString(16)}, type: ${s2}, offset ${e3} is outside of chunk size ${n3.byteLength}`), 1 === s2) return n3.getUint8Array(e3, r2); + if (2 === s2) return m(n3.getString(e3, r2)); + if (7 === s2) return n3.getUint8Array(e3, r2); + if (1 === r2) return this.parseTagValue(s2, e3); + { + let t3 = new (function(e4) { + switch (e4) { + case 1: + return Uint8Array; + case 3: + return Uint16Array; + case 4: + return Uint32Array; + case 5: + return Array; + case 6: + return Int8Array; + case 8: + return Int16Array; + case 9: + return Int32Array; + case 10: + return Array; + case 11: + return Float32Array; + case 12: + return Float64Array; + default: + return Array; + } + }(s2))(r2), i4 = a2; + for (let n4 = 0; n4 < r2; n4++) t3[n4] = this.parseTagValue(s2, e3), e3 += i4; + return t3; + } + } + parseTagValue(e3, t2) { + let { chunk: i3 } = this; + switch (e3) { + case 1: + return i3.getUint8(t2); + case 3: + return i3.getUint16(t2); + case 4: + return i3.getUint32(t2); + case 5: + return i3.getUint32(t2) / i3.getUint32(t2 + 4); + case 6: + return i3.getInt8(t2); + case 8: + return i3.getInt16(t2); + case 9: + return i3.getInt32(t2); + case 10: + return i3.getInt32(t2) / i3.getInt32(t2 + 4); + case 11: + return i3.getFloat(t2); + case 12: + return i3.getDouble(t2); + case 13: + return i3.getUint32(t2); + default: + g2(`Invalid tiff type ${e3}`); + } + } + }; + fe = class extends ce { + static canHandle(e3, t2) { + return 225 === e3.getUint8(t2 + 1) && 1165519206 === e3.getUint32(t2 + 4) && 0 === e3.getUint16(t2 + 8); + } + async parse() { + this.parseHeader(); + let { options: e3 } = this; + return e3.ifd0.enabled && await this.parseIfd0Block(), e3.exif.enabled && await this.safeParse("parseExifBlock"), e3.gps.enabled && await this.safeParse("parseGpsBlock"), e3.interop.enabled && await this.safeParse("parseInteropBlock"), e3.ifd1.enabled && await this.safeParse("parseThumbnailBlock"), this.createOutput(); + } + safeParse(e3) { + let t2 = this[e3](); + return void 0 !== t2.catch && (t2 = t2.catch(this.handleError)), t2; + } + findIfd0Offset() { + void 0 === this.ifd0Offset && (this.ifd0Offset = this.chunk.getUint32(4)); + } + findIfd1Offset() { + if (void 0 === this.ifd1Offset) { + this.findIfd0Offset(); + let e3 = this.chunk.getUint16(this.ifd0Offset), t2 = this.ifd0Offset + 2 + 12 * e3; + this.ifd1Offset = this.chunk.getUint32(t2); + } + } + parseBlock(e3, t2) { + let i3 = /* @__PURE__ */ new Map(); + return this[t2] = i3, this.parseTags(e3, t2, i3), i3; + } + async parseIfd0Block() { + if (this.ifd0) return; + let { file: e3 } = this; + this.findIfd0Offset(), this.ifd0Offset < 8 && g2("Malformed EXIF data"), !e3.chunked && this.ifd0Offset > e3.byteLength && g2(`IFD0 offset points to outside of file. +this.ifd0Offset: ${this.ifd0Offset}, file.byteLength: ${e3.byteLength}`), e3.tiff && await e3.ensureChunk(this.ifd0Offset, S(this.options)); + let t2 = this.parseBlock(this.ifd0Offset, "ifd0"); + return 0 !== t2.size ? (this.exifOffset = t2.get(34665), this.interopOffset = t2.get(40965), this.gpsOffset = t2.get(34853), this.xmp = t2.get(700), this.iptc = t2.get(33723), this.icc = t2.get(34675), this.options.sanitize && (t2.delete(34665), t2.delete(40965), t2.delete(34853), t2.delete(700), t2.delete(33723), t2.delete(34675)), t2) : void 0; + } + async parseExifBlock() { + if (this.exif) return; + if (this.ifd0 || await this.parseIfd0Block(), void 0 === this.exifOffset) return; + this.file.tiff && await this.file.ensureChunk(this.exifOffset, S(this.options)); + let e3 = this.parseBlock(this.exifOffset, "exif"); + return this.interopOffset || (this.interopOffset = e3.get(40965)), this.makerNote = e3.get(37500), this.userComment = e3.get(37510), this.options.sanitize && (e3.delete(40965), e3.delete(37500), e3.delete(37510)), this.unpack(e3, 41728), this.unpack(e3, 41729), e3; + } + unpack(e3, t2) { + let i3 = e3.get(t2); + i3 && 1 === i3.length && e3.set(t2, i3[0]); + } + async parseGpsBlock() { + if (this.gps) return; + if (this.ifd0 || await this.parseIfd0Block(), void 0 === this.gpsOffset) return; + let e3 = this.parseBlock(this.gpsOffset, "gps"); + return e3 && e3.has(2) && e3.has(4) && (e3.set("latitude", de(...e3.get(2), e3.get(1))), e3.set("longitude", de(...e3.get(4), e3.get(3)))), e3; + } + async parseInteropBlock() { + if (!this.interop && (this.ifd0 || await this.parseIfd0Block(), void 0 !== this.interopOffset || this.exif || await this.parseExifBlock(), void 0 !== this.interopOffset)) return this.parseBlock(this.interopOffset, "interop"); + } + async parseThumbnailBlock(e3 = false) { + if (!this.ifd1 && !this.ifd1Parsed && (!this.options.mergeOutput || e3)) return this.findIfd1Offset(), this.ifd1Offset > 0 && (this.parseBlock(this.ifd1Offset, "ifd1"), this.ifd1Parsed = true), this.ifd1; + } + async extractThumbnail() { + if (this.headerParsed || this.parseHeader(), this.ifd1Parsed || await this.parseThumbnailBlock(true), void 0 === this.ifd1) return; + let e3 = this.ifd1.get(513), t2 = this.ifd1.get(514); + return this.chunk.getUint8Array(e3, t2); + } + get image() { + return this.ifd0; + } + get thumbnail() { + return this.ifd1; + } + createOutput() { + let e3, t2, i3, n3 = {}; + for (t2 of H) if (e3 = this[t2], !p(e3)) if (i3 = this.canTranslate ? this.translateBlock(e3, t2) : Object.fromEntries(e3), this.options.mergeOutput) { + if ("ifd1" === t2) continue; + Object.assign(n3, i3); + } else n3[t2] = i3; + return this.makerNote && (n3.makerNote = this.makerNote), this.userComment && (n3.userComment = this.userComment), n3; + } + assignToOutput(e3, t2) { + if (this.globalOptions.mergeOutput) Object.assign(e3, t2); + else for (let [i3, n3] of Object.entries(t2)) this.assignObjectToOutput(e3, i3, n3); + } + }; + c(fe, "type", "tiff"), c(fe, "headerLength", 10), T.set("tiff", fe); + 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 }); + ge = { ifd0: false, ifd1: false, exif: false, gps: false, interop: false, sanitize: false, reviveValues: true, translateKeys: false, translateValues: false, mergeOutput: false }; + me = Object.assign({}, ge, { firstChunkSize: 4e4, gps: [1, 2, 3, 4] }); + Ce = Object.assign({}, ge, { tiff: false, ifd1: true, mergeOutput: false }); + Ie = Object.assign({}, ge, { firstChunkSize: 4e4, ifd0: [274] }); + ke = Object.freeze({ 1: { dimensionSwapped: false, scaleX: 1, scaleY: 1, deg: 0, rad: 0 }, 2: { dimensionSwapped: false, scaleX: -1, scaleY: 1, deg: 0, rad: 0 }, 3: { dimensionSwapped: false, scaleX: 1, scaleY: 1, deg: 180, rad: 180 * Math.PI / 180 }, 4: { dimensionSwapped: false, scaleX: -1, scaleY: 1, deg: 180, rad: 180 * Math.PI / 180 }, 5: { dimensionSwapped: true, scaleX: 1, scaleY: -1, deg: 90, rad: 90 * Math.PI / 180 }, 6: { dimensionSwapped: true, scaleX: 1, scaleY: 1, deg: 90, rad: 90 * Math.PI / 180 }, 7: { dimensionSwapped: true, scaleX: 1, scaleY: -1, deg: 270, rad: 270 * Math.PI / 180 }, 8: { dimensionSwapped: true, scaleX: 1, scaleY: 1, deg: 270, rad: 270 * Math.PI / 180 } }); + we = true; + Te = true; + if ("object" == typeof navigator) { + let e3 = navigator.userAgent; + if (e3.includes("iPad") || e3.includes("iPhone")) { + let t2 = e3.match(/OS (\d+)_(\d+)/); + if (t2) { + let [, e4, i3] = t2, n3 = Number(e4) + 0.1 * Number(i3); + we = n3 < 13.4, Te = false; + } + } else if (e3.includes("OS X 10")) { + let [, t2] = e3.match(/OS X 10[_.](\d+)/); + we = Te = Number(t2) < 15; + } + if (e3.includes("Chrome/")) { + let [, t2] = e3.match(/Chrome\/(\d+)/); + we = Te = Number(t2) < 81; + } else if (e3.includes("Firefox/")) { + let [, t2] = e3.match(/Firefox\/(\d+)/); + we = Te = Number(t2) < 77; + } + } + De = class extends I { + constructor(...e3) { + super(...e3), c(this, "ranges", new Oe()), 0 !== this.byteLength && this.ranges.add(0, this.byteLength); + } + _tryExtend(e3, t2, i3) { + if (0 === e3 && 0 === this.byteLength && i3) { + let e4 = new DataView(i3.buffer || i3, i3.byteOffset, i3.byteLength); + this._swapDataView(e4); + } else { + let i4 = e3 + t2; + if (i4 > this.byteLength) { + let { dataView: e4 } = this._extend(i4); + this._swapDataView(e4); + } + } + } + _extend(e3) { + let t2; + t2 = a ? s.allocUnsafe(e3) : new Uint8Array(e3); + let i3 = new DataView(t2.buffer, t2.byteOffset, t2.byteLength); + return t2.set(new Uint8Array(this.buffer, this.byteOffset, this.byteLength), 0), { uintView: t2, dataView: i3 }; + } + subarray(e3, t2, i3 = false) { + return t2 = t2 || this._lengthToEnd(e3), i3 && this._tryExtend(e3, t2), this.ranges.add(e3, t2), super.subarray(e3, t2); + } + set(e3, t2, i3 = false) { + i3 && this._tryExtend(t2, e3.byteLength, e3); + let n3 = super.set(e3, t2); + return this.ranges.add(t2, n3.byteLength), n3; + } + async ensureChunk(e3, t2) { + this.chunked && (this.ranges.available(e3, t2) || await this.readChunk(e3, t2)); + } + available(e3, t2) { + return this.ranges.available(e3, t2); + } + }; + Oe = class { + constructor() { + c(this, "list", []); + } + get length() { + return this.list.length; + } + add(e3, t2, i3 = 0) { + let n3 = e3 + t2, s2 = this.list.filter((t3) => xe(e3, t3.offset, n3) || xe(e3, t3.end, n3)); + if (s2.length > 0) { + e3 = Math.min(e3, ...s2.map((e4) => e4.offset)), n3 = Math.max(n3, ...s2.map((e4) => e4.end)), t2 = n3 - e3; + let i4 = s2.shift(); + i4.offset = e3, i4.length = t2, i4.end = n3, this.list = this.list.filter((e4) => !s2.includes(e4)); + } else this.list.push({ offset: e3, length: t2, end: n3 }); + } + available(e3, t2) { + let i3 = e3 + t2; + return this.list.some((t3) => t3.offset <= e3 && i3 <= t3.end); + } + }; + ve = class extends De { + constructor(e3, t2) { + super(0), c(this, "chunksRead", 0), this.input = e3, this.options = t2; + } + async readWhole() { + this.chunked = false, await this.readChunk(this.nextChunkOffset); + } + async readChunked() { + this.chunked = true, await this.readChunk(0, this.options.firstChunkSize); + } + async readNextChunk(e3 = this.nextChunkOffset) { + if (this.fullyRead) return this.chunksRead++, false; + let t2 = this.options.chunkSize, i3 = await this.readChunk(e3, t2); + return !!i3 && i3.byteLength === t2; + } + async readChunk(e3, t2) { + if (this.chunksRead++, 0 !== (t2 = this.safeWrapAddress(e3, t2))) return this._readChunk(e3, t2); + } + safeWrapAddress(e3, t2) { + return void 0 !== this.size && e3 + t2 > this.size ? Math.max(0, this.size - e3) : t2; + } + get nextChunkOffset() { + if (0 !== this.ranges.list.length) return this.ranges.list[0].length; + } + get canReadNextChunk() { + return this.chunksRead < this.options.chunkLimit; + } + get fullyRead() { + return void 0 !== this.size && this.nextChunkOffset === this.size; + } + read() { + return this.options.chunked ? this.readChunked() : this.readWhole(); + } + close() { + } + }; + A.set("blob", class extends ve { + async readWhole() { + this.chunked = false; + let e3 = await R(this.input); + this._swapArrayBuffer(e3); + } + readChunked() { + return this.chunked = true, this.size = this.input.size, super.readChunked(); + } + async _readChunk(e3, t2) { + let i3 = t2 ? e3 + t2 : void 0, n3 = this.input.slice(e3, i3), s2 = await R(n3); + return this.set(s2, e3, true); + } + }); + 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; + }, rotation: Ae }); + A.set("url", class extends ve { + async readWhole() { + this.chunked = false; + let e3 = await M(this.input); + e3 instanceof ArrayBuffer ? this._swapArrayBuffer(e3) : e3 instanceof Uint8Array && this._swapBuffer(e3); + } + async _readChunk(e3, t2) { + let i3 = t2 ? e3 + t2 - 1 : void 0, n3 = this.options.httpHeaders || {}; + (e3 || i3) && (n3.range = `bytes=${[e3, i3].join("-")}`); + let s2 = await h(this.input, { headers: n3 }), r2 = await s2.arrayBuffer(), a2 = r2.byteLength; + if (416 !== s2.status) return a2 !== t2 && (this.size = e3 + a2), this.set(r2, e3, true); + } + }); + I.prototype.getUint64 = function(e3) { + let t2 = this.getUint32(e3), i3 = this.getUint32(e3 + 4); + return t2 < 1048575 ? t2 << 32 | i3 : void 0 !== typeof r ? (console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."), r(t2) << r(32) | r(i3)) : void g2("Trying to read 64b value but JS can only handle 53b numbers."); + }; + Re = class extends se { + parseBoxes(e3 = 0) { + let t2 = []; + for (; e3 < this.file.byteLength - 4; ) { + let i3 = this.parseBoxHead(e3); + if (t2.push(i3), 0 === i3.length) break; + e3 += i3.length; + } + return t2; + } + parseSubBoxes(e3) { + e3.boxes = this.parseBoxes(e3.start); + } + findBox(e3, t2) { + return void 0 === e3.boxes && this.parseSubBoxes(e3), e3.boxes.find((e4) => e4.kind === t2); + } + parseBoxHead(e3) { + let t2 = this.file.getUint32(e3), i3 = this.file.getString(e3 + 4, 4), n3 = e3 + 8; + return 1 === t2 && (t2 = this.file.getUint64(e3 + 8), n3 += 8), { offset: e3, length: t2, kind: i3, start: n3 }; + } + parseBoxFullHead(e3) { + if (void 0 !== e3.version) return; + let t2 = this.file.getUint32(e3.start); + e3.version = t2 >> 24, e3.start += 4; + } + }; + Le = class extends Re { + static canHandle(e3, t2) { + if (0 !== t2) return false; + let i3 = e3.getUint16(2); + if (i3 > 50) return false; + let n3 = 16, s2 = []; + for (; n3 < i3; ) s2.push(e3.getString(n3, 4)), n3 += 4; + return s2.includes(this.type); + } + async parse() { + let e3 = this.file.getUint32(0), t2 = this.parseBoxHead(e3); + for (; "meta" !== t2.kind; ) e3 += t2.length, await this.file.ensureChunk(e3, 16), t2 = this.parseBoxHead(e3); + await this.file.ensureChunk(t2.offset, t2.length), this.parseBoxFullHead(t2), this.parseSubBoxes(t2), this.options.icc.enabled && await this.findIcc(t2), this.options.tiff.enabled && await this.findExif(t2); + } + async registerSegment(e3, t2, i3) { + await this.file.ensureChunk(t2, i3); + let n3 = this.file.subarray(t2, i3); + this.createParser(e3, n3); + } + async findIcc(e3) { + let t2 = this.findBox(e3, "iprp"); + if (void 0 === t2) return; + let i3 = this.findBox(t2, "ipco"); + if (void 0 === i3) return; + let n3 = this.findBox(i3, "colr"); + void 0 !== n3 && await this.registerSegment("icc", n3.offset + 12, n3.length); + } + async findExif(e3) { + let t2 = this.findBox(e3, "iinf"); + if (void 0 === t2) return; + let i3 = this.findBox(e3, "iloc"); + if (void 0 === i3) return; + let n3 = this.findExifLocIdInIinf(t2), s2 = this.findExtentInIloc(i3, n3); + if (void 0 === s2) return; + let [r2, a2] = s2; + await this.file.ensureChunk(r2, a2); + let o2 = 4 + this.file.getUint32(r2); + r2 += o2, a2 -= o2, await this.registerSegment("tiff", r2, a2); + } + findExifLocIdInIinf(e3) { + this.parseBoxFullHead(e3); + let t2, i3, n3, s2, r2 = e3.start, a2 = this.file.getUint16(r2); + for (r2 += 2; a2--; ) { + if (t2 = this.parseBoxHead(r2), this.parseBoxFullHead(t2), i3 = t2.start, t2.version >= 2 && (n3 = 3 === t2.version ? 4 : 2, s2 = this.file.getString(i3 + n3 + 2, 4), "Exif" === s2)) return this.file.getUintBytes(i3, n3); + r2 += t2.length; + } + } + get8bits(e3) { + let t2 = this.file.getUint8(e3); + return [t2 >> 4, 15 & t2]; + } + findExtentInIloc(e3, t2) { + this.parseBoxFullHead(e3); + let i3 = e3.start, [n3, s2] = this.get8bits(i3++), [r2, a2] = this.get8bits(i3++), o2 = 2 === e3.version ? 4 : 2, l2 = 1 === e3.version || 2 === e3.version ? 2 : 0, h2 = a2 + n3 + s2, u2 = 2 === e3.version ? 4 : 2, c2 = this.file.getUintBytes(i3, u2); + for (i3 += u2; c2--; ) { + let e4 = this.file.getUintBytes(i3, o2); + i3 += o2 + l2 + 2 + r2; + let u3 = this.file.getUint16(i3); + if (i3 += 2, e4 === t2) return u3 > 1 && console.warn("ILOC box has more than one extent but we're only processing one\nPlease create an issue at https://github.com/MikeKovarik/exifr with this file"), [this.file.getUintBytes(i3 + a2, n3), this.file.getUintBytes(i3 + a2 + n3, s2)]; + i3 += u3 * h2; + } + } + }; + Ue = class extends Le { + }; + c(Ue, "type", "heic"); + Fe = class extends Le { + }; + c(Fe, "type", "avif"), w.set("heic", Ue), w.set("avif", Fe), U(E, ["ifd0", "ifd1"], [[256, "ImageWidth"], [257, "ImageHeight"], [258, "BitsPerSample"], [259, "Compression"], [262, "PhotometricInterpretation"], [270, "ImageDescription"], [271, "Make"], [272, "Model"], [273, "StripOffsets"], [274, "Orientation"], [277, "SamplesPerPixel"], [278, "RowsPerStrip"], [279, "StripByteCounts"], [282, "XResolution"], [283, "YResolution"], [284, "PlanarConfiguration"], [296, "ResolutionUnit"], [301, "TransferFunction"], [305, "Software"], [306, "ModifyDate"], [315, "Artist"], [316, "HostComputer"], [317, "Predictor"], [318, "WhitePoint"], [319, "PrimaryChromaticities"], [513, "ThumbnailOffset"], [514, "ThumbnailLength"], [529, "YCbCrCoefficients"], [530, "YCbCrSubSampling"], [531, "YCbCrPositioning"], [532, "ReferenceBlackWhite"], [700, "ApplicationNotes"], [33432, "Copyright"], [33723, "IPTC"], [34665, "ExifIFD"], [34675, "ICC"], [34853, "GpsIFD"], [330, "SubIFD"], [40965, "InteropIFD"], [40091, "XPTitle"], [40092, "XPComment"], [40093, "XPAuthor"], [40094, "XPKeywords"], [40095, "XPSubject"]]), U(E, "exif", [[33434, "ExposureTime"], [33437, "FNumber"], [34850, "ExposureProgram"], [34852, "SpectralSensitivity"], [34855, "ISO"], [34858, "TimeZoneOffset"], [34859, "SelfTimerMode"], [34864, "SensitivityType"], [34865, "StandardOutputSensitivity"], [34866, "RecommendedExposureIndex"], [34867, "ISOSpeed"], [34868, "ISOSpeedLatitudeyyy"], [34869, "ISOSpeedLatitudezzz"], [36864, "ExifVersion"], [36867, "DateTimeOriginal"], [36868, "CreateDate"], [36873, "GooglePlusUploadCode"], [36880, "OffsetTime"], [36881, "OffsetTimeOriginal"], [36882, "OffsetTimeDigitized"], [37121, "ComponentsConfiguration"], [37122, "CompressedBitsPerPixel"], [37377, "ShutterSpeedValue"], [37378, "ApertureValue"], [37379, "BrightnessValue"], [37380, "ExposureCompensation"], [37381, "MaxApertureValue"], [37382, "SubjectDistance"], [37383, "MeteringMode"], [37384, "LightSource"], [37385, "Flash"], [37386, "FocalLength"], [37393, "ImageNumber"], [37394, "SecurityClassification"], [37395, "ImageHistory"], [37396, "SubjectArea"], [37500, "MakerNote"], [37510, "UserComment"], [37520, "SubSecTime"], [37521, "SubSecTimeOriginal"], [37522, "SubSecTimeDigitized"], [37888, "AmbientTemperature"], [37889, "Humidity"], [37890, "Pressure"], [37891, "WaterDepth"], [37892, "Acceleration"], [37893, "CameraElevationAngle"], [40960, "FlashpixVersion"], [40961, "ColorSpace"], [40962, "ExifImageWidth"], [40963, "ExifImageHeight"], [40964, "RelatedSoundFile"], [41483, "FlashEnergy"], [41486, "FocalPlaneXResolution"], [41487, "FocalPlaneYResolution"], [41488, "FocalPlaneResolutionUnit"], [41492, "SubjectLocation"], [41493, "ExposureIndex"], [41495, "SensingMethod"], [41728, "FileSource"], [41729, "SceneType"], [41730, "CFAPattern"], [41985, "CustomRendered"], [41986, "ExposureMode"], [41987, "WhiteBalance"], [41988, "DigitalZoomRatio"], [41989, "FocalLengthIn35mmFormat"], [41990, "SceneCaptureType"], [41991, "GainControl"], [41992, "Contrast"], [41993, "Saturation"], [41994, "Sharpness"], [41996, "SubjectDistanceRange"], [42016, "ImageUniqueID"], [42032, "OwnerName"], [42033, "SerialNumber"], [42034, "LensInfo"], [42035, "LensMake"], [42036, "LensModel"], [42037, "LensSerialNumber"], [42080, "CompositeImage"], [42081, "CompositeImageCount"], [42082, "CompositeImageExposureTimes"], [42240, "Gamma"], [59932, "Padding"], [59933, "OffsetSchema"], [65e3, "OwnerName"], [65001, "SerialNumber"], [65002, "Lens"], [65100, "RawFile"], [65101, "Converter"], [65102, "WhiteBalance"], [65105, "Exposure"], [65106, "Shadows"], [65107, "Brightness"], [65108, "Contrast"], [65109, "Saturation"], [65110, "Sharpness"], [65111, "Smoothness"], [65112, "MoireFilter"], [40965, "InteropIFD"]]), U(E, "gps", [[0, "GPSVersionID"], [1, "GPSLatitudeRef"], [2, "GPSLatitude"], [3, "GPSLongitudeRef"], [4, "GPSLongitude"], [5, "GPSAltitudeRef"], [6, "GPSAltitude"], [7, "GPSTimeStamp"], [8, "GPSSatellites"], [9, "GPSStatus"], [10, "GPSMeasureMode"], [11, "GPSDOP"], [12, "GPSSpeedRef"], [13, "GPSSpeed"], [14, "GPSTrackRef"], [15, "GPSTrack"], [16, "GPSImgDirectionRef"], [17, "GPSImgDirection"], [18, "GPSMapDatum"], [19, "GPSDestLatitudeRef"], [20, "GPSDestLatitude"], [21, "GPSDestLongitudeRef"], [22, "GPSDestLongitude"], [23, "GPSDestBearingRef"], [24, "GPSDestBearing"], [25, "GPSDestDistanceRef"], [26, "GPSDestDistance"], [27, "GPSProcessingMethod"], [28, "GPSAreaInformation"], [29, "GPSDateStamp"], [30, "GPSDifferential"], [31, "GPSHPositioningError"]]), U(B, ["ifd0", "ifd1"], [[274, { 1: "Horizontal (normal)", 2: "Mirror horizontal", 3: "Rotate 180", 4: "Mirror vertical", 5: "Mirror horizontal and rotate 270 CW", 6: "Rotate 90 CW", 7: "Mirror horizontal and rotate 90 CW", 8: "Rotate 270 CW" }], [296, { 1: "None", 2: "inches", 3: "cm" }]]); + Ee = U(B, "exif", [[34850, { 0: "Not defined", 1: "Manual", 2: "Normal program", 3: "Aperture priority", 4: "Shutter priority", 5: "Creative program", 6: "Action program", 7: "Portrait mode", 8: "Landscape mode" }], [37121, { 0: "-", 1: "Y", 2: "Cb", 3: "Cr", 4: "R", 5: "G", 6: "B" }], [37383, { 0: "Unknown", 1: "Average", 2: "CenterWeightedAverage", 3: "Spot", 4: "MultiSpot", 5: "Pattern", 6: "Partial", 255: "Other" }], [37384, { 0: "Unknown", 1: "Daylight", 2: "Fluorescent", 3: "Tungsten (incandescent light)", 4: "Flash", 9: "Fine weather", 10: "Cloudy weather", 11: "Shade", 12: "Daylight fluorescent (D 5700 - 7100K)", 13: "Day white fluorescent (N 4600 - 5400K)", 14: "Cool white fluorescent (W 3900 - 4500K)", 15: "White fluorescent (WW 3200 - 3700K)", 17: "Standard light A", 18: "Standard light B", 19: "Standard light C", 20: "D55", 21: "D65", 22: "D75", 23: "D50", 24: "ISO studio tungsten", 255: "Other" }], [37385, { 0: "Flash did not fire", 1: "Flash fired", 5: "Strobe return light not detected", 7: "Strobe return light detected", 9: "Flash fired, compulsory flash mode", 13: "Flash fired, compulsory flash mode, return light not detected", 15: "Flash fired, compulsory flash mode, return light detected", 16: "Flash did not fire, compulsory flash mode", 24: "Flash did not fire, auto mode", 25: "Flash fired, auto mode", 29: "Flash fired, auto mode, return light not detected", 31: "Flash fired, auto mode, return light detected", 32: "No flash function", 65: "Flash fired, red-eye reduction mode", 69: "Flash fired, red-eye reduction mode, return light not detected", 71: "Flash fired, red-eye reduction mode, return light detected", 73: "Flash fired, compulsory flash mode, red-eye reduction mode", 77: "Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected", 79: "Flash fired, compulsory flash mode, red-eye reduction mode, return light detected", 89: "Flash fired, auto mode, red-eye reduction mode", 93: "Flash fired, auto mode, return light not detected, red-eye reduction mode", 95: "Flash fired, auto mode, return light detected, red-eye reduction mode" }], [41495, { 1: "Not defined", 2: "One-chip color area sensor", 3: "Two-chip color area sensor", 4: "Three-chip color area sensor", 5: "Color sequential area sensor", 7: "Trilinear sensor", 8: "Color sequential linear sensor" }], [41728, { 1: "Film Scanner", 2: "Reflection Print Scanner", 3: "Digital Camera" }], [41729, { 1: "Directly photographed" }], [41985, { 0: "Normal", 1: "Custom", 2: "HDR (no original saved)", 3: "HDR (original saved)", 4: "Original (for HDR)", 6: "Panorama", 7: "Portrait HDR", 8: "Portrait" }], [41986, { 0: "Auto", 1: "Manual", 2: "Auto bracket" }], [41987, { 0: "Auto", 1: "Manual" }], [41990, { 0: "Standard", 1: "Landscape", 2: "Portrait", 3: "Night", 4: "Other" }], [41991, { 0: "None", 1: "Low gain up", 2: "High gain up", 3: "Low gain down", 4: "High gain down" }], [41996, { 0: "Unknown", 1: "Macro", 2: "Close", 3: "Distant" }], [42080, { 0: "Unknown", 1: "Not a Composite Image", 2: "General Composite Image", 3: "Composite Image Captured While Shooting" }]]); + Be = { 1: "No absolute unit of measurement", 2: "Inch", 3: "Centimeter" }; + Ee.set(37392, Be), Ee.set(41488, Be); + Ne = { 0: "Normal", 1: "Low", 2: "High" }; + Ee.set(41992, Ne), Ee.set(41993, Ne), Ee.set(41994, Ne), U(N, ["ifd0", "ifd1"], [[50827, function(e3) { + return "string" != typeof e3 ? b(e3) : e3; + }], [306, ze], [40091, He], [40092, He], [40093, He], [40094, He], [40095, He]]), U(N, "exif", [[40960, Ve], [36864, Ve], [36867, ze], [36868, ze], [40962, Ge], [40963, Ge]]), U(N, "gps", [[0, (e3) => Array.from(e3).join(".")], [7, (e3) => Array.from(e3).join(":")]]); + We = class extends re2 { + static canHandle(e3, t2) { + return 225 === e3.getUint8(t2 + 1) && 1752462448 === e3.getUint32(t2 + 4) && "http://ns.adobe.com/" === e3.getString(t2 + 4, "http://ns.adobe.com/".length); + } + static headerLength(e3, t2) { + return "http://ns.adobe.com/xmp/extension/" === e3.getString(t2 + 4, "http://ns.adobe.com/xmp/extension/".length) ? 79 : 4 + "http://ns.adobe.com/xap/1.0/".length + 1; + } + static findPosition(e3, t2) { + let i3 = super.findPosition(e3, t2); + return i3.multiSegment = i3.extended = 79 === i3.headerLength, i3.multiSegment ? (i3.chunkCount = e3.getUint8(t2 + 72), i3.chunkNumber = e3.getUint8(t2 + 76), 0 !== e3.getUint8(t2 + 77) && i3.chunkNumber++) : (i3.chunkCount = 1 / 0, i3.chunkNumber = -1), i3; + } + static handleMultiSegments(e3) { + return e3.map((e4) => e4.chunk.getString()).join(""); + } + normalizeInput(e3) { + return "string" == typeof e3 ? e3 : I.from(e3).getString(); + } + parse(e3 = this.chunk) { + if (!this.localOptions.parse) return e3; + e3 = function(e4) { + let t3 = {}, i4 = {}; + for (let e6 of Ze) t3[e6] = [], i4[e6] = 0; + return e4.replace(et, (e6, n4, s2) => { + if ("<" === n4) { + let n5 = ++i4[s2]; + return t3[s2].push(n5), `${e6}#${n5}`; + } + return `${e6}#${t3[s2].pop()}`; + }); + }(e3); + let t2 = Xe.findAll(e3, "rdf", "Description"); + 0 === t2.length && t2.push(new Xe("rdf", "Description", void 0, e3)); + let i3, n3 = {}; + for (let e4 of t2) for (let t3 of e4.properties) i3 = Je(t3.ns, n3), _e(t3, i3); + return function(e4) { + let t3; + for (let i4 in e4) t3 = e4[i4] = f(e4[i4]), void 0 === t3 && delete e4[i4]; + return f(e4); + }(n3); + } + assignToOutput(e3, t2) { + if (this.localOptions.parse) for (let [i3, n3] of Object.entries(t2)) switch (i3) { + case "tiff": + this.assignObjectToOutput(e3, "ifd0", n3); + break; + case "exif": + this.assignObjectToOutput(e3, "exif", n3); + break; + case "xmlns": + break; + default: + this.assignObjectToOutput(e3, i3, n3); + } + else e3.xmp = t2; + } + }; + c(We, "type", "xmp"), c(We, "multiSegment", true), T.set("xmp", We); + Ke = class _Ke { + static findAll(e3) { + return qe(e3, /([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(_Ke.unpackMatch); + } + static unpackMatch(e3) { + let t2 = e3[1], i3 = e3[2], n3 = e3[3].slice(1, -1); + return n3 = Qe(n3), new _Ke(t2, i3, n3); + } + constructor(e3, t2, i3) { + this.ns = e3, this.name = t2, this.value = i3; + } + serialize() { + return this.value; + } + }; + Xe = class _Xe { + static findAll(e3, t2, i3) { + if (void 0 !== t2 || void 0 !== i3) { + t2 = t2 || "[\\w\\d-]+", i3 = i3 || "[\\w\\d-]+"; + var n3 = new RegExp(`<(${t2}):(${i3})(#\\d+)?((\\s+?[\\w\\d-:]+=("[^"]*"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)`, "gm"); + } else n3 = /<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm; + return qe(e3, n3).map(_Xe.unpackMatch); + } + static unpackMatch(e3) { + let t2 = e3[1], i3 = e3[2], n3 = e3[4], s2 = e3[8]; + return new _Xe(t2, i3, n3, s2); + } + constructor(e3, t2, i3, n3) { + this.ns = e3, this.name = t2, this.attrString = i3, this.innerXml = n3, this.attrs = Ke.findAll(i3), this.children = _Xe.findAll(n3), this.value = 0 === this.children.length ? Qe(n3) : void 0, this.properties = [...this.attrs, ...this.children]; + } + get isPrimitive() { + return void 0 !== this.value && 0 === this.attrs.length && 0 === this.children.length; + } + get isListContainer() { + return 1 === this.children.length && this.children[0].isList; + } + get isList() { + let { ns: e3, name: t2 } = this; + return "rdf" === e3 && ("Seq" === t2 || "Bag" === t2 || "Alt" === t2); + } + get isListItem() { + return "rdf" === this.ns && "li" === this.name; + } + serialize() { + if (0 === this.properties.length && void 0 === this.value) return; + if (this.isPrimitive) return this.value; + if (this.isListContainer) return this.children[0].serialize(); + if (this.isList) return $e(this.children.map(Ye)); + if (this.isListItem && 1 === this.children.length && 0 === this.attrs.length) return this.children[0].serialize(); + let e3 = {}; + for (let t2 of this.properties) _e(t2, e3); + return void 0 !== this.value && (e3.value = this.value), f(e3); + } + }; + Ye = (e3) => e3.serialize(); + $e = (e3) => 1 === e3.length ? e3[0] : e3; + Je = (e3, t2) => t2[e3] ? t2[e3] : t2[e3] = {}; + Ze = ["rdf:li", "rdf:Seq", "rdf:Bag", "rdf:Alt", "rdf:Description"]; + et = new RegExp(`(<|\\/)(${Ze.join("|")})`, "g"); + 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; + }, rotation: Ae }); + at = l("fs", (e3) => e3.promises); + A.set("fs", class extends ve { + async readWhole() { + this.chunked = false, this.fs = await at; + let e3 = await this.fs.readFile(this.input); + this._swapBuffer(e3); + } + async readChunked() { + this.chunked = true, this.fs = await at, await this.open(), await this.readChunk(0, this.options.firstChunkSize); + } + async open() { + void 0 === this.fh && (this.fh = await this.fs.open(this.input, "r"), this.size = (await this.fh.stat(this.input)).size); + } + async _readChunk(e3, t2) { + void 0 === this.fh && await this.open(), e3 + t2 > this.size && (t2 = this.size - e3); + var i3 = this.subarray(e3, t2, true); + return await this.fh.read(i3.dataView, 0, t2, e3), i3; + } + async close() { + if (this.fh) { + let e3 = this.fh; + this.fh = void 0, await e3.close(); + } + } + }); + A.set("base64", class extends ve { + constructor(...e3) { + super(...e3), this.input = this.input.replace(/^data:([^;]+);base64,/gim, ""), this.size = this.input.length / 4 * 3, this.input.endsWith("==") ? this.size -= 2 : this.input.endsWith("=") && (this.size -= 1); + } + async _readChunk(e3, t2) { + let i3, n3, r2 = this.input; + void 0 === e3 ? (e3 = 0, i3 = 0, n3 = 0) : (i3 = 4 * Math.floor(e3 / 3), n3 = e3 - i3 / 4 * 3), void 0 === t2 && (t2 = this.size); + let o2 = e3 + t2, l2 = i3 + 4 * Math.ceil(o2 / 3); + r2 = r2.slice(i3, l2); + let h2 = Math.min(t2, this.size - e3); + if (a) { + let t3 = s.from(r2, "base64").slice(n3, n3 + h2); + return this.set(t3, e3, true); + } + { + let t3 = this.subarray(e3, h2, true), i4 = atob(r2), s2 = t3.toUint8(); + for (let e4 = 0; e4 < h2; e4++) s2[e4] = i4.charCodeAt(n3 + e4); + return t3; + } + } + }); + ot = class extends se { + static canHandle(e3, t2) { + return 18761 === t2 || 19789 === t2; + } + extendOptions(e3) { + let { ifd0: t2, xmp: i3, iptc: n3, icc: s2 } = e3; + i3.enabled && t2.deps.add(700), n3.enabled && t2.deps.add(33723), s2.enabled && t2.deps.add(34675), t2.finalizeFilters(); + } + async parse() { + let { tiff: e3, xmp: t2, iptc: i3, icc: n3 } = this.options; + if (e3.enabled || t2.enabled || i3.enabled || n3.enabled) { + let e4 = Math.max(S(this.options), this.options.chunkSize); + await this.file.ensureChunk(0, e4), this.createParser("tiff", this.file), this.parsers.tiff.parseHeader(), await this.parsers.tiff.parseIfd0Block(), this.adaptTiffPropAsSegment("xmp"), this.adaptTiffPropAsSegment("iptc"), this.adaptTiffPropAsSegment("icc"); } - return false; } - function addLabel(yOffset) { - if (width2 && areaWidth >= width2 + 20) { - var labelX = centroid[0]; - var labelY = centroid[1] + yOffset; - var bbox3 = { - minX: labelX - width2 / 2 - padding, - minY: labelY - height / 2 - padding, - maxX: labelX + width2 / 2 + padding, - maxY: labelY + height / 2 + padding - }; - if (tryInsert([bbox3], entity2.id, true)) { - p3.x = labelX; - p3.y = labelY; - p3.textAnchor = "middle"; - p3.height = height; - return true; - } + adaptTiffPropAsSegment(e3) { + if (this.parsers.tiff[e3]) { + let t2 = this.parsers.tiff[e3]; + this.injectSegment(e3, t2); } - return false; } - } - function doInsert(bbox3, id2) { - bbox3.id = id2; - var oldbox = _entitybboxes[id2]; - if (oldbox) { - _rdrawn.remove(oldbox); + }; + c(ot, "type", "tiff"), w.set("tiff", ot); + lt = l("zlib"); + ht = ["ihdr", "iccp", "text", "itxt", "exif"]; + ut = class extends se { + constructor(...e3) { + super(...e3), c(this, "catchError", (e4) => this.errors.push(e4)), c(this, "metaChunks", []), c(this, "unknownChunks", []); } - _entitybboxes[id2] = bbox3; - _rdrawn.insert(bbox3); - } - function tryInsert(bboxes, id2, saveSkipped) { - var skipped = false; - for (var i4 = 0; i4 < bboxes.length; i4++) { - var bbox3 = bboxes[i4]; - bbox3.id = id2; - if (bbox3.minX < 0 || bbox3.minY < 0 || bbox3.maxX > dimensions[0] || bbox3.maxY > dimensions[1]) { - skipped = true; - break; + static canHandle(e3, t2) { + return 35152 === t2 && 2303741511 === e3.getUint32(0) && 218765834 === e3.getUint32(4); + } + async parse() { + let { file: e3 } = this; + await this.findPngChunksInRange("\x89PNG\r\n\n".length, e3.byteLength), await this.readSegments(this.metaChunks), this.findIhdr(), this.parseTextChunks(), await this.findExif().catch(this.catchError), await this.findXmp().catch(this.catchError), await this.findIcc().catch(this.catchError); + } + async findPngChunksInRange(e3, t2) { + let { file: i3 } = this; + for (; e3 < t2; ) { + let t3 = i3.getUint32(e3), n3 = i3.getUint32(e3 + 4), s2 = i3.getString(e3 + 4, 4).toLowerCase(), r2 = t3 + 4 + 4 + 4, a2 = { type: s2, offset: e3, length: r2, start: e3 + 4 + 4, size: t3, marker: n3 }; + ht.includes(s2) ? this.metaChunks.push(a2) : this.unknownChunks.push(a2), e3 += r2; } - if (_rdrawn.collides(bbox3)) { - skipped = true; - break; + } + parseTextChunks() { + let e3 = this.metaChunks.filter((e4) => "text" === e4.type); + for (let t2 of e3) { + let [e4, i3] = this.file.getString(t2.start, t2.size).split("\0"); + this.injectKeyValToIhdr(e4, i3); } } - _entitybboxes[id2] = bboxes; - if (skipped) { - if (saveSkipped) { - _rskipped.load(bboxes); + injectKeyValToIhdr(e3, t2) { + let i3 = this.parsers.ihdr; + i3 && i3.raw.set(e3, t2); + } + findIhdr() { + let e3 = this.metaChunks.find((e4) => "ihdr" === e4.type); + e3 && false !== this.options.ihdr.enabled && this.createParser("ihdr", e3.chunk); + } + async findExif() { + let e3 = this.metaChunks.find((e4) => "exif" === e4.type); + e3 && this.injectSegment("tiff", e3.chunk); + } + async findXmp() { + let e3 = this.metaChunks.filter((e4) => "itxt" === e4.type); + for (let t2 of e3) { + "XML:com.adobe.xmp" === t2.chunk.getString(0, "XML:com.adobe.xmp".length) && this.injectSegment("xmp", t2.chunk); } - } else { - _rdrawn.load(bboxes); } - return !skipped; - } - var layer = selection2.selectAll(".layer-osm.labels"); - layer.selectAll(".labels-group").data(["halo", "label", "debug"]).enter().append("g").attr("class", function(d2) { - return "labels-group " + d2; - }); - var halo = layer.selectAll(".labels-group.halo"); - var label = layer.selectAll(".labels-group.label"); - var debug2 = layer.selectAll(".labels-group.debug"); - drawPointLabels(label, labelled.point, filter2, "pointlabel", positions.point); - drawPointLabels(halo, labelled.point, filter2, "pointlabel-halo", positions.point); - drawLinePaths(layer, labelled.line, filter2, "", positions.line); - drawLineLabels(label, labelled.line, filter2, "linelabel", positions.line); - drawLineLabels(halo, labelled.line, filter2, "linelabel-halo", positions.line); - drawAreaLabels(label, labelled.area, filter2, "arealabel", positions.area); - drawAreaLabels(halo, labelled.area, filter2, "arealabel-halo", positions.area); - drawAreaIcons(label, labelled.area, filter2, "areaicon", positions.area); - drawAreaIcons(halo, labelled.area, filter2, "areaicon-halo", positions.area); - drawCollisionBoxes(debug2, _rskipped, "debug-skipped"); - drawCollisionBoxes(debug2, _rdrawn, "debug-drawn"); - layer.call(filterLabels); - } - function filterLabels(selection2) { - var drawLayer = selection2.selectAll(".layer-osm.labels"); - var layers = drawLayer.selectAll(".labels-group.halo, .labels-group.label"); - layers.selectAll(".nolabel").classed("nolabel", false); - var mouse = context.map().mouse(); - var graph = context.graph(); - var selectedIDs = context.selectedIDs(); - var ids = []; - var pad2, bbox2; - if (mouse) { - pad2 = 20; - bbox2 = { minX: mouse[0] - pad2, minY: mouse[1] - pad2, maxX: mouse[0] + pad2, maxY: mouse[1] + pad2 }; - var nearMouse = _rdrawn.search(bbox2).map(function(entity2) { - return entity2.id; - }); - ids.push.apply(ids, nearMouse); - } - for (var i3 = 0; i3 < selectedIDs.length; i3++) { - var entity = graph.hasEntity(selectedIDs[i3]); - if (entity && entity.type === "node") { - ids.push(selectedIDs[i3]); + async findIcc() { + let e3 = this.metaChunks.find((e4) => "iccp" === e4.type); + if (!e3) return; + let { chunk: t2 } = e3, i3 = t2.getUint8Array(0, 81), s2 = 0; + for (; s2 < 80 && 0 !== i3[s2]; ) s2++; + let r2 = s2 + 2, a2 = t2.getString(0, s2); + if (this.injectKeyValToIhdr("ProfileName", a2), n2) { + let e4 = await lt, i4 = t2.getUint8Array(r2); + i4 = e4.inflateSync(i4), this.injectSegment("icc", i4); + } } - } - layers.selectAll(utilEntitySelector(ids)).classed("nolabel", true); - var debug2 = selection2.selectAll(".labels-group.debug"); - var gj = []; - if (context.getDebug("collision")) { - gj = bbox2 ? [{ - type: "Polygon", - coordinates: [[ - [bbox2.minX, bbox2.minY], - [bbox2.maxX, bbox2.minY], - [bbox2.maxX, bbox2.maxY], - [bbox2.minX, bbox2.maxY], - [bbox2.minX, bbox2.minY] - ]] - }] : []; - } - var box = debug2.selectAll(".debug-mouse").data(gj); - box.exit().remove(); - box.enter().append("path").attr("class", "debug debug-mouse yellow").merge(box).attr("d", path_default()); - } - var throttleFilterLabels = throttle_default(filterLabels, 100); - drawLabels.observe = function(selection2) { - var listener = function() { - throttleFilterLabels(selection2); }; - selection2.on("mousemove.hidelabels", listener); - context.on("enter.hidelabels", listener); - }; - drawLabels.off = function(selection2) { - throttleFilterLabels.cancel(); - selection2.on("mousemove.hidelabels", null); - context.on("enter.hidelabels", null); - }; - return drawLabels; - } - - // node_modules/exifr/dist/full.esm.mjs - var e = "undefined" != typeof self ? self : global; - var t = "undefined" != typeof navigator; - var i2 = t && "undefined" == typeof HTMLImageElement; - var n2 = !("undefined" == typeof global || "undefined" == typeof process || !process.versions || !process.versions.node); - var s = e.Buffer; - var r = e.BigInt; - var a = !!s; - var o = (e3) => e3; - function l(e3, t2 = o) { - if (n2) try { - return "function" == typeof __require ? Promise.resolve(t2(__require(e3))) : import( - /* webpackIgnore: true */ - e3 - ).then(t2); - } catch (t3) { - console.warn("Couldn't load ".concat(e3)); - } - } - var h = e.fetch; - var u = (e3) => h = e3; - 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 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); - } - r2({ status: e4.statusCode, arrayBuffer: () => new Promise((t3) => { - let i4 = []; - e4.on("data", (e6) => i4.push(e6)), e4.on("end", () => t3(Buffer.concat(i4))); - }) }); - }); - d2.on("error", a2), d2.end(); - }); - u(i3); - } - 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 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); - } - function g2(e3) { - let t2 = new Error(e3); - throw delete t2.stack, t2; - } - function m(e3) { - return "" === (e3 = function(e4) { - for (; e4.endsWith("\0"); ) e4 = e4.slice(0, -1); - return e4; - }(e3).trim()) ? void 0 : e3; - } - function S(e3) { - let t2 = function(e4) { - let t3 = 0; - return e4.ifd0.enabled && (t3 += 1024), e4.exif.enabled && (t3 += 2048), e4.makerNote && (t3 += 2048), e4.userComment && (t3 += 1024), e4.gps.enabled && (t3 += 512), e4.interop.enabled && (t3 += 100), e4.ifd1.enabled && (t3 += 1024), t3 + 2048; - }(e3); - return e3.jfif.enabled && (t2 += 50), e3.xmp.enabled && (t2 += 2e4), e3.iptc.enabled && (t2 += 14e3), e3.icc.enabled && (t2 += 6e3), t2; - } - var C = (e3) => String.fromCharCode.apply(null, e3); - var y = "undefined" != typeof TextDecoder ? new TextDecoder("utf-8") : void 0; - function b(e3) { - return y ? y.decode(e3) : a ? Buffer.from(e3).toString("utf8") : decodeURIComponent(escape(C(e3))); - } - var I = class _I { - static from(e3, t2) { - return e3 instanceof this && e3.le === t2 ? e3 : new _I(e3, void 0, void 0, t2); - } - constructor(e3, t2 = 0, i3, n3) { - if ("boolean" == typeof n3 && (this.le = n3), Array.isArray(e3) && (e3 = new Uint8Array(e3)), 0 === e3) this.byteOffset = 0, this.byteLength = 0; - else if (e3 instanceof ArrayBuffer) { - void 0 === i3 && (i3 = e3.byteLength - t2); - let n4 = new DataView(e3, t2, i3); - this._swapDataView(n4); - } else if (e3 instanceof Uint8Array || e3 instanceof DataView || e3 instanceof _I) { - void 0 === i3 && (i3 = e3.byteLength - t2), (t2 += e3.byteOffset) + i3 > e3.byteOffset + e3.byteLength && g2("Creating view outside of available memory in ArrayBuffer"); - let n4 = new DataView(e3.buffer, t2, i3); - this._swapDataView(n4); - } else if ("number" == typeof e3) { - let t3 = new DataView(new ArrayBuffer(e3)); - this._swapDataView(t3); - } else g2("Invalid input argument for BufferView: " + e3); - } - _swapArrayBuffer(e3) { - this._swapDataView(new DataView(e3)); - } - _swapBuffer(e3) { - this._swapDataView(new DataView(e3.buffer, e3.byteOffset, e3.byteLength)); - } - _swapDataView(e3) { - this.dataView = e3, this.buffer = e3.buffer, this.byteOffset = e3.byteOffset, this.byteLength = e3.byteLength; - } - _lengthToEnd(e3) { - return this.byteLength - e3; - } - set(e3, t2, i3 = _I) { - return e3 instanceof DataView || e3 instanceof _I ? e3 = new Uint8Array(e3.buffer, e3.byteOffset, e3.byteLength) : e3 instanceof ArrayBuffer && (e3 = new Uint8Array(e3)), e3 instanceof Uint8Array || g2("BufferView.set(): Invalid data argument."), this.toUint8().set(e3, t2), new i3(this, t2, e3.byteLength); - } - subarray(e3, t2) { - return t2 = t2 || this._lengthToEnd(e3), new _I(this, e3, t2); - } - toUint8() { - return new Uint8Array(this.buffer, this.byteOffset, this.byteLength); - } - getUint8Array(e3, t2) { - return new Uint8Array(this.buffer, this.byteOffset + e3, t2); - } - getString(e3 = 0, t2 = this.byteLength) { - return b(this.getUint8Array(e3, t2)); - } - getLatin1String(e3 = 0, t2 = this.byteLength) { - let i3 = this.getUint8Array(e3, t2); - return C(i3); - } - getUnicodeString(e3 = 0, t2 = this.byteLength) { - const i3 = []; - for (let n3 = 0; n3 < t2 && e3 + n3 < this.byteLength; n3 += 2) i3.push(this.getUint16(e3 + n3)); - return C(i3); - } - getInt8(e3) { - return this.dataView.getInt8(e3); - } - getUint8(e3) { - return this.dataView.getUint8(e3); - } - getInt16(e3, t2 = this.le) { - return this.dataView.getInt16(e3, t2); - } - getInt32(e3, t2 = this.le) { - return this.dataView.getInt32(e3, t2); - } - getUint16(e3, t2 = this.le) { - return this.dataView.getUint16(e3, t2); - } - getUint32(e3, t2 = this.le) { - return this.dataView.getUint32(e3, t2); - } - getFloat32(e3, t2 = this.le) { - return this.dataView.getFloat32(e3, t2); - } - getFloat64(e3, t2 = this.le) { - return this.dataView.getFloat64(e3, t2); - } - getFloat(e3, t2 = this.le) { - return this.dataView.getFloat32(e3, t2); - } - getDouble(e3, t2 = this.le) { - return this.dataView.getFloat64(e3, t2); - } - getUintBytes(e3, t2, i3) { - switch (t2) { - case 1: - return this.getUint8(e3, i3); - case 2: - return this.getUint16(e3, i3); - case 4: - return this.getUint32(e3, i3); - case 8: - return this.getUint64 && this.getUint64(e3, i3); - } - } - getUint(e3, t2, i3) { - switch (t2) { - case 8: - return this.getUint8(e3, i3); - case 16: - return this.getUint16(e3, i3); - case 32: - return this.getUint32(e3, i3); - case 64: - return this.getUint64 && this.getUint64(e3, i3); - } - } - toString(e3) { - return this.dataView.toString(e3, this.constructor.name); - } - ensureChunk() { - } - }; - function P(e3, t2) { - g2("".concat(e3, " '").concat(t2, "' was not loaded, try using full build of exifr.")); - } - var k = class extends Map { - constructor(e3) { - super(), this.kind = e3; - } - get(e3, t2) { - return this.has(e3) || P(this.kind, e3), t2 && (e3 in t2 || function(e4, t3) { - g2("Unknown ".concat(e4, " '").concat(t3, "'.")); - }(this.kind, e3), t2[e3].enabled || P(this.kind, e3)), super.get(e3); - } - keyList() { - return Array.from(this.keys()); + c(ut, "type", "png"), w.set("png", ut), U(E, "interop", [[1, "InteropIndex"], [2, "InteropVersion"], [4096, "RelatedImageFileFormat"], [4097, "RelatedImageWidth"], [4098, "RelatedImageHeight"]]), F(E, "ifd0", [[11, "ProcessingSoftware"], [254, "SubfileType"], [255, "OldSubfileType"], [263, "Thresholding"], [264, "CellWidth"], [265, "CellLength"], [266, "FillOrder"], [269, "DocumentName"], [280, "MinSampleValue"], [281, "MaxSampleValue"], [285, "PageName"], [286, "XPosition"], [287, "YPosition"], [290, "GrayResponseUnit"], [297, "PageNumber"], [321, "HalftoneHints"], [322, "TileWidth"], [323, "TileLength"], [332, "InkSet"], [337, "TargetPrinter"], [18246, "Rating"], [18249, "RatingPercent"], [33550, "PixelScale"], [34264, "ModelTransform"], [34377, "PhotoshopSettings"], [50706, "DNGVersion"], [50707, "DNGBackwardVersion"], [50708, "UniqueCameraModel"], [50709, "LocalizedCameraModel"], [50736, "DNGLensInfo"], [50739, "ShadowScale"], [50740, "DNGPrivateData"], [33920, "IntergraphMatrix"], [33922, "ModelTiePoint"], [34118, "SEMInfo"], [34735, "GeoTiffDirectory"], [34736, "GeoTiffDoubleParams"], [34737, "GeoTiffAsciiParams"], [50341, "PrintIM"], [50721, "ColorMatrix1"], [50722, "ColorMatrix2"], [50723, "CameraCalibration1"], [50724, "CameraCalibration2"], [50725, "ReductionMatrix1"], [50726, "ReductionMatrix2"], [50727, "AnalogBalance"], [50728, "AsShotNeutral"], [50729, "AsShotWhiteXY"], [50730, "BaselineExposure"], [50731, "BaselineNoise"], [50732, "BaselineSharpness"], [50734, "LinearResponseLimit"], [50735, "CameraSerialNumber"], [50741, "MakerNoteSafety"], [50778, "CalibrationIlluminant1"], [50779, "CalibrationIlluminant2"], [50781, "RawDataUniqueID"], [50827, "OriginalRawFileName"], [50828, "OriginalRawFileData"], [50831, "AsShotICCProfile"], [50832, "AsShotPreProfileMatrix"], [50833, "CurrentICCProfile"], [50834, "CurrentPreProfileMatrix"], [50879, "ColorimetricReference"], [50885, "SRawType"], [50898, "PanasonicTitle"], [50899, "PanasonicTitle2"], [50931, "CameraCalibrationSig"], [50932, "ProfileCalibrationSig"], [50933, "ProfileIFD"], [50934, "AsShotProfileName"], [50936, "ProfileName"], [50937, "ProfileHueSatMapDims"], [50938, "ProfileHueSatMapData1"], [50939, "ProfileHueSatMapData2"], [50940, "ProfileToneCurve"], [50941, "ProfileEmbedPolicy"], [50942, "ProfileCopyright"], [50964, "ForwardMatrix1"], [50965, "ForwardMatrix2"], [50966, "PreviewApplicationName"], [50967, "PreviewApplicationVersion"], [50968, "PreviewSettingsName"], [50969, "PreviewSettingsDigest"], [50970, "PreviewColorSpace"], [50971, "PreviewDateTime"], [50972, "RawImageDigest"], [50973, "OriginalRawFileDigest"], [50981, "ProfileLookTableDims"], [50982, "ProfileLookTableData"], [51043, "TimeCodes"], [51044, "FrameRate"], [51058, "TStop"], [51081, "ReelName"], [51089, "OriginalDefaultFinalSize"], [51090, "OriginalBestQualitySize"], [51091, "OriginalDefaultCropSize"], [51105, "CameraLabel"], [51107, "ProfileHueSatMapEncoding"], [51108, "ProfileLookTableEncoding"], [51109, "BaselineExposureOffset"], [51110, "DefaultBlackRender"], [51111, "NewRawImageDigest"], [51112, "RawToPreviewGain"]]); + ct = [[273, "StripOffsets"], [279, "StripByteCounts"], [288, "FreeOffsets"], [289, "FreeByteCounts"], [291, "GrayResponseCurve"], [292, "T4Options"], [293, "T6Options"], [300, "ColorResponseUnit"], [320, "ColorMap"], [324, "TileOffsets"], [325, "TileByteCounts"], [326, "BadFaxLines"], [327, "CleanFaxData"], [328, "ConsecutiveBadFaxLines"], [330, "SubIFD"], [333, "InkNames"], [334, "NumberofInks"], [336, "DotRange"], [338, "ExtraSamples"], [339, "SampleFormat"], [340, "SMinSampleValue"], [341, "SMaxSampleValue"], [342, "TransferRange"], [343, "ClipPath"], [344, "XClipPathUnits"], [345, "YClipPathUnits"], [346, "Indexed"], [347, "JPEGTables"], [351, "OPIProxy"], [400, "GlobalParametersIFD"], [401, "ProfileType"], [402, "FaxProfile"], [403, "CodingMethods"], [404, "VersionYear"], [405, "ModeNumber"], [433, "Decode"], [434, "DefaultImageColor"], [435, "T82Options"], [437, "JPEGTables"], [512, "JPEGProc"], [515, "JPEGRestartInterval"], [517, "JPEGLosslessPredictors"], [518, "JPEGPointTransforms"], [519, "JPEGQTables"], [520, "JPEGDCTables"], [521, "JPEGACTables"], [559, "StripRowCounts"], [999, "USPTOMiscellaneous"], [18247, "XP_DIP_XML"], [18248, "StitchInfo"], [28672, "SonyRawFileType"], [28688, "SonyToneCurve"], [28721, "VignettingCorrection"], [28722, "VignettingCorrParams"], [28724, "ChromaticAberrationCorrection"], [28725, "ChromaticAberrationCorrParams"], [28726, "DistortionCorrection"], [28727, "DistortionCorrParams"], [29895, "SonyCropTopLeft"], [29896, "SonyCropSize"], [32781, "ImageID"], [32931, "WangTag1"], [32932, "WangAnnotation"], [32933, "WangTag3"], [32934, "WangTag4"], [32953, "ImageReferencePoints"], [32954, "RegionXformTackPoint"], [32955, "WarpQuadrilateral"], [32956, "AffineTransformMat"], [32995, "Matteing"], [32996, "DataType"], [32997, "ImageDepth"], [32998, "TileDepth"], [33300, "ImageFullWidth"], [33301, "ImageFullHeight"], [33302, "TextureFormat"], [33303, "WrapModes"], [33304, "FovCot"], [33305, "MatrixWorldToScreen"], [33306, "MatrixWorldToCamera"], [33405, "Model2"], [33421, "CFARepeatPatternDim"], [33422, "CFAPattern2"], [33423, "BatteryLevel"], [33424, "KodakIFD"], [33445, "MDFileTag"], [33446, "MDScalePixel"], [33447, "MDColorTable"], [33448, "MDLabName"], [33449, "MDSampleInfo"], [33450, "MDPrepDate"], [33451, "MDPrepTime"], [33452, "MDFileUnits"], [33589, "AdventScale"], [33590, "AdventRevision"], [33628, "UIC1Tag"], [33629, "UIC2Tag"], [33630, "UIC3Tag"], [33631, "UIC4Tag"], [33918, "IntergraphPacketData"], [33919, "IntergraphFlagRegisters"], [33921, "INGRReserved"], [34016, "Site"], [34017, "ColorSequence"], [34018, "IT8Header"], [34019, "RasterPadding"], [34020, "BitsPerRunLength"], [34021, "BitsPerExtendedRunLength"], [34022, "ColorTable"], [34023, "ImageColorIndicator"], [34024, "BackgroundColorIndicator"], [34025, "ImageColorValue"], [34026, "BackgroundColorValue"], [34027, "PixelIntensityRange"], [34028, "TransparencyIndicator"], [34029, "ColorCharacterization"], [34030, "HCUsage"], [34031, "TrapIndicator"], [34032, "CMYKEquivalent"], [34152, "AFCP_IPTC"], [34232, "PixelMagicJBIGOptions"], [34263, "JPLCartoIFD"], [34306, "WB_GRGBLevels"], [34310, "LeafData"], [34687, "TIFF_FXExtensions"], [34688, "MultiProfiles"], [34689, "SharedData"], [34690, "T88Options"], [34732, "ImageLayer"], [34750, "JBIGOptions"], [34856, "Opto-ElectricConvFactor"], [34857, "Interlace"], [34908, "FaxRecvParams"], [34909, "FaxSubAddress"], [34910, "FaxRecvTime"], [34929, "FedexEDR"], [34954, "LeafSubIFD"], [37387, "FlashEnergy"], [37388, "SpatialFrequencyResponse"], [37389, "Noise"], [37390, "FocalPlaneXResolution"], [37391, "FocalPlaneYResolution"], [37392, "FocalPlaneResolutionUnit"], [37397, "ExposureIndex"], [37398, "TIFF-EPStandardID"], [37399, "SensingMethod"], [37434, "CIP3DataFile"], [37435, "CIP3Sheet"], [37436, "CIP3Side"], [37439, "StoNits"], [37679, "MSDocumentText"], [37680, "MSPropertySetStorage"], [37681, "MSDocumentTextPosition"], [37724, "ImageSourceData"], [40965, "InteropIFD"], [40976, "SamsungRawPointersOffset"], [40977, "SamsungRawPointersLength"], [41217, "SamsungRawByteOrder"], [41218, "SamsungRawUnknown"], [41484, "SpatialFrequencyResponse"], [41485, "Noise"], [41489, "ImageNumber"], [41490, "SecurityClassification"], [41491, "ImageHistory"], [41494, "TIFF-EPStandardID"], [41995, "DeviceSettingDescription"], [42112, "GDALMetadata"], [42113, "GDALNoData"], [44992, "ExpandSoftware"], [44993, "ExpandLens"], [44994, "ExpandFilm"], [44995, "ExpandFilterLens"], [44996, "ExpandScanner"], [44997, "ExpandFlashLamp"], [46275, "HasselbladRawImage"], [48129, "PixelFormat"], [48130, "Transformation"], [48131, "Uncompressed"], [48132, "ImageType"], [48256, "ImageWidth"], [48257, "ImageHeight"], [48258, "WidthResolution"], [48259, "HeightResolution"], [48320, "ImageOffset"], [48321, "ImageByteCount"], [48322, "AlphaOffset"], [48323, "AlphaByteCount"], [48324, "ImageDataDiscard"], [48325, "AlphaDataDiscard"], [50215, "OceScanjobDesc"], [50216, "OceApplicationSelector"], [50217, "OceIDNumber"], [50218, "OceImageLogic"], [50255, "Annotations"], [50459, "HasselbladExif"], [50547, "OriginalFileName"], [50560, "USPTOOriginalContentType"], [50656, "CR2CFAPattern"], [50710, "CFAPlaneColor"], [50711, "CFALayout"], [50712, "LinearizationTable"], [50713, "BlackLevelRepeatDim"], [50714, "BlackLevel"], [50715, "BlackLevelDeltaH"], [50716, "BlackLevelDeltaV"], [50717, "WhiteLevel"], [50718, "DefaultScale"], [50719, "DefaultCropOrigin"], [50720, "DefaultCropSize"], [50733, "BayerGreenSplit"], [50737, "ChromaBlurRadius"], [50738, "AntiAliasStrength"], [50752, "RawImageSegmentation"], [50780, "BestQualityScale"], [50784, "AliasLayerMetadata"], [50829, "ActiveArea"], [50830, "MaskedAreas"], [50935, "NoiseReductionApplied"], [50974, "SubTileBlockSize"], [50975, "RowInterleaveFactor"], [51008, "OpcodeList1"], [51009, "OpcodeList2"], [51022, "OpcodeList3"], [51041, "NoiseProfile"], [51114, "CacheVersion"], [51125, "DefaultUserCrop"], [51157, "NikonNEFInfo"], [65024, "KdcIFD"]]; + F(E, "ifd0", ct), F(E, "exif", ct), U(B, "gps", [[23, { M: "Magnetic North", T: "True North" }], [25, { K: "Kilometers", M: "Miles", N: "Nautical Miles" }]]); + ft = class extends re2 { + static canHandle(e3, t2) { + return 224 === e3.getUint8(t2 + 1) && 1246120262 === e3.getUint32(t2 + 4) && 0 === e3.getUint8(t2 + 8); + } + parse() { + return this.parseTags(), this.translate(), this.output; + } + parseTags() { + this.raw = /* @__PURE__ */ new Map([[0, this.chunk.getUint16(0)], [2, this.chunk.getUint8(2)], [3, this.chunk.getUint16(3)], [5, this.chunk.getUint16(5)], [7, this.chunk.getUint8(7)], [8, this.chunk.getUint8(8)]]); + } + }; + c(ft, "type", "jfif"), c(ft, "headerLength", 9), T.set("jfif", ft), U(E, "jfif", [[0, "JFIFVersion"], [2, "ResolutionUnit"], [3, "XResolution"], [5, "YResolution"], [7, "ThumbnailWidth"], [8, "ThumbnailHeight"]]); + dt = class extends re2 { + parse() { + return this.parseTags(), this.translate(), this.output; + } + parseTags() { + this.raw = new Map([[0, this.chunk.getUint32(0)], [4, this.chunk.getUint32(4)], [8, this.chunk.getUint8(8)], [9, this.chunk.getUint8(9)], [10, this.chunk.getUint8(10)], [11, this.chunk.getUint8(11)], [12, this.chunk.getUint8(12)], ...Array.from(this.raw)]); + } + }; + c(dt, "type", "ihdr"), T.set("ihdr", dt), U(E, "ihdr", [[0, "ImageWidth"], [4, "ImageHeight"], [8, "BitDepth"], [9, "ColorType"], [10, "Compression"], [11, "Filter"], [12, "Interlace"]]), U(B, "ihdr", [[9, { 0: "Grayscale", 2: "RGB", 3: "Palette", 4: "Grayscale with Alpha", 6: "RGB with Alpha", DEFAULT: "Unknown" }], [10, { 0: "Deflate/Inflate", DEFAULT: "Unknown" }], [11, { 0: "Adaptive", DEFAULT: "Unknown" }], [12, { 0: "Noninterlaced", 1: "Adam7 Interlace", DEFAULT: "Unknown" }]]); + pt = class extends re2 { + static canHandle(e3, t2) { + return 226 === e3.getUint8(t2 + 1) && 1229144927 === e3.getUint32(t2 + 4); + } + static findPosition(e3, t2) { + let i3 = super.findPosition(e3, t2); + return i3.chunkNumber = e3.getUint8(t2 + 16), i3.chunkCount = e3.getUint8(t2 + 17), i3.multiSegment = i3.chunkCount > 1, i3; + } + static handleMultiSegments(e3) { + return function(e4) { + let t2 = function(e6) { + let t3 = e6[0].constructor, i3 = 0; + for (let t4 of e6) i3 += t4.length; + let n3 = new t3(i3), s2 = 0; + for (let t4 of e6) n3.set(t4, s2), s2 += t4.length; + return n3; + }(e4.map((e6) => e6.chunk.toUint8())); + return new I(t2); + }(e3); + } + parse() { + return this.raw = /* @__PURE__ */ new Map(), this.parseHeader(), this.parseTags(), this.translate(), this.output; + } + parseHeader() { + let { raw: e3 } = this; + this.chunk.byteLength < 84 && g2("ICC header is too short"); + for (let [t2, i3] of Object.entries(gt)) { + t2 = parseInt(t2, 10); + let n3 = i3(this.chunk, t2); + "\0\0\0\0" !== n3 && e3.set(t2, n3); + } + } + parseTags() { + let e3, t2, i3, n3, s2, { raw: r2 } = this, a2 = this.chunk.getUint32(128), o2 = 132, l2 = this.chunk.byteLength; + for (; a2--; ) { + if (e3 = this.chunk.getString(o2, 4), t2 = this.chunk.getUint32(o2 + 4), i3 = this.chunk.getUint32(o2 + 8), n3 = this.chunk.getString(t2, 4), t2 + i3 > l2) return void console.warn("reached the end of the first ICC chunk. Enable options.tiff.multiSegment to read all ICC segments."); + s2 = this.parseTag(n3, t2, i3), void 0 !== s2 && "\0\0\0\0" !== s2 && r2.set(e3, s2), o2 += 12; + } + } + parseTag(e3, t2, i3) { + switch (e3) { + case "desc": + return this.parseDesc(t2); + case "mluc": + return this.parseMluc(t2); + case "text": + return this.parseText(t2, i3); + case "sig ": + return this.parseSig(t2); + } + if (!(t2 + i3 > this.chunk.byteLength)) return this.chunk.getUint8Array(t2, i3); + } + parseDesc(e3) { + let t2 = this.chunk.getUint32(e3 + 8) - 1; + return m(this.chunk.getString(e3 + 12, t2)); + } + parseText(e3, t2) { + return m(this.chunk.getString(e3 + 8, t2 - 8)); + } + parseSig(e3) { + return m(this.chunk.getString(e3 + 8, 4)); + } + parseMluc(e3) { + let { chunk: t2 } = this, i3 = t2.getUint32(e3 + 8), n3 = t2.getUint32(e3 + 12), s2 = e3 + 16, r2 = []; + for (let a2 = 0; a2 < i3; a2++) { + let i4 = t2.getString(s2 + 0, 2), a3 = t2.getString(s2 + 2, 2), o2 = t2.getUint32(s2 + 4), l2 = t2.getUint32(s2 + 8) + e3, h2 = m(t2.getUnicodeString(l2, o2)); + r2.push({ lang: i4, country: a3, text: h2 }), s2 += n3; + } + return 1 === i3 ? r2[0].text : r2; + } + translateValue(e3, t2) { + return "string" == typeof e3 ? t2[e3] || t2[e3.toLowerCase()] || e3 : t2[e3] || e3; + } + }; + c(pt, "type", "icc"), c(pt, "multiSegment", true), c(pt, "headerLength", 18); + gt = { 4: mt, 8: function(e3, t2) { + return [e3.getUint8(t2), e3.getUint8(t2 + 1) >> 4, e3.getUint8(t2 + 1) % 16].map((e4) => e4.toString(10)).join("."); + }, 12: mt, 16: mt, 20: mt, 24: function(e3, t2) { + const i3 = e3.getUint16(t2), n3 = e3.getUint16(t2 + 2) - 1, s2 = e3.getUint16(t2 + 4), r2 = e3.getUint16(t2 + 6), a2 = e3.getUint16(t2 + 8), o2 = e3.getUint16(t2 + 10); + return new Date(Date.UTC(i3, n3, s2, r2, a2, o2)); + }, 36: mt, 40: mt, 48: mt, 52: mt, 64: (e3, t2) => e3.getUint32(t2), 80: mt }; + T.set("icc", pt), U(E, "icc", [[4, "ProfileCMMType"], [8, "ProfileVersion"], [12, "ProfileClass"], [16, "ColorSpaceData"], [20, "ProfileConnectionSpace"], [24, "ProfileDateTime"], [36, "ProfileFileSignature"], [40, "PrimaryPlatform"], [44, "CMMFlags"], [48, "DeviceManufacturer"], [52, "DeviceModel"], [56, "DeviceAttributes"], [64, "RenderingIntent"], [68, "ConnectionSpaceIlluminant"], [80, "ProfileCreator"], [84, "ProfileID"], ["Header", "ProfileHeader"], ["MS00", "WCSProfiles"], ["bTRC", "BlueTRC"], ["bXYZ", "BlueMatrixColumn"], ["bfd", "UCRBG"], ["bkpt", "MediaBlackPoint"], ["calt", "CalibrationDateTime"], ["chad", "ChromaticAdaptation"], ["chrm", "Chromaticity"], ["ciis", "ColorimetricIntentImageState"], ["clot", "ColorantTableOut"], ["clro", "ColorantOrder"], ["clrt", "ColorantTable"], ["cprt", "ProfileCopyright"], ["crdi", "CRDInfo"], ["desc", "ProfileDescription"], ["devs", "DeviceSettings"], ["dmdd", "DeviceModelDesc"], ["dmnd", "DeviceMfgDesc"], ["dscm", "ProfileDescriptionML"], ["fpce", "FocalPlaneColorimetryEstimates"], ["gTRC", "GreenTRC"], ["gXYZ", "GreenMatrixColumn"], ["gamt", "Gamut"], ["kTRC", "GrayTRC"], ["lumi", "Luminance"], ["meas", "Measurement"], ["meta", "Metadata"], ["mmod", "MakeAndModel"], ["ncl2", "NamedColor2"], ["ncol", "NamedColor"], ["ndin", "NativeDisplayInfo"], ["pre0", "Preview0"], ["pre1", "Preview1"], ["pre2", "Preview2"], ["ps2i", "PS2RenderingIntent"], ["ps2s", "PostScript2CSA"], ["psd0", "PostScript2CRD0"], ["psd1", "PostScript2CRD1"], ["psd2", "PostScript2CRD2"], ["psd3", "PostScript2CRD3"], ["pseq", "ProfileSequenceDesc"], ["psid", "ProfileSequenceIdentifier"], ["psvm", "PS2CRDVMSize"], ["rTRC", "RedTRC"], ["rXYZ", "RedMatrixColumn"], ["resp", "OutputResponse"], ["rhoc", "ReflectionHardcopyOrigColorimetry"], ["rig0", "PerceptualRenderingIntentGamut"], ["rig2", "SaturationRenderingIntentGamut"], ["rpoc", "ReflectionPrintOutputColorimetry"], ["sape", "SceneAppearanceEstimates"], ["scoe", "SceneColorimetryEstimates"], ["scrd", "ScreeningDesc"], ["scrn", "Screening"], ["targ", "CharTarget"], ["tech", "Technology"], ["vcgt", "VideoCardGamma"], ["view", "ViewingConditions"], ["vued", "ViewingCondDesc"], ["wtpt", "MediaWhitePoint"]]); + St = { "4d2p": "Erdt Systems", AAMA: "Aamazing Technologies", ACER: "Acer", ACLT: "Acolyte Color Research", ACTI: "Actix Sytems", ADAR: "Adara Technology", ADBE: "Adobe", ADI: "ADI Systems", AGFA: "Agfa Graphics", ALMD: "Alps Electric", ALPS: "Alps Electric", ALWN: "Alwan Color Expertise", AMTI: "Amiable Technologies", AOC: "AOC International", APAG: "Apago", APPL: "Apple Computer", AST: "AST", "AT&T": "AT&T", BAEL: "BARBIERI electronic", BRCO: "Barco NV", BRKP: "Breakpoint", BROT: "Brother", BULL: "Bull", BUS: "Bus Computer Systems", "C-IT": "C-Itoh", CAMR: "Intel", CANO: "Canon", CARR: "Carroll Touch", CASI: "Casio", CBUS: "Colorbus PL", CEL: "Crossfield", CELx: "Crossfield", CGS: "CGS Publishing Technologies International", CHM: "Rochester Robotics", CIGL: "Colour Imaging Group, London", CITI: "Citizen", CL00: "Candela", CLIQ: "Color IQ", CMCO: "Chromaco", CMiX: "CHROMiX", COLO: "Colorgraphic Communications", COMP: "Compaq", COMp: "Compeq/Focus Technology", CONR: "Conrac Display Products", CORD: "Cordata Technologies", CPQ: "Compaq", CPRO: "ColorPro", CRN: "Cornerstone", CTX: "CTX International", CVIS: "ColorVision", CWC: "Fujitsu Laboratories", DARI: "Darius Technology", DATA: "Dataproducts", DCP: "Dry Creek Photo", DCRC: "Digital Contents Resource Center, Chung-Ang University", DELL: "Dell Computer", DIC: "Dainippon Ink and Chemicals", DICO: "Diconix", DIGI: "Digital", "DL&C": "Digital Light & Color", DPLG: "Doppelganger", DS: "Dainippon Screen", DSOL: "DOOSOL", DUPN: "DuPont", EPSO: "Epson", ESKO: "Esko-Graphics", ETRI: "Electronics and Telecommunications Research Institute", EVER: "Everex Systems", EXAC: "ExactCODE", Eizo: "Eizo", FALC: "Falco Data Products", FF: "Fuji Photo Film", FFEI: "FujiFilm Electronic Imaging", FNRD: "Fnord Software", FORA: "Fora", FORE: "Forefront Technology", FP: "Fujitsu", FPA: "WayTech Development", FUJI: "Fujitsu", FX: "Fuji Xerox", GCC: "GCC Technologies", GGSL: "Global Graphics Software", GMB: "Gretagmacbeth", GMG: "GMG", GOLD: "GoldStar Technology", GOOG: "Google", GPRT: "Giantprint", GTMB: "Gretagmacbeth", GVC: "WayTech Development", GW2K: "Sony", HCI: "HCI", HDM: "Heidelberger Druckmaschinen", HERM: "Hermes", HITA: "Hitachi America", HP: "Hewlett-Packard", HTC: "Hitachi", HiTi: "HiTi Digital", IBM: "IBM", IDNT: "Scitex", IEC: "Hewlett-Packard", IIYA: "Iiyama North America", IKEG: "Ikegami Electronics", IMAG: "Image Systems", IMI: "Ingram Micro", INTC: "Intel", INTL: "N/A (INTL)", INTR: "Intra Electronics", IOCO: "Iocomm International Technology", IPS: "InfoPrint Solutions Company", IRIS: "Scitex", ISL: "Ichikawa Soft Laboratory", ITNL: "N/A (ITNL)", IVM: "IVM", IWAT: "Iwatsu Electric", Idnt: "Scitex", Inca: "Inca Digital Printers", Iris: "Scitex", JPEG: "Joint Photographic Experts Group", JSFT: "Jetsoft Development", JVC: "JVC Information Products", KART: "Scitex", KFC: "KFC Computek Components", KLH: "KLH Computers", KMHD: "Konica Minolta", KNCA: "Konica", KODA: "Kodak", KYOC: "Kyocera", Kart: "Scitex", LCAG: "Leica", LCCD: "Leeds Colour", LDAK: "Left Dakota", LEAD: "Leading Technology", LEXM: "Lexmark International", LINK: "Link Computer", LINO: "Linotronic", LITE: "Lite-On", Leaf: "Leaf", Lino: "Linotronic", MAGC: "Mag Computronic", MAGI: "MAG Innovision", MANN: "Mannesmann", MICN: "Micron Technology", MICR: "Microtek", MICV: "Microvitec", MINO: "Minolta", MITS: "Mitsubishi Electronics America", MITs: "Mitsuba", MNLT: "Minolta", MODG: "Modgraph", MONI: "Monitronix", MONS: "Monaco Systems", MORS: "Morse Technology", MOTI: "Motive Systems", MSFT: "Microsoft", MUTO: "MUTOH INDUSTRIES", Mits: "Mitsubishi Electric", NANA: "NANAO", NEC: "NEC", NEXP: "NexPress Solutions", NISS: "Nissei Sangyo America", NKON: "Nikon", NONE: "none", OCE: "Oce Technologies", OCEC: "OceColor", OKI: "Oki", OKID: "Okidata", OKIP: "Okidata", OLIV: "Olivetti", OLYM: "Olympus", ONYX: "Onyx Graphics", OPTI: "Optiquest", PACK: "Packard Bell", PANA: "Matsushita Electric Industrial", PANT: "Pantone", PBN: "Packard Bell", PFU: "PFU", PHIL: "Philips Consumer Electronics", PNTX: "HOYA", POne: "Phase One A/S", PREM: "Premier Computer Innovations", PRIN: "Princeton Graphic Systems", PRIP: "Princeton Publishing Labs", QLUX: "Hong Kong", QMS: "QMS", QPCD: "QPcard AB", QUAD: "QuadLaser", QUME: "Qume", RADI: "Radius", RDDx: "Integrated Color Solutions", RDG: "Roland DG", REDM: "REDMS Group", RELI: "Relisys", RGMS: "Rolf Gierling Multitools", RICO: "Ricoh", RNLD: "Edmund Ronald", ROYA: "Royal", RPC: "Ricoh Printing Systems", RTL: "Royal Information Electronics", SAMP: "Sampo", SAMS: "Samsung", SANT: "Jaime Santana Pomares", SCIT: "Scitex", SCRN: "Dainippon Screen", SDP: "Scitex", SEC: "Samsung", SEIK: "Seiko Instruments", SEIk: "Seikosha", SGUY: "ScanGuy.com", SHAR: "Sharp Laboratories", SICC: "International Color Consortium", SONY: "Sony", SPCL: "SpectraCal", STAR: "Star", STC: "Sampo Technology", Scit: "Scitex", Sdp: "Scitex", Sony: "Sony", TALO: "Talon Technology", TAND: "Tandy", TATU: "Tatung", TAXA: "TAXAN America", TDS: "Tokyo Denshi Sekei", TECO: "TECO Information Systems", TEGR: "Tegra", TEKT: "Tektronix", TI: "Texas Instruments", TMKR: "TypeMaker", TOSB: "Toshiba", TOSH: "Toshiba", TOTK: "TOTOKU ELECTRIC", TRIU: "Triumph", TSBT: "Toshiba", TTX: "TTX Computer Products", TVM: "TVM Professional Monitor", TW: "TW Casper", ULSX: "Ulead Systems", UNIS: "Unisys", UTZF: "Utz Fehlau & Sohn", VARI: "Varityper", VIEW: "Viewsonic", VISL: "Visual communication", VIVO: "Vivo Mobile Communication", WANG: "Wang", WLBR: "Wilbur Imaging", WTG2: "Ware To Go", WYSE: "WYSE Technology", XERX: "Xerox", XRIT: "X-Rite", ZRAN: "Zoran", Zebr: "Zebra Technologies", appl: "Apple Computer", bICC: "basICColor", berg: "bergdesign", ceyd: "Integrated Color Solutions", clsp: "MacDermid ColorSpan", ds: "Dainippon Screen", dupn: "DuPont", ffei: "FujiFilm Electronic Imaging", flux: "FluxData", iris: "Scitex", kart: "Scitex", lcms: "Little CMS", lino: "Linotronic", none: "none", ob4d: "Erdt Systems", obic: "Medigraph", quby: "Qubyx Sarl", scit: "Scitex", scrn: "Dainippon Screen", sdp: "Scitex", siwi: "SIWI GRAFIKA", yxym: "YxyMaster" }; + Ct = { scnr: "Scanner", mntr: "Monitor", prtr: "Printer", link: "Device Link", abst: "Abstract", spac: "Color Space Conversion Profile", nmcl: "Named Color", cenc: "ColorEncodingSpace profile", mid: "MultiplexIdentification profile", mlnk: "MultiplexLink profile", mvis: "MultiplexVisualization profile", nkpf: "Nikon Input Device Profile (NON-STANDARD!)" }; + U(B, "icc", [[4, St], [12, Ct], [40, Object.assign({}, St, Ct)], [48, St], [80, St], [64, { 0: "Perceptual", 1: "Relative Colorimetric", 2: "Saturation", 3: "Absolute Colorimetric" }], ["tech", { amd: "Active Matrix Display", crt: "Cathode Ray Tube Display", kpcd: "Photo CD", pmd: "Passive Matrix Display", dcam: "Digital Camera", dcpj: "Digital Cinema Projector", dmpc: "Digital Motion Picture Camera", dsub: "Dye Sublimation Printer", epho: "Electrophotographic Printer", esta: "Electrostatic Printer", flex: "Flexography", fprn: "Film Writer", fscn: "Film Scanner", grav: "Gravure", ijet: "Ink Jet Printer", imgs: "Photo Image Setter", mpfr: "Motion Picture Film Recorder", mpfs: "Motion Picture Film Scanner", offs: "Offset Lithography", pjtv: "Projection Television", rpho: "Photographic Paper Printer", rscn: "Reflective Scanner", silk: "Silkscreen", twax: "Thermal Wax Printer", vidc: "Video Camera", vidm: "Video Monitor" }]]); + yt = class extends re2 { + static canHandle(e3, t2, i3) { + return 237 === e3.getUint8(t2 + 1) && "Photoshop" === e3.getString(t2 + 4, 9) && void 0 !== this.containsIptc8bim(e3, t2, i3); + } + static headerLength(e3, t2, i3) { + let n3, s2 = this.containsIptc8bim(e3, t2, i3); + if (void 0 !== s2) return n3 = e3.getUint8(t2 + s2 + 7), n3 % 2 != 0 && (n3 += 1), 0 === n3 && (n3 = 4), s2 + 8 + n3; + } + static containsIptc8bim(e3, t2, i3) { + for (let n3 = 0; n3 < i3; n3++) if (this.isIptcSegmentHead(e3, t2 + n3)) return n3; + } + static isIptcSegmentHead(e3, t2) { + return 56 === e3.getUint8(t2) && 943868237 === e3.getUint32(t2) && 1028 === e3.getUint16(t2 + 4); + } + parse() { + let { raw: e3 } = this, t2 = this.chunk.byteLength - 1, i3 = false; + for (let n3 = 0; n3 < t2; n3++) if (28 === this.chunk.getUint8(n3) && 2 === this.chunk.getUint8(n3 + 1)) { + i3 = true; + let t3 = this.chunk.getUint16(n3 + 3), s2 = this.chunk.getUint8(n3 + 2), r2 = this.chunk.getLatin1String(n3 + 5, t3); + e3.set(s2, this.pluralizeValue(e3.get(s2), r2)), n3 += 4 + t3; + } else if (i3) break; + return this.translate(), this.output; + } + pluralizeValue(e3, t2) { + return void 0 !== e3 ? e3 instanceof Array ? (e3.push(t2), e3) : [e3, t2] : t2; + } + }; + c(yt, "type", "iptc"), c(yt, "translateValues", false), c(yt, "reviveValues", false), T.set("iptc", yt), U(E, "iptc", [[0, "ApplicationRecordVersion"], [3, "ObjectTypeReference"], [4, "ObjectAttributeReference"], [5, "ObjectName"], [7, "EditStatus"], [8, "EditorialUpdate"], [10, "Urgency"], [12, "SubjectReference"], [15, "Category"], [20, "SupplementalCategories"], [22, "FixtureIdentifier"], [25, "Keywords"], [26, "ContentLocationCode"], [27, "ContentLocationName"], [30, "ReleaseDate"], [35, "ReleaseTime"], [37, "ExpirationDate"], [38, "ExpirationTime"], [40, "SpecialInstructions"], [42, "ActionAdvised"], [45, "ReferenceService"], [47, "ReferenceDate"], [50, "ReferenceNumber"], [55, "DateCreated"], [60, "TimeCreated"], [62, "DigitalCreationDate"], [63, "DigitalCreationTime"], [65, "OriginatingProgram"], [70, "ProgramVersion"], [75, "ObjectCycle"], [80, "Byline"], [85, "BylineTitle"], [90, "City"], [92, "Sublocation"], [95, "State"], [100, "CountryCode"], [101, "Country"], [103, "OriginalTransmissionReference"], [105, "Headline"], [110, "Credit"], [115, "Source"], [116, "CopyrightNotice"], [118, "Contact"], [120, "Caption"], [121, "LocalCaption"], [122, "Writer"], [125, "RasterizedCaption"], [130, "ImageType"], [131, "ImageOrientation"], [135, "LanguageIdentifier"], [150, "AudioType"], [151, "AudioSamplingRate"], [152, "AudioSamplingResolution"], [153, "AudioDuration"], [154, "AudioOutcue"], [184, "JobID"], [185, "MasterDocumentID"], [186, "ShortDocumentID"], [187, "UniqueDocumentID"], [188, "OwnerID"], [200, "ObjectPreviewFileFormat"], [201, "ObjectPreviewFileVersion"], [202, "ObjectPreviewData"], [221, "Prefs"], [225, "ClassifyState"], [228, "SimilarityIndex"], [230, "DocumentNotes"], [231, "DocumentHistory"], [232, "ExifCameraInfo"], [255, "CatalogSets"]]), U(B, "iptc", [[10, { 0: "0 (reserved)", 1: "1 (most urgent)", 2: "2", 3: "3", 4: "4", 5: "5 (normal urgency)", 6: "6", 7: "7", 8: "8 (least urgent)", 9: "9 (user-defined priority)" }], [75, { a: "Morning", b: "Both Morning and Evening", p: "Evening" }], [131, { L: "Landscape", P: "Portrait", S: "Square" }]]); + full_esm_default = tt; } - }; - var w = new k("file parser"); - var T = new k("segment parser"); - var A = new k("file reader"); - function D(e3, n3) { - return "string" == typeof e3 ? O(e3, n3) : t && !i2 && e3 instanceof HTMLImageElement ? O(e3.src, n3) : e3 instanceof Uint8Array || e3 instanceof ArrayBuffer || e3 instanceof DataView ? new I(e3) : t && e3 instanceof Blob ? x(e3, n3, "blob", R) : void g2("Invalid input argument"); - } - function O(e3, i3) { - return (s2 = e3).startsWith("data:") || s2.length > 1e4 ? v(e3, i3, "base64") : n2 && e3.includes("://") ? x(e3, i3, "url", M) : n2 ? v(e3, i3, "fs") : t ? x(e3, i3, "url", M) : void g2("Invalid input argument"); - var s2; - } - async function x(e3, t2, i3, n3) { - return A.has(i3) ? v(e3, t2, i3) : n3 ? async function(e4, t3) { - let i4 = await t3(e4); - return new I(i4); - }(e3, n3) : void g2("Parser ".concat(i3, " is not loaded")); - } - async function v(e3, t2, i3) { - let n3 = new (A.get(i3))(e3, t2); - return await n3.read(), n3; - } - var M = (e3) => h(e3).then((e4) => e4.arrayBuffer()); - var R = (e3) => new Promise((t2, i3) => { - let n3 = new FileReader(); - n3.onloadend = () => t2(n3.result || new ArrayBuffer()), n3.onerror = i3, n3.readAsArrayBuffer(e3); }); - var L = class extends Map { - get tagKeys() { - return this.allKeys || (this.allKeys = Array.from(this.keys())), this.allKeys; - } - get tagValues() { - return this.allValues || (this.allValues = Array.from(this.values())), this.allValues; - } - }; - function U(e3, t2, i3) { - let n3 = new L(); - for (let [e4, t3] of i3) n3.set(e4, t3); - if (Array.isArray(t2)) for (let i4 of t2) e3.set(i4, n3); - else e3.set(t2, n3); - return n3; + + // modules/services/plane_photo.js + var plane_photo_exports = {}; + __export(plane_photo_exports, { + default: () => plane_photo_default + }); + function zoomPan(d3_event) { + let t2 = d3_event.transform; + _imageWrapper.call(utilSetTransform, t2.x, t2.y, t2.k); } - function F(e3, t2, i3) { - let n3, s2 = e3.get(t2); - for (n3 of i3) s2.set(n3[0], n3[1]); + function loadImage(selection2, path) { + return new Promise((resolve) => { + selection2.attr("src", path); + selection2.on("load", () => { + resolve(selection2); + }); + }); } - var E = /* @__PURE__ */ new Map(); - var B = /* @__PURE__ */ new Map(); - var N = /* @__PURE__ */ new Map(); - var G = ["chunked", "firstChunkSize", "firstChunkSizeNode", "firstChunkSizeBrowser", "chunkSize", "chunkLimit"]; - var V = ["jfif", "xmp", "icc", "iptc", "ihdr"]; - var z = ["tiff", ...V]; - var H = ["ifd0", "ifd1", "exif", "gps", "interop"]; - var j = [...z, ...H]; - var W = ["makerNote", "userComment"]; - var K = ["translateKeys", "translateValues", "reviveValues", "multiSegment"]; - var X = [...K, "sanitize", "mergeOutput", "silentErrors"]; - var _ = class { - get translate() { - return this.translateKeys || this.translateValues || this.reviveValues; - } - }; - var Y = class extends _ { - get needed() { - return this.enabled || this.deps.size > 0; - } - constructor(e3, t2, i3, n3) { - if (super(), c(this, "enabled", false), c(this, "skip", /* @__PURE__ */ new Set()), c(this, "pick", /* @__PURE__ */ new Set()), c(this, "deps", /* @__PURE__ */ new Set()), c(this, "translateKeys", false), c(this, "translateValues", false), c(this, "reviveValues", false), this.key = e3, this.enabled = t2, this.parse = this.enabled, this.applyInheritables(n3), this.canBeFiltered = H.includes(e3), this.canBeFiltered && (this.dict = E.get(e3)), void 0 !== i3) if (Array.isArray(i3)) this.parse = this.enabled = true, this.canBeFiltered && i3.length > 0 && this.translateTagSet(i3, this.pick); - else if ("object" == typeof i3) { - if (this.enabled = true, this.parse = false !== i3.parse, this.canBeFiltered) { - let { pick: e4, skip: t3 } = i3; - e4 && e4.length > 0 && this.translateTagSet(e4, this.pick), t3 && t3.length > 0 && this.translateTagSet(t3, this.skip); + var dispatch5, _photo, _imageWrapper, _planeWrapper, _imgZoom, plane_photo_default; + var init_plane_photo = __esm({ + "modules/services/plane_photo.js"() { + "use strict"; + init_src4(); + init_src12(); + init_util(); + dispatch5 = dispatch_default("viewerChanged"); + _imgZoom = zoom_default2().extent([[0, 0], [320, 240]]).translateExtent([[0, 0], [320, 240]]).scaleExtent([1, 15]); + plane_photo_default = { + init: async function(context, selection2) { + this.event = utilRebind(this, dispatch5, "on"); + _planeWrapper = selection2; + _planeWrapper.call(_imgZoom.on("zoom", zoomPan)); + _imageWrapper = _planeWrapper.append("div").attr("class", "photo-frame plane-frame").classed("hide", true); + _photo = _imageWrapper.append("img").attr("class", "plane-photo"); + context.ui().photoviewer.on("resize.plane", function(dimensions) { + _imgZoom.extent([[0, 0], dimensions]).translateExtent([[0, 0], dimensions]); + }); + await Promise.resolve(); + return this; + }, + /** + * Shows the photo frame if hidden + * @param {*} context the HTML wrap of the frame + */ + showPhotoFrame: function(context) { + const isHidden = context.selectAll(".photo-frame.plane-frame.hide").size(); + if (isHidden) { + context.selectAll(".photo-frame:not(.plane-frame)").classed("hide", true); + context.selectAll(".photo-frame.plane-frame").classed("hide", false); + } + return this; + }, + /** + * Hides the photo frame if shown + * @param {*} context the HTML wrap of the frame + */ + hidePhotoFrame: function(context) { + context.select("photo-frame.plane-frame").classed("hide", false); + return this; + }, + /** + * Renders an image inside the frame + * @param {*} data the image data, it should contain an image_path attribute, a link to the actual image. + */ + selectPhoto: function(data) { + dispatch5.call("viewerChanged"); + loadImage(_photo, ""); + loadImage(_photo, data.image_path).then(() => { + _planeWrapper.call(_imgZoom.transform, identity2); + }); + return this; + }, + getYaw: function() { + return 0; } - this.applyInheritables(i3); - } else true === i3 || false === i3 ? this.parse = this.enabled = i3 : g2("Invalid options argument: ".concat(i3)); - } - applyInheritables(e3) { - let t2, i3; - for (t2 of K) i3 = e3[t2], void 0 !== i3 && (this[t2] = i3); - } - translateTagSet(e3, t2) { - if (this.dict) { - let i3, n3, { tagKeys: s2, tagValues: r2 } = this.dict; - for (i3 of e3) "string" == typeof i3 ? (n3 = r2.indexOf(i3), -1 === n3 && (n3 = s2.indexOf(Number(i3))), -1 !== n3 && t2.add(Number(s2[n3]))) : t2.add(i3); - } else for (let i3 of e3) t2.add(i3); - } - finalizeFilters() { - !this.enabled && this.deps.size > 0 ? (this.enabled = true, ee(this.pick, this.deps)) : this.enabled && this.pick.size > 0 && ee(this.pick, this.deps); + }; } - }; - var $2 = { jfif: false, tiff: true, xmp: false, icc: false, iptc: false, ifd0: true, ifd1: false, exif: true, gps: true, interop: false, ihdr: void 0, makerNote: false, userComment: false, multiSegment: false, skip: [], pick: [], translateKeys: true, translateValues: true, reviveValues: true, sanitize: true, mergeOutput: true, silentErrors: true, chunked: true, firstChunkSize: void 0, firstChunkSizeNode: 512, firstChunkSizeBrowser: 65536, chunkSize: 65536, chunkLimit: 5 }; - var J = /* @__PURE__ */ new Map(); - var q = class extends _ { - static useCached(e3) { - let t2 = J.get(e3); - return void 0 !== t2 || (t2 = new this(e3), J.set(e3, t2)), t2; - } - constructor(e3) { - super(), true === e3 ? this.setupFromTrue() : void 0 === e3 ? this.setupFromUndefined() : Array.isArray(e3) ? this.setupFromArray(e3) : "object" == typeof e3 ? this.setupFromObject(e3) : g2("Invalid options argument ".concat(e3)), void 0 === this.firstChunkSize && (this.firstChunkSize = t ? this.firstChunkSizeBrowser : this.firstChunkSizeNode), this.mergeOutput && (this.ifd1.enabled = false), this.filterNestedSegmentTags(), this.traverseTiffDependencyTree(), this.checkLoadedPlugins(); - } - setupFromUndefined() { - let e3; - for (e3 of G) this[e3] = $2[e3]; - for (e3 of X) this[e3] = $2[e3]; - for (e3 of W) this[e3] = $2[e3]; - for (e3 of j) this[e3] = new Y(e3, $2[e3], void 0, this); - } - setupFromTrue() { - let e3; - for (e3 of G) this[e3] = $2[e3]; - for (e3 of X) this[e3] = $2[e3]; - for (e3 of W) this[e3] = true; - for (e3 of j) this[e3] = new Y(e3, true, void 0, this); - } - setupFromArray(e3) { - let t2; - for (t2 of G) this[t2] = $2[t2]; - for (t2 of X) this[t2] = $2[t2]; - for (t2 of W) this[t2] = $2[t2]; - for (t2 of j) this[t2] = new Y(t2, false, void 0, this); - this.setupGlobalFilters(e3, void 0, H); - } - setupFromObject(e3) { - let t2; - for (t2 of (H.ifd0 = H.ifd0 || H.image, H.ifd1 = H.ifd1 || H.thumbnail, Object.assign(this, e3), G)) this[t2] = Z(e3[t2], $2[t2]); - for (t2 of X) this[t2] = Z(e3[t2], $2[t2]); - for (t2 of W) this[t2] = Z(e3[t2], $2[t2]); - for (t2 of z) 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, 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) this[i3].enabled = t2; - } - batchEnableWithUserValue(e3, t2) { - for (let i3 of e3) { - let e4 = t2[i3]; - this[i3].enabled = false !== e4 && void 0 !== e4; - } - } - setupGlobalFilters(e3, t2, i3, n3 = i3) { - if (e3 && e3.length) { - for (let e4 of n3) this[e4].enabled = false; - let t3 = Q(e3, i3); - for (let [e4, i4] of t3) ee(this[e4].pick, i4), this[e4].enabled = true; - } else if (t2 && t2.length) { - let e4 = Q(t2, i3); - for (let [t3, i4] of e4) ee(this[t3].skip, i4); - } - } - filterNestedSegmentTags() { - let { ifd0: e3, exif: t2, xmp: i3, iptc: n3, icc: s2 } = this; - this.makerNote ? t2.deps.add(37500) : t2.skip.add(37500), this.userComment ? t2.deps.add(37510) : t2.skip.add(37510), i3.enabled || e3.skip.add(700), n3.enabled || e3.skip.add(33723), s2.enabled || e3.skip.add(34675); - } - traverseTiffDependencyTree() { - let { ifd0: e3, exif: t2, gps: i3, interop: n3 } = this; - n3.needed && (t2.deps.add(40965), e3.deps.add(40965)), t2.needed && e3.deps.add(34665), i3.needed && e3.deps.add(34853), this.tiff.enabled = H.some((e4) => true === this[e4].enabled) || this.makerNote || this.userComment; - for (let e4 of H) this[e4].finalizeFilters(); - } - get onlyTiff() { - return !V.map((e3) => this[e3].enabled).some((e3) => true === e3) && this.tiff.enabled; - } - checkLoadedPlugins() { - for (let e3 of z) this[e3].enabled && !T.has(e3) && P("segment parser", e3); + }); + + // modules/svg/local_photos.js + var local_photos_exports = {}; + __export(local_photos_exports, { + svgLocalPhotos: () => svgLocalPhotos + }); + function svgLocalPhotos(projection2, context, dispatch14) { + const detected = utilDetect(); + let layer = select_default2(null); + let _fileList; + let _photos = []; + let _idAutoinc = 0; + let _photoFrame; + let _activePhotoIdx; + function init2() { + if (_initialized2) return; + _enabled2 = true; + function over(d3_event) { + d3_event.stopPropagation(); + d3_event.preventDefault(); + d3_event.dataTransfer.dropEffect = "copy"; + } + context.container().attr("dropzone", "copy").on("drop.svgLocalPhotos", function(d3_event) { + d3_event.stopPropagation(); + d3_event.preventDefault(); + if (!detected.filedrop) return; + drawPhotos.fileList(d3_event.dataTransfer.files, (loaded) => { + if (loaded.length > 0) { + drawPhotos.fitZoom(false); + } + }); + }).on("dragenter.svgLocalPhotos", over).on("dragexit.svgLocalPhotos", over).on("dragover.svgLocalPhotos", over); + _initialized2 = true; } - }; - function Q(e3, t2) { - let i3, n3, s2, r2, a2 = []; - for (s2 of t2) { - for (r2 of (i3 = E.get(s2), n3 = [], i3)) (e3.includes(r2[0]) || e3.includes(r2[1])) && n3.push(r2[0]); - n3.length && a2.push([s2, n3]); + function ensureViewerLoaded(context2) { + if (_photoFrame) { + return Promise.resolve(_photoFrame); + } + 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 photo-attribution-dual fillD"); + const controlsEnter = viewerEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls-local"); + controlsEnter.append("button").classed("back", true).on("click.back", () => stepPhotos(-1)).text("\u25C0"); + controlsEnter.append("button").classed("forward", true).on("click.forward", () => stepPhotos(1)).text("\u25B6"); + return plane_photo_default.init(context2, viewerEnter).then((planePhotoFrame) => { + _photoFrame = planePhotoFrame; + }); } - return a2; - } - function Z(e3, t2) { - return void 0 !== e3 ? e3 : void 0 !== t2 ? t2 : void 0; - } - function ee(e3, t2) { - for (let i3 of t2) e3.add(i3); - } - c(q, "default", $2); - var te = class { - constructor(e3) { - c(this, "parsers", {}), c(this, "output", {}), c(this, "errors", []), c(this, "pushToErrors", (e4) => this.errors.push(e4)), this.options = q.useCached(e3); - } - async read(e3) { - this.file = await D(e3, this.options); - } - setup() { - if (this.fileParser) return; - let { file: e3 } = this, t2 = e3.getUint16(0); - for (let [i3, n3] of w) if (n3.canHandle(e3, t2)) return this.fileParser = new n3(this.options, this.file, this.parsers), e3[i3] = true; - this.file.close && this.file.close(), g2("Unknown file format"); - } - 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), f(e3); - } - async executeParsers() { - let { output: e3 } = this; - await this.fileParser.parse(); - let t2 = Object.values(this.parsers).map(async (t3) => { - let i3 = await t3.parse(); - t3.assignToOutput(e3, i3); - }); - this.options.silentErrors && (t2 = t2.map((e4) => e4.catch(this.pushToErrors))), await Promise.all(t2); - } - async extractThumbnail() { - this.setup(); - let { options: e3, file: t2 } = this, i3 = T.get("tiff", e3); - var n3; - if (t2.tiff ? n3 = { start: 0, type: "tiff" } : t2.jpeg && (n3 = await this.fileParser.getOrFindSegment("tiff")), void 0 === n3) return; - let s2 = await this.fileParser.ensureSegmentChunk(n3), r2 = this.parsers.tiff = new i3(s2, e3, t2), a2 = await r2.extractThumbnail(); - return t2.close && t2.close(), a2; + function stepPhotos(stepBy) { + if (!_photos || _photos.length === 0) return; + if (_activePhotoIdx === void 0) _activePhotoIdx = 0; + const newIndex = _activePhotoIdx + stepBy; + _activePhotoIdx = Math.max(0, Math.min(_photos.length - 1, newIndex)); + click(null, _photos[_activePhotoIdx], false); } - }; - async function ie(e3, t2) { - 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: j, tiffExtractables: W, inheritables: K, allFormatters: X, Options: q }); - var se = class { - constructor(e3, t2, i3) { - c(this, "errors", []), c(this, "ensureSegmentChunk", async (e4) => { - let t3 = e4.start, i4 = e4.size || 65536; - if (this.file.chunked) if (this.file.available(t3, i4)) e4.chunk = this.file.subarray(t3, i4); - else try { - e4.chunk = await this.file.readChunk(t3, i4); - } catch (t4) { - g2("Couldn't read segment: ".concat(JSON.stringify(e4), ". ").concat(t4.message)); + function click(d3_event, image, zoomTo) { + _activePhotoIdx = _photos.indexOf(image); + ensureViewerLoaded(context).then(() => { + const viewer = context.container().select(".photoviewer").datum(image).classed("hide", false); + const viewerWrap = viewer.select(".local-photos-wrapper").classed("hide", false); + const controlsWrap = viewer.select(".photo-controls-wrap"); + controlsWrap.select(".back").attr("disabled", _activePhotoIdx <= 0 ? true : null); + controlsWrap.select(".forward").attr("disabled", _activePhotoIdx >= _photos.length - 1 ? true : null); + const attribution = viewerWrap.selectAll(".photo-attribution").text(""); + if (image.date) { + attribution.append("span").text(image.date.toLocaleString(_mainLocalizer.localeCode())); } - else this.file.byteLength > t3 + i4 ? e4.chunk = this.file.subarray(t3, i4) : void 0 === e4.size ? e4.chunk = this.file.subarray(t3) : g2("Segment unreachable: " + JSON.stringify(e4)); - return e4.chunk; - }), this.extendOptions && this.extendOptions(e3), this.options = e3, this.file = t2, this.parsers = i3; - } - injectSegment(e3, t2) { - this.options[e3].enabled && this.createParser(e3, t2); - } - createParser(e3, t2) { - let i3 = new (T.get(e3))(t2, this.options, this.file); - return this.parsers[e3] = i3; - } - createParsers(e3) { - for (let t2 of e3) { - let { type: e4, chunk: i3 } = t2, n3 = this.options[e4]; - if (n3 && n3.enabled) { - let t3 = this.parsers[e4]; - t3 && t3.append || t3 || this.createParser(e4, i3); + if (image.name) { + attribution.append("span").classed("filename", true).text(image.name); } + _photoFrame.selectPhoto({ image_path: "" }); + image.getSrc().then((src) => { + _photoFrame.selectPhoto({ image_path: src }).showPhotoFrame(viewerWrap); + setStyles(); + }); + }); + if (zoomTo) { + context.map().centerEase(image.loc); } } - async readSegments(e3) { - let t2 = e3.map(this.ensureSegmentChunk); - await Promise.all(t2); + function transform2(d2) { + var svgpoint = projection2(d2.loc); + return "translate(" + svgpoint[0] + "," + svgpoint[1] + ")"; } - }; - var re2 = class { - static findPosition(e3, t2) { - let i3 = e3.getUint16(t2 + 2) + 2, n3 = "function" == typeof this.headerLength ? this.headerLength(e3, t2, i3) : this.headerLength, s2 = t2 + n3, r2 = i3 - n3; - return { offset: t2, length: i3, headerLength: n3, start: s2, size: r2, end: s2 + r2 }; + function setStyles(hovered) { + const viewer = context.container().select(".photoviewer"); + const selected = viewer.empty() ? void 0 : viewer.datum(); + context.container().selectAll(".layer-local-photos .viewfield-group").classed("hovered", (d2) => d2.id === (hovered == null ? void 0 : hovered.id)).classed("highlighted", (d2) => d2.id === (hovered == null ? void 0 : hovered.id) || d2.id === (selected == null ? void 0 : selected.id)).classed("currentView", (d2) => d2.id === (selected == null ? void 0 : selected.id)); } - static parse(e3, t2 = {}) { - return new this(e3, new q({ [this.type]: t2 }), e3).parse(); + function display_markers(imageList) { + imageList = imageList.filter((image) => isArray_default(image.loc) && isNumber_default(image.loc[0]) && isNumber_default(image.loc[1])); + const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(imageList, function(d2) { + return d2.id; + }); + groups.exit().remove(); + const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", (d3_event, d2) => setStyles(d2)).on("mouseleave", () => setStyles(null)).on("click", click); + groupsEnter.append("g").attr("class", "viewfield-scale"); + const markers = groups.merge(groupsEnter).attr("transform", transform2).select(".viewfield-scale"); + markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6"); + const showViewfields = context.map().zoom() >= minViewfieldZoom; + const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []); + viewfields.exit().remove(); + viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", function() { + var _a3; + const d2 = this.parentNode.__data__; + return `rotate(${Math.round((_a3 = d2.direction) != null ? _a3 : 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"; + }); } - normalizeInput(e3) { - return e3 instanceof I ? e3 : new I(e3); + function drawPhotos(selection2) { + layer = selection2.selectAll(".layer-local-photos").data(_photos ? [0] : []); + layer.exit().remove(); + const layerEnter = layer.enter().append("g").attr("class", "layer-local-photos"); + layerEnter.append("g").attr("class", "markers"); + layer = layerEnter.merge(layer); + if (_photos) { + display_markers(_photos); + } } - constructor(e3, t2 = {}, i3) { - c(this, "errors", []), c(this, "raw", /* @__PURE__ */ new Map()), c(this, "handleError", (e4) => { - if (!this.options.silentErrors) throw e4; - this.errors.push(e4.message); - }), this.chunk = this.normalizeInput(e3), this.file = i3, this.type = this.constructor.type, this.globalOptions = this.options = t2, this.localOptions = t2[this.type], this.canTranslate = this.localOptions && this.localOptions.translate; + function readFileAsDataURL(file) { + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.onload = () => resolve(reader.result); + reader.onerror = (error) => reject(error); + reader.readAsDataURL(file); + }); } - translate() { - this.canTranslate && (this.translated = this.translateBlock(this.raw, this.type)); + async function readmultifiles(files, callback) { + const loaded = []; + for (const file of files) { + try { + const exifData = await full_esm_default.parse(file); + const photo = { + id: _idAutoinc++, + name: file.name, + getSrc: () => readFileAsDataURL(file), + file, + loc: [exifData.longitude, exifData.latitude], + direction: exifData.GPSImgDirection, + date: exifData.CreateDate || exifData.DateTimeOriginal || exifData.ModifyDate + }; + loaded.push(photo); + const sameName = _photos.filter((i3) => i3.name === photo.name); + if (sameName.length === 0) { + _photos.push(photo); + } else { + const thisContent = await photo.getSrc(); + const sameNameContent = await Promise.allSettled(sameName.map((i3) => i3.getSrc())); + if (!sameNameContent.some((i3) => i3.value === thisContent)) { + _photos.push(photo); + } + } + } catch { + } + } + if (typeof callback === "function") callback(loaded); + dispatch14.call("change"); } - get output() { - return this.translated ? this.translated : this.raw ? Object.fromEntries(this.raw) : void 0; + drawPhotos.setFiles = function(fileList, callback) { + readmultifiles(Array.from(fileList), callback); + return this; + }; + drawPhotos.fileList = function(fileList, callback) { + if (!arguments.length) return _fileList; + _fileList = fileList; + if (!fileList || !fileList.length) return this; + drawPhotos.setFiles(_fileList, callback); + return this; + }; + drawPhotos.getPhotos = function() { + return _photos; + }; + drawPhotos.removePhoto = function(id2) { + _photos = _photos.filter((i3) => i3.id !== id2); + dispatch14.call("change"); + return _photos; + }; + drawPhotos.openPhoto = click; + drawPhotos.fitZoom = function(force) { + const coords = _photos.map((image) => image.loc).filter((l2) => isArray_default(l2) && isNumber_default(l2[0]) && isNumber_default(l2[1])); + if (coords.length === 0) return; + const extent = coords.map((l2) => geoExtent(l2, l2)).reduce((a2, b2) => a2.extend(b2)); + const map2 = context.map(); + var viewport = map2.trimmedExtent().polygon(); + if (force !== false || !geoPolygonIntersectsPolygon(viewport, coords, true)) { + map2.centerZoom(extent.center(), Math.min(18, map2.trimmedExtentZoom(extent))); + } + }; + function showLayer() { + layer.style("display", "block"); + layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() { + dispatch14.call("change"); + }); } - translateBlock(e3, t2) { - let i3 = N.get(t2), n3 = B.get(t2), s2 = E.get(t2), r2 = this.options[t2], a2 = r2.reviveValues && !!i3, o2 = r2.translateValues && !!n3, l2 = r2.translateKeys && !!s2, h2 = {}; - for (let [t3, r3] of e3) a2 && i3.has(t3) ? r3 = i3.get(t3)(r3) : o2 && n3.has(t3) && (r3 = this.translateValue(r3, n3.get(t3))), l2 && s2.has(t3) && (t3 = s2.get(t3) || t3), h2[t3] = r3; - return h2; + function hideLayer() { + layer.transition().duration(250).style("opacity", 0).on("end", () => { + layer.selectAll(".viewfield-group").remove(); + layer.style("display", "none"); + }); } - translateValue(e3, t2) { - return t2[e3] || t2.DEFAULT || e3; + drawPhotos.enabled = function(val) { + if (!arguments.length) return _enabled2; + _enabled2 = val; + if (_enabled2) { + showLayer(); + } else { + hideLayer(); + } + dispatch14.call("change"); + return this; + }; + drawPhotos.hasData = function() { + return isArray_default(_photos) && _photos.length > 0; + }; + init2(); + return drawPhotos; + } + var _initialized2, _enabled2, minViewfieldZoom; + var init_local_photos = __esm({ + "modules/svg/local_photos.js"() { + "use strict"; + init_src5(); + init_full_esm(); + init_lodash(); + init_localizer(); + init_detect(); + init_geo2(); + init_plane_photo(); + _initialized2 = false; + _enabled2 = false; + minViewfieldZoom = 16; } - assignToOutput(e3, t2) { - this.assignObjectToOutput(e3, this.constructor.type, t2); + }); + + // modules/svg/osmose.js + var osmose_exports2 = {}; + __export(osmose_exports2, { + svgOsmose: () => svgOsmose + }); + function svgOsmose(projection2, context, dispatch14) { + const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3); + const minZoom5 = 12; + let touchLayer = select_default2(null); + let drawLayer = select_default2(null); + let layerVisible = false; + function markerPath(selection2, klass) { + selection2.attr("class", klass).attr("transform", "translate(-10, -28)").attr("points", "16,3 4,3 1,6 1,17 4,20 7,20 10,27 13,20 16,20 19,17.033 19,6"); } - assignObjectToOutput(e3, t2, i3) { - if (this.globalOptions.mergeOutput) return Object.assign(e3, i3); - e3[t2] ? Object.assign(e3[t2], i3) : e3[t2] = i3; + function getService() { + if (services.osmose && !_qaService2) { + _qaService2 = services.osmose; + _qaService2.on("loaded", throttledRedraw); + } else if (!services.osmose && _qaService2) { + _qaService2 = null; + } + return _qaService2; } - }; - c(re2, "headerLength", 4), c(re2, "type", void 0), c(re2, "multiSegment", false), c(re2, "canHandle", () => false); - function ae(e3) { - return 192 === e3 || 194 === e3 || 196 === e3 || 219 === e3 || 221 === e3 || 218 === e3 || 254 === e3; - } - function oe(e3) { - return e3 >= 224 && e3 <= 239; - } - function le(e3, t2, i3) { - for (let [n3, s2] of T) if (s2.canHandle(e3, t2, i3)) return n3; - } - var he = class extends se { - constructor(...e3) { - super(...e3), c(this, "appSegments", []), c(this, "jpegSegments", []), c(this, "unknownSegments", []); + function editOn() { + if (!layerVisible) { + layerVisible = true; + drawLayer.style("display", "block"); + } } - static canHandle(e3, t2) { - return 65496 === t2; + function editOff() { + if (layerVisible) { + layerVisible = false; + drawLayer.style("display", "none"); + drawLayer.selectAll(".qaItem.osmose").remove(); + touchLayer.selectAll(".qaItem.osmose").remove(); + } } - async parse() { - await this.findAppSegments(), await this.readSegments(this.appSegments), this.mergeMultiSegments(), this.createParsers(this.mergedAppSegments || this.appSegments); + function layerOn() { + editOn(); + drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", () => dispatch14.call("change")); } - setupSegmentFinderArgs(e3) { - true === e3 ? (this.findAll = true, this.wanted = new Set(T.keyList())) : (e3 = void 0 === e3 ? T.keyList().filter((e4) => this.options[e4].enabled) : e3.filter((e4) => this.options[e4].enabled && T.has(e4)), this.findAll = false, this.remaining = new Set(e3), this.wanted = new Set(e3)), this.unfinishedMultiSegment = false; + function layerOff() { + throttledRedraw.cancel(); + drawLayer.interrupt(); + touchLayer.selectAll(".qaItem.osmose").remove(); + drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", () => { + editOff(); + dispatch14.call("change"); + }); } - async findAppSegments(e3 = 0, t2) { - this.setupSegmentFinderArgs(t2); - let { file: i3, findAll: n3, wanted: s2, remaining: r2 } = this; - if (!n3 && this.file.chunked && (n3 = Array.from(s2).some((e4) => { - let t3 = T.get(e4), i4 = this.options[e4]; - return t3.multiSegment && i4.multiSegment; - }), n3 && await this.file.readWhole()), e3 = this.findAppSegmentsInRange(e3, i3.byteLength), !this.options.onlyTiff && i3.chunked) { - let t3 = false; - for (; r2.size > 0 && !t3 && (i3.canReadNextChunk || this.unfinishedMultiSegment); ) { - let { nextChunkOffset: n4 } = i3, s3 = this.appSegments.some((e4) => !this.file.available(e4.offset || e4.start, e4.length || e4.size)); - if (t3 = e3 > n4 && !s3 ? !await i3.readNextChunk(e3) : !await i3.readNextChunk(n4), void 0 === (e3 = this.findAppSegmentsInRange(e3, i3.byteLength))) return; - } + function updateMarkers() { + if (!layerVisible || !_layerEnabled2) return; + const service = getService(); + const selectedID = context.selectedErrorID(); + const data = service ? service.getItems(projection2) : []; + const getTransform = svgPointTransform(projection2); + const markers = drawLayer.selectAll(".qaItem.osmose").data(data, (d2) => d2.id); + markers.exit().remove(); + const markersEnter = markers.enter().append("g").attr("class", (d2) => `qaItem ${d2.service} itemId-${d2.id} itemType-${d2.itemType}`); + markersEnter.append("polygon").call(markerPath, "shadow"); + markersEnter.append("ellipse").attr("cx", 0).attr("cy", 0).attr("rx", 4.5).attr("ry", 2).attr("class", "stroke"); + markersEnter.append("polygon").attr("fill", (d2) => service.getColor(d2.item)).call(markerPath, "qaItem-fill"); + markersEnter.append("use").attr("class", "icon-annotation").attr("transform", "translate(-6, -22)").attr("width", "12px").attr("height", "12px").attr("xlink:href", (d2) => d2.icon ? "#" + d2.icon : ""); + markers.merge(markersEnter).sort(sortY).classed("selected", (d2) => d2.id === selectedID).attr("transform", getTransform); + if (touchLayer.empty()) return; + const fillClass = context.getDebug("target") ? "pink" : "nocolor"; + const targets = touchLayer.selectAll(".qaItem.osmose").data(data, (d2) => d2.id); + targets.exit().remove(); + targets.enter().append("rect").attr("width", "20px").attr("height", "30px").attr("x", "-10px").attr("y", "-28px").merge(targets).sort(sortY).attr("class", (d2) => `qaItem ${d2.service} target ${fillClass} itemId-${d2.id}`).attr("transform", getTransform); + function sortY(a2, b2) { + return a2.id === selectedID ? 1 : b2.id === selectedID ? -1 : b2.loc[1] - a2.loc[1]; } } - findAppSegmentsInRange(e3, t2) { - t2 -= 2; - 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 = 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; - 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 !== f2.stopAfterSos) return; - f2.recordJpegSegments && this.jpegSegments.push({ offset: e3, length: n3, marker: i3 }), e3 += n3 + 1; + function drawOsmose(selection2) { + const service = getService(); + const surface = context.surface(); + if (surface && !surface.empty()) { + touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers"); + } + drawLayer = selection2.selectAll(".layer-osmose").data(service ? [0] : []); + drawLayer.exit().remove(); + drawLayer = drawLayer.enter().append("g").attr("class", "layer-osmose").style("display", _layerEnabled2 ? "block" : "none").merge(drawLayer); + if (_layerEnabled2) { + if (service && ~~context.map().zoom() >= minZoom5) { + editOn(); + service.loadIssues(projection2); + updateMarkers(); + } else { + editOff(); } } - return e3; } - mergeMultiSegments() { - if (!this.appSegments.some((e4) => e4.multiSegment)) return; - let e3 = function(e4, t2) { - let i3, n3, s2, r2 = /* @__PURE__ */ new Map(); - for (let a2 = 0; a2 < e4.length; a2++) i3 = e4[a2], n3 = i3[t2], r2.has(n3) ? s2 = r2.get(n3) : r2.set(n3, s2 = []), s2.push(i3); - return Array.from(r2); - }(this.appSegments, "type"); - this.mergedAppSegments = e3.map(([e4, t2]) => { - let i3 = T.get(e4, this.options); - if (i3.handleMultiSegments) { - return { type: e4, chunk: i3.handleMultiSegments(t2) }; + drawOsmose.enabled = function(val) { + if (!arguments.length) return _layerEnabled2; + _layerEnabled2 = val; + if (_layerEnabled2) { + getService().loadStrings().then(layerOn).catch((err) => { + console.log(err); + }); + } else { + layerOff(); + if (context.selectedErrorID()) { + context.enter(modeBrowse(context)); } - return t2[0]; - }); - } - getSegment(e3) { - return this.appSegments.find((t2) => t2.type === e3); - } - async getOrFindSegment(e3) { - let t2 = this.getSegment(e3); - return void 0 === t2 && (await this.findAppSegments(0, [e3]), t2 = this.getSegment(e3)), t2; - } - }; - c(he, "type", "jpeg"), w.set("jpeg", he); - var ue = [void 0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 4]; - var ce = class extends re2 { - parseHeader() { - var e3 = this.chunk.getUint16(); - 18761 === e3 ? this.le = true : 19789 === e3 && (this.le = false), this.chunk.le = this.le, this.headerParsed = true; - } - parseTags(e3, t2, i3 = /* @__PURE__ */ new Map()) { - let { pick: n3, skip: s2 } = this.options[t2]; - n3 = new Set(n3); - let r2 = n3.size > 0, a2 = 0 === s2.size, o2 = this.chunk.getUint16(e3); - e3 += 2; - for (let l2 = 0; l2 < o2; l2++) { - let o3 = this.chunk.getUint16(e3); - if (r2) { - if (n3.has(o3) && (i3.set(o3, this.parseTag(e3, o3, t2)), n3.delete(o3), 0 === n3.size)) break; - } else !a2 && s2.has(o3) || i3.set(o3, this.parseTag(e3, o3, t2)); - e3 += 12; } - return i3; + dispatch14.call("change"); + return this; + }; + drawOsmose.supported = () => !!getService(); + return drawOsmose; + } + var _layerEnabled2, _qaService2; + var init_osmose2 = __esm({ + "modules/svg/osmose.js"() { + "use strict"; + init_throttle(); + init_src5(); + init_browse(); + init_helpers(); + init_services(); + _layerEnabled2 = false; } - parseTag(e3, t2, i3) { - let { chunk: n3 } = this, s2 = n3.getUint16(e3 + 2), r2 = n3.getUint32(e3 + 4), a2 = ue[s2]; - if (a2 * r2 <= 4 ? e3 += 8 : e3 = n3.getUint32(e3 + 8), (s2 < 1 || s2 > 13) && g2("Invalid TIFF value type. block: ".concat(i3.toUpperCase(), ", tag: ").concat(t2.toString(16), ", type: ").concat(s2, ", offset ").concat(e3)), e3 > n3.byteLength && g2("Invalid TIFF value offset. block: ".concat(i3.toUpperCase(), ", tag: ").concat(t2.toString(16), ", type: ").concat(s2, ", offset ").concat(e3, " is outside of chunk size ").concat(n3.byteLength)), 1 === s2) return n3.getUint8Array(e3, r2); - if (2 === s2) return m(n3.getString(e3, r2)); - if (7 === s2) return n3.getUint8Array(e3, r2); - if (1 === r2) return this.parseTagValue(s2, e3); - { - let t3 = new (function(e4) { - switch (e4) { - case 1: - return Uint8Array; - case 3: - return Uint16Array; - case 4: - return Uint32Array; - case 5: - return Array; - case 6: - return Int8Array; - case 8: - return Int16Array; - case 9: - return Int32Array; - case 10: - return Array; - case 11: - return Float32Array; - case 12: - return Float64Array; - default: - return Array; - } - }(s2))(r2), i4 = a2; - for (let n4 = 0; n4 < r2; n4++) t3[n4] = this.parseTagValue(s2, e3), e3 += i4; - return t3; - } - } - parseTagValue(e3, t2) { - let { chunk: i3 } = this; - switch (e3) { - case 1: - return i3.getUint8(t2); - case 3: - return i3.getUint16(t2); - case 4: - return i3.getUint32(t2); - case 5: - return i3.getUint32(t2) / i3.getUint32(t2 + 4); - case 6: - return i3.getInt8(t2); - case 8: - return i3.getInt16(t2); - case 9: - return i3.getInt32(t2); - case 10: - return i3.getInt32(t2) / i3.getInt32(t2 + 4); - case 11: - return i3.getFloat(t2); - case 12: - return i3.getDouble(t2); - case 13: - return i3.getUint32(t2); - default: - g2("Invalid tiff type ".concat(e3)); - } + }); + + // modules/svg/streetside.js + var streetside_exports = {}; + __export(streetside_exports, { + svgStreetside: () => svgStreetside + }); + function svgStreetside(projection2, context, dispatch14) { + var throttledRedraw = throttle_default(function() { + dispatch14.call("change"); + }, 1e3); + var minZoom5 = 14; + var minMarkerZoom = 16; + var minViewfieldZoom2 = 18; + var layer = select_default2(null); + var _viewerYaw = 0; + var _selectedSequence = null; + var _streetside; + function init2() { + if (svgStreetside.initialized) return; + svgStreetside.enabled = false; + svgStreetside.initialized = true; } - }; - var fe = class extends ce { - static canHandle(e3, t2) { - return 225 === e3.getUint8(t2 + 1) && 1165519206 === e3.getUint32(t2 + 4) && 0 === e3.getUint16(t2 + 8); - } - async parse() { - this.parseHeader(); - let { options: e3 } = this; - return e3.ifd0.enabled && await this.parseIfd0Block(), e3.exif.enabled && await this.safeParse("parseExifBlock"), e3.gps.enabled && await this.safeParse("parseGpsBlock"), e3.interop.enabled && await this.safeParse("parseInteropBlock"), e3.ifd1.enabled && await this.safeParse("parseThumbnailBlock"), this.createOutput(); - } - safeParse(e3) { - let t2 = this[e3](); - return void 0 !== t2.catch && (t2 = t2.catch(this.handleError)), t2; - } - findIfd0Offset() { - void 0 === this.ifd0Offset && (this.ifd0Offset = this.chunk.getUint32(4)); - } - findIfd1Offset() { - if (void 0 === this.ifd1Offset) { - this.findIfd0Offset(); - let e3 = this.chunk.getUint16(this.ifd0Offset), t2 = this.ifd0Offset + 2 + 12 * e3; - this.ifd1Offset = this.chunk.getUint32(t2); - } - } - parseBlock(e3, t2) { - let i3 = /* @__PURE__ */ new Map(); - return this[t2] = i3, this.parseTags(e3, t2, i3), i3; - } - async parseIfd0Block() { - if (this.ifd0) return; - let { file: e3 } = this; - this.findIfd0Offset(), this.ifd0Offset < 8 && g2("Malformed EXIF data"), !e3.chunked && this.ifd0Offset > e3.byteLength && g2("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset, ", file.byteLength: ").concat(e3.byteLength)), e3.tiff && await e3.ensureChunk(this.ifd0Offset, S(this.options)); - let t2 = this.parseBlock(this.ifd0Offset, "ifd0"); - return 0 !== t2.size ? (this.exifOffset = t2.get(34665), this.interopOffset = t2.get(40965), this.gpsOffset = t2.get(34853), this.xmp = t2.get(700), this.iptc = t2.get(33723), this.icc = t2.get(34675), this.options.sanitize && (t2.delete(34665), t2.delete(40965), t2.delete(34853), t2.delete(700), t2.delete(33723), t2.delete(34675)), t2) : void 0; - } - async parseExifBlock() { - if (this.exif) return; - if (this.ifd0 || await this.parseIfd0Block(), void 0 === this.exifOffset) return; - this.file.tiff && await this.file.ensureChunk(this.exifOffset, S(this.options)); - let e3 = this.parseBlock(this.exifOffset, "exif"); - return this.interopOffset || (this.interopOffset = e3.get(40965)), this.makerNote = e3.get(37500), this.userComment = e3.get(37510), this.options.sanitize && (e3.delete(40965), e3.delete(37500), e3.delete(37510)), this.unpack(e3, 41728), this.unpack(e3, 41729), e3; - } - unpack(e3, t2) { - let i3 = e3.get(t2); - i3 && 1 === i3.length && e3.set(t2, i3[0]); - } - async parseGpsBlock() { - if (this.gps) return; - if (this.ifd0 || await this.parseIfd0Block(), void 0 === this.gpsOffset) return; - let e3 = this.parseBlock(this.gpsOffset, "gps"); - return e3 && e3.has(2) && e3.has(4) && (e3.set("latitude", de(...e3.get(2), e3.get(1))), e3.set("longitude", de(...e3.get(4), e3.get(3)))), e3; - } - async parseInteropBlock() { - if (!this.interop && (this.ifd0 || await this.parseIfd0Block(), void 0 !== this.interopOffset || this.exif || await this.parseExifBlock(), void 0 !== this.interopOffset)) return this.parseBlock(this.interopOffset, "interop"); - } - async parseThumbnailBlock(e3 = false) { - if (!this.ifd1 && !this.ifd1Parsed && (!this.options.mergeOutput || e3)) return this.findIfd1Offset(), this.ifd1Offset > 0 && (this.parseBlock(this.ifd1Offset, "ifd1"), this.ifd1Parsed = true), this.ifd1; - } - async extractThumbnail() { - if (this.headerParsed || this.parseHeader(), this.ifd1Parsed || await this.parseThumbnailBlock(true), void 0 === this.ifd1) return; - let e3 = this.ifd1.get(513), t2 = this.ifd1.get(514); - return this.chunk.getUint8Array(e3, t2); - } - get image() { - return this.ifd0; - } - get thumbnail() { - return this.ifd1; - } - createOutput() { - let e3, t2, i3, n3 = {}; - for (t2 of H) if (e3 = this[t2], !p(e3)) if (i3 = this.canTranslate ? this.translateBlock(e3, t2) : Object.fromEntries(e3), this.options.mergeOutput) { - if ("ifd1" === t2) continue; - Object.assign(n3, i3); - } else n3[t2] = i3; - return this.makerNote && (n3.makerNote = this.makerNote), this.userComment && (n3.userComment = this.userComment), n3; - } - assignToOutput(e3, t2) { - if (this.globalOptions.mergeOutput) Object.assign(e3, t2); - else for (let [i3, n3] of Object.entries(t2)) this.assignObjectToOutput(e3, i3, n3); + function getService() { + if (services.streetside && !_streetside) { + _streetside = services.streetside; + _streetside.event.on("viewerChanged.svgStreetside", viewerChanged).on("loadedImages.svgStreetside", throttledRedraw); + } else if (!services.streetside && _streetside) { + _streetside = null; + } + return _streetside; } - }; - function de(e3, t2, i3, n3) { - var s2 = e3 + t2 / 60 + i3 / 3600; - 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: 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) { - let t2 = new te(me); - await t2.read(e3); - let i3 = await t2.parse(); - if (i3 && i3.gps) { - let { latitude: e4, longitude: t3 } = i3.gps; - return { latitude: e4, longitude: t3 }; + function showLayer() { + var service = getService(); + if (!service) return; + editOn(); + layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() { + dispatch14.call("change"); + }); } - } - var Ce = Object.assign({}, ge, { tiff: false, ifd1: true, mergeOutput: false }); - async function ye(e3) { - let t2 = new te(Ce); - await t2.read(e3); - let i3 = await t2.extractThumbnail(); - return i3 && a ? s.from(i3) : i3; - } - async function be(e3) { - let t2 = await this.thumbnail(e3); - if (void 0 !== t2) { - let e4 = new Blob([t2]); - return URL.createObjectURL(e4); + function hideLayer() { + throttledRedraw.cancel(); + layer.transition().duration(250).style("opacity", 0).on("end", editOff); } - } - var Ie = Object.assign({}, ge, { firstChunkSize: 4e4, ifd0: [274] }); - async function Pe(e3) { - let t2 = new te(Ie); - await t2.read(e3); - let i3 = await t2.parse(); - if (i3 && i3.ifd0) return i3.ifd0[274]; - } - var ke = Object.freeze({ 1: { dimensionSwapped: false, scaleX: 1, scaleY: 1, deg: 0, rad: 0 }, 2: { dimensionSwapped: false, scaleX: -1, scaleY: 1, deg: 0, rad: 0 }, 3: { dimensionSwapped: false, scaleX: 1, scaleY: 1, deg: 180, rad: 180 * Math.PI / 180 }, 4: { dimensionSwapped: false, scaleX: -1, scaleY: 1, deg: 180, rad: 180 * Math.PI / 180 }, 5: { dimensionSwapped: true, scaleX: 1, scaleY: -1, deg: 90, rad: 90 * Math.PI / 180 }, 6: { dimensionSwapped: true, scaleX: 1, scaleY: 1, deg: 90, rad: 90 * Math.PI / 180 }, 7: { dimensionSwapped: true, scaleX: 1, scaleY: -1, deg: 270, rad: 270 * Math.PI / 180 }, 8: { dimensionSwapped: true, scaleX: 1, scaleY: 1, deg: 270, rad: 270 * Math.PI / 180 } }); - var we = true; - var Te = true; - if ("object" == typeof navigator) { - let e3 = navigator.userAgent; - if (e3.includes("iPad") || e3.includes("iPhone")) { - let t2 = e3.match(/OS (\d+)_(\d+)/); - if (t2) { - let [, e4, i3] = t2, n3 = Number(e4) + 0.1 * Number(i3); - we = n3 < 13.4, Te = false; - } - } else if (e3.includes("OS X 10")) { - let [, t2] = e3.match(/OS X 10[_.](\d+)/); - we = Te = Number(t2) < 15; - } - if (e3.includes("Chrome/")) { - let [, t2] = e3.match(/Chrome\/(\d+)/); - we = Te = Number(t2) < 81; - } else if (e3.includes("Firefox/")) { - let [, t2] = e3.match(/Firefox\/(\d+)/); - we = Te = Number(t2) < 77; + function editOn() { + layer.style("display", "block"); } - } - async function Ae(e3) { - let t2 = await Pe(e3); - return Object.assign({ canvas: we, css: Te }, ke[t2]); - } - var De = class extends I { - constructor(...e3) { - super(...e3), c(this, "ranges", new Oe()), 0 !== this.byteLength && this.ranges.add(0, this.byteLength); + function editOff() { + layer.selectAll(".viewfield-group").remove(); + layer.style("display", "none"); } - _tryExtend(e3, t2, i3) { - if (0 === e3 && 0 === this.byteLength && i3) { - let e4 = new DataView(i3.buffer || i3, i3.byteOffset, i3.byteLength); - this._swapDataView(e4); - } else { - let i4 = e3 + t2; - if (i4 > this.byteLength) { - let { dataView: e4 } = this._extend(i4); - this._swapDataView(e4); - } + function click(d3_event, d2) { + var service = getService(); + if (!service) return; + if (d2.sequenceKey !== _selectedSequence) { + _viewerYaw = 0; } + _selectedSequence = d2.sequenceKey; + service.ensureViewerLoaded(context).then(function() { + service.selectImage(context, d2.key).yaw(_viewerYaw).showViewer(context); + }); + context.map().centerEase(d2.loc); } - _extend(e3) { - let t2; - t2 = a ? s.allocUnsafe(e3) : new Uint8Array(e3); - let i3 = new DataView(t2.buffer, t2.byteOffset, t2.byteLength); - return t2.set(new Uint8Array(this.buffer, this.byteOffset, this.byteLength), 0), { uintView: t2, dataView: i3 }; - } - subarray(e3, t2, i3 = false) { - return t2 = t2 || this._lengthToEnd(e3), i3 && this._tryExtend(e3, t2), this.ranges.add(e3, t2), super.subarray(e3, t2); + function mouseover(d3_event, d2) { + var service = getService(); + if (service) service.setStyles(context, d2); } - set(e3, t2, i3 = false) { - i3 && this._tryExtend(t2, e3.byteLength, e3); - let n3 = super.set(e3, t2); - return this.ranges.add(t2, n3.byteLength), n3; + function mouseout() { + var service = getService(); + if (service) service.setStyles(context, null); } - async ensureChunk(e3, t2) { - this.chunked && (this.ranges.available(e3, t2) || await this.readChunk(e3, t2)); + function transform2(d2) { + var t2 = svgPointTransform(projection2)(d2); + var rot = d2.ca + _viewerYaw; + if (rot) { + t2 += " rotate(" + Math.floor(rot) + ",0,0)"; + } + return t2; } - available(e3, t2) { - return this.ranges.available(e3, t2); + function viewerChanged() { + var service = getService(); + if (!service) return; + var viewer = service.viewer(); + if (!viewer) return; + _viewerYaw = viewer.getYaw(); + if (context.map().isTransformed()) return; + layer.selectAll(".viewfield-group.currentView").attr("transform", transform2); } - }; - var Oe = class { - constructor() { - c(this, "list", []); + function filterBubbles(bubbles) { + var fromDate = context.photos().fromDate(); + var toDate = context.photos().toDate(); + var usernames = context.photos().usernames(); + if (fromDate) { + var fromTimestamp = new Date(fromDate).getTime(); + bubbles = bubbles.filter(function(bubble) { + return new Date(bubble.captured_at).getTime() >= fromTimestamp; + }); + } + if (toDate) { + var toTimestamp = new Date(toDate).getTime(); + bubbles = bubbles.filter(function(bubble) { + return new Date(bubble.captured_at).getTime() <= toTimestamp; + }); + } + if (usernames) { + bubbles = bubbles.filter(function(bubble) { + return usernames.indexOf(bubble.captured_by) !== -1; + }); + } + return bubbles; } - get length() { - return this.list.length; + function filterSequences(sequences) { + var fromDate = context.photos().fromDate(); + var toDate = context.photos().toDate(); + var usernames = context.photos().usernames(); + if (fromDate) { + var fromTimestamp = new Date(fromDate).getTime(); + sequences = sequences.filter(function(sequences2) { + return new Date(sequences2.properties.captured_at).getTime() >= fromTimestamp; + }); + } + if (toDate) { + var toTimestamp = new Date(toDate).getTime(); + sequences = sequences.filter(function(sequences2) { + return new Date(sequences2.properties.captured_at).getTime() <= toTimestamp; + }); + } + if (usernames) { + sequences = sequences.filter(function(sequences2) { + return usernames.indexOf(sequences2.properties.captured_by) !== -1; + }); + } + return sequences; } - add(e3, t2, i3 = 0) { - let n3 = e3 + t2, s2 = this.list.filter((t3) => xe(e3, t3.offset, n3) || xe(e3, t3.end, n3)); - if (s2.length > 0) { - e3 = Math.min(e3, ...s2.map((e4) => e4.offset)), n3 = Math.max(n3, ...s2.map((e4) => e4.end)), t2 = n3 - e3; - let i4 = s2.shift(); - i4.offset = e3, i4.length = t2, i4.end = n3, this.list = this.list.filter((e4) => !s2.includes(e4)); - } else this.list.push({ offset: e3, length: t2, end: n3 }); + function update() { + var viewer = context.container().select(".photoviewer"); + var selected = viewer.empty() ? void 0 : viewer.datum(); + var z2 = ~~context.map().zoom(); + var showMarkers = z2 >= minMarkerZoom; + var showViewfields = z2 >= minViewfieldZoom2; + var service = getService(); + var sequences = []; + var bubbles = []; + if (context.photos().showsPanoramic()) { + sequences = service ? service.sequences(projection2) : []; + bubbles = service && showMarkers ? service.bubbles(projection2) : []; + sequences = filterSequences(sequences); + bubbles = filterBubbles(bubbles); + } + var traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) { + return d2.properties.key; + }); + dispatch14.call("photoDatesChanged", this, "streetside", [...bubbles.map((p2) => p2.captured_at), ...sequences.map((t2) => t2.properties.vintageStart)]); + traces.exit().remove(); + traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson); + var groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(bubbles, function(d2) { + return d2.key + (d2.sequenceKey ? "v1" : "v0"); + }); + groups.exit().remove(); + var groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click); + groupsEnter.append("g").attr("class", "viewfield-scale"); + var markers = groups.merge(groupsEnter).sort(function(a2, b2) { + return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1]; + }).attr("transform", transform2).select(".viewfield-scale"); + markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6"); + var viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []); + viewfields.exit().remove(); + viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath); + function viewfieldPath() { + var d2 = this.parentNode.__data__; + if (d2.pano) { + return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0"; + } else { + return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z"; + } + } } - available(e3, t2) { - let i3 = e3 + t2; - return this.list.some((t3) => t3.offset <= e3 && i3 <= t3.end); + function drawImages(selection2) { + var enabled = svgStreetside.enabled; + var service = getService(); + layer = selection2.selectAll(".layer-streetside-images").data(service ? [0] : []); + layer.exit().remove(); + var layerEnter = layer.enter().append("g").attr("class", "layer-streetside-images").style("display", enabled ? "block" : "none"); + layerEnter.append("g").attr("class", "sequences"); + layerEnter.append("g").attr("class", "markers"); + layer = layerEnter.merge(layer); + if (enabled) { + if (service && ~~context.map().zoom() >= minZoom5) { + editOn(); + update(); + service.loadBubbles(projection2); + } else { + dispatch14.call("photoDatesChanged", this, "streetside", []); + editOff(); + } + } else { + dispatch14.call("photoDatesChanged", this, "streetside", []); + } } - }; - function xe(e3, t2, i3) { - return e3 <= t2 && t2 <= i3; + drawImages.enabled = function(_2) { + if (!arguments.length) return svgStreetside.enabled; + svgStreetside.enabled = _2; + if (svgStreetside.enabled) { + showLayer(); + context.photos().on("change.streetside", update); + } else { + hideLayer(); + context.photos().on("change.streetside", null); + } + dispatch14.call("change"); + return this; + }; + drawImages.supported = function() { + return !!getService(); + }; + drawImages.rendered = function(zoom) { + return zoom >= minZoom5; + }; + init2(); + return drawImages; } - var ve = class extends De { - constructor(e3, t2) { - super(0), c(this, "chunksRead", 0), this.input = e3, this.options = t2; - } - async readWhole() { - this.chunked = false, await this.readChunk(this.nextChunkOffset); + var init_streetside = __esm({ + "modules/svg/streetside.js"() { + "use strict"; + init_throttle(); + init_src5(); + init_helpers(); + init_services(); } - async readChunked() { - this.chunked = true, await this.readChunk(0, this.options.firstChunkSize); + }); + + // modules/svg/vegbilder.js + var vegbilder_exports = {}; + __export(vegbilder_exports, { + svgVegbilder: () => svgVegbilder + }); + function svgVegbilder(projection2, context, dispatch14) { + const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3); + const minZoom5 = 14; + const minMarkerZoom = 16; + const minViewfieldZoom2 = 18; + let layer = select_default2(null); + let _viewerYaw = 0; + let _vegbilder; + function init2() { + if (svgVegbilder.initialized) return; + svgVegbilder.enabled = false; + svgVegbilder.initialized = true; } - async readNextChunk(e3 = this.nextChunkOffset) { - if (this.fullyRead) return this.chunksRead++, false; - let t2 = this.options.chunkSize, i3 = await this.readChunk(e3, t2); - return !!i3 && i3.byteLength === t2; + function getService() { + if (services.vegbilder && !_vegbilder) { + _vegbilder = services.vegbilder; + _vegbilder.event.on("viewerChanged.svgVegbilder", viewerChanged).on("loadedImages.svgVegbilder", throttledRedraw); + } else if (!services.vegbilder && _vegbilder) { + _vegbilder = null; + } + return _vegbilder; } - async readChunk(e3, t2) { - if (this.chunksRead++, 0 !== (t2 = this.safeWrapAddress(e3, t2))) return this._readChunk(e3, t2); + function showLayer() { + const service = getService(); + if (!service) return; + editOn(); + layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", () => dispatch14.call("change")); } - safeWrapAddress(e3, t2) { - return void 0 !== this.size && e3 + t2 > this.size ? Math.max(0, this.size - e3) : t2; + function hideLayer() { + throttledRedraw.cancel(); + layer.transition().duration(250).style("opacity", 0).on("end", editOff); } - get nextChunkOffset() { - if (0 !== this.ranges.list.length) return this.ranges.list[0].length; + function editOn() { + layer.style("display", "block"); } - get canReadNextChunk() { - return this.chunksRead < this.options.chunkLimit; + function editOff() { + layer.selectAll(".viewfield-group").remove(); + layer.style("display", "none"); } - get fullyRead() { - return void 0 !== this.size && this.nextChunkOffset === this.size; + function click(d3_event, d2) { + const service = getService(); + if (!service) return; + service.ensureViewerLoaded(context).then(() => { + service.selectImage(context, d2.key).showViewer(context); + }); + context.map().centerEase(d2.loc); } - read() { - return this.options.chunked ? this.readChunked() : this.readWhole(); + function mouseover(d3_event, d2) { + const service = getService(); + if (service) service.setStyles(context, d2); } - close() { + function mouseout() { + const service = getService(); + if (service) service.setStyles(context, null); } - }; - A.set("blob", class extends ve { - async readWhole() { - this.chunked = false; - let e3 = await R(this.input); - this._swapArrayBuffer(e3); - } - readChunked() { - return this.chunked = true, this.size = this.input.size, super.readChunked(); - } - async _readChunk(e3, t2) { - let i3 = t2 ? e3 + t2 : void 0, n3 = this.input.slice(e3, i3), s2 = await R(n3); - 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: 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; - }, rotation: Ae }); - A.set("url", class extends ve { - async readWhole() { - this.chunked = false; - let e3 = await M(this.input); - e3 instanceof ArrayBuffer ? this._swapArrayBuffer(e3) : e3 instanceof Uint8Array && this._swapBuffer(e3); - } - async _readChunk(e3, t2) { - let i3 = t2 ? e3 + t2 - 1 : void 0, n3 = this.options.httpHeaders || {}; - (e3 || i3) && (n3.range = "bytes=".concat([e3, i3].join("-"))); - let s2 = await h(this.input, { headers: n3 }), r2 = await s2.arrayBuffer(), a2 = r2.byteLength; - if (416 !== s2.status) return a2 !== t2 && (this.size = e3 + a2), this.set(r2, e3, true); - } - }); - I.prototype.getUint64 = function(e3) { - let t2 = this.getUint32(e3), i3 = this.getUint32(e3 + 4); - return t2 < 1048575 ? t2 << 32 | i3 : void 0 !== typeof r ? (console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."), r(t2) << r(32) | r(i3)) : void g2("Trying to read 64b value but JS can only handle 53b numbers."); - }; - var Re = class extends se { - parseBoxes(e3 = 0) { - let t2 = []; - for (; e3 < this.file.byteLength - 4; ) { - let i3 = this.parseBoxHead(e3); - if (t2.push(i3), 0 === i3.length) break; - e3 += i3.length; + function transform2(d2, selected) { + let t2 = svgPointTransform(projection2)(d2); + let rot = d2.ca; + if (d2 === selected) { + rot += _viewerYaw; + } + if (rot) { + t2 += " rotate(" + Math.floor(rot) + ",0,0)"; } return t2; } - parseSubBoxes(e3) { - e3.boxes = this.parseBoxes(e3.start); - } - findBox(e3, t2) { - return void 0 === e3.boxes && this.parseSubBoxes(e3), e3.boxes.find((e4) => e4.kind === t2); - } - parseBoxHead(e3) { - let t2 = this.file.getUint32(e3), i3 = this.file.getString(e3 + 4, 4), n3 = e3 + 8; - return 1 === t2 && (t2 = this.file.getUint64(e3 + 8), n3 += 8), { offset: e3, length: t2, kind: i3, start: n3 }; - } - parseBoxFullHead(e3) { - if (void 0 !== e3.version) return; - let t2 = this.file.getUint32(e3.start); - e3.version = t2 >> 24, e3.start += 4; + function viewerChanged() { + const service = getService(); + if (!service) return; + const frame2 = service.photoFrame(); + _viewerYaw = frame2.getYaw(); + if (context.map().isTransformed()) return; + layer.selectAll(".viewfield-group.currentView").attr("transform", (d2) => transform2(d2, d2)); } - }; - var Le = class extends Re { - static canHandle(e3, t2) { - if (0 !== t2) return false; - let i3 = e3.getUint16(2); - if (i3 > 50) return false; - let n3 = 16, s2 = []; - for (; n3 < i3; ) s2.push(e3.getString(n3, 4)), n3 += 4; - return s2.includes(this.type); - } - async parse() { - let e3 = this.file.getUint32(0), t2 = this.parseBoxHead(e3); - for (; "meta" !== t2.kind; ) e3 += t2.length, await this.file.ensureChunk(e3, 16), t2 = this.parseBoxHead(e3); - await this.file.ensureChunk(t2.offset, t2.length), this.parseBoxFullHead(t2), this.parseSubBoxes(t2), this.options.icc.enabled && await this.findIcc(t2), this.options.tiff.enabled && await this.findExif(t2); - } - async registerSegment(e3, t2, i3) { - await this.file.ensureChunk(t2, i3); - let n3 = this.file.subarray(t2, i3); - this.createParser(e3, n3); - } - async findIcc(e3) { - let t2 = this.findBox(e3, "iprp"); - if (void 0 === t2) return; - let i3 = this.findBox(t2, "ipco"); - if (void 0 === i3) return; - let n3 = this.findBox(i3, "colr"); - void 0 !== n3 && await this.registerSegment("icc", n3.offset + 12, n3.length); - } - async findExif(e3) { - let t2 = this.findBox(e3, "iinf"); - if (void 0 === t2) return; - let i3 = this.findBox(e3, "iloc"); - if (void 0 === i3) return; - let n3 = this.findExifLocIdInIinf(t2), s2 = this.findExtentInIloc(i3, n3); - if (void 0 === s2) return; - let [r2, a2] = s2; - await this.file.ensureChunk(r2, a2); - let o2 = 4 + this.file.getUint32(r2); - r2 += o2, a2 -= o2, await this.registerSegment("tiff", r2, a2); - } - findExifLocIdInIinf(e3) { - this.parseBoxFullHead(e3); - let t2, i3, n3, s2, r2 = e3.start, a2 = this.file.getUint16(r2); - for (r2 += 2; a2--; ) { - if (t2 = this.parseBoxHead(r2), this.parseBoxFullHead(t2), i3 = t2.start, t2.version >= 2 && (n3 = 3 === t2.version ? 4 : 2, s2 = this.file.getString(i3 + n3 + 2, 4), "Exif" === s2)) return this.file.getUintBytes(i3, n3); - r2 += t2.length; - } - } - get8bits(e3) { - let t2 = this.file.getUint8(e3); - return [t2 >> 4, 15 & t2]; - } - findExtentInIloc(e3, t2) { - this.parseBoxFullHead(e3); - let i3 = e3.start, [n3, s2] = this.get8bits(i3++), [r2, a2] = this.get8bits(i3++), o2 = 2 === e3.version ? 4 : 2, l2 = 1 === e3.version || 2 === e3.version ? 2 : 0, h2 = a2 + n3 + s2, u2 = 2 === e3.version ? 4 : 2, c2 = this.file.getUintBytes(i3, u2); - for (i3 += u2; c2--; ) { - let e4 = this.file.getUintBytes(i3, o2); - i3 += o2 + l2 + 2 + r2; - let u3 = this.file.getUint16(i3); - if (i3 += 2, e4 === t2) return u3 > 1 && console.warn("ILOC box has more than one extent but we're only processing one\nPlease create an issue at https://github.com/MikeKovarik/exifr with this file"), [this.file.getUintBytes(i3 + a2, n3), this.file.getUintBytes(i3 + a2 + n3, s2)]; - i3 += u3 * h2; + function filterImages(images) { + const photoContext = context.photos(); + const fromDateString = photoContext.fromDate(); + const toDateString = photoContext.toDate(); + const showsFlat = photoContext.showsFlat(); + const showsPano = photoContext.showsPanoramic(); + if (fromDateString) { + const fromDate = new Date(fromDateString); + images = images.filter((image) => image.captured_at.getTime() >= fromDate.getTime()); } - } - }; - var Ue = class extends Le { - }; - c(Ue, "type", "heic"); - var Fe = class extends Le { - }; - c(Fe, "type", "avif"), w.set("heic", Ue), w.set("avif", Fe), U(E, ["ifd0", "ifd1"], [[256, "ImageWidth"], [257, "ImageHeight"], [258, "BitsPerSample"], [259, "Compression"], [262, "PhotometricInterpretation"], [270, "ImageDescription"], [271, "Make"], [272, "Model"], [273, "StripOffsets"], [274, "Orientation"], [277, "SamplesPerPixel"], [278, "RowsPerStrip"], [279, "StripByteCounts"], [282, "XResolution"], [283, "YResolution"], [284, "PlanarConfiguration"], [296, "ResolutionUnit"], [301, "TransferFunction"], [305, "Software"], [306, "ModifyDate"], [315, "Artist"], [316, "HostComputer"], [317, "Predictor"], [318, "WhitePoint"], [319, "PrimaryChromaticities"], [513, "ThumbnailOffset"], [514, "ThumbnailLength"], [529, "YCbCrCoefficients"], [530, "YCbCrSubSampling"], [531, "YCbCrPositioning"], [532, "ReferenceBlackWhite"], [700, "ApplicationNotes"], [33432, "Copyright"], [33723, "IPTC"], [34665, "ExifIFD"], [34675, "ICC"], [34853, "GpsIFD"], [330, "SubIFD"], [40965, "InteropIFD"], [40091, "XPTitle"], [40092, "XPComment"], [40093, "XPAuthor"], [40094, "XPKeywords"], [40095, "XPSubject"]]), U(E, "exif", [[33434, "ExposureTime"], [33437, "FNumber"], [34850, "ExposureProgram"], [34852, "SpectralSensitivity"], [34855, "ISO"], [34858, "TimeZoneOffset"], [34859, "SelfTimerMode"], [34864, "SensitivityType"], [34865, "StandardOutputSensitivity"], [34866, "RecommendedExposureIndex"], [34867, "ISOSpeed"], [34868, "ISOSpeedLatitudeyyy"], [34869, "ISOSpeedLatitudezzz"], [36864, "ExifVersion"], [36867, "DateTimeOriginal"], [36868, "CreateDate"], [36873, "GooglePlusUploadCode"], [36880, "OffsetTime"], [36881, "OffsetTimeOriginal"], [36882, "OffsetTimeDigitized"], [37121, "ComponentsConfiguration"], [37122, "CompressedBitsPerPixel"], [37377, "ShutterSpeedValue"], [37378, "ApertureValue"], [37379, "BrightnessValue"], [37380, "ExposureCompensation"], [37381, "MaxApertureValue"], [37382, "SubjectDistance"], [37383, "MeteringMode"], [37384, "LightSource"], [37385, "Flash"], [37386, "FocalLength"], [37393, "ImageNumber"], [37394, "SecurityClassification"], [37395, "ImageHistory"], [37396, "SubjectArea"], [37500, "MakerNote"], [37510, "UserComment"], [37520, "SubSecTime"], [37521, "SubSecTimeOriginal"], [37522, "SubSecTimeDigitized"], [37888, "AmbientTemperature"], [37889, "Humidity"], [37890, "Pressure"], [37891, "WaterDepth"], [37892, "Acceleration"], [37893, "CameraElevationAngle"], [40960, "FlashpixVersion"], [40961, "ColorSpace"], [40962, "ExifImageWidth"], [40963, "ExifImageHeight"], [40964, "RelatedSoundFile"], [41483, "FlashEnergy"], [41486, "FocalPlaneXResolution"], [41487, "FocalPlaneYResolution"], [41488, "FocalPlaneResolutionUnit"], [41492, "SubjectLocation"], [41493, "ExposureIndex"], [41495, "SensingMethod"], [41728, "FileSource"], [41729, "SceneType"], [41730, "CFAPattern"], [41985, "CustomRendered"], [41986, "ExposureMode"], [41987, "WhiteBalance"], [41988, "DigitalZoomRatio"], [41989, "FocalLengthIn35mmFormat"], [41990, "SceneCaptureType"], [41991, "GainControl"], [41992, "Contrast"], [41993, "Saturation"], [41994, "Sharpness"], [41996, "SubjectDistanceRange"], [42016, "ImageUniqueID"], [42032, "OwnerName"], [42033, "SerialNumber"], [42034, "LensInfo"], [42035, "LensMake"], [42036, "LensModel"], [42037, "LensSerialNumber"], [42080, "CompositeImage"], [42081, "CompositeImageCount"], [42082, "CompositeImageExposureTimes"], [42240, "Gamma"], [59932, "Padding"], [59933, "OffsetSchema"], [65e3, "OwnerName"], [65001, "SerialNumber"], [65002, "Lens"], [65100, "RawFile"], [65101, "Converter"], [65102, "WhiteBalance"], [65105, "Exposure"], [65106, "Shadows"], [65107, "Brightness"], [65108, "Contrast"], [65109, "Saturation"], [65110, "Sharpness"], [65111, "Smoothness"], [65112, "MoireFilter"], [40965, "InteropIFD"]]), U(E, "gps", [[0, "GPSVersionID"], [1, "GPSLatitudeRef"], [2, "GPSLatitude"], [3, "GPSLongitudeRef"], [4, "GPSLongitude"], [5, "GPSAltitudeRef"], [6, "GPSAltitude"], [7, "GPSTimeStamp"], [8, "GPSSatellites"], [9, "GPSStatus"], [10, "GPSMeasureMode"], [11, "GPSDOP"], [12, "GPSSpeedRef"], [13, "GPSSpeed"], [14, "GPSTrackRef"], [15, "GPSTrack"], [16, "GPSImgDirectionRef"], [17, "GPSImgDirection"], [18, "GPSMapDatum"], [19, "GPSDestLatitudeRef"], [20, "GPSDestLatitude"], [21, "GPSDestLongitudeRef"], [22, "GPSDestLongitude"], [23, "GPSDestBearingRef"], [24, "GPSDestBearing"], [25, "GPSDestDistanceRef"], [26, "GPSDestDistance"], [27, "GPSProcessingMethod"], [28, "GPSAreaInformation"], [29, "GPSDateStamp"], [30, "GPSDifferential"], [31, "GPSHPositioningError"]]), U(B, ["ifd0", "ifd1"], [[274, { 1: "Horizontal (normal)", 2: "Mirror horizontal", 3: "Rotate 180", 4: "Mirror vertical", 5: "Mirror horizontal and rotate 270 CW", 6: "Rotate 90 CW", 7: "Mirror horizontal and rotate 90 CW", 8: "Rotate 270 CW" }], [296, { 1: "None", 2: "inches", 3: "cm" }]]); - var Ee = U(B, "exif", [[34850, { 0: "Not defined", 1: "Manual", 2: "Normal program", 3: "Aperture priority", 4: "Shutter priority", 5: "Creative program", 6: "Action program", 7: "Portrait mode", 8: "Landscape mode" }], [37121, { 0: "-", 1: "Y", 2: "Cb", 3: "Cr", 4: "R", 5: "G", 6: "B" }], [37383, { 0: "Unknown", 1: "Average", 2: "CenterWeightedAverage", 3: "Spot", 4: "MultiSpot", 5: "Pattern", 6: "Partial", 255: "Other" }], [37384, { 0: "Unknown", 1: "Daylight", 2: "Fluorescent", 3: "Tungsten (incandescent light)", 4: "Flash", 9: "Fine weather", 10: "Cloudy weather", 11: "Shade", 12: "Daylight fluorescent (D 5700 - 7100K)", 13: "Day white fluorescent (N 4600 - 5400K)", 14: "Cool white fluorescent (W 3900 - 4500K)", 15: "White fluorescent (WW 3200 - 3700K)", 17: "Standard light A", 18: "Standard light B", 19: "Standard light C", 20: "D55", 21: "D65", 22: "D75", 23: "D50", 24: "ISO studio tungsten", 255: "Other" }], [37385, { 0: "Flash did not fire", 1: "Flash fired", 5: "Strobe return light not detected", 7: "Strobe return light detected", 9: "Flash fired, compulsory flash mode", 13: "Flash fired, compulsory flash mode, return light not detected", 15: "Flash fired, compulsory flash mode, return light detected", 16: "Flash did not fire, compulsory flash mode", 24: "Flash did not fire, auto mode", 25: "Flash fired, auto mode", 29: "Flash fired, auto mode, return light not detected", 31: "Flash fired, auto mode, return light detected", 32: "No flash function", 65: "Flash fired, red-eye reduction mode", 69: "Flash fired, red-eye reduction mode, return light not detected", 71: "Flash fired, red-eye reduction mode, return light detected", 73: "Flash fired, compulsory flash mode, red-eye reduction mode", 77: "Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected", 79: "Flash fired, compulsory flash mode, red-eye reduction mode, return light detected", 89: "Flash fired, auto mode, red-eye reduction mode", 93: "Flash fired, auto mode, return light not detected, red-eye reduction mode", 95: "Flash fired, auto mode, return light detected, red-eye reduction mode" }], [41495, { 1: "Not defined", 2: "One-chip color area sensor", 3: "Two-chip color area sensor", 4: "Three-chip color area sensor", 5: "Color sequential area sensor", 7: "Trilinear sensor", 8: "Color sequential linear sensor" }], [41728, { 1: "Film Scanner", 2: "Reflection Print Scanner", 3: "Digital Camera" }], [41729, { 1: "Directly photographed" }], [41985, { 0: "Normal", 1: "Custom", 2: "HDR (no original saved)", 3: "HDR (original saved)", 4: "Original (for HDR)", 6: "Panorama", 7: "Portrait HDR", 8: "Portrait" }], [41986, { 0: "Auto", 1: "Manual", 2: "Auto bracket" }], [41987, { 0: "Auto", 1: "Manual" }], [41990, { 0: "Standard", 1: "Landscape", 2: "Portrait", 3: "Night", 4: "Other" }], [41991, { 0: "None", 1: "Low gain up", 2: "High gain up", 3: "Low gain down", 4: "High gain down" }], [41996, { 0: "Unknown", 1: "Macro", 2: "Close", 3: "Distant" }], [42080, { 0: "Unknown", 1: "Not a Composite Image", 2: "General Composite Image", 3: "Composite Image Captured While Shooting" }]]); - var Be = { 1: "No absolute unit of measurement", 2: "Inch", 3: "Centimeter" }; - Ee.set(37392, Be), Ee.set(41488, Be); - var Ne = { 0: "Normal", 1: "Low", 2: "High" }; - function Ge(e3) { - return "object" == typeof e3 && void 0 !== e3.length ? e3[0] : e3; - } - function Ve(e3) { - let t2 = Array.from(e3).slice(1); - return t2[1] > 15 && (t2 = t2.map((e4) => String.fromCharCode(e4))), "0" !== t2[2] && 0 !== t2[2] || t2.pop(), t2.join("."); - } - function ze(e3) { - if ("string" == typeof e3) { - var [t2, i3, n3, s2, r2, a2] = e3.trim().split(/[-: ]/g).map(Number), o2 = new Date(t2, i3 - 1, n3); - return Number.isNaN(s2) || Number.isNaN(r2) || Number.isNaN(a2) || (o2.setHours(s2), o2.setMinutes(r2), o2.setSeconds(a2)), Number.isNaN(+o2) ? e3 : o2; - } - } - function He(e3) { - if ("string" == typeof e3) return e3; - let t2 = []; - if (0 === e3[1] && 0 === e3[e3.length - 1]) for (let i3 = 0; i3 < e3.length; i3 += 2) t2.push(je(e3[i3 + 1], e3[i3])); - else for (let i3 = 0; i3 < e3.length; i3 += 2) t2.push(je(e3[i3], e3[i3 + 1])); - return m(String.fromCodePoint(...t2)); - } - function je(e3, t2) { - return e3 << 8 | t2; - } - Ee.set(41992, Ne), Ee.set(41993, Ne), Ee.set(41994, Ne), U(N, ["ifd0", "ifd1"], [[50827, function(e3) { - return "string" != typeof e3 ? b(e3) : e3; - }], [306, ze], [40091, He], [40092, He], [40093, He], [40094, He], [40095, He]]), U(N, "exif", [[40960, Ve], [36864, Ve], [36867, ze], [36868, ze], [40962, Ge], [40963, Ge]]), U(N, "gps", [[0, (e3) => Array.from(e3).join(".")], [7, (e3) => Array.from(e3).join(":")]]); - var We = class extends re2 { - static canHandle(e3, t2) { - return 225 === e3.getUint8(t2 + 1) && 1752462448 === e3.getUint32(t2 + 4) && "http://ns.adobe.com/" === e3.getString(t2 + 4, "http://ns.adobe.com/".length); - } - static headerLength(e3, t2) { - return "http://ns.adobe.com/xmp/extension/" === e3.getString(t2 + 4, "http://ns.adobe.com/xmp/extension/".length) ? 79 : 4 + "http://ns.adobe.com/xap/1.0/".length + 1; - } - static findPosition(e3, t2) { - let i3 = super.findPosition(e3, t2); - return i3.multiSegment = i3.extended = 79 === i3.headerLength, i3.multiSegment ? (i3.chunkCount = e3.getUint8(t2 + 72), i3.chunkNumber = e3.getUint8(t2 + 76), 0 !== e3.getUint8(t2 + 77) && i3.chunkNumber++) : (i3.chunkCount = 1 / 0, i3.chunkNumber = -1), i3; - } - static handleMultiSegments(e3) { - return e3.map((e4) => e4.chunk.getString()).join(""); - } - normalizeInput(e3) { - return "string" == typeof e3 ? e3 : I.from(e3).getString(); - } - parse(e3 = this.chunk) { - if (!this.localOptions.parse) return e3; - e3 = function(e4) { - let t3 = {}, i4 = {}; - for (let e6 of Ze) t3[e6] = [], i4[e6] = 0; - return e4.replace(et, (e6, n4, s2) => { - if ("<" === n4) { - let n5 = ++i4[s2]; - return t3[s2].push(n5), "".concat(e6, "#").concat(n5); - } - return "".concat(e6, "#").concat(t3[s2].pop()); - }); - }(e3); - let t2 = Xe.findAll(e3, "rdf", "Description"); - 0 === t2.length && t2.push(new Xe("rdf", "Description", void 0, e3)); - let i3, n3 = {}; - for (let e4 of t2) for (let t3 of e4.properties) i3 = Je(t3.ns, n3), _e(t3, i3); - return function(e4) { - let t3; - for (let i4 in e4) t3 = e4[i4] = f(e4[i4]), void 0 === t3 && delete e4[i4]; - return f(e4); - }(n3); - } - assignToOutput(e3, t2) { - if (this.localOptions.parse) for (let [i3, n3] of Object.entries(t2)) switch (i3) { - case "tiff": - this.assignObjectToOutput(e3, "ifd0", n3); - break; - case "exif": - this.assignObjectToOutput(e3, "exif", n3); - break; - case "xmlns": - break; - default: - this.assignObjectToOutput(e3, i3, n3); + if (toDateString) { + const toDate = new Date(toDateString); + images = images.filter((image) => image.captured_at.getTime() <= toDate.getTime()); } - else e3.xmp = t2; - } - }; - c(We, "type", "xmp"), c(We, "multiSegment", true), T.set("xmp", We); - var Ke = class _Ke { - static findAll(e3) { - return qe(e3, /([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(_Ke.unpackMatch); - } - static unpackMatch(e3) { - let t2 = e3[1], i3 = e3[2], n3 = e3[3].slice(1, -1); - return n3 = Qe(n3), new _Ke(t2, i3, n3); - } - constructor(e3, t2, i3) { - this.ns = e3, this.name = t2, this.value = i3; - } - serialize() { - return this.value; - } - }; - var Xe = class _Xe { - static findAll(e3, t2, i3) { - if (void 0 !== t2 || void 0 !== i3) { - t2 = t2 || "[\\w\\d-]+", i3 = i3 || "[\\w\\d-]+"; - var n3 = new RegExp("<(".concat(t2, "):(").concat(i3, ")(#\\d+)?((\\s+?[\\w\\d-:]+=(\"[^\"]*\"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)"), "gm"); - } else n3 = /<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm; - return qe(e3, n3).map(_Xe.unpackMatch); - } - static unpackMatch(e3) { - let t2 = e3[1], i3 = e3[2], n3 = e3[4], s2 = e3[8]; - return new _Xe(t2, i3, n3, s2); - } - constructor(e3, t2, i3, n3) { - this.ns = e3, this.name = t2, this.attrString = i3, this.innerXml = n3, this.attrs = Ke.findAll(i3), this.children = _Xe.findAll(n3), this.value = 0 === this.children.length ? Qe(n3) : void 0, this.properties = [...this.attrs, ...this.children]; - } - get isPrimitive() { - return void 0 !== this.value && 0 === this.attrs.length && 0 === this.children.length; - } - get isListContainer() { - return 1 === this.children.length && this.children[0].isList; - } - get isList() { - let { ns: e3, name: t2 } = this; - return "rdf" === e3 && ("Seq" === t2 || "Bag" === t2 || "Alt" === t2); - } - get isListItem() { - return "rdf" === this.ns && "li" === this.name; - } - serialize() { - if (0 === this.properties.length && void 0 === this.value) return; - if (this.isPrimitive) return this.value; - if (this.isListContainer) return this.children[0].serialize(); - if (this.isList) return $e(this.children.map(Ye)); - if (this.isListItem && 1 === this.children.length && 0 === this.attrs.length) return this.children[0].serialize(); - let e3 = {}; - for (let t2 of this.properties) _e(t2, e3); - return void 0 !== this.value && (e3.value = this.value), f(e3); + if (!showsPano) { + images = images.filter((image) => !image.is_sphere); + } + if (!showsFlat) { + images = images.filter((image) => image.is_sphere); + } + return images; } - }; - function _e(e3, t2) { - let i3 = e3.serialize(); - void 0 !== i3 && (t2[e3.name] = i3); - } - var Ye = (e3) => e3.serialize(); - var $e = (e3) => 1 === e3.length ? e3[0] : e3; - var Je = (e3, t2) => t2[e3] ? t2[e3] : t2[e3] = {}; - function qe(e3, t2) { - let i3, n3 = []; - if (!e3) return n3; - for (; null !== (i3 = t2.exec(e3)); ) n3.push(i3); - return n3; - } - function Qe(e3) { - if (function(e4) { - return null == e4 || "null" === e4 || "undefined" === e4 || "" === e4 || "" === e4.trim(); - }(e3)) return; - let t2 = Number(e3); - if (!Number.isNaN(t2)) return t2; - let i3 = e3.toLowerCase(); - return "true" === i3 || "false" !== i3 && e3.trim(); - } - 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: 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; - }, rotation: Ae }); - var at = l("fs", (e3) => e3.promises); - A.set("fs", class extends ve { - async readWhole() { - this.chunked = false, this.fs = await at; - let e3 = await this.fs.readFile(this.input); - this._swapBuffer(e3); - } - async readChunked() { - this.chunked = true, this.fs = await at, await this.open(), await this.readChunk(0, this.options.firstChunkSize); - } - async open() { - void 0 === this.fh && (this.fh = await this.fs.open(this.input, "r"), this.size = (await this.fh.stat(this.input)).size); - } - async _readChunk(e3, t2) { - void 0 === this.fh && await this.open(), e3 + t2 > this.size && (t2 = this.size - e3); - var i3 = this.subarray(e3, t2, true); - return await this.fh.read(i3.dataView, 0, t2, e3), i3; - } - async close() { - if (this.fh) { - let e3 = this.fh; - this.fh = void 0, await e3.close(); - } - } - }); - A.set("base64", class extends ve { - constructor(...e3) { - super(...e3), this.input = this.input.replace(/^data:([^;]+);base64,/gim, ""), this.size = this.input.length / 4 * 3, this.input.endsWith("==") ? this.size -= 2 : this.input.endsWith("=") && (this.size -= 1); - } - async _readChunk(e3, t2) { - let i3, n3, r2 = this.input; - void 0 === e3 ? (e3 = 0, i3 = 0, n3 = 0) : (i3 = 4 * Math.floor(e3 / 3), n3 = e3 - i3 / 4 * 3), void 0 === t2 && (t2 = this.size); - let o2 = e3 + t2, l2 = i3 + 4 * Math.ceil(o2 / 3); - r2 = r2.slice(i3, l2); - let h2 = Math.min(t2, this.size - e3); - if (a) { - let t3 = s.from(r2, "base64").slice(n3, n3 + h2); - return this.set(t3, e3, true); + function filterSequences(sequences) { + const photoContext = context.photos(); + const fromDateString = photoContext.fromDate(); + const toDateString = photoContext.toDate(); + const showsFlat = photoContext.showsFlat(); + const showsPano = photoContext.showsPanoramic(); + if (fromDateString) { + const fromDate = new Date(fromDateString); + sequences = sequences.filter(({ images }) => images[0].captured_at.getTime() >= fromDate.getTime()); } - { - let t3 = this.subarray(e3, h2, true), i4 = atob(r2), s2 = t3.toUint8(); - for (let e4 = 0; e4 < h2; e4++) s2[e4] = i4.charCodeAt(n3 + e4); - return t3; + if (toDateString) { + const toDate = new Date(toDateString); + sequences = sequences.filter(({ images }) => images[images.length - 1].captured_at.getTime() <= toDate.getTime()); } - } - }); - var ot = class extends se { - static canHandle(e3, t2) { - return 18761 === t2 || 19789 === t2; - } - extendOptions(e3) { - let { ifd0: t2, xmp: i3, iptc: n3, icc: s2 } = e3; - i3.enabled && t2.deps.add(700), n3.enabled && t2.deps.add(33723), s2.enabled && t2.deps.add(34675), t2.finalizeFilters(); - } - async parse() { - let { tiff: e3, xmp: t2, iptc: i3, icc: n3 } = this.options; - if (e3.enabled || t2.enabled || i3.enabled || n3.enabled) { - let e4 = Math.max(S(this.options), this.options.chunkSize); - await this.file.ensureChunk(0, e4), this.createParser("tiff", this.file), this.parsers.tiff.parseHeader(), await this.parsers.tiff.parseIfd0Block(), this.adaptTiffPropAsSegment("xmp"), this.adaptTiffPropAsSegment("iptc"), this.adaptTiffPropAsSegment("icc"); + if (!showsPano) { + sequences = sequences.filter(({ images }) => !images[0].is_sphere); } - } - adaptTiffPropAsSegment(e3) { - if (this.parsers.tiff[e3]) { - let t2 = this.parsers.tiff[e3]; - this.injectSegment(e3, t2); + if (!showsFlat) { + sequences = sequences.filter(({ images }) => images[0].is_sphere); } + return sequences; } - }; - c(ot, "type", "tiff"), w.set("tiff", ot); - var lt = l("zlib"); - var ht = ["ihdr", "iccp", "text", "itxt", "exif"]; - var ut = class extends se { - constructor(...e3) { - super(...e3), c(this, "catchError", (e4) => this.errors.push(e4)), c(this, "metaChunks", []), c(this, "unknownChunks", []); - } - static canHandle(e3, t2) { - return 35152 === t2 && 2303741511 === e3.getUint32(0) && 218765834 === e3.getUint32(4); - } - async parse() { - let { file: e3 } = this; - await this.findPngChunksInRange("\x89PNG\r\n\n".length, e3.byteLength), await this.readSegments(this.metaChunks), this.findIhdr(), this.parseTextChunks(), await this.findExif().catch(this.catchError), await this.findXmp().catch(this.catchError), await this.findIcc().catch(this.catchError); - } - async findPngChunksInRange(e3, t2) { - let { file: i3 } = this; - for (; e3 < t2; ) { - let t3 = i3.getUint32(e3), n3 = i3.getUint32(e3 + 4), s2 = i3.getString(e3 + 4, 4).toLowerCase(), r2 = t3 + 4 + 4 + 4, a2 = { type: s2, offset: e3, length: r2, start: e3 + 4 + 4, size: t3, marker: n3 }; - ht.includes(s2) ? this.metaChunks.push(a2) : this.unknownChunks.push(a2), e3 += r2; + function update() { + const viewer = context.container().select(".photoviewer"); + const selected = viewer.empty() ? void 0 : viewer.datum(); + const z2 = ~~context.map().zoom(); + const showMarkers = z2 >= minMarkerZoom; + const showViewfields = z2 >= minViewfieldZoom2; + const service = getService(); + let sequences = []; + let images = []; + if (service) { + service.loadImages(context); + sequences = service.sequences(projection2); + images = showMarkers ? service.images(projection2) : []; + dispatch14.call("photoDatesChanged", this, "vegbilder", images.map((p2) => p2.captured_at)); + images = filterImages(images); + sequences = filterSequences(sequences); } - } - parseTextChunks() { - let e3 = this.metaChunks.filter((e4) => "text" === e4.type); - for (let t2 of e3) { - let [e4, i3] = this.file.getString(t2.start, t2.size).split("\0"); - this.injectKeyValToIhdr(e4, i3); + let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, (d2) => d2.key); + traces.exit().remove(); + traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson); + const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, (d2) => d2.key); + groups.exit().remove(); + const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click); + groupsEnter.append("g").attr("class", "viewfield-scale"); + const markers = groups.merge(groupsEnter).sort((a2, b2) => { + return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1]; + }).attr("transform", (d2) => transform2(d2, selected)).select(".viewfield-scale"); + markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6"); + const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []); + viewfields.exit().remove(); + viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath); + function viewfieldPath() { + const d2 = this.parentNode.__data__; + if (d2.is_sphere) { + return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0"; + } else { + return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z"; + } } } - injectKeyValToIhdr(e3, t2) { - let i3 = this.parsers.ihdr; - i3 && i3.raw.set(e3, t2); - } - findIhdr() { - let e3 = this.metaChunks.find((e4) => "ihdr" === e4.type); - e3 && false !== this.options.ihdr.enabled && this.createParser("ihdr", e3.chunk); - } - async findExif() { - let e3 = this.metaChunks.find((e4) => "exif" === e4.type); - e3 && this.injectSegment("tiff", e3.chunk); + function drawImages(selection2) { + const enabled = svgVegbilder.enabled; + const service = getService(); + layer = selection2.selectAll(".layer-vegbilder").data(service ? [0] : []); + layer.exit().remove(); + const layerEnter = layer.enter().append("g").attr("class", "layer-vegbilder").style("display", enabled ? "block" : "none"); + layerEnter.append("g").attr("class", "sequences"); + layerEnter.append("g").attr("class", "markers"); + layer = layerEnter.merge(layer); + if (enabled) { + if (service && ~~context.map().zoom() >= minZoom5) { + editOn(); + update(); + service.loadImages(context); + } else { + editOff(); + } + } } - async findXmp() { - let e3 = this.metaChunks.filter((e4) => "itxt" === e4.type); - for (let t2 of e3) { - "XML:com.adobe.xmp" === t2.chunk.getString(0, "XML:com.adobe.xmp".length) && this.injectSegment("xmp", t2.chunk); + drawImages.enabled = function(_2) { + if (!arguments.length) return svgVegbilder.enabled; + svgVegbilder.enabled = _2; + if (svgVegbilder.enabled) { + showLayer(); + context.photos().on("change.vegbilder", update); + } else { + hideLayer(); + context.photos().on("change.vegbilder", null); } + dispatch14.call("change"); + return this; + }; + drawImages.supported = function() { + return !!getService(); + }; + drawImages.rendered = function(zoom) { + return zoom >= minZoom5; + }; + drawImages.validHere = function(extent, zoom) { + return zoom >= minZoom5 - 2 && getService().validHere(extent); + }; + init2(); + return drawImages; + } + var init_vegbilder = __esm({ + "modules/svg/vegbilder.js"() { + "use strict"; + init_throttle(); + init_src5(); + init_helpers(); + init_services(); + } + }); + + // modules/svg/mapillary_images.js + var mapillary_images_exports = {}; + __export(mapillary_images_exports, { + svgMapillaryImages: () => svgMapillaryImages + }); + function svgMapillaryImages(projection2, context, dispatch14) { + const throttledRedraw = throttle_default(function() { + dispatch14.call("change"); + }, 1e3); + const minZoom5 = 12; + const minMarkerZoom = 16; + const minViewfieldZoom2 = 18; + let layer = select_default2(null); + let _mapillary; + function init2() { + if (svgMapillaryImages.initialized) return; + svgMapillaryImages.enabled = false; + svgMapillaryImages.initialized = true; } - async findIcc() { - let e3 = this.metaChunks.find((e4) => "iccp" === e4.type); - if (!e3) return; - let { chunk: t2 } = e3, i3 = t2.getUint8Array(0, 81), s2 = 0; - for (; s2 < 80 && 0 !== i3[s2]; ) s2++; - let r2 = s2 + 2, a2 = t2.getString(0, s2); - if (this.injectKeyValToIhdr("ProfileName", a2), n2) { - let e4 = await lt, i4 = t2.getUint8Array(r2); - i4 = e4.inflateSync(i4), this.injectSegment("icc", i4); + function getService() { + if (services.mapillary && !_mapillary) { + _mapillary = services.mapillary; + _mapillary.event.on("loadedImages", throttledRedraw); + } else if (!services.mapillary && _mapillary) { + _mapillary = null; } + return _mapillary; } - }; - c(ut, "type", "png"), w.set("png", ut), U(E, "interop", [[1, "InteropIndex"], [2, "InteropVersion"], [4096, "RelatedImageFileFormat"], [4097, "RelatedImageWidth"], [4098, "RelatedImageHeight"]]), F(E, "ifd0", [[11, "ProcessingSoftware"], [254, "SubfileType"], [255, "OldSubfileType"], [263, "Thresholding"], [264, "CellWidth"], [265, "CellLength"], [266, "FillOrder"], [269, "DocumentName"], [280, "MinSampleValue"], [281, "MaxSampleValue"], [285, "PageName"], [286, "XPosition"], [287, "YPosition"], [290, "GrayResponseUnit"], [297, "PageNumber"], [321, "HalftoneHints"], [322, "TileWidth"], [323, "TileLength"], [332, "InkSet"], [337, "TargetPrinter"], [18246, "Rating"], [18249, "RatingPercent"], [33550, "PixelScale"], [34264, "ModelTransform"], [34377, "PhotoshopSettings"], [50706, "DNGVersion"], [50707, "DNGBackwardVersion"], [50708, "UniqueCameraModel"], [50709, "LocalizedCameraModel"], [50736, "DNGLensInfo"], [50739, "ShadowScale"], [50740, "DNGPrivateData"], [33920, "IntergraphMatrix"], [33922, "ModelTiePoint"], [34118, "SEMInfo"], [34735, "GeoTiffDirectory"], [34736, "GeoTiffDoubleParams"], [34737, "GeoTiffAsciiParams"], [50341, "PrintIM"], [50721, "ColorMatrix1"], [50722, "ColorMatrix2"], [50723, "CameraCalibration1"], [50724, "CameraCalibration2"], [50725, "ReductionMatrix1"], [50726, "ReductionMatrix2"], [50727, "AnalogBalance"], [50728, "AsShotNeutral"], [50729, "AsShotWhiteXY"], [50730, "BaselineExposure"], [50731, "BaselineNoise"], [50732, "BaselineSharpness"], [50734, "LinearResponseLimit"], [50735, "CameraSerialNumber"], [50741, "MakerNoteSafety"], [50778, "CalibrationIlluminant1"], [50779, "CalibrationIlluminant2"], [50781, "RawDataUniqueID"], [50827, "OriginalRawFileName"], [50828, "OriginalRawFileData"], [50831, "AsShotICCProfile"], [50832, "AsShotPreProfileMatrix"], [50833, "CurrentICCProfile"], [50834, "CurrentPreProfileMatrix"], [50879, "ColorimetricReference"], [50885, "SRawType"], [50898, "PanasonicTitle"], [50899, "PanasonicTitle2"], [50931, "CameraCalibrationSig"], [50932, "ProfileCalibrationSig"], [50933, "ProfileIFD"], [50934, "AsShotProfileName"], [50936, "ProfileName"], [50937, "ProfileHueSatMapDims"], [50938, "ProfileHueSatMapData1"], [50939, "ProfileHueSatMapData2"], [50940, "ProfileToneCurve"], [50941, "ProfileEmbedPolicy"], [50942, "ProfileCopyright"], [50964, "ForwardMatrix1"], [50965, "ForwardMatrix2"], [50966, "PreviewApplicationName"], [50967, "PreviewApplicationVersion"], [50968, "PreviewSettingsName"], [50969, "PreviewSettingsDigest"], [50970, "PreviewColorSpace"], [50971, "PreviewDateTime"], [50972, "RawImageDigest"], [50973, "OriginalRawFileDigest"], [50981, "ProfileLookTableDims"], [50982, "ProfileLookTableData"], [51043, "TimeCodes"], [51044, "FrameRate"], [51058, "TStop"], [51081, "ReelName"], [51089, "OriginalDefaultFinalSize"], [51090, "OriginalBestQualitySize"], [51091, "OriginalDefaultCropSize"], [51105, "CameraLabel"], [51107, "ProfileHueSatMapEncoding"], [51108, "ProfileLookTableEncoding"], [51109, "BaselineExposureOffset"], [51110, "DefaultBlackRender"], [51111, "NewRawImageDigest"], [51112, "RawToPreviewGain"]]); - var ct = [[273, "StripOffsets"], [279, "StripByteCounts"], [288, "FreeOffsets"], [289, "FreeByteCounts"], [291, "GrayResponseCurve"], [292, "T4Options"], [293, "T6Options"], [300, "ColorResponseUnit"], [320, "ColorMap"], [324, "TileOffsets"], [325, "TileByteCounts"], [326, "BadFaxLines"], [327, "CleanFaxData"], [328, "ConsecutiveBadFaxLines"], [330, "SubIFD"], [333, "InkNames"], [334, "NumberofInks"], [336, "DotRange"], [338, "ExtraSamples"], [339, "SampleFormat"], [340, "SMinSampleValue"], [341, "SMaxSampleValue"], [342, "TransferRange"], [343, "ClipPath"], [344, "XClipPathUnits"], [345, "YClipPathUnits"], [346, "Indexed"], [347, "JPEGTables"], [351, "OPIProxy"], [400, "GlobalParametersIFD"], [401, "ProfileType"], [402, "FaxProfile"], [403, "CodingMethods"], [404, "VersionYear"], [405, "ModeNumber"], [433, "Decode"], [434, "DefaultImageColor"], [435, "T82Options"], [437, "JPEGTables"], [512, "JPEGProc"], [515, "JPEGRestartInterval"], [517, "JPEGLosslessPredictors"], [518, "JPEGPointTransforms"], [519, "JPEGQTables"], [520, "JPEGDCTables"], [521, "JPEGACTables"], [559, "StripRowCounts"], [999, "USPTOMiscellaneous"], [18247, "XP_DIP_XML"], [18248, "StitchInfo"], [28672, "SonyRawFileType"], [28688, "SonyToneCurve"], [28721, "VignettingCorrection"], [28722, "VignettingCorrParams"], [28724, "ChromaticAberrationCorrection"], [28725, "ChromaticAberrationCorrParams"], [28726, "DistortionCorrection"], [28727, "DistortionCorrParams"], [29895, "SonyCropTopLeft"], [29896, "SonyCropSize"], [32781, "ImageID"], [32931, "WangTag1"], [32932, "WangAnnotation"], [32933, "WangTag3"], [32934, "WangTag4"], [32953, "ImageReferencePoints"], [32954, "RegionXformTackPoint"], [32955, "WarpQuadrilateral"], [32956, "AffineTransformMat"], [32995, "Matteing"], [32996, "DataType"], [32997, "ImageDepth"], [32998, "TileDepth"], [33300, "ImageFullWidth"], [33301, "ImageFullHeight"], [33302, "TextureFormat"], [33303, "WrapModes"], [33304, "FovCot"], [33305, "MatrixWorldToScreen"], [33306, "MatrixWorldToCamera"], [33405, "Model2"], [33421, "CFARepeatPatternDim"], [33422, "CFAPattern2"], [33423, "BatteryLevel"], [33424, "KodakIFD"], [33445, "MDFileTag"], [33446, "MDScalePixel"], [33447, "MDColorTable"], [33448, "MDLabName"], [33449, "MDSampleInfo"], [33450, "MDPrepDate"], [33451, "MDPrepTime"], [33452, "MDFileUnits"], [33589, "AdventScale"], [33590, "AdventRevision"], [33628, "UIC1Tag"], [33629, "UIC2Tag"], [33630, "UIC3Tag"], [33631, "UIC4Tag"], [33918, "IntergraphPacketData"], [33919, "IntergraphFlagRegisters"], [33921, "INGRReserved"], [34016, "Site"], [34017, "ColorSequence"], [34018, "IT8Header"], [34019, "RasterPadding"], [34020, "BitsPerRunLength"], [34021, "BitsPerExtendedRunLength"], [34022, "ColorTable"], [34023, "ImageColorIndicator"], [34024, "BackgroundColorIndicator"], [34025, "ImageColorValue"], [34026, "BackgroundColorValue"], [34027, "PixelIntensityRange"], [34028, "TransparencyIndicator"], [34029, "ColorCharacterization"], [34030, "HCUsage"], [34031, "TrapIndicator"], [34032, "CMYKEquivalent"], [34152, "AFCP_IPTC"], [34232, "PixelMagicJBIGOptions"], [34263, "JPLCartoIFD"], [34306, "WB_GRGBLevels"], [34310, "LeafData"], [34687, "TIFF_FXExtensions"], [34688, "MultiProfiles"], [34689, "SharedData"], [34690, "T88Options"], [34732, "ImageLayer"], [34750, "JBIGOptions"], [34856, "Opto-ElectricConvFactor"], [34857, "Interlace"], [34908, "FaxRecvParams"], [34909, "FaxSubAddress"], [34910, "FaxRecvTime"], [34929, "FedexEDR"], [34954, "LeafSubIFD"], [37387, "FlashEnergy"], [37388, "SpatialFrequencyResponse"], [37389, "Noise"], [37390, "FocalPlaneXResolution"], [37391, "FocalPlaneYResolution"], [37392, "FocalPlaneResolutionUnit"], [37397, "ExposureIndex"], [37398, "TIFF-EPStandardID"], [37399, "SensingMethod"], [37434, "CIP3DataFile"], [37435, "CIP3Sheet"], [37436, "CIP3Side"], [37439, "StoNits"], [37679, "MSDocumentText"], [37680, "MSPropertySetStorage"], [37681, "MSDocumentTextPosition"], [37724, "ImageSourceData"], [40965, "InteropIFD"], [40976, "SamsungRawPointersOffset"], [40977, "SamsungRawPointersLength"], [41217, "SamsungRawByteOrder"], [41218, "SamsungRawUnknown"], [41484, "SpatialFrequencyResponse"], [41485, "Noise"], [41489, "ImageNumber"], [41490, "SecurityClassification"], [41491, "ImageHistory"], [41494, "TIFF-EPStandardID"], [41995, "DeviceSettingDescription"], [42112, "GDALMetadata"], [42113, "GDALNoData"], [44992, "ExpandSoftware"], [44993, "ExpandLens"], [44994, "ExpandFilm"], [44995, "ExpandFilterLens"], [44996, "ExpandScanner"], [44997, "ExpandFlashLamp"], [46275, "HasselbladRawImage"], [48129, "PixelFormat"], [48130, "Transformation"], [48131, "Uncompressed"], [48132, "ImageType"], [48256, "ImageWidth"], [48257, "ImageHeight"], [48258, "WidthResolution"], [48259, "HeightResolution"], [48320, "ImageOffset"], [48321, "ImageByteCount"], [48322, "AlphaOffset"], [48323, "AlphaByteCount"], [48324, "ImageDataDiscard"], [48325, "AlphaDataDiscard"], [50215, "OceScanjobDesc"], [50216, "OceApplicationSelector"], [50217, "OceIDNumber"], [50218, "OceImageLogic"], [50255, "Annotations"], [50459, "HasselbladExif"], [50547, "OriginalFileName"], [50560, "USPTOOriginalContentType"], [50656, "CR2CFAPattern"], [50710, "CFAPlaneColor"], [50711, "CFALayout"], [50712, "LinearizationTable"], [50713, "BlackLevelRepeatDim"], [50714, "BlackLevel"], [50715, "BlackLevelDeltaH"], [50716, "BlackLevelDeltaV"], [50717, "WhiteLevel"], [50718, "DefaultScale"], [50719, "DefaultCropOrigin"], [50720, "DefaultCropSize"], [50733, "BayerGreenSplit"], [50737, "ChromaBlurRadius"], [50738, "AntiAliasStrength"], [50752, "RawImageSegmentation"], [50780, "BestQualityScale"], [50784, "AliasLayerMetadata"], [50829, "ActiveArea"], [50830, "MaskedAreas"], [50935, "NoiseReductionApplied"], [50974, "SubTileBlockSize"], [50975, "RowInterleaveFactor"], [51008, "OpcodeList1"], [51009, "OpcodeList2"], [51022, "OpcodeList3"], [51041, "NoiseProfile"], [51114, "CacheVersion"], [51125, "DefaultUserCrop"], [51157, "NikonNEFInfo"], [65024, "KdcIFD"]]; - F(E, "ifd0", ct), F(E, "exif", ct), U(B, "gps", [[23, { M: "Magnetic North", T: "True North" }], [25, { K: "Kilometers", M: "Miles", N: "Nautical Miles" }]]); - var ft = class extends re2 { - static canHandle(e3, t2) { - return 224 === e3.getUint8(t2 + 1) && 1246120262 === e3.getUint32(t2 + 4) && 0 === e3.getUint8(t2 + 8); + function showLayer() { + const service = getService(); + if (!service) return; + editOn(); + layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() { + dispatch14.call("change"); + }); } - parse() { - return this.parseTags(), this.translate(), this.output; + function hideLayer() { + throttledRedraw.cancel(); + layer.transition().duration(250).style("opacity", 0).on("end", editOff); } - parseTags() { - this.raw = /* @__PURE__ */ new Map([[0, this.chunk.getUint16(0)], [2, this.chunk.getUint8(2)], [3, this.chunk.getUint16(3)], [5, this.chunk.getUint16(5)], [7, this.chunk.getUint8(7)], [8, this.chunk.getUint8(8)]]); + function editOn() { + layer.style("display", "block"); } - }; - c(ft, "type", "jfif"), c(ft, "headerLength", 9), T.set("jfif", ft), U(E, "jfif", [[0, "JFIFVersion"], [2, "ResolutionUnit"], [3, "XResolution"], [5, "YResolution"], [7, "ThumbnailWidth"], [8, "ThumbnailHeight"]]); - var dt = class extends re2 { - parse() { - return this.parseTags(), this.translate(), this.output; + function editOff() { + layer.selectAll(".viewfield-group").remove(); + layer.style("display", "none"); } - parseTags() { - this.raw = new Map([[0, this.chunk.getUint32(0)], [4, this.chunk.getUint32(4)], [8, this.chunk.getUint8(8)], [9, this.chunk.getUint8(9)], [10, this.chunk.getUint8(10)], [11, this.chunk.getUint8(11)], [12, this.chunk.getUint8(12)], ...Array.from(this.raw)]); + function click(d3_event, image) { + const service = getService(); + if (!service) return; + service.ensureViewerLoaded(context).then(function() { + service.selectImage(context, image.id).showViewer(context); + }); + context.map().centerEase(image.loc); } - }; - c(dt, "type", "ihdr"), T.set("ihdr", dt), U(E, "ihdr", [[0, "ImageWidth"], [4, "ImageHeight"], [8, "BitDepth"], [9, "ColorType"], [10, "Compression"], [11, "Filter"], [12, "Interlace"]]), U(B, "ihdr", [[9, { 0: "Grayscale", 2: "RGB", 3: "Palette", 4: "Grayscale with Alpha", 6: "RGB with Alpha", DEFAULT: "Unknown" }], [10, { 0: "Deflate/Inflate", DEFAULT: "Unknown" }], [11, { 0: "Adaptive", DEFAULT: "Unknown" }], [12, { 0: "Noninterlaced", 1: "Adam7 Interlace", DEFAULT: "Unknown" }]]); - var pt = class extends re2 { - static canHandle(e3, t2) { - return 226 === e3.getUint8(t2 + 1) && 1229144927 === e3.getUint32(t2 + 4); - } - static findPosition(e3, t2) { - let i3 = super.findPosition(e3, t2); - return i3.chunkNumber = e3.getUint8(t2 + 16), i3.chunkCount = e3.getUint8(t2 + 17), i3.multiSegment = i3.chunkCount > 1, i3; - } - static handleMultiSegments(e3) { - return function(e4) { - let t2 = function(e6) { - let t3 = e6[0].constructor, i3 = 0; - for (let t4 of e6) i3 += t4.length; - let n3 = new t3(i3), s2 = 0; - for (let t4 of e6) n3.set(t4, s2), s2 += t4.length; - return n3; - }(e4.map((e6) => e6.chunk.toUint8())); - return new I(t2); - }(e3); + function mouseover(d3_event, image) { + const service = getService(); + if (service) service.setStyles(context, image); } - parse() { - return this.raw = /* @__PURE__ */ new Map(), this.parseHeader(), this.parseTags(), this.translate(), this.output; + function mouseout() { + const service = getService(); + if (service) service.setStyles(context, null); } - parseHeader() { - let { raw: e3 } = this; - this.chunk.byteLength < 84 && g2("ICC header is too short"); - for (let [t2, i3] of Object.entries(gt)) { - t2 = parseInt(t2, 10); - let n3 = i3(this.chunk, t2); - "\0\0\0\0" !== n3 && e3.set(t2, n3); + function transform2(d2) { + let t2 = svgPointTransform(projection2)(d2); + if (d2.ca) { + t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)"; } + return t2; } - parseTags() { - let e3, t2, i3, n3, s2, { raw: r2 } = this, a2 = this.chunk.getUint32(128), o2 = 132, l2 = this.chunk.byteLength; - for (; a2--; ) { - if (e3 = this.chunk.getString(o2, 4), t2 = this.chunk.getUint32(o2 + 4), i3 = this.chunk.getUint32(o2 + 8), n3 = this.chunk.getString(t2, 4), t2 + i3 > l2) return void console.warn("reached the end of the first ICC chunk. Enable options.tiff.multiSegment to read all ICC segments."); - s2 = this.parseTag(n3, t2, i3), void 0 !== s2 && "\0\0\0\0" !== s2 && r2.set(e3, s2), o2 += 12; + function filterImages(images) { + const showsPano = context.photos().showsPanoramic(); + const showsFlat = context.photos().showsFlat(); + const fromDate = context.photos().fromDate(); + const toDate = context.photos().toDate(); + if (!showsPano || !showsFlat) { + images = images.filter(function(image) { + if (image.is_pano) return showsPano; + return showsFlat; + }); } - } - parseTag(e3, t2, i3) { - switch (e3) { - case "desc": - return this.parseDesc(t2); - case "mluc": - return this.parseMluc(t2); - case "text": - return this.parseText(t2, i3); - case "sig ": - return this.parseSig(t2); + if (fromDate) { + images = images.filter(function(image) { + return new Date(image.captured_at).getTime() >= new Date(fromDate).getTime(); + }); } - if (!(t2 + i3 > this.chunk.byteLength)) return this.chunk.getUint8Array(t2, i3); - } - parseDesc(e3) { - let t2 = this.chunk.getUint32(e3 + 8) - 1; - return m(this.chunk.getString(e3 + 12, t2)); - } - parseText(e3, t2) { - return m(this.chunk.getString(e3 + 8, t2 - 8)); - } - parseSig(e3) { - return m(this.chunk.getString(e3 + 8, 4)); - } - parseMluc(e3) { - let { chunk: t2 } = this, i3 = t2.getUint32(e3 + 8), n3 = t2.getUint32(e3 + 12), s2 = e3 + 16, r2 = []; - for (let a2 = 0; a2 < i3; a2++) { - let i4 = t2.getString(s2 + 0, 2), a3 = t2.getString(s2 + 2, 2), o2 = t2.getUint32(s2 + 4), l2 = t2.getUint32(s2 + 8) + e3, h2 = m(t2.getUnicodeString(l2, o2)); - r2.push({ lang: i4, country: a3, text: h2 }), s2 += n3; + if (toDate) { + images = images.filter(function(image) { + return new Date(image.captured_at).getTime() <= new Date(toDate).getTime(); + }); } - return 1 === i3 ? r2[0].text : r2; - } - translateValue(e3, t2) { - return "string" == typeof e3 ? t2[e3] || t2[e3.toLowerCase()] || e3 : t2[e3] || e3; - } - }; - c(pt, "type", "icc"), c(pt, "multiSegment", true), c(pt, "headerLength", 18); - var gt = { 4: mt, 8: function(e3, t2) { - return [e3.getUint8(t2), e3.getUint8(t2 + 1) >> 4, e3.getUint8(t2 + 1) % 16].map((e4) => e4.toString(10)).join("."); - }, 12: mt, 16: mt, 20: mt, 24: function(e3, t2) { - const i3 = e3.getUint16(t2), n3 = e3.getUint16(t2 + 2) - 1, s2 = e3.getUint16(t2 + 4), r2 = e3.getUint16(t2 + 6), a2 = e3.getUint16(t2 + 8), o2 = e3.getUint16(t2 + 10); - return new Date(Date.UTC(i3, n3, s2, r2, a2, o2)); - }, 36: mt, 40: mt, 48: mt, 52: mt, 64: (e3, t2) => e3.getUint32(t2), 80: mt }; - function mt(e3, t2) { - return m(e3.getString(t2, 4)); - } - T.set("icc", pt), U(E, "icc", [[4, "ProfileCMMType"], [8, "ProfileVersion"], [12, "ProfileClass"], [16, "ColorSpaceData"], [20, "ProfileConnectionSpace"], [24, "ProfileDateTime"], [36, "ProfileFileSignature"], [40, "PrimaryPlatform"], [44, "CMMFlags"], [48, "DeviceManufacturer"], [52, "DeviceModel"], [56, "DeviceAttributes"], [64, "RenderingIntent"], [68, "ConnectionSpaceIlluminant"], [80, "ProfileCreator"], [84, "ProfileID"], ["Header", "ProfileHeader"], ["MS00", "WCSProfiles"], ["bTRC", "BlueTRC"], ["bXYZ", "BlueMatrixColumn"], ["bfd", "UCRBG"], ["bkpt", "MediaBlackPoint"], ["calt", "CalibrationDateTime"], ["chad", "ChromaticAdaptation"], ["chrm", "Chromaticity"], ["ciis", "ColorimetricIntentImageState"], ["clot", "ColorantTableOut"], ["clro", "ColorantOrder"], ["clrt", "ColorantTable"], ["cprt", "ProfileCopyright"], ["crdi", "CRDInfo"], ["desc", "ProfileDescription"], ["devs", "DeviceSettings"], ["dmdd", "DeviceModelDesc"], ["dmnd", "DeviceMfgDesc"], ["dscm", "ProfileDescriptionML"], ["fpce", "FocalPlaneColorimetryEstimates"], ["gTRC", "GreenTRC"], ["gXYZ", "GreenMatrixColumn"], ["gamt", "Gamut"], ["kTRC", "GrayTRC"], ["lumi", "Luminance"], ["meas", "Measurement"], ["meta", "Metadata"], ["mmod", "MakeAndModel"], ["ncl2", "NamedColor2"], ["ncol", "NamedColor"], ["ndin", "NativeDisplayInfo"], ["pre0", "Preview0"], ["pre1", "Preview1"], ["pre2", "Preview2"], ["ps2i", "PS2RenderingIntent"], ["ps2s", "PostScript2CSA"], ["psd0", "PostScript2CRD0"], ["psd1", "PostScript2CRD1"], ["psd2", "PostScript2CRD2"], ["psd3", "PostScript2CRD3"], ["pseq", "ProfileSequenceDesc"], ["psid", "ProfileSequenceIdentifier"], ["psvm", "PS2CRDVMSize"], ["rTRC", "RedTRC"], ["rXYZ", "RedMatrixColumn"], ["resp", "OutputResponse"], ["rhoc", "ReflectionHardcopyOrigColorimetry"], ["rig0", "PerceptualRenderingIntentGamut"], ["rig2", "SaturationRenderingIntentGamut"], ["rpoc", "ReflectionPrintOutputColorimetry"], ["sape", "SceneAppearanceEstimates"], ["scoe", "SceneColorimetryEstimates"], ["scrd", "ScreeningDesc"], ["scrn", "Screening"], ["targ", "CharTarget"], ["tech", "Technology"], ["vcgt", "VideoCardGamma"], ["view", "ViewingConditions"], ["vued", "ViewingCondDesc"], ["wtpt", "MediaWhitePoint"]]); - var St = { "4d2p": "Erdt Systems", AAMA: "Aamazing Technologies", ACER: "Acer", ACLT: "Acolyte Color Research", ACTI: "Actix Sytems", ADAR: "Adara Technology", ADBE: "Adobe", ADI: "ADI Systems", AGFA: "Agfa Graphics", ALMD: "Alps Electric", ALPS: "Alps Electric", ALWN: "Alwan Color Expertise", AMTI: "Amiable Technologies", AOC: "AOC International", APAG: "Apago", APPL: "Apple Computer", AST: "AST", "AT&T": "AT&T", BAEL: "BARBIERI electronic", BRCO: "Barco NV", BRKP: "Breakpoint", BROT: "Brother", BULL: "Bull", BUS: "Bus Computer Systems", "C-IT": "C-Itoh", CAMR: "Intel", CANO: "Canon", CARR: "Carroll Touch", CASI: "Casio", CBUS: "Colorbus PL", CEL: "Crossfield", CELx: "Crossfield", CGS: "CGS Publishing Technologies International", CHM: "Rochester Robotics", CIGL: "Colour Imaging Group, London", CITI: "Citizen", CL00: "Candela", CLIQ: "Color IQ", CMCO: "Chromaco", CMiX: "CHROMiX", COLO: "Colorgraphic Communications", COMP: "Compaq", COMp: "Compeq/Focus Technology", CONR: "Conrac Display Products", CORD: "Cordata Technologies", CPQ: "Compaq", CPRO: "ColorPro", CRN: "Cornerstone", CTX: "CTX International", CVIS: "ColorVision", CWC: "Fujitsu Laboratories", DARI: "Darius Technology", DATA: "Dataproducts", DCP: "Dry Creek Photo", DCRC: "Digital Contents Resource Center, Chung-Ang University", DELL: "Dell Computer", DIC: "Dainippon Ink and Chemicals", DICO: "Diconix", DIGI: "Digital", "DL&C": "Digital Light & Color", DPLG: "Doppelganger", DS: "Dainippon Screen", DSOL: "DOOSOL", DUPN: "DuPont", EPSO: "Epson", ESKO: "Esko-Graphics", ETRI: "Electronics and Telecommunications Research Institute", EVER: "Everex Systems", EXAC: "ExactCODE", Eizo: "Eizo", FALC: "Falco Data Products", FF: "Fuji Photo Film", FFEI: "FujiFilm Electronic Imaging", FNRD: "Fnord Software", FORA: "Fora", FORE: "Forefront Technology", FP: "Fujitsu", FPA: "WayTech Development", FUJI: "Fujitsu", FX: "Fuji Xerox", GCC: "GCC Technologies", GGSL: "Global Graphics Software", GMB: "Gretagmacbeth", GMG: "GMG", GOLD: "GoldStar Technology", GOOG: "Google", GPRT: "Giantprint", GTMB: "Gretagmacbeth", GVC: "WayTech Development", GW2K: "Sony", HCI: "HCI", HDM: "Heidelberger Druckmaschinen", HERM: "Hermes", HITA: "Hitachi America", HP: "Hewlett-Packard", HTC: "Hitachi", HiTi: "HiTi Digital", IBM: "IBM", IDNT: "Scitex", IEC: "Hewlett-Packard", IIYA: "Iiyama North America", IKEG: "Ikegami Electronics", IMAG: "Image Systems", IMI: "Ingram Micro", INTC: "Intel", INTL: "N/A (INTL)", INTR: "Intra Electronics", IOCO: "Iocomm International Technology", IPS: "InfoPrint Solutions Company", IRIS: "Scitex", ISL: "Ichikawa Soft Laboratory", ITNL: "N/A (ITNL)", IVM: "IVM", IWAT: "Iwatsu Electric", Idnt: "Scitex", Inca: "Inca Digital Printers", Iris: "Scitex", JPEG: "Joint Photographic Experts Group", JSFT: "Jetsoft Development", JVC: "JVC Information Products", KART: "Scitex", KFC: "KFC Computek Components", KLH: "KLH Computers", KMHD: "Konica Minolta", KNCA: "Konica", KODA: "Kodak", KYOC: "Kyocera", Kart: "Scitex", LCAG: "Leica", LCCD: "Leeds Colour", LDAK: "Left Dakota", LEAD: "Leading Technology", LEXM: "Lexmark International", LINK: "Link Computer", LINO: "Linotronic", LITE: "Lite-On", Leaf: "Leaf", Lino: "Linotronic", MAGC: "Mag Computronic", MAGI: "MAG Innovision", MANN: "Mannesmann", MICN: "Micron Technology", MICR: "Microtek", MICV: "Microvitec", MINO: "Minolta", MITS: "Mitsubishi Electronics America", MITs: "Mitsuba", MNLT: "Minolta", MODG: "Modgraph", MONI: "Monitronix", MONS: "Monaco Systems", MORS: "Morse Technology", MOTI: "Motive Systems", MSFT: "Microsoft", MUTO: "MUTOH INDUSTRIES", Mits: "Mitsubishi Electric", NANA: "NANAO", NEC: "NEC", NEXP: "NexPress Solutions", NISS: "Nissei Sangyo America", NKON: "Nikon", NONE: "none", OCE: "Oce Technologies", OCEC: "OceColor", OKI: "Oki", OKID: "Okidata", OKIP: "Okidata", OLIV: "Olivetti", OLYM: "Olympus", ONYX: "Onyx Graphics", OPTI: "Optiquest", PACK: "Packard Bell", PANA: "Matsushita Electric Industrial", PANT: "Pantone", PBN: "Packard Bell", PFU: "PFU", PHIL: "Philips Consumer Electronics", PNTX: "HOYA", POne: "Phase One A/S", PREM: "Premier Computer Innovations", PRIN: "Princeton Graphic Systems", PRIP: "Princeton Publishing Labs", QLUX: "Hong Kong", QMS: "QMS", QPCD: "QPcard AB", QUAD: "QuadLaser", QUME: "Qume", RADI: "Radius", RDDx: "Integrated Color Solutions", RDG: "Roland DG", REDM: "REDMS Group", RELI: "Relisys", RGMS: "Rolf Gierling Multitools", RICO: "Ricoh", RNLD: "Edmund Ronald", ROYA: "Royal", RPC: "Ricoh Printing Systems", RTL: "Royal Information Electronics", SAMP: "Sampo", SAMS: "Samsung", SANT: "Jaime Santana Pomares", SCIT: "Scitex", SCRN: "Dainippon Screen", SDP: "Scitex", SEC: "Samsung", SEIK: "Seiko Instruments", SEIk: "Seikosha", SGUY: "ScanGuy.com", SHAR: "Sharp Laboratories", SICC: "International Color Consortium", SONY: "Sony", SPCL: "SpectraCal", STAR: "Star", STC: "Sampo Technology", Scit: "Scitex", Sdp: "Scitex", Sony: "Sony", TALO: "Talon Technology", TAND: "Tandy", TATU: "Tatung", TAXA: "TAXAN America", TDS: "Tokyo Denshi Sekei", TECO: "TECO Information Systems", TEGR: "Tegra", TEKT: "Tektronix", TI: "Texas Instruments", TMKR: "TypeMaker", TOSB: "Toshiba", TOSH: "Toshiba", TOTK: "TOTOKU ELECTRIC", TRIU: "Triumph", TSBT: "Toshiba", TTX: "TTX Computer Products", TVM: "TVM Professional Monitor", TW: "TW Casper", ULSX: "Ulead Systems", UNIS: "Unisys", UTZF: "Utz Fehlau & Sohn", VARI: "Varityper", VIEW: "Viewsonic", VISL: "Visual communication", VIVO: "Vivo Mobile Communication", WANG: "Wang", WLBR: "Wilbur Imaging", WTG2: "Ware To Go", WYSE: "WYSE Technology", XERX: "Xerox", XRIT: "X-Rite", ZRAN: "Zoran", Zebr: "Zebra Technologies", appl: "Apple Computer", bICC: "basICColor", berg: "bergdesign", ceyd: "Integrated Color Solutions", clsp: "MacDermid ColorSpan", ds: "Dainippon Screen", dupn: "DuPont", ffei: "FujiFilm Electronic Imaging", flux: "FluxData", iris: "Scitex", kart: "Scitex", lcms: "Little CMS", lino: "Linotronic", none: "none", ob4d: "Erdt Systems", obic: "Medigraph", quby: "Qubyx Sarl", scit: "Scitex", scrn: "Dainippon Screen", sdp: "Scitex", siwi: "SIWI GRAFIKA", yxym: "YxyMaster" }; - var Ct = { scnr: "Scanner", mntr: "Monitor", prtr: "Printer", link: "Device Link", abst: "Abstract", spac: "Color Space Conversion Profile", nmcl: "Named Color", cenc: "ColorEncodingSpace profile", mid: "MultiplexIdentification profile", mlnk: "MultiplexLink profile", mvis: "MultiplexVisualization profile", nkpf: "Nikon Input Device Profile (NON-STANDARD!)" }; - U(B, "icc", [[4, St], [12, Ct], [40, Object.assign({}, St, Ct)], [48, St], [80, St], [64, { 0: "Perceptual", 1: "Relative Colorimetric", 2: "Saturation", 3: "Absolute Colorimetric" }], ["tech", { amd: "Active Matrix Display", crt: "Cathode Ray Tube Display", kpcd: "Photo CD", pmd: "Passive Matrix Display", dcam: "Digital Camera", dcpj: "Digital Cinema Projector", dmpc: "Digital Motion Picture Camera", dsub: "Dye Sublimation Printer", epho: "Electrophotographic Printer", esta: "Electrostatic Printer", flex: "Flexography", fprn: "Film Writer", fscn: "Film Scanner", grav: "Gravure", ijet: "Ink Jet Printer", imgs: "Photo Image Setter", mpfr: "Motion Picture Film Recorder", mpfs: "Motion Picture Film Scanner", offs: "Offset Lithography", pjtv: "Projection Television", rpho: "Photographic Paper Printer", rscn: "Reflective Scanner", silk: "Silkscreen", twax: "Thermal Wax Printer", vidc: "Video Camera", vidm: "Video Monitor" }]]); - var yt = class extends re2 { - static canHandle(e3, t2, i3) { - return 237 === e3.getUint8(t2 + 1) && "Photoshop" === e3.getString(t2 + 4, 9) && void 0 !== this.containsIptc8bim(e3, t2, i3); - } - static headerLength(e3, t2, i3) { - let n3, s2 = this.containsIptc8bim(e3, t2, i3); - if (void 0 !== s2) return n3 = e3.getUint8(t2 + s2 + 7), n3 % 2 != 0 && (n3 += 1), 0 === n3 && (n3 = 4), s2 + 8 + n3; - } - static containsIptc8bim(e3, t2, i3) { - for (let n3 = 0; n3 < i3; n3++) if (this.isIptcSegmentHead(e3, t2 + n3)) return n3; - } - static isIptcSegmentHead(e3, t2) { - return 56 === e3.getUint8(t2) && 943868237 === e3.getUint32(t2) && 1028 === e3.getUint16(t2 + 4); - } - parse() { - let { raw: e3 } = this, t2 = this.chunk.byteLength - 1, i3 = false; - for (let n3 = 0; n3 < t2; n3++) if (28 === this.chunk.getUint8(n3) && 2 === this.chunk.getUint8(n3 + 1)) { - i3 = true; - let t3 = this.chunk.getUint16(n3 + 3), s2 = this.chunk.getUint8(n3 + 2), r2 = this.chunk.getLatin1String(n3 + 5, t3); - e3.set(s2, this.pluralizeValue(e3.get(s2), r2)), n3 += 4 + t3; - } else if (i3) break; - return this.translate(), this.output; + return images; } - pluralizeValue(e3, t2) { - return void 0 !== e3 ? e3 instanceof Array ? (e3.push(t2), e3) : [e3, t2] : t2; + function filterSequences(sequences) { + const showsPano = context.photos().showsPanoramic(); + const showsFlat = context.photos().showsFlat(); + const fromDate = context.photos().fromDate(); + const toDate = context.photos().toDate(); + if (!showsPano || !showsFlat) { + sequences = sequences.filter(function(sequence) { + if (sequence.properties.hasOwnProperty("is_pano")) { + if (sequence.properties.is_pano) return showsPano; + return showsFlat; + } + return false; + }); + } + if (fromDate) { + sequences = sequences.filter(function(sequence) { + return new Date(sequence.properties.captured_at).getTime() >= new Date(fromDate).getTime().toString(); + }); + } + if (toDate) { + sequences = sequences.filter(function(sequence) { + return new Date(sequence.properties.captured_at).getTime() <= new Date(toDate).getTime().toString(); + }); + } + return sequences; } - }; - c(yt, "type", "iptc"), c(yt, "translateValues", false), c(yt, "reviveValues", false), T.set("iptc", yt), U(E, "iptc", [[0, "ApplicationRecordVersion"], [3, "ObjectTypeReference"], [4, "ObjectAttributeReference"], [5, "ObjectName"], [7, "EditStatus"], [8, "EditorialUpdate"], [10, "Urgency"], [12, "SubjectReference"], [15, "Category"], [20, "SupplementalCategories"], [22, "FixtureIdentifier"], [25, "Keywords"], [26, "ContentLocationCode"], [27, "ContentLocationName"], [30, "ReleaseDate"], [35, "ReleaseTime"], [37, "ExpirationDate"], [38, "ExpirationTime"], [40, "SpecialInstructions"], [42, "ActionAdvised"], [45, "ReferenceService"], [47, "ReferenceDate"], [50, "ReferenceNumber"], [55, "DateCreated"], [60, "TimeCreated"], [62, "DigitalCreationDate"], [63, "DigitalCreationTime"], [65, "OriginatingProgram"], [70, "ProgramVersion"], [75, "ObjectCycle"], [80, "Byline"], [85, "BylineTitle"], [90, "City"], [92, "Sublocation"], [95, "State"], [100, "CountryCode"], [101, "Country"], [103, "OriginalTransmissionReference"], [105, "Headline"], [110, "Credit"], [115, "Source"], [116, "CopyrightNotice"], [118, "Contact"], [120, "Caption"], [121, "LocalCaption"], [122, "Writer"], [125, "RasterizedCaption"], [130, "ImageType"], [131, "ImageOrientation"], [135, "LanguageIdentifier"], [150, "AudioType"], [151, "AudioSamplingRate"], [152, "AudioSamplingResolution"], [153, "AudioDuration"], [154, "AudioOutcue"], [184, "JobID"], [185, "MasterDocumentID"], [186, "ShortDocumentID"], [187, "UniqueDocumentID"], [188, "OwnerID"], [200, "ObjectPreviewFileFormat"], [201, "ObjectPreviewFileVersion"], [202, "ObjectPreviewData"], [221, "Prefs"], [225, "ClassifyState"], [228, "SimilarityIndex"], [230, "DocumentNotes"], [231, "DocumentHistory"], [232, "ExifCameraInfo"], [255, "CatalogSets"]]), U(B, "iptc", [[10, { 0: "0 (reserved)", 1: "1 (most urgent)", 2: "2", 3: "3", 4: "4", 5: "5 (normal urgency)", 6: "6", 7: "7", 8: "8 (least urgent)", 9: "9 (user-defined priority)" }], [75, { a: "Morning", b: "Both Morning and Evening", p: "Evening" }], [131, { L: "Landscape", P: "Portrait", S: "Square" }]]); - var full_esm_default = tt; - - // modules/services/plane_photo.js - var dispatch5 = dispatch_default("viewerChanged"); - var _photo; - var _wrapper; - var imgZoom; - var _widthOverflow; - function zoomPan(d3_event) { - let t2 = d3_event.transform; - _photo.call(utilSetTransform, t2.x, t2.y, t2.k); - } - function zoomBeahvior() { - const { width: wrapperWidth, height: wrapperHeight } = _wrapper.node().getBoundingClientRect(); - const { naturalHeight, naturalWidth } = _photo.node(); - const intrinsicRatio = naturalWidth / naturalHeight; - _widthOverflow = wrapperHeight * intrinsicRatio - wrapperWidth; - return zoom_default2().extent([[0, 0], [wrapperWidth, wrapperHeight]]).translateExtent([[0, 0], [wrapperWidth + _widthOverflow, wrapperHeight]]).scaleExtent([1, 15]).on("zoom", zoomPan); - } - function loadImage(selection2, path) { - return new Promise((resolve) => { - selection2.attr("src", path); - selection2.on("load", () => { - resolve(selection2); + function update() { + const z2 = ~~context.map().zoom(); + const showMarkers = z2 >= minMarkerZoom; + const showViewfields = z2 >= minViewfieldZoom2; + const service = getService(); + let sequences = service ? service.sequences(projection2) : []; + let images = service && showMarkers ? service.images(projection2) : []; + dispatch14.call("photoDatesChanged", this, "mapillary", [...images.map((p2) => p2.captured_at), ...sequences.map((s2) => s2.properties.captured_at)]); + images = filterImages(images); + sequences = filterSequences(sequences, service); + service.filterViewer(context); + let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) { + return d2.properties.id; }); - }); - } - var plane_photo_default = { - init: async function(context, selection2) { - this.event = utilRebind(this, dispatch5, "on"); - _wrapper = selection2.append("div").attr("class", "photo-frame plane-frame").classed("hide", true); - _photo = _wrapper.append("img").attr("class", "plane-photo"); - context.ui().photoviewer.on("resize.plane", () => { - imgZoom = zoomBeahvior(); - _wrapper.call(imgZoom); + traces.exit().remove(); + traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson); + const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) { + return d2.id; }); - await Promise.resolve(); - return this; - }, - showPhotoFrame: function(context) { - const isHidden = context.selectAll(".photo-frame.plane-frame.hide").size(); - if (isHidden) { - context.selectAll(".photo-frame:not(.plane-frame)").classed("hide", true); - context.selectAll(".photo-frame.plane-frame").classed("hide", false); + groups.exit().remove(); + const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click); + groupsEnter.append("g").attr("class", "viewfield-scale"); + const markers = groups.merge(groupsEnter).sort(function(a2, b2) { + return b2.loc[1] - a2.loc[1]; + }).attr("transform", transform2).select(".viewfield-scale"); + markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6"); + const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []); + viewfields.exit().remove(); + viewfields.enter().insert("path", "circle").attr("class", "viewfield").classed("pano", function() { + return this.parentNode.__data__.is_pano; + }).attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath); + function viewfieldPath() { + if (this.parentNode.__data__.is_pano) { + return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0"; + } else { + return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z"; + } } + } + function drawImages(selection2) { + const enabled = svgMapillaryImages.enabled; + const service = getService(); + layer = selection2.selectAll(".layer-mapillary").data(service ? [0] : []); + layer.exit().remove(); + const layerEnter = layer.enter().append("g").attr("class", "layer-mapillary").style("display", enabled ? "block" : "none"); + layerEnter.append("g").attr("class", "sequences"); + layerEnter.append("g").attr("class", "markers"); + layer = layerEnter.merge(layer); + if (enabled) { + if (service && ~~context.map().zoom() >= minZoom5) { + editOn(); + update(); + service.loadImages(projection2); + } else { + dispatch14.call("photoDatesChanged", this, "mapillary", []); + editOff(); + } + } else { + dispatch14.call("photoDatesChanged", this, "mapillary", []); + } + } + drawImages.enabled = function(_2) { + if (!arguments.length) return svgMapillaryImages.enabled; + svgMapillaryImages.enabled = _2; + if (svgMapillaryImages.enabled) { + showLayer(); + context.photos().on("change.mapillary_images", update); + } else { + hideLayer(); + context.photos().on("change.mapillary_images", null); + } + dispatch14.call("change"); return this; - }, - hidePhotoFrame: function(context) { - context.select("photo-frame.plane-frame").classed("hide", false); - return this; - }, - selectPhoto: function(data) { - dispatch5.call("viewerChanged"); - loadImage(_photo, ""); - loadImage(_photo, data.image_path).then(() => { - imgZoom = zoomBeahvior(); - _wrapper.call(imgZoom); - _wrapper.call(imgZoom.transform, identity2.translate(-_widthOverflow / 2, 0)); - }); - return this; - }, - getYaw: function() { - return 0; + }; + drawImages.supported = function() { + return !!getService(); + }; + drawImages.rendered = function(zoom) { + return zoom >= minZoom5; + }; + init2(); + return drawImages; + } + var init_mapillary_images = __esm({ + "modules/svg/mapillary_images.js"() { + "use strict"; + init_throttle(); + init_src5(); + init_helpers(); + init_services(); } - }; + }); - // modules/svg/local_photos.js - var _initialized2 = false; - var _enabled2 = false; - var minViewfieldZoom = 16; - function svgLocalPhotos(projection2, context, dispatch14) { - const detected = utilDetect(); + // modules/svg/mapillary_position.js + var mapillary_position_exports = {}; + __export(mapillary_position_exports, { + svgMapillaryPosition: () => svgMapillaryPosition + }); + function svgMapillaryPosition(projection2, context) { + const throttledRedraw = throttle_default(function() { + update(); + }, 1e3); + const minZoom5 = 12; + const minViewfieldZoom2 = 18; let layer = select_default2(null); - let _fileList; - let _photos = []; - let _idAutoinc = 0; - let _photoFrame; + let _mapillary; + let viewerCompassAngle; function init2() { - if (_initialized2) return; - _enabled2 = true; - function over(d3_event) { - d3_event.stopPropagation(); - d3_event.preventDefault(); - d3_event.dataTransfer.dropEffect = "copy"; - } - context.container().attr("dropzone", "copy").on("drop.svgLocalPhotos", function(d3_event) { - d3_event.stopPropagation(); - d3_event.preventDefault(); - if (!detected.filedrop) return; - drawPhotos.fileList(d3_event.dataTransfer.files, (loaded) => { - if (loaded.length > 0) { - drawPhotos.fitZoom(false); - } - }); - }).on("dragenter.svgLocalPhotos", over).on("dragexit.svgLocalPhotos", over).on("dragover.svgLocalPhotos", over); - _initialized2 = true; - } - function ensureViewerLoaded(context2) { - if (_photoFrame) { - return Promise.resolve(_photoFrame); - } - 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 photo-attribution-dual fillD"); - return plane_photo_default.init(context2, viewerEnter).then((planePhotoFrame) => { - _photoFrame = planePhotoFrame; - }); + if (svgMapillaryPosition.initialized) return; + svgMapillaryPosition.initialized = true; } - function click(d3_event, image, zoomTo) { - ensureViewerLoaded(context).then(() => { - 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); - } - _photoFrame.selectPhoto({ image_path: "" }); - image.getSrc().then((src) => { - _photoFrame.selectPhoto({ image_path: src }).showPhotoFrame(viewerWrap); - setStyles(); + function getService() { + if (services.mapillary && !_mapillary) { + _mapillary = services.mapillary; + _mapillary.event.on("imageChanged", throttledRedraw); + _mapillary.event.on("bearingChanged", function(e3) { + viewerCompassAngle = e3.bearing; + if (context.map().isTransformed()) return; + layer.selectAll(".viewfield-group.currentView").filter(function(d2) { + return d2.is_pano; + }).attr("transform", transform2); }); - }); - if (zoomTo) { - context.map().centerEase(image.loc); + } else if (!services.mapillary && _mapillary) { + _mapillary = null; } + return _mapillary; } - function transform2(d2) { - var svgpoint = projection2(d2.loc); - return "translate(" + svgpoint[0] + "," + svgpoint[1] + ")"; + function editOn() { + layer.style("display", "block"); } - function setStyles(hovered) { - const viewer = context.container().select(".photoviewer"); - const selected = viewer.empty() ? void 0 : viewer.datum(); - context.container().selectAll(".layer-local-photos .viewfield-group").classed("hovered", (d2) => d2.id === (hovered == null ? void 0 : hovered.id)).classed("highlighted", (d2) => d2.id === (hovered == null ? void 0 : hovered.id) || d2.id === (selected == null ? void 0 : selected.id)).classed("currentView", (d2) => d2.id === (selected == null ? void 0 : selected.id)); + function editOff() { + layer.selectAll(".viewfield-group").remove(); + layer.style("display", "none"); } - function display_markers(imageList) { - imageList = imageList.filter((image) => isArray_default(image.loc) && isNumber_default(image.loc[0]) && isNumber_default(image.loc[1])); - const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(imageList, function(d2) { + function transform2(d2) { + let t2 = svgPointTransform(projection2)(d2); + if (d2.is_pano && viewerCompassAngle !== null && isFinite(viewerCompassAngle)) { + t2 += " rotate(" + Math.floor(viewerCompassAngle) + ",0,0)"; + } else if (d2.ca) { + t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)"; + } + return t2; + } + function update() { + const z2 = ~~context.map().zoom(); + const showViewfields = z2 >= minViewfieldZoom2; + const service = getService(); + const image = service && service.getActiveImage(); + const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(image ? [image] : [], function(d2) { return d2.id; }); groups.exit().remove(); - const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", (d3_event, d2) => setStyles(d2)).on("mouseleave", () => setStyles(null)).on("click", click); + const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group currentView highlighted"); groupsEnter.append("g").attr("class", "viewfield-scale"); const markers = groups.merge(groupsEnter).attr("transform", transform2).select(".viewfield-scale"); markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6"); - const showViewfields = context.map().zoom() >= minViewfieldZoom; const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []); viewfields.exit().remove(); - viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", function() { - var _a4; - const d2 = this.parentNode.__data__; - return "rotate(".concat(Math.round((_a4 = d2.direction) != null ? _a4 : 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"; - }); + viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z"); } - function drawPhotos(selection2) { - layer = selection2.selectAll(".layer-local-photos").data(_photos ? [0] : []); + function drawImages(selection2) { + const service = getService(); + layer = selection2.selectAll(".layer-mapillary-position").data(service ? [0] : []); layer.exit().remove(); - const layerEnter = layer.enter().append("g").attr("class", "layer-local-photos"); + const layerEnter = layer.enter().append("g").attr("class", "layer-mapillary-position"); layerEnter.append("g").attr("class", "markers"); layer = layerEnter.merge(layer); - if (_photos) { - display_markers(_photos); - } - } - function readFileAsDataURL(file) { - return new Promise((resolve, reject) => { - const reader = new FileReader(); - reader.onload = () => resolve(reader.result); - reader.onerror = (error) => reject(error); - reader.readAsDataURL(file); - }); - } - async function readmultifiles(files, callback) { - const loaded = []; - for (const file of files) { - try { - const exifData = await full_esm_default.parse(file); - const photo = { - id: _idAutoinc++, - name: file.name, - getSrc: () => readFileAsDataURL(file), - file, - loc: [exifData.longitude, exifData.latitude], - direction: exifData.GPSImgDirection, - date: exifData.CreateDate || exifData.DateTimeOriginal || exifData.ModifyDate - }; - loaded.push(photo); - const sameName = _photos.filter((i3) => i3.name === photo.name); - if (sameName.length === 0) { - _photos.push(photo); - } else { - const thisContent = await photo.getSrc(); - const sameNameContent = await Promise.allSettled(sameName.map((i3) => i3.getSrc())); - if (!sameNameContent.some((i3) => i3.value === thisContent)) { - _photos.push(photo); - } - } - } catch (e3) { - } + if (service && ~~context.map().zoom() >= minZoom5) { + editOn(); + update(); + } else { + editOff(); } - if (typeof callback === "function") callback(loaded); - dispatch14.call("change"); } - drawPhotos.setFiles = function(fileList, callback) { - readmultifiles(Array.from(fileList), callback); + drawImages.enabled = function() { + update(); return this; }; - drawPhotos.fileList = function(fileList, callback) { - if (!arguments.length) return _fileList; - _fileList = fileList; - if (!fileList || !fileList.length) return this; - drawPhotos.setFiles(_fileList, callback); - return this; + drawImages.supported = function() { + return !!getService(); }; - drawPhotos.getPhotos = function() { - return _photos; + drawImages.rendered = function(zoom) { + return zoom >= minZoom5; }; - drawPhotos.removePhoto = function(id2) { - _photos = _photos.filter((i3) => i3.id !== id2); + init2(); + return drawImages; + } + var init_mapillary_position = __esm({ + "modules/svg/mapillary_position.js"() { + "use strict"; + init_throttle(); + init_src5(); + init_helpers(); + init_services(); + } + }); + + // modules/svg/mapillary_signs.js + var mapillary_signs_exports = {}; + __export(mapillary_signs_exports, { + svgMapillarySigns: () => svgMapillarySigns + }); + function svgMapillarySigns(projection2, context, dispatch14) { + const throttledRedraw = throttle_default(function() { dispatch14.call("change"); - return _photos; - }; - drawPhotos.openPhoto = click; - drawPhotos.fitZoom = function(force) { - const coords = _photos.map((image) => image.loc).filter((l2) => isArray_default(l2) && isNumber_default(l2[0]) && isNumber_default(l2[1])); - if (coords.length === 0) return; - const extent = coords.map((l2) => geoExtent(l2, l2)).reduce((a2, b2) => a2.extend(b2)); - const map2 = context.map(); - var viewport = map2.trimmedExtent().polygon(); - if (force !== false || !geoPolygonIntersectsPolygon(viewport, coords, true)) { - map2.centerZoom(extent.center(), Math.min(18, map2.trimmedExtentZoom(extent))); + }, 1e3); + const minZoom5 = 12; + let layer = select_default2(null); + let _mapillary; + function init2() { + if (svgMapillarySigns.initialized) return; + svgMapillarySigns.enabled = false; + svgMapillarySigns.initialized = true; + } + function getService() { + if (services.mapillary && !_mapillary) { + _mapillary = services.mapillary; + _mapillary.event.on("loadedSigns", throttledRedraw); + } else if (!services.mapillary && _mapillary) { + _mapillary = null; } - }; + return _mapillary; + } function showLayer() { + const service = getService(); + if (!service) return; + service.loadSignResources(context); + editOn(); + } + function hideLayer() { + throttledRedraw.cancel(); + editOff(); + } + function editOn() { layer.style("display", "block"); - layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() { - dispatch14.call("change"); + } + function editOff() { + layer.selectAll(".icon-sign").remove(); + layer.style("display", "none"); + } + function click(d3_event, d2) { + const service = getService(); + if (!service) return; + context.map().centerEase(d2.loc); + const selectedImageId = service.getActiveImage() && service.getActiveImage().id; + service.getDetections(d2.id).then((detections) => { + if (detections.length) { + const imageId = detections[0].image.id; + if (imageId === selectedImageId) { + service.highlightDetection(detections[0]).selectImage(context, imageId); + } else { + service.ensureViewerLoaded(context).then(function() { + service.highlightDetection(detections[0]).selectImage(context, imageId).showViewer(context); + }); + } + } }); } - function hideLayer() { - layer.transition().duration(250).style("opacity", 0).on("end", () => { - layer.selectAll(".viewfield-group").remove(); - layer.style("display", "none"); + function filterData(detectedFeatures) { + var fromDate = context.photos().fromDate(); + var toDate = context.photos().toDate(); + if (fromDate) { + var fromTimestamp = new Date(fromDate).getTime(); + detectedFeatures = detectedFeatures.filter(function(feature3) { + return new Date(feature3.last_seen_at).getTime() >= fromTimestamp; + }); + } + if (toDate) { + var toTimestamp = new Date(toDate).getTime(); + detectedFeatures = detectedFeatures.filter(function(feature3) { + return new Date(feature3.first_seen_at).getTime() <= toTimestamp; + }); + } + return detectedFeatures; + } + function update() { + const service = getService(); + let data = service ? service.signs(projection2) : []; + data = filterData(data); + const transform2 = svgPointTransform(projection2); + const signs = layer.selectAll(".icon-sign").data(data, function(d2) { + return d2.id; + }); + signs.exit().remove(); + const enter = signs.enter().append("g").attr("class", "icon-sign icon-detected").on("click", click); + enter.append("use").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px").attr("xlink:href", function(d2) { + return "#" + d2.value; }); + enter.append("rect").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px"); + signs.merge(enter).attr("transform", transform2); } - drawPhotos.enabled = function(val) { - if (!arguments.length) return _enabled2; - _enabled2 = val; - if (_enabled2) { + function drawSigns(selection2) { + const enabled = svgMapillarySigns.enabled; + const service = getService(); + layer = selection2.selectAll(".layer-mapillary-signs").data(service ? [0] : []); + layer.exit().remove(); + layer = layer.enter().append("g").attr("class", "layer-mapillary-signs layer-mapillary-detections").style("display", enabled ? "block" : "none").merge(layer); + if (enabled) { + if (service && ~~context.map().zoom() >= minZoom5) { + editOn(); + update(); + service.loadSigns(projection2); + service.showSignDetections(true); + } else { + editOff(); + } + } else if (service) { + service.showSignDetections(false); + } + } + drawSigns.enabled = function(_2) { + if (!arguments.length) return svgMapillarySigns.enabled; + svgMapillarySigns.enabled = _2; + if (svgMapillarySigns.enabled) { showLayer(); + context.photos().on("change.mapillary_signs", update); } else { hideLayer(); + context.photos().on("change.mapillary_signs", null); } dispatch14.call("change"); return this; }; - drawPhotos.hasData = function() { - return isArray_default(_photos) && _photos.length > 0; + drawSigns.supported = function() { + return !!getService(); + }; + drawSigns.rendered = function(zoom) { + return zoom >= minZoom5; }; init2(); - return drawPhotos; + return drawSigns; } + var init_mapillary_signs = __esm({ + "modules/svg/mapillary_signs.js"() { + "use strict"; + init_throttle(); + init_src5(); + init_helpers(); + init_services(); + } + }); - // modules/svg/osmose.js - var _layerEnabled2 = false; - var _qaService2; - function svgOsmose(projection2, context, dispatch14) { - const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3); + // modules/svg/mapillary_map_features.js + var mapillary_map_features_exports = {}; + __export(mapillary_map_features_exports, { + svgMapillaryMapFeatures: () => svgMapillaryMapFeatures + }); + function svgMapillaryMapFeatures(projection2, context, dispatch14) { + const throttledRedraw = throttle_default(function() { + dispatch14.call("change"); + }, 1e3); const minZoom5 = 12; - let touchLayer = select_default2(null); - let drawLayer = select_default2(null); - let layerVisible = false; - function markerPath(selection2, klass) { - selection2.attr("class", klass).attr("transform", "translate(-10, -28)").attr("points", "16,3 4,3 1,6 1,17 4,20 7,20 10,27 13,20 16,20 19,17.033 19,6"); + let layer = select_default2(null); + let _mapillary; + function init2() { + if (svgMapillaryMapFeatures.initialized) return; + svgMapillaryMapFeatures.enabled = false; + svgMapillaryMapFeatures.initialized = true; } function getService() { - if (services.osmose && !_qaService2) { - _qaService2 = services.osmose; - _qaService2.on("loaded", throttledRedraw); - } else if (!services.osmose && _qaService2) { - _qaService2 = null; + if (services.mapillary && !_mapillary) { + _mapillary = services.mapillary; + _mapillary.event.on("loadedMapFeatures", throttledRedraw); + } else if (!services.mapillary && _mapillary) { + _mapillary = null; } - return _qaService2; + return _mapillary; + } + function showLayer() { + const service = getService(); + if (!service) return; + service.loadObjectResources(context); + editOn(); + } + function hideLayer() { + throttledRedraw.cancel(); + editOff(); } function editOn() { - if (!layerVisible) { - layerVisible = true; - drawLayer.style("display", "block"); - } + layer.style("display", "block"); } function editOff() { - if (layerVisible) { - layerVisible = false; - drawLayer.style("display", "none"); - drawLayer.selectAll(".qaItem.osmose").remove(); - touchLayer.selectAll(".qaItem.osmose").remove(); - } - } - function layerOn() { - editOn(); - drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", () => dispatch14.call("change")); + layer.selectAll(".icon-map-feature").remove(); + layer.style("display", "none"); } - function layerOff() { - throttledRedraw.cancel(); - drawLayer.interrupt(); - touchLayer.selectAll(".qaItem.osmose").remove(); - drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", () => { - editOff(); - dispatch14.call("change"); + function click(d3_event, d2) { + const service = getService(); + if (!service) return; + context.map().centerEase(d2.loc); + const selectedImageId = service.getActiveImage() && service.getActiveImage().id; + service.getDetections(d2.id).then((detections) => { + if (detections.length) { + const imageId = detections[0].image.id; + if (imageId === selectedImageId) { + service.highlightDetection(detections[0]).selectImage(context, imageId); + } else { + service.ensureViewerLoaded(context).then(function() { + service.highlightDetection(detections[0]).selectImage(context, imageId).showViewer(context); + }); + } + } }); } - function updateMarkers() { - if (!layerVisible || !_layerEnabled2) return; - const service = getService(); - const selectedID = context.selectedErrorID(); - const data = service ? service.getItems(projection2) : []; - const getTransform = svgPointTransform(projection2); - const markers = drawLayer.selectAll(".qaItem.osmose").data(data, (d2) => d2.id); - markers.exit().remove(); - const markersEnter = markers.enter().append("g").attr("class", (d2) => "qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.itemType)); - markersEnter.append("polygon").call(markerPath, "shadow"); - markersEnter.append("ellipse").attr("cx", 0).attr("cy", 0).attr("rx", 4.5).attr("ry", 2).attr("class", "stroke"); - markersEnter.append("polygon").attr("fill", (d2) => service.getColor(d2.item)).call(markerPath, "qaItem-fill"); - markersEnter.append("use").attr("class", "icon-annotation").attr("transform", "translate(-6, -22)").attr("width", "12px").attr("height", "12px").attr("xlink:href", (d2) => d2.icon ? "#" + d2.icon : ""); - markers.merge(markersEnter).sort(sortY).classed("selected", (d2) => d2.id === selectedID).attr("transform", getTransform); - if (touchLayer.empty()) return; - const fillClass = context.getDebug("target") ? "pink" : "nocolor"; - const targets = touchLayer.selectAll(".qaItem.osmose").data(data, (d2) => d2.id); - targets.exit().remove(); - targets.enter().append("rect").attr("width", "20px").attr("height", "30px").attr("x", "-10px").attr("y", "-28px").merge(targets).sort(sortY).attr("class", (d2) => "qaItem ".concat(d2.service, " target ").concat(fillClass, " itemId-").concat(d2.id)).attr("transform", getTransform); - function sortY(a2, b2) { - return a2.id === selectedID ? 1 : b2.id === selectedID ? -1 : b2.loc[1] - a2.loc[1]; + function filterData(detectedFeatures) { + const fromDate = context.photos().fromDate(); + const toDate = context.photos().toDate(); + if (fromDate) { + detectedFeatures = detectedFeatures.filter(function(feature3) { + return new Date(feature3.last_seen_at).getTime() >= new Date(fromDate).getTime(); + }); + } + if (toDate) { + detectedFeatures = detectedFeatures.filter(function(feature3) { + return new Date(feature3.first_seen_at).getTime() <= new Date(toDate).getTime(); + }); } + return detectedFeatures; } - function drawOsmose(selection2) { + function update() { const service = getService(); - const surface = context.surface(); - if (surface && !surface.empty()) { - touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers"); - } - drawLayer = selection2.selectAll(".layer-osmose").data(service ? [0] : []); - drawLayer.exit().remove(); - drawLayer = drawLayer.enter().append("g").attr("class", "layer-osmose").style("display", _layerEnabled2 ? "block" : "none").merge(drawLayer); - if (_layerEnabled2) { + let data = service ? service.mapFeatures(projection2) : []; + data = filterData(data); + const transform2 = svgPointTransform(projection2); + const mapFeatures = layer.selectAll(".icon-map-feature").data(data, function(d2) { + return d2.id; + }); + mapFeatures.exit().remove(); + const enter = mapFeatures.enter().append("g").attr("class", "icon-map-feature icon-detected").on("click", click); + enter.append("title").text(function(d2) { + var id2 = d2.value.replace(/--/g, ".").replace(/-/g, "_"); + return _t("mapillary_map_features." + id2); + }); + enter.append("use").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px").attr("xlink:href", function(d2) { + if (d2.value === "object--billboard") { + return "#object--sign--advertisement"; + } + return "#" + d2.value; + }); + enter.append("rect").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px"); + mapFeatures.merge(enter).attr("transform", transform2); + } + function drawMapFeatures(selection2) { + const enabled = svgMapillaryMapFeatures.enabled; + const service = getService(); + layer = selection2.selectAll(".layer-mapillary-map-features").data(service ? [0] : []); + layer.exit().remove(); + layer = layer.enter().append("g").attr("class", "layer-mapillary-map-features layer-mapillary-detections").style("display", enabled ? "block" : "none").merge(layer); + if (enabled) { if (service && ~~context.map().zoom() >= minZoom5) { editOn(); - service.loadIssues(projection2); - updateMarkers(); + update(); + service.loadMapFeatures(projection2); + service.showFeatureDetections(true); } else { editOff(); } + } else if (service) { + service.showFeatureDetections(false); } } - drawOsmose.enabled = function(val) { - if (!arguments.length) return _layerEnabled2; - _layerEnabled2 = val; - if (_layerEnabled2) { - getService().loadStrings().then(layerOn).catch((err) => { - console.log(err); - }); + drawMapFeatures.enabled = function(_2) { + if (!arguments.length) return svgMapillaryMapFeatures.enabled; + svgMapillaryMapFeatures.enabled = _2; + if (svgMapillaryMapFeatures.enabled) { + showLayer(); + context.photos().on("change.mapillary_map_features", update); } else { - layerOff(); - if (context.selectedErrorID()) { - context.enter(modeBrowse(context)); - } + hideLayer(); + context.photos().on("change.mapillary_map_features", null); } dispatch14.call("change"); return this; }; - drawOsmose.supported = () => !!getService(); - return drawOsmose; + drawMapFeatures.supported = function() { + return !!getService(); + }; + drawMapFeatures.rendered = function(zoom) { + return zoom >= minZoom5; + }; + init2(); + return drawMapFeatures; } + var init_mapillary_map_features = __esm({ + "modules/svg/mapillary_map_features.js"() { + "use strict"; + init_throttle(); + init_src5(); + init_helpers(); + init_services(); + init_localizer(); + } + }); - // modules/svg/streetside.js - function svgStreetside(projection2, context, dispatch14) { + // modules/svg/kartaview_images.js + var kartaview_images_exports = {}; + __export(kartaview_images_exports, { + svgKartaviewImages: () => svgKartaviewImages + }); + function svgKartaviewImages(projection2, context, dispatch14) { var throttledRedraw = throttle_default(function() { dispatch14.call("change"); }, 1e3); - var minZoom5 = 14; + var minZoom5 = 12; var minMarkerZoom = 16; var minViewfieldZoom2 = 18; var layer = select_default2(null); - var _viewerYaw = 0; - var _selectedSequence = null; - var _streetside; + var _kartaview; function init2() { - if (svgStreetside.initialized) return; - svgStreetside.enabled = false; - svgStreetside.initialized = true; + if (svgKartaviewImages.initialized) return; + svgKartaviewImages.enabled = false; + svgKartaviewImages.initialized = true; } function getService() { - if (services.streetside && !_streetside) { - _streetside = services.streetside; - _streetside.event.on("viewerChanged.svgStreetside", viewerChanged).on("loadedImages.svgStreetside", throttledRedraw); - } else if (!services.streetside && _streetside) { - _streetside = null; + if (services.kartaview && !_kartaview) { + _kartaview = services.kartaview; + _kartaview.event.on("loadedImages", throttledRedraw); + } else if (!services.kartaview && _kartaview) { + _kartaview = null; } - return _streetside; + return _kartaview; } function showLayer() { var service = getService(); @@ -53552,12 +55991,8 @@ function click(d3_event, d2) { var service = getService(); if (!service) return; - if (d2.sequenceKey !== _selectedSequence) { - _viewerYaw = 0; - } - _selectedSequence = d2.sequenceKey; service.ensureViewerLoaded(context).then(function() { - service.selectImage(context, d2.key).yaw(_viewerYaw).showViewer(context); + service.selectImage(context, d2.key).showViewer(context); }); context.map().centerEase(d2.loc); } @@ -53571,43 +56006,33 @@ } function transform2(d2) { var t2 = svgPointTransform(projection2)(d2); - var rot = d2.ca + _viewerYaw; - if (rot) { - t2 += " rotate(" + Math.floor(rot) + ",0,0)"; + if (d2.ca) { + t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)"; } return t2; } - function viewerChanged() { - var service = getService(); - if (!service) return; - var viewer = service.viewer(); - if (!viewer) return; - _viewerYaw = viewer.getYaw(); - if (context.map().isTransformed()) return; - layer.selectAll(".viewfield-group.currentView").attr("transform", transform2); - } - function filterBubbles(bubbles) { + function filterImages(images) { var fromDate = context.photos().fromDate(); var toDate = context.photos().toDate(); var usernames = context.photos().usernames(); if (fromDate) { var fromTimestamp = new Date(fromDate).getTime(); - bubbles = bubbles.filter(function(bubble) { - return new Date(bubble.captured_at).getTime() >= fromTimestamp; + images = images.filter(function(item) { + return new Date(item.captured_at).getTime() >= fromTimestamp; }); } if (toDate) { var toTimestamp = new Date(toDate).getTime(); - bubbles = bubbles.filter(function(bubble) { - return new Date(bubble.captured_at).getTime() <= toTimestamp; + images = images.filter(function(item) { + return new Date(item.captured_at).getTime() <= toTimestamp; }); } if (usernames) { - bubbles = bubbles.filter(function(bubble) { - return usernames.indexOf(bubble.captured_by) !== -1; + images = images.filter(function(item) { + return usernames.indexOf(item.captured_by) !== -1; }); } - return bubbles; + return images; } function filterSequences(sequences) { var fromDate = context.photos().fromDate(); @@ -53615,19 +56040,19 @@ var usernames = context.photos().usernames(); if (fromDate) { var fromTimestamp = new Date(fromDate).getTime(); - sequences = sequences.filter(function(sequences2) { - return new Date(sequences2.properties.captured_at).getTime() >= fromTimestamp; + sequences = sequences.filter(function(sequence) { + return new Date(sequence.properties.captured_at).getTime() >= fromTimestamp; }); } if (toDate) { var toTimestamp = new Date(toDate).getTime(); - sequences = sequences.filter(function(sequences2) { - return new Date(sequences2.properties.captured_at).getTime() <= toTimestamp; + sequences = sequences.filter(function(sequence) { + return new Date(sequence.properties.captured_at).getTime() <= toTimestamp; }); } if (usernames) { - sequences = sequences.filter(function(sequences2) { - return usernames.indexOf(sequences2.properties.captured_by) !== -1; + sequences = sequences.filter(function(sequence) { + return usernames.indexOf(sequence.properties.captured_by) !== -1; }); } return sequences; @@ -53640,20 +56065,19 @@ var showViewfields = z2 >= minViewfieldZoom2; var service = getService(); var sequences = []; - var bubbles = []; - if (context.photos().showsPanoramic()) { - sequences = service ? service.sequences(projection2) : []; - bubbles = service && showMarkers ? service.bubbles(projection2) : []; - sequences = filterSequences(sequences); - bubbles = filterBubbles(bubbles); - } + var images = []; + sequences = service ? service.sequences(projection2) : []; + images = service && showMarkers ? service.images(projection2) : []; + dispatch14.call("photoDatesChanged", this, "kartaview", [...images.map((p2) => p2.captured_at), ...sequences.map((s2) => s2.properties.captured_at)]); + sequences = filterSequences(sequences); + images = filterImages(images); var traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) { return d2.properties.key; }); traces.exit().remove(); traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson); - var groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(bubbles, function(d2) { - return d2.key + (d2.sequenceKey ? "v1" : "v0"); + var groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) { + return d2.key; }); groups.exit().remove(); var groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click); @@ -53664,22 +56088,13 @@ markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6"); var viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []); viewfields.exit().remove(); - viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath); - function viewfieldPath() { - var d2 = this.parentNode.__data__; - if (d2.pano) { - return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0"; - } else { - return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z"; - } - } + viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z"); } function drawImages(selection2) { - var enabled = svgStreetside.enabled; - var service = getService(); - layer = selection2.selectAll(".layer-streetside-images").data(service ? [0] : []); + var enabled = svgKartaviewImages.enabled, service = getService(); + layer = selection2.selectAll(".layer-kartaview").data(service ? [0] : []); layer.exit().remove(); - var layerEnter = layer.enter().append("g").attr("class", "layer-streetside-images").style("display", enabled ? "block" : "none"); + var layerEnter = layer.enter().append("g").attr("class", "layer-kartaview").style("display", enabled ? "block" : "none"); layerEnter.append("g").attr("class", "sequences"); layerEnter.append("g").attr("class", "markers"); layer = layerEnter.merge(layer); @@ -53687,21 +56102,24 @@ if (service && ~~context.map().zoom() >= minZoom5) { editOn(); update(); - service.loadBubbles(projection2); + service.loadImages(projection2); } else { + dispatch14.call("photoDatesChanged", this, "kartaview", []); editOff(); } + } else { + dispatch14.call("photoDatesChanged", this, "kartaview", []); } } drawImages.enabled = function(_2) { - if (!arguments.length) return svgStreetside.enabled; - svgStreetside.enabled = _2; - if (svgStreetside.enabled) { + if (!arguments.length) return svgKartaviewImages.enabled; + svgKartaviewImages.enabled = _2; + if (svgKartaviewImages.enabled) { showLayer(); - context.photos().on("change.streetside", update); + context.photos().on("change.kartaview_images", update); } else { hideLayer(); - context.photos().on("change.streetside", null); + context.photos().on("change.kartaview_images", null); } dispatch14.call("change"); return this; @@ -53715,40 +56133,62 @@ init2(); return drawImages; } + var init_kartaview_images = __esm({ + "modules/svg/kartaview_images.js"() { + "use strict"; + init_throttle(); + init_src5(); + init_helpers(); + init_services(); + } + }); - // modules/svg/vegbilder.js - function svgVegbilder(projection2, context, dispatch14) { - const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3); - const minZoom5 = 14; - const minMarkerZoom = 16; - const minViewfieldZoom2 = 18; + // modules/svg/mapilio_images.js + var mapilio_images_exports = {}; + __export(mapilio_images_exports, { + svgMapilioImages: () => svgMapilioImages + }); + function svgMapilioImages(projection2, context, dispatch14) { + const throttledRedraw = throttle_default(function() { + dispatch14.call("change"); + }, 1e3); + const minZoom5 = 12; let layer = select_default2(null); - let _viewerYaw = 0; - let _vegbilder; + let _mapilio; + const viewFieldZoomLevel = 18; function init2() { - if (svgVegbilder.initialized) return; - svgVegbilder.enabled = false; - svgVegbilder.initialized = true; + if (svgMapilioImages.initialized) return; + svgMapilioImages.enabled = false; + svgMapilioImages.initialized = true; } function getService() { - if (services.vegbilder && !_vegbilder) { - _vegbilder = services.vegbilder; - _vegbilder.event.on("viewerChanged.svgVegbilder", viewerChanged).on("loadedImages.svgVegbilder", throttledRedraw); - } else if (!services.vegbilder && _vegbilder) { - _vegbilder = null; + if (services.mapilio && !_mapilio) { + _mapilio = services.mapilio; + _mapilio.event.on("loadedImages", throttledRedraw); + } else if (!services.mapilio && _mapilio) { + _mapilio = null; } - return _vegbilder; + return _mapilio; } function showLayer() { const service = getService(); if (!service) return; editOn(); - layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", () => dispatch14.call("change")); + layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() { + dispatch14.call("change"); + }); } function hideLayer() { throttledRedraw.cancel(); layer.transition().duration(250).style("opacity", 0).on("end", editOff); } + function transform2(d2) { + let t2 = svgPointTransform(projection2)(d2); + if (d2.heading) { + t2 += " rotate(" + Math.floor(d2.heading) + ",0,0)"; + } + return t2; + } function editOn() { layer.style("display", "block"); } @@ -53756,118 +56196,85 @@ layer.selectAll(".viewfield-group").remove(); layer.style("display", "none"); } - function click(d3_event, d2) { + function click(d3_event, image) { const service = getService(); if (!service) return; - service.ensureViewerLoaded(context).then(() => { - service.selectImage(context, d2.key).showViewer(context); + service.ensureViewerLoaded(context, image.id).then(function() { + service.selectImage(context, image.id).showViewer(context); }); - context.map().centerEase(d2.loc); + context.map().centerEase(image.loc); } - function mouseover(d3_event, d2) { + function mouseover(d3_event, image) { const service = getService(); - if (service) service.setStyles(context, d2); + if (service) service.setStyles(context, image); } function mouseout() { const service = getService(); if (service) service.setStyles(context, null); } - function transform2(d2, selected) { - let t2 = svgPointTransform(projection2)(d2); - let rot = d2.ca; - if (d2 === selected) { - rot += _viewerYaw; - } - if (rot) { - t2 += " rotate(" + Math.floor(rot) + ",0,0)"; - } - return t2; - } - function viewerChanged() { - const service = getService(); - if (!service) return; - const frame2 = service.photoFrame(); - _viewerYaw = frame2.getYaw(); - if (context.map().isTransformed()) return; - layer.selectAll(".viewfield-group.currentView").attr("transform", (d2) => transform2(d2, d2)); - } function filterImages(images) { - const photoContext = context.photos(); - const fromDateString = photoContext.fromDate(); - const toDateString = photoContext.toDate(); - const showsFlat = photoContext.showsFlat(); - const showsPano = photoContext.showsPanoramic(); - if (fromDateString) { - const fromDate = new Date(fromDateString); - images = images.filter((image) => image.captured_at.getTime() >= fromDate.getTime()); - } - if (toDateString) { - const toDate = new Date(toDateString); - images = images.filter((image) => image.captured_at.getTime() <= toDate.getTime()); - } - if (!showsPano) { - images = images.filter((image) => !image.is_sphere); + var fromDate = context.photos().fromDate(); + var toDate = context.photos().toDate(); + if (fromDate) { + var fromTimestamp = new Date(fromDate).getTime(); + images = images.filter(function(photo) { + return new Date(photo.capture_time).getTime() >= fromTimestamp; + }); } - if (!showsFlat) { - images = images.filter((image) => image.is_sphere); + if (toDate) { + var toTimestamp = new Date(toDate).getTime(); + images = images.filter(function(photo) { + return new Date(photo.capture_time).getTime() <= toTimestamp; + }); } return images; } function filterSequences(sequences) { - const photoContext = context.photos(); - const fromDateString = photoContext.fromDate(); - const toDateString = photoContext.toDate(); - const showsFlat = photoContext.showsFlat(); - const showsPano = photoContext.showsPanoramic(); - if (fromDateString) { - const fromDate = new Date(fromDateString); - sequences = sequences.filter(({ images }) => images[0].captured_at.getTime() >= fromDate.getTime()); - } - if (toDateString) { - const toDate = new Date(toDateString); - sequences = sequences.filter(({ images }) => images[images.length - 1].captured_at.getTime() <= toDate.getTime()); - } - if (!showsPano) { - sequences = sequences.filter(({ images }) => !images[0].is_sphere); + var fromDate = context.photos().fromDate(); + var toDate = context.photos().toDate(); + if (fromDate) { + var fromTimestamp = new Date(fromDate).getTime(); + sequences = sequences.filter(function(sequence) { + return new Date(sequence.properties.capture_time).getTime() >= fromTimestamp; + }); } - if (!showsFlat) { - sequences = sequences.filter(({ images }) => images[0].is_sphere); + if (toDate) { + var toTimestamp = new Date(toDate).getTime(); + sequences = sequences.filter(function(sequence) { + return new Date(sequence.properties.capture_time).getTime() <= toTimestamp; + }); } return sequences; } function update() { - const viewer = context.container().select(".photoviewer"); - const selected = viewer.empty() ? void 0 : viewer.datum(); const z2 = ~~context.map().zoom(); - const showMarkers = z2 >= minMarkerZoom; - const showViewfields = z2 >= minViewfieldZoom2; + const showViewfields = z2 >= viewFieldZoomLevel; const service = getService(); - let sequences = []; - let images = []; - if (service) { - service.loadImages(context); - sequences = service.sequences(projection2); - images = showMarkers ? service.images(projection2) : []; - images = filterImages(images); - sequences = filterSequences(sequences); - } - let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, (d2) => d2.key); + let sequences = service ? service.sequences(projection2) : []; + let images = service ? service.images(projection2) : []; + dispatch14.call("photoDatesChanged", this, "mapilio", [...images.map((p2) => p2.capture_time), ...sequences.map((s2) => s2.properties.capture_time)]); + sequences = filterSequences(sequences); + images = filterImages(images); + let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) { + return d2.properties.id; + }); traces.exit().remove(); traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson); - const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, (d2) => d2.key); + const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) { + return d2.id; + }); groups.exit().remove(); const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click); groupsEnter.append("g").attr("class", "viewfield-scale"); - const markers = groups.merge(groupsEnter).sort((a2, b2) => { - return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1]; - }).attr("transform", (d2) => transform2(d2, selected)).select(".viewfield-scale"); + const markers = groups.merge(groupsEnter).sort(function(a2, b2) { + return b2.loc[1] - a2.loc[1]; + }).attr("transform", transform2).select(".viewfield-scale"); markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6"); const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []); viewfields.exit().remove(); viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath); function viewfieldPath() { - const d2 = this.parentNode.__data__; - if (d2.is_sphere) { + if (this.parentNode.__data__.isPano) { return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0"; } else { return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z"; @@ -53875,11 +56282,11 @@ } } function drawImages(selection2) { - const enabled = svgVegbilder.enabled; + const enabled = svgMapilioImages.enabled; const service = getService(); - layer = selection2.selectAll(".layer-vegbilder").data(service ? [0] : []); + layer = selection2.selectAll(".layer-mapilio").data(service ? [0] : []); layer.exit().remove(); - const layerEnter = layer.enter().append("g").attr("class", "layer-vegbilder").style("display", enabled ? "block" : "none"); + const layerEnter = layer.enter().append("g").attr("class", "layer-mapilio").style("display", enabled ? "block" : "none"); layerEnter.append("g").attr("class", "sequences"); layerEnter.append("g").attr("class", "markers"); layer = layerEnter.merge(layer); @@ -53887,21 +56294,25 @@ if (service && ~~context.map().zoom() >= minZoom5) { editOn(); update(); - service.loadImages(context); + service.loadImages(projection2); + service.loadLines(projection2); } else { + dispatch14.call("photoDatesChanged", this, "mapilio", []); editOff(); } + } else { + dispatch14.call("photoDatesChanged", this, "mapilio", []); } } drawImages.enabled = function(_2) { - if (!arguments.length) return svgVegbilder.enabled; - svgVegbilder.enabled = _2; - if (svgVegbilder.enabled) { + if (!arguments.length) return svgMapilioImages.enabled; + svgMapilioImages.enabled = _2; + if (svgMapilioImages.enabled) { showLayer(); - context.photos().on("change.vegbilder", update); + context.photos().on("change.mapilio_images", update); } else { hideLayer(); - context.photos().on("change.vegbilder", null); + context.photos().on("change.mapilio_images", null); } dispatch14.call("change"); return this; @@ -53912,36 +56323,125 @@ drawImages.rendered = function(zoom) { return zoom >= minZoom5; }; - drawImages.validHere = function(extent, zoom) { - return zoom >= minZoom5 - 2 && getService().validHere(extent); - }; init2(); return drawImages; } + var init_mapilio_images = __esm({ + "modules/svg/mapilio_images.js"() { + "use strict"; + init_throttle(); + init_src5(); + init_services(); + init_helpers(); + } + }); - // modules/svg/mapillary_images.js - function svgMapillaryImages(projection2, context, dispatch14) { + // modules/svg/panoramax_images.js + var panoramax_images_exports = {}; + __export(panoramax_images_exports, { + svgPanoramaxImages: () => svgPanoramaxImages + }); + function svgPanoramaxImages(projection2, context, dispatch14) { const throttledRedraw = throttle_default(function() { dispatch14.call("change"); }, 1e3); - const minZoom5 = 12; - const minMarkerZoom = 16; - const minViewfieldZoom2 = 18; + const imageMinZoom2 = 15; + const lineMinZoom2 = 10; + const viewFieldZoomLevel = 18; let layer = select_default2(null); - let _mapillary; + let _panoramax; + let _viewerYaw = 0; + let _activeUsernameFilter; + let _activeIds; function init2() { - if (svgMapillaryImages.initialized) return; - svgMapillaryImages.enabled = false; - svgMapillaryImages.initialized = true; + if (svgPanoramaxImages.initialized) return; + svgPanoramaxImages.enabled = false; + svgPanoramaxImages.initialized = true; } function getService() { - if (services.mapillary && !_mapillary) { - _mapillary = services.mapillary; - _mapillary.event.on("loadedImages", throttledRedraw); - } else if (!services.mapillary && _mapillary) { - _mapillary = null; + if (services.panoramax && !_panoramax) { + _panoramax = services.panoramax; + _panoramax.event.on("viewerChanged", viewerChanged).on("loadedLines", throttledRedraw).on("loadedImages", throttledRedraw); + } else if (!services.panoramax && _panoramax) { + _panoramax = null; } - return _mapillary; + return _panoramax; + } + async function filterImages(images) { + const showsPano = context.photos().showsPanoramic(); + const showsFlat = context.photos().showsFlat(); + const fromDate = context.photos().fromDate(); + const toDate = context.photos().toDate(); + const username = context.photos().usernames(); + const service = getService(); + if (!showsPano || !showsFlat) { + images = images.filter(function(image) { + if (image.isPano) return showsPano; + return showsFlat; + }); + } + if (fromDate) { + images = images.filter(function(image) { + return new Date(image.capture_time).getTime() >= new Date(fromDate).getTime(); + }); + } + if (toDate) { + images = images.filter(function(image) { + return new Date(image.capture_time).getTime() <= new Date(toDate).getTime(); + }); + } + if (username && service) { + if (_activeUsernameFilter !== username) { + _activeUsernameFilter = username; + const tempIds = await service.getUserIds(username); + _activeIds = {}; + tempIds.forEach((id2) => { + _activeIds[id2] = true; + }); + } + images = images.filter(function(image) { + return _activeIds[image.account_id]; + }); + } + return images; + } + async function filterSequences(sequences) { + const showsPano = context.photos().showsPanoramic(); + const showsFlat = context.photos().showsFlat(); + const fromDate = context.photos().fromDate(); + const toDate = context.photos().toDate(); + const username = context.photos().usernames(); + const service = getService(); + if (!showsPano || !showsFlat) { + sequences = sequences.filter(function(sequence) { + if (sequence.properties.type === "equirectangular") return showsPano; + return showsFlat; + }); + } + if (fromDate) { + sequences = sequences.filter(function(sequence) { + return new Date(sequence.properties.date).getTime() >= new Date(fromDate).getTime().toString(); + }); + } + if (toDate) { + sequences = sequences.filter(function(sequence) { + return new Date(sequence.properties.date).getTime() <= new Date(toDate).getTime().toString(); + }); + } + if (username && service) { + if (_activeUsernameFilter !== username) { + _activeUsernameFilter = username; + const tempIds = await service.getUserIds(username); + _activeIds = {}; + tempIds.forEach((id2) => { + _activeIds[id2] = true; + }); + } + sequences = sequences.filter(function(sequence) { + return _activeIds[sequence.properties.account_id]; + }); + } + return sequences; } function showLayer() { const service = getService(); @@ -53955,10 +56455,23 @@ throttledRedraw.cancel(); layer.transition().duration(250).style("opacity", 0).on("end", editOff); } + function transform2(d2, selectedImageId) { + let t2 = svgPointTransform(projection2)(d2); + let rot = d2.heading; + if (d2.id === selectedImageId) { + rot += _viewerYaw; + } + if (rot) { + t2 += " rotate(" + Math.floor(rot) + ",0,0)"; + } + return t2; + } function editOn() { layer.style("display", "block"); } function editOff() { + const service = getService(); + service.hideViewer(context); layer.selectAll(".viewfield-group").remove(); layer.style("display", "none"); } @@ -53978,4103 +56491,4733 @@ const service = getService(); if (service) service.setStyles(context, null); } - function transform2(d2) { - let t2 = svgPointTransform(projection2)(d2); - if (d2.ca) { - t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)"; + async function update() { + var _a3; + const zoom = ~~context.map().zoom(); + const showViewfields = zoom >= viewFieldZoomLevel; + const service = getService(); + let sequences = service ? service.sequences(projection2, zoom) : []; + let images = service && zoom >= imageMinZoom2 ? service.images(projection2) : []; + dispatch14.call("photoDatesChanged", this, "panoramax", [...images.map((p2) => p2.capture_time), ...sequences.map((s2) => s2.properties.date)]); + let isHidden = select_default2(".photo-wrapper.panoramax-wrapper.hide").size(); + if (isHidden) service.setActiveImage(null); + images = await filterImages(images); + sequences = await filterSequences(sequences, service); + let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) { + return d2.properties.id; + }); + traces.exit().remove(); + traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson); + const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) { + return d2.id; + }); + groups.exit().remove(); + const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click); + groupsEnter.append("g").attr("class", "viewfield-scale"); + const activeImageId = (_a3 = service.getActiveImage()) == null ? void 0 : _a3.id; + const markers = groups.merge(groupsEnter).sort(function(a2, b2) { + if (a2.id === activeImageId) return 1; + if (b2.id === activeImageId) return -1; + return a2.capture_time_parsed - b2.capture_time_parsed; + }).attr("transform", (d2) => transform2(d2, activeImageId)).select(".viewfield-scale"); + markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6"); + const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []); + viewfields.exit().remove(); + viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath); + service.setStyles(context, null); + function viewfieldPath() { + if (this.parentNode.__data__.isPano) { + return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0"; + } else { + return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z"; + } } - return t2; } - function filterImages(images) { - const showsPano = context.photos().showsPanoramic(); - const showsFlat = context.photos().showsFlat(); - const fromDate = context.photos().fromDate(); - const toDate = context.photos().toDate(); - if (!showsPano || !showsFlat) { - images = images.filter(function(image) { - if (image.is_pano) return showsPano; - return showsFlat; - }); + function viewerChanged() { + const service = getService(); + if (!service) return; + const frame2 = service.photoFrame(); + if (!frame2) return; + _viewerYaw = frame2.getYaw(); + if (context.map().isTransformed()) return; + layer.selectAll(".viewfield-group.currentView").attr("transform", (d2) => transform2(d2, d2.id)); + } + function drawImages(selection2) { + const enabled = svgPanoramaxImages.enabled; + const service = getService(); + layer = selection2.selectAll(".layer-panoramax").data(service ? [0] : []); + layer.exit().remove(); + const layerEnter = layer.enter().append("g").attr("class", "layer-panoramax").style("display", enabled ? "block" : "none"); + layerEnter.append("g").attr("class", "sequences"); + layerEnter.append("g").attr("class", "markers"); + layer = layerEnter.merge(layer); + if (enabled) { + let zoom = ~~context.map().zoom(); + if (service) { + if (zoom >= imageMinZoom2) { + editOn(); + update(); + service.loadImages(projection2); + } else if (zoom >= lineMinZoom2) { + editOn(); + update(); + service.loadLines(projection2, zoom); + } else { + editOff(); + dispatch14.call("photoDatesChanged", this, "panoramax", []); + } + } else { + editOff(); + } + } else { + dispatch14.call("photoDatesChanged", this, "panoramax", []); } - if (fromDate) { - images = images.filter(function(image) { - return new Date(image.captured_at).getTime() >= new Date(fromDate).getTime(); - }); + } + drawImages.enabled = function(_2) { + if (!arguments.length) return svgPanoramaxImages.enabled; + svgPanoramaxImages.enabled = _2; + if (svgPanoramaxImages.enabled) { + showLayer(); + context.photos().on("change.panoramax_images", update); + } else { + hideLayer(); + context.photos().on("change.panoramax_images", null); } - if (toDate) { - images = images.filter(function(image) { - return new Date(image.captured_at).getTime() <= new Date(toDate).getTime(); - }); + dispatch14.call("change"); + return this; + }; + drawImages.supported = function() { + return !!getService(); + }; + drawImages.rendered = function(zoom) { + return zoom >= lineMinZoom2; + }; + init2(); + return drawImages; + } + var init_panoramax_images = __esm({ + "modules/svg/panoramax_images.js"() { + "use strict"; + init_throttle(); + init_src5(); + init_services(); + init_helpers(); + } + }); + + // modules/svg/osm.js + var osm_exports2 = {}; + __export(osm_exports2, { + svgOsm: () => svgOsm + }); + function svgOsm(projection2, context, dispatch14) { + var enabled = true; + function drawOsm(selection2) { + selection2.selectAll(".layer-osm").data(["covered", "areas", "lines", "points", "labels"]).enter().append("g").attr("class", function(d2) { + return "layer-osm " + d2; + }); + selection2.selectAll(".layer-osm.points").selectAll(".points-group").data(["points", "midpoints", "vertices", "turns"]).enter().append("g").attr("class", function(d2) { + return "points-group " + d2; + }); + } + function showLayer() { + var layer = context.surface().selectAll(".data-layer.osm"); + layer.interrupt(); + layer.classed("disabled", false).style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", function() { + dispatch14.call("change"); + }); + } + function hideLayer() { + var layer = context.surface().selectAll(".data-layer.osm"); + layer.interrupt(); + layer.transition().duration(250).style("opacity", 0).on("end interrupt", function() { + layer.classed("disabled", true); + dispatch14.call("change"); + }); + } + drawOsm.enabled = function(val) { + if (!arguments.length) return enabled; + enabled = val; + if (enabled) { + showLayer(); + } else { + hideLayer(); } - return images; + dispatch14.call("change"); + return this; + }; + return drawOsm; + } + var init_osm2 = __esm({ + "modules/svg/osm.js"() { + "use strict"; } - function filterSequences(sequences) { - const showsPano = context.photos().showsPanoramic(); - const showsFlat = context.photos().showsFlat(); - const fromDate = context.photos().fromDate(); - const toDate = context.photos().toDate(); - if (!showsPano || !showsFlat) { - sequences = sequences.filter(function(sequence) { - if (sequence.properties.hasOwnProperty("is_pano")) { - if (sequence.properties.is_pano) return showsPano; - return showsFlat; - } - return false; - }); + }); + + // modules/svg/notes.js + var notes_exports = {}; + __export(notes_exports, { + svgNotes: () => svgNotes + }); + function svgNotes(projection2, context, dispatch14) { + if (!dispatch14) { + dispatch14 = dispatch_default("change"); + } + var throttledRedraw = throttle_default(function() { + dispatch14.call("change"); + }, 1e3); + var minZoom5 = 12; + var touchLayer = select_default2(null); + var drawLayer = select_default2(null); + var _notesVisible = false; + function markerPath(selection2, klass) { + selection2.attr("class", klass).attr("transform", "translate(-8, -22)").attr("d", "m17.5,0l-15,0c-1.37,0 -2.5,1.12 -2.5,2.5l0,11.25c0,1.37 1.12,2.5 2.5,2.5l3.75,0l0,3.28c0,0.38 0.43,0.6 0.75,0.37l4.87,-3.65l5.62,0c1.37,0 2.5,-1.12 2.5,-2.5l0,-11.25c0,-1.37 -1.12,-2.5 -2.5,-2.5z"); + } + function getService() { + if (services.osm && !_osmService) { + _osmService = services.osm; + _osmService.on("loadedNotes", throttledRedraw); + } else if (!services.osm && _osmService) { + _osmService = null; } - if (fromDate) { - sequences = sequences.filter(function(sequence) { - return new Date(sequence.properties.captured_at).getTime() >= new Date(fromDate).getTime().toString(); - }); + return _osmService; + } + function editOn() { + if (!_notesVisible) { + _notesVisible = true; + drawLayer.style("display", "block"); } - if (toDate) { - sequences = sequences.filter(function(sequence) { - return new Date(sequence.properties.captured_at).getTime() <= new Date(toDate).getTime().toString(); - }); + } + function editOff() { + if (_notesVisible) { + _notesVisible = false; + drawLayer.style("display", "none"); + drawLayer.selectAll(".note").remove(); + touchLayer.selectAll(".note").remove(); } - return sequences; } - function update() { - const z2 = ~~context.map().zoom(); - const showMarkers = z2 >= minMarkerZoom; - const showViewfields = z2 >= minViewfieldZoom2; - const service = getService(); - let sequences = service ? service.sequences(projection2) : []; - let images = service && showMarkers ? service.images(projection2) : []; - images = filterImages(images); - sequences = filterSequences(sequences, service); - service.filterViewer(context); - let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) { - return d2.properties.id; + function layerOn() { + editOn(); + drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", function() { + dispatch14.call("change"); + }); + } + function layerOff() { + throttledRedraw.cancel(); + drawLayer.interrupt(); + touchLayer.selectAll(".note").remove(); + drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", function() { + editOff(); + dispatch14.call("change"); + }); + } + function updateMarkers() { + if (!_notesVisible || !_notesEnabled) return; + var service = getService(); + var selectedID = context.selectedNoteID(); + var data = service ? service.notes(projection2) : []; + var getTransform = svgPointTransform(projection2); + var notes = drawLayer.selectAll(".note").data(data, function(d2) { + return d2.status + d2.id; }); - traces.exit().remove(); - traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson); - const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) { + notes.exit().remove(); + var notesEnter = notes.enter().append("g").attr("class", function(d2) { + return "note note-" + d2.id + " " + d2.status; + }).classed("new", function(d2) { + return d2.id < 0; + }); + notesEnter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke"); + notesEnter.append("path").call(markerPath, "shadow"); + notesEnter.append("use").attr("class", "note-fill").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").attr("xlink:href", "#iD-icon-note"); + notesEnter.selectAll(".icon-annotation").data(function(d2) { + return [d2]; + }).enter().append("use").attr("class", "icon-annotation").attr("width", "10px").attr("height", "10px").attr("x", "-3px").attr("y", "-19px").attr("xlink:href", function(d2) { + if (d2.id < 0) return "#iD-icon-plus"; + if (d2.status === "open") return "#iD-icon-close"; + return "#iD-icon-apply"; + }); + notes.merge(notesEnter).sort(sortY).classed("selected", function(d2) { + var mode = context.mode(); + var isMoving = mode && mode.id === "drag-note"; + return !isMoving && d2.id === selectedID; + }).attr("transform", getTransform); + if (touchLayer.empty()) return; + var fillClass = context.getDebug("target") ? "pink " : "nocolor "; + var targets = touchLayer.selectAll(".note").data(data, function(d2) { return d2.id; }); - groups.exit().remove(); - const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click); - groupsEnter.append("g").attr("class", "viewfield-scale"); - const markers = groups.merge(groupsEnter).sort(function(a2, b2) { + targets.exit().remove(); + targets.enter().append("rect").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").merge(targets).sort(sortY).attr("class", function(d2) { + var newClass = d2.id < 0 ? "new" : ""; + return "note target note-" + d2.id + " " + fillClass + newClass; + }).attr("transform", getTransform); + function sortY(a2, b2) { + if (a2.id === selectedID) return 1; + if (b2.id === selectedID) return -1; return b2.loc[1] - a2.loc[1]; - }).attr("transform", transform2).select(".viewfield-scale"); - markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6"); - const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []); - viewfields.exit().remove(); - viewfields.enter().insert("path", "circle").attr("class", "viewfield").classed("pano", function() { - return this.parentNode.__data__.is_pano; - }).attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath); - function viewfieldPath() { - if (this.parentNode.__data__.is_pano) { - return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0"; - } else { - return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z"; - } } } - function drawImages(selection2) { - const enabled = svgMapillaryImages.enabled; - const service = getService(); - layer = selection2.selectAll(".layer-mapillary").data(service ? [0] : []); - layer.exit().remove(); - const layerEnter = layer.enter().append("g").attr("class", "layer-mapillary").style("display", enabled ? "block" : "none"); - layerEnter.append("g").attr("class", "sequences"); - layerEnter.append("g").attr("class", "markers"); - layer = layerEnter.merge(layer); - if (enabled) { + function drawNotes(selection2) { + var service = getService(); + var surface = context.surface(); + if (surface && !surface.empty()) { + touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers"); + } + drawLayer = selection2.selectAll(".layer-notes").data(service ? [0] : []); + drawLayer.exit().remove(); + drawLayer = drawLayer.enter().append("g").attr("class", "layer-notes").style("display", _notesEnabled ? "block" : "none").merge(drawLayer); + if (_notesEnabled) { if (service && ~~context.map().zoom() >= minZoom5) { editOn(); - update(); - service.loadImages(projection2); + service.loadNotes(projection2); + updateMarkers(); } else { editOff(); } } } - drawImages.enabled = function(_2) { - if (!arguments.length) return svgMapillaryImages.enabled; - svgMapillaryImages.enabled = _2; - if (svgMapillaryImages.enabled) { - showLayer(); - context.photos().on("change.mapillary_images", update); + drawNotes.enabled = function(val) { + if (!arguments.length) return _notesEnabled; + _notesEnabled = val; + if (_notesEnabled) { + layerOn(); } else { - hideLayer(); - context.photos().on("change.mapillary_images", null); + layerOff(); + if (context.selectedNoteID()) { + context.enter(modeBrowse(context)); + } } dispatch14.call("change"); return this; }; - drawImages.supported = function() { - return !!getService(); - }; - drawImages.rendered = function(zoom) { - return zoom >= minZoom5; - }; - init2(); - return drawImages; + return drawNotes; } + var hash, _notesEnabled, _osmService; + var init_notes = __esm({ + "modules/svg/notes.js"() { + "use strict"; + init_throttle(); + init_src5(); + init_src4(); + init_browse(); + init_helpers(); + init_services(); + init_util(); + hash = utilStringQs(window.location.hash); + _notesEnabled = !!hash.notes; + } + }); - // modules/svg/mapillary_position.js - function svgMapillaryPosition(projection2, context) { - const throttledRedraw = throttle_default(function() { - update(); - }, 1e3); - const minZoom5 = 12; - const minViewfieldZoom2 = 18; - let layer = select_default2(null); - let _mapillary; - let viewerCompassAngle; - function init2() { - if (svgMapillaryPosition.initialized) return; - svgMapillaryPosition.initialized = true; + // modules/svg/touch.js + var touch_exports = {}; + __export(touch_exports, { + svgTouch: () => svgTouch + }); + function svgTouch() { + function drawTouch(selection2) { + selection2.selectAll(".layer-touch").data(["areas", "lines", "points", "turns", "markers"]).enter().append("g").attr("class", function(d2) { + return "layer-touch " + d2; + }); } - function getService() { - if (services.mapillary && !_mapillary) { - _mapillary = services.mapillary; - _mapillary.event.on("imageChanged", throttledRedraw); - _mapillary.event.on("bearingChanged", function(e3) { - viewerCompassAngle = e3.bearing; - if (context.map().isTransformed()) return; - layer.selectAll(".viewfield-group.currentView").filter(function(d2) { - return d2.is_pano; - }).attr("transform", transform2); - }); - } else if (!services.mapillary && _mapillary) { - _mapillary = null; - } - return _mapillary; + return drawTouch; + } + var init_touch = __esm({ + "modules/svg/touch.js"() { + "use strict"; } - function editOn() { - layer.style("display", "block"); + }); + + // modules/util/dimensions.js + var dimensions_exports = {}; + __export(dimensions_exports, { + utilGetDimensions: () => utilGetDimensions, + utilSetDimensions: () => utilSetDimensions + }); + function refresh(selection2, node) { + var cr = node.getBoundingClientRect(); + var prop = [cr.width, cr.height]; + selection2.property("__dimensions__", prop); + return prop; + } + function utilGetDimensions(selection2, force) { + if (!selection2 || selection2.empty()) { + return [0, 0]; } - function editOff() { - layer.selectAll(".viewfield-group").remove(); - layer.style("display", "none"); + var node = selection2.node(), cached = selection2.property("__dimensions__"); + return !cached || force ? refresh(selection2, node) : cached; + } + function utilSetDimensions(selection2, dimensions) { + if (!selection2 || selection2.empty()) { + return selection2; } - function transform2(d2) { - let t2 = svgPointTransform(projection2)(d2); - if (d2.is_pano && viewerCompassAngle !== null && isFinite(viewerCompassAngle)) { - t2 += " rotate(" + Math.floor(viewerCompassAngle) + ",0,0)"; - } else if (d2.ca) { - t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)"; - } - return t2; + var node = selection2.node(); + if (dimensions === null) { + refresh(selection2, node); + return selection2; } - function update() { - const z2 = ~~context.map().zoom(); - const showViewfields = z2 >= minViewfieldZoom2; - const service = getService(); - const image = service && service.getActiveImage(); - const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(image ? [image] : [], function(d2) { - return d2.id; - }); - groups.exit().remove(); - const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group currentView highlighted"); - groupsEnter.append("g").attr("class", "viewfield-scale"); - const markers = groups.merge(groupsEnter).attr("transform", transform2).select(".viewfield-scale"); - markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6"); - const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []); - viewfields.exit().remove(); - viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z"); + return selection2.property("__dimensions__", [dimensions[0], dimensions[1]]).attr("width", dimensions[0]).attr("height", dimensions[1]); + } + var init_dimensions = __esm({ + "modules/util/dimensions.js"() { + "use strict"; } - function drawImages(selection2) { - const service = getService(); - layer = selection2.selectAll(".layer-mapillary-position").data(service ? [0] : []); - layer.exit().remove(); - const layerEnter = layer.enter().append("g").attr("class", "layer-mapillary-position"); - layerEnter.append("g").attr("class", "markers"); - layer = layerEnter.merge(layer); - if (service && ~~context.map().zoom() >= minZoom5) { - editOn(); - update(); - } else { - editOff(); - } + }); + + // modules/svg/layers.js + var layers_exports = {}; + __export(layers_exports, { + svgLayers: () => svgLayers + }); + function svgLayers(projection2, context) { + var dispatch14 = dispatch_default("change", "photoDatesChanged"); + var svg2 = select_default2(null); + var _layers = [ + { id: "osm", layer: svgOsm(projection2, context, dispatch14) }, + { id: "notes", layer: svgNotes(projection2, context, dispatch14) }, + { id: "data", layer: svgData(projection2, context, dispatch14) }, + { id: "keepRight", layer: svgKeepRight(projection2, context, dispatch14) }, + { id: "osmose", layer: svgOsmose(projection2, context, dispatch14) }, + { id: "streetside", layer: svgStreetside(projection2, context, dispatch14) }, + { id: "mapillary", layer: svgMapillaryImages(projection2, context, dispatch14) }, + { id: "mapillary-position", layer: svgMapillaryPosition(projection2, context, dispatch14) }, + { id: "mapillary-map-features", layer: svgMapillaryMapFeatures(projection2, context, dispatch14) }, + { id: "mapillary-signs", layer: svgMapillarySigns(projection2, context, dispatch14) }, + { id: "kartaview", layer: svgKartaviewImages(projection2, context, dispatch14) }, + { id: "mapilio", layer: svgMapilioImages(projection2, context, dispatch14) }, + { id: "vegbilder", layer: svgVegbilder(projection2, context, dispatch14) }, + { id: "panoramax", layer: svgPanoramaxImages(projection2, context, dispatch14) }, + { id: "local-photos", layer: svgLocalPhotos(projection2, context, dispatch14) }, + { id: "debug", layer: svgDebug(projection2, context, dispatch14) }, + { id: "geolocate", layer: svgGeolocate(projection2, context, dispatch14) }, + { id: "touch", layer: svgTouch(projection2, context, dispatch14) } + ]; + function drawLayers(selection2) { + svg2 = selection2.selectAll(".surface").data([0]); + svg2 = svg2.enter().append("svg").attr("class", "surface").merge(svg2); + var defs = svg2.selectAll(".surface-defs").data([0]); + defs.enter().append("defs").attr("class", "surface-defs"); + var groups = svg2.selectAll(".data-layer").data(_layers); + groups.exit().remove(); + groups.enter().append("g").attr("class", function(d2) { + return "data-layer " + d2.id; + }).merge(groups).each(function(d2) { + select_default2(this).call(d2.layer); + }); } - drawImages.enabled = function() { - update(); + drawLayers.all = function() { + return _layers; + }; + drawLayers.layer = function(id2) { + var obj = _layers.find(function(o2) { + return o2.id === id2; + }); + return obj && obj.layer; + }; + drawLayers.only = function(what) { + var arr = [].concat(what); + var all = _layers.map(function(layer) { + return layer.id; + }); + return drawLayers.remove(utilArrayDifference(all, arr)); + }; + drawLayers.remove = function(what) { + var arr = [].concat(what); + arr.forEach(function(id2) { + _layers = _layers.filter(function(o2) { + return o2.id !== id2; + }); + }); + dispatch14.call("change"); return this; }; - drawImages.supported = function() { - return !!getService(); + drawLayers.add = function(what) { + var arr = [].concat(what); + arr.forEach(function(obj) { + if ("id" in obj && "layer" in obj) { + _layers.push(obj); + } + }); + dispatch14.call("change"); + return this; }; - drawImages.rendered = function(zoom) { - return zoom >= minZoom5; + drawLayers.dimensions = function(val) { + if (!arguments.length) return utilGetDimensions(svg2); + utilSetDimensions(svg2, val); + return this; }; - init2(); - return drawImages; + return utilRebind(drawLayers, dispatch14, "on"); } + var init_layers = __esm({ + "modules/svg/layers.js"() { + "use strict"; + init_src4(); + init_src5(); + init_data2(); + init_local_photos(); + init_debug(); + init_geolocate(); + init_keepRight2(); + init_osmose2(); + init_streetside(); + init_vegbilder(); + init_mapillary_images(); + init_mapillary_position(); + init_mapillary_signs(); + init_mapillary_map_features(); + init_kartaview_images(); + init_mapilio_images(); + init_panoramax_images(); + init_osm2(); + init_notes(); + init_touch(); + init_util(); + init_dimensions(); + } + }); - // modules/svg/mapillary_signs.js - function svgMapillarySigns(projection2, context, dispatch14) { - const throttledRedraw = throttle_default(function() { - dispatch14.call("change"); - }, 1e3); - const minZoom5 = 12; - let layer = select_default2(null); - let _mapillary; - function init2() { - if (svgMapillarySigns.initialized) return; - svgMapillarySigns.enabled = false; - svgMapillarySigns.initialized = true; + // modules/svg/lines.js + var lines_exports = {}; + __export(lines_exports, { + svgLines: () => svgLines + }); + function onewayArrowColour(tags) { + if (tags.highway === "construction" && tags.bridge) return "white"; + if (tags.highway === "pedestrian") return "gray"; + if (tags.railway) return "gray"; + if (tags.aeroway === "runway") return "white"; + return "black"; + } + function svgLines(projection2, context) { + var detected = utilDetect(); + var highway_stack = { + motorway: 0, + motorway_link: 1, + trunk: 2, + trunk_link: 3, + primary: 4, + primary_link: 5, + secondary: 6, + tertiary: 7, + unclassified: 8, + residential: 9, + service: 10, + busway: 11, + footway: 12 + }; + function drawTargets(selection2, graph, entities, filter2) { + var targetClass = context.getDebug("target") ? "pink " : "nocolor "; + var nopeClass = context.getDebug("target") ? "red " : "nocolor "; + var getPath = svgPath(projection2).geojson; + var activeID = context.activeID(); + var base = context.history().base(); + var data = { targets: [], nopes: [] }; + entities.forEach(function(way) { + var features = svgSegmentWay(way, graph, activeID); + data.targets.push.apply(data.targets, features.passive); + data.nopes.push.apply(data.nopes, features.active); + }); + var targetData = data.targets.filter(getPath); + var targets = selection2.selectAll(".line.target-allowed").filter(function(d2) { + return filter2(d2.properties.entity); + }).data(targetData, function key(d2) { + return d2.id; + }); + targets.exit().remove(); + var segmentWasEdited = function(d2) { + var wayID = d2.properties.entity.id; + if (!base.entities[wayID] || !(0, import_fast_deep_equal6.default)(graph.entities[wayID].nodes, base.entities[wayID].nodes)) { + return false; + } + return d2.properties.nodes.some(function(n3) { + return !base.entities[n3.id] || !(0, import_fast_deep_equal6.default)(graph.entities[n3.id].loc, base.entities[n3.id].loc); + }); + }; + targets.enter().append("path").merge(targets).attr("d", getPath).attr("class", function(d2) { + return "way line target target-allowed " + targetClass + d2.id; + }).classed("segment-edited", segmentWasEdited); + var nopeData = data.nopes.filter(getPath); + var nopes = selection2.selectAll(".line.target-nope").filter(function(d2) { + return filter2(d2.properties.entity); + }).data(nopeData, function key(d2) { + return d2.id; + }); + nopes.exit().remove(); + nopes.enter().append("path").merge(nopes).attr("d", getPath).attr("class", function(d2) { + return "way line target target-nope " + nopeClass + d2.id; + }).classed("segment-edited", segmentWasEdited); } - function getService() { - if (services.mapillary && !_mapillary) { - _mapillary = services.mapillary; - _mapillary.event.on("loadedSigns", throttledRedraw); - } else if (!services.mapillary && _mapillary) { - _mapillary = null; + function drawLines(selection2, graph, entities, filter2) { + var base = context.history().base(); + function waystack(a2, b2) { + var selected = context.selectedIDs(); + var scoreA = selected.indexOf(a2.id) !== -1 ? 20 : 0; + var scoreB = selected.indexOf(b2.id) !== -1 ? 20 : 0; + if (a2.tags.highway) { + scoreA -= highway_stack[a2.tags.highway]; + } + if (b2.tags.highway) { + scoreB -= highway_stack[b2.tags.highway]; + } + return scoreA - scoreB; } - return _mapillary; - } - function showLayer() { - const service = getService(); - if (!service) return; - service.loadSignResources(context); - editOn(); - } - function hideLayer() { - throttledRedraw.cancel(); - editOff(); - } - function editOn() { - layer.style("display", "block"); + function drawLineGroup(selection3, klass, isSelected) { + var mode = context.mode(); + var isDrawing = mode && /^draw/.test(mode.id); + var selectedClass = !isDrawing && isSelected ? "selected " : ""; + var lines = selection3.selectAll("path").filter(filter2).data(getPathData(isSelected), osmEntity.key); + lines.exit().remove(); + lines.enter().append("path").attr("class", function(d2) { + var prefix = "way line"; + if (!d2.hasInterestingTags()) { + var parentRelations = graph.parentRelations(d2); + var parentMultipolygons = parentRelations.filter(function(relation) { + return relation.isMultipolygon(); + }); + if (parentMultipolygons.length > 0 && // and only multipolygon relations + parentRelations.length === parentMultipolygons.length) { + prefix = "relation area"; + } + } + var oldMPClass = oldMultiPolygonOuters[d2.id] ? "old-multipolygon " : ""; + return prefix + " " + klass + " " + selectedClass + oldMPClass + d2.id; + }).classed("added", function(d2) { + return !base.entities[d2.id]; + }).classed("geometry-edited", function(d2) { + return graph.entities[d2.id] && base.entities[d2.id] && !(0, import_fast_deep_equal6.default)(graph.entities[d2.id].nodes, base.entities[d2.id].nodes); + }).classed("retagged", function(d2) { + return graph.entities[d2.id] && base.entities[d2.id] && !(0, import_fast_deep_equal6.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags); + }).call(svgTagClasses()).merge(lines).sort(waystack).attr("d", getPath).call(svgTagClasses().tags(svgRelationMemberTags(graph))); + return selection3; + } + function getPathData(isSelected) { + return function() { + var layer = this.parentNode.__data__; + var data = pathdata[layer] || []; + return data.filter(function(d2) { + if (isSelected) { + return context.selectedIDs().indexOf(d2.id) !== -1; + } else { + return context.selectedIDs().indexOf(d2.id) === -1; + } + }); + }; + } + function addMarkers(layergroup, pathclass, groupclass, groupdata, marker) { + var markergroup = layergroup.selectAll("g." + groupclass).data([pathclass]); + markergroup = markergroup.enter().append("g").attr("class", groupclass).merge(markergroup); + var markers = markergroup.selectAll("path").filter(filter2).data( + function data() { + return groupdata[this.parentNode.__data__] || []; + }, + function key(d2) { + return [d2.id, d2.index]; + } + ); + markers.exit().remove(); + markers = markers.enter().append("path").attr("class", pathclass).merge(markers).attr("marker-mid", marker).attr("d", function(d2) { + return d2.d; + }); + if (detected.ie) { + markers.each(function() { + this.parentNode.insertBefore(this, this); + }); + } + } + var getPath = svgPath(projection2, graph); + var ways = []; + var onewaydata = {}; + var sideddata = {}; + var oldMultiPolygonOuters = {}; + for (var i3 = 0; i3 < entities.length; i3++) { + var entity = entities[i3]; + if (entity.geometry(graph) === "line" || entity.geometry(graph) === "area" && entity.sidednessIdentifier && entity.sidednessIdentifier() === "coastline") { + ways.push(entity); + } + } + ways = ways.filter(getPath); + const pathdata = utilArrayGroupBy(ways, (way) => Math.trunc(way.layer())); + Object.keys(pathdata).forEach(function(k2) { + var v2 = pathdata[k2]; + var onewayArr = v2.filter(function(d2) { + return d2.isOneWay(); + }); + var onewaySegments = svgMarkerSegments( + projection2, + graph, + 36, + (entity2) => entity2.isOneWayBackwards(), + (entity2) => entity2.isBiDirectional() + ); + onewaydata[k2] = utilArrayFlatten(onewayArr.map(onewaySegments)); + var sidedArr = v2.filter(function(d2) { + return d2.isSided(); + }); + var sidedSegments = svgMarkerSegments( + projection2, + graph, + 30 + ); + sideddata[k2] = utilArrayFlatten(sidedArr.map(sidedSegments)); + }); + var covered = selection2.selectAll(".layer-osm.covered"); + var uncovered = selection2.selectAll(".layer-osm.lines"); + var touchLayer = selection2.selectAll(".layer-touch.lines"); + [covered, uncovered].forEach(function(selection3) { + var range3 = selection3 === covered ? range(-10, 0) : range(0, 11); + var layergroup = selection3.selectAll("g.layergroup").data(range3); + layergroup = layergroup.enter().append("g").attr("class", function(d2) { + return "layergroup layer" + String(d2); + }).merge(layergroup); + layergroup.selectAll("g.linegroup").data(["shadow", "casing", "stroke", "shadow-highlighted", "casing-highlighted", "stroke-highlighted"]).enter().append("g").attr("class", function(d2) { + return "linegroup line-" + d2; + }); + layergroup.selectAll("g.line-shadow").call(drawLineGroup, "shadow", false); + layergroup.selectAll("g.line-casing").call(drawLineGroup, "casing", false); + layergroup.selectAll("g.line-stroke").call(drawLineGroup, "stroke", false); + layergroup.selectAll("g.line-shadow-highlighted").call(drawLineGroup, "shadow", true); + layergroup.selectAll("g.line-casing-highlighted").call(drawLineGroup, "casing", true); + layergroup.selectAll("g.line-stroke-highlighted").call(drawLineGroup, "stroke", true); + addMarkers(layergroup, "oneway", "onewaygroup", onewaydata, (d2) => { + const category = onewayArrowColour(graph.entity(d2.id).tags); + return `url(#ideditor-oneway-marker-${category})`; + }); + addMarkers( + layergroup, + "sided", + "sidedgroup", + sideddata, + function marker(d2) { + var category = graph.entity(d2.id).sidednessIdentifier(); + return "url(#ideditor-sided-marker-" + category + ")"; + } + ); + }); + touchLayer.call(drawTargets, graph, ways, filter2); } - function editOff() { - layer.selectAll(".icon-sign").remove(); - layer.style("display", "none"); + return drawLines; + } + var import_fast_deep_equal6; + var init_lines = __esm({ + "modules/svg/lines.js"() { + "use strict"; + import_fast_deep_equal6 = __toESM(require_fast_deep_equal()); + init_src(); + init_helpers(); + init_tag_classes(); + init_osm(); + init_util(); + init_detect(); } - function click(d3_event, d2) { - const service = getService(); - if (!service) return; - context.map().centerEase(d2.loc); - const selectedImageId = service.getActiveImage() && service.getActiveImage().id; - service.getDetections(d2.id).then((detections) => { - if (detections.length) { - const imageId = detections[0].image.id; - if (imageId === selectedImageId) { - service.highlightDetection(detections[0]).selectImage(context, imageId); - } else { - service.ensureViewerLoaded(context).then(function() { - service.highlightDetection(detections[0]).selectImage(context, imageId).showViewer(context); - }); + }); + + // modules/svg/midpoints.js + var midpoints_exports = {}; + __export(midpoints_exports, { + svgMidpoints: () => svgMidpoints + }); + function svgMidpoints(projection2, context) { + var targetRadius = 8; + function drawTargets(selection2, graph, entities, filter2) { + var fillClass = context.getDebug("target") ? "pink " : "nocolor "; + var getTransform = svgPointTransform(projection2).geojson; + var data = entities.map(function(midpoint) { + return { + type: "Feature", + id: midpoint.id, + properties: { + target: true, + entity: midpoint + }, + geometry: { + type: "Point", + coordinates: midpoint.loc } - } + }; + }); + var targets = selection2.selectAll(".midpoint.target").filter(function(d2) { + return filter2(d2.properties.entity); + }).data(data, function key(d2) { + return d2.id; }); + targets.exit().remove(); + targets.enter().append("circle").attr("r", targetRadius).merge(targets).attr("class", function(d2) { + return "node midpoint target " + fillClass + d2.id; + }).attr("transform", getTransform); } - function filterData(detectedFeatures) { - var fromDate = context.photos().fromDate(); - var toDate = context.photos().toDate(); - if (fromDate) { - var fromTimestamp = new Date(fromDate).getTime(); - detectedFeatures = detectedFeatures.filter(function(feature3) { - return new Date(feature3.last_seen_at).getTime() >= fromTimestamp; - }); + function drawMidpoints(selection2, graph, entities, filter2, extent) { + var drawLayer = selection2.selectAll(".layer-osm.points .points-group.midpoints"); + var touchLayer = selection2.selectAll(".layer-touch.points"); + var mode = context.mode(); + if (mode && mode.id !== "select" || !context.map().withinEditableZoom()) { + drawLayer.selectAll(".midpoint").remove(); + touchLayer.selectAll(".midpoint.target").remove(); + return; } - if (toDate) { - var toTimestamp = new Date(toDate).getTime(); - detectedFeatures = detectedFeatures.filter(function(feature3) { - return new Date(feature3.first_seen_at).getTime() <= toTimestamp; - }); + var poly = extent.polygon(); + var midpoints = {}; + for (var i3 = 0; i3 < entities.length; i3++) { + var entity = entities[i3]; + if (entity.type !== "way") continue; + if (!filter2(entity)) continue; + if (context.selectedIDs().indexOf(entity.id) < 0) continue; + var nodes = graph.childNodes(entity); + 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); + } else if (geoVecLength(projection2(a2.loc), projection2(b2.loc)) > 40) { + var point = geoVecInterp(a2.loc, b2.loc, 0.5); + var loc = null; + if (extent.intersects(point)) { + loc = point; + } else { + for (var k2 = 0; k2 < 4; k2++) { + point = geoLineIntersection([a2.loc, b2.loc], [poly[k2], poly[k2 + 1]]); + if (point && geoVecLength(projection2(a2.loc), projection2(point)) > 20 && geoVecLength(projection2(b2.loc), projection2(point)) > 20) { + loc = point; + break; + } + } + } + if (loc) { + midpoints[id2] = { + type: "midpoint", + id: id2, + loc, + edge: [a2.id, b2.id], + parents: [entity] + }; + } + } + } } - return detectedFeatures; - } - function update() { - const service = getService(); - let data = service ? service.signs(projection2) : []; - data = filterData(data); - const transform2 = svgPointTransform(projection2); - const signs = layer.selectAll(".icon-sign").data(data, function(d2) { + function midpointFilter(d2) { + if (midpoints[d2.id]) return true; + for (var i4 = 0; i4 < d2.parents.length; i4++) { + if (filter2(d2.parents[i4])) { + return true; + } + } + return false; + } + var groups = drawLayer.selectAll(".midpoint").filter(midpointFilter).data(Object.values(midpoints), function(d2) { return d2.id; }); - signs.exit().remove(); - const enter = signs.enter().append("g").attr("class", "icon-sign icon-detected").on("click", click); - enter.append("use").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px").attr("xlink:href", function(d2) { - return "#" + d2.value; - }); - enter.append("rect").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px"); - signs.merge(enter).attr("transform", transform2); - } - function drawSigns(selection2) { - const enabled = svgMapillarySigns.enabled; - const service = getService(); - layer = selection2.selectAll(".layer-mapillary-signs").data(service ? [0] : []); - layer.exit().remove(); - layer = layer.enter().append("g").attr("class", "layer-mapillary-signs layer-mapillary-detections").style("display", enabled ? "block" : "none").merge(layer); - if (enabled) { - if (service && ~~context.map().zoom() >= minZoom5) { - editOn(); - update(); - service.loadSigns(projection2); - service.showSignDetections(true); - } else { - editOff(); + groups.exit().remove(); + var enter = groups.enter().insert("g", ":first-child").attr("class", "midpoint"); + enter.append("polygon").attr("points", "-6,8 10,0 -6,-8").attr("class", "shadow"); + enter.append("polygon").attr("points", "-3,4 5,0 -3,-4").attr("class", "fill"); + groups = groups.merge(enter).attr("transform", function(d2) { + var translate = svgPointTransform(projection2); + var a3 = graph.entity(d2.edge[0]); + var b3 = graph.entity(d2.edge[1]); + var angle2 = geoAngle(a3, b3, projection2) * (180 / Math.PI); + return translate(d2) + " rotate(" + angle2 + ")"; + }).call(svgTagClasses().tags( + function(d2) { + return d2.parents[0].tags; } - } else if (service) { - service.showSignDetections(false); - } + )); + groups.select("polygon.shadow"); + groups.select("polygon.fill"); + touchLayer.call(drawTargets, graph, Object.values(midpoints), midpointFilter); } - drawSigns.enabled = function(_2) { - if (!arguments.length) return svgMapillarySigns.enabled; - svgMapillarySigns.enabled = _2; - if (svgMapillarySigns.enabled) { - showLayer(); - context.photos().on("change.mapillary_signs", update); - } else { - hideLayer(); - context.photos().on("change.mapillary_signs", null); - } - dispatch14.call("change"); - return this; - }; - drawSigns.supported = function() { - return !!getService(); - }; - drawSigns.rendered = function(zoom) { - return zoom >= minZoom5; - }; - init2(); - return drawSigns; + return drawMidpoints; } - - // modules/svg/mapillary_map_features.js - function svgMapillaryMapFeatures(projection2, context, dispatch14) { - const throttledRedraw = throttle_default(function() { - dispatch14.call("change"); - }, 1e3); - const minZoom5 = 12; - let layer = select_default2(null); - let _mapillary; - function init2() { - if (svgMapillaryMapFeatures.initialized) return; - svgMapillaryMapFeatures.enabled = false; - svgMapillaryMapFeatures.initialized = true; - } - function getService() { - if (services.mapillary && !_mapillary) { - _mapillary = services.mapillary; - _mapillary.event.on("loadedMapFeatures", throttledRedraw); - } else if (!services.mapillary && _mapillary) { - _mapillary = null; - } - return _mapillary; - } - function showLayer() { - const service = getService(); - if (!service) return; - service.loadObjectResources(context); - editOn(); - } - function hideLayer() { - throttledRedraw.cancel(); - editOff(); + var init_midpoints = __esm({ + "modules/svg/midpoints.js"() { + "use strict"; + init_helpers(); + init_tag_classes(); + init_geo2(); } - function editOn() { - layer.style("display", "block"); + }); + + // modules/svg/points.js + var points_exports = {}; + __export(points_exports, { + svgPoints: () => svgPoints + }); + function svgPoints(projection2, context) { + function markerPath(selection2, klass) { + selection2.attr("class", klass).attr("transform", "translate(-8, -23)").attr("d", "M 17,8 C 17,13 11,21 8.5,23.5 C 6,21 0,13 0,8 C 0,4 4,-0.5 8.5,-0.5 C 13,-0.5 17,4 17,8 z"); } - function editOff() { - layer.selectAll(".icon-map-feature").remove(); - layer.style("display", "none"); + function sortY(a2, b2) { + return b2.loc[1] - a2.loc[1]; } - function click(d3_event, d2) { - const service = getService(); - if (!service) return; - context.map().centerEase(d2.loc); - const selectedImageId = service.getActiveImage() && service.getActiveImage().id; - service.getDetections(d2.id).then((detections) => { - if (detections.length) { - const imageId = detections[0].image.id; - if (imageId === selectedImageId) { - service.highlightDetection(detections[0]).selectImage(context, imageId); - } else { - service.ensureViewerLoaded(context).then(function() { - service.highlightDetection(detections[0]).selectImage(context, imageId).showViewer(context); - }); - } - } - }); + function fastEntityKey(d2) { + var mode = context.mode(); + var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id); + return isMoving ? d2.id : osmEntity.key(d2); } - function filterData(detectedFeatures) { - const fromDate = context.photos().fromDate(); - const toDate = context.photos().toDate(); - if (fromDate) { - detectedFeatures = detectedFeatures.filter(function(feature3) { - return new Date(feature3.last_seen_at).getTime() >= new Date(fromDate).getTime(); - }); - } - if (toDate) { - detectedFeatures = detectedFeatures.filter(function(feature3) { - return new Date(feature3.first_seen_at).getTime() <= new Date(toDate).getTime(); + function drawTargets(selection2, graph, entities, filter2) { + var fillClass = context.getDebug("target") ? "pink " : "nocolor "; + var getTransform = svgPointTransform(projection2).geojson; + var activeID = context.activeID(); + var data = []; + entities.forEach(function(node) { + if (activeID === node.id) return; + data.push({ + type: "Feature", + id: node.id, + properties: { + target: true, + entity: node + }, + geometry: node.asGeoJSON() }); - } - return detectedFeatures; - } - function update() { - const service = getService(); - let data = service ? service.mapFeatures(projection2) : []; - data = filterData(data); - const transform2 = svgPointTransform(projection2); - const mapFeatures = layer.selectAll(".icon-map-feature").data(data, function(d2) { - return d2.id; - }); - mapFeatures.exit().remove(); - const enter = mapFeatures.enter().append("g").attr("class", "icon-map-feature icon-detected").on("click", click); - enter.append("title").text(function(d2) { - var id2 = d2.value.replace(/--/g, ".").replace(/-/g, "_"); - return _t("mapillary_map_features." + id2); }); - enter.append("use").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px").attr("xlink:href", function(d2) { - if (d2.value === "object--billboard") { - return "#object--sign--advertisement"; - } - return "#" + d2.value; + var targets = selection2.selectAll(".point.target").filter(function(d2) { + return filter2(d2.properties.entity); + }).data(data, function key(d2) { + return d2.id; }); - enter.append("rect").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px"); - mapFeatures.merge(enter).attr("transform", transform2); + targets.exit().remove(); + targets.enter().append("rect").attr("x", -10).attr("y", -26).attr("width", 20).attr("height", 30).merge(targets).attr("class", function(d2) { + return "node point target " + fillClass + d2.id; + }).attr("transform", getTransform); } - function drawMapFeatures(selection2) { - const enabled = svgMapillaryMapFeatures.enabled; - const service = getService(); - layer = selection2.selectAll(".layer-mapillary-map-features").data(service ? [0] : []); - layer.exit().remove(); - layer = layer.enter().append("g").attr("class", "layer-mapillary-map-features layer-mapillary-detections").style("display", enabled ? "block" : "none").merge(layer); - if (enabled) { - if (service && ~~context.map().zoom() >= minZoom5) { - editOn(); - update(); - service.loadMapFeatures(projection2); - service.showFeatureDetections(true); - } else { - editOff(); - } - } else if (service) { - service.showFeatureDetections(false); + function drawPoints(selection2, graph, entities, filter2) { + var wireframe = context.surface().classed("fill-wireframe"); + var zoom = geoScaleToZoom(projection2.scale()); + var base = context.history().base(); + function renderAsPoint(entity) { + return entity.geometry(graph) === "point" && !(zoom >= 18 && entity.directions(graph, projection2).length); } + var points = wireframe ? [] : entities.filter(renderAsPoint); + points.sort(sortY); + var drawLayer = selection2.selectAll(".layer-osm.points .points-group.points"); + var touchLayer = selection2.selectAll(".layer-touch.points"); + var groups = drawLayer.selectAll("g.point").filter(filter2).data(points, fastEntityKey); + groups.exit().remove(); + var enter = groups.enter().append("g").attr("class", function(d2) { + return "node point " + d2.id; + }).order(); + enter.append("path").call(markerPath, "shadow"); + enter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke"); + enter.append("path").call(markerPath, "stroke"); + enter.append("use").attr("transform", "translate(-5.5, -20)").attr("class", "icon").attr("width", "12px").attr("height", "12px"); + groups = groups.merge(enter).attr("transform", svgPointTransform(projection2)).classed("added", function(d2) { + return !base.entities[d2.id]; + }).classed("moved", function(d2) { + return base.entities[d2.id] && !(0, import_fast_deep_equal7.default)(graph.entities[d2.id].loc, base.entities[d2.id].loc); + }).classed("retagged", function(d2) { + return base.entities[d2.id] && !(0, import_fast_deep_equal7.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags); + }).call(svgTagClasses()); + groups.select(".shadow"); + groups.select(".stroke"); + groups.select(".icon").attr("xlink:href", function(entity) { + var preset = _mainPresetIndex.match(entity, graph); + var picon = preset && preset.icon; + return picon ? "#" + picon : ""; + }); + touchLayer.call(drawTargets, graph, points, filter2); } - drawMapFeatures.enabled = function(_2) { - if (!arguments.length) return svgMapillaryMapFeatures.enabled; - svgMapillaryMapFeatures.enabled = _2; - if (svgMapillaryMapFeatures.enabled) { - showLayer(); - context.photos().on("change.mapillary_map_features", update); - } else { - hideLayer(); - context.photos().on("change.mapillary_map_features", null); - } - dispatch14.call("change"); - return this; - }; - drawMapFeatures.supported = function() { - return !!getService(); - }; - drawMapFeatures.rendered = function(zoom) { - return zoom >= minZoom5; - }; - init2(); - return drawMapFeatures; + return drawPoints; } + var import_fast_deep_equal7; + var init_points = __esm({ + "modules/svg/points.js"() { + "use strict"; + import_fast_deep_equal7 = __toESM(require_fast_deep_equal()); + init_geo2(); + init_osm(); + init_helpers(); + init_tag_classes(); + init_presets(); + } + }); - // modules/svg/kartaview_images.js - function svgKartaviewImages(projection2, context, dispatch14) { - var throttledRedraw = throttle_default(function() { - dispatch14.call("change"); - }, 1e3); - var minZoom5 = 12; - var minMarkerZoom = 16; - var minViewfieldZoom2 = 18; - var layer = select_default2(null); - var _kartaview; - function init2() { - if (svgKartaviewImages.initialized) return; - svgKartaviewImages.enabled = false; - svgKartaviewImages.initialized = true; + // modules/svg/turns.js + var turns_exports = {}; + __export(turns_exports, { + svgTurns: () => svgTurns + }); + function svgTurns(projection2, context) { + function icon2(turn) { + var u2 = turn.u ? "-u" : ""; + if (turn.no) return "#iD-turn-no" + u2; + if (turn.only) return "#iD-turn-only" + u2; + return "#iD-turn-yes" + u2; } - function getService() { - if (services.kartaview && !_kartaview) { - _kartaview = services.kartaview; - _kartaview.event.on("loadedImages", throttledRedraw); - } else if (!services.kartaview && _kartaview) { - _kartaview = null; + function drawTurns(selection2, graph, turns) { + function turnTransform(d2) { + var pxRadius = 50; + var toWay = graph.entity(d2.to.way); + var toPoints = graph.childNodes(toWay).map(function(n3) { + return n3.loc; + }).map(projection2); + var toLength = geoPathLength(toPoints); + var mid = toLength / 2; + var toNode = graph.entity(d2.to.node); + var toVertex = graph.entity(d2.to.vertex); + var a2 = geoAngle(toVertex, toNode, projection2); + var o2 = projection2(toVertex.loc); + var r2 = d2.u ? 0 : !toWay.__via ? pxRadius : Math.min(mid, pxRadius); + return "translate(" + (r2 * Math.cos(a2) + o2[0]) + "," + (r2 * Math.sin(a2) + o2[1]) + ") rotate(" + a2 * 180 / Math.PI + ")"; } - return _kartaview; - } - function showLayer() { - var service = getService(); - if (!service) return; - editOn(); - layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() { - dispatch14.call("change"); + var drawLayer = selection2.selectAll(".layer-osm.points .points-group.turns"); + var touchLayer = selection2.selectAll(".layer-touch.turns"); + var groups = drawLayer.selectAll("g.turn").data(turns, function(d2) { + return d2.key; }); - } - function hideLayer() { - throttledRedraw.cancel(); - layer.transition().duration(250).style("opacity", 0).on("end", editOff); - } - function editOn() { - layer.style("display", "block"); - } - function editOff() { - layer.selectAll(".viewfield-group").remove(); - layer.style("display", "none"); - } - function click(d3_event, d2) { - var service = getService(); - if (!service) return; - service.ensureViewerLoaded(context).then(function() { - service.selectImage(context, d2.key).showViewer(context); + groups.exit().remove(); + var groupsEnter = groups.enter().append("g").attr("class", function(d2) { + return "turn " + d2.key; + }); + var turnsEnter = groupsEnter.filter(function(d2) { + return !d2.u; + }); + turnsEnter.append("rect").attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24"); + turnsEnter.append("use").attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24"); + var uEnter = groupsEnter.filter(function(d2) { + return d2.u; + }); + uEnter.append("circle").attr("r", "16"); + uEnter.append("use").attr("transform", "translate(-16, -16)").attr("width", "32").attr("height", "32"); + groups = groups.merge(groupsEnter).attr("opacity", function(d2) { + return d2.direct === false ? "0.7" : null; + }).attr("transform", turnTransform); + groups.select("use").attr("xlink:href", icon2); + groups.select("rect"); + groups.select("circle"); + var fillClass = context.getDebug("target") ? "pink " : "nocolor "; + groups = touchLayer.selectAll("g.turn").data(turns, function(d2) { + return d2.key; }); - context.map().centerEase(d2.loc); - } - function mouseover(d3_event, d2) { - var service = getService(); - if (service) service.setStyles(context, d2); + groups.exit().remove(); + groupsEnter = groups.enter().append("g").attr("class", function(d2) { + return "turn " + d2.key; + }); + turnsEnter = groupsEnter.filter(function(d2) { + return !d2.u; + }); + turnsEnter.append("rect").attr("class", "target " + fillClass).attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24"); + uEnter = groupsEnter.filter(function(d2) { + return d2.u; + }); + uEnter.append("circle").attr("class", "target " + fillClass).attr("r", "16"); + groups = groups.merge(groupsEnter).attr("transform", turnTransform); + groups.select("rect"); + groups.select("circle"); + return this; } - function mouseout() { - var service = getService(); - if (service) service.setStyles(context, null); + return drawTurns; + } + var init_turns = __esm({ + "modules/svg/turns.js"() { + "use strict"; + init_geo2(); } - function transform2(d2) { - var t2 = svgPointTransform(projection2)(d2); - if (d2.ca) { - t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)"; - } - return t2; + }); + + // modules/svg/vertices.js + var vertices_exports = {}; + __export(vertices_exports, { + svgVertices: () => svgVertices + }); + function svgVertices(projection2, context) { + var radiuses = { + // z16-, z17, z18+, w/icon + shadow: [6, 7.5, 7.5, 12], + stroke: [2.5, 3.5, 3.5, 8], + fill: [1, 1.5, 1.5, 1.5] + }; + var _currHoverTarget; + var _currPersistent = {}; + var _currHover = {}; + var _prevHover = {}; + var _currSelected = {}; + var _prevSelected = {}; + var _radii = {}; + function sortY(a2, b2) { + return b2.loc[1] - a2.loc[1]; } - function filterImages(images) { - var fromDate = context.photos().fromDate(); - var toDate = context.photos().toDate(); - var usernames = context.photos().usernames(); - if (fromDate) { - var fromTimestamp = new Date(fromDate).getTime(); - images = images.filter(function(item) { - return new Date(item.captured_at).getTime() >= fromTimestamp; - }); - } - if (toDate) { - var toTimestamp = new Date(toDate).getTime(); - images = images.filter(function(item) { - return new Date(item.captured_at).getTime() <= toTimestamp; - }); - } - if (usernames) { - images = images.filter(function(item) { - return usernames.indexOf(item.captured_by) !== -1; - }); - } - return images; + function fastEntityKey(d2) { + var mode = context.mode(); + var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id); + return isMoving ? d2.id : osmEntity.key(d2); } - function filterSequences(sequences) { - var fromDate = context.photos().fromDate(); - var toDate = context.photos().toDate(); - var usernames = context.photos().usernames(); - if (fromDate) { - var fromTimestamp = new Date(fromDate).getTime(); - sequences = sequences.filter(function(image) { - return new Date(image.properties.captured_at).getTime() >= fromTimestamp; - }); + function draw(selection2, graph, vertices, sets2, filter2) { + sets2 = sets2 || { selected: {}, important: {}, hovered: {} }; + var icons = {}; + var directions = {}; + var wireframe = context.surface().classed("fill-wireframe"); + var zoom = geoScaleToZoom(projection2.scale()); + var z2 = zoom < 17 ? 0 : zoom < 18 ? 1 : 2; + var activeID = context.activeID(); + var base = context.history().base(); + function getIcon(d2) { + var entity = graph.entity(d2.id); + if (entity.id in icons) return icons[entity.id]; + icons[entity.id] = entity.hasInterestingTags() && _mainPresetIndex.match(entity, graph).icon; + return icons[entity.id]; } - if (toDate) { - var toTimestamp = new Date(toDate).getTime(); - sequences = sequences.filter(function(image) { - return new Date(image.properties.captured_at).getTime() <= toTimestamp; - }); + function getDirections(entity) { + if (entity.id in directions) return directions[entity.id]; + var angles = entity.directions(graph, projection2); + directions[entity.id] = angles.length ? angles : false; + return angles; } - if (usernames) { - sequences = sequences.filter(function(image) { - return usernames.indexOf(image.properties.captured_by) !== -1; + function updateAttributes(selection3) { + ["shadow", "stroke", "fill"].forEach(function(klass) { + var rads = radiuses[klass]; + selection3.selectAll("." + klass).each(function(entity) { + var i3 = z2 && getIcon(entity); + var r2 = rads[i3 ? 3 : z2]; + if (entity.id !== activeID && entity.isEndpoint(graph) && !entity.isConnected(graph)) { + r2 += 1.5; + } + if (klass === "shadow") { + _radii[entity.id] = r2; + } + select_default2(this).attr("r", r2).attr("visibility", i3 && klass === "fill" ? "hidden" : null); + }); }); } - return sequences; - } - function update() { - var viewer = context.container().select(".photoviewer"); - var selected = viewer.empty() ? void 0 : viewer.datum(); - var z2 = ~~context.map().zoom(); - var showMarkers = z2 >= minMarkerZoom; - var showViewfields = z2 >= minViewfieldZoom2; - var service = getService(); - var sequences = []; - var images = []; - if (context.photos().showsFlat()) { - sequences = service ? service.sequences(projection2) : []; - images = service && showMarkers ? service.images(projection2) : []; - sequences = filterSequences(sequences); - images = filterImages(images); - } - var traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) { - return d2.properties.key; + vertices.sort(sortY); + var groups = selection2.selectAll("g.vertex").filter(filter2).data(vertices, fastEntityKey); + groups.exit().remove(); + var enter = groups.enter().append("g").attr("class", function(d2) { + return "node vertex " + d2.id; + }).order(); + enter.append("circle").attr("class", "shadow"); + enter.append("circle").attr("class", "stroke"); + enter.filter(function(d2) { + return d2.hasInterestingTags(); + }).append("circle").attr("class", "fill"); + groups = groups.merge(enter).attr("transform", svgPointTransform(projection2)).classed("sibling", function(d2) { + return d2.id in sets2.selected; + }).classed("shared", function(d2) { + return graph.isShared(d2); + }).classed("endpoint", function(d2) { + return d2.isEndpoint(graph); + }).classed("added", function(d2) { + return !base.entities[d2.id]; + }).classed("moved", function(d2) { + return base.entities[d2.id] && !(0, import_fast_deep_equal8.default)(graph.entities[d2.id].loc, base.entities[d2.id].loc); + }).classed("retagged", function(d2) { + return base.entities[d2.id] && !(0, import_fast_deep_equal8.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags); + }).call(svgTagClasses()).call(updateAttributes); + var iconUse = groups.selectAll(".icon").data(function data(d2) { + return zoom >= 17 && getIcon(d2) ? [d2] : []; + }, fastEntityKey); + iconUse.exit().remove(); + iconUse.enter().append("use").attr("class", "icon").attr("width", "12px").attr("height", "12px").attr("transform", "translate(-6, -6)").attr("xlink:href", function(d2) { + var picon = getIcon(d2); + return picon ? "#" + picon : ""; }); - traces.exit().remove(); - traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson); - var groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) { - return d2.key; + var dgroups = groups.selectAll(".viewfieldgroup").data(function data(d2) { + return zoom >= 18 && getDirections(d2) ? [d2] : []; + }, fastEntityKey); + dgroups.exit().remove(); + dgroups = dgroups.enter().insert("g", ".shadow").attr("class", "viewfieldgroup").merge(dgroups); + var viewfields = dgroups.selectAll(".viewfield").data(getDirections, function key(d2) { + return osmEntity.key(d2); }); - groups.exit().remove(); - var groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click); - groupsEnter.append("g").attr("class", "viewfield-scale"); - var markers = groups.merge(groupsEnter).sort(function(a2, b2) { - return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1]; - }).attr("transform", transform2).select(".viewfield-scale"); - markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6"); - var viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []); viewfields.exit().remove(); - viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z"); + viewfields.enter().append("path").attr("class", "viewfield").attr("d", "M0,0H0").merge(viewfields).attr("marker-start", "url(#ideditor-viewfield-marker" + (wireframe ? "-wireframe" : "") + ")").attr("transform", function(d2) { + return "rotate(" + d2 + ")"; + }); } - function drawImages(selection2) { - var enabled = svgKartaviewImages.enabled, service = getService(); - layer = selection2.selectAll(".layer-kartaview").data(service ? [0] : []); - layer.exit().remove(); - var layerEnter = layer.enter().append("g").attr("class", "layer-kartaview").style("display", enabled ? "block" : "none"); - layerEnter.append("g").attr("class", "sequences"); - layerEnter.append("g").attr("class", "markers"); - layer = layerEnter.merge(layer); - if (enabled) { - if (service && ~~context.map().zoom() >= minZoom5) { - editOn(); - update(); - service.loadImages(projection2); + function drawTargets(selection2, graph, entities, filter2) { + var targetClass = context.getDebug("target") ? "pink " : "nocolor "; + var nopeClass = context.getDebug("target") ? "red " : "nocolor "; + var getTransform = svgPointTransform(projection2).geojson; + var activeID = context.activeID(); + var data = { targets: [], nopes: [] }; + entities.forEach(function(node) { + if (activeID === node.id) return; + var vertexType = svgPassiveVertex(node, graph, activeID); + if (vertexType !== 0) { + data.targets.push({ + type: "Feature", + id: node.id, + properties: { + target: true, + entity: node + }, + geometry: node.asGeoJSON() + }); } else { - editOff(); + data.nopes.push({ + type: "Feature", + id: node.id + "-nope", + properties: { + nope: true, + target: true, + entity: node + }, + geometry: node.asGeoJSON() + }); } - } - } - drawImages.enabled = function(_2) { - if (!arguments.length) return svgKartaviewImages.enabled; - svgKartaviewImages.enabled = _2; - if (svgKartaviewImages.enabled) { - showLayer(); - context.photos().on("change.kartaview_images", update); - } else { - hideLayer(); - context.photos().on("change.kartaview_images", null); - } - dispatch14.call("change"); - return this; - }; - drawImages.supported = function() { - return !!getService(); - }; - drawImages.rendered = function(zoom) { - return zoom >= minZoom5; - }; - init2(); - return drawImages; - } - - // modules/svg/mapilio_images.js - function svgMapilioImages(projection2, context, dispatch14) { - const throttledRedraw = throttle_default(function() { - dispatch14.call("change"); - }, 1e3); - const minZoom5 = 12; - let layer = select_default2(null); - let _mapilio; - const viewFieldZoomLevel = 18; - function init2() { - if (svgMapilioImages.initialized) return; - svgMapilioImages.enabled = false; - svgMapilioImages.initialized = true; - } - function getService() { - if (services.mapilio && !_mapilio) { - _mapilio = services.mapilio; - _mapilio.event.on("loadedImages", throttledRedraw); - } else if (!services.mapilio && _mapilio) { - _mapilio = null; - } - return _mapilio; - } - function showLayer() { - const service = getService(); - if (!service) return; - editOn(); - layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() { - dispatch14.call("change"); }); - } - function hideLayer() { - throttledRedraw.cancel(); - layer.transition().duration(250).style("opacity", 0).on("end", editOff); - } - function transform2(d2) { - let t2 = svgPointTransform(projection2)(d2); - if (d2.heading) { - t2 += " rotate(" + Math.floor(d2.heading) + ",0,0)"; - } - return t2; - } - function editOn() { - layer.style("display", "block"); - } - function editOff() { - layer.selectAll(".viewfield-group").remove(); - layer.style("display", "none"); - } - function click(d3_event, image) { - const service = getService(); - if (!service) return; - service.ensureViewerLoaded(context, image.id).then(function() { - service.selectImage(context, image.id).showViewer(context); + var targets = selection2.selectAll(".vertex.target-allowed").filter(function(d2) { + return filter2(d2.properties.entity); + }).data(data.targets, function key(d2) { + return d2.id; }); - context.map().centerEase(image.loc); + targets.exit().remove(); + targets.enter().append("circle").attr("r", function(d2) { + return _radii[d2.id] || radiuses.shadow[3]; + }).merge(targets).attr("class", function(d2) { + return "node vertex target target-allowed " + targetClass + d2.id; + }).attr("transform", getTransform); + var nopes = selection2.selectAll(".vertex.target-nope").filter(function(d2) { + return filter2(d2.properties.entity); + }).data(data.nopes, function key(d2) { + return d2.id; + }); + nopes.exit().remove(); + nopes.enter().append("circle").attr("r", function(d2) { + return _radii[d2.properties.entity.id] || radiuses.shadow[3]; + }).merge(nopes).attr("class", function(d2) { + return "node vertex target target-nope " + nopeClass + d2.id; + }).attr("transform", getTransform); } - function mouseover(d3_event, image) { - const service = getService(); - if (service) service.setStyles(context, image); + function renderAsVertex(entity, graph, wireframe, zoom) { + var geometry = entity.geometry(graph); + return geometry === "vertex" || geometry === "point" && (wireframe || zoom >= 18 && entity.directions(graph, projection2).length); } - function mouseout() { - const service = getService(); - if (service) service.setStyles(context, null); + function isEditedNode(node, base, head) { + var baseNode = base.entities[node.id]; + var headNode = head.entities[node.id]; + return !headNode || !baseNode || !(0, import_fast_deep_equal8.default)(headNode.tags, baseNode.tags) || !(0, import_fast_deep_equal8.default)(headNode.loc, baseNode.loc); } - function update() { - const z2 = ~~context.map().zoom(); - const showViewfields = z2 >= viewFieldZoomLevel; - const service = getService(); - let sequences = service ? service.sequences(projection2) : []; - let images = service ? service.images(projection2) : []; - let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) { - return d2.properties.id; - }); - traces.exit().remove(); - traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson); - const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) { - return d2.id; - }); - groups.exit().remove(); - const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click); - groupsEnter.append("g").attr("class", "viewfield-scale"); - const markers = groups.merge(groupsEnter).sort(function(a2, b2) { - return b2.loc[1] - a2.loc[1]; - }).attr("transform", transform2).select(".viewfield-scale"); - markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6"); - const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []); - viewfields.exit().remove(); - viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath); - function viewfieldPath() { - if (this.parentNode.__data__.isPano) { - return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0"; - } else { - return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z"; + function getSiblingAndChildVertices(ids, graph, wireframe, zoom) { + var results = {}; + var seenIds = {}; + function addChildVertices(entity) { + if (seenIds[entity.id]) return; + seenIds[entity.id] = true; + var geometry = entity.geometry(graph); + if (!context.features().isHiddenFeature(entity, graph, geometry)) { + var i3; + if (entity.type === "way") { + for (i3 = 0; i3 < entity.nodes.length; i3++) { + var child = graph.hasEntity(entity.nodes[i3]); + if (child) { + addChildVertices(child); + } + } + } else if (entity.type === "relation") { + for (i3 = 0; i3 < entity.members.length; i3++) { + var member = graph.hasEntity(entity.members[i3].id); + if (member) { + addChildVertices(member); + } + } + } else if (renderAsVertex(entity, graph, wireframe, zoom)) { + results[entity.id] = entity; + } } } - } - function drawImages(selection2) { - const enabled = svgMapilioImages.enabled; - const service = getService(); - layer = selection2.selectAll(".layer-mapilio").data(service ? [0] : []); - layer.exit().remove(); - const layerEnter = layer.enter().append("g").attr("class", "layer-mapilio").style("display", enabled ? "block" : "none"); - layerEnter.append("g").attr("class", "sequences"); - layerEnter.append("g").attr("class", "markers"); - layer = layerEnter.merge(layer); - if (enabled) { - if (service && ~~context.map().zoom() >= minZoom5) { - editOn(); - update(); - service.loadImages(projection2); - service.loadLines(projection2); + ids.forEach(function(id2) { + var entity = graph.hasEntity(id2); + if (!entity) return; + if (entity.type === "node") { + if (renderAsVertex(entity, graph, wireframe, zoom)) { + results[entity.id] = entity; + graph.parentWays(entity).forEach(function(entity2) { + addChildVertices(entity2); + }); + } } else { - editOff(); + addChildVertices(entity); + } + }); + return results; + } + function drawVertices(selection2, graph, entities, filter2, extent, fullRedraw) { + var wireframe = context.surface().classed("fill-wireframe"); + var visualDiff = context.surface().classed("highlight-edited"); + var zoom = geoScaleToZoom(projection2.scale()); + var mode = context.mode(); + var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id); + var base = context.history().base(); + var drawLayer = selection2.selectAll(".layer-osm.points .points-group.vertices"); + var touchLayer = selection2.selectAll(".layer-touch.points"); + if (fullRedraw) { + _currPersistent = {}; + _radii = {}; + } + for (var i3 = 0; i3 < entities.length; i3++) { + var entity = entities[i3]; + var geometry = entity.geometry(graph); + var keep = false; + if (geometry === "point" && renderAsVertex(entity, graph, wireframe, zoom)) { + _currPersistent[entity.id] = entity; + keep = true; + } else if (geometry === "vertex" && (entity.hasInterestingTags() || entity.isEndpoint(graph) || entity.isConnected(graph) || visualDiff && isEditedNode(entity, base, graph))) { + _currPersistent[entity.id] = entity; + keep = true; + } + if (!keep && !fullRedraw) { + delete _currPersistent[entity.id]; } } + var sets2 = { + persistent: _currPersistent, + // persistent = important vertices (render always) + selected: _currSelected, + // selected + siblings of selected (render always) + hovered: _currHover + // hovered + siblings of hovered (render only in draw modes) + }; + var all = Object.assign({}, isMoving ? _currHover : {}, _currSelected, _currPersistent); + var filterRendered = function(d2) { + return d2.id in _currPersistent || d2.id in _currSelected || d2.id in _currHover || filter2(d2); + }; + drawLayer.call(draw, graph, currentVisible(all), sets2, filterRendered); + var filterTouch = function(d2) { + return isMoving ? true : filterRendered(d2); + }; + touchLayer.call(drawTargets, graph, currentVisible(all), filterTouch); + function currentVisible(which) { + return Object.keys(which).map(graph.hasEntity, graph).filter(function(entity2) { + return entity2 && entity2.intersects(extent, graph); + }); + } + } + drawVertices.drawSelected = function(selection2, graph, extent) { + var wireframe = context.surface().classed("fill-wireframe"); + var zoom = geoScaleToZoom(projection2.scale()); + _prevSelected = _currSelected || {}; + if (context.map().isInWideSelection()) { + _currSelected = {}; + context.selectedIDs().forEach(function(id2) { + var entity = graph.hasEntity(id2); + if (!entity) return; + if (entity.type === "node") { + if (renderAsVertex(entity, graph, wireframe, zoom)) { + _currSelected[entity.id] = entity; + } + } + }); + } else { + _currSelected = getSiblingAndChildVertices(context.selectedIDs(), graph, wireframe, zoom); + } + var filter2 = function(d2) { + return d2.id in _prevSelected; + }; + drawVertices(selection2, graph, Object.values(_prevSelected), filter2, extent, false); + }; + drawVertices.drawHover = function(selection2, graph, target, extent) { + if (target === _currHoverTarget) return; + var wireframe = context.surface().classed("fill-wireframe"); + var zoom = geoScaleToZoom(projection2.scale()); + _prevHover = _currHover || {}; + _currHoverTarget = target; + var entity = target && target.properties && target.properties.entity; + if (entity) { + _currHover = getSiblingAndChildVertices([entity.id], graph, wireframe, zoom); + } else { + _currHover = {}; + } + var filter2 = function(d2) { + return d2.id in _prevHover; + }; + drawVertices(selection2, graph, Object.values(_prevHover), filter2, extent, false); + }; + return drawVertices; + } + var import_fast_deep_equal8; + var init_vertices = __esm({ + "modules/svg/vertices.js"() { + "use strict"; + import_fast_deep_equal8 = __toESM(require_fast_deep_equal()); + init_src5(); + init_presets(); + init_geo2(); + init_osm(); + init_helpers(); + init_tag_classes(); } - drawImages.enabled = function(_2) { - if (!arguments.length) return svgMapilioImages.enabled; - svgMapilioImages.enabled = _2; - if (svgMapilioImages.enabled) { - showLayer(); - context.photos().on("change.mapilio_images", update); + }); + + // modules/svg/index.js + var svg_exports = {}; + __export(svg_exports, { + svgAreas: () => svgAreas, + svgData: () => svgData, + svgDebug: () => svgDebug, + svgDefs: () => svgDefs, + svgGeolocate: () => svgGeolocate, + svgIcon: () => svgIcon, + svgKartaviewImages: () => svgKartaviewImages, + svgKeepRight: () => svgKeepRight, + svgLabels: () => svgLabels, + svgLayers: () => svgLayers, + svgLines: () => svgLines, + svgMapilioImages: () => svgMapilioImages, + svgMapillaryImages: () => svgMapillaryImages, + svgMapillarySigns: () => svgMapillarySigns, + svgMarkerSegments: () => svgMarkerSegments, + svgMidpoints: () => svgMidpoints, + svgNotes: () => svgNotes, + svgOsm: () => svgOsm, + svgPanoramaxImages: () => svgPanoramaxImages, + svgPassiveVertex: () => svgPassiveVertex, + svgPath: () => svgPath, + svgPointTransform: () => svgPointTransform, + svgPoints: () => svgPoints, + svgRelationMemberTags: () => svgRelationMemberTags, + svgSegmentWay: () => svgSegmentWay, + svgStreetside: () => svgStreetside, + svgTagClasses: () => svgTagClasses, + svgTagPattern: () => svgTagPattern, + svgTouch: () => svgTouch, + svgTurns: () => svgTurns, + svgVegbilder: () => svgVegbilder, + svgVertices: () => svgVertices + }); + var init_svg = __esm({ + "modules/svg/index.js"() { + "use strict"; + init_areas(); + init_data2(); + init_debug(); + init_defs(); + init_keepRight2(); + init_icon(); + init_geolocate(); + init_labels(); + init_layers(); + init_lines(); + init_mapillary_images(); + init_mapillary_signs(); + init_midpoints(); + init_notes(); + init_helpers(); + init_kartaview_images(); + init_osm2(); + init_helpers(); + init_helpers(); + init_helpers(); + init_points(); + init_helpers(); + init_helpers(); + init_streetside(); + init_vegbilder(); + init_tag_classes(); + init_tag_pattern(); + init_touch(); + init_turns(); + init_vertices(); + init_mapilio_images(); + init_panoramax_images(); + } + }); + + // modules/ui/length_indicator.js + var length_indicator_exports = {}; + __export(length_indicator_exports, { + uiLengthIndicator: () => uiLengthIndicator + }); + function uiLengthIndicator(maxChars) { + var _wrap = select_default2(null); + var _tooltip = uiPopover("tooltip max-length-warning").placement("bottom").hasArrow(true).content(() => (selection2) => { + selection2.text(""); + selection2.call(svgIcon("#iD-icon-alert", "inline")); + selection2.call(_t.append("inspector.max_length_reached", { maxChars })); + }); + var _silent = false; + var lengthIndicator = function(selection2) { + _wrap = selection2.selectAll("span.length-indicator-wrap").data([0]); + _wrap = _wrap.enter().append("span").merge(_wrap).classed("length-indicator-wrap", true); + selection2.call(_tooltip); + }; + lengthIndicator.update = function(val) { + const strLen = utilUnicodeCharsCount(utilCleanOsmString(val, Number.POSITIVE_INFINITY)); + let indicator = _wrap.selectAll("span.length-indicator").data([strLen]); + indicator.enter().append("span").merge(indicator).classed("length-indicator", true).classed("limit-reached", (d2) => d2 > maxChars).style("border-right-width", (d2) => `${Math.abs(maxChars - d2) * 2}px`).style("margin-right", (d2) => d2 > maxChars ? `${(maxChars - d2) * 2}px` : 0).style("opacity", (d2) => d2 > maxChars * 0.8 ? Math.min(1, (d2 / maxChars - 0.8) / (1 - 0.8)) : 0).style("pointer-events", (d2) => d2 > maxChars * 0.8 ? null : "none"); + if (_silent) return; + if (strLen > maxChars) { + _tooltip.show(); } else { - hideLayer(); - context.photos().on("change.mapilio_images", null); + _tooltip.hide(); } - dispatch14.call("change"); - return this; - }; - drawImages.supported = function() { - return !!getService(); }; - drawImages.rendered = function(zoom) { - return zoom >= minZoom5; + lengthIndicator.silent = function(val) { + if (!arguments.length) return _silent; + _silent = val; + return lengthIndicator; }; - init2(); - return drawImages; + return lengthIndicator; } + var init_length_indicator = __esm({ + "modules/ui/length_indicator.js"() { + "use strict"; + init_src5(); + init_localizer(); + init_svg(); + init_util(); + init_popover(); + } + }); - // modules/svg/panoramax_images.js - function svgPanoramaxImages(projection2, context, dispatch14) { - const throttledRedraw = throttle_default(function() { - dispatch14.call("change"); - }, 1e3); - const imageMinZoom2 = 15; - const lineMinZoom2 = 10; - const viewFieldZoomLevel = 18; - let layer = select_default2(null); - let _panoramax; - let _viewerYaw = 0; - let _selectedSequence; - let _activeUsernameFilter; - let _activeIds; - function init2() { - if (svgPanoramaxImages.initialized) return; - svgPanoramaxImages.enabled = false; - svgPanoramaxImages.initialized = true; + // modules/ui/fields/combo.js + var combo_exports = {}; + __export(combo_exports, { + uiFieldCombo: () => uiFieldCombo, + uiFieldManyCombo: () => uiFieldCombo, + uiFieldMultiCombo: () => uiFieldCombo, + uiFieldNetworkCombo: () => uiFieldCombo, + uiFieldSemiCombo: () => uiFieldCombo, + uiFieldTypeCombo: () => uiFieldCombo + }); + function uiFieldCombo(field, context) { + var dispatch14 = dispatch_default("change"); + var _isMulti = field.type === "multiCombo" || field.type === "manyCombo"; + var _isNetwork = field.type === "networkCombo"; + var _isSemi = field.type === "semiCombo"; + var _showTagInfoSuggestions = field.type !== "manyCombo" && field.autoSuggestions !== false; + var _allowCustomValues = field.type !== "manyCombo" && field.customValues !== false; + var _snake_case = field.snake_case || field.snake_case === void 0; + var _combobox = uiCombobox(context, "combo-" + field.safeid).caseSensitive(field.caseSensitive).minItems(1); + var _container = select_default2(null); + var _inputWrap = select_default2(null); + var _input = select_default2(null); + var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue()); + var _comboData = []; + var _multiData = []; + var _entityIDs = []; + var _tags; + var _countryCode; + var _staticPlaceholder; + var _customOptions = []; + var _dataDeprecated = []; + _mainFileFetcher.get("deprecated").then(function(d2) { + _dataDeprecated = d2; + }).catch(function() { + }); + if (_isMulti && field.key && /[^:]$/.test(field.key)) { + field.key += ":"; } - function getService() { - if (services.panoramax && !_panoramax) { - _panoramax = services.panoramax; - _panoramax.event.on("viewerChanged", viewerChanged).on("loadedLines", throttledRedraw).on("loadedImages", throttledRedraw); - } else if (!services.panoramax && _panoramax) { - _panoramax = null; - } - return _panoramax; + function snake(s2) { + return s2.replace(/\s+/g, "_"); } - async function filterImages(images) { - const showsPano = context.photos().showsPanoramic(); - const showsFlat = context.photos().showsFlat(); - const fromDate = context.photos().fromDate(); - const toDate = context.photos().toDate(); - const username = context.photos().usernames(); - const service = getService(); - if (!showsPano || !showsFlat) { - images = images.filter(function(image) { - if (image.isPano) return showsPano; - return showsFlat; - }); - } - if (fromDate) { - images = images.filter(function(image) { - return new Date(image.capture_time).getTime() >= new Date(fromDate).getTime(); - }); + function clean2(s2) { + return s2.split(";").map(function(s3) { + return s3.trim(); + }).join(";"); + } + function tagValue(dval) { + dval = clean2(dval || ""); + var found = getOptions(true).find(function(o2) { + return o2.key && clean2(o2.value) === dval; + }); + if (found) return found.key; + if (field.type === "typeCombo" && !dval) { + return "yes"; } - if (toDate) { - images = images.filter(function(image) { - return new Date(image.capture_time).getTime() <= new Date(toDate).getTime(); - }); + return restrictTagValueSpelling(dval) || void 0; + } + function restrictTagValueSpelling(dval) { + if (_snake_case) { + dval = snake(dval); } - if (username && service) { - if (_activeUsernameFilter !== username) { - _activeUsernameFilter = username; - const tempIds = await service.getUserIds(username); - _activeIds = {}; - tempIds.forEach((id2) => { - _activeIds[id2] = true; - }); - } - images = images.filter(function(image) { - return _activeIds[image.account_id]; - }); + if (!field.caseSensitive) { + dval = dval.toLowerCase(); } - return images; + return dval; } - async function filterSequences(sequences) { - const showsPano = context.photos().showsPanoramic(); - const showsFlat = context.photos().showsFlat(); - const fromDate = context.photos().fromDate(); - const toDate = context.photos().toDate(); - const username = context.photos().usernames(); - const service = getService(); - if (!showsPano || !showsFlat) { - sequences = sequences.filter(function(sequence) { - if (sequence.properties.type === "equirectangular") return showsPano; - return showsFlat; - }); + function getLabelId(field2, v2) { + return field2.hasTextForStringId(`options.${v2}.title`) ? `options.${v2}.title` : `options.${v2}`; + } + function displayValue(tval) { + tval = tval || ""; + var stringsField = field.resolveReference("stringsCrossReference"); + const labelId = getLabelId(stringsField, tval); + if (stringsField.hasTextForStringId(labelId)) { + return stringsField.t(labelId, { default: tval }); } - if (fromDate) { - sequences = sequences.filter(function(sequence) { - return new Date(sequence.properties.date).getTime() >= new Date(fromDate).getTime().toString(); - }); + if (field.type === "typeCombo" && tval.toLowerCase() === "yes") { + return ""; } - if (toDate) { - sequences = sequences.filter(function(sequence) { - return new Date(sequence.properties.date).getTime() <= new Date(toDate).getTime().toString(); - }); + return tval; + } + function renderValue(tval) { + tval = tval || ""; + var stringsField = field.resolveReference("stringsCrossReference"); + const labelId = getLabelId(stringsField, tval); + if (stringsField.hasTextForStringId(labelId)) { + return stringsField.t.append(labelId, { default: tval }); } - if (username && service) { - if (_activeUsernameFilter !== username) { - _activeUsernameFilter = username; - const tempIds = await service.getUserIds(username); - _activeIds = {}; - tempIds.forEach((id2) => { - _activeIds[id2] = true; - }); - } - sequences = sequences.filter(function(sequence) { - return _activeIds[sequence.properties.account_id]; - }); + if (field.type === "typeCombo" && tval.toLowerCase() === "yes") { + tval = ""; } - return sequences; + return (selection2) => selection2.text(tval); } - function showLayer() { - const service = getService(); - if (!service) return; - editOn(); - layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() { - dispatch14.call("change"); + function objectDifference(a2, b2) { + return a2.filter(function(d1) { + return !b2.some(function(d2) { + return d1.value === d2.value; + }); }); } - function hideLayer() { - throttledRedraw.cancel(); - layer.transition().duration(250).style("opacity", 0).on("end", editOff); - } - function transform2(d2, selectedImageId) { - let t2 = svgPointTransform(projection2)(d2); - let rot = d2.heading; - if (d2.id === selectedImageId) { - rot += _viewerYaw; + function initCombo(selection2, attachTo) { + if (!_allowCustomValues) { + selection2.attr("readonly", "readonly"); } - if (rot) { - t2 += " rotate(" + Math.floor(rot) + ",0,0)"; + if (_showTagInfoSuggestions && services.taginfo) { + selection2.call(_combobox.fetcher(setTaginfoValues), attachTo); + setTaginfoValues("", setPlaceholder); + } else { + selection2.call(_combobox, attachTo); + setTimeout(() => setStaticValues(setPlaceholder), 0); } - return t2; - } - function editOn() { - layer.style("display", "block"); - } - function editOff() { - layer.selectAll(".viewfield-group").remove(); - layer.style("display", "none"); } - function click(d3_event, image) { - const service = getService(); - if (!service) return; - if (image.sequence_id !== _selectedSequence) { - _viewerYaw = 0; + function getOptions(allOptions) { + var stringsField = field.resolveReference("stringsCrossReference"); + if (!(field.options || stringsField.options)) return []; + let options2; + if (allOptions !== true) { + options2 = field.options || stringsField.options; + } else { + options2 = [].concat(field.options, stringsField.options).filter(Boolean); } - _selectedSequence = image.sequence_id; - service.ensureViewerLoaded(context).then(function() { - service.selectImage(context, image.id).showViewer(context); + const result = options2.map(function(v2) { + const labelId = getLabelId(stringsField, v2); + return { + key: v2, + value: stringsField.t(labelId, { default: v2 }), + title: stringsField.t(`options.${v2}.description`, { default: v2 }), + display: addComboboxIcons(stringsField.t.append(labelId, { default: v2 }), v2), + klass: stringsField.hasTextForStringId(labelId) ? "" : "raw-option" + }; }); - context.map().centerEase(image.loc); - } - function mouseover(d3_event, image) { - const service = getService(); - if (service) service.setStyles(context, image); + return [...result, ..._customOptions]; } - function mouseout() { - const service = getService(); - if (service) service.setStyles(context, null); + function hasStaticValues() { + return getOptions().length > 0; } - async function update() { - var _a4; - const zoom = ~~context.map().zoom(); - const showViewfields = zoom >= viewFieldZoomLevel; - const service = getService(); - let sequences = service ? service.sequences(projection2, zoom) : []; - let images = service && zoom >= imageMinZoom2 ? service.images(projection2) : []; - images = await filterImages(images); - sequences = await filterSequences(sequences, service); - let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) { - return d2.properties.id; - }); - traces.exit().remove(); - traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson); - const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) { - return d2.id; - }); - groups.exit().remove(); - const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click); - groupsEnter.append("g").attr("class", "viewfield-scale"); - const activeImageId = (_a4 = service.getActiveImage()) == null ? void 0 : _a4.id; - const markers = groups.merge(groupsEnter).sort(function(a2, b2) { - if (a2.id === activeImageId) return 1; - if (b2.id === activeImageId) return -1; - return a2.capture_time_parsed - b2.capture_time_parsed; - }).attr("transform", (d2) => transform2(d2, activeImageId)).select(".viewfield-scale"); - markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6"); - const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []); - viewfields.exit().remove(); - viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath); - service.setStyles(context, null); - function viewfieldPath() { - if (this.parentNode.__data__.isPano) { - return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0"; - } else { - return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z"; - } + function setStaticValues(callback, filter2) { + _comboData = getOptions(); + if (filter2 !== void 0) { + _comboData = _comboData.filter(filter2); } + _comboData = objectDifference(_comboData, _multiData); + _combobox.data(_comboData); + _container.classed("empty-combobox", _comboData.length === 0); + if (callback) callback(_comboData); } - function viewerChanged() { - const service = getService(); - if (!service) return; - const frame2 = service.photoFrame(); - if (!frame2) return; - _viewerYaw = frame2.getYaw(); - if (context.map().isTransformed()) return; - layer.selectAll(".viewfield-group.currentView").attr("transform", (d2) => transform2(d2, d2.id)); - } - function drawImages(selection2) { - const enabled = svgPanoramaxImages.enabled; - const service = getService(); - layer = selection2.selectAll(".layer-panoramax").data(service ? [0] : []); - layer.exit().remove(); - const layerEnter = layer.enter().append("g").attr("class", "layer-panoramax").style("display", enabled ? "block" : "none"); - layerEnter.append("g").attr("class", "sequences"); - layerEnter.append("g").attr("class", "markers"); - layer = layerEnter.merge(layer); - if (enabled) { - let zoom = ~~context.map().zoom(); - if (service) { - if (zoom >= imageMinZoom2) { - editOn(); - update(); - service.loadImages(projection2); - } else if (zoom >= lineMinZoom2) { - editOn(); - update(); - service.loadLines(projection2, zoom); - } else { - editOff(); - } - } else { - editOff(); - } + function setTaginfoValues(q2, callback) { + var queryFilter = (d2) => d2.value.toLowerCase().includes(q2.toLowerCase()) || d2.key.toLowerCase().includes(q2.toLowerCase()); + if (hasStaticValues()) { + setStaticValues(callback, queryFilter); } - } - drawImages.enabled = function(_2) { - if (!arguments.length) return svgPanoramaxImages.enabled; - svgPanoramaxImages.enabled = _2; - if (svgPanoramaxImages.enabled) { - showLayer(); - context.photos().on("change.panoramax_images", update); - } else { - hideLayer(); - context.photos().on("change.panoramax_images", null); + var stringsField = field.resolveReference("stringsCrossReference"); + var fn = _isMulti ? "multikeys" : "values"; + var query = (_isMulti ? field.key : "") + q2; + var hasCountryPrefix = _isNetwork && _countryCode && _countryCode.indexOf(q2.toLowerCase()) === 0; + if (hasCountryPrefix) { + query = _countryCode + ":"; } - dispatch14.call("change"); - return this; - }; - drawImages.supported = function() { - return !!getService(); - }; - drawImages.rendered = function(zoom) { - return zoom >= lineMinZoom2; - }; - init2(); - return drawImages; - } - - // modules/svg/osm.js - function svgOsm(projection2, context, dispatch14) { - var enabled = true; - function drawOsm(selection2) { - selection2.selectAll(".layer-osm").data(["covered", "areas", "lines", "points", "labels"]).enter().append("g").attr("class", function(d2) { - return "layer-osm " + d2; - }); - selection2.selectAll(".layer-osm.points").selectAll(".points-group").data(["points", "midpoints", "vertices", "turns"]).enter().append("g").attr("class", function(d2) { - return "points-group " + d2; - }); - } - function showLayer() { - var layer = context.surface().selectAll(".data-layer.osm"); - layer.interrupt(); - layer.classed("disabled", false).style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", function() { - dispatch14.call("change"); + var params = { + debounce: q2 !== "", + key: field.key, + query + }; + if (_entityIDs.length) { + params.geometry = context.graph().geometry(_entityIDs[0]); + } + services.taginfo[fn](params, function(err, data) { + if (err) return; + data = data.filter((d2) => field.type !== "typeCombo" || d2.value !== "yes"); + data = data.filter((d2) => { + var value = d2.value; + if (_isMulti) { + value = value.slice(field.key.length); + } + return value === restrictTagValueSpelling(value); + }); + var deprecatedValues = deprecatedTagValuesByKey(_dataDeprecated)[field.key]; + if (deprecatedValues) { + data = data.filter((d2) => !deprecatedValues.includes(d2.value)); + } + if (hasCountryPrefix) { + data = data.filter((d2) => d2.value.toLowerCase().indexOf(_countryCode + ":") === 0); + } + const additionalOptions = (field.options || stringsField.options || []).filter((v2) => !data.some((dv) => dv.value === (_isMulti ? field.key + v2 : v2))).map((v2) => ({ value: v2 })); + _container.classed("empty-combobox", data.length === 0); + _comboData = data.concat(additionalOptions).map(function(d2) { + var v2 = d2.value; + if (_isMulti) v2 = v2.replace(field.key, ""); + const labelId = getLabelId(stringsField, v2); + var isLocalizable = stringsField.hasTextForStringId(labelId); + var label = stringsField.t(labelId, { default: v2 }); + return { + key: v2, + value: label, + title: stringsField.t(`options.${v2}.description`, { default: isLocalizable ? v2 : d2.title !== label ? d2.title : "" }), + display: addComboboxIcons(stringsField.t.append(labelId, { default: v2 }), v2), + klass: isLocalizable ? "" : "raw-option" + }; + }); + _comboData = _comboData.filter(queryFilter); + _comboData = objectDifference(_comboData, _multiData); + if (callback) callback(_comboData, hasStaticValues()); }); } - function hideLayer() { - var layer = context.surface().selectAll(".data-layer.osm"); - layer.interrupt(); - layer.transition().duration(250).style("opacity", 0).on("end interrupt", function() { - layer.classed("disabled", true); - dispatch14.call("change"); - }); + function addComboboxIcons(disp, value) { + const iconsField = field.resolveReference("iconsCrossReference"); + if (iconsField.icons) { + return function(selection2) { + var span = selection2.insert("span", ":first-child").attr("class", "tag-value-icon"); + if (iconsField.icons[value]) { + span.call(svgIcon(`#${iconsField.icons[value]}`)); + } + disp.call(this, selection2); + }; + } + return disp; } - drawOsm.enabled = function(val) { - if (!arguments.length) return enabled; - enabled = val; - if (enabled) { - showLayer(); + function setPlaceholder(values) { + if (_isMulti || _isSemi) { + _staticPlaceholder = field.placeholder() || _t("inspector.add"); } else { - hideLayer(); + var vals = values.map(function(d2) { + return d2.value; + }).filter(function(s2) { + return s2.length < 20; + }); + var placeholders = vals.length > 1 ? vals : values.map(function(d2) { + return d2.key; + }); + _staticPlaceholder = field.placeholder() || placeholders.slice(0, 3).join(", "); } - dispatch14.call("change"); - return this; - }; - return drawOsm; - } - - // modules/svg/notes.js - var hash = utilStringQs(window.location.hash); - var _notesEnabled = !!hash.notes; - var _osmService; - function svgNotes(projection2, context, dispatch14) { - if (!dispatch14) { - dispatch14 = dispatch_default("change"); - } - var throttledRedraw = throttle_default(function() { - dispatch14.call("change"); - }, 1e3); - var minZoom5 = 12; - var touchLayer = select_default2(null); - var drawLayer = select_default2(null); - var _notesVisible = false; - function markerPath(selection2, klass) { - selection2.attr("class", klass).attr("transform", "translate(-8, -22)").attr("d", "m17.5,0l-15,0c-1.37,0 -2.5,1.12 -2.5,2.5l0,11.25c0,1.37 1.12,2.5 2.5,2.5l3.75,0l0,3.28c0,0.38 0.43,0.6 0.75,0.37l4.87,-3.65l5.62,0c1.37,0 2.5,-1.12 2.5,-2.5l0,-11.25c0,-1.37 -1.12,-2.5 -2.5,-2.5z"); - } - function getService() { - if (services.osm && !_osmService) { - _osmService = services.osm; - _osmService.on("loadedNotes", throttledRedraw); - } else if (!services.osm && _osmService) { - _osmService = null; + if (!/(…|\.\.\.)$/.test(_staticPlaceholder)) { + _staticPlaceholder += "\u2026"; } - return _osmService; - } - function editOn() { - if (!_notesVisible) { - _notesVisible = true; - drawLayer.style("display", "block"); + var ph; + if (!_isMulti && !_isSemi && _tags && Array.isArray(_tags[field.key])) { + ph = _t("inspector.multiple_values"); + } else { + ph = _staticPlaceholder; } + _container.selectAll("input").attr("placeholder", ph); + var hideAdd = !_allowCustomValues && !values.length; + _container.selectAll(".chiplist .input-wrap").style("display", hideAdd ? "none" : null); } - function editOff() { - if (_notesVisible) { - _notesVisible = false; - drawLayer.style("display", "none"); - drawLayer.selectAll(".note").remove(); - touchLayer.selectAll(".note").remove(); + function change() { + var t2 = {}; + var val; + if (_isMulti || _isSemi) { + var vals; + if (_isMulti) { + vals = [tagValue(utilGetSetValue(_input))]; + } else if (_isSemi) { + val = tagValue(utilGetSetValue(_input)) || ""; + val = val.replace(/,/g, ";"); + vals = val.split(";"); + } + vals = vals.filter(Boolean); + if (!vals.length) return; + _container.classed("active", false); + utilGetSetValue(_input, ""); + if (_isMulti) { + utilArrayUniq(vals).forEach(function(v2) { + var key = (field.key || "") + v2; + if (_tags) { + var old = _tags[key]; + if (typeof old === "string" && old.toLowerCase() !== "no") return; + } + key = context.cleanTagKey(key); + field.keys.push(key); + t2[key] = "yes"; + }); + } else if (_isSemi) { + var arr = _multiData.map(function(d2) { + return d2.key; + }); + arr = arr.concat(vals); + t2[field.key] = context.cleanTagValue(utilArrayUniq(arr).filter(Boolean).join(";")); + } + window.setTimeout(function() { + _input.node().focus(); + }, 10); + } else { + var rawValue = utilGetSetValue(_input); + if (!rawValue && Array.isArray(_tags[field.key])) return; + val = context.cleanTagValue(tagValue(rawValue)); + t2[field.key] = val || void 0; } + dispatch14.call("change", this, t2); } - function layerOn() { - editOn(); - drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", function() { - dispatch14.call("change"); - }); - } - function layerOff() { - throttledRedraw.cancel(); - drawLayer.interrupt(); - touchLayer.selectAll(".note").remove(); - drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", function() { - editOff(); - dispatch14.call("change"); - }); - } - function updateMarkers() { - if (!_notesVisible || !_notesEnabled) return; - var service = getService(); - var selectedID = context.selectedNoteID(); - var data = service ? service.notes(projection2) : []; - var getTransform = svgPointTransform(projection2); - var notes = drawLayer.selectAll(".note").data(data, function(d2) { - return d2.status + d2.id; - }); - notes.exit().remove(); - var notesEnter = notes.enter().append("g").attr("class", function(d2) { - return "note note-" + d2.id + " " + d2.status; - }).classed("new", function(d2) { - return d2.id < 0; - }); - notesEnter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke"); - notesEnter.append("path").call(markerPath, "shadow"); - notesEnter.append("use").attr("class", "note-fill").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").attr("xlink:href", "#iD-icon-note"); - notesEnter.selectAll(".icon-annotation").data(function(d2) { - return [d2]; - }).enter().append("use").attr("class", "icon-annotation").attr("width", "10px").attr("height", "10px").attr("x", "-3px").attr("y", "-19px").attr("xlink:href", function(d2) { - if (d2.id < 0) return "#iD-icon-plus"; - if (d2.status === "open") return "#iD-icon-close"; - return "#iD-icon-apply"; - }); - notes.merge(notesEnter).sort(sortY).classed("selected", function(d2) { - var mode = context.mode(); - var isMoving = mode && mode.id === "drag-note"; - return !isMoving && d2.id === selectedID; - }).attr("transform", getTransform); - if (touchLayer.empty()) return; - var fillClass = context.getDebug("target") ? "pink " : "nocolor "; - var targets = touchLayer.selectAll(".note").data(data, function(d2) { - return d2.id; - }); - targets.exit().remove(); - targets.enter().append("rect").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").merge(targets).sort(sortY).attr("class", function(d2) { - var newClass = d2.id < 0 ? "new" : ""; - return "note target note-" + d2.id + " " + fillClass + newClass; - }).attr("transform", getTransform); - function sortY(a2, b2) { - if (a2.id === selectedID) return 1; - if (b2.id === selectedID) return -1; - return b2.loc[1] - a2.loc[1]; + function removeMultikey(d3_event, d2) { + d3_event.preventDefault(); + d3_event.stopPropagation(); + var t2 = {}; + if (_isMulti) { + t2[d2.key] = void 0; + } else if (_isSemi) { + var arr = _multiData.map(function(md) { + return md.key === d2.key ? null : md.key; + }).filter(Boolean); + arr = utilArrayUniq(arr); + t2[field.key] = arr.length ? arr.join(";") : void 0; + _lengthIndicator.update(t2[field.key]); } + dispatch14.call("change", this, t2); } - function drawNotes(selection2) { - var service = getService(); - var surface = context.surface(); - if (surface && !surface.empty()) { - touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers"); - } - drawLayer = selection2.selectAll(".layer-notes").data(service ? [0] : []); - drawLayer.exit().remove(); - drawLayer = drawLayer.enter().append("g").attr("class", "layer-notes").style("display", _notesEnabled ? "block" : "none").merge(drawLayer); - if (_notesEnabled) { - if (service && ~~context.map().zoom() >= minZoom5) { - editOn(); - service.loadNotes(projection2); - updateMarkers(); - } else { - editOff(); - } + function invertMultikey(d3_event, d2) { + d3_event.preventDefault(); + d3_event.stopPropagation(); + var t2 = {}; + if (_isMulti) { + t2[d2.key] = _tags[d2.key] === "yes" ? "no" : "yes"; } + dispatch14.call("change", this, t2); } - drawNotes.enabled = function(val) { - if (!arguments.length) return _notesEnabled; - _notesEnabled = val; - if (_notesEnabled) { - layerOn(); - } else { - layerOff(); - if (context.selectedNoteID()) { - context.enter(modeBrowse(context)); + function combo(selection2) { + _container = selection2.selectAll(".form-field-input-wrap").data([0]); + var type2 = _isMulti || _isSemi ? "multicombo" : "combo"; + _container = _container.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + type2).merge(_container); + if (_isMulti || _isSemi) { + _container = _container.selectAll(".chiplist").data([0]); + var listClass = "chiplist"; + if (field.key === "destination" || field.key === "via") { + listClass += " full-line-chips"; } + _container = _container.enter().append("ul").attr("class", listClass).on("click", function() { + window.setTimeout(function() { + _input.node().focus(); + }, 10); + }).merge(_container); + _inputWrap = _container.selectAll(".input-wrap").data([0]); + _inputWrap = _inputWrap.enter().append("li").attr("class", "input-wrap").merge(_inputWrap); + var hideAdd = !_allowCustomValues && !_comboData.length; + _inputWrap.style("display", hideAdd ? "none" : null); + _input = _inputWrap.selectAll("input").data([0]); + } else { + _input = _container.selectAll("input").data([0]); } - dispatch14.call("change"); - return this; - }; - return drawNotes; - } - - // modules/svg/touch.js - function svgTouch() { - function drawTouch(selection2) { - selection2.selectAll(".layer-touch").data(["areas", "lines", "points", "turns", "markers"]).enter().append("g").attr("class", function(d2) { - return "layer-touch " + d2; - }); - } - return drawTouch; - } - - // modules/util/dimensions.js - function refresh(selection2, node) { - var cr = node.getBoundingClientRect(); - var prop = [cr.width, cr.height]; - selection2.property("__dimensions__", prop); - return prop; - } - function utilGetDimensions(selection2, force) { - if (!selection2 || selection2.empty()) { - return [0, 0]; - } - var node = selection2.node(), cached = selection2.property("__dimensions__"); - return !cached || force ? refresh(selection2, node) : cached; - } - function utilSetDimensions(selection2, dimensions) { - if (!selection2 || selection2.empty()) { - return selection2; - } - var node = selection2.node(); - if (dimensions === null) { - refresh(selection2, node); - return selection2; - } - return selection2.property("__dimensions__", [dimensions[0], dimensions[1]]).attr("width", dimensions[0]).attr("height", dimensions[1]); - } - - // modules/svg/layers.js - function svgLayers(projection2, context) { - var dispatch14 = dispatch_default("change"); - var svg2 = select_default2(null); - var _layers = [ - { id: "osm", layer: svgOsm(projection2, context, dispatch14) }, - { id: "notes", layer: svgNotes(projection2, context, dispatch14) }, - { id: "data", layer: svgData(projection2, context, dispatch14) }, - { id: "keepRight", layer: svgKeepRight(projection2, context, dispatch14) }, - { id: "osmose", layer: svgOsmose(projection2, context, dispatch14) }, - { id: "streetside", layer: svgStreetside(projection2, context, dispatch14) }, - { id: "mapillary", layer: svgMapillaryImages(projection2, context, dispatch14) }, - { id: "mapillary-position", layer: svgMapillaryPosition(projection2, context, dispatch14) }, - { id: "mapillary-map-features", layer: svgMapillaryMapFeatures(projection2, context, dispatch14) }, - { id: "mapillary-signs", layer: svgMapillarySigns(projection2, context, dispatch14) }, - { id: "kartaview", layer: svgKartaviewImages(projection2, context, dispatch14) }, - { id: "mapilio", layer: svgMapilioImages(projection2, context, dispatch14) }, - { id: "vegbilder", layer: svgVegbilder(projection2, context, dispatch14) }, - { id: "panoramax", layer: svgPanoramaxImages(projection2, context, dispatch14) }, - { id: "local-photos", layer: svgLocalPhotos(projection2, context, dispatch14) }, - { id: "debug", layer: svgDebug(projection2, context, dispatch14) }, - { id: "geolocate", layer: svgGeolocate(projection2, context, dispatch14) }, - { id: "touch", layer: svgTouch(projection2, context, dispatch14) } - ]; - function drawLayers(selection2) { - svg2 = selection2.selectAll(".surface").data([0]); - svg2 = svg2.enter().append("svg").attr("class", "surface").merge(svg2); - var defs = svg2.selectAll(".surface-defs").data([0]); - defs.enter().append("defs").attr("class", "surface-defs"); - var groups = svg2.selectAll(".data-layer").data(_layers); - groups.exit().remove(); - groups.enter().append("g").attr("class", function(d2) { - return "data-layer " + d2.id; - }).merge(groups).each(function(d2) { - select_default2(this).call(d2.layer); - }); - } - drawLayers.all = function() { - return _layers; - }; - drawLayers.layer = function(id2) { - var obj = _layers.find(function(o2) { - return o2.id === id2; + _input = _input.enter().append("input").attr("type", "text").attr("id", field.domId).call(utilNoAuto).call(initCombo, _container).merge(_input); + if (_isSemi) { + _inputWrap.call(_lengthIndicator); + } else if (!_isMulti) { + _container.call(_lengthIndicator); + } + if (_isNetwork) { + var extent = combinedEntityExtent(); + var countryCode = extent && iso1A2Code(extent.center()); + _countryCode = countryCode && countryCode.toLowerCase(); + } + _input.on("change", change).on("blur", change).on("input", function() { + let val = utilGetSetValue(_input); + updateIcon(val); + if (_isSemi && _tags[field.key]) { + val += ";" + _tags[field.key]; + } + _lengthIndicator.update(val); }); - return obj && obj.layer; - }; - drawLayers.only = function(what) { - var arr = [].concat(what); - var all = _layers.map(function(layer) { - return layer.id; + _input.on("keydown.field", function(d3_event) { + switch (d3_event.keyCode) { + case 13: + _input.node().blur(); + d3_event.stopPropagation(); + break; + } }); - return drawLayers.remove(utilArrayDifference(all, arr)); - }; - drawLayers.remove = function(what) { - var arr = [].concat(what); - arr.forEach(function(id2) { - _layers = _layers.filter(function(o2) { - return o2.id !== id2; + if (_isMulti || _isSemi) { + _combobox.on("accept", function() { + _input.node().blur(); + _input.node().focus(); + }); + _input.on("focus", function() { + _container.classed("active", true); }); + } + _combobox.on("cancel", function() { + _input.node().blur(); + }).on("update", function() { + updateIcon(utilGetSetValue(_input)); }); - dispatch14.call("change"); - return this; - }; - drawLayers.add = function(what) { - var arr = [].concat(what); - arr.forEach(function(obj) { - if ("id" in obj && "layer" in obj) { - _layers.push(obj); + } + function updateIcon(value) { + value = tagValue(value); + let container = _container; + if (field.type === "multiCombo" || field.type === "semiCombo") { + container = _container.select(".input-wrap"); + } + const iconsField = field.resolveReference("iconsCrossReference"); + if (iconsField.icons) { + container.selectAll(".tag-value-icon").remove(); + if (iconsField.icons[value]) { + container.selectAll(".tag-value-icon").data([value]).enter().insert("div", "input").attr("class", "tag-value-icon").call(svgIcon(`#${iconsField.icons[value]}`)); } - }); - dispatch14.call("change"); - return this; - }; - drawLayers.dimensions = function(val) { - if (!arguments.length) return utilGetDimensions(svg2); - utilSetDimensions(svg2, val); - return this; - }; - return utilRebind(drawLayers, dispatch14, "on"); - } - - // modules/svg/lines.js - var import_fast_deep_equal6 = __toESM(require_fast_deep_equal()); - function onewayArrowColour(tags) { - if (tags.highway === "construction" && tags.bridge) return "white"; - if (tags.highway === "pedestrian" && tags.bridge) return "pink"; - if (tags.railway) return "black"; - if (tags.aeroway === "runway") return "pink"; - return "black"; - } - function svgLines(projection2, context) { - var detected = utilDetect(); - var highway_stack = { - motorway: 0, - motorway_link: 1, - trunk: 2, - trunk_link: 3, - primary: 4, - primary_link: 5, - secondary: 6, - tertiary: 7, - unclassified: 8, - residential: 9, - service: 10, - busway: 11, - footway: 12 - }; - function drawTargets(selection2, graph, entities, filter2) { - var targetClass = context.getDebug("target") ? "pink " : "nocolor "; - var nopeClass = context.getDebug("target") ? "red " : "nocolor "; - var getPath = svgPath(projection2).geojson; - var activeID = context.activeID(); - var base = context.history().base(); - var data = { targets: [], nopes: [] }; - entities.forEach(function(way) { - var features = svgSegmentWay(way, graph, activeID); - data.targets.push.apply(data.targets, features.passive); - data.nopes.push.apply(data.nopes, features.active); - }); - var targetData = data.targets.filter(getPath); - var targets = selection2.selectAll(".line.target-allowed").filter(function(d2) { - return filter2(d2.properties.entity); - }).data(targetData, function key(d2) { - return d2.id; - }); - targets.exit().remove(); - var segmentWasEdited = function(d2) { - var wayID = d2.properties.entity.id; - if (!base.entities[wayID] || !(0, import_fast_deep_equal6.default)(graph.entities[wayID].nodes, base.entities[wayID].nodes)) { - return false; + } + } + combo.tags = function(tags) { + _tags = tags; + var stringsField = field.resolveReference("stringsCrossReference"); + var isMixed = Array.isArray(tags[field.key]); + var showsValue = (value) => !isMixed && value && !(field.type === "typeCombo" && value === "yes"); + var isRawValue = (value) => showsValue(value) && !stringsField.hasTextForStringId(`options.${value}`) && !stringsField.hasTextForStringId(`options.${value}.title`); + var isKnownValue = (value) => showsValue(value) && !isRawValue(value); + var isReadOnly = !_allowCustomValues; + if (_isMulti || _isSemi) { + _multiData = []; + var maxLength; + if (_isMulti) { + for (var k2 in tags) { + if (field.key && k2.indexOf(field.key) !== 0) continue; + if (!field.key && field.keys.indexOf(k2) === -1) continue; + var v2 = tags[k2]; + var suffix = field.key ? k2.slice(field.key.length) : k2; + _multiData.push({ + key: k2, + value: displayValue(suffix), + display: addComboboxIcons(renderValue(suffix), suffix), + state: typeof v2 === "string" ? v2.toLowerCase() : "", + isMixed: Array.isArray(v2) + }); + } + if (field.key) { + field.keys = _multiData.map(function(d2) { + return d2.key; + }); + maxLength = context.maxCharsForTagKey() - utilUnicodeCharsCount(field.key); + } else { + maxLength = context.maxCharsForTagKey(); + } + } else if (_isSemi) { + var allValues = []; + var commonValues; + if (Array.isArray(tags[field.key])) { + tags[field.key].forEach(function(tagVal) { + var thisVals = utilArrayUniq((tagVal || "").split(";")).filter(Boolean); + allValues = allValues.concat(thisVals); + if (!commonValues) { + commonValues = thisVals; + } else { + commonValues = commonValues.filter((value) => thisVals.includes(value)); + } + }); + allValues = utilArrayUniq(allValues).filter(Boolean); + } else { + allValues = utilArrayUniq((tags[field.key] || "").split(";")).filter(Boolean); + commonValues = allValues; + } + _multiData = allValues.map(function(v3) { + return { + key: v3, + value: displayValue(v3), + display: addComboboxIcons(renderValue(v3), v3), + isMixed: !commonValues.includes(v3) + }; + }); + var currLength = utilUnicodeCharsCount(commonValues.join(";")); + maxLength = context.maxCharsForTagValue() - currLength; + if (currLength > 0) { + maxLength -= 1; + } } - return d2.properties.nodes.some(function(n3) { - return !base.entities[n3.id] || !(0, import_fast_deep_equal6.default)(graph.entities[n3.id].loc, base.entities[n3.id].loc); - }); - }; - targets.enter().append("path").merge(targets).attr("d", getPath).attr("class", function(d2) { - return "way line target target-allowed " + targetClass + d2.id; - }).classed("segment-edited", segmentWasEdited); - var nopeData = data.nopes.filter(getPath); - var nopes = selection2.selectAll(".line.target-nope").filter(function(d2) { - return filter2(d2.properties.entity); - }).data(nopeData, function key(d2) { - return d2.id; - }); - nopes.exit().remove(); - nopes.enter().append("path").merge(nopes).attr("d", getPath).attr("class", function(d2) { - return "way line target target-nope " + nopeClass + d2.id; - }).classed("segment-edited", segmentWasEdited); - } - function drawLines(selection2, graph, entities, filter2) { - var base = context.history().base(); - function waystack(a2, b2) { - var selected = context.selectedIDs(); - var scoreA = selected.indexOf(a2.id) !== -1 ? 20 : 0; - var scoreB = selected.indexOf(b2.id) !== -1 ? 20 : 0; - if (a2.tags.highway) { - scoreA -= highway_stack[a2.tags.highway]; + maxLength = Math.max(0, maxLength); + var hideAdd = maxLength <= 0 || !_allowCustomValues && !_comboData.length; + _container.selectAll(".chiplist .input-wrap").style("display", hideAdd ? "none" : null); + var allowDragAndDrop = _isSemi && !Array.isArray(tags[field.key]); + var chips = _container.selectAll(".chip").data(_multiData); + chips.exit().remove(); + var enter = chips.enter().insert("li", ".input-wrap").attr("class", "chip"); + enter.append("span"); + 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) k3 = k3.replace(field.key, ""); + return !stringsField.hasTextForStringId("options." + k3); + }).classed("draggable", allowDragAndDrop).classed("mixed", function(d2) { + return d2.isMixed; + }).attr("title", function(d2) { + if (d2.isMixed) { + return _t("inspector.unshared_value_tooltip"); + } + if (!["yes", "no"].includes(d2.state)) { + return d2.state; + } + return null; + }).classed("negated", (d2) => d2.state === "no"); + if (!_isSemi) { + chips.selectAll("input[type=checkbox]").remove(); + chips.insert("input", "span").attr("type", "checkbox").property("checked", (d2) => d2.state === "yes").property("indeterminate", (d2) => d2.isMixed || !["yes", "no"].includes(d2.state)).on("click", invertMultikey); } - if (b2.tags.highway) { - scoreB -= highway_stack[b2.tags.highway]; + if (allowDragAndDrop) { + registerDragAndDrop(chips); } - return scoreA - scoreB; - } - function drawLineGroup(selection3, klass, isSelected) { - var mode = context.mode(); - var isDrawing = mode && /^draw/.test(mode.id); - var selectedClass = !isDrawing && isSelected ? "selected " : ""; - var lines = selection3.selectAll("path").filter(filter2).data(getPathData(isSelected), osmEntity.key); - lines.exit().remove(); - lines.enter().append("path").attr("class", function(d2) { - var prefix = "way line"; - if (!d2.hasInterestingTags()) { - var parentRelations = graph.parentRelations(d2); - var parentMultipolygons = parentRelations.filter(function(relation) { - return relation.isMultipolygon(); + 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"); }); - if (parentMultipolygons.length > 0 && // and only multipolygon relations - parentRelations.length === parentMultipolygons.length) { - prefix = "relation area"; - } + return; } - var oldMPClass = oldMultiPolygonOuters[d2.id] ? "old-multipolygon " : ""; - return prefix + " " + klass + " " + selectedClass + oldMPClass + d2.id; - }).classed("added", function(d2) { - return !base.entities[d2.id]; - }).classed("geometry-edited", function(d2) { - return graph.entities[d2.id] && base.entities[d2.id] && !(0, import_fast_deep_equal6.default)(graph.entities[d2.id].nodes, base.entities[d2.id].nodes); - }).classed("retagged", function(d2) { - return graph.entities[d2.id] && base.entities[d2.id] && !(0, import_fast_deep_equal6.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags); - }).call(svgTagClasses()).merge(lines).sort(waystack).attr("d", getPath).call(svgTagClasses().tags(svgRelationMemberTags(graph))); - return selection3; - } - function getPathData(isSelected) { - return function() { - var layer = this.parentNode.__data__; - var data = pathdata[layer] || []; - return data.filter(function(d2) { - if (isSelected) { - return context.selectedIDs().indexOf(d2.id) !== -1; - } else { - return context.selectedIDs().indexOf(d2.id) === -1; - } - }); - }; - } - function addMarkers(layergroup, pathclass, groupclass, groupdata, marker) { - var markergroup = layergroup.selectAll("g." + groupclass).data([pathclass]); - markergroup = markergroup.enter().append("g").attr("class", groupclass).merge(markergroup); - var markers = markergroup.selectAll("path").filter(filter2).data( - function data() { - return groupdata[this.parentNode.__data__] || []; - }, - function key(d2) { - return [d2.id, d2.index]; + if (d2.display) { + d2.display(text_span); + return; } - ); - markers.exit().remove(); - markers = markers.enter().append("path").attr("class", pathclass).merge(markers).attr("marker-mid", marker).attr("d", function(d2) { - return d2.d; + text_span.text(d2.value); }); - if (detected.ie) { - markers.each(function() { - this.parentNode.insertBefore(this, this); - }); + 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) { + return displayValue(val); + }).filter(Boolean); + utilGetSetValue(_input, !isMixed ? displayValue(tags[field.key]) : "").data([tags[field.key]]).classed("raw-value", isRawValue).classed("known-value", isKnownValue).attr("readonly", isReadOnly ? "readonly" : void 0).attr("title", isMixed ? mixedValues.join("\n") : void 0).attr("placeholder", isMixed ? _t("inspector.multiple_values") : _staticPlaceholder || "").classed("mixed", isMixed).on("keydown.deleteCapture", function(d3_event) { + if (isReadOnly && isKnownValue(tags[field.key]) && (d3_event.keyCode === utilKeybinding.keyCodes["\u232B"] || d3_event.keyCode === utilKeybinding.keyCodes["\u2326"])) { + d3_event.preventDefault(); + d3_event.stopPropagation(); + var t2 = {}; + t2[field.key] = void 0; + dispatch14.call("change", this, t2); + } + }); + if (!Array.isArray(tags[field.key])) { + updateIcon(tags[field.key]); } - } - var getPath = svgPath(projection2, graph); - var ways = []; - var onewaydata = {}; - var sideddata = {}; - var oldMultiPolygonOuters = {}; - for (var i3 = 0; i3 < entities.length; i3++) { - var entity = entities[i3]; - if (entity.geometry(graph) === "line" || entity.geometry(graph) === "area" && entity.sidednessIdentifier && entity.sidednessIdentifier() === "coastline") { - ways.push(entity); + if (!isMixed) { + _lengthIndicator.update(tags[field.key]); } } - ways = ways.filter(getPath); - const pathdata = utilArrayGroupBy(ways, (way) => Math.trunc(way.layer())); - Object.keys(pathdata).forEach(function(k2) { - var v2 = pathdata[k2]; - var onewayArr = v2.filter(function(d2) { - return d2.isOneWay(); - }); - var onewaySegments = svgMarkerSegments( - projection2, - graph, - 35, - (entity2) => entity2.isOneWayBackwards(), - (entity2) => entity2.isBiDirectional() - ); - onewaydata[k2] = utilArrayFlatten(onewayArr.map(onewaySegments)); - var sidedArr = v2.filter(function(d2) { - return d2.isSided(); - }); - var sidedSegments = svgMarkerSegments( - projection2, - graph, - 30, - function shouldReverse() { - return false; - }, - function bothDirections() { - return false; + const refreshStyles = () => { + _input.data([tagValue(utilGetSetValue(_input))]).classed("raw-value", isRawValue).classed("known-value", isKnownValue); + }; + _input.on("input.refreshStyles", refreshStyles); + _combobox.on("update.refreshStyles", refreshStyles); + refreshStyles(); + }; + function registerDragAndDrop(selection2) { + var dragOrigin, targetIndex; + selection2.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 = selection2.nodes().indexOf(this); + select_default2(this).classed("dragging", true); + targetIndex = null; + var targetIndexOffsetTop = null; + var draggedTagWidth = select_default2(this).node().offsetWidth; + if (field.key === "destination" || field.key === "via") { + _container.selectAll(".chip").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; + }); + } else { + _container.selectAll(".chip").each(function(d2, index2) { + var node = select_default2(this).node(); + if (index !== index2 && d3_event.x < node.offsetLeft + node.offsetWidth + 5 && d3_event.x > node.offsetLeft && d3_event.y < node.offsetTop + node.offsetHeight && d3_event.y > node.offsetTop) { + targetIndex = index2; + targetIndexOffsetTop = node.offsetTop; + } + }).style("transform", function(d2, index2) { + var node = select_default2(this).node(); + if (index === index2) { + return "translate(" + x2 + "px, " + y2 + "px)"; + } + if (node.offsetTop === targetIndexOffsetTop) { + if (index2 < index && index2 >= targetIndex) { + return "translateX(" + draggedTagWidth + "px)"; + } else if (index2 > index && index2 <= targetIndex) { + return "translateX(-" + draggedTagWidth + "px)"; + } + } + return null; + }); } - ); - sideddata[k2] = utilArrayFlatten(sidedArr.map(sidedSegments)); - }); - var covered = selection2.selectAll(".layer-osm.covered"); - var uncovered = selection2.selectAll(".layer-osm.lines"); - var touchLayer = selection2.selectAll(".layer-touch.lines"); - [covered, uncovered].forEach(function(selection3) { - var range3 = selection3 === covered ? range(-10, 0) : range(0, 11); - var layergroup = selection3.selectAll("g.layergroup").data(range3); - layergroup = layergroup.enter().append("g").attr("class", function(d2) { - return "layergroup layer" + String(d2); - }).merge(layergroup); - layergroup.selectAll("g.linegroup").data(["shadow", "casing", "stroke", "shadow-highlighted", "casing-highlighted", "stroke-highlighted"]).enter().append("g").attr("class", function(d2) { - return "linegroup line-" + d2; - }); - layergroup.selectAll("g.line-shadow").call(drawLineGroup, "shadow", false); - layergroup.selectAll("g.line-casing").call(drawLineGroup, "casing", false); - layergroup.selectAll("g.line-stroke").call(drawLineGroup, "stroke", false); - layergroup.selectAll("g.line-shadow-highlighted").call(drawLineGroup, "shadow", true); - layergroup.selectAll("g.line-casing-highlighted").call(drawLineGroup, "casing", true); - layergroup.selectAll("g.line-stroke-highlighted").call(drawLineGroup, "stroke", true); - addMarkers(layergroup, "oneway", "onewaygroup", onewaydata, (d2) => { - const category = onewayArrowColour(graph.entity(d2.id).tags); - return "url(#ideditor-oneway-marker-".concat(category, ")"); - }); - addMarkers( - layergroup, - "sided", - "sidedgroup", - sideddata, - function marker(d2) { - var category = graph.entity(d2.id).sidednessIdentifier(); - return "url(#ideditor-sided-marker-" + category + ")"; + }).on("end", function() { + if (!select_default2(this).classed("dragging")) { + return; } - ); - }); - touchLayer.call(drawTargets, graph, ways, filter2); + var index = selection2.nodes().indexOf(this); + select_default2(this).classed("dragging", false); + _container.selectAll(".chip").style("transform", null); + if (typeof targetIndex === "number") { + var element = _multiData[index]; + _multiData.splice(index, 1); + _multiData.splice(targetIndex, 0, element); + var t2 = {}; + if (_multiData.length) { + t2[field.key] = _multiData.map(function(element2) { + return element2.key; + }).join(";"); + } else { + t2[field.key] = void 0; + } + dispatch14.call("change", this, t2); + } + dragOrigin = void 0; + targetIndex = void 0; + }) + ); } - return drawLines; + combo.setCustomOptions = (newValue) => { + _customOptions = newValue; + }; + combo.focus = function() { + _input.node().focus(); + }; + combo.entityIDs = function(val) { + if (!arguments.length) return _entityIDs; + _entityIDs = val; + return combo; + }; + function combinedEntityExtent() { + return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph()); + } + return utilRebind(combo, dispatch14, "on"); } + var init_combo = __esm({ + "modules/ui/fields/combo.js"() { + "use strict"; + init_src4(); + init_src5(); + init_src6(); + init_country_coder(); + init_file_fetcher(); + init_localizer(); + init_services(); + init_combobox(); + init_icon(); + init_keybinding(); + init_util(); + init_length_indicator(); + init_deprecated(); + } + }); - // modules/svg/midpoints.js - function svgMidpoints(projection2, context) { - var targetRadius = 8; - function drawTargets(selection2, graph, entities, filter2) { - var fillClass = context.getDebug("target") ? "pink " : "nocolor "; - var getTransform = svgPointTransform(projection2).geojson; - var data = entities.map(function(midpoint) { - return { - type: "Feature", - id: midpoint.id, - properties: { - target: true, - entity: midpoint - }, - geometry: { - type: "Point", - coordinates: midpoint.loc - } - }; + // modules/behavior/hash.js + var hash_exports = {}; + __export(hash_exports, { + behaviorHash: () => behaviorHash + }); + function behaviorHash(context) { + var _cachedHash = null; + var _latitudeLimit = 90 - 1e-8; + function computedHashParameters() { + var map2 = context.map(); + var center = map2.center(); + var zoom = map2.zoom(); + var precision3 = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)); + var oldParams = utilObjectOmit( + utilStringQs(window.location.hash), + ["comment", "source", "hashtags", "walkthrough"] + ); + var newParams = {}; + delete oldParams.id; + var selected = context.selectedIDs().filter(function(id2) { + return context.hasEntity(id2); }); - var targets = selection2.selectAll(".midpoint.target").filter(function(d2) { - return filter2(d2.properties.entity); - }).data(data, function key(d2) { - return d2.id; + if (selected.length) { + newParams.id = selected.join(","); + } else if (context.selectedNoteID()) { + newParams.id = `note/${context.selectedNoteID()}`; + } + newParams.map = zoom.toFixed(2) + "/" + center[1].toFixed(precision3) + "/" + center[0].toFixed(precision3); + return Object.assign(oldParams, newParams); + } + function computedHash() { + return "#" + utilQsString(computedHashParameters(), true); + } + function computedTitle(includeChangeCount) { + var baseTitle = context.documentTitleBase() || "iD"; + var contextual; + var changeCount; + var titleID; + var selected = context.selectedIDs().filter(function(id2) { + return context.hasEntity(id2); }); - targets.exit().remove(); - targets.enter().append("circle").attr("r", targetRadius).merge(targets).attr("class", function(d2) { - return "node midpoint target " + fillClass + d2.id; - }).attr("transform", getTransform); + if (selected.length) { + var firstLabel = utilDisplayLabel(context.entity(selected[0]), context.graph()); + if (selected.length > 1) { + contextual = _t("title.labeled_and_more", { + labeled: firstLabel, + count: selected.length - 1 + }); + } else { + contextual = firstLabel; + } + titleID = "context"; + } + if (includeChangeCount) { + changeCount = context.history().difference().summary().length; + if (changeCount > 0) { + titleID = contextual ? "changes_context" : "changes"; + } + } + if (titleID) { + return _t("title.format." + titleID, { + changes: changeCount, + base: baseTitle, + context: contextual + }); + } + return baseTitle; } - function drawMidpoints(selection2, graph, entities, filter2, extent) { - var drawLayer = selection2.selectAll(".layer-osm.points .points-group.midpoints"); - var touchLayer = selection2.selectAll(".layer-touch.points"); - var mode = context.mode(); - if (mode && mode.id !== "select" || !context.map().withinEditableZoom()) { - drawLayer.selectAll(".midpoint").remove(); - touchLayer.selectAll(".midpoint.target").remove(); - return; + function updateTitle(includeChangeCount) { + if (!context.setsDocumentTitle()) return; + var newTitle = computedTitle(includeChangeCount); + if (document.title !== newTitle) { + document.title = newTitle; } - var poly = extent.polygon(); - var midpoints = {}; - for (var i3 = 0; i3 < entities.length; i3++) { - var entity = entities[i3]; - if (entity.type !== "way") continue; - if (!filter2(entity)) continue; - if (context.selectedIDs().indexOf(entity.id) < 0) continue; - var nodes = graph.childNodes(entity); - 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); - } else if (geoVecLength(projection2(a2.loc), projection2(b2.loc)) > 40) { - var point = geoVecInterp(a2.loc, b2.loc, 0.5); - var loc = null; - if (extent.intersects(point)) { - loc = point; - } else { - for (var k2 = 0; k2 < 4; k2++) { - point = geoLineIntersection([a2.loc, b2.loc], [poly[k2], poly[k2 + 1]]); - if (point && geoVecLength(projection2(a2.loc), projection2(point)) > 20 && geoVecLength(projection2(b2.loc), projection2(point)) > 20) { - loc = point; - break; - } - } - } - if (loc) { - midpoints[id2] = { - type: "midpoint", - id: id2, - loc, - edge: [a2.id, b2.id], - parents: [entity] - }; + } + function updateHashIfNeeded() { + if (context.inIntro()) return; + var latestHash = computedHash(); + if (_cachedHash !== latestHash) { + _cachedHash = latestHash; + window.history.replaceState(null, computedTitle( + false + /* includeChangeCount */ + ), latestHash); + updateTitle( + true + /* includeChangeCount */ + ); + const q2 = utilStringQs(latestHash); + if (q2.map) { + corePreferences("map-location", q2.map); + } + } + } + var _throttledUpdate = throttle_default(updateHashIfNeeded, 500); + var _throttledUpdateTitle = throttle_default(function() { + updateTitle( + true + /* includeChangeCount */ + ); + }, 500); + function hashchange() { + if (window.location.hash === _cachedHash) return; + _cachedHash = window.location.hash; + var q2 = utilStringQs(_cachedHash); + var mapArgs = (q2.map || "").split("/").map(Number); + if (mapArgs.length < 3 || mapArgs.some(isNaN)) { + updateHashIfNeeded(); + } else { + if (_cachedHash === computedHash()) return; + var mode = context.mode(); + context.map().centerZoom([mapArgs[2], Math.min(_latitudeLimit, Math.max(-_latitudeLimit, mapArgs[1]))], mapArgs[0]); + if (q2.id && mode) { + var ids = q2.id.split(",").filter(function(id2) { + return context.hasEntity(id2) || id2.startsWith("note/"); + }); + if (ids.length && ["browse", "select-note", "select"].includes(mode.id)) { + if (ids.length === 1 && ids[0].startsWith("note/")) { + context.enter(modeSelectNote(context, ids[0])); + } else if (!utilArrayIdentical(mode.selectedIDs(), ids)) { + context.enter(modeSelect(context, ids)); } + return; } } - } - function midpointFilter(d2) { - if (midpoints[d2.id]) return true; - for (var i4 = 0; i4 < d2.parents.length; i4++) { - if (filter2(d2.parents[i4])) { - return true; - } + var center = context.map().center(); + var dist = geoSphericalDistance(center, [mapArgs[2], mapArgs[1]]); + var maxdist = 500; + if (mode && mode.id.match(/^draw/) !== null && dist > maxdist) { + context.enter(modeBrowse(context)); + return; } - return false; } - var groups = drawLayer.selectAll(".midpoint").filter(midpointFilter).data(Object.values(midpoints), function(d2) { - return d2.id; - }); - groups.exit().remove(); - var enter = groups.enter().insert("g", ":first-child").attr("class", "midpoint"); - enter.append("polygon").attr("points", "-6,8 10,0 -6,-8").attr("class", "shadow"); - enter.append("polygon").attr("points", "-3,4 5,0 -3,-4").attr("class", "fill"); - groups = groups.merge(enter).attr("transform", function(d2) { - var translate = svgPointTransform(projection2); - var a3 = graph.entity(d2.edge[0]); - var b3 = graph.entity(d2.edge[1]); - var angle2 = geoAngle(a3, b3, projection2) * (180 / Math.PI); - return translate(d2) + " rotate(" + angle2 + ")"; - }).call(svgTagClasses().tags( - function(d2) { - return d2.parents[0].tags; + } + function behavior() { + context.map().on("move.behaviorHash", _throttledUpdate); + context.history().on("change.behaviorHash", _throttledUpdateTitle); + context.on("enter.behaviorHash", _throttledUpdate); + select_default2(window).on("hashchange.behaviorHash", hashchange); + var q2 = utilStringQs(window.location.hash); + if (q2.id) { + const selectIds = q2.id.split(","); + if (selectIds.length === 1 && selectIds[0].startsWith("note/")) { + const noteId = selectIds[0].split("/")[1]; + context.moveToNote(noteId, !q2.map); + } else { + context.zoomToEntities( + // convert ids to short form id: node/123 -> n123 + selectIds.map((id2) => id2.replace(/([nwr])[^/]*\//, "$1")), + !q2.map + ); } - )); - groups.select("polygon.shadow"); - groups.select("polygon.fill"); - touchLayer.call(drawTargets, graph, Object.values(midpoints), midpointFilter); + } + if (q2.walkthrough === "true") { + behavior.startWalkthrough = true; + } + if (q2.map) { + behavior.hadLocation = true; + } else if (!q2.id && corePreferences("map-location")) { + const mapArgs = corePreferences("map-location").split("/").map(Number); + context.map().centerZoom([mapArgs[2], Math.min(_latitudeLimit, Math.max(-_latitudeLimit, mapArgs[1]))], mapArgs[0]); + updateHashIfNeeded(); + behavior.hadLocation = true; + } + hashchange(); + updateTitle(false); } - return drawMidpoints; + behavior.off = function() { + _throttledUpdate.cancel(); + _throttledUpdateTitle.cancel(); + context.map().on("move.behaviorHash", null); + context.on("enter.behaviorHash", null); + select_default2(window).on("hashchange.behaviorHash", null); + window.location.hash = ""; + }; + return behavior; } - - // modules/svg/points.js - var import_fast_deep_equal7 = __toESM(require_fast_deep_equal()); - function svgPoints(projection2, context) { - function markerPath(selection2, klass) { - selection2.attr("class", klass).attr("transform", "translate(-8, -23)").attr("d", "M 17,8 C 17,13 11,21 8.5,23.5 C 6,21 0,13 0,8 C 0,4 4,-0.5 8.5,-0.5 C 13,-0.5 17,4 17,8 z"); - } - function sortY(a2, b2) { - return b2.loc[1] - a2.loc[1]; + var init_hash = __esm({ + "modules/behavior/hash.js"() { + "use strict"; + init_throttle(); + init_src5(); + init_geo2(); + init_browse(); + init_modes2(); + init_util(); + init_array3(); + init_utilDisplayLabel(); + init_localizer(); + init_preferences(); } - function fastEntityKey(d2) { - var mode = context.mode(); - var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id); - return isMoving ? d2.id : osmEntity.key(d2); + }); + + // modules/behavior/index.js + var behavior_exports = {}; + __export(behavior_exports, { + behaviorAddWay: () => behaviorAddWay, + behaviorBreathe: () => behaviorBreathe, + behaviorDrag: () => behaviorDrag, + behaviorDraw: () => behaviorDraw, + behaviorDrawWay: () => behaviorDrawWay, + behaviorEdit: () => behaviorEdit, + behaviorHash: () => behaviorHash, + behaviorHover: () => behaviorHover, + behaviorLasso: () => behaviorLasso, + behaviorOperation: () => behaviorOperation, + behaviorPaste: () => behaviorPaste, + behaviorSelect: () => behaviorSelect + }); + var init_behavior = __esm({ + "modules/behavior/index.js"() { + "use strict"; + init_add_way(); + init_breathe(); + init_drag2(); + init_draw_way(); + init_draw(); + init_edit(); + init_hash(); + init_hover(); + init_lasso2(); + init_operation(); + init_paste(); + init_select4(); } - function drawTargets(selection2, graph, entities, filter2) { - var fillClass = context.getDebug("target") ? "pink " : "nocolor "; - var getTransform = svgPointTransform(projection2).geojson; - var activeID = context.activeID(); - var data = []; - entities.forEach(function(node) { - if (activeID === node.id) return; - data.push({ - type: "Feature", - id: node.id, - properties: { - target: true, - entity: node - }, - geometry: node.asGeoJSON() + }); + + // modules/ui/account.js + var account_exports = {}; + __export(account_exports, { + uiAccount: () => uiAccount + }); + function uiAccount(context) { + const osm = context.connection(); + function updateUserDetails(selection2) { + if (!osm) return; + if (!osm.authenticated()) { + render(selection2, null); + } else { + osm.userDetails((err, user) => { + if (err && err.status === 401) { + osm.logout(); + } + render(selection2, user); }); - }); - var targets = selection2.selectAll(".point.target").filter(function(d2) { - return filter2(d2.properties.entity); - }).data(data, function key(d2) { - return d2.id; - }); - targets.exit().remove(); - targets.enter().append("rect").attr("x", -10).attr("y", -26).attr("width", 20).attr("height", 30).merge(targets).attr("class", function(d2) { - return "node point target " + fillClass + d2.id; - }).attr("transform", getTransform); + } } - function drawPoints(selection2, graph, entities, filter2) { - var wireframe = context.surface().classed("fill-wireframe"); - var zoom = geoScaleToZoom(projection2.scale()); - var base = context.history().base(); - function renderAsPoint(entity) { - return entity.geometry(graph) === "point" && !(zoom >= 18 && entity.directions(graph, projection2).length); + function render(selection2, user) { + let userInfo = selection2.select(".userInfo"); + let loginLogout = selection2.select(".loginLogout"); + if (user) { + userInfo.html("").classed("hide", false); + let userLink = userInfo.append("a").attr("href", osm.userURL(user.display_name)).attr("target", "_blank"); + if (user.image_url) { + userLink.append("img").attr("class", "icon pre-text user-icon").attr("src", user.image_url); + } else { + userLink.call(svgIcon("#iD-icon-avatar", "pre-text light")); + } + userLink.append("span").attr("class", "label").text(user.display_name); + loginLogout.classed("hide", false).select("a").text(_t("logout")).on("click", (e3) => { + e3.preventDefault(); + osm.logout(); + osm.authenticate(void 0, { switchUser: true }); + }); + } else { + userInfo.html("").classed("hide", true); + loginLogout.classed("hide", false).select("a").text(_t("login")).on("click", (e3) => { + e3.preventDefault(); + osm.authenticate(); + }); } - var points = wireframe ? [] : entities.filter(renderAsPoint); - points.sort(sortY); - var drawLayer = selection2.selectAll(".layer-osm.points .points-group.points"); - var touchLayer = selection2.selectAll(".layer-touch.points"); - var groups = drawLayer.selectAll("g.point").filter(filter2).data(points, fastEntityKey); - groups.exit().remove(); - var enter = groups.enter().append("g").attr("class", function(d2) { - return "node point " + d2.id; - }).order(); - enter.append("path").call(markerPath, "shadow"); - enter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke"); - enter.append("path").call(markerPath, "stroke"); - enter.append("use").attr("transform", "translate(-5.5, -20)").attr("class", "icon").attr("width", "12px").attr("height", "12px"); - groups = groups.merge(enter).attr("transform", svgPointTransform(projection2)).classed("added", function(d2) { - return !base.entities[d2.id]; - }).classed("moved", function(d2) { - return base.entities[d2.id] && !(0, import_fast_deep_equal7.default)(graph.entities[d2.id].loc, base.entities[d2.id].loc); - }).classed("retagged", function(d2) { - return base.entities[d2.id] && !(0, import_fast_deep_equal7.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags); - }).call(svgTagClasses()); - groups.select(".shadow"); - groups.select(".stroke"); - groups.select(".icon").attr("xlink:href", function(entity) { - var preset = _mainPresetIndex.match(entity, graph); - var picon = preset && preset.icon; - return picon ? "#" + picon : ""; - }); - touchLayer.call(drawTargets, graph, points, filter2); } - return drawPoints; + return function(selection2) { + if (!osm) return; + selection2.append("li").attr("class", "userInfo").classed("hide", true); + selection2.append("li").attr("class", "loginLogout").classed("hide", true).append("a").attr("href", "#"); + osm.on("change.account", () => updateUserDetails(selection2)); + updateUserDetails(selection2); + }; } - - // modules/svg/turns.js - function svgTurns(projection2, context) { - function icon2(turn) { - var u2 = turn.u ? "-u" : ""; - if (turn.no) return "#iD-turn-no" + u2; - if (turn.only) return "#iD-turn-only" + u2; - return "#iD-turn-yes" + u2; + var init_account = __esm({ + "modules/ui/account.js"() { + "use strict"; + init_localizer(); + init_icon(); } - function drawTurns(selection2, graph, turns) { - function turnTransform(d2) { - var pxRadius = 50; - var toWay = graph.entity(d2.to.way); - var toPoints = graph.childNodes(toWay).map(function(n3) { - return n3.loc; - }).map(projection2); - var toLength = geoPathLength(toPoints); - var mid = toLength / 2; - var toNode = graph.entity(d2.to.node); - var toVertex = graph.entity(d2.to.vertex); - var a2 = geoAngle(toVertex, toNode, projection2); - var o2 = projection2(toVertex.loc); - var r2 = d2.u ? 0 : !toWay.__via ? pxRadius : Math.min(mid, pxRadius); - return "translate(" + (r2 * Math.cos(a2) + o2[0]) + "," + (r2 * Math.sin(a2) + o2[1]) + ") rotate(" + a2 * 180 / Math.PI + ")"; - } - var drawLayer = selection2.selectAll(".layer-osm.points .points-group.turns"); - var touchLayer = selection2.selectAll(".layer-touch.turns"); - var groups = drawLayer.selectAll("g.turn").data(turns, function(d2) { - return d2.key; - }); - groups.exit().remove(); - var groupsEnter = groups.enter().append("g").attr("class", function(d2) { - return "turn " + d2.key; - }); - var turnsEnter = groupsEnter.filter(function(d2) { - return !d2.u; - }); - turnsEnter.append("rect").attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24"); - turnsEnter.append("use").attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24"); - var uEnter = groupsEnter.filter(function(d2) { - return d2.u; - }); - uEnter.append("circle").attr("r", "16"); - uEnter.append("use").attr("transform", "translate(-16, -16)").attr("width", "32").attr("height", "32"); - groups = groups.merge(groupsEnter).attr("opacity", function(d2) { - return d2.direct === false ? "0.7" : null; - }).attr("transform", turnTransform); - groups.select("use").attr("xlink:href", icon2); - groups.select("rect"); - groups.select("circle"); - var fillClass = context.getDebug("target") ? "pink " : "nocolor "; - groups = touchLayer.selectAll("g.turn").data(turns, function(d2) { - return d2.key; - }); - groups.exit().remove(); - groupsEnter = groups.enter().append("g").attr("class", function(d2) { - return "turn " + d2.key; - }); - turnsEnter = groupsEnter.filter(function(d2) { - return !d2.u; - }); - turnsEnter.append("rect").attr("class", "target " + fillClass).attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24"); - uEnter = groupsEnter.filter(function(d2) { - return d2.u; + }); + + // modules/ui/attribution.js + var attribution_exports = {}; + __export(attribution_exports, { + uiAttribution: () => uiAttribution + }); + function uiAttribution(context) { + let _selection = select_default2(null); + function render(selection2, data, klass) { + let div = selection2.selectAll(`.${klass}`).data([0]); + div = div.enter().append("div").attr("class", klass).merge(div); + let attributions = div.selectAll(".attribution").data(data, (d2) => d2.id); + attributions.exit().remove(); + attributions = attributions.enter().append("span").attr("class", "attribution").each((d2, i3, nodes) => { + let attribution = select_default2(nodes[i3]); + if (d2.terms_html) { + attribution.html(d2.terms_html); + return; + } + if (d2.terms_url) { + attribution = attribution.append("a").attr("href", d2.terms_url).attr("target", "_blank"); + } + const sourceID = d2.id.replace(/\./g, ""); + const terms_text = _t( + `imagery.${sourceID}.attribution.text`, + { default: d2.terms_text || d2.id || d2.name() } + ); + if (d2.icon && !d2.overlay) { + attribution.append("img").attr("class", "source-image").attr("src", d2.icon); + } + attribution.append("span").attr("class", "attribution-text").text(terms_text); + }).merge(attributions); + let copyright = attributions.selectAll(".copyright-notice").data((d2) => { + let notice = d2.copyrightNotices(context.map().zoom(), context.map().extent()); + return notice ? [notice] : []; }); - uEnter.append("circle").attr("class", "target " + fillClass).attr("r", "16"); - groups = groups.merge(groupsEnter).attr("transform", turnTransform); - groups.select("rect"); - groups.select("circle"); - return this; + copyright.exit().remove(); + copyright = copyright.enter().append("span").attr("class", "copyright-notice").merge(copyright); + copyright.text(String); } - return drawTurns; - } - - // modules/svg/vertices.js - var import_fast_deep_equal8 = __toESM(require_fast_deep_equal()); - function svgVertices(projection2, context) { - var radiuses = { - // z16-, z17, z18+, w/icon - shadow: [6, 7.5, 7.5, 12], - stroke: [2.5, 3.5, 3.5, 8], - fill: [1, 1.5, 1.5, 1.5] - }; - var _currHoverTarget; - var _currPersistent = {}; - var _currHover = {}; - var _prevHover = {}; - var _currSelected = {}; - var _prevSelected = {}; - var _radii = {}; - function sortY(a2, b2) { - return b2.loc[1] - a2.loc[1]; + function update() { + let baselayer = context.background().baseLayerSource(); + _selection.call(render, baselayer ? [baselayer] : [], "base-layer-attribution"); + const z2 = context.map().zoom(); + let overlays = context.background().overlayLayerSources() || []; + _selection.call(render, overlays.filter((s2) => s2.validZoom(z2)), "overlay-layer-attribution"); } - function fastEntityKey(d2) { - var mode = context.mode(); - var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id); - return isMoving ? d2.id : osmEntity.key(d2); + return function(selection2) { + _selection = selection2; + context.background().on("change.attribution", update); + context.map().on("move.attribution", throttle_default(update, 400, { leading: false })); + update(); + }; + } + var init_attribution = __esm({ + "modules/ui/attribution.js"() { + "use strict"; + init_throttle(); + init_src5(); + init_localizer(); } - function draw(selection2, graph, vertices, sets2, filter2) { - sets2 = sets2 || { selected: {}, important: {}, hovered: {} }; - var icons = {}; - var directions = {}; - var wireframe = context.surface().classed("fill-wireframe"); - var zoom = geoScaleToZoom(projection2.scale()); - var z2 = zoom < 17 ? 0 : zoom < 18 ? 1 : 2; - var activeID = context.activeID(); - var base = context.history().base(); - function getIcon(d2) { - var entity = graph.entity(d2.id); - if (entity.id in icons) return icons[entity.id]; - icons[entity.id] = entity.hasInterestingTags() && _mainPresetIndex.match(entity, graph).icon; - return icons[entity.id]; - } - function getDirections(entity) { - if (entity.id in directions) return directions[entity.id]; - var angles = entity.directions(graph, projection2); - directions[entity.id] = angles.length ? angles : false; - return angles; + }); + + // modules/ui/contributors.js + var contributors_exports = {}; + __export(contributors_exports, { + uiContributors: () => uiContributors + }); + function uiContributors(context) { + var osm = context.connection(), debouncedUpdate = debounce_default(function() { + update(); + }, 1e3), limit = 4, hidden = false, wrap2 = select_default2(null); + function update() { + if (!osm) return; + var users = {}, entities = context.history().intersects(context.map().extent()); + entities.forEach(function(entity) { + if (entity && entity.user) users[entity.user] = true; + }); + var u2 = Object.keys(users), subset = u2.slice(0, u2.length > limit ? limit - 1 : limit); + wrap2.html("").call(svgIcon("#iD-icon-nearby", "pre-text light")); + var userList = select_default2(document.createElement("span")); + userList.selectAll().data(subset).enter().append("a").attr("class", "user-link").attr("href", function(d2) { + return osm.userURL(d2); + }).attr("target", "_blank").text(String); + if (u2.length > limit) { + var count = select_default2(document.createElement("span")); + var othersNum = u2.length - limit + 1; + count.append("a").attr("target", "_blank").attr("href", function() { + return osm.changesetsURL(context.map().center(), context.map().zoom()); + }).text(othersNum); + wrap2.append("span").html(_t.html("contributors.truncated_list", { n: othersNum, users: { html: userList.html() }, count: { html: count.html() } })); + } else { + wrap2.append("span").html(_t.html("contributors.list", { users: { html: userList.html() } })); } - function updateAttributes(selection3) { - ["shadow", "stroke", "fill"].forEach(function(klass) { - var rads = radiuses[klass]; - selection3.selectAll("." + klass).each(function(entity) { - var i3 = z2 && getIcon(entity); - var r2 = rads[i3 ? 3 : z2]; - if (entity.id !== activeID && entity.isEndpoint(graph) && !entity.isConnected(graph)) { - r2 += 1.5; - } - if (klass === "shadow") { - _radii[entity.id] = r2; - } - select_default2(this).attr("r", r2).attr("visibility", i3 && klass === "fill" ? "hidden" : null); - }); - }); + if (!u2.length) { + hidden = true; + wrap2.transition().style("opacity", 0); + } else if (hidden) { + wrap2.transition().style("opacity", 1); } - vertices.sort(sortY); - var groups = selection2.selectAll("g.vertex").filter(filter2).data(vertices, fastEntityKey); - groups.exit().remove(); - var enter = groups.enter().append("g").attr("class", function(d2) { - return "node vertex " + d2.id; - }).order(); - enter.append("circle").attr("class", "shadow"); - enter.append("circle").attr("class", "stroke"); - enter.filter(function(d2) { - return d2.hasInterestingTags(); - }).append("circle").attr("class", "fill"); - groups = groups.merge(enter).attr("transform", svgPointTransform(projection2)).classed("sibling", function(d2) { - return d2.id in sets2.selected; - }).classed("shared", function(d2) { - return graph.isShared(d2); - }).classed("endpoint", function(d2) { - return d2.isEndpoint(graph); - }).classed("added", function(d2) { - return !base.entities[d2.id]; - }).classed("moved", function(d2) { - return base.entities[d2.id] && !(0, import_fast_deep_equal8.default)(graph.entities[d2.id].loc, base.entities[d2.id].loc); - }).classed("retagged", function(d2) { - return base.entities[d2.id] && !(0, import_fast_deep_equal8.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags); - }).call(svgTagClasses()).call(updateAttributes); - var iconUse = groups.selectAll(".icon").data(function data(d2) { - return zoom >= 17 && getIcon(d2) ? [d2] : []; - }, fastEntityKey); - iconUse.exit().remove(); - iconUse.enter().append("use").attr("class", "icon").attr("width", "12px").attr("height", "12px").attr("transform", "translate(-6, -6)").attr("xlink:href", function(d2) { - var picon = getIcon(d2); - return picon ? "#" + picon : ""; - }); - var dgroups = groups.selectAll(".viewfieldgroup").data(function data(d2) { - return zoom >= 18 && getDirections(d2) ? [d2] : []; - }, fastEntityKey); - dgroups.exit().remove(); - dgroups = dgroups.enter().insert("g", ".shadow").attr("class", "viewfieldgroup").merge(dgroups); - var viewfields = dgroups.selectAll(".viewfield").data(getDirections, function key(d2) { - return osmEntity.key(d2); - }); - viewfields.exit().remove(); - viewfields.enter().append("path").attr("class", "viewfield").attr("d", "M0,0H0").merge(viewfields).attr("marker-start", "url(#ideditor-viewfield-marker" + (wireframe ? "-wireframe" : "") + ")").attr("transform", function(d2) { - return "rotate(" + d2 + ")"; + } + return function(selection2) { + if (!osm) return; + wrap2 = selection2; + update(); + osm.on("loaded.contributors", debouncedUpdate); + context.map().on("move.contributors", debouncedUpdate); + }; + } + var init_contributors = __esm({ + "modules/ui/contributors.js"() { + "use strict"; + init_debounce(); + init_src5(); + init_localizer(); + init_svg(); + } + }); + + // modules/ui/edit_menu.js + var edit_menu_exports = {}; + __export(edit_menu_exports, { + uiEditMenu: () => uiEditMenu + }); + function uiEditMenu(context) { + var dispatch14 = dispatch_default("toggled"); + var _menu = select_default2(null); + var _operations = []; + var _anchorLoc = [0, 0]; + var _anchorLocLonLat = [0, 0]; + var _triggerType = ""; + var _vpTopMargin = 85; + var _vpBottomMargin = 45; + var _vpSideMargin = 35; + var _menuTop = false; + var _menuHeight; + var _menuWidth; + var _verticalPadding = 4; + var _tooltipWidth = 210; + var _menuSideMargin = 10; + var _tooltips = []; + var editMenu = function(selection2) { + var isTouchMenu = _triggerType.includes("touch") || _triggerType.includes("pen"); + var ops = _operations.filter(function(op) { + return !isTouchMenu || !op.mouseOnly; }); - } - function drawTargets(selection2, graph, entities, filter2) { - var targetClass = context.getDebug("target") ? "pink " : "nocolor "; - var nopeClass = context.getDebug("target") ? "red " : "nocolor "; - var getTransform = svgPointTransform(projection2).geojson; - var activeID = context.activeID(); - var data = { targets: [], nopes: [] }; - entities.forEach(function(node) { - if (activeID === node.id) return; - var vertexType = svgPassiveVertex(node, graph, activeID); - if (vertexType !== 0) { - data.targets.push({ - type: "Feature", - id: node.id, - properties: { - target: true, - entity: node - }, - geometry: node.asGeoJSON() - }); - } else { - data.nopes.push({ - type: "Feature", - id: node.id + "-nope", - properties: { - nope: true, - target: true, - entity: node - }, - geometry: node.asGeoJSON() - }); - } + if (!ops.length) return; + _tooltips = []; + _menuTop = isTouchMenu; + var showLabels = isTouchMenu; + var buttonHeight = showLabels ? 32 : 34; + if (showLabels) { + _menuWidth = 52 + Math.min(120, 6 * Math.max.apply(Math, ops.map(function(op) { + return op.title.length; + }))); + } else { + _menuWidth = 44; + } + _menuHeight = _verticalPadding * 2 + ops.length * buttonHeight; + _menu = selection2.append("div").attr("class", "edit-menu").classed("touch-menu", isTouchMenu).style("padding", _verticalPadding + "px 0"); + var buttons = _menu.selectAll(".edit-menu-item").data(ops); + var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) { + return "edit-menu-item edit-menu-item-" + d2.id; + }).style("height", buttonHeight + "px").on("click", click).on("pointerup", pointerup).on("pointerdown mousedown", function pointerdown(d3_event) { + d3_event.stopPropagation(); + }).on("mouseenter.highlight", function(d3_event, d2) { + if (!d2.relatedEntityIds || select_default2(this).classed("disabled")) return; + utilHighlightEntities(d2.relatedEntityIds(), true, context); + }).on("mouseleave.highlight", function(d3_event, d2) { + if (!d2.relatedEntityIds) return; + utilHighlightEntities(d2.relatedEntityIds(), false, context); }); - var targets = selection2.selectAll(".vertex.target-allowed").filter(function(d2) { - return filter2(d2.properties.entity); - }).data(data.targets, function key(d2) { - return d2.id; + buttonsEnter.each(function(d2) { + var tooltip = uiTooltip().heading(() => d2.title).title(d2.tooltip).keys([d2.keys[0]]); + _tooltips.push(tooltip); + select_default2(this).call(tooltip).append("div").attr("class", "icon-wrap").call(svgIcon(d2.icon && d2.icon() || "#iD-operation-" + d2.id, "operation")); }); - targets.exit().remove(); - targets.enter().append("circle").attr("r", function(d2) { - return _radii[d2.id] || radiuses.shadow[3]; - }).merge(targets).attr("class", function(d2) { - return "node vertex target target-allowed " + targetClass + d2.id; - }).attr("transform", getTransform); - var nopes = selection2.selectAll(".vertex.target-nope").filter(function(d2) { - return filter2(d2.properties.entity); - }).data(data.nopes, function key(d2) { - return d2.id; + if (showLabels) { + buttonsEnter.append("span").attr("class", "label").each(function(d2) { + select_default2(this).call(d2.title); + }); + } + buttonsEnter.merge(buttons).classed("disabled", function(d2) { + return d2.disabled(); }); - nopes.exit().remove(); - nopes.enter().append("circle").attr("r", function(d2) { - return _radii[d2.properties.entity.id] || radiuses.shadow[3]; - }).merge(nopes).attr("class", function(d2) { - return "node vertex target target-nope " + nopeClass + d2.id; - }).attr("transform", getTransform); - } - function renderAsVertex(entity, graph, wireframe, zoom) { - var geometry = entity.geometry(graph); - return geometry === "vertex" || geometry === "point" && (wireframe || zoom >= 18 && entity.directions(graph, projection2).length); - } - function isEditedNode(node, base, head) { - var baseNode = base.entities[node.id]; - var headNode = head.entities[node.id]; - return !headNode || !baseNode || !(0, import_fast_deep_equal8.default)(headNode.tags, baseNode.tags) || !(0, import_fast_deep_equal8.default)(headNode.loc, baseNode.loc); - } - function getSiblingAndChildVertices(ids, graph, wireframe, zoom) { - var results = {}; - var seenIds = {}; - function addChildVertices(entity) { - if (seenIds[entity.id]) return; - seenIds[entity.id] = true; - var geometry = entity.geometry(graph); - if (!context.features().isHiddenFeature(entity, graph, geometry)) { - var i3; - if (entity.type === "way") { - for (i3 = 0; i3 < entity.nodes.length; i3++) { - var child = graph.hasEntity(entity.nodes[i3]); - if (child) { - addChildVertices(child); - } - } - } else if (entity.type === "relation") { - for (i3 = 0; i3 < entity.members.length; i3++) { - var member = graph.hasEntity(entity.members[i3].id); - if (member) { - addChildVertices(member); - } - } - } else if (renderAsVertex(entity, graph, wireframe, zoom)) { - results[entity.id] = entity; - } + updatePosition(); + var initialScale = context.projection.scale(); + context.map().on("move.edit-menu", function() { + if (initialScale !== context.projection.scale()) { + editMenu.close(); } + }).on("drawn.edit-menu", function(info) { + if (info.full) updatePosition(); + }); + var lastPointerUpType; + function pointerup(d3_event) { + lastPointerUpType = d3_event.pointerType; } - ids.forEach(function(id2) { - var entity = graph.hasEntity(id2); - if (!entity) return; - if (entity.type === "node") { - if (renderAsVertex(entity, graph, wireframe, zoom)) { - results[entity.id] = entity; - graph.parentWays(entity).forEach(function(entity2) { - addChildVertices(entity2); - }); + function click(d3_event, operation2) { + d3_event.stopPropagation(); + if (operation2.relatedEntityIds) { + utilHighlightEntities(operation2.relatedEntityIds(), false, context); + } + if (operation2.disabled()) { + if (lastPointerUpType === "touch" || lastPointerUpType === "pen") { + context.ui().flash.duration(4e3).iconName("#iD-operation-" + operation2.id).iconClass("operation disabled").label(operation2.tooltip())(); } } else { - addChildVertices(entity); + if (lastPointerUpType === "touch" || lastPointerUpType === "pen") { + context.ui().flash.duration(2e3).iconName("#iD-operation-" + operation2.id).iconClass("operation").label(operation2.annotation() || operation2.title)(); + } + operation2(); + editMenu.close(); } - }); - return results; - } - function drawVertices(selection2, graph, entities, filter2, extent, fullRedraw) { - var wireframe = context.surface().classed("fill-wireframe"); - var visualDiff = context.surface().classed("highlight-edited"); - var zoom = geoScaleToZoom(projection2.scale()); - var mode = context.mode(); - var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id); - var base = context.history().base(); - var drawLayer = selection2.selectAll(".layer-osm.points .points-group.vertices"); - var touchLayer = selection2.selectAll(".layer-touch.points"); - if (fullRedraw) { - _currPersistent = {}; - _radii = {}; + lastPointerUpType = null; } - for (var i3 = 0; i3 < entities.length; i3++) { - var entity = entities[i3]; - var geometry = entity.geometry(graph); - var keep = false; - if (geometry === "point" && renderAsVertex(entity, graph, wireframe, zoom)) { - _currPersistent[entity.id] = entity; - keep = true; - } else if (geometry === "vertex" && (entity.hasInterestingTags() || entity.isEndpoint(graph) || entity.isConnected(graph) || visualDiff && isEditedNode(entity, base, graph))) { - _currPersistent[entity.id] = entity; - keep = true; + dispatch14.call("toggled", this, true); + }; + function updatePosition() { + if (!_menu || _menu.empty()) return; + var anchorLoc = context.projection(_anchorLocLonLat); + var viewport = context.surfaceRect(); + if (anchorLoc[0] < 0 || anchorLoc[0] > viewport.width || anchorLoc[1] < 0 || anchorLoc[1] > viewport.height) { + editMenu.close(); + return; + } + var menuLeft = displayOnLeft(viewport); + var offset = [0, 0]; + offset[0] = menuLeft ? -1 * (_menuSideMargin + _menuWidth) : _menuSideMargin; + if (_menuTop) { + if (anchorLoc[1] - _menuHeight < _vpTopMargin) { + offset[1] = -anchorLoc[1] + _vpTopMargin; + } else { + offset[1] = -_menuHeight; } - if (!keep && !fullRedraw) { - delete _currPersistent[entity.id]; + } else { + if (anchorLoc[1] + _menuHeight > viewport.height - _vpBottomMargin) { + offset[1] = -anchorLoc[1] - _menuHeight + viewport.height - _vpBottomMargin; + } else { + offset[1] = 0; } } - var sets2 = { - persistent: _currPersistent, - // persistent = important vertices (render always) - selected: _currSelected, - // selected + siblings of selected (render always) - hovered: _currHover - // hovered + siblings of hovered (render only in draw modes) - }; - var all = Object.assign({}, isMoving ? _currHover : {}, _currSelected, _currPersistent); - var filterRendered = function(d2) { - return d2.id in _currPersistent || d2.id in _currSelected || d2.id in _currHover || filter2(d2); - }; - drawLayer.call(draw, graph, currentVisible(all), sets2, filterRendered); - var filterTouch = function(d2) { - return isMoving ? true : filterRendered(d2); - }; - touchLayer.call(drawTargets, graph, currentVisible(all), filterTouch); - function currentVisible(which) { - return Object.keys(which).map(graph.hasEntity, graph).filter(function(entity2) { - return entity2 && entity2.intersects(extent, graph); - }); + var origin = geoVecAdd(anchorLoc, offset); + var _verticalOffset = parseFloat(utilGetDimensions(select_default2(".top-toolbar-wrap"))[1]); + origin[1] -= _verticalOffset; + _menu.style("left", origin[0] + "px").style("top", origin[1] + "px"); + var tooltipSide = tooltipPosition(viewport, menuLeft); + _tooltips.forEach(function(tooltip) { + tooltip.placement(tooltipSide); + }); + function displayOnLeft(viewport2) { + if (_mainLocalizer.textDirection() === "ltr") { + if (anchorLoc[0] + _menuSideMargin + _menuWidth > viewport2.width - _vpSideMargin) { + return true; + } + return false; + } else { + if (anchorLoc[0] - _menuSideMargin - _menuWidth < _vpSideMargin) { + return false; + } + return true; + } } - } - drawVertices.drawSelected = function(selection2, graph, extent) { - var wireframe = context.surface().classed("fill-wireframe"); - var zoom = geoScaleToZoom(projection2.scale()); - _prevSelected = _currSelected || {}; - if (context.map().isInWideSelection()) { - _currSelected = {}; - context.selectedIDs().forEach(function(id2) { - var entity = graph.hasEntity(id2); - if (!entity) return; - if (entity.type === "node") { - if (renderAsVertex(entity, graph, wireframe, zoom)) { - _currSelected[entity.id] = entity; - } + function tooltipPosition(viewport2, menuLeft2) { + if (_mainLocalizer.textDirection() === "ltr") { + if (menuLeft2) { + return "left"; } - }); - } else { - _currSelected = getSiblingAndChildVertices(context.selectedIDs(), graph, wireframe, zoom); + if (anchorLoc[0] + _menuSideMargin + _menuWidth + _tooltipWidth > viewport2.width - _vpSideMargin) { + return "left"; + } + return "right"; + } else { + if (!menuLeft2) { + return "right"; + } + if (anchorLoc[0] - _menuSideMargin - _menuWidth - _tooltipWidth < _vpSideMargin) { + return "right"; + } + return "left"; + } } - var filter2 = function(d2) { - return d2.id in _prevSelected; - }; - drawVertices(selection2, graph, Object.values(_prevSelected), filter2, extent, false); + } + editMenu.close = function() { + context.map().on("move.edit-menu", null).on("drawn.edit-menu", null); + _menu.remove(); + _tooltips = []; + dispatch14.call("toggled", this, false); }; - drawVertices.drawHover = function(selection2, graph, target, extent) { - if (target === _currHoverTarget) return; - var wireframe = context.surface().classed("fill-wireframe"); - var zoom = geoScaleToZoom(projection2.scale()); - _prevHover = _currHover || {}; - _currHoverTarget = target; - var entity = target && target.properties && target.properties.entity; - if (entity) { - _currHover = getSiblingAndChildVertices([entity.id], graph, wireframe, zoom); - } else { - _currHover = {}; - } - var filter2 = function(d2) { - return d2.id in _prevHover; - }; - drawVertices(selection2, graph, Object.values(_prevHover), filter2, extent, false); + editMenu.anchorLoc = function(val) { + if (!arguments.length) return _anchorLoc; + _anchorLoc = val; + _anchorLocLonLat = context.projection.invert(_anchorLoc); + return editMenu; }; - return drawVertices; + editMenu.triggerType = function(val) { + if (!arguments.length) return _triggerType; + _triggerType = val; + return editMenu; + }; + editMenu.operations = function(val) { + if (!arguments.length) return _operations; + _operations = val; + return editMenu; + }; + return utilRebind(editMenu, dispatch14, "on"); } + var init_edit_menu = __esm({ + "modules/ui/edit_menu.js"() { + "use strict"; + init_src5(); + init_src4(); + init_geo2(); + init_localizer(); + init_tooltip(); + init_rebind(); + init_util2(); + init_dimensions(); + init_icon(); + } + }); - // modules/ui/length_indicator.js - function uiLengthIndicator(maxChars) { - var _wrap = select_default2(null); - var _tooltip = uiPopover("tooltip max-length-warning").placement("bottom").hasArrow(true).content(() => (selection2) => { + // modules/ui/feature_info.js + var feature_info_exports = {}; + __export(feature_info_exports, { + uiFeatureInfo: () => uiFeatureInfo + }); + function uiFeatureInfo(context) { + function update(selection2) { + var features = context.features(); + var stats = features.stats(); + var count = 0; + var hiddenList = features.hidden().map(function(k2) { + if (stats[k2]) { + count += stats[k2]; + return _t.append("inspector.title_count", { + title: _t("feature." + k2 + ".description"), + count: stats[k2] + }); + } + return null; + }).filter(Boolean); selection2.text(""); - selection2.call(svgIcon("#iD-icon-alert", "inline")); - selection2.call(_t.append("inspector.max_length_reached", { maxChars })); - }); - var _silent = false; - var lengthIndicator = function(selection2) { - _wrap = selection2.selectAll("span.length-indicator-wrap").data([0]); - _wrap = _wrap.enter().append("span").merge(_wrap).classed("length-indicator-wrap", true); - selection2.call(_tooltip); + if (hiddenList.length) { + var tooltipBehavior = uiTooltip().placement("top").title(function() { + return (selection3) => { + hiddenList.forEach((hiddenFeature) => { + selection3.append("div").call(hiddenFeature); + }); + }; + }); + selection2.append("a").attr("class", "chip").attr("href", "#").call(_t.append("feature_info.hidden_warning", { count })).call(tooltipBehavior).on("click", function(d3_event) { + tooltipBehavior.hide(); + d3_event.preventDefault(); + context.ui().togglePanes(context.container().select(".map-panes .map-data-pane")); + }); + } + selection2.classed("hide", !hiddenList.length); + } + return function(selection2) { + update(selection2); + context.features().on("change.feature_info", function() { + update(selection2); + }); }; - lengthIndicator.update = function(val) { - const strLen = utilUnicodeCharsCount(utilCleanOsmString(val, Number.POSITIVE_INFINITY)); - let indicator = _wrap.selectAll("span.length-indicator").data([strLen]); - indicator.enter().append("span").merge(indicator).classed("length-indicator", true).classed("limit-reached", (d2) => d2 > maxChars).style("border-right-width", (d2) => "".concat(Math.abs(maxChars - d2) * 2, "px")).style("margin-right", (d2) => d2 > maxChars ? "".concat((maxChars - d2) * 2, "px") : 0).style("opacity", (d2) => d2 > maxChars * 0.8 ? Math.min(1, (d2 / maxChars - 0.8) / (1 - 0.8)) : 0).style("pointer-events", (d2) => d2 > maxChars * 0.8 ? null : "none"); - if (_silent) return; - if (strLen > maxChars) { - _tooltip.show(); + } + var init_feature_info = __esm({ + "modules/ui/feature_info.js"() { + "use strict"; + init_localizer(); + init_tooltip(); + } + }); + + // modules/ui/flash.js + var flash_exports = {}; + __export(flash_exports, { + uiFlash: () => uiFlash + }); + function uiFlash(context) { + var _flashTimer; + var _duration = 2e3; + var _iconName = "#iD-icon-no"; + var _iconClass = "disabled"; + var _label = (s2) => s2.text(""); + function flash() { + if (_flashTimer) { + _flashTimer.stop(); + } + context.container().select(".main-footer-wrap").classed("footer-hide", true).classed("footer-show", false); + context.container().select(".flash-wrap").classed("footer-hide", false).classed("footer-show", true); + var content = context.container().select(".flash-wrap").selectAll(".flash-content").data([0]); + var contentEnter = content.enter().append("div").attr("class", "flash-content"); + var iconEnter = contentEnter.append("svg").attr("class", "flash-icon icon").append("g").attr("transform", "translate(10,10)"); + iconEnter.append("circle").attr("r", 9); + iconEnter.append("use").attr("transform", "translate(-7,-7)").attr("width", "14").attr("height", "14"); + contentEnter.append("div").attr("class", "flash-text"); + content = content.merge(contentEnter); + content.selectAll(".flash-icon").attr("class", "icon flash-icon " + (_iconClass || "")); + content.selectAll(".flash-icon use").attr("xlink:href", _iconName); + content.selectAll(".flash-text").attr("class", "flash-text").call(_label); + _flashTimer = timeout_default(function() { + _flashTimer = null; + context.container().select(".main-footer-wrap").classed("footer-hide", false).classed("footer-show", true); + context.container().select(".flash-wrap").classed("footer-hide", true).classed("footer-show", false); + }, _duration); + return content; + } + flash.duration = function(_2) { + if (!arguments.length) return _duration; + _duration = _2; + return flash; + }; + flash.label = function(_2) { + if (!arguments.length) return _label; + if (typeof _2 !== "function") { + _label = (selection2) => selection2.text(_2); } else { - _tooltip.hide(); + _label = (selection2) => selection2.text("").call(_2); } + return flash; }; - lengthIndicator.silent = function(val) { - if (!arguments.length) return _silent; - _silent = val; - return lengthIndicator; + flash.iconName = function(_2) { + if (!arguments.length) return _iconName; + _iconName = _2; + return flash; }; - return lengthIndicator; + flash.iconClass = function(_2) { + if (!arguments.length) return _iconClass; + _iconClass = _2; + return flash; + }; + return flash; } - - // modules/ui/fields/combo.js - function uiFieldCombo(field, context) { - var dispatch14 = dispatch_default("change"); - var _isMulti = field.type === "multiCombo" || field.type === "manyCombo"; - var _isNetwork = field.type === "networkCombo"; - var _isSemi = field.type === "semiCombo"; - var _showTagInfoSuggestions = field.type !== "manyCombo" && field.autoSuggestions !== false; - var _allowCustomValues = field.type !== "manyCombo" && field.customValues !== false; - var _snake_case = field.snake_case || field.snake_case === void 0; - var _combobox = uiCombobox(context, "combo-" + field.safeid).caseSensitive(field.caseSensitive).minItems(1); - var _container = select_default2(null); - var _inputWrap = select_default2(null); - var _input = select_default2(null); - var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue()); - var _comboData = []; - var _multiData = []; - var _entityIDs = []; - var _tags; - var _countryCode; - var _staticPlaceholder; - var _customOptions = []; - var _dataDeprecated = []; - _mainFileFetcher.get("deprecated").then(function(d2) { - _dataDeprecated = d2; - }).catch(function() { - }); - if (_isMulti && field.key && /[^:]$/.test(field.key)) { - field.key += ":"; - } - function snake(s2) { - return s2.replace(/\s+/g, "_"); - } - function clean2(s2) { - return s2.split(";").map(function(s3) { - return s3.trim(); - }).join(";"); + var init_flash = __esm({ + "modules/ui/flash.js"() { + "use strict"; + init_src9(); } - function tagValue(dval) { - dval = clean2(dval || ""); - var found = getOptions(true).find(function(o2) { - return o2.key && clean2(o2.value) === dval; - }); - if (found) return found.key; - if (field.type === "typeCombo" && !dval) { - return "yes"; + }); + + // modules/ui/full_screen.js + var full_screen_exports = {}; + __export(full_screen_exports, { + uiFullScreen: () => uiFullScreen + }); + function uiFullScreen(context) { + var element = context.container().node(); + function getFullScreenFn() { + if (element.requestFullscreen) { + return element.requestFullscreen; + } else if (element.msRequestFullscreen) { + return element.msRequestFullscreen; + } else if (element.mozRequestFullScreen) { + return element.mozRequestFullScreen; + } else if (element.webkitRequestFullscreen) { + return element.webkitRequestFullscreen; } - return restrictTagValueSpelling(dval) || void 0; } - function restrictTagValueSpelling(dval) { - if (_snake_case) { - dval = snake(dval); - } - if (!field.caseSensitive) { - dval = dval.toLowerCase(); + function getExitFullScreenFn() { + if (document.exitFullscreen) { + return document.exitFullscreen; + } else if (document.msExitFullscreen) { + return document.msExitFullscreen; + } else if (document.mozCancelFullScreen) { + return document.mozCancelFullScreen; + } else if (document.webkitExitFullscreen) { + return document.webkitExitFullscreen; } - return dval; } - function getLabelId(field2, v2) { - return field2.hasTextForStringId("options.".concat(v2, ".title")) ? "options.".concat(v2, ".title") : "options.".concat(v2); + function isFullScreen() { + return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement; } - function displayValue(tval) { - tval = tval || ""; - var stringsField = field.resolveReference("stringsCrossReference"); - const labelId = getLabelId(stringsField, tval); - if (stringsField.hasTextForStringId(labelId)) { - return stringsField.t(labelId, { default: tval }); - } - if (field.type === "typeCombo" && tval.toLowerCase() === "yes") { - return ""; - } - return tval; + function isSupported() { + return !!getFullScreenFn(); } - function renderValue(tval) { - tval = tval || ""; - var stringsField = field.resolveReference("stringsCrossReference"); - const labelId = getLabelId(stringsField, tval); - if (stringsField.hasTextForStringId(labelId)) { - return stringsField.t.append(labelId, { default: tval }); - } - if (field.type === "typeCombo" && tval.toLowerCase() === "yes") { - tval = ""; + function fullScreen(d3_event) { + d3_event.preventDefault(); + if (!isFullScreen()) { + getFullScreenFn().apply(element); + } else { + getExitFullScreenFn().apply(document); } - return (selection2) => selection2.text(tval); } - function objectDifference(a2, b2) { - return a2.filter(function(d1) { - return !b2.some(function(d2) { - return d1.value === d2.value; - }); - }); + return function() { + if (!isSupported()) return; + var detected = utilDetect(); + var keys2 = detected.os === "mac" ? [uiCmd("\u2303\u2318F"), "f11"] : ["f11"]; + context.keybinding().on(keys2, fullScreen); + }; + } + var init_full_screen = __esm({ + "modules/ui/full_screen.js"() { + "use strict"; + init_cmd(); + init_detect(); } - function initCombo(selection2, attachTo) { - if (!_allowCustomValues) { - selection2.attr("readonly", "readonly"); - } - if (_showTagInfoSuggestions && services.taginfo) { - selection2.call(_combobox.fetcher(setTaginfoValues), attachTo); - setTaginfoValues("", setPlaceholder); + }); + + // modules/ui/geolocate.js + var geolocate_exports2 = {}; + __export(geolocate_exports2, { + uiGeolocate: () => uiGeolocate + }); + function uiGeolocate(context) { + var _geolocationOptions = { + // prioritize speed and power usage over precision + enableHighAccuracy: false, + // don't hang indefinitely getting the location + timeout: 6e3 + // 6sec + }; + var _locating = uiLoading(context).message(_t.html("geolocate.locating")).blocking(true); + var _layer = context.layers().layer("geolocate"); + var _position; + var _extent; + var _timeoutID; + var _button = select_default2(null); + function click() { + if (context.inIntro()) return; + if (!_layer.enabled() && !_locating.isShown()) { + _timeoutID = setTimeout( + error, + 1e4 + /* 10sec */ + ); + context.container().call(_locating); + navigator.geolocation.getCurrentPosition(success, error, _geolocationOptions); } else { - selection2.call(_combobox, attachTo); - setTimeout(() => setStaticValues(setPlaceholder), 0); + _locating.close(); + _layer.enabled(null, false); + updateButtonState(); } } - function getOptions(allOptions) { - var stringsField = field.resolveReference("stringsCrossReference"); - if (!(field.options || stringsField.options)) return []; - let options2; - if (allOptions !== true) { - options2 = field.options || stringsField.options; - } else { - options2 = [].concat(field.options, stringsField.options).filter(Boolean); - } - const result = options2.map(function(v2) { - const labelId = getLabelId(stringsField, v2); - return { - key: v2, - value: stringsField.t(labelId, { default: v2 }), - title: stringsField.t("options.".concat(v2, ".description"), { default: v2 }), - display: addComboboxIcons(stringsField.t.append(labelId, { default: v2 }), v2), - klass: stringsField.hasTextForStringId(labelId) ? "" : "raw-option" - }; - }); - return [...result, ..._customOptions]; + function zoomTo() { + context.enter(modeBrowse(context)); + var map2 = context.map(); + _layer.enabled(_position, true); + updateButtonState(); + map2.centerZoomEase(_extent.center(), Math.min(20, map2.extentZoom(_extent))); } - function hasStaticValues() { - return getOptions().length > 0; + function success(geolocation) { + _position = geolocation; + var coords = _position.coords; + _extent = geoExtent([coords.longitude, coords.latitude]).padByMeters(coords.accuracy); + zoomTo(); + finish(); } - function setStaticValues(callback, filter2) { - _comboData = getOptions(); - if (filter2 !== void 0) { - _comboData = _comboData.filter(filter2); + function error() { + if (_position) { + zoomTo(); + } else { + context.ui().flash.label(_t.append("geolocate.location_unavailable")).iconName("#iD-icon-geolocate")(); } - _comboData = objectDifference(_comboData, _multiData); - _combobox.data(_comboData); - _container.classed("empty-combobox", _comboData.length === 0); - if (callback) callback(_comboData); + finish(); } - function setTaginfoValues(q2, callback) { - var queryFilter = (d2) => d2.value.toLowerCase().includes(q2.toLowerCase()) || d2.key.toLowerCase().includes(q2.toLowerCase()); - if (hasStaticValues()) { - setStaticValues(callback, queryFilter); + function finish() { + _locating.close(); + if (_timeoutID) { + clearTimeout(_timeoutID); } - var stringsField = field.resolveReference("stringsCrossReference"); - var fn = _isMulti ? "multikeys" : "values"; - var query = (_isMulti ? field.key : "") + q2; - var hasCountryPrefix = _isNetwork && _countryCode && _countryCode.indexOf(q2.toLowerCase()) === 0; - if (hasCountryPrefix) { - query = _countryCode + ":"; + _timeoutID = void 0; + } + function updateButtonState() { + _button.classed("active", _layer.enabled()); + _button.attr("aria-pressed", _layer.enabled()); + } + return function(selection2) { + if (!navigator.geolocation || !navigator.geolocation.getCurrentPosition) return; + _button = selection2.append("button").on("click", click).attr("aria-pressed", false).call(svgIcon("#iD-icon-geolocate", "light")).call( + uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(() => _t.append("geolocate.title")) + ); + }; + } + var init_geolocate2 = __esm({ + "modules/ui/geolocate.js"() { + "use strict"; + init_src5(); + init_localizer(); + init_tooltip(); + init_geo2(); + init_browse(); + init_icon(); + init_loading(); + } + }); + + // modules/ui/panels/background.js + var background_exports = {}; + __export(background_exports, { + uiPanelBackground: () => uiPanelBackground + }); + function uiPanelBackground(context) { + var background = context.background(); + var _currSourceName = null; + var _metadata = {}; + var _metadataKeys = [ + "zoom", + "vintage", + "source", + "description", + "resolution", + "accuracy" + ]; + var debouncedRedraw = debounce_default(redraw, 250); + function redraw(selection2) { + var source = background.baseLayerSource(); + if (!source) return; + var isDG = source.id.match(/^DigitalGlobe/i) !== null; + var sourceLabel = source.label(); + if (_currSourceName !== sourceLabel) { + _currSourceName = sourceLabel; + _metadata = {}; } - var params = { - debounce: q2 !== "", - key: field.key, - query - }; - if (_entityIDs.length) { - params.geometry = context.graph().geometry(_entityIDs[0]); + selection2.text(""); + var list2 = selection2.append("ul").attr("class", "background-info"); + list2.append("li").call(_currSourceName); + _metadataKeys.forEach(function(k2) { + if (isDG && k2 === "vintage") return; + 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"; + selection2.append("a").call(_t.append("info_panels.background." + toggleTiles)).attr("href", "#").attr("class", "button button-toggle-tiles").on("click", function(d3_event) { + d3_event.preventDefault(); + context.setDebug("tile", !context.getDebug("tile")); + selection2.call(redraw); + }); + if (isDG) { + var key = source.id + "-vintage"; + var sourceVintage = context.background().findSource(key); + var showsVintage = context.background().showsLayer(sourceVintage); + var toggleVintage = showsVintage ? "hide_vintage" : "show_vintage"; + selection2.append("a").call(_t.append("info_panels.background." + toggleVintage)).attr("href", "#").attr("class", "button button-toggle-vintage").on("click", function(d3_event) { + d3_event.preventDefault(); + context.background().toggleOverlayLayer(sourceVintage); + selection2.call(redraw); + }); } - services.taginfo[fn](params, function(err, data) { - if (err) return; - data = data.filter((d2) => field.type !== "typeCombo" || d2.value !== "yes"); - data = data.filter((d2) => { - var value = d2.value; - if (_isMulti) { - value = value.slice(field.key.length); + ["DigitalGlobe-Premium", "DigitalGlobe-Standard"].forEach(function(layerId) { + if (source.id !== layerId) { + var key2 = layerId + "-vintage"; + var sourceVintage2 = context.background().findSource(key2); + if (context.background().showsLayer(sourceVintage2)) { + context.background().toggleOverlayLayer(sourceVintage2); } - return value === restrictTagValueSpelling(value); - }); - var deprecatedValues = osmEntity.deprecatedTagValuesByKey(_dataDeprecated)[field.key]; - if (deprecatedValues) { - data = data.filter((d2) => !deprecatedValues.includes(d2.value)); - } - if (hasCountryPrefix) { - data = data.filter((d2) => d2.value.toLowerCase().indexOf(_countryCode + ":") === 0); } - const additionalOptions = (field.options || stringsField.options || []).filter((v2) => !data.some((dv) => dv.value === (_isMulti ? field.key + v2 : v2))).map((v2) => ({ value: v2 })); - _container.classed("empty-combobox", data.length === 0); - _comboData = data.concat(additionalOptions).map(function(d2) { - var v2 = d2.value; - if (_isMulti) v2 = v2.replace(field.key, ""); - const labelId = getLabelId(stringsField, v2); - var isLocalizable = stringsField.hasTextForStringId(labelId); - var label = stringsField.t(labelId, { default: v2 }); - return { - key: v2, - value: label, - title: stringsField.t("options.".concat(v2, ".description"), { default: isLocalizable ? v2 : d2.title !== label ? d2.title : "" }), - display: addComboboxIcons(stringsField.t.append(labelId, { default: v2 }), v2), - klass: isLocalizable ? "" : "raw-option" - }; + }); + } + var debouncedGetMetadata = debounce_default(getMetadata, 250); + function getMetadata(selection2) { + var tile = context.container().select(".layer-background img.tile-center"); + if (tile.empty()) return; + var sourceName = _currSourceName; + var d2 = tile.datum(); + var zoom = d2 && d2.length >= 3 && d2[2] || Math.floor(context.map().zoom()); + var center = context.map().center(); + _metadata.zoom = String(zoom); + selection2.selectAll(".background-info-list-zoom").classed("hide", false).selectAll(".background-info-span-zoom").text(_metadata.zoom); + if (!d2 || !d2.length >= 3) return; + background.baseLayerSource().getMetadata(center, d2, function(err, result) { + if (err || _currSourceName !== sourceName) return; + var vintage = result.vintage; + _metadata.vintage = vintage && vintage.range || _t("info_panels.background.unknown"); + selection2.selectAll(".background-info-list-vintage").classed("hide", false).selectAll(".background-info-span-vintage").text(_metadata.vintage); + _metadataKeys.forEach(function(k2) { + if (k2 === "zoom" || k2 === "vintage") return; + var val = result[k2]; + _metadata[k2] = val; + selection2.selectAll(".background-info-list-" + k2).classed("hide", !val).selectAll(".background-info-span-" + k2).text(val); }); - _comboData = _comboData.filter(queryFilter); - _comboData = objectDifference(_comboData, _multiData); - if (callback) callback(_comboData, hasStaticValues()); }); } - function addComboboxIcons(disp, value) { - const iconsField = field.resolveReference("iconsCrossReference"); - if (iconsField.icons) { - return function(selection2) { - var span = selection2.insert("span", ":first-child").attr("class", "tag-value-icon"); - if (iconsField.icons[value]) { - span.call(svgIcon("#".concat(iconsField.icons[value]))); - } - disp.call(this, selection2); - }; - } - return disp; + var panel = function(selection2) { + selection2.call(redraw); + context.map().on("drawn.info-background", function() { + selection2.call(debouncedRedraw); + }).on("move.info-background", function() { + selection2.call(debouncedGetMetadata); + }); + }; + panel.off = function() { + context.map().on("drawn.info-background", null).on("move.info-background", null); + }; + panel.id = "background"; + panel.label = _t.append("info_panels.background.title"); + panel.key = _t("info_panels.background.key"); + return panel; + } + var init_background = __esm({ + "modules/ui/panels/background.js"() { + "use strict"; + init_debounce(); + init_localizer(); } - function setPlaceholder(values) { - if (_isMulti || _isSemi) { - _staticPlaceholder = field.placeholder() || _t("inspector.add"); - } else { - var vals = values.map(function(d2) { - return d2.value; - }).filter(function(s2) { - return s2.length < 20; - }); - var placeholders = vals.length > 1 ? vals : values.map(function(d2) { - return d2.key; - }); - _staticPlaceholder = field.placeholder() || placeholders.slice(0, 3).join(", "); + }); + + // modules/ui/panels/history.js + var history_exports2 = {}; + __export(history_exports2, { + uiPanelHistory: () => uiPanelHistory + }); + function uiPanelHistory(context) { + var osm; + function displayTimestamp(timestamp) { + if (!timestamp) return _t("info_panels.history.unknown"); + var options2 = { + day: "numeric", + month: "short", + year: "numeric", + hour: "numeric", + minute: "numeric", + second: "numeric" + }; + var d2 = new Date(timestamp); + if (isNaN(d2.getTime())) return _t("info_panels.history.unknown"); + return d2.toLocaleString(_mainLocalizer.localeCode(), options2); + } + function displayUser(selection2, userName) { + if (!userName) { + selection2.append("span").call(_t.append("info_panels.history.unknown")); + return; } - if (!/(…|\.\.\.)$/.test(_staticPlaceholder)) { - _staticPlaceholder += "\u2026"; + selection2.append("span").attr("class", "user-name").text(userName); + var links = selection2.append("div").attr("class", "links"); + if (osm) { + links.append("a").attr("class", "user-osm-link").attr("href", osm.userURL(userName)).attr("target", "_blank").call(_t.append("info_panels.history.profile_link")); } - var ph; - if (!_isMulti && !_isSemi && _tags && Array.isArray(_tags[field.key])) { - ph = _t("inspector.multiple_values"); - } else { - ph = _staticPlaceholder; + links.append("a").attr("class", "user-hdyc-link").attr("href", "https://hdyc.neis-one.org/?" + userName).attr("target", "_blank").attr("tabindex", -1).text("HDYC"); + } + function displayChangeset(selection2, changeset) { + if (!changeset) { + selection2.append("span").call(_t.append("info_panels.history.unknown")); + return; } - _container.selectAll("input").attr("placeholder", ph); - var hideAdd = !_allowCustomValues && !values.length; - _container.selectAll(".chiplist .input-wrap").style("display", hideAdd ? "none" : null); + selection2.append("span").attr("class", "changeset-id").text(changeset); + var links = selection2.append("div").attr("class", "links"); + if (osm) { + links.append("a").attr("class", "changeset-osm-link").attr("href", osm.changesetURL(changeset)).attr("target", "_blank").call(_t.append("info_panels.history.changeset_link")); + } + links.append("a").attr("class", "changeset-osmcha-link").attr("href", "https://osmcha.org/changesets/" + changeset).attr("target", "_blank").text("OSMCha"); + links.append("a").attr("class", "changeset-achavi-link").attr("href", "https://overpass-api.de/achavi/?changeset=" + changeset).attr("target", "_blank").text("Achavi"); } - function change() { - var t2 = {}; - var val; - if (_isMulti || _isSemi) { - var vals; - if (_isMulti) { - vals = [tagValue(utilGetSetValue(_input))]; - } else if (_isSemi) { - val = tagValue(utilGetSetValue(_input)) || ""; - val = val.replace(/,/g, ";"); - vals = val.split(";"); - } - vals = vals.filter(Boolean); - if (!vals.length) return; - _container.classed("active", false); - utilGetSetValue(_input, ""); - if (_isMulti) { - utilArrayUniq(vals).forEach(function(v2) { - var key = (field.key || "") + v2; - if (_tags) { - var old = _tags[key]; - if (typeof old === "string" && old.toLowerCase() !== "no") return; - } - key = context.cleanTagKey(key); - field.keys.push(key); - t2[key] = "yes"; - }); - } else if (_isSemi) { - var arr = _multiData.map(function(d2) { - return d2.key; - }); - arr = arr.concat(vals); - t2[field.key] = context.cleanTagValue(utilArrayUniq(arr).filter(Boolean).join(";")); + function redraw(selection2) { + var selectedNoteID = context.selectedNoteID(); + osm = context.connection(); + var selected, note, entity; + if (selectedNoteID && osm) { + selected = [_t.html("note.note") + " " + selectedNoteID]; + note = osm.getNote(selectedNoteID); + } else { + selected = context.selectedIDs().filter(function(e3) { + return context.hasEntity(e3); + }); + if (selected.length) { + entity = context.entity(selected[0]); } - window.setTimeout(function() { - _input.node().focus(); - }, 10); + } + var singular = selected.length === 1 ? selected[0] : null; + selection2.html(""); + if (singular) { + selection2.append("h4").attr("class", "history-heading").html(singular); } else { - var rawValue = utilGetSetValue(_input); - if (!rawValue && Array.isArray(_tags[field.key])) return; - val = context.cleanTagValue(tagValue(rawValue)); - t2[field.key] = val || void 0; + selection2.append("h4").attr("class", "history-heading").call(_t.append("info_panels.selected", { n: selected.length })); } - dispatch14.call("change", this, t2); - } - function removeMultikey(d3_event, d2) { - d3_event.preventDefault(); - d3_event.stopPropagation(); - var t2 = {}; - if (_isMulti) { - t2[d2.key] = void 0; - } else if (_isSemi) { - var arr = _multiData.map(function(md) { - return md.key === d2.key ? null : md.key; - }).filter(Boolean); - arr = utilArrayUniq(arr); - t2[field.key] = arr.length ? arr.join(";") : void 0; - _lengthIndicator.update(t2[field.key]); + if (!singular) return; + if (entity) { + selection2.call(redrawEntity, entity); + } else if (note) { + selection2.call(redrawNote, note); } - dispatch14.call("change", this, t2); } - function invertMultikey(d3_event, d2) { - d3_event.preventDefault(); - d3_event.stopPropagation(); - var t2 = {}; - if (_isMulti) { - t2[d2.key] = _tags[d2.key] === "yes" ? "no" : "yes"; + function redrawNote(selection2, note) { + if (!note || note.isNew()) { + selection2.append("div").call(_t.append("info_panels.history.note_no_history")); + return; } - dispatch14.call("change", this, t2); - } - function combo(selection2) { - _container = selection2.selectAll(".form-field-input-wrap").data([0]); - var type2 = _isMulti || _isSemi ? "multicombo" : "combo"; - _container = _container.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + type2).merge(_container); - if (_isMulti || _isSemi) { - _container = _container.selectAll(".chiplist").data([0]); - var listClass = "chiplist"; - if (field.key === "destination" || field.key === "via") { - listClass += " full-line-chips"; - } - _container = _container.enter().append("ul").attr("class", listClass).on("click", function() { - window.setTimeout(function() { - _input.node().focus(); - }, 10); - }).merge(_container); - _inputWrap = _container.selectAll(".input-wrap").data([0]); - _inputWrap = _inputWrap.enter().append("li").attr("class", "input-wrap").merge(_inputWrap); - var hideAdd = !_allowCustomValues && !_comboData.length; - _inputWrap.style("display", hideAdd ? "none" : null); - _input = _inputWrap.selectAll("input").data([0]); - } else { - _input = _container.selectAll("input").data([0]); + 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) { + 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); } - _input = _input.enter().append("input").attr("type", "text").attr("id", field.domId).call(utilNoAuto).call(initCombo, _container).merge(_input); - if (_isSemi) { - _inputWrap.call(_lengthIndicator); - } else if (!_isMulti) { - _container.call(_lengthIndicator); + 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")); } - if (_isNetwork) { - var extent = combinedEntityExtent(); - var countryCode = extent && iso1A2Code(extent.center()); - _countryCode = countryCode && countryCode.toLowerCase(); + } + function redrawEntity(selection2, entity) { + if (!entity || entity.isNew()) { + selection2.append("div").call(_t.append("info_panels.history.no_history")); + return; } - _input.on("change", change).on("blur", change).on("input", function() { - let val = utilGetSetValue(_input); - updateIcon(val); - if (_isSemi && _tags[field.key]) { - val += ";" + _tags[field.key]; - } - _lengthIndicator.update(val); + var links = selection2.append("div").attr("class", "links"); + if (osm) { + 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 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); + context.map().on("drawn.info-history", function() { + selection2.call(redraw); }); - _input.on("keydown.field", function(d3_event) { - switch (d3_event.keyCode) { - case 13: - _input.node().blur(); - d3_event.stopPropagation(); - break; - } + context.on("enter.info-history", function() { + selection2.call(redraw); }); - if (_isMulti || _isSemi) { - _combobox.on("accept", function() { - _input.node().blur(); - _input.node().focus(); - }); - _input.on("focus", function() { - _container.classed("active", true); + }; + panel.off = function() { + context.map().on("drawn.info-history", null); + context.on("enter.info-history", null); + }; + panel.id = "history"; + panel.label = _t.append("info_panels.history.title"); + panel.key = _t("info_panels.history.key"); + return panel; + } + var init_history2 = __esm({ + "modules/ui/panels/history.js"() { + "use strict"; + init_localizer(); + init_svg(); + } + }); + + // modules/ui/panels/location.js + var location_exports = {}; + __export(location_exports, { + uiPanelLocation: () => uiPanelLocation + }); + function uiPanelLocation(context) { + var currLocation = ""; + function redraw(selection2) { + selection2.html(""); + var list2 = selection2.append("ul"); + var coord2 = context.map().mouseCoordinates(); + if (coord2.some(isNaN)) { + coord2 = context.map().center(); + } + list2.append("li").text(dmsCoordinatePair(coord2)).append("li").text(decimalCoordinatePair(coord2)); + selection2.append("div").attr("class", "location-info").text(currLocation || " "); + debouncedGetLocation(selection2, coord2); + } + var debouncedGetLocation = debounce_default(getLocation, 250); + function getLocation(selection2, coord2) { + if (!services.geocoder) { + currLocation = _t("info_panels.location.unknown_location"); + selection2.selectAll(".location-info").text(currLocation); + } else { + services.geocoder.reverse(coord2, function(err, result) { + currLocation = result ? result.display_name : _t("info_panels.location.unknown_location"); + selection2.selectAll(".location-info").text(currLocation); }); } - _combobox.on("cancel", function() { - _input.node().blur(); - }).on("update", function() { - updateIcon(utilGetSetValue(_input)); + } + var panel = function(selection2) { + selection2.call(redraw); + context.surface().on(("PointerEvent" in window ? "pointer" : "mouse") + "move.info-location", function() { + selection2.call(redraw); }); + }; + panel.off = function() { + context.surface().on(".info-location", null); + }; + panel.id = "location"; + panel.label = _t.append("info_panels.location.title"); + panel.key = _t("info_panels.location.key"); + return panel; + } + var init_location = __esm({ + "modules/ui/panels/location.js"() { + "use strict"; + init_debounce(); + init_units(); + init_localizer(); + init_services(); } - function updateIcon(value) { - value = tagValue(value); - let container = _container; - if (field.type === "multiCombo" || field.type === "semiCombo") { - container = _container.select(".input-wrap"); - } - const iconsField = field.resolveReference("iconsCrossReference"); - if (iconsField.icons) { - container.selectAll(".tag-value-icon").remove(); - if (iconsField.icons[value]) { - container.selectAll(".tag-value-icon").data([value]).enter().insert("div", "input").attr("class", "tag-value-icon").call(svgIcon("#".concat(iconsField.icons[value]))); - } + }); + + // modules/ui/panels/measurement.js + var measurement_exports = {}; + __export(measurement_exports, { + uiPanelMeasurement: () => uiPanelMeasurement + }); + function uiPanelMeasurement(context) { + function radiansToMeters(r2) { + return r2 * 63710071809e-4; + } + function steradiansToSqmeters(r2) { + return r2 / (4 * Math.PI) * 510065621724e3; + } + function toLineString(feature3) { + if (feature3.type === "LineString") return feature3; + var result = { type: "LineString", coordinates: [] }; + if (feature3.type === "Polygon") { + result.coordinates = feature3.coordinates[0]; + } else if (feature3.type === "MultiPolygon") { + result.coordinates = feature3.coordinates[0][0]; } + return result; } - combo.tags = function(tags) { - _tags = tags; - var stringsField = field.resolveReference("stringsCrossReference"); - var isMixed = Array.isArray(tags[field.key]); - var showsValue = (value) => !isMixed && value && !(field.type === "typeCombo" && value === "yes"); - var isRawValue = (value) => showsValue(value) && !stringsField.hasTextForStringId("options.".concat(value)) && !stringsField.hasTextForStringId("options.".concat(value, ".title")); - var isKnownValue = (value) => showsValue(value) && !isRawValue(value); - var isReadOnly = !_allowCustomValues; - if (_isMulti || _isSemi) { - _multiData = []; - var maxLength; - if (_isMulti) { - for (var k2 in tags) { - if (field.key && k2.indexOf(field.key) !== 0) continue; - if (!field.key && field.keys.indexOf(k2) === -1) continue; - var v2 = tags[k2]; - var suffix = field.key ? k2.slice(field.key.length) : k2; - _multiData.push({ - key: k2, - value: displayValue(suffix), - display: addComboboxIcons(renderValue(suffix), suffix), - state: typeof v2 === "string" ? v2.toLowerCase() : "", - isMixed: Array.isArray(v2) - }); - } - if (field.key) { - field.keys = _multiData.map(function(d2) { - return d2.key; - }); - maxLength = context.maxCharsForTagKey() - utilUnicodeCharsCount(field.key); - } else { - maxLength = context.maxCharsForTagKey(); - } - } else if (_isSemi) { - var allValues = []; - var commonValues; - if (Array.isArray(tags[field.key])) { - tags[field.key].forEach(function(tagVal) { - var thisVals = utilArrayUniq((tagVal || "").split(";")).filter(Boolean); - allValues = allValues.concat(thisVals); - if (!commonValues) { - commonValues = thisVals; - } else { - commonValues = commonValues.filter((value) => thisVals.includes(value)); + var _isImperial = !_mainLocalizer.usesMetric(); + function redraw(selection2) { + var graph = context.graph(); + var selectedNoteID = context.selectedNoteID(); + var osm = services.osm; + var localeCode = _mainLocalizer.localeCode(); + var heading2; + var center, location, centroid; + var closed, geometry; + var totalNodeCount, length2 = 0, area = 0, distance; + if (selectedNoteID && osm) { + var note = osm.getNote(selectedNoteID); + heading2 = _t.html("note.note") + " " + selectedNoteID; + location = note.loc; + geometry = "note"; + } else { + var selectedIDs = context.selectedIDs().filter(function(id2) { + return context.hasEntity(id2); + }); + var selected = selectedIDs.map(function(id2) { + return context.entity(id2); + }); + 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) { + var entity = selected[i3]; + extent._extend(entity.extent(graph)); + geometry = entity.geometry(graph); + if (geometry === "line" || geometry === "area") { + closed = entity.type === "relation" || entity.isClosed() && !entity.isDegenerate(); + var feature3 = entity.asGeoJSON(graph); + 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])) { + centroid = entity.extent(graph).center(); } - }); - allValues = utilArrayUniq(allValues).filter(Boolean); - } else { - allValues = utilArrayUniq((tags[field.key] || "").split(";")).filter(Boolean); - commonValues = allValues; - } - _multiData = allValues.map(function(v3) { - return { - key: v3, - value: displayValue(v3), - display: addComboboxIcons(renderValue(v3), v3), - isMixed: !commonValues.includes(v3) - }; - }); - var currLength = utilUnicodeCharsCount(commonValues.join(";")); - maxLength = context.maxCharsForTagValue() - currLength; - if (currLength > 0) { - maxLength -= 1; - } - } - maxLength = Math.max(0, maxLength); - var hideAdd = maxLength <= 0 || !_allowCustomValues && !_comboData.length; - _container.selectAll(".chiplist .input-wrap").style("display", hideAdd ? "none" : null); - var allowDragAndDrop = _isSemi && !Array.isArray(tags[field.key]); - var chips = _container.selectAll(".chip").data(_multiData); - chips.exit().remove(); - var enter = chips.enter().insert("li", ".input-wrap").attr("class", "chip"); - enter.append("span"); - 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) k3 = k3.replace(field.key, ""); - return !stringsField.hasTextForStringId("options." + k3); - }).classed("draggable", allowDragAndDrop).classed("mixed", function(d2) { - return d2.isMixed; - }).attr("title", function(d2) { - if (d2.isMixed) { - return _t("inspector.unshared_value_tooltip"); - } - if (!["yes", "no"].includes(d2.state)) { - return d2.state; + if (closed) { + area += steradiansToSqmeters(entity.area(graph)); + } + } } - return null; - }).classed("negated", (d2) => d2.state === "no"); - if (!_isSemi) { - chips.selectAll("input[type=checkbox]").remove(); - chips.insert("input", "span").attr("type", "checkbox").property("checked", (d2) => d2.state === "yes").property("indeterminate", (d2) => d2.isMixed || !["yes", "no"].includes(d2.state)).on("click", invertMultikey); - } - if (allowDragAndDrop) { - registerDragAndDrop(chips); - } - 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 (selected.length > 1) { + geometry = null; + closed = null; + centroid = null; } - 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 (selected.length === 2 && selected[0].type === "node" && selected[1].type === "node") { + distance = geoSphericalDistance(selected[0].loc, selected[1].loc); } - if (d2.display) { - d2.display(text_span); - return; + if (selected.length === 1 && selected[0].type === "node") { + location = selected[0].loc; + } else { + totalNodeCount = utilGetAllNodes(selectedIDs, context.graph()).length; } - text_span.text(d2.value); - }); - 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) { - return displayValue(val); - }).filter(Boolean); - utilGetSetValue(_input, !isMixed ? displayValue(tags[field.key]) : "").data([tags[field.key]]).classed("raw-value", isRawValue).classed("known-value", isKnownValue).attr("readonly", isReadOnly ? "readonly" : void 0).attr("title", isMixed ? mixedValues.join("\n") : void 0).attr("placeholder", isMixed ? _t("inspector.multiple_values") : _staticPlaceholder || "").classed("mixed", isMixed).on("keydown.deleteCapture", function(d3_event) { - if (isReadOnly && isKnownValue(tags[field.key]) && (d3_event.keyCode === utilKeybinding.keyCodes["\u232B"] || d3_event.keyCode === utilKeybinding.keyCodes["\u2326"])) { - d3_event.preventDefault(); - d3_event.stopPropagation(); - var t2 = {}; - t2[field.key] = void 0; - dispatch14.call("change", this, t2); + if (!location && !centroid) { + center = extent.center(); } - }); - if (!Array.isArray(tags[field.key])) { - updateIcon(tags[field.key]); - } - if (!isMixed) { - _lengthIndicator.update(tags[field.key]); } } - const refreshStyles = () => { - _input.data([tagValue(utilGetSetValue(_input))]).classed("raw-value", isRawValue).classed("known-value", isKnownValue); - }; - _input.on("input.refreshStyles", refreshStyles); - _combobox.on("update.refreshStyles", refreshStyles); - refreshStyles(); - }; - function registerDragAndDrop(selection2) { - var dragOrigin, targetIndex; - selection2.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 = selection2.nodes().indexOf(this); - select_default2(this).classed("dragging", true); - targetIndex = null; - var targetIndexOffsetTop = null; - var draggedTagWidth = select_default2(this).node().offsetWidth; - if (field.key === "destination" || field.key === "via") { - _container.selectAll(".chip").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; - }); - } else { - _container.selectAll(".chip").each(function(d2, index2) { - var node = select_default2(this).node(); - if (index !== index2 && d3_event.x < node.offsetLeft + node.offsetWidth + 5 && d3_event.x > node.offsetLeft && d3_event.y < node.offsetTop + node.offsetHeight && d3_event.y > node.offsetTop) { - targetIndex = index2; - targetIndexOffsetTop = node.offsetTop; - } - }).style("transform", function(d2, index2) { - var node = select_default2(this).node(); - if (index === index2) { - return "translate(" + x2 + "px, " + y2 + "px)"; - } - if (node.offsetTop === targetIndexOffsetTop) { - if (index2 < index && index2 >= targetIndex) { - return "translateX(" + draggedTagWidth + "px)"; - } else if (index2 > index && index2 <= targetIndex) { - return "translateX(-" + draggedTagWidth + "px)"; - } - } - return null; - }); - } - }).on("end", function() { - if (!select_default2(this).classed("dragging")) { - return; - } - var index = selection2.nodes().indexOf(this); - select_default2(this).classed("dragging", false); - _container.selectAll(".chip").style("transform", null); - if (typeof targetIndex === "number") { - var element = _multiData[index]; - _multiData.splice(index, 1); - _multiData.splice(targetIndex, 0, element); - var t2 = {}; - if (_multiData.length) { - t2[field.key] = _multiData.map(function(element2) { - return element2.key; - }).join(";"); - } else { - t2[field.key] = void 0; - } - dispatch14.call("change", this, t2); - } - dragOrigin = void 0; - targetIndex = void 0; - }) - ); - } - combo.setCustomOptions = (newValue) => { - _customOptions = newValue; - }; - combo.focus = function() { - _input.node().focus(); - }; - combo.entityIDs = function(val) { - if (!arguments.length) return _entityIDs; - _entityIDs = val; - return combo; - }; - function combinedEntityExtent() { - return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph()); - } - return utilRebind(combo, dispatch14, "on"); - } - - // modules/ui/account.js - function uiAccount(context) { - const osm = context.connection(); - function updateUserDetails(selection2) { - if (!osm) return; - if (!osm.authenticated()) { - render(selection2, null); - } else { - osm.userDetails((err, user) => render(selection2, user)); + selection2.html(""); + if (heading2) { + selection2.append("h4").attr("class", "measurement-heading").html(heading2); } - } - function render(selection2, user) { - let userInfo = selection2.select(".userInfo"); - let loginLogout = selection2.select(".loginLogout"); - if (user) { - userInfo.html("").classed("hide", false); - let userLink = userInfo.append("a").attr("href", osm.userURL(user.display_name)).attr("target", "_blank"); - if (user.image_url) { - userLink.append("img").attr("class", "icon pre-text user-icon").attr("src", user.image_url); - } else { - userLink.call(svgIcon("#iD-icon-avatar", "pre-text light")); - } - userLink.append("span").attr("class", "label").text(user.display_name); - loginLogout.classed("hide", false).select("a").text(_t("logout")).on("click", (e3) => { - e3.preventDefault(); - osm.logout(); - osm.authenticate(void 0, { switchUser: true }); - }); - } else { - userInfo.html("").classed("hide", true); - loginLogout.classed("hide", false).select("a").text(_t("login")).on("click", (e3) => { - e3.preventDefault(); - osm.authenticate(); + var list2 = selection2.append("ul"); + var coordItem; + if (geometry) { + 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) { + list2.append("li").call(_t.append("info_panels.measurement.node_count", { suffix: ":" })).append("span").text(totalNodeCount.toLocaleString(localeCode)); + } + if (area) { + list2.append("li").call(_t.append("info_panels.measurement.area", { suffix: ":" })).append("span").text(displayArea(area, _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") { + list2.append("li").call(_t.append("info_panels.measurement.distance", { suffix: ":" })).append("span").text(displayLength(distance, _isImperial)); + } + if (location) { + 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 = 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 = list2.append("li").call(_t.append("info_panels.measurement.center", { suffix: ":" })); + coordItem.append("span").text(dmsCoordinatePair(center)); + coordItem.append("span").text(decimalCoordinatePair(center)); + } + 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(); + _isImperial = !_isImperial; + selection2.call(redraw); }); } } - return function(selection2) { - if (!osm) return; - selection2.append("li").attr("class", "userInfo").classed("hide", true); - selection2.append("li").attr("class", "loginLogout").classed("hide", true).append("a").attr("href", "#"); - osm.on("change.account", () => updateUserDetails(selection2)); - updateUserDetails(selection2); + var panel = function(selection2) { + selection2.call(redraw); + context.map().on("drawn.info-measurement", function() { + selection2.call(redraw); + }); + context.on("enter.info-measurement", function() { + selection2.call(redraw); + }); + }; + panel.off = function() { + context.map().on("drawn.info-measurement", null); + context.on("enter.info-measurement", null); }; + panel.id = "measurement"; + panel.label = _t.append("info_panels.measurement.title"); + panel.key = _t("info_panels.measurement.key"); + return panel; } - - // modules/ui/attribution.js - function uiAttribution(context) { - let _selection = select_default2(null); - function render(selection2, data, klass) { - let div = selection2.selectAll(".".concat(klass)).data([0]); - div = div.enter().append("div").attr("class", klass).merge(div); - let attributions = div.selectAll(".attribution").data(data, (d2) => d2.id); - attributions.exit().remove(); - attributions = attributions.enter().append("span").attr("class", "attribution").each((d2, i3, nodes) => { - let attribution = select_default2(nodes[i3]); - if (d2.terms_html) { - attribution.html(d2.terms_html); - return; - } - if (d2.terms_url) { - attribution = attribution.append("a").attr("href", d2.terms_url).attr("target", "_blank"); - } - const sourceID = d2.id.replace(/\./g, ""); - const terms_text = _t( - "imagery.".concat(sourceID, ".attribution.text"), - { default: d2.terms_text || d2.id || d2.name() } - ); - if (d2.icon && !d2.overlay) { - attribution.append("img").attr("class", "source-image").attr("src", d2.icon); - } - attribution.append("span").attr("class", "attribution-text").text(terms_text); - }).merge(attributions); - let copyright = attributions.selectAll(".copyright-notice").data((d2) => { - let notice = d2.copyrightNotices(context.map().zoom(), context.map().extent()); - return notice ? [notice] : []; - }); - copyright.exit().remove(); - copyright = copyright.enter().append("span").attr("class", "copyright-notice").merge(copyright); - copyright.text(String); + var init_measurement = __esm({ + "modules/ui/panels/measurement.js"() { + "use strict"; + init_src2(); + init_localizer(); + init_units(); + init_geo2(); + init_services(); + init_util(); } - function update() { - let baselayer = context.background().baseLayerSource(); - _selection.call(render, baselayer ? [baselayer] : [], "base-layer-attribution"); - const z2 = context.map().zoom(); - let overlays = context.background().overlayLayerSources() || []; - _selection.call(render, overlays.filter((s2) => s2.validZoom(z2)), "overlay-layer-attribution"); + }); + + // modules/ui/panels/index.js + var panels_exports = {}; + __export(panels_exports, { + uiInfoPanels: () => uiInfoPanels, + uiPanelBackground: () => uiPanelBackground, + uiPanelHistory: () => uiPanelHistory, + uiPanelLocation: () => uiPanelLocation, + uiPanelMeasurement: () => uiPanelMeasurement + }); + var uiInfoPanels; + var init_panels = __esm({ + "modules/ui/panels/index.js"() { + "use strict"; + init_background(); + init_history2(); + init_location(); + init_measurement(); + init_background(); + init_history2(); + init_location(); + init_measurement(); + uiInfoPanels = { + background: uiPanelBackground, + history: uiPanelHistory, + location: uiPanelLocation, + measurement: uiPanelMeasurement + }; } - return function(selection2) { - _selection = selection2; - context.background().on("change.attribution", update); - context.map().on("move.attribution", throttle_default(update, 400, { leading: false })); - update(); - }; - } + }); - // modules/ui/contributors.js - function uiContributors(context) { - var osm = context.connection(), debouncedUpdate = debounce_default(function() { - update(); - }, 1e3), limit = 4, hidden = false, wrap2 = select_default2(null); - function update() { - if (!osm) return; - var users = {}, entities = context.history().intersects(context.map().extent()); - entities.forEach(function(entity) { - if (entity && entity.user) users[entity.user] = true; - }); - var u2 = Object.keys(users), subset = u2.slice(0, u2.length > limit ? limit - 1 : limit); - wrap2.html("").call(svgIcon("#iD-icon-nearby", "pre-text light")); - var userList = select_default2(document.createElement("span")); - userList.selectAll().data(subset).enter().append("a").attr("class", "user-link").attr("href", function(d2) { - return osm.userURL(d2); - }).attr("target", "_blank").text(String); - if (u2.length > limit) { - var count = select_default2(document.createElement("span")); - var othersNum = u2.length - limit + 1; - count.append("a").attr("target", "_blank").attr("href", function() { - return osm.changesetsURL(context.map().center(), context.map().zoom()); - }).text(othersNum); - wrap2.append("span").html(_t.html("contributors.truncated_list", { n: othersNum, users: { html: userList.html() }, count: { html: count.html() } })); - } else { - wrap2.append("span").html(_t.html("contributors.list", { users: { html: userList.html() } })); + // modules/ui/info.js + var info_exports = {}; + __export(info_exports, { + uiInfo: () => uiInfo + }); + function uiInfo(context) { + var ids = Object.keys(uiInfoPanels); + var wasActive = ["measurement"]; + var panels = {}; + var active = {}; + ids.forEach(function(k2) { + if (!panels[k2]) { + panels[k2] = uiInfoPanels[k2](context); + active[k2] = false; } - if (!u2.length) { - hidden = true; - wrap2.transition().style("opacity", 0); - } else if (hidden) { - wrap2.transition().style("opacity", 1); + }); + function info(selection2) { + function redraw() { + var activeids = ids.filter(function(k2) { + return active[k2]; + }).sort(); + var containers = infoPanels.selectAll(".panel-container").data(activeids, function(k2) { + return k2; + }); + containers.exit().style("opacity", 1).transition().duration(200).style("opacity", 0).on("end", function(d2) { + select_default2(this).call(panels[d2].off).remove(); + }); + var enter = containers.enter().append("div").attr("class", function(d2) { + return "fillD2 panel-container panel-container-" + d2; + }); + enter.style("opacity", 0).transition().duration(200).style("opacity", 1); + var title = enter.append("div").attr("class", "panel-title fillD2"); + title.append("h3").each(function(d2) { + return panels[d2].label(select_default2(this)); + }); + title.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function(d3_event, d2) { + d3_event.stopImmediatePropagation(); + d3_event.preventDefault(); + info.toggle(d2); + }).call(svgIcon("#iD-icon-close")); + enter.append("div").attr("class", function(d2) { + return "panel-content panel-content-" + d2; + }); + infoPanels.selectAll(".panel-content").each(function(d2) { + select_default2(this).call(panels[d2]); + }); } + info.toggle = function(which) { + var activeids = ids.filter(function(k2) { + return active[k2]; + }); + if (which) { + active[which] = !active[which]; + if (activeids.length === 1 && activeids[0] === which) { + wasActive = [which]; + } + context.container().select("." + which + "-panel-toggle-item").classed("active", active[which]).select("input").property("checked", active[which]); + } else { + if (activeids.length) { + wasActive = activeids; + activeids.forEach(function(k2) { + active[k2] = false; + }); + } else { + wasActive.forEach(function(k2) { + active[k2] = true; + }); + } + } + redraw(); + }; + var infoPanels = selection2.selectAll(".info-panels").data([0]); + infoPanels = infoPanels.enter().append("div").attr("class", "info-panels").merge(infoPanels); + redraw(); + context.keybinding().on(uiCmd("\u2318" + _t("info_panels.key")), function(d3_event) { + if (d3_event.shiftKey) return; + d3_event.stopImmediatePropagation(); + d3_event.preventDefault(); + info.toggle(); + }); + ids.forEach(function(k2) { + var key = _t("info_panels." + k2 + ".key", { default: null }); + if (!key) return; + context.keybinding().on(uiCmd("\u2318\u21E7" + key), function(d3_event) { + d3_event.stopImmediatePropagation(); + d3_event.preventDefault(); + info.toggle(k2); + }); + }); + } + return info; + } + var init_info = __esm({ + "modules/ui/info.js"() { + "use strict"; + init_src5(); + init_localizer(); + init_icon(); + init_cmd(); + init_panels(); } + }); + + // modules/ui/toggle.js + var toggle_exports = {}; + __export(toggle_exports, { + uiToggle: () => uiToggle + }); + function uiToggle(show, callback) { return function(selection2) { - if (!osm) return; - wrap2 = selection2; - update(); - osm.on("loaded.contributors", debouncedUpdate); - context.map().on("move.contributors", debouncedUpdate); + selection2.style("opacity", show ? 0 : 1).classed("hide", false).transition().style("opacity", show ? 1 : 0).on("end", function() { + select_default2(this).classed("hide", !show).style("opacity", null); + if (callback) callback.apply(this); + }); }; } + var init_toggle = __esm({ + "modules/ui/toggle.js"() { + "use strict"; + init_src5(); + } + }); - // modules/ui/edit_menu.js - function uiEditMenu(context) { - var dispatch14 = dispatch_default("toggled"); - var _menu = select_default2(null); - var _operations = []; - var _anchorLoc = [0, 0]; - var _anchorLocLonLat = [0, 0]; - var _triggerType = ""; - var _vpTopMargin = 85; - var _vpBottomMargin = 45; - var _vpSideMargin = 35; - var _menuTop = false; - var _menuHeight; - var _menuWidth; - var _verticalPadding = 4; - var _tooltipWidth = 210; - var _menuSideMargin = 10; - var _tooltips = []; - var editMenu = function(selection2) { - var isTouchMenu = _triggerType.includes("touch") || _triggerType.includes("pen"); - var ops = _operations.filter(function(op) { - return !isTouchMenu || !op.mouseOnly; - }); - if (!ops.length) return; - _tooltips = []; - _menuTop = isTouchMenu; - var showLabels = isTouchMenu; - var buttonHeight = showLabels ? 32 : 34; - if (showLabels) { - _menuWidth = 52 + Math.min(120, 6 * Math.max.apply(Math, ops.map(function(op) { - return op.title.length; - }))); - } else { - _menuWidth = 44; + // modules/ui/curtain.js + var curtain_exports = {}; + __export(curtain_exports, { + uiCurtain: () => uiCurtain + }); + function uiCurtain(containerNode) { + var surface = select_default2(null), tooltip = select_default2(null), darkness = select_default2(null); + function curtain(selection2) { + surface = selection2.append("svg").attr("class", "curtain").style("top", 0).style("left", 0); + darkness = surface.append("path").attr("x", 0).attr("y", 0).attr("class", "curtain-darkness"); + select_default2(window).on("resize.curtain", resize); + tooltip = selection2.append("div").attr("class", "tooltip"); + tooltip.append("div").attr("class", "popover-arrow"); + tooltip.append("div").attr("class", "popover-inner"); + resize(); + function resize() { + surface.attr("width", containerNode.clientWidth).attr("height", containerNode.clientHeight); + curtain.cut(darkness.datum()); } - _menuHeight = _verticalPadding * 2 + ops.length * buttonHeight; - _menu = selection2.append("div").attr("class", "edit-menu").classed("touch-menu", isTouchMenu).style("padding", _verticalPadding + "px 0"); - var buttons = _menu.selectAll(".edit-menu-item").data(ops); - var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) { - return "edit-menu-item edit-menu-item-" + d2.id; - }).style("height", buttonHeight + "px").on("click", click).on("pointerup", pointerup).on("pointerdown mousedown", function pointerdown(d3_event) { - d3_event.stopPropagation(); - }).on("mouseenter.highlight", function(d3_event, d2) { - if (!d2.relatedEntityIds || select_default2(this).classed("disabled")) return; - utilHighlightEntities(d2.relatedEntityIds(), true, context); - }).on("mouseleave.highlight", function(d3_event, d2) { - if (!d2.relatedEntityIds) return; - utilHighlightEntities(d2.relatedEntityIds(), false, context); - }); - buttonsEnter.each(function(d2) { - var tooltip = uiTooltip().heading(() => d2.title).title(d2.tooltip).keys([d2.keys[0]]); - _tooltips.push(tooltip); - select_default2(this).call(tooltip).append("div").attr("class", "icon-wrap").call(svgIcon(d2.icon && d2.icon() || "#iD-operation-" + d2.id, "operation")); - }); - if (showLabels) { - buttonsEnter.append("span").attr("class", "label").each(function(d2) { - select_default2(this).call(d2.title); - }); + } + curtain.reveal = function(box, html3, options2) { + options2 = options2 || {}; + if (typeof box === "string") { + box = select_default2(box).node(); } - buttonsEnter.merge(buttons).classed("disabled", function(d2) { - return d2.disabled(); - }); - updatePosition(); - var initialScale = context.projection.scale(); - context.map().on("move.edit-menu", function() { - if (initialScale !== context.projection.scale()) { - editMenu.close(); - } - }).on("drawn.edit-menu", function(info) { - if (info.full) updatePosition(); - }); - var lastPointerUpType; - function pointerup(d3_event) { - lastPointerUpType = d3_event.pointerType; + if (box && box.getBoundingClientRect) { + box = copyBox(box.getBoundingClientRect()); } - function click(d3_event, operation2) { - d3_event.stopPropagation(); - if (operation2.relatedEntityIds) { - utilHighlightEntities(operation2.relatedEntityIds(), false, context); - } - if (operation2.disabled()) { - if (lastPointerUpType === "touch" || lastPointerUpType === "pen") { - 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-" + operation2.id).iconClass("operation").label(operation2.annotation() || operation2.title)(); - } - operation2(); - editMenu.close(); - } - lastPointerUpType = null; + if (box) { + var containerRect = containerNode.getBoundingClientRect(); + box.top -= containerRect.top; + box.left -= containerRect.left; } - dispatch14.call("toggled", this, true); - }; - function updatePosition() { - if (!_menu || _menu.empty()) return; - var anchorLoc = context.projection(_anchorLocLonLat); - var viewport = context.surfaceRect(); - if (anchorLoc[0] < 0 || anchorLoc[0] > viewport.width || anchorLoc[1] < 0 || anchorLoc[1] > viewport.height) { - editMenu.close(); - return; + if (box && options2.padding) { + box.top -= options2.padding; + box.left -= options2.padding; + box.bottom += options2.padding; + box.right += options2.padding; + box.height += options2.padding * 2; + box.width += options2.padding * 2; } - var menuLeft = displayOnLeft(viewport); - var offset = [0, 0]; - offset[0] = menuLeft ? -1 * (_menuSideMargin + _menuWidth) : _menuSideMargin; - if (_menuTop) { - if (anchorLoc[1] - _menuHeight < _vpTopMargin) { - offset[1] = -anchorLoc[1] + _vpTopMargin; - } else { - offset[1] = -_menuHeight; + var tooltipBox; + if (options2.tooltipBox) { + tooltipBox = options2.tooltipBox; + if (typeof tooltipBox === "string") { + tooltipBox = select_default2(tooltipBox).node(); } - } else { - if (anchorLoc[1] + _menuHeight > viewport.height - _vpBottomMargin) { - offset[1] = -anchorLoc[1] - _menuHeight + viewport.height - _vpBottomMargin; - } else { - offset[1] = 0; + if (tooltipBox && tooltipBox.getBoundingClientRect) { + tooltipBox = copyBox(tooltipBox.getBoundingClientRect()); } + } else { + tooltipBox = box; } - var origin = geoVecAdd(anchorLoc, offset); - var _verticalOffset = parseFloat(utilGetDimensions(select_default2(".top-toolbar-wrap"))[1]); - origin[1] -= _verticalOffset; - _menu.style("left", origin[0] + "px").style("top", origin[1] + "px"); - var tooltipSide = tooltipPosition(viewport, menuLeft); - _tooltips.forEach(function(tooltip) { - tooltip.placement(tooltipSide); - }); - function displayOnLeft(viewport2) { - if (_mainLocalizer.textDirection() === "ltr") { - if (anchorLoc[0] + _menuSideMargin + _menuWidth > viewport2.width - _vpSideMargin) { - return true; - } - return false; - } else { - if (anchorLoc[0] - _menuSideMargin - _menuWidth < _vpSideMargin) { - return false; + if (tooltipBox && html3) { + if (html3.indexOf("**") !== -1) { + if (html3.indexOf(")(.+?)(\*\*)/, "$1$2$3"); + } else { + html3 = html3.replace(/^(.+?)(\*\*)/, "$1$2"); } - return true; + html3 = html3.replace(/\*\*(.*?)\*\*/g, '$1'); } - } - function tooltipPosition(viewport2, menuLeft2) { - if (_mainLocalizer.textDirection() === "ltr") { - if (menuLeft2) { - return "left"; - } - if (anchorLoc[0] + _menuSideMargin + _menuWidth + _tooltipWidth > viewport2.width - _vpSideMargin) { - return "left"; - } - return "right"; + html3 = html3.replace(/\*(.*?)\*/g, "$1"); + html3 = html3.replace(/\{br\}/g, "

    "); + if (options2.buttonText && options2.buttonCallback) { + html3 += '
    "; + } + var classes = "curtain-tooltip popover tooltip arrowed in " + (options2.tooltipClass || ""); + 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) { + d3_event.preventDefault(); + options2.buttonCallback(); + }); + } + var tip = copyBox(tooltip.node().getBoundingClientRect()), w2 = containerNode.clientWidth, h2 = containerNode.clientHeight, tooltipWidth = 200, tooltipArrow = 5, side, pos; + if (options2.tooltipClass === "intro-mouse") { + tip.height += 80; + } + if (tooltipBox.top + tooltipBox.height > h2) { + tooltipBox.height -= tooltipBox.top + tooltipBox.height - h2; + } + if (tooltipBox.left + tooltipBox.width > w2) { + tooltipBox.width -= tooltipBox.left + tooltipBox.width - w2; + } + const onLeftOrRightEdge = tooltipBox.left + tooltipBox.width / 2 > w2 - 100 || tooltipBox.left + tooltipBox.width / 2 < 100; + if (tooltipBox.top + tooltipBox.height < 100 && !onLeftOrRightEdge) { + side = "bottom"; + pos = [ + tooltipBox.left + tooltipBox.width / 2 - tip.width / 2, + tooltipBox.top + tooltipBox.height + ]; + } else if (tooltipBox.top > h2 - 140 && !onLeftOrRightEdge) { + side = "top"; + pos = [ + tooltipBox.left + tooltipBox.width / 2 - tip.width / 2, + tooltipBox.top - tip.height + ]; } else { - if (!menuLeft2) { - return "right"; - } - if (anchorLoc[0] - _menuSideMargin - _menuWidth - _tooltipWidth < _vpSideMargin) { - return "right"; + var tipY = tooltipBox.top + tooltipBox.height / 2 - tip.height / 2; + if (_mainLocalizer.textDirection() === "rtl") { + if (tooltipBox.left - tooltipWidth - tooltipArrow < 70) { + side = "right"; + pos = [tooltipBox.left + tooltipBox.width + tooltipArrow, tipY]; + } else { + side = "left"; + pos = [tooltipBox.left - tooltipWidth - tooltipArrow, tipY]; + } + } else { + if (tooltipBox.left + tooltipBox.width + tooltipArrow + tooltipWidth > w2 - 70) { + side = "left"; + pos = [tooltipBox.left - tooltipWidth - tooltipArrow, tipY]; + } else { + side = "right"; + pos = [tooltipBox.left + tooltipBox.width + tooltipArrow, tipY]; + } } - return "left"; } - } - } - editMenu.close = function() { - context.map().on("move.edit-menu", null).on("drawn.edit-menu", null); - _menu.remove(); - _tooltips = []; - dispatch14.call("toggled", this, false); - }; - editMenu.anchorLoc = function(val) { - if (!arguments.length) return _anchorLoc; - _anchorLoc = val; - _anchorLocLonLat = context.projection.invert(_anchorLoc); - return editMenu; - }; - editMenu.triggerType = function(val) { - if (!arguments.length) return _triggerType; - _triggerType = val; - return editMenu; - }; - editMenu.operations = function(val) { - if (!arguments.length) return _operations; - _operations = val; - return editMenu; - }; - return utilRebind(editMenu, dispatch14, "on"); - } - - // modules/ui/feature_info.js - function uiFeatureInfo(context) { - function update(selection2) { - var features = context.features(); - var stats = features.stats(); - var count = 0; - var hiddenList = features.hidden().map(function(k2) { - if (stats[k2]) { - count += stats[k2]; - return _t.append("inspector.title_count", { - title: _t("feature." + k2 + ".description"), - count: stats[k2] - }); + if (options2.duration !== 0 || !tooltip.classed(side)) { + tooltip.call(uiToggle(true)); + } + tooltip.style("top", pos[1] + "px").style("left", pos[0] + "px").attr("class", classes + " " + side); + var shiftY = 0; + if (side === "left" || side === "right") { + if (pos[1] < 60) { + shiftY = 60 - pos[1]; + } else if (pos[1] + tip.height > h2 - 100) { + shiftY = h2 - pos[1] - tip.height - 100; + } } - return null; - }).filter(Boolean); - selection2.text(""); - if (hiddenList.length) { - var tooltipBehavior = uiTooltip().placement("top").title(function() { - return (selection3) => { - hiddenList.forEach((hiddenFeature) => { - selection3.append("div").call(hiddenFeature); - }); - }; - }); - selection2.append("a").attr("class", "chip").attr("href", "#").call(_t.append("feature_info.hidden_warning", { count })).call(tooltipBehavior).on("click", function(d3_event) { - tooltipBehavior.hide(); - d3_event.preventDefault(); - context.ui().togglePanes(context.container().select(".map-panes .map-data-pane")); - }); + tooltip.selectAll(".popover-inner").style("top", shiftY + "px"); + } else { + tooltip.classed("in", false).call(uiToggle(false)); } - selection2.classed("hide", !hiddenList.length); - } - return function(selection2) { - update(selection2); - context.features().on("change.feature_info", function() { - update(selection2); + curtain.cut(box, options2.duration); + return tooltip; + }; + curtain.cut = function(datum2, duration) { + darkness.datum(datum2).interrupt(); + var selection2; + if (duration === 0) { + selection2 = darkness; + } else { + selection2 = darkness.transition().duration(duration || 600).ease(linear2); + } + selection2.attr("d", function(d2) { + var containerWidth = containerNode.clientWidth; + var containerHeight = containerNode.clientHeight; + var string = "M 0,0 L 0," + containerHeight + " L " + containerWidth + "," + containerHeight + "L" + containerWidth + ",0 Z"; + if (!d2) return string; + return string + "M" + d2.left + "," + d2.top + "L" + d2.left + "," + (d2.top + d2.height) + "L" + (d2.left + d2.width) + "," + (d2.top + d2.height) + "L" + (d2.left + d2.width) + "," + d2.top + "Z"; }); }; + curtain.remove = function() { + surface.remove(); + tooltip.remove(); + select_default2(window).on("resize.curtain", null); + }; + function copyBox(src) { + return { + top: src.top, + right: src.right, + bottom: src.bottom, + left: src.left, + width: src.width, + height: src.height + }; + } + return curtain; } - - // modules/ui/flash.js - function uiFlash(context) { - var _flashTimer; - var _duration = 2e3; - var _iconName = "#iD-icon-no"; - var _iconClass = "disabled"; - var _label = (s2) => s2.text(""); - function flash() { - if (_flashTimer) { - _flashTimer.stop(); - } - context.container().select(".main-footer-wrap").classed("footer-hide", true).classed("footer-show", false); - context.container().select(".flash-wrap").classed("footer-hide", false).classed("footer-show", true); - var content = context.container().select(".flash-wrap").selectAll(".flash-content").data([0]); - var contentEnter = content.enter().append("div").attr("class", "flash-content"); - var iconEnter = contentEnter.append("svg").attr("class", "flash-icon icon").append("g").attr("transform", "translate(10,10)"); - iconEnter.append("circle").attr("r", 9); - iconEnter.append("use").attr("transform", "translate(-7,-7)").attr("width", "14").attr("height", "14"); - contentEnter.append("div").attr("class", "flash-text"); - content = content.merge(contentEnter); - content.selectAll(".flash-icon").attr("class", "icon flash-icon " + (_iconClass || "")); - content.selectAll(".flash-icon use").attr("xlink:href", _iconName); - content.selectAll(".flash-text").attr("class", "flash-text").call(_label); - _flashTimer = timeout_default(function() { - _flashTimer = null; - context.container().select(".main-footer-wrap").classed("footer-hide", false).classed("footer-show", true); - context.container().select(".flash-wrap").classed("footer-hide", true).classed("footer-show", false); - }, _duration); - return content; + var init_curtain = __esm({ + "modules/ui/curtain.js"() { + "use strict"; + init_src10(); + init_src5(); + init_localizer(); + init_toggle(); } - flash.duration = function(_2) { - if (!arguments.length) return _duration; - _duration = _2; - return flash; + }); + + // modules/ui/intro/welcome.js + var welcome_exports = {}; + __export(welcome_exports, { + uiIntroWelcome: () => uiIntroWelcome + }); + function uiIntroWelcome(context, reveal) { + var dispatch14 = dispatch_default("done"); + var chapter = { + title: "intro.welcome.title" }; - flash.label = function(_2) { - if (!arguments.length) return _label; - if (typeof _2 !== "function") { - _label = (selection2) => selection2.text(_2); - } else { - _label = (selection2) => selection2.text("").call(_2); - } - return flash; + function welcome() { + context.map().centerZoom([-85.63591, 41.94285], 19); + reveal( + ".intro-nav-wrap .chapter-welcome", + helpHtml("intro.welcome.welcome"), + { buttonText: _t.html("intro.ok"), buttonCallback: practice } + ); + } + function practice() { + reveal( + ".intro-nav-wrap .chapter-welcome", + helpHtml("intro.welcome.practice"), + { buttonText: _t.html("intro.ok"), buttonCallback: words } + ); + } + function words() { + reveal( + ".intro-nav-wrap .chapter-welcome", + helpHtml("intro.welcome.words"), + { buttonText: _t.html("intro.ok"), buttonCallback: chapters } + ); + } + function chapters() { + dispatch14.call("done"); + reveal( + ".intro-nav-wrap .chapter-navigation", + helpHtml("intro.welcome.chapters", { next: _t("intro.navigation.title") }) + ); + } + chapter.enter = function() { + welcome(); }; - flash.iconName = function(_2) { - if (!arguments.length) return _iconName; - _iconName = _2; - return flash; + chapter.exit = function() { + context.container().select(".curtain-tooltip.intro-mouse").selectAll(".counter").remove(); }; - flash.iconClass = function(_2) { - if (!arguments.length) return _iconClass; - _iconClass = _2; - return flash; + chapter.restart = function() { + chapter.exit(); + chapter.enter(); }; - return flash; + return utilRebind(chapter, dispatch14, "on"); } + var init_welcome = __esm({ + "modules/ui/intro/welcome.js"() { + "use strict"; + init_src4(); + init_helper(); + init_localizer(); + init_rebind(); + } + }); - // modules/ui/full_screen.js - function uiFullScreen(context) { - var element = context.container().node(); - function getFullScreenFn() { - if (element.requestFullscreen) { - return element.requestFullscreen; - } else if (element.msRequestFullscreen) { - return element.msRequestFullscreen; - } else if (element.mozRequestFullScreen) { - return element.mozRequestFullScreen; - } else if (element.webkitRequestFullscreen) { - return element.webkitRequestFullscreen; - } + // modules/ui/intro/navigation.js + var navigation_exports = {}; + __export(navigation_exports, { + uiIntroNavigation: () => uiIntroNavigation + }); + function uiIntroNavigation(context, reveal) { + var dispatch14 = dispatch_default("done"); + var timeouts = []; + var hallId = "n2061"; + var townHall = [-85.63591, 41.94285]; + var springStreetId = "w397"; + var springStreetEndId = "n1834"; + var springStreet = [-85.63582, 41.94255]; + var onewayField = _mainPresetIndex.field("oneway"); + var maxspeedField = _mainPresetIndex.field("maxspeed"); + var chapter = { + title: "intro.navigation.title" + }; + function timeout2(f2, t2) { + timeouts.push(window.setTimeout(f2, t2)); } - function getExitFullScreenFn() { - if (document.exitFullscreen) { - return document.exitFullscreen; - } else if (document.msExitFullscreen) { - return document.msExitFullscreen; - } else if (document.mozCancelFullScreen) { - return document.mozCancelFullScreen; - } else if (document.webkitExitFullscreen) { - return document.webkitExitFullscreen; - } + function eventCancel(d3_event) { + d3_event.stopPropagation(); + d3_event.preventDefault(); } - function isFullScreen() { - return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement; + function isTownHallSelected() { + var ids = context.selectedIDs(); + return ids.length === 1 && ids[0] === hallId; } - function isSupported() { - return !!getFullScreenFn(); + function dragMap() { + context.enter(modeBrowse(context)); + context.history().reset("initial"); + var msec = transitionTime(townHall, context.map().center()); + if (msec) { + reveal(null, null, { duration: 0 }); + } + context.map().centerZoomEase(townHall, 19, msec); + timeout2(function() { + var centerStart = context.map().center(); + var textId = context.lastPointerType() === "mouse" ? "drag" : "drag_touch"; + var dragString = helpHtml("intro.navigation.map_info") + "{br}" + helpHtml("intro.navigation." + textId); + reveal(".main-map .surface", dragString); + context.map().on("drawn.intro", function() { + reveal(".main-map .surface", dragString, { duration: 0 }); + }); + context.map().on("move.intro", function() { + var centerNow = context.map().center(); + if (centerStart[0] !== centerNow[0] || centerStart[1] !== centerNow[1]) { + context.map().on("move.intro", null); + timeout2(function() { + continueTo(zoomMap); + }, 3e3); + } + }); + }, msec + 100); + function continueTo(nextStep) { + context.map().on("move.intro drawn.intro", null); + nextStep(); + } } - function fullScreen(d3_event) { - d3_event.preventDefault(); - if (!isFullScreen()) { - getFullScreenFn().apply(element); - } else { - getExitFullScreenFn().apply(document); + function zoomMap() { + var zoomStart = context.map().zoom(); + var textId = context.lastPointerType() === "mouse" ? "zoom" : "zoom_touch"; + var zoomString = helpHtml("intro.navigation." + textId); + reveal(".main-map .surface", zoomString); + context.map().on("drawn.intro", function() { + reveal(".main-map .surface", zoomString, { duration: 0 }); + }); + context.map().on("move.intro", function() { + if (context.map().zoom() !== zoomStart) { + context.map().on("move.intro", null); + timeout2(function() { + continueTo(features); + }, 3e3); + } + }); + function continueTo(nextStep) { + context.map().on("move.intro drawn.intro", null); + nextStep(); } } - return function() { - if (!isSupported()) return; - var detected = utilDetect(); - var keys2 = detected.os === "mac" ? [uiCmd("\u2303\u2318F"), "f11"] : ["f11"]; - context.keybinding().on(keys2, fullScreen); - }; - } - - // modules/ui/geolocate.js - function uiGeolocate(context) { - var _geolocationOptions = { - // prioritize speed and power usage over precision - enableHighAccuracy: false, - // don't hang indefinitely getting the location - timeout: 6e3 - // 6sec - }; - var _locating = uiLoading(context).message(_t.html("geolocate.locating")).blocking(true); - var _layer = context.layers().layer("geolocate"); - var _position; - var _extent; - var _timeoutID; - var _button = select_default2(null); - function click() { - if (context.inIntro()) return; - if (!_layer.enabled() && !_locating.isShown()) { - _timeoutID = setTimeout( - error, - 1e4 - /* 10sec */ + function features() { + var onClick = function() { + continueTo(pointsLinesAreas); + }; + reveal( + ".main-map .surface", + helpHtml("intro.navigation.features"), + { buttonText: _t.html("intro.ok"), buttonCallback: onClick } + ); + context.map().on("drawn.intro", function() { + reveal( + ".main-map .surface", + helpHtml("intro.navigation.features"), + { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick } ); - context.container().call(_locating); - navigator.geolocation.getCurrentPosition(success, error, _geolocationOptions); - } else { - _locating.close(); - _layer.enabled(null, false); - updateButtonState(); + }); + function continueTo(nextStep) { + context.map().on("drawn.intro", null); + nextStep(); } } - function zoomTo() { - context.enter(modeBrowse(context)); - var map2 = context.map(); - _layer.enabled(_position, true); - updateButtonState(); - map2.centerZoomEase(_extent.center(), Math.min(20, map2.extentZoom(_extent))); - } - function success(geolocation) { - _position = geolocation; - var coords = _position.coords; - _extent = geoExtent([coords.longitude, coords.latitude]).padByMeters(coords.accuracy); - zoomTo(); - finish(); + function pointsLinesAreas() { + var onClick = function() { + continueTo(nodesWays); + }; + reveal( + ".main-map .surface", + helpHtml("intro.navigation.points_lines_areas"), + { buttonText: _t.html("intro.ok"), buttonCallback: onClick } + ); + context.map().on("drawn.intro", function() { + reveal( + ".main-map .surface", + helpHtml("intro.navigation.points_lines_areas"), + { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick } + ); + }); + function continueTo(nextStep) { + context.map().on("drawn.intro", null); + nextStep(); + } } - function error() { - if (_position) { - zoomTo(); - } else { - context.ui().flash.label(_t.append("geolocate.location_unavailable")).iconName("#iD-icon-geolocate")(); + function nodesWays() { + var onClick = function() { + continueTo(clickTownHall); + }; + reveal( + ".main-map .surface", + helpHtml("intro.navigation.nodes_ways"), + { buttonText: _t.html("intro.ok"), buttonCallback: onClick } + ); + context.map().on("drawn.intro", function() { + reveal( + ".main-map .surface", + helpHtml("intro.navigation.nodes_ways"), + { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick } + ); + }); + function continueTo(nextStep) { + context.map().on("drawn.intro", null); + nextStep(); } - finish(); } - function finish() { - _locating.close(); - if (_timeoutID) { - clearTimeout(_timeoutID); + function clickTownHall() { + context.enter(modeBrowse(context)); + context.history().reset("initial"); + var entity = context.hasEntity(hallId); + if (!entity) return; + reveal(null, null, { duration: 0 }); + context.map().centerZoomEase(entity.loc, 19, 500); + timeout2(function() { + var entity2 = context.hasEntity(hallId); + if (!entity2) return; + var box = pointBox(entity2.loc, context); + var textId = context.lastPointerType() === "mouse" ? "click_townhall" : "tap_townhall"; + reveal(box, helpHtml("intro.navigation." + textId)); + context.map().on("move.intro drawn.intro", function() { + var entity3 = context.hasEntity(hallId); + if (!entity3) return; + var box2 = pointBox(entity3.loc, context); + reveal(box2, helpHtml("intro.navigation." + textId), { duration: 0 }); + }); + context.on("enter.intro", function() { + if (isTownHallSelected()) continueTo(selectedTownHall); + }); + }, 550); + context.history().on("change.intro", function() { + if (!context.hasEntity(hallId)) { + continueTo(clickTownHall); + } + }); + function continueTo(nextStep) { + context.on("enter.intro", null); + context.map().on("move.intro drawn.intro", null); + context.history().on("change.intro", null); + nextStep(); } - _timeoutID = void 0; } - function updateButtonState() { - _button.classed("active", _layer.enabled()); - _button.attr("aria-pressed", _layer.enabled()); + function selectedTownHall() { + if (!isTownHallSelected()) return clickTownHall(); + var entity = context.hasEntity(hallId); + if (!entity) return clickTownHall(); + var box = pointBox(entity.loc, context); + var onClick = function() { + continueTo(editorTownHall); + }; + reveal( + box, + helpHtml("intro.navigation.selected_townhall"), + { buttonText: _t.html("intro.ok"), buttonCallback: onClick } + ); + context.map().on("move.intro drawn.intro", function() { + var entity2 = context.hasEntity(hallId); + if (!entity2) return; + var box2 = pointBox(entity2.loc, context); + reveal( + box2, + helpHtml("intro.navigation.selected_townhall"), + { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick } + ); + }); + context.history().on("change.intro", function() { + if (!context.hasEntity(hallId)) { + continueTo(clickTownHall); + } + }); + function continueTo(nextStep) { + context.map().on("move.intro drawn.intro", null); + context.history().on("change.intro", null); + nextStep(); + } } - return function(selection2) { - if (!navigator.geolocation || !navigator.geolocation.getCurrentPosition) return; - _button = selection2.append("button").on("click", click).attr("aria-pressed", false).call(svgIcon("#iD-icon-geolocate", "light")).call( - uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(() => _t.append("geolocate.title")) + function editorTownHall() { + if (!isTownHallSelected()) return clickTownHall(); + context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); + var onClick = function() { + continueTo(presetTownHall); + }; + reveal( + ".entity-editor-pane", + helpHtml("intro.navigation.editor_townhall"), + { buttonText: _t.html("intro.ok"), buttonCallback: onClick } ); - }; - } - - // modules/ui/panels/background.js - function uiPanelBackground(context) { - var background = context.background(); - var _currSourceName = null; - var _metadata = {}; - var _metadataKeys = [ - "zoom", - "vintage", - "source", - "description", - "resolution", - "accuracy" - ]; - var debouncedRedraw = debounce_default(redraw, 250); - function redraw(selection2) { - var source = background.baseLayerSource(); - if (!source) return; - var isDG = source.id.match(/^DigitalGlobe/i) !== null; - var sourceLabel = source.label(); - if (_currSourceName !== sourceLabel) { - _currSourceName = sourceLabel; - _metadata = {}; + context.on("exit.intro", function() { + continueTo(clickTownHall); + }); + context.history().on("change.intro", function() { + if (!context.hasEntity(hallId)) { + continueTo(clickTownHall); + } + }); + function continueTo(nextStep) { + context.on("exit.intro", null); + context.history().on("change.intro", null); + context.container().select(".inspector-wrap").on("wheel.intro", null); + nextStep(); } - selection2.text(""); - var list2 = selection2.append("ul").attr("class", "background-info"); - list2.append("li").call(_currSourceName); - _metadataKeys.forEach(function(k2) { - if (isDG && k2 === "vintage") return; - 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]); + } + function presetTownHall() { + if (!isTownHallSelected()) return clickTownHall(); + context.container().select(".inspector-wrap .panewrap").style("right", "0%"); + context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); + var entity = context.entity(context.selectedIDs()[0]); + var preset = _mainPresetIndex.match(entity, context.graph()); + var onClick = function() { + continueTo(fieldsTownHall); + }; + reveal( + ".entity-editor-pane .section-feature-type", + helpHtml("intro.navigation.preset_townhall", { preset: preset.name() }), + { buttonText: _t.html("intro.ok"), buttonCallback: onClick } + ); + context.on("exit.intro", function() { + continueTo(clickTownHall); }); - debouncedGetMetadata(selection2); - var toggleTiles = context.getDebug("tile") ? "hide_tiles" : "show_tiles"; - selection2.append("a").call(_t.append("info_panels.background." + toggleTiles)).attr("href", "#").attr("class", "button button-toggle-tiles").on("click", function(d3_event) { - d3_event.preventDefault(); - context.setDebug("tile", !context.getDebug("tile")); - selection2.call(redraw); + context.history().on("change.intro", function() { + if (!context.hasEntity(hallId)) { + continueTo(clickTownHall); + } }); - if (isDG) { - var key = source.id + "-vintage"; - var sourceVintage = context.background().findSource(key); - var showsVintage = context.background().showsLayer(sourceVintage); - var toggleVintage = showsVintage ? "hide_vintage" : "show_vintage"; - selection2.append("a").call(_t.append("info_panels.background." + toggleVintage)).attr("href", "#").attr("class", "button button-toggle-vintage").on("click", function(d3_event) { - d3_event.preventDefault(); - context.background().toggleOverlayLayer(sourceVintage); - selection2.call(redraw); - }); + function continueTo(nextStep) { + context.on("exit.intro", null); + context.history().on("change.intro", null); + context.container().select(".inspector-wrap").on("wheel.intro", null); + nextStep(); } - ["DigitalGlobe-Premium", "DigitalGlobe-Standard"].forEach(function(layerId) { - if (source.id !== layerId) { - var key2 = layerId + "-vintage"; - var sourceVintage2 = context.background().findSource(key2); - if (context.background().showsLayer(sourceVintage2)) { - context.background().toggleOverlayLayer(sourceVintage2); - } + } + function fieldsTownHall() { + if (!isTownHallSelected()) return clickTownHall(); + context.container().select(".inspector-wrap .panewrap").style("right", "0%"); + context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); + var onClick = function() { + continueTo(closeTownHall); + }; + reveal( + ".entity-editor-pane .section-preset-fields", + helpHtml("intro.navigation.fields_townhall"), + { buttonText: _t.html("intro.ok"), buttonCallback: onClick } + ); + context.on("exit.intro", function() { + continueTo(clickTownHall); + }); + context.history().on("change.intro", function() { + if (!context.hasEntity(hallId)) { + continueTo(clickTownHall); } }); + function continueTo(nextStep) { + context.on("exit.intro", null); + context.history().on("change.intro", null); + context.container().select(".inspector-wrap").on("wheel.intro", null); + nextStep(); + } } - var debouncedGetMetadata = debounce_default(getMetadata, 250); - function getMetadata(selection2) { - var tile = context.container().select(".layer-background img.tile-center"); - if (tile.empty()) return; - var sourceName = _currSourceName; - var d2 = tile.datum(); - var zoom = d2 && d2.length >= 3 && d2[2] || Math.floor(context.map().zoom()); - var center = context.map().center(); - _metadata.zoom = String(zoom); - selection2.selectAll(".background-info-list-zoom").classed("hide", false).selectAll(".background-info-span-zoom").text(_metadata.zoom); - if (!d2 || !d2.length >= 3) return; - background.baseLayerSource().getMetadata(center, d2, function(err, result) { - if (err || _currSourceName !== sourceName) return; - var vintage = result.vintage; - _metadata.vintage = vintage && vintage.range || _t("info_panels.background.unknown"); - selection2.selectAll(".background-info-list-vintage").classed("hide", false).selectAll(".background-info-span-vintage").text(_metadata.vintage); - _metadataKeys.forEach(function(k2) { - if (k2 === "zoom" || k2 === "vintage") return; - var val = result[k2]; - _metadata[k2] = val; - selection2.selectAll(".background-info-list-" + k2).classed("hide", !val).selectAll(".background-info-span-" + k2).text(val); - }); + function closeTownHall() { + if (!isTownHallSelected()) return clickTownHall(); + var selector = ".entity-editor-pane button.close svg use"; + var href = select_default2(selector).attr("href") || "#iD-icon-close"; + reveal( + ".entity-editor-pane", + helpHtml("intro.navigation.close_townhall", { button: { html: icon(href, "inline") } }) + ); + context.on("exit.intro", function() { + continueTo(searchStreet); }); - } - var panel = function(selection2) { - selection2.call(redraw); - context.map().on("drawn.info-background", function() { - selection2.call(debouncedRedraw); - }).on("move.info-background", function() { - selection2.call(debouncedGetMetadata); + context.history().on("change.intro", function() { + var selector2 = ".entity-editor-pane button.close svg use"; + var href2 = select_default2(selector2).attr("href") || "#iD-icon-close"; + reveal( + ".entity-editor-pane", + helpHtml("intro.navigation.close_townhall", { button: { html: icon(href2, "inline") } }), + { duration: 0 } + ); }); - }; - panel.off = function() { - context.map().on("drawn.info-background", null).on("move.info-background", null); - }; - panel.id = "background"; - panel.label = _t.append("info_panels.background.title"); - panel.key = _t("info_panels.background.key"); - return panel; - } - - // modules/ui/panels/history.js - function uiPanelHistory(context) { - var osm; - function displayTimestamp(timestamp) { - if (!timestamp) return _t("info_panels.history.unknown"); - var options2 = { - day: "numeric", - month: "short", - year: "numeric", - hour: "numeric", - minute: "numeric", - second: "numeric" - }; - var d2 = new Date(timestamp); - if (isNaN(d2.getTime())) return _t("info_panels.history.unknown"); - return d2.toLocaleString(_mainLocalizer.localeCode(), options2); - } - function displayUser(selection2, userName) { - if (!userName) { - selection2.append("span").call(_t.append("info_panels.history.unknown")); - return; - } - selection2.append("span").attr("class", "user-name").text(userName); - var links = selection2.append("div").attr("class", "links"); - if (osm) { - links.append("a").attr("class", "user-osm-link").attr("href", osm.userURL(userName)).attr("target", "_blank").call(_t.append("info_panels.history.profile_link")); + function continueTo(nextStep) { + context.on("exit.intro", null); + context.history().on("change.intro", null); + nextStep(); } - links.append("a").attr("class", "user-hdyc-link").attr("href", "https://hdyc.neis-one.org/?" + userName).attr("target", "_blank").attr("tabindex", -1).text("HDYC"); } - function displayChangeset(selection2, changeset) { - if (!changeset) { - selection2.append("span").call(_t.append("info_panels.history.unknown")); - return; - } - selection2.append("span").attr("class", "changeset-id").text(changeset); - var links = selection2.append("div").attr("class", "links"); - if (osm) { - links.append("a").attr("class", "changeset-osm-link").attr("href", osm.changesetURL(changeset)).attr("target", "_blank").call(_t.append("info_panels.history.changeset_link")); + function searchStreet() { + context.enter(modeBrowse(context)); + context.history().reset("initial"); + var msec = transitionTime(springStreet, context.map().center()); + if (msec) { + reveal(null, null, { duration: 0 }); } - links.append("a").attr("class", "changeset-osmcha-link").attr("href", "https://osmcha.org/changesets/" + changeset).attr("target", "_blank").text("OSMCha"); - links.append("a").attr("class", "changeset-achavi-link").attr("href", "https://overpass-api.de/achavi/?changeset=" + changeset).attr("target", "_blank").text("Achavi"); + context.map().centerZoomEase(springStreet, 19, msec); + timeout2(function() { + reveal( + ".search-header input", + helpHtml("intro.navigation.search_street", { name: _t("intro.graph.name.spring-street") }) + ); + context.container().select(".search-header input").on("keyup.intro", checkSearchResult); + }, msec + 100); } - function redraw(selection2) { - var selectedNoteID = context.selectedNoteID(); - osm = context.connection(); - var selected, note, entity; - if (selectedNoteID && osm) { - selected = [_t.html("note.note") + " " + selectedNoteID]; - note = osm.getNote(selectedNoteID); - } else { - selected = context.selectedIDs().filter(function(e3) { - return context.hasEntity(e3); + function checkSearchResult() { + var first = context.container().select(".feature-list-item:nth-child(0n+2)"); + var firstName = first.select(".entity-name"); + var name = _t("intro.graph.name.spring-street"); + if (!firstName.empty() && firstName.html() === name) { + reveal( + first.node(), + helpHtml("intro.navigation.choose_street", { name }), + { duration: 300 } + ); + context.on("exit.intro", function() { + continueTo(selectedStreet); }); - if (selected.length) { - entity = context.entity(selected[0]); - } - } - var singular = selected.length === 1 ? selected[0] : null; - selection2.html(""); - if (singular) { - selection2.append("h4").attr("class", "history-heading").html(singular); - } else { - selection2.append("h4").attr("class", "history-heading").call(_t.append("info_panels.selected", { n: selected.length })); - } - if (!singular) return; - if (entity) { - selection2.call(redrawEntity, entity); - } else if (note) { - selection2.call(redrawNote, note); - } - } - function redrawNote(selection2, note) { - if (!note || note.isNew()) { - selection2.append("div").call(_t.append("info_panels.history.note_no_history")); - return; - } - 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) { - 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); + context.container().select(".search-header input").on("keydown.intro", eventCancel, true).on("keyup.intro", null); } - 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")); + function continueTo(nextStep) { + context.on("exit.intro", null); + context.container().select(".search-header input").on("keydown.intro", null).on("keyup.intro", null); + nextStep(); } } - function redrawEntity(selection2, entity) { - if (!entity || entity.isNew()) { - selection2.append("div").call(_t.append("info_panels.history.no_history")); - return; + function selectedStreet() { + if (!context.hasEntity(springStreetEndId) || !context.hasEntity(springStreetId)) { + return searchStreet(); } - var links = selection2.append("div").attr("class", "links"); - if (osm) { - 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")); + var onClick = function() { + continueTo(editorStreet); + }; + var entity = context.entity(springStreetEndId); + var box = pointBox(entity.loc, context); + box.height = 500; + reveal( + box, + helpHtml("intro.navigation.selected_street", { name: _t("intro.graph.name.spring-street") }), + { duration: 600, buttonText: _t.html("intro.ok"), buttonCallback: onClick } + ); + timeout2(function() { + context.map().on("move.intro drawn.intro", function() { + var entity2 = context.hasEntity(springStreetEndId); + if (!entity2) return; + var box2 = pointBox(entity2.loc, context); + box2.height = 500; + reveal( + box2, + helpHtml("intro.navigation.selected_street", { name: _t("intro.graph.name.spring-street") }), + { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick } + ); + }); + }, 600); + context.on("enter.intro", function(mode) { + if (!context.hasEntity(springStreetId)) { + return continueTo(searchStreet); + } + var ids = context.selectedIDs(); + if (mode.id !== "select" || !ids.length || ids[0] !== springStreetId) { + context.enter(modeSelect(context, [springStreetId])); + } + }); + context.history().on("change.intro", function() { + if (!context.hasEntity(springStreetEndId) || !context.hasEntity(springStreetId)) { + timeout2(function() { + continueTo(searchStreet); + }, 300); + } + }); + function continueTo(nextStep) { + context.map().on("move.intro drawn.intro", null); + context.on("enter.intro", null); + context.history().on("change.intro", null); + nextStep(); } - 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 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); - context.map().on("drawn.info-history", function() { - selection2.call(redraw); + function editorStreet() { + var selector = ".entity-editor-pane button.close svg use"; + var href = select_default2(selector).attr("href") || "#iD-icon-close"; + reveal(".entity-editor-pane", helpHtml("intro.navigation.street_different_fields") + "{br}" + helpHtml("intro.navigation.editor_street", { + button: { html: icon(href, "inline") }, + field1: onewayField.title(), + field2: maxspeedField.title() + })); + context.on("exit.intro", function() { + continueTo(play); }); - context.on("enter.info-history", function() { - selection2.call(redraw); + context.history().on("change.intro", function() { + var selector2 = ".entity-editor-pane button.close svg use"; + var href2 = select_default2(selector2).attr("href") || "#iD-icon-close"; + reveal( + ".entity-editor-pane", + helpHtml("intro.navigation.street_different_fields") + "{br}" + helpHtml("intro.navigation.editor_street", { + button: { html: icon(href2, "inline") }, + field1: onewayField.title(), + field2: maxspeedField.title() + }), + { duration: 0 } + ); }); - }; - panel.off = function() { - context.map().on("drawn.info-history", null); - context.on("enter.info-history", null); - }; - panel.id = "history"; - panel.label = _t.append("info_panels.history.title"); - panel.key = _t("info_panels.history.key"); - return panel; - } - - // modules/ui/panels/location.js - function uiPanelLocation(context) { - var currLocation = ""; - function redraw(selection2) { - selection2.html(""); - var list2 = selection2.append("ul"); - var coord2 = context.map().mouseCoordinates(); - if (coord2.some(isNaN)) { - coord2 = context.map().center(); + function continueTo(nextStep) { + context.on("exit.intro", null); + context.history().on("change.intro", null); + nextStep(); } - list2.append("li").text(dmsCoordinatePair(coord2)).append("li").text(decimalCoordinatePair(coord2)); - selection2.append("div").attr("class", "location-info").text(currLocation || " "); - debouncedGetLocation(selection2, coord2); } - var debouncedGetLocation = debounce_default(getLocation, 250); - function getLocation(selection2, coord2) { - if (!services.geocoder) { - currLocation = _t("info_panels.location.unknown_location"); - selection2.selectAll(".location-info").text(currLocation); - } else { - services.geocoder.reverse(coord2, function(err, result) { - currLocation = result ? result.display_name : _t("info_panels.location.unknown_location"); - selection2.selectAll(".location-info").text(currLocation); - }); - } + function play() { + dispatch14.call("done"); + reveal( + ".ideditor", + helpHtml("intro.navigation.play", { next: _t("intro.points.title") }), + { + tooltipBox: ".intro-nav-wrap .chapter-point", + buttonText: _t.html("intro.ok"), + buttonCallback: function() { + reveal(".ideditor"); + } + } + ); } - var panel = function(selection2) { - selection2.call(redraw); - context.surface().on(("PointerEvent" in window ? "pointer" : "mouse") + "move.info-location", function() { - selection2.call(redraw); - }); + chapter.enter = function() { + dragMap(); }; - panel.off = function() { - context.surface().on(".info-location", null); + chapter.exit = function() { + timeouts.forEach(window.clearTimeout); + context.on("enter.intro exit.intro", null); + context.map().on("move.intro drawn.intro", null); + context.history().on("change.intro", null); + context.container().select(".inspector-wrap").on("wheel.intro", null); + context.container().select(".search-header input").on("keydown.intro keyup.intro", null); }; - panel.id = "location"; - panel.label = _t.append("info_panels.location.title"); - panel.key = _t("info_panels.location.key"); - return panel; + chapter.restart = function() { + chapter.exit(); + chapter.enter(); + }; + return utilRebind(chapter, dispatch14, "on"); } - - // modules/ui/panels/measurement.js - function uiPanelMeasurement(context) { - function radiansToMeters(r2) { - return r2 * 63710071809e-4; + var init_navigation = __esm({ + "modules/ui/intro/navigation.js"() { + "use strict"; + init_src4(); + init_src5(); + init_presets(); + init_localizer(); + init_browse(); + init_select5(); + init_rebind(); + init_helper(); } - function steradiansToSqmeters(r2) { - return r2 / (4 * Math.PI) * 510065621724e3; + }); + + // modules/ui/intro/point.js + var point_exports = {}; + __export(point_exports, { + uiIntroPoint: () => uiIntroPoint + }); + function uiIntroPoint(context, reveal) { + var dispatch14 = dispatch_default("done"); + var timeouts = []; + 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(f2, t2) { + timeouts.push(window.setTimeout(f2, t2)); } - function toLineString(feature3) { - if (feature3.type === "LineString") return feature3; - var result = { type: "LineString", coordinates: [] }; - if (feature3.type === "Polygon") { - result.coordinates = feature3.coordinates[0]; - } else if (feature3.type === "MultiPolygon") { - result.coordinates = feature3.coordinates[0][0]; - } - return result; + function eventCancel(d3_event) { + d3_event.stopPropagation(); + d3_event.preventDefault(); } - var _isImperial = !_mainLocalizer.usesMetric(); - function redraw(selection2) { - var graph = context.graph(); - var selectedNoteID = context.selectedNoteID(); - var osm = services.osm; - var localeCode = _mainLocalizer.localeCode(); - var heading2; - var center, location, centroid; - var closed, geometry; - var totalNodeCount, length2 = 0, area = 0, distance; - if (selectedNoteID && osm) { - var note = osm.getNote(selectedNoteID); - heading2 = _t.html("note.note") + " " + selectedNoteID; - location = note.loc; - geometry = "note"; - } else { - var selectedIDs = context.selectedIDs().filter(function(id2) { - return context.hasEntity(id2); - }); - var selected = selectedIDs.map(function(id2) { - return context.entity(id2); - }); - 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) { - var entity = selected[i3]; - extent._extend(entity.extent(graph)); - geometry = entity.geometry(graph); - if (geometry === "line" || geometry === "area") { - closed = entity.type === "relation" || entity.isClosed() && !entity.isDegenerate(); - var feature3 = entity.asGeoJSON(graph); - 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])) { - centroid = entity.extent(graph).center(); - } - if (closed) { - area += steradiansToSqmeters(entity.area(graph)); - } - } - } - if (selected.length > 1) { - geometry = null; - closed = null; - centroid = null; - } - if (selected.length === 2 && selected[0].type === "node" && selected[1].type === "node") { - distance = geoSphericalDistance(selected[0].loc, selected[1].loc); - } - if (selected.length === 1 && selected[0].type === "node") { - location = selected[0].loc; - } else { - totalNodeCount = utilGetAllNodes(selectedIDs, context.graph()).length; - } - if (!location && !centroid) { - center = extent.center(); - } - } - } - selection2.html(""); - if (heading2) { - selection2.append("h4").attr("class", "measurement-heading").html(heading2); + function addPoint() { + context.enter(modeBrowse(context)); + context.history().reset("initial"); + var msec = transitionTime(intersection2, context.map().center()); + if (msec) { + reveal(null, null, { duration: 0 }); } - var list2 = selection2.append("ul"); - var coordItem; - if (geometry) { - 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) + context.map().centerZoomEase(intersection2, 19, msec); + timeout2(function() { + var tooltip = reveal( + "button.add-point", + helpHtml("intro.points.points_info") + "{br}" + helpHtml("intro.points.add_point") ); + _pointID = null; + tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-points"); + context.on("enter.intro", function(mode) { + if (mode.id !== "add-point") return; + continueTo(placePoint); + }); + }, msec + 100); + function continueTo(nextStep) { + context.on("enter.intro", null); + nextStep(); } - if (totalNodeCount) { - list2.append("li").call(_t.append("info_panels.measurement.node_count", { suffix: ":" })).append("span").text(totalNodeCount.toLocaleString(localeCode)); - } - if (area) { - list2.append("li").call(_t.append("info_panels.measurement.area", { suffix: ":" })).append("span").text(displayArea(area, _isImperial)); + } + function placePoint() { + if (context.mode().id !== "add-point") { + return chapter.restart(); } - if (length2) { - list2.append("li").call(_t.append("info_panels.measurement." + (closed ? "perimeter" : "length"), { suffix: ":" })).append("span").text(displayLength(length2, _isImperial)); + var pointBox2 = pad2(building, 150, context); + var textId = context.lastPointerType() === "mouse" ? "place_point" : "place_point_touch"; + reveal(pointBox2, helpHtml("intro.points." + textId)); + context.map().on("move.intro drawn.intro", function() { + pointBox2 = pad2(building, 150, context); + reveal(pointBox2, helpHtml("intro.points." + textId), { duration: 0 }); + }); + context.on("enter.intro", function(mode) { + if (mode.id !== "select") return chapter.restart(); + _pointID = context.mode().selectedIDs()[0]; + 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); + context.on("enter.intro", null); + nextStep(); } - if (typeof distance === "number") { - list2.append("li").call(_t.append("info_panels.measurement.distance", { suffix: ":" })).append("span").text(displayLength(distance, _isImperial)); + } + function searchPreset() { + if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) { + return addPoint(); } - if (location) { - coordItem = list2.append("li").call(_t.append("info_panels.measurement.location", { suffix: ":" })); - coordItem.append("span").text(dmsCoordinatePair(location)); - coordItem.append("span").text(decimalCoordinatePair(location)); + context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); + context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch); + reveal( + ".preset-search-input", + helpHtml("intro.points.search_cafe", { preset: cafePreset.name() }) + ); + context.on("enter.intro", function(mode) { + if (!_pointID || !context.hasEntity(_pointID)) { + return continueTo(addPoint); + } + var ids = context.selectedIDs(); + if (mode.id !== "select" || !ids.length || ids[0] !== _pointID) { + context.enter(modeSelect(context, [_pointID])); + context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); + context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch); + reveal( + ".preset-search-input", + helpHtml("intro.points.search_cafe", { preset: cafePreset.name() }) + ); + context.history().on("change.intro", null); + } + }); + function checkPresetSearch() { + var first = context.container().select(".preset-list-item:first-child"); + if (first.classed("preset-amenity-cafe")) { + context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null); + reveal( + first.select(".preset-list-button").node(), + helpHtml("intro.points.choose_cafe", { preset: cafePreset.name() }), + { duration: 300 } + ); + context.history().on("change.intro", function() { + continueTo(aboutFeatureEditor); + }); + } } - if (centroid) { - coordItem = list2.append("li").call(_t.append("info_panels.measurement.centroid", { suffix: ":" })); - coordItem.append("span").text(dmsCoordinatePair(centroid)); - coordItem.append("span").text(decimalCoordinatePair(centroid)); + function continueTo(nextStep) { + context.on("enter.intro", null); + context.history().on("change.intro", null); + context.container().select(".inspector-wrap").on("wheel.intro", null); + context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null); + nextStep(); } - if (center) { - coordItem = list2.append("li").call(_t.append("info_panels.measurement.center", { suffix: ":" })); - coordItem.append("span").text(dmsCoordinatePair(center)); - coordItem.append("span").text(decimalCoordinatePair(center)); + } + function aboutFeatureEditor() { + if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) { + return addPoint(); } - 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(); - _isImperial = !_isImperial; - selection2.call(redraw); + timeout2(function() { + reveal(".entity-editor-pane", helpHtml("intro.points.feature_editor"), { + tooltipClass: "intro-points-describe", + buttonText: _t.html("intro.ok"), + buttonCallback: function() { + continueTo(addName); + } }); - } - } - var panel = function(selection2) { - selection2.call(redraw); - context.map().on("drawn.info-measurement", function() { - selection2.call(redraw); - }); - context.on("enter.info-measurement", function() { - selection2.call(redraw); + }, 400); + context.on("exit.intro", function() { + continueTo(reselectPoint); }); - }; - panel.off = function() { - context.map().on("drawn.info-measurement", null); - context.on("enter.info-measurement", null); - }; - panel.id = "measurement"; - panel.label = _t.append("info_panels.measurement.title"); - panel.key = _t("info_panels.measurement.key"); - return panel; - } - - // modules/ui/panels/index.js - var uiInfoPanels = { - background: uiPanelBackground, - history: uiPanelHistory, - location: uiPanelLocation, - measurement: uiPanelMeasurement - }; - - // modules/ui/info.js - function uiInfo(context) { - var ids = Object.keys(uiInfoPanels); - var wasActive = ["measurement"]; - var panels = {}; - var active = {}; - ids.forEach(function(k2) { - if (!panels[k2]) { - panels[k2] = uiInfoPanels[k2](context); - active[k2] = false; + function continueTo(nextStep) { + context.on("exit.intro", null); + nextStep(); } - }); - function info(selection2) { - function redraw() { - var activeids = ids.filter(function(k2) { - return active[k2]; - }).sort(); - var containers = infoPanels.selectAll(".panel-container").data(activeids, function(k2) { - return k2; - }); - containers.exit().style("opacity", 1).transition().duration(200).style("opacity", 0).on("end", function(d2) { - select_default2(this).call(panels[d2].off).remove(); - }); - var enter = containers.enter().append("div").attr("class", function(d2) { - return "fillD2 panel-container panel-container-" + d2; - }); - enter.style("opacity", 0).transition().duration(200).style("opacity", 1); - var title = enter.append("div").attr("class", "panel-title fillD2"); - title.append("h3").each(function(d2) { - return panels[d2].label(select_default2(this)); - }); - title.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function(d3_event, d2) { - d3_event.stopImmediatePropagation(); - d3_event.preventDefault(); - info.toggle(d2); - }).call(svgIcon("#iD-icon-close")); - enter.append("div").attr("class", function(d2) { - return "panel-content panel-content-" + d2; - }); - infoPanels.selectAll(".panel-content").each(function(d2) { - select_default2(this).call(panels[d2]); - }); + } + function addName() { + if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) { + return addPoint(); } - info.toggle = function(which) { - var activeids = ids.filter(function(k2) { - return active[k2]; - }); - if (which) { - active[which] = !active[which]; - if (activeids.length === 1 && activeids[0] === which) { - wasActive = [which]; - } - context.container().select("." + which + "-panel-toggle-item").classed("active", active[which]).select("input").property("checked", active[which]); + context.container().select(".inspector-wrap .panewrap").style("right", "0%"); + var addNameString = helpHtml("intro.points.fields_info") + "{br}" + helpHtml("intro.points.add_name") + "{br}" + helpHtml("intro.points.add_reminder"); + timeout2(function() { + var entity = context.entity(_pointID); + if (entity.tags.name) { + var tooltip = reveal(".entity-editor-pane", addNameString, { + tooltipClass: "intro-points-describe", + buttonText: _t.html("intro.ok"), + buttonCallback: function() { + continueTo(addCloseEditor); + } + }); + tooltip.select(".instruction").style("display", "none"); } else { - if (activeids.length) { - wasActive = activeids; - activeids.forEach(function(k2) { - active[k2] = false; - }); - } else { - wasActive.forEach(function(k2) { - active[k2] = true; - }); - } + reveal( + ".entity-editor-pane", + addNameString, + { tooltipClass: "intro-points-describe" } + ); } - redraw(); - }; - var infoPanels = selection2.selectAll(".info-panels").data([0]); - infoPanels = infoPanels.enter().append("div").attr("class", "info-panels").merge(infoPanels); - redraw(); - context.keybinding().on(uiCmd("\u2318" + _t("info_panels.key")), function(d3_event) { - d3_event.stopImmediatePropagation(); - d3_event.preventDefault(); - info.toggle(); + }, 400); + context.history().on("change.intro", function() { + continueTo(addCloseEditor); }); - ids.forEach(function(k2) { - var key = _t("info_panels." + k2 + ".key", { default: null }); - if (!key) return; - context.keybinding().on(uiCmd("\u2318\u21E7" + key), function(d3_event) { - d3_event.stopImmediatePropagation(); - d3_event.preventDefault(); - info.toggle(k2); - }); + context.on("exit.intro", function() { + continueTo(reselectPoint); }); + function continueTo(nextStep) { + context.on("exit.intro", null); + context.history().on("change.intro", null); + nextStep(); + } } - return info; - } - - // modules/ui/toggle.js - function uiToggle(show, callback) { - return function(selection2) { - selection2.style("opacity", show ? 0 : 1).classed("hide", false).transition().style("opacity", show ? 1 : 0).on("end", function() { - select_default2(this).classed("hide", !show).style("opacity", null); - if (callback) callback.apply(this); + function addCloseEditor() { + context.container().select(".inspector-wrap .panewrap").style("right", "0%"); + var selector = ".entity-editor-pane button.close svg use"; + var href = select_default2(selector).attr("href") || "#iD-icon-close"; + context.on("exit.intro", function() { + continueTo(reselectPoint); }); - }; - } - - // modules/ui/curtain.js - function uiCurtain(containerNode) { - var surface = select_default2(null), tooltip = select_default2(null), darkness = select_default2(null); - function curtain(selection2) { - surface = selection2.append("svg").attr("class", "curtain").style("top", 0).style("left", 0); - darkness = surface.append("path").attr("x", 0).attr("y", 0).attr("class", "curtain-darkness"); - select_default2(window).on("resize.curtain", resize); - tooltip = selection2.append("div").attr("class", "tooltip"); - tooltip.append("div").attr("class", "popover-arrow"); - tooltip.append("div").attr("class", "popover-inner"); - resize(); - function resize() { - surface.attr("width", containerNode.clientWidth).attr("height", containerNode.clientHeight); - curtain.cut(darkness.datum()); + reveal( + ".entity-editor-pane", + helpHtml("intro.points.add_close", { button: { html: icon(href, "inline") } }) + ); + function continueTo(nextStep) { + context.on("exit.intro", null); + nextStep(); } } - curtain.reveal = function(box, html3, options2) { - options2 = options2 || {}; - if (typeof box === "string") { - box = select_default2(box).node(); - } - if (box && box.getBoundingClientRect) { - box = copyBox(box.getBoundingClientRect()); - } - if (box) { - var containerRect = containerNode.getBoundingClientRect(); - box.top -= containerRect.top; - box.left -= containerRect.left; + function reselectPoint() { + if (!_pointID) return chapter.restart(); + var entity = context.hasEntity(_pointID); + if (!entity) return chapter.restart(); + var oldPreset = _mainPresetIndex.match(entity, context.graph()); + context.replace(actionChangePreset(_pointID, oldPreset, cafePreset)); + context.enter(modeBrowse(context)); + var msec = transitionTime(entity.loc, context.map().center()); + if (msec) { + reveal(null, null, { duration: 0 }); } - if (box && options2.padding) { - box.top -= options2.padding; - box.left -= options2.padding; - box.bottom += options2.padding; - box.right += options2.padding; - box.height += options2.padding * 2; - box.width += options2.padding * 2; + context.map().centerEase(entity.loc, msec); + timeout2(function() { + var box = pointBox(entity.loc, context); + reveal(box, helpHtml("intro.points.reselect"), { duration: 600 }); + timeout2(function() { + context.map().on("move.intro drawn.intro", function() { + var entity2 = context.hasEntity(_pointID); + if (!entity2) return chapter.restart(); + var box2 = pointBox(entity2.loc, context); + reveal(box2, helpHtml("intro.points.reselect"), { duration: 0 }); + }); + }, 600); + context.on("enter.intro", function(mode) { + if (mode.id !== "select") return; + continueTo(updatePoint); + }); + }, msec + 100); + function continueTo(nextStep) { + context.map().on("move.intro drawn.intro", null); + context.on("enter.intro", null); + nextStep(); } - var tooltipBox; - if (options2.tooltipBox) { - tooltipBox = options2.tooltipBox; - if (typeof tooltipBox === "string") { - tooltipBox = select_default2(tooltipBox).node(); - } - if (tooltipBox && tooltipBox.getBoundingClientRect) { - tooltipBox = copyBox(tooltipBox.getBoundingClientRect()); - } - } else { - tooltipBox = box; + } + function updatePoint() { + if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) { + return continueTo(reselectPoint); } - if (tooltipBox && html3) { - if (html3.indexOf("**") !== -1) { - if (html3.indexOf(")(.+?)(\*\*)/, "$1$2$3"); - } else { - html3 = html3.replace(/^(.+?)(\*\*)/, "$1$2"); - } - html3 = html3.replace(/\*\*(.*?)\*\*/g, '$1'); - } - html3 = html3.replace(/\*(.*?)\*/g, "$1"); - html3 = html3.replace(/\{br\}/g, "

    "); - if (options2.buttonText && options2.buttonCallback) { - html3 += '
    "; - } - var classes = "curtain-tooltip popover tooltip arrowed in " + (options2.tooltipClass || ""); - 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) { - d3_event.preventDefault(); - options2.buttonCallback(); - }); - } - var tip = copyBox(tooltip.node().getBoundingClientRect()), w2 = containerNode.clientWidth, h2 = containerNode.clientHeight, tooltipWidth = 200, tooltipArrow = 5, side, pos; - if (options2.tooltipClass === "intro-mouse") { - tip.height += 80; - } - if (tooltipBox.top + tooltipBox.height > h2) { - tooltipBox.height -= tooltipBox.top + tooltipBox.height - h2; - } - if (tooltipBox.left + tooltipBox.width > w2) { - tooltipBox.width -= tooltipBox.left + tooltipBox.width - w2; - } - const onLeftOrRightEdge = tooltipBox.left + tooltipBox.width / 2 > w2 - 100 || tooltipBox.left + tooltipBox.width / 2 < 100; - if (tooltipBox.top + tooltipBox.height < 100 && !onLeftOrRightEdge) { - side = "bottom"; - pos = [ - tooltipBox.left + tooltipBox.width / 2 - tip.width / 2, - tooltipBox.top + tooltipBox.height - ]; - } else if (tooltipBox.top > h2 - 140 && !onLeftOrRightEdge) { - side = "top"; - pos = [ - tooltipBox.left + tooltipBox.width / 2 - tip.width / 2, - tooltipBox.top - tip.height - ]; - } else { - var tipY = tooltipBox.top + tooltipBox.height / 2 - tip.height / 2; - if (_mainLocalizer.textDirection() === "rtl") { - if (tooltipBox.left - tooltipWidth - tooltipArrow < 70) { - side = "right"; - pos = [tooltipBox.left + tooltipBox.width + tooltipArrow, tipY]; - } else { - side = "left"; - pos = [tooltipBox.left - tooltipWidth - tooltipArrow, tipY]; - } - } else { - if (tooltipBox.left + tooltipBox.width + tooltipArrow + tooltipWidth > w2 - 70) { - side = "left"; - pos = [tooltipBox.left - tooltipWidth - tooltipArrow, tipY]; - } else { - side = "right"; - pos = [tooltipBox.left + tooltipBox.width + tooltipArrow, tipY]; - } - } - } - if (options2.duration !== 0 || !tooltip.classed(side)) { - tooltip.call(uiToggle(true)); - } - tooltip.style("top", pos[1] + "px").style("left", pos[0] + "px").attr("class", classes + " " + side); - var shiftY = 0; - if (side === "left" || side === "right") { - if (pos[1] < 60) { - shiftY = 60 - pos[1]; - } else if (pos[1] + tip.height > h2 - 100) { - shiftY = h2 - pos[1] - tip.height - 100; - } - } - tooltip.selectAll(".popover-inner").style("top", shiftY + "px"); - } else { - tooltip.classed("in", false).call(uiToggle(false)); + context.container().select(".inspector-wrap .panewrap").style("right", "0%"); + context.on("exit.intro", function() { + continueTo(reselectPoint); + }); + context.history().on("change.intro", function() { + continueTo(updateCloseEditor); + }); + timeout2(function() { + reveal( + ".entity-editor-pane", + helpHtml("intro.points.update"), + { tooltipClass: "intro-points-describe" } + ); + }, 400); + function continueTo(nextStep) { + context.on("exit.intro", null); + context.history().on("change.intro", null); + nextStep(); } - curtain.cut(box, options2.duration); - return tooltip; - }; - curtain.cut = function(datum2, duration) { - darkness.datum(datum2).interrupt(); - var selection2; - if (duration === 0) { - selection2 = darkness; - } else { - selection2 = darkness.transition().duration(duration || 600).ease(linear2); + } + function updateCloseEditor() { + if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) { + return continueTo(reselectPoint); } - selection2.attr("d", function(d2) { - var containerWidth = containerNode.clientWidth; - var containerHeight = containerNode.clientHeight; - var string = "M 0,0 L 0," + containerHeight + " L " + containerWidth + "," + containerHeight + "L" + containerWidth + ",0 Z"; - if (!d2) return string; - return string + "M" + d2.left + "," + d2.top + "L" + d2.left + "," + (d2.top + d2.height) + "L" + (d2.left + d2.width) + "," + (d2.top + d2.height) + "L" + (d2.left + d2.width) + "," + d2.top + "Z"; + context.container().select(".inspector-wrap .panewrap").style("right", "0%"); + context.on("exit.intro", function() { + continueTo(rightClickPoint); }); - }; - curtain.remove = function() { - surface.remove(); - tooltip.remove(); - select_default2(window).on("resize.curtain", null); - }; - function copyBox(src) { - return { - top: src.top, - right: src.right, - bottom: src.bottom, - left: src.left, - width: src.width, - height: src.height - }; + timeout2(function() { + reveal( + ".entity-editor-pane", + helpHtml("intro.points.update_close", { button: { html: icon("#iD-icon-close", "inline") } }) + ); + }, 500); + function continueTo(nextStep) { + context.on("exit.intro", null); + nextStep(); + } } - return curtain; - } - - // modules/ui/intro/welcome.js - function uiIntroWelcome(context, reveal) { - var dispatch14 = dispatch_default("done"); - var chapter = { - title: "intro.welcome.title" - }; - function welcome() { - context.map().centerZoom([-85.63591, 41.94285], 19); - reveal( - ".intro-nav-wrap .chapter-welcome", - helpHtml("intro.welcome.welcome"), - { buttonText: _t.html("intro.ok"), buttonCallback: practice } - ); + function rightClickPoint() { + if (!_pointID) return chapter.restart(); + var entity = context.hasEntity(_pointID); + if (!entity) return chapter.restart(); + context.enter(modeBrowse(context)); + var box = pointBox(entity.loc, context); + var textId = context.lastPointerType() === "mouse" ? "rightclick" : "edit_menu_touch"; + reveal(box, helpHtml("intro.points." + textId), { duration: 600 }); + timeout2(function() { + context.map().on("move.intro", function() { + var entity2 = context.hasEntity(_pointID); + if (!entity2) return chapter.restart(); + var box2 = pointBox(entity2.loc, context); + reveal(box2, helpHtml("intro.points." + textId), { duration: 0 }); + }); + }, 600); + context.on("enter.intro", function(mode) { + if (mode.id !== "select") return; + var ids = context.selectedIDs(); + if (ids.length !== 1 || ids[0] !== _pointID) return; + timeout2(function() { + var node = selectMenuItem(context, "delete").node(); + if (!node) return; + continueTo(enterDelete); + }, 50); + }); + function continueTo(nextStep) { + context.on("enter.intro", null); + context.map().on("move.intro", null); + nextStep(); + } } - function practice() { + function enterDelete() { + if (!_pointID) return chapter.restart(); + var entity = context.hasEntity(_pointID); + if (!entity) return chapter.restart(); + var node = selectMenuItem(context, "delete").node(); + if (!node) { + return continueTo(rightClickPoint); + } reveal( - ".intro-nav-wrap .chapter-welcome", - helpHtml("intro.welcome.practice"), - { buttonText: _t.html("intro.ok"), buttonCallback: words } + ".edit-menu", + helpHtml("intro.points.delete"), + { padding: 50 } ); + timeout2(function() { + context.map().on("move.intro", function() { + if (selectMenuItem(context, "delete").empty()) { + return continueTo(rightClickPoint); + } + reveal( + ".edit-menu", + helpHtml("intro.points.delete"), + { duration: 0, padding: 50 } + ); + }); + }, 300); + context.on("exit.intro", function() { + if (!_pointID) return chapter.restart(); + var entity2 = context.hasEntity(_pointID); + if (entity2) return continueTo(rightClickPoint); + }); + context.history().on("change.intro", function(changed) { + if (changed.deleted().length) { + continueTo(undo); + } + }); + function continueTo(nextStep) { + context.map().on("move.intro", null); + context.history().on("change.intro", null); + context.on("exit.intro", null); + nextStep(); + } } - function words() { + function undo() { + context.history().on("change.intro", function() { + continueTo(play); + }); reveal( - ".intro-nav-wrap .chapter-welcome", - helpHtml("intro.welcome.words"), - { buttonText: _t.html("intro.ok"), buttonCallback: chapters } + ".top-toolbar button.undo-button", + helpHtml("intro.points.undo") ); + function continueTo(nextStep) { + context.history().on("change.intro", null); + nextStep(); + } } - function chapters() { + function play() { dispatch14.call("done"); reveal( - ".intro-nav-wrap .chapter-navigation", - helpHtml("intro.welcome.chapters", { next: _t("intro.navigation.title") }) + ".ideditor", + helpHtml("intro.points.play", { next: _t("intro.areas.title") }), + { + tooltipBox: ".intro-nav-wrap .chapter-area", + buttonText: _t.html("intro.ok"), + buttonCallback: function() { + reveal(".ideditor"); + } + } ); } chapter.enter = function() { - welcome(); + addPoint(); }; chapter.exit = function() { - context.container().select(".curtain-tooltip.intro-mouse").selectAll(".counter").remove(); + timeouts.forEach(window.clearTimeout); + context.on("enter.intro exit.intro", null); + context.map().on("move.intro drawn.intro", null); + context.history().on("change.intro", null); + context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); + context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null); }; chapter.restart = function() { chapter.exit(); @@ -58082,20 +61225,36 @@ }; return utilRebind(chapter, dispatch14, "on"); } + var init_point = __esm({ + "modules/ui/intro/point.js"() { + "use strict"; + init_src4(); + init_src5(); + init_presets(); + init_localizer(); + init_change_preset(); + init_browse(); + init_select5(); + init_rebind(); + init_helper(); + } + }); - // modules/ui/intro/navigation.js - function uiIntroNavigation(context, reveal) { + // modules/ui/intro/area.js + var area_exports = {}; + __export(area_exports, { + uiIntroArea: () => uiIntroArea + }); + function uiIntroArea(context, reveal) { var dispatch14 = dispatch_default("done"); + var playground = [-85.63552, 41.94159]; + var playgroundPreset = _mainPresetIndex.item("leisure/playground"); + var nameField = _mainPresetIndex.field("name"); + var descriptionField = _mainPresetIndex.field("description"); var timeouts = []; - var hallId = "n2061"; - var townHall = [-85.63591, 41.94285]; - var springStreetId = "w397"; - var springStreetEndId = "n1834"; - var springStreet = [-85.63582, 41.94255]; - var onewayField = _mainPresetIndex.field("oneway"); - var maxspeedField = _mainPresetIndex.field("maxspeed"); + var _areaID; var chapter = { - title: "intro.navigation.title" + title: "intro.areas.title" }; function timeout2(f2, t2) { timeouts.push(window.setTimeout(f2, t2)); @@ -58104,417 +61263,353 @@ d3_event.stopPropagation(); d3_event.preventDefault(); } - function isTownHallSelected() { - var ids = context.selectedIDs(); - return ids.length === 1 && ids[0] === hallId; + function revealPlayground(center, text, options2) { + var padding = 180 * Math.pow(2, context.map().zoom() - 19.5); + var box = pad2(center, padding, context); + reveal(box, text, options2); } - function dragMap() { + function addArea() { context.enter(modeBrowse(context)); context.history().reset("initial"); - var msec = transitionTime(townHall, context.map().center()); + _areaID = null; + var msec = transitionTime(playground, context.map().center()); if (msec) { reveal(null, null, { duration: 0 }); } - context.map().centerZoomEase(townHall, 19, msec); + context.map().centerZoomEase(playground, 19, msec); timeout2(function() { - var centerStart = context.map().center(); - var textId = context.lastPointerType() === "mouse" ? "drag" : "drag_touch"; - var dragString = helpHtml("intro.navigation.map_info") + "{br}" + helpHtml("intro.navigation." + textId); - reveal(".main-map .surface", dragString); - context.map().on("drawn.intro", function() { - reveal(".main-map .surface", dragString, { duration: 0 }); - }); - context.map().on("move.intro", function() { - var centerNow = context.map().center(); - if (centerStart[0] !== centerNow[0] || centerStart[1] !== centerNow[1]) { - context.map().on("move.intro", null); - timeout2(function() { - continueTo(zoomMap); - }, 3e3); - } + var tooltip = reveal( + "button.add-area", + helpHtml("intro.areas.add_playground") + ); + tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-areas"); + context.on("enter.intro", function(mode) { + if (mode.id !== "add-area") return; + continueTo(startPlayground); }); }, msec + 100); function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); + context.on("enter.intro", null); nextStep(); } } - function zoomMap() { - var zoomStart = context.map().zoom(); - var textId = context.lastPointerType() === "mouse" ? "zoom" : "zoom_touch"; - var zoomString = helpHtml("intro.navigation." + textId); - reveal(".main-map .surface", zoomString); - context.map().on("drawn.intro", function() { - reveal(".main-map .surface", zoomString, { duration: 0 }); - }); - context.map().on("move.intro", function() { - if (context.map().zoom() !== zoomStart) { - context.map().on("move.intro", null); - timeout2(function() { - continueTo(features); - }, 3e3); - } - }); - function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); - nextStep(); + function startPlayground() { + if (context.mode().id !== "add-area") { + return chapter.restart(); } - } - function features() { - var onClick = function() { - continueTo(pointsLinesAreas); - }; - reveal( - ".main-map .surface", - helpHtml("intro.navigation.features"), - { buttonText: _t.html("intro.ok"), buttonCallback: onClick } - ); - context.map().on("drawn.intro", function() { - reveal( - ".main-map .surface", - helpHtml("intro.navigation.features"), - { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick } + _areaID = null; + context.map().zoomEase(19.5, 500); + timeout2(function() { + var textId = context.lastPointerType() === "mouse" ? "starting_node_click" : "starting_node_tap"; + var startDrawString = helpHtml("intro.areas.start_playground") + helpHtml("intro.areas." + textId); + revealPlayground( + playground, + startDrawString, + { duration: 250 } ); - }); + timeout2(function() { + context.map().on("move.intro drawn.intro", function() { + revealPlayground( + playground, + startDrawString, + { duration: 0 } + ); + }); + context.on("enter.intro", function(mode) { + if (mode.id !== "draw-area") return chapter.restart(); + continueTo(continuePlayground); + }); + }, 250); + }, 550); function continueTo(nextStep) { - context.map().on("drawn.intro", null); + context.map().on("move.intro drawn.intro", null); + context.on("enter.intro", null); nextStep(); } } - function pointsLinesAreas() { - var onClick = function() { - continueTo(nodesWays); - }; - reveal( - ".main-map .surface", - helpHtml("intro.navigation.points_lines_areas"), - { buttonText: _t.html("intro.ok"), buttonCallback: onClick } - ); - context.map().on("drawn.intro", function() { - reveal( - ".main-map .surface", - helpHtml("intro.navigation.points_lines_areas"), - { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick } - ); - }); - function continueTo(nextStep) { - context.map().on("drawn.intro", null); - nextStep(); + function continuePlayground() { + if (context.mode().id !== "draw-area") { + return chapter.restart(); } - } - function nodesWays() { - var onClick = function() { - continueTo(clickTownHall); - }; - reveal( - ".main-map .surface", - helpHtml("intro.navigation.nodes_ways"), - { buttonText: _t.html("intro.ok"), buttonCallback: onClick } + _areaID = null; + revealPlayground( + playground, + helpHtml("intro.areas.continue_playground"), + { duration: 250 } ); - context.map().on("drawn.intro", function() { - reveal( - ".main-map .surface", - helpHtml("intro.navigation.nodes_ways"), - { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick } - ); + timeout2(function() { + context.map().on("move.intro drawn.intro", function() { + revealPlayground( + playground, + helpHtml("intro.areas.continue_playground"), + { duration: 0 } + ); + }); + }, 250); + context.on("enter.intro", function(mode) { + if (mode.id === "draw-area") { + var entity = context.hasEntity(context.selectedIDs()[0]); + if (entity && entity.nodes.length >= 6) { + return continueTo(finishPlayground); + } else { + return; + } + } else if (mode.id === "select") { + _areaID = context.selectedIDs()[0]; + return continueTo(searchPresets); + } else { + return chapter.restart(); + } }); function continueTo(nextStep) { - context.map().on("drawn.intro", null); + context.map().on("move.intro drawn.intro", null); + context.on("enter.intro", null); nextStep(); } } - function clickTownHall() { - context.enter(modeBrowse(context)); - context.history().reset("initial"); - var entity = context.hasEntity(hallId); - if (!entity) return; - reveal(null, null, { duration: 0 }); - context.map().centerZoomEase(entity.loc, 19, 500); + function finishPlayground() { + if (context.mode().id !== "draw-area") { + return chapter.restart(); + } + _areaID = null; + var finishString = helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.areas.finish_playground"); + revealPlayground( + playground, + finishString, + { duration: 250 } + ); timeout2(function() { - var entity2 = context.hasEntity(hallId); - if (!entity2) return; - var box = pointBox(entity2.loc, context); - var textId = context.lastPointerType() === "mouse" ? "click_townhall" : "tap_townhall"; - reveal(box, helpHtml("intro.navigation." + textId)); context.map().on("move.intro drawn.intro", function() { - var entity3 = context.hasEntity(hallId); - if (!entity3) return; - var box2 = pointBox(entity3.loc, context); - reveal(box2, helpHtml("intro.navigation." + textId), { duration: 0 }); - }); - context.on("enter.intro", function() { - if (isTownHallSelected()) continueTo(selectedTownHall); + revealPlayground( + playground, + finishString, + { duration: 0 } + ); }); - }, 550); - context.history().on("change.intro", function() { - if (!context.hasEntity(hallId)) { - continueTo(clickTownHall); + }, 250); + context.on("enter.intro", function(mode) { + if (mode.id === "draw-area") { + return; + } else if (mode.id === "select") { + _areaID = context.selectedIDs()[0]; + return continueTo(searchPresets); + } else { + return chapter.restart(); } }); function continueTo(nextStep) { - context.on("enter.intro", null); context.map().on("move.intro drawn.intro", null); - context.history().on("change.intro", null); + context.on("enter.intro", null); nextStep(); } } - function selectedTownHall() { - if (!isTownHallSelected()) return clickTownHall(); - var entity = context.hasEntity(hallId); - if (!entity) return clickTownHall(); - var box = pointBox(entity.loc, context); - var onClick = function() { - continueTo(editorTownHall); - }; - reveal( - box, - helpHtml("intro.navigation.selected_townhall"), - { buttonText: _t.html("intro.ok"), buttonCallback: onClick } - ); - context.map().on("move.intro drawn.intro", function() { - var entity2 = context.hasEntity(hallId); - if (!entity2) return; - var box2 = pointBox(entity2.loc, context); + function searchPresets() { + if (!_areaID || !context.hasEntity(_areaID)) { + return addArea(); + } + var ids = context.selectedIDs(); + if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) { + context.enter(modeSelect(context, [_areaID])); + } + context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); + timeout2(function() { + context.container().select(".inspector-wrap .panewrap").style("right", "-100%"); + context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch); reveal( - box2, - helpHtml("intro.navigation.selected_townhall"), - { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick } + ".preset-search-input", + helpHtml("intro.areas.search_playground", { preset: playgroundPreset.name() }) ); - }); - context.history().on("change.intro", function() { - if (!context.hasEntity(hallId)) { - continueTo(clickTownHall); + }, 400); + context.on("enter.intro", function(mode) { + if (!_areaID || !context.hasEntity(_areaID)) { + return continueTo(addArea); + } + var ids2 = context.selectedIDs(); + if (mode.id !== "select" || !ids2.length || ids2[0] !== _areaID) { + context.enter(modeSelect(context, [_areaID])); + context.container().select(".inspector-wrap .panewrap").style("right", "-100%"); + context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); + context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch); + reveal( + ".preset-search-input", + helpHtml("intro.areas.search_playground", { preset: playgroundPreset.name() }) + ); + context.history().on("change.intro", null); } }); + function checkPresetSearch() { + var first = context.container().select(".preset-list-item:first-child"); + if (first.classed("preset-leisure-playground")) { + reveal( + first.select(".preset-list-button").node(), + helpHtml("intro.areas.choose_playground", { preset: playgroundPreset.name() }), + { duration: 300 } + ); + context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null); + context.history().on("change.intro", function() { + continueTo(clickAddField); + }); + } + } function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); + context.container().select(".inspector-wrap").on("wheel.intro", null); + context.on("enter.intro", null); context.history().on("change.intro", null); + context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null); nextStep(); } } - function editorTownHall() { - if (!isTownHallSelected()) return clickTownHall(); + function clickAddField() { + if (!_areaID || !context.hasEntity(_areaID)) { + return addArea(); + } + var ids = context.selectedIDs(); + if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) { + return searchPresets(); + } + if (!context.container().select(".form-field-description").empty()) { + return continueTo(describePlayground); + } context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); - var onClick = function() { - continueTo(presetTownHall); - }; - reveal( - ".entity-editor-pane", - helpHtml("intro.navigation.editor_townhall"), - { buttonText: _t.html("intro.ok"), buttonCallback: onClick } - ); - context.on("exit.intro", function() { - continueTo(clickTownHall); - }); - context.history().on("change.intro", function() { - if (!context.hasEntity(hallId)) { - continueTo(clickTownHall); + timeout2(function() { + context.container().select(".inspector-wrap .panewrap").style("right", "0%"); + var entity = context.entity(_areaID); + if (entity.tags.description) { + return continueTo(play); + } + var box = context.container().select(".more-fields").node().getBoundingClientRect(); + if (box.top > 300) { + var pane = context.container().select(".entity-editor-pane .inspector-body"); + var start2 = pane.node().scrollTop; + var end = start2 + (box.top - 300); + pane.transition().duration(250).tween("scroll.inspector", function() { + var node = this; + var i3 = number_default(start2, end); + return function(t2) { + node.scrollTop = i3(t2); + }; + }); } + timeout2(function() { + reveal( + ".more-fields .combobox-input", + helpHtml("intro.areas.add_field", { + name: nameField.title(), + description: descriptionField.title() + }), + { duration: 300 } + ); + context.container().select(".more-fields .combobox-input").on("click.intro", function() { + var watcher; + watcher = window.setInterval(function() { + if (!context.container().select("div.combobox").empty()) { + window.clearInterval(watcher); + continueTo(chooseDescriptionField); + } + }, 300); + }); + }, 300); + }, 400); + context.on("exit.intro", function() { + return continueTo(searchPresets); }); function continueTo(nextStep) { - context.on("exit.intro", null); - context.history().on("change.intro", null); context.container().select(".inspector-wrap").on("wheel.intro", null); + context.container().select(".more-fields .combobox-input").on("click.intro", null); + context.on("exit.intro", null); nextStep(); } } - function presetTownHall() { - if (!isTownHallSelected()) return clickTownHall(); - context.container().select(".inspector-wrap .panewrap").style("right", "0%"); - context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); - var entity = context.entity(context.selectedIDs()[0]); - var preset = _mainPresetIndex.match(entity, context.graph()); - var onClick = function() { - continueTo(fieldsTownHall); - }; + function chooseDescriptionField() { + if (!_areaID || !context.hasEntity(_areaID)) { + return addArea(); + } + var ids = context.selectedIDs(); + if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) { + return searchPresets(); + } + if (!context.container().select(".form-field-description").empty()) { + return continueTo(describePlayground); + } + if (context.container().select("div.combobox").empty()) { + return continueTo(clickAddField); + } + var watcher; + watcher = window.setInterval(function() { + if (context.container().select("div.combobox").empty()) { + window.clearInterval(watcher); + timeout2(function() { + if (context.container().select(".form-field-description").empty()) { + continueTo(retryChooseDescription); + } else { + continueTo(describePlayground); + } + }, 300); + } + }, 300); reveal( - ".entity-editor-pane .section-feature-type", - helpHtml("intro.navigation.preset_townhall", { preset: preset.name() }), - { buttonText: _t.html("intro.ok"), buttonCallback: onClick } + "div.combobox", + helpHtml("intro.areas.choose_field", { field: descriptionField.title() }), + { duration: 300 } ); context.on("exit.intro", function() { - continueTo(clickTownHall); - }); - context.history().on("change.intro", function() { - if (!context.hasEntity(hallId)) { - continueTo(clickTownHall); - } + return continueTo(searchPresets); }); function continueTo(nextStep) { + if (watcher) window.clearInterval(watcher); context.on("exit.intro", null); - context.history().on("change.intro", null); - context.container().select(".inspector-wrap").on("wheel.intro", null); nextStep(); } } - function fieldsTownHall() { - if (!isTownHallSelected()) return clickTownHall(); + function describePlayground() { + if (!_areaID || !context.hasEntity(_areaID)) { + return addArea(); + } + var ids = context.selectedIDs(); + if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) { + return searchPresets(); + } context.container().select(".inspector-wrap .panewrap").style("right", "0%"); - context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); - var onClick = function() { - continueTo(closeTownHall); - }; - reveal( - ".entity-editor-pane .section-preset-fields", - helpHtml("intro.navigation.fields_townhall"), - { buttonText: _t.html("intro.ok"), buttonCallback: onClick } - ); + if (context.container().select(".form-field-description").empty()) { + return continueTo(retryChooseDescription); + } context.on("exit.intro", function() { - continueTo(clickTownHall); - }); - context.history().on("change.intro", function() { - if (!context.hasEntity(hallId)) { - continueTo(clickTownHall); - } + continueTo(play); }); - function continueTo(nextStep) { - context.on("exit.intro", null); - context.history().on("change.intro", null); - context.container().select(".inspector-wrap").on("wheel.intro", null); - nextStep(); - } - } - function closeTownHall() { - if (!isTownHallSelected()) return clickTownHall(); - var selector = ".entity-editor-pane button.close svg use"; - var href = select_default2(selector).attr("href") || "#iD-icon-close"; reveal( ".entity-editor-pane", - helpHtml("intro.navigation.close_townhall", { button: { html: icon(href, "inline") } }) + helpHtml("intro.areas.describe_playground", { button: { html: icon("#iD-icon-close", "inline") } }), + { duration: 300 } ); - context.on("exit.intro", function() { - continueTo(searchStreet); - }); - context.history().on("change.intro", function() { - var selector2 = ".entity-editor-pane button.close svg use"; - var href2 = select_default2(selector2).attr("href") || "#iD-icon-close"; - reveal( - ".entity-editor-pane", - helpHtml("intro.navigation.close_townhall", { button: { html: icon(href2, "inline") } }), - { duration: 0 } - ); - }); function continueTo(nextStep) { context.on("exit.intro", null); - context.history().on("change.intro", null); nextStep(); } } - function searchStreet() { - context.enter(modeBrowse(context)); - context.history().reset("initial"); - var msec = transitionTime(springStreet, context.map().center()); - if (msec) { - reveal(null, null, { duration: 0 }); - } - context.map().centerZoomEase(springStreet, 19, msec); - timeout2(function() { - reveal( - ".search-header input", - helpHtml("intro.navigation.search_street", { name: _t("intro.graph.name.spring-street") }) - ); - context.container().select(".search-header input").on("keyup.intro", checkSearchResult); - }, msec + 100); - } - function checkSearchResult() { - var first = context.container().select(".feature-list-item:nth-child(0n+2)"); - var firstName = first.select(".entity-name"); - var name = _t("intro.graph.name.spring-street"); - if (!firstName.empty() && firstName.html() === name) { - reveal( - first.node(), - helpHtml("intro.navigation.choose_street", { name }), - { duration: 300 } - ); - context.on("exit.intro", function() { - continueTo(selectedStreet); - }); - context.container().select(".search-header input").on("keydown.intro", eventCancel, true).on("keyup.intro", null); - } - function continueTo(nextStep) { - context.on("exit.intro", null); - context.container().select(".search-header input").on("keydown.intro", null).on("keyup.intro", null); - nextStep(); + function retryChooseDescription() { + if (!_areaID || !context.hasEntity(_areaID)) { + return addArea(); } - } - function selectedStreet() { - if (!context.hasEntity(springStreetEndId) || !context.hasEntity(springStreetId)) { - return searchStreet(); + var ids = context.selectedIDs(); + if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) { + return searchPresets(); } - var onClick = function() { - continueTo(editorStreet); - }; - var entity = context.entity(springStreetEndId); - var box = pointBox(entity.loc, context); - box.height = 500; + context.container().select(".inspector-wrap .panewrap").style("right", "0%"); reveal( - box, - helpHtml("intro.navigation.selected_street", { name: _t("intro.graph.name.spring-street") }), - { duration: 600, buttonText: _t.html("intro.ok"), buttonCallback: onClick } - ); - timeout2(function() { - context.map().on("move.intro drawn.intro", function() { - var entity2 = context.hasEntity(springStreetEndId); - if (!entity2) return; - var box2 = pointBox(entity2.loc, context); - box2.height = 500; - reveal( - box2, - helpHtml("intro.navigation.selected_street", { name: _t("intro.graph.name.spring-street") }), - { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick } - ); - }); - }, 600); - context.on("enter.intro", function(mode) { - if (!context.hasEntity(springStreetId)) { - return continueTo(searchStreet); - } - var ids = context.selectedIDs(); - if (mode.id !== "select" || !ids.length || ids[0] !== springStreetId) { - context.enter(modeSelect(context, [springStreetId])); - } - }); - context.history().on("change.intro", function() { - if (!context.hasEntity(springStreetEndId) || !context.hasEntity(springStreetId)) { - timeout2(function() { - continueTo(searchStreet); - }, 300); + ".entity-editor-pane", + helpHtml("intro.areas.retry_add_field", { field: descriptionField.title() }), + { + buttonText: _t.html("intro.ok"), + buttonCallback: function() { + continueTo(clickAddField); + } } - }); - function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); - context.on("enter.intro", null); - context.history().on("change.intro", null); - nextStep(); - } - } - function editorStreet() { - var selector = ".entity-editor-pane button.close svg use"; - var href = select_default2(selector).attr("href") || "#iD-icon-close"; - reveal(".entity-editor-pane", helpHtml("intro.navigation.street_different_fields") + "{br}" + helpHtml("intro.navigation.editor_street", { - button: { html: icon(href, "inline") }, - field1: onewayField.title(), - field2: maxspeedField.title() - })); + ); context.on("exit.intro", function() { - continueTo(play); - }); - context.history().on("change.intro", function() { - var selector2 = ".entity-editor-pane button.close svg use"; - var href2 = select_default2(selector2).attr("href") || "#iD-icon-close"; - reveal( - ".entity-editor-pane", - helpHtml("intro.navigation.street_different_fields") + "{br}" + helpHtml("intro.navigation.editor_street", { - button: { html: icon(href2, "inline") }, - field1: onewayField.title(), - field2: maxspeedField.title() - }), - { duration: 0 } - ); + return continueTo(searchPresets); }); function continueTo(nextStep) { context.on("exit.intro", null); - context.history().on("change.intro", null); nextStep(); } } @@ -58522,9 +61617,9 @@ dispatch14.call("done"); reveal( ".ideditor", - helpHtml("intro.navigation.play", { next: _t("intro.points.title") }), + helpHtml("intro.areas.play", { next: _t("intro.lines.title") }), { - tooltipBox: ".intro-nav-wrap .chapter-point", + tooltipBox: ".intro-nav-wrap .chapter-line", buttonText: _t.html("intro.ok"), buttonCallback: function() { reveal(".ideditor"); @@ -58533,7 +61628,7 @@ ); } chapter.enter = function() { - dragMap(); + addArea(); }; chapter.exit = function() { timeouts.forEach(window.clearTimeout); @@ -58541,7 +61636,8 @@ context.map().on("move.intro drawn.intro", null); context.history().on("change.intro", null); context.container().select(".inspector-wrap").on("wheel.intro", null); - context.container().select(".search-header input").on("keydown.intro keyup.intro", null); + context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null); + context.container().select(".more-fields .combobox-input").on("click.intro", null); }; chapter.restart = function() { chapter.exit(); @@ -58549,17 +61645,51 @@ }; return utilRebind(chapter, dispatch14, "on"); } + var init_area4 = __esm({ + "modules/ui/intro/area.js"() { + "use strict"; + init_src4(); + init_src8(); + init_presets(); + init_localizer(); + init_browse(); + init_select5(); + init_rebind(); + init_helper(); + } + }); - // modules/ui/intro/point.js - function uiIntroPoint(context, reveal) { + // modules/ui/intro/line.js + var line_exports = {}; + __export(line_exports, { + uiIntroLine: () => uiIntroLine + }); + function uiIntroLine(context, reveal) { var dispatch14 = dispatch_default("done"); var timeouts = []; - var intersection2 = [-85.63279, 41.94394]; - var building = [-85.632422, 41.944045]; - var cafePreset = _mainPresetIndex.item("amenity/cafe"); - var _pointID = null; + var _tulipRoadID = null; + var flowerRoadID = "w646"; + var tulipRoadStart = [-85.6297754121684, 41.95805253325314]; + var tulipRoadMidpoint = [-85.62975395449628, 41.95787501510204]; + var tulipRoadIntersection = [-85.62974496187628, 41.95742515554585]; + var roadCategory = _mainPresetIndex.item("category-road_minor"); + var residentialPreset = _mainPresetIndex.item("highway/residential"); + var woodRoadID = "w525"; + var woodRoadEndID = "n2862"; + var woodRoadAddNode = [-85.62390110349587, 41.95397111462291]; + var woodRoadDragEndpoint = [-85.623867390213, 41.95466987786487]; + var woodRoadDragMidpoint = [-85.62386254803509, 41.95430395953872]; + var washingtonStreetID = "w522"; + var twelfthAvenueID = "w1"; + var eleventhAvenueEndID = "n3550"; + var twelfthAvenueEndID = "n5"; + var _washingtonSegmentID = null; + var eleventhAvenueEnd = context.entity(eleventhAvenueEndID).loc; + var twelfthAvenueEnd = context.entity(twelfthAvenueEndID).loc; + var deleteLinesLoc = [-85.6219395542764, 41.95228033922477]; + var twelfthAvenue = [-85.62219310052491, 41.952505413152956]; var chapter = { - title: "intro.points.title" + title: "intro.lines.title" }; function timeout2(f2, t2) { timeouts.push(window.setTimeout(f2, t2)); @@ -58568,24 +61698,23 @@ d3_event.stopPropagation(); d3_event.preventDefault(); } - function addPoint() { + function addLine() { context.enter(modeBrowse(context)); context.history().reset("initial"); - var msec = transitionTime(intersection2, context.map().center()); + var msec = transitionTime(tulipRoadStart, context.map().center()); if (msec) { reveal(null, null, { duration: 0 }); } - context.map().centerZoomEase(intersection2, 19, msec); + context.map().centerZoomEase(tulipRoadStart, 18.5, msec); timeout2(function() { var tooltip = reveal( - "button.add-point", - helpHtml("intro.points.points_info") + "{br}" + helpHtml("intro.points.add_point") + "button.add-line", + helpHtml("intro.lines.add_line") ); - _pointID = null; - tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-points"); + tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-lines"); context.on("enter.intro", function(mode) { - if (mode.id !== "add-point") return; - continueTo(placePoint); + if (mode.id !== "add-line") return; + continueTo(startLine); }); }, msec + 100); function continueTo(nextStep) { @@ -58593,723 +61722,797 @@ nextStep(); } } - function placePoint() { - if (context.mode().id !== "add-point") { - return chapter.restart(); - } - var pointBox2 = pad(building, 150, context); - var textId = context.lastPointerType() === "mouse" ? "place_point" : "place_point_touch"; - reveal(pointBox2, helpHtml("intro.points." + textId)); + function startLine() { + if (context.mode().id !== "add-line") return chapter.restart(); + _tulipRoadID = null; + var padding = 70 * Math.pow(2, context.map().zoom() - 18); + var box = pad2(tulipRoadStart, padding, context); + box.height = box.height + 100; + var textId = context.lastPointerType() === "mouse" ? "start_line" : "start_line_tap"; + var startLineString = helpHtml("intro.lines.missing_road") + "{br}" + helpHtml("intro.lines.line_draw_info") + helpHtml("intro.lines." + textId); + reveal(box, startLineString); context.map().on("move.intro drawn.intro", function() { - pointBox2 = pad(building, 150, context); - reveal(pointBox2, helpHtml("intro.points." + textId), { duration: 0 }); + padding = 70 * Math.pow(2, context.map().zoom() - 18); + box = pad2(tulipRoadStart, padding, context); + box.height = box.height + 100; + reveal(box, startLineString, { duration: 0 }); }); context.on("enter.intro", function(mode) { - if (mode.id !== "select") return chapter.restart(); - _pointID = context.mode().selectedIDs()[0]; - 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(); - } - }); + if (mode.id !== "draw-line") return chapter.restart(); + continueTo(drawLine); + }); + function continueTo(nextStep) { + context.map().on("move.intro drawn.intro", null); + context.on("enter.intro", null); + nextStep(); + } + } + function drawLine() { + if (context.mode().id !== "draw-line") return chapter.restart(); + _tulipRoadID = context.mode().selectedIDs()[0]; + context.map().centerEase(tulipRoadMidpoint, 500); + timeout2(function() { + var padding = 200 * Math.pow(2, context.map().zoom() - 18.5); + var box = pad2(tulipRoadMidpoint, padding, context); + box.height = box.height * 2; + reveal( + box, + helpHtml("intro.lines.intersect", { name: _t("intro.graph.name.flower-street") }) + ); + context.map().on("move.intro drawn.intro", function() { + padding = 200 * Math.pow(2, context.map().zoom() - 18.5); + box = pad2(tulipRoadMidpoint, padding, context); + box.height = box.height * 2; + reveal( + box, + helpHtml("intro.lines.intersect", { name: _t("intro.graph.name.flower-street") }), + { duration: 0 } + ); + }); + }, 550); + context.history().on("change.intro", function() { + if (isLineConnected()) { + continueTo(continueLine); + } + }); + context.on("enter.intro", function(mode) { + if (mode.id === "draw-line") { + return; + } else if (mode.id === "select") { + continueTo(retryIntersect); + return; } else { - continueTo(searchPreset); + return chapter.restart(); } }); function continueTo(nextStep) { context.map().on("move.intro drawn.intro", null); + context.history().on("change.intro", null); context.on("enter.intro", null); nextStep(); } } - function searchPreset() { - if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) { - return addPoint(); - } - context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); - context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch); + function isLineConnected() { + var entity = _tulipRoadID && context.hasEntity(_tulipRoadID); + if (!entity) return false; + var drawNodes = context.graph().childNodes(entity); + return drawNodes.some(function(node) { + return context.graph().parentWays(node).some(function(parent) { + return parent.id === flowerRoadID; + }); + }); + } + function retryIntersect() { + select_default2(window).on("pointerdown.intro mousedown.intro", eventCancel, true); + var box = pad2(tulipRoadIntersection, 80, context); reveal( - ".preset-search-input", - helpHtml("intro.points.search_cafe", { preset: cafePreset.name() }) + box, + helpHtml("intro.lines.retry_intersect", { name: _t("intro.graph.name.flower-street") }) ); + timeout2(chapter.restart, 3e3); + } + function continueLine() { + if (context.mode().id !== "draw-line") return chapter.restart(); + var entity = _tulipRoadID && context.hasEntity(_tulipRoadID); + if (!entity) return chapter.restart(); + context.map().centerEase(tulipRoadIntersection, 500); + var continueLineText = helpHtml("intro.lines.continue_line") + "{br}" + helpHtml("intro.lines.finish_line_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.lines.finish_road"); + reveal(".main-map .surface", continueLineText); context.on("enter.intro", function(mode) { - if (!_pointID || !context.hasEntity(_pointID)) { - return continueTo(addPoint); - } - var ids = context.selectedIDs(); - if (mode.id !== "select" || !ids.length || ids[0] !== _pointID) { - context.enter(modeSelect(context, [_pointID])); - context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); - context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch); - reveal( - ".preset-search-input", - helpHtml("intro.points.search_cafe", { preset: cafePreset.name() }) - ); - context.history().on("change.intro", null); + if (mode.id === "draw-line") { + return; + } else if (mode.id === "select") { + return continueTo(chooseCategoryRoad); + } else { + return chapter.restart(); } }); - function checkPresetSearch() { - var first = context.container().select(".preset-list-item:first-child"); - if (first.classed("preset-amenity-cafe")) { - context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null); - reveal( - first.select(".preset-list-button").node(), - helpHtml("intro.points.choose_cafe", { preset: cafePreset.name() }), - { duration: 300 } - ); - context.history().on("change.intro", function() { - continueTo(aboutFeatureEditor); - }); - } - } function continueTo(nextStep) { context.on("enter.intro", null); - context.history().on("change.intro", null); - context.container().select(".inspector-wrap").on("wheel.intro", null); - context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null); nextStep(); } } - function aboutFeatureEditor() { - if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) { - return addPoint(); - } + function chooseCategoryRoad() { + if (context.mode().id !== "select") return chapter.restart(); + context.on("exit.intro", function() { + return chapter.restart(); + }); + var button = context.container().select(".preset-category-road_minor .preset-list-button"); + if (button.empty()) return chapter.restart(); + context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); timeout2(function() { - reveal(".entity-editor-pane", helpHtml("intro.points.feature_editor"), { - tooltipClass: "intro-points-describe", - buttonText: _t.html("intro.ok"), - buttonCallback: function() { - continueTo(addName); - } + context.container().select(".inspector-wrap .panewrap").style("right", "-100%"); + reveal( + button.node(), + helpHtml("intro.lines.choose_category_road", { category: roadCategory.name() }) + ); + button.on("click.intro", function() { + continueTo(choosePresetResidential); }); }, 400); + function continueTo(nextStep) { + context.container().select(".inspector-wrap").on("wheel.intro", null); + context.container().select(".preset-list-button").on("click.intro", null); + context.on("exit.intro", null); + nextStep(); + } + } + function choosePresetResidential() { + if (context.mode().id !== "select") return chapter.restart(); context.on("exit.intro", function() { - continueTo(reselectPoint); + return chapter.restart(); + }); + var subgrid = context.container().select(".preset-category-road_minor .subgrid"); + if (subgrid.empty()) return chapter.restart(); + subgrid.selectAll(":not(.preset-highway-residential) .preset-list-button").on("click.intro", function() { + continueTo(retryPresetResidential); + }); + subgrid.selectAll(".preset-highway-residential .preset-list-button").on("click.intro", function() { + continueTo(nameRoad); + }); + timeout2(function() { + reveal( + subgrid.node(), + helpHtml("intro.lines.choose_preset_residential", { preset: residentialPreset.name() }), + { tooltipBox: ".preset-highway-residential .preset-list-button", duration: 300 } + ); + }, 300); + function continueTo(nextStep) { + context.container().select(".preset-list-button").on("click.intro", null); + context.on("exit.intro", null); + nextStep(); + } + } + function retryPresetResidential() { + if (context.mode().id !== "select") return chapter.restart(); + context.on("exit.intro", function() { + return chapter.restart(); }); + context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); + timeout2(function() { + var button = context.container().select(".entity-editor-pane .preset-list-button"); + reveal( + button.node(), + helpHtml("intro.lines.retry_preset_residential", { preset: residentialPreset.name() }) + ); + button.on("click.intro", function() { + continueTo(chooseCategoryRoad); + }); + }, 500); function continueTo(nextStep) { + context.container().select(".inspector-wrap").on("wheel.intro", null); + context.container().select(".preset-list-button").on("click.intro", null); context.on("exit.intro", null); nextStep(); } } - function addName() { - if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) { - return addPoint(); - } - context.container().select(".inspector-wrap .panewrap").style("right", "0%"); - var addNameString = helpHtml("intro.points.fields_info") + "{br}" + helpHtml("intro.points.add_name") + "{br}" + helpHtml("intro.points.add_reminder"); - timeout2(function() { - var entity = context.entity(_pointID); - if (entity.tags.name) { - var tooltip = reveal(".entity-editor-pane", addNameString, { - tooltipClass: "intro-points-describe", - buttonText: _t.html("intro.ok"), - buttonCallback: function() { - continueTo(addCloseEditor); - } - }); - tooltip.select(".instruction").style("display", "none"); - } else { - reveal( - ".entity-editor-pane", - addNameString, - { tooltipClass: "intro-points-describe" } - ); - } - }, 400); - context.history().on("change.intro", function() { - continueTo(addCloseEditor); - }); + function nameRoad() { context.on("exit.intro", function() { - continueTo(reselectPoint); + continueTo(didNameRoad); }); + timeout2(function() { + reveal( + ".entity-editor-pane", + helpHtml("intro.lines.name_road", { button: { html: icon("#iD-icon-close", "inline") } }), + { tooltipClass: "intro-lines-name_road" } + ); + }, 500); function continueTo(nextStep) { context.on("exit.intro", null); - context.history().on("change.intro", null); nextStep(); } } - function addCloseEditor() { - context.container().select(".inspector-wrap .panewrap").style("right", "0%"); - var selector = ".entity-editor-pane button.close svg use"; - var href = select_default2(selector).attr("href") || "#iD-icon-close"; - context.on("exit.intro", function() { - continueTo(reselectPoint); - }); - reveal( - ".entity-editor-pane", - helpHtml("intro.points.add_close", { button: { html: icon(href, "inline") } }) - ); + function didNameRoad() { + context.history().checkpoint("doneAddLine"); + timeout2(function() { + reveal(".main-map .surface", helpHtml("intro.lines.did_name_road"), { + buttonText: _t.html("intro.ok"), + buttonCallback: function() { + continueTo(updateLine); + } + }); + }, 500); function continueTo(nextStep) { - context.on("exit.intro", null); nextStep(); } } - function reselectPoint() { - if (!_pointID) return chapter.restart(); - var entity = context.hasEntity(_pointID); - if (!entity) return chapter.restart(); - var oldPreset = _mainPresetIndex.match(entity, context.graph()); - context.replace(actionChangePreset(_pointID, oldPreset, cafePreset)); - context.enter(modeBrowse(context)); - var msec = transitionTime(entity.loc, context.map().center()); + function updateLine() { + context.history().reset("doneAddLine"); + if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { + return chapter.restart(); + } + var msec = transitionTime(woodRoadDragMidpoint, context.map().center()); if (msec) { reveal(null, null, { duration: 0 }); } - context.map().centerEase(entity.loc, msec); + context.map().centerZoomEase(woodRoadDragMidpoint, 19, msec); timeout2(function() { - var box = pointBox(entity.loc, context); - reveal(box, helpHtml("intro.points.reselect"), { duration: 600 }); - timeout2(function() { - context.map().on("move.intro drawn.intro", function() { - var entity2 = context.hasEntity(_pointID); - if (!entity2) return chapter.restart(); - var box2 = pointBox(entity2.loc, context); - reveal(box2, helpHtml("intro.points.reselect"), { duration: 0 }); - }); - }, 600); - context.on("enter.intro", function(mode) { - if (mode.id !== "select") return; - continueTo(updatePoint); + var padding = 250 * Math.pow(2, context.map().zoom() - 19); + var box = pad2(woodRoadDragMidpoint, padding, context); + var advance = function() { + continueTo(addNode); + }; + reveal( + box, + helpHtml("intro.lines.update_line"), + { buttonText: _t.html("intro.ok"), buttonCallback: advance } + ); + context.map().on("move.intro drawn.intro", function() { + var padding2 = 250 * Math.pow(2, context.map().zoom() - 19); + var box2 = pad2(woodRoadDragMidpoint, padding2, context); + reveal( + box2, + helpHtml("intro.lines.update_line"), + { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance } + ); }); }, msec + 100); function continueTo(nextStep) { context.map().on("move.intro drawn.intro", null); - context.on("enter.intro", null); nextStep(); } } - function updatePoint() { - if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) { - return continueTo(reselectPoint); + function addNode() { + context.history().reset("doneAddLine"); + if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { + return chapter.restart(); } - context.container().select(".inspector-wrap .panewrap").style("right", "0%"); - context.on("exit.intro", function() { - continueTo(reselectPoint); + var padding = 40 * Math.pow(2, context.map().zoom() - 19); + var box = pad2(woodRoadAddNode, padding, context); + var addNodeString = helpHtml("intro.lines.add_node" + (context.lastPointerType() === "mouse" ? "" : "_touch")); + reveal(box, addNodeString); + context.map().on("move.intro drawn.intro", function() { + var padding2 = 40 * Math.pow(2, context.map().zoom() - 19); + var box2 = pad2(woodRoadAddNode, padding2, context); + reveal(box2, addNodeString, { duration: 0 }); }); - context.history().on("change.intro", function() { - continueTo(updateCloseEditor); + context.history().on("change.intro", function(changed) { + if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { + return continueTo(updateLine); + } + if (changed.created().length === 1) { + timeout2(function() { + continueTo(startDragEndpoint); + }, 500); + } + }); + context.on("enter.intro", function(mode) { + if (mode.id !== "select") { + continueTo(updateLine); + } }); - timeout2(function() { - reveal( - ".entity-editor-pane", - helpHtml("intro.points.update"), - { tooltipClass: "intro-points-describe" } - ); - }, 400); function continueTo(nextStep) { - context.on("exit.intro", null); + context.map().on("move.intro drawn.intro", null); context.history().on("change.intro", null); + context.on("enter.intro", null); nextStep(); } } - function updateCloseEditor() { - if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) { - return continueTo(reselectPoint); + function startDragEndpoint() { + if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { + return continueTo(updateLine); } - context.container().select(".inspector-wrap .panewrap").style("right", "0%"); - context.on("exit.intro", function() { - continueTo(rightClickPoint); + var padding = 100 * Math.pow(2, context.map().zoom() - 19); + var box = pad2(woodRoadDragEndpoint, padding, context); + var startDragString = helpHtml("intro.lines.start_drag_endpoint" + (context.lastPointerType() === "mouse" ? "" : "_touch")) + helpHtml("intro.lines.drag_to_intersection"); + reveal(box, startDragString); + context.map().on("move.intro drawn.intro", function() { + if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { + return continueTo(updateLine); + } + var padding2 = 100 * Math.pow(2, context.map().zoom() - 19); + var box2 = pad2(woodRoadDragEndpoint, padding2, context); + reveal(box2, startDragString, { duration: 0 }); + var entity = context.entity(woodRoadEndID); + if (geoSphericalDistance(entity.loc, woodRoadDragEndpoint) <= 4) { + continueTo(finishDragEndpoint); + } }); - timeout2(function() { - reveal( - ".entity-editor-pane", - helpHtml("intro.points.update_close", { button: { html: icon("#iD-icon-close", "inline") } }) - ); - }, 500); function continueTo(nextStep) { - context.on("exit.intro", null); + context.map().on("move.intro drawn.intro", null); nextStep(); } } - function rightClickPoint() { - if (!_pointID) return chapter.restart(); - var entity = context.hasEntity(_pointID); - if (!entity) return chapter.restart(); - context.enter(modeBrowse(context)); - var box = pointBox(entity.loc, context); - var textId = context.lastPointerType() === "mouse" ? "rightclick" : "edit_menu_touch"; - reveal(box, helpHtml("intro.points." + textId), { duration: 600 }); - timeout2(function() { - context.map().on("move.intro", function() { - var entity2 = context.hasEntity(_pointID); - if (!entity2) return chapter.restart(); - var box2 = pointBox(entity2.loc, context); - reveal(box2, helpHtml("intro.points." + textId), { duration: 0 }); - }); - }, 600); - context.on("enter.intro", function(mode) { - if (mode.id !== "select") return; - var ids = context.selectedIDs(); - if (ids.length !== 1 || ids[0] !== _pointID) return; - timeout2(function() { - var node = selectMenuItem(context, "delete").node(); - if (!node) return; - continueTo(enterDelete); - }, 50); + function finishDragEndpoint() { + if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { + return continueTo(updateLine); + } + var padding = 100 * Math.pow(2, context.map().zoom() - 19); + var box = pad2(woodRoadDragEndpoint, padding, context); + var finishDragString = helpHtml("intro.lines.spot_looks_good") + helpHtml("intro.lines.finish_drag_endpoint" + (context.lastPointerType() === "mouse" ? "" : "_touch")); + reveal(box, finishDragString); + context.map().on("move.intro drawn.intro", function() { + if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { + return continueTo(updateLine); + } + var padding2 = 100 * Math.pow(2, context.map().zoom() - 19); + var box2 = pad2(woodRoadDragEndpoint, padding2, context); + reveal(box2, finishDragString, { duration: 0 }); + var entity = context.entity(woodRoadEndID); + if (geoSphericalDistance(entity.loc, woodRoadDragEndpoint) > 4) { + continueTo(startDragEndpoint); + } + }); + context.on("enter.intro", function() { + continueTo(startDragMidpoint); }); function continueTo(nextStep) { + context.map().on("move.intro drawn.intro", null); context.on("enter.intro", null); - context.map().on("move.intro", null); nextStep(); } } - function enterDelete() { - if (!_pointID) return chapter.restart(); - var entity = context.hasEntity(_pointID); - if (!entity) return chapter.restart(); - var node = selectMenuItem(context, "delete").node(); - if (!node) { - return continueTo(rightClickPoint); + function startDragMidpoint() { + if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { + return continueTo(updateLine); } - reveal( - ".edit-menu", - helpHtml("intro.points.delete"), - { padding: 50 } - ); - timeout2(function() { - context.map().on("move.intro", function() { - if (selectMenuItem(context, "delete").empty()) { - return continueTo(rightClickPoint); - } - reveal( - ".edit-menu", - helpHtml("intro.points.delete"), - { duration: 0, padding: 50 } - ); - }); - }, 300); - context.on("exit.intro", function() { - if (!_pointID) return chapter.restart(); - var entity2 = context.hasEntity(_pointID); - if (entity2) return continueTo(rightClickPoint); + if (context.selectedIDs().indexOf(woodRoadID) === -1) { + context.enter(modeSelect(context, [woodRoadID])); + } + var padding = 80 * Math.pow(2, context.map().zoom() - 19); + var box = pad2(woodRoadDragMidpoint, padding, context); + reveal(box, helpHtml("intro.lines.start_drag_midpoint")); + context.map().on("move.intro drawn.intro", function() { + if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { + return continueTo(updateLine); + } + var padding2 = 80 * Math.pow(2, context.map().zoom() - 19); + var box2 = pad2(woodRoadDragMidpoint, padding2, context); + reveal(box2, helpHtml("intro.lines.start_drag_midpoint"), { duration: 0 }); }); context.history().on("change.intro", function(changed) { - if (changed.deleted().length) { - continueTo(undo); + if (changed.created().length === 1) { + continueTo(continueDragMidpoint); + } + }); + context.on("enter.intro", function(mode) { + if (mode.id !== "select") { + context.enter(modeSelect(context, [woodRoadID])); } }); function continueTo(nextStep) { - context.map().on("move.intro", null); + context.map().on("move.intro drawn.intro", null); context.history().on("change.intro", null); - context.on("exit.intro", null); + context.on("enter.intro", null); nextStep(); } } - function undo() { - context.history().on("change.intro", function() { - continueTo(play); - }); + function continueDragMidpoint() { + if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { + return continueTo(updateLine); + } + var padding = 100 * Math.pow(2, context.map().zoom() - 19); + var box = pad2(woodRoadDragEndpoint, padding, context); + box.height += 400; + var advance = function() { + context.history().checkpoint("doneUpdateLine"); + continueTo(deleteLines); + }; reveal( - ".top-toolbar button.undo-button", - helpHtml("intro.points.undo") + box, + helpHtml("intro.lines.continue_drag_midpoint"), + { buttonText: _t.html("intro.ok"), buttonCallback: advance } ); + context.map().on("move.intro drawn.intro", function() { + if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { + return continueTo(updateLine); + } + var padding2 = 100 * Math.pow(2, context.map().zoom() - 19); + var box2 = pad2(woodRoadDragEndpoint, padding2, context); + box2.height += 400; + reveal( + box2, + helpHtml("intro.lines.continue_drag_midpoint"), + { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance } + ); + }); function continueTo(nextStep) { - context.history().on("change.intro", null); + context.map().on("move.intro drawn.intro", null); nextStep(); } } - function play() { - dispatch14.call("done"); - reveal( - ".ideditor", - helpHtml("intro.points.play", { next: _t("intro.areas.title") }), - { - tooltipBox: ".intro-nav-wrap .chapter-area", - buttonText: _t.html("intro.ok"), - buttonCallback: function() { - reveal(".ideditor"); - } - } - ); - } - chapter.enter = function() { - addPoint(); - }; - chapter.exit = function() { - timeouts.forEach(window.clearTimeout); - context.on("enter.intro exit.intro", null); - context.map().on("move.intro drawn.intro", null); - context.history().on("change.intro", null); - context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); - context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null); - }; - chapter.restart = function() { - chapter.exit(); - chapter.enter(); - }; - return utilRebind(chapter, dispatch14, "on"); - } - - // modules/ui/intro/area.js - function uiIntroArea(context, reveal) { - var dispatch14 = dispatch_default("done"); - var playground = [-85.63552, 41.94159]; - var playgroundPreset = _mainPresetIndex.item("leisure/playground"); - var nameField = _mainPresetIndex.field("name"); - var descriptionField = _mainPresetIndex.field("description"); - var timeouts = []; - var _areaID; - var chapter = { - title: "intro.areas.title" - }; - function timeout2(f2, t2) { - timeouts.push(window.setTimeout(f2, t2)); - } - function eventCancel(d3_event) { - d3_event.stopPropagation(); - d3_event.preventDefault(); - } - function revealPlayground(center, text, options2) { - var padding = 180 * Math.pow(2, context.map().zoom() - 19.5); - var box = pad(center, padding, context); - reveal(box, text, options2); - } - function addArea() { + function deleteLines() { + context.history().reset("doneUpdateLine"); context.enter(modeBrowse(context)); - context.history().reset("initial"); - _areaID = null; - var msec = transitionTime(playground, context.map().center()); + if (!context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { + return chapter.restart(); + } + var msec = transitionTime(deleteLinesLoc, context.map().center()); if (msec) { reveal(null, null, { duration: 0 }); } - context.map().centerZoomEase(playground, 19, msec); + context.map().centerZoomEase(deleteLinesLoc, 18, msec); timeout2(function() { - var tooltip = reveal( - "button.add-area", - helpHtml("intro.areas.add_playground") + var padding = 200 * Math.pow(2, context.map().zoom() - 18); + var box = pad2(deleteLinesLoc, padding, context); + box.top -= 200; + box.height += 400; + var advance = function() { + continueTo(rightClickIntersection); + }; + reveal( + box, + helpHtml("intro.lines.delete_lines", { street: _t("intro.graph.name.12th-avenue") }), + { buttonText: _t.html("intro.ok"), buttonCallback: advance } ); - tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-areas"); - context.on("enter.intro", function(mode) { - if (mode.id !== "add-area") return; - continueTo(startPlayground); + context.map().on("move.intro drawn.intro", function() { + var padding2 = 200 * Math.pow(2, context.map().zoom() - 18); + var box2 = pad2(deleteLinesLoc, padding2, context); + box2.top -= 200; + box2.height += 400; + reveal( + box2, + helpHtml("intro.lines.delete_lines", { street: _t("intro.graph.name.12th-avenue") }), + { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance } + ); + }); + context.history().on("change.intro", function() { + timeout2(function() { + continueTo(deleteLines); + }, 500); }); }, msec + 100); function continueTo(nextStep) { + context.map().on("move.intro drawn.intro", null); + context.history().on("change.intro", null); + nextStep(); + } + } + function rightClickIntersection() { + context.history().reset("doneUpdateLine"); + context.enter(modeBrowse(context)); + context.map().centerZoomEase(eleventhAvenueEnd, 18, 500); + var rightClickString = helpHtml("intro.lines.split_street", { + street1: _t("intro.graph.name.11th-avenue"), + street2: _t("intro.graph.name.washington-street") + }) + helpHtml("intro.lines." + (context.lastPointerType() === "mouse" ? "rightclick_intersection" : "edit_menu_intersection_touch")); + timeout2(function() { + var padding = 60 * Math.pow(2, context.map().zoom() - 18); + var box = pad2(eleventhAvenueEnd, padding, context); + reveal(box, rightClickString); + context.map().on("move.intro drawn.intro", function() { + var padding2 = 60 * Math.pow(2, context.map().zoom() - 18); + var box2 = pad2(eleventhAvenueEnd, padding2, context); + reveal( + box2, + rightClickString, + { duration: 0 } + ); + }); + context.on("enter.intro", function(mode) { + if (mode.id !== "select") return; + var ids = context.selectedIDs(); + if (ids.length !== 1 || ids[0] !== eleventhAvenueEndID) return; + timeout2(function() { + var node = selectMenuItem(context, "split").node(); + if (!node) return; + continueTo(splitIntersection); + }, 50); + }); + context.history().on("change.intro", function() { + timeout2(function() { + continueTo(deleteLines); + }, 300); + }); + }, 600); + function continueTo(nextStep) { + context.map().on("move.intro drawn.intro", null); context.on("enter.intro", null); + context.history().on("change.intro", null); nextStep(); } } - function startPlayground() { - if (context.mode().id !== "add-area") { - return chapter.restart(); + function splitIntersection() { + if (!context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { + return continueTo(deleteLines); } - _areaID = null; - context.map().zoomEase(19.5, 500); - timeout2(function() { - var textId = context.lastPointerType() === "mouse" ? "starting_node_click" : "starting_node_tap"; - var startDrawString = helpHtml("intro.areas.start_playground") + helpHtml("intro.areas." + textId); - revealPlayground( - playground, - startDrawString, - { duration: 250 } - ); - timeout2(function() { - context.map().on("move.intro drawn.intro", function() { - revealPlayground( - playground, - startDrawString, - { duration: 0 } - ); - }); - context.on("enter.intro", function(mode) { - if (mode.id !== "draw-area") return chapter.restart(); - continueTo(continuePlayground); - }); - }, 250); - }, 550); + var node = selectMenuItem(context, "split").node(); + if (!node) { + return continueTo(rightClickIntersection); + } + var wasChanged = false; + _washingtonSegmentID = null; + reveal( + ".edit-menu", + helpHtml( + "intro.lines.split_intersection", + { street: _t("intro.graph.name.washington-street") } + ), + { padding: 50 } + ); + context.map().on("move.intro drawn.intro", function() { + var node2 = selectMenuItem(context, "split").node(); + if (!wasChanged && !node2) { + return continueTo(rightClickIntersection); + } + reveal( + ".edit-menu", + helpHtml( + "intro.lines.split_intersection", + { street: _t("intro.graph.name.washington-street") } + ), + { duration: 0, padding: 50 } + ); + }); + context.history().on("change.intro", function(changed) { + wasChanged = true; + timeout2(function() { + if (context.history().undoAnnotation() === _t("operations.split.annotation.line", { n: 1 })) { + _washingtonSegmentID = changed.created()[0].id; + continueTo(didSplit); + } else { + _washingtonSegmentID = null; + continueTo(retrySplit); + } + }, 300); + }); function continueTo(nextStep) { context.map().on("move.intro drawn.intro", null); - context.on("enter.intro", null); + context.history().on("change.intro", null); nextStep(); } } - function continuePlayground() { - if (context.mode().id !== "draw-area") { - return chapter.restart(); - } - _areaID = null; - revealPlayground( - playground, - helpHtml("intro.areas.continue_playground"), - { duration: 250 } + function retrySplit() { + context.enter(modeBrowse(context)); + context.map().centerZoomEase(eleventhAvenueEnd, 18, 500); + var advance = function() { + continueTo(rightClickIntersection); + }; + var padding = 60 * Math.pow(2, context.map().zoom() - 18); + var box = pad2(eleventhAvenueEnd, padding, context); + reveal( + box, + helpHtml("intro.lines.retry_split"), + { buttonText: _t.html("intro.ok"), buttonCallback: advance } ); - timeout2(function() { - context.map().on("move.intro drawn.intro", function() { - revealPlayground( - playground, - helpHtml("intro.areas.continue_playground"), - { duration: 0 } - ); - }); - }, 250); - context.on("enter.intro", function(mode) { - if (mode.id === "draw-area") { - var entity = context.hasEntity(context.selectedIDs()[0]); - if (entity && entity.nodes.length >= 6) { - return continueTo(finishPlayground); - } else { - return; - } - } else if (mode.id === "select") { - _areaID = context.selectedIDs()[0]; - return continueTo(searchPresets); - } else { - return chapter.restart(); - } + context.map().on("move.intro drawn.intro", function() { + var padding2 = 60 * Math.pow(2, context.map().zoom() - 18); + var box2 = pad2(eleventhAvenueEnd, padding2, context); + reveal( + box2, + helpHtml("intro.lines.retry_split"), + { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance } + ); }); function continueTo(nextStep) { context.map().on("move.intro drawn.intro", null); - context.on("enter.intro", null); nextStep(); } } - function finishPlayground() { - if (context.mode().id !== "draw-area") { - return chapter.restart(); + function didSplit() { + if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { + return continueTo(rightClickIntersection); } - _areaID = null; - var finishString = helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.areas.finish_playground"); - revealPlayground( - playground, - finishString, - { duration: 250 } + var ids = context.selectedIDs(); + var string = "intro.lines.did_split_" + (ids.length > 1 ? "multi" : "single"); + var street = _t("intro.graph.name.washington-street"); + var padding = 200 * Math.pow(2, context.map().zoom() - 18); + var box = pad2(twelfthAvenue, padding, context); + box.width = box.width / 2; + reveal( + box, + helpHtml(string, { street1: street, street2: street }), + { duration: 500 } ); timeout2(function() { + context.map().centerZoomEase(twelfthAvenue, 18, 500); context.map().on("move.intro drawn.intro", function() { - revealPlayground( - playground, - finishString, + var padding2 = 200 * Math.pow(2, context.map().zoom() - 18); + var box2 = pad2(twelfthAvenue, padding2, context); + box2.width = box2.width / 2; + reveal( + box2, + helpHtml(string, { street1: street, street2: street }), { duration: 0 } ); }); - }, 250); - context.on("enter.intro", function(mode) { - if (mode.id === "draw-area") { - return; - } else if (mode.id === "select") { - _areaID = context.selectedIDs()[0]; - return continueTo(searchPresets); - } else { - return chapter.restart(); + }, 600); + context.on("enter.intro", function() { + var ids2 = context.selectedIDs(); + if (ids2.length === 1 && ids2[0] === _washingtonSegmentID) { + continueTo(multiSelect2); + } + }); + context.history().on("change.intro", function() { + if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { + return continueTo(rightClickIntersection); } }); function continueTo(nextStep) { context.map().on("move.intro drawn.intro", null); context.on("enter.intro", null); + context.history().on("change.intro", null); nextStep(); } } - function searchPresets() { - if (!_areaID || !context.hasEntity(_areaID)) { - return addArea(); + function multiSelect2() { + if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { + return continueTo(rightClickIntersection); } var ids = context.selectedIDs(); - if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) { - context.enter(modeSelect(context, [_areaID])); + var hasWashington = ids.indexOf(_washingtonSegmentID) !== -1; + var hasTwelfth = ids.indexOf(twelfthAvenueID) !== -1; + if (hasWashington && hasTwelfth) { + return continueTo(multiRightClick); + } else if (!hasWashington && !hasTwelfth) { + return continueTo(didSplit); } - context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); + context.map().centerZoomEase(twelfthAvenue, 18, 500); timeout2(function() { - context.container().select(".inspector-wrap .panewrap").style("right", "-100%"); - context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch); + var selected, other2, padding, box; + if (hasWashington) { + selected = _t("intro.graph.name.washington-street"); + other2 = _t("intro.graph.name.12th-avenue"); + padding = 60 * Math.pow(2, context.map().zoom() - 18); + box = pad2(twelfthAvenueEnd, padding, context); + box.width *= 3; + } else { + selected = _t("intro.graph.name.12th-avenue"); + other2 = _t("intro.graph.name.washington-street"); + padding = 200 * Math.pow(2, context.map().zoom() - 18); + box = pad2(twelfthAvenue, padding, context); + box.width /= 2; + } reveal( - ".preset-search-input", - helpHtml("intro.areas.search_playground", { preset: playgroundPreset.name() }) + box, + helpHtml( + "intro.lines.multi_select", + { selected, other1: other2 } + ) + " " + helpHtml( + "intro.lines.add_to_selection_" + (context.lastPointerType() === "mouse" ? "click" : "touch"), + { selected, other2 } + ) ); - }, 400); - context.on("enter.intro", function(mode) { - if (!_areaID || !context.hasEntity(_areaID)) { - return continueTo(addArea); - } - var ids2 = context.selectedIDs(); - if (mode.id !== "select" || !ids2.length || ids2[0] !== _areaID) { - context.enter(modeSelect(context, [_areaID])); - context.container().select(".inspector-wrap .panewrap").style("right", "-100%"); - context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); - context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch); - reveal( - ".preset-search-input", - helpHtml("intro.areas.search_playground", { preset: playgroundPreset.name() }) - ); - context.history().on("change.intro", null); - } - }); - function checkPresetSearch() { - var first = context.container().select(".preset-list-item:first-child"); - if (first.classed("preset-leisure-playground")) { + context.map().on("move.intro drawn.intro", function() { + if (hasWashington) { + selected = _t("intro.graph.name.washington-street"); + other2 = _t("intro.graph.name.12th-avenue"); + padding = 60 * Math.pow(2, context.map().zoom() - 18); + box = pad2(twelfthAvenueEnd, padding, context); + box.width *= 3; + } else { + selected = _t("intro.graph.name.12th-avenue"); + other2 = _t("intro.graph.name.washington-street"); + padding = 200 * Math.pow(2, context.map().zoom() - 18); + box = pad2(twelfthAvenue, padding, context); + box.width /= 2; + } reveal( - first.select(".preset-list-button").node(), - helpHtml("intro.areas.choose_playground", { preset: playgroundPreset.name() }), - { duration: 300 } + box, + helpHtml( + "intro.lines.multi_select", + { selected, other1: other2 } + ) + " " + helpHtml( + "intro.lines.add_to_selection_" + (context.lastPointerType() === "mouse" ? "click" : "touch"), + { selected, other2 } + ), + { duration: 0 } ); - context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null); - context.history().on("change.intro", function() { - continueTo(clickAddField); - }); - } - } + }); + context.on("enter.intro", function() { + continueTo(multiSelect2); + }); + context.history().on("change.intro", function() { + if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { + return continueTo(rightClickIntersection); + } + }); + }, 600); function continueTo(nextStep) { - context.container().select(".inspector-wrap").on("wheel.intro", null); + context.map().on("move.intro drawn.intro", null); context.on("enter.intro", null); context.history().on("change.intro", null); - context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null); nextStep(); } } - function clickAddField() { - if (!_areaID || !context.hasEntity(_areaID)) { - return addArea(); - } - var ids = context.selectedIDs(); - if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) { - return searchPresets(); - } - if (!context.container().select(".form-field-description").empty()) { - return continueTo(describePlayground); + function multiRightClick() { + if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { + return continueTo(rightClickIntersection); } - context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); - timeout2(function() { - context.container().select(".inspector-wrap .panewrap").style("right", "0%"); - var entity = context.entity(_areaID); - if (entity.tags.description) { - return continueTo(play); - } - var box = context.container().select(".more-fields").node().getBoundingClientRect(); - if (box.top > 300) { - var pane = context.container().select(".entity-editor-pane .inspector-body"); - var start2 = pane.node().scrollTop; - var end = start2 + (box.top - 300); - pane.transition().duration(250).tween("scroll.inspector", function() { - var node = this; - var i3 = number_default(start2, end); - return function(t2) { - node.scrollTop = i3(t2); - }; - }); - } + var padding = 200 * Math.pow(2, context.map().zoom() - 18); + var box = pad2(twelfthAvenue, padding, context); + var rightClickString = helpHtml("intro.lines.multi_select_success") + helpHtml("intro.lines.multi_" + (context.lastPointerType() === "mouse" ? "rightclick" : "edit_menu_touch")); + reveal(box, rightClickString); + context.map().on("move.intro drawn.intro", function() { + var padding2 = 200 * Math.pow(2, context.map().zoom() - 18); + var box2 = pad2(twelfthAvenue, padding2, context); + reveal(box2, rightClickString, { duration: 0 }); + }); + context.ui().editMenu().on("toggled.intro", function(open) { + if (!open) return; timeout2(function() { - reveal( - ".more-fields .combobox-input", - helpHtml("intro.areas.add_field", { - name: nameField.title(), - description: descriptionField.title() - }), - { duration: 300 } - ); - context.container().select(".more-fields .combobox-input").on("click.intro", function() { - var watcher; - watcher = window.setInterval(function() { - if (!context.container().select("div.combobox").empty()) { - window.clearInterval(watcher); - continueTo(chooseDescriptionField); - } - }, 300); - }); + var ids = context.selectedIDs(); + if (ids.length === 2 && ids.indexOf(twelfthAvenueID) !== -1 && ids.indexOf(_washingtonSegmentID) !== -1) { + var node = selectMenuItem(context, "delete").node(); + if (!node) return; + continueTo(multiDelete); + } else if (ids.length === 1 && ids.indexOf(_washingtonSegmentID) !== -1) { + return continueTo(multiSelect2); + } else { + return continueTo(didSplit); + } }, 300); - }, 400); - context.on("exit.intro", function() { - return continueTo(searchPresets); + }); + context.history().on("change.intro", function() { + if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { + return continueTo(rightClickIntersection); + } }); function continueTo(nextStep) { - context.container().select(".inspector-wrap").on("wheel.intro", null); - context.container().select(".more-fields .combobox-input").on("click.intro", null); - context.on("exit.intro", null); + context.map().on("move.intro drawn.intro", null); + context.ui().editMenu().on("toggled.intro", null); + context.history().on("change.intro", null); nextStep(); } } - function chooseDescriptionField() { - if (!_areaID || !context.hasEntity(_areaID)) { - return addArea(); - } - var ids = context.selectedIDs(); - if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) { - return searchPresets(); - } - if (!context.container().select(".form-field-description").empty()) { - return continueTo(describePlayground); - } - if (context.container().select("div.combobox").empty()) { - return continueTo(clickAddField); + function multiDelete() { + if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { + return continueTo(rightClickIntersection); } - var watcher; - watcher = window.setInterval(function() { - if (context.container().select("div.combobox").empty()) { - window.clearInterval(watcher); - timeout2(function() { - if (context.container().select(".form-field-description").empty()) { - continueTo(retryChooseDescription); - } else { - continueTo(describePlayground); - } - }, 300); - } - }, 300); + var node = selectMenuItem(context, "delete").node(); + if (!node) return continueTo(multiRightClick); reveal( - "div.combobox", - helpHtml("intro.areas.choose_field", { field: descriptionField.title() }), - { duration: 300 } + ".edit-menu", + helpHtml("intro.lines.multi_delete"), + { padding: 50 } ); - context.on("exit.intro", function() { - return continueTo(searchPresets); + context.map().on("move.intro drawn.intro", function() { + reveal( + ".edit-menu", + helpHtml("intro.lines.multi_delete"), + { duration: 0, padding: 50 } + ); }); - function continueTo(nextStep) { - if (watcher) window.clearInterval(watcher); - context.on("exit.intro", null); - nextStep(); - } - } - function describePlayground() { - if (!_areaID || !context.hasEntity(_areaID)) { - return addArea(); - } - var ids = context.selectedIDs(); - if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) { - return searchPresets(); - } - context.container().select(".inspector-wrap .panewrap").style("right", "0%"); - if (context.container().select(".form-field-description").empty()) { - return continueTo(retryChooseDescription); - } context.on("exit.intro", function() { - continueTo(play); + if (context.hasEntity(_washingtonSegmentID) || context.hasEntity(twelfthAvenueID)) { + return continueTo(multiSelect2); + } + }); + context.history().on("change.intro", function() { + if (context.hasEntity(_washingtonSegmentID) || context.hasEntity(twelfthAvenueID)) { + continueTo(retryDelete); + } else { + continueTo(play); + } }); - reveal( - ".entity-editor-pane", - helpHtml("intro.areas.describe_playground", { button: { html: icon("#iD-icon-close", "inline") } }), - { duration: 300 } - ); function continueTo(nextStep) { + context.map().on("move.intro drawn.intro", null); context.on("exit.intro", null); + context.history().on("change.intro", null); nextStep(); } } - function retryChooseDescription() { - if (!_areaID || !context.hasEntity(_areaID)) { - return addArea(); - } - var ids = context.selectedIDs(); - if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) { - return searchPresets(); - } - context.container().select(".inspector-wrap .panewrap").style("right", "0%"); - reveal( - ".entity-editor-pane", - helpHtml("intro.areas.retry_add_field", { field: descriptionField.title() }), - { - buttonText: _t.html("intro.ok"), - buttonCallback: function() { - continueTo(clickAddField); - } + function retryDelete() { + context.enter(modeBrowse(context)); + var padding = 200 * Math.pow(2, context.map().zoom() - 18); + var box = pad2(twelfthAvenue, padding, context); + reveal(box, helpHtml("intro.lines.retry_delete"), { + buttonText: _t.html("intro.ok"), + buttonCallback: function() { + continueTo(multiSelect2); } - ); - context.on("exit.intro", function() { - return continueTo(searchPresets); }); function continueTo(nextStep) { - context.on("exit.intro", null); nextStep(); } } @@ -59317,9 +62520,9 @@ dispatch14.call("done"); reveal( ".ideditor", - helpHtml("intro.areas.play", { next: _t("intro.lines.title") }), + helpHtml("intro.lines.play", { next: _t("intro.buildings.title") }), { - tooltipBox: ".intro-nav-wrap .chapter-line", + tooltipBox: ".intro-nav-wrap .chapter-building", buttonText: _t.html("intro.ok"), buttonCallback: function() { reveal(".ideditor"); @@ -59328,16 +62531,16 @@ ); } chapter.enter = function() { - addArea(); + addLine(); }; chapter.exit = function() { timeouts.forEach(window.clearTimeout); + select_default2(window).on("pointerdown.intro mousedown.intro", null, true); context.on("enter.intro exit.intro", null); context.map().on("move.intro drawn.intro", null); context.history().on("change.intro", null); context.container().select(".inspector-wrap").on("wheel.intro", null); - context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null); - context.container().select(".more-fields .combobox-input").on("click.intro", null); + context.container().select(".preset-list-button").on("click.intro", null); }; chapter.restart = function() { chapter.exit(); @@ -59345,34 +62548,38 @@ }; return utilRebind(chapter, dispatch14, "on"); } + var init_line2 = __esm({ + "modules/ui/intro/line.js"() { + "use strict"; + init_src4(); + init_src5(); + init_presets(); + init_localizer(); + init_geo2(); + init_browse(); + init_select5(); + init_rebind(); + init_helper(); + } + }); - // modules/ui/intro/line.js - function uiIntroLine(context, reveal) { + // modules/ui/intro/building.js + var building_exports = {}; + __export(building_exports, { + uiIntroBuilding: () => uiIntroBuilding + }); + function uiIntroBuilding(context, reveal) { var dispatch14 = dispatch_default("done"); + var house = [-85.62815, 41.95638]; + var tank = [-85.62732, 41.95347]; + var buildingCatetory = _mainPresetIndex.item("category-building"); + var housePreset = _mainPresetIndex.item("building/house"); + var tankPreset = _mainPresetIndex.item("man_made/storage_tank"); var timeouts = []; - var _tulipRoadID = null; - var flowerRoadID = "w646"; - var tulipRoadStart = [-85.6297754121684, 41.95805253325314]; - var tulipRoadMidpoint = [-85.62975395449628, 41.95787501510204]; - var tulipRoadIntersection = [-85.62974496187628, 41.95742515554585]; - var roadCategory = _mainPresetIndex.item("category-road_minor"); - var residentialPreset = _mainPresetIndex.item("highway/residential"); - var woodRoadID = "w525"; - var woodRoadEndID = "n2862"; - var woodRoadAddNode = [-85.62390110349587, 41.95397111462291]; - var woodRoadDragEndpoint = [-85.623867390213, 41.95466987786487]; - var woodRoadDragMidpoint = [-85.62386254803509, 41.95430395953872]; - var washingtonStreetID = "w522"; - var twelfthAvenueID = "w1"; - var eleventhAvenueEndID = "n3550"; - var twelfthAvenueEndID = "n5"; - var _washingtonSegmentID = null; - var eleventhAvenueEnd = context.entity(eleventhAvenueEndID).loc; - var twelfthAvenueEnd = context.entity(twelfthAvenueEndID).loc; - var deleteLinesLoc = [-85.6219395542764, 41.95228033922477]; - var twelfthAvenue = [-85.62219310052491, 41.952505413152956]; + var _houseID = null; + var _tankID = null; var chapter = { - title: "intro.lines.title" + title: "intro.buildings.title" }; function timeout2(f2, t2) { timeouts.push(window.setTimeout(f2, t2)); @@ -59381,223 +62588,212 @@ d3_event.stopPropagation(); d3_event.preventDefault(); } - function addLine() { + function revealHouse(center, text, options2) { + var padding = 160 * Math.pow(2, context.map().zoom() - 20); + var box = pad2(center, padding, context); + reveal(box, text, options2); + } + function revealTank(center, text, options2) { + var padding = 190 * Math.pow(2, context.map().zoom() - 19.5); + var box = pad2(center, padding, context); + reveal(box, text, options2); + } + function addHouse() { context.enter(modeBrowse(context)); context.history().reset("initial"); - var msec = transitionTime(tulipRoadStart, context.map().center()); + _houseID = null; + var msec = transitionTime(house, context.map().center()); if (msec) { reveal(null, null, { duration: 0 }); } - context.map().centerZoomEase(tulipRoadStart, 18.5, msec); + context.map().centerZoomEase(house, 19, msec); timeout2(function() { - var tooltip = reveal( - "button.add-line", - helpHtml("intro.lines.add_line") - ); - tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-lines"); - context.on("enter.intro", function(mode) { - if (mode.id !== "add-line") return; - continueTo(startLine); - }); - }, msec + 100); - function continueTo(nextStep) { - context.on("enter.intro", null); - nextStep(); - } - } - function startLine() { - if (context.mode().id !== "add-line") return chapter.restart(); - _tulipRoadID = null; - var padding = 70 * Math.pow(2, context.map().zoom() - 18); - var box = pad(tulipRoadStart, padding, context); - box.height = box.height + 100; - var textId = context.lastPointerType() === "mouse" ? "start_line" : "start_line_tap"; - var startLineString = helpHtml("intro.lines.missing_road") + "{br}" + helpHtml("intro.lines.line_draw_info") + helpHtml("intro.lines." + textId); - reveal(box, startLineString); - context.map().on("move.intro drawn.intro", function() { - padding = 70 * Math.pow(2, context.map().zoom() - 18); - box = pad(tulipRoadStart, padding, context); - box.height = box.height + 100; - reveal(box, startLineString, { duration: 0 }); - }); - context.on("enter.intro", function(mode) { - if (mode.id !== "draw-line") return chapter.restart(); - continueTo(drawLine); - }); + var tooltip = reveal( + "button.add-area", + helpHtml("intro.buildings.add_building") + ); + tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-buildings"); + context.on("enter.intro", function(mode) { + if (mode.id !== "add-area") return; + continueTo(startHouse); + }); + }, msec + 100); function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); context.on("enter.intro", null); nextStep(); } } - function drawLine() { - if (context.mode().id !== "draw-line") return chapter.restart(); - _tulipRoadID = context.mode().selectedIDs()[0]; - context.map().centerEase(tulipRoadMidpoint, 500); + function startHouse() { + if (context.mode().id !== "add-area") { + return continueTo(addHouse); + } + _houseID = null; + context.map().zoomEase(20, 500); timeout2(function() { - var padding = 200 * Math.pow(2, context.map().zoom() - 18.5); - var box = pad(tulipRoadMidpoint, padding, context); - box.height = box.height * 2; - reveal( - box, - helpHtml("intro.lines.intersect", { name: _t("intro.graph.name.flower-street") }) - ); + var startString = helpHtml("intro.buildings.start_building") + helpHtml("intro.buildings.building_corner_" + (context.lastPointerType() === "mouse" ? "click" : "tap")); + revealHouse(house, startString); context.map().on("move.intro drawn.intro", function() { - padding = 200 * Math.pow(2, context.map().zoom() - 18.5); - box = pad(tulipRoadMidpoint, padding, context); - box.height = box.height * 2; - reveal( - box, - helpHtml("intro.lines.intersect", { name: _t("intro.graph.name.flower-street") }), - { duration: 0 } - ); + revealHouse(house, startString, { duration: 0 }); + }); + context.on("enter.intro", function(mode) { + if (mode.id !== "draw-area") return chapter.restart(); + continueTo(continueHouse); }); }, 550); - context.history().on("change.intro", function() { - if (isLineConnected()) { - continueTo(continueLine); - } - }); - context.on("enter.intro", function(mode) { - if (mode.id === "draw-line") { - return; - } else if (mode.id === "select") { - continueTo(retryIntersect); - return; - } else { - return chapter.restart(); - } - }); function continueTo(nextStep) { context.map().on("move.intro drawn.intro", null); - context.history().on("change.intro", null); context.on("enter.intro", null); nextStep(); } } - function isLineConnected() { - var entity = _tulipRoadID && context.hasEntity(_tulipRoadID); - if (!entity) return false; - var drawNodes = context.graph().childNodes(entity); - return drawNodes.some(function(node) { - return context.graph().parentWays(node).some(function(parent) { - return parent.id === flowerRoadID; - }); + function continueHouse() { + if (context.mode().id !== "draw-area") { + return continueTo(addHouse); + } + _houseID = null; + var continueString = helpHtml("intro.buildings.continue_building") + "{br}" + helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.buildings.finish_building"); + revealHouse(house, continueString); + context.map().on("move.intro drawn.intro", function() { + revealHouse(house, continueString, { duration: 0 }); }); - } - function retryIntersect() { - select_default2(window).on("pointerdown.intro mousedown.intro", eventCancel, true); - var box = pad(tulipRoadIntersection, 80, context); - reveal( - box, - helpHtml("intro.lines.retry_intersect", { name: _t("intro.graph.name.flower-street") }) - ); - timeout2(chapter.restart, 3e3); - } - function continueLine() { - if (context.mode().id !== "draw-line") return chapter.restart(); - var entity = _tulipRoadID && context.hasEntity(_tulipRoadID); - if (!entity) return chapter.restart(); - context.map().centerEase(tulipRoadIntersection, 500); - var continueLineText = helpHtml("intro.lines.continue_line") + "{br}" + helpHtml("intro.lines.finish_line_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.lines.finish_road"); - reveal(".main-map .surface", continueLineText); context.on("enter.intro", function(mode) { - if (mode.id === "draw-line") { + if (mode.id === "draw-area") { return; } else if (mode.id === "select") { - return continueTo(chooseCategoryRoad); + var graph = context.graph(); + var way = context.entity(context.selectedIDs()[0]); + var nodes = graph.childNodes(way); + var points = utilArrayUniq(nodes).map(function(n3) { + return context.projection(n3.loc); + }); + if (isMostlySquare(points)) { + _houseID = way.id; + return continueTo(chooseCategoryBuilding); + } else { + return continueTo(retryHouse); + } } else { return chapter.restart(); } }); function continueTo(nextStep) { + context.map().on("move.intro drawn.intro", null); context.on("enter.intro", null); nextStep(); } } - function chooseCategoryRoad() { - if (context.mode().id !== "select") return chapter.restart(); - context.on("exit.intro", function() { - return chapter.restart(); + function retryHouse() { + var onClick = function() { + continueTo(addHouse); + }; + revealHouse( + house, + helpHtml("intro.buildings.retry_building"), + { buttonText: _t.html("intro.ok"), buttonCallback: onClick } + ); + context.map().on("move.intro drawn.intro", function() { + revealHouse( + house, + helpHtml("intro.buildings.retry_building"), + { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick } + ); }); - var button = context.container().select(".preset-category-road_minor .preset-list-button"); - if (button.empty()) return chapter.restart(); + function continueTo(nextStep) { + context.map().on("move.intro drawn.intro", null); + nextStep(); + } + } + function chooseCategoryBuilding() { + if (!_houseID || !context.hasEntity(_houseID)) { + return addHouse(); + } + var ids = context.selectedIDs(); + if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) { + context.enter(modeSelect(context, [_houseID])); + } context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); timeout2(function() { context.container().select(".inspector-wrap .panewrap").style("right", "-100%"); + var button = context.container().select(".preset-category-building .preset-list-button"); reveal( button.node(), - helpHtml("intro.lines.choose_category_road", { category: roadCategory.name() }) + helpHtml("intro.buildings.choose_category_building", { category: buildingCatetory.name() }) ); button.on("click.intro", function() { - continueTo(choosePresetResidential); + button.on("click.intro", null); + continueTo(choosePresetHouse); }); }, 400); + context.on("enter.intro", function(mode) { + if (!_houseID || !context.hasEntity(_houseID)) { + return continueTo(addHouse); + } + var ids2 = context.selectedIDs(); + if (mode.id !== "select" || !ids2.length || ids2[0] !== _houseID) { + return continueTo(chooseCategoryBuilding); + } + }); function continueTo(nextStep) { context.container().select(".inspector-wrap").on("wheel.intro", null); context.container().select(".preset-list-button").on("click.intro", null); - context.on("exit.intro", null); + context.on("enter.intro", null); nextStep(); } } - function choosePresetResidential() { - if (context.mode().id !== "select") return chapter.restart(); - context.on("exit.intro", function() { - return chapter.restart(); - }); - var subgrid = context.container().select(".preset-category-road_minor .subgrid"); - if (subgrid.empty()) return chapter.restart(); - subgrid.selectAll(":not(.preset-highway-residential) .preset-list-button").on("click.intro", function() { - continueTo(retryPresetResidential); - }); - subgrid.selectAll(".preset-highway-residential .preset-list-button").on("click.intro", function() { - continueTo(nameRoad); - }); - timeout2(function() { - reveal( - subgrid.node(), - helpHtml("intro.lines.choose_preset_residential", { preset: residentialPreset.name() }), - { tooltipBox: ".preset-highway-residential .preset-list-button", duration: 300 } - ); - }, 300); - function continueTo(nextStep) { - context.container().select(".preset-list-button").on("click.intro", null); - context.on("exit.intro", null); - nextStep(); + function choosePresetHouse() { + if (!_houseID || !context.hasEntity(_houseID)) { + return addHouse(); + } + var ids = context.selectedIDs(); + if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) { + context.enter(modeSelect(context, [_houseID])); } - } - function retryPresetResidential() { - if (context.mode().id !== "select") return chapter.restart(); - context.on("exit.intro", function() { - return chapter.restart(); - }); context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); timeout2(function() { - var button = context.container().select(".entity-editor-pane .preset-list-button"); + context.container().select(".inspector-wrap .panewrap").style("right", "-100%"); + var button = context.container().select(".preset-building-house .preset-list-button"); reveal( button.node(), - helpHtml("intro.lines.retry_preset_residential", { preset: residentialPreset.name() }) + helpHtml("intro.buildings.choose_preset_house", { preset: housePreset.name() }), + { duration: 300 } ); button.on("click.intro", function() { - continueTo(chooseCategoryRoad); + button.on("click.intro", null); + continueTo(closeEditorHouse); }); - }, 500); + }, 400); + context.on("enter.intro", function(mode) { + if (!_houseID || !context.hasEntity(_houseID)) { + return continueTo(addHouse); + } + var ids2 = context.selectedIDs(); + if (mode.id !== "select" || !ids2.length || ids2[0] !== _houseID) { + return continueTo(chooseCategoryBuilding); + } + }); function continueTo(nextStep) { context.container().select(".inspector-wrap").on("wheel.intro", null); context.container().select(".preset-list-button").on("click.intro", null); - context.on("exit.intro", null); + context.on("enter.intro", null); nextStep(); } } - function nameRoad() { + function closeEditorHouse() { + if (!_houseID || !context.hasEntity(_houseID)) { + return addHouse(); + } + var ids = context.selectedIDs(); + if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) { + context.enter(modeSelect(context, [_houseID])); + } + context.history().checkpoint("hasHouse"); context.on("exit.intro", function() { - continueTo(didNameRoad); + continueTo(rightClickHouse); }); timeout2(function() { reveal( ".entity-editor-pane", - helpHtml("intro.lines.name_road", { button: { html: icon("#iD-icon-close", "inline") } }), - { tooltipClass: "intro-lines-name_road" } + helpHtml("intro.buildings.close", { button: { html: icon("#iD-icon-close", "inline") } }) ); }, 500); function continueTo(nextStep) { @@ -59605,24681 +62801,31583 @@ nextStep(); } } - function didNameRoad() { - context.history().checkpoint("doneAddLine"); - timeout2(function() { - reveal(".main-map .surface", helpHtml("intro.lines.did_name_road"), { - buttonText: _t.html("intro.ok"), - buttonCallback: function() { - continueTo(updateLine); - } - }); - }, 500); - function continueTo(nextStep) { - nextStep(); - } - } - function updateLine() { - context.history().reset("doneAddLine"); - if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { - return chapter.restart(); - } - var msec = transitionTime(woodRoadDragMidpoint, context.map().center()); - if (msec) { - reveal(null, null, { duration: 0 }); + function rightClickHouse() { + if (!_houseID) return chapter.restart(); + context.enter(modeBrowse(context)); + context.history().reset("hasHouse"); + var zoom = context.map().zoom(); + if (zoom < 20) { + zoom = 20; } - context.map().centerZoomEase(woodRoadDragMidpoint, 19, msec); - timeout2(function() { - var padding = 250 * Math.pow(2, context.map().zoom() - 19); - var box = pad(woodRoadDragMidpoint, padding, context); - var advance = function() { - continueTo(addNode); - }; - reveal( - box, - helpHtml("intro.lines.update_line"), - { buttonText: _t.html("intro.ok"), buttonCallback: advance } - ); - context.map().on("move.intro drawn.intro", function() { - var padding2 = 250 * Math.pow(2, context.map().zoom() - 19); - var box2 = pad(woodRoadDragMidpoint, padding2, context); - reveal( - box2, - helpHtml("intro.lines.update_line"), - { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance } - ); - }); - }, msec + 100); + context.map().centerZoomEase(house, zoom, 500); + context.on("enter.intro", function(mode) { + if (mode.id !== "select") return; + var ids = context.selectedIDs(); + if (ids.length !== 1 || ids[0] !== _houseID) return; + timeout2(function() { + var node = selectMenuItem(context, "orthogonalize").node(); + if (!node) return; + continueTo(clickSquare); + }, 50); + }); + context.map().on("move.intro drawn.intro", function() { + var rightclickString = helpHtml("intro.buildings." + (context.lastPointerType() === "mouse" ? "rightclick_building" : "edit_menu_building_touch")); + revealHouse(house, rightclickString, { duration: 0 }); + }); + context.history().on("change.intro", function() { + continueTo(rightClickHouse); + }); function continueTo(nextStep) { + context.on("enter.intro", null); context.map().on("move.intro drawn.intro", null); + context.history().on("change.intro", null); nextStep(); } } - function addNode() { - context.history().reset("doneAddLine"); - if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { - return chapter.restart(); + function clickSquare() { + if (!_houseID) return chapter.restart(); + var entity = context.hasEntity(_houseID); + if (!entity) return continueTo(rightClickHouse); + var node = selectMenuItem(context, "orthogonalize").node(); + if (!node) { + return continueTo(rightClickHouse); } - var padding = 40 * Math.pow(2, context.map().zoom() - 19); - var box = pad(woodRoadAddNode, padding, context); - var addNodeString = helpHtml("intro.lines.add_node" + (context.lastPointerType() === "mouse" ? "" : "_touch")); - reveal(box, addNodeString); - context.map().on("move.intro drawn.intro", function() { - var padding2 = 40 * Math.pow(2, context.map().zoom() - 19); - var box2 = pad(woodRoadAddNode, padding2, context); - reveal(box2, addNodeString, { duration: 0 }); - }); - context.history().on("change.intro", function(changed) { - if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { - return continueTo(updateLine); - } - if (changed.created().length === 1) { - timeout2(function() { - continueTo(startDragEndpoint); - }, 500); + var wasChanged = false; + reveal( + ".edit-menu", + helpHtml("intro.buildings.square_building"), + { padding: 50 } + ); + context.on("enter.intro", function(mode) { + if (mode.id === "browse") { + continueTo(rightClickHouse); + } else if (mode.id === "move" || mode.id === "rotate") { + continueTo(retryClickSquare); } }); - context.on("enter.intro", function(mode) { - if (mode.id !== "select") { - continueTo(updateLine); + context.map().on("move.intro", function() { + var node2 = selectMenuItem(context, "orthogonalize").node(); + if (!wasChanged && !node2) { + return continueTo(rightClickHouse); } + reveal( + ".edit-menu", + helpHtml("intro.buildings.square_building"), + { duration: 0, padding: 50 } + ); }); - function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); + context.history().on("change.intro", function() { + wasChanged = true; context.history().on("change.intro", null); + timeout2(function() { + if (context.history().undoAnnotation() === _t("operations.orthogonalize.annotation.feature", { n: 1 })) { + continueTo(doneSquare); + } else { + continueTo(retryClickSquare); + } + }, 500); + }); + function continueTo(nextStep) { context.on("enter.intro", null); + context.map().on("move.intro", null); + context.history().on("change.intro", null); nextStep(); } } - function startDragEndpoint() { - if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { - return continueTo(updateLine); - } - var padding = 100 * Math.pow(2, context.map().zoom() - 19); - var box = pad(woodRoadDragEndpoint, padding, context); - var startDragString = helpHtml("intro.lines.start_drag_endpoint" + (context.lastPointerType() === "mouse" ? "" : "_touch")) + helpHtml("intro.lines.drag_to_intersection"); - reveal(box, startDragString); - context.map().on("move.intro drawn.intro", function() { - if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { - return continueTo(updateLine); - } - var padding2 = 100 * Math.pow(2, context.map().zoom() - 19); - var box2 = pad(woodRoadDragEndpoint, padding2, context); - reveal(box2, startDragString, { duration: 0 }); - var entity = context.entity(woodRoadEndID); - if (geoSphericalDistance(entity.loc, woodRoadDragEndpoint) <= 4) { - continueTo(finishDragEndpoint); + function retryClickSquare() { + context.enter(modeBrowse(context)); + revealHouse(house, helpHtml("intro.buildings.retry_square"), { + buttonText: _t.html("intro.ok"), + buttonCallback: function() { + continueTo(rightClickHouse); } }); function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); nextStep(); } } - function finishDragEndpoint() { - if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { - return continueTo(updateLine); - } - var padding = 100 * Math.pow(2, context.map().zoom() - 19); - var box = pad(woodRoadDragEndpoint, padding, context); - var finishDragString = helpHtml("intro.lines.spot_looks_good") + helpHtml("intro.lines.finish_drag_endpoint" + (context.lastPointerType() === "mouse" ? "" : "_touch")); - reveal(box, finishDragString); - context.map().on("move.intro drawn.intro", function() { - if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { - return continueTo(updateLine); - } - var padding2 = 100 * Math.pow(2, context.map().zoom() - 19); - var box2 = pad(woodRoadDragEndpoint, padding2, context); - reveal(box2, finishDragString, { duration: 0 }); - var entity = context.entity(woodRoadEndID); - if (geoSphericalDistance(entity.loc, woodRoadDragEndpoint) > 4) { - continueTo(startDragEndpoint); + function doneSquare() { + context.history().checkpoint("doneSquare"); + revealHouse(house, helpHtml("intro.buildings.done_square"), { + buttonText: _t.html("intro.ok"), + buttonCallback: function() { + continueTo(addTank); } }); - context.on("enter.intro", function() { - continueTo(startDragMidpoint); - }); function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); - context.on("enter.intro", null); nextStep(); } } - function startDragMidpoint() { - if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { - return continueTo(updateLine); + function addTank() { + context.enter(modeBrowse(context)); + context.history().reset("doneSquare"); + _tankID = null; + var msec = transitionTime(tank, context.map().center()); + if (msec) { + reveal(null, null, { duration: 0 }); } - if (context.selectedIDs().indexOf(woodRoadID) === -1) { - context.enter(modeSelect(context, [woodRoadID])); + context.map().centerZoomEase(tank, 19.5, msec); + timeout2(function() { + reveal( + "button.add-area", + helpHtml("intro.buildings.add_tank") + ); + context.on("enter.intro", function(mode) { + if (mode.id !== "add-area") return; + continueTo(startTank); + }); + }, msec + 100); + function continueTo(nextStep) { + context.on("enter.intro", null); + nextStep(); } - var padding = 80 * Math.pow(2, context.map().zoom() - 19); - var box = pad(woodRoadDragMidpoint, padding, context); - reveal(box, helpHtml("intro.lines.start_drag_midpoint")); - context.map().on("move.intro drawn.intro", function() { - if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { - return continueTo(updateLine); - } - var padding2 = 80 * Math.pow(2, context.map().zoom() - 19); - var box2 = pad(woodRoadDragMidpoint, padding2, context); - reveal(box2, helpHtml("intro.lines.start_drag_midpoint"), { duration: 0 }); - }); - context.history().on("change.intro", function(changed) { - if (changed.created().length === 1) { - continueTo(continueDragMidpoint); - } - }); - context.on("enter.intro", function(mode) { - if (mode.id !== "select") { - context.enter(modeSelect(context, [woodRoadID])); - } - }); + } + function startTank() { + if (context.mode().id !== "add-area") { + return continueTo(addTank); + } + _tankID = null; + timeout2(function() { + var startString = helpHtml("intro.buildings.start_tank") + helpHtml("intro.buildings.tank_edge_" + (context.lastPointerType() === "mouse" ? "click" : "tap")); + revealTank(tank, startString); + context.map().on("move.intro drawn.intro", function() { + revealTank(tank, startString, { duration: 0 }); + }); + context.on("enter.intro", function(mode) { + if (mode.id !== "draw-area") return chapter.restart(); + continueTo(continueTank); + }); + }, 550); function continueTo(nextStep) { context.map().on("move.intro drawn.intro", null); - context.history().on("change.intro", null); context.on("enter.intro", null); nextStep(); } } - function continueDragMidpoint() { - if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { - return continueTo(updateLine); + function continueTank() { + if (context.mode().id !== "draw-area") { + return continueTo(addTank); } - var padding = 100 * Math.pow(2, context.map().zoom() - 19); - var box = pad(woodRoadDragEndpoint, padding, context); - box.height += 400; - var advance = function() { - context.history().checkpoint("doneUpdateLine"); - continueTo(deleteLines); - }; - reveal( - box, - helpHtml("intro.lines.continue_drag_midpoint"), - { buttonText: _t.html("intro.ok"), buttonCallback: advance } - ); + _tankID = null; + var continueString = helpHtml("intro.buildings.continue_tank") + "{br}" + helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.buildings.finish_tank"); + revealTank(tank, continueString); context.map().on("move.intro drawn.intro", function() { - if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) { - return continueTo(updateLine); - } - var padding2 = 100 * Math.pow(2, context.map().zoom() - 19); - var box2 = pad(woodRoadDragEndpoint, padding2, context); - box2.height += 400; - reveal( - box2, - helpHtml("intro.lines.continue_drag_midpoint"), - { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance } - ); + revealTank(tank, continueString, { duration: 0 }); + }); + context.on("enter.intro", function(mode) { + if (mode.id === "draw-area") { + return; + } else if (mode.id === "select") { + _tankID = context.selectedIDs()[0]; + return continueTo(searchPresetTank); + } else { + return continueTo(addTank); + } }); function continueTo(nextStep) { context.map().on("move.intro drawn.intro", null); + context.on("enter.intro", null); nextStep(); } } - function deleteLines() { - context.history().reset("doneUpdateLine"); - context.enter(modeBrowse(context)); - if (!context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { - return chapter.restart(); + function searchPresetTank() { + if (!_tankID || !context.hasEntity(_tankID)) { + return addTank(); } - var msec = transitionTime(deleteLinesLoc, context.map().center()); - if (msec) { - reveal(null, null, { duration: 0 }); + var ids = context.selectedIDs(); + if (context.mode().id !== "select" || !ids.length || ids[0] !== _tankID) { + context.enter(modeSelect(context, [_tankID])); } - context.map().centerZoomEase(deleteLinesLoc, 18, msec); + context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); timeout2(function() { - var padding = 200 * Math.pow(2, context.map().zoom() - 18); - var box = pad(deleteLinesLoc, padding, context); - box.top -= 200; - box.height += 400; - var advance = function() { - continueTo(rightClickIntersection); - }; + context.container().select(".inspector-wrap .panewrap").style("right", "-100%"); + context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch); reveal( - box, - helpHtml("intro.lines.delete_lines", { street: _t("intro.graph.name.12th-avenue") }), - { buttonText: _t.html("intro.ok"), buttonCallback: advance } + ".preset-search-input", + helpHtml("intro.buildings.search_tank", { preset: tankPreset.name() }) ); - context.map().on("move.intro drawn.intro", function() { - var padding2 = 200 * Math.pow(2, context.map().zoom() - 18); - var box2 = pad(deleteLinesLoc, padding2, context); - box2.top -= 200; - box2.height += 400; + }, 400); + context.on("enter.intro", function(mode) { + if (!_tankID || !context.hasEntity(_tankID)) { + return continueTo(addTank); + } + var ids2 = context.selectedIDs(); + if (mode.id !== "select" || !ids2.length || ids2[0] !== _tankID) { + context.enter(modeSelect(context, [_tankID])); + context.container().select(".inspector-wrap .panewrap").style("right", "-100%"); + context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); + context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch); reveal( - box2, - helpHtml("intro.lines.delete_lines", { street: _t("intro.graph.name.12th-avenue") }), - { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance } + ".preset-search-input", + helpHtml("intro.buildings.search_tank", { preset: tankPreset.name() }) ); - }); - context.history().on("change.intro", function() { - timeout2(function() { - continueTo(deleteLines); - }, 500); - }); - }, msec + 100); + context.history().on("change.intro", null); + } + }); + function checkPresetSearch() { + var first = context.container().select(".preset-list-item:first-child"); + if (first.classed("preset-man_made-storage_tank")) { + reveal( + first.select(".preset-list-button").node(), + helpHtml("intro.buildings.choose_tank", { preset: tankPreset.name() }), + { duration: 300 } + ); + context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null); + context.history().on("change.intro", function() { + continueTo(closeEditorTank); + }); + } + } function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); + context.container().select(".inspector-wrap").on("wheel.intro", null); + context.on("enter.intro", null); context.history().on("change.intro", null); + context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null); nextStep(); } } - function rightClickIntersection() { - context.history().reset("doneUpdateLine"); + function closeEditorTank() { + if (!_tankID || !context.hasEntity(_tankID)) { + return addTank(); + } + var ids = context.selectedIDs(); + if (context.mode().id !== "select" || !ids.length || ids[0] !== _tankID) { + context.enter(modeSelect(context, [_tankID])); + } + context.history().checkpoint("hasTank"); + context.on("exit.intro", function() { + continueTo(rightClickTank); + }); + timeout2(function() { + reveal( + ".entity-editor-pane", + helpHtml("intro.buildings.close", { button: { html: icon("#iD-icon-close", "inline") } }) + ); + }, 500); + function continueTo(nextStep) { + context.on("exit.intro", null); + nextStep(); + } + } + function rightClickTank() { + if (!_tankID) return continueTo(addTank); context.enter(modeBrowse(context)); - context.map().centerZoomEase(eleventhAvenueEnd, 18, 500); - var rightClickString = helpHtml("intro.lines.split_street", { - street1: _t("intro.graph.name.11th-avenue"), - street2: _t("intro.graph.name.washington-street") - }) + helpHtml("intro.lines." + (context.lastPointerType() === "mouse" ? "rightclick_intersection" : "edit_menu_intersection_touch")); + context.history().reset("hasTank"); + context.map().centerEase(tank, 500); timeout2(function() { - var padding = 60 * Math.pow(2, context.map().zoom() - 18); - var box = pad(eleventhAvenueEnd, padding, context); - reveal(box, rightClickString); - context.map().on("move.intro drawn.intro", function() { - var padding2 = 60 * Math.pow(2, context.map().zoom() - 18); - var box2 = pad(eleventhAvenueEnd, padding2, context); - reveal( - box2, - rightClickString, - { duration: 0 } - ); - }); context.on("enter.intro", function(mode) { if (mode.id !== "select") return; var ids = context.selectedIDs(); - if (ids.length !== 1 || ids[0] !== eleventhAvenueEndID) return; + if (ids.length !== 1 || ids[0] !== _tankID) return; timeout2(function() { - var node = selectMenuItem(context, "split").node(); + var node = selectMenuItem(context, "circularize").node(); if (!node) return; - continueTo(splitIntersection); + continueTo(clickCircle); }, 50); }); + var rightclickString = helpHtml("intro.buildings." + (context.lastPointerType() === "mouse" ? "rightclick_tank" : "edit_menu_tank_touch")); + revealTank(tank, rightclickString); + context.map().on("move.intro drawn.intro", function() { + revealTank(tank, rightclickString, { duration: 0 }); + }); context.history().on("change.intro", function() { - timeout2(function() { - continueTo(deleteLines); - }, 300); + continueTo(rightClickTank); }); }, 600); function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); context.on("enter.intro", null); + context.map().on("move.intro drawn.intro", null); context.history().on("change.intro", null); nextStep(); } } - function splitIntersection() { - if (!context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { - return continueTo(deleteLines); - } - var node = selectMenuItem(context, "split").node(); + function clickCircle() { + if (!_tankID) return chapter.restart(); + var entity = context.hasEntity(_tankID); + if (!entity) return continueTo(rightClickTank); + var node = selectMenuItem(context, "circularize").node(); if (!node) { - return continueTo(rightClickIntersection); + return continueTo(rightClickTank); } var wasChanged = false; - _washingtonSegmentID = null; reveal( ".edit-menu", - helpHtml( - "intro.lines.split_intersection", - { street: _t("intro.graph.name.washington-street") } - ), + helpHtml("intro.buildings.circle_tank"), { padding: 50 } ); - context.map().on("move.intro drawn.intro", function() { - var node2 = selectMenuItem(context, "split").node(); + context.on("enter.intro", function(mode) { + if (mode.id === "browse") { + continueTo(rightClickTank); + } else if (mode.id === "move" || mode.id === "rotate") { + continueTo(retryClickCircle); + } + }); + context.map().on("move.intro", function() { + var node2 = selectMenuItem(context, "circularize").node(); if (!wasChanged && !node2) { - return continueTo(rightClickIntersection); + return continueTo(rightClickTank); } reveal( ".edit-menu", - helpHtml( - "intro.lines.split_intersection", - { street: _t("intro.graph.name.washington-street") } - ), + helpHtml("intro.buildings.circle_tank"), { duration: 0, padding: 50 } ); }); - context.history().on("change.intro", function(changed) { + context.history().on("change.intro", function() { wasChanged = true; + context.history().on("change.intro", null); timeout2(function() { - if (context.history().undoAnnotation() === _t("operations.split.annotation.line", { n: 1 })) { - _washingtonSegmentID = changed.created()[0].id; - continueTo(didSplit); + if (context.history().undoAnnotation() === _t("operations.circularize.annotation.feature", { n: 1 })) { + continueTo(play); } else { - _washingtonSegmentID = null; - continueTo(retrySplit); + continueTo(retryClickCircle); } - }, 300); + }, 500); }); function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); + context.on("enter.intro", null); + context.map().on("move.intro", null); context.history().on("change.intro", null); nextStep(); } } - function retrySplit() { + function retryClickCircle() { context.enter(modeBrowse(context)); - context.map().centerZoomEase(eleventhAvenueEnd, 18, 500); - var advance = function() { - continueTo(rightClickIntersection); - }; - var padding = 60 * Math.pow(2, context.map().zoom() - 18); - var box = pad(eleventhAvenueEnd, padding, context); - reveal( - box, - helpHtml("intro.lines.retry_split"), - { buttonText: _t.html("intro.ok"), buttonCallback: advance } - ); - context.map().on("move.intro drawn.intro", function() { - var padding2 = 60 * Math.pow(2, context.map().zoom() - 18); - var box2 = pad(eleventhAvenueEnd, padding2, context); - reveal( - box2, - helpHtml("intro.lines.retry_split"), - { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance } - ); + revealTank(tank, helpHtml("intro.buildings.retry_circle"), { + buttonText: _t.html("intro.ok"), + buttonCallback: function() { + continueTo(rightClickTank); + } }); function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); nextStep(); } } - function didSplit() { - if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { - return continueTo(rightClickIntersection); - } - var ids = context.selectedIDs(); - var string = "intro.lines.did_split_" + (ids.length > 1 ? "multi" : "single"); - var street = _t("intro.graph.name.washington-street"); - var padding = 200 * Math.pow(2, context.map().zoom() - 18); - var box = pad(twelfthAvenue, padding, context); - box.width = box.width / 2; + function play() { + dispatch14.call("done"); reveal( - box, - helpHtml(string, { street1: street, street2: street }), - { duration: 500 } + ".ideditor", + helpHtml("intro.buildings.play", { next: _t("intro.startediting.title") }), + { + tooltipBox: ".intro-nav-wrap .chapter-startEditing", + buttonText: _t.html("intro.ok"), + buttonCallback: function() { + reveal(".ideditor"); + } + } ); - timeout2(function() { - context.map().centerZoomEase(twelfthAvenue, 18, 500); - context.map().on("move.intro drawn.intro", function() { - var padding2 = 200 * Math.pow(2, context.map().zoom() - 18); - var box2 = pad(twelfthAvenue, padding2, context); - box2.width = box2.width / 2; - reveal( - box2, - helpHtml(string, { street1: street, street2: street }), - { duration: 0 } - ); + } + chapter.enter = function() { + addHouse(); + }; + chapter.exit = function() { + timeouts.forEach(window.clearTimeout); + context.on("enter.intro exit.intro", null); + context.map().on("move.intro drawn.intro", null); + context.history().on("change.intro", null); + context.container().select(".inspector-wrap").on("wheel.intro", null); + context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null); + context.container().select(".more-fields .combobox-input").on("click.intro", null); + }; + chapter.restart = function() { + chapter.exit(); + chapter.enter(); + }; + return utilRebind(chapter, dispatch14, "on"); + } + var init_building = __esm({ + "modules/ui/intro/building.js"() { + "use strict"; + init_src4(); + init_presets(); + init_localizer(); + init_browse(); + init_select5(); + init_util(); + init_helper(); + } + }); + + // modules/ui/intro/start_editing.js + var start_editing_exports = {}; + __export(start_editing_exports, { + uiIntroStartEditing: () => uiIntroStartEditing + }); + function uiIntroStartEditing(context, reveal) { + var dispatch14 = dispatch_default("done", "startEditing"); + var modalSelection = select_default2(null); + var chapter = { + title: "intro.startediting.title" + }; + function showHelp() { + reveal( + ".map-control.help-control", + helpHtml("intro.startediting.help"), + { + buttonText: _t.html("intro.ok"), + buttonCallback: function() { + shortcuts(); + } + } + ); + } + function shortcuts() { + reveal( + ".map-control.help-control", + helpHtml("intro.startediting.shortcuts"), + { + buttonText: _t.html("intro.ok"), + buttonCallback: function() { + showSave(); + } + } + ); + } + function showSave() { + context.container().selectAll(".shaded").remove(); + reveal( + ".top-toolbar button.save", + helpHtml("intro.startediting.save"), + { + buttonText: _t.html("intro.ok"), + buttonCallback: function() { + showStart(); + } + } + ); + } + function showStart() { + context.container().selectAll(".shaded").remove(); + modalSelection = uiModal(context.container()); + modalSelection.select(".modal").attr("class", "modal-splash modal"); + modalSelection.selectAll(".close").remove(); + var startbutton = modalSelection.select(".content").attr("class", "fillL").append("button").attr("class", "modal-section huge-modal-button").on("click", function() { + modalSelection.remove(); + }); + startbutton.append("svg").attr("class", "illustration").append("use").attr("xlink:href", "#iD-logo-walkthrough"); + startbutton.append("h2").call(_t.append("intro.startediting.start")); + dispatch14.call("startEditing"); + } + chapter.enter = function() { + showHelp(); + }; + chapter.exit = function() { + modalSelection.remove(); + context.container().selectAll(".shaded").remove(); + }; + return utilRebind(chapter, dispatch14, "on"); + } + var init_start_editing = __esm({ + "modules/ui/intro/start_editing.js"() { + "use strict"; + init_src4(); + init_src5(); + init_localizer(); + init_helper(); + init_modal(); + init_rebind(); + } + }); + + // modules/ui/intro/intro.js + var intro_exports = {}; + __export(intro_exports, { + uiIntro: () => uiIntro + }); + function uiIntro(context) { + const INTRO_IMAGERY = "EsriWorldImageryClarity"; + let _introGraph = {}; + let _currChapter; + function intro(selection2) { + _mainFileFetcher.get("intro_graph").then((dataIntroGraph) => { + for (let id2 in dataIntroGraph) { + if (!_introGraph[id2]) { + _introGraph[id2] = osmEntity(localize(dataIntroGraph[id2])); + } + } + selection2.call(startIntro); + }).catch(function() { + }); + } + function startIntro(selection2) { + context.enter(modeBrowse(context)); + let osm = context.connection(); + let history = context.history().toJSON(); + let hash2 = window.location.hash; + let center = context.map().center(); + let zoom = context.map().zoom(); + let background = context.background().baseLayerSource(); + let overlays = context.background().overlayLayerSources(); + let opacity = context.container().selectAll(".main-map .layer-background").style("opacity"); + let caches = osm && osm.caches(); + let baseEntities = context.history().graph().base().entities; + context.ui().sidebar.expand(); + context.container().selectAll("button.sidebar-toggle").classed("disabled", true); + context.inIntro(true); + if (osm) { + osm.toggle(false).reset(); + } + context.history().reset(); + context.history().merge(Object.values(coreGraph().load(_introGraph).entities)); + context.history().checkpoint("initial"); + let imagery = context.background().findSource(INTRO_IMAGERY); + if (imagery) { + context.background().baseLayerSource(imagery); + } else { + context.background().bing(); + } + overlays.forEach((d2) => context.background().toggleOverlayLayer(d2)); + let layers = context.layers(); + layers.all().forEach((item) => { + if (typeof item.layer.enabled === "function") { + item.layer.enabled(item.id === "osm"); + } + }); + context.container().selectAll(".main-map .layer-background").style("opacity", 1); + let curtain = uiCurtain(context.container().node()); + selection2.call(curtain); + corePreferences("walkthrough_started", "yes"); + let storedProgress = corePreferences("walkthrough_progress") || ""; + let progress = storedProgress.split(";").filter(Boolean); + let chapters = chapterFlow.map((chapter, i3) => { + let s2 = chapterUi[chapter](context, curtain.reveal).on("done", () => { + buttons.filter((d2) => d2.title === s2.title).classed("finished", true); + if (i3 < chapterFlow.length - 1) { + const next = chapterFlow[i3 + 1]; + context.container().select(`button.chapter-${next}`).classed("next", true); + } + progress.push(chapter); + corePreferences("walkthrough_progress", utilArrayUniq(progress).join(";")); + }); + return s2; + }); + chapters[chapters.length - 1].on("startEditing", () => { + progress.push("startEditing"); + corePreferences("walkthrough_progress", utilArrayUniq(progress).join(";")); + let incomplete = utilArrayDifference(chapterFlow, progress); + if (!incomplete.length) { + corePreferences("walkthrough_completed", "yes"); + } + curtain.remove(); + navwrap.remove(); + context.container().selectAll(".main-map .layer-background").style("opacity", opacity); + context.container().selectAll("button.sidebar-toggle").classed("disabled", false); + if (osm) { + osm.toggle(true).reset().caches(caches); + } + context.history().reset().merge(Object.values(baseEntities)); + context.background().baseLayerSource(background); + overlays.forEach((d2) => context.background().toggleOverlayLayer(d2)); + if (history) { + context.history().fromJSON(history, false); + } + context.map().centerZoom(center, zoom); + window.location.replace(hash2); + context.inIntro(false); + }); + let navwrap = selection2.append("div").attr("class", "intro-nav-wrap fillD"); + navwrap.append("svg").attr("class", "intro-nav-wrap-logo").append("use").attr("xlink:href", "#iD-logo-walkthrough"); + let buttonwrap = navwrap.append("div").attr("class", "joined").selectAll("button.chapter"); + let buttons = buttonwrap.data(chapters).enter().append("button").attr("class", (d2, i3) => `chapter chapter-${chapterFlow[i3]}`).on("click", enterChapter); + buttons.append("span").html((d2) => _t.html(d2.title)); + buttons.append("span").attr("class", "status").call(svgIcon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward", "inline")); + enterChapter(null, chapters[0]); + function enterChapter(d3_event, newChapter) { + if (_currChapter) { + _currChapter.exit(); + } + context.enter(modeBrowse(context)); + _currChapter = newChapter; + _currChapter.enter(); + buttons.classed("next", false).classed("active", (d2) => d2.title === _currChapter.title); + } + } + return intro; + } + var chapterUi, chapterFlow; + var init_intro = __esm({ + "modules/ui/intro/intro.js"() { + "use strict"; + init_localizer(); + init_helper(); + init_preferences(); + init_file_fetcher(); + init_graph(); + init_browse(); + init_entity(); + init_icon(); + init_curtain(); + init_util(); + init_welcome(); + init_navigation(); + init_point(); + init_area4(); + init_line2(); + init_building(); + init_start_editing(); + chapterUi = { + welcome: uiIntroWelcome, + navigation: uiIntroNavigation, + point: uiIntroPoint, + area: uiIntroArea, + line: uiIntroLine, + building: uiIntroBuilding, + startEditing: uiIntroStartEditing + }; + chapterFlow = [ + "welcome", + "navigation", + "point", + "area", + "line", + "building", + "startEditing" + ]; + } + }); + + // modules/ui/intro/index.js + var intro_exports2 = {}; + __export(intro_exports2, { + uiIntro: () => uiIntro + }); + var init_intro2 = __esm({ + "modules/ui/intro/index.js"() { + "use strict"; + init_intro(); + } + }); + + // modules/ui/issues_info.js + var issues_info_exports = {}; + __export(issues_info_exports, { + uiIssuesInfo: () => uiIssuesInfo + }); + function uiIssuesInfo(context) { + var warningsItem = { + id: "warnings", + count: 0, + iconID: "iD-icon-alert", + descriptionID: "issues.warnings_and_errors" + }; + var resolvedItem = { + id: "resolved", + count: 0, + iconID: "iD-icon-apply", + descriptionID: "issues.user_resolved_issues" + }; + function update(selection2) { + var shownItems = []; + var liveIssues = context.validator().getIssues({ + what: corePreferences("validate-what") || "edited", + where: corePreferences("validate-where") || "all" + }); + if (liveIssues.length) { + warningsItem.count = liveIssues.length; + shownItems.push(warningsItem); + } + if (corePreferences("validate-what") === "all") { + var resolvedIssues = context.validator().getResolvedIssues(); + if (resolvedIssues.length) { + resolvedItem.count = resolvedIssues.length; + shownItems.push(resolvedItem); + } + } + var chips = selection2.selectAll(".chip").data(shownItems, function(d2) { + return d2.id; + }); + chips.exit().remove(); + var enter = chips.enter().append("a").attr("class", function(d2) { + return "chip " + d2.id + "-count"; + }).attr("href", "#").each(function(d2) { + var chipSelection = select_default2(this); + var tooltipBehavior = uiTooltip().placement("top").title(() => _t.append(d2.descriptionID)); + chipSelection.call(tooltipBehavior).on("click", function(d3_event) { + d3_event.preventDefault(); + tooltipBehavior.hide(select_default2(this)); + context.ui().togglePanes(context.container().select(".map-panes .issues-pane")); }); - }, 600); - context.on("enter.intro", function() { - var ids2 = context.selectedIDs(); - if (ids2.length === 1 && ids2[0] === _washingtonSegmentID) { - continueTo(multiSelect2); - } + chipSelection.call(svgIcon("#" + d2.iconID)); }); - context.history().on("change.intro", function() { - if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { - return continueTo(rightClickIntersection); - } + enter.append("span").attr("class", "count"); + enter.merge(chips).selectAll("span.count").text(function(d2) { + return d2.count.toString(); }); - function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); - context.on("enter.intro", null); - context.history().on("change.intro", null); - nextStep(); - } } - function multiSelect2() { - if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { - return continueTo(rightClickIntersection); + return function(selection2) { + update(selection2); + context.validator().on("validated.infobox", function() { + update(selection2); + }); + }; + } + var init_issues_info = __esm({ + "modules/ui/issues_info.js"() { + "use strict"; + init_src5(); + init_preferences(); + init_icon(); + init_localizer(); + init_tooltip(); + } + }); + + // modules/util/IntervalTasksQueue.js + var IntervalTasksQueue_exports = {}; + __export(IntervalTasksQueue_exports, { + IntervalTasksQueue: () => IntervalTasksQueue + }); + var IntervalTasksQueue; + var init_IntervalTasksQueue = __esm({ + "modules/util/IntervalTasksQueue.js"() { + "use strict"; + IntervalTasksQueue = class { + /** + * Interval in milliseconds inside which only 1 task can execute. + * e.g. if interval is 200ms, and 5 async tasks are unqueued, + * they will complete in ~1s if not cleared + * @param {number} intervalInMs + */ + constructor(intervalInMs) { + this.intervalInMs = intervalInMs; + this.pendingHandles = []; + this.time = 0; + } + enqueue(task) { + let taskTimeout = this.time; + this.time += this.intervalInMs; + this.pendingHandles.push(setTimeout(() => { + this.time -= this.intervalInMs; + task(); + }, taskTimeout)); + } + clear() { + this.pendingHandles.forEach((timeoutHandle) => { + clearTimeout(timeoutHandle); + }); + this.pendingHandles = []; + this.time = 0; + } + }; + } + }); + + // modules/renderer/background_source.js + var background_source_exports = {}; + __export(background_source_exports, { + rendererBackgroundSource: () => rendererBackgroundSource + }); + function localeDateString(s2) { + if (!s2) return null; + var options2 = { day: "numeric", month: "short", year: "numeric" }; + var d2 = new Date(s2); + if (isNaN(d2.getTime())) return null; + return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2); + } + function vintageRange(vintage) { + var s2; + if (vintage.start || vintage.end) { + s2 = vintage.start || "?"; + if (vintage.start !== vintage.end) { + s2 += " - " + (vintage.end || "?"); } - var ids = context.selectedIDs(); - var hasWashington = ids.indexOf(_washingtonSegmentID) !== -1; - var hasTwelfth = ids.indexOf(twelfthAvenueID) !== -1; - if (hasWashington && hasTwelfth) { - return continueTo(multiRightClick); - } else if (!hasWashington && !hasTwelfth) { - return continueTo(didSplit); + } + return s2; + } + function rendererBackgroundSource(data) { + var source = Object.assign({}, data); + var _offset = [0, 0]; + var _name = source.name; + var _description = source.description; + var _best = !!source.best; + var _template = source.encrypted ? utilAesDecrypt(source.template) : source.template; + source.tileSize = data.tileSize || 256; + source.zoomExtent = data.zoomExtent || [0, 22]; + source.overzoom = data.overzoom !== false; + source.offset = function(val) { + if (!arguments.length) return _offset; + _offset = val; + return source; + }; + source.nudge = function(val, zoomlevel) { + _offset[0] += val[0] / Math.pow(2, zoomlevel); + _offset[1] += val[1] / Math.pow(2, zoomlevel); + return source; + }; + source.name = function() { + var id_safe = source.id.replace(/\./g, ""); + return _t("imagery." + id_safe + ".name", { default: (0, import_lodash4.escape)(_name) }); + }; + source.label = function() { + var id_safe = source.id.replace(/\./g, ""); + return _t.append("imagery." + id_safe + ".name", { default: (0, import_lodash4.escape)(_name) }); + }; + source.hasDescription = function() { + var id_safe = source.id.replace(/\./g, ""); + var descriptionText = _mainLocalizer.tInfo("imagery." + id_safe + ".description", { default: (0, import_lodash4.escape)(_description) }).text; + return descriptionText !== ""; + }; + source.description = function() { + var id_safe = source.id.replace(/\./g, ""); + return _t.append("imagery." + id_safe + ".description", { default: (0, import_lodash4.escape)(_description) }); + }; + source.best = function() { + return _best; + }; + source.area = function() { + if (!data.polygon) return Number.MAX_VALUE; + var area = area_default({ type: "MultiPolygon", coordinates: [data.polygon] }); + return isNaN(area) ? 0 : area; + }; + source.imageryUsed = function() { + return _name || source.id; + }; + source.template = function(val) { + if (!arguments.length) return _template; + if (source.id === "custom" || source.id === "Bing") { + _template = val; } - context.map().centerZoomEase(twelfthAvenue, 18, 500); - timeout2(function() { - var selected, other2, padding, box; - if (hasWashington) { - selected = _t("intro.graph.name.washington-street"); - other2 = _t("intro.graph.name.12th-avenue"); - padding = 60 * Math.pow(2, context.map().zoom() - 18); - box = pad(twelfthAvenueEnd, padding, context); - box.width *= 3; - } else { - selected = _t("intro.graph.name.12th-avenue"); - other2 = _t("intro.graph.name.washington-street"); - padding = 200 * Math.pow(2, context.map().zoom() - 18); - box = pad(twelfthAvenue, padding, context); - box.width /= 2; + return source; + }; + source.url = function(coord2) { + var result = _template.replace(/#[\s\S]*/u, ""); + if (result === "") return result; + if (!source.type || source.id === "custom") { + if (/SERVICE=WMS|\{(proj|wkid|bbox)\}/.test(result)) { + source.type = "wms"; + source.projection = "EPSG:3857"; + } else if (/\{(x|y)\}/.test(result)) { + source.type = "tms"; + } else if (/\{u\}/.test(result)) { + source.type = "bing"; } - reveal( - box, - helpHtml( - "intro.lines.multi_select", - { selected, other1: other2 } - ) + " " + helpHtml( - "intro.lines.add_to_selection_" + (context.lastPointerType() === "mouse" ? "click" : "touch"), - { selected, other2 } - ) - ); - context.map().on("move.intro drawn.intro", function() { - if (hasWashington) { - selected = _t("intro.graph.name.washington-street"); - other2 = _t("intro.graph.name.12th-avenue"); - padding = 60 * Math.pow(2, context.map().zoom() - 18); - box = pad(twelfthAvenueEnd, padding, context); - box.width *= 3; - } else { - selected = _t("intro.graph.name.12th-avenue"); - other2 = _t("intro.graph.name.washington-street"); - padding = 200 * Math.pow(2, context.map().zoom() - 18); - box = pad(twelfthAvenue, padding, context); - box.width /= 2; + } + if (source.type === "wms") { + var tileToProjectedCoords = function(x2, y2, z2) { + var zoomSize = Math.pow(2, z2); + var lon = x2 / zoomSize * Math.PI * 2 - Math.PI; + var lat = Math.atan(Math.sinh(Math.PI * (1 - 2 * y2 / zoomSize))); + switch (source.projection) { + case "EPSG:4326": + return { + x: lon * 180 / Math.PI, + y: lat * 180 / Math.PI + }; + default: + var mercCoords = mercatorRaw(lon, lat); + return { + x: 2003750834e-2 / Math.PI * mercCoords[0], + y: 2003750834e-2 / Math.PI * mercCoords[1] + }; + } + }; + var tileSize = source.tileSize; + var projection2 = source.projection; + var minXmaxY = tileToProjectedCoords(coord2[0], coord2[1], coord2[2]); + var maxXminY = tileToProjectedCoords(coord2[0] + 1, coord2[1] + 1, coord2[2]); + result = result.replace(/\{(\w+)\}/g, function(token, key) { + switch (key) { + case "width": + case "height": + return tileSize; + case "proj": + return projection2; + case "wkid": + return projection2.replace(/^EPSG:/, ""); + case "bbox": + if (projection2 === "EPSG:4326" && // The CRS parameter implies version 1.3 (prior versions use SRS) + /VERSION=1.3|CRS={proj}/.test(source.template().toUpperCase())) { + return maxXminY.y + "," + minXmaxY.x + "," + minXmaxY.y + "," + maxXminY.x; + } else { + return minXmaxY.x + "," + maxXminY.y + "," + maxXminY.x + "," + minXmaxY.y; + } + case "w": + return minXmaxY.x; + case "s": + return maxXminY.y; + case "n": + return maxXminY.x; + case "e": + return minXmaxY.y; + default: + return token; } - reveal( - box, - helpHtml( - "intro.lines.multi_select", - { selected, other1: other2 } - ) + " " + helpHtml( - "intro.lines.add_to_selection_" + (context.lastPointerType() === "mouse" ? "click" : "touch"), - { selected, other2 } - ), - { duration: 0 } - ); - }); - context.on("enter.intro", function() { - continueTo(multiSelect2); }); - context.history().on("change.intro", function() { - if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { - return continueTo(rightClickIntersection); + } else if (source.type === "tms") { + result = result.replace("{x}", coord2[0]).replace("{y}", coord2[1]).replace(/\{[t-]y\}/, Math.pow(2, coord2[2]) - coord2[1] - 1).replace(/\{z(oom)?\}/, coord2[2]).replace(/\{@2x\}|\{r\}/, isRetina ? "@2x" : ""); + } else if (source.type === "bing") { + result = result.replace("{u}", function() { + var u2 = ""; + for (var zoom = coord2[2]; zoom > 0; zoom--) { + var b2 = 0; + var mask = 1 << zoom - 1; + if ((coord2[0] & mask) !== 0) b2++; + if ((coord2[1] & mask) !== 0) b2 += 2; + u2 += b2.toString(); } + return u2; }); - }, 600); - function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); - context.on("enter.intro", null); - context.history().on("change.intro", null); - nextStep(); } - } - function multiRightClick() { - if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { - return continueTo(rightClickIntersection); - } - var padding = 200 * Math.pow(2, context.map().zoom() - 18); - var box = pad(twelfthAvenue, padding, context); - var rightClickString = helpHtml("intro.lines.multi_select_success") + helpHtml("intro.lines.multi_" + (context.lastPointerType() === "mouse" ? "rightclick" : "edit_menu_touch")); - reveal(box, rightClickString); - context.map().on("move.intro drawn.intro", function() { - var padding2 = 200 * Math.pow(2, context.map().zoom() - 18); - var box2 = pad(twelfthAvenue, padding2, context); - reveal(box2, rightClickString, { duration: 0 }); + result = result.replace(/\{switch:([^}]+)\}/, function(s2, r2) { + var subdomains = r2.split(","); + return subdomains[(coord2[0] + coord2[1]) % subdomains.length]; }); - context.ui().editMenu().on("toggled.intro", function(open) { - if (!open) return; - timeout2(function() { - var ids = context.selectedIDs(); - if (ids.length === 2 && ids.indexOf(twelfthAvenueID) !== -1 && ids.indexOf(_washingtonSegmentID) !== -1) { - var node = selectMenuItem(context, "delete").node(); - if (!node) return; - continueTo(multiDelete); - } else if (ids.length === 1 && ids.indexOf(_washingtonSegmentID) !== -1) { - return continueTo(multiSelect2); - } else { - return continueTo(didSplit); + return result; + }; + source.validZoom = function(z2, underzoom) { + if (underzoom === void 0) underzoom = 0; + return source.zoomExtent[0] - underzoom <= z2 && (source.overzoom || source.zoomExtent[1] > z2); + }; + source.isLocatorOverlay = function() { + return source.id === "mapbox_locator_overlay"; + }; + source.isHidden = function() { + return source.id === "DigitalGlobe-Premium-vintage" || source.id === "DigitalGlobe-Standard-vintage"; + }; + source.copyrightNotices = function() { + }; + source.getMetadata = function(center, tileCoord, callback) { + var vintage = { + start: localeDateString(source.startDate), + end: localeDateString(source.endDate) + }; + vintage.range = vintageRange(vintage); + var metadata = { vintage }; + callback(null, metadata); + }; + return source; + } + var import_lodash4, isRetina, _a2; + var init_background_source = __esm({ + "modules/renderer/background_source.js"() { + "use strict"; + init_src2(); + init_src18(); + import_lodash4 = __toESM(require_lodash()); + init_localizer(); + init_geo2(); + init_util(); + init_aes(); + init_IntervalTasksQueue(); + isRetina = window.devicePixelRatio && window.devicePixelRatio >= 2; + (_a2 = window.matchMedia) == null ? void 0 : _a2.call(window, ` + (-webkit-min-device-pixel-ratio: 2), /* Safari */ + (min-resolution: 2dppx), /* standard */ + (min-resolution: 192dpi) /* fallback */ + `).addListener(function() { + isRetina = window.devicePixelRatio && window.devicePixelRatio >= 2; + }); + rendererBackgroundSource.Bing = function(data, dispatch14) { + data.template = "https://ecn.t{switch:0,1,2,3}.tiles.virtualearth.net/tiles/a{u}.jpeg?g=1&pr=odbl&n=z"; + var bing = rendererBackgroundSource(data); + var key = utilAesDecrypt("5c875730b09c6b422433e807e1ff060b6536c791dbfffcffc4c6b18a1bdba1f14593d151adb50e19e1be1ab19aef813bf135d0f103475e5c724dec94389e45d0"); + const strictParam = "n"; + var url = "https://dev.virtualearth.net/REST/v1/Imagery/Metadata/AerialOSM?include=ImageryProviders&uriScheme=https&key=" + key; + var cache = {}; + var inflight = {}; + var providers = []; + var taskQueue = new IntervalTasksQueue(250); + var metadataLastZoom = -1; + json_default(url).then(function(json) { + let imageryResource = json.resourceSets[0].resources[0]; + let template = imageryResource.imageUrl; + let subDomains = imageryResource.imageUrlSubdomains; + let subDomainNumbers = subDomains.map((subDomain) => { + return subDomain.substring(1); + }).join(","); + template = template.replace("{subdomain}", `t{switch:${subDomainNumbers}}`).replace("{quadkey}", "{u}"); + if (!new URLSearchParams(template).has(strictParam)) { + template += `&${strictParam}=z`; + } + bing.template(template); + providers = imageryResource.imageryProviders.map(function(provider) { + return { + attribution: provider.attribution, + areas: provider.coverageAreas.map(function(area) { + return { + zoom: [area.zoomMin, area.zoomMax], + extent: geoExtent([area.bbox[1], area.bbox[0]], [area.bbox[3], area.bbox[2]]) + }; + }) + }; + }); + dispatch14.call("change"); + }).catch(function() { + }); + bing.copyrightNotices = function(zoom, extent) { + zoom = Math.min(zoom, 21); + return providers.filter(function(provider) { + return provider.areas.some(function(area) { + return extent.intersects(area.extent) && area.zoom[0] <= zoom && area.zoom[1] >= zoom; + }); + }).map(function(provider) { + return provider.attribution; + }).join(", "); + }; + bing.getMetadata = function(center, tileCoord, callback) { + var tileID = tileCoord.slice(0, 3).join("/"); + var zoom = Math.min(tileCoord[2], 21); + var centerPoint = center[1] + "," + center[0]; + var url2 = "https://dev.virtualearth.net/REST/v1/Imagery/BasicMetadata/AerialOSM/" + centerPoint + "?zl=" + zoom + "&key=" + key; + if (inflight[tileID]) return; + if (!cache[tileID]) { + cache[tileID] = {}; + } + if (cache[tileID] && cache[tileID].metadata) { + return callback(null, cache[tileID].metadata); + } + inflight[tileID] = true; + if (metadataLastZoom !== tileCoord[2]) { + metadataLastZoom = tileCoord[2]; + taskQueue.clear(); + } + taskQueue.enqueue(() => { + json_default(url2).then(function(result) { + delete inflight[tileID]; + if (!result) { + throw new Error("Unknown Error"); + } + var vintage = { + start: localeDateString(result.resourceSets[0].resources[0].vintageStart), + end: localeDateString(result.resourceSets[0].resources[0].vintageEnd) + }; + vintage.range = vintageRange(vintage); + var metadata = { vintage }; + cache[tileID].metadata = metadata; + if (callback) callback(null, metadata); + }).catch(function(err) { + delete inflight[tileID]; + if (callback) callback(err.message); + }); + }); + }; + bing.terms_url = "https://blog.openstreetmap.org/2010/11/30/microsoft-imagery-details"; + return bing; + }; + rendererBackgroundSource.Esri = function(data) { + if (data.template.match(/blankTile/) === null) { + data.template = data.template + "?blankTile=false"; + } + var esri = rendererBackgroundSource(data); + var cache = {}; + var inflight = {}; + var _prevCenter; + esri.fetchTilemap = function(center) { + if (_prevCenter && geoSphericalDistance(center, _prevCenter) < 5e3) return; + _prevCenter = center; + var z2 = 20; + var dummyUrl = esri.url([1, 2, 3]); + var x2 = Math.floor((center[0] + 180) / 360 * Math.pow(2, z2)); + var y2 = Math.floor((1 - Math.log(Math.tan(center[1] * Math.PI / 180) + 1 / Math.cos(center[1] * Math.PI / 180)) / Math.PI) / 2 * Math.pow(2, z2)); + var tilemapUrl = dummyUrl.replace(/tile\/[0-9]+\/[0-9]+\/[0-9]+\?blankTile=false/, "tilemap") + "/" + z2 + "/" + y2 + "/" + x2 + "/8/8"; + json_default(tilemapUrl).then(function(tilemap) { + if (!tilemap) { + throw new Error("Unknown Error"); + } + var hasTiles = true; + for (var i3 = 0; i3 < tilemap.data.length; i3++) { + if (!tilemap.data[i3]) { + hasTiles = false; + break; + } + } + esri.zoomExtent[1] = hasTiles ? 22 : 19; + }).catch(function() { + }); + }; + esri.getMetadata = function(center, tileCoord, callback) { + if (esri.id !== "EsriWorldImagery") { + return callback(null, {}); + } + var tileID = tileCoord.slice(0, 3).join("/"); + var zoom = Math.min(tileCoord[2], esri.zoomExtent[1]); + var centerPoint = center[0] + "," + center[1]; + var unknown = _t("info_panels.background.unknown"); + var vintage = {}; + var metadata = {}; + if (inflight[tileID]) return; + var url = "https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/4/query"; + url += "?returnGeometry=false&geometry=" + centerPoint + "&inSR=4326&geometryType=esriGeometryPoint&outFields=*&f=json"; + if (!cache[tileID]) { + cache[tileID] = {}; + } + if (cache[tileID] && cache[tileID].metadata) { + return callback(null, cache[tileID].metadata); + } + inflight[tileID] = true; + json_default(url).then(function(result) { + delete inflight[tileID]; + 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) { + throw new Error("No Results"); + } else if (result.error && result.error.message) { + throw new Error(result.error.message); + } + var captureDate = localeDateString(result.SRC_DATE2); + vintage = { + start: captureDate, + end: captureDate, + range: captureDate + }; + metadata = { + vintage, + source: clean2(result.NICE_NAME), + description: clean2(result.NICE_DESC), + resolution: clean2(+Number(result.SRC_RES).toFixed(4)), + accuracy: clean2(+Number(result.SRC_ACC).toFixed(4)) + }; + if (isFinite(metadata.resolution)) { + metadata.resolution += " m"; + } + if (isFinite(metadata.accuracy)) { + metadata.accuracy += " m"; + } + cache[tileID].metadata = metadata; + if (callback) callback(null, metadata); + }).catch(function(err) { + delete inflight[tileID]; + if (callback) callback(err.message); + }); + function clean2(val) { + return String(val).trim() || unknown; } - }, 300); - }); - context.history().on("change.intro", function() { - if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { - return continueTo(rightClickIntersection); - } - }); - function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); - context.ui().editMenu().on("toggled.intro", null); - context.history().on("change.intro", null); - nextStep(); - } + }; + return esri; + }; + rendererBackgroundSource.None = function() { + var source = rendererBackgroundSource({ id: "none", template: "" }); + source.name = function() { + return _t("background.none"); + }; + source.label = function() { + return _t.append("background.none"); + }; + source.imageryUsed = function() { + return null; + }; + source.area = function() { + return -1; + }; + return source; + }; + rendererBackgroundSource.Custom = function(template) { + var source = rendererBackgroundSource({ id: "custom", template }); + source.name = function() { + return _t("background.custom"); + }; + source.label = function() { + return _t.append("background.custom"); + }; + source.imageryUsed = function() { + var cleaned = source.template(); + if (cleaned.indexOf("?") !== -1) { + var parts = cleaned.split("?", 2); + var qs = utilStringQs(parts[1]); + ["access_token", "connectId", "token", "Signature"].forEach(function(param) { + if (qs[param]) { + qs[param] = "{apikey}"; + } + }); + cleaned = parts[0] + "?" + utilQsString(qs, true); + } + cleaned = cleaned.replace(/token\/(\w+)/, "token/{apikey}").replace(/key=(\w+)/, "key={apikey}"); + return "Custom (" + cleaned + " )"; + }; + source.area = function() { + return -2; + }; + return source; + }; } - function multiDelete() { - if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) { - return continueTo(rightClickIntersection); - } - var node = selectMenuItem(context, "delete").node(); - if (!node) return continueTo(multiRightClick); - reveal( - ".edit-menu", - helpHtml("intro.lines.multi_delete"), - { padding: 50 } - ); - context.map().on("move.intro drawn.intro", function() { - reveal( - ".edit-menu", - helpHtml("intro.lines.multi_delete"), - { duration: 0, padding: 50 } + }); + + // node_modules/@turf/helpers/dist/esm/index.js + function feature2(geom, properties, options2 = {}) { + const feat = { type: "Feature" }; + if (options2.id === 0 || options2.id) { + feat.id = options2.id; + } + if (options2.bbox) { + feat.bbox = options2.bbox; + } + feat.properties = properties || {}; + feat.geometry = geom; + return feat; + } + function polygon(coordinates, properties, options2 = {}) { + for (const ring of coordinates) { + if (ring.length < 4) { + throw new Error( + "Each LinearRing of a Polygon must have 4 or more Positions." ); - }); - context.on("exit.intro", function() { - if (context.hasEntity(_washingtonSegmentID) || context.hasEntity(twelfthAvenueID)) { - return continueTo(multiSelect2); - } - }); - context.history().on("change.intro", function() { - if (context.hasEntity(_washingtonSegmentID) || context.hasEntity(twelfthAvenueID)) { - continueTo(retryDelete); - } else { - continueTo(play); - } - }); - function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); - context.on("exit.intro", null); - context.history().on("change.intro", null); - nextStep(); } - } - function retryDelete() { - context.enter(modeBrowse(context)); - var padding = 200 * Math.pow(2, context.map().zoom() - 18); - var box = pad(twelfthAvenue, padding, context); - reveal(box, helpHtml("intro.lines.retry_delete"), { - buttonText: _t.html("intro.ok"), - buttonCallback: function() { - continueTo(multiSelect2); - } - }); - function continueTo(nextStep) { - nextStep(); + if (ring[ring.length - 1].length !== ring[0].length) { + throw new Error("First and last Position are not equivalent."); } - } - function play() { - dispatch14.call("done"); - reveal( - ".ideditor", - helpHtml("intro.lines.play", { next: _t("intro.buildings.title") }), - { - tooltipBox: ".intro-nav-wrap .chapter-building", - buttonText: _t.html("intro.ok"), - buttonCallback: function() { - reveal(".ideditor"); - } + for (let 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."); } - ); + } } - chapter.enter = function() { - addLine(); - }; - chapter.exit = function() { - timeouts.forEach(window.clearTimeout); - select_default2(window).on("pointerdown.intro mousedown.intro", null, true); - context.on("enter.intro exit.intro", null); - context.map().on("move.intro drawn.intro", null); - context.history().on("change.intro", null); - context.container().select(".inspector-wrap").on("wheel.intro", null); - context.container().select(".preset-list-button").on("click.intro", null); + const geom = { + type: "Polygon", + coordinates }; - chapter.restart = function() { - chapter.exit(); - chapter.enter(); + return feature2(geom, properties, options2); + } + function lineString(coordinates, properties, options2 = {}) { + if (coordinates.length < 2) { + throw new Error("coordinates must be an array of two or more positions"); + } + const geom = { + type: "LineString", + coordinates }; - return utilRebind(chapter, dispatch14, "on"); + return feature2(geom, properties, options2); } - - // modules/ui/intro/building.js - function uiIntroBuilding(context, reveal) { - var dispatch14 = dispatch_default("done"); - var house = [-85.62815, 41.95638]; - var tank = [-85.62732, 41.95347]; - var buildingCatetory = _mainPresetIndex.item("category-building"); - var housePreset = _mainPresetIndex.item("building/house"); - var tankPreset = _mainPresetIndex.item("man_made/storage_tank"); - var timeouts = []; - var _houseID = null; - var _tankID = null; - var chapter = { - title: "intro.buildings.title" + function multiLineString(coordinates, properties, options2 = {}) { + const geom = { + type: "MultiLineString", + coordinates }; - function timeout2(f2, t2) { - timeouts.push(window.setTimeout(f2, t2)); - } - function eventCancel(d3_event) { - d3_event.stopPropagation(); - d3_event.preventDefault(); - } - function revealHouse(center, text, options2) { - var padding = 160 * Math.pow(2, context.map().zoom() - 20); - var box = pad(center, padding, context); - reveal(box, text, 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, text, options2); + return feature2(geom, properties, options2); + } + function multiPolygon(coordinates, properties, options2 = {}) { + const geom = { + type: "MultiPolygon", + coordinates + }; + return feature2(geom, properties, options2); + } + var earthRadius, factors; + var init_esm3 = __esm({ + "node_modules/@turf/helpers/dist/esm/index.js"() { + earthRadius = 63710088e-1; + factors = { + centimeters: earthRadius * 100, + centimetres: earthRadius * 100, + degrees: 360 / (2 * Math.PI), + feet: earthRadius * 3.28084, + inches: earthRadius * 39.37, + kilometers: earthRadius / 1e3, + kilometres: earthRadius / 1e3, + meters: earthRadius, + metres: earthRadius, + miles: earthRadius / 1609.344, + millimeters: earthRadius * 1e3, + millimetres: earthRadius * 1e3, + nauticalmiles: earthRadius / 1852, + radians: 1, + yards: earthRadius * 1.0936 + }; } - function addHouse() { - context.enter(modeBrowse(context)); - context.history().reset("initial"); - _houseID = null; - var msec = transitionTime(house, context.map().center()); - if (msec) { - reveal(null, null, { duration: 0 }); - } - context.map().centerZoomEase(house, 19, msec); - timeout2(function() { - var tooltip = reveal( - "button.add-area", - helpHtml("intro.buildings.add_building") - ); - tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-buildings"); - context.on("enter.intro", function(mode) { - if (mode.id !== "add-area") return; - continueTo(startHouse); - }); - }, msec + 100); - function continueTo(nextStep) { - context.on("enter.intro", null); - nextStep(); - } + }); + + // node_modules/@turf/invariant/dist/esm/index.js + function getGeom(geojson) { + if (geojson.type === "Feature") { + return geojson.geometry; } - function startHouse() { - if (context.mode().id !== "add-area") { - return continueTo(addHouse); - } - _houseID = null; - context.map().zoomEase(20, 500); - timeout2(function() { - var startString = helpHtml("intro.buildings.start_building") + helpHtml("intro.buildings.building_corner_" + (context.lastPointerType() === "mouse" ? "click" : "tap")); - revealHouse(house, startString); - context.map().on("move.intro drawn.intro", function() { - revealHouse(house, startString, { duration: 0 }); - }); - context.on("enter.intro", function(mode) { - if (mode.id !== "draw-area") return chapter.restart(); - continueTo(continueHouse); - }); - }, 550); - function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); - context.on("enter.intro", null); - nextStep(); - } + return geojson; + } + var init_esm4 = __esm({ + "node_modules/@turf/invariant/dist/esm/index.js"() { } - function continueHouse() { - if (context.mode().id !== "draw-area") { - return continueTo(addHouse); - } - _houseID = null; - var continueString = helpHtml("intro.buildings.continue_building") + "{br}" + helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.buildings.finish_building"); - revealHouse(house, continueString); - context.map().on("move.intro drawn.intro", function() { - revealHouse(house, continueString, { duration: 0 }); - }); - context.on("enter.intro", function(mode) { - if (mode.id === "draw-area") { - return; - } else if (mode.id === "select") { - var graph = context.graph(); - var way = context.entity(context.selectedIDs()[0]); - var nodes = graph.childNodes(way); - var points = utilArrayUniq(nodes).map(function(n3) { - return context.projection(n3.loc); - }); - if (isMostlySquare(points)) { - _houseID = way.id; - return continueTo(chooseCategoryBuilding); - } else { - return continueTo(retryHouse); + }); + + // node_modules/@turf/bbox-clip/dist/esm/index.js + function lineclip(points, bbox2, result) { + var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i3, codeB, lastCode; + let a2; + let b2; + if (!result) result = []; + for (i3 = 1; i3 < len; i3++) { + a2 = points[i3 - 1]; + b2 = points[i3]; + codeB = lastCode = bitCode(b2, bbox2); + while (true) { + if (!(codeA | codeB)) { + part.push(a2); + if (codeB !== lastCode) { + part.push(b2); + if (i3 < len - 1) { + result.push(part); + part = []; + } + } else if (i3 === len - 1) { + part.push(b2); } + break; + } else if (codeA & codeB) { + break; + } else if (codeA) { + a2 = intersect(a2, b2, codeA, bbox2); + codeA = bitCode(a2, bbox2); } else { - return chapter.restart(); + b2 = intersect(a2, b2, codeB, bbox2); + codeB = bitCode(b2, bbox2); } - }); - function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); - context.on("enter.intro", null); - nextStep(); } + codeA = lastCode; } - function retryHouse() { - var onClick = function() { - continueTo(addHouse); - }; - revealHouse( - house, - helpHtml("intro.buildings.retry_building"), - { buttonText: _t.html("intro.ok"), buttonCallback: onClick } - ); - context.map().on("move.intro drawn.intro", function() { - revealHouse( - house, - helpHtml("intro.buildings.retry_building"), - { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick } - ); - }); - function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); - nextStep(); + if (part.length) result.push(part); + return result; + } + function polygonclip(points, bbox2) { + var result, edge, prev, prevInside, i3, p2, inside; + for (edge = 1; edge <= 8; edge *= 2) { + result = []; + prev = points[points.length - 1]; + prevInside = !(bitCode(prev, bbox2) & edge); + for (i3 = 0; i3 < points.length; i3++) { + p2 = points[i3]; + inside = !(bitCode(p2, bbox2) & edge); + if (inside !== prevInside) result.push(intersect(prev, p2, edge, bbox2)); + if (inside) result.push(p2); + prev = p2; + prevInside = inside; } + points = result; + if (!points.length) break; } - function chooseCategoryBuilding() { - if (!_houseID || !context.hasEntity(_houseID)) { - return addHouse(); - } - var ids = context.selectedIDs(); - if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) { - context.enter(modeSelect(context, [_houseID])); - } - context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); - timeout2(function() { - context.container().select(".inspector-wrap .panewrap").style("right", "-100%"); - var button = context.container().select(".preset-category-building .preset-list-button"); - reveal( - button.node(), - helpHtml("intro.buildings.choose_category_building", { category: buildingCatetory.name() }) - ); - button.on("click.intro", function() { - button.on("click.intro", null); - continueTo(choosePresetHouse); - }); - }, 400); - context.on("enter.intro", function(mode) { - if (!_houseID || !context.hasEntity(_houseID)) { - return continueTo(addHouse); + return result; + } + function intersect(a2, b2, edge, bbox2) { + return edge & 8 ? [a2[0] + (b2[0] - a2[0]) * (bbox2[3] - a2[1]) / (b2[1] - a2[1]), bbox2[3]] : edge & 4 ? [a2[0] + (b2[0] - a2[0]) * (bbox2[1] - a2[1]) / (b2[1] - a2[1]), bbox2[1]] : edge & 2 ? [bbox2[2], a2[1] + (b2[1] - a2[1]) * (bbox2[2] - a2[0]) / (b2[0] - a2[0])] : edge & 1 ? [bbox2[0], a2[1] + (b2[1] - a2[1]) * (bbox2[0] - a2[0]) / (b2[0] - a2[0])] : null; + } + function bitCode(p2, bbox2) { + var code = 0; + if (p2[0] < bbox2[0]) code |= 1; + else if (p2[0] > bbox2[2]) code |= 2; + if (p2[1] < bbox2[1]) code |= 4; + else if (p2[1] > bbox2[3]) code |= 8; + return code; + } + function bboxClip(feature3, bbox2) { + const geom = getGeom(feature3); + const type2 = geom.type; + const properties = feature3.type === "Feature" ? feature3.properties : {}; + let coords = geom.coordinates; + switch (type2) { + case "LineString": + case "MultiLineString": { + const lines = []; + if (type2 === "LineString") { + coords = [coords]; } - var ids2 = context.selectedIDs(); - if (mode.id !== "select" || !ids2.length || ids2[0] !== _houseID) { - return continueTo(chooseCategoryBuilding); + coords.forEach((line) => { + lineclip(line, bbox2, lines); + }); + if (lines.length === 1) { + return lineString(lines[0], properties); } - }); - function continueTo(nextStep) { - context.container().select(".inspector-wrap").on("wheel.intro", null); - context.container().select(".preset-list-button").on("click.intro", null); - context.on("enter.intro", null); - nextStep(); - } - } - function choosePresetHouse() { - if (!_houseID || !context.hasEntity(_houseID)) { - return addHouse(); - } - var ids = context.selectedIDs(); - if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) { - context.enter(modeSelect(context, [_houseID])); + return multiLineString(lines, properties); } - context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); - timeout2(function() { - context.container().select(".inspector-wrap .panewrap").style("right", "-100%"); - var button = context.container().select(".preset-building-house .preset-list-button"); - reveal( - button.node(), - helpHtml("intro.buildings.choose_preset_house", { preset: housePreset.name() }), - { duration: 300 } + case "Polygon": + return polygon(clipPolygon(coords, bbox2), properties); + case "MultiPolygon": + return multiPolygon( + coords.map((poly) => { + return clipPolygon(poly, bbox2); + }), + properties ); - button.on("click.intro", function() { - button.on("click.intro", null); - continueTo(closeEditorHouse); - }); - }, 400); - context.on("enter.intro", function(mode) { - if (!_houseID || !context.hasEntity(_houseID)) { - return continueTo(addHouse); + default: + throw new Error("geometry " + type2 + " not supported"); + } + } + function clipPolygon(rings, bbox2) { + const outRings = []; + for (const ring of rings) { + const clipped = polygonclip(ring, bbox2); + if (clipped.length > 0) { + if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) { + clipped.push(clipped[0]); } - var ids2 = context.selectedIDs(); - if (mode.id !== "select" || !ids2.length || ids2[0] !== _houseID) { - return continueTo(chooseCategoryBuilding); + if (clipped.length >= 4) { + outRings.push(clipped); } - }); - function continueTo(nextStep) { - context.container().select(".inspector-wrap").on("wheel.intro", null); - context.container().select(".preset-list-button").on("click.intro", null); - context.on("enter.intro", null); - nextStep(); } } - function closeEditorHouse() { - if (!_houseID || !context.hasEntity(_houseID)) { - return addHouse(); - } - var ids = context.selectedIDs(); - if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) { - context.enter(modeSelect(context, [_houseID])); - } - context.history().checkpoint("hasHouse"); - context.on("exit.intro", function() { - continueTo(rightClickHouse); - }); - timeout2(function() { - reveal( - ".entity-editor-pane", - helpHtml("intro.buildings.close", { button: { html: icon("#iD-icon-close", "inline") } }) - ); - }, 500); - function continueTo(nextStep) { - context.on("exit.intro", null); - nextStep(); + return outRings; + } + var turf_bbox_clip_default; + var init_esm5 = __esm({ + "node_modules/@turf/bbox-clip/dist/esm/index.js"() { + init_esm3(); + init_esm4(); + turf_bbox_clip_default = bboxClip; + } + }); + + // node_modules/@turf/meta/dist/esm/index.js + function coordEach(geojson, callback, excludeWrapCoord) { + if (geojson === null) return; + 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; + stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1; + for (var geomIndex = 0; geomIndex < stopG; geomIndex++) { + var multiFeatureIndex = 0; + var geometryIndex = 0; + geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection; + if (geometry === null) continue; + coords = geometry.coordinates; + var geomType = geometry.type; + wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0; + switch (geomType) { + case null: + break; + case "Point": + if (callback( + coords, + coordIndex, + featureIndex, + multiFeatureIndex, + geometryIndex + ) === false) + return false; + coordIndex++; + multiFeatureIndex++; + break; + case "LineString": + case "MultiPoint": + for (j2 = 0; j2 < coords.length; j2++) { + if (callback( + coords[j2], + coordIndex, + featureIndex, + multiFeatureIndex, + geometryIndex + ) === false) + return false; + coordIndex++; + if (geomType === "MultiPoint") multiFeatureIndex++; + } + if (geomType === "LineString") multiFeatureIndex++; + break; + case "Polygon": + case "MultiLineString": + for (j2 = 0; j2 < coords.length; j2++) { + for (k2 = 0; k2 < coords[j2].length - wrapShrink; k2++) { + if (callback( + coords[j2][k2], + coordIndex, + featureIndex, + multiFeatureIndex, + geometryIndex + ) === false) + return false; + coordIndex++; + } + if (geomType === "MultiLineString") multiFeatureIndex++; + if (geomType === "Polygon") geometryIndex++; + } + if (geomType === "Polygon") multiFeatureIndex++; + break; + case "MultiPolygon": + for (j2 = 0; j2 < coords.length; j2++) { + geometryIndex = 0; + for (k2 = 0; k2 < coords[j2].length; k2++) { + for (l2 = 0; l2 < coords[j2][k2].length - wrapShrink; l2++) { + if (callback( + coords[j2][k2][l2], + coordIndex, + featureIndex, + multiFeatureIndex, + geometryIndex + ) === false) + return false; + coordIndex++; + } + geometryIndex++; + } + multiFeatureIndex++; + } + break; + case "GeometryCollection": + for (j2 = 0; j2 < geometry.geometries.length; j2++) + if (coordEach(geometry.geometries[j2], callback, excludeWrapCoord) === false) + return false; + break; + default: + throw new Error("Unknown Geometry Type"); + } } } - function rightClickHouse() { - if (!_houseID) return chapter.restart(); - context.enter(modeBrowse(context)); - context.history().reset("hasHouse"); - var zoom = context.map().zoom(); - if (zoom < 20) { - zoom = 20; + } + var init_esm6 = __esm({ + "node_modules/@turf/meta/dist/esm/index.js"() { + } + }); + + // node_modules/@turf/bbox/dist/esm/index.js + function bbox(geojson, options2 = {}) { + if (geojson.bbox != null && true !== options2.recompute) { + return geojson.bbox; + } + const result = [Infinity, Infinity, -Infinity, -Infinity]; + coordEach(geojson, (coord2) => { + if (result[0] > coord2[0]) { + result[0] = coord2[0]; } - context.map().centerZoomEase(house, zoom, 500); - context.on("enter.intro", function(mode) { - if (mode.id !== "select") return; - var ids = context.selectedIDs(); - if (ids.length !== 1 || ids[0] !== _houseID) return; - timeout2(function() { - var node = selectMenuItem(context, "orthogonalize").node(); - if (!node) return; - continueTo(clickSquare); - }, 50); - }); - context.map().on("move.intro drawn.intro", function() { - var rightclickString = helpHtml("intro.buildings." + (context.lastPointerType() === "mouse" ? "rightclick_building" : "edit_menu_building_touch")); - revealHouse(house, rightclickString, { duration: 0 }); - }); - context.history().on("change.intro", function() { - continueTo(rightClickHouse); - }); - function continueTo(nextStep) { - context.on("enter.intro", null); - context.map().on("move.intro drawn.intro", null); - context.history().on("change.intro", null); - nextStep(); + if (result[1] > coord2[1]) { + result[1] = coord2[1]; } - } - function clickSquare() { - if (!_houseID) return chapter.restart(); - var entity = context.hasEntity(_houseID); - if (!entity) return continueTo(rightClickHouse); - var node = selectMenuItem(context, "orthogonalize").node(); - if (!node) { - return continueTo(rightClickHouse); + if (result[2] < coord2[0]) { + result[2] = coord2[0]; } - var wasChanged = false; - reveal( - ".edit-menu", - helpHtml("intro.buildings.square_building"), - { padding: 50 } - ); - context.on("enter.intro", function(mode) { - if (mode.id === "browse") { - continueTo(rightClickHouse); - } else if (mode.id === "move" || mode.id === "rotate") { - continueTo(retryClickSquare); - } - }); - context.map().on("move.intro", function() { - var node2 = selectMenuItem(context, "orthogonalize").node(); - if (!wasChanged && !node2) { - return continueTo(rightClickHouse); - } - reveal( - ".edit-menu", - helpHtml("intro.buildings.square_building"), - { duration: 0, padding: 50 } - ); - }); - context.history().on("change.intro", function() { - wasChanged = true; - context.history().on("change.intro", null); - timeout2(function() { - if (context.history().undoAnnotation() === _t("operations.orthogonalize.annotation.feature", { n: 1 })) { - continueTo(doneSquare); - } else { - continueTo(retryClickSquare); - } - }, 500); - }); - function continueTo(nextStep) { - context.on("enter.intro", null); - context.map().on("move.intro", null); - context.history().on("change.intro", null); - nextStep(); + if (result[3] < coord2[1]) { + result[3] = coord2[1]; } + }); + return result; + } + var turf_bbox_default; + var init_esm7 = __esm({ + "node_modules/@turf/bbox/dist/esm/index.js"() { + init_esm6(); + turf_bbox_default = bbox; + } + }); + + // modules/renderer/tile_layer.js + var tile_layer_exports = {}; + __export(tile_layer_exports, { + rendererTileLayer: () => rendererTileLayer + }); + function rendererTileLayer(context) { + var transformProp = utilPrefixCSSProperty("Transform"); + var tiler8 = utilTiler(); + var _tileSize = 256; + var _projection; + var _cache5 = {}; + var _tileOrigin; + var _zoom; + var _source; + var _underzoom = 0; + function tileSizeAtZoom(d2, z2) { + return d2.tileSize * Math.pow(2, z2 - d2[2]) / d2.tileSize; } - function retryClickSquare() { - context.enter(modeBrowse(context)); - revealHouse(house, helpHtml("intro.buildings.retry_square"), { - buttonText: _t.html("intro.ok"), - buttonCallback: function() { - continueTo(rightClickHouse); + function atZoom(t2, distance) { + var power = Math.pow(2, distance); + return [ + Math.floor(t2[0] * power), + Math.floor(t2[1] * power), + t2[2] + distance + ]; + } + function lookUp(d2) { + for (var up = -1; up > -d2[2]; up--) { + var tile = atZoom(d2, up); + if (_cache5[_source.url(tile)] !== false) { + return tile; } - }); - function continueTo(nextStep) { - nextStep(); } } - function doneSquare() { - context.history().checkpoint("doneSquare"); - revealHouse(house, helpHtml("intro.buildings.done_square"), { - buttonText: _t.html("intro.ok"), - buttonCallback: function() { - continueTo(addTank); + function uniqueBy(a2, n3) { + var o2 = []; + var seen = {}; + for (var i3 = 0; i3 < a2.length; i3++) { + if (seen[a2[i3][n3]] === void 0) { + o2.push(a2[i3]); + seen[a2[i3][n3]] = true; } - }); - function continueTo(nextStep) { - nextStep(); } + return o2; } - function addTank() { - context.enter(modeBrowse(context)); - context.history().reset("doneSquare"); - _tankID = null; - var msec = transitionTime(tank, context.map().center()); - if (msec) { - reveal(null, null, { duration: 0 }); - } - context.map().centerZoomEase(tank, 19.5, msec); - timeout2(function() { - reveal( - "button.add-area", - helpHtml("intro.buildings.add_tank") - ); - context.on("enter.intro", function(mode) { - if (mode.id !== "add-area") return; - continueTo(startTank); - }); - }, msec + 100); - function continueTo(nextStep) { - context.on("enter.intro", null); - nextStep(); - } + function addSource(d2) { + d2.url = _source.url(d2); + d2.tileSize = _tileSize; + d2.source = _source; + return d2; } - function startTank() { - if (context.mode().id !== "add-area") { - return continueTo(addTank); + function background(selection2) { + _zoom = geoScaleToZoom(_projection.scale(), _tileSize); + var pixelOffset; + if (_source) { + pixelOffset = [ + _source.offset()[0] * Math.pow(2, _zoom), + _source.offset()[1] * Math.pow(2, _zoom) + ]; + } else { + pixelOffset = [0, 0]; } - _tankID = null; - timeout2(function() { - var startString = helpHtml("intro.buildings.start_tank") + helpHtml("intro.buildings.tank_edge_" + (context.lastPointerType() === "mouse" ? "click" : "tap")); - revealTank(tank, startString); - context.map().on("move.intro drawn.intro", function() { - revealTank(tank, startString, { duration: 0 }); + tiler8.scale(_projection.scale() * 2 * Math.PI).translate([ + _projection.translate()[0] + pixelOffset[0], + _projection.translate()[1] + pixelOffset[1] + ]); + _tileOrigin = [ + _projection.scale() * Math.PI - _projection.translate()[0], + _projection.scale() * Math.PI - _projection.translate()[1] + ]; + render(selection2); + } + function render(selection2) { + if (!_source) return; + var requests = []; + var showDebug = context.getDebug("tile") && !_source.overlay; + if (_source.validZoom(_zoom, _underzoom)) { + tiler8.skipNullIsland(!!_source.overlay); + tiler8().forEach(function(d2) { + addSource(d2); + if (d2.url === "") return; + if (typeof d2.url !== "string") return; + requests.push(d2); + if (_cache5[d2.url] === false && lookUp(d2)) { + requests.push(addSource(lookUp(d2))); + } }); - context.on("enter.intro", function(mode) { - if (mode.id !== "draw-area") return chapter.restart(); - continueTo(continueTank); + requests = uniqueBy(requests, "url").filter(function(r2) { + return _cache5[r2.url] !== false; }); - }, 550); - function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); - context.on("enter.intro", null); - nextStep(); } - } - function continueTank() { - if (context.mode().id !== "draw-area") { - return continueTo(addTank); + function load(d3_event, d2) { + _cache5[d2.url] = true; + select_default2(this).on("error", null).on("load", null); + render(selection2); } - _tankID = null; - var continueString = helpHtml("intro.buildings.continue_tank") + "{br}" + helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.buildings.finish_tank"); - revealTank(tank, continueString); - context.map().on("move.intro drawn.intro", function() { - revealTank(tank, continueString, { duration: 0 }); - }); - context.on("enter.intro", function(mode) { - if (mode.id === "draw-area") { - return; - } else if (mode.id === "select") { - _tankID = context.selectedIDs()[0]; - return continueTo(searchPresetTank); - } else { - return continueTo(addTank); - } - }); - function continueTo(nextStep) { - context.map().on("move.intro drawn.intro", null); - context.on("enter.intro", null); - nextStep(); + function error(d3_event, d2) { + _cache5[d2.url] = false; + select_default2(this).on("error", null).on("load", null).remove(); + render(selection2); } - } - function searchPresetTank() { - if (!_tankID || !context.hasEntity(_tankID)) { - return addTank(); + function imageTransform(d2) { + var ts = d2.tileSize * Math.pow(2, _zoom - d2[2]); + var scale = tileSizeAtZoom(d2, _zoom); + return "translate(" + ((d2[0] * ts + d2.source.offset()[0] * Math.pow(2, _zoom)) * _tileSize / d2.tileSize - _tileOrigin[0]) + "px," + ((d2[1] * ts + d2.source.offset()[1] * Math.pow(2, _zoom)) * _tileSize / d2.tileSize - _tileOrigin[1]) + "px) scale(" + scale * _tileSize / d2.tileSize + "," + scale * _tileSize / d2.tileSize + ")"; } - var ids = context.selectedIDs(); - if (context.mode().id !== "select" || !ids.length || ids[0] !== _tankID) { - context.enter(modeSelect(context, [_tankID])); + function tileCenter(d2) { + var ts = d2.tileSize * Math.pow(2, _zoom - d2[2]); + return [ + d2[0] * ts - _tileOrigin[0] + ts / 2, + d2[1] * ts - _tileOrigin[1] + ts / 2 + ]; } - context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); - timeout2(function() { - context.container().select(".inspector-wrap .panewrap").style("right", "-100%"); - context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch); - reveal( - ".preset-search-input", - helpHtml("intro.buildings.search_tank", { preset: tankPreset.name() }) - ); - }, 400); - context.on("enter.intro", function(mode) { - if (!_tankID || !context.hasEntity(_tankID)) { - return continueTo(addTank); + function debugTransform(d2) { + var coord2 = tileCenter(d2); + return "translate(" + coord2[0] + "px," + coord2[1] + "px)"; + } + var dims = tiler8.size(); + var mapCenter = [dims[0] / 2, dims[1] / 2]; + var minDist = Math.max(dims[0], dims[1]); + var nearCenter; + requests.forEach(function(d2) { + var c2 = tileCenter(d2); + var dist = geoVecLength(c2, mapCenter); + if (dist < minDist) { + minDist = dist; + nearCenter = d2; } - var ids2 = context.selectedIDs(); - if (mode.id !== "select" || !ids2.length || ids2[0] !== _tankID) { - context.enter(modeSelect(context, [_tankID])); - context.container().select(".inspector-wrap .panewrap").style("right", "-100%"); - context.container().select(".inspector-wrap").on("wheel.intro", eventCancel); - context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch); - reveal( - ".preset-search-input", - helpHtml("intro.buildings.search_tank", { preset: tankPreset.name() }) - ); - context.history().on("change.intro", null); + }); + var image = selection2.selectAll("img").data(requests, function(d2) { + return d2.url; + }); + image.exit().style(transformProp, imageTransform).classed("tile-removing", true).classed("tile-center", false).on("transitionend", function() { + const tile = select_default2(this); + if (tile.classed("tile-removing")) { + tile.remove(); } }); - function checkPresetSearch() { - var first = context.container().select(".preset-list-item:first-child"); - if (first.classed("preset-man_made-storage_tank")) { - reveal( - first.select(".preset-list-button").node(), - helpHtml("intro.buildings.choose_tank", { preset: tankPreset.name() }), - { duration: 300 } - ); - context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null); - context.history().on("change.intro", function() { - continueTo(closeEditorTank); + image.enter().append("img").attr("class", "tile").attr("alt", "").attr("draggable", "false").style("width", _tileSize + "px").style("height", _tileSize + "px").attr("src", function(d2) { + return d2.url; + }).on("error", error).on("load", load).merge(image).style(transformProp, imageTransform).classed("tile-debug", showDebug).classed("tile-removing", false).classed("tile-center", function(d2) { + return d2 === nearCenter; + }).sort((a2, b2) => a2[2] - b2[2]); + var debug2 = selection2.selectAll(".tile-label-debug").data(showDebug ? requests : [], function(d2) { + return d2.url; + }); + debug2.exit().remove(); + if (showDebug) { + var debugEnter = debug2.enter().append("div").attr("class", "tile-label-debug"); + debugEnter.append("div").attr("class", "tile-label-debug-coord"); + debugEnter.append("div").attr("class", "tile-label-debug-vintage"); + debug2 = debug2.merge(debugEnter); + debug2.style(transformProp, debugTransform); + debug2.selectAll(".tile-label-debug-coord").text(function(d2) { + return d2[2] + " / " + d2[0] + " / " + d2[1]; + }); + debug2.selectAll(".tile-label-debug-vintage").each(function(d2) { + var span = select_default2(this); + var center = context.projection.invert(tileCenter(d2)); + _source.getMetadata(center, d2, function(err, result) { + if (result && result.vintage && result.vintage.range) { + span.text(result.vintage.range); + } else { + span.text(""); + span.call(_t.append("info_panels.background.vintage")); + span.append("span").text(": "); + span.call(_t.append("info_panels.background.unknown")); + } }); + }); + } + } + background.projection = function(val) { + if (!arguments.length) return _projection; + _projection = val; + return background; + }; + background.dimensions = function(val) { + if (!arguments.length) return tiler8.size(); + tiler8.size(val); + return background; + }; + background.source = function(val) { + if (!arguments.length) return _source; + _source = val; + _tileSize = _source.tileSize; + _cache5 = {}; + tiler8.tileSize(_source.tileSize).zoomExtent(_source.zoomExtent); + return background; + }; + background.underzoom = function(amount) { + if (!arguments.length) return _underzoom; + _underzoom = amount; + return background; + }; + return background; + } + var init_tile_layer = __esm({ + "modules/renderer/tile_layer.js"() { + "use strict"; + init_src5(); + init_localizer(); + init_geo2(); + init_util(); + } + }); + + // modules/renderer/background.js + var background_exports2 = {}; + __export(background_exports2, { + rendererBackground: () => rendererBackground + }); + function rendererBackground(context) { + const dispatch14 = dispatch_default("change"); + const baseLayer = rendererTileLayer(context).projection(context.projection); + let _checkedBlocklists = []; + let _isValid = true; + let _overlayLayers = []; + let _brightness = 1; + let _contrast = 1; + let _saturation = 1; + let _sharpness = 1; + function ensureImageryIndex() { + return _mainFileFetcher.get("imagery").then((sources) => { + if (_imageryIndex) return _imageryIndex; + _imageryIndex = { + imagery: sources, + features: {} + }; + const features = sources.map((source) => { + if (!source.polygon) return null; + const rings = source.polygon.map((ring) => [ring]); + const feature3 = { + type: "Feature", + properties: { id: source.id }, + geometry: { type: "MultiPolygon", coordinates: rings } + }; + _imageryIndex.features[source.id] = feature3; + return feature3; + }).filter(Boolean); + _imageryIndex.query = (0, import_which_polygon3.default)({ type: "FeatureCollection", features }); + _imageryIndex.backgrounds = sources.map((source) => { + if (source.type === "bing") { + return rendererBackgroundSource.Bing(source, dispatch14); + } else if (/^EsriWorldImagery/.test(source.id)) { + return rendererBackgroundSource.Esri(source); + } else { + return rendererBackgroundSource(source); + } + }); + _imageryIndex.backgrounds.unshift(rendererBackgroundSource.None()); + let template = corePreferences("background-custom-template") || ""; + const custom = rendererBackgroundSource.Custom(template); + _imageryIndex.backgrounds.unshift(custom); + return _imageryIndex; + }); + } + function background(selection2) { + const currSource = baseLayer.source(); + if (context.map().zoom() > 18) { + if (currSource && /^EsriWorldImagery/.test(currSource.id)) { + const center = context.map().center(); + currSource.fetchTilemap(center); } } - function continueTo(nextStep) { - context.container().select(".inspector-wrap").on("wheel.intro", null); - context.on("enter.intro", null); - context.history().on("change.intro", null); - context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null); - nextStep(); + const sources = background.sources(context.map().extent()); + const wasValid = _isValid; + _isValid = !!sources.filter((d2) => d2 === currSource).length; + if (wasValid !== _isValid) { + background.updateImagery(); } - } - function closeEditorTank() { - if (!_tankID || !context.hasEntity(_tankID)) { - return addTank(); + let baseFilter = ""; + if (_brightness !== 1) { + baseFilter += ` brightness(${_brightness})`; } - var ids = context.selectedIDs(); - if (context.mode().id !== "select" || !ids.length || ids[0] !== _tankID) { - context.enter(modeSelect(context, [_tankID])); + if (_contrast !== 1) { + baseFilter += ` contrast(${_contrast})`; } - context.history().checkpoint("hasTank"); - context.on("exit.intro", function() { - continueTo(rightClickTank); - }); - timeout2(function() { - reveal( - ".entity-editor-pane", - helpHtml("intro.buildings.close", { button: { html: icon("#iD-icon-close", "inline") } }) - ); - }, 500); - function continueTo(nextStep) { - context.on("exit.intro", null); - nextStep(); + if (_saturation !== 1) { + baseFilter += ` saturate(${_saturation})`; } - } - function rightClickTank() { - if (!_tankID) return continueTo(addTank); - context.enter(modeBrowse(context)); - context.history().reset("hasTank"); - context.map().centerEase(tank, 500); - timeout2(function() { - context.on("enter.intro", function(mode) { - if (mode.id !== "select") return; - var ids = context.selectedIDs(); - if (ids.length !== 1 || ids[0] !== _tankID) return; - timeout2(function() { - var node = selectMenuItem(context, "circularize").node(); - if (!node) return; - continueTo(clickCircle); - }, 50); - }); - var rightclickString = helpHtml("intro.buildings." + (context.lastPointerType() === "mouse" ? "rightclick_tank" : "edit_menu_tank_touch")); - revealTank(tank, rightclickString); - context.map().on("move.intro drawn.intro", function() { - revealTank(tank, rightclickString, { duration: 0 }); - }); - context.history().on("change.intro", function() { - continueTo(rightClickTank); - }); - }, 600); - function continueTo(nextStep) { - context.on("enter.intro", null); - context.map().on("move.intro drawn.intro", null); - context.history().on("change.intro", null); - nextStep(); + if (_sharpness < 1) { + const blur = number_default(0.5, 5)(1 - _sharpness); + baseFilter += ` blur(${blur}px)`; + } + let base = selection2.selectAll(".layer-background").data([0]); + base = base.enter().insert("div", ".layer-data").attr("class", "layer layer-background").merge(base); + base.style("filter", baseFilter || null); + let imagery = base.selectAll(".layer-imagery").data([0]); + imagery.enter().append("div").attr("class", "layer layer-imagery").merge(imagery).call(baseLayer); + let maskFilter = ""; + let mixBlendMode = ""; + if (_sharpness > 1) { + mixBlendMode = "overlay"; + maskFilter = "saturate(0) blur(3px) invert(1)"; + let contrast = _sharpness - 1; + maskFilter += ` contrast(${contrast})`; + let brightness = number_default(1, 0.85)(_sharpness - 1); + maskFilter += ` brightness(${brightness})`; } + let mask = base.selectAll(".layer-unsharp-mask").data(_sharpness > 1 ? [0] : []); + mask.exit().remove(); + mask.enter().append("div").attr("class", "layer layer-mask layer-unsharp-mask").merge(mask).call(baseLayer).style("filter", maskFilter || null).style("mix-blend-mode", mixBlendMode || null); + let overlays = selection2.selectAll(".layer-overlay").data(_overlayLayers, (d2) => d2.source().name()); + overlays.exit().remove(); + overlays.enter().insert("div", ".layer-data").attr("class", "layer layer-overlay").merge(overlays).each((layer, i3, nodes) => select_default2(nodes[i3]).call(layer)); } - function clickCircle() { - if (!_tankID) return chapter.restart(); - var entity = context.hasEntity(_tankID); - if (!entity) return continueTo(rightClickTank); - var node = selectMenuItem(context, "circularize").node(); - if (!node) { - return continueTo(rightClickTank); + background.updateImagery = function() { + let currSource = baseLayer.source(); + if (context.inIntro() || !currSource) return; + let o2 = _overlayLayers.filter((d2) => !d2.source().isLocatorOverlay() && !d2.source().isHidden()).map((d2) => d2.source().id).join(","); + const meters = geoOffsetToMeters(currSource.offset()); + const EPSILON = 0.01; + const x2 = +meters[0].toFixed(2); + const y2 = +meters[1].toFixed(2); + let hash2 = utilStringQs(window.location.hash); + let id2 = currSource.id; + if (id2 === "custom") { + id2 = `custom:${currSource.template()}`; } - var wasChanged = false; - reveal( - ".edit-menu", - helpHtml("intro.buildings.circle_tank"), - { padding: 50 } - ); - context.on("enter.intro", function(mode) { - if (mode.id === "browse") { - continueTo(rightClickTank); - } else if (mode.id === "move" || mode.id === "rotate") { - continueTo(retryClickCircle); - } - }); - context.map().on("move.intro", function() { - var node2 = selectMenuItem(context, "circularize").node(); - if (!wasChanged && !node2) { - return continueTo(rightClickTank); - } - reveal( - ".edit-menu", - helpHtml("intro.buildings.circle_tank"), - { duration: 0, padding: 50 } - ); - }); - context.history().on("change.intro", function() { - wasChanged = true; - context.history().on("change.intro", null); - timeout2(function() { - if (context.history().undoAnnotation() === _t("operations.circularize.annotation.feature", { n: 1 })) { - continueTo(play); - } else { - continueTo(retryClickCircle); - } - }, 500); - }); - function continueTo(nextStep) { - context.on("enter.intro", null); - context.map().on("move.intro", null); - context.history().on("change.intro", null); - nextStep(); + if (id2) { + hash2.background = id2; + } else { + delete hash2.background; + } + if (o2) { + hash2.overlays = o2; + } else { + delete hash2.overlays; + } + if (Math.abs(x2) > EPSILON || Math.abs(y2) > EPSILON) { + hash2.offset = `${x2},${y2}`; + } else { + delete hash2.offset; + } + if (!window.mocha) { + window.location.replace("#" + utilQsString(hash2, true)); + } + let imageryUsed = []; + let photoOverlaysUsed = []; + const currUsed = currSource.imageryUsed(); + if (currUsed && _isValid) { + imageryUsed.push(currUsed); } - } - function retryClickCircle() { - context.enter(modeBrowse(context)); - revealTank(tank, helpHtml("intro.buildings.retry_circle"), { - buttonText: _t.html("intro.ok"), - buttonCallback: function() { - continueTo(rightClickTank); + _overlayLayers.filter((d2) => !d2.source().isLocatorOverlay() && !d2.source().isHidden()).forEach((d2) => imageryUsed.push(d2.source().imageryUsed())); + const dataLayer = context.layers().layer("data"); + if (dataLayer && dataLayer.enabled() && dataLayer.hasData()) { + imageryUsed.push(dataLayer.getSrc()); + } + const photoOverlayLayers = { + streetside: "Bing Streetside", + mapillary: "Mapillary Images", + "mapillary-map-features": "Mapillary Map Features", + "mapillary-signs": "Mapillary Signs", + kartaview: "KartaView Images", + vegbilder: "Norwegian Road Administration Images", + mapilio: "Mapilio Images", + panoramax: "Panoramax Images" + }; + for (let layerID in photoOverlayLayers) { + const layer = context.layers().layer(layerID); + if (layer && layer.enabled()) { + photoOverlaysUsed.push(layerID); + imageryUsed.push(photoOverlayLayers[layerID]); } + } + context.history().imageryUsed(imageryUsed); + context.history().photoOverlaysUsed(photoOverlaysUsed); + }; + background.sources = (extent, zoom, includeCurrent) => { + if (!_imageryIndex) return []; + let visible = {}; + (_imageryIndex.query.bbox(extent.rectangle(), true) || []).forEach((d2) => visible[d2.id] = true); + const currSource = baseLayer.source(); + const osm = context.connection(); + const blocklists = osm && osm.imageryBlocklists() || []; + const blocklistChanged = blocklists.length !== _checkedBlocklists.length || blocklists.some((regex, index) => String(regex) !== _checkedBlocklists[index]); + if (blocklistChanged) { + _imageryIndex.backgrounds.forEach((source) => { + source.isBlocked = blocklists.some((regex) => regex.test(source.template())); + }); + _checkedBlocklists = blocklists.map((regex) => String(regex)); + } + return _imageryIndex.backgrounds.filter((source) => { + if (includeCurrent && currSource === source) return true; + if (source.isBlocked) return false; + if (!source.polygon) return true; + if (zoom && zoom < 6) return false; + return visible[source.id]; }); - function continueTo(nextStep) { - nextStep(); + }; + background.dimensions = (val) => { + if (!val) return; + baseLayer.dimensions(val); + _overlayLayers.forEach((layer) => layer.dimensions(val)); + }; + background.baseLayerSource = function(d2) { + if (!arguments.length) return baseLayer.source(); + const osm = context.connection(); + if (!osm) return background; + const blocklists = osm.imageryBlocklists(); + const template = d2.template(); + let fail = false; + let tested = 0; + let regex; + for (let i3 = 0; i3 < blocklists.length; i3++) { + regex = blocklists[i3]; + fail = regex.test(template); + tested++; + if (fail) break; } - } - function play() { - dispatch14.call("done"); - reveal( - ".ideditor", - helpHtml("intro.buildings.play", { next: _t("intro.startediting.title") }), - { - tooltipBox: ".intro-nav-wrap .chapter-startEditing", - buttonText: _t.html("intro.ok"), - buttonCallback: function() { - reveal(".ideditor"); - } + if (!tested) { + regex = /.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/; + fail = regex.test(template); + } + baseLayer.source(!fail ? d2 : background.findSource("none")); + dispatch14.call("change"); + background.updateImagery(); + return background; + }; + background.findSource = (id2) => { + if (!id2 || !_imageryIndex) return null; + return _imageryIndex.backgrounds.find((d2) => d2.id && d2.id === id2); + }; + background.bing = () => { + background.baseLayerSource(background.findSource("Bing")); + }; + background.showsLayer = (d2) => { + const currSource = baseLayer.source(); + if (!d2 || !currSource) return false; + return d2.id === currSource.id || _overlayLayers.some((layer) => d2.id === layer.source().id); + }; + background.overlayLayerSources = () => { + return _overlayLayers.map((layer) => layer.source()); + }; + background.toggleOverlayLayer = (d2) => { + let layer; + for (let i3 = 0; i3 < _overlayLayers.length; i3++) { + layer = _overlayLayers[i3]; + if (layer.source() === d2) { + _overlayLayers.splice(i3, 1); + dispatch14.call("change"); + background.updateImagery(); + return; } + } + layer = rendererTileLayer(context).source(d2).projection(context.projection).dimensions( + baseLayer.dimensions() ); - } - chapter.enter = function() { - addHouse(); + _overlayLayers.push(layer); + dispatch14.call("change"); + background.updateImagery(); }; - chapter.exit = function() { - timeouts.forEach(window.clearTimeout); - context.on("enter.intro exit.intro", null); - context.map().on("move.intro drawn.intro", null); - context.history().on("change.intro", null); - context.container().select(".inspector-wrap").on("wheel.intro", null); - context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null); - context.container().select(".more-fields .combobox-input").on("click.intro", null); + background.nudge = (d2, zoom) => { + const currSource = baseLayer.source(); + if (currSource) { + currSource.nudge(d2, zoom); + dispatch14.call("change"); + background.updateImagery(); + } + return background; }; - chapter.restart = function() { - chapter.exit(); - chapter.enter(); + background.offset = function(d2) { + const currSource = baseLayer.source(); + if (!arguments.length) { + return currSource && currSource.offset() || [0, 0]; + } + if (currSource) { + currSource.offset(d2); + dispatch14.call("change"); + background.updateImagery(); + } + return background; }; - return utilRebind(chapter, dispatch14, "on"); - } - - // modules/ui/intro/start_editing.js - function uiIntroStartEditing(context, reveal) { - var dispatch14 = dispatch_default("done", "startEditing"); - var modalSelection = select_default2(null); - var chapter = { - title: "intro.startediting.title" + background.brightness = function(d2) { + if (!arguments.length) return _brightness; + _brightness = d2; + if (context.mode()) dispatch14.call("change"); + return background; }; - function showHelp() { - reveal( - ".map-control.help-control", - helpHtml("intro.startediting.help"), - { - buttonText: _t.html("intro.ok"), - buttonCallback: function() { - shortcuts(); - } + background.contrast = function(d2) { + if (!arguments.length) return _contrast; + _contrast = d2; + if (context.mode()) dispatch14.call("change"); + return background; + }; + background.saturation = function(d2) { + if (!arguments.length) return _saturation; + _saturation = d2; + if (context.mode()) dispatch14.call("change"); + return background; + }; + background.sharpness = function(d2) { + if (!arguments.length) return _sharpness; + _sharpness = d2; + if (context.mode()) dispatch14.call("change"); + return background; + }; + let _loadPromise; + background.ensureLoaded = () => { + if (_loadPromise) return _loadPromise; + return _loadPromise = ensureImageryIndex(); + }; + background.init = () => { + const loadPromise = background.ensureLoaded(); + const hash2 = utilStringQs(window.location.hash); + const requestedBackground = hash2.background || hash2.layer; + const lastUsedBackground = corePreferences("background-last-used"); + return loadPromise.then((imageryIndex) => { + const extent = context.map().extent(); + const validBackgrounds = background.sources(extent).filter((d2) => d2.id !== "none" && d2.id !== "custom"); + const first = validBackgrounds.length && validBackgrounds[0]; + const isLastUsedValid = !!validBackgrounds.find((d2) => d2.id && d2.id === lastUsedBackground); + let best; + if (!requestedBackground && extent) { + const viewArea = extent.area(); + best = validBackgrounds.find((s2) => { + if (!s2.best() || s2.overlay) return false; + let bbox2 = turf_bbox_default(turf_bbox_clip_default( + { type: "MultiPolygon", coordinates: [s2.polygon || [extent.polygon()]] }, + extent.rectangle() + )); + let area = geoExtent(bbox2.slice(0, 2), bbox2.slice(2, 4)).area(); + return area / viewArea > 0.5; + }); } - ); - } - function shortcuts() { - reveal( - ".map-control.help-control", - helpHtml("intro.startediting.shortcuts"), - { - buttonText: _t.html("intro.ok"), - buttonCallback: function() { - showSave(); + if (requestedBackground && requestedBackground.indexOf("custom:") === 0) { + const template = requestedBackground.replace(/^custom:/, ""); + const custom = background.findSource("custom"); + background.baseLayerSource(custom.template(template)); + corePreferences("background-custom-template", template); + } else { + background.baseLayerSource( + background.findSource(requestedBackground) || best || isLastUsedValid && background.findSource(lastUsedBackground) || background.findSource("Bing") || first || background.findSource("none") + ); + } + const locator = imageryIndex.backgrounds.find((d2) => d2.overlay && d2.default); + if (locator) { + background.toggleOverlayLayer(locator); + } + const overlays = (hash2.overlays || "").split(","); + overlays.forEach((overlay) => { + overlay = background.findSource(overlay); + if (overlay) { + background.toggleOverlayLayer(overlay); + } + }); + if (hash2.gpx) { + const gpx2 = context.layers().layer("data"); + if (gpx2) { + gpx2.url(hash2.gpx, ".gpx"); } } - ); - } - function showSave() { - context.container().selectAll(".shaded").remove(); - reveal( - ".top-toolbar button.save", - helpHtml("intro.startediting.save"), - { - buttonText: _t.html("intro.ok"), - buttonCallback: function() { - showStart(); + if (hash2.offset) { + const offset = hash2.offset.replace(/;/g, ",").split(",").map((n3) => !isNaN(n3) && n3); + if (offset.length === 2) { + background.offset(geoMetersToOffset(offset)); } } - ); - } - function showStart() { - context.container().selectAll(".shaded").remove(); - modalSelection = uiModal(context.container()); - modalSelection.select(".modal").attr("class", "modal-splash modal"); - modalSelection.selectAll(".close").remove(); - var startbutton = modalSelection.select(".content").attr("class", "fillL").append("button").attr("class", "modal-section huge-modal-button").on("click", function() { - modalSelection.remove(); + }).catch((err) => { + console.error(err); }); - startbutton.append("svg").attr("class", "illustration").append("use").attr("xlink:href", "#iD-logo-walkthrough"); - startbutton.append("h2").call(_t.append("intro.startediting.start")); - dispatch14.call("startEditing"); - } - chapter.enter = function() { - showHelp(); - }; - chapter.exit = function() { - modalSelection.remove(); - context.container().selectAll(".shaded").remove(); }; - return utilRebind(chapter, dispatch14, "on"); + return utilRebind(background, dispatch14, "on"); } + var import_which_polygon3, _imageryIndex; + var init_background2 = __esm({ + "modules/renderer/background.js"() { + "use strict"; + init_src4(); + init_src8(); + init_src5(); + init_esm5(); + init_esm7(); + import_which_polygon3 = __toESM(require_which_polygon()); + init_preferences(); + init_file_fetcher(); + init_geo2(); + init_background_source(); + init_tile_layer(); + init_util(); + init_rebind(); + _imageryIndex = null; + } + }); - // modules/ui/intro/intro.js - var chapterUi = { - welcome: uiIntroWelcome, - navigation: uiIntroNavigation, - point: uiIntroPoint, - area: uiIntroArea, - line: uiIntroLine, - building: uiIntroBuilding, - startEditing: uiIntroStartEditing - }; - var chapterFlow = [ - "welcome", - "navigation", - "point", - "area", - "line", - "building", - "startEditing" - ]; - function uiIntro(context) { - const INTRO_IMAGERY = "EsriWorldImageryClarity"; - let _introGraph = {}; - let _currChapter; - function intro(selection2) { - _mainFileFetcher.get("intro_graph").then((dataIntroGraph) => { - for (let id2 in dataIntroGraph) { - if (!_introGraph[id2]) { - _introGraph[id2] = osmEntity(localize(dataIntroGraph[id2])); - } + // modules/renderer/features.js + var features_exports = {}; + __export(features_exports, { + rendererFeatures: () => rendererFeatures + }); + function rendererFeatures(context) { + var dispatch14 = dispatch_default("change", "redraw"); + const features = {}; + var _deferred2 = /* @__PURE__ */ new Set(); + var traffic_roads = { + "motorway": true, + "motorway_link": true, + "trunk": true, + "trunk_link": true, + "primary": true, + "primary_link": true, + "secondary": true, + "secondary_link": true, + "tertiary": true, + "tertiary_link": true, + "residential": true, + "unclassified": true, + "living_street": true, + "busway": true + }; + var service_roads = { + "service": true, + "road": true, + "track": true + }; + var paths = { + "path": true, + "footway": true, + "cycleway": true, + "bridleway": true, + "steps": true, + "ladder": true, + "pedestrian": true + }; + var _cullFactor = 1; + var _cache5 = {}; + var _rules = {}; + var _stats = {}; + var _keys = []; + var _hidden = []; + var _forceVisible = {}; + function update() { + if (!window.mocha) { + var hash2 = utilStringQs(window.location.hash); + var disabled = features.disabled(); + if (disabled.length) { + hash2.disable_features = disabled.join(","); + } else { + delete hash2.disable_features; } - selection2.call(startIntro); - }).catch(function() { - }); - } - function startIntro(selection2) { - context.enter(modeBrowse(context)); - let osm = context.connection(); - let history = context.history().toJSON(); - let hash2 = window.location.hash; - let center = context.map().center(); - let zoom = context.map().zoom(); - let background = context.background().baseLayerSource(); - let overlays = context.background().overlayLayerSources(); - let opacity = context.container().selectAll(".main-map .layer-background").style("opacity"); - let caches = osm && osm.caches(); - let baseEntities = context.history().graph().base().entities; - context.ui().sidebar.expand(); - context.container().selectAll("button.sidebar-toggle").classed("disabled", true); - context.inIntro(true); - if (osm) { - osm.toggle(false).reset(); - } - context.history().reset(); - context.history().merge(Object.values(coreGraph().load(_introGraph).entities)); - context.history().checkpoint("initial"); - let imagery = context.background().findSource(INTRO_IMAGERY); - if (imagery) { - context.background().baseLayerSource(imagery); - } else { - context.background().bing(); + window.location.replace("#" + utilQsString(hash2, true)); + corePreferences("disabled-features", disabled.join(",")); } - overlays.forEach((d2) => context.background().toggleOverlayLayer(d2)); - let layers = context.layers(); - layers.all().forEach((item) => { - if (typeof item.layer.enabled === "function") { - item.layer.enabled(item.id === "osm"); - } - }); - context.container().selectAll(".main-map .layer-background").style("opacity", 1); - let curtain = uiCurtain(context.container().node()); - selection2.call(curtain); - corePreferences("walkthrough_started", "yes"); - let storedProgress = corePreferences("walkthrough_progress") || ""; - let progress = storedProgress.split(";").filter(Boolean); - let chapters = chapterFlow.map((chapter, i3) => { - let s2 = chapterUi[chapter](context, curtain.reveal).on("done", () => { - buttons.filter((d2) => d2.title === s2.title).classed("finished", true); - if (i3 < chapterFlow.length - 1) { - const next = chapterFlow[i3 + 1]; - context.container().select("button.chapter-".concat(next)).classed("next", true); - } - progress.push(chapter); - corePreferences("walkthrough_progress", utilArrayUniq(progress).join(";")); - }); - return s2; - }); - chapters[chapters.length - 1].on("startEditing", () => { - progress.push("startEditing"); - corePreferences("walkthrough_progress", utilArrayUniq(progress).join(";")); - let incomplete = utilArrayDifference(chapterFlow, progress); - if (!incomplete.length) { - corePreferences("walkthrough_completed", "yes"); - } - curtain.remove(); - navwrap.remove(); - context.container().selectAll(".main-map .layer-background").style("opacity", opacity); - context.container().selectAll("button.sidebar-toggle").classed("disabled", false); - if (osm) { - osm.toggle(true).reset().caches(caches); - } - context.history().reset().merge(Object.values(baseEntities)); - context.background().baseLayerSource(background); - overlays.forEach((d2) => context.background().toggleOverlayLayer(d2)); - if (history) { - context.history().fromJSON(history, false); - } - context.map().centerZoom(center, zoom); - window.location.replace(hash2); - context.inIntro(false); - }); - let navwrap = selection2.append("div").attr("class", "intro-nav-wrap fillD"); - navwrap.append("svg").attr("class", "intro-nav-wrap-logo").append("use").attr("xlink:href", "#iD-logo-walkthrough"); - let buttonwrap = navwrap.append("div").attr("class", "joined").selectAll("button.chapter"); - let buttons = buttonwrap.data(chapters).enter().append("button").attr("class", (d2, i3) => "chapter chapter-".concat(chapterFlow[i3])).on("click", enterChapter); - buttons.append("span").html((d2) => _t.html(d2.title)); - buttons.append("span").attr("class", "status").call(svgIcon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward", "inline")); - enterChapter(null, chapters[0]); - function enterChapter(d3_event, newChapter) { - if (_currChapter) { - _currChapter.exit(); + _hidden = features.hidden(); + dispatch14.call("change"); + dispatch14.call("redraw"); + } + function defineRule(k2, filter2, max3) { + var isEnabled = true; + _keys.push(k2); + _rules[k2] = { + filter: filter2, + enabled: isEnabled, + // whether the user wants it enabled.. + count: 0, + currentMax: max3 || Infinity, + defaultMax: max3 || Infinity, + enable: function() { + this.enabled = true; + this.currentMax = this.defaultMax; + }, + disable: function() { + this.enabled = false; + this.currentMax = 0; + }, + hidden: function() { + return this.count === 0 && !this.enabled || this.count > this.currentMax * _cullFactor; + }, + autoHidden: function() { + return this.hidden() && this.currentMax > 0; } - context.enter(modeBrowse(context)); - _currChapter = newChapter; - _currChapter.enter(); - buttons.classed("next", false).classed("active", (d2) => d2.title === _currChapter.title); + }; + } + defineRule("points", function isPoint(tags, geometry) { + return geometry === "point"; + }, 200); + defineRule("traffic_roads", function isTrafficRoad(tags) { + return traffic_roads[tags.highway]; + }); + defineRule("service_roads", function isServiceRoad(tags) { + return service_roads[tags.highway]; + }); + defineRule("paths", function isPath(tags) { + return paths[tags.highway]; + }); + defineRule("buildings", function isBuilding(tags) { + return !!tags.building && tags.building !== "no" || tags.parking === "multi-storey" || tags.parking === "sheds" || tags.parking === "carports" || tags.parking === "garage_boxes"; + }, 250); + defineRule("building_parts", function isBuildingPart(tags) { + return !!tags["building:part"]; + }); + defineRule("indoor", function isIndoor(tags) { + return !!tags.indoor && tags.indoor !== "no" || !!tags.indoormark && tags.indoormark !== "no"; + }); + defineRule("landuse", function isLanduse(tags, geometry) { + return geometry === "area" && (!!tags.landuse || !!tags.natural || !!tags.leisure || !!tags.amenity) && !_rules.buildings.filter(tags) && !_rules.building_parts.filter(tags) && !_rules.indoor.filter(tags) && !_rules.water.filter(tags) && !_rules.pistes.filter(tags); + }); + defineRule("boundaries", function isBoundary(tags, geometry) { + return (geometry === "line" && !!tags.boundary || geometry === "relation" && tags.type === "boundary") && !(traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway] || tags.waterway || tags.railway || tags.landuse || tags.natural || tags.building || tags.power); + }); + defineRule("water", function isWater(tags) { + return !!tags.waterway || tags.natural === "water" || tags.natural === "coastline" || tags.natural === "bay" || tags.landuse === "pond" || tags.landuse === "basin" || tags.landuse === "reservoir" || tags.landuse === "salt_pond"; + }); + defineRule("rail", function isRail(tags) { + return (!!tags.railway || tags.landuse === "railway") && !(traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway]); + }); + defineRule("pistes", function isPiste(tags) { + return tags["piste:type"]; + }); + defineRule("aerialways", function isAerialways(tags) { + return !!(tags == null ? void 0 : tags.aerialway) && tags.aerialway !== "yes" && tags.aerialway !== "station"; + }); + defineRule("power", function isPower(tags) { + return !!tags.power; + }); + defineRule("past_future", function isPastFuture(tags) { + if (traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway]) { + return false; } - } - return intro; - } - - // modules/ui/issues_info.js - function uiIssuesInfo(context) { - var warningsItem = { - id: "warnings", - count: 0, - iconID: "iD-icon-alert", - descriptionID: "issues.warnings_and_errors" + const keys2 = Object.keys(tags); + for (let i3 = 0; i3 < keys2.length; i3++) { + const key = keys2[i3]; + const s2 = key.split(":")[0]; + if (osmLifecyclePrefixes[s2] || osmLifecyclePrefixes[tags[key]]) return true; + } + return false; + }); + defineRule("others", function isOther(tags, geometry) { + return geometry === "line" || geometry === "area"; + }); + features.features = function() { + return _rules; }; - var resolvedItem = { - id: "resolved", - count: 0, - iconID: "iD-icon-apply", - descriptionID: "issues.user_resolved_issues" + features.keys = function() { + return _keys; }; - function update(selection2) { - var shownItems = []; - var liveIssues = context.validator().getIssues({ - what: corePreferences("validate-what") || "edited", - where: corePreferences("validate-where") || "all" - }); - if (liveIssues.length) { - warningsItem.count = liveIssues.length; - shownItems.push(warningsItem); - } - if (corePreferences("validate-what") === "all") { - var resolvedIssues = context.validator().getResolvedIssues(); - if (resolvedIssues.length) { - resolvedItem.count = resolvedIssues.length; - shownItems.push(resolvedItem); - } - } - var chips = selection2.selectAll(".chip").data(shownItems, function(d2) { - return d2.id; - }); - chips.exit().remove(); - var enter = chips.enter().append("a").attr("class", function(d2) { - return "chip " + d2.id + "-count"; - }).attr("href", "#").each(function(d2) { - var chipSelection = select_default2(this); - var tooltipBehavior = uiTooltip().placement("top").title(() => _t.append(d2.descriptionID)); - chipSelection.call(tooltipBehavior).on("click", function(d3_event) { - d3_event.preventDefault(); - tooltipBehavior.hide(select_default2(this)); - context.ui().togglePanes(context.container().select(".map-panes .issues-pane")); + features.enabled = function(k2) { + if (!arguments.length) { + return _keys.filter(function(k3) { + return _rules[k3].enabled; }); - chipSelection.call(svgIcon("#" + d2.iconID)); - }); - enter.append("span").attr("class", "count"); - enter.merge(chips).selectAll("span.count").text(function(d2) { - return d2.count.toString(); - }); - } - return function(selection2) { - update(selection2); - context.validator().on("validated.infobox", function() { - update(selection2); - }); - }; - } - - // modules/renderer/background_source.js - var import_lodash4 = __toESM(require_lodash()); - - // modules/util/IntervalTasksQueue.js - var IntervalTasksQueue = class { - /** - * Interval in milliseconds inside which only 1 task can execute. - * e.g. if interval is 200ms, and 5 async tasks are unqueued, - * they will complete in ~1s if not cleared - * @param {number} intervalInMs - */ - constructor(intervalInMs) { - this.intervalInMs = intervalInMs; - this.pendingHandles = []; - this.time = 0; - } - enqueue(task) { - let taskTimeout = this.time; - this.time += this.intervalInMs; - this.pendingHandles.push(setTimeout(() => { - this.time -= this.intervalInMs; - task(); - }, taskTimeout)); - } - clear() { - this.pendingHandles.forEach((timeoutHandle) => { - clearTimeout(timeoutHandle); - }); - this.pendingHandles = []; - this.time = 0; - } - }; - - // modules/renderer/background_source.js - var isRetina = window.devicePixelRatio && window.devicePixelRatio >= 2; - var _a3; - (_a3 = window.matchMedia) == null ? void 0 : _a3.call(window, "\n (-webkit-min-device-pixel-ratio: 2), /* Safari */\n (min-resolution: 2dppx), /* standard */\n (min-resolution: 192dpi) /* fallback */\n ").addListener(function() { - isRetina = window.devicePixelRatio && window.devicePixelRatio >= 2; - }); - function localeDateString(s2) { - if (!s2) return null; - var options2 = { day: "numeric", month: "short", year: "numeric" }; - var d2 = new Date(s2); - if (isNaN(d2.getTime())) return null; - return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2); - } - function vintageRange(vintage) { - var s2; - if (vintage.start || vintage.end) { - s2 = vintage.start || "?"; - if (vintage.start !== vintage.end) { - s2 += " - " + (vintage.end || "?"); } - } - return s2; - } - function rendererBackgroundSource(data) { - var source = Object.assign({}, data); - var _offset = [0, 0]; - var _name = source.name; - var _description = source.description; - var _best = !!source.best; - var _template = source.encrypted ? utilAesDecrypt(source.template) : source.template; - source.tileSize = data.tileSize || 256; - source.zoomExtent = data.zoomExtent || [0, 22]; - source.overzoom = data.overzoom !== false; - source.offset = function(val) { - if (!arguments.length) return _offset; - _offset = val; - return source; + return _rules[k2] && _rules[k2].enabled; }; - source.nudge = function(val, zoomlevel) { - _offset[0] += val[0] / Math.pow(2, zoomlevel); - _offset[1] += val[1] / Math.pow(2, zoomlevel); - return source; + features.disabled = function(k2) { + if (!arguments.length) { + return _keys.filter(function(k3) { + return !_rules[k3].enabled; + }); + } + return _rules[k2] && !_rules[k2].enabled; }; - source.name = function() { - var id_safe = source.id.replace(/\./g, ""); - return _t("imagery." + id_safe + ".name", { default: (0, import_lodash4.escape)(_name) }); + features.hidden = function(k2) { + var _a3; + if (!arguments.length) { + return _keys.filter(function(k3) { + return _rules[k3].hidden(); + }); + } + return (_a3 = _rules[k2]) == null ? void 0 : _a3.hidden(); }; - source.label = function() { - var id_safe = source.id.replace(/\./g, ""); - return _t.append("imagery." + id_safe + ".name", { default: (0, import_lodash4.escape)(_name) }); + features.autoHidden = function(k2) { + if (!arguments.length) { + return _keys.filter(function(k3) { + return _rules[k3].autoHidden(); + }); + } + return _rules[k2] && _rules[k2].autoHidden(); }; - source.hasDescription = function() { - var id_safe = source.id.replace(/\./g, ""); - var descriptionText = _mainLocalizer.tInfo("imagery." + id_safe + ".description", { default: (0, import_lodash4.escape)(_description) }).text; - return descriptionText !== ""; + features.enable = function(k2) { + if (_rules[k2] && !_rules[k2].enabled) { + _rules[k2].enable(); + update(); + } }; - source.description = function() { - var id_safe = source.id.replace(/\./g, ""); - return _t.append("imagery." + id_safe + ".description", { default: (0, import_lodash4.escape)(_description) }); + features.enableAll = function() { + var didEnable = false; + for (var k2 in _rules) { + if (!_rules[k2].enabled) { + didEnable = true; + _rules[k2].enable(); + } + } + if (didEnable) update(); }; - source.best = function() { - return _best; + features.disable = function(k2) { + if (_rules[k2] && _rules[k2].enabled) { + _rules[k2].disable(); + update(); + } }; - source.area = function() { - if (!data.polygon) return Number.MAX_VALUE; - var area = area_default({ type: "MultiPolygon", coordinates: [data.polygon] }); - return isNaN(area) ? 0 : area; + features.disableAll = function() { + var didDisable = false; + for (var k2 in _rules) { + if (_rules[k2].enabled) { + didDisable = true; + _rules[k2].disable(); + } + } + if (didDisable) update(); }; - source.imageryUsed = function() { - return _name || source.id; + features.toggle = function(k2) { + if (_rules[k2]) { + (function(f2) { + return f2.enabled ? f2.disable() : f2.enable(); + })(_rules[k2]); + update(); + } }; - source.template = function(val) { - if (!arguments.length) return _template; - if (source.id === "custom" || source.id === "Bing") { - _template = val; + features.resetStats = function() { + for (var i3 = 0; i3 < _keys.length; i3++) { + _rules[_keys[i3]].count = 0; } - return source; + dispatch14.call("change"); }; - source.url = function(coord2) { - var result = _template.replace(new RegExp("#[\\s\\S]*", "u"), ""); - if (result === "") return result; - if (!source.type || source.id === "custom") { - if (/SERVICE=WMS|\{(proj|wkid|bbox)\}/.test(result)) { - source.type = "wms"; - source.projection = "EPSG:3857"; - } else if (/\{(x|y)\}/.test(result)) { - source.type = "tms"; - } else if (/\{u\}/.test(result)) { - source.type = "bing"; + features.gatherStats = function(d2, resolver, dimensions) { + var needsRedraw = false; + var types = utilArrayGroupBy(d2, "type"); + var entities = [].concat(types.relation || [], types.way || [], types.node || []); + var currHidden, geometry, matches, i3, j2; + for (i3 = 0; i3 < _keys.length; i3++) { + _rules[_keys[i3]].count = 0; + } + _cullFactor = dimensions[0] * dimensions[1] / 1e6; + for (i3 = 0; i3 < entities.length; i3++) { + geometry = entities[i3].geometry(resolver); + matches = Object.keys(features.getMatches(entities[i3], resolver, geometry)); + for (j2 = 0; j2 < matches.length; j2++) { + _rules[matches[j2]].count++; } } - if (source.type === "wms") { - var tileToProjectedCoords = function(x2, y2, z2) { - var zoomSize = Math.pow(2, z2); - var lon = x2 / zoomSize * Math.PI * 2 - Math.PI; - var lat = Math.atan(Math.sinh(Math.PI * (1 - 2 * y2 / zoomSize))); - switch (source.projection) { - case "EPSG:4326": - return { - x: lon * 180 / Math.PI, - y: lat * 180 / Math.PI - }; - default: - var mercCoords = mercatorRaw(lon, lat); - return { - x: 2003750834e-2 / Math.PI * mercCoords[0], - y: 2003750834e-2 / Math.PI * mercCoords[1] - }; - } - }; - var tileSize = source.tileSize; - var projection2 = source.projection; - var minXmaxY = tileToProjectedCoords(coord2[0], coord2[1], coord2[2]); - var maxXminY = tileToProjectedCoords(coord2[0] + 1, coord2[1] + 1, coord2[2]); - result = result.replace(/\{(\w+)\}/g, function(token, key) { - switch (key) { - case "width": - case "height": - return tileSize; - case "proj": - return projection2; - case "wkid": - return projection2.replace(/^EPSG:/, ""); - case "bbox": - if (projection2 === "EPSG:4326" && // The CRS parameter implies version 1.3 (prior versions use SRS) - /VERSION=1.3|CRS={proj}/.test(source.template().toUpperCase())) { - return maxXminY.y + "," + minXmaxY.x + "," + minXmaxY.y + "," + maxXminY.x; - } else { - return minXmaxY.x + "," + maxXminY.y + "," + maxXminY.x + "," + minXmaxY.y; - } - case "w": - return minXmaxY.x; - case "s": - return maxXminY.y; - case "n": - return maxXminY.x; - case "e": - return minXmaxY.y; - default: - return token; - } - }); - } else if (source.type === "tms") { - result = result.replace("{x}", coord2[0]).replace("{y}", coord2[1]).replace(/\{[t-]y\}/, Math.pow(2, coord2[2]) - coord2[1] - 1).replace(/\{z(oom)?\}/, coord2[2]).replace(/\{@2x\}|\{r\}/, isRetina ? "@2x" : ""); - } else if (source.type === "bing") { - result = result.replace("{u}", function() { - var u2 = ""; - for (var zoom = coord2[2]; zoom > 0; zoom--) { - var b2 = 0; - var mask = 1 << zoom - 1; - if ((coord2[0] & mask) !== 0) b2++; - if ((coord2[1] & mask) !== 0) b2 += 2; - u2 += b2.toString(); - } - return u2; - }); + currHidden = features.hidden(); + if (currHidden !== _hidden) { + _hidden = currHidden; + needsRedraw = true; + dispatch14.call("change"); } - result = result.replace(/\{switch:([^}]+)\}/, function(s2, r2) { - var subdomains = r2.split(","); - return subdomains[(coord2[0] + coord2[1]) % subdomains.length]; - }); - return result; - }; - source.validZoom = function(z2, underzoom) { - if (underzoom === void 0) underzoom = 0; - return source.zoomExtent[0] - underzoom <= z2 && (source.overzoom || source.zoomExtent[1] > z2); + return needsRedraw; }; - source.isLocatorOverlay = function() { - return source.id === "mapbox_locator_overlay"; + features.stats = function() { + for (var i3 = 0; i3 < _keys.length; i3++) { + _stats[_keys[i3]] = _rules[_keys[i3]].count; + } + return _stats; }; - source.isHidden = function() { - return source.id === "DigitalGlobe-Premium-vintage" || source.id === "DigitalGlobe-Standard-vintage"; + features.clear = function(d2) { + for (var i3 = 0; i3 < d2.length; i3++) { + features.clearEntity(d2[i3]); + } }; - source.copyrightNotices = function() { + features.clearEntity = function(entity) { + delete _cache5[osmEntity.key(entity)]; }; - source.getMetadata = function(center, tileCoord, callback) { - var vintage = { - start: localeDateString(source.startDate), - end: localeDateString(source.endDate) - }; - vintage.range = vintageRange(vintage); - var metadata = { vintage }; - callback(null, metadata); + features.reset = function() { + Array.from(_deferred2).forEach(function(handle) { + window.cancelIdleCallback(handle); + _deferred2.delete(handle); + }); + _cache5 = {}; }; - return source; - } - rendererBackgroundSource.Bing = function(data, dispatch14) { - data.template = "https://ecn.t{switch:0,1,2,3}.tiles.virtualearth.net/tiles/a{u}.jpeg?g=1&pr=odbl&n=z"; - var bing = rendererBackgroundSource(data); - var key = utilAesDecrypt("5c875730b09c6b422433e807e1ff060b6536c791dbfffcffc4c6b18a1bdba1f14593d151adb50e19e1be1ab19aef813bf135d0f103475e5c724dec94389e45d0"); - const strictParam = "n"; - var url = "https://dev.virtualearth.net/REST/v1/Imagery/Metadata/AerialOSM?include=ImageryProviders&uriScheme=https&key=" + key; - var cache = {}; - var inflight = {}; - var providers = []; - var taskQueue = new IntervalTasksQueue(250); - var metadataLastZoom = -1; - json_default(url).then(function(json) { - let imageryResource = json.resourceSets[0].resources[0]; - let template = imageryResource.imageUrl; - let subDomains = imageryResource.imageUrlSubdomains; - let subDomainNumbers = subDomains.map((subDomain) => { - return subDomain.substring(1); - }).join(","); - template = template.replace("{subdomain}", "t{switch:".concat(subDomainNumbers, "}")).replace("{quadkey}", "{u}"); - if (!new URLSearchParams(template).has(strictParam)) { - template += "&".concat(strictParam, "=z"); + function relationShouldBeChecked(relation) { + return relation.tags.type === "boundary"; + } + features.getMatches = function(entity, resolver, geometry) { + if (geometry === "vertex" || geometry === "relation" && !relationShouldBeChecked(entity)) return {}; + var ent = osmEntity.key(entity); + if (!_cache5[ent]) { + _cache5[ent] = {}; } - bing.template(template); - providers = imageryResource.imageryProviders.map(function(provider) { - return { - attribution: provider.attribution, - areas: provider.coverageAreas.map(function(area) { - return { - zoom: [area.zoomMin, area.zoomMax], - extent: geoExtent([area.bbox[1], area.bbox[0]], [area.bbox[3], area.bbox[2]]) - }; - }) - }; - }); - dispatch14.call("change"); - }).catch(function() { - }); - bing.copyrightNotices = function(zoom, extent) { - zoom = Math.min(zoom, 21); - return providers.filter(function(provider) { - return provider.areas.some(function(area) { - return extent.intersects(area.extent) && area.zoom[0] <= zoom && area.zoom[1] >= zoom; - }); - }).map(function(provider) { - return provider.attribution; - }).join(", "); - }; - bing.getMetadata = function(center, tileCoord, callback) { - var tileID = tileCoord.slice(0, 3).join("/"); - var zoom = Math.min(tileCoord[2], 21); - var centerPoint = center[1] + "," + center[0]; - var url2 = "https://dev.virtualearth.net/REST/v1/Imagery/BasicMetadata/AerialOSM/" + centerPoint + "?zl=" + zoom + "&key=" + key; - if (inflight[tileID]) return; - if (!cache[tileID]) { - cache[tileID] = {}; - } - if (cache[tileID] && cache[tileID].metadata) { - return callback(null, cache[tileID].metadata); - } - inflight[tileID] = true; - if (metadataLastZoom !== tileCoord[2]) { - metadataLastZoom = tileCoord[2]; - taskQueue.clear(); - } - taskQueue.enqueue(() => { - json_default(url2).then(function(result) { - delete inflight[tileID]; - if (!result) { - throw new Error("Unknown Error"); + if (!_cache5[ent].matches) { + var matches = {}; + var hasMatch = false; + for (var i3 = 0; i3 < _keys.length; i3++) { + if (_keys[i3] === "others") { + if (hasMatch) continue; + if (entity.type === "way") { + var parents = features.getParents(entity, resolver, geometry); + if (parents.length === 1 && parents[0].isMultipolygon() || // 2b. or belongs only to boundary relations + parents.length > 0 && parents.every(function(parent) { + return parent.tags.type === "boundary"; + })) { + var pkey = osmEntity.key(parents[0]); + if (_cache5[pkey] && _cache5[pkey].matches) { + matches = Object.assign({}, _cache5[pkey].matches); + continue; + } + } + } } - var vintage = { - start: localeDateString(result.resourceSets[0].resources[0].vintageStart), - end: localeDateString(result.resourceSets[0].resources[0].vintageEnd) - }; - vintage.range = vintageRange(vintage); - var metadata = { vintage }; - cache[tileID].metadata = metadata; - if (callback) callback(null, metadata); - }).catch(function(err) { - delete inflight[tileID]; - if (callback) callback(err.message); - }); - }); - }; - bing.terms_url = "https://blog.openstreetmap.org/2010/11/30/microsoft-imagery-details"; - return bing; - }; - rendererBackgroundSource.Esri = function(data) { - if (data.template.match(/blankTile/) === null) { - data.template = data.template + "?blankTile=false"; - } - var esri = rendererBackgroundSource(data); - var cache = {}; - var inflight = {}; - var _prevCenter; - esri.fetchTilemap = function(center) { - if (_prevCenter && geoSphericalDistance(center, _prevCenter) < 5e3) return; - _prevCenter = center; - var z2 = 20; - var dummyUrl = esri.url([1, 2, 3]); - var x2 = Math.floor((center[0] + 180) / 360 * Math.pow(2, z2)); - var y2 = Math.floor((1 - Math.log(Math.tan(center[1] * Math.PI / 180) + 1 / Math.cos(center[1] * Math.PI / 180)) / Math.PI) / 2 * Math.pow(2, z2)); - var tilemapUrl = dummyUrl.replace(/tile\/[0-9]+\/[0-9]+\/[0-9]+\?blankTile=false/, "tilemap") + "/" + z2 + "/" + y2 + "/" + x2 + "/8/8"; - json_default(tilemapUrl).then(function(tilemap) { - if (!tilemap) { - throw new Error("Unknown Error"); - } - var hasTiles = true; - for (var i3 = 0; i3 < tilemap.data.length; i3++) { - if (!tilemap.data[i3]) { - hasTiles = false; - break; + if (_rules[_keys[i3]].filter(entity.tags, geometry)) { + matches[_keys[i3]] = hasMatch = true; } } - esri.zoomExtent[1] = hasTiles ? 22 : 19; - }).catch(function() { - }); + _cache5[ent].matches = matches; + } + return _cache5[ent].matches; }; - esri.getMetadata = function(center, tileCoord, callback) { - if (esri.id !== "EsriWorldImagery") { - return callback(null, {}); - } - var tileID = tileCoord.slice(0, 3).join("/"); - var zoom = Math.min(tileCoord[2], esri.zoomExtent[1]); - var centerPoint = center[0] + "," + center[1]; - var unknown = _t("info_panels.background.unknown"); - var vintage = {}; - var metadata = {}; - if (inflight[tileID]) return; - var url = "https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/4/query"; - url += "?returnGeometry=false&geometry=" + centerPoint + "&inSR=4326&geometryType=esriGeometryPoint&outFields=*&f=json"; - if (!cache[tileID]) { - cache[tileID] = {}; - } - if (cache[tileID] && cache[tileID].metadata) { - return callback(null, cache[tileID].metadata); - } - inflight[tileID] = true; - json_default(url).then(function(result) { - delete inflight[tileID]; - 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) { - throw new Error("No Results"); - } else if (result.error && result.error.message) { - throw new Error(result.error.message); - } - var captureDate = localeDateString(result.SRC_DATE2); - vintage = { - start: captureDate, - end: captureDate, - range: captureDate - }; - metadata = { - vintage, - source: clean2(result.NICE_NAME), - description: clean2(result.NICE_DESC), - resolution: clean2(+Number(result.SRC_RES).toFixed(4)), - accuracy: clean2(+Number(result.SRC_ACC).toFixed(4)) - }; - if (isFinite(metadata.resolution)) { - metadata.resolution += " m"; - } - if (isFinite(metadata.accuracy)) { - metadata.accuracy += " m"; + features.getParents = function(entity, resolver, geometry) { + if (geometry === "point") return []; + var ent = osmEntity.key(entity); + if (!_cache5[ent]) { + _cache5[ent] = {}; + } + if (!_cache5[ent].parents) { + var parents = []; + if (geometry === "vertex") { + parents = resolver.parentWays(entity); + } else { + parents = resolver.parentRelations(entity); } - cache[tileID].metadata = metadata; - if (callback) callback(null, metadata); - }).catch(function(err) { - delete inflight[tileID]; - if (callback) callback(err.message); - }); - function clean2(val) { - return String(val).trim() || unknown; + _cache5[ent].parents = parents; } + return _cache5[ent].parents; }; - return esri; - }; - rendererBackgroundSource.None = function() { - var source = rendererBackgroundSource({ id: "none", template: "" }); - source.name = function() { - return _t("background.none"); + features.isHiddenPreset = function(preset, geometry) { + if (!_hidden.length) return false; + if (!preset.tags) return false; + var test = preset.setTags({}, geometry); + for (var key in _rules) { + if (_rules[key].filter(test, geometry)) { + if (_hidden.indexOf(key) !== -1) { + return key; + } + return false; + } + } + return false; }; - source.label = function() { - return _t.append("background.none"); + features.isHiddenFeature = function(entity, resolver, geometry) { + if (!_hidden.length) return false; + if (!entity.version) return false; + if (_forceVisible[entity.id]) return false; + var matches = Object.keys(features.getMatches(entity, resolver, geometry)); + return matches.length && matches.every(function(k2) { + return features.hidden(k2); + }); }; - source.imageryUsed = function() { - return null; + features.isHiddenChild = function(entity, resolver, geometry) { + if (!_hidden.length) return false; + if (!entity.version || geometry === "point") return false; + if (_forceVisible[entity.id]) return false; + var parents = features.getParents(entity, resolver, geometry); + if (!parents.length) return false; + for (var i3 = 0; i3 < parents.length; i3++) { + if (!features.isHidden(parents[i3], resolver, parents[i3].geometry(resolver))) { + return false; + } + } + return true; }; - source.area = function() { - return -1; + features.hasHiddenConnections = function(entity, resolver) { + if (!_hidden.length) return false; + var childNodes, connections; + if (entity.type === "midpoint") { + childNodes = [resolver.entity(entity.edge[0]), resolver.entity(entity.edge[1])]; + connections = []; + } else { + childNodes = entity.nodes ? resolver.childNodes(entity) : []; + connections = features.getParents(entity, resolver, entity.geometry(resolver)); + } + connections = childNodes.reduce(function(result, e3) { + return resolver.isShared(e3) ? utilArrayUnion(result, resolver.parentWays(e3)) : result; + }, connections); + return connections.some(function(e3) { + return features.isHidden(e3, resolver, e3.geometry(resolver)); + }); }; - return source; - }; - rendererBackgroundSource.Custom = function(template) { - var source = rendererBackgroundSource({ id: "custom", template }); - source.name = function() { - return _t("background.custom"); + features.isHidden = function(entity, resolver, geometry) { + if (!_hidden.length) return false; + if (!entity.version) return false; + var fn = geometry === "vertex" ? features.isHiddenChild : features.isHiddenFeature; + return fn(entity, resolver, geometry); }; - source.label = function() { - return _t.append("background.custom"); + features.filter = function(d2, resolver) { + if (!_hidden.length) return d2; + var result = []; + for (var i3 = 0; i3 < d2.length; i3++) { + var entity = d2[i3]; + if (!features.isHidden(entity, resolver, entity.geometry(resolver))) { + result.push(entity); + } + } + return result; }; - source.imageryUsed = function() { - var cleaned = source.template(); - if (cleaned.indexOf("?") !== -1) { - var parts = cleaned.split("?", 2); - var qs = utilStringQs(parts[1]); - ["access_token", "connectId", "token", "Signature"].forEach(function(param) { - if (qs[param]) { - qs[param] = "{apikey}"; + features.forceVisible = function(entityIDs) { + if (!arguments.length) return Object.keys(_forceVisible); + _forceVisible = {}; + for (var i3 = 0; i3 < entityIDs.length; i3++) { + _forceVisible[entityIDs[i3]] = true; + var entity = context.hasEntity(entityIDs[i3]); + if (entity && entity.type === "relation") { + for (var j2 in entity.members) { + _forceVisible[entity.members[j2].id] = true; } - }); - cleaned = parts[0] + "?" + utilQsString(qs, true); + } } - cleaned = cleaned.replace(/token\/(\w+)/, "token/{apikey}").replace(/key=(\w+)/, "key={apikey}"); - return "Custom (" + cleaned + " )"; - }; - source.area = function() { - return -2; + return features; }; - return source; - }; - - // node_modules/@turf/helpers/dist/esm/index.js - var earthRadius = 63710088e-1; - var factors = { - centimeters: earthRadius * 100, - centimetres: earthRadius * 100, - degrees: 360 / (2 * Math.PI), - feet: earthRadius * 3.28084, - inches: earthRadius * 39.37, - kilometers: earthRadius / 1e3, - kilometres: earthRadius / 1e3, - meters: earthRadius, - metres: earthRadius, - miles: earthRadius / 1609.344, - millimeters: earthRadius * 1e3, - millimetres: earthRadius * 1e3, - nauticalmiles: earthRadius / 1852, - radians: 1, - yards: earthRadius * 1.0936 - }; - function feature2(geom, properties, options2 = {}) { - const feat = { type: "Feature" }; - if (options2.id === 0 || options2.id) { - feat.id = options2.id; - } - if (options2.bbox) { - feat.bbox = options2.bbox; - } - feat.properties = properties || {}; - feat.geometry = geom; - return feat; - } - function polygon(coordinates, properties, options2 = {}) { - for (const ring of coordinates) { - if (ring.length < 4) { - throw new Error( - "Each LinearRing of a Polygon must have 4 or more Positions." - ); - } - if (ring[ring.length - 1].length !== ring[0].length) { - throw new Error("First and last Position are not equivalent."); + features.init = function() { + var storage = corePreferences("disabled-features"); + if (storage) { + var storageDisabled = storage.replace(/;/g, ",").split(","); + storageDisabled.forEach(features.disable); } - for (let 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."); - } + var hash2 = utilStringQs(window.location.hash); + if (hash2.disable_features) { + var hashDisabled = hash2.disable_features.replace(/;/g, ",").split(","); + hashDisabled.forEach(features.disable); } - } - const geom = { - type: "Polygon", - coordinates }; - return feature2(geom, properties, options2); + context.history().on("merge.features", function(newEntities) { + if (!newEntities) return; + var handle = window.requestIdleCallback(function() { + var graph = context.graph(); + var types = utilArrayGroupBy(newEntities, "type"); + var entities = [].concat(types.relation || [], types.way || [], types.node || []); + for (var i3 = 0; i3 < entities.length; i3++) { + var geometry = entities[i3].geometry(graph); + features.getMatches(entities[i3], graph, geometry); + } + }); + _deferred2.add(handle); + }); + return utilRebind(features, dispatch14, "on"); } - function lineString(coordinates, properties, options2 = {}) { - if (coordinates.length < 2) { - throw new Error("coordinates must be an array of two or more positions"); + var init_features = __esm({ + "modules/renderer/features.js"() { + "use strict"; + init_src4(); + init_preferences(); + init_osm(); + init_rebind(); + init_util(); } - const geom = { - type: "LineString", - coordinates - }; - return feature2(geom, properties, options2); - } - function multiLineString(coordinates, properties, options2 = {}) { - const geom = { - type: "MultiLineString", - coordinates - }; - return feature2(geom, properties, options2); - } - function multiPolygon(coordinates, properties, options2 = {}) { - const geom = { - type: "MultiPolygon", - coordinates - }; - return feature2(geom, properties, options2); - } + }); - // node_modules/@turf/invariant/dist/esm/index.js - function getGeom(geojson) { - if (geojson.type === "Feature") { - return geojson.geometry; + // modules/util/bind_once.js + var bind_once_exports = {}; + __export(bind_once_exports, { + utilBindOnce: () => utilBindOnce + }); + function utilBindOnce(target, type2, listener, capture) { + var typeOnce = type2 + ".once"; + function one2() { + target.on(typeOnce, null); + listener.apply(this, arguments); } - return geojson; + target.on(typeOnce, one2, capture); + return this; } - - // node_modules/@turf/bbox-clip/dist/esm/index.js - function lineclip(points, bbox2, result) { - var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i3, codeB, lastCode; - let a2; - let b2; - if (!result) result = []; - for (i3 = 1; i3 < len; i3++) { - a2 = points[i3 - 1]; - b2 = points[i3]; - codeB = lastCode = bitCode(b2, bbox2); - while (true) { - if (!(codeA | codeB)) { - part.push(a2); - if (codeB !== lastCode) { - part.push(b2); - if (i3 < len - 1) { - result.push(part); - part = []; - } - } else if (i3 === len - 1) { - part.push(b2); - } - break; - } else if (codeA & codeB) { - break; - } else if (codeA) { - a2 = intersect(a2, b2, codeA, bbox2); - codeA = bitCode(a2, bbox2); - } else { - b2 = intersect(a2, b2, codeB, bbox2); - codeB = bitCode(b2, bbox2); - } - } - codeA = lastCode; + var init_bind_once = __esm({ + "modules/util/bind_once.js"() { + "use strict"; } - if (part.length) result.push(part); - return result; + }); + + // modules/util/zoom_pan.js + var zoom_pan_exports = {}; + __export(zoom_pan_exports, { + utilZoomPan: () => utilZoomPan + }); + function defaultFilter3(d3_event) { + return !d3_event.ctrlKey && !d3_event.button; } - function polygonclip(points, bbox2) { - var result, edge, prev, prevInside, i3, p2, inside; - for (edge = 1; edge <= 8; edge *= 2) { - result = []; - prev = points[points.length - 1]; - prevInside = !(bitCode(prev, bbox2) & edge); - for (i3 = 0; i3 < points.length; i3++) { - p2 = points[i3]; - inside = !(bitCode(p2, bbox2) & edge); - if (inside !== prevInside) result.push(intersect(prev, p2, edge, bbox2)); - if (inside) result.push(p2); - prev = p2; - prevInside = inside; + function defaultExtent2() { + var e3 = this; + if (e3 instanceof SVGElement) { + e3 = e3.ownerSVGElement || e3; + if (e3.hasAttribute("viewBox")) { + e3 = e3.viewBox.baseVal; + return [[e3.x, e3.y], [e3.x + e3.width, e3.y + e3.height]]; } - points = result; - if (!points.length) break; + return [[0, 0], [e3.width.baseVal.value, e3.height.baseVal.value]]; } - return result; + return [[0, 0], [e3.clientWidth, e3.clientHeight]]; } - function intersect(a2, b2, edge, bbox2) { - return edge & 8 ? [a2[0] + (b2[0] - a2[0]) * (bbox2[3] - a2[1]) / (b2[1] - a2[1]), bbox2[3]] : edge & 4 ? [a2[0] + (b2[0] - a2[0]) * (bbox2[1] - a2[1]) / (b2[1] - a2[1]), bbox2[1]] : edge & 2 ? [bbox2[2], a2[1] + (b2[1] - a2[1]) * (bbox2[2] - a2[0]) / (b2[0] - a2[0])] : edge & 1 ? [bbox2[0], a2[1] + (b2[1] - a2[1]) * (bbox2[0] - a2[0]) / (b2[0] - a2[0])] : null; + function defaultWheelDelta2(d3_event) { + return -d3_event.deltaY * (d3_event.deltaMode === 1 ? 0.05 : d3_event.deltaMode ? 1 : 2e-3); } - function bitCode(p2, bbox2) { - var code = 0; - if (p2[0] < bbox2[0]) code |= 1; - else if (p2[0] > bbox2[2]) code |= 2; - if (p2[1] < bbox2[1]) code |= 4; - else if (p2[1] > bbox2[3]) code |= 8; - return code; + function defaultConstrain2(transform2, extent, translateExtent) { + var dx0 = transform2.invertX(extent[0][0]) - translateExtent[0][0], dx1 = transform2.invertX(extent[1][0]) - translateExtent[1][0], dy0 = transform2.invertY(extent[0][1]) - translateExtent[0][1], dy1 = transform2.invertY(extent[1][1]) - translateExtent[1][1]; + return transform2.translate( + dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1), + dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1) + ); } - function bboxClip(feature3, bbox2) { - const geom = getGeom(feature3); - const type2 = geom.type; - const properties = feature3.type === "Feature" ? feature3.properties : {}; - let coords = geom.coordinates; - switch (type2) { - case "LineString": - case "MultiLineString": { - const lines = []; - if (type2 === "LineString") { - coords = [coords]; - } - coords.forEach((line) => { - lineclip(line, bbox2, lines); + function utilZoomPan() { + var filter2 = defaultFilter3, extent = defaultExtent2, constrain = defaultConstrain2, wheelDelta = defaultWheelDelta2, scaleExtent = [0, Infinity], translateExtent = [[-Infinity, -Infinity], [Infinity, Infinity]], interpolate = zoom_default, dispatch14 = dispatch_default("start", "zoom", "end"), _wheelDelay = 150, _transform = identity2, _activeGesture; + function zoom(selection2) { + selection2.on("pointerdown.zoom", pointerdown).on("wheel.zoom", wheeled).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)"); + select_default2(window).on("pointermove.zoompan", pointermove).on("pointerup.zoompan pointercancel.zoompan", pointerup); + } + zoom.transform = function(collection, transform2, point) { + var selection2 = collection.selection ? collection.selection() : collection; + if (collection !== selection2) { + schedule(collection, transform2, point); + } else { + selection2.interrupt().each(function() { + gesture(this, arguments).start(null).zoom(null, null, typeof transform2 === "function" ? transform2.apply(this, arguments) : transform2).end(null); }); - if (lines.length === 1) { - return lineString(lines[0], properties); - } - return multiLineString(lines, properties); } - case "Polygon": - return polygon(clipPolygon(coords, bbox2), properties); - case "MultiPolygon": - return multiPolygon( - coords.map((poly) => { - return clipPolygon(poly, bbox2); - }), - properties - ); - default: - throw new Error("geometry " + type2 + " not supported"); + }; + zoom.scaleBy = function(selection2, k2, p2) { + zoom.scaleTo(selection2, function() { + var k0 = _transform.k, k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2; + return k0 * k1; + }, p2); + }; + zoom.scaleTo = function(selection2, k2, p2) { + zoom.transform(selection2, function() { + var e3 = extent.apply(this, arguments), t02 = _transform, p02 = !p2 ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2, p1 = t02.invert(p02), k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2; + return constrain(translate(scale(t02, k1), p02, p1), e3, translateExtent); + }, p2); + }; + zoom.translateBy = function(selection2, x2, y2) { + zoom.transform(selection2, function() { + return constrain(_transform.translate( + typeof x2 === "function" ? x2.apply(this, arguments) : x2, + typeof y2 === "function" ? y2.apply(this, arguments) : y2 + ), extent.apply(this, arguments), translateExtent); + }); + }; + zoom.translateTo = function(selection2, x2, y2, p2) { + zoom.transform(selection2, function() { + var e3 = extent.apply(this, arguments), t2 = _transform, p02 = !p2 ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2; + return constrain(identity2.translate(p02[0], p02[1]).scale(t2.k).translate( + typeof x2 === "function" ? -x2.apply(this, arguments) : -x2, + typeof y2 === "function" ? -y2.apply(this, arguments) : -y2 + ), e3, translateExtent); + }, p2); + }; + function scale(transform2, k2) { + k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k2)); + return k2 === transform2.k ? transform2 : new Transform(k2, transform2.x, transform2.y); } - } - function clipPolygon(rings, bbox2) { - const outRings = []; - for (const ring of rings) { - const clipped = polygonclip(ring, bbox2); - if (clipped.length > 0) { - if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) { - clipped.push(clipped[0]); + function translate(transform2, p02, p1) { + var x2 = p02[0] - p1[0] * transform2.k, y2 = p02[1] - p1[1] * transform2.k; + return x2 === transform2.x && y2 === transform2.y ? transform2 : new Transform(transform2.k, x2, y2); + } + function centroid(extent2) { + return [(+extent2[0][0] + +extent2[1][0]) / 2, (+extent2[0][1] + +extent2[1][1]) / 2]; + } + function schedule(transition2, transform2, point) { + transition2.on("start.zoom", function() { + gesture(this, arguments).start(null); + }).on("interrupt.zoom end.zoom", function() { + gesture(this, arguments).end(null); + }).tween("zoom", function() { + var that = this, args = arguments, g3 = gesture(that, args), e3 = extent.apply(that, args), p2 = !point ? centroid(e3) : typeof point === "function" ? point.apply(that, args) : point, w2 = Math.max(e3[1][0] - e3[0][0], e3[1][1] - e3[0][1]), a2 = _transform, b2 = typeof transform2 === "function" ? transform2.apply(that, args) : transform2, i3 = interpolate(a2.invert(p2).concat(w2 / a2.k), b2.invert(p2).concat(w2 / b2.k)); + return function(t2) { + if (t2 === 1) { + t2 = b2; + } else { + var l2 = i3(t2); + var k2 = w2 / l2[2]; + t2 = new Transform(k2, p2[0] - l2[0] * k2, p2[1] - l2[1] * k2); + } + g3.zoom(null, null, t2); + }; + }); + } + function gesture(that, args, clean2) { + return !clean2 && _activeGesture || new Gesture(that, args); + } + function Gesture(that, args) { + this.that = that; + this.args = args; + this.active = 0; + this.extent = extent.apply(that, args); + } + Gesture.prototype = { + start: function(d3_event) { + if (++this.active === 1) { + _activeGesture = this; + dispatch14.call("start", this, d3_event); } - if (clipped.length >= 4) { - outRings.push(clipped); + return this; + }, + zoom: function(d3_event, key, transform2) { + if (this.mouse && key !== "mouse") this.mouse[1] = transform2.invert(this.mouse[0]); + if (this.pointer0 && key !== "touch") this.pointer0[1] = transform2.invert(this.pointer0[0]); + if (this.pointer1 && key !== "touch") this.pointer1[1] = transform2.invert(this.pointer1[0]); + _transform = transform2; + dispatch14.call("zoom", this, d3_event, key, transform2); + return this; + }, + end: function(d3_event) { + if (--this.active === 0) { + _activeGesture = null; + dispatch14.call("end", this, d3_event); } + return this; } - } - return outRings; - } - var turf_bbox_clip_default = bboxClip; - - // node_modules/@turf/meta/dist/esm/index.js - function coordEach(geojson, callback, excludeWrapCoord) { - if (geojson === null) return; - 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; - stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1; - for (var geomIndex = 0; geomIndex < stopG; geomIndex++) { - var multiFeatureIndex = 0; - var geometryIndex = 0; - geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection; - if (geometry === null) continue; - coords = geometry.coordinates; - var geomType = geometry.type; - wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0; - switch (geomType) { - case null: - break; - case "Point": - if (callback( - coords, - coordIndex, - featureIndex, - multiFeatureIndex, - geometryIndex - ) === false) - return false; - coordIndex++; - multiFeatureIndex++; - break; - case "LineString": - case "MultiPoint": - for (j2 = 0; j2 < coords.length; j2++) { - if (callback( - coords[j2], - coordIndex, - featureIndex, - multiFeatureIndex, - geometryIndex - ) === false) - return false; - coordIndex++; - if (geomType === "MultiPoint") multiFeatureIndex++; - } - if (geomType === "LineString") multiFeatureIndex++; - break; - case "Polygon": - case "MultiLineString": - for (j2 = 0; j2 < coords.length; j2++) { - for (k2 = 0; k2 < coords[j2].length - wrapShrink; k2++) { - if (callback( - coords[j2][k2], - coordIndex, - featureIndex, - multiFeatureIndex, - geometryIndex - ) === false) - return false; - coordIndex++; - } - if (geomType === "MultiLineString") multiFeatureIndex++; - if (geomType === "Polygon") geometryIndex++; - } - if (geomType === "Polygon") multiFeatureIndex++; - break; - case "MultiPolygon": - for (j2 = 0; j2 < coords.length; j2++) { - geometryIndex = 0; - for (k2 = 0; k2 < coords[j2].length; k2++) { - for (l2 = 0; l2 < coords[j2][k2].length - wrapShrink; l2++) { - if (callback( - coords[j2][k2][l2], - coordIndex, - featureIndex, - multiFeatureIndex, - geometryIndex - ) === false) - return false; - coordIndex++; - } - geometryIndex++; - } - multiFeatureIndex++; - } - break; - case "GeometryCollection": - for (j2 = 0; j2 < geometry.geometries.length; j2++) - if (coordEach(geometry.geometries[j2], callback, excludeWrapCoord) === false) - return false; - break; - default: - throw new Error("Unknown Geometry Type"); + }; + function wheeled(d3_event) { + if (!filter2.apply(this, arguments)) return; + var g3 = gesture(this, arguments), t2 = _transform, k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], t2.k * Math.pow(2, wheelDelta.apply(this, arguments)))), p2 = utilFastMouse(this)(d3_event); + if (g3.wheel) { + if (g3.mouse[0][0] !== p2[0] || g3.mouse[0][1] !== p2[1]) { + g3.mouse[1] = t2.invert(g3.mouse[0] = p2); } + clearTimeout(g3.wheel); + } else { + g3.mouse = [p2, t2.invert(p2)]; + interrupt_default(this); + g3.start(d3_event); + } + d3_event.preventDefault(); + d3_event.stopImmediatePropagation(); + g3.wheel = setTimeout(wheelidled, _wheelDelay); + g3.zoom(d3_event, "mouse", constrain(translate(scale(t2, k2), g3.mouse[0], g3.mouse[1]), g3.extent, translateExtent)); + function wheelidled() { + g3.wheel = null; + g3.end(d3_event); + } + } + var _downPointerIDs = /* @__PURE__ */ new Set(); + var _pointerLocGetter; + function pointerdown(d3_event) { + _downPointerIDs.add(d3_event.pointerId); + if (!filter2.apply(this, arguments)) return; + var g3 = gesture(this, arguments, _downPointerIDs.size === 1); + var started; + d3_event.stopImmediatePropagation(); + _pointerLocGetter = utilFastMouse(this); + var loc = _pointerLocGetter(d3_event); + var p2 = [loc, _transform.invert(loc), d3_event.pointerId]; + if (!g3.pointer0) { + g3.pointer0 = p2; + started = true; + } else if (!g3.pointer1 && g3.pointer0[2] !== p2[2]) { + g3.pointer1 = p2; + } + if (started) { + interrupt_default(this); + g3.start(d3_event); + } + } + function pointermove(d3_event) { + if (!_downPointerIDs.has(d3_event.pointerId)) return; + if (!_activeGesture || !_pointerLocGetter) return; + var g3 = gesture(this, arguments); + var isPointer0 = g3.pointer0 && g3.pointer0[2] === d3_event.pointerId; + var isPointer1 = !isPointer0 && g3.pointer1 && g3.pointer1[2] === d3_event.pointerId; + if ((isPointer0 || isPointer1) && "buttons" in d3_event && !d3_event.buttons) { + if (g3.pointer0) _downPointerIDs.delete(g3.pointer0[2]); + if (g3.pointer1) _downPointerIDs.delete(g3.pointer1[2]); + g3.end(d3_event); + return; + } + d3_event.preventDefault(); + d3_event.stopImmediatePropagation(); + var loc = _pointerLocGetter(d3_event); + var t2, p2, l2; + if (isPointer0) g3.pointer0[0] = loc; + else if (isPointer1) g3.pointer1[0] = loc; + t2 = _transform; + if (g3.pointer1) { + var p02 = g3.pointer0[0], l0 = g3.pointer0[1], p1 = g3.pointer1[0], l1 = g3.pointer1[1], dp = (dp = p1[0] - p02[0]) * dp + (dp = p1[1] - p02[1]) * dp, dl = (dl = l1[0] - l0[0]) * dl + (dl = l1[1] - l0[1]) * dl; + t2 = scale(t2, Math.sqrt(dp / dl)); + p2 = [(p02[0] + p1[0]) / 2, (p02[1] + p1[1]) / 2]; + l2 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2]; + } else if (g3.pointer0) { + p2 = g3.pointer0[0]; + l2 = g3.pointer0[1]; + } else { + return; + } + g3.zoom(d3_event, "touch", constrain(translate(t2, p2, l2), g3.extent, translateExtent)); + } + function pointerup(d3_event) { + if (!_downPointerIDs.has(d3_event.pointerId)) return; + _downPointerIDs.delete(d3_event.pointerId); + if (!_activeGesture) return; + var g3 = gesture(this, arguments); + d3_event.stopImmediatePropagation(); + if (g3.pointer0 && g3.pointer0[2] === d3_event.pointerId) delete g3.pointer0; + else if (g3.pointer1 && g3.pointer1[2] === d3_event.pointerId) delete g3.pointer1; + if (g3.pointer1 && !g3.pointer0) { + g3.pointer0 = g3.pointer1; + delete g3.pointer1; + } + if (g3.pointer0) { + g3.pointer0[1] = _transform.invert(g3.pointer0[0]); + } else { + g3.end(d3_event); } } + zoom.wheelDelta = function(_2) { + return arguments.length ? (wheelDelta = utilFunctor(+_2), zoom) : wheelDelta; + }; + zoom.filter = function(_2) { + return arguments.length ? (filter2 = utilFunctor(!!_2), zoom) : filter2; + }; + zoom.extent = function(_2) { + return arguments.length ? (extent = utilFunctor([[+_2[0][0], +_2[0][1]], [+_2[1][0], +_2[1][1]]]), zoom) : extent; + }; + zoom.scaleExtent = function(_2) { + return arguments.length ? (scaleExtent[0] = +_2[0], scaleExtent[1] = +_2[1], zoom) : [scaleExtent[0], scaleExtent[1]]; + }; + zoom.translateExtent = function(_2) { + return arguments.length ? (translateExtent[0][0] = +_2[0][0], translateExtent[1][0] = +_2[1][0], translateExtent[0][1] = +_2[0][1], translateExtent[1][1] = +_2[1][1], zoom) : [[translateExtent[0][0], translateExtent[0][1]], [translateExtent[1][0], translateExtent[1][1]]]; + }; + zoom.constrain = function(_2) { + return arguments.length ? (constrain = _2, zoom) : constrain; + }; + zoom.interpolate = function(_2) { + return arguments.length ? (interpolate = _2, zoom) : interpolate; + }; + zoom._transform = function(_2) { + return arguments.length ? (_transform = _2, zoom) : _transform; + }; + return utilRebind(zoom, dispatch14, "on"); } + var init_zoom_pan = __esm({ + "modules/util/zoom_pan.js"() { + "use strict"; + init_src4(); + init_src8(); + init_src5(); + init_src11(); + init_src12(); + init_transform3(); + init_util2(); + init_rebind(); + } + }); - // node_modules/@turf/bbox/dist/esm/index.js - function bbox(geojson, options2 = {}) { - if (geojson.bbox != null && true !== options2.recompute) { - return geojson.bbox; + // modules/util/double_up.js + var double_up_exports = {}; + __export(double_up_exports, { + utilDoubleUp: () => utilDoubleUp + }); + function utilDoubleUp() { + var dispatch14 = dispatch_default("doubleUp"); + var _maxTimespan = 500; + var _maxDistance = 20; + var _pointer; + function pointerIsValidFor(loc) { + return (/* @__PURE__ */ new Date()).getTime() - _pointer.startTime <= _maxTimespan && // all pointer events must occur within a small distance of the first pointerdown + geoVecLength(_pointer.startLoc, loc) <= _maxDistance; } - const result = [Infinity, Infinity, -Infinity, -Infinity]; - coordEach(geojson, (coord2) => { - if (result[0] > coord2[0]) { - result[0] = coord2[0]; + function pointerdown(d3_event) { + if (d3_event.ctrlKey || d3_event.button === 2) return; + var loc = [d3_event.clientX, d3_event.clientY]; + if (_pointer && !pointerIsValidFor(loc)) { + _pointer = void 0; } - if (result[1] > coord2[1]) { - result[1] = coord2[1]; + if (!_pointer) { + _pointer = { + startLoc: loc, + startTime: (/* @__PURE__ */ new Date()).getTime(), + upCount: 0, + pointerId: d3_event.pointerId + }; + } else { + _pointer.pointerId = d3_event.pointerId; } - if (result[2] < coord2[0]) { - result[2] = coord2[0]; + } + function pointerup(d3_event) { + if (d3_event.ctrlKey || d3_event.button === 2) return; + if (!_pointer || _pointer.pointerId !== d3_event.pointerId) return; + _pointer.upCount += 1; + if (_pointer.upCount === 2) { + var loc = [d3_event.clientX, d3_event.clientY]; + if (pointerIsValidFor(loc)) { + var locInThis = utilFastMouse(this)(d3_event); + dispatch14.call("doubleUp", this, d3_event, locInThis); + } + _pointer = void 0; } - if (result[3] < coord2[1]) { - result[3] = coord2[1]; + } + function doubleUp(selection2) { + if ("PointerEvent" in window) { + selection2.on("pointerdown.doubleUp", pointerdown).on("pointerup.doubleUp", pointerup); + } else { + selection2.on("dblclick.doubleUp", function(d3_event) { + dispatch14.call("doubleUp", this, d3_event, utilFastMouse(this)(d3_event)); + }); } - }); - return result; + } + doubleUp.off = function(selection2) { + selection2.on("pointerdown.doubleUp", null).on("pointerup.doubleUp", null).on("dblclick.doubleUp", null); + }; + return utilRebind(doubleUp, dispatch14, "on"); } - var turf_bbox_default = bbox; - - // modules/renderer/background.js - var import_which_polygon3 = __toESM(require_which_polygon()); - - // modules/renderer/tile_layer.js - function rendererTileLayer(context) { - var transformProp = utilPrefixCSSProperty("Transform"); - var tiler8 = utilTiler(); - var _tileSize = 256; - var _projection; - var _cache5 = {}; - var _tileOrigin; - var _zoom; - var _source; - var _underzoom = 0; - function tileSizeAtZoom(d2, z2) { - return d2.tileSize * Math.pow(2, z2 - d2[2]) / d2.tileSize; + var init_double_up = __esm({ + "modules/util/double_up.js"() { + "use strict"; + init_src4(); + init_util2(); + init_rebind(); + init_vector(); } - function atZoom(t2, distance) { - var power = Math.pow(2, distance); - return [ - Math.floor(t2[0] * power), - Math.floor(t2[1] * power), - t2[2] + distance - ]; + }); + + // modules/renderer/map.js + var map_exports = {}; + __export(map_exports, { + rendererMap: () => rendererMap + }); + function clamp2(num, min3, max3) { + return Math.max(min3, Math.min(num, max3)); + } + function rendererMap(context) { + var dispatch14 = dispatch_default( + "move", + "drawn", + "crossEditableZoom", + "hitMinZoom", + "changeHighlighting", + "changeAreaFill" + ); + var projection2 = context.projection; + var curtainProjection = context.curtainProjection; + var drawLayers; + var drawPoints; + var drawVertices; + var drawLines; + var drawAreas; + var drawMidpoints; + var drawLabels; + var _selection = select_default2(null); + var supersurface = select_default2(null); + var wrapper = select_default2(null); + var surface = select_default2(null); + var _dimensions = [1, 1]; + var _dblClickZoomEnabled = true; + var _redrawEnabled = true; + var _gestureTransformStart; + var _transformStart = projection2.transform(); + var _transformLast; + var _isTransformed = false; + var _minzoom = 0; + var _getMouseCoords; + var _lastPointerEvent; + var _lastWithinEditableZoom; + var _pointerDown = false; + var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse"; + var _zoomerPannerFunction = "PointerEvent" in window ? utilZoomPan : zoom_default2; + var _zoomerPanner = _zoomerPannerFunction().scaleExtent([kMin, kMax]).interpolate(value_default).filter(zoomEventFilter).on("zoom.map", zoomPan2).on("start.map", function(d3_event) { + _pointerDown = d3_event && (d3_event.type === "pointerdown" || d3_event.sourceEvent && d3_event.sourceEvent.type === "pointerdown"); + }).on("end.map", function() { + _pointerDown = false; + }); + var _doubleUpHandler = utilDoubleUp(); + var scheduleRedraw = throttle_default(redraw, 750); + function cancelPendingRedraw() { + scheduleRedraw.cancel(); } - function lookUp(d2) { - for (var up = -1; up > -d2[2]; up--) { - var tile = atZoom(d2, up); - if (_cache5[_source.url(tile)] !== false) { - return tile; + function map2(selection2) { + _selection = selection2; + context.on("change.map", immediateRedraw); + var osm = context.connection(); + if (osm) { + osm.on("change.map", immediateRedraw); + } + function didUndoOrRedo(targetTransform) { + var mode = context.mode().id; + if (mode !== "browse" && mode !== "select") return; + if (targetTransform) { + map2.transformEase(targetTransform); + } + } + context.history().on("merge.map", function() { + scheduleRedraw(); + }).on("change.map", immediateRedraw).on("undone.map", function(stack, fromStack) { + didUndoOrRedo(fromStack.transform); + }).on("redone.map", function(stack) { + didUndoOrRedo(stack.transform); + }); + context.background().on("change.map", immediateRedraw); + context.features().on("redraw.map", immediateRedraw); + drawLayers.on("change.map", function() { + context.background().updateImagery(); + immediateRedraw(); + }); + selection2.on("wheel.map mousewheel.map", function(d3_event) { + d3_event.preventDefault(); + }).call(_zoomerPanner).call(_zoomerPanner.transform, projection2.transform()).on("dblclick.zoom", null); + map2.supersurface = supersurface = selection2.append("div").attr("class", "supersurface").call(utilSetTransform, 0, 0); + wrapper = supersurface.append("div").attr("class", "layer layer-data"); + map2.surface = surface = wrapper.call(drawLayers).selectAll(".surface"); + surface.call(drawLabels.observe).call(_doubleUpHandler).on(_pointerPrefix + "down.zoom", function(d3_event) { + _lastPointerEvent = d3_event; + if (d3_event.button === 2) { + d3_event.stopPropagation(); + } + }, true).on(_pointerPrefix + "up.zoom", function(d3_event) { + _lastPointerEvent = d3_event; + if (resetTransform()) { + immediateRedraw(); + } + }).on(_pointerPrefix + "move.map", function(d3_event) { + _lastPointerEvent = d3_event; + }).on(_pointerPrefix + "over.vertices", function(d3_event) { + if (map2.editableDataEnabled() && !_isTransformed) { + var hover = d3_event.target.__data__; + surface.call(drawVertices.drawHover, context.graph(), hover, map2.extent()); + dispatch14.call("drawn", this, { full: false }); + } + }).on(_pointerPrefix + "out.vertices", function(d3_event) { + if (map2.editableDataEnabled() && !_isTransformed) { + var hover = d3_event.relatedTarget && d3_event.relatedTarget.__data__; + surface.call(drawVertices.drawHover, context.graph(), hover, map2.extent()); + dispatch14.call("drawn", this, { full: false }); } + }); + var detected = utilDetect(); + if ("GestureEvent" in window && // Listening for gesture events on iOS 13.4+ breaks double-tapping, + // but we only need to do this on desktop Safari anyway. – #7694 + !detected.isMobileWebKit) { + surface.on("gesturestart.surface", function(d3_event) { + d3_event.preventDefault(); + _gestureTransformStart = projection2.transform(); + }).on("gesturechange.surface", gestureChange); } + updateAreaFill(); + _doubleUpHandler.on("doubleUp.map", function(d3_event, p02) { + if (!_dblClickZoomEnabled) return; + if (typeof d3_event.target.__data__ === "object" && // or area fills + !select_default2(d3_event.target).classed("fill")) return; + var zoomOut2 = d3_event.shiftKey; + var t2 = projection2.transform(); + var p1 = t2.invert(p02); + t2 = t2.scale(zoomOut2 ? 0.5 : 2); + t2.x = p02[0] - p1[0] * t2.k; + t2.y = p02[1] - p1[1] * t2.k; + map2.transformEase(t2); + }); + context.on("enter.map", function() { + if (!map2.editableDataEnabled( + true + /* skip zoom check */ + )) return; + if (_isTransformed) return; + var graph = context.graph(); + var selectedAndParents = {}; + context.selectedIDs().forEach(function(id2) { + var entity = graph.hasEntity(id2); + if (entity) { + selectedAndParents[entity.id] = entity; + if (entity.type === "node") { + graph.parentWays(entity).forEach(function(parent) { + selectedAndParents[parent.id] = parent; + }); + } + } + }); + var data = Object.values(selectedAndParents); + var filter2 = function(d2) { + return d2.id in selectedAndParents; + }; + data = context.features().filter(data, graph); + surface.call(drawVertices.drawSelected, graph, map2.extent()).call(drawLines, graph, data, filter2).call(drawAreas, graph, data, filter2).call(drawMidpoints, graph, data, filter2, map2.trimmedExtent()); + dispatch14.call("drawn", this, { full: false }); + scheduleRedraw(); + }); + map2.dimensions(utilGetDimensions(selection2)); } - function uniqueBy(a2, n3) { - var o2 = []; - var seen = {}; - for (var i3 = 0; i3 < a2.length; i3++) { - if (seen[a2[i3][n3]] === void 0) { - o2.push(a2[i3]); - seen[a2[i3][n3]] = true; + function zoomEventFilter(d3_event) { + if (d3_event.type === "mousedown") { + var hasOrphan = false; + var listeners = window.__on; + for (var i3 = 0; i3 < listeners.length; i3++) { + var listener = listeners[i3]; + if (listener.name === "zoom" && listener.type === "mouseup") { + hasOrphan = true; + break; + } + } + if (hasOrphan) { + var event = window.CustomEvent; + if (event) { + event = new event("mouseup"); + } else { + event = window.document.createEvent("Event"); + event.initEvent("mouseup", false, false); + } + event.view = window; + window.dispatchEvent(event); } } - return o2; + return d3_event.button !== 2; } - function addSource(d2) { - d2.url = _source.url(d2); - d2.tileSize = _tileSize; - d2.source = _source; - return d2; + function pxCenter() { + return [_dimensions[0] / 2, _dimensions[1] / 2]; } - function background(selection2) { - _zoom = geoScaleToZoom(_projection.scale(), _tileSize); - var pixelOffset; - if (_source) { - pixelOffset = [ - _source.offset()[0] * Math.pow(2, _zoom), - _source.offset()[1] * Math.pow(2, _zoom) - ]; + 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 set4; + var filter2; + var applyFeatureLayerFilters = true; + if (map2.isInWideSelection()) { + data = []; + utilEntityAndDeepMemberIDs(mode.selectedIDs(), context.graph()).forEach(function(id2) { + var entity = context.hasEntity(id2); + if (entity) data.push(entity); + }); + fullRedraw = true; + filter2 = utilFunctor(true); + applyFeatureLayerFilters = false; + } else if (difference2) { + var complete = difference2.complete(map2.extent()); + data = Object.values(complete).filter(Boolean); + set4 = new Set(Object.keys(complete)); + filter2 = function(d2) { + return set4.has(d2.id); + }; + features.clear(data); } else { - pixelOffset = [0, 0]; + if (features.gatherStats(all, graph, _dimensions)) { + extent = void 0; + } + if (extent) { + data = context.history().intersects(map2.extent().intersection(extent)); + set4 = new Set(data.map(function(entity) { + return entity.id; + })); + filter2 = function(d2) { + return set4.has(d2.id); + }; + } else { + data = all; + fullRedraw = true; + filter2 = utilFunctor(true); + } } - tiler8.scale(_projection.scale() * 2 * Math.PI).translate([ - _projection.translate()[0] + pixelOffset[0], - _projection.translate()[1] + pixelOffset[1] - ]); - _tileOrigin = [ - _projection.scale() * Math.PI - _projection.translate()[0], - _projection.scale() * Math.PI - _projection.translate()[1] - ]; - render(selection2); + if (applyFeatureLayerFilters) { + data = features.filter(data, graph); + } else { + context.features().resetStats(); + } + if (mode && mode.id === "select") { + surface.call(drawVertices.drawSelected, graph, map2.extent()); + } + surface.call(drawVertices, graph, data, filter2, map2.extent(), fullRedraw).call(drawLines, graph, data, filter2).call(drawAreas, graph, data, filter2).call(drawMidpoints, graph, data, filter2, map2.trimmedExtent()).call(drawLabels, graph, data, filter2, _dimensions, fullRedraw).call(drawPoints, graph, data, filter2); + dispatch14.call("drawn", this, { full: true }); } - function render(selection2) { - if (!_source) return; - var requests = []; - var showDebug = context.getDebug("tile") && !_source.overlay; - if (_source.validZoom(_zoom, _underzoom)) { - tiler8.skipNullIsland(!!_source.overlay); - tiler8().forEach(function(d2) { - addSource(d2); - if (d2.url === "") return; - if (typeof d2.url !== "string") return; - requests.push(d2); - if (_cache5[d2.url] === false && lookUp(d2)) { - requests.push(addSource(lookUp(d2))); + map2.init = function() { + drawLayers = svgLayers(projection2, context); + drawPoints = svgPoints(projection2, context); + drawVertices = svgVertices(projection2, context); + drawLines = svgLines(projection2, context); + drawAreas = svgAreas(projection2, context); + drawMidpoints = svgMidpoints(projection2, context); + drawLabels = svgLabels(projection2, context); + }; + function editOff() { + context.features().resetStats(); + surface.selectAll(".layer-osm *").remove(); + surface.selectAll(".layer-touch:not(.markers) *").remove(); + var allowed = { + "browse": true, + "save": true, + "select-note": true, + "select-data": true, + "select-error": true + }; + var mode = context.mode(); + if (mode && !allowed[mode.id]) { + context.enter(modeBrowse(context)); + } + dispatch14.call("drawn", this, { full: true }); + } + function gestureChange(d3_event) { + var e3 = d3_event; + e3.preventDefault(); + var props = { + deltaMode: 0, + // dummy values to ignore in zoomPan + deltaY: 1, + // dummy values to ignore in zoomPan + clientX: e3.clientX, + clientY: e3.clientY, + screenX: e3.screenX, + screenY: e3.screenY, + x: e3.x, + y: e3.y + }; + var e22 = new WheelEvent("wheel", props); + e22._scale = e3.scale; + e22._rotation = e3.rotation; + _selection.node().dispatchEvent(e22); + } + function zoomPan2(event, key, transform2) { + var source = event && event.sourceEvent || event; + var eventTransform = transform2 || event && event.transform; + var x2 = eventTransform.x; + var y2 = eventTransform.y; + var k2 = eventTransform.k; + if (source && source.type === "wheel") { + if (_pointerDown) return; + var detected = utilDetect(); + var dX = source.deltaX; + var dY = source.deltaY; + var x22 = x2; + var y22 = y2; + var k22 = k2; + var t02, p02, p1; + if (source.deltaMode === 1) { + var lines = Math.abs(source.deltaY); + var sign2 = source.deltaY > 0 ? 1 : -1; + dY = sign2 * clamp2( + lines * 18.001, + 4.000244140625, + // min + 350.000244140625 + // max + ); + t02 = _isTransformed ? _transformLast : _transformStart; + p02 = _getMouseCoords(source); + p1 = t02.invert(p02); + k22 = t02.k * Math.pow(2, -dY / 500); + k22 = clamp2(k22, kMin, kMax); + x22 = p02[0] - p1[0] * k22; + y22 = p02[1] - p1[1] * k22; + } else if (source._scale) { + t02 = _gestureTransformStart; + p02 = _getMouseCoords(source); + p1 = t02.invert(p02); + k22 = t02.k * source._scale; + k22 = clamp2(k22, kMin, kMax); + x22 = p02[0] - p1[0] * k22; + y22 = p02[1] - p1[1] * k22; + } else if (source.ctrlKey && !isInteger(dY)) { + dY *= 6; + t02 = _isTransformed ? _transformLast : _transformStart; + p02 = _getMouseCoords(source); + p1 = t02.invert(p02); + k22 = t02.k * Math.pow(2, -dY / 500); + 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)) { + t02 = _isTransformed ? _transformLast : _transformStart; + p02 = _getMouseCoords(source); + p1 = t02.invert(p02); + k22 = t02.k * Math.pow(2, -dY / 500); + 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)) { + p1 = projection2.translate(); + x22 = p1[0] - dX; + y22 = p1[1] - dY; + k22 = projection2.scale(); + k22 = clamp2(k22, kMin, kMax); + } + if (x22 !== x2 || y22 !== y2 || k22 !== k2) { + x2 = x22; + y2 = y22; + k2 = k22; + eventTransform = identity2.translate(x22, y22).scale(k22); + if (_zoomerPanner._transform) { + _zoomerPanner._transform(eventTransform); + } else { + _selection.node().__zoom = eventTransform; } - }); - requests = uniqueBy(requests, "url").filter(function(r2) { - return _cache5[r2.url] !== false; - }); + } } - function load(d3_event, d2) { - _cache5[d2.url] = true; - select_default2(this).on("error", null).on("load", null); - render(selection2); + if (_transformStart.x === x2 && _transformStart.y === y2 && _transformStart.k === k2) { + return; } - function error(d3_event, d2) { - _cache5[d2.url] = false; - select_default2(this).on("error", null).on("load", null).remove(); - render(selection2); + if (geoScaleToZoom(k2, TILESIZE) < _minzoom) { + surface.interrupt(); + dispatch14.call("hitMinZoom", this, map2); + setCenterZoom(map2.center(), context.minEditableZoom(), 0, true); + scheduleRedraw(); + dispatch14.call("move", this, map2); + return; } - function imageTransform(d2) { - var ts = d2.tileSize * Math.pow(2, _zoom - d2[2]); - var scale = tileSizeAtZoom(d2, _zoom); - return "translate(" + ((d2[0] * ts + d2.source.offset()[0] * Math.pow(2, _zoom)) * _tileSize / d2.tileSize - _tileOrigin[0]) + "px," + ((d2[1] * ts + d2.source.offset()[1] * Math.pow(2, _zoom)) * _tileSize / d2.tileSize - _tileOrigin[1]) + "px) scale(" + scale * _tileSize / d2.tileSize + "," + scale * _tileSize / d2.tileSize + ")"; + projection2.transform(eventTransform); + var withinEditableZoom = map2.withinEditableZoom(); + if (_lastWithinEditableZoom !== withinEditableZoom) { + if (_lastWithinEditableZoom !== void 0) { + dispatch14.call("crossEditableZoom", this, withinEditableZoom); + } + _lastWithinEditableZoom = withinEditableZoom; } - function tileCenter(d2) { - var ts = d2.tileSize * Math.pow(2, _zoom - d2[2]); - return [ - d2[0] * ts - _tileOrigin[0] + ts / 2, - d2[1] * ts - _tileOrigin[1] + ts / 2 - ]; + var scale = k2 / _transformStart.k; + var tX = (x2 / scale - _transformStart.x) * scale; + var tY = (y2 / scale - _transformStart.y) * scale; + if (context.inIntro()) { + curtainProjection.transform({ + x: x2 - tX, + y: y2 - tY, + k: k2 + }); } - function debugTransform(d2) { - var coord2 = tileCenter(d2); - return "translate(" + coord2[0] + "px," + coord2[1] + "px)"; + if (source) { + _lastPointerEvent = event; } - var dims = tiler8.size(); - var mapCenter = [dims[0] / 2, dims[1] / 2]; - var minDist = Math.max(dims[0], dims[1]); - var nearCenter; - requests.forEach(function(d2) { - var c2 = tileCenter(d2); - var dist = geoVecLength(c2, mapCenter); - if (dist < minDist) { - minDist = dist; - nearCenter = d2; - } - }); - var image = selection2.selectAll("img").data(requests, function(d2) { - return d2.url; - }); - image.exit().style(transformProp, imageTransform).classed("tile-removing", true).classed("tile-center", false).on("transitionend", function() { - const tile = select_default2(this); - if (tile.classed("tile-removing")) { - tile.remove(); - } - }); - image.enter().append("img").attr("class", "tile").attr("alt", "").attr("draggable", "false").style("width", _tileSize + "px").style("height", _tileSize + "px").attr("src", function(d2) { - return d2.url; - }).on("error", error).on("load", load).merge(image).style(transformProp, imageTransform).classed("tile-debug", showDebug).classed("tile-removing", false).classed("tile-center", function(d2) { - return d2 === nearCenter; - }).sort((a2, b2) => a2[2] - b2[2]); - var debug2 = selection2.selectAll(".tile-label-debug").data(showDebug ? requests : [], function(d2) { - return d2.url; - }); - debug2.exit().remove(); - if (showDebug) { - var debugEnter = debug2.enter().append("div").attr("class", "tile-label-debug"); - debugEnter.append("div").attr("class", "tile-label-debug-coord"); - debugEnter.append("div").attr("class", "tile-label-debug-vintage"); - debug2 = debug2.merge(debugEnter); - debug2.style(transformProp, debugTransform); - debug2.selectAll(".tile-label-debug-coord").text(function(d2) { - return d2[2] + " / " + d2[0] + " / " + d2[1]; - }); - debug2.selectAll(".tile-label-debug-vintage").each(function(d2) { - var span = select_default2(this); - var center = context.projection.invert(tileCenter(d2)); - _source.getMetadata(center, d2, function(err, result) { - if (result && result.vintage && result.vintage.range) { - span.text(result.vintage.range); - } else { - span.text(""); - span.call(_t.append("info_panels.background.vintage")); - span.append("span").text(": "); - span.call(_t.append("info_panels.background.unknown")); - } - }); - }); + _isTransformed = true; + _transformLast = eventTransform; + utilSetTransform(supersurface, tX, tY, scale); + scheduleRedraw(); + dispatch14.call("move", this, map2); + function isInteger(val) { + return typeof val === "number" && isFinite(val) && Math.floor(val) === val; } } - background.projection = function(val) { - if (!arguments.length) return _projection; - _projection = val; - return background; - }; - background.dimensions = function(val) { - if (!arguments.length) return tiler8.size(); - tiler8.size(val); - return background; - }; - background.source = function(val) { - if (!arguments.length) return _source; - _source = val; - _tileSize = _source.tileSize; - _cache5 = {}; - tiler8.tileSize(_source.tileSize).zoomExtent(_source.zoomExtent); - return background; - }; - background.underzoom = function(amount) { - if (!arguments.length) return _underzoom; - _underzoom = amount; - return background; - }; - return background; - } - - // modules/renderer/background.js - var _imageryIndex = null; - function rendererBackground(context) { - const dispatch14 = dispatch_default("change"); - const baseLayer = rendererTileLayer(context).projection(context.projection); - let _checkedBlocklists = []; - let _isValid = true; - let _overlayLayers = []; - let _brightness = 1; - let _contrast = 1; - let _saturation = 1; - let _sharpness = 1; - function ensureImageryIndex() { - return _mainFileFetcher.get("imagery").then((sources) => { - if (_imageryIndex) return _imageryIndex; - _imageryIndex = { - imagery: sources, - features: {} - }; - const features = sources.map((source) => { - if (!source.polygon) return null; - const rings = source.polygon.map((ring) => [ring]); - const feature3 = { - type: "Feature", - properties: { id: source.id }, - geometry: { type: "MultiPolygon", coordinates: rings } - }; - _imageryIndex.features[source.id] = feature3; - return feature3; - }).filter(Boolean); - _imageryIndex.query = (0, import_which_polygon3.default)({ type: "FeatureCollection", features }); - _imageryIndex.backgrounds = sources.map((source) => { - if (source.type === "bing") { - return rendererBackgroundSource.Bing(source, dispatch14); - } else if (/^EsriWorldImagery/.test(source.id)) { - return rendererBackgroundSource.Esri(source); - } else { - return rendererBackgroundSource(source); - } - }); - _imageryIndex.backgrounds.unshift(rendererBackgroundSource.None()); - let template = corePreferences("background-custom-template") || ""; - const custom = rendererBackgroundSource.Custom(template); - _imageryIndex.backgrounds.unshift(custom); - return _imageryIndex; - }); + function resetTransform() { + if (!_isTransformed) return false; + utilSetTransform(supersurface, 0, 0); + _isTransformed = false; + if (context.inIntro()) { + curtainProjection.transform(projection2.transform()); + } + return true; } - function background(selection2) { - const currSource = baseLayer.source(); - if (context.map().zoom() > 18) { - if (currSource && /^EsriWorldImagery/.test(currSource.id)) { - const center = context.map().center(); - currSource.fetchTilemap(center); - } + function redraw(difference2, extent) { + if (typeof window === "undefined") return; + if (surface.empty() || !_redrawEnabled) return; + if (resetTransform()) { + difference2 = extent = void 0; } - const sources = background.sources(context.map().extent()); - const wasValid = _isValid; - _isValid = !!sources.filter((d2) => d2 === currSource).length; - if (wasValid !== _isValid) { - background.updateImagery(); + var zoom = map2.zoom(); + var z2 = String(~~zoom); + if (surface.attr("data-zoom") !== z2) { + surface.attr("data-zoom", z2); } - let baseFilter = ""; - if (_brightness !== 1) { - baseFilter += " brightness(".concat(_brightness, ")"); + 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 (!difference2) { + supersurface.call(context.background()); + wrapper.call(drawLayers); } - if (_contrast !== 1) { - baseFilter += " contrast(".concat(_contrast, ")"); + if (map2.editableDataEnabled() || map2.isInWideSelection()) { + context.loadTiles(projection2); + drawEditable(difference2, extent); + } else { + editOff(); } - if (_saturation !== 1) { - baseFilter += " saturate(".concat(_saturation, ")"); + _transformStart = projection2.transform(); + return map2; + } + var immediateRedraw = function(difference2, extent) { + if (!difference2 && !extent) cancelPendingRedraw(); + redraw(difference2, extent); + }; + map2.lastPointerEvent = function() { + return _lastPointerEvent; + }; + map2.mouse = function(d3_event) { + var event = d3_event || _lastPointerEvent; + if (event) { + var s2; + while (s2 = event.sourceEvent) { + event = s2; + } + return _getMouseCoords(event); } - if (_sharpness < 1) { - const blur = number_default(0.5, 5)(1 - _sharpness); - baseFilter += " blur(".concat(blur, "px)"); + return null; + }; + map2.mouseCoordinates = function() { + var coord2 = map2.mouse() || pxCenter(); + return projection2.invert(coord2); + }; + map2.dblclickZoomEnable = function(val) { + if (!arguments.length) return _dblClickZoomEnabled; + _dblClickZoomEnabled = val; + return map2; + }; + map2.redrawEnable = function(val) { + if (!arguments.length) return _redrawEnabled; + _redrawEnabled = val; + return map2; + }; + map2.isTransformed = function() { + return _isTransformed; + }; + function setTransform(t2, duration, force) { + var t3 = projection2.transform(); + if (!force && t2.k === t3.k && t2.x === t3.x && t2.y === t3.y) return false; + if (duration) { + _selection.transition().duration(duration).on("start", function() { + map2.startEase(); + }).call(_zoomerPanner.transform, identity2.translate(t2.x, t2.y).scale(t2.k)); + } else { + projection2.transform(t2); + _transformStart = t2; + _selection.call(_zoomerPanner.transform, _transformStart); } - let base = selection2.selectAll(".layer-background").data([0]); - base = base.enter().insert("div", ".layer-data").attr("class", "layer layer-background").merge(base); - base.style("filter", baseFilter || null); - let imagery = base.selectAll(".layer-imagery").data([0]); - imagery.enter().append("div").attr("class", "layer layer-imagery").merge(imagery).call(baseLayer); - let maskFilter = ""; - let mixBlendMode = ""; - if (_sharpness > 1) { - mixBlendMode = "overlay"; - maskFilter = "saturate(0) blur(3px) invert(1)"; - let contrast = _sharpness - 1; - maskFilter += " contrast(".concat(contrast, ")"); - let brightness = number_default(1, 0.85)(_sharpness - 1); - maskFilter += " brightness(".concat(brightness, ")"); + return true; + } + function setCenterZoom(loc2, z2, duration, force) { + var c2 = map2.center(); + var z3 = map2.zoom(); + if (loc2[0] === c2[0] && loc2[1] === c2[1] && z2 === z3 && !force) return false; + var proj = geoRawMercator().transform(projection2.transform()); + var k2 = clamp2(geoZoomToScale(z2, TILESIZE), kMin, kMax); + proj.scale(k2); + var t2 = proj.translate(); + var point = proj(loc2); + var center = pxCenter(); + t2[0] += center[0] - point[0]; + t2[1] += center[1] - point[1]; + return setTransform(identity2.translate(t2[0], t2[1]).scale(k2), duration, force); + } + map2.pan = function(delta, duration) { + var t2 = projection2.translate(); + var k2 = projection2.scale(); + t2[0] += delta[0]; + t2[1] += delta[1]; + if (duration) { + _selection.transition().duration(duration).on("start", function() { + map2.startEase(); + }).call(_zoomerPanner.transform, identity2.translate(t2[0], t2[1]).scale(k2)); + } else { + projection2.translate(t2); + _transformStart = projection2.transform(); + _selection.call(_zoomerPanner.transform, _transformStart); + dispatch14.call("move", this, map2); + immediateRedraw(); } - let mask = base.selectAll(".layer-unsharp-mask").data(_sharpness > 1 ? [0] : []); - mask.exit().remove(); - mask.enter().append("div").attr("class", "layer layer-mask layer-unsharp-mask").merge(mask).call(baseLayer).style("filter", maskFilter || null).style("mix-blend-mode", mixBlendMode || null); - let overlays = selection2.selectAll(".layer-overlay").data(_overlayLayers, (d2) => d2.source().name()); - overlays.exit().remove(); - overlays.enter().insert("div", ".layer-data").attr("class", "layer layer-overlay").merge(overlays).each((layer, i3, nodes) => select_default2(nodes[i3]).call(layer)); + return map2; + }; + map2.dimensions = function(val) { + if (!arguments.length) return _dimensions; + _dimensions = val; + drawLayers.dimensions(_dimensions); + context.background().dimensions(_dimensions); + projection2.clipExtent([[0, 0], _dimensions]); + _getMouseCoords = utilFastMouse(supersurface.node()); + scheduleRedraw(); + return map2; + }; + function zoomIn(delta) { + setCenterZoom(map2.center(), ~~map2.zoom() + delta, 250, true); } - background.updateImagery = function() { - let currSource = baseLayer.source(); - if (context.inIntro() || !currSource) return; - let o2 = _overlayLayers.filter((d2) => !d2.source().isLocatorOverlay() && !d2.source().isHidden()).map((d2) => d2.source().id).join(","); - const meters = geoOffsetToMeters(currSource.offset()); - const EPSILON = 0.01; - const x2 = +meters[0].toFixed(2); - const y2 = +meters[1].toFixed(2); - let hash2 = utilStringQs(window.location.hash); - let id2 = currSource.id; - if (id2 === "custom") { - id2 = "custom:".concat(currSource.template()); + function zoomOut(delta) { + setCenterZoom(map2.center(), ~~map2.zoom() - delta, 250, true); + } + map2.zoomIn = function() { + zoomIn(1); + }; + map2.zoomInFurther = function() { + zoomIn(4); + }; + map2.canZoomIn = function() { + return map2.zoom() < maxZoom; + }; + map2.zoomOut = function() { + zoomOut(1); + }; + map2.zoomOutFurther = function() { + zoomOut(4); + }; + map2.canZoomOut = function() { + return map2.zoom() > minZoom2; + }; + map2.center = function(loc2) { + if (!arguments.length) { + return projection2.invert(pxCenter()); } - if (id2) { - hash2.background = id2; - } else { - delete hash2.background; + if (setCenterZoom(loc2, map2.zoom())) { + dispatch14.call("move", this, map2); } - if (o2) { - hash2.overlays = o2; - } else { - delete hash2.overlays; + scheduleRedraw(); + return map2; + }; + map2.unobscuredCenterZoomEase = function(loc, zoom) { + var offset = map2.unobscuredOffsetPx(); + var proj = geoRawMercator().transform(projection2.transform()); + proj.scale(geoZoomToScale(zoom, TILESIZE)); + var locPx = proj(loc); + var offsetLocPx = [locPx[0] + offset[0], locPx[1] + offset[1]]; + var offsetLoc = proj.invert(offsetLocPx); + map2.centerZoomEase(offsetLoc, zoom); + }; + map2.unobscuredOffsetPx = function() { + var openPane = context.container().select(".map-panes .map-pane.shown"); + if (!openPane.empty()) { + return [openPane.node().offsetWidth / 2, 0]; } - if (Math.abs(x2) > EPSILON || Math.abs(y2) > EPSILON) { - hash2.offset = "".concat(x2, ",").concat(y2); - } else { - delete hash2.offset; + return [0, 0]; + }; + map2.zoom = function(z2) { + if (!arguments.length) { + return Math.max(geoScaleToZoom(projection2.scale(), TILESIZE), 0); } - if (!window.mocha) { - window.location.replace("#" + utilQsString(hash2, true)); + if (z2 < _minzoom) { + surface.interrupt(); + dispatch14.call("hitMinZoom", this, map2); + z2 = context.minEditableZoom(); } - let imageryUsed = []; - let photoOverlaysUsed = []; - const currUsed = currSource.imageryUsed(); - if (currUsed && _isValid) { - imageryUsed.push(currUsed); + if (setCenterZoom(map2.center(), z2)) { + dispatch14.call("move", this, map2); } - _overlayLayers.filter((d2) => !d2.source().isLocatorOverlay() && !d2.source().isHidden()).forEach((d2) => imageryUsed.push(d2.source().imageryUsed())); - const dataLayer = context.layers().layer("data"); - if (dataLayer && dataLayer.enabled() && dataLayer.hasData()) { - imageryUsed.push(dataLayer.getSrc()); + scheduleRedraw(); + return map2; + }; + map2.centerZoom = function(loc2, z2) { + if (setCenterZoom(loc2, z2)) { + dispatch14.call("move", this, map2); } - const photoOverlayLayers = { - streetside: "Bing Streetside", - mapillary: "Mapillary Images", - "mapillary-map-features": "Mapillary Map Features", - "mapillary-signs": "Mapillary Signs", - kartaview: "KartaView Images", - vegbilder: "Norwegian Road Administration Images", - mapilio: "Mapilio Images", - panoramax: "Panoramax Images" - }; - for (let layerID in photoOverlayLayers) { - const layer = context.layers().layer(layerID); - if (layer && layer.enabled()) { - photoOverlaysUsed.push(layerID); - imageryUsed.push(photoOverlayLayers[layerID]); - } + scheduleRedraw(); + return map2; + }; + map2.zoomTo = function(entities) { + if (!isArray_default(entities)) { + entities = [entities]; } - context.history().imageryUsed(imageryUsed); - context.history().photoOverlaysUsed(photoOverlaysUsed); + if (entities.length === 0) return map2; + var extent = entities.map((entity) => entity.extent(context.graph())).reduce((a2, b2) => a2.extend(b2)); + if (!isFinite(extent.area())) return map2; + var z2 = clamp2(map2.trimmedExtentZoom(extent), 0, 20); + return map2.centerZoom(extent.center(), z2); }; - background.sources = (extent, zoom, includeCurrent) => { - if (!_imageryIndex) return []; - let visible = {}; - (_imageryIndex.query.bbox(extent.rectangle(), true) || []).forEach((d2) => visible[d2.id] = true); - const currSource = baseLayer.source(); - const osm = context.connection(); - const blocklists = osm && osm.imageryBlocklists() || []; - const blocklistChanged = blocklists.length !== _checkedBlocklists.length || blocklists.some((regex, index) => String(regex) !== _checkedBlocklists[index]); - if (blocklistChanged) { - _imageryIndex.backgrounds.forEach((source) => { - source.isBlocked = blocklists.some((regex) => regex.test(source.template())); + map2.centerEase = function(loc2, duration) { + duration = duration || 250; + setCenterZoom(loc2, map2.zoom(), duration); + return map2; + }; + map2.zoomEase = function(z2, duration) { + duration = duration || 250; + setCenterZoom(map2.center(), z2, duration, false); + return map2; + }; + map2.centerZoomEase = function(loc2, z2, duration) { + duration = duration || 250; + setCenterZoom(loc2, z2, duration, false); + return map2; + }; + map2.transformEase = function(t2, duration) { + duration = duration || 250; + setTransform( + t2, + duration, + false + /* don't force */ + ); + return map2; + }; + map2.zoomToEase = function(obj, duration) { + var extent; + if (Array.isArray(obj)) { + obj.forEach(function(entity) { + var entityExtent = entity.extent(context.graph()); + if (!extent) { + extent = entityExtent; + } else { + extent = extent.extend(entityExtent); + } }); - _checkedBlocklists = blocklists.map((regex) => String(regex)); + } else { + extent = obj.extent(context.graph()); } - return _imageryIndex.backgrounds.filter((source) => { - if (includeCurrent && currSource === source) return true; - if (source.isBlocked) return false; - if (!source.polygon) return true; - if (zoom && zoom < 6) return false; - return visible[source.id]; + if (!isFinite(extent.area())) return map2; + var z2 = clamp2(map2.trimmedExtentZoom(extent), 0, 20); + return map2.centerZoomEase(extent.center(), z2, duration); + }; + map2.startEase = function() { + utilBindOnce(surface, _pointerPrefix + "down.ease", function() { + map2.cancelEase(); }); + return map2; }; - background.dimensions = (val) => { - if (!val) return; - baseLayer.dimensions(val); - _overlayLayers.forEach((layer) => layer.dimensions(val)); + map2.cancelEase = function() { + _selection.interrupt(); + return map2; }; - background.baseLayerSource = function(d2) { - if (!arguments.length) return baseLayer.source(); - const osm = context.connection(); - if (!osm) return background; - const blocklists = osm.imageryBlocklists(); - const template = d2.template(); - let fail = false; - let tested = 0; - let regex; - for (let i3 = 0; i3 < blocklists.length; i3++) { - regex = blocklists[i3]; - fail = regex.test(template); - tested++; - if (fail) break; + map2.extent = function(val) { + if (!arguments.length) { + return new geoExtent( + projection2.invert([0, _dimensions[1]]), + projection2.invert([_dimensions[0], 0]) + ); + } else { + var extent = geoExtent(val); + map2.centerZoom(extent.center(), map2.extentZoom(extent)); } - if (!tested) { - regex = /.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/; - fail = regex.test(template); + }; + map2.trimmedExtent = function(val) { + if (!arguments.length) { + var headerY = 71; + var footerY = 30; + var pad3 = 10; + return new geoExtent( + projection2.invert([pad3, _dimensions[1] - footerY - pad3]), + projection2.invert([_dimensions[0] - pad3, headerY + pad3]) + ); + } else { + var extent = geoExtent(val); + map2.centerZoom(extent.center(), map2.trimmedExtentZoom(extent)); } - baseLayer.source(!fail ? d2 : background.findSource("none")); - dispatch14.call("change"); - background.updateImagery(); - return background; }; - background.findSource = (id2) => { - if (!id2 || !_imageryIndex) return null; - return _imageryIndex.backgrounds.find((d2) => d2.id && d2.id === id2); + function calcExtentZoom(extent, dim) { + var tl = projection2([extent[0][0], extent[1][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); + return newZoom; + } + map2.extentZoom = function(val) { + return calcExtentZoom(geoExtent(val), _dimensions); }; - background.bing = () => { - background.baseLayerSource(background.findSource("Bing")); + map2.trimmedExtentZoom = function(val) { + var trimY = 120; + var trimX = 40; + var trimmed = [_dimensions[0] - trimX, _dimensions[1] - trimY]; + return calcExtentZoom(geoExtent(val), trimmed); }; - background.showsLayer = (d2) => { - const currSource = baseLayer.source(); - if (!d2 || !currSource) return false; - return d2.id === currSource.id || _overlayLayers.some((layer) => d2.id === layer.source().id); + map2.withinEditableZoom = function() { + return map2.zoom() >= context.minEditableZoom(); }; - background.overlayLayerSources = () => { - return _overlayLayers.map((layer) => layer.source()); + map2.isInWideSelection = function() { + return !map2.withinEditableZoom() && context.selectedIDs().length; }; - background.toggleOverlayLayer = (d2) => { - let layer; - for (let i3 = 0; i3 < _overlayLayers.length; i3++) { - layer = _overlayLayers[i3]; - if (layer.source() === d2) { - _overlayLayers.splice(i3, 1); - dispatch14.call("change"); - background.updateImagery(); - return; - } - } - layer = rendererTileLayer(context).source(d2).projection(context.projection).dimensions( - baseLayer.dimensions() - ); - _overlayLayers.push(layer); - dispatch14.call("change"); - background.updateImagery(); + map2.editableDataEnabled = function(skipZoomCheck) { + var layer = context.layers().layer("osm"); + if (!layer || !layer.enabled()) return false; + return skipZoomCheck || map2.withinEditableZoom(); }; - background.nudge = (d2, zoom) => { - const currSource = baseLayer.source(); - if (currSource) { - currSource.nudge(d2, zoom); - dispatch14.call("change"); - background.updateImagery(); - } - return background; + map2.notesEditable = function() { + var layer = context.layers().layer("notes"); + if (!layer || !layer.enabled()) return false; + return map2.withinEditableZoom(); }; - background.offset = function(d2) { - const currSource = baseLayer.source(); - if (!arguments.length) { - return currSource && currSource.offset() || [0, 0]; + map2.minzoom = function(val) { + if (!arguments.length) return _minzoom; + _minzoom = val; + return map2; + }; + map2.toggleHighlightEdited = function() { + surface.classed("highlight-edited", !surface.classed("highlight-edited")); + map2.pan([0, 0]); + dispatch14.call("changeHighlighting", this); + }; + map2.areaFillOptions = ["wireframe", "partial", "full"]; + map2.activeAreaFill = function(val) { + if (!arguments.length) return corePreferences("area-fill") || "partial"; + corePreferences("area-fill", val); + if (val !== "wireframe") { + corePreferences("area-fill-toggle", val); } - if (currSource) { - currSource.offset(d2); - dispatch14.call("change"); - background.updateImagery(); + updateAreaFill(); + map2.pan([0, 0]); + dispatch14.call("changeAreaFill", this); + return map2; + }; + map2.toggleWireframe = function() { + var activeFill = map2.activeAreaFill(); + if (activeFill === "wireframe") { + activeFill = corePreferences("area-fill-toggle") || "partial"; + } else { + activeFill = "wireframe"; } - return background; + map2.activeAreaFill(activeFill); }; - background.brightness = function(d2) { - if (!arguments.length) return _brightness; - _brightness = d2; - if (context.mode()) dispatch14.call("change"); - return background; + function updateAreaFill() { + var activeFill = map2.activeAreaFill(); + map2.areaFillOptions.forEach(function(opt) { + surface.classed("fill-" + opt, Boolean(opt === activeFill)); + }); + } + map2.layers = () => drawLayers; + map2.doubleUpHandler = function() { + return _doubleUpHandler; }; - background.contrast = function(d2) { - if (!arguments.length) return _contrast; - _contrast = d2; - if (context.mode()) dispatch14.call("change"); - return background; + return utilRebind(map2, dispatch14, "on"); + } + var TILESIZE, minZoom2, maxZoom, kMin, kMax; + var init_map = __esm({ + "modules/renderer/map.js"() { + "use strict"; + init_throttle(); + init_src4(); + init_src8(); + init_src16(); + init_src5(); + init_src12(); + init_preferences(); + init_geo2(); + init_browse(); + init_svg(); + init_util2(); + init_bind_once(); + init_detect(); + init_dimensions(); + init_rebind(); + init_zoom_pan(); + init_double_up(); + init_lodash(); + TILESIZE = 256; + minZoom2 = 2; + maxZoom = 24; + kMin = geoZoomToScale(minZoom2, TILESIZE); + kMax = geoZoomToScale(maxZoom, TILESIZE); + } + }); + + // modules/renderer/photos.js + var photos_exports = {}; + __export(photos_exports, { + rendererPhotos: () => rendererPhotos + }); + function rendererPhotos(context) { + var dispatch14 = dispatch_default("change"); + var _layerIDs = ["streetside", "mapillary", "mapillary-map-features", "mapillary-signs", "kartaview", "mapilio", "vegbilder", "panoramax"]; + var _allPhotoTypes = ["flat", "panoramic"]; + var _shownPhotoTypes = _allPhotoTypes.slice(); + var _dateFilters = ["fromDate", "toDate"]; + var _fromDate; + var _toDate; + var _usernames; + function photos() { + } + function updateStorage() { + if (window.mocha) return; + var hash2 = utilStringQs(window.location.hash); + var enabled = context.layers().all().filter(function(d2) { + return _layerIDs.indexOf(d2.id) !== -1 && d2.layer && d2.layer.supported() && d2.layer.enabled(); + }).map(function(d2) { + return d2.id; + }); + if (enabled.length) { + hash2.photo_overlay = enabled.join(","); + } else { + delete hash2.photo_overlay; + } + window.location.replace("#" + utilQsString(hash2, true)); + } + photos.overlayLayerIDs = function() { + return _layerIDs; }; - background.saturation = function(d2) { - if (!arguments.length) return _saturation; - _saturation = d2; - if (context.mode()) dispatch14.call("change"); - return background; + photos.allPhotoTypes = function() { + return _allPhotoTypes; }; - background.sharpness = function(d2) { - if (!arguments.length) return _sharpness; - _sharpness = d2; - if (context.mode()) dispatch14.call("change"); - return background; + photos.dateFilters = function() { + return _dateFilters; }; - let _loadPromise; - background.ensureLoaded = () => { - if (_loadPromise) return _loadPromise; - return _loadPromise = ensureImageryIndex(); + photos.dateFilterValue = function(val) { + return val === _dateFilters[0] ? _fromDate : _toDate; }; - background.init = () => { - const loadPromise = background.ensureLoaded(); - const hash2 = utilStringQs(window.location.hash); - const requestedBackground = hash2.background || hash2.layer; - const lastUsedBackground = corePreferences("background-last-used"); - return loadPromise.then((imageryIndex) => { - const extent = context.map().extent(); - const validBackgrounds = background.sources(extent).filter((d2) => d2.id !== "none" && d2.id !== "custom"); - const first = validBackgrounds.length && validBackgrounds[0]; - const isLastUsedValid = !!validBackgrounds.find((d2) => d2.id && d2.id === lastUsedBackground); - let best; - if (!requestedBackground && extent) { - const viewArea = extent.area(); - best = validBackgrounds.find((s2) => { - if (!s2.best() || s2.overlay) return false; - let bbox2 = turf_bbox_default(turf_bbox_clip_default( - { type: "MultiPolygon", coordinates: [s2.polygon || [extent.polygon()]] }, - extent.rectangle() - )); - let area = geoExtent(bbox2.slice(0, 2), bbox2.slice(2, 4)).area(); - return area / viewArea > 0.5; - }); + photos.setDateFilter = function(type2, val, updateUrl) { + var date = val && new Date(val); + if (date && !isNaN(date)) { + val = date.toISOString().slice(0, 10); + } else { + val = null; + } + if (type2 === _dateFilters[0]) { + _fromDate = val; + if (_fromDate && _toDate && new Date(_toDate) < new Date(_fromDate)) { + _toDate = _fromDate; } - if (requestedBackground && requestedBackground.indexOf("custom:") === 0) { - const template = requestedBackground.replace(/^custom:/, ""); - const custom = background.findSource("custom"); - background.baseLayerSource(custom.template(template)); - corePreferences("background-custom-template", template); - } else { - background.baseLayerSource( - background.findSource(requestedBackground) || best || isLastUsedValid && background.findSource(lastUsedBackground) || background.findSource("Bing") || first || background.findSource("none") - ); + } + if (type2 === _dateFilters[1]) { + _toDate = val; + if (_fromDate && _toDate && new Date(_toDate) < new Date(_fromDate)) { + _fromDate = _toDate; } - const locator = imageryIndex.backgrounds.find((d2) => d2.overlay && d2.default); - if (locator) { - background.toggleOverlayLayer(locator); + } + dispatch14.call("change", this); + if (updateUrl) { + var rangeString; + if (_fromDate || _toDate) { + rangeString = (_fromDate || "") + "_" + (_toDate || ""); } - const overlays = (hash2.overlays || "").split(","); - overlays.forEach((overlay) => { - overlay = background.findSource(overlay); - if (overlay) { - background.toggleOverlayLayer(overlay); - } - }); - if (hash2.gpx) { - const gpx2 = context.layers().layer("data"); - if (gpx2) { - gpx2.url(hash2.gpx, ".gpx"); - } + setUrlFilterValue("photo_dates", rangeString); + } + }; + photos.setUsernameFilter = function(val, updateUrl) { + if (val && typeof val === "string") val = val.replace(/;/g, ",").split(","); + if (val) { + val = val.map((d2) => d2.trim()).filter(Boolean); + if (!val.length) { + val = null; } - if (hash2.offset) { - const offset = hash2.offset.replace(/;/g, ",").split(",").map((n3) => !isNaN(n3) && n3); - if (offset.length === 2) { - background.offset(geoMetersToOffset(offset)); - } + } + _usernames = val; + dispatch14.call("change", this); + if (updateUrl) { + var hashString; + if (_usernames) { + hashString = _usernames.join(","); } - }).catch((err) => { - console.error(err); - }); - }; - return utilRebind(background, dispatch14, "on"); - } - - // modules/renderer/features.js - function rendererFeatures(context) { - var dispatch14 = dispatch_default("change", "redraw"); - const features = {}; - var _deferred2 = /* @__PURE__ */ new Set(); - var traffic_roads = { - "motorway": true, - "motorway_link": true, - "trunk": true, - "trunk_link": true, - "primary": true, - "primary_link": true, - "secondary": true, - "secondary_link": true, - "tertiary": true, - "tertiary_link": true, - "residential": true, - "unclassified": true, - "living_street": true, - "busway": true - }; - var service_roads = { - "service": true, - "road": true, - "track": true + setUrlFilterValue("photo_username", hashString); + } }; - var paths = { - "path": true, - "footway": true, - "cycleway": true, - "bridleway": true, - "steps": true, - "ladder": true, - "pedestrian": true + photos.togglePhotoType = function(val, updateUrl) { + var index = _shownPhotoTypes.indexOf(val); + if (index !== -1) { + _shownPhotoTypes.splice(index, 1); + } else { + _shownPhotoTypes.push(val); + } + if (updateUrl) { + var hashString; + if (_shownPhotoTypes) { + hashString = _shownPhotoTypes.join(","); + } + setUrlFilterValue("photo_type", hashString); + } + dispatch14.call("change", this); + return photos; }; - var _cullFactor = 1; - var _cache5 = {}; - var _rules = {}; - var _stats = {}; - var _keys = []; - var _hidden = []; - var _forceVisible = {}; - function update() { + function setUrlFilterValue(property, val) { if (!window.mocha) { var hash2 = utilStringQs(window.location.hash); - var disabled = features.disabled(); - if (disabled.length) { - hash2.disable_features = disabled.join(","); + if (val) { + if (hash2[property] === val) return; + hash2[property] = val; } else { - delete hash2.disable_features; + if (!(property in hash2)) return; + delete hash2[property]; } window.location.replace("#" + utilQsString(hash2, true)); - corePreferences("disabled-features", disabled.join(",")); } - _hidden = features.hidden(); - dispatch14.call("change"); - dispatch14.call("redraw"); } - function defineRule(k2, filter2, max3) { - var isEnabled = true; - _keys.push(k2); - _rules[k2] = { - filter: filter2, - enabled: isEnabled, - // whether the user wants it enabled.. - count: 0, - currentMax: max3 || Infinity, - defaultMax: max3 || Infinity, - enable: function() { - this.enabled = true; - this.currentMax = this.defaultMax; - }, - disable: function() { - this.enabled = false; - this.currentMax = 0; - }, - hidden: function() { - return this.count === 0 && !this.enabled || this.count > this.currentMax * _cullFactor; - }, - autoHidden: function() { - return this.hidden() && this.currentMax > 0; - } - }; + function showsLayer(id2) { + var layer = context.layers().layer(id2); + return layer && layer.supported() && layer.enabled(); } - defineRule("points", function isPoint(tags, geometry) { - return geometry === "point"; - }, 200); - defineRule("traffic_roads", function isTrafficRoad(tags) { - return traffic_roads[tags.highway]; - }); - defineRule("service_roads", function isServiceRoad(tags) { - return service_roads[tags.highway]; - }); - defineRule("paths", function isPath(tags) { - return paths[tags.highway]; - }); - defineRule("buildings", function isBuilding(tags) { - return !!tags.building && tags.building !== "no" || tags.parking === "multi-storey" || tags.parking === "sheds" || tags.parking === "carports" || tags.parking === "garage_boxes"; - }, 250); - defineRule("building_parts", function isBuildingPart(tags) { - return !!tags["building:part"]; - }); - defineRule("indoor", function isIndoor(tags) { - return !!tags.indoor && tags.indoor !== "no" || !!tags.indoormark && tags.indoormark !== "no"; - }); - defineRule("landuse", function isLanduse(tags, geometry) { - return geometry === "area" && (!!tags.landuse || !!tags.natural || !!tags.leisure || !!tags.amenity) && !_rules.buildings.filter(tags) && !_rules.building_parts.filter(tags) && !_rules.indoor.filter(tags) && !_rules.water.filter(tags) && !_rules.pistes.filter(tags); - }); - defineRule("boundaries", function isBoundary(tags, geometry) { - return (geometry === "line" && !!tags.boundary || geometry === "relation" && tags.type === "boundary") && !(traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway] || tags.waterway || tags.railway || tags.landuse || tags.natural || tags.building || tags.power); - }); - defineRule("water", function isWater(tags) { - return !!tags.waterway || tags.natural === "water" || tags.natural === "coastline" || tags.natural === "bay" || tags.landuse === "pond" || tags.landuse === "basin" || tags.landuse === "reservoir" || tags.landuse === "salt_pond"; - }); - defineRule("rail", function isRail(tags) { - return (!!tags.railway || tags.landuse === "railway") && !(traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway]); - }); - defineRule("pistes", function isPiste(tags) { - return tags["piste:type"]; - }); - defineRule("aerialways", function isAerialways(tags) { - return !!(tags == null ? void 0 : tags.aerialway) && tags.aerialway !== "yes" && tags.aerialway !== "station"; - }); - defineRule("power", function isPower(tags) { - return !!tags.power; - }); - defineRule("past_future", function isPastFuture(tags) { - if (traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway]) { - return false; - } - const keys2 = Object.keys(tags); - for (let i3 = 0; i3 < keys2.length; i3++) { - const key = keys2[i3]; - const s2 = key.split(":")[0]; - if (osmLifecyclePrefixes[s2] || osmLifecyclePrefixes[tags[key]]) return true; - } - return false; - }); - defineRule("others", function isOther(tags, geometry) { - return geometry === "line" || geometry === "area"; - }); - features.features = function() { - return _rules; + photos.shouldFilterDateBySlider = function() { + return showsLayer("mapillary") || showsLayer("kartaview") || showsLayer("mapilio") || showsLayer("streetside") || showsLayer("vegbilder") || showsLayer("panoramax"); + }; + photos.shouldFilterByPhotoType = function() { + return showsLayer("mapillary") || showsLayer("streetside") && showsLayer("kartaview") || showsLayer("vegbilder") || showsLayer("panoramax"); + }; + photos.shouldFilterByUsername = function() { + return !showsLayer("mapillary") && showsLayer("kartaview") && !showsLayer("streetside") || showsLayer("panoramax"); + }; + photos.showsPhotoType = function(val) { + if (!photos.shouldFilterByPhotoType()) return true; + return _shownPhotoTypes.indexOf(val) !== -1; + }; + photos.showsFlat = function() { + return photos.showsPhotoType("flat"); + }; + photos.showsPanoramic = function() { + return photos.showsPhotoType("panoramic"); + }; + photos.fromDate = function() { + return _fromDate; }; - features.keys = function() { - return _keys; + photos.toDate = function() { + return _toDate; }; - features.enabled = function(k2) { - if (!arguments.length) { - return _keys.filter(function(k3) { - return _rules[k3].enabled; - }); - } - return _rules[k2] && _rules[k2].enabled; + photos.usernames = function() { + return _usernames; }; - features.disabled = function(k2) { - if (!arguments.length) { - return _keys.filter(function(k3) { - return !_rules[k3].enabled; - }); + photos.init = function() { + var hash2 = utilStringQs(window.location.hash); + var parts; + if (hash2.photo_dates) { + parts = /^(.*)[–_](.*)$/g.exec(hash2.photo_dates.trim()); + this.setDateFilter("fromDate", parts && parts.length >= 2 && parts[1], false); + this.setDateFilter("toDate", parts && parts.length >= 3 && parts[2], false); } - return _rules[k2] && !_rules[k2].enabled; - }; - features.hidden = function(k2) { - var _a4; - if (!arguments.length) { - return _keys.filter(function(k3) { - return _rules[k3].hidden(); - }); + if (hash2.photo_username) { + this.setUsernameFilter(hash2.photo_username, false); } - return (_a4 = _rules[k2]) == null ? void 0 : _a4.hidden(); - }; - features.autoHidden = function(k2) { - if (!arguments.length) { - return _keys.filter(function(k3) { - return _rules[k3].autoHidden(); + if (hash2.photo_type) { + parts = hash2.photo_type.replace(/;/g, ",").split(","); + _allPhotoTypes.forEach((d2) => { + if (!parts.includes(d2)) this.togglePhotoType(d2, false); }); } - return _rules[k2] && _rules[k2].autoHidden(); - }; - features.enable = function(k2) { - if (_rules[k2] && !_rules[k2].enabled) { - _rules[k2].enable(); - update(); + if (hash2.photo_overlay) { + var hashOverlayIDs = hash2.photo_overlay.replace(/;/g, ",").split(","); + hashOverlayIDs.forEach(function(id2) { + if (id2 === "openstreetcam") id2 = "kartaview"; + var layer2 = _layerIDs.indexOf(id2) !== -1 && context.layers().layer(id2); + if (layer2 && !layer2.enabled()) layer2.enabled(true); + }); } - }; - features.enableAll = function() { - var didEnable = false; - for (var k2 in _rules) { - if (!_rules[k2].enabled) { - didEnable = true; - _rules[k2].enable(); + if (hash2.photo) { + var photoIds = hash2.photo.replace(/;/g, ",").split(","); + var photoId = photoIds.length && photoIds[0].trim(); + var results = /(.*)\/(.*)/g.exec(photoId); + if (results && results.length >= 3) { + var serviceId = results[1]; + if (serviceId === "openstreetcam") serviceId = "kartaview"; + var photoKey = results[2]; + var service = services[serviceId]; + if (service && service.ensureViewerLoaded) { + var layer = _layerIDs.indexOf(serviceId) !== -1 && context.layers().layer(serviceId); + if (layer && !layer.enabled()) layer.enabled(true); + var baselineTime = Date.now(); + service.on("loadedImages.rendererPhotos", function() { + if (Date.now() - baselineTime > 45e3) { + service.on("loadedImages.rendererPhotos", null); + return; + } + if (!service.cachedImage(photoKey)) return; + service.on("loadedImages.rendererPhotos", null); + service.ensureViewerLoaded(context).then(function() { + service.selectImage(context, photoKey).showViewer(context); + }); + }); + } } } - if (didEnable) update(); + context.layers().on("change.rendererPhotos", updateStorage); }; - features.disable = function(k2) { - if (_rules[k2] && _rules[k2].enabled) { - _rules[k2].disable(); - update(); + return utilRebind(photos, dispatch14, "on"); + } + var init_photos = __esm({ + "modules/renderer/photos.js"() { + "use strict"; + init_src4(); + init_services(); + init_rebind(); + init_util(); + } + }); + + // modules/renderer/index.js + var renderer_exports = {}; + __export(renderer_exports, { + rendererBackground: () => rendererBackground, + rendererBackgroundSource: () => rendererBackgroundSource, + rendererFeatures: () => rendererFeatures, + rendererMap: () => rendererMap, + rendererPhotos: () => rendererPhotos, + rendererTileLayer: () => rendererTileLayer + }); + var init_renderer = __esm({ + "modules/renderer/index.js"() { + "use strict"; + init_background_source(); + init_background2(); + init_features(); + init_map(); + init_photos(); + init_tile_layer(); + } + }); + + // modules/ui/map_in_map.js + var map_in_map_exports = {}; + __export(map_in_map_exports, { + uiMapInMap: () => uiMapInMap + }); + function uiMapInMap(context) { + function mapInMap(selection2) { + var backgroundLayer = rendererTileLayer(context).underzoom(2); + var overlayLayers = {}; + var projection2 = geoRawMercator(); + var dataLayer = svgData(projection2, context).showLabels(false); + var debugLayer = svgDebug(projection2, context); + var zoom = zoom_default2().scaleExtent([geoZoomToScale(0.5), geoZoomToScale(24)]).on("start", zoomStarted).on("zoom", zoomed).on("end", zoomEnded); + var wrap2 = select_default2(null); + var tiles = select_default2(null); + var viewport = select_default2(null); + var _isTransformed = false; + var _isHidden = true; + var _skipEvents = false; + var _gesture = null; + var _zDiff = 6; + var _dMini; + var _cMini; + var _tStart; + var _tCurr; + var _timeoutID; + function zoomStarted() { + if (_skipEvents) return; + _tStart = _tCurr = projection2.transform(); + _gesture = null; } - }; - features.disableAll = function() { - var didDisable = false; - for (var k2 in _rules) { - if (_rules[k2].enabled) { - didDisable = true; - _rules[k2].disable(); + function zoomed(d3_event) { + if (_skipEvents) return; + var x2 = d3_event.transform.x; + var y2 = d3_event.transform.y; + var k2 = d3_event.transform.k; + var isZooming = k2 !== _tStart.k; + var isPanning = x2 !== _tStart.x || y2 !== _tStart.y; + if (!isZooming && !isPanning) { + return; } + if (!_gesture) { + _gesture = isZooming ? "zoom" : "pan"; + } + var tMini = projection2.transform(); + var tX, tY, scale; + if (_gesture === "zoom") { + scale = k2 / tMini.k; + tX = (_cMini[0] / scale - _cMini[0]) * scale; + tY = (_cMini[1] / scale - _cMini[1]) * scale; + } else { + k2 = tMini.k; + scale = 1; + tX = x2 - tMini.x; + tY = y2 - tMini.y; + } + utilSetTransform(tiles, tX, tY, scale); + utilSetTransform(viewport, 0, 0, scale); + _isTransformed = true; + _tCurr = identity2.translate(x2, y2).scale(k2); + var zMain = geoScaleToZoom(context.projection.scale()); + var zMini = geoScaleToZoom(k2); + _zDiff = zMain - zMini; + queueRedraw(); } - if (didDisable) update(); - }; - features.toggle = function(k2) { - if (_rules[k2]) { - (function(f2) { - return f2.enabled ? f2.disable() : f2.enable(); - })(_rules[k2]); - update(); - } - }; - features.resetStats = function() { - for (var i3 = 0; i3 < _keys.length; i3++) { - _rules[_keys[i3]].count = 0; - } - dispatch14.call("change"); - }; - features.gatherStats = function(d2, resolver, dimensions) { - var needsRedraw = false; - var types = utilArrayGroupBy(d2, "type"); - var entities = [].concat(types.relation || [], types.way || [], types.node || []); - var currHidden, geometry, matches, i3, j2; - for (i3 = 0; i3 < _keys.length; i3++) { - _rules[_keys[i3]].count = 0; + function zoomEnded() { + if (_skipEvents) return; + if (_gesture !== "pan") return; + updateProjection(); + _gesture = null; + context.map().center(projection2.invert(_cMini)); } - _cullFactor = dimensions[0] * dimensions[1] / 1e6; - for (i3 = 0; i3 < entities.length; i3++) { - geometry = entities[i3].geometry(resolver); - matches = Object.keys(features.getMatches(entities[i3], resolver, geometry)); - for (j2 = 0; j2 < matches.length; j2++) { - _rules[matches[j2]].count++; + function updateProjection() { + var loc = context.map().center(); + var tMain = context.projection.transform(); + var zMain = geoScaleToZoom(tMain.k); + var zMini = Math.max(zMain - _zDiff, 0.5); + var kMini = geoZoomToScale(zMini); + projection2.translate([tMain.x, tMain.y]).scale(kMini); + var point = projection2(loc); + var mouse = _gesture === "pan" ? geoVecSubtract([_tCurr.x, _tCurr.y], [_tStart.x, _tStart.y]) : [0, 0]; + var xMini = _cMini[0] - point[0] + tMain.x + mouse[0]; + var yMini = _cMini[1] - point[1] + tMain.y + mouse[1]; + projection2.translate([xMini, yMini]).clipExtent([[0, 0], _dMini]); + _tCurr = projection2.transform(); + if (_isTransformed) { + utilSetTransform(tiles, 0, 0); + utilSetTransform(viewport, 0, 0); + _isTransformed = false; } + zoom.scaleExtent([geoZoomToScale(0.5), geoZoomToScale(zMain - 3)]); + _skipEvents = true; + wrap2.call(zoom.transform, _tCurr); + _skipEvents = false; } - currHidden = features.hidden(); - if (currHidden !== _hidden) { - _hidden = currHidden; - needsRedraw = true; - dispatch14.call("change"); + function redraw() { + clearTimeout(_timeoutID); + if (_isHidden) return; + updateProjection(); + var zMini = geoScaleToZoom(projection2.scale()); + tiles = wrap2.selectAll(".map-in-map-tiles").data([0]); + tiles = tiles.enter().append("div").attr("class", "map-in-map-tiles").merge(tiles); + backgroundLayer.source(context.background().baseLayerSource()).projection(projection2).dimensions(_dMini); + var background = tiles.selectAll(".map-in-map-background").data([0]); + background.enter().append("div").attr("class", "map-in-map-background").merge(background).call(backgroundLayer); + var overlaySources = context.background().overlayLayerSources(); + var activeOverlayLayers = []; + for (var i3 = 0; i3 < overlaySources.length; i3++) { + if (overlaySources[i3].validZoom(zMini)) { + if (!overlayLayers[i3]) overlayLayers[i3] = rendererTileLayer(context); + activeOverlayLayers.push(overlayLayers[i3].source(overlaySources[i3]).projection(projection2).dimensions(_dMini)); + } + } + var overlay = tiles.selectAll(".map-in-map-overlay").data([0]); + overlay = overlay.enter().append("div").attr("class", "map-in-map-overlay").merge(overlay); + var overlays = overlay.selectAll("div").data(activeOverlayLayers, function(d2) { + return d2.source().name(); + }); + overlays.exit().remove(); + overlays = overlays.enter().append("div").merge(overlays).each(function(layer) { + select_default2(this).call(layer); + }); + var dataLayers = tiles.selectAll(".map-in-map-data").data([0]); + dataLayers.exit().remove(); + dataLayers = dataLayers.enter().append("svg").attr("class", "map-in-map-data").merge(dataLayers).call(dataLayer).call(debugLayer); + if (_gesture !== "pan") { + var getPath = path_default(projection2); + var bbox2 = { type: "Polygon", coordinates: [context.map().extent().polygon()] }; + viewport = wrap2.selectAll(".map-in-map-viewport").data([0]); + viewport = viewport.enter().append("svg").attr("class", "map-in-map-viewport").merge(viewport); + var path = viewport.selectAll(".map-in-map-bbox").data([bbox2]); + path.enter().append("path").attr("class", "map-in-map-bbox").merge(path).attr("d", getPath).classed("thick", function(d2) { + return getPath.area(d2) < 30; + }); + } } - return needsRedraw; - }; - features.stats = function() { - for (var i3 = 0; i3 < _keys.length; i3++) { - _stats[_keys[i3]] = _rules[_keys[i3]].count; + function queueRedraw() { + clearTimeout(_timeoutID); + _timeoutID = setTimeout(function() { + redraw(); + }, 750); } - return _stats; - }; - features.clear = function(d2) { - for (var i3 = 0; i3 < d2.length; i3++) { - features.clearEntity(d2[i3]); + function toggle(d3_event) { + if (d3_event) d3_event.preventDefault(); + _isHidden = !_isHidden; + context.container().select(".minimap-toggle-item").classed("active", !_isHidden).select("input").property("checked", !_isHidden); + if (_isHidden) { + wrap2.style("display", "block").style("opacity", "1").transition().duration(200).style("opacity", "0").on("end", function() { + selection2.selectAll(".map-in-map").style("display", "none"); + }); + } else { + wrap2.style("display", "block").style("opacity", "0").transition().duration(200).style("opacity", "1").on("end", function() { + redraw(); + }); + } } - }; - features.clearEntity = function(entity) { - delete _cache5[osmEntity.key(entity)]; - }; - features.reset = function() { - Array.from(_deferred2).forEach(function(handle) { - window.cancelIdleCallback(handle); - _deferred2.delete(handle); + uiMapInMap.toggle = toggle; + wrap2 = selection2.selectAll(".map-in-map").data([0]); + wrap2 = wrap2.enter().append("div").attr("class", "map-in-map").style("display", _isHidden ? "none" : "block").call(zoom).on("dblclick.zoom", null).merge(wrap2); + _dMini = [200, 150]; + _cMini = geoVecScale(_dMini, 0.5); + context.map().on("drawn.map-in-map", function(drawn) { + if (drawn.full === true) { + redraw(); + } }); - _cache5 = {}; + redraw(); + context.keybinding().on(_t("background.minimap.key"), toggle); + } + return mapInMap; + } + var init_map_in_map = __esm({ + "modules/ui/map_in_map.js"() { + "use strict"; + init_src2(); + init_src5(); + init_src12(); + init_localizer(); + init_geo2(); + init_renderer(); + init_svg(); + init_util(); + } + }); + + // modules/ui/notice.js + var notice_exports = {}; + __export(notice_exports, { + uiNotice: () => uiNotice + }); + function uiNotice(context) { + return function(selection2) { + var div = selection2.append("div").attr("class", "notice"); + var button = div.append("button").attr("class", "zoom-to notice fillD").on("click", function() { + context.map().zoomEase(context.minEditableZoom()); + }).on("wheel", function(d3_event) { + var e22 = new WheelEvent(d3_event.type, d3_event); + context.surface().node().dispatchEvent(e22); + }); + button.call(svgIcon("#iD-icon-plus", "pre-text")).append("span").attr("class", "label").call(_t.append("zoom_in_edit")); + function disableTooHigh() { + var canEdit = context.map().zoom() >= context.minEditableZoom(); + div.style("display", canEdit ? "none" : "block"); + } + context.map().on("move.notice", debounce_default(disableTooHigh, 500)); + disableTooHigh(); }; - function relationShouldBeChecked(relation) { - return relation.tags.type === "boundary"; + } + var init_notice = __esm({ + "modules/ui/notice.js"() { + "use strict"; + init_debounce(); + init_localizer(); + init_svg(); } - features.getMatches = function(entity, resolver, geometry) { - if (geometry === "vertex" || geometry === "relation" && !relationShouldBeChecked(entity)) return {}; - var ent = osmEntity.key(entity); - if (!_cache5[ent]) { - _cache5[ent] = {}; + }); + + // modules/ui/photoviewer.js + var photoviewer_exports = {}; + __export(photoviewer_exports, { + uiPhotoviewer: () => uiPhotoviewer + }); + function uiPhotoviewer(context) { + var dispatch14 = dispatch_default("resize"); + var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse"; + const addPhotoIdButton = /* @__PURE__ */ new Set(["mapillary", "panoramax"]); + function photoviewer(selection2) { + selection2.append("button").attr("class", "thumb-hide").attr("title", _t("icons.close")).on("click", function() { + if (services.streetside) { + services.streetside.hideViewer(context); + } + if (services.mapillary) { + services.mapillary.hideViewer(context); + } + if (services.kartaview) { + services.kartaview.hideViewer(context); + } + if (services.mapilio) { + services.mapilio.hideViewer(context); + } + if (services.panoramax) { + services.panoramax.hideViewer(context); + } + if (services.vegbilder) { + services.vegbilder.hideViewer(context); + } + }).append("div").call(svgIcon("#iD-icon-close")); + function preventDefault(d3_event) { + d3_event.preventDefault(); } - if (!_cache5[ent].matches) { - var matches = {}; - var hasMatch = false; - for (var i3 = 0; i3 < _keys.length; i3++) { - if (_keys[i3] === "others") { - if (hasMatch) continue; - if (entity.type === "way") { - var parents = features.getParents(entity, resolver, geometry); - if (parents.length === 1 && parents[0].isMultipolygon() || // 2b. or belongs only to boundary relations - parents.length > 0 && parents.every(function(parent) { - return parent.tags.type === "boundary"; - })) { - var pkey = osmEntity.key(parents[0]); - if (_cache5[pkey] && _cache5[pkey].matches) { - matches = Object.assign({}, _cache5[pkey].matches); - continue; - } - } + selection2.append("button").attr("class", "resize-handle-xy").on("touchstart touchdown touchend", preventDefault).on( + _pointerPrefix + "down", + buildResizeListener(selection2, "resize", dispatch14, { resizeOnX: true, resizeOnY: true }) + ); + selection2.append("button").attr("class", "resize-handle-x").on("touchstart touchdown touchend", preventDefault).on( + _pointerPrefix + "down", + buildResizeListener(selection2, "resize", dispatch14, { resizeOnX: true }) + ); + selection2.append("button").attr("class", "resize-handle-y").on("touchstart touchdown touchend", preventDefault).on( + _pointerPrefix + "down", + buildResizeListener(selection2, "resize", dispatch14, { resizeOnY: true }) + ); + context.features().on("change.setPhotoFromViewer", function() { + setPhotoTagButton(); + }); + context.history().on("change.setPhotoFromViewer", function() { + setPhotoTagButton(); + }); + function setPhotoTagButton() { + const service = getServiceId(); + const isActiveForService = addPhotoIdButton.has(service) && services[service].isViewerOpen(); + if (isActiveForService) { + let setPhotoId2 = function() { + const activeServiceId = getServiceId(); + const image = services[activeServiceId].getActiveImage(); + const action = (graph) => context.selectedIDs().reduce((graph2, entityID) => { + const tags = graph2.entity(entityID).tags; + const action2 = actionChangeTags(entityID, { ...tags, [activeServiceId]: image.id }); + return action2(graph2); + }, graph); + const annotation = _t("operations.change_tags.annotation"); + context.perform(action, annotation); + }; + var setPhotoId = setPhotoId2; + if (context.mode().id !== "select" || !layerEnabled(service)) { + buttonRemove(); + } else { + if (selection2.select(".set-photo-from-viewer").empty()) { + const button = buttonCreate(); + button.on("click", function(e3) { + e3.preventDefault(); + e3.stopPropagation(); + setPhotoId2(); + buttonDisable("already_set"); + }); } + buttonShowHide(service); } - if (_rules[_keys[i3]].filter(entity.tags, geometry)) { - matches[_keys[i3]] = hasMatch = true; + } + function layerEnabled(which) { + const layers = context.layers(); + const layer = layers.layer(which); + return layer.enabled(); + } + function getServiceId() { + const hash2 = utilStringQs(window.location.hash); + let serviceId; + if (hash2.photo) { + let result = hash2.photo.split("/"); + serviceId = result[0]; } + return serviceId; } - _cache5[ent].matches = matches; - } - return _cache5[ent].matches; - }; - features.getParents = function(entity, resolver, geometry) { - if (geometry === "point") return []; - var ent = osmEntity.key(entity); - if (!_cache5[ent]) { - _cache5[ent] = {}; - } - if (!_cache5[ent].parents) { - var parents = []; - if (geometry === "vertex") { - parents = resolver.parentWays(entity); - } else { - parents = resolver.parentRelations(entity); + function buttonCreate() { + const button = selection2.selectAll(".set-photo-from-viewer").data([0]); + const buttonEnter = button.enter().append("button").attr("class", "set-photo-from-viewer").call(svgIcon("#fas-eye-dropper")).call( + uiTooltip().title(() => _t.append("inspector.set_photo_from_viewer.enable")).placement("right") + ); + buttonEnter.select(".tooltip").classed("dark", true).style("width", "300px"); + if (service === "panoramax") { + const panoramaxControls = selection2.select(".pnlm-zoom-controls.pnlm-controls"); + panoramaxControls.style("margin-top", "36px"); + } + return buttonEnter; } - _cache5[ent].parents = parents; - } - return _cache5[ent].parents; - }; - features.isHiddenPreset = function(preset, geometry) { - if (!_hidden.length) return false; - if (!preset.tags) return false; - var test = preset.setTags({}, geometry); - for (var key in _rules) { - if (_rules[key].filter(test, geometry)) { - if (_hidden.indexOf(key) !== -1) { - return key; + function buttonRemove() { + const button = selection2.selectAll(".set-photo-from-viewer").data([0]); + button.remove(); + if (service === "panoramax") { + const panoramaxControls = selection2.select(".pnlm-zoom-controls.pnlm-controls"); + panoramaxControls.style("margin-top", "6px"); } - return false; } - } - return false; - }; - features.isHiddenFeature = function(entity, resolver, geometry) { - if (!_hidden.length) return false; - if (!entity.version) return false; - if (_forceVisible[entity.id]) return false; - var matches = Object.keys(features.getMatches(entity, resolver, geometry)); - return matches.length && matches.every(function(k2) { - return features.hidden(k2); - }); - }; - features.isHiddenChild = function(entity, resolver, geometry) { - if (!_hidden.length) return false; - if (!entity.version || geometry === "point") return false; - if (_forceVisible[entity.id]) return false; - var parents = features.getParents(entity, resolver, geometry); - if (!parents.length) return false; - for (var i3 = 0; i3 < parents.length; i3++) { - if (!features.isHidden(parents[i3], resolver, parents[i3].geometry(resolver))) { - return false; + function buttonShowHide(tagName) { + const activeImage = services[tagName].getActiveImage(); + const graph = context.graph(); + const entities = context.selectedIDs().map((id2) => graph.entity(id2)); + if (entities.map((entity) => entity.tags[tagName]).every((value) => value === (activeImage == null ? void 0 : activeImage.id))) { + buttonDisable("already_set"); + } else if (activeImage && entities.map((entity) => entity.extent(context.graph()).center()).every((loc) => geoSphericalDistance(loc, activeImage.loc) > 100)) { + buttonDisable("too_far"); + } else { + buttonDisable(false); + } } - } - return true; - }; - features.hasHiddenConnections = function(entity, resolver) { - if (!_hidden.length) return false; - var childNodes, connections; - if (entity.type === "midpoint") { - childNodes = [resolver.entity(entity.edge[0]), resolver.entity(entity.edge[1])]; - connections = []; - } else { - childNodes = entity.nodes ? resolver.childNodes(entity) : []; - connections = features.getParents(entity, resolver, entity.geometry(resolver)); - } - connections = childNodes.reduce(function(result, e3) { - return resolver.isShared(e3) ? utilArrayUnion(result, resolver.parentWays(e3)) : result; - }, connections); - return connections.some(function(e3) { - return features.isHidden(e3, resolver, e3.geometry(resolver)); - }); - }; - features.isHidden = function(entity, resolver, geometry) { - if (!_hidden.length) return false; - if (!entity.version) return false; - var fn = geometry === "vertex" ? features.isHiddenChild : features.isHiddenFeature; - return fn(entity, resolver, geometry); - }; - features.filter = function(d2, resolver) { - if (!_hidden.length) return d2; - var result = []; - for (var i3 = 0; i3 < d2.length; i3++) { - var entity = d2[i3]; - if (!features.isHidden(entity, resolver, entity.geometry(resolver))) { - result.push(entity); + function buttonDisable(reason) { + const disabled = reason !== false; + const button = selection2.selectAll(".set-photo-from-viewer").data([0]); + button.attr("disabled", disabled ? "true" : null); + button.classed("disabled", disabled); + button.call(uiTooltip().destroyAny); + if (disabled) { + button.call( + uiTooltip().title(() => _t.append(`inspector.set_photo_from_viewer.disable.${reason}`)).placement("right") + ); + } else { + button.call( + uiTooltip().title(() => _t.append("inspector.set_photo_from_viewer.enable")).placement("right") + ); + } + button.select(".tooltip").classed("dark", true).style("width", "300px"); } } - return result; - }; - features.forceVisible = function(entityIDs) { - if (!arguments.length) return Object.keys(_forceVisible); - _forceVisible = {}; - for (var i3 = 0; i3 < entityIDs.length; i3++) { - _forceVisible[entityIDs[i3]] = true; - var entity = context.hasEntity(entityIDs[i3]); - if (entity && entity.type === "relation") { - for (var j2 in entity.members) { - _forceVisible[entity.members[j2].id] = true; + function buildResizeListener(target, eventName, dispatch15, options2) { + var resizeOnX = !!options2.resizeOnX; + var resizeOnY = !!options2.resizeOnY; + var minHeight = options2.minHeight || 240; + var minWidth = options2.minWidth || 320; + var pointerId; + var startX; + var startY; + var startWidth; + var startHeight; + function startResize(d3_event) { + if (pointerId !== (d3_event.pointerId || "mouse")) return; + d3_event.preventDefault(); + d3_event.stopPropagation(); + var mapSize = context.map().dimensions(); + if (resizeOnX) { + var mapWidth = mapSize[0]; + const viewerMargin = parseInt(select_default2(".photoviewer").style("margin-left"), 10); + var newWidth = clamp3(startWidth + d3_event.clientX - startX, minWidth, mapWidth - viewerMargin * 2); + target.style("width", newWidth + "px"); + } + if (resizeOnY) { + const menuHeight = utilGetDimensions(select_default2(".top-toolbar"))[1] + utilGetDimensions(select_default2(".map-footer"))[1]; + const viewerMargin = parseInt(select_default2(".photoviewer").style("margin-bottom"), 10); + var maxHeight = mapSize[1] - menuHeight - viewerMargin * 2; + var newHeight = clamp3(startHeight + startY - d3_event.clientY, minHeight, maxHeight); + target.style("height", newHeight + "px"); } + dispatch15.call(eventName, target, subtractPadding(utilGetDimensions(target, true), target)); } + function clamp3(num, min3, max3) { + return Math.max(min3, Math.min(num, max3)); + } + function stopResize(d3_event) { + if (pointerId !== (d3_event.pointerId || "mouse")) return; + d3_event.preventDefault(); + d3_event.stopPropagation(); + select_default2(window).on("." + eventName, null); + } + return function initResize(d3_event) { + d3_event.preventDefault(); + d3_event.stopPropagation(); + pointerId = d3_event.pointerId || "mouse"; + startX = d3_event.clientX; + startY = d3_event.clientY; + var targetRect = target.node().getBoundingClientRect(); + startWidth = targetRect.width; + startHeight = targetRect.height; + select_default2(window).on(_pointerPrefix + "move." + eventName, startResize, false).on(_pointerPrefix + "up." + eventName, stopResize, false); + if (_pointerPrefix === "pointer") { + select_default2(window).on("pointercancel." + eventName, stopResize, false); + } + }; } - return features; - }; - features.init = function() { - var storage = corePreferences("disabled-features"); - if (storage) { - var storageDisabled = storage.replace(/;/g, ",").split(","); - storageDisabled.forEach(features.disable); - } - var hash2 = utilStringQs(window.location.hash); - if (hash2.disable_features) { - var hashDisabled = hash2.disable_features.replace(/;/g, ",").split(","); - hashDisabled.forEach(features.disable); + } + photoviewer.onMapResize = function() { + var photoviewer2 = context.container().select(".photoviewer"); + var content = context.container().select(".main-content"); + var mapDimensions = utilGetDimensions(content, true); + const menuHeight = utilGetDimensions(select_default2(".top-toolbar"))[1] + utilGetDimensions(select_default2(".map-footer"))[1]; + const viewerMargin = parseInt(select_default2(".photoviewer").style("margin-bottom"), 10); + var photoDimensions = utilGetDimensions(photoviewer2, true); + if (photoDimensions[0] > mapDimensions[0] || photoDimensions[1] > mapDimensions[1] - menuHeight - viewerMargin * 2) { + var setPhotoDimensions = [ + Math.min(photoDimensions[0], mapDimensions[0]), + Math.min(photoDimensions[1], mapDimensions[1] - menuHeight - viewerMargin * 2) + ]; + photoviewer2.style("width", setPhotoDimensions[0] + "px").style("height", setPhotoDimensions[1] + "px"); + dispatch14.call("resize", photoviewer2, subtractPadding(setPhotoDimensions, photoviewer2)); } }; - context.history().on("merge.features", function(newEntities) { - if (!newEntities) return; - var handle = window.requestIdleCallback(function() { - var graph = context.graph(); - var types = utilArrayGroupBy(newEntities, "type"); - var entities = [].concat(types.relation || [], types.way || [], types.node || []); - for (var i3 = 0; i3 < entities.length; i3++) { - var geometry = entities[i3].geometry(graph); - features.getMatches(entities[i3], graph, geometry); - } - }); - _deferred2.add(handle); - }); - return utilRebind(features, dispatch14, "on"); - } - - // modules/util/bind_once.js - function utilBindOnce(target, type2, listener, capture) { - var typeOnce = type2 + ".once"; - function one2() { - target.on(typeOnce, null); - listener.apply(this, arguments); + function subtractPadding(dimensions, selection2) { + return [ + dimensions[0] - parseFloat(selection2.style("padding-left")) - parseFloat(selection2.style("padding-right")), + dimensions[1] - parseFloat(selection2.style("padding-top")) - parseFloat(selection2.style("padding-bottom")) + ]; } - target.on(typeOnce, one2, capture); - return this; + return utilRebind(photoviewer, dispatch14, "on"); } + var init_photoviewer = __esm({ + "modules/ui/photoviewer.js"() { + "use strict"; + init_src5(); + init_localizer(); + init_src4(); + init_icon(); + init_dimensions(); + init_util(); + init_services(); + init_tooltip(); + init_actions(); + init_geo2(); + } + }); - // modules/util/zoom_pan.js - function defaultFilter3(d3_event) { - return !d3_event.ctrlKey && !d3_event.button; + // modules/ui/restore.js + var restore_exports = {}; + __export(restore_exports, { + uiRestore: () => uiRestore + }); + function uiRestore(context) { + return function(selection2) { + if (!context.history().hasRestorableChanges()) return; + let modalSelection = uiModal(selection2, true); + modalSelection.select(".modal").attr("class", "modal fillL"); + let introModal = modalSelection.select(".content"); + introModal.append("div").attr("class", "modal-section").append("h3").call(_t.append("restore.heading")); + introModal.append("div").attr("class", "modal-section").append("p").call(_t.append("restore.description")); + let buttonWrap = introModal.append("div").attr("class", "modal-actions"); + let restore = buttonWrap.append("button").attr("class", "restore").on("click", () => { + context.history().restore(); + modalSelection.remove(); + }); + restore.append("svg").attr("class", "logo logo-restore").append("use").attr("xlink:href", "#iD-logo-restore"); + restore.append("div").call(_t.append("restore.restore")); + let reset = buttonWrap.append("button").attr("class", "reset").on("click", () => { + context.history().clearSaved(); + modalSelection.remove(); + }); + reset.append("svg").attr("class", "logo logo-reset").append("use").attr("xlink:href", "#iD-logo-reset"); + reset.append("div").call(_t.append("restore.reset")); + restore.node().focus(); + }; } - function defaultExtent2() { - var e3 = this; - if (e3 instanceof SVGElement) { - e3 = e3.ownerSVGElement || e3; - if (e3.hasAttribute("viewBox")) { - e3 = e3.viewBox.baseVal; - return [[e3.x, e3.y], [e3.x + e3.width, e3.y + e3.height]]; + var init_restore = __esm({ + "modules/ui/restore.js"() { + "use strict"; + init_localizer(); + init_modal(); + } + }); + + // modules/ui/scale.js + var scale_exports2 = {}; + __export(scale_exports2, { + uiScale: () => uiScale + }); + function uiScale(context) { + var projection2 = context.projection, isImperial = !_mainLocalizer.usesMetric(), maxLength = 180, tickHeight = 8; + function scaleDefs(loc1, loc2) { + var lat = (loc2[1] + loc1[1]) / 2, conversion = isImperial ? 3.28084 : 1, dist = geoLonToMeters(loc2[0] - loc1[0], lat) * conversion, scale = { dist: 0, px: 0, text: "" }, buckets, i3, val, dLon; + if (isImperial) { + buckets = [528e4, 528e3, 52800, 5280, 500, 50, 5, 1]; + } else { + buckets = [5e6, 5e5, 5e4, 5e3, 500, 50, 5, 1]; } - return [[0, 0], [e3.width.baseVal.value, e3.height.baseVal.value]]; + for (i3 = 0; i3 < buckets.length; i3++) { + val = buckets[i3]; + if (dist >= val) { + scale.dist = Math.floor(dist / val) * val; + break; + } else { + scale.dist = +dist.toFixed(2); + } + } + dLon = geoMetersToLon(scale.dist / conversion, lat); + scale.px = Math.round(projection2([loc1[0] + dLon, loc1[1]])[0]); + scale.text = displayLength(scale.dist / conversion, isImperial); + return scale; } - return [[0, 0], [e3.clientWidth, e3.clientHeight]]; - } - function defaultWheelDelta2(d3_event) { - return -d3_event.deltaY * (d3_event.deltaMode === 1 ? 0.05 : d3_event.deltaMode ? 1 : 2e-3); - } - function defaultConstrain2(transform2, extent, translateExtent) { - var dx0 = transform2.invertX(extent[0][0]) - translateExtent[0][0], dx1 = transform2.invertX(extent[1][0]) - translateExtent[1][0], dy0 = transform2.invertY(extent[0][1]) - translateExtent[0][1], dy1 = transform2.invertY(extent[1][1]) - translateExtent[1][1]; - return transform2.translate( - dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1), - dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1) - ); - } - function utilZoomPan() { - var filter2 = defaultFilter3, extent = defaultExtent2, constrain = defaultConstrain2, wheelDelta = defaultWheelDelta2, scaleExtent = [0, Infinity], translateExtent = [[-Infinity, -Infinity], [Infinity, Infinity]], interpolate = zoom_default, dispatch14 = dispatch_default("start", "zoom", "end"), _wheelDelay = 150, _transform = identity2, _activeGesture; - function zoom(selection2) { - selection2.on("pointerdown.zoom", pointerdown).on("wheel.zoom", wheeled).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)"); - select_default2(window).on("pointermove.zoompan", pointermove).on("pointerup.zoompan pointercancel.zoompan", pointerup); + function update(selection2) { + var dims = context.map().dimensions(), loc1 = projection2.invert([0, dims[1]]), loc2 = projection2.invert([maxLength, dims[1]]), scale = scaleDefs(loc1, loc2); + selection2.select(".scale-path").attr("d", "M0.5,0.5v" + tickHeight + "h" + scale.px + "v-" + tickHeight); + selection2.select(".scale-text").style(_mainLocalizer.textDirection() === "ltr" ? "left" : "right", scale.px + 16 + "px").text(scale.text); } - zoom.transform = function(collection, transform2, point) { - var selection2 = collection.selection ? collection.selection() : collection; - if (collection !== selection2) { - schedule(collection, transform2, point); - } else { - selection2.interrupt().each(function() { - gesture(this, arguments).start(null).zoom(null, null, typeof transform2 === "function" ? transform2.apply(this, arguments) : transform2).end(null); - }); + return function(selection2) { + function switchUnits() { + isImperial = !isImperial; + selection2.call(update); } - }; - zoom.scaleBy = function(selection2, k2, p2) { - zoom.scaleTo(selection2, function() { - var k0 = _transform.k, k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2; - return k0 * k1; - }, p2); - }; - zoom.scaleTo = function(selection2, k2, p2) { - zoom.transform(selection2, function() { - var e3 = extent.apply(this, arguments), t0 = _transform, p02 = !p2 ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2, p1 = t0.invert(p02), k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2; - return constrain(translate(scale(t0, k1), p02, p1), e3, translateExtent); - }, p2); - }; - zoom.translateBy = function(selection2, x2, y2) { - zoom.transform(selection2, function() { - return constrain(_transform.translate( - typeof x2 === "function" ? x2.apply(this, arguments) : x2, - typeof y2 === "function" ? y2.apply(this, arguments) : y2 - ), extent.apply(this, arguments), translateExtent); + var scalegroup = selection2.append("svg").attr("class", "scale").on("click", switchUnits).append("g").attr("transform", "translate(10,11)"); + scalegroup.append("path").attr("class", "scale-path"); + selection2.append("div").attr("class", "scale-text"); + selection2.call(update); + context.map().on("move.scale", function() { + update(selection2); }); }; - zoom.translateTo = function(selection2, x2, y2, p2) { - zoom.transform(selection2, function() { - var e3 = extent.apply(this, arguments), t2 = _transform, p02 = !p2 ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2; - return constrain(identity2.translate(p02[0], p02[1]).scale(t2.k).translate( - typeof x2 === "function" ? -x2.apply(this, arguments) : -x2, - typeof y2 === "function" ? -y2.apply(this, arguments) : -y2 - ), e3, translateExtent); - }, p2); - }; - function scale(transform2, k2) { - k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k2)); - return k2 === transform2.k ? transform2 : new Transform(k2, transform2.x, transform2.y); - } - function translate(transform2, p02, p1) { - var x2 = p02[0] - p1[0] * transform2.k, y2 = p02[1] - p1[1] * transform2.k; - return x2 === transform2.x && y2 === transform2.y ? transform2 : new Transform(transform2.k, x2, y2); - } - function centroid(extent2) { - return [(+extent2[0][0] + +extent2[1][0]) / 2, (+extent2[0][1] + +extent2[1][1]) / 2]; + } + var init_scale2 = __esm({ + "modules/ui/scale.js"() { + "use strict"; + init_units(); + init_geo2(); + init_localizer(); } - function schedule(transition2, transform2, point) { - transition2.on("start.zoom", function() { - gesture(this, arguments).start(null); - }).on("interrupt.zoom end.zoom", function() { - gesture(this, arguments).end(null); - }).tween("zoom", function() { - var that = this, args = arguments, g3 = gesture(that, args), e3 = extent.apply(that, args), p2 = !point ? centroid(e3) : typeof point === "function" ? point.apply(that, args) : point, w2 = Math.max(e3[1][0] - e3[0][0], e3[1][1] - e3[0][1]), a2 = _transform, b2 = typeof transform2 === "function" ? transform2.apply(that, args) : transform2, i3 = interpolate(a2.invert(p2).concat(w2 / a2.k), b2.invert(p2).concat(w2 / b2.k)); - return function(t2) { - if (t2 === 1) { - t2 = b2; - } else { - var l2 = i3(t2); - var k2 = w2 / l2[2]; - t2 = new Transform(k2, p2[0] - l2[0] * k2, p2[1] - l2[1] * k2); - } - g3.zoom(null, null, t2); - }; + }); + + // modules/ui/shortcuts.js + var shortcuts_exports = {}; + __export(shortcuts_exports, { + uiShortcuts: () => uiShortcuts + }); + function uiShortcuts(context) { + var detected = utilDetect(); + var _activeTab = 0; + var _modalSelection; + var _selection = select_default2(null); + var _dataShortcuts; + function shortcutsModal(_modalSelection2) { + _modalSelection2.select(".modal").classed("modal-shortcuts", true); + var content = _modalSelection2.select(".content"); + content.append("div").attr("class", "modal-section header").append("h2").call(_t.append("shortcuts.title")); + _mainFileFetcher.get("shortcuts").then(function(data) { + _dataShortcuts = data; + content.call(render); + }).catch(function() { }); } - function gesture(that, args, clean2) { - return !clean2 && _activeGesture || new Gesture(that, args); - } - function Gesture(that, args) { - this.that = that; - this.args = args; - this.active = 0; - this.extent = extent.apply(that, args); - } - Gesture.prototype = { - start: function(d3_event) { - if (++this.active === 1) { - _activeGesture = this; - dispatch14.call("start", this, d3_event); + function render(selection2) { + if (!_dataShortcuts) return; + var wrapper = selection2.selectAll(".wrapper").data([0]); + var wrapperEnter = wrapper.enter().append("div").attr("class", "wrapper modal-section"); + var tabsBar = wrapperEnter.append("div").attr("class", "tabs-bar"); + var shortcutsList = wrapperEnter.append("div").attr("class", "shortcuts-list"); + wrapper = wrapper.merge(wrapperEnter); + var tabs = tabsBar.selectAll(".tab").data(_dataShortcuts); + var tabsEnter = tabs.enter().append("a").attr("class", "tab").attr("href", "#").on("click", function(d3_event, d2) { + d3_event.preventDefault(); + var i3 = _dataShortcuts.indexOf(d2); + _activeTab = i3; + render(selection2); + }); + tabsEnter.append("span").html(function(d2) { + return _t.html(d2.text); + }); + wrapper.selectAll(".tab").classed("active", function(d2, i3) { + return i3 === _activeTab; + }); + var shortcuts = shortcutsList.selectAll(".shortcut-tab").data(_dataShortcuts); + var shortcutsEnter = shortcuts.enter().append("div").attr("class", function(d2) { + return "shortcut-tab shortcut-tab-" + d2.tab; + }); + var columnsEnter = shortcutsEnter.selectAll(".shortcut-column").data(function(d2) { + return d2.columns; + }).enter().append("table").attr("class", "shortcut-column"); + var rowsEnter = columnsEnter.selectAll(".shortcut-row").data(function(d2) { + return d2.rows; + }).enter().append("tr").attr("class", "shortcut-row"); + var sectionRows = rowsEnter.filter(function(d2) { + return !d2.shortcuts; + }); + sectionRows.append("td"); + sectionRows.append("td").attr("class", "shortcut-section").append("h3").html(function(d2) { + return _t.html(d2.text); + }); + var shortcutRows = rowsEnter.filter(function(d2) { + return d2.shortcuts; + }); + var shortcutKeys = shortcutRows.append("td").attr("class", "shortcut-keys"); + var modifierKeys = shortcutKeys.filter(function(d2) { + return d2.modifiers; + }); + modifierKeys.selectAll("kbd.modifier").data(function(d2) { + if (detected.os === "win" && d2.text === "shortcuts.editing.commands.redo") { + return ["\u2318"]; + } else if (detected.os !== "mac" && d2.text === "shortcuts.browsing.display_options.fullscreen") { + return []; + } else { + return d2.modifiers; } - return this; - }, - zoom: function(d3_event, key, transform2) { - if (this.mouse && key !== "mouse") this.mouse[1] = transform2.invert(this.mouse[0]); - if (this.pointer0 && key !== "touch") this.pointer0[1] = transform2.invert(this.pointer0[0]); - if (this.pointer1 && key !== "touch") this.pointer1[1] = transform2.invert(this.pointer1[0]); - _transform = transform2; - dispatch14.call("zoom", this, d3_event, key, transform2); - return this; - }, - end: function(d3_event) { - if (--this.active === 0) { - _activeGesture = null; - dispatch14.call("end", this, d3_event); + }).enter().each(function() { + var selection3 = select_default2(this); + selection3.append("kbd").attr("class", "modifier").text(function(d2) { + return uiCmd.display(d2); + }); + selection3.append("span").text("+"); + }); + shortcutKeys.selectAll("kbd.shortcut").data(function(d2) { + var arr = d2.shortcuts; + if (detected.os === "win" && d2.text === "shortcuts.editing.commands.redo") { + arr = ["Y"]; + } else if (detected.os !== "mac" && d2.text === "shortcuts.browsing.display_options.fullscreen") { + arr = ["F11"]; } - return this; - } - }; - function wheeled(d3_event) { - if (!filter2.apply(this, arguments)) return; - var g3 = gesture(this, arguments), t2 = _transform, k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], t2.k * Math.pow(2, wheelDelta.apply(this, arguments)))), p2 = utilFastMouse(this)(d3_event); - if (g3.wheel) { - if (g3.mouse[0][0] !== p2[0] || g3.mouse[0][1] !== p2[1]) { - g3.mouse[1] = t2.invert(g3.mouse[0] = p2); + arr = arr.map(function(s2) { + return uiCmd.display(s2.indexOf(".") !== -1 ? _t(s2) : s2); + }); + return utilArrayUniq(arr).map(function(s2) { + return { + shortcut: s2, + separator: d2.separator, + suffix: d2.suffix + }; + }); + }).enter().each(function(d2, i3, nodes) { + var selection3 = select_default2(this); + var click = d2.shortcut.toLowerCase().match(/(.*).click/); + if (click && click[1]) { + selection3.call(svgIcon("#iD-walkthrough-mouse-" + click[1], "operation")); + } else if (d2.shortcut.toLowerCase() === "long-press") { + selection3.call(svgIcon("#iD-walkthrough-longpress", "longpress operation")); + } else if (d2.shortcut.toLowerCase() === "tap") { + selection3.call(svgIcon("#iD-walkthrough-tap", "tap operation")); + } else { + selection3.append("kbd").attr("class", "shortcut").text(function(d4) { + return d4.shortcut; + }); } - clearTimeout(g3.wheel); - } else { - g3.mouse = [p2, t2.invert(p2)]; - interrupt_default(this); - g3.start(d3_event); - } - d3_event.preventDefault(); - d3_event.stopImmediatePropagation(); - g3.wheel = setTimeout(wheelidled, _wheelDelay); - g3.zoom(d3_event, "mouse", constrain(translate(scale(t2, k2), g3.mouse[0], g3.mouse[1]), g3.extent, translateExtent)); - function wheelidled() { - g3.wheel = null; - g3.end(d3_event); + if (i3 < nodes.length - 1) { + selection3.append("span").html(d2.separator || "\xA0" + _t.html("shortcuts.or") + "\xA0"); + } else if (i3 === nodes.length - 1 && d2.suffix) { + selection3.append("span").text(d2.suffix); + } + }); + shortcutKeys.filter(function(d2) { + return d2.gesture; + }).each(function() { + var selection3 = select_default2(this); + selection3.append("span").text("+"); + selection3.append("span").attr("class", "gesture").html(function(d2) { + return _t.html(d2.gesture); + }); + }); + shortcutRows.append("td").attr("class", "shortcut-desc").html(function(d2) { + return d2.text ? _t.html(d2.text) : "\xA0"; + }); + wrapper.selectAll(".shortcut-tab").style("display", function(d2, i3) { + return i3 === _activeTab ? "flex" : "none"; + }); + } + return function(selection2, show) { + _selection = selection2; + if (show) { + _modalSelection = uiModal(selection2); + _modalSelection.call(shortcutsModal); + } else { + context.keybinding().on([_t("shortcuts.toggle.key"), "?"], function() { + if (context.container().selectAll(".modal-shortcuts").size()) { + if (_modalSelection) { + _modalSelection.close(); + _modalSelection = null; + } + } else { + _modalSelection = uiModal(_selection); + _modalSelection.call(shortcutsModal); + } + }); } + }; + } + var init_shortcuts = __esm({ + "modules/ui/shortcuts.js"() { + "use strict"; + init_src5(); + init_file_fetcher(); + init_localizer(); + init_icon(); + init_cmd(); + init_modal(); + init_util(); + init_detect(); } - var _downPointerIDs = /* @__PURE__ */ new Set(); - var _pointerLocGetter; - function pointerdown(d3_event) { - _downPointerIDs.add(d3_event.pointerId); - if (!filter2.apply(this, arguments)) return; - var g3 = gesture(this, arguments, _downPointerIDs.size === 1); - var started; - d3_event.stopImmediatePropagation(); - _pointerLocGetter = utilFastMouse(this); - var loc = _pointerLocGetter(d3_event); - var p2 = [loc, _transform.invert(loc), d3_event.pointerId]; - if (!g3.pointer0) { - g3.pointer0 = p2; - started = true; - } else if (!g3.pointer1 && g3.pointer0[2] !== p2[2]) { - g3.pointer1 = p2; - } - if (started) { - interrupt_default(this); - g3.start(d3_event); - } + }); + + // modules/ui/data_header.js + var data_header_exports = {}; + __export(data_header_exports, { + uiDataHeader: () => uiDataHeader + }); + function uiDataHeader() { + var _datum; + function dataHeader(selection2) { + var header = selection2.selectAll(".data-header").data( + _datum ? [_datum] : [], + function(d2) { + return d2.__featurehash__; + } + ); + header.exit().remove(); + var headerEnter = header.enter().append("div").attr("class", "data-header"); + var iconEnter = headerEnter.append("div").attr("class", "data-header-icon"); + iconEnter.append("div").attr("class", "preset-icon-28").call(svgIcon("#iD-icon-data", "note-fill")); + headerEnter.append("div").attr("class", "data-header-label").call(_t.append("map_data.layers.custom.title")); } - function pointermove(d3_event) { - if (!_downPointerIDs.has(d3_event.pointerId)) return; - if (!_activeGesture || !_pointerLocGetter) return; - var g3 = gesture(this, arguments); - var isPointer0 = g3.pointer0 && g3.pointer0[2] === d3_event.pointerId; - var isPointer1 = !isPointer0 && g3.pointer1 && g3.pointer1[2] === d3_event.pointerId; - if ((isPointer0 || isPointer1) && "buttons" in d3_event && !d3_event.buttons) { - if (g3.pointer0) _downPointerIDs.delete(g3.pointer0[2]); - if (g3.pointer1) _downPointerIDs.delete(g3.pointer1[2]); - g3.end(d3_event); - return; + dataHeader.datum = function(val) { + if (!arguments.length) return _datum; + _datum = val; + return this; + }; + return dataHeader; + } + var init_data_header = __esm({ + "modules/ui/data_header.js"() { + "use strict"; + init_localizer(); + init_icon(); + } + }); + + // modules/ui/disclosure.js + var disclosure_exports = {}; + __export(disclosure_exports, { + uiDisclosure: () => uiDisclosure + }); + function uiDisclosure(context, key, expandedDefault) { + var dispatch14 = dispatch_default("toggled"); + var _expanded; + var _label = utilFunctor(""); + var _updatePreference = true; + var _content = function() { + }; + var disclosure = function(selection2) { + if (_expanded === void 0 || _expanded === null) { + var preference = corePreferences("disclosure." + key + ".expanded"); + _expanded = preference === null ? !!expandedDefault : preference === "true"; } - d3_event.preventDefault(); - d3_event.stopImmediatePropagation(); - var loc = _pointerLocGetter(d3_event); - var t2, p2, l2; - if (isPointer0) g3.pointer0[0] = loc; - else if (isPointer1) g3.pointer1[0] = loc; - t2 = _transform; - if (g3.pointer1) { - var p02 = g3.pointer0[0], l0 = g3.pointer0[1], p1 = g3.pointer1[0], l1 = g3.pointer1[1], dp = (dp = p1[0] - p02[0]) * dp + (dp = p1[1] - p02[1]) * dp, dl = (dl = l1[0] - l0[0]) * dl + (dl = l1[1] - l0[1]) * dl; - t2 = scale(t2, Math.sqrt(dp / dl)); - p2 = [(p02[0] + p1[0]) / 2, (p02[1] + p1[1]) / 2]; - l2 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2]; - } else if (g3.pointer0) { - p2 = g3.pointer0[0]; - l2 = g3.pointer0[1]; + var hideToggle = selection2.selectAll(".hide-toggle-" + key).data([0]); + var hideToggleEnter = hideToggle.enter().append("h3").append("a").attr("role", "button").attr("href", "#").attr("class", "hide-toggle hide-toggle-" + key).call(svgIcon("", "pre-text", "hide-toggle-icon")); + hideToggleEnter.append("span").attr("class", "hide-toggle-text"); + hideToggle = hideToggleEnter.merge(hideToggle); + hideToggle.on("click", toggle).attr("title", _t(`icons.${_expanded ? "collapse" : "expand"}`)).attr("aria-expanded", _expanded).classed("expanded", _expanded); + const label = _label(); + const labelSelection = hideToggle.selectAll(".hide-toggle-text"); + if (typeof label !== "function") { + labelSelection.text(_label()); } else { - return; + labelSelection.text("").call(label); } - g3.zoom(d3_event, "touch", constrain(translate(t2, p2, l2), g3.extent, translateExtent)); - } - function pointerup(d3_event) { - if (!_downPointerIDs.has(d3_event.pointerId)) return; - _downPointerIDs.delete(d3_event.pointerId); - if (!_activeGesture) return; - var g3 = gesture(this, arguments); - d3_event.stopImmediatePropagation(); - if (g3.pointer0 && g3.pointer0[2] === d3_event.pointerId) delete g3.pointer0; - else if (g3.pointer1 && g3.pointer1[2] === d3_event.pointerId) delete g3.pointer1; - if (g3.pointer1 && !g3.pointer0) { - g3.pointer0 = g3.pointer1; - delete g3.pointer1; + hideToggle.selectAll(".hide-toggle-icon").attr( + "xlink:href", + _expanded ? "#iD-icon-down" : _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward" + ); + var wrap2 = selection2.selectAll(".disclosure-wrap").data([0]); + wrap2 = wrap2.enter().append("div").attr("class", "disclosure-wrap disclosure-wrap-" + key).merge(wrap2).classed("hide", !_expanded); + if (_expanded) { + wrap2.call(_content); } - if (g3.pointer0) { - g3.pointer0[1] = _transform.invert(g3.pointer0[0]); - } else { - g3.end(d3_event); + function toggle(d3_event) { + d3_event.preventDefault(); + _expanded = !_expanded; + if (_updatePreference) { + corePreferences("disclosure." + key + ".expanded", _expanded); + } + hideToggle.classed("expanded", _expanded).attr("aria-expanded", _expanded).attr("title", _t(`icons.${_expanded ? "collapse" : "expand"}`)); + hideToggle.selectAll(".hide-toggle-icon").attr( + "xlink:href", + _expanded ? "#iD-icon-down" : _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward" + ); + wrap2.call(uiToggle(_expanded)); + if (_expanded) { + wrap2.call(_content); + } + dispatch14.call("toggled", this, _expanded); } + }; + disclosure.label = function(val) { + if (!arguments.length) return _label; + _label = utilFunctor(val); + return disclosure; + }; + disclosure.expanded = function(val) { + if (!arguments.length) return _expanded; + _expanded = val; + return disclosure; + }; + disclosure.updatePreference = function(val) { + if (!arguments.length) return _updatePreference; + _updatePreference = val; + return disclosure; + }; + disclosure.content = function(val) { + if (!arguments.length) return _content; + _content = val; + return disclosure; + }; + return utilRebind(disclosure, dispatch14, "on"); + } + var init_disclosure = __esm({ + "modules/ui/disclosure.js"() { + "use strict"; + init_src4(); + init_preferences(); + init_icon(); + init_util(); + init_rebind(); + init_toggle(); + init_localizer(); } - zoom.wheelDelta = function(_2) { - return arguments.length ? (wheelDelta = utilFunctor(+_2), zoom) : wheelDelta; + }); + + // modules/ui/section.js + var section_exports = {}; + __export(section_exports, { + uiSection: () => uiSection + }); + function uiSection(id2, context) { + var _classes = utilFunctor(""); + var _shouldDisplay; + var _content; + var _disclosure; + var _label; + var _expandedByDefault = utilFunctor(true); + var _disclosureContent; + var _disclosureExpanded; + var _containerSelection = select_default2(null); + var section = { + id: id2 }; - zoom.filter = function(_2) { - return arguments.length ? (filter2 = utilFunctor(!!_2), zoom) : filter2; + section.classes = function(val) { + if (!arguments.length) return _classes; + _classes = utilFunctor(val); + return section; }; - zoom.extent = function(_2) { - return arguments.length ? (extent = utilFunctor([[+_2[0][0], +_2[0][1]], [+_2[1][0], +_2[1][1]]]), zoom) : extent; + section.label = function(val) { + if (!arguments.length) return _label; + _label = utilFunctor(val); + return section; }; - zoom.scaleExtent = function(_2) { - return arguments.length ? (scaleExtent[0] = +_2[0], scaleExtent[1] = +_2[1], zoom) : [scaleExtent[0], scaleExtent[1]]; + section.expandedByDefault = function(val) { + if (!arguments.length) return _expandedByDefault; + _expandedByDefault = utilFunctor(val); + return section; }; - zoom.translateExtent = function(_2) { - return arguments.length ? (translateExtent[0][0] = +_2[0][0], translateExtent[1][0] = +_2[1][0], translateExtent[0][1] = +_2[0][1], translateExtent[1][1] = +_2[1][1], zoom) : [[translateExtent[0][0], translateExtent[0][1]], [translateExtent[1][0], translateExtent[1][1]]]; + section.shouldDisplay = function(val) { + if (!arguments.length) return _shouldDisplay; + _shouldDisplay = utilFunctor(val); + return section; }; - zoom.constrain = function(_2) { - return arguments.length ? (constrain = _2, zoom) : constrain; + section.content = function(val) { + if (!arguments.length) return _content; + _content = val; + return section; }; - zoom.interpolate = function(_2) { - return arguments.length ? (interpolate = _2, zoom) : interpolate; + section.disclosureContent = function(val) { + if (!arguments.length) return _disclosureContent; + _disclosureContent = val; + return section; }; - zoom._transform = function(_2) { - return arguments.length ? (_transform = _2, zoom) : _transform; + section.disclosureExpanded = function(val) { + if (!arguments.length) return _disclosureExpanded; + _disclosureExpanded = val; + return section; }; - return utilRebind(zoom, dispatch14, "on"); + section.render = function(selection2) { + _containerSelection = selection2.selectAll(".section-" + id2).data([0]); + var sectionEnter = _containerSelection.enter().append("div").attr("class", "section section-" + id2 + " " + (_classes && _classes() || "")); + _containerSelection = sectionEnter.merge(_containerSelection); + _containerSelection.call(renderContent); + }; + section.reRender = function() { + _containerSelection.call(renderContent); + }; + section.selection = function() { + return _containerSelection; + }; + section.disclosure = function() { + return _disclosure; + }; + function renderContent(selection2) { + if (_shouldDisplay) { + var shouldDisplay = _shouldDisplay(); + selection2.classed("hide", !shouldDisplay); + if (!shouldDisplay) { + selection2.html(""); + return; + } + } + if (_disclosureContent) { + if (!_disclosure) { + _disclosure = uiDisclosure(context, id2.replace(/-/g, "_"), _expandedByDefault()).label(_label || "").content(_disclosureContent); + } + if (_disclosureExpanded !== void 0) { + _disclosure.expanded(_disclosureExpanded); + _disclosureExpanded = void 0; + } + selection2.call(_disclosure); + return; + } + if (_content) { + selection2.call(_content); + } + } + return section; } + var init_section = __esm({ + "modules/ui/section.js"() { + "use strict"; + init_src5(); + init_disclosure(); + init_util(); + } + }); - // modules/util/double_up.js - function utilDoubleUp() { - var dispatch14 = dispatch_default("doubleUp"); - var _maxTimespan = 500; - var _maxDistance = 20; - var _pointer; - function pointerIsValidFor(loc) { - return (/* @__PURE__ */ new Date()).getTime() - _pointer.startTime <= _maxTimespan && // all pointer events must occur within a small distance of the first pointerdown - geoVecLength(_pointer.startLoc, loc) <= _maxDistance; + // modules/ui/tag_reference.js + var tag_reference_exports = {}; + __export(tag_reference_exports, { + uiTagReference: () => uiTagReference + }); + function uiTagReference(what) { + var wikibase = what.qid ? services.wikidata : services.osmWikibase; + var tagReference = {}; + var _button = select_default2(null); + var _body = select_default2(null); + var _loaded; + var _showing; + function load() { + if (!wikibase) return; + _button.classed("tag-reference-loading", true); + wikibase.getDocs(what, gotDocs); } - function pointerdown(d3_event) { - if (d3_event.ctrlKey || d3_event.button === 2) return; - var loc = [d3_event.clientX, d3_event.clientY]; - if (_pointer && !pointerIsValidFor(loc)) { - _pointer = void 0; + function gotDocs(err, docs) { + _body.html(""); + if (!docs || !docs.title) { + _body.append("p").attr("class", "tag-reference-description").call(_t.append("inspector.no_documentation_key")); + done(); + return; } - if (!_pointer) { - _pointer = { - startLoc: loc, - startTime: (/* @__PURE__ */ new Date()).getTime(), - upCount: 0, - pointerId: d3_event.pointerId - }; + if (docs.imageURL) { + _body.append("img").attr("class", "tag-reference-wiki-image").attr("alt", docs.title).attr("src", docs.imageURL).on("load", function() { + done(); + }).on("error", function() { + select_default2(this).remove(); + done(); + }); } else { - _pointer.pointerId = d3_event.pointerId; + done(); + } + var tagReferenceDescription = _body.append("p").attr("class", "tag-reference-description").append("span"); + if (docs.description) { + tagReferenceDescription = tagReferenceDescription.attr("class", "localized-text").attr("lang", docs.descriptionLocaleCode || "und").call(docs.description); + } else { + tagReferenceDescription = tagReferenceDescription.call(_t.append("inspector.no_documentation_key")); + } + tagReferenceDescription.append("a").attr("class", "tag-reference-edit").attr("target", "_blank").attr("title", _t("inspector.edit_reference")).attr("href", docs.editURL).call(svgIcon("#iD-icon-edit", "inline")); + if (docs.wiki) { + _body.append("a").attr("class", "tag-reference-link").attr("target", "_blank").attr("href", docs.wiki.url).call(svgIcon("#iD-icon-out-link", "inline")).append("span").call(_t.append(docs.wiki.text)); + } + if (what.key === "comment") { + _body.append("a").attr("class", "tag-reference-comment-link").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).attr("href", _t("commit.about_changeset_comments_link")).append("span").call(_t.append("commit.about_changeset_comments")); } } - function pointerup(d3_event) { - if (d3_event.ctrlKey || d3_event.button === 2) return; - if (!_pointer || _pointer.pointerId !== d3_event.pointerId) return; - _pointer.upCount += 1; - if (_pointer.upCount === 2) { - var loc = [d3_event.clientX, d3_event.clientY]; - if (pointerIsValidFor(loc)) { - var locInThis = utilFastMouse(this)(d3_event); - dispatch14.call("doubleUp", this, d3_event, locInThis); + function done() { + _loaded = true; + _button.classed("tag-reference-loading", false); + _body.classed("expanded", true).transition().duration(200).style("max-height", "200px").style("opacity", "1"); + _showing = true; + _button.selectAll("svg.icon use").each(function() { + var iconUse = select_default2(this); + if (iconUse.attr("href") === "#iD-icon-info") { + iconUse.attr("href", "#iD-icon-info-filled"); } - _pointer = void 0; - } + }); } - function doubleUp(selection2) { - if ("PointerEvent" in window) { - selection2.on("pointerdown.doubleUp", pointerdown).on("pointerup.doubleUp", pointerup); - } else { - selection2.on("dblclick.doubleUp", function(d3_event) { - dispatch14.call("doubleUp", this, d3_event, utilFastMouse(this)(d3_event)); - }); - } + function hide() { + _body.transition().duration(200).style("max-height", "0px").style("opacity", "0").on("end", function() { + _body.classed("expanded", false); + }); + _showing = false; + _button.selectAll("svg.icon use").each(function() { + var iconUse = select_default2(this); + if (iconUse.attr("href") === "#iD-icon-info-filled") { + iconUse.attr("href", "#iD-icon-info"); + } + }); } - doubleUp.off = function(selection2) { - selection2.on("pointerdown.doubleUp", null).on("pointerup.doubleUp", null).on("dblclick.doubleUp", null); + tagReference.button = function(selection2, klass, iconName) { + _button = selection2.selectAll(".tag-reference-button").data([0]); + _button = _button.enter().append("button").attr("class", "tag-reference-button " + (klass || "")).attr("title", _t("icons.information")).call(svgIcon("#iD-icon-" + (iconName || "inspect"))).merge(_button); + _button.on("click", function(d3_event) { + d3_event.stopPropagation(); + d3_event.preventDefault(); + this.blur(); + if (_showing) { + hide(); + } else if (_loaded) { + done(); + } else { + load(); + } + }); }; - return utilRebind(doubleUp, dispatch14, "on"); + tagReference.body = function(selection2) { + var itemID = what.qid || what.key + "-" + (what.value || ""); + _body = selection2.selectAll(".tag-reference-body").data([itemID], function(d2) { + return d2; + }); + _body.exit().remove(); + _body = _body.enter().append("div").attr("class", "tag-reference-body").style("max-height", "0").style("opacity", "0").merge(_body); + if (_showing === false) { + hide(); + } + }; + tagReference.showing = function(val) { + if (!arguments.length) return _showing; + _showing = val; + return tagReference; + }; + return tagReference; } + var init_tag_reference = __esm({ + "modules/ui/tag_reference.js"() { + "use strict"; + init_src5(); + init_localizer(); + init_services(); + init_icon(); + } + }); - // modules/renderer/map.js - var TILESIZE = 256; - var minZoom2 = 2; - var maxZoom = 24; - var kMin = geoZoomToScale(minZoom2, TILESIZE); - var kMax = geoZoomToScale(maxZoom, TILESIZE); - function clamp2(num, min3, max3) { - return Math.max(min3, Math.min(num, max3)); - } - function rendererMap(context) { - var dispatch14 = dispatch_default( - "move", - "drawn", - "crossEditableZoom", - "hitMinZoom", - "changeHighlighting", - "changeAreaFill" - ); - var projection2 = context.projection; - var curtainProjection = context.curtainProjection; - var drawLayers; - var drawPoints; - var drawVertices; - var drawLines; - var drawAreas; - var drawMidpoints; - var drawLabels; - var _selection = select_default2(null); - var supersurface = select_default2(null); - var wrapper = select_default2(null); - var surface = select_default2(null); - var _dimensions = [1, 1]; - var _dblClickZoomEnabled = true; - var _redrawEnabled = true; - var _gestureTransformStart; - var _transformStart = projection2.transform(); - var _transformLast; - var _isTransformed = false; - var _minzoom = 0; - var _getMouseCoords; - var _lastPointerEvent; - var _lastWithinEditableZoom; - var _pointerDown = false; - var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse"; - var _zoomerPannerFunction = "PointerEvent" in window ? utilZoomPan : zoom_default2; - var _zoomerPanner = _zoomerPannerFunction().scaleExtent([kMin, kMax]).interpolate(value_default).filter(zoomEventFilter).on("zoom.map", zoomPan2).on("start.map", function(d3_event) { - _pointerDown = d3_event && (d3_event.type === "pointerdown" || d3_event.sourceEvent && d3_event.sourceEvent.type === "pointerdown"); - }).on("end.map", function() { - _pointerDown = false; + // modules/ui/sections/raw_tag_editor.js + var raw_tag_editor_exports = {}; + __export(raw_tag_editor_exports, { + uiSectionRawTagEditor: () => uiSectionRawTagEditor + }); + 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 _doubleUpHandler = utilDoubleUp(); - var scheduleRedraw = throttle_default(redraw, 750); - function cancelPendingRedraw() { - scheduleRedraw.cancel(); + 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 map2(selection2) { - _selection = selection2; - context.on("change.map", immediateRedraw); - var osm = context.connection(); - if (osm) { - osm.on("change.map", immediateRedraw); + 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]); } - function didUndoOrRedo(targetTransform) { - var mode = context.mode().id; - if (mode !== "browse" && mode !== "select") return; - if (targetTransform) { - map2.transformEase(targetTransform); - } + 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: "" }); } - context.history().on("merge.map", function() { - scheduleRedraw(); - }).on("change.map", immediateRedraw).on("undone.map", function(stack, fromStack) { - didUndoOrRedo(fromStack.transform); - }).on("redone.map", function(stack) { - didUndoOrRedo(stack.transform); + 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)); }); - context.background().on("change.map", immediateRedraw); - context.features().on("redraw.map", immediateRedraw); - drawLayers.on("change.map", function() { - context.background().updateImagery(); - immediateRedraw(); + 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; }); - selection2.on("wheel.map mousewheel.map", function(d3_event) { - d3_event.preventDefault(); - }).call(_zoomerPanner).call(_zoomerPanner.transform, projection2.transform()).on("dblclick.zoom", null); - map2.supersurface = supersurface = selection2.append("div").attr("class", "supersurface").call(utilSetTransform, 0, 0); - wrapper = supersurface.append("div").attr("class", "layer layer-data"); - map2.surface = surface = wrapper.call(drawLayers).selectAll(".surface"); - surface.call(drawLabels.observe).call(_doubleUpHandler).on(_pointerPrefix + "down.zoom", function(d3_event) { - _lastPointerEvent = d3_event; - if (d3_event.button === 2) { - d3_event.stopPropagation(); - } - }, true).on(_pointerPrefix + "up.zoom", function(d3_event) { - _lastPointerEvent = d3_event; - if (resetTransform()) { - immediateRedraw(); + 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); } - }).on(_pointerPrefix + "move.map", function(d3_event) { - _lastPointerEvent = d3_event; - }).on(_pointerPrefix + "over.vertices", function(d3_event) { - if (map2.editableDataEnabled() && !_isTransformed) { - var hover = d3_event.target.__data__; - surface.call(drawVertices.drawHover, context.graph(), hover, map2.extent()); - dispatch14.call("drawn", this, { full: false }); + var referenceOptions = { key: d2.key }; + if (typeof d2.value === "string") { + referenceOptions.value = d2.value; } - }).on(_pointerPrefix + "out.vertices", function(d3_event) { - if (map2.editableDataEnabled() && !_isTransformed) { - var hover = d3_event.relatedTarget && d3_event.relatedTarget.__data__; - surface.call(drawVertices.drawHover, context.graph(), hover, map2.extent()); - dispatch14.call("drawn", this, { full: false }); + 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"); }); - var detected = utilDetect(); - if ("GestureEvent" in window && // Listening for gesture events on iOS 13.4+ breaks double-tapping, - // but we only need to do this on desktop Safari anyway. – #7694 - !detected.isMobileWebKit) { - surface.on("gesturestart.surface", function(d3_event) { - d3_event.preventDefault(); - _gestureTransformStart = projection2.transform(); - }).on("gesturechange.surface", gestureChange); - } - updateAreaFill(); - _doubleUpHandler.on("doubleUp.map", function(d3_event, p02) { - if (!_dblClickZoomEnabled) return; - if (typeof d3_event.target.__data__ === "object" && // or area fills - !select_default2(d3_event.target).classed("fill")) return; - var zoomOut2 = d3_event.shiftKey; - var t2 = projection2.transform(); - var p1 = t2.invert(p02); - t2 = t2.scale(zoomOut2 ? 0.5 : 2); - t2.x = p02[0] - p1[0] * t2.k; - t2.y = p02[1] - p1[1] * t2.k; - map2.transformEase(t2); + 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; }); - context.on("enter.map", function() { - if (!map2.editableDataEnabled( - true - /* skip zoom check */ - )) return; - if (_isTransformed) return; - var graph = context.graph(); - var selectedAndParents = {}; - context.selectedIDs().forEach(function(id2) { - var entity = graph.hasEntity(id2); - if (entity) { - selectedAndParents[entity.id] = entity; - if (entity.type === "node") { - graph.parentWays(entity).forEach(function(parent) { - selectedAndParents[parent.id] = parent; - }); - } - } - }); - var data = Object.values(selectedAndParents); - var filter2 = function(d2) { - return d2.id in selectedAndParents; - }; - data = context.features().filter(data, graph); - surface.call(drawVertices.drawSelected, graph, map2.extent()).call(drawLines, graph, data, filter2).call(drawAreas, graph, data, filter2).call(drawMidpoints, graph, data, filter2, map2.trimmedExtent()); - dispatch14.call("drawn", this, { full: false }); - scheduleRedraw(); + 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; }); - map2.dimensions(utilGetDimensions(selection2)); - } - function zoomEventFilter(d3_event) { - if (d3_event.type === "mousedown") { - var hasOrphan = false; - var listeners = window.__on; - for (var i3 = 0; i3 < listeners.length; i3++) { - var listener = listeners[i3]; - if (listener.name === "zoom" && listener.type === "mouseup") { - hasOrphan = true; - break; - } + 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); } - if (hasOrphan) { - var event = window.CustomEvent; - if (event) { - event = new event("mouseup"); - } else { - event = window.document.createEvent("Event"); - event.initEvent("mouseup", false, false); - } - event.view = window; - window.dispatchEvent(event); + ); + } + function isReadOnly(d2) { + for (var i3 = 0; i3 < _readOnlyTags.length; i3++) { + if (d2.key.match(_readOnlyTags[i3]) !== null) { + return true; } } - return d3_event.button !== 2; + return false; } - function pxCenter() { - return [_dimensions[0] / 2, _dimensions[1] / 2]; + 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 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 set4; - var filter2; - var applyFeatureLayerFilters = true; - if (map2.isInWideSelection()) { - data = []; - utilEntityAndDeepMemberIDs(mode.selectedIDs(), context.graph()).forEach(function(id2) { - var entity = context.hasEntity(id2); - if (entity) data.push(entity); - }); - fullRedraw = true; - filter2 = utilFunctor(true); - applyFeatureLayerFilters = false; - } else if (difference2) { - var complete = difference2.complete(map2.extent()); - data = Object.values(complete).filter(Boolean); - set4 = new Set(Object.keys(complete)); - filter2 = function(d2) { - return set4.has(d2.id); - }; - features.clear(data); + function stringify3(s2) { + const stringified = JSON.stringify(s2).slice(1, -1); + if (stringified !== s2) { + return `"${stringified}"`; } else { - if (features.gatherStats(all, graph, _dimensions)) { - extent = void 0; - } - if (extent) { - data = context.history().intersects(map2.extent().intersection(extent)); - set4 = new Set(data.map(function(entity) { - return entity.id; - })); - filter2 = function(d2) { - return set4.has(d2.id); - }; - } else { - data = all; - fullRedraw = true; - filter2 = utilFunctor(true); - } + return s2; } - if (applyFeatureLayerFilters) { - data = features.filter(data, graph); + } + function unstringify(s2) { + const isQuoted = s2.length > 1 && s2.charAt(0) === '"' && s2.charAt(s2.length - 1) === '"'; + if (isQuoted) { + try { + return JSON.parse(s2); + } catch { + return s2; + } } else { - context.features().resetStats(); - } - if (mode && mode.id === "select") { - surface.call(drawVertices.drawSelected, graph, map2.extent()); + return s2; } - surface.call(drawVertices, graph, data, filter2, map2.extent(), fullRedraw).call(drawLines, graph, data, filter2).call(drawAreas, graph, data, filter2).call(drawMidpoints, graph, data, filter2, map2.trimmedExtent()).call(drawLabels, graph, data, filter2, _dimensions, fullRedraw).call(drawPoints, graph, data, filter2); - dispatch14.call("drawn", this, { full: true }); } - map2.init = function() { - drawLayers = svgLayers(projection2, context); - drawPoints = svgPoints(projection2, context); - drawVertices = svgVertices(projection2, context); - drawLines = svgLines(projection2, context); - drawAreas = svgAreas(projection2, context); - drawMidpoints = svgMidpoints(projection2, context); - drawLabels = svgLabels(projection2, context); - }; - function editOff() { - context.features().resetStats(); - surface.selectAll(".layer-osm *").remove(); - surface.selectAll(".layer-touch:not(.markers) *").remove(); - var allowed = { - "browse": true, - "save": true, - "select-note": true, - "select-data": true, - "select-error": true - }; - var mode = context.mode(); - if (mode && !allowed[mode.id]) { - 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"; } - dispatch14.call("drawn", this, { full: true }); - } - function gestureChange(d3_event) { - var e3 = d3_event; - e3.preventDefault(); - var props = { - deltaMode: 0, - // dummy values to ignore in zoomPan - deltaY: 1, - // dummy values to ignore in zoomPan - clientX: e3.clientX, - clientY: e3.clientY, - screenX: e3.screenX, - screenY: e3.screenY, - x: e3.x, - y: e3.y - }; - var e22 = new WheelEvent("wheel", props); - e22._scale = e3.scale; - e22._rotation = e3.rotation; - _selection.node().dispatchEvent(e22); + return str; } - function zoomPan2(event, key, transform2) { - var source = event && event.sourceEvent || event; - var eventTransform = transform2 || event && event.transform; - var x2 = eventTransform.x; - var y2 = eventTransform.y; - var k2 = eventTransform.k; - if (source && source.type === "wheel") { - if (_pointerDown) return; - var detected = utilDetect(); - var dX = source.deltaX; - var dY = source.deltaY; - var x22 = x2; - var y22 = y2; - var k22 = k2; - var t0, p02, p1; - if (source.deltaMode === 1) { - var lines = Math.abs(source.deltaY); - var sign2 = source.deltaY > 0 ? 1 : -1; - dY = sign2 * clamp2( - lines * 18.001, - 4.000244140625, - // min - 350.000244140625 - // max - ); - t0 = _isTransformed ? _transformLast : _transformStart; - p02 = _getMouseCoords(source); - p1 = t0.invert(p02); - k22 = t0.k * Math.pow(2, -dY / 500); - k22 = clamp2(k22, kMin, kMax); - x22 = p02[0] - p1[0] * k22; - y22 = p02[1] - p1[1] * k22; - } else if (source._scale) { - t0 = _gestureTransformStart; - p02 = _getMouseCoords(source); - p1 = t0.invert(p02); - k22 = t0.k * source._scale; - k22 = clamp2(k22, kMin, kMax); - x22 = p02[0] - p1[0] * k22; - y22 = p02[1] - p1[1] * k22; - } else if (source.ctrlKey && !isInteger(dY)) { - dY *= 6; - t0 = _isTransformed ? _transformLast : _transformStart; - p02 = _getMouseCoords(source); - p1 = t0.invert(p02); - k22 = t0.k * Math.pow(2, -dY / 500); - 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)) { - t0 = _isTransformed ? _transformLast : _transformStart; - p02 = _getMouseCoords(source); - p1 = t0.invert(p02); - k22 = t0.k * Math.pow(2, -dY / 500); - 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)) { - p1 = projection2.translate(); - x22 = p1[0] - dX; - y22 = p1[1] - dY; - k22 = projection2.scale(); - k22 = clamp2(k22, kMin, kMax); + 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; } - if (x22 !== x2 || y22 !== y2 || k22 !== k2) { - x2 = x22; - y2 = y22; - k2 = k22; - eventTransform = identity2.translate(x22, y22).scale(k22); - if (_zoomerPanner._transform) { - _zoomerPanner._transform(eventTransform); - } else { - _selection.node().__zoom = eventTransform; - } + }); + var tagDiff = utilTagDiff(_tags, newTags); + _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 (_transformStart.x === x2 && _transformStart.y === y2 && _transformStart.k === k2) { + }); + if (Object.keys(_pendingChange).length === 0) { + _pendingChange = null; + section.reRender(); return; } - if (geoScaleToZoom(k2, TILESIZE) < _minzoom) { - surface.interrupt(); - dispatch14.call("hitMinZoom", this, map2); - setCenterZoom(map2.center(), context.minEditableZoom(), 0, true); - scheduleRedraw(); - dispatch14.call("move", this, map2); - 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(); } - projection2.transform(eventTransform); - var withinEditableZoom = map2.withinEditableZoom(); - if (_lastWithinEditableZoom !== withinEditableZoom) { - if (_lastWithinEditableZoom !== void 0) { - dispatch14.call("crossEditableZoom", this, withinEditableZoom); - } - _lastWithinEditableZoom = withinEditableZoom; + } + 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].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 scale = k2 / _transformStart.k; - var tX = (x2 / scale - _transformStart.x) * scale; - var tY = (y2 / scale - _transformStart.y) * scale; - if (context.inIntro()) { - curtainProjection.transform({ - x: x2 - tX, - y: y2 - tY, - k: k2 + 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)); + } }); - } - if (source) { - _lastPointerEvent = event; - } - _isTransformed = true; - _transformLast = eventTransform; - utilSetTransform(supersurface, tX, tY, scale); - scheduleRedraw(); - dispatch14.call("move", this, map2); - function isInteger(val) { - return typeof val === "number" && isFinite(val) && Math.floor(val) === val; + })); + 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 other2 = []; + for (var i3 = 0; i3 < data.length; i3++) { + if (data[i3].value.substring(0, value2.length) === value2) { + sameletter.push(data[i3]); + } else { + other2.push(data[i3]); + } + } + return sameletter.concat(other2); } } - function resetTransform() { - if (!_isTransformed) return false; - utilSetTransform(supersurface, 0, 0); - _isTransformed = false; - if (context.inIntro()) { - curtainProjection.transform(projection2.transform()); - } - return true; + function unbind() { + var row = select_default2(this); + row.selectAll("input.key").call(uiCombobox.off, context); + row.selectAll("input.value").call(uiCombobox.off, context); } - function redraw(difference2, extent) { - if (typeof window === "undefined") return; - if (surface.empty() || !_redrawEnabled) return; - if (resetTransform()) { - difference2 = extent = void 0; - } - var zoom = map2.zoom(); - var z2 = String(~~zoom); - if (surface.attr("data-zoom") !== z2) { - surface.attr("data-zoom", z2); - } - 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 (!difference2) { - supersurface.call(context.background()); - wrapper.call(drawLayers); - } - if (map2.editableDataEnabled() || map2.isInWideSelection()) { - context.loadTiles(projection2); - drawEditable(difference2, extent); - } else { - editOff(); + 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; } - _transformStart = projection2.transform(); - return map2; - } - var immediateRedraw = function(difference2, extent) { - if (!difference2 && !extent) cancelPendingRedraw(); - redraw(difference2, extent); - }; - map2.lastPointerEvent = function() { - return _lastPointerEvent; - }; - map2.mouse = function(d3_event) { - var event = d3_event || _lastPointerEvent; - if (event) { - var s2; - while (s2 = event.sourceEvent) { - event = s2; - } - return _getMouseCoords(event); + 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; } - return null; - }; - map2.mouseCoordinates = function() { - var coord2 = map2.mouse() || pxCenter(); - return projection2.invert(coord2); - }; - map2.dblclickZoomEnable = function(val) { - if (!arguments.length) return _dblClickZoomEnabled; - _dblClickZoomEnabled = val; - return map2; - }; - map2.redrawEnable = function(val) { - if (!arguments.length) return _redrawEnabled; - _redrawEnabled = val; - return map2; - }; - map2.isTransformed = function() { - return _isTransformed; - }; - function setTransform(t2, duration, force) { - var t3 = projection2.transform(); - if (!force && t2.k === t3.k && t2.x === t3.x && t2.y === t3.y) return false; - if (duration) { - _selection.transition().duration(duration).on("start", function() { - map2.startEase(); - }).call(_zoomerPanner.transform, identity2.translate(t2.x, t2.y).scale(t2.k)); + _pendingChange = _pendingChange || {}; + if (kOld) { + if (kOld === kNew) return; + _pendingChange[kNew] = _pendingChange[kOld] || { oldKey: kOld }; + _pendingChange[kOld] = void 0; } else { - projection2.transform(t2); - _transformStart = t2; - _selection.call(_zoomerPanner.transform, _transformStart); + 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); } - return true; + var existingKeyIndex = _orderedKeys.indexOf(kOld); + if (existingKeyIndex !== -1) _orderedKeys[existingKeyIndex] = kNew; + d2.key = kNew; + this.value = kNew; + scheduleChange(); } - function setCenterZoom(loc2, z2, duration, force) { - var c2 = map2.center(); - var z3 = map2.zoom(); - if (loc2[0] === c2[0] && loc2[1] === c2[1] && z2 === z3 && !force) return false; - var proj = geoRawMercator().transform(projection2.transform()); - var k2 = clamp2(geoZoomToScale(z2, TILESIZE), kMin, kMax); - proj.scale(k2); - var t2 = proj.translate(); - var point = proj(loc2); - var center = pxCenter(); - t2[0] += center[0] - point[0]; - t2[1] += center[1] - point[1]; - return setTransform(identity2.translate(t2[0], t2[1]).scale(k2), duration, force); + 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(); } - map2.pan = function(delta, duration) { - var t2 = projection2.translate(); - var k2 = projection2.scale(); - t2[0] += delta[0]; - t2[1] += delta[1]; - if (duration) { - _selection.transition().duration(duration).on("start", function() { - map2.startEase(); - }).call(_zoomerPanner.transform, identity2.translate(t2[0], t2[1]).scale(k2)); + function removeTag(d3_event, d2) { + if (isReadOnly(d2)) return; + if (d2.key === "") { + _showBlank = false; + section.reRender(); } else { - projection2.translate(t2); - _transformStart = projection2.transform(); - _selection.call(_zoomerPanner.transform, _transformStart); - dispatch14.call("move", this, map2); - immediateRedraw(); + _orderedKeys = _orderedKeys.filter(function(key) { + return key !== d2.key; + }); + _pendingChange = _pendingChange || {}; + _pendingChange[d2.key] = void 0; + scheduleChange(); } - return map2; - }; - map2.dimensions = function(val) { - if (!arguments.length) return _dimensions; - _dimensions = val; - drawLayers.dimensions(_dimensions); - context.background().dimensions(_dimensions); - projection2.clipExtent([[0, 0], _dimensions]); - _getMouseCoords = utilFastMouse(supersurface.node()); - scheduleRedraw(); - return map2; - }; - function zoomIn(delta) { - setCenterZoom(map2.center(), ~~map2.zoom() + delta, 250, true); } - function zoomOut(delta) { - setCenterZoom(map2.center(), ~~map2.zoom() - delta, 250, true); + function addTag() { + window.setTimeout(function() { + _showBlank = true; + section.reRender(); + section.selection().selectAll(".tag-list li:last-child input.key").node().focus(); + }, 20); } - map2.zoomIn = function() { - zoomIn(1); - }; - map2.zoomInFurther = function() { - zoomIn(4); - }; - map2.canZoomIn = function() { - return map2.zoom() < maxZoom; - }; - map2.zoomOut = function() { - zoomOut(1); - }; - map2.zoomOutFurther = function() { - zoomOut(4); - }; - map2.canZoomOut = function() { - return map2.zoom() > minZoom2; - }; - map2.center = function(loc2) { - if (!arguments.length) { - return projection2.invert(pxCenter()); - } - if (setCenterZoom(loc2, map2.zoom())) { - dispatch14.call("move", this, map2); - } - scheduleRedraw(); - return map2; - }; - map2.unobscuredCenterZoomEase = function(loc, zoom) { - var offset = map2.unobscuredOffsetPx(); - var proj = geoRawMercator().transform(projection2.transform()); - proj.scale(geoZoomToScale(zoom, TILESIZE)); - var locPx = proj(loc); - var offsetLocPx = [locPx[0] + offset[0], locPx[1] + offset[1]]; - var offsetLoc = proj.invert(offsetLocPx); - map2.centerZoomEase(offsetLoc, zoom); - }; - map2.unobscuredOffsetPx = function() { - var openPane = context.container().select(".map-panes .map-pane.shown"); - if (!openPane.empty()) { - return [openPane.node().offsetWidth / 2, 0]; + function scheduleChange() { + var entityIDs = _entityIDs; + window.setTimeout(function() { + if (!_pendingChange) return; + dispatch14.call("change", this, entityIDs, _pendingChange); + _pendingChange = null; + }, 10); + } + section.state = function(val) { + if (!arguments.length) return _state; + if (_state !== val) { + _orderedKeys = []; + _state = val; } - return [0, 0]; + return section; }; - map2.zoom = function(z2) { - if (!arguments.length) { - return Math.max(geoScaleToZoom(projection2.scale(), TILESIZE), 0); - } - if (z2 < _minzoom) { - surface.interrupt(); - dispatch14.call("hitMinZoom", this, map2); - z2 = context.minEditableZoom(); - } - if (setCenterZoom(map2.center(), z2)) { - dispatch14.call("move", this, map2); + 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); } - scheduleRedraw(); - return map2; + return section; }; - map2.centerZoom = function(loc2, z2) { - if (setCenterZoom(loc2, z2)) { - dispatch14.call("move", this, map2); - } - scheduleRedraw(); - return map2; + section.tags = function(val) { + if (!arguments.length) return _tags; + _tags = val; + return section; }; - map2.zoomTo = function(entities) { - if (!isArray_default(entities)) { - entities = [entities]; + section.entityIDs = function(val) { + if (!arguments.length) return _entityIDs; + if (!_entityIDs || !val || !utilArrayIdentical(_entityIDs, val)) { + _entityIDs = val; + _orderedKeys = []; } - if (entities.length === 0) return map2; - var extent = entities.map((entity) => entity.extent(context.graph())).reduce((a2, b2) => a2.extend(b2)); - if (!isFinite(extent.area())) return map2; - var z2 = clamp2(map2.trimmedExtentZoom(extent), 0, 20); - return map2.centerZoom(extent.center(), z2); - }; - map2.centerEase = function(loc2, duration) { - duration = duration || 250; - setCenterZoom(loc2, map2.zoom(), duration); - return map2; - }; - map2.zoomEase = function(z2, duration) { - duration = duration || 250; - setCenterZoom(map2.center(), z2, duration, false); - return map2; + return section; }; - map2.centerZoomEase = function(loc2, z2, duration) { - duration = duration || 250; - setCenterZoom(loc2, z2, duration, false); - return map2; + section.readOnlyTags = function(val) { + if (!arguments.length) return _readOnlyTags; + _readOnlyTags = val; + return section; }; - map2.transformEase = function(t2, duration) { - duration = duration || 250; - setTransform( - t2, - duration, - false - /* don't force */ - ); - return map2; + return utilRebind(section, dispatch14, "on"); + } + var init_raw_tag_editor = __esm({ + "modules/ui/sections/raw_tag_editor.js"() { + "use strict"; + init_src4(); + init_src5(); + init_services(); + init_icon(); + init_combobox(); + init_section(); + init_tag_reference(); + init_preferences(); + init_localizer(); + init_array3(); + init_util(); + init_ui(); + init_tags(); + init_core(); + } + }); + + // modules/ui/data_editor.js + var data_editor_exports = {}; + __export(data_editor_exports, { + uiDataEditor: () => uiDataEditor + }); + 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]); + 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); + } + dataEditor.datum = function(val) { + if (!arguments.length) return _datum; + _datum = val; + return this; }; - map2.zoomToEase = function(obj, duration) { - var extent; - if (Array.isArray(obj)) { - obj.forEach(function(entity) { - var entityExtent = entity.extent(context.graph()); - if (!extent) { - extent = entityExtent; - } else { - extent = extent.extend(entityExtent); - } - }); - } else { - extent = obj.extent(context.graph()); + return dataEditor; + } + var init_data_editor = __esm({ + "modules/ui/data_editor.js"() { + "use strict"; + init_localizer(); + init_browse(); + init_icon(); + init_data_header(); + init_raw_tag_editor(); + } + }); + + // 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; } - if (!isFinite(extent.area())) return map2; - var z2 = clamp2(map2.trimmedExtentZoom(extent), 0, 20); - return map2.centerZoomEase(extent.center(), z2, duration); - }; - map2.startEase = function() { - utilBindOnce(surface, _pointerPrefix + "down.ease", function() { - map2.cancelEase(); - }); - return map2; - }; - map2.cancelEase = function() { - _selection.interrupt(); - return map2; - }; - map2.extent = function(val) { - if (!arguments.length) { - return new geoExtent( - projection2.invert([0, _dimensions[1]]), - projection2.invert([_dimensions[0], 0]) - ); - } else { - var extent = geoExtent(val); - map2.centerZoom(extent.center(), map2.extentZoom(extent)); + function formatPair(input) { + return format2(input.lat, "lat") + " " + format2(input.lon, "lon"); } - }; - map2.trimmedExtent = function(val) { - if (!arguments.length) { - var headerY = 71; - var footerY = 30; - var pad2 = 10; - return new geoExtent( - projection2.invert([pad2, _dimensions[1] - footerY - pad2]), - projection2.invert([_dimensions[0] - pad2, headerY + pad2]) - ); - } else { - var extent = geoExtent(val); - map2.centerZoom(extent.center(), map2.trimmedExtentZoom(extent)); + function format2(input, dim) { + var dms = coordToDMS(input, dim); + return dms.whole + "\xB0 " + (dms.minutes ? dms.minutes + "' " : "") + (dms.seconds ? dms.seconds + '" ' : "") + dms.dir; } - }; - function calcExtentZoom(extent, dim) { - var tl = projection2([extent[0][0], extent[1][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); - return newZoom; - } - map2.extentZoom = function(val) { - return calcExtentZoom(geoExtent(val), _dimensions); - }; - map2.trimmedExtentZoom = function(val) { - var trimY = 120; - var trimX = 40; - var trimmed = [_dimensions[0] - trimX, _dimensions[1] - trimY]; - return calcExtentZoom(geoExtent(val), trimmed); - }; - map2.withinEditableZoom = function() { - return map2.zoom() >= context.minEditableZoom(); - }; - map2.isInWideSelection = function() { - return !map2.withinEditableZoom() && context.selectedIDs().length; - }; - map2.editableDataEnabled = function(skipZoomCheck) { - var layer = context.layers().layer("osm"); - if (!layer || !layer.enabled()) return false; - return skipZoomCheck || map2.withinEditableZoom(); - }; - map2.notesEditable = function() { - var layer = context.layers().layer("notes"); - if (!layer || !layer.enabled()) return false; - return map2.withinEditableZoom(); - }; - map2.minzoom = function(val) { - if (!arguments.length) return _minzoom; - _minzoom = val; - return map2; - }; - map2.toggleHighlightEdited = function() { - surface.classed("highlight-edited", !surface.classed("highlight-edited")); - map2.pan([0, 0]); - dispatch14.call("changeHighlighting", this); - }; - map2.areaFillOptions = ["wireframe", "partial", "full"]; - map2.activeAreaFill = function(val) { - if (!arguments.length) return corePreferences("area-fill") || "partial"; - corePreferences("area-fill", val); - if (val !== "wireframe") { - corePreferences("area-fill-toggle", val); + 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) + }; } - updateAreaFill(); - map2.pan([0, 0]); - dispatch14.call("changeAreaFill", this); - return map2; - }; - map2.toggleWireframe = function() { - var activeFill = map2.activeAreaFill(); - if (activeFill === "wireframe") { - activeFill = corePreferences("area-fill-toggle") || "partial"; - } else { - activeFill = "wireframe"; + 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]; + } } - map2.activeAreaFill(activeFill); - }; - function updateAreaFill() { - var activeFill = map2.activeAreaFill(); - map2.areaFillOptions.forEach(function(opt) { - surface.classed("fill-" + opt, Boolean(opt === activeFill)); - }); - } - map2.layers = () => drawLayers; - map2.doubleUpHandler = function() { - return _doubleUpHandler; - }; - return utilRebind(map2, dispatch14, "on"); - } - - // modules/renderer/photos.js - function rendererPhotos(context) { - var dispatch14 = dispatch_default("change"); - var _layerIDs = ["streetside", "mapillary", "mapillary-map-features", "mapillary-signs", "kartaview", "mapilio", "vegbilder", "panoramax"]; - var _allPhotoTypes = ["flat", "panoramic"]; - var _shownPhotoTypes = _allPhotoTypes.slice(); - var _dateFilters = ["fromDate", "toDate"]; - var _fromDate; - var _toDate; - var _usernames; - function photos() { - } - function updateStorage() { - if (window.mocha) return; - var hash2 = utilStringQs(window.location.hash); - var enabled = context.layers().all().filter(function(d2) { - return _layerIDs.indexOf(d2.id) !== -1 && d2.layer && d2.layer.supported() && d2.layer.enabled(); - }).map(function(d2) { - return d2.id; - }); - if (enabled.length) { - hash2.photo_overlay = enabled.join(","); - } else { - delete hash2.photo_overlay; + function swapdim(a2, b2, dim) { + if (dim === "N" || dim === "S") return [a2, b2]; + if (dim === "W" || dim === "E") return [b2, a2]; } - window.location.replace("#" + utilQsString(hash2, true)); } - photos.overlayLayerIDs = function() { - return _layerIDs; - }; - photos.allPhotoTypes = function() { - return _allPhotoTypes; - }; - photos.dateFilters = function() { - return _dateFilters; - }; - photos.dateFilterValue = function(val) { - return val === _dateFilters[0] ? _fromDate : _toDate; - }; - photos.setDateFilter = function(type2, val, updateUrl) { - var date = val && new Date(val); - if (date && !isNaN(date)) { - val = date.toISOString().slice(0, 10); - } else { - val = null; + }); + + // modules/ui/feature_list.js + var feature_list_exports = {}; + __export(feature_list_exports, { + uiFeatureList: () => uiFeatureList + }); + 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(); } - if (type2 === _dateFilters[0]) { - _fromDate = val; - if (_fromDate && _toDate && new Date(_toDate) < new Date(_fromDate)) { - _toDate = _fromDate; + function keydown(d3_event) { + if (d3_event.keyCode === 27) { + search.node().blur(); } } - if (type2 === _dateFilters[1]) { - _toDate = val; - if (_fromDate && _toDate && new Date(_toDate) < new Date(_fromDate)) { - _fromDate = _toDate; + 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()); } } - dispatch14.call("change", this); - if (updateUrl) { - var rangeString; - if (_fromDate || _toDate) { - rangeString = (_fromDate || "") + "_" + (_toDate || ""); - } - setUrlFilterValue("photo_dates", rangeString); + function inputevent() { + _geocodeResults = void 0; + drawList(); } - }; - photos.setUsernameFilter = function(val, updateUrl) { - if (val && typeof val === "string") val = val.replace(/;/g, ",").split(","); - if (val) { - val = val.map((d2) => d2.trim()).filter(Boolean); - if (!val.length) { - val = null; + function clearSearch() { + search.property("value", ""); + drawList(); + } + function mapDrawn(e3) { + if (e3.full) { + drawList(); } } - _usernames = val; - dispatch14.call("change", this); - if (updateUrl) { - var hashString; - if (_usernames) { - hashString = _usernames.join(","); + function features() { + var graph = context.graph(); + var visibleCenter = context.map().extent().center(); + var q2 = search.property("value").toLowerCase().trim(); + if (!q2) return []; + const locationMatch = sexagesimal.pair(q2.toUpperCase()) || dmsMatcher(q2); + const coordResult = []; + if (locationMatch) { + const latLon = [Number(locationMatch[0]), Number(locationMatch[1])]; + const lonLat = [latLon[1], latLon[0]]; + const isLatLonValid = latLon[0] >= -90 && latLon[0] <= 90 && latLon[1] >= -180 && latLon[1] <= 180; + let isLonLatValid = lonLat[0] >= -90 && lonLat[0] <= 90 && lonLat[1] >= -180 && lonLat[1] <= 180; + isLonLatValid && (isLonLatValid = !q2.match(/[NSEW]/i)); + isLonLatValid && (isLonLatValid = !locationMatch[2]); + isLonLatValid && (isLonLatValid = lonLat[0] !== lonLat[1]); + if (isLatLonValid) { + coordResult.push({ + id: latLon[0] + "/" + latLon[1], + geometry: "point", + type: _t("inspector.location"), + name: dmsCoordinatePair([latLon[1], latLon[0]]), + location: latLon, + zoom: locationMatch[2] + }); + } + if (isLonLatValid) { + coordResult.push({ + id: lonLat[0] + "/" + lonLat[1], + geometry: "point", + type: _t("inspector.location"), + name: dmsCoordinatePair([lonLat[1], lonLat[0]]), + location: lonLat + }); + } } - setUrlFilterValue("photo_username", hashString); + const idMatch = !locationMatch && q2.match(/(?:^|\W)(node|way|relation|note|[nwr])\W{0,2}0*([1-9]\d*)(?:\W|$)/i); + const idResult = []; + if (idMatch) { + var elemType = idMatch[1] === "note" ? idMatch[1] : idMatch[1].charAt(0); + var elemId = idMatch[2]; + idResult.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; + const 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.sort((a2, b2) => a2.distance - b2.distance); + const geocodeResults = []; + (_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); + geocodeResults.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])] + ) + }); + } + }); + const extraResults = []; + if (q2.match(/^[0-9]+$/)) { + extraResults.push({ + id: "n" + q2, + geometry: "point", + type: _t("inspector.node"), + name: q2 + }); + extraResults.push({ + id: "w" + q2, + geometry: "line", + type: _t("inspector.way"), + name: q2 + }); + extraResults.push({ + id: "r" + q2, + geometry: "relation", + type: _t("inspector.relation"), + name: q2 + }); + extraResults.push({ + id: "note" + q2, + geometry: "note", + type: _t("note.note"), + name: q2 + }); + } + return [...idResult, ...localResults, ...coordResult, ...geocodeResults, ...extraResults]; } - }; - function setUrlFilterValue(property, val) { - if (!window.mocha) { - var hash2 = utilStringQs(window.location.hash); - if (val) { - if (hash2[property] === val) return; - hash2[property] = val; - } else { - if (!(property in hash2)) return; - delete hash2[property]; + 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")); } - window.location.replace("#" + utilQsString(hash2, true)); + 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"); + 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("pointerenter", mouseover).on("pointerleave", mouseout).on("focus", mouseover).on("blur", 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.exit().each((d2) => mouseout(void 0, d2)).remove(); + items.merge(enter).order(); } - } - function showsLayer(id2) { - var layer = context.layers().layer(id2); - return layer && layer.supported() && layer.enabled(); - } - photos.shouldFilterByDate = function() { - return showsLayer("mapillary") || showsLayer("kartaview") || showsLayer("streetside") || showsLayer("vegbilder") || showsLayer("panoramax"); - }; - photos.shouldFilterByPhotoType = function() { - return showsLayer("mapillary") || showsLayer("streetside") && showsLayer("kartaview") || showsLayer("vegbilder") || showsLayer("panoramax"); - }; - photos.shouldFilterByUsername = function() { - return !showsLayer("mapillary") && showsLayer("kartaview") && !showsLayer("streetside") || showsLayer("panoramax"); - }; - photos.showsPhotoType = function(val) { - if (!photos.shouldFilterByPhotoType()) return true; - return _shownPhotoTypes.indexOf(val) !== -1; - }; - photos.showsFlat = function() { - return photos.showsPhotoType("flat"); - }; - photos.showsPanoramic = function() { - return photos.showsPhotoType("panoramic"); - }; - photos.fromDate = function() { - return _fromDate; - }; - photos.toDate = function() { - return _toDate; - }; - photos.togglePhotoType = function(val) { - var index = _shownPhotoTypes.indexOf(val); - if (index !== -1) { - _shownPhotoTypes.splice(index, 1); - } else { - _shownPhotoTypes.push(val); + function mouseover(d3_event, d2) { + if (d2.location !== void 0) return; + utilHighlightEntities([d2.id], true, context); } - dispatch14.call("change", this); - return photos; - }; - photos.usernames = function() { - return _usernames; - }; - photos.init = function() { - var hash2 = utilStringQs(window.location.hash); - if (hash2.photo_dates) { - var parts = /^(.*)[–_](.*)$/g.exec(hash2.photo_dates.trim()); - this.setDateFilter("fromDate", parts && parts.length >= 2 && parts[1], false); - this.setDateFilter("toDate", parts && parts.length >= 3 && parts[2], false); + function mouseout(d3_event, d2) { + if (d2.location !== void 0) return; + utilHighlightEntities([d2.id], false, context); } - if (hash2.photo_username) { - this.setUsernameFilter(hash2.photo_username, false); + function click(d3_event, d2) { + d3_event.preventDefault(); + if (d2.location) { + context.map().centerZoomEase([d2.location[1], d2.location[0]], d2.zoom || 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.moveToNote(noteId); + } else { + context.zoomToEntity(d2.id); + } } - if (hash2.photo_overlay) { - var hashOverlayIDs = hash2.photo_overlay.replace(/;/g, ",").split(","); - hashOverlayIDs.forEach(function(id2) { - if (id2 === "openstreetcam") id2 = "kartaview"; - var layer2 = _layerIDs.indexOf(id2) !== -1 && context.layers().layer(id2); - if (layer2 && !layer2.enabled()) layer2.enabled(true); + function geocoderSearch() { + services.geocoder.search(search.property("value"), function(err, resp) { + _geocodeResults = resp || []; + drawList(); }); } - if (hash2.photo) { - var photoIds = hash2.photo.replace(/;/g, ",").split(","); - var photoId = photoIds.length && photoIds[0].trim(); - var results = /(.*)\/(.*)/g.exec(photoId); - if (results && results.length >= 3) { - var serviceId = results[1]; - if (serviceId === "openstreetcam") serviceId = "kartaview"; - var photoKey = results[2]; - var service = services[serviceId]; - if (service && service.ensureViewerLoaded) { - var layer = _layerIDs.indexOf(serviceId) !== -1 && context.layers().layer(serviceId); - if (layer && !layer.enabled()) layer.enabled(true); - var baselineTime = Date.now(); - service.on("loadedImages.rendererPhotos", function() { - if (Date.now() - baselineTime > 45e3) { - service.on("loadedImages.rendererPhotos", null); - return; - } - if (!service.cachedImage(photoKey)) return; - service.on("loadedImages.rendererPhotos", null); - service.ensureViewerLoaded(context).then(function() { - service.selectImage(context, photoKey).showViewer(context); - }); - }); + } + return featureList; + } + var sexagesimal; + var init_feature_list = __esm({ + "modules/ui/feature_list.js"() { + "use strict"; + init_src5(); + sexagesimal = __toESM(require_sexagesimal()); + init_presets(); + init_localizer(); + init_units(); + init_graph(); + init_geo(); + init_geo2(); + init_select5(); + init_entity(); + init_tags(); + init_services(); + init_icon(); + init_cmd(); + init_util(); + } + }); + + // modules/ui/sections/entity_issues.js + var entity_issues_exports = {}; + __export(entity_issues_exports, { + uiSectionEntityIssues: () => uiSectionEntityIssues + }); + function uiSectionEntityIssues(context) { + var preference = corePreferences("entity-issues.reference.expanded"); + var _expanded = preference === null ? true : preference === "true"; + var _entityIDs = []; + var _issues = []; + var _activeIssueID; + var section = uiSection("entity-issues", context).shouldDisplay(function() { + return _issues.length > 0; + }).label(function() { + return _t.append("inspector.title_count", { title: _t("issues.list_title"), count: _issues.length }); + }).disclosureContent(renderDisclosureContent); + context.validator().on("validated.entity_issues", function() { + reloadIssues(); + section.reRender(); + }).on("focusedIssue.entity_issues", function(issue) { + makeActiveIssue(issue.id); + }); + function reloadIssues() { + _issues = context.validator().getSharedEntityIssues(_entityIDs, { includeDisabledRules: true }); + } + function makeActiveIssue(issueID) { + _activeIssueID = issueID; + section.selection().selectAll(".issue-container").classed("active", function(d2) { + return d2.id === _activeIssueID; + }); + } + function renderDisclosureContent(selection2) { + selection2.classed("grouped-items-area", true); + _activeIssueID = _issues.length > 0 ? _issues[0].id : null; + var containers = selection2.selectAll(".issue-container").data(_issues, function(d2) { + return d2.key; + }); + containers.exit().remove(); + var containersEnter = containers.enter().append("div").attr("class", "issue-container"); + var itemsEnter = containersEnter.append("div").attr("class", function(d2) { + return "issue severity-" + d2.severity; + }).on("mouseover.highlight", function(d3_event, d2) { + var ids = d2.entityIds.filter(function(e3) { + return _entityIDs.indexOf(e3) === -1; + }); + utilHighlightEntities(ids, true, context); + }).on("mouseout.highlight", function(d3_event, d2) { + var ids = d2.entityIds.filter(function(e3) { + return _entityIDs.indexOf(e3) === -1; + }); + utilHighlightEntities(ids, false, context); + }); + var labelsEnter = itemsEnter.append("div").attr("class", "issue-label"); + var textEnter = labelsEnter.append("button").attr("class", "issue-text").on("click", function(d3_event, d2) { + makeActiveIssue(d2.id); + var extent = d2.extent(context.graph()); + if (extent) { + var setZoom = Math.max(context.map().zoom(), 19); + context.map().unobscuredCenterZoomEase(extent.center(), setZoom); + } + }); + textEnter.each(function(d2) { + var iconName = "#iD-icon-" + (d2.severity === "warning" ? "alert" : "error"); + select_default2(this).call(svgIcon(iconName, "issue-icon")); + }); + textEnter.append("span").attr("class", "issue-message"); + var infoButton = labelsEnter.append("button").attr("class", "issue-info-button").attr("title", _t("icons.information")).call(svgIcon("#iD-icon-inspect")); + infoButton.on("click", function(d3_event) { + d3_event.stopPropagation(); + d3_event.preventDefault(); + this.blur(); + var container = select_default2(this.parentNode.parentNode.parentNode); + var info = container.selectAll(".issue-info"); + var isExpanded = info.classed("expanded"); + _expanded = !isExpanded; + corePreferences("entity-issues.reference.expanded", _expanded); + if (isExpanded) { + info.transition().duration(200).style("max-height", "0px").style("opacity", "0").on("end", function() { + info.classed("expanded", false); + }); + } else { + info.classed("expanded", true).transition().duration(200).style("max-height", "200px").style("opacity", "1").on("end", function() { + info.style("max-height", null); + }); + } + }); + itemsEnter.append("ul").attr("class", "issue-fix-list"); + containersEnter.append("div").attr("class", "issue-info" + (_expanded ? " expanded" : "")).style("max-height", _expanded ? null : "0").style("opacity", _expanded ? "1" : "0").each(function(d2) { + if (typeof d2.reference === "function") { + select_default2(this).call(d2.reference); + } else { + select_default2(this).call(_t.append("inspector.no_documentation_key")); + } + }); + containers = containers.merge(containersEnter).classed("active", function(d2) { + return d2.id === _activeIssueID; + }); + containers.selectAll(".issue-message").text("").each(function(d2) { + return d2.message(context)(select_default2(this)); + }); + var fixLists = containers.selectAll(".issue-fix-list"); + var fixes = fixLists.selectAll(".issue-fix-item").data(function(d2) { + return d2.fixes ? d2.fixes(context) : []; + }, function(fix) { + return fix.id; + }); + fixes.exit().remove(); + var fixesEnter = fixes.enter().append("li").attr("class", "issue-fix-item"); + var buttons = fixesEnter.append("button").on("click", function(d3_event, d2) { + if (select_default2(this).attr("disabled") || !d2.onClick) return; + if (d2.issue.dateLastRanFix && /* @__PURE__ */ new Date() - d2.issue.dateLastRanFix < 1e3) return; + d2.issue.dateLastRanFix = /* @__PURE__ */ new Date(); + utilHighlightEntities(d2.issue.entityIds.concat(d2.entityIds), false, context); + new Promise(function(resolve, reject) { + d2.onClick(context, resolve, reject); + if (d2.onClick.length <= 1) { + resolve(); } + }).then(function() { + context.validator().validate(); + }); + }).on("mouseover.highlight", function(d3_event, d2) { + utilHighlightEntities(d2.entityIds, true, context); + }).on("mouseout.highlight", function(d3_event, d2) { + utilHighlightEntities(d2.entityIds, false, context); + }); + buttons.each(function(d2) { + var iconName = d2.icon || "iD-icon-wrench"; + if (iconName.startsWith("maki")) { + iconName += "-15"; + } + select_default2(this).call(svgIcon("#" + iconName, "fix-icon")); + }); + buttons.append("span").attr("class", "fix-message").each(function(d2) { + return d2.title(select_default2(this)); + }); + fixesEnter.merge(fixes).selectAll("button").classed("actionable", function(d2) { + return d2.onClick; + }).attr("disabled", function(d2) { + return d2.onClick ? null : "true"; + }).attr("title", function(d2) { + if (d2.disabledReason) { + return d2.disabledReason; } + return null; + }); + } + section.entityIDs = function(val) { + if (!arguments.length) return _entityIDs; + if (!_entityIDs || !val || !utilArrayIdentical(_entityIDs, val)) { + _entityIDs = val; + _activeIssueID = null; + reloadIssues(); } - context.layers().on("change.rendererPhotos", updateStorage); + return section; }; - return utilRebind(photos, dispatch14, "on"); + return section; } + var init_entity_issues = __esm({ + "modules/ui/sections/entity_issues.js"() { + "use strict"; + init_src5(); + init_preferences(); + init_icon(); + init_array3(); + init_localizer(); + init_util(); + init_section(); + } + }); - // modules/ui/map_in_map.js - function uiMapInMap(context) { - function mapInMap(selection2) { - var backgroundLayer = rendererTileLayer(context).underzoom(2); - var overlayLayers = {}; - var projection2 = geoRawMercator(); - var dataLayer = svgData(projection2, context).showLabels(false); - var debugLayer = svgDebug(projection2, context); - var zoom = zoom_default2().scaleExtent([geoZoomToScale(0.5), geoZoomToScale(24)]).on("start", zoomStarted).on("zoom", zoomed).on("end", zoomEnded); - var wrap2 = select_default2(null); - var tiles = select_default2(null); - var viewport = select_default2(null); - var _isTransformed = false; - var _isHidden = true; - var _skipEvents = false; - var _gesture = null; - var _zDiff = 6; - var _dMini; - var _cMini; - var _tStart; - var _tCurr; - var _timeoutID; - function zoomStarted() { - if (_skipEvents) return; - _tStart = _tCurr = projection2.transform(); - _gesture = null; + // modules/ui/preset_icon.js + var preset_icon_exports = {}; + __export(preset_icon_exports, { + uiPresetIcon: () => uiPresetIcon + }); + function uiPresetIcon() { + let _preset; + let _geometry; + function presetIcon(selection2) { + selection2.each(render); + } + function getIcon(p2, geom) { + if (p2.isFallback && p2.isFallback()) return geom === "vertex" ? "" : "iD-icon-" + p2.id; + if (p2.icon) return p2.icon; + if (geom === "line") return "iD-other-line"; + if (geom === "vertex") return "temaki-vertex"; + return "maki-marker-stroked"; + } + function renderPointBorder(container, drawPoint) { + let pointBorder = container.selectAll(".preset-icon-point-border").data(drawPoint ? [0] : []); + pointBorder.exit().remove(); + let pointBorderEnter = pointBorder.enter(); + const w2 = 40; + const h2 = 40; + pointBorderEnter.append("svg").attr("class", "preset-icon-fill preset-icon-point-border").attr("width", w2).attr("height", h2).attr("viewBox", `0 0 ${w2} ${h2}`).append("path").attr("transform", "translate(11.5, 8)").attr("d", "M 17,8 C 17,13 11,21 8.5,23.5 C 6,21 0,13 0,8 C 0,4 4,-0.5 8.5,-0.5 C 13,-0.5 17,4 17,8 z"); + pointBorder = pointBorderEnter.merge(pointBorder); + } + function renderCategoryBorder(container, category) { + let categoryBorder = container.selectAll(".preset-icon-category-border").data(category ? [0] : []); + categoryBorder.exit().remove(); + let categoryBorderEnter = categoryBorder.enter(); + const d2 = 60; + let svgEnter = categoryBorderEnter.append("svg").attr("class", "preset-icon-fill preset-icon-category-border").attr("width", d2).attr("height", d2).attr("viewBox", `0 0 ${d2} ${d2}`); + svgEnter.append("path").attr("class", "area").attr("d", "M9.5,7.5 L25.5,7.5 L28.5,12.5 L49.5,12.5 C51.709139,12.5 53.5,14.290861 53.5,16.5 L53.5,43.5 C53.5,45.709139 51.709139,47.5 49.5,47.5 L10.5,47.5 C8.290861,47.5 6.5,45.709139 6.5,43.5 L6.5,12.5 L9.5,7.5 Z"); + categoryBorder = categoryBorderEnter.merge(categoryBorder); + if (category) { + categoryBorder.selectAll("path").attr("class", `area ${category.id}`); } - function zoomed(d3_event) { - if (_skipEvents) return; - var x2 = d3_event.transform.x; - var y2 = d3_event.transform.y; - var k2 = d3_event.transform.k; - var isZooming = k2 !== _tStart.k; - var isPanning = x2 !== _tStart.x || y2 !== _tStart.y; - if (!isZooming && !isPanning) { - return; - } - if (!_gesture) { - _gesture = isZooming ? "zoom" : "pan"; - } - var tMini = projection2.transform(); - var tX, tY, scale; - if (_gesture === "zoom") { - scale = k2 / tMini.k; - tX = (_cMini[0] / scale - _cMini[0]) * scale; - tY = (_cMini[1] / scale - _cMini[1]) * scale; - } else { - k2 = tMini.k; - scale = 1; - tX = x2 - tMini.x; - tY = y2 - tMini.y; + } + function renderCircleFill(container, drawVertex) { + let vertexFill = container.selectAll(".preset-icon-fill-vertex").data(drawVertex ? [0] : []); + vertexFill.exit().remove(); + let vertexFillEnter = vertexFill.enter(); + const w2 = 60; + const h2 = 60; + const d2 = 40; + vertexFillEnter.append("svg").attr("class", "preset-icon-fill preset-icon-fill-vertex").attr("width", w2).attr("height", h2).attr("viewBox", `0 0 ${w2} ${h2}`).append("circle").attr("cx", w2 / 2).attr("cy", h2 / 2).attr("r", d2 / 2); + vertexFill = vertexFillEnter.merge(vertexFill); + } + function renderSquareFill(container, drawArea, tagClasses) { + let fill = container.selectAll(".preset-icon-fill-area").data(drawArea ? [0] : []); + fill.exit().remove(); + let fillEnter = fill.enter(); + const d2 = 60; + const w2 = d2; + const h2 = d2; + const l2 = d2 * 2 / 3; + const c1 = (w2 - l2) / 2; + const c2 = c1 + l2; + fillEnter = fillEnter.append("svg").attr("class", "preset-icon-fill preset-icon-fill-area").attr("width", w2).attr("height", h2).attr("viewBox", `0 0 ${w2} ${h2}`); + ["fill", "stroke"].forEach((klass) => { + fillEnter.append("path").attr("d", `M${c1} ${c1} L${c1} ${c2} L${c2} ${c2} L${c2} ${c1} Z`).attr("class", `area ${klass}`); + }); + const rVertex = 2.5; + [[c1, c1], [c1, c2], [c2, c2], [c2, c1]].forEach((point) => { + fillEnter.append("circle").attr("class", "vertex").attr("cx", point[0]).attr("cy", point[1]).attr("r", rVertex); + }); + const rMidpoint = 1.25; + [[c1, w2 / 2], [c2, w2 / 2], [h2 / 2, c1], [h2 / 2, c2]].forEach((point) => { + fillEnter.append("circle").attr("class", "midpoint").attr("cx", point[0]).attr("cy", point[1]).attr("r", rMidpoint); + }); + fill = fillEnter.merge(fill); + fill.selectAll("path.stroke").attr("class", `area stroke ${tagClasses}`); + fill.selectAll("path.fill").attr("class", `area fill ${tagClasses}`); + } + function renderLine(container, drawLine, tagClasses) { + let line = container.selectAll(".preset-icon-line").data(drawLine ? [0] : []); + line.exit().remove(); + let lineEnter = line.enter(); + const d2 = 60; + const w2 = d2; + const h2 = d2; + const y2 = Math.round(d2 * 0.72); + const l2 = Math.round(d2 * 0.6); + const r2 = 2.5; + const x12 = (w2 - l2) / 2; + const x2 = x12 + l2; + lineEnter = lineEnter.append("svg").attr("class", "preset-icon-line").attr("width", w2).attr("height", h2).attr("viewBox", `0 0 ${w2} ${h2}`); + ["casing", "stroke"].forEach((klass) => { + lineEnter.append("path").attr("d", `M${x12} ${y2} L${x2} ${y2}`).attr("class", `line ${klass}`); + }); + [[x12 - 1, y2], [x2 + 1, y2]].forEach((point) => { + lineEnter.append("circle").attr("class", "vertex").attr("cx", point[0]).attr("cy", point[1]).attr("r", r2); + }); + line = lineEnter.merge(line); + line.selectAll("path.stroke").attr("class", `line stroke ${tagClasses}`); + line.selectAll("path.casing").attr("class", `line casing ${tagClasses}`); + } + function renderRoute(container, drawRoute, p2) { + let route = container.selectAll(".preset-icon-route").data(drawRoute ? [0] : []); + route.exit().remove(); + let routeEnter = route.enter(); + const d2 = 60; + const w2 = d2; + const h2 = d2; + const y12 = Math.round(d2 * 0.8); + const y2 = Math.round(d2 * 0.68); + const l2 = Math.round(d2 * 0.6); + const r2 = 2; + const x12 = (w2 - l2) / 2; + const x2 = x12 + l2 / 3; + const x3 = x2 + l2 / 3; + const x4 = x3 + l2 / 3; + routeEnter = routeEnter.append("svg").attr("class", "preset-icon-route").attr("width", w2).attr("height", h2).attr("viewBox", `0 0 ${w2} ${h2}`); + ["casing", "stroke"].forEach((klass) => { + routeEnter.append("path").attr("d", `M${x12} ${y12} L${x2} ${y2}`).attr("class", `segment0 line ${klass}`); + routeEnter.append("path").attr("d", `M${x2} ${y2} L${x3} ${y12}`).attr("class", `segment1 line ${klass}`); + routeEnter.append("path").attr("d", `M${x3} ${y12} L${x4} ${y2}`).attr("class", `segment2 line ${klass}`); + }); + [[x12, y12], [x2, y2], [x3, y12], [x4, y2]].forEach((point) => { + routeEnter.append("circle").attr("class", "vertex").attr("cx", point[0]).attr("cy", point[1]).attr("r", r2); + }); + route = routeEnter.merge(route); + if (drawRoute) { + let routeType = p2.tags.type === "waterway" ? "waterway" : p2.tags.route; + const segmentPresetIDs = routeSegments[routeType]; + for (let i3 in segmentPresetIDs) { + const segmentPreset = _mainPresetIndex.item(segmentPresetIDs[i3]); + const segmentTagClasses = svgTagClasses().getClassesString(segmentPreset.tags, ""); + route.selectAll(`path.stroke.segment${i3}`).attr("class", `segment${i3} line stroke ${segmentTagClasses}`); + route.selectAll(`path.casing.segment${i3}`).attr("class", `segment${i3} line casing ${segmentTagClasses}`); } - utilSetTransform(tiles, tX, tY, scale); - utilSetTransform(viewport, 0, 0, scale); - _isTransformed = true; - _tCurr = identity2.translate(x2, y2).scale(k2); - var zMain = geoScaleToZoom(context.projection.scale()); - var zMini = geoScaleToZoom(k2); - _zDiff = zMain - zMini; - queueRedraw(); - } - function zoomEnded() { - if (_skipEvents) return; - if (_gesture !== "pan") return; - updateProjection(); - _gesture = null; - context.map().center(projection2.invert(_cMini)); } - function updateProjection() { - var loc = context.map().center(); - var tMain = context.projection.transform(); - var zMain = geoScaleToZoom(tMain.k); - var zMini = Math.max(zMain - _zDiff, 0.5); - var kMini = geoZoomToScale(zMini); - projection2.translate([tMain.x, tMain.y]).scale(kMini); - var point = projection2(loc); - var mouse = _gesture === "pan" ? geoVecSubtract([_tCurr.x, _tCurr.y], [_tStart.x, _tStart.y]) : [0, 0]; - var xMini = _cMini[0] - point[0] + tMain.x + mouse[0]; - var yMini = _cMini[1] - point[1] + tMain.y + mouse[1]; - projection2.translate([xMini, yMini]).clipExtent([[0, 0], _dMini]); - _tCurr = projection2.transform(); - if (_isTransformed) { - utilSetTransform(tiles, 0, 0); - utilSetTransform(viewport, 0, 0); - _isTransformed = false; - } - zoom.scaleExtent([geoZoomToScale(0.5), geoZoomToScale(zMain - 3)]); - _skipEvents = true; - wrap2.call(zoom.transform, _tCurr); - _skipEvents = false; + } + function renderSvgIcon(container, picon, geom, isFramed, category, tagClasses) { + const isMaki = picon && /^maki-/.test(picon); + const isTemaki = picon && /^temaki-/.test(picon); + const isFa = picon && /^fa[srb]-/.test(picon); + const isR\u00F6ntgen = picon && /^roentgen-/.test(picon); + const isiDIcon = picon && !(isMaki || isTemaki || isFa || isR\u00F6ntgen); + let icon2 = container.selectAll(".preset-icon").data(picon ? [0] : []); + icon2.exit().remove(); + icon2 = icon2.enter().append("div").attr("class", "preset-icon").call(svgIcon("")).merge(icon2); + icon2.attr("class", "preset-icon " + (geom ? geom + "-geom" : "")).classed("category", category).classed("framed", isFramed).classed("preset-icon-iD", isiDIcon); + icon2.selectAll("svg").attr("class", "icon " + picon + " " + (!isiDIcon && geom !== "line" ? "" : tagClasses)); + icon2.selectAll("use").attr("href", "#" + picon); + } + function renderImageIcon(container, imageURL) { + let imageIcon = container.selectAll("img.image-icon").data(imageURL ? [0] : []); + imageIcon.exit().remove(); + imageIcon = imageIcon.enter().append("img").attr("class", "image-icon").on("load", () => container.classed("showing-img", true)).on("error", () => container.classed("showing-img", false)).merge(imageIcon); + imageIcon.attr("src", imageURL); + } + const routeSegments = { + bicycle: ["highway/cycleway", "highway/cycleway", "highway/cycleway"], + bus: ["highway/unclassified", "highway/secondary", "highway/primary"], + trolleybus: ["highway/unclassified", "highway/secondary", "highway/primary"], + detour: ["highway/tertiary", "highway/residential", "highway/unclassified"], + ferry: ["route/ferry", "route/ferry", "route/ferry"], + foot: ["highway/footway", "highway/footway", "highway/footway"], + hiking: ["highway/path", "highway/path", "highway/path"], + horse: ["highway/bridleway", "highway/bridleway", "highway/bridleway"], + light_rail: ["railway/light_rail", "railway/light_rail", "railway/light_rail"], + monorail: ["railway/monorail", "railway/monorail", "railway/monorail"], + mtb: ["highway/path", "highway/track", "highway/bridleway"], + pipeline: ["man_made/pipeline", "man_made/pipeline", "man_made/pipeline"], + piste: ["piste/downhill", "piste/hike", "piste/nordic"], + power: ["power/line", "power/line", "power/line"], + road: ["highway/secondary", "highway/primary", "highway/trunk"], + 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() { + let p2 = _preset.apply(this, arguments); + let geom = _geometry ? _geometry.apply(this, arguments) : null; + if (geom === "relation" && p2.tags && (p2.tags.type === "route" && p2.tags.route && routeSegments[p2.tags.route] || p2.tags.type === "waterway")) { + geom = "route"; } - function redraw() { - clearTimeout(_timeoutID); - if (_isHidden) return; - updateProjection(); - var zMini = geoScaleToZoom(projection2.scale()); - tiles = wrap2.selectAll(".map-in-map-tiles").data([0]); - tiles = tiles.enter().append("div").attr("class", "map-in-map-tiles").merge(tiles); - backgroundLayer.source(context.background().baseLayerSource()).projection(projection2).dimensions(_dMini); - var background = tiles.selectAll(".map-in-map-background").data([0]); - background.enter().append("div").attr("class", "map-in-map-background").merge(background).call(backgroundLayer); - var overlaySources = context.background().overlayLayerSources(); - var activeOverlayLayers = []; - for (var i3 = 0; i3 < overlaySources.length; i3++) { - if (overlaySources[i3].validZoom(zMini)) { - if (!overlayLayers[i3]) overlayLayers[i3] = rendererTileLayer(context); - activeOverlayLayers.push(overlayLayers[i3].source(overlaySources[i3]).projection(projection2).dimensions(_dMini)); - } - } - var overlay = tiles.selectAll(".map-in-map-overlay").data([0]); - overlay = overlay.enter().append("div").attr("class", "map-in-map-overlay").merge(overlay); - var overlays = overlay.selectAll("div").data(activeOverlayLayers, function(d2) { - return d2.source().name(); - }); - overlays.exit().remove(); - overlays = overlays.enter().append("div").merge(overlays).each(function(layer) { - select_default2(this).call(layer); - }); - var dataLayers = tiles.selectAll(".map-in-map-data").data([0]); - dataLayers.exit().remove(); - dataLayers = dataLayers.enter().append("svg").attr("class", "map-in-map-data").merge(dataLayers).call(dataLayer).call(debugLayer); - if (_gesture !== "pan") { - var getPath = path_default(projection2); - var bbox2 = { type: "Polygon", coordinates: [context.map().extent().polygon()] }; - viewport = wrap2.selectAll(".map-in-map-viewport").data([0]); - viewport = viewport.enter().append("svg").attr("class", "map-in-map-viewport").merge(viewport); - var path = viewport.selectAll(".map-in-map-bbox").data([bbox2]); - path.enter().append("path").attr("class", "map-in-map-bbox").merge(path).attr("d", getPath).classed("thick", function(d2) { - return getPath.area(d2) < 30; - }); + const showThirdPartyIcons = corePreferences("preferences.privacy.thirdpartyicons") || "true"; + const isFallback = p2.isFallback && p2.isFallback(); + const imageURL = showThirdPartyIcons === "true" && p2.imageURL; + const picon = getIcon(p2, geom); + const isCategory = !p2.setTags; + const drawPoint = false; + const drawVertex = picon !== null && geom === "vertex"; + const drawLine = picon && geom === "line" && !isFallback && !isCategory; + const drawArea = picon && geom === "area" && !isFallback && !isCategory; + const drawRoute = picon && geom === "route"; + const isFramed = drawVertex || drawArea || drawLine || drawRoute || isCategory; + let tags = !isCategory ? p2.setTags({}, geom) : {}; + for (let k2 in tags) { + if (tags[k2] === "*") { + tags[k2] = "yes"; } } - function queueRedraw() { - clearTimeout(_timeoutID); - _timeoutID = setTimeout(function() { - redraw(); - }, 750); + let tagClasses = svgTagClasses().getClassesString(tags, ""); + let selection2 = select_default2(this); + let container = selection2.selectAll(".preset-icon-container").data([0]); + container = container.enter().append("div").attr("class", "preset-icon-container").merge(container); + container.classed("showing-img", !!imageURL).classed("fallback", isFallback); + renderCategoryBorder(container, isCategory && p2); + renderPointBorder(container, drawPoint); + renderCircleFill(container, drawVertex); + renderSquareFill(container, drawArea, tagClasses); + renderLine(container, drawLine, tagClasses); + renderRoute(container, drawRoute, p2); + renderSvgIcon(container, picon, geom, isFramed, isCategory, tagClasses); + renderImageIcon(container, imageURL); + } + presetIcon.preset = function(val) { + if (!arguments.length) return _preset; + _preset = utilFunctor(val); + return presetIcon; + }; + presetIcon.geometry = function(val) { + if (!arguments.length) return _geometry; + _geometry = utilFunctor(val); + return presetIcon; + }; + return presetIcon; + } + var init_preset_icon = __esm({ + "modules/ui/preset_icon.js"() { + "use strict"; + init_src5(); + init_presets(); + init_preferences(); + init_svg(); + init_util(); + } + }); + + // modules/ui/sections/feature_type.js + var feature_type_exports = {}; + __export(feature_type_exports, { + uiSectionFeatureType: () => uiSectionFeatureType + }); + function uiSectionFeatureType(context) { + var dispatch14 = dispatch_default("choose"); + var _entityIDs = []; + var _presets = []; + var _tagReference; + var section = uiSection("feature-type", context).label(() => _t.append("inspector.feature_type")).disclosureContent(renderDisclosureContent); + function renderDisclosureContent(selection2) { + selection2.classed("preset-list-item", true); + selection2.classed("mixed-types", _presets.length > 1); + var presetButtonWrap = selection2.selectAll(".preset-list-button-wrap").data([0]).enter().append("div").attr("class", "preset-list-button-wrap"); + var presetButton = presetButtonWrap.append("button").attr("class", "preset-list-button preset-reset").call( + uiTooltip().title(() => _t.append("inspector.back_tooltip")).placement("bottom") + ); + presetButton.append("div").attr("class", "preset-icon-container"); + presetButton.append("div").attr("class", "label").append("div").attr("class", "label-inner"); + presetButtonWrap.append("div").attr("class", "accessory-buttons"); + var tagReferenceBodyWrap = selection2.selectAll(".tag-reference-body-wrap").data([0]); + tagReferenceBodyWrap = tagReferenceBodyWrap.enter().append("div").attr("class", "tag-reference-body-wrap").merge(tagReferenceBodyWrap); + if (_tagReference) { + selection2.selectAll(".preset-list-button-wrap .accessory-buttons").style("display", _presets.length === 1 ? null : "none").call(_tagReference.button); + tagReferenceBodyWrap.style("display", _presets.length === 1 ? null : "none").call(_tagReference.body); } - function toggle(d3_event) { - if (d3_event) d3_event.preventDefault(); - _isHidden = !_isHidden; - context.container().select(".minimap-toggle-item").classed("active", !_isHidden).select("input").property("checked", !_isHidden); - if (_isHidden) { - wrap2.style("display", "block").style("opacity", "1").transition().duration(200).style("opacity", "0").on("end", function() { - selection2.selectAll(".map-in-map").style("display", "none"); - }); - } else { - wrap2.style("display", "block").style("opacity", "0").transition().duration(200).style("opacity", "1").on("end", function() { - redraw(); - }); + selection2.selectAll(".preset-reset").on("click", function() { + dispatch14.call("choose", this, _presets); + }).on("pointerdown pointerup mousedown mouseup", function(d3_event) { + d3_event.preventDefault(); + d3_event.stopPropagation(); + }); + var geometries = entityGeometries(); + selection2.select(".preset-list-item button").call( + uiPresetIcon().geometry(_presets.length === 1 ? geometries.length === 1 && geometries[0] : null).preset(_presets.length === 1 ? _presets[0] : _mainPresetIndex.item("point")) + ); + var names = _presets.length === 1 ? [ + _presets[0].nameLabel(), + _presets[0].subtitleLabel() + ].filter(Boolean) : [_t.append("inspector.multiple_types")]; + var label = selection2.select(".label-inner"); + var nameparts = label.selectAll(".namepart").data(names, (d2) => d2.stringId); + nameparts.exit().remove(); + nameparts.enter().append("div").attr("class", "namepart").text("").each(function(d2) { + d2(select_default2(this)); + }); + } + section.entityIDs = function(val) { + if (!arguments.length) return _entityIDs; + _entityIDs = val; + return section; + }; + section.presets = function(val) { + if (!arguments.length) return _presets; + if (!utilArrayIdentical(val, _presets)) { + _presets = val; + if (_presets.length === 1) { + _tagReference = uiTagReference(_presets[0].reference(), context).showing(false); } } - uiMapInMap.toggle = toggle; - wrap2 = selection2.selectAll(".map-in-map").data([0]); - wrap2 = wrap2.enter().append("div").attr("class", "map-in-map").style("display", _isHidden ? "none" : "block").call(zoom).on("dblclick.zoom", null).merge(wrap2); - _dMini = [200, 150]; - _cMini = geoVecScale(_dMini, 0.5); - context.map().on("drawn.map-in-map", function(drawn) { - if (drawn.full === true) { - redraw(); - } + return section; + }; + function entityGeometries() { + var counts = {}; + for (var i3 in _entityIDs) { + var geometry = context.graph().geometry(_entityIDs[i3]); + if (!counts[geometry]) counts[geometry] = 0; + counts[geometry] += 1; + } + return Object.keys(counts).sort(function(geom1, geom2) { + return counts[geom2] - counts[geom1]; }); - redraw(); - context.keybinding().on(_t("background.minimap.key"), toggle); } - return mapInMap; + return utilRebind(section, dispatch14, "on"); } + var init_feature_type = __esm({ + "modules/ui/sections/feature_type.js"() { + "use strict"; + init_src4(); + init_src5(); + init_presets(); + init_array3(); + init_localizer(); + init_tooltip(); + init_util(); + init_preset_icon(); + init_section(); + init_tag_reference(); + } + }); - // modules/ui/notice.js - function uiNotice(context) { - return function(selection2) { - var div = selection2.append("div").attr("class", "notice"); - var button = div.append("button").attr("class", "zoom-to notice fillD").on("click", function() { - context.map().zoomEase(context.minEditableZoom()); - }).on("wheel", function(d3_event) { - var e22 = new WheelEvent(d3_event.type, d3_event); - context.surface().node().dispatchEvent(e22); + // modules/ui/form_fields.js + var form_fields_exports = {}; + __export(form_fields_exports, { + uiFormFields: () => uiFormFields + }); + function uiFormFields(context) { + var moreCombo = uiCombobox(context, "more-fields").minItems(1); + var _fieldsArr = []; + var _lastPlaceholder = ""; + var _state = ""; + var _klass = ""; + function formFields(selection2) { + var allowedFields = _fieldsArr.filter(function(field) { + return field.isAllowed(); + }); + var shown = allowedFields.filter(function(field) { + return field.isShown(); + }); + var notShown = allowedFields.filter(function(field) { + return !field.isShown(); + }).sort(function(a2, b2) { + return a2.universal === b2.universal ? 0 : a2.universal ? 1 : -1; + }); + var container = selection2.selectAll(".form-fields-container").data([0]); + container = container.enter().append("div").attr("class", "form-fields-container " + (_klass || "")).merge(container); + var fields = container.selectAll(".wrap-form-field").data(shown, function(d2) { + return d2.id + (d2.entityIDs ? d2.entityIDs.join() : ""); + }); + fields.exit().remove(); + var enter = fields.enter().append("div").attr("class", function(d2) { + return "wrap-form-field wrap-form-field-" + d2.safeid; + }); + fields = fields.merge(enter); + fields.order().each(function(d2) { + select_default2(this).call(d2.render); }); - button.call(svgIcon("#iD-icon-plus", "pre-text")).append("span").attr("class", "label").call(_t.append("zoom_in_edit")); - function disableTooHigh() { - var canEdit = context.map().zoom() >= context.minEditableZoom(); - div.style("display", canEdit ? "none" : "block"); + var titles = []; + var moreFields = notShown.map(function(field) { + var title = field.title(); + titles.push(title); + var terms = field.terms(); + if (field.key) terms.push(field.key); + if (field.keys) terms = terms.concat(field.keys); + return { + display: field.label(), + value: title, + title, + field, + terms + }; + }); + var placeholder = titles.slice(0, 3).join(", ") + (titles.length > 3 ? "\u2026" : ""); + var more = selection2.selectAll(".more-fields").data(_state === "hover" || moreFields.length === 0 ? [] : [0]); + more.exit().remove(); + var moreEnter = more.enter().append("div").attr("class", "more-fields").append("label"); + moreEnter.append("span").call(_t.append("inspector.add_fields")); + more = moreEnter.merge(more); + var input = more.selectAll(".value").data([0]); + input.exit().remove(); + input = input.enter().append("input").attr("class", "value").attr("type", "text").attr("placeholder", placeholder).call(utilNoAuto).merge(input); + input.call(utilGetSetValue, "").call( + moreCombo.data(moreFields).on("accept", function(d2) { + if (!d2) return; + var field = d2.field; + field.show(); + selection2.call(formFields); + field.focus(); + }) + ); + if (_lastPlaceholder !== placeholder) { + input.attr("placeholder", placeholder); + _lastPlaceholder = placeholder; } - context.map().on("move.notice", debounce_default(disableTooHigh, 500)); - disableTooHigh(); + } + formFields.fieldsArr = function(val) { + if (!arguments.length) return _fieldsArr; + _fieldsArr = val || []; + return formFields; + }; + formFields.state = function(val) { + if (!arguments.length) return _state; + _state = val; + return formFields; + }; + formFields.klass = function(val) { + if (!arguments.length) return _klass; + _klass = val; + return formFields; }; + return formFields; } + var init_form_fields = __esm({ + "modules/ui/form_fields.js"() { + "use strict"; + init_src5(); + init_localizer(); + init_combobox(); + init_util(); + } + }); - // modules/ui/photoviewer.js - function uiPhotoviewer(context) { - var dispatch14 = dispatch_default("resize"); - var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse"; - function photoviewer(selection2) { - selection2.append("button").attr("class", "thumb-hide").attr("title", _t("icons.close")).on("click", function() { - if (services.streetside) { - services.streetside.hideViewer(context); - } - if (services.mapillary) { - services.mapillary.hideViewer(context); - } - if (services.kartaview) { - services.kartaview.hideViewer(context); - } - if (services.mapilio) { - services.mapilio.hideViewer(context); - } - if (services.panoramax) { - services.panoramax.hideViewer(context); - } - if (services.vegbilder) { - services.vegbilder.hideViewer(context); - } - }).append("div").call(svgIcon("#iD-icon-close")); - function preventDefault(d3_event) { - d3_event.preventDefault(); - } - selection2.append("button").attr("class", "resize-handle-xy").on("touchstart touchdown touchend", preventDefault).on( - _pointerPrefix + "down", - buildResizeListener(selection2, "resize", dispatch14, { resizeOnX: true, resizeOnY: true }) - ); - selection2.append("button").attr("class", "resize-handle-x").on("touchstart touchdown touchend", preventDefault).on( - _pointerPrefix + "down", - buildResizeListener(selection2, "resize", dispatch14, { resizeOnX: true }) - ); - selection2.append("button").attr("class", "resize-handle-y").on("touchstart touchdown touchend", preventDefault).on( - _pointerPrefix + "down", - buildResizeListener(selection2, "resize", dispatch14, { resizeOnY: true }) - ); - context.features().on("change.setPhotoFromViewer", function() { - setPhotoFromViewerButton(); - }); - context.history().on("change.setPhotoFromViewer", function() { - setPhotoFromViewerButton(); - }); - function setPhotoFromViewerButton() { - if (services.mapillary.isViewerOpen()) { - let setMapillaryPhotoId2 = function() { - const service = services.mapillary; - const image = service.getActiveImage(); - const action = (graph) => context.selectedIDs().reduce((graph2, entityID) => { - const tags = graph2.entity(entityID).tags; - const action2 = actionChangeTags(entityID, __spreadProps(__spreadValues({}, tags), { mapillary: image.id })); - return action2(graph2); - }, graph); - const annotation = _t("operations.change_tags.annotation"); - context.perform(action, annotation); - }; - var setMapillaryPhotoId = setMapillaryPhotoId2; - if (context.mode().id !== "select" || !(layerStatus("mapillary") && getServiceId() === "mapillary")) { - buttonRemove(); + // modules/ui/sections/preset_fields.js + var preset_fields_exports = {}; + __export(preset_fields_exports, { + uiSectionPresetFields: () => uiSectionPresetFields + }); + function uiSectionPresetFields(context) { + var section = uiSection("preset-fields", context).label(() => _t.append("inspector.fields")).disclosureContent(renderDisclosureContent); + var dispatch14 = dispatch_default("change", "revert"); + var formFields = uiFormFields(context); + var _state; + var _fieldsArr; + var _presets = []; + var _tags; + var _entityIDs; + function renderDisclosureContent(selection2) { + if (!_fieldsArr) { + var graph = context.graph(); + var geometries = Object.keys(_entityIDs.reduce(function(geoms, entityID) { + geoms[graph.entity(entityID).geometry(graph)] = true; + return geoms; + }, {})); + const loc = _entityIDs.reduce(function(extent, entityID) { + var entity = context.graph().entity(entityID); + return extent.extend(entity.extent(context.graph())); + }, geoExtent()).center(); + var presetsManager = _mainPresetIndex; + var allFields = []; + var allMoreFields = []; + var sharedTotalFields; + _presets.forEach(function(preset) { + var fields = preset.fields(loc); + var moreFields = preset.moreFields(loc); + allFields = utilArrayUnion(allFields, fields); + allMoreFields = utilArrayUnion(allMoreFields, moreFields); + if (!sharedTotalFields) { + sharedTotalFields = utilArrayUnion(fields, moreFields); } else { - if (selection2.select(".set-photo-from-viewer").empty()) { - const button = buttonCreate(); - button.on("click", function(e3) { - e3.preventDefault(); - e3.stopPropagation(); - setMapillaryPhotoId2(); - buttonDisable("already_set"); - }); - } - buttonShowHide(); + sharedTotalFields = sharedTotalFields.filter(function(field) { + return fields.indexOf(field) !== -1 || moreFields.indexOf(field) !== -1; + }); } - } - function layerStatus(which) { - const layers = context.layers(); - const layer = layers.layer(which); - return layer.enabled(); - } - function getServiceId() { - const hash2 = utilStringQs(window.location.hash); - let serviceId; - if (hash2.photo) { - let result = hash2.photo.split("/"); - serviceId = result[0]; + }); + var sharedFields = allFields.filter(function(field) { + return sharedTotalFields.indexOf(field) !== -1; + }); + var sharedMoreFields = allMoreFields.filter(function(field) { + return sharedTotalFields.indexOf(field) !== -1; + }); + _fieldsArr = []; + sharedFields.forEach(function(field) { + if (field.matchAllGeometry(geometries)) { + _fieldsArr.push( + uiField(context, field, _entityIDs) + ); } - return serviceId; - } - function buttonCreate() { - const button = selection2.selectAll(".set-photo-from-viewer").data([0]); - const buttonEnter = button.enter().append("button").attr("class", "set-photo-from-viewer").call(svgIcon("#iD-icon-plus")).call( - uiTooltip().title(() => _t.append("inspector.set_photo_from_viewer.enable")).placement("right") + }); + var singularEntity = _entityIDs.length === 1 && graph.hasEntity(_entityIDs[0]); + if (singularEntity && singularEntity.type === "node" && singularEntity.isHighwayIntersection(graph) && presetsManager.field("restrictions")) { + _fieldsArr.push( + uiField(context, presetsManager.field("restrictions"), _entityIDs) ); - buttonEnter.select(".tooltip").classed("dark", true).style("width", "300px"); - return buttonEnter; - } - function buttonRemove() { - const button = selection2.selectAll(".set-photo-from-viewer").data([0]); - button.remove(); - } - function buttonShowHide() { - const activeImage = services.mapillary.getActiveImage(); - const graph = context.graph(); - const entities = context.selectedIDs().map((id2) => graph.entity(id2)); - if (entities.map((entity) => entity.tags.mapillary).every((value) => value === (activeImage == null ? void 0 : activeImage.id))) { - buttonDisable("already_set"); - } else if (activeImage && entities.map((entity) => entity.extent(context.graph()).center()).every((loc) => geoSphericalDistance(loc, activeImage.loc) > 100)) { - buttonDisable("too_far"); - } else { - buttonDisable(false); - } } - function buttonDisable(reason) { - const disabled = reason !== false; - const button = selection2.selectAll(".set-photo-from-viewer").data([0]); - button.attr("disabled", disabled ? "true" : null); - button.classed("disabled", disabled); - button.call(uiTooltip().destroyAny); - if (disabled) { - button.call( - uiTooltip().title(() => _t.append("inspector.set_photo_from_viewer.disable.".concat(reason))).placement("right") - ); - } else { - button.call( - uiTooltip().title(() => _t.append("inspector.set_photo_from_viewer.enable")).placement("right") + var additionalFields = utilArrayUnion(sharedMoreFields, presetsManager.universal()); + additionalFields.sort(function(field1, field2) { + return field1.title().localeCompare(field2.title(), _mainLocalizer.localeCode()); + }); + additionalFields.forEach(function(field) { + if (sharedFields.indexOf(field) === -1 && field.matchAllGeometry(geometries)) { + _fieldsArr.push( + uiField(context, field, _entityIDs, { show: false }) ); } - button.select(".tooltip").classed("dark", true).style("width", "300px"); - } - } - function buildResizeListener(target, eventName, dispatch15, options2) { - var resizeOnX = !!options2.resizeOnX; - var resizeOnY = !!options2.resizeOnY; - var minHeight = options2.minHeight || 240; - var minWidth = options2.minWidth || 320; - var pointerId; - var startX; - var startY; - var startWidth; - var startHeight; - function startResize(d3_event) { - if (pointerId !== (d3_event.pointerId || "mouse")) return; - d3_event.preventDefault(); - d3_event.stopPropagation(); - var mapSize = context.map().dimensions(); - if (resizeOnX) { - var mapWidth = mapSize[0]; - const viewerMargin = parseInt(select_default2(".photoviewer").style("margin-left"), 10); - var newWidth = clamp3(startWidth + d3_event.clientX - startX, minWidth, mapWidth - viewerMargin * 2); - target.style("width", newWidth + "px"); - } - if (resizeOnY) { - const menuHeight = utilGetDimensions(select_default2(".top-toolbar"))[1] + utilGetDimensions(select_default2(".map-footer"))[1]; - const viewerMargin = parseInt(select_default2(".photoviewer").style("margin-bottom"), 10); - var maxHeight = mapSize[1] - menuHeight - viewerMargin * 2; - var newHeight = clamp3(startHeight + startY - d3_event.clientY, minHeight, maxHeight); - target.style("height", newHeight + "px"); - } - dispatch15.call(eventName, target, subtractPadding(utilGetDimensions(target, true), target)); - } - function clamp3(num, min3, max3) { - return Math.max(min3, Math.min(num, max3)); - } - function stopResize(d3_event) { - if (pointerId !== (d3_event.pointerId || "mouse")) return; - d3_event.preventDefault(); - d3_event.stopPropagation(); - select_default2(window).on("." + eventName, null); - } - return function initResize(d3_event) { - d3_event.preventDefault(); - d3_event.stopPropagation(); - pointerId = d3_event.pointerId || "mouse"; - startX = d3_event.clientX; - startY = d3_event.clientY; - var targetRect = target.node().getBoundingClientRect(); - startWidth = targetRect.width; - startHeight = targetRect.height; - select_default2(window).on(_pointerPrefix + "move." + eventName, startResize, false).on(_pointerPrefix + "up." + eventName, stopResize, false); - if (_pointerPrefix === "pointer") { - select_default2(window).on("pointercancel." + eventName, stopResize, false); - } - }; + }); + _fieldsArr.forEach(function(field) { + field.on("change", function(t2, onInput) { + dispatch14.call("change", field, _entityIDs, t2, onInput); + }).on("revert", function(keys2) { + dispatch14.call("revert", field, keys2); + }); + }); } + _fieldsArr.forEach(function(field) { + field.state(_state).tags(_tags); + }); + selection2.call( + formFields.fieldsArr(_fieldsArr).state(_state).klass("grouped-items-area") + ); } - photoviewer.onMapResize = function() { - var photoviewer2 = context.container().select(".photoviewer"); - var content = context.container().select(".main-content"); - var mapDimensions = utilGetDimensions(content, true); - const menuHeight = utilGetDimensions(select_default2(".top-toolbar"))[1] + utilGetDimensions(select_default2(".map-footer"))[1]; - const viewerMargin = parseInt(select_default2(".photoviewer").style("margin-bottom"), 10); - var photoDimensions = utilGetDimensions(photoviewer2, true); - if (photoDimensions[0] > mapDimensions[0] || photoDimensions[1] > mapDimensions[1] - menuHeight - viewerMargin * 2) { - var setPhotoDimensions = [ - Math.min(photoDimensions[0], mapDimensions[0]), - Math.min(photoDimensions[1], mapDimensions[1] - menuHeight - viewerMargin * 2) - ]; - photoviewer2.style("width", setPhotoDimensions[0] + "px").style("height", setPhotoDimensions[1] + "px"); - dispatch14.call("resize", photoviewer2, subtractPadding(setPhotoDimensions, photoviewer2)); + section.presets = function(val) { + if (!arguments.length) return _presets; + if (!_presets || !val || !utilArrayIdentical(_presets, val)) { + _presets = val; + _fieldsArr = null; } + return section; }; - function subtractPadding(dimensions, selection2) { - return [ - dimensions[0] - parseFloat(selection2.style("padding-left")) - parseFloat(selection2.style("padding-right")), - dimensions[1] - parseFloat(selection2.style("padding-top")) - parseFloat(selection2.style("padding-bottom")) - ]; - } - return utilRebind(photoviewer, dispatch14, "on"); - } - - // modules/ui/restore.js - function uiRestore(context) { - return function(selection2) { - if (!context.history().hasRestorableChanges()) return; - let modalSelection = uiModal(selection2, true); - modalSelection.select(".modal").attr("class", "modal fillL"); - let introModal = modalSelection.select(".content"); - introModal.append("div").attr("class", "modal-section").append("h3").call(_t.append("restore.heading")); - introModal.append("div").attr("class", "modal-section").append("p").call(_t.append("restore.description")); - let buttonWrap = introModal.append("div").attr("class", "modal-actions"); - let restore = buttonWrap.append("button").attr("class", "restore").on("click", () => { - context.history().restore(); - modalSelection.remove(); - }); - restore.append("svg").attr("class", "logo logo-restore").append("use").attr("xlink:href", "#iD-logo-restore"); - restore.append("div").call(_t.append("restore.restore")); - let reset = buttonWrap.append("button").attr("class", "reset").on("click", () => { - context.history().clearSaved(); - modalSelection.remove(); - }); - reset.append("svg").attr("class", "logo logo-reset").append("use").attr("xlink:href", "#iD-logo-reset"); - reset.append("div").call(_t.append("restore.reset")); - restore.node().focus(); + section.state = function(val) { + if (!arguments.length) return _state; + _state = val; + return section; }; - } - - // modules/ui/scale.js - function uiScale(context) { - var projection2 = context.projection, isImperial = !_mainLocalizer.usesMetric(), maxLength = 180, tickHeight = 8; - function scaleDefs(loc1, loc2) { - var lat = (loc2[1] + loc1[1]) / 2, conversion = isImperial ? 3.28084 : 1, dist = geoLonToMeters(loc2[0] - loc1[0], lat) * conversion, scale = { dist: 0, px: 0, text: "" }, buckets, i3, val, dLon; - if (isImperial) { - buckets = [528e4, 528e3, 52800, 5280, 500, 50, 5, 1]; - } else { - buckets = [5e6, 5e5, 5e4, 5e3, 500, 50, 5, 1]; - } - for (i3 = 0; i3 < buckets.length; i3++) { - val = buckets[i3]; - if (dist >= val) { - scale.dist = Math.floor(dist / val) * val; - break; - } else { - scale.dist = +dist.toFixed(2); - } - } - dLon = geoMetersToLon(scale.dist / conversion, lat); - scale.px = Math.round(projection2([loc1[0] + dLon, loc1[1]])[0]); - scale.text = displayLength(scale.dist / conversion, isImperial); - return scale; - } - function update(selection2) { - var dims = context.map().dimensions(), loc1 = projection2.invert([0, dims[1]]), loc2 = projection2.invert([maxLength, dims[1]]), scale = scaleDefs(loc1, loc2); - selection2.select(".scale-path").attr("d", "M0.5,0.5v" + tickHeight + "h" + scale.px + "v-" + tickHeight); - selection2.select(".scale-text").style(_mainLocalizer.textDirection() === "ltr" ? "left" : "right", scale.px + 16 + "px").text(scale.text); - } - return function(selection2) { - function switchUnits() { - isImperial = !isImperial; - selection2.call(update); + section.tags = function(val) { + if (!arguments.length) return _tags; + _tags = val; + return section; + }; + section.entityIDs = function(val) { + if (!arguments.length) return _entityIDs; + if (!val || !_entityIDs || !utilArrayIdentical(_entityIDs, val)) { + _entityIDs = val; + _fieldsArr = null; } - var scalegroup = selection2.append("svg").attr("class", "scale").on("click", switchUnits).append("g").attr("transform", "translate(10,11)"); - scalegroup.append("path").attr("class", "scale-path"); - selection2.append("div").attr("class", "scale-text"); - selection2.call(update); - context.map().on("move.scale", function() { - update(selection2); - }); + return section; }; + return utilRebind(section, dispatch14, "on"); } + var init_preset_fields = __esm({ + "modules/ui/sections/preset_fields.js"() { + "use strict"; + init_src4(); + init_presets(); + init_localizer(); + init_array3(); + init_util(); + init_extent(); + init_field2(); + init_form_fields(); + init_section(); + } + }); - // modules/ui/shortcuts.js - function uiShortcuts(context) { - var detected = utilDetect(); - var _activeTab = 0; - var _modalSelection; - var _selection = select_default2(null); - var _dataShortcuts; - function shortcutsModal(_modalSelection2) { - _modalSelection2.select(".modal").classed("modal-shortcuts", true); - var content = _modalSelection2.select(".content"); - content.append("div").attr("class", "modal-section header").append("h2").call(_t.append("shortcuts.title")); - _mainFileFetcher.get("shortcuts").then(function(data) { - _dataShortcuts = data; - content.call(render); - }).catch(function() { + // modules/ui/sections/raw_member_editor.js + var raw_member_editor_exports = {}; + __export(raw_member_editor_exports, { + uiSectionRawMemberEditor: () => uiSectionRawMemberEditor + }); + function uiSectionRawMemberEditor(context) { + var section = uiSection("raw-member-editor", context).shouldDisplay(function() { + if (!_entityIDs || _entityIDs.length !== 1) return false; + var entity = context.hasEntity(_entityIDs[0]); + return entity && entity.type === "relation"; + }).label(function() { + var entity = context.hasEntity(_entityIDs[0]); + if (!entity) return ""; + var gt2 = entity.members.length > _maxMembers ? ">" : ""; + var count = gt2 + entity.members.slice(0, _maxMembers).length; + return _t.append("inspector.title_count", { title: _t("inspector.members"), count }); + }).disclosureContent(renderDisclosureContent); + var taginfo = services.taginfo; + var _entityIDs; + var _maxMembers = 1e3; + function downloadMember(d3_event, d2) { + d3_event.preventDefault(); + select_default2(this).classed("loading", true); + context.loadEntity(d2.id, function() { + section.reRender(); }); } - function render(selection2) { - if (!_dataShortcuts) return; - var wrapper = selection2.selectAll(".wrapper").data([0]); - var wrapperEnter = wrapper.enter().append("div").attr("class", "wrapper modal-section"); - var tabsBar = wrapperEnter.append("div").attr("class", "tabs-bar"); - var shortcutsList = wrapperEnter.append("div").attr("class", "shortcuts-list"); - wrapper = wrapper.merge(wrapperEnter); - var tabs = tabsBar.selectAll(".tab").data(_dataShortcuts); - var tabsEnter = tabs.enter().append("a").attr("class", "tab").attr("href", "#").on("click", function(d3_event, d2) { - d3_event.preventDefault(); - var i3 = _dataShortcuts.indexOf(d2); - _activeTab = i3; - render(selection2); - }); - tabsEnter.append("span").html(function(d2) { - return _t.html(d2.text); - }); - wrapper.selectAll(".tab").classed("active", function(d2, i3) { - return i3 === _activeTab; - }); - var shortcuts = shortcutsList.selectAll(".shortcut-tab").data(_dataShortcuts); - var shortcutsEnter = shortcuts.enter().append("div").attr("class", function(d2) { - return "shortcut-tab shortcut-tab-" + d2.tab; - }); - var columnsEnter = shortcutsEnter.selectAll(".shortcut-column").data(function(d2) { - return d2.columns; - }).enter().append("table").attr("class", "shortcut-column"); - var rowsEnter = columnsEnter.selectAll(".shortcut-row").data(function(d2) { - return d2.rows; - }).enter().append("tr").attr("class", "shortcut-row"); - var sectionRows = rowsEnter.filter(function(d2) { - return !d2.shortcuts; - }); - sectionRows.append("td"); - sectionRows.append("td").attr("class", "shortcut-section").append("h3").html(function(d2) { - return _t.html(d2.text); + function zoomToMember(d3_event, d2) { + d3_event.preventDefault(); + var entity = context.entity(d2.id); + context.map().zoomToEase(entity); + utilHighlightEntities([d2.id], true, context); + } + function selectMember(d3_event, d2) { + d3_event.preventDefault(); + utilHighlightEntities([d2.id], false, context); + var entity = context.entity(d2.id); + var mapExtent = context.map().extent(); + if (!entity.intersects(mapExtent, context.graph())) { + context.map().zoomToEase(entity); + } + context.enter(modeSelect(context, [d2.id])); + } + function changeRole(d3_event, d2) { + var oldRole = d2.role; + var newRole = context.cleanRelationRole(select_default2(this).property("value")); + if (oldRole !== newRole) { + 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 shortcutRows = rowsEnter.filter(function(d2) { - return d2.shortcuts; + 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 shortcutKeys = shortcutRows.append("td").attr("class", "shortcut-keys"); - var modifierKeys = shortcutKeys.filter(function(d2) { - return d2.modifiers; + 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; }); - modifierKeys.selectAll("kbd.modifier").data(function(d2) { - if (detected.os === "win" && d2.text === "shortcuts.editing.commands.redo") { - return ["\u2318"]; - } else if (detected.os !== "mac" && d2.text === "shortcuts.browsing.display_options.fullscreen") { - return []; + 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 { - return d2.modifiers; + 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); } - }).enter().each(function() { - var selection3 = select_default2(this); - selection3.append("kbd").attr("class", "modifier").text(function(d2) { - return uiCmd.display(d2); - }); - selection3.append("span").text("+"); }); - shortcutKeys.selectAll("kbd.shortcut").data(function(d2) { - var arr = d2.shortcuts; - if (detected.os === "win" && d2.text === "shortcuts.editing.commands.redo") { - arr = ["Y"]; - } else if (detected.os !== "mac" && d2.text === "shortcuts.browsing.display_options.fullscreen") { - arr = ["F11"]; - } - arr = arr.map(function(s2) { - return uiCmd.display(s2.indexOf(".") !== -1 ? _t(s2) : s2); - }); - return utilArrayUniq(arr).map(function(s2) { - return { - shortcut: s2, - separator: d2.separator, - suffix: d2.suffix + 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 }; - }); - }).enter().each(function(d2, i3, nodes) { - var selection3 = select_default2(this); - var click = d2.shortcut.toLowerCase().match(/(.*).click/); - if (click && click[1]) { - selection3.call(svgIcon("#iD-walkthrough-mouse-" + click[1], "operation")); - } else if (d2.shortcut.toLowerCase() === "long-press") { - selection3.call(svgIcon("#iD-walkthrough-longpress", "longpress operation")); - } else if (d2.shortcut.toLowerCase() === "tap") { - selection3.call(svgIcon("#iD-walkthrough-tap", "tap operation")); - } else { - selection3.append("kbd").attr("class", "shortcut").text(function(d4) { - return d4.shortcut; + 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; }); - } - if (i3 < nodes.length - 1) { - selection3.append("span").html(d2.separator || "\xA0" + _t.html("shortcuts.or") + "\xA0"); - } else if (i3 === nodes.length - 1 && d2.suffix) { - selection3.append("span").text(d2.suffix); - } - }); - shortcutKeys.filter(function(d2) { - return d2.gesture; - }).each(function() { - var selection3 = select_default2(this); - selection3.append("span").text("+"); - selection3.append("span").attr("class", "gesture").html(function(d2) { - return _t.html(d2.gesture); - }); - }); - shortcutRows.append("td").attr("class", "shortcut-desc").html(function(d2) { - return d2.text ? _t.html(d2.text) : "\xA0"; - }); - wrapper.selectAll(".shortcut-tab").style("display", function(d2, i3) { - return i3 === _activeTab ? "flex" : "none"; - }); - } - return function(selection2, show) { - _selection = selection2; - if (show) { - _modalSelection = uiModal(selection2); - _modalSelection.call(shortcutsModal); - } else { - context.keybinding().on([_t("shortcuts.toggle.key"), "?"], function() { - if (context.container().selectAll(".modal-shortcuts").size()) { - if (_modalSelection) { - _modalSelection.close(); - _modalSelection = 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 other2 = []; + for (var i3 = 0; i3 < data.length; i3++) { + if (data[i3].value.substring(0, value.length) === value) { + sameletter.push(data[i3]); + } else { + other2.push(data[i3]); } - } else { - _modalSelection = uiModal(_selection); - _modalSelection.call(shortcutsModal); } - }); - } - }; - } - - // modules/ui/data_header.js - function uiDataHeader() { - var _datum; - function dataHeader(selection2) { - var header = selection2.selectAll(".data-header").data( - _datum ? [_datum] : [], - function(d2) { - return d2.__featurehash__; + return sameletter.concat(other2); } - ); - header.exit().remove(); - var headerEnter = header.enter().append("div").attr("class", "data-header"); - var iconEnter = headerEnter.append("div").attr("class", "data-header-icon"); - iconEnter.append("div").attr("class", "preset-icon-28").call(svgIcon("#iD-icon-data", "note-fill")); - headerEnter.append("div").attr("class", "data-header-label").call(_t.append("map_data.layers.custom.title")); + 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); + } } - dataHeader.datum = function(val) { - if (!arguments.length) return _datum; - _datum = val; - return this; + section.entityIDs = function(val) { + if (!arguments.length) return _entityIDs; + _entityIDs = val; + return section; }; - return dataHeader; + return section; } + var init_raw_member_editor = __esm({ + "modules/ui/sections/raw_member_editor.js"() { + "use strict"; + init_src6(); + init_src5(); + init_presets(); + init_localizer(); + init_change_member(); + init_delete_member(); + init_move_member(); + init_browse(); + init_select5(); + init_osm(); + init_tags(); + init_icon(); + init_services(); + init_combobox(); + init_section(); + init_util(); + } + }); - // modules/ui/disclosure.js - function uiDisclosure(context, key, expandedDefault) { - var dispatch14 = dispatch_default("toggled"); - var _expanded; - var _label = utilFunctor(""); - var _updatePreference = true; - var _content = function() { - }; - var disclosure = function(selection2) { - if (_expanded === void 0 || _expanded === null) { - var preference = corePreferences("disclosure." + key + ".expanded"); - _expanded = preference === null ? !!expandedDefault : preference === "true"; - } - var hideToggle = selection2.selectAll(".hide-toggle-" + key).data([0]); - var hideToggleEnter = hideToggle.enter().append("h3").append("a").attr("role", "button").attr("href", "#").attr("class", "hide-toggle hide-toggle-" + key).call(svgIcon("", "pre-text", "hide-toggle-icon")); - hideToggleEnter.append("span").attr("class", "hide-toggle-text"); - hideToggle = hideToggleEnter.merge(hideToggle); - hideToggle.on("click", toggle).attr("title", _t("icons.".concat(_expanded ? "collapse" : "expand"))).attr("aria-expanded", _expanded).classed("expanded", _expanded); - const label = _label(); - const labelSelection = hideToggle.selectAll(".hide-toggle-text"); - if (typeof label !== "function") { - labelSelection.text(_label()); - } else { - labelSelection.text("").call(label); - } - hideToggle.selectAll(".hide-toggle-icon").attr( - "xlink:href", - _expanded ? "#iD-icon-down" : _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward" - ); - var wrap2 = selection2.selectAll(".disclosure-wrap").data([0]); - wrap2 = wrap2.enter().append("div").attr("class", "disclosure-wrap disclosure-wrap-" + key).merge(wrap2).classed("hide", !_expanded); - if (_expanded) { - wrap2.call(_content); - } - function toggle(d3_event) { - d3_event.preventDefault(); - _expanded = !_expanded; - if (_updatePreference) { - corePreferences("disclosure." + key + ".expanded", _expanded); - } - hideToggle.classed("expanded", _expanded).attr("aria-expanded", _expanded).attr("title", _t("icons.".concat(_expanded ? "collapse" : "expand"))); - hideToggle.selectAll(".hide-toggle-icon").attr( - "xlink:href", - _expanded ? "#iD-icon-down" : _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward" - ); - wrap2.call(uiToggle(_expanded)); - if (_expanded) { - wrap2.call(_content); + // modules/ui/sections/raw_membership_editor.js + var raw_membership_editor_exports = {}; + __export(raw_membership_editor_exports, { + uiSectionRawMembershipEditor: () => uiSectionRawMembershipEditor + }); + 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; + const recentlyAdded = /* @__PURE__ */ new Set(); + 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)); } - dispatch14.call("toggled", this, _expanded); + if (!parents.length) break; } - }; - disclosure.label = function(val) { - if (!arguments.length) return _label; - _label = utilFunctor(val); - return disclosure; - }; - disclosure.expanded = function(val) { - if (!arguments.length) return _expanded; - _expanded = val; - return disclosure; - }; - disclosure.updatePreference = function(val) { - if (!arguments.length) return _updatePreference; - _updatePreference = val; - return disclosure; - }; - disclosure.content = function(val) { - if (!arguments.length) return _content; - _content = val; - return disclosure; - }; - return utilRebind(disclosure, dispatch14, "on"); - } - - // modules/ui/section.js - function uiSection(id2, context) { - var _classes = utilFunctor(""); - var _shouldDisplay; - var _content; - var _disclosure; - var _label; - var _expandedByDefault = utilFunctor(true); - var _disclosureContent; - var _disclosureExpanded; - var _containerSelection = select_default2(null); - var section = { - id: id2 - }; - section.classes = function(val) { - if (!arguments.length) return _classes; - _classes = utilFunctor(val); - return section; - }; - section.label = function(val) { - if (!arguments.length) return _label; - _label = utilFunctor(val); - return section; - }; - section.expandedByDefault = function(val) { - if (!arguments.length) return _expandedByDefault; - _expandedByDefault = utilFunctor(val); - return section; - }; - section.shouldDisplay = function(val) { - if (!arguments.length) return _shouldDisplay; - _shouldDisplay = utilFunctor(val); - return section; - }; - section.content = function(val) { - if (!arguments.length) return _content; - _content = val; - return section; - }; - section.disclosureContent = function(val) { - if (!arguments.length) return _disclosureContent; - _disclosureContent = val; - return section; - }; - section.disclosureExpanded = function(val) { - if (!arguments.length) return _disclosureExpanded; - _disclosureExpanded = val; - return section; - }; - section.render = function(selection2) { - _containerSelection = selection2.selectAll(".section-" + id2).data([0]); - var sectionEnter = _containerSelection.enter().append("div").attr("class", "section section-" + id2 + " " + (_classes && _classes() || "")); - _containerSelection = sectionEnter.merge(_containerSelection); - _containerSelection.call(renderContent); - }; - section.reRender = function() { - _containerSelection.call(renderContent); - }; - section.selection = function() { - return _containerSelection; - }; - section.disclosure = function() { - return _disclosure; - }; - function renderContent(selection2) { - if (_shouldDisplay) { - var shouldDisplay = _shouldDisplay(); - selection2.classed("hide", !shouldDisplay); - if (!shouldDisplay) { - selection2.html(""); - return; + 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; + }); + const existingRelations = memberships.filter((membership2) => !recentlyAdded.has(membership2.relation.id)).map((membership2) => ({ + ...membership2, + // We only sort relations that were not added just now. + // Sorting uses the same label as shown in the UI. + // If the label is not unique, the relation ID ensures + // that the sort order is still stable. + _sortKey: [ + baseDisplayValue(membership2.relation), + membership2.relation.id + ].join("-") + })).sort((a2, b2) => { + return a2._sortKey.localeCompare( + b2._sortKey, + _mainLocalizer.localeCodes(), + { numeric: true } + ); + }); + const newlyAddedRelations = memberships.filter((membership2) => recentlyAdded.has(membership2.relation.id)); + return [ + // the sorted relations come first + ...existingRelations, + // then the ones that were just added from this panel + ...newlyAddedRelations + ]; + } + 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(); } - if (_disclosureContent) { - if (!_disclosure) { - _disclosure = uiDisclosure(context, id2.replace(/-/g, "_"), _expandedByDefault()).label(_label || "").content(_disclosureContent); - } - if (_disclosureExpanded !== void 0) { - _disclosure.expanded(_disclosureExpanded); - _disclosureExpanded = void 0; - } - selection2.call(_disclosure); - return; + _inChange = false; + } + function addMembership(d2, role) { + _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 (_content) { - selection2.call(_content); + if (d2.relation) { + recentlyAdded.add(d2.relation.id); + 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)); } } - return section; - } - - // modules/ui/tag_reference.js - function uiTagReference(what) { - var wikibase = what.qid ? services.wikidata : services.osmWikibase; - var tagReference = {}; - var _button = select_default2(null); - var _body = select_default2(null); - var _loaded; - var _showing; - function load() { - if (!wikibase) return; - _button.classed("tag-reference-loading", true); - wikibase.getDocs(what, gotDocs); + 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 gotDocs(err, docs) { - _body.html(""); - if (!docs || !docs.title) { - _body.append("p").attr("class", "tag-reference-description").call(_t.append("inspector.no_documentation_key")); - done(); - return; + 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 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); + }; } - if (docs.imageURL) { - _body.append("img").attr("class", "tag-reference-wiki-image").attr("alt", docs.title).attr("src", docs.imageURL).on("load", function() { - done(); - }).on("error", function() { - select_default2(this).remove(); - done(); + 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) }); } else { - done(); - } - var tagReferenceDescription = _body.append("p").attr("class", "tag-reference-description").append("span"); - if (docs.description) { - tagReferenceDescription = tagReferenceDescription.attr("class", "localized-text").attr("lang", docs.descriptionLocaleCode || "und").call(docs.description); - } else { - tagReferenceDescription = tagReferenceDescription.call(_t.append("inspector.no_documentation_key")); - } - tagReferenceDescription.append("a").attr("class", "tag-reference-edit").attr("target", "_blank").attr("title", _t("inspector.edit_reference")).attr("href", docs.editURL).call(svgIcon("#iD-icon-edit", "inline")); - if (docs.wiki) { - _body.append("a").attr("class", "tag-reference-link").attr("target", "_blank").attr("href", docs.wiki.url).call(svgIcon("#iD-icon-out-link", "inline")).append("span").call(_t.append(docs.wiki.text)); - } - if (what.key === "comment") { - _body.append("a").attr("class", "tag-reference-comment-link").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).attr("href", _t("commit.about_changeset_comments_link")).append("span").call(_t.append("commit.about_changeset_comments")); + 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({ + relation: entity, + value, + display: baseDisplayLabel(entity) + }); + }); + 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; + }); + }); } - } - function done() { - _loaded = true; - _button.classed("tag-reference-loading", false); - _body.classed("expanded", true).transition().duration(200).style("max-height", "200px").style("opacity", "1"); - _showing = true; - _button.selectAll("svg.icon use").each(function() { - var iconUse = select_default2(this); - if (iconUse.attr("href") === "#iD-icon-info") { - iconUse.attr("href", "#iD-icon-info-filled"); - } + result.forEach(function(obj) { + obj.title = obj.value; }); + result.unshift(newRelation); + callback(result); } - function hide() { - _body.transition().duration(200).style("max-height", "0px").style("opacity", "0").on("end", function() { - _body.classed("expanded", false); + function baseDisplayValue(entity) { + const graph = context.graph(); + var matched = _mainPresetIndex.match(entity, graph); + var presetName = matched && matched.name() || _t("inspector.relation"); + var entityName = utilDisplayName(entity) || ""; + return presetName + " " + entityName; + } + 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; }); - _showing = false; - _button.selectAll("svg.icon use").each(function() { - var iconUse = select_default2(this); - if (iconUse.attr("href") === "#iD-icon-info-filled") { - iconUse.attr("href", "#iD-icon-info"); - } + 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); }); - } - tagReference.button = function(selection2, klass, iconName) { - _button = selection2.selectAll(".tag-reference-button").data([0]); - _button = _button.enter().append("button").attr("class", "tag-reference-button " + (klass || "")).attr("title", _t("icons.information")).call(svgIcon("#iD-icon-" + (iconName || "inspect"))).merge(_button); - _button.on("click", function(d3_event) { - d3_event.stopPropagation(); - d3_event.preventDefault(); - this.blur(); - if (_showing) { - hide(); - } else if (_loaded) { - done(); - } else { - load(); - } + var labelEnter = itemsEnter.append("label").attr("class", "field-label").attr("for", function(d2) { + return d2.domId; }); - }; - tagReference.body = function(selection2) { - var itemID = what.qid || what.key + "-" + (what.value || ""); - _body = selection2.selectAll(".tag-reference-body").data([itemID], function(d2) { - return d2; + 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"); }); - _body.exit().remove(); - _body = _body.enter().append("div").attr("class", "tag-reference-body").style("max-height", "0").style("opacity", "0").merge(_body); - if (_showing === false) { - hide(); - } - }; - tagReference.showing = function(val) { - if (!arguments.length) return _showing; - _showing = val; - return tagReference; - }; - return tagReference; - } - - // 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; + labelLink.append("span").attr("class", "member-entity-name").classed("has-colour", (d2) => d2.relation.tags.colour && isColourValid(d2.relation.tags.colour)).style("border-color", (d2) => d2.relation.tags.colour).html(function(d2) { + const matched = _mainPresetIndex.match(d2.relation, context.graph()); + return utilDisplayName(d2.relation, matched.suggestion); }); - 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] }; + 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)); }); - if (!rowData.length || _showBlank) { - _showBlank = false; - rowData.push({ index: rowData.length, key: "", value: "" }); + 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 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 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 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); + 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", function(d2) { + this.blur(); + acceptEntity.call(this, d2); + }).on("cancel", cancelEntity) + ); + 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"); - 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; + addRow = addRow.merge(addRowEnter); + addRow.select(".add-relation").on("click", function() { + _showBlank = true; + section.reRender(); + list2.selectAll(".member-entity-input").node().focus(); }); - 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 acceptEntity(d2) { + if (!d2) { + cancelEntity(); + return; } - ); - } - function isReadOnly(d2) { - for (var i3 = 0; i3 < _readOnlyTags.length; i3++) { - if (d2.key.match(_readOnlyTags[i3]) !== null) { - return true; + 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 other2 = []; + for (var i3 = 0; i3 < data.length; i3++) { + if (data[i3].value.substring(0, value.length) === value) { + sameletter.push(data[i3]); + } else { + other2.push(data[i3]); + } + } + return sameletter.concat(other2); } + 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); + }) + ); } - return false; - } - 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 stringify3(s2) { - const stringified = JSON.stringify(s2).slice(1, -1); - if (stringified !== s2) { - return '"'.concat(stringified, '"'); - } else { - return s2; + 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; + const didChange = _entityIDs.join(",") !== val.join(","); + _entityIDs = val; + _showBlank = false; + if (didChange) { + recentlyAdded.clear(); } + return section; + }; + return section; + } + var init_raw_membership_editor = __esm({ + "modules/ui/sections/raw_membership_editor.js"() { + "use strict"; + init_src5(); + init_presets(); + init_localizer(); + init_add_entity(); + init_add_member(); + init_change_member(); + init_delete_members(); + init_select5(); + init_osm(); + init_tags(); + init_services(); + init_icon(); + init_combobox(); + init_section(); + init_tooltip(); + init_array3(); + init_util(); } - function unstringify(s2) { - const isQuoted = s2.length > 1 && s2.charAt(0) === '"' && s2.charAt(s2.length - 1) === '"'; - if (isQuoted) { - try { - return JSON.parse(s2); - } catch (e3) { - return s2; - } - } else { - return s2; + }); + + // modules/ui/sections/selection_list.js + var selection_list_exports = {}; + __export(selection_list_exports, { + uiSectionSelectionList: () => uiSectionSelectionList + }); + 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 _selectedIDs; + _selectedIDs = val; + return section; + }; + function selectEntity(d3_event, entity) { + context.enter(modeSelect(context, [entity.id])); } - 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"; + 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)); } - return str; } - 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 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); + }); }); - var tagDiff = utilTagDiff(_tags, newTags); - _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 || ""; - } + 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); }); - if (Object.keys(_pendingChange).length === 0) { - _pendingChange = null; - section.reRender(); - 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(); - } + return section; + } + var init_selection_list = __esm({ + "modules/ui/sections/selection_list.js"() { + "use strict"; + init_src5(); + init_presets(); + init_select5(); + init_osm(); + init_icon(); + init_section(); + init_localizer(); + init_util(); } - 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].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; + }); + + // modules/ui/entity_editor.js + var entity_editor_exports = {}; + __export(entity_editor_exports, { + uiEntityEditor: () => uiEntityEditor + }); + 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-${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) + ]; } - 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 other2 = []; - for (var i3 = 0; i3 < data.length; i3++) { - if (data[i3].value.substring(0, value2.length) === value2) { - sameletter.push(data[i3]); - } else { - other2.push(data[i3]); - } + _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(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); } - return sameletter.concat(other2); } } - 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(); + 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; + } } - }); - return; + } + if (!onInput) { + tags = utilCleanTags(tags); + } + if (!(0, import_fast_deep_equal9.default)(entity.tags, tags)) { + actions.push(actionChangeTags(entityID, tags)); + } } - _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); + 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; + } } - 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(); - } - 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(); + if (!onInput) { + context.validator().validate(); } } - 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); - } - section.state = function(val) { - if (!arguments.length) return _state; - if (_state !== val) { - _orderedKeys = []; - _state = val; + 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 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_equal9.default)(entity.tags, tags)) { + actions.push(actionChangeTags(entityID, tags)); + } } - 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); + 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; + } } - return section; + context.validator().validate(); + } + entityEditor.modified = function(val) { + if (!arguments.length) return _modified; + _modified = val; + return entityEditor; }; - section.tags = function(val) { - if (!arguments.length) return _tags; - _tags = val; - return section; + entityEditor.state = function(val) { + if (!arguments.length) return _state; + _state = val; + return entityEditor; }; - section.entityIDs = function(val) { + entityEditor.entityIDs = function(val) { if (!arguments.length) return _entityIDs; - if (!_entityIDs || !val || !utilArrayIdentical(_entityIDs, val)) { - _entityIDs = val; - _orderedKeys = []; - } - return section; + _base = context.graph(); + _coalesceChanges = false; + if (val && _entityIDs && utilArrayIdentical(_entityIDs, val)) return entityEditor; + _entityIDs = val; + loadActivePresets(true); + return entityEditor.modified(false); }; - section.readOnlyTags = function(val) { - if (!arguments.length) return _readOnlyTags; - _readOnlyTags = val; - return section; + entityEditor.newFeature = function(val) { + if (!arguments.length) return _newFeature; + _newFeature = val; + return entityEditor; }; - return utilRebind(section, dispatch14, "on"); - } - - // 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]); - 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); + 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; + } + entityEditor.presets(matches); } - dataEditor.datum = function(val) { - if (!arguments.length) return _datum; - _datum = val; - return this; + entityEditor.presets = function(val) { + if (!arguments.length) return _activePresets; + if (!utilArrayIdentical(val, _activePresets)) { + _activePresets = val; + } + return entityEditor; }; - return dataEditor; + return utilRebind(entityEditor, dispatch14, "on"); } + var import_fast_deep_equal9; + var init_entity_editor = __esm({ + "modules/ui/entity_editor.js"() { + "use strict"; + init_src4(); + import_fast_deep_equal9 = __toESM(require_fast_deep_equal()); + init_presets(); + init_localizer(); + init_change_tags(); + init_browse(); + init_icon(); + init_array3(); + init_util(); + init_entity_issues(); + init_feature_type(); + init_preset_fields(); + init_raw_member_editor(); + init_raw_membership_editor(); + init_raw_tag_editor(); + init_selection_list(); + } + }); - // 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 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(); + // modules/ui/preset_list.js + var preset_list_exports = {}; + __export(preset_list_exports, { + uiPresetList: () => uiPresetList + }); + 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")); + 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-close")); + 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 === 27) { - search.node().blur(); + 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 q2 = search.property("value"), items = list2.selectAll(".feature-list-item"); + var value = search.property("value"); if (d3_event.keyCode === 13 && // ↩ Return - q2.length && items.size()) { - click(d3_event, items.datum()); + value.length) { + list2.selectAll(".preset-list-item:first-child").each(function(d2) { + d2.choose.call(this); + }); } } function inputevent() { - _geocodeResults = void 0; - drawList(); + 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); } - function clearSearch() { - search.property("value", ""); - drawList(); + 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_feature_type")).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); } - function mapDrawn(e3) { - if (e3.full) { - drawList(); + 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)); } - } - 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) { - const latLon = [Number(locationMatch[0]), Number(locationMatch[1])]; - const lonLat = [latLon[1], latLon[0]]; - const isLatLonValid = latLon[0] >= -90 && latLon[0] <= 90 && latLon[1] >= -180 && latLon[1] <= 180; - let isLonLatValid = lonLat[0] >= -90 && lonLat[0] <= 90 && lonLat[1] >= -180 && lonLat[1] <= 180; - isLonLatValid && (isLonLatValid = !q2.match(/[NSEW]/i)); - isLonLatValid && (isLonLatValid = lonLat[0] !== lonLat[1]); - if (isLatLonValid) { - result.push({ - id: latLon[0] + "/" + latLon[1], - geometry: "point", - type: _t("inspector.location"), - name: dmsCoordinatePair([latLon[1], latLon[0]]), - location: latLon - }); + 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(); + d3_event.stopPropagation(); + var nextItem = select_default2(item.node().nextElementSibling); + if (nextItem.empty()) { + if (!parentItem.empty()) { + nextItem = select_default2(parentItem.node().nextElementSibling); } - if (isLonLatValid) { - result.push({ - id: lonLat[0] + "/" + lonLat[1], - geometry: "point", - type: _t("inspector.location"), - name: dmsCoordinatePair([lonLat[1], lonLat[0]]), - location: lonLat - }); + } 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"); } - 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 - }); + 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(); } - 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; + } 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(); } - 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"]; + } 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(); + } + 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); } - 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])] - ) - }); + } 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 { + itemKeydown.call(this, d3_event); } }); - 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; + 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"); } - 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")); + 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 { + 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"); } - 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"); - 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("pointerenter", mouseover).on("pointerleave", mouseout).on("focus", mouseover).on("blur", 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; + }; + 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)); }); - 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; + 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); + }; + 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; + } + 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") + ); + } + }); + } + 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()); }); - enter.style("opacity", 0).transition().style("opacity", 1); - items.exit().each((d2) => mouseout(void 0, d2)).remove(); - items.merge(enter).order(); + presetList.presets(presets); } - function mouseover(d3_event, d2) { - if (d2.location !== void 0) return; - utilHighlightEntities([d2.id], true, context); + 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"; + } + if (!counts[geometry]) counts[geometry] = 0; + counts[geometry] += 1; } - function mouseout(d3_event, d2) { - if (d2.location !== void 0) return; - utilHighlightEntities([d2.id], false, context); + return Object.keys(counts).sort(function(geom1, geom2) { + return counts[geom2] - counts[geom1]; + }); + } + return utilRebind(presetList, dispatch14, "on"); + } + var init_preset_list = __esm({ + "modules/ui/preset_list.js"() { + "use strict"; + init_src4(); + init_src5(); + init_debounce(); + init_presets(); + init_localizer(); + init_change_preset(); + init_delete(); + init_svg(); + init_tooltip(); + init_extent(); + init_preset_icon(); + init_tag_reference(); + init_util(); + } + }); + + // modules/ui/inspector.js + var inspector_exports = {}; + __export(inspector_exports, { + uiInspector: () => uiInspector + }); + 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.type === "node" && 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); } - 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.moveToNote(noteId); - } else { - context.zoomToEntity(d2.id); + presetPane.call(presetList.autofocus(true)); + }; + 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); } - function geocoderSearch() { - services.geocoder.search(search.property("value"), function(err, resp) { - _geocodeResults = resp || []; - drawList(); + }; + inspector.state = function(val) { + if (!arguments.length) return _state; + _state = val; + entityEditor.state(_state); + context.container().selectAll(".field-help-body").remove(); + return inspector; + }; + inspector.entityIDs = function(val) { + if (!arguments.length) return _entityIDs; + _entityIDs = val; + return inspector; + }; + inspector.newFeature = function(val) { + if (!arguments.length) return _newFeature; + _newFeature = val; + return inspector; + }; + return inspector; + } + var init_inspector = __esm({ + "modules/ui/inspector.js"() { + "use strict"; + init_src8(); + init_src5(); + init_entity_editor(); + init_preset_list(); + init_view_on_osm(); + } + }); + + // modules/ui/keepRight_details.js + var keepRight_details_exports = {}; + __export(keepRight_details_exports, { + uiKeepRightDetails: () => uiKeepRightDetails + }); + 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.${itemType}.title`)) { + return _t.html(`QA.keepRight.errorTypes.${itemType}.description`, replacements); + } else { + return _t.html(`QA.keepRight.errorTypes.${parentIssueType}.description`, replacements); + } + } + function keepRightDetails(selection2) { + const details = selection2.selectAll(".error-details").data( + _qaItem ? [_qaItem] : [], + (d2) => `${d2.id}-${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().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]); + } + keepRightDetails.issue = function(val) { + if (!arguments.length) return _qaItem; + _qaItem = val; + return keepRightDetails; + }; + return keepRightDetails; + } + var init_keepRight_details = __esm({ + "modules/ui/keepRight_details.js"() { + "use strict"; + init_src5(); + init_presets(); + init_select5(); + init_localizer(); + init_util(); + } + }); + + // modules/ui/keepRight_header.js + var keepRight_header_exports = {}; + __export(keepRight_header_exports, { + uiKeepRightHeader: () => uiKeepRightHeader + }); + 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.${itemType}.title`)) { + return _t.html(`QA.keepRight.errorTypes.${itemType}.title`, replacements); + } else { + return _t.html(`QA.keepRight.errorTypes.${parentIssueType}.title`, replacements); } } - return featureList; + function keepRightHeader(selection2) { + const header = selection2.selectAll(".qa-header").data( + _qaItem ? [_qaItem] : [], + (d2) => `${d2.id}-${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 ${d2.service} itemId-${d2.id} itemType-${d2.parentIssueType}`).call(svgIcon("#iD-icon-bolt", "qaItem-fill")); + headerEnter.append("div").attr("class", "qa-header-label").html(issueTitle); + } + keepRightHeader.issue = function(val) { + if (!arguments.length) return _qaItem; + _qaItem = val; + return keepRightHeader; + }; + return keepRightHeader; } + var init_keepRight_header = __esm({ + "modules/ui/keepRight_header.js"() { + "use strict"; + init_icon(); + init_localizer(); + } + }); - // modules/ui/entity_editor.js - var import_fast_deep_equal9 = __toESM(require_fast_deep_equal()); + // modules/ui/view_on_keepRight.js + var view_on_keepRight_exports = {}; + __export(view_on_keepRight_exports, { + uiViewOnKeepRight: () => uiViewOnKeepRight + }); + function uiViewOnKeepRight() { + let _qaItem; + function viewOnKeepRight(selection2) { + let url; + if (services.keepRight && _qaItem instanceof QAItem) { + url = services.keepRight.issueURL(_qaItem); + } + 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 _qaItem; + _qaItem = val; + return viewOnKeepRight; + }; + return viewOnKeepRight; + } + var init_view_on_keepRight = __esm({ + "modules/ui/view_on_keepRight.js"() { + "use strict"; + init_localizer(); + init_services(); + init_icon(); + init_osm(); + } + }); - // modules/ui/sections/entity_issues.js - function uiSectionEntityIssues(context) { - var preference = corePreferences("entity-issues.reference.expanded"); - var _expanded = preference === null ? true : preference === "true"; - var _entityIDs = []; - var _issues = []; - var _activeIssueID; - var section = uiSection("entity-issues", context).shouldDisplay(function() { - return _issues.length > 0; - }).label(function() { - return _t.append("inspector.title_count", { title: _t("issues.list_title"), count: _issues.length }); - }).disclosureContent(renderDisclosureContent); - context.validator().on("validated.entity_issues", function() { - reloadIssues(); - section.reRender(); - }).on("focusedIssue.entity_issues", function(issue) { - makeActiveIssue(issue.id); - }); - function reloadIssues() { - _issues = context.validator().getSharedEntityIssues(_entityIDs, { includeDisabledRules: true }); + // modules/ui/keepRight_editor.js + var keepRight_editor_exports = {}; + __export(keepRight_editor_exports, { + uiKeepRightEditor: () => uiKeepRightEditor + }); + 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)); } - function makeActiveIssue(issueID) { - _activeIssueID = issueID; - section.selection().selectAll(".issue-container").classed("active", function(d2) { - return d2.id === _activeIssueID; - }); + 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) => `${d2.id}-${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); + } } - function renderDisclosureContent(selection2) { - selection2.classed("grouped-items-area", true); - _activeIssueID = _issues.length > 0 ? _issues[0].id : null; - var containers = selection2.selectAll(".issue-container").data(_issues, function(d2) { - return d2.key; - }); - containers.exit().remove(); - var containersEnter = containers.enter().append("div").attr("class", "issue-container"); - var itemsEnter = containersEnter.append("div").attr("class", function(d2) { - return "issue severity-" + d2.severity; - }).on("mouseover.highlight", function(d3_event, d2) { - var ids = d2.entityIds.filter(function(e3) { - return _entityIDs.indexOf(e3) === -1; - }); - utilHighlightEntities(ids, true, context); - }).on("mouseout.highlight", function(d3_event, d2) { - var ids = d2.entityIds.filter(function(e3) { - return _entityIDs.indexOf(e3) === -1; - }); - utilHighlightEntities(ids, false, context); - }); - var labelsEnter = itemsEnter.append("div").attr("class", "issue-label"); - var textEnter = labelsEnter.append("button").attr("class", "issue-text").on("click", function(d3_event, d2) { - makeActiveIssue(d2.id); - var extent = d2.extent(context.graph()); - if (extent) { - var setZoom = Math.max(context.map().zoom(), 19); - context.map().unobscuredCenterZoomEase(extent.center(), setZoom); + 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)); } }); - textEnter.each(function(d2) { - var iconName = "#iD-icon-" + (d2.severity === "warning" ? "alert" : "error"); - select_default2(this).call(svgIcon(iconName, "issue-icon")); - }); - textEnter.append("span").attr("class", "issue-message"); - var infoButton = labelsEnter.append("button").attr("class", "issue-info-button").attr("title", _t("icons.information")).call(svgIcon("#iD-icon-inspect")); - infoButton.on("click", function(d3_event) { - d3_event.stopPropagation(); - d3_event.preventDefault(); + buttonSection.select(".close-button").html((d2) => { + const andComment = d2.newComment ? "_comment" : ""; + return _t.html(`QA.keepRight.close${andComment}`); + }).on("click.close", function(d3_event, d2) { this.blur(); - var container = select_default2(this.parentNode.parentNode.parentNode); - var info = container.selectAll(".issue-info"); - var isExpanded = info.classed("expanded"); - _expanded = !isExpanded; - corePreferences("entity-issues.reference.expanded", _expanded); - if (isExpanded) { - info.transition().duration(200).style("max-height", "0px").style("opacity", "0").on("end", function() { - info.classed("expanded", false); - }); - } else { - info.classed("expanded", true).transition().duration(200).style("max-height", "200px").style("opacity", "1").on("end", function() { - info.style("max-height", null); - }); + const qaService = services.keepRight; + if (qaService) { + d2.newStatus = "ignore_t"; + qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item)); } }); - itemsEnter.append("ul").attr("class", "issue-fix-list"); - containersEnter.append("div").attr("class", "issue-info" + (_expanded ? " expanded" : "")).style("max-height", _expanded ? null : "0").style("opacity", _expanded ? "1" : "0").each(function(d2) { - if (typeof d2.reference === "function") { - select_default2(this).call(d2.reference); - } else { - select_default2(this).call(_t.append("inspector.no_documentation_key")); + buttonSection.select(".ignore-button").html((d2) => { + const andComment = d2.newComment ? "_comment" : ""; + return _t.html(`QA.keepRight.ignore${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)); } }); - containers = containers.merge(containersEnter).classed("active", function(d2) { - return d2.id === _activeIssueID; - }); - containers.selectAll(".issue-message").text("").each(function(d2) { - return d2.message(context)(select_default2(this)); - }); - var fixLists = containers.selectAll(".issue-fix-list"); - var fixes = fixLists.selectAll(".issue-fix-item").data(function(d2) { - return d2.fixes ? d2.fixes(context) : []; - }, function(fix) { - return fix.id; - }); - fixes.exit().remove(); - var fixesEnter = fixes.enter().append("li").attr("class", "issue-fix-item"); - var buttons = fixesEnter.append("button").on("click", function(d3_event, d2) { - if (select_default2(this).attr("disabled") || !d2.onClick) return; - if (d2.issue.dateLastRanFix && /* @__PURE__ */ new Date() - d2.issue.dateLastRanFix < 1e3) return; - d2.issue.dateLastRanFix = /* @__PURE__ */ new Date(); - utilHighlightEntities(d2.issue.entityIds.concat(d2.entityIds), false, context); - new Promise(function(resolve, reject) { - d2.onClick(context, resolve, reject); - if (d2.onClick.length <= 1) { - resolve(); + } + keepRightEditor.error = function(val) { + if (!arguments.length) return _qaItem; + _qaItem = val; + return keepRightEditor; + }; + return utilRebind(keepRightEditor, dispatch14, "on"); + } + var init_keepRight_editor = __esm({ + "modules/ui/keepRight_editor.js"() { + "use strict"; + init_src4(); + init_src5(); + init_localizer(); + init_services(); + init_browse(); + init_icon(); + init_keepRight_details(); + init_keepRight_header(); + init_view_on_keepRight(); + init_util(); + } + }); + + // modules/ui/osmose_details.js + var osmose_details_exports = {}; + __export(osmose_details_exports, { + uiOsmoseDetails: () => uiOsmoseDetails + }); + function uiOsmoseDetails(context) { + let _qaItem; + function issueString(d2, type2) { + if (!d2) return ""; + const s2 = services.osmose.getStrings(d2.itemType); + return type2 in s2 ? s2[type2] : ""; + } + function osmoseDetails(selection2) { + const details = selection2.selectAll(".error-details").data( + _qaItem ? [_qaItem] : [], + (d2) => `${d2.id}-${d2.status || 0}` + ); + details.exit().remove(); + const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container"); + if (issueString(_qaItem, "detail")) { + const div = detailsEnter.append("div").attr("class", "qa-details-subsection"); + div.append("h4").call(_t.append("QA.keepRight.detail_description")); + div.append("p").attr("class", "qa-details-description-text").html((d2) => issueString(d2, "detail")).selectAll("a").attr("rel", "noopener").attr("target", "_blank"); + } + const detailsDiv = detailsEnter.append("div").attr("class", "qa-details-subsection"); + const elemsDiv = detailsEnter.append("div").attr("class", "qa-details-subsection"); + if (issueString(_qaItem, "fix")) { + const div = detailsEnter.append("div").attr("class", "qa-details-subsection"); + div.append("h4").call(_t.append("QA.osmose.fix_title")); + div.append("p").html((d2) => issueString(d2, "fix")).selectAll("a").attr("rel", "noopener").attr("target", "_blank"); + } + if (issueString(_qaItem, "trap")) { + const div = detailsEnter.append("div").attr("class", "qa-details-subsection"); + div.append("h4").call(_t.append("QA.osmose.trap_title")); + div.append("p").html((d2) => issueString(d2, "trap")).selectAll("a").attr("rel", "noopener").attr("target", "_blank"); + } + const thisItem = _qaItem; + services.osmose.loadIssueDetail(_qaItem).then((d2) => { + if (!d2.elems || d2.elems.length === 0) return; + if (context.selectedErrorID() !== thisItem.id && context.container().selectAll(`.qaItem.osmose.hover.itemId-${thisItem.id}`).empty()) return; + if (d2.detail) { + detailsDiv.append("h4").call(_t.append("QA.osmose.detail_title")); + detailsDiv.append("p").html((d4) => d4.detail).selectAll("a").attr("rel", "noopener").attr("target", "_blank"); + } + 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 link3 = select_default2(this); + const entityID = this.textContent; + const entity = context.hasEntity(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(d2.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) { + const preset = _mainPresetIndex.match(entity, context.graph()); + name = preset && !preset.isFallback() && preset.name(); + } + if (name) { + this.innerText = name; + } } - }).then(function() { - context.validator().validate(); }); - }).on("mouseover.highlight", function(d3_event, d2) { - utilHighlightEntities(d2.entityIds, true, context); - }).on("mouseout.highlight", function(d3_event, d2) { - utilHighlightEntities(d2.entityIds, false, context); - }); - buttons.each(function(d2) { - var iconName = d2.icon || "iD-icon-wrench"; - if (iconName.startsWith("maki")) { - iconName += "-15"; - } - select_default2(this).call(svgIcon("#" + iconName, "fix-icon")); - }); - buttons.append("span").attr("class", "fix-message").each(function(d2) { - return d2.title(select_default2(this)); - }); - fixesEnter.merge(fixes).selectAll("button").classed("actionable", function(d2) { - return d2.onClick; - }).attr("disabled", function(d2) { - return d2.onClick ? null : "true"; - }).attr("title", function(d2) { - if (d2.disabledReason) { - return d2.disabledReason; - } - return null; + context.features().forceVisible(d2.elems); + context.map().pan([0, 0]); + }).catch((err) => { + console.log(err); }); } - section.entityIDs = function(val) { - if (!arguments.length) return _entityIDs; - if (!_entityIDs || !val || !utilArrayIdentical(_entityIDs, val)) { - _entityIDs = val; - _activeIssueID = null; - reloadIssues(); - } - return section; + osmoseDetails.issue = function(val) { + if (!arguments.length) return _qaItem; + _qaItem = val; + return osmoseDetails; + }; + return osmoseDetails; + } + var init_osmose_details = __esm({ + "modules/ui/osmose_details.js"() { + "use strict"; + init_src5(); + init_presets(); + init_select5(); + init_localizer(); + init_services(); + init_util(); + } + }); + + // modules/ui/osmose_header.js + var osmose_header_exports = {}; + __export(osmose_header_exports, { + uiOsmoseHeader: () => uiOsmoseHeader + }); + function uiOsmoseHeader() { + let _qaItem; + function issueTitle(d2) { + const unknown = _t("inspector.unknown"); + if (!d2) return unknown; + const s2 = services.osmose.getStrings(d2.itemType); + return "title" in s2 ? s2.title : unknown; + } + function osmoseHeader(selection2) { + const header = selection2.selectAll(".qa-header").data( + _qaItem ? [_qaItem] : [], + (d2) => `${d2.id}-${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 ${d2.service} itemId-${d2.id} itemType-${d2.itemType}`); + svgEnter.append("polygon").attr("fill", (d2) => services.osmose.getColor(d2.item)).attr("class", "qaItem-fill").attr("points", "16,3 4,3 1,6 1,17 4,20 7,20 10,27 13,20 16,20 19,17.033 19,6"); + 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").text(issueTitle); + } + osmoseHeader.issue = function(val) { + if (!arguments.length) return _qaItem; + _qaItem = val; + return osmoseHeader; }; - return section; + return osmoseHeader; } - - // modules/ui/preset_icon.js - function uiPresetIcon() { - let _preset; - let _geometry; - function presetIcon(selection2) { - selection2.each(render); + var init_osmose_header = __esm({ + "modules/ui/osmose_header.js"() { + "use strict"; + init_services(); + init_localizer(); } - function getIcon(p2, geom) { - if (p2.isFallback && p2.isFallback()) return geom === "vertex" ? "" : "iD-icon-" + p2.id; - if (p2.icon) return p2.icon; - if (geom === "line") return "iD-other-line"; - if (geom === "vertex") return "temaki-vertex"; - return "maki-marker-stroked"; + }); + + // modules/ui/view_on_osmose.js + var view_on_osmose_exports = {}; + __export(view_on_osmose_exports, { + uiViewOnOsmose: () => uiViewOnOsmose + }); + function uiViewOnOsmose() { + let _qaItem; + function viewOnOsmose(selection2) { + let url; + if (services.osmose && _qaItem instanceof QAItem) { + url = services.osmose.itemURL(_qaItem); + } + 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")); } - function renderPointBorder(container, drawPoint) { - let pointBorder = container.selectAll(".preset-icon-point-border").data(drawPoint ? [0] : []); - pointBorder.exit().remove(); - let pointBorderEnter = pointBorder.enter(); - const w2 = 40; - const h2 = 40; - pointBorderEnter.append("svg").attr("class", "preset-icon-fill preset-icon-point-border").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2)).append("path").attr("transform", "translate(11.5, 8)").attr("d", "M 17,8 C 17,13 11,21 8.5,23.5 C 6,21 0,13 0,8 C 0,4 4,-0.5 8.5,-0.5 C 13,-0.5 17,4 17,8 z"); - pointBorder = pointBorderEnter.merge(pointBorder); + viewOnOsmose.what = function(val) { + if (!arguments.length) return _qaItem; + _qaItem = val; + return viewOnOsmose; + }; + return viewOnOsmose; + } + var init_view_on_osmose = __esm({ + "modules/ui/view_on_osmose.js"() { + "use strict"; + init_localizer(); + init_services(); + init_icon(); + init_osm(); } - function renderCategoryBorder(container, category) { - let categoryBorder = container.selectAll(".preset-icon-category-border").data(category ? [0] : []); - categoryBorder.exit().remove(); - let categoryBorderEnter = categoryBorder.enter(); - const d2 = 60; - let svgEnter = categoryBorderEnter.append("svg").attr("class", "preset-icon-fill preset-icon-category-border").attr("width", d2).attr("height", d2).attr("viewBox", "0 0 ".concat(d2, " ").concat(d2)); - svgEnter.append("path").attr("class", "area").attr("d", "M9.5,7.5 L25.5,7.5 L28.5,12.5 L49.5,12.5 C51.709139,12.5 53.5,14.290861 53.5,16.5 L53.5,43.5 C53.5,45.709139 51.709139,47.5 49.5,47.5 L10.5,47.5 C8.290861,47.5 6.5,45.709139 6.5,43.5 L6.5,12.5 L9.5,7.5 Z"); - categoryBorder = categoryBorderEnter.merge(categoryBorder); - if (category) { - categoryBorder.selectAll("path").attr("class", "area ".concat(category.id)); - } + }); + + // modules/ui/osmose_editor.js + var osmose_editor_exports = {}; + __export(osmose_editor_exports, { + uiOsmoseEditor: () => uiOsmoseEditor + }); + function uiOsmoseEditor(context) { + const dispatch14 = dispatch_default("change"); + const qaDetails = uiOsmoseDetails(context); + const qaHeader = uiOsmoseHeader(context); + let _qaItem; + function osmoseEditor(selection2) { + const header = selection2.selectAll(".header").data([0]); + const headerEnter = header.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.osmose.title")); + let body = selection2.selectAll(".body").data([0]); + body = body.enter().append("div").attr("class", "body").merge(body); + let 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(osmoseSaveSection); + const footer = selection2.selectAll(".footer").data([0]); + footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnOsmose(context).what(_qaItem)); } - function renderCircleFill(container, drawVertex) { - let vertexFill = container.selectAll(".preset-icon-fill-vertex").data(drawVertex ? [0] : []); - vertexFill.exit().remove(); - let vertexFillEnter = vertexFill.enter(); - const w2 = 60; - const h2 = 60; - const d2 = 40; - vertexFillEnter.append("svg").attr("class", "preset-icon-fill preset-icon-fill-vertex").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2)).append("circle").attr("cx", w2 / 2).attr("cy", h2 / 2).attr("r", d2 / 2); - vertexFill = vertexFillEnter.merge(vertexFill); + function osmoseSaveSection(selection2) { + const isSelected = _qaItem && _qaItem.id === context.selectedErrorID(); + const isShown = _qaItem && isSelected; + let saveSection = selection2.selectAll(".qa-save").data( + isShown ? [_qaItem] : [], + (d2) => `${d2.id}-${d2.status || 0}` + ); + saveSection.exit().remove(); + const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf"); + saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons); } - function renderSquareFill(container, drawArea, tagClasses) { - let fill = container.selectAll(".preset-icon-fill-area").data(drawArea ? [0] : []); - fill.exit().remove(); - let fillEnter = fill.enter(); - const d2 = 60; - const w2 = d2; - const h2 = d2; - const l2 = d2 * 2 / 3; - const c1 = (w2 - l2) / 2; - const c2 = c1 + l2; - fillEnter = fillEnter.append("svg").attr("class", "preset-icon-fill preset-icon-fill-area").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2)); - ["fill", "stroke"].forEach((klass) => { - fillEnter.append("path").attr("d", "M".concat(c1, " ").concat(c1, " L").concat(c1, " ").concat(c2, " L").concat(c2, " ").concat(c2, " L").concat(c2, " ").concat(c1, " Z")).attr("class", "area ".concat(klass)); - }); - const rVertex = 2.5; - [[c1, c1], [c1, c2], [c2, c2], [c2, c1]].forEach((point) => { - fillEnter.append("circle").attr("class", "vertex").attr("cx", point[0]).attr("cy", point[1]).attr("r", rVertex); + 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 close-button action"); + buttonEnter.append("button").attr("class", "button ignore-button action"); + buttonSection = buttonSection.merge(buttonEnter); + buttonSection.select(".close-button").call(_t.append("QA.keepRight.close")).on("click.close", function(d3_event, d2) { + this.blur(); + const qaService = services.osmose; + if (qaService) { + d2.newStatus = "done"; + qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item)); + } }); - const rMidpoint = 1.25; - [[c1, w2 / 2], [c2, w2 / 2], [h2 / 2, c1], [h2 / 2, c2]].forEach((point) => { - fillEnter.append("circle").attr("class", "midpoint").attr("cx", point[0]).attr("cy", point[1]).attr("r", rMidpoint); + buttonSection.select(".ignore-button").call(_t.append("QA.keepRight.ignore")).on("click.ignore", function(d3_event, d2) { + this.blur(); + const qaService = services.osmose; + if (qaService) { + d2.newStatus = "false"; + qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item)); + } }); - fill = fillEnter.merge(fill); - fill.selectAll("path.stroke").attr("class", "area stroke ".concat(tagClasses)); - fill.selectAll("path.fill").attr("class", "area fill ".concat(tagClasses)); } - function renderLine(container, drawLine, tagClasses) { - let line = container.selectAll(".preset-icon-line").data(drawLine ? [0] : []); - line.exit().remove(); - let lineEnter = line.enter(); - const d2 = 60; - const w2 = d2; - const h2 = d2; - const y2 = Math.round(d2 * 0.72); - const l2 = Math.round(d2 * 0.6); - const r2 = 2.5; - const x12 = (w2 - l2) / 2; - const x2 = x12 + l2; - lineEnter = lineEnter.append("svg").attr("class", "preset-icon-line").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2)); - ["casing", "stroke"].forEach((klass) => { - lineEnter.append("path").attr("d", "M".concat(x12, " ").concat(y2, " L").concat(x2, " ").concat(y2)).attr("class", "line ".concat(klass)); - }); - [[x12 - 1, y2], [x2 + 1, y2]].forEach((point) => { - lineEnter.append("circle").attr("class", "vertex").attr("cx", point[0]).attr("cy", point[1]).attr("r", r2); - }); - line = lineEnter.merge(line); - line.selectAll("path.stroke").attr("class", "line stroke ".concat(tagClasses)); - line.selectAll("path.casing").attr("class", "line casing ".concat(tagClasses)); + osmoseEditor.error = function(val) { + if (!arguments.length) return _qaItem; + _qaItem = val; + return osmoseEditor; + }; + return utilRebind(osmoseEditor, dispatch14, "on"); + } + var init_osmose_editor = __esm({ + "modules/ui/osmose_editor.js"() { + "use strict"; + init_src4(); + init_localizer(); + init_services(); + init_browse(); + init_icon(); + init_osmose_details(); + init_osmose_header(); + init_view_on_osmose(); + init_util(); } - function renderRoute(container, drawRoute, p2) { - let route = container.selectAll(".preset-icon-route").data(drawRoute ? [0] : []); - route.exit().remove(); - let routeEnter = route.enter(); - const d2 = 60; - const w2 = d2; - const h2 = d2; - const y12 = Math.round(d2 * 0.8); - const y2 = Math.round(d2 * 0.68); - const l2 = Math.round(d2 * 0.6); - const r2 = 2; - const x12 = (w2 - l2) / 2; - const x2 = x12 + l2 / 3; - const x3 = x2 + l2 / 3; - const x4 = x3 + l2 / 3; - routeEnter = routeEnter.append("svg").attr("class", "preset-icon-route").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2)); - ["casing", "stroke"].forEach((klass) => { - routeEnter.append("path").attr("d", "M".concat(x12, " ").concat(y12, " L").concat(x2, " ").concat(y2)).attr("class", "segment0 line ".concat(klass)); - routeEnter.append("path").attr("d", "M".concat(x2, " ").concat(y2, " L").concat(x3, " ").concat(y12)).attr("class", "segment1 line ".concat(klass)); - routeEnter.append("path").attr("d", "M".concat(x3, " ").concat(y12, " L").concat(x4, " ").concat(y2)).attr("class", "segment2 line ".concat(klass)); - }); - [[x12, y12], [x2, y2], [x3, y12], [x4, y2]].forEach((point) => { - routeEnter.append("circle").attr("class", "vertex").attr("cx", point[0]).attr("cy", point[1]).attr("r", r2); - }); - route = routeEnter.merge(route); - if (drawRoute) { - let routeType = p2.tags.type === "waterway" ? "waterway" : p2.tags.route; - const segmentPresetIDs = routeSegments[routeType]; - for (let i3 in segmentPresetIDs) { - const segmentPreset = _mainPresetIndex.item(segmentPresetIDs[i3]); - const segmentTagClasses = svgTagClasses().getClassesString(segmentPreset.tags, ""); - route.selectAll("path.stroke.segment".concat(i3)).attr("class", "segment".concat(i3, " line stroke ").concat(segmentTagClasses)); - route.selectAll("path.casing.segment".concat(i3)).attr("class", "segment".concat(i3, " line casing ").concat(segmentTagClasses)); + }); + + // modules/ui/sidebar.js + var sidebar_exports = {}; + __export(sidebar_exports, { + uiSidebar: () => uiSidebar + }); + function uiSidebar(context) { + var inspector = uiInspector(context); + var dataEditor = uiDataEditor(context); + var noteEditor = uiNoteEditor(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; + 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 { + 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 renderSvgIcon(container, picon, geom, isFramed, category, tagClasses) { - const isMaki = picon && /^maki-/.test(picon); - const isTemaki = picon && /^temaki-/.test(picon); - const isFa = picon && /^fa[srb]-/.test(picon); - const isR\u00F6ntgen = picon && /^roentgen-/.test(picon); - const isiDIcon = picon && !(isMaki || isTemaki || isFa || isR\u00F6ntgen); - let icon2 = container.selectAll(".preset-icon").data(picon ? [0] : []); - icon2.exit().remove(); - icon2 = icon2.enter().append("div").attr("class", "preset-icon").call(svgIcon("")).merge(icon2); - icon2.attr("class", "preset-icon " + (geom ? geom + "-geom" : "")).classed("category", category).classed("framed", isFramed).classed("preset-icon-iD", isiDIcon); - icon2.selectAll("svg").attr("class", "icon " + picon + " " + (!isiDIcon && geom !== "line" ? "" : tagClasses)); - icon2.selectAll("use").attr("href", "#" + picon); - } - function renderImageIcon(container, imageURL) { - let imageIcon = container.selectAll("img.image-icon").data(imageURL ? [0] : []); - imageIcon.exit().remove(); - imageIcon = imageIcon.enter().append("img").attr("class", "image-icon").on("load", () => container.classed("showing-img", true)).on("error", () => container.classed("showing-img", false)).merge(imageIcon); - imageIcon.attr("src", imageURL); - } - const routeSegments = { - bicycle: ["highway/cycleway", "highway/cycleway", "highway/cycleway"], - bus: ["highway/unclassified", "highway/secondary", "highway/primary"], - trolleybus: ["highway/unclassified", "highway/secondary", "highway/primary"], - detour: ["highway/tertiary", "highway/residential", "highway/unclassified"], - ferry: ["route/ferry", "route/ferry", "route/ferry"], - foot: ["highway/footway", "highway/footway", "highway/footway"], - hiking: ["highway/path", "highway/path", "highway/path"], - horse: ["highway/bridleway", "highway/bridleway", "highway/bridleway"], - light_rail: ["railway/light_rail", "railway/light_rail", "railway/light_rail"], - monorail: ["railway/monorail", "railway/monorail", "railway/monorail"], - mtb: ["highway/path", "highway/track", "highway/bridleway"], - pipeline: ["man_made/pipeline", "man_made/pipeline", "man_made/pipeline"], - piste: ["piste/downhill", "piste/hike", "piste/nordic"], - power: ["power/line", "power/line", "power/line"], - road: ["highway/secondary", "highway/primary", "highway/trunk"], - 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() { - let p2 = _preset.apply(this, arguments); - let geom = _geometry ? _geometry.apply(this, arguments) : null; - if (geom === "relation" && p2.tags && (p2.tags.type === "route" && p2.tags.route && routeSegments[p2.tags.route] || p2.tags.type === "waterway")) { - geom = "route"; + 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); } - const showThirdPartyIcons = corePreferences("preferences.privacy.thirdpartyicons") || "true"; - const isFallback = p2.isFallback && p2.isFallback(); - const imageURL = showThirdPartyIcons === "true" && p2.imageURL; - const picon = getIcon(p2, geom); - const isCategory = !p2.setTags; - const drawPoint = false; - const drawVertex = picon !== null && geom === "vertex"; - const drawLine = picon && geom === "line" && !isFallback && !isCategory; - const drawArea = picon && geom === "area" && !isFallback && !isCategory; - const drawRoute = picon && geom === "route"; - const isFramed = drawVertex || drawArea || drawLine || drawRoute || isCategory; - let tags = !isCategory ? p2.setTags({}, geom) : {}; - for (let k2 in tags) { - if (tags[k2] === "*") { - tags[k2] = "yes"; + 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 { + errEditor = osmoseEditor; + } + 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(); } } - let tagClasses = svgTagClasses().getClassesString(tags, ""); - let selection2 = select_default2(this); - let container = selection2.selectAll(".preset-icon-container").data([0]); - container = container.enter().append("div").attr("class", "preset-icon-container").merge(container); - container.classed("showing-img", !!imageURL).classed("fallback", isFallback); - renderCategoryBorder(container, isCategory && p2); - renderPointBorder(container, drawPoint); - renderCircleFill(container, drawVertex); - renderSquareFill(container, drawArea, tagClasses); - renderLine(container, drawLine, tagClasses); - renderRoute(container, drawRoute, p2); - renderSvgIcon(container, picon, geom, isFramed, isCategory, tagClasses); - renderImageIcon(container, imageURL); + 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([]); + } + }); } - presetIcon.preset = function(val) { - if (!arguments.length) return _preset; - _preset = utilFunctor(val); - return presetIcon; + sidebar.showPresetList = function() { }; - presetIcon.geometry = function(val) { - if (!arguments.length) return _geometry; - _geometry = utilFunctor(val); - return presetIcon; + sidebar.hover = function() { }; - return presetIcon; + 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; } + var init_sidebar = __esm({ + "modules/ui/sidebar.js"() { + "use strict"; + init_throttle(); + init_src8(); + init_src5(); + init_array3(); + init_util(); + init_osm(); + init_services(); + init_data_editor(); + init_feature_list(); + init_inspector(); + init_keepRight_editor(); + init_osmose_editor(); + init_note_editor(); + init_localizer(); + } + }); - // modules/ui/sections/feature_type.js - function uiSectionFeatureType(context) { - var dispatch14 = dispatch_default("choose"); - var _entityIDs = []; - var _presets = []; - var _tagReference; - var section = uiSection("feature-type", context).label(() => _t.append("inspector.feature_type")).disclosureContent(renderDisclosureContent); - function renderDisclosureContent(selection2) { - selection2.classed("preset-list-item", true); - selection2.classed("mixed-types", _presets.length > 1); - var presetButtonWrap = selection2.selectAll(".preset-list-button-wrap").data([0]).enter().append("div").attr("class", "preset-list-button-wrap"); - var presetButton = presetButtonWrap.append("button").attr("class", "preset-list-button preset-reset").call( - uiTooltip().title(() => _t.append("inspector.back_tooltip")).placement("bottom") - ); - presetButton.append("div").attr("class", "preset-icon-container"); - presetButton.append("div").attr("class", "label").append("div").attr("class", "label-inner"); - presetButtonWrap.append("div").attr("class", "accessory-buttons"); - var tagReferenceBodyWrap = selection2.selectAll(".tag-reference-body-wrap").data([0]); - tagReferenceBodyWrap = tagReferenceBodyWrap.enter().append("div").attr("class", "tag-reference-body-wrap").merge(tagReferenceBodyWrap); - if (_tagReference) { - selection2.selectAll(".preset-list-button-wrap .accessory-buttons").style("display", _presets.length === 1 ? null : "none").call(_tagReference.button); - tagReferenceBodyWrap.style("display", _presets.length === 1 ? null : "none").call(_tagReference.body); - } - selection2.selectAll(".preset-reset").on("click", function() { - dispatch14.call("choose", this, _presets); - }).on("pointerdown pointerup mousedown mouseup", function(d3_event) { - d3_event.preventDefault(); - d3_event.stopPropagation(); - }); - var geometries = entityGeometries(); - selection2.select(".preset-list-item button").call( - uiPresetIcon().geometry(_presets.length === 1 ? geometries.length === 1 && geometries[0] : null).preset(_presets.length === 1 ? _presets[0] : _mainPresetIndex.item("point")) - ); - var names = _presets.length === 1 ? [ - _presets[0].nameLabel(), - _presets[0].subtitleLabel() - ].filter(Boolean) : [_t.append("inspector.multiple_types")]; - var label = selection2.select(".label-inner"); - var nameparts = label.selectAll(".namepart").data(names, (d2) => d2.stringId); - nameparts.exit().remove(); - nameparts.enter().append("div").attr("class", "namepart").text("").each(function(d2) { - d2(select_default2(this)); - }); + // modules/ui/source_switch.js + var source_switch_exports = {}; + __export(source_switch_exports, { + uiSourceSwitch: () => uiSourceSwitch + }); + 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]); } - section.entityIDs = function(val) { - if (!arguments.length) return _entityIDs; - _entityIDs = val; - return section; + var sourceSwitch = function(selection2) { + selection2.append("a").attr("href", "#").call(_t.append("source_switch.live")).attr("class", "live chip").on("click", click); }; - section.presets = function(val) { - if (!arguments.length) return _presets; - if (!utilArrayIdentical(val, _presets)) { - _presets = val; - if (_presets.length === 1) { - _tagReference = uiTagReference(_presets[0].reference(), context).showing(false); - } - } - return section; + sourceSwitch.keys = function(_2) { + if (!arguments.length) return keys2; + keys2 = _2; + return sourceSwitch; }; - function entityGeometries() { - var counts = {}; - for (var i3 in _entityIDs) { - var geometry = context.graph().geometry(_entityIDs[i3]); - if (!counts[geometry]) counts[geometry] = 0; - counts[geometry] += 1; + return sourceSwitch; + } + var init_source_switch = __esm({ + "modules/ui/source_switch.js"() { + "use strict"; + init_src5(); + init_localizer(); + init_browse(); + } + }); + + // modules/ui/spinner.js + var spinner_exports = {}; + __export(spinner_exports, { + uiSpinner: () => uiSpinner + }); + 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); + }); } - return Object.keys(counts).sort(function(geom1, geom2) { - return counts[geom2] - counts[geom1]; + }; + } + var init_spinner = __esm({ + "modules/ui/spinner.js"() { + "use strict"; + } + }); + + // modules/ui/sections/privacy.js + var privacy_exports = {}; + __export(privacy_exports, { + uiSectionPrivacy: () => uiSectionPrivacy + }); + 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 utilRebind(section, dispatch14, "on"); + corePreferences.onChange("preferences.privacy.thirdpartyicons", section.reRender); + return section; } + var init_privacy = __esm({ + "modules/ui/sections/privacy.js"() { + "use strict"; + init_preferences(); + init_localizer(); + init_tooltip(); + init_icon(); + init_section(); + } + }); - // modules/ui/form_fields.js - function uiFormFields(context) { - var moreCombo = uiCombobox(context, "more-fields").minItems(1); - var _fieldsArr = []; - var _lastPlaceholder = ""; - var _state = ""; - var _klass = ""; - function formFields(selection2) { - var allowedFields = _fieldsArr.filter(function(field) { - return field.isAllowed(); - }); - var shown = allowedFields.filter(function(field) { - return field.isShown(); - }); - var notShown = allowedFields.filter(function(field) { - return !field.isShown(); - }).sort(function(a2, b2) { - return a2.universal === b2.universal ? 0 : a2.universal ? 1 : -1; - }); - var container = selection2.selectAll(".form-fields-container").data([0]); - container = container.enter().append("div").attr("class", "form-fields-container " + (_klass || "")).merge(container); - var fields = container.selectAll(".wrap-form-field").data(shown, function(d2) { - return d2.id + (d2.entityIDs ? d2.entityIDs.join() : ""); - }); - fields.exit().remove(); - var enter = fields.enter().append("div").attr("class", function(d2) { - return "wrap-form-field wrap-form-field-" + d2.safeid; - }); - fields = fields.merge(enter); - fields.order().each(function(d2) { - select_default2(this).call(d2.render); - }); - var titles = []; - var moreFields = notShown.map(function(field) { - var title = field.title(); - titles.push(title); - var terms = field.terms(); - if (field.key) terms.push(field.key); - if (field.keys) terms = terms.concat(field.keys); - return { - display: field.label(), - value: title, - title, - field, - terms - }; - }); - var placeholder = titles.slice(0, 3).join(", ") + (titles.length > 3 ? "\u2026" : ""); - var more = selection2.selectAll(".more-fields").data(_state === "hover" || moreFields.length === 0 ? [] : [0]); - more.exit().remove(); - var moreEnter = more.enter().append("div").attr("class", "more-fields").append("label"); - moreEnter.append("span").call(_t.append("inspector.add_fields")); - more = moreEnter.merge(more); - var input = more.selectAll(".value").data([0]); - input.exit().remove(); - input = input.enter().append("input").attr("class", "value").attr("type", "text").attr("placeholder", placeholder).call(utilNoAuto).merge(input); - input.call(utilGetSetValue, "").call( - moreCombo.data(moreFields).on("accept", function(d2) { - if (!d2) return; - var field = d2.field; - field.show(); - selection2.call(formFields); - field.focus(); - }) - ); - if (_lastPlaceholder !== placeholder) { - input.attr("placeholder", placeholder); - _lastPlaceholder = placeholder; + // modules/ui/splash.js + var splash_exports = {}; + __export(splash_exports, { + uiSplash: () => uiSplash + }); + function uiSplash(context) { + return (selection2) => { + if (context.history().hasRestorableChanges()) return; + let updateMessage = ""; + const sawPrivacyVersion = corePreferences("sawPrivacyVersion"); + let showSplash = !corePreferences("sawSplash"); + if (sawPrivacyVersion && sawPrivacyVersion !== context.privacyVersion) { + updateMessage = _t("splash.privacy_update"); + showSplash = true; } - } - formFields.fieldsArr = function(val) { - if (!arguments.length) return _fieldsArr; - _fieldsArr = val || []; - return formFields; - }; - formFields.state = function(val) { - if (!arguments.length) return _state; - _state = val; - return formFields; - }; - formFields.klass = function(val) { - if (!arguments.length) return _klass; - _klass = val; - return formFields; + 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"); }; - return formFields; } + var init_splash = __esm({ + "modules/ui/splash.js"() { + "use strict"; + init_preferences(); + init_file_fetcher(); + init_localizer(); + init_intro2(); + init_modal(); + init_privacy(); + } + }); - // modules/ui/sections/preset_fields.js - function uiSectionPresetFields(context) { - var section = uiSection("preset-fields", context).label(() => _t.append("inspector.fields")).disclosureContent(renderDisclosureContent); - var dispatch14 = dispatch_default("change", "revert"); - var formFields = uiFormFields(context); - var _state; - var _fieldsArr; - var _presets = []; - var _tags; - var _entityIDs; - function renderDisclosureContent(selection2) { - if (!_fieldsArr) { - var graph = context.graph(); - var geometries = Object.keys(_entityIDs.reduce(function(geoms, entityID) { - geoms[graph.entity(entityID).geometry(graph)] = true; - return geoms; - }, {})); - const loc = _entityIDs.reduce(function(extent, entityID) { - var entity = context.graph().entity(entityID); - return extent.extend(entity.extent(context.graph())); - }, geoExtent()).center(); - var presetsManager = _mainPresetIndex; - var allFields = []; - var allMoreFields = []; - var sharedTotalFields; - _presets.forEach(function(preset) { - var fields = preset.fields(loc); - var moreFields = preset.moreFields(loc); - allFields = utilArrayUnion(allFields, fields); - allMoreFields = utilArrayUnion(allMoreFields, moreFields); - if (!sharedTotalFields) { - sharedTotalFields = utilArrayUnion(fields, moreFields); + // modules/ui/status.js + var status_exports = {}; + __export(status_exports, { + uiStatus: () => uiStatus + }); + 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") { + if (!osm.authenticated()) { + 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 { + selection2.call(_t.append("osm_api_status.message.rateLimited")); + } } else { - sharedTotalFields = sharedTotalFields.filter(function(field) { - return fields.indexOf(field) !== -1 || moreFields.indexOf(field) !== -1; + 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(); + }; + } + var init_status = __esm({ + "modules/ui/status.js"() { + "use strict"; + init_throttle(); + init_localizer(); + init_icon(); + } + }); + + // modules/ui/tools/modes.js + var modes_exports = {}; + __export(modes_exports, { + uiToolDrawModes: () => uiToolDrawModes + }); + function uiToolDrawModes(context) { + var tool = { + id: "old_modes", + label: _t.append("toolbar.add_feature") + }; + var modes = [ + modeAddPoint(context, { + title: _t.append("modes.add_point.title"), + button: "point", + description: _t.append("modes.add_point.description"), + preset: _mainPresetIndex.item("point"), + key: "1" + }), + modeAddLine(context, { + title: _t.append("modes.add_line.title"), + button: "line", + description: _t.append("modes.add_line.description"), + preset: _mainPresetIndex.item("line"), + key: "2" + }), + modeAddArea(context, { + title: _t.append("modes.add_area.title"), + button: "area", + description: _t.append("modes.add_area.description"), + preset: _mainPresetIndex.item("area"), + key: "3" + }) + ]; + function enabled(_mode) { + return osmEditable(); + } + function osmEditable() { + return context.editable(); + } + modes.forEach(function(mode) { + context.keybinding().on(mode.key, function() { + if (!enabled(mode)) return; + if (mode.id === context.mode().id) { + context.enter(modeBrowse(context)); + } else { + context.enter(mode); + } + }); + }); + tool.render = function(selection2) { + var wrap2 = selection2.append("div").attr("class", "joined").style("display", "flex"); + var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true }); + context.map().on("move.modes", debouncedUpdate).on("drawn.modes", debouncedUpdate); + context.on("enter.modes", update); + update(); + function update() { + var buttons = wrap2.selectAll("button.add-button").data(modes, function(d2) { + return d2.id; }); - var sharedFields = allFields.filter(function(field) { - return sharedTotalFields.indexOf(field) !== -1; - }); - var sharedMoreFields = allMoreFields.filter(function(field) { - return sharedTotalFields.indexOf(field) !== -1; - }); - _fieldsArr = []; - sharedFields.forEach(function(field) { - if (field.matchAllGeometry(geometries)) { - _fieldsArr.push( - uiField(context, field, _entityIDs) - ); + buttons.exit().remove(); + var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) { + return d2.id + " add-button bar-button"; + }).on("click.mode-buttons", function(d3_event, d2) { + if (!enabled(d2)) return; + var currMode = context.mode().id; + if (/^draw/.test(currMode)) return; + if (d2.id === currMode) { + context.enter(modeBrowse(context)); + } else { + context.enter(d2); } + }).call( + uiTooltip().placement("bottom").title(function(d2) { + return d2.description; + }).keys(function(d2) { + return [d2.key]; + }).scrollContainer(context.container().select(".top-toolbar")) + ); + buttonsEnter.each(function(d2) { + select_default2(this).call(svgIcon("#iD-icon-" + d2.button)); }); - var singularEntity = _entityIDs.length === 1 && graph.hasEntity(_entityIDs[0]); - if (singularEntity && singularEntity.type === "node" && singularEntity.isHighwayIntersection(graph) && presetsManager.field("restrictions")) { - _fieldsArr.push( - uiField(context, presetsManager.field("restrictions"), _entityIDs) - ); + buttonsEnter.append("span").attr("class", "label").text("").each(function(mode) { + mode.title(select_default2(this)); + }); + if (buttons.enter().size() || buttons.exit().size()) { + context.ui().checkOverflow(".top-toolbar", true); } - var additionalFields = utilArrayUnion(sharedMoreFields, presetsManager.universal()); - additionalFields.sort(function(field1, field2) { - return field1.title().localeCompare(field2.title(), _mainLocalizer.localeCode()); + buttons = buttons.merge(buttonsEnter).attr("aria-disabled", function(d2) { + return !enabled(d2); + }).classed("disabled", function(d2) { + return !enabled(d2); + }).attr("aria-pressed", function(d2) { + return context.mode() && context.mode().button === d2.button; + }).classed("active", function(d2) { + return context.mode() && context.mode().button === d2.button; + }); + } + }; + return tool; + } + var init_modes = __esm({ + "modules/ui/tools/modes.js"() { + "use strict"; + init_debounce(); + init_src5(); + init_modes2(); + init_presets(); + init_localizer(); + init_svg(); + init_tooltip(); + } + }); + + // modules/ui/tools/notes.js + var notes_exports2 = {}; + __export(notes_exports2, { + uiToolNotes: () => uiToolNotes + }); + function uiToolNotes(context) { + var tool = { + id: "notes", + label: _t.append("modes.add_note.label") + }; + var mode = modeAddNote(context); + function enabled() { + return notesEnabled() && notesEditable(); + } + function notesEnabled() { + var noteLayer = context.layers().layer("notes"); + return noteLayer && noteLayer.enabled(); + } + function notesEditable() { + var mode2 = context.mode(); + return context.map().notesEditable() && mode2 && mode2.id !== "save"; + } + context.keybinding().on(mode.key, function() { + if (!enabled()) return; + if (mode.id === context.mode().id) { + context.enter(modeBrowse(context)); + } else { + context.enter(mode); + } + }); + tool.render = function(selection2) { + var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true }); + context.map().on("move.notes", debouncedUpdate).on("drawn.notes", debouncedUpdate); + context.on("enter.notes", update); + update(); + function update() { + var showNotes = notesEnabled(); + var data = showNotes ? [mode] : []; + var buttons = selection2.selectAll("button.add-button").data(data, function(d2) { + return d2.id; }); - additionalFields.forEach(function(field) { - if (sharedFields.indexOf(field) === -1 && field.matchAllGeometry(geometries)) { - _fieldsArr.push( - uiField(context, field, _entityIDs, { show: false }) - ); + buttons.exit().remove(); + var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) { + return d2.id + " add-button bar-button"; + }).on("click.notes", function(d3_event, d2) { + if (!enabled()) return; + var currMode = context.mode().id; + if (/^draw/.test(currMode)) return; + if (d2.id === currMode) { + context.enter(modeBrowse(context)); + } else { + context.enter(d2); } + }).call( + uiTooltip().placement("bottom").title(function(d2) { + return d2.description; + }).keys(function(d2) { + return [d2.key]; + }).scrollContainer(context.container().select(".top-toolbar")) + ); + buttonsEnter.each(function(d2) { + select_default2(this).call(svgIcon(d2.icon || "#iD-icon-" + d2.button)); }); - _fieldsArr.forEach(function(field) { - field.on("change", function(t2, onInput) { - dispatch14.call("change", field, _entityIDs, t2, onInput); - }).on("revert", function(keys2) { - dispatch14.call("revert", field, keys2); - }); + if (buttons.enter().size() || buttons.exit().size()) { + context.ui().checkOverflow(".top-toolbar", true); + } + buttons = buttons.merge(buttonsEnter).classed("disabled", function() { + return !enabled(); + }).attr("aria-disabled", function() { + return !enabled(); + }).classed("active", function(d2) { + return context.mode() && context.mode().button === d2.button; + }).attr("aria-pressed", function(d2) { + return context.mode() && context.mode().button === d2.button; }); } - _fieldsArr.forEach(function(field) { - field.state(_state).tags(_tags); - }); - selection2.call( - formFields.fieldsArr(_fieldsArr).state(_state).klass("grouped-items-area") - ); - } - section.presets = function(val) { - if (!arguments.length) return _presets; - if (!_presets || !val || !utilArrayIdentical(_presets, val)) { - _presets = val; - _fieldsArr = null; - } - return section; - }; - section.state = function(val) { - if (!arguments.length) return _state; - _state = val; - return section; }; - section.tags = function(val) { - if (!arguments.length) return _tags; - _tags = val; - return section; - }; - section.entityIDs = function(val) { - if (!arguments.length) return _entityIDs; - if (!val || !_entityIDs || !utilArrayIdentical(_entityIDs, val)) { - _entityIDs = val; - _fieldsArr = null; - } - return section; + tool.uninstall = function() { + context.on("enter.editor.notes", null).on("exit.editor.notes", null).on("enter.notes", null); + context.map().on("move.notes", null).on("drawn.notes", null); }; - return utilRebind(section, dispatch14, "on"); + return tool; } + var init_notes2 = __esm({ + "modules/ui/tools/notes.js"() { + "use strict"; + init_debounce(); + init_src5(); + init_modes2(); + init_localizer(); + init_svg(); + init_tooltip(); + } + }); - // modules/ui/sections/raw_member_editor.js - function uiSectionRawMemberEditor(context) { - var section = uiSection("raw-member-editor", context).shouldDisplay(function() { - if (!_entityIDs || _entityIDs.length !== 1) return false; - var entity = context.hasEntity(_entityIDs[0]); - return entity && entity.type === "relation"; - }).label(function() { - var entity = context.hasEntity(_entityIDs[0]); - if (!entity) return ""; - var gt2 = entity.members.length > _maxMembers ? ">" : ""; - var count = gt2 + entity.members.slice(0, _maxMembers).length; - return _t.append("inspector.title_count", { title: _t("inspector.members"), count }); - }).disclosureContent(renderDisclosureContent); - var taginfo = services.taginfo; - var _entityIDs; - var _maxMembers = 1e3; - function downloadMember(d3_event, d2) { - d3_event.preventDefault(); - select_default2(this).classed("loading", true); - context.loadEntity(d2.id, function() { - section.reRender(); - }); + // modules/ui/tools/save.js + var save_exports = {}; + __export(save_exports, { + uiToolSave: () => uiToolSave + }); + function uiToolSave(context) { + var tool = { + id: "save", + label: _t.append("save.title") + }; + var button = null; + var tooltipBehavior = null; + var history = context.history(); + var key = uiCmd("\u2318S"); + var _numChanges = 0; + function isSaving() { + var mode = context.mode(); + return mode && mode.id === "save"; } - function zoomToMember(d3_event, d2) { - d3_event.preventDefault(); - var entity = context.entity(d2.id); - context.map().zoomToEase(entity); - utilHighlightEntities([d2.id], true, context); + function isDisabled() { + return _numChanges === 0 || isSaving(); } - function selectMember(d3_event, d2) { + function save(d3_event) { d3_event.preventDefault(); - utilHighlightEntities([d2.id], false, context); - var entity = context.entity(d2.id); - var mapExtent = context.map().extent(); - if (!entity.intersects(mapExtent, context.graph())) { - context.map().zoomToEase(entity); + if (!context.inIntro() && !isSaving() && history.hasChanges()) { + context.enter(modeSave(context)); } - context.enter(modeSelect(context, [d2.id])); } - function changeRole(d3_event, d2) { - var oldRole = d2.role; - var newRole = context.cleanRelationRole(select_default2(this).property("value")); - if (oldRole !== newRole) { - 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 bgColor(numChanges) { + var step; + if (numChanges === 0) { + return null; + } else if (numChanges <= 50) { + step = numChanges / 50; + return rgb_default("#fff", "#ff8")(step); + } else { + step = Math.min((numChanges - 50) / 50, 1); + return rgb_default("#ff8", "#f88")(step); } } - 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 updateCount() { + var val = history.difference().summary().length; + if (val === _numChanges) return; + _numChanges = val; + if (tooltipBehavior) { + tooltipBehavior.title(() => _t.append(_numChanges > 0 ? "save.help" : "save.no_changes")).keys([key]); + } + if (button) { + button.classed("disabled", isDisabled()).style("background", bgColor(_numChanges)); + button.select("span.count").text(_numChanges); } } - 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) - }); + tool.render = function(selection2) { + tooltipBehavior = uiTooltip().placement("bottom").title(() => _t.append("save.no_changes")).keys([key]).scrollContainer(context.container().select(".top-toolbar")); + var lastPointerUpType; + button = selection2.append("button").attr("class", "save disabled bar-button").on("pointerup", function(d3_event) { + lastPointerUpType = d3_event.pointerType; + }).on("click", function(d3_event) { + save(d3_event); + if (_numChanges === 0 && (lastPointerUpType === "touch" || lastPointerUpType === "pen")) { + context.ui().flash.duration(2e3).iconName("#iD-icon-save").iconClass("disabled").label(_t.append("save.no_changes"))(); + } + lastPointerUpType = null; + }).call(tooltipBehavior); + button.call(svgIcon("#iD-icon-save")); + button.append("span").attr("class", "count").attr("aria-hidden", "true").text("0"); + updateCount(); + context.keybinding().on(key, save, true); + context.history().on("change.save", updateCount); + context.on("enter.save", function() { + if (button) { + button.classed("disabled", isDisabled()); + if (isSaving()) { + button.call(tooltipBehavior.hide); + } + } }); - 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"); + }; + tool.uninstall = function() { + context.keybinding().off(key, true); + context.history().on("change.save", null); + context.on("enter.save", null); + button = null; + tooltipBehavior = null; + }; + return tool; + } + var init_save = __esm({ + "modules/ui/tools/save.js"() { + "use strict"; + init_src8(); + init_localizer(); + init_modes2(); + init_svg(); + init_cmd(); + init_tooltip(); + } + }); + + // modules/ui/tools/sidebar_toggle.js + var sidebar_toggle_exports = {}; + __export(sidebar_toggle_exports, { + uiToolSidebarToggle: () => uiToolSidebarToggle + }); + function uiToolSidebarToggle(context) { + var tool = { + id: "sidebar_toggle", + label: _t.append("toolbar.inspect") + }; + tool.render = function(selection2) { + selection2.append("button").attr("class", "bar-button").attr("aria-label", _t("sidebar.tooltip")).on("click", function() { + context.ui().sidebar.toggle(); + }).call( + uiTooltip().placement("bottom").title(() => _t.append("sidebar.tooltip")).keys([_t("sidebar.key")]).scrollContainer(context.container().select(".top-toolbar")) + ).call(svgIcon("#iD-icon-sidebar-" + (_mainLocalizer.textDirection() === "rtl" ? "right" : "left"))); + }; + return tool; + } + var init_sidebar_toggle = __esm({ + "modules/ui/tools/sidebar_toggle.js"() { + "use strict"; + init_localizer(); + init_svg(); + init_tooltip(); + } + }); + + // modules/ui/tools/undo_redo.js + var undo_redo_exports = {}; + __export(undo_redo_exports, { + uiToolUndoRedo: () => uiToolUndoRedo + }); + function uiToolUndoRedo(context) { + var tool = { + id: "undo_redo", + label: _t.append("toolbar.undo_redo") + }; + var commands = [{ + id: "undo", + cmd: uiCmd("\u2318Z"), + action: function() { + context.undo(); + }, + annotation: function() { + return context.history().undoAnnotation(); + }, + icon: "iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo") + }, { + id: "redo", + cmd: uiCmd("\u2318\u21E7Z"), + action: function() { + context.redo(); + }, + annotation: function() { + return context.history().redoAnnotation(); + }, + icon: "iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "undo" : "redo") + }]; + function editable() { + return context.mode() && context.mode().id !== "save" && context.map().editableDataEnabled( + true + /* ignore min zoom */ + ); + } + tool.render = function(selection2) { + var tooltipBehavior = uiTooltip().placement("bottom").title(function(d2) { + return d2.annotation() ? _t.append(d2.id + ".tooltip", { action: d2.annotation() }) : _t.append(d2.id + ".nothing"); + }).keys(function(d2) { + return [d2.cmd]; + }).scrollContainer(context.container().select(".top-toolbar")); + var lastPointerUpType; + var buttons = selection2.selectAll("button").data(commands).enter().append("button").attr("class", function(d2) { + return "disabled " + d2.id + "-button bar-button"; + }).on("pointerup", function(d3_event) { + lastPointerUpType = d3_event.pointerType; + }).on("click", function(d3_event, d2) { + d3_event.preventDefault(); + var annotation = d2.annotation(); + if (editable() && annotation) { + d2.action(); + } + if (editable() && (lastPointerUpType === "touch" || lastPointerUpType === "pen")) { + var label = annotation ? _t.append(d2.id + ".tooltip", { action: annotation }) : _t.append(d2.id + ".nothing"); + context.ui().flash.duration(2e3).iconName("#" + d2.icon).iconClass(annotation ? "" : "disabled").label(label)(); + } + lastPointerUpType = null; + }).call(tooltipBehavior); + buttons.each(function(d2) { + select_default2(this).call(svgIcon("#" + d2.icon)); }); - 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; + context.keybinding().on(commands[0].cmd, function(d3_event) { + d3_event.preventDefault(); + if (editable()) commands[0].action(); + }).on(commands[1].cmd, function(d3_event) { + d3_event.preventDefault(); + if (editable()) commands[1].action(); }); - 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); - } + 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(difference2) { + if (difference2) update(); }); - 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 other2 = []; - for (var i3 = 0; i3 < data.length; i3++) { - if (data[i3].value.substring(0, value.length) === value) { - sameletter.push(data[i3]); - } else { - other2.push(data[i3]); - } + context.on("enter.undo_redo", update); + function update() { + buttons.classed("disabled", function(d2) { + return !editable() || !d2.annotation(); + }).each(function() { + var selection3 = select_default2(this); + if (!selection3.select(".tooltip.in").empty()) { + selection3.call(tooltipBehavior.updateContent); } - return sameletter.concat(other2); - } - 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); + }; + tool.uninstall = function() { + context.keybinding().off(commands[0].cmd).off(commands[1].cmd); + context.map().on("move.undo_redo", null).on("drawn.undo_redo", null); + context.history().on("change.undo_redo", null); + context.on("enter.undo_redo", null); + }; + return tool; + } + var init_undo_redo = __esm({ + "modules/ui/tools/undo_redo.js"() { + "use strict"; + init_debounce(); + init_src5(); + init_localizer(); + init_svg(); + init_cmd(); + init_tooltip(); + } + }); + + // modules/ui/tools/index.js + var tools_exports = {}; + __export(tools_exports, { + uiToolDrawModes: () => uiToolDrawModes, + uiToolNotes: () => uiToolNotes, + uiToolSave: () => uiToolSave, + uiToolSidebarToggle: () => uiToolSidebarToggle, + uiToolUndoRedo: () => uiToolUndoRedo + }); + var init_tools = __esm({ + "modules/ui/tools/index.js"() { + "use strict"; + init_modes(); + init_notes2(); + init_save(); + init_sidebar_toggle(); + init_undo_redo(); + } + }); + + // modules/ui/top_toolbar.js + var top_toolbar_exports = {}; + __export(top_toolbar_exports, { + uiTopToolbar: () => uiTopToolbar + }); + function uiTopToolbar(context) { + var sidebarToggle = uiToolSidebarToggle(context), modes = uiToolDrawModes(context), notes = uiToolNotes(context), undoRedo = uiToolUndoRedo(context), save = uiToolSave(context); + function notesEnabled() { + var noteLayer = context.layers().layer("notes"); + return noteLayer && noteLayer.enabled(); + } + function topToolbar(bar) { + bar.on("wheel.topToolbar", function(d3_event) { + if (!d3_event.deltaX) { + bar.node().scrollLeft += d3_event.deltaY; + } + }); + var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true }); + context.layers().on("change.topToolbar", debouncedUpdate); + update(); + function update() { + var tools = [ + sidebarToggle, + "spacer", + modes + ]; + tools.push("spacer"); + if (notesEnabled()) { + tools = tools.concat([notes, "spacer"]); + } + tools = tools.concat([undoRedo, save]); + var toolbarItems = bar.selectAll(".toolbar-item").data(tools, function(d2) { + return d2.id || d2; + }); + toolbarItems.exit().each(function(d2) { + if (d2.uninstall) { + d2.uninstall(); + } + }).remove(); + var itemsEnter = toolbarItems.enter().append("div").attr("class", function(d2) { + var classes = "toolbar-item " + (d2.id || d2).replace("_", "-"); + if (d2.klass) classes += " " + d2.klass; + return classes; + }); + var actionableItems = itemsEnter.filter(function(d2) { + return d2 !== "spacer"; + }); + actionableItems.append("div").attr("class", "item-content").each(function(d2) { + select_default2(this).call(d2.render, bar); + }); + actionableItems.append("div").attr("class", "item-label").each(function(d2) { + d2.label(select_default2(this)); + }); } } - section.entityIDs = function(val) { - if (!arguments.length) return _entityIDs; - _entityIDs = val; - return section; - }; - return section; + return topToolbar; } + var init_top_toolbar = __esm({ + "modules/ui/top_toolbar.js"() { + "use strict"; + init_src5(); + init_debounce(); + init_tools(); + } + }); - // 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); + // modules/ui/version.js + var version_exports = {}; + __export(version_exports, { + uiVersion: () => uiVersion + }); + 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/releases/tag/v${currVersion}`).call(svgIcon("#maki-gift")).call( + uiTooltip().title(() => _t.append("version.whats_new", { version: currVersion })).placement("top").scrollContainer(context.container().select(".main-footer-wrap")) + ); } - return graph; }; } + var sawVersion, isNewVersion, isNewUser; + var init_version = __esm({ + "modules/ui/version.js"() { + "use strict"; + init_preferences(); + init_localizer(); + init_icon(); + init_tooltip(); + sawVersion = null; + isNewVersion = false; + isNewUser = false; + } + }); - // 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; - const recentlyAdded = /* @__PURE__ */ new Set(); - 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; + // modules/ui/zoom.js + var zoom_exports = {}; + __export(zoom_exports, { + uiZoom: () => uiZoom + }); + 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 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; - }); - const existingRelations = memberships.filter((membership2) => !recentlyAdded.has(membership2.relation.id)).map((membership2) => __spreadProps(__spreadValues({}, membership2), { - // We only sort relations that were not added just now. - // Sorting uses the same label as shown in the UI. - // If the label is not unique, the relation ID ensures - // that the sort order is still stable. - _sortKey: [ - baseDisplayValue(membership2.relation), - membership2.relation.id - ].join("-") - })).sort((a2, b2) => { - return a2._sortKey.localeCompare( - b2._sortKey, - _mainLocalizer.localeCodes(), - { numeric: true } - ); - }); - const newlyAddedRelations = memberships.filter((membership2) => recentlyAdded.has(membership2.relation.id)); - return [ - // the sorted relations come first - ...existingRelations, - // then the ones that were just added from this panel - ...newlyAddedRelations - ]; + function zoomOut(d3_event) { + if (d3_event.shiftKey) return; + d3_event.preventDefault(); + context.map().zoomOut(); } - function selectRelation(d3_event, d2) { + function zoomInFurther(d3_event) { + if (d3_event.shiftKey) return; d3_event.preventDefault(); - utilHighlightEntities([d2.relation.id], false, context); - context.enter(modeSelect(context, [d2.relation.id])); + context.map().zoomInFurther(); } - function zoomToRelation(d3_event, d2) { + function zoomOutFurther(d3_event) { + if (d3_event.shiftKey) return; d3_event.preventDefault(); - var entity = context.entity(d2.relation.id); - context.map().zoomToEase(entity); - utilHighlightEntities([d2.relation.id], true, context); + context.map().zoomOutFurther(); } - 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; + 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]; }); - 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) { - _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); + 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); } - return graph; - }; + }); } - if (d2.relation) { - recentlyAdded.add(d2.relation.id); - context.perform( - actionAddMembers(d2.relation.id, _entityIDs, role), - _t("operations.add_member.annotation", { - n: _entityIDs.length - }) - ); - context.validator().validate(); + updateButtonStates(); + context.map().on("move.uiZoom", updateButtonStates); + }; + } + var init_zoom3 = __esm({ + "modules/ui/zoom.js"() { + "use strict"; + init_src5(); + init_localizer(); + init_icon(); + init_cmd(); + init_tooltip(); + init_keybinding(); + } + }); + + // modules/ui/zoom_to_selection.js + var zoom_to_selection_exports = {}; + __export(zoom_to_selection_exports, { + uiZoomToSelection: () => uiZoomToSelection + }); + function uiZoomToSelection(context) { + function isDisabled() { + var mode = context.mode(); + return !mode || !mode.zoomToSelected; + } + var _lastPointerUpType; + function pointerup(d3_event) { + _lastPointerUpType = d3_event.pointerType; + } + function click(d3_event) { + d3_event.preventDefault(); + if (isDisabled()) { + if (_lastPointerUpType === "touch" || _lastPointerUpType === "pen") { + context.ui().flash.duration(2e3).iconName("#iD-icon-framed-dot").iconClass("disabled").label(_t.append("inspector.zoom_to.no_selection"))(); + } } 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)); + var mode = context.mode(); + if (mode && mode.zoomToSelected) { + mode.zoomToSelected(); + } } + _lastPointerUpType = null; } - 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(); - }); + return function(selection2) { + var tooltipBehavior = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(function() { + if (isDisabled()) { + return _t.append("inspector.zoom_to.no_selection"); + } + return _t.append("inspector.zoom_to.title"); + }).keys([_t("inspector.zoom_to.key")]); + var button = selection2.append("button").on("pointerup", pointerup).on("click", click).call(svgIcon("#iD-icon-framed-dot", "light")).call(tooltipBehavior); + function setEnabledState() { + button.classed("disabled", isDisabled()); + if (!button.select(".tooltip.in").empty()) { + button.call(tooltipBehavior.updateContent); + } + } + context.on("enter.uiZoomToSelection", setEnabledState); + setEnabledState(); + }; + } + var init_zoom_to_selection = __esm({ + "modules/ui/zoom_to_selection.js"() { + "use strict"; + init_localizer(); + init_tooltip(); + init_icon(); } - 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(); + }); + + // modules/ui/pane.js + var pane_exports = {}; + __export(pane_exports, { + uiPane: () => uiPane + }); + function uiPane(id2, context) { + var _key; + var _label = ""; + var _description = ""; + var _iconName = ""; + var _sections; + var _paneSelection = select_default2(null); + var _paneTooltip; + var pane = { + id: id2 + }; + pane.label = function(val) { + if (!arguments.length) return _label; + _label = val; + return pane; + }; + pane.key = function(val) { + if (!arguments.length) return _key; + _key = val; + return pane; + }; + pane.description = function(val) { + if (!arguments.length) return _description; + _description = val; + return pane; + }; + pane.iconName = function(val) { + if (!arguments.length) return _iconName; + _iconName = val; + return pane; + }; + pane.sections = function(val) { + if (!arguments.length) return _sections; + _sections = val; + return pane; + }; + pane.selection = function() { + return _paneSelection; + }; + function hidePane() { + context.ui().togglePanes(); } - 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 (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); - }; + pane.togglePane = function(d3_event) { + if (d3_event) d3_event.preventDefault(); + _paneTooltip.hide(); + context.ui().togglePanes(!_paneSelection.classed("shown") ? _paneSelection : void 0); + }; + pane.renderToggleButton = function(selection2) { + if (!_paneTooltip) { + _paneTooltip = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(() => _description).keys([_key]); } - 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) - }); - } 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({ - relation: entity, - value, - display: baseDisplayLabel(entity) - }); - }); - 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; - }); + selection2.append("button").on("click", pane.togglePane).call(svgIcon("#" + _iconName, "light")).call(_paneTooltip); + }; + pane.renderContent = function(selection2) { + if (_sections) { + _sections.forEach(function(section) { + selection2.call(section.render); }); } - result.forEach(function(obj) { - obj.title = obj.value; - }); - result.unshift(newRelation); - callback(result); + }; + pane.renderPane = function(selection2) { + _paneSelection = selection2.append("div").attr("class", "fillL map-pane hide " + id2 + "-pane").attr("pane", id2); + 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); + } + }; + return pane; + } + var init_pane = __esm({ + "modules/ui/pane.js"() { + "use strict"; + init_src5(); + init_icon(); + init_localizer(); + init_tooltip(); + } + }); + + // modules/ui/sections/background_display_options.js + var background_display_options_exports = {}; + __export(background_display_options_exports, { + uiSectionBackgroundDisplayOptions: () => uiSectionBackgroundDisplayOptions + }); + function uiSectionBackgroundDisplayOptions(context) { + var section = uiSection("background-display-options", context).label(() => _t.append("background.display_options")).disclosureContent(renderDisclosureContent); + var _storedOpacity = corePreferences("background-opacity"); + var _minVal = 0; + var _maxVal = 3; + var _sliders = ["brightness", "contrast", "saturation", "sharpness"]; + var _options = { + brightness: _storedOpacity !== null ? +_storedOpacity : 1, + contrast: 1, + saturation: 1, + sharpness: 1 + }; + function clamp3(x2, min3, max3) { + return Math.max(min3, Math.min(x2, max3)); } - function baseDisplayValue(entity) { - const graph = context.graph(); - var matched = _mainPresetIndex.match(entity, graph); - var presetName = matched && matched.name() || _t("inspector.relation"); - var entityName = utilDisplayName(entity) || ""; - return presetName + " " + entityName; + function updateValue(d2, val) { + val = clamp3(val, _minVal, _maxVal); + _options[d2] = val; + context.background()[d2](val); + if (d2 === "brightness") { + corePreferences("background-opacity", val); + } + section.reRender(); } 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 container = selection2.selectAll(".display-options-container").data([0]); + var containerEnter = container.enter().append("div").attr("class", "display-options-container controls-list"); + var slidersEnter = containerEnter.selectAll(".display-control").data(_sliders).enter().append("label").attr("class", function(d2) { + return "display-control display-control-" + d2; }); - var labelEnter = itemsEnter.append("label").attr("class", "field-label").attr("for", function(d2) { - return d2.domId; + slidersEnter.html(function(d2) { + return _t.html("background." + d2); + }).append("span").attr("class", function(d2) { + return "display-option-value display-option-value-" + d2; }); - 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"); + var sildersControlEnter = slidersEnter.append("div").attr("class", "control-wrap"); + sildersControlEnter.append("input").attr("class", function(d2) { + return "display-option-input display-option-input-" + d2; + }).attr("type", "range").attr("min", _minVal).attr("max", _maxVal).attr("step", "0.01").on("input", function(d3_event, d2) { + var val = select_default2(this).property("value"); + if (!val && d3_event && d3_event.target) { + val = d3_event.target.value; + } + updateValue(d2, val); }); - labelLink.append("span").attr("class", "member-entity-name").classed("has-colour", (d2) => d2.relation.tags.colour && isColourValid(d2.relation.tags.colour)).style("border-color", (d2) => d2.relation.tags.colour).html(function(d2) { - const matched = _mainPresetIndex.match(d2.relation, context.graph()); - return utilDisplayName(d2.relation, matched.suggestion); + sildersControlEnter.append("button").attr("title", function(d2) { + return `${_t("background.reset")} ${_t("background." + d2)}`; + }).attr("class", function(d2) { + return "display-option-reset display-option-reset-" + d2; + }).on("click", function(d3_event, d2) { + if (d3_event.button !== 0) return; + updateValue(d2, 1); + }).call(svgIcon("#iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo"))); + containerEnter.append("a").attr("class", "display-option-resetlink").attr("role", "button").attr("href", "#").call(_t.append("background.reset_all")).on("click", function(d3_event) { + d3_event.preventDefault(); + for (var i3 = 0; i3 < _sliders.length; i3++) { + updateValue(_sliders[i3], 1); + } }); - 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)); + container = containerEnter.merge(container); + container.selectAll(".display-option-input").property("value", function(d2) { + return _options[d2]; }); - 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(); + container.selectAll(".display-option-value").text(function(d2) { + return Math.floor(_options[d2] * 100) + "%"; }); - 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", function(d2) { - this.blur(); - acceptEntity.call(this, d2); - }).on("cancel", cancelEntity) - ); - 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(); + container.selectAll(".display-option-reset").classed("disabled", function(d2) { + return _options[d2] === 1; }); - 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 other2 = []; - for (var i3 = 0; i3 < data.length; i3++) { - if (data[i3].value.substring(0, value.length) === value) { - sameletter.push(data[i3]); - } else { - other2.push(data[i3]); - } - } - return sameletter.concat(other2); - } - 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); + if (containerEnter.size() && _options.brightness !== 1) { + context.background().brightness(_options.brightness); } } - section.entityIDs = function(val) { - if (!arguments.length) return _entityIDs; - const didChange = _entityIDs.join(",") !== val.join(","); - _entityIDs = val; - _showBlank = false; - if (didChange) { - recentlyAdded.clear(); - } - return section; - }; return section; } + var init_background_display_options = __esm({ + "modules/ui/sections/background_display_options.js"() { + "use strict"; + init_src5(); + init_preferences(); + init_localizer(); + init_icon(); + init_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(difference2) { - if (difference2) { - section.reRender(); + // modules/ui/settings/custom_background.js + var custom_background_exports = {}; + __export(custom_background_exports, { + uiSettingsCustomBackground: () => uiSettingsCustomBackground + }); + function uiSettingsCustomBackground() { + var dispatch14 = dispatch_default("change"); + function render(selection2) { + var _origSettings = { + template: corePreferences("background-custom-template") + }; + var _currSettings = { + template: corePreferences("background-custom-template") + }; + 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")); + var textSection = modal.select(".modal-section.message-text"); + var instructions = `${_t.html("settings.custom_background.instructions.info")} + +#### ${_t.html("settings.custom_background.instructions.wms.tokens_label")} +* ${_t.html("settings.custom_background.instructions.wms.tokens.proj")} +* ${_t.html("settings.custom_background.instructions.wms.tokens.wkid")} +* ${_t.html("settings.custom_background.instructions.wms.tokens.dimensions")} +* ${_t.html("settings.custom_background.instructions.wms.tokens.bbox")} + +#### ${_t.html("settings.custom_background.instructions.tms.tokens_label")} +* ${_t.html("settings.custom_background.instructions.tms.tokens.xyz")} +* ${_t.html("settings.custom_background.instructions.tms.tokens.flipped_y")} +* ${_t.html("settings.custom_background.instructions.tms.tokens.switch")} +* ${_t.html("settings.custom_background.instructions.tms.tokens.quadtile")} +* ${_t.html("settings.custom_background.instructions.tms.tokens.scale_factor")} + +#### ${_t.html("settings.custom_background.instructions.example")} +\`${example}\``; + textSection.append("div").attr("class", "instructions-template").html(marked(instructions)); + textSection.append("textarea").attr("class", "field-template").attr("placeholder", _t("settings.custom_background.template.placeholder")).call(utilNoAuto).property("value", _currSettings.template); + var buttonSection = modal.select(".modal-section.buttons"); + buttonSection.insert("button", ".ok-button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel")); + buttonSection.select(".cancel-button").on("click.cancel", clickCancel); + buttonSection.select(".ok-button").attr("disabled", isSaveDisabled).on("click.save", clickSave); + function isSaveDisabled() { + return null; } - }); - 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 clickCancel() { + textSection.select(".field-template").property("value", _origSettings.template); + corePreferences("background-custom-template", _origSettings.template); + this.blur(); + modal.close(); + } + function clickSave() { + _currSettings.template = textSection.select(".field-template").property("value"); + corePreferences("background-custom-template", _currSettings.template); + this.blur(); + modal.close(); + dispatch14.call("change", this, _currSettings); } } + return utilRebind(render, dispatch14, "on"); + } + var init_custom_background = __esm({ + "modules/ui/settings/custom_background.js"() { + "use strict"; + init_src4(); + init_marked_esm(); + init_preferences(); + init_localizer(); + init_confirm(); + init_util(); + } + }); + + // modules/ui/sections/background_list.js + var background_list_exports = {}; + __export(background_list_exports, { + uiSectionBackgroundList: () => uiSectionBackgroundList + }); + function uiSectionBackgroundList(context) { + var _backgroundList = select_default2(null); + var _customSource = context.background().findSource("custom"); + var _settingsCustomBackground = uiSettingsCustomBackground(context).on("change", customChanged); + var section = uiSection("background-list", context).label(() => _t.append("background.backgrounds")).disclosureContent(renderDisclosureContent); + function previousBackgroundID() { + return corePreferences("background-last-used-toggle"); + } 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); - }); + var container = selection2.selectAll(".layer-background-list").data([0]); + _backgroundList = container.enter().append("ul").attr("class", "layer-list layer-background-list").attr("dir", "auto").merge(container); + var bgExtrasListEnter = selection2.selectAll(".bg-extras-list").data([0]).enter().append("ul").attr("class", "layer-list bg-extras-list"); + var minimapLabelEnter = bgExtrasListEnter.append("li").attr("class", "minimap-toggle-item").append("label").call( + uiTooltip().title(() => _t.append("background.minimap.tooltip")).keys([_t("background.minimap.key")]).placement("top") + ); + minimapLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) { + d3_event.preventDefault(); + uiMapInMap.toggle(); }); - 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()); + minimapLabelEnter.append("span").call(_t.append("background.minimap.description")); + var panelLabelEnter = bgExtrasListEnter.append("li").attr("class", "background-panel-toggle-item").append("label").call( + uiTooltip().title(() => _t.append("background.panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.background.key"))]).placement("top") + ); + panelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) { + d3_event.preventDefault(); + context.ui().info.toggle("background"); }); - items.selectAll(".entity-type").text(function(entity) { - return _mainPresetIndex.match(entity, context.graph()).name(); + panelLabelEnter.append("span").call(_t.append("background.panel.description")); + var locPanelLabelEnter = bgExtrasListEnter.append("li").attr("class", "location-panel-toggle-item").append("label").call( + uiTooltip().title(() => _t.append("background.location_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.location.key"))]).placement("top") + ); + locPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) { + d3_event.preventDefault(); + context.ui().info.toggle("location"); }); - items.selectAll(".entity-name").text(function(d2) { - var entity = context.entity(d2.id); - return utilDisplayName(entity); + locPanelLabelEnter.append("span").call(_t.append("background.location_panel.description")); + selection2.selectAll(".imagery-faq").data([0]).enter().append("div").attr("class", "imagery-faq").append("a").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).attr("href", "https://github.com/openstreetmap/iD/blob/develop/FAQ.md#how-can-i-report-an-issue-with-background-imagery").append("span").call(_t.append("background.imagery_problem_faq")); + _backgroundList.call(drawListItems, "radio", function(d3_event, d2) { + chooseBackground(d2); + }, function(d2) { + return !d2.isHidden() && !d2.overlay; }); } - 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); + function setTooltips(selection2) { + selection2.each(function(d2, i3, nodes) { + var item = select_default2(this).select("label"); + var span = item.select("span"); + var placement = i3 < nodes.length / 2 ? "bottom" : "top"; + var hasDescription = d2.hasDescription(); + var isOverflowing = span.property("clientWidth") !== span.property("scrollWidth"); + item.call(uiTooltip().destroyAny); + if (d2.id === previousBackgroundID()) { + item.call( + uiTooltip().placement(placement).title(() => _t.append("background.switch")).keys([uiCmd("\u2318" + _t("background.key"))]) + ); + } else if (hasDescription || isOverflowing) { + item.call( + uiTooltip().placement(placement).title(() => hasDescription ? d2.description() : d2.label()) + ); } - body.call(section.render); }); - 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); - } - } - } - 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_equal9.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 j2 in keys2) { - var key = keys2[j2]; - 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_equal9.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(); + function drawListItems(layerList, type2, change, filter2) { + var sources = context.background().sources(context.map().extent(), context.map().zoom(), true).filter(filter2).sort(function(a2, b2) { + return a2.best() && !b2.best() ? -1 : b2.best() && !a2.best() ? 1 : descending(a2.area(), b2.area()) || ascending(a2.name(), b2.name()) || 0; + }); + var layerLinks = layerList.selectAll("li").data(sources, function(d2, i3) { + return d2.id + "---" + i3; + }); + layerLinks.exit().remove(); + var enter = layerLinks.enter().append("li").classed("layer-custom", function(d2) { + return d2.id === "custom"; + }).classed("best", function(d2) { + return d2.best(); + }); + var label = enter.append("label"); + label.append("input").attr("type", type2).attr("name", "background-layer").attr("value", function(d2) { + return d2.id; + }).on("change", change); + label.append("span").each(function(d2) { + d2.label()(select_default2(this)); + }); + enter.filter(function(d2) { + return d2.id === "custom"; + }).append("button").attr("class", "layer-browse").call( + uiTooltip().title(() => _t.append("settings.custom_background.tooltip")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left") + ).on("click", function(d3_event) { + d3_event.preventDefault(); + editCustom(); + }).call(svgIcon("#iD-icon-more")); + enter.filter(function(d2) { + return d2.best(); + }).append("div").attr("class", "best").call( + uiTooltip().title(() => _t.append("background.best_imagery")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left") + ).append("span").text("\u2605"); + layerList.call(updateLayerSelections); } - 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; + function updateLayerSelections(selection2) { + function active(d2) { + return context.background().showsLayer(d2); } - 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; + selection2.selectAll("li").classed("active", active).classed("switch", function(d2) { + return d2.id === previousBackgroundID(); + }).call(setTooltips).selectAll("input").property("checked", active); + } + function chooseBackground(d2) { + if (d2.id === "custom" && !d2.template()) { + return editCustom(); } - entityEditor.presets(matches); + var previousBackground = context.background().baseLayerSource(); + corePreferences("background-last-used-toggle", previousBackground.id); + corePreferences("background-last-used", d2.id); + context.background().baseLayerSource(d2); } - entityEditor.presets = function(val) { - if (!arguments.length) return _activePresets; - if (!utilArrayIdentical(val, _activePresets)) { - _activePresets = val; + function customChanged(d2) { + if (d2 && d2.template) { + _customSource.template(d2.template); + chooseBackground(_customSource); + } else { + _customSource.template(""); + chooseBackground(context.background().findSource("none")); } - return entityEditor; - }; - return utilRebind(entityEditor, dispatch14, "on"); + } + function editCustom() { + context.container().call(_settingsCustomBackground); + } + context.background().on("change.background_list", function() { + _backgroundList.call(updateLayerSelections); + }); + context.map().on( + "move.background_list", + debounce_default(function() { + window.requestIdleCallback(section.reRender); + }, 1e3) + ); + return section; } + var init_background_list = __esm({ + "modules/ui/sections/background_list.js"() { + "use strict"; + init_debounce(); + init_src(); + init_src5(); + init_preferences(); + init_localizer(); + init_tooltip(); + init_icon(); + init_cmd(); + init_custom_background(); + init_map_in_map(); + init_section(); + } + }); - // 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")); - 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-close")); - 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(); - } + // modules/ui/sections/background_offset.js + var background_offset_exports = {}; + __export(background_offset_exports, { + uiSectionBackgroundOffset: () => uiSectionBackgroundOffset + }); + function uiSectionBackgroundOffset(context) { + var section = uiSection("background-offset", context).label(() => _t.append("background.fix_misalignment")).disclosureContent(renderDisclosureContent).expandedByDefault(false); + var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse"; + var _directions = [ + ["top", [0, -0.5]], + ["left", [-0.5, 0]], + ["right", [0.5, 0]], + ["bottom", [0, 0.5]] + ]; + function updateValue() { + var meters = geoOffsetToMeters(context.background().offset()); + var x2 = +meters[0].toFixed(2); + var y2 = +meters[1].toFixed(2); + context.container().selectAll(".nudge-inner-rect").select("input").classed("error", false).property("value", x2 + ", " + y2); + context.container().selectAll(".nudge-reset").classed("disabled", function() { + return x2 === 0 && y2 === 0; + }); + } + function resetOffset() { + context.background().offset([0, 0]); + updateValue(); + } + function nudge(d2) { + context.background().nudge(d2, context.map().zoom()); + updateValue(); + } + function inputOffset() { + var input = select_default2(this); + var d2 = input.node().value; + if (d2 === "") return resetOffset(); + d2 = d2.replace(/;/g, ",").split(",").map(function(n3) { + return !isNaN(n3) && n3; + }); + if (d2.length !== 2 || !d2[0] || !d2[1]) { + input.classed("error", true); + return; } - 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); - }); - } + context.background().offset(geoMetersToOffset(d2)); + updateValue(); + } + function dragOffset(d3_event) { + if (d3_event.button !== 0) return; + var origin = [d3_event.clientX, d3_event.clientY]; + var pointerId = d3_event.pointerId || "mouse"; + context.container().append("div").attr("class", "nudge-surface"); + select_default2(window).on(_pointerPrefix + "move.drag-bg-offset", pointermove).on(_pointerPrefix + "up.drag-bg-offset", pointerup); + if (_pointerPrefix === "pointer") { + select_default2(window).on("pointercancel.drag-bg-offset", pointerup); } - 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); + function pointermove(d3_event2) { + if (pointerId !== (d3_event2.pointerId || "mouse")) return; + var latest = [d3_event2.clientX, d3_event2.clientY]; + var d2 = [ + -(origin[0] - latest[0]) / 4, + -(origin[1] - latest[1]) / 4 + ]; + origin = latest; + nudge(d2); } - 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_feature_type")).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); + function pointerup(d3_event2) { + if (pointerId !== (d3_event2.pointerId || "mouse")) return; + if (d3_event2.button !== 0) return; + context.container().selectAll(".nudge-surface").remove(); + select_default2(window).on(".drag-bg-offset", null); } - 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; + function renderDisclosureContent(selection2) { + var container = selection2.selectAll(".nudge-container").data([0]); + var containerEnter = container.enter().append("div").attr("class", "nudge-container"); + containerEnter.append("div").attr("class", "nudge-instructions").call(_t.append("background.offset")); + var nudgeWrapEnter = containerEnter.append("div").attr("class", "nudge-controls-wrap"); + var nudgeEnter = nudgeWrapEnter.append("div").attr("class", "nudge-outer-rect").on(_pointerPrefix + "down", dragOffset); + nudgeEnter.append("div").attr("class", "nudge-inner-rect").append("input").attr("type", "text").attr("aria-label", _t("background.offset_label")).on("change", inputOffset); + nudgeWrapEnter.append("div").selectAll("button").data(_directions).enter().append("button").attr("title", function(d2) { + return _t(`background.nudge.${d2[0]}`); + }).attr("class", function(d2) { + return d2[0] + " nudge"; + }).on("click", function(d3_event, d2) { + nudge(d2[1]); }); - 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"]) { + nudgeWrapEnter.append("button").attr("title", _t("background.reset")).attr("class", "nudge-reset disabled").on("click", function(d3_event) { 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(); - } - 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 { - 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"); - } - 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 { - 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"); - } - }; - item.preset = preset; - return item; + resetOffset(); + }).call(svgIcon("#iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo"))); + updateValue(); } - 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); - }; - item.help = function(d3_event) { - d3_event.stopPropagation(); - item.reference.toggle(); - }; - item.preset = preset; - item.reference = uiTagReference(preset.reference(), context); - return item; + context.background().on("change.backgroundOffset-update", updateValue); + return section; + } + var init_background_offset = __esm({ + "modules/ui/sections/background_offset.js"() { + "use strict"; + init_src5(); + init_localizer(); + init_geo2(); + init_icon(); + init_section(); } - 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; - } - 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") + }); + + // modules/ui/sections/overlay_list.js + var overlay_list_exports = {}; + __export(overlay_list_exports, { + uiSectionOverlayList: () => uiSectionOverlayList + }); + function uiSectionOverlayList(context) { + var section = uiSection("overlay-list", context).label(() => _t.append("background.overlays")).disclosureContent(renderDisclosureContent); + var _overlayList = select_default2(null); + function setTooltips(selection2) { + selection2.each(function(d2, i3, nodes) { + var item = select_default2(this).select("label"); + var span = item.select("span"); + var placement = i3 < nodes.length / 2 ? "bottom" : "top"; + var description = d2.description(); + var isOverflowing = span.property("clientWidth") !== span.property("scrollWidth"); + item.call(uiTooltip().destroyAny); + if (description || isOverflowing) { + item.call( + uiTooltip().placement(placement).title(() => description || d2.name()) ); } }); } - 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()); - }); - presetList.presets(presets); + function updateLayerSelections(selection2) { + function active(d2) { + return context.background().showsLayer(d2); } - 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"; - } - if (!counts[geometry]) counts[geometry] = 0; - counts[geometry] += 1; + selection2.selectAll("li").classed("active", active).call(setTooltips).selectAll("input").property("checked", active); + } + function chooseOverlay(d3_event, d2) { + d3_event.preventDefault(); + context.background().toggleOverlayLayer(d2); + _overlayList.call(updateLayerSelections); + document.activeElement.blur(); + } + function drawListItems(layerList, type2, change, filter2) { + var sources = context.background().sources(context.map().extent(), context.map().zoom(), true).filter(filter2); + var layerLinks = layerList.selectAll("li").data(sources, function(d2) { + return d2.name(); + }); + layerLinks.exit().remove(); + var enter = layerLinks.enter().append("li"); + var label = enter.append("label"); + label.append("input").attr("type", type2).attr("name", "layers").on("change", change); + label.append("span").each(function(d2) { + d2.label()(select_default2(this)); + }); + layerList.selectAll("li").sort(sortSources); + layerList.call(updateLayerSelections); + function sortSources(a2, b2) { + return a2.best() && !b2.best() ? -1 : b2.best() && !a2.best() ? 1 : descending(a2.area(), b2.area()) || ascending(a2.name(), b2.name()) || 0; } - return Object.keys(counts).sort(function(geom1, geom2) { - return counts[geom2] - counts[geom1]; + } + function renderDisclosureContent(selection2) { + var container = selection2.selectAll(".layer-overlay-list").data([0]); + _overlayList = container.enter().append("ul").attr("class", "layer-list layer-overlay-list").attr("dir", "auto").merge(container); + _overlayList.call(drawListItems, "checkbox", chooseOverlay, function(d2) { + return !d2.isHidden() && d2.overlay; }); } - return utilRebind(presetList, dispatch14, "on"); + context.map().on( + "move.overlay_list", + debounce_default(function() { + window.requestIdleCallback(section.reRender); + }, 1e3) + ); + return section; } + var init_overlay_list = __esm({ + "modules/ui/sections/overlay_list.js"() { + "use strict"; + init_debounce(); + init_src(); + init_src5(); + init_localizer(); + init_tooltip(); + init_section(); + } + }); - // 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.type === "node" && 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])) - ); + // modules/ui/panes/background.js + var background_exports3 = {}; + __export(background_exports3, { + uiPaneBackground: () => uiPaneBackground + }); + function uiPaneBackground(context) { + var backgroundPane = uiPane("background", context).key(_t("background.key")).label(_t.append("background.title")).description(_t.append("background.description")).iconName("iD-icon-layers").sections([ + uiSectionBackgroundList(context), + uiSectionOverlayList(context), + uiSectionBackgroundDisplayOptions(context), + uiSectionBackgroundOffset(context) + ]); + return backgroundPane; + } + var init_background3 = __esm({ + "modules/ui/panes/background.js"() { + "use strict"; + init_localizer(); + init_pane(); + init_background_display_options(); + init_background_list(); + init_background_offset(); + init_overlay_list(); } - 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/panes/help.js + var help_exports = {}; + __export(help_exports, { + uiPaneHelp: () => uiPaneHelp + }); + function uiPaneHelp(context) { + var docKeys = [ + ["help", [ + "welcome", + "open_data_h", + "open_data", + "before_start_h", + "before_start", + "open_source_h", + "open_source", + "open_source_attribution", + "open_source_help" + ]], + ["overview", [ + "navigation_h", + "navigation_drag", + "navigation_zoom", + "features_h", + "features", + "nodes_ways" + ]], + ["editing", [ + "select_h", + "select_left_click", + "select_right_click", + "select_space", + "multiselect_h", + "multiselect", + "multiselect_shift_click", + "multiselect_lasso", + "undo_redo_h", + "undo_redo", + "save_h", + "save", + "save_validation", + "upload_h", + "upload", + "backups_h", + "backups", + "keyboard_h", + "keyboard" + ]], + ["feature_editor", [ + "intro", + "definitions", + "type_h", + "type", + "type_picker", + "fields_h", + "fields_all_fields", + "fields_example", + "fields_add_field", + "tags_h", + "tags_all_tags", + "tags_resources" + ]], + ["points", [ + "intro", + "add_point_h", + "add_point", + "add_point_finish", + "move_point_h", + "move_point", + "delete_point_h", + "delete_point", + "delete_point_command" + ]], + ["lines", [ + "intro", + "add_line_h", + "add_line", + "add_line_draw", + "add_line_continue", + "add_line_finish", + "modify_line_h", + "modify_line_dragnode", + "modify_line_addnode", + "connect_line_h", + "connect_line", + "connect_line_display", + "connect_line_drag", + "connect_line_tag", + "disconnect_line_h", + "disconnect_line_command", + "move_line_h", + "move_line_command", + "move_line_connected", + "delete_line_h", + "delete_line", + "delete_line_command" + ]], + ["areas", [ + "intro", + "point_or_area_h", + "point_or_area", + "add_area_h", + "add_area_command", + "add_area_draw", + "add_area_continue", + "add_area_finish", + "square_area_h", + "square_area_command", + "modify_area_h", + "modify_area_dragnode", + "modify_area_addnode", + "delete_area_h", + "delete_area", + "delete_area_command" + ]], + ["relations", [ + "intro", + "edit_relation_h", + "edit_relation", + "edit_relation_add", + "edit_relation_delete", + "maintain_relation_h", + "maintain_relation", + "relation_types_h", + "multipolygon_h", + "multipolygon", + "multipolygon_create", + "multipolygon_merge", + "turn_restriction_h", + "turn_restriction", + "turn_restriction_field", + "turn_restriction_editing", + "route_h", + "route", + "route_add", + "boundary_h", + "boundary", + "boundary_add" + ]], + ["operations", [ + "intro", + "intro_2", + "straighten", + "orthogonalize", + "circularize", + "move", + "rotate", + "reflect", + "continue", + "reverse", + "disconnect", + "split", + "extract", + "merge", + "delete", + "downgrade", + "copy_paste" + ]], + ["notes", [ + "intro", + "add_note_h", + "add_note", + "place_note", + "move_note", + "update_note_h", + "update_note", + "save_note_h", + "save_note" + ]], + ["imagery", [ + "intro", + "sources_h", + "choosing", + "sources", + "offsets_h", + "offset", + "offset_change" + ]], + ["streetlevel", [ + "intro", + "using_h", + "using", + "photos", + "viewer" + ]], + ["gps", [ + "intro", + "survey", + "using_h", + "using", + "tracing", + "upload" + ]], + ["qa", [ + "intro", + "tools_h", + "tools", + "issues_h", + "issues" + ]] + ]; + var headings = { + "help.help.open_data_h": 3, + "help.help.before_start_h": 3, + "help.help.open_source_h": 3, + "help.overview.navigation_h": 3, + "help.overview.features_h": 3, + "help.editing.select_h": 3, + "help.editing.multiselect_h": 3, + "help.editing.undo_redo_h": 3, + "help.editing.save_h": 3, + "help.editing.upload_h": 3, + "help.editing.backups_h": 3, + "help.editing.keyboard_h": 3, + "help.feature_editor.type_h": 3, + "help.feature_editor.fields_h": 3, + "help.feature_editor.tags_h": 3, + "help.points.add_point_h": 3, + "help.points.move_point_h": 3, + "help.points.delete_point_h": 3, + "help.lines.add_line_h": 3, + "help.lines.modify_line_h": 3, + "help.lines.connect_line_h": 3, + "help.lines.disconnect_line_h": 3, + "help.lines.move_line_h": 3, + "help.lines.delete_line_h": 3, + "help.areas.point_or_area_h": 3, + "help.areas.add_area_h": 3, + "help.areas.square_area_h": 3, + "help.areas.modify_area_h": 3, + "help.areas.delete_area_h": 3, + "help.relations.edit_relation_h": 3, + "help.relations.maintain_relation_h": 3, + "help.relations.relation_types_h": 2, + "help.relations.multipolygon_h": 3, + "help.relations.turn_restriction_h": 3, + "help.relations.route_h": 3, + "help.relations.boundary_h": 3, + "help.notes.add_note_h": 3, + "help.notes.update_note_h": 3, + "help.notes.save_note_h": 3, + "help.imagery.sources_h": 3, + "help.imagery.offsets_h": 3, + "help.streetlevel.using_h": 3, + "help.gps.using_h": 3, + "help.qa.tools_h": 3, + "help.qa.issues_h": 3 }; - 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); + var docs = docKeys.map(function(key) { + var helpkey = "help." + key[0]; + var helpPaneReplacements = { version: context.version }; + var text = key[1].reduce(function(all, part) { + var subkey = helpkey + "." + part; + var depth = headings[subkey]; + var hhh = depth ? Array(depth + 1).join("#") + " " : ""; + return all + hhh + helpHtml(subkey, helpPaneReplacements) + "\n\n"; + }, ""); + return { + title: _t.html(helpkey + ".title"), + 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"); + helpPane.renderContent = function(content) { + function clickHelp(d2, i3) { + var rtl = _mainLocalizer.textDirection() === "rtl"; + content.property("scrollTop", 0); + helpPane.selection().select(".pane-heading h2").html(d2.title); + body.html(d2.content); + body.selectAll("a").attr("target", "_blank"); + menuItems.classed("selected", function(m2) { + return m2.title === d2.title; }); - if (preset) { - entityEditor.presets([preset]); + nav.html(""); + if (rtl) { + nav.call(drawNext).call(drawPrevious); + } else { + nav.call(drawPrevious).call(drawNext); } - editorPane.call(entityEditor); - } - }; - inspector.state = function(val) { - if (!arguments.length) return _state; - _state = val; - entityEditor.state(_state); - context.container().selectAll(".field-help-body").remove(); - return inspector; - }; - inspector.entityIDs = function(val) { - if (!arguments.length) return _entityIDs; - _entityIDs = val; - return inspector; - }; - inspector.newFeature = function(val) { - if (!arguments.length) return _newFeature; - _newFeature = val; - return inspector; - }; - return inspector; - } - - // 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 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); - } - 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])); + function drawNext(selection2) { + if (i3 < docs.length - 1) { + var nextLink = selection2.append("a").attr("href", "#").attr("class", "next").on("click", function(d3_event) { + d3_event.preventDefault(); + clickHelp(docs[i3 + 1], i3 + 1); }); + nextLink.append("span").html(docs[i3 + 1].title).call(svgIcon(rtl ? "#iD-icon-backward" : "#iD-icon-forward", "inline")); } - }); - 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; + } + function drawPrevious(selection2) { + if (i3 > 0) { + var prevLink = selection2.append("a").attr("href", "#").attr("class", "previous").on("click", function(d3_event) { + d3_event.preventDefault(); + clickHelp(docs[i3 - 1], i3 - 1); + }); + prevLink.call(svgIcon(rtl ? "#iD-icon-forward" : "#iD-icon-backward", "inline")).append("span").html(docs[i3 - 1].title); } } + } + function clickWalkthrough(d3_event) { + d3_event.preventDefault(); + if (context.inIntro()) return; + context.container().call(uiIntro(context)); + context.ui().togglePanes(); + } + function clickShortcuts(d3_event) { + d3_event.preventDefault(); + context.container().call(context.ui().shortcuts, true); + } + var toc = content.append("ul").attr("class", "toc"); + var menuItems = toc.selectAll("li").data(docs).enter().append("li").append("a").attr("role", "button").attr("href", "#").html(function(d2) { + return d2.title; + }).on("click", function(d3_event, d2) { + d3_event.preventDefault(); + clickHelp(d2, docs.indexOf(d2)); }); - context.features().forceVisible(relatedEntities); - context.map().pan([0, 0]); - } - keepRightDetails.issue = function(val) { - if (!arguments.length) return _qaItem; - _qaItem = val; - return keepRightDetails; + var shortcuts = toc.append("li").attr("class", "shortcuts").call( + uiTooltip().title(() => _t.append("shortcuts.tooltip")).keys(["?"]).placement("top") + ).append("a").attr("href", "#").on("click", clickShortcuts); + shortcuts.append("div").call(_t.append("shortcuts.title")); + var walkthrough = toc.append("li").attr("class", "walkthrough").append("a").attr("href", "#").on("click", clickWalkthrough); + walkthrough.append("svg").attr("class", "logo logo-walkthrough").append("use").attr("xlink:href", "#iD-logo-walkthrough"); + walkthrough.append("div").call(_t.append("splash.walkthrough")); + var helpContent = content.append("div").attr("class", "left-content"); + var body = helpContent.append("div").attr("class", "body"); + var nav = helpContent.append("div").attr("class", "nav"); + clickHelp(docs[0], 0); }; - return keepRightDetails; + return helpPane; } + var init_help = __esm({ + "modules/ui/panes/help.js"() { + "use strict"; + init_marked_esm(); + init_icon(); + init_intro(); + init_pane(); + init_localizer(); + init_tooltip(); + init_helper(); + } + }); - // 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/ui/sections/validation_issues.js + var validation_issues_exports = {}; + __export(validation_issues_exports, { + uiSectionValidationIssues: () => uiSectionValidationIssues + }); + function uiSectionValidationIssues(id2, severity, context) { + var _issues = []; + var section = uiSection(id2, context).label(function() { + if (!_issues) return ""; + var issueCountText = _issues.length > 1e3 ? "1000+" : String(_issues.length); + return _t.append("inspector.title_count", { title: _t("issues." + severity + "s.list_title"), count: issueCountText }); + }).disclosureContent(renderDisclosureContent).shouldDisplay(function() { + return _issues && _issues.length; + }); + function getOptions() { + return { + what: corePreferences("validate-what") || "edited", + where: corePreferences("validate-where") || "all" + }; } - 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); + function reloadIssues() { + _issues = context.validator().getIssuesBySeverity(getOptions())[severity]; } - keepRightHeader.issue = function(val) { - if (!arguments.length) return _qaItem; - _qaItem = val; - return keepRightHeader; - }; - return keepRightHeader; + function renderDisclosureContent(selection2) { + var center = context.map().center(); + var graph = context.graph(); + var issues = _issues.map(function withDistance(issue) { + var extent = issue.extent(graph); + var dist = extent ? geoSphericalDistance(center, extent.center()) : 0; + return Object.assign(issue, { dist }); + }).sort(function byDistance(a2, b2) { + return a2.dist - b2.dist; + }); + issues = issues.slice(0, 1e3); + selection2.call(drawIssuesList, issues); + } + function drawIssuesList(selection2, issues) { + 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(); + var itemsEnter = items.enter().append("li").attr("class", function(d2) { + return "issue severity-" + d2.severity; + }); + var labelsEnter = itemsEnter.append("button").attr("class", "issue-label").on("click", function(d3_event, d2) { + context.validator().focusIssue(d2); + }).on("mouseover", function(d3_event, d2) { + utilHighlightEntities(d2.entityIds, true, context); + }).on("mouseout", function(d3_event, d2) { + utilHighlightEntities(d2.entityIds, false, context); + }); + var textEnter = labelsEnter.append("span").attr("class", "issue-text"); + textEnter.append("span").attr("class", "issue-icon").each(function(d2) { + var iconName = "#iD-icon-" + (d2.severity === "warning" ? "alert" : "error"); + select_default2(this).call(svgIcon(iconName)); + }); + textEnter.append("span").attr("class", "issue-message"); + items = items.merge(itemsEnter).order(); + items.selectAll(".issue-message").text("").each(function(d2) { + return d2.message(context)(select_default2(this)); + }); + } + context.validator().on("validated.uiSectionValidationIssues" + id2, function() { + window.requestIdleCallback(function() { + reloadIssues(); + section.reRender(); + }); + }); + context.map().on( + "move.uiSectionValidationIssues" + id2, + debounce_default(function() { + window.requestIdleCallback(function() { + if (getOptions().where === "visible") { + reloadIssues(); + } + section.reRender(); + }); + }, 1e3) + ); + return section; } + var init_validation_issues = __esm({ + "modules/ui/sections/validation_issues.js"() { + "use strict"; + init_debounce(); + init_src5(); + init_geo2(); + init_icon(); + init_preferences(); + init_localizer(); + init_util(); + init_section(); + } + }); - // 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); + // modules/ui/sections/validation_options.js + var validation_options_exports = {}; + __export(validation_options_exports, { + uiSectionValidationOptions: () => uiSectionValidationOptions + }); + function uiSectionValidationOptions(context) { + var section = uiSection("issues-options", context).content(renderContent); + function renderContent(selection2) { + var container = selection2.selectAll(".issues-options-container").data([0]); + container = container.enter().append("div").attr("class", "issues-options-container").merge(container); + var data = [ + { key: "what", values: ["edited", "all"] }, + { key: "where", values: ["visible", "all"] } + ]; + var options2 = container.selectAll(".issues-option").data(data, function(d2) { + return d2.key; + }); + var optionsEnter = options2.enter().append("div").attr("class", function(d2) { + return "issues-option issues-option-" + d2.key; + }); + optionsEnter.append("div").attr("class", "issues-option-title").html(function(d2) { + return _t.html("issues.options." + d2.key + ".title"); + }); + var valuesEnter = optionsEnter.selectAll("label").data(function(d2) { + return d2.values.map(function(val) { + return { value: val, key: d2.key }; + }); + }).enter().append("label"); + valuesEnter.append("input").attr("type", "radio").attr("name", function(d2) { + return "issues-option-" + d2.key; + }).attr("value", function(d2) { + return d2.value; + }).property("checked", function(d2) { + return getOptions()[d2.key] === d2.value; + }).on("change", function(d3_event, d2) { + updateOptionValue(d3_event, d2.key, d2.value); + }); + valuesEnter.append("span").html(function(d2) { + return _t.html("issues.options." + d2.key + "." + d2.value); + }); + } + function getOptions() { + return { + what: corePreferences("validate-what") || "edited", + // 'all', 'edited' + where: corePreferences("validate-where") || "all" + // 'all', 'visible' + }; + } + function updateOptionValue(d3_event, d2, val) { + if (!val && d3_event && d3_event.target) { + val = d3_event.target.value; } - 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")); + corePreferences("validate-" + d2, val); + context.validator().validate(); } - viewOnKeepRight.what = function(val) { - if (!arguments.length) return _qaItem; - _qaItem = val; - return viewOnKeepRight; - }; - return viewOnKeepRight; + return section; } + var init_validation_options = __esm({ + "modules/ui/sections/validation_options.js"() { + "use strict"; + init_preferences(); + init_localizer(); + init_section(); + } + }); - // 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/ui/sections/validation_rules.js + var validation_rules_exports = {}; + __export(validation_rules_exports, { + uiSectionValidationRules: () => uiSectionValidationRules + }); + function uiSectionValidationRules(context) { + var MINSQUARE = 0; + var MAXSQUARE = 20; + var DEFAULTSQUARE = 5; + var section = uiSection("issues-rules", context).disclosureContent(renderDisclosureContent).label(() => _t.append("issues.rules.title")); + var _ruleKeys = context.validator().getRuleKeys().filter(function(key) { + return key !== "maprules"; + }).sort(function(key1, key2) { + return _t("issues." + key1 + ".title") < _t("issues." + key2 + ".title") ? -1 : 1; + }); + function renderDisclosureContent(selection2) { + var container = selection2.selectAll(".issues-rulelist-container").data([0]); + var containerEnter = container.enter().append("div").attr("class", "issues-rulelist-container"); + containerEnter.append("ul").attr("class", "layer-list issue-rules-list"); + var ruleLinks = containerEnter.append("div").attr("class", "issue-rules-links section-footer"); + ruleLinks.append("a").attr("class", "issue-rules-link").attr("role", "button").attr("href", "#").call(_t.append("issues.disable_all")).on("click", function(d3_event) { + d3_event.preventDefault(); + context.validator().disableRules(_ruleKeys); + }); + ruleLinks.append("a").attr("class", "issue-rules-link").attr("role", "button").attr("href", "#").call(_t.append("issues.enable_all")).on("click", function(d3_event) { + d3_event.preventDefault(); + context.validator().disableRules([]); + }); + container = container.merge(containerEnter); + container.selectAll(".issue-rules-list").call(drawListItems, _ruleKeys, "checkbox", "rule", toggleRule, isRuleEnabled); } - 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); + function drawListItems(selection2, data, type2, name, change, active) { + var items = selection2.selectAll("li").data(data); + items.exit().remove(); + var enter = items.enter().append("li"); + if (name === "rule") { + enter.call( + uiTooltip().title(function(d2) { + return _t.append("issues." + d2 + ".tip"); + }).placement("top") + ); } - } - 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)); + var label = enter.append("label"); + label.append("input").attr("type", type2).attr("name", name).on("change", change); + label.append("span").html(function(d2) { + var params = {}; + if (d2 === "unsquare_way") { + params.val = { html: '' }; } + return _t.html("issues." + d2 + ".title", params); }); - 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)); + items = items.merge(enter); + items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", false); + var degStr = corePreferences("validate-square-degrees"); + if (degStr === null) { + degStr = DEFAULTSQUARE.toString(); + } + var span = items.selectAll(".square-degrees"); + var input = span.selectAll(".square-degrees-input").data([0]); + input.enter().append("input").attr("type", "number").attr("min", MINSQUARE.toString()).attr("max", MAXSQUARE.toString()).attr("step", "0.5").attr("class", "square-degrees-input").call(utilNoAuto).on("click", function(d3_event) { + d3_event.preventDefault(); + d3_event.stopPropagation(); + this.select(); + }).on("keyup", function(d3_event) { + if (d3_event.keyCode === 13) { + this.blur(); + this.select(); } - }); + }).on("blur", changeSquare).merge(input).property("value", degStr); } - keepRightEditor.error = function(val) { - if (!arguments.length) return _qaItem; - _qaItem = val; - return keepRightEditor; - }; - return utilRebind(keepRightEditor, dispatch14, "on"); + function changeSquare() { + var input = select_default2(this); + var degStr = utilGetSetValue(input).trim(); + var degNum = Number(degStr); + if (!isFinite(degNum)) { + degNum = DEFAULTSQUARE; + } else if (degNum > MAXSQUARE) { + degNum = MAXSQUARE; + } else if (degNum < MINSQUARE) { + degNum = MINSQUARE; + } + degNum = Math.round(degNum * 10) / 10; + degStr = degNum.toString(); + input.property("value", degStr); + corePreferences("validate-square-degrees", degStr); + context.validator().revalidateUnsquare(); + } + function isRuleEnabled(d2) { + return context.validator().isRuleEnabled(d2); + } + function toggleRule(d3_event, d2) { + context.validator().toggleRule(d2); + } + context.validator().on("validated.uiSectionValidationRules", function() { + window.requestIdleCallback(section.reRender); + }); + return section; } + var init_validation_rules = __esm({ + "modules/ui/sections/validation_rules.js"() { + "use strict"; + init_src5(); + init_preferences(); + init_localizer(); + init_util(); + init_tooltip(); + init_section(); + } + }); - // modules/ui/osmose_details.js - function uiOsmoseDetails(context) { - let _qaItem; - function issueString(d2, type2) { - if (!d2) return ""; - const s2 = services.osmose.getStrings(d2.itemType); - return type2 in s2 ? s2[type2] : ""; + // modules/ui/sections/validation_status.js + var validation_status_exports = {}; + __export(validation_status_exports, { + uiSectionValidationStatus: () => uiSectionValidationStatus + }); + function uiSectionValidationStatus(context) { + var section = uiSection("issues-status", context).content(renderContent).shouldDisplay(function() { + var issues = context.validator().getIssues(getOptions()); + return issues.length === 0; + }); + function getOptions() { + return { + what: corePreferences("validate-what") || "edited", + where: corePreferences("validate-where") || "all" + }; } - function osmoseDetails(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"); - if (issueString(_qaItem, "detail")) { - const div = detailsEnter.append("div").attr("class", "qa-details-subsection"); - div.append("h4").call(_t.append("QA.keepRight.detail_description")); - div.append("p").attr("class", "qa-details-description-text").html((d2) => issueString(d2, "detail")).selectAll("a").attr("rel", "noopener").attr("target", "_blank"); - } - const detailsDiv = detailsEnter.append("div").attr("class", "qa-details-subsection"); - const elemsDiv = detailsEnter.append("div").attr("class", "qa-details-subsection"); - if (issueString(_qaItem, "fix")) { - const div = detailsEnter.append("div").attr("class", "qa-details-subsection"); - div.append("h4").call(_t.append("QA.osmose.fix_title")); - div.append("p").html((d2) => issueString(d2, "fix")).selectAll("a").attr("rel", "noopener").attr("target", "_blank"); - } - if (issueString(_qaItem, "trap")) { - const div = detailsEnter.append("div").attr("class", "qa-details-subsection"); - div.append("h4").call(_t.append("QA.osmose.trap_title")); - div.append("p").html((d2) => issueString(d2, "trap")).selectAll("a").attr("rel", "noopener").attr("target", "_blank"); - } - const thisItem = _qaItem; - services.osmose.loadIssueDetail(_qaItem).then((d2) => { - if (!d2.elems || d2.elems.length === 0) return; - if (context.selectedErrorID() !== thisItem.id && context.container().selectAll(".qaItem.osmose.hover.itemId-".concat(thisItem.id)).empty()) return; - if (d2.detail) { - detailsDiv.append("h4").call(_t.append("QA.osmose.detail_title")); - detailsDiv.append("p").html((d4) => d4.detail).selectAll("a").attr("rel", "noopener").attr("target", "_blank"); - } - 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 link3 = select_default2(this); - const entityID = this.textContent; - const entity = context.hasEntity(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(d2.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) { - const preset = _mainPresetIndex.match(entity, context.graph()); - name = preset && !preset.isFallback() && preset.name(); - } - if (name) { - this.innerText = name; - } + function renderContent(selection2) { + var box = selection2.selectAll(".box").data([0]); + var boxEnter = box.enter().append("div").attr("class", "box"); + boxEnter.append("div").call(svgIcon("#iD-icon-apply", "pre-text")); + var noIssuesMessage = boxEnter.append("span"); + noIssuesMessage.append("strong").attr("class", "message"); + noIssuesMessage.append("br"); + noIssuesMessage.append("span").attr("class", "details"); + renderIgnoredIssuesReset(selection2); + setNoIssuesText(selection2); + } + function renderIgnoredIssuesReset(selection2) { + var ignoredIssues = context.validator().getIssues({ what: "all", where: "all", includeDisabledRules: true, includeIgnored: "only" }); + var resetIgnored = selection2.selectAll(".reset-ignored").data(ignoredIssues.length ? [0] : []); + resetIgnored.exit().remove(); + var resetIgnoredEnter = resetIgnored.enter().append("div").attr("class", "reset-ignored section-footer"); + resetIgnoredEnter.append("a").attr("href", "#"); + resetIgnored = resetIgnored.merge(resetIgnoredEnter); + resetIgnored.select("a").html(_t.html("inspector.title_count", { title: { html: _t.html("issues.reset_ignored") }, count: ignoredIssues.length })); + resetIgnored.on("click", function(d3_event) { + d3_event.preventDefault(); + context.validator().resetIgnoredIssues(); + }); + } + function setNoIssuesText(selection2) { + var opts = getOptions(); + function checkForHiddenIssues(cases) { + for (var type2 in cases) { + var hiddenOpts = cases[type2]; + var hiddenIssues = context.validator().getIssues(hiddenOpts); + if (hiddenIssues.length) { + selection2.select(".box .details").html("").call(_t.append( + "issues.no_issues.hidden_issues." + type2, + { count: hiddenIssues.length.toString() } + )); + return; } + } + selection2.select(".box .details").html("").call(_t.append("issues.no_issues.hidden_issues.none")); + } + var messageType; + if (opts.what === "edited" && opts.where === "visible") { + messageType = "edits_in_view"; + checkForHiddenIssues({ + elsewhere: { what: "edited", where: "all" }, + everything_else: { what: "all", where: "visible" }, + disabled_rules: { what: "edited", where: "visible", includeDisabledRules: "only" }, + everything_else_elsewhere: { what: "all", where: "all" }, + disabled_rules_elsewhere: { what: "edited", where: "all", includeDisabledRules: "only" }, + ignored_issues: { what: "edited", where: "visible", includeIgnored: "only" }, + ignored_issues_elsewhere: { what: "edited", where: "all", includeIgnored: "only" } }); - context.features().forceVisible(d2.elems); - context.map().pan([0, 0]); - }).catch((err) => { - console.log(err); - }); + } else if (opts.what === "edited" && opts.where === "all") { + messageType = "edits"; + checkForHiddenIssues({ + everything_else: { what: "all", where: "all" }, + disabled_rules: { what: "edited", where: "all", includeDisabledRules: "only" }, + ignored_issues: { what: "edited", where: "all", includeIgnored: "only" } + }); + } else if (opts.what === "all" && opts.where === "visible") { + messageType = "everything_in_view"; + checkForHiddenIssues({ + elsewhere: { what: "all", where: "all" }, + disabled_rules: { what: "all", where: "visible", includeDisabledRules: "only" }, + disabled_rules_elsewhere: { what: "all", where: "all", includeDisabledRules: "only" }, + ignored_issues: { what: "all", where: "visible", includeIgnored: "only" }, + ignored_issues_elsewhere: { what: "all", where: "all", includeIgnored: "only" } + }); + } else if (opts.what === "all" && opts.where === "all") { + messageType = "everything"; + checkForHiddenIssues({ + disabled_rules: { what: "all", where: "all", includeDisabledRules: "only" }, + ignored_issues: { what: "all", where: "all", includeIgnored: "only" } + }); + } + if (opts.what === "edited" && context.history().difference().summary().length === 0) { + messageType = "no_edits"; + } + selection2.select(".box .message").html("").call(_t.append("issues.no_issues.message." + messageType)); } - osmoseDetails.issue = function(val) { - if (!arguments.length) return _qaItem; - _qaItem = val; - return osmoseDetails; - }; - return osmoseDetails; + context.validator().on("validated.uiSectionValidationStatus", function() { + window.requestIdleCallback(section.reRender); + }); + context.map().on( + "move.uiSectionValidationStatus", + debounce_default(function() { + window.requestIdleCallback(section.reRender); + }, 1e3) + ); + return section; } - - // modules/ui/osmose_header.js - function uiOsmoseHeader() { - let _qaItem; - function issueTitle(d2) { - const unknown = _t("inspector.unknown"); - if (!d2) return unknown; - const s2 = services.osmose.getStrings(d2.itemType); - return "title" in s2 ? s2.title : unknown; - } - function osmoseHeader(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", (d2) => services.osmose.getColor(d2.item)).attr("class", "qaItem-fill").attr("points", "16,3 4,3 1,6 1,17 4,20 7,20 10,27 13,20 16,20 19,17.033 19,6"); - 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").text(issueTitle); + var init_validation_status = __esm({ + "modules/ui/sections/validation_status.js"() { + "use strict"; + init_debounce(); + init_icon(); + init_preferences(); + init_localizer(); + init_section(); } - osmoseHeader.issue = function(val) { - if (!arguments.length) return _qaItem; - _qaItem = val; - return osmoseHeader; - }; - return osmoseHeader; - } + }); - // modules/ui/view_on_osmose.js - function uiViewOnOsmose() { - let _qaItem; - function viewOnOsmose(selection2) { - let url; - if (services.osmose && _qaItem instanceof QAItem) { - url = services.osmose.itemURL(_qaItem); - } - 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) { - if (!arguments.length) return _qaItem; - _qaItem = val; - return viewOnOsmose; - }; - return viewOnOsmose; + // modules/ui/panes/issues.js + var issues_exports = {}; + __export(issues_exports, { + uiPaneIssues: () => uiPaneIssues + }); + function uiPaneIssues(context) { + var issuesPane = uiPane("issues", context).key(_t("issues.key")).label(_t.append("issues.title")).description(_t.append("issues.title")).iconName("iD-icon-alert").sections([ + uiSectionValidationOptions(context), + uiSectionValidationStatus(context), + uiSectionValidationIssues("issues-errors", "error", context), + uiSectionValidationIssues("issues-warnings", "warning", context), + uiSectionValidationRules(context) + ]); + return issuesPane; } - - // modules/ui/osmose_editor.js - function uiOsmoseEditor(context) { - const dispatch14 = dispatch_default("change"); - const qaDetails = uiOsmoseDetails(context); - const qaHeader = uiOsmoseHeader(context); - let _qaItem; - function osmoseEditor(selection2) { - const header = selection2.selectAll(".header").data([0]); - const headerEnter = header.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.osmose.title")); - let body = selection2.selectAll(".body").data([0]); - body = body.enter().append("div").attr("class", "body").merge(body); - let 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(osmoseSaveSection); - const footer = selection2.selectAll(".footer").data([0]); - footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnOsmose(context).what(_qaItem)); - } - function osmoseSaveSection(selection2) { - const isSelected = _qaItem && _qaItem.id === context.selectedErrorID(); - const isShown = _qaItem && isSelected; - 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"); - saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons); + var init_issues = __esm({ + "modules/ui/panes/issues.js"() { + "use strict"; + init_localizer(); + init_pane(); + init_validation_issues(); + init_validation_options(); + init_validation_rules(); + init_validation_status(); } - 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 close-button action"); - buttonEnter.append("button").attr("class", "button ignore-button action"); - buttonSection = buttonSection.merge(buttonEnter); - buttonSection.select(".close-button").call(_t.append("QA.keepRight.close")).on("click.close", function(d3_event, d2) { - this.blur(); - const qaService = services.osmose; - if (qaService) { - d2.newStatus = "done"; - qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item)); + }); + + // modules/ui/settings/custom_data.js + var custom_data_exports = {}; + __export(custom_data_exports, { + uiSettingsCustomData: () => uiSettingsCustomData + }); + function uiSettingsCustomData(context) { + var dispatch14 = dispatch_default("change"); + function render(selection2) { + var dataLayer = context.layers().layer("data"); + var _origSettings = { + fileList: dataLayer && dataLayer.fileList() || null, + url: corePreferences("settings-custom-data-url") + }; + var _currSettings = { + fileList: dataLayer && dataLayer.fileList() || null + // url: prefs('settings-custom-data-url') + }; + var modal = uiConfirm(selection2).okButton(); + modal.classed("settings-modal settings-custom-data", true); + modal.select(".modal-section.header").append("h3").call(_t.append("settings.custom_data.header")); + var textSection = modal.select(".modal-section.message-text"); + textSection.append("pre").attr("class", "instructions-file").call(_t.append("settings.custom_data.file.instructions")); + textSection.append("input").attr("class", "field-file").attr("type", "file").attr("accept", ".gpx,.kml,.geojson,.json,application/gpx+xml,application/vnd.google-earth.kml+xml,application/geo+json,application/json").property("files", _currSettings.fileList).on("change", function(d3_event) { + var files = d3_event.target.files; + if (files && files.length) { + _currSettings.url = ""; + textSection.select(".field-url").property("value", ""); + _currSettings.fileList = files; + } else { + _currSettings.fileList = null; } }); - buttonSection.select(".ignore-button").call(_t.append("QA.keepRight.ignore")).on("click.ignore", function(d3_event, d2) { + textSection.append("h4").call(_t.append("settings.custom_data.or")); + textSection.append("pre").attr("class", "instructions-url").call(_t.append("settings.custom_data.url.instructions")); + textSection.append("textarea").attr("class", "field-url").attr("placeholder", _t("settings.custom_data.url.placeholder")).call(utilNoAuto).property("value", _currSettings.url); + var buttonSection = modal.select(".modal-section.buttons"); + buttonSection.insert("button", ".ok-button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel")); + buttonSection.select(".cancel-button").on("click.cancel", clickCancel); + buttonSection.select(".ok-button").attr("disabled", isSaveDisabled).on("click.save", clickSave); + function isSaveDisabled() { + return null; + } + function clickCancel() { + textSection.select(".field-url").property("value", _origSettings.url); + corePreferences("settings-custom-data-url", _origSettings.url); this.blur(); - const qaService = services.osmose; - if (qaService) { - d2.newStatus = "false"; - qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item)); + modal.close(); + } + function clickSave() { + _currSettings.url = textSection.select(".field-url").property("value").trim(); + if (_currSettings.url) { + _currSettings.fileList = null; } - }); + if (_currSettings.fileList) { + _currSettings.url = ""; + } + corePreferences("settings-custom-data-url", _currSettings.url); + this.blur(); + modal.close(); + dispatch14.call("change", this, _currSettings); + } } - osmoseEditor.error = function(val) { - if (!arguments.length) return _qaItem; - _qaItem = val; - return osmoseEditor; - }; - return utilRebind(osmoseEditor, dispatch14, "on"); + return utilRebind(render, dispatch14, "on"); } + var init_custom_data = __esm({ + "modules/ui/settings/custom_data.js"() { + "use strict"; + init_src4(); + init_preferences(); + init_localizer(); + init_confirm(); + init_util(); + } + }); - // modules/ui/sidebar.js - function uiSidebar(context) { - var inspector = uiInspector(context); - var dataEditor = uiDataEditor(context); - var noteEditor = uiNoteEditor(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; - 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 { - 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 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); + // modules/ui/sections/data_layers.js + var data_layers_exports = {}; + __export(data_layers_exports, { + uiSectionDataLayers: () => uiSectionDataLayers + }); + function uiSectionDataLayers(context) { + var settingsCustomData = uiSettingsCustomData(context).on("change", customChanged); + var layers = context.layers(); + var section = uiSection("data-layers", context).label(() => _t.append("map_data.data_layers")).disclosureContent(renderDisclosureContent); + function renderDisclosureContent(selection2) { + var container = selection2.selectAll(".data-layer-container").data([0]); + container.enter().append("div").attr("class", "data-layer-container").merge(container).call(drawOsmItems).call(drawQAItems).call(drawCustomDataItems).call(drawVectorItems).call(drawPanelItems); + } + function showsLayer(which) { + var layer = layers.layer(which); + if (layer) { + return layer.enabled(); } - 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 { - errEditor = osmoseEditor; - } - 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(); + return false; + } + function setLayer(which, enabled) { + var mode = context.mode(); + if (mode && /^draw/.test(mode.id)) return; + var layer = layers.layer(which); + if (layer) { + layer.enabled(enabled); + if (!enabled && (which === "osm" || which === "notes")) { + context.enter(modeBrowse(context)); } } - 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; + } + function toggleLayer(which) { + setLayer(which, !showsLayer(which)); + } + function drawOsmItems(selection2) { + var osmKeys = ["osm", "notes"]; + var osmLayers = layers.all().filter(function(obj) { + return osmKeys.indexOf(obj.id) !== -1; + }); + var ul = selection2.selectAll(".layer-list-osm").data([0]); + ul = ul.enter().append("ul").attr("class", "layer-list layer-list-osm").merge(ul); + var li = ul.selectAll(".list-item").data(osmLayers); + li.exit().remove(); + var liEnter = li.enter().append("li").attr("class", function(d2) { + return "list-item list-item-" + d2.id; + }); + var labelEnter = liEnter.append("label").each(function(d2) { + if (d2.id === "osm") { + select_default2(this).call( + uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).keys([uiCmd("\u2325" + _t("area_fill.wireframe.key"))]).placement("bottom") + ); } else { - startMargin = lastMargin = -sidebarWidth; - endMargin = 0; - } - if (!isCollapsing) { - selection2.classed("collapsed", isCollapsing); + select_default2(this).call( + uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).placement("bottom") + ); } - 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(); + }); + labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) { + toggleLayer(d2.id); + }); + labelEnter.append("span").html(function(d2) { + return _t.html("map_data.layers." + d2.id + ".title"); + }); + li.merge(liEnter).classed("active", function(d2) { + return d2.layer.enabled(); + }).selectAll("input").property("checked", function(d2) { + return d2.layer.enabled(); + }); + } + function drawQAItems(selection2) { + var qaKeys = ["keepRight", "osmose"]; + var qaLayers = layers.all().filter(function(obj) { + return qaKeys.indexOf(obj.id) !== -1; + }); + var ul = selection2.selectAll(".layer-list-qa").data([0]); + ul = ul.enter().append("ul").attr("class", "layer-list layer-list-qa").merge(ul); + var li = ul.selectAll(".list-item").data(qaLayers); + li.exit().remove(); + var liEnter = li.enter().append("li").attr("class", function(d2) { + return "list-item list-item-" + d2.id; + }); + var labelEnter = liEnter.append("label").each(function(d2) { + select_default2(this).call( + uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).placement("bottom") + ); + }); + labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) { + toggleLayer(d2.id); + }); + labelEnter.append("span").each(function(d2) { + _t.append("map_data.layers." + d2.id + ".title")(select_default2(this)); + }); + li.merge(liEnter).classed("active", function(d2) { + return d2.layer.enabled(); + }).selectAll("input").property("checked", function(d2) { + return d2.layer.enabled(); + }); + } + function drawVectorItems(selection2) { + var dataLayer = layers.layer("data"); + var vtData = [ + { + name: "Detroit Neighborhoods/Parks", + src: "neighborhoods-parks", + tooltip: "Neighborhood boundaries and parks as compiled by City of Detroit in concert with community groups.", + template: "https://{switch:a,b,c,d}.tiles.mapbox.com/v4/jonahadkins.cjksmur6x34562qp9iv1u3ksf-54hev,jonahadkins.cjksmqxdx33jj2wp90xd9x2md-4e5y2/{z}/{x}/{y}.vector.pbf?access_token=pk.eyJ1Ijoiam9uYWhhZGtpbnMiLCJhIjoiRlVVVkx3VSJ9.9sdVEK_B_VkEXPjssU5MqA" + }, + { + name: "Detroit Composite POIs", + src: "composite-poi", + tooltip: "Fire Inspections, Business Licenses, and other public location data collated from the City of Detroit.", + template: "https://{switch:a,b,c,d}.tiles.mapbox.com/v4/jonahadkins.cjksmm6a02sli31myxhsr7zf3-2sw8h/{z}/{x}/{y}.vector.pbf?access_token=pk.eyJ1Ijoiam9uYWhhZGtpbnMiLCJhIjoiRlVVVkx3VSJ9.9sdVEK_B_VkEXPjssU5MqA" + }, + { + name: "Detroit All-The-Places POIs", + src: "alltheplaces-poi", + tooltip: "Public domain business location data created by web scrapers.", + template: "https://{switch:a,b,c,d}.tiles.mapbox.com/v4/jonahadkins.cjksmswgk340g2vo06p1w9w0j-8fjjc/{z}/{x}/{y}.vector.pbf?access_token=pk.eyJ1Ijoiam9uYWhhZGtpbnMiLCJhIjoiRlVVVkx3VSJ9.9sdVEK_B_VkEXPjssU5MqA" } - sidebar.toggle(); + ]; + var detroit = geoExtent([-83.5, 42.1], [-82.8, 42.5]); + var showVectorItems = context.map().zoom() > 9 && detroit.contains(context.map().center()); + var container = selection2.selectAll(".vectortile-container").data(showVectorItems ? [0] : []); + container.exit().remove(); + var containerEnter = container.enter().append("div").attr("class", "vectortile-container"); + containerEnter.append("h4").attr("class", "vectortile-header").text("Detroit Vector Tiles (Beta)"); + containerEnter.append("ul").attr("class", "layer-list layer-list-vectortile"); + containerEnter.append("div").attr("class", "vectortile-footer").append("a").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).attr("href", "https://github.com/osmus/detroit-mapping-challenge").append("span").text("About these layers"); + container = container.merge(containerEnter); + var ul = container.selectAll(".layer-list-vectortile"); + var li = ul.selectAll(".list-item").data(vtData); + li.exit().remove(); + var liEnter = li.enter().append("li").attr("class", function(d2) { + return "list-item list-item-" + d2.src; }); - context.map().on("crossEditableZoom.sidebar", function(within) { - if (!within && !selection2.select(".inspector-hover").empty()) { - hover([]); + var labelEnter = liEnter.append("label").each(function(d2) { + select_default2(this).call( + uiTooltip().title(d2.tooltip).placement("top") + ); + }); + labelEnter.append("input").attr("type", "radio").attr("name", "vectortile").on("change", selectVTLayer); + labelEnter.append("span").text(function(d2) { + return d2.name; + }); + li.merge(liEnter).classed("active", isVTLayerSelected).selectAll("input").property("checked", isVTLayerSelected); + function isVTLayerSelected(d2) { + return dataLayer && dataLayer.template() === d2.template; + } + function selectVTLayer(d3_event, d2) { + corePreferences("settings-custom-data-url", d2.template); + if (dataLayer) { + dataLayer.template(d2.template, d2.src); + dataLayer.enabled(true); } + } + } + function drawCustomDataItems(selection2) { + var dataLayer = layers.layer("data"); + var hasData = dataLayer && dataLayer.hasData(); + var showsData = hasData && dataLayer.enabled(); + var ul = selection2.selectAll(".layer-list-data").data(dataLayer ? [0] : []); + ul.exit().remove(); + var ulEnter = ul.enter().append("ul").attr("class", "layer-list layer-list-data"); + var liEnter = ulEnter.append("li").attr("class", "list-item-data"); + var labelEnter = liEnter.append("label").call( + uiTooltip().title(() => _t.append("map_data.layers.custom.tooltip")).placement("top") + ); + labelEnter.append("input").attr("type", "checkbox").on("change", function() { + toggleLayer("data"); }); + labelEnter.append("span").call(_t.append("map_data.layers.custom.title")); + liEnter.append("button").attr("class", "open-data-options").call( + uiTooltip().title(() => _t.append("settings.custom_data.tooltip")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left") + ).on("click", function(d3_event) { + d3_event.preventDefault(); + editCustom(); + }).call(svgIcon("#iD-icon-more")); + liEnter.append("button").attr("class", "zoom-to-data").call( + uiTooltip().title(() => _t.append("map_data.layers.custom.zoom")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left") + ).on("click", function(d3_event) { + if (select_default2(this).classed("disabled")) return; + d3_event.preventDefault(); + d3_event.stopPropagation(); + dataLayer.fitZoom(); + }).call(svgIcon("#iD-icon-framed-dot", "monochrome")); + ul = ul.merge(ulEnter); + ul.selectAll(".list-item-data").classed("active", showsData).selectAll("label").classed("deemphasize", !hasData).selectAll("input").property("disabled", !hasData).property("checked", showsData); + ul.selectAll("button.zoom-to-data").classed("disabled", !hasData); } - sidebar.showPresetList = function() { - }; - sidebar.hover = function() { - }; - 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/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]); + function editCustom() { + context.container().call(settingsCustomData); } - 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); - }); + function customChanged(d2) { + var dataLayer = layers.layer("data"); + if (d2 && d2.url) { + dataLayer.url(d2.url); + } else if (d2 && d2.fileList) { + dataLayer.fileList(d2.fileList); } - }; + } + function drawPanelItems(selection2) { + var panelsListEnter = selection2.selectAll(".md-extras-list").data([0]).enter().append("ul").attr("class", "layer-list md-extras-list"); + var historyPanelLabelEnter = panelsListEnter.append("li").attr("class", "history-panel-toggle-item").append("label").call( + uiTooltip().title(() => _t.append("map_data.history_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.history.key"))]).placement("top") + ); + historyPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) { + d3_event.preventDefault(); + context.ui().info.toggle("history"); + }); + historyPanelLabelEnter.append("span").call(_t.append("map_data.history_panel.title")); + var measurementPanelLabelEnter = panelsListEnter.append("li").attr("class", "measurement-panel-toggle-item").append("label").call( + uiTooltip().title(() => _t.append("map_data.measurement_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.measurement.key"))]).placement("top") + ); + measurementPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) { + d3_event.preventDefault(); + context.ui().info.toggle("measurement"); + }); + measurementPanelLabelEnter.append("span").call(_t.append("map_data.measurement_panel.title")); + } + context.layers().on("change.uiSectionDataLayers", section.reRender); + context.map().on( + "move.uiSectionDataLayers", + debounce_default(function() { + window.requestIdleCallback(section.reRender); + }, 1e3) + ); + return section; } + var init_data_layers = __esm({ + "modules/ui/sections/data_layers.js"() { + "use strict"; + init_debounce(); + init_src5(); + init_preferences(); + init_localizer(); + init_tooltip(); + init_icon(); + init_geo2(); + init_browse(); + init_cmd(); + init_section(); + init_custom_data(); + } + }); - // modules/ui/sections/privacy.js - function uiSectionPrivacy(context) { - let section = uiSection("preferences-third-party", context).label(() => _t.append("preferences.privacy.title")).disclosureContent(renderDisclosureContent); + // modules/ui/sections/map_features.js + var map_features_exports = {}; + __export(map_features_exports, { + uiSectionMapFeatures: () => uiSectionMapFeatures + }); + function uiSectionMapFeatures(context) { + var _features = context.features().keys(); + var section = uiSection("map-features", context).label(() => _t.append("map_data.map_features")).disclosureContent(renderDisclosureContent).expandedByDefault(false); 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) => { + var container = selection2.selectAll(".layer-feature-list-container").data([0]); + var containerEnter = container.enter().append("div").attr("class", "layer-feature-list-container"); + containerEnter.append("ul").attr("class", "layer-list layer-feature-list"); + var footer = containerEnter.append("div").attr("class", "feature-list-links section-footer"); + footer.append("a").attr("class", "feature-list-link").attr("role", "button").attr("href", "#").call(_t.append("issues.disable_all")).on("click", function(d3_event) { d3_event.preventDefault(); - corePreferences("preferences.privacy.thirdpartyicons", d2 === "true" ? "false" : "true"); + context.features().disableAll(); }); - 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")); + footer.append("a").attr("class", "feature-list-link").attr("role", "button").attr("href", "#").call(_t.append("issues.enable_all")).on("click", function(d3_event) { + d3_event.preventDefault(); + context.features().enableAll(); + }); + container = container.merge(containerEnter); + container.selectAll(".layer-feature-list").call(drawListItems, _features, "checkbox", "feature", clickFeature, showsFeature); } - corePreferences.onChange("preferences.privacy.thirdpartyicons", section.reRender); + function drawListItems(selection2, data, type2, name, change, active) { + var items = selection2.selectAll("li").data(data); + items.exit().remove(); + var enter = items.enter().append("li").call( + uiTooltip().title(function(d2) { + var tip = _t.append(name + "." + d2 + ".tooltip"); + if (autoHiddenFeature(d2)) { + var msg = showsLayer("osm") ? _t.append("map_data.autohidden") : _t.append("map_data.osmhidden"); + return (selection3) => { + selection3.call(tip); + selection3.append("div").call(msg); + }; + } + return tip; + }).placement("top") + ); + var label = enter.append("label"); + label.append("input").attr("type", type2).attr("name", name).on("change", change); + label.append("span").html(function(d2) { + return _t.html(name + "." + d2 + ".description"); + }); + items = items.merge(enter); + items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", autoHiddenFeature); + } + function autoHiddenFeature(d2) { + return context.features().autoHidden(d2); + } + function showsFeature(d2) { + return context.features().enabled(d2); + } + function clickFeature(d3_event, d2) { + context.features().toggle(d2); + } + function showsLayer(id2) { + var layer = context.layers().layer(id2); + return layer && layer.enabled(); + } + context.features().on("change.map_features", section.reRender); return section; } + var init_map_features = __esm({ + "modules/ui/sections/map_features.js"() { + "use strict"; + init_localizer(); + init_tooltip(); + init_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(); + // modules/ui/sections/map_style_options.js + var map_style_options_exports = {}; + __export(map_style_options_exports, { + uiSectionMapStyleOptions: () => uiSectionMapStyleOptions + }); + function uiSectionMapStyleOptions(context) { + var section = uiSection("fill-area", context).label(() => _t.append("map_data.style_options")).disclosureContent(renderDisclosureContent).expandedByDefault(false); + function renderDisclosureContent(selection2) { + var container = selection2.selectAll(".layer-fill-list").data([0]); + container.enter().append("ul").attr("class", "layer-list layer-fill-list").merge(container).call(drawListItems, context.map().areaFillOptions, "radio", "area_fill", setFill, isActiveFill); + var container2 = selection2.selectAll(".layer-visual-diff-list").data([0]); + container2.enter().append("ul").attr("class", "layer-list layer-visual-diff-list").merge(container2).call(drawListItems, ["highlight_edits"], "checkbox", "visual_diff", toggleHighlightEdited, function() { + return context.surface().classed("highlight-edited"); }); - 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"); - }; + } + function drawListItems(selection2, data, type2, name, change, active) { + var items = selection2.selectAll("li").data(data); + items.exit().remove(); + var enter = items.enter().append("li").call( + uiTooltip().title(function(d2) { + return _t.append(name + "." + d2 + ".tooltip"); + }).keys(function(d2) { + var key = d2 === "wireframe" ? _t("area_fill.wireframe.key") : null; + if (d2 === "highlight_edits") key = _t("map_data.highlight_edits.key"); + return key ? [key] : null; + }).placement("top") + ); + var label = enter.append("label"); + label.append("input").attr("type", type2).attr("name", name).on("change", change); + label.append("span").html(function(d2) { + return _t.html(name + "." + d2 + ".description"); + }); + items = items.merge(enter); + items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", false); + } + function isActiveFill(d2) { + return context.map().activeAreaFill() === d2; + } + function toggleHighlightEdited(d3_event) { + d3_event.preventDefault(); + context.map().toggleHighlightEdited(); + } + function setFill(d3_event, d2) { + context.map().activeAreaFill(d2); + } + context.map().on("changeHighlighting.ui_style, changeAreaFill.ui_style", section.reRender); + return section; } + var init_map_style_options = __esm({ + "modules/ui/sections/map_style_options.js"() { + "use strict"; + init_localizer(); + init_tooltip(); + init_section(); + } + }); - // 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")); + // modules/ui/settings/local_photos.js + var local_photos_exports2 = {}; + __export(local_photos_exports2, { + uiSettingsLocalPhotos: () => uiSettingsLocalPhotos + }); + function uiSettingsLocalPhotos(context) { + var dispatch14 = dispatch_default("change"); + var photoLayer = context.layers().layer("local-photos"); + var modal; + function render(selection2) { + modal = uiConfirm(selection2).okButton(); + modal.classed("settings-modal settings-local-photos", true); + modal.select(".modal-section.header").append("h3").call(_t.append("local_photos.header")); + modal.select(".modal-section.message-text").append("div").classed("local-photos", true); + var instructionsSection = modal.select(".modal-section.message-text .local-photos").append("div").classed("instructions", true); + instructionsSection.append("p").classed("instructions-local-photos", true).call(_t.append("local_photos.file.instructions")); + instructionsSection.append("input").classed("field-file", true).attr("type", "file").attr("multiple", "multiple").attr("accept", ".jpg,.jpeg,.png,image/png,image/jpeg").style("visibility", "hidden").attr("id", "local-photo-files").on("change", function(d3_event) { + var files = d3_event.target.files; + if (files && files.length) { + photoList.select("ul").append("li").classed("placeholder", true).append("div"); + dispatch14.call("change", this, files); } - selection2.attr("class", "api-status " + (err ? "error" : apiStatus)); + d3_event.target.value = null; + }); + instructionsSection.append("label").attr("for", "local-photo-files").classed("button", true).call(_t.append("local_photos.file.label")); + const photoList = modal.select(".modal-section.message-text .local-photos").append("div").append("div").classed("list-local-photos", true); + photoList.append("ul"); + updatePhotoList(photoList.select("ul")); + context.layers().on("change", () => updatePhotoList(photoList.select("ul"))); + } + function updatePhotoList(container) { + var _a3; + function locationUnavailable(d2) { + return !(isArray_default(d2.loc) && isNumber_default(d2.loc[0]) && isNumber_default(d2.loc[1])); } - 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); + container.selectAll("li.placeholder").remove(); + let selection2 = container.selectAll("li").data((_a3 = photoLayer.getPhotos()) != null ? _a3 : [], (d2) => d2.id); + selection2.exit().remove(); + const selectionEnter = selection2.enter().append("li"); + selectionEnter.append("span").classed("filename", true); + selectionEnter.append("button").classed("form-field-button zoom-to-data", true).attr("title", _t("local_photos.zoom_single")).call(svgIcon("#iD-icon-framed-dot")); + selectionEnter.append("button").classed("form-field-button no-geolocation", true).call(svgIcon("#iD-icon-alert")).call( + uiTooltip().title(() => _t.append("local_photos.no_geolocation.tooltip")).placement("left") + ); + selectionEnter.append("button").classed("form-field-button remove", true).attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")); + selection2 = selection2.merge(selectionEnter); + selection2.classed("invalid", locationUnavailable); + selection2.select("span.filename").text((d2) => d2.name).attr("title", (d2) => d2.name); + selection2.select("span.filename").on("click", (d3_event, d2) => { + photoLayer.openPhoto(d3_event, d2, false); }); - window.setInterval(function() { - osm.reloadApiStatus(); - }, 9e4); - osm.reloadApiStatus(); - }; + selection2.select("button.zoom-to-data").on("click", (d3_event, d2) => { + photoLayer.openPhoto(d3_event, d2, true); + }); + selection2.select("button.remove").on("click", (d3_event, d2) => { + photoLayer.removePhoto(d2.id); + updatePhotoList(container); + }); + } + return utilRebind(render, dispatch14, "on"); } - - // modules/ui/tools/modes.js - function uiToolDrawModes(context) { - var tool = { - id: "old_modes", - label: _t.append("toolbar.add_feature") - }; - var modes = [ - modeAddPoint(context, { - title: _t.append("modes.add_point.title"), - button: "point", - description: _t.append("modes.add_point.description"), - preset: _mainPresetIndex.item("point"), - key: "1" - }), - modeAddLine(context, { - title: _t.append("modes.add_line.title"), - button: "line", - description: _t.append("modes.add_line.description"), - preset: _mainPresetIndex.item("line"), - key: "2" - }), - modeAddArea(context, { - title: _t.append("modes.add_area.title"), - button: "area", - description: _t.append("modes.add_area.description"), - preset: _mainPresetIndex.item("area"), - key: "3" - }) - ]; - function enabled(_mode) { - return osmEditable(); + var init_local_photos2 = __esm({ + "modules/ui/settings/local_photos.js"() { + "use strict"; + init_src4(); + init_lodash(); + init_localizer(); + init_confirm(); + init_util(); + init_tooltip(); + init_svg(); } - function osmEditable() { - return context.editable(); + }); + + // modules/ui/sections/photo_overlays.js + var photo_overlays_exports = {}; + __export(photo_overlays_exports, { + uiSectionPhotoOverlays: () => uiSectionPhotoOverlays + }); + function uiSectionPhotoOverlays(context) { + let _savedLayers = []; + let _layersHidden = false; + const _streetLayerIDs = ["streetside", "mapillary", "mapillary-map-features", "mapillary-signs", "kartaview", "mapilio", "vegbilder", "panoramax"]; + var settingsLocalPhotos = uiSettingsLocalPhotos(context).on("change", localPhotosChanged); + var layers = context.layers(); + var section = uiSection("photo-overlays", context).label(() => _t.append("photo_overlays.title")).disclosureContent(renderDisclosureContent).expandedByDefault(false); + const photoDates = {}; + const now3 = +/* @__PURE__ */ new Date(); + function renderDisclosureContent(selection2) { + var container = selection2.selectAll(".photo-overlay-container").data([0]); + container.enter().append("div").attr("class", "photo-overlay-container").merge(container).call(drawPhotoItems).call(drawPhotoTypeItems).call(drawDateSlider).call(drawUsernameFilter).call(drawLocalPhotos); } - modes.forEach(function(mode) { - context.keybinding().on(mode.key, function() { - if (!enabled(mode)) return; - if (mode.id === context.mode().id) { - context.enter(modeBrowse(context)); - } else { - context.enter(mode); + function drawPhotoItems(selection2) { + var photoKeys = context.photos().overlayLayerIDs(); + var photoLayers = layers.all().filter(function(obj) { + return photoKeys.indexOf(obj.id) !== -1; + }); + var data = photoLayers.filter(function(obj) { + if (!obj.layer.supported()) return false; + if (layerEnabled(obj)) return true; + if (typeof obj.layer.validHere === "function") { + return obj.layer.validHere(context.map().extent(), context.map().zoom()); + } + return true; + }); + function layerSupported(d2) { + return d2.layer && d2.layer.supported(); + } + function layerEnabled(d2) { + return layerSupported(d2) && (d2.layer.enabled() || _savedLayers.includes(d2.id)); + } + function layerRendered(d2) { + var _a3, _b2, _c; + return (_c = (_b2 = (_a3 = d2.layer).rendered) == null ? void 0 : _b2.call(_a3, 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); + var li = ul.selectAll(".list-item-photos").data(data, (d2) => d2.id); + li.exit().remove(); + var liEnter = li.enter().append("li").attr("class", function(d2) { + var classes = "list-item-photos list-item-" + d2.id; + if (d2.id === "mapillary-signs" || d2.id === "mapillary-map-features") { + classes += " indented"; } + return classes; }); - }); - tool.render = function(selection2) { - var wrap2 = selection2.append("div").attr("class", "joined").style("display", "flex"); - var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true }); - context.map().on("move.modes", debouncedUpdate).on("drawn.modes", debouncedUpdate); - context.on("enter.modes", update); - update(); - function update() { - var buttons = wrap2.selectAll("button.add-button").data(modes, function(d2) { - return d2.id; - }); - buttons.exit().remove(); - var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) { - return d2.id + " add-button bar-button"; - }).on("click.mode-buttons", function(d3_event, d2) { - if (!enabled(d2)) return; - var currMode = context.mode().id; - if (/^draw/.test(currMode)) return; - if (d2.id === currMode) { - context.enter(modeBrowse(context)); - } else { - context.enter(d2); - } - }).call( - uiTooltip().placement("bottom").title(function(d2) { - return d2.description; - }).keys(function(d2) { - return [d2.key]; - }).scrollContainer(context.container().select(".top-toolbar")) + var labelEnter = liEnter.append("label").each(function(d2) { + var titleID; + if (d2.id === "mapillary-signs") titleID = "mapillary.signs.tooltip"; + else if (d2.id === "mapillary") titleID = "mapillary_images.tooltip"; + else if (d2.id === "kartaview") titleID = "kartaview_images.tooltip"; + else titleID = d2.id.replace(/-/g, "_") + ".tooltip"; + select_default2(this).call( + uiTooltip().title(() => { + if (!layerRendered(d2)) { + return _t.append("street_side.minzoom_tooltip"); + } else { + return _t.append(titleID); + } + }).placement("top") ); - buttonsEnter.each(function(d2) { - select_default2(this).call(svgIcon("#iD-icon-" + d2.button)); - }); - buttonsEnter.append("span").attr("class", "label").text("").each(function(mode) { - mode.title(select_default2(this)); - }); - if (buttons.enter().size() || buttons.exit().size()) { - context.ui().checkOverflow(".top-toolbar", true); - } - buttons = buttons.merge(buttonsEnter).attr("aria-disabled", function(d2) { - return !enabled(d2); - }).classed("disabled", function(d2) { - return !enabled(d2); - }).attr("aria-pressed", function(d2) { - return context.mode() && context.mode().button === d2.button; - }).classed("active", function(d2) { - return context.mode() && context.mode().button === d2.button; - }); - } - }; - return tool; - } - - // modules/ui/tools/notes.js - function uiToolNotes(context) { - var tool = { - id: "notes", - label: _t.append("modes.add_note.label") - }; - var mode = modeAddNote(context); - function enabled() { - return notesEnabled() && notesEditable(); + }); + labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) { + toggleLayer(d2.id); + }); + labelEnter.append("span").html(function(d2) { + var id2 = d2.id; + if (id2 === "mapillary-signs") id2 = "photo_overlays.traffic_signs"; + return _t.html(id2.replace(/-/g, "_") + ".title"); + }); + li.merge(liEnter).classed("active", layerEnabled).selectAll("input").property("disabled", (d2) => !layerRendered(d2)).property("checked", layerEnabled); } - function notesEnabled() { - var noteLayer = context.layers().layer("notes"); - return noteLayer && noteLayer.enabled(); + function drawPhotoTypeItems(selection2) { + var data = context.photos().allPhotoTypes(); + function typeEnabled(d2) { + return context.photos().showsPhotoType(d2); + } + var ul = selection2.selectAll(".layer-list-photo-types").data([0]); + ul.exit().remove(); + ul = ul.enter().append("ul").attr("class", "layer-list layer-list-photo-types").merge(ul); + var li = ul.selectAll(".list-item-photo-types").data(context.photos().shouldFilterByPhotoType() ? data : []); + li.exit().remove(); + var liEnter = li.enter().append("li").attr("class", function(d2) { + return "list-item-photo-types list-item-" + d2; + }); + var labelEnter = liEnter.append("label").each(function(d2) { + select_default2(this).call( + uiTooltip().title(() => _t.append("photo_overlays.photo_type." + d2 + ".tooltip")).placement("top") + ); + }); + labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) { + context.photos().togglePhotoType(d2, true); + }); + labelEnter.append("span").html(function(d2) { + return _t.html("photo_overlays.photo_type." + d2 + ".title"); + }); + li.merge(liEnter).classed("active", typeEnabled).selectAll("input").property("checked", typeEnabled); } - function notesEditable() { - var mode2 = context.mode(); - return context.map().notesEditable() && mode2 && mode2.id !== "save"; + function drawDateSlider(selection2) { + var ul = selection2.selectAll(".layer-list-date-slider").data([0]); + ul.exit().remove(); + ul = ul.enter().append("ul").attr("class", "layer-list layer-list-date-slider").merge(ul); + var li = ul.selectAll(".list-item-date-slider").data(context.photos().shouldFilterDateBySlider() ? ["date-slider"] : []); + li.exit().remove(); + var liEnter = li.enter().append("li").attr("class", "list-item-date-slider"); + var labelEnter = liEnter.append("label").each(function() { + select_default2(this).call( + uiTooltip().title(() => _t.append("photo_overlays.age_slider_filter.tooltip")).placement("top") + ); + }); + labelEnter.append("span").attr("class", "dateSliderSpan").call(_t.append("photo_overlays.age_slider_filter.title")); + let sliderWrap = labelEnter.append("div").attr("class", "slider-wrap"); + sliderWrap.append("input").attr("type", "range").attr("min", 0).attr("max", 1).attr("step", 1e-3).attr("list", "photo-overlay-data-range").attr("value", () => dateSliderValue("from")).classed("list-option-date-slider", true).classed("from-date", true).style("direction", _mainLocalizer.textDirection() === "rtl" ? "ltr" : "rtl").call(utilNoAuto).on("change", function() { + let value = select_default2(this).property("value"); + setYearFilter(value, true, "from"); + }); + selection2.select("input.from-date").each(function() { + this.value = dateSliderValue("from"); + }); + sliderWrap.append("div").attr("class", "date-slider-label"); + sliderWrap.append("input").attr("type", "range").attr("min", 0).attr("max", 1).attr("step", 1e-3).attr("list", "photo-overlay-data-range-inverted").attr("value", () => 1 - dateSliderValue("to")).classed("list-option-date-slider", true).classed("to-date", true).style("display", () => dateSliderValue("to") === 0 ? "none" : null).style("direction", _mainLocalizer.textDirection()).call(utilNoAuto).on("change", function() { + let value = select_default2(this).property("value"); + setYearFilter(1 - value, true, "to"); + }); + selection2.select("input.to-date").each(function() { + this.value = 1 - dateSliderValue("to"); + }); + selection2.select(".date-slider-label").call(dateSliderValue("from") === 1 ? _t.addOrUpdate("photo_overlays.age_slider_filter.label_all") : _t.addOrUpdate("photo_overlays.age_slider_filter.label_date", { + date: new Date(now3 - Math.pow(dateSliderValue("from"), 1.45) * 10 * 365.25 * 86400 * 1e3).toLocaleDateString(_mainLocalizer.localeCode()) + })); + sliderWrap.append("datalist").attr("class", "date-slider-values").attr("id", "photo-overlay-data-range"); + sliderWrap.append("datalist").attr("class", "date-slider-values").attr("id", "photo-overlay-data-range-inverted"); + const dateTicks = /* @__PURE__ */ new Set(); + for (const dates of Object.values(photoDates)) { + dates.forEach((date) => { + dateTicks.add(Math.round(1e3 * Math.pow((now3 - date) / (10 * 365.25 * 86400 * 1e3), 1 / 1.45)) / 1e3); + }); + } + const ticks2 = selection2.select("datalist#photo-overlay-data-range").selectAll("option").data([...dateTicks].concat([1, 0])); + ticks2.exit().remove(); + ticks2.enter().append("option").merge(ticks2).attr("value", (d2) => d2); + const ticksInverted = selection2.select("datalist#photo-overlay-data-range-inverted").selectAll("option").data([...dateTicks].concat([1, 0])); + ticksInverted.exit().remove(); + ticksInverted.enter().append("option").merge(ticksInverted).attr("value", (d2) => 1 - d2); + li.merge(liEnter).classed("active", filterEnabled); + function filterEnabled() { + return !!context.photos().fromDate(); + } } - context.keybinding().on(mode.key, function() { - if (!enabled()) return; - if (mode.id === context.mode().id) { - context.enter(modeBrowse(context)); + function dateSliderValue(which) { + const val = which === "from" ? context.photos().fromDate() : context.photos().toDate(); + if (val) { + const date = +new Date(val); + return Math.pow((now3 - date) / (10 * 365.25 * 86400 * 1e3), 1 / 1.45); + } else return which === "from" ? 1 : 0; + } + function setYearFilter(value, updateUrl, which) { + value = +value + (which === "from" ? 1e-3 : -1e-3); + if (value < 1 && value > 0) { + const date = new Date(now3 - Math.pow(value, 1.45) * 10 * 365.25 * 86400 * 1e3).toISOString().substring(0, 10); + context.photos().setDateFilter(`${which}Date`, date, updateUrl); } else { - context.enter(mode); + context.photos().setDateFilter(`${which}Date`, null, updateUrl); } - }); - tool.render = function(selection2) { - var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true }); - context.map().on("move.notes", debouncedUpdate).on("drawn.notes", debouncedUpdate); - context.on("enter.notes", update); - update(); - function update() { - var showNotes = notesEnabled(); - var data = showNotes ? [mode] : []; - var buttons = selection2.selectAll("button.add-button").data(data, function(d2) { - return d2.id; - }); - buttons.exit().remove(); - var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) { - return d2.id + " add-button bar-button"; - }).on("click.notes", function(d3_event, d2) { - if (!enabled()) return; - var currMode = context.mode().id; - if (/^draw/.test(currMode)) return; - if (d2.id === currMode) { - context.enter(modeBrowse(context)); - } else { - context.enter(d2); - } - }).call( - uiTooltip().placement("bottom").title(function(d2) { - return d2.description; - }).keys(function(d2) { - return [d2.key]; - }).scrollContainer(context.container().select(".top-toolbar")) + } + ; + function drawUsernameFilter(selection2) { + function filterEnabled() { + return context.photos().usernames(); + } + var ul = selection2.selectAll(".layer-list-username-filter").data([0]); + ul.exit().remove(); + ul = ul.enter().append("ul").attr("class", "layer-list layer-list-username-filter").merge(ul); + var li = ul.selectAll(".list-item-username-filter").data(context.photos().shouldFilterByUsername() ? ["username-filter"] : []); + li.exit().remove(); + var liEnter = li.enter().append("li").attr("class", "list-item-username-filter"); + var labelEnter = liEnter.append("label").each(function() { + select_default2(this).call( + uiTooltip().title(() => _t.append("photo_overlays.username_filter.tooltip")).placement("top") ); - buttonsEnter.each(function(d2) { - select_default2(this).call(svgIcon(d2.icon || "#iD-icon-" + d2.button)); - }); - if (buttons.enter().size() || buttons.exit().size()) { - context.ui().checkOverflow(".top-toolbar", true); - } - buttons = buttons.merge(buttonsEnter).classed("disabled", function() { - return !enabled(); - }).attr("aria-disabled", function() { - return !enabled(); - }).classed("active", function(d2) { - return context.mode() && context.mode().button === d2.button; - }).attr("aria-pressed", function(d2) { - return context.mode() && context.mode().button === d2.button; - }); + }); + labelEnter.append("span").call(_t.append("photo_overlays.username_filter.title")); + labelEnter.append("input").attr("type", "text").attr("class", "list-item-input").call(utilNoAuto).property("value", usernameValue).on("change", function() { + var value = select_default2(this).property("value"); + context.photos().setUsernameFilter(value, true); + select_default2(this).property("value", usernameValue); + }); + li.merge(liEnter).classed("active", filterEnabled); + function usernameValue() { + var usernames = context.photos().usernames(); + if (usernames) return usernames.join("; "); + return usernames; } - }; - tool.uninstall = function() { - context.on("enter.editor.notes", null).on("exit.editor.notes", null).on("enter.notes", null); - context.map().on("move.notes", null).on("drawn.notes", null); - }; - return tool; - } - - // modules/ui/tools/save.js - function uiToolSave(context) { - var tool = { - id: "save", - label: _t.append("save.title") - }; - var button = null; - var tooltipBehavior = null; - var history = context.history(); - var key = uiCmd("\u2318S"); - var _numChanges = 0; - function isSaving() { - var mode = context.mode(); - return mode && mode.id === "save"; } - function isDisabled() { - return _numChanges === 0 || isSaving(); + function toggleLayer(which) { + setLayer(which, !showsLayer(which)); } - function save(d3_event) { - d3_event.preventDefault(); - if (!context.inIntro() && !isSaving() && history.hasChanges()) { - context.enter(modeSave(context)); + function showsLayer(which) { + var layer = layers.layer(which); + if (layer) { + return layer.enabled(); } + return false; } - function bgColor(numChanges) { - var step; - if (numChanges === 0) { - return null; - } else if (numChanges <= 50) { - step = numChanges / 50; - return rgb_default("#fff", "#ff8")(step); - } else { - step = Math.min((numChanges - 50) / 50, 1); - return rgb_default("#ff8", "#f88")(step); + function setLayer(which, enabled) { + var layer = layers.layer(which); + if (layer) { + layer.enabled(enabled); } } - function updateCount() { - var val = history.difference().summary().length; - if (val === _numChanges) return; - _numChanges = val; - if (tooltipBehavior) { - tooltipBehavior.title(() => _t.append(_numChanges > 0 ? "save.help" : "save.no_changes")).keys([key]); - } - if (button) { - button.classed("disabled", isDisabled()).style("background", bgColor(_numChanges)); - button.select("span.count").text(_numChanges); - } + function drawLocalPhotos(selection2) { + var photoLayer = layers.layer("local-photos"); + var hasData = photoLayer && photoLayer.hasData(); + var showsData = hasData && photoLayer.enabled(); + var ul = selection2.selectAll(".layer-list-local-photos").data(photoLayer ? [0] : []); + ul.exit().remove(); + var ulEnter = ul.enter().append("ul").attr("class", "layer-list layer-list-local-photos"); + var localPhotosEnter = ulEnter.append("li").attr("class", "list-item-local-photos"); + var localPhotosLabelEnter = localPhotosEnter.append("label").call(uiTooltip().title(() => _t.append("local_photos.tooltip"))); + localPhotosLabelEnter.append("input").attr("type", "checkbox").on("change", function() { + toggleLayer("local-photos"); + }); + localPhotosLabelEnter.call(_t.append("local_photos.header")); + localPhotosEnter.append("button").attr("class", "open-data-options").call( + uiTooltip().title(() => _t.append("local_photos.tooltip_edit")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left") + ).on("click", function(d3_event) { + d3_event.preventDefault(); + editLocalPhotos(); + }).call(svgIcon("#iD-icon-more")); + localPhotosEnter.append("button").attr("class", "zoom-to-data").call( + uiTooltip().title(() => _t.append("local_photos.zoom")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left") + ).on("click", function(d3_event) { + if (select_default2(this).classed("disabled")) return; + d3_event.preventDefault(); + d3_event.stopPropagation(); + photoLayer.fitZoom(); + }).call(svgIcon("#iD-icon-framed-dot", "monochrome")); + ul = ul.merge(ulEnter); + ul.selectAll(".list-item-local-photos").classed("active", showsData).selectAll("label").classed("deemphasize", !hasData).selectAll("input").property("disabled", !hasData).property("checked", showsData); + ul.selectAll("button.zoom-to-data").classed("disabled", !hasData); } - tool.render = function(selection2) { - tooltipBehavior = uiTooltip().placement("bottom").title(() => _t.append("save.no_changes")).keys([key]).scrollContainer(context.container().select(".top-toolbar")); - var lastPointerUpType; - button = selection2.append("button").attr("class", "save disabled bar-button").on("pointerup", function(d3_event) { - lastPointerUpType = d3_event.pointerType; - }).on("click", function(d3_event) { - save(d3_event); - if (_numChanges === 0 && (lastPointerUpType === "touch" || lastPointerUpType === "pen")) { - context.ui().flash.duration(2e3).iconName("#iD-icon-save").iconClass("disabled").label(_t.append("save.no_changes"))(); - } - lastPointerUpType = null; - }).call(tooltipBehavior); - button.call(svgIcon("#iD-icon-save")); - button.append("span").attr("class", "count").attr("aria-hidden", "true").text("0"); - updateCount(); - context.keybinding().on(key, save, true); - context.history().on("change.save", updateCount); - context.on("enter.save", function() { - if (button) { - button.classed("disabled", isDisabled()); - if (isSaving()) { - button.call(tooltipBehavior.hide); + function editLocalPhotos() { + context.container().call(settingsLocalPhotos); + } + function localPhotosChanged(d2) { + var localPhotosLayer = layers.layer("local-photos"); + localPhotosLayer.fileList(d2); + } + function toggleStreetSide() { + let layerContainer = select_default2(".photo-overlay-container"); + if (!_layersHidden) { + layers.all().forEach((d2) => { + if (_streetLayerIDs.includes(d2.id)) { + if (showsLayer(d2.id)) _savedLayers.push(d2.id); + setLayer(d2.id, false); } - } - }); - }; - tool.uninstall = function() { - context.keybinding().off(key, true); - context.history().on("change.save", null); - context.on("enter.save", null); - button = null; - tooltipBehavior = null; - }; - return tool; + }); + layerContainer.classed("disabled-panel", true); + } else { + _savedLayers.forEach((d2) => { + setLayer(d2, true); + }); + _savedLayers = []; + layerContainer.classed("disabled-panel", false); + } + _layersHidden = !_layersHidden; + } + ; + context.layers().on("change.uiSectionPhotoOverlays", section.reRender); + context.photos().on("change.uiSectionPhotoOverlays", section.reRender); + context.layers().on("photoDatesChanged.uiSectionPhotoOverlays", function(service, dates) { + photoDates[service] = dates.map((date) => +new Date(date)); + section.reRender(); + }); + context.keybinding().on("\u21E7P", toggleStreetSide); + context.map().on( + "move.photo_overlays", + debounce_default(function() { + window.requestIdleCallback(section.reRender); + }, 1e3) + ); + return section; } + var init_photo_overlays = __esm({ + "modules/ui/sections/photo_overlays.js"() { + "use strict"; + init_debounce(); + init_src5(); + init_localizer(); + init_tooltip(); + init_section(); + init_util(); + init_local_photos2(); + init_svg(); + } + }); - // modules/ui/tools/sidebar_toggle.js - function uiToolSidebarToggle(context) { - var tool = { - id: "sidebar_toggle", - label: _t.append("toolbar.inspect") - }; - tool.render = function(selection2) { - selection2.append("button").attr("class", "bar-button").attr("aria-label", _t("sidebar.tooltip")).on("click", function() { - context.ui().sidebar.toggle(); - }).call( - uiTooltip().placement("bottom").title(() => _t.append("sidebar.tooltip")).keys([_t("sidebar.key")]).scrollContainer(context.container().select(".top-toolbar")) - ).call(svgIcon("#iD-icon-sidebar-" + (_mainLocalizer.textDirection() === "rtl" ? "right" : "left"))); - }; - return tool; + // modules/ui/panes/map_data.js + var map_data_exports = {}; + __export(map_data_exports, { + uiPaneMapData: () => uiPaneMapData + }); + function uiPaneMapData(context) { + var mapDataPane = uiPane("map-data", context).key(_t("map_data.key")).label(_t.append("map_data.title")).description(_t.append("map_data.description")).iconName("iD-icon-data").sections([ + uiSectionDataLayers(context), + uiSectionPhotoOverlays(context), + uiSectionMapStyleOptions(context), + uiSectionMapFeatures(context) + ]); + return mapDataPane; } + var init_map_data = __esm({ + "modules/ui/panes/map_data.js"() { + "use strict"; + init_localizer(); + init_pane(); + init_data_layers(); + init_map_features(); + init_map_style_options(); + init_photo_overlays(); + } + }); - // modules/ui/tools/undo_redo.js - function uiToolUndoRedo(context) { - var tool = { - id: "undo_redo", - label: _t.append("toolbar.undo_redo") - }; - var commands = [{ - id: "undo", - cmd: uiCmd("\u2318Z"), - action: function() { - context.undo(); - }, - annotation: function() { - return context.history().undoAnnotation(); - }, - icon: "iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo") - }, { - id: "redo", - cmd: uiCmd("\u2318\u21E7Z"), - action: function() { - context.redo(); - }, - annotation: function() { - return context.history().redoAnnotation(); - }, - icon: "iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "undo" : "redo") - }]; - function editable() { - return context.mode() && context.mode().id !== "save" && context.map().editableDataEnabled( - true - /* ignore min zoom */ - ); + // modules/ui/panes/preferences.js + var preferences_exports2 = {}; + __export(preferences_exports2, { + uiPanePreferences: () => uiPanePreferences + }); + function uiPanePreferences(context) { + let preferencesPane = uiPane("preferences", context).key(_t("preferences.key")).label(_t.append("preferences.title")).description(_t.append("preferences.description")).iconName("fas-user-cog").sections([ + uiSectionPrivacy(context) + ]); + return preferencesPane; + } + var init_preferences2 = __esm({ + "modules/ui/panes/preferences.js"() { + "use strict"; + init_localizer(); + init_pane(); + init_privacy(); } - tool.render = function(selection2) { - var tooltipBehavior = uiTooltip().placement("bottom").title(function(d2) { - return d2.annotation() ? _t.append(d2.id + ".tooltip", { action: d2.annotation() }) : _t.append(d2.id + ".nothing"); - }).keys(function(d2) { - return [d2.cmd]; - }).scrollContainer(context.container().select(".top-toolbar")); - var lastPointerUpType; - var buttons = selection2.selectAll("button").data(commands).enter().append("button").attr("class", function(d2) { - return "disabled " + d2.id + "-button bar-button"; - }).on("pointerup", function(d3_event) { - lastPointerUpType = d3_event.pointerType; - }).on("click", function(d3_event, d2) { + }); + + // modules/ui/init.js + var init_exports = {}; + __export(init_exports, { + uiInit: () => uiInit + }); + function uiInit(context) { + var _initCounter = 0; + var _needWidth = {}; + var _lastPointerType; + var overMap; + function render(container) { + container.on("click.ui", function(d3_event) { + if (d3_event.button !== 0) return; + if (!d3_event.composedPath) return; + var isOkayTarget = d3_event.composedPath().some(function(node) { + return node.nodeType === 1 && // clicking focuses it and/or changes a value + (node.nodeName === "INPUT" || // clicking