+ // modules/ui/panes/background.js
+ 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;
+ }
+
+ // modules/ui/panes/help.js
+ 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
+ };
+ 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(/<code>/g, "<kbd>").replace(/<\/code>/g, "</kbd>")
+ };
+ });
+ 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;
+ });
+ nav.html("");
+ if (rtl) {
+ nav.call(drawNext).call(drawPrevious);
+ } else {
+ nav.call(drawPrevious).call(drawNext);
+ }
+ 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"));
+ }
+ }
+ 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));
+ });
+ 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 helpPane;
+ }
+
+ // modules/ui/sections/validation_issues.js
+ 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 reloadIssues() {
+ _issues = context.validator().getIssuesBySeverity(getOptions())[severity];
+ }
+ 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;
+ }
+
+ // modules/ui/sections/validation_options.js
+ 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;
+ }
+ corePreferences("validate-" + d2, val);
+ context.validator().validate();
+ }
+ return section;
+ }
+
+ // modules/ui/sections/validation_rules.js
+ 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 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")
+ );
+ }
+ 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: '<span class="square-degrees"></span>' };
+ }
+ return _t.html("issues." + d2 + ".title", params);
+ });
+ 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);
+ }
+ 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;
+ }
+
+ // modules/ui/sections/validation_status.js
+ 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 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" }
+ });
+ } 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));
+ }
+ 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/panes/issues.js
+ 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/settings/custom_data.js
+ 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;
+ }
+ });
+ 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();
+ 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);
+ }
+ }
+ return utilRebind(render, dispatch14, "on");
+ }
+
+ // modules/ui/sections/data_layers.js
+ 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();
+ }
+ 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));
+ }
+ }
+ }
+ 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 {
+ 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").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"
+ }
+ ];
+ 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;
+ });
+ 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);
+ }
+ function editCustom() {
+ context.container().call(settingsCustomData);
+ }
+ 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;
+ }
+
+ // modules/ui/sections/map_features.js
+ 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) {
+ 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();
+ context.features().disableAll();
+ });
+ 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);
+ }
+ 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;
+ }
+
+ // modules/ui/sections/map_style_options.js
+ 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");
+ });
+ }
+ 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;
+ }
+
+ // modules/ui/settings/local_photos.js
+ 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);
+ }
+ 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]));
+ }
+ 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);
+ });
+ 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/sections/photo_overlays.js
+ function uiSectionPhotoOverlays(context) {
+ 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);
+ 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(drawDateFilter).call(drawUsernameFilter).call(drawLocalPhotos);
+ }
+ 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();
+ }
+ function layerRendered(d2) {
+ var _a3, _b3, _c;
+ return (_c = (_b3 = (_a3 = d2.layer).rendered) == null ? void 0 : _b3.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;
+ });
+ 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")
+ );
+ });
+ 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 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);
+ });
+ 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 drawDateFilter(selection2) {
+ var data = context.photos().dateFilters();
+ function filterEnabled(d2) {
+ return context.photos().dateFilterValue(d2);
+ }
+ var ul = selection2.selectAll(".layer-list-date-filter").data([0]);
+ ul.exit().remove();
+ ul = ul.enter().append("ul").attr("class", "layer-list layer-list-date-filter").merge(ul);
+ var li = ul.selectAll(".list-item-date-filter").data(context.photos().shouldFilterByDate() ? data : []);
+ li.exit().remove();
+ var liEnter = li.enter().append("li").attr("class", "list-item-date-filter");
+ var labelEnter = liEnter.append("label").each(function(d2) {
+ select_default2(this).call(
+ uiTooltip().title(() => _t.append("photo_overlays.date_filter." + d2 + ".tooltip")).placement("top")
+ );
+ });
+ labelEnter.append("span").each(function(d2) {
+ _t.append("photo_overlays.date_filter." + d2 + ".title")(select_default2(this));
+ });
+ labelEnter.append("input").attr("type", "date").attr("class", "list-item-input").attr("placeholder", _t("units.year_month_day")).call(utilNoAuto).each(function(d2) {
+ utilGetSetValue(select_default2(this), context.photos().dateFilterValue(d2) || "");
+ }).on("change", function(d3_event, d2) {
+ var value = utilGetSetValue(select_default2(this)).trim();
+ context.photos().setDateFilter(d2, value, true);
+ li.selectAll("input").each(function(d4) {
+ utilGetSetValue(select_default2(this), context.photos().dateFilterValue(d4) || "");
+ });
+ });
+ li = li.merge(liEnter).classed("active", filterEnabled);
+ }
+ 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")
+ );
+ });
+ 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;
+ }
+ }
+ function toggleLayer(which) {
+ setLayer(which, !showsLayer(which));
+ }
+ function showsLayer(which) {
+ var layer = layers.layer(which);
+ if (layer) {
+ return layer.enabled();
+ }
+ return false;
+ }
+ function setLayer(which, enabled) {
+ var layer = layers.layer(which);
+ if (layer) {
+ layer.enabled(enabled);
+ }
+ }
+ 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);
+ }
+ function editLocalPhotos() {
+ context.container().call(settingsLocalPhotos);
+ }
+ function localPhotosChanged(d2) {
+ var localPhotosLayer = layers.layer("local-photos");
+ localPhotosLayer.fileList(d2);
+ }
+ context.layers().on("change.uiSectionPhotoOverlays", section.reRender);
+ context.photos().on("change.uiSectionPhotoOverlays", section.reRender);
+ context.map().on(
+ "move.photo_overlays",
+ debounce_default(function() {
+ window.requestIdleCallback(section.reRender);
+ }, 1e3)
+ );
+ return section;
+ }
+
+ // modules/ui/panes/map_data.js
+ 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;
+ }
+
+ // modules/ui/panes/preferences.js
+ 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;
+ }
+
+ // modules/ui/init.js
+ function uiInit(context) {
+ var _initCounter = 0;
+ var _needWidth = {};
+ var _lastPointerType;
+ 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 <input> focuses it and/or changes a value
+ (node.nodeName === "INPUT" || // clicking <label> affects its <input> by default
+ node.nodeName === "LABEL" || // clicking <a> opens a hyperlink by default
+ node.nodeName === "A");
+ });
+ if (isOkayTarget) return;
+ d3_event.preventDefault();
+ });
+ 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) {
+ container.on("gesturestart.ui gesturechange.ui gestureend.ui", function(d3_event) {
+ d3_event.preventDefault();
+ });
+ }
+ if ("PointerEvent" in window) {
+ select_default2(window).on("pointerdown.ui pointerup.ui", function(d3_event) {
+ var pointerType = d3_event.pointerType || "mouse";
+ if (_lastPointerType !== pointerType) {
+ _lastPointerType = pointerType;
+ container.attr("pointer", pointerType);
+ }
+ }, true);
+ } else {
+ _lastPointerType = "mouse";
+ container.attr("pointer", "mouse");
+ }
+ container.attr("lang", _mainLocalizer.localeCode()).attr("dir", _mainLocalizer.textDirection());
+ container.call(uiFullScreen(context));
+ var map2 = context.map();
+ map2.redrawEnable(false);
+ map2.on("hitMinZoom.ui", function() {
+ ui.flash.iconName("#iD-icon-no").label(_t.append("cannot_zoom"))();
+ });
+ container.append("svg").attr("id", "ideditor-defs").call(ui.svgDefs);
+ container.append("div").attr("class", "sidebar").call(ui.sidebar);
+ var content = container.append("div").attr("class", "main-content active");
+ content.append("div").attr("class", "top-toolbar-wrap").append("div").attr("class", "top-toolbar fillD").call(uiTopToolbar(context));
+ content.append("div").attr("class", "main-map").attr("dir", "ltr").call(map2);
+ var overMap = content.append("div").attr("class", "over-map");
+ overMap.append("div").attr("class", "select-trap").text("t");
+ overMap.call(uiMapInMap(context)).call(uiNotice(context));
+ overMap.append("div").attr("class", "spinner").call(uiSpinner(context));
+ var controlsWrap = overMap.append("div").attr("class", "map-controls-wrap");
+ var controls = controlsWrap.append("div").attr("class", "map-controls");
+ controls.append("div").attr("class", "map-control zoombuttons").call(uiZoom(context));
+ controls.append("div").attr("class", "map-control zoom-to-selection-control").call(uiZoomToSelection(context));
+ controls.append("div").attr("class", "map-control geolocate-control").call(uiGeolocate(context));
+ controlsWrap.on("wheel.mapControls", function(d3_event) {
+ if (!d3_event.deltaX) {
+ controlsWrap.node().scrollTop += d3_event.deltaY;
+ }
+ });
+ var panes = overMap.append("div").attr("class", "map-panes");
+ var uiPanes = [
+ uiPaneBackground(context),
+ uiPaneMapData(context),
+ uiPaneIssues(context),
+ uiPanePreferences(context),
+ uiPaneHelp(context)
+ ];
+ uiPanes.forEach(function(pane) {
+ controls.append("div").attr("class", "map-control map-pane-control " + pane.id + "-control").call(pane.renderToggleButton);
+ panes.call(pane.renderPane);
+ });
+ ui.info = uiInfo(context);
+ overMap.call(ui.info);
+ overMap.append("div").attr("class", "photoviewer").classed("al", true).classed("hide", true).call(ui.photoviewer);
+ overMap.append("div").attr("class", "attribution-wrap").attr("dir", "ltr").call(uiAttribution(context));
+ var about = content.append("div").attr("class", "map-footer");
+ about.append("div").attr("class", "api-status").call(uiStatus(context));
+ var footer = about.append("div").attr("class", "map-footer-bar fillD");
+ footer.append("div").attr("class", "flash-wrap footer-hide");
+ var footerWrap = footer.append("div").attr("class", "main-footer-wrap footer-show");
+ footerWrap.append("div").attr("class", "scale-block").call(uiScale(context));
+ var aboutList = footerWrap.append("div").attr("class", "info-block").append("ul").attr("class", "map-footer-list");
+ aboutList.append("li").attr("class", "user-list").call(uiContributors(context));
+ var apiConnections = context.connection().apiConnections();
+ if (apiConnections && apiConnections.length > 1) {
+ aboutList.append("li").attr("class", "source-switch").call(
+ uiSourceSwitch(context).keys(apiConnections)
+ );
+ }
+ aboutList.append("li").attr("class", "issues-info").call(uiIssuesInfo(context));
+ aboutList.append("li").attr("class", "feature-warning").call(uiFeatureInfo(context));
+ var issueLinks = aboutList.append("li");
+ issueLinks.append("a").attr("target", "_blank").attr("href", "https://github.com/openstreetmap/iD/issues").attr("aria-label", _t("report_a_bug")).call(svgIcon("#iD-icon-bug", "light")).call(uiTooltip().title(() => _t.append("report_a_bug")).placement("top"));
+ issueLinks.append("a").attr("target", "_blank").attr("href", "https://github.com/openstreetmap/iD/blob/develop/CONTRIBUTING.md#translating").attr("aria-label", _t("help_translate")).call(svgIcon("#iD-icon-translate", "light")).call(uiTooltip().title(() => _t.append("help_translate")).placement("top"));
+ aboutList.append("li").attr("class", "version").call(uiVersion(context));
+ if (!context.embed()) {
+ aboutList.call(uiAccount(context));
+ }
+ ui.onResize();
+ map2.redrawEnable(true);
+ ui.hash = behaviorHash(context);
+ ui.hash();
+ if (!ui.hash.hadLocation) {
+ map2.centerZoom([0, 0], 2);
+ }
+ window.onbeforeunload = function() {
+ return context.save();
+ };
+ window.onunload = function() {
+ context.history().unlock();
+ };
+ select_default2(window).on("resize.editor", function() {
+ ui.onResize();
+ });
+ var panPixels = 80;
+ context.keybinding().on("\u232B", function(d3_event) {
+ d3_event.preventDefault();
+ }).on([_t("sidebar.key"), "`", "\xB2", "@"], ui.sidebar.toggle).on("\u2190", pan([panPixels, 0])).on("\u2191", pan([0, panPixels])).on("\u2192", pan([-panPixels, 0])).on("\u2193", pan([0, -panPixels])).on(uiCmd("\u2325\u2190"), pan([map2.dimensions()[0], 0])).on(uiCmd("\u2325\u2191"), pan([0, map2.dimensions()[1]])).on(uiCmd("\u2325\u2192"), pan([-map2.dimensions()[0], 0])).on(uiCmd("\u2325\u2193"), pan([0, -map2.dimensions()[1]])).on(uiCmd("\u2318" + _t("background.key")), function quickSwitch(d3_event) {
+ if (d3_event) {
+ d3_event.stopImmediatePropagation();
+ d3_event.preventDefault();
+ }
+ var previousBackground = context.background().findSource(corePreferences("background-last-used-toggle"));
+ if (previousBackground) {
+ var currentBackground = context.background().baseLayerSource();
+ corePreferences("background-last-used-toggle", currentBackground.id);
+ corePreferences("background-last-used", previousBackground.id);
+ context.background().baseLayerSource(previousBackground);
+ }
+ }).on(_t("area_fill.wireframe.key"), function toggleWireframe(d3_event) {
+ d3_event.preventDefault();
+ d3_event.stopPropagation();
+ context.map().toggleWireframe();
+ }).on(uiCmd("\u2325" + _t("area_fill.wireframe.key")), function toggleOsmData(d3_event) {
+ d3_event.preventDefault();
+ d3_event.stopPropagation();
+ var mode = context.mode();
+ if (mode && /^draw/.test(mode.id)) return;
+ var layer = context.layers().layer("osm");
+ if (layer) {
+ layer.enabled(!layer.enabled());
+ if (!layer.enabled()) {
+ context.enter(modeBrowse(context));
+ }
+ }
+ }).on(_t("map_data.highlight_edits.key"), function toggleHighlightEdited(d3_event) {
+ d3_event.preventDefault();
+ context.map().toggleHighlightEdited();
+ });
+ context.on("enter.editor", function(entered) {
+ container.classed("mode-" + entered.id, true);
+ }).on("exit.editor", function(exited) {
+ container.classed("mode-" + exited.id, false);
+ });
+ context.enter(modeBrowse(context));
+ if (!_initCounter++) {
+ if (!ui.hash.startWalkthrough) {
+ context.container().call(uiSplash(context)).call(uiRestore(context));
+ }
+ context.container().call(ui.shortcuts);
+ }
+ var osm = context.connection();
+ var auth = uiLoading(context).message(_t.html("loading_auth")).blocking(true);
+ if (osm && auth) {
+ osm.on("authLoading.ui", function() {
+ context.container().call(auth);
+ }).on("authDone.ui", function() {
+ auth.close();
+ });
+ }
+ _initCounter++;
+ if (ui.hash.startWalkthrough) {
+ ui.hash.startWalkthrough = false;
+ context.container().call(uiIntro(context));
+ }
+ function pan(d2) {
+ return function(d3_event) {
+ if (d3_event.shiftKey) return;
+ if (context.container().select(".combobox").size()) return;
+ d3_event.preventDefault();
+ context.map().pan(d2, 100);
+ };
+ }
+ }
+ let ui = {};
+ let _loadPromise;
+ ui.ensureLoaded = () => {
+ if (_loadPromise) return _loadPromise;
+ return _loadPromise = Promise.all([
+ // must have strings and presets before loading the UI
+ _mainLocalizer.ensureLoaded(),
+ _mainPresetIndex.ensureLoaded()
+ ]).then(() => {
+ if (!context.container().empty()) render(context.container());
+ }).catch((err) => console.error(err));
+ };
+ ui.restart = function() {
+ context.keybinding().clear();
+ _loadPromise = null;
+ context.container().selectAll("*").remove();
+ ui.ensureLoaded();
+ };
+ ui.lastPointerType = function() {
+ return _lastPointerType;
+ };
+ ui.svgDefs = svgDefs(context);
+ ui.flash = uiFlash(context);
+ ui.sidebar = uiSidebar(context);
+ ui.photoviewer = uiPhotoviewer(context);
+ ui.shortcuts = uiShortcuts(context);
+ ui.onResize = function(withPan) {
+ var map2 = context.map();
+ var mapDimensions = utilGetDimensions(context.container().select(".main-content"), true);
+ utilGetDimensions(context.container().select(".sidebar"), true);
+ if (withPan !== void 0) {
+ map2.redrawEnable(false);
+ map2.pan(withPan);
+ map2.redrawEnable(true);
+ }
+ map2.dimensions(mapDimensions);
+ ui.photoviewer.onMapResize();
+ ui.checkOverflow(".top-toolbar");
+ ui.checkOverflow(".map-footer-bar");
+ var resizeWindowEvent = document.createEvent("Event");
+ resizeWindowEvent.initEvent("resizeWindow", true, true);
+ document.dispatchEvent(resizeWindowEvent);
+ };
+ ui.checkOverflow = function(selector, reset) {
+ if (reset) {
+ delete _needWidth[selector];
+ }
+ var selection2 = context.container().select(selector);
+ if (selection2.empty()) return;
+ var scrollWidth = selection2.property("scrollWidth");
+ var clientWidth = selection2.property("clientWidth");
+ var needed = _needWidth[selector] || scrollWidth;
+ if (scrollWidth > clientWidth) {
+ selection2.classed("narrow", true);
+ if (!_needWidth[selector]) {
+ _needWidth[selector] = scrollWidth;
+ }
+ } else if (scrollWidth >= needed) {
+ selection2.classed("narrow", false);
+ }
+ };
+ ui.togglePanes = function(showPane) {
+ var hidePanes = context.container().selectAll(".map-pane.shown");
+ var side = _mainLocalizer.textDirection() === "ltr" ? "right" : "left";
+ hidePanes.classed("shown", false).classed("hide", true);
+ context.container().selectAll(".map-pane-control button").classed("active", false);
+ if (showPane) {
+ hidePanes.classed("shown", false).classed("hide", true).style(side, "-500px");
+ context.container().selectAll("." + showPane.attr("pane") + "-control button").classed("active", true);
+ showPane.classed("shown", true).classed("hide", false);
+ if (hidePanes.empty()) {
+ showPane.style(side, "-500px").transition().duration(200).style(side, "0px");
+ } else {
+ showPane.style(side, "0px");
+ }
+ } else {
+ hidePanes.classed("shown", true).classed("hide", false).style(side, "0px").transition().duration(200).style(side, "-500px").on("end", function() {
+ select_default2(this).classed("shown", false).classed("hide", true);
+ });
+ }
+ };
+ var _editMenu = uiEditMenu(context);
+ ui.editMenu = function() {
+ return _editMenu;
+ };
+ ui.showEditMenu = function(anchorPoint, triggerType, operations) {
+ ui.closeEditMenu();
+ if (!operations && context.mode().operations) operations = context.mode().operations();
+ if (!operations || !operations.length) return;
+ if (!context.map().editableDataEnabled()) return;
+ var surfaceNode = context.surface().node();
+ if (surfaceNode.focus) {
+ surfaceNode.focus();
+ }
+ operations.forEach(function(operation2) {
+ if (operation2.point) operation2.point(anchorPoint);
+ });
+ _editMenu.anchorLoc(anchorPoint).triggerType(triggerType).operations(operations);
+ context.map().supersurface.call(_editMenu);
+ };
+ ui.closeEditMenu = function() {
+ context.map().supersurface.select(".edit-menu").remove();
+ };
+ var _saveLoading = select_default2(null);
+ context.uploader().on("saveStarted.ui", function() {
+ _saveLoading = uiLoading(context).message(_t.html("save.uploading")).blocking(true);
+ context.container().call(_saveLoading);
+ }).on("saveEnded.ui", function() {
+ _saveLoading.close();
+ _saveLoading = select_default2(null);
+ });
+ marked.use({
+ mangle: false,
+ headerIds: false
+ });
+ return ui;
+ }
+
+ // modules/ui/commit_warnings.js
+ function uiCommitWarnings(context) {
+ function commitWarnings(selection2) {
+ var issuesBySeverity = context.validator().getIssuesBySeverity({ what: "edited", where: "all", includeDisabledRules: true });
+ for (var severity in issuesBySeverity) {
+ var issues = issuesBySeverity[severity];
+ if (severity !== "error") {
+ issues = issues.filter(function(issue) {
+ return issue.type !== "help_request";
+ });
+ }
+ var section = severity + "-section";
+ var issueItem = severity + "-item";
+ var container = selection2.selectAll("." + section).data(issues.length ? [0] : []);
+ container.exit().remove();
+ var containerEnter = container.enter().append("div").attr("class", "modal-section " + section + " fillL2");
+ containerEnter.append("h3").call(severity === "warning" ? _t.append("commit.warnings") : _t.append("commit.errors"));
+ containerEnter.append("ul").attr("class", "changeset-list");
+ container = containerEnter.merge(container);
+ var items = container.select("ul").selectAll("li").data(issues, function(d2) {
+ return d2.key;
+ });
+ items.exit().remove();
+ var itemsEnter = items.enter().append("li").attr("class", issueItem);
+ var buttons = itemsEnter.append("button").on("mouseover", function(d3_event, d2) {
+ if (d2.entityIds) {
+ context.surface().selectAll(
+ utilEntityOrMemberSelector(
+ d2.entityIds,
+ context.graph()
+ )
+ ).classed("hover", true);
+ }
+ }).on("mouseout", function() {
+ context.surface().selectAll(".hover").classed("hover", false);
+ }).on("click", function(d3_event, d2) {
+ context.validator().focusIssue(d2);
+ });
+ buttons.call(svgIcon("#iD-icon-alert", "pre-text"));
+ buttons.append("strong").attr("class", "issue-message");
+ buttons.filter(function(d2) {
+ return d2.tooltip;
+ }).call(
+ uiTooltip().title(function(d2) {
+ return d2.tooltip;
+ }).placement("top")
+ );
+ items = itemsEnter.merge(items);
+ items.selectAll(".issue-message").text("").each(function(d2) {
+ return d2.message(context)(select_default2(this));
+ });
+ }
+ }
+ return commitWarnings;
+ }
+
+ // modules/ui/lasso.js
+ function uiLasso(context) {
+ var group, polygon2;
+ lasso.coordinates = [];
+ function lasso(selection2) {
+ context.container().classed("lasso", true);
+ group = selection2.append("g").attr("class", "lasso hide");
+ polygon2 = group.append("path").attr("class", "lasso-path");
+ group.call(uiToggle(true));
+ }
+ function draw() {
+ if (polygon2) {
+ polygon2.data([lasso.coordinates]).attr("d", function(d2) {
+ return "M" + d2.join(" L") + " Z";
+ });
+ }
+ }
+ lasso.extent = function() {
+ return lasso.coordinates.reduce(function(extent, point) {
+ return extent.extend(geoExtent(point));
+ }, geoExtent());
+ };
+ lasso.p = function(_2) {
+ if (!arguments.length) return lasso;
+ lasso.coordinates.push(_2);
+ draw();
+ return lasso;
+ };
+ lasso.close = function() {
+ if (group) {
+ group.call(uiToggle(false, function() {
+ select_default2(this).remove();
+ }));
+ }
+ context.container().classed("lasso", false);
+ };
+ return lasso;
+ }
+
+ // node_modules/osm-community-index/lib/simplify.js
+ var import_diacritics2 = __toESM(require_diacritics(), 1);
+ function simplify(str) {
+ if (typeof str !== "string") return "";
+ return import_diacritics2.default.remove(
+ str.replace(/&/g, "and").replace(/(İ|i̇)/ig, "i").replace(/[\s\-=_!"#%'*{},.\/:;?\(\)\[\]@\\$\^*+<>«»~`’\u00a1\u00a7\u00b6\u00b7\u00bf\u037e\u0387\u055a-\u055f\u0589\u05c0\u05c3\u05c6\u05f3\u05f4\u0609\u060a\u060c\u060d\u061b\u061e\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0830-\u083e\u085e\u0964\u0965\u0970\u0af0\u0df4\u0e4f\u0e5a\u0e5b\u0f04-\u0f12\u0f14\u0f85\u0fd0-\u0fd4\u0fd9\u0fda\u104a-\u104f\u10fb\u1360-\u1368\u166d\u166e\u16eb-\u16ed\u1735\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u1805\u1807-\u180a\u1944\u1945\u1a1e\u1a1f\u1aa0-\u1aa6\u1aa8-\u1aad\u1b5a-\u1b60\u1bfc-\u1bff\u1c3b-\u1c3f\u1c7e\u1c7f\u1cc0-\u1cc7\u1cd3\u2000-\u206f\u2cf9-\u2cfc\u2cfe\u2cff\u2d70\u2e00-\u2e7f\u3001-\u3003\u303d\u30fb\ua4fe\ua4ff\ua60d-\ua60f\ua673\ua67e\ua6f2-\ua6f7\ua874-\ua877\ua8ce\ua8cf\ua8f8-\ua8fa\ua92e\ua92f\ua95f\ua9c1-\ua9cd\ua9de\ua9df\uaa5c-\uaa5f\uaade\uaadf\uaaf0\uaaf1\uabeb\ufe10-\ufe16\ufe19\ufe30\ufe45\ufe46\ufe49-\ufe4c\ufe50-\ufe52\ufe54-\ufe57\ufe5f-\ufe61\ufe68\ufe6a\ufe6b\ufeff\uff01-\uff03\uff05-\uff07\uff0a\uff0c\uff0e\uff0f\uff1a\uff1b\uff1f\uff20\uff3c\uff61\uff64\uff65]+/g, "").toLowerCase()
+ );
+ }
+
+ // node_modules/osm-community-index/lib/resolve_strings.js
+ function resolveStrings(item, defaults, localizerFn) {
+ let itemStrings = Object.assign({}, item.strings);
+ let defaultStrings = Object.assign({}, defaults[item.type]);
+ const anyToken = new RegExp(/(\{\w+\})/, "gi");
+ if (localizerFn) {
+ if (itemStrings.community) {
+ const communityID = simplify(itemStrings.community);
+ itemStrings.community = localizerFn("_communities.".concat(communityID));
+ }
+ ["name", "description", "extendedDescription"].forEach((prop) => {
+ if (defaultStrings[prop]) defaultStrings[prop] = localizerFn("_defaults.".concat(item.type, ".").concat(prop));
+ if (itemStrings[prop]) itemStrings[prop] = localizerFn("".concat(item.id, ".").concat(prop));
+ });
+ }
+ let replacements = {
+ account: item.account,
+ community: itemStrings.community,
+ signupUrl: itemStrings.signupUrl,
+ url: itemStrings.url
+ };
+ if (!replacements.signupUrl) {
+ replacements.signupUrl = resolve(itemStrings.signupUrl || defaultStrings.signupUrl);
+ }
+ if (!replacements.url) {
+ replacements.url = resolve(itemStrings.url || defaultStrings.url);
+ }
+ let resolved = {
+ name: resolve(itemStrings.name || defaultStrings.name),
+ url: resolve(itemStrings.url || defaultStrings.url),
+ signupUrl: resolve(itemStrings.signupUrl || defaultStrings.signupUrl),
+ description: resolve(itemStrings.description || defaultStrings.description),
+ extendedDescription: resolve(itemStrings.extendedDescription || defaultStrings.extendedDescription)
+ };
+ resolved.nameHTML = linkify(resolved.url, resolved.name);
+ resolved.urlHTML = linkify(resolved.url);
+ resolved.signupUrlHTML = linkify(resolved.signupUrl);
+ resolved.descriptionHTML = resolve(itemStrings.description || defaultStrings.description, true);
+ resolved.extendedDescriptionHTML = resolve(itemStrings.extendedDescription || defaultStrings.extendedDescription, true);
+ return resolved;
+ function resolve(s2, addLinks) {
+ if (!s2) return void 0;
+ let result = s2;
+ for (let key in replacements) {
+ const token = "{".concat(key, "}");
+ const regex = new RegExp(token, "g");
+ if (regex.test(result)) {
+ let replacement = replacements[key];
+ if (!replacement) {
+ throw new Error("Cannot resolve token: ".concat(token));
+ } else {
+ if (addLinks && (key === "signupUrl" || key === "url")) {
+ replacement = linkify(replacement);
+ }
+ result = result.replace(regex, replacement);
+ }
+ }
+ }
+ const leftovers = result.match(anyToken);
+ if (leftovers) {
+ throw new Error("Cannot resolve tokens: ".concat(leftovers));
+ }
+ if (addLinks && item.type === "reddit") {
+ result = result.replace(/(\/r\/\w+\/*)/i, (match) => linkify(resolved.url, match));
+ }
+ return result;
+ }
+ function linkify(url, text) {
+ if (!url) return void 0;
+ text = text || url;
+ return '<a target="_blank" href="'.concat(url, '">').concat(text, "</a>");
+ }
+ }
+
+ // modules/ui/success.js
+ var _oci = null;
+ function uiSuccess(context) {
+ const MAXEVENTS = 2;
+ const dispatch14 = dispatch_default("cancel");
+ let _changeset2;
+ let _location;
+ ensureOSMCommunityIndex();
+ function ensureOSMCommunityIndex() {
+ const data = _mainFileFetcher;
+ return Promise.all([
+ data.get("oci_features"),
+ data.get("oci_resources"),
+ data.get("oci_defaults")
+ ]).then((vals) => {
+ if (_oci) return _oci;
+ if (vals[0] && Array.isArray(vals[0].features)) {
+ _sharedLocationManager.mergeCustomGeoJSON(vals[0]);
+ }
+ let ociResources = Object.values(vals[1].resources);
+ if (ociResources.length) {
+ return _sharedLocationManager.mergeLocationSets(ociResources).then(() => {
+ _oci = {
+ resources: ociResources,
+ defaults: vals[2].defaults
+ };
+ return _oci;
+ });
+ } else {
+ _oci = {
+ resources: [],
+ // no resources?
+ defaults: vals[2].defaults
+ };
+ return _oci;
+ }
+ });
+ }
+ function parseEventDate(when) {
+ if (!when) return;
+ let raw = when.trim();
+ if (!raw) return;
+ if (!/Z$/.test(raw)) {
+ raw += "Z";
+ }
+ const parsed = new Date(raw);
+ return new Date(parsed.toUTCString().slice(0, 25));
+ }
+ function success(selection2) {
+ let header = selection2.append("div").attr("class", "header fillL");
+ header.append("h2").call(_t.append("success.just_edited"));
+ header.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => dispatch14.call("cancel")).call(svgIcon("#iD-icon-close"));
+ let body = selection2.append("div").attr("class", "body save-success fillL");
+ let summary = body.append("div").attr("class", "save-summary");
+ summary.append("h3").call(_t.append("success.thank_you" + (_location ? "_location" : ""), { where: _location }));
+ summary.append("p").call(_t.append("success.help_html")).append("a").attr("class", "link-out").attr("target", "_blank").attr("href", _t("success.help_link_url")).call(svgIcon("#iD-icon-out-link", "inline")).append("span").call(_t.append("success.help_link_text"));
+ let osm = context.connection();
+ if (!osm) return;
+ let changesetURL = osm.changesetURL(_changeset2.id);
+ let table = summary.append("table").attr("class", "summary-table");
+ let row = table.append("tr").attr("class", "summary-row");
+ row.append("td").attr("class", "cell-icon summary-icon").append("a").attr("target", "_blank").attr("href", changesetURL).append("svg").attr("class", "logo-small").append("use").attr("xlink:href", "#iD-logo-osm");
+ let summaryDetail = row.append("td").attr("class", "cell-detail summary-detail");
+ summaryDetail.append("a").attr("class", "cell-detail summary-view-on-osm").attr("target", "_blank").attr("href", changesetURL).call(_t.append("success.view_on_osm"));
+ summaryDetail.append("div").html(_t.html("success.changeset_id", {
+ changeset_id: { html: '<a href="'.concat(changesetURL, '" target="_blank">').concat(_changeset2.id, "</a>") }
+ }));
+ if (showDonationMessage !== false) {
+ const donationUrl = "https://supporting.openstreetmap.org/";
+ let supporting = body.append("div").attr("class", "save-supporting");
+ supporting.append("h3").call(_t.append("success.supporting.title"));
+ supporting.append("p").call(_t.append("success.supporting.details"));
+ table = supporting.append("table").attr("class", "supporting-table");
+ row = table.append("tr").attr("class", "supporting-row");
+ row.append("td").attr("class", "cell-icon supporting-icon").append("a").attr("target", "_blank").attr("href", donationUrl).append("svg").attr("class", "logo-small").append("use").attr("xlink:href", "#iD-donation");
+ let supportingDetail = row.append("td").attr("class", "cell-detail supporting-detail");
+ supportingDetail.append("a").attr("class", "cell-detail support-the-map").attr("target", "_blank").attr("href", donationUrl).call(_t.append("success.supporting.donation.title"));
+ supportingDetail.append("div").call(_t.append("success.supporting.donation.details"));
+ }
+ ensureOSMCommunityIndex().then((oci) => {
+ const loc = context.map().center();
+ const validHere = _sharedLocationManager.locationSetsAt(loc);
+ let communities = [];
+ oci.resources.forEach((resource) => {
+ let area = validHere[resource.locationSetID];
+ if (!area) return;
+ const localizer = (stringID) => _t.html("community.".concat(stringID));
+ resource.resolved = resolveStrings(resource, oci.defaults, localizer);
+ communities.push({
+ area,
+ order: resource.order || 0,
+ resource
+ });
+ });
+ communities.sort((a2, b2) => a2.area - b2.area || b2.order - a2.order);
+ body.call(showCommunityLinks, communities.map((c2) => c2.resource));
+ });
+ }
+ function showCommunityLinks(selection2, resources) {
+ let communityLinks = selection2.append("div").attr("class", "save-communityLinks");
+ communityLinks.append("h3").call(_t.append("success.like_osm"));
+ let table = communityLinks.append("table").attr("class", "community-table");
+ let row = table.selectAll(".community-row").data(resources);
+ let rowEnter = row.enter().append("tr").attr("class", "community-row");
+ rowEnter.append("td").attr("class", "cell-icon community-icon").append("a").attr("target", "_blank").attr("href", (d2) => d2.resolved.url).append("svg").attr("class", "logo-small").append("use").attr("xlink:href", (d2) => "#community-".concat(d2.type));
+ let communityDetail = rowEnter.append("td").attr("class", "cell-detail community-detail");
+ communityDetail.each(showCommunityDetails);
+ communityLinks.append("div").attr("class", "community-missing").call(_t.append("success.missing")).append("a").attr("class", "link-out").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).attr("href", "https://github.com/osmlab/osm-community-index/issues").append("span").call(_t.append("success.tell_us"));
+ }
+ function showCommunityDetails(d2) {
+ let selection2 = select_default2(this);
+ let communityID = d2.id;
+ selection2.append("div").attr("class", "community-name").html(d2.resolved.nameHTML);
+ selection2.append("div").attr("class", "community-description").html(d2.resolved.descriptionHTML);
+ if (d2.resolved.extendedDescriptionHTML || d2.languageCodes && d2.languageCodes.length) {
+ selection2.append("div").call(
+ uiDisclosure(context, "community-more-".concat(d2.id), false).expanded(false).updatePreference(false).label(() => _t.append("success.more")).content(showMore)
+ );
+ }
+ let nextEvents = (d2.events || []).map((event) => {
+ event.date = parseEventDate(event.when);
+ return event;
+ }).filter((event) => {
+ const t2 = event.date.getTime();
+ const now3 = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0);
+ return !isNaN(t2) && t2 >= now3;
+ }).sort((a2, b2) => {
+ return a2.date < b2.date ? -1 : a2.date > b2.date ? 1 : 0;
+ }).slice(0, MAXEVENTS);
+ if (nextEvents.length) {
+ selection2.append("div").call(
+ uiDisclosure(context, "community-events-".concat(d2.id), false).expanded(false).updatePreference(false).label(_t.html("success.events")).content(showNextEvents)
+ ).select(".hide-toggle").append("span").attr("class", "badge-text").text(nextEvents.length);
+ }
+ function showMore(selection3) {
+ let more = selection3.selectAll(".community-more").data([0]);
+ let moreEnter = more.enter().append("div").attr("class", "community-more");
+ if (d2.resolved.extendedDescriptionHTML) {
+ moreEnter.append("div").attr("class", "community-extended-description").html(d2.resolved.extendedDescriptionHTML);
+ }
+ if (d2.languageCodes && d2.languageCodes.length) {
+ const languageList = d2.languageCodes.map((code) => _mainLocalizer.languageName(code)).join(", ");
+ moreEnter.append("div").attr("class", "community-languages").call(_t.append("success.languages", { languages: languageList }));
+ }
+ }
+ function showNextEvents(selection3) {
+ let events = selection3.append("div").attr("class", "community-events");
+ let item = events.selectAll(".community-event").data(nextEvents);
+ let itemEnter = item.enter().append("div").attr("class", "community-event");
+ itemEnter.append("div").attr("class", "community-event-name").append("a").attr("target", "_blank").attr("href", (d4) => d4.url).text((d4) => {
+ let name = d4.name;
+ if (d4.i18n && d4.id) {
+ name = _t("community.".concat(communityID, ".events.").concat(d4.id, ".name"), { default: name });
+ }
+ return name;
+ });
+ itemEnter.append("div").attr("class", "community-event-when").text((d4) => {
+ let options2 = { weekday: "short", day: "numeric", month: "short", year: "numeric" };
+ if (d4.date.getHours() || d4.date.getMinutes()) {
+ options2.hour = "numeric";
+ options2.minute = "numeric";
+ }
+ return d4.date.toLocaleString(_mainLocalizer.localeCode(), options2);
+ });
+ itemEnter.append("div").attr("class", "community-event-where").text((d4) => {
+ let where = d4.where;
+ if (d4.i18n && d4.id) {
+ where = _t("community.".concat(communityID, ".events.").concat(d4.id, ".where"), { default: where });
+ }
+ return where;
+ });
+ itemEnter.append("div").attr("class", "community-event-description").text((d4) => {
+ let description = d4.description;
+ if (d4.i18n && d4.id) {
+ description = _t("community.".concat(communityID, ".events.").concat(d4.id, ".description"), { default: description });
+ }
+ return description;
+ });
+ }
+ }
+ success.changeset = function(val) {
+ if (!arguments.length) return _changeset2;
+ _changeset2 = val;
+ return success;
+ };
+ success.location = function(val) {
+ if (!arguments.length) return _location;
+ _location = val;
+ return success;
+ };
+ return utilRebind(success, dispatch14, "on");
+ }
+
+ // modules/ui/fields/input.js
+ var likelyRawNumberFormat = /^-?(0\.\d*|\d*\.\d{0,2}(\d{4,})?|\d{4,}\.\d{3})$/;
+ function uiFieldText(field, context) {
+ var dispatch14 = dispatch_default("change");
+ var input = select_default2(null);
+ var outlinkButton = select_default2(null);
+ var wrap2 = select_default2(null);
+ var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue());
+ var _entityIDs = [];
+ var _tags;
+ var _phoneFormats = {};
+ const isDirectionField = field.key.split(":").some((keyPart) => keyPart === "direction");
+ const formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
+ const parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
+ const countDecimalPlaces = _mainLocalizer.decimalPlaceCounter(_mainLocalizer.languageCode());
+ if (field.type === "tel") {
+ _mainFileFetcher.get("phone_formats").then(function(d2) {
+ _phoneFormats = d2;
+ updatePhonePlaceholder();
+ }).catch(function() {
+ });
+ }
+ function calcLocked() {
+ var isLocked = (field.id === "brand" || field.id === "network" || field.id === "operator" || field.id === "flag") && _entityIDs.length && _entityIDs.some(function(entityID) {
+ var entity = context.graph().hasEntity(entityID);
+ if (!entity) return false;
+ if (entity.tags.wikidata) return true;
+ var preset = _mainPresetIndex.match(entity, context.graph());
+ var isSuggestion = preset && preset.suggestion;
+ var which = field.id;
+ return isSuggestion && !!entity.tags[which] && !!entity.tags[which + ":wikidata"];
+ });
+ field.locked(isLocked);
+ }
+ function i3(selection2) {
+ calcLocked();
+ var isLocked = field.locked();
+ wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
+ wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
+ input = wrap2.selectAll("input").data([0]);
+ input = input.enter().append("input").attr("type", field.type === "identifier" ? "text" : field.type).attr("id", field.domId).classed(field.type, true).call(utilNoAuto).merge(input);
+ input.classed("disabled", !!isLocked).attr("readonly", isLocked || null).on("input", change(true)).on("blur", change()).on("change", change());
+ wrap2.call(_lengthIndicator);
+ if (field.type === "tel") {
+ updatePhonePlaceholder();
+ } else if (field.type === "number") {
+ var rtl = _mainLocalizer.textDirection() === "rtl";
+ input.attr("type", "text");
+ var inc = field.increment;
+ var buttons = wrap2.selectAll(".increment, .decrement").data(rtl ? [inc, -inc] : [-inc, inc]);
+ buttons.enter().append("button").attr("class", function(d2) {
+ var which = d2 > 0 ? "increment" : "decrement";
+ return "form-field-button " + which;
+ }).attr("title", function(d2) {
+ var which = d2 > 0 ? "increment" : "decrement";
+ return _t("inspector.".concat(which));
+ }).merge(buttons).on("click", function(d3_event, d2) {
+ d3_event.preventDefault();
+ var isMixed = Array.isArray(_tags[field.key]);
+ if (isMixed) return;
+ var raw_vals = input.node().value || "0";
+ var vals = raw_vals.split(";");
+ vals = vals.map(function(v2) {
+ v2 = v2.trim();
+ const isRawNumber = likelyRawNumberFormat.test(v2);
+ var num = isRawNumber ? parseFloat(v2) : parseLocaleFloat(v2);
+ if (isDirectionField) {
+ const compassDir = cardinal[v2.toLowerCase()];
+ if (compassDir !== void 0) {
+ num = compassDir;
+ }
+ }
+ if (!isFinite(num)) return v2;
+ num = parseFloat(num);
+ if (!isFinite(num)) return v2;
+ num += d2;
+ if (isDirectionField) {
+ num = (num % 360 + 360) % 360;
+ }
+ return formatFloat(clamped(num), isRawNumber ? v2.includes(".") ? v2.split(".")[1].length : 0 : countDecimalPlaces(v2));
+ });
+ input.node().value = vals.join(";");
+ change()();
+ });
+ } else if (field.type === "identifier" && field.urlFormat && field.pattern) {
+ input.attr("type", "text");
+ outlinkButton = wrap2.selectAll(".foreign-id-permalink").data([0]);
+ outlinkButton = outlinkButton.enter().append("button").call(svgIcon("#iD-icon-out-link")).attr("class", "form-field-button foreign-id-permalink").attr("title", function() {
+ var domainResults = /^https?:\/\/(.{1,}?)\//.exec(field.urlFormat);
+ if (domainResults.length >= 2 && domainResults[1]) {
+ var domain = domainResults[1];
+ return _t("icons.view_on", { domain });
+ }
+ return "";
+ }).merge(outlinkButton);
+ outlinkButton.on("click", function(d3_event) {
+ d3_event.preventDefault();
+ var value = validIdentifierValueForLink();
+ if (value) {
+ var url = field.urlFormat.replace(/{value}/, encodeURIComponent(value));
+ window.open(url, "_blank");
+ }
+ }).classed("disabled", () => !validIdentifierValueForLink()).merge(outlinkButton);
+ } else if (field.type === "url") {
+ input.attr("type", "text");
+ outlinkButton = wrap2.selectAll(".foreign-id-permalink").data([0]);
+ outlinkButton.enter().append("button").call(svgIcon("#iD-icon-out-link")).attr("class", "form-field-button foreign-id-permalink").attr("title", () => _t("icons.visit_website")).on("click", function(d3_event) {
+ d3_event.preventDefault();
+ const value = validIdentifierValueForLink();
+ if (value) window.open(value, "_blank");
+ }).merge(outlinkButton);
+ } else if (field.type === "colour") {
+ input.attr("type", "text");
+ updateColourPreview();
+ } else if (field.type === "date") {
+ input.attr("type", "text");
+ updateDateField();
+ }
+ }
+ function updateColourPreview() {
+ wrap2.selectAll(".colour-preview").remove();
+ const colour = utilGetSetValue(input);
+ if (!isColourValid(colour) && colour !== "") {
+ wrap2.selectAll("input.colour-selector").remove();
+ wrap2.selectAll(".form-field-button").remove();
+ return;
+ }
+ var colourSelector = wrap2.selectAll(".colour-selector").data([0]);
+ colourSelector.enter().append("input").attr("type", "color").attr("class", "colour-selector").on("input", debounce_default(function(d3_event) {
+ d3_event.preventDefault();
+ var colour2 = this.value;
+ if (!isColourValid(colour2)) return;
+ utilGetSetValue(input, this.value);
+ change()();
+ updateColourPreview();
+ }, 100));
+ wrap2.selectAll("input.colour-selector").attr("value", colour);
+ var chooserButton = wrap2.selectAll(".colour-preview").data([colour]);
+ chooserButton = chooserButton.enter().append("div").attr("class", "form-field-button colour-preview").append("div").style("background-color", (d2) => d2).attr("class", "colour-box");
+ if (colour === "") {
+ chooserButton = chooserButton.call(svgIcon("#iD-icon-edit"));
+ }
+ chooserButton.on("click", () => wrap2.select(".colour-selector").node().showPicker());
+ }
+ function updateDateField() {
+ function isDateValid(date2) {
+ return date2.match(/^[0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?$/);
+ }
+ const date = utilGetSetValue(input);
+ const now3 = /* @__PURE__ */ new Date();
+ const today = new Date(now3.getTime() - now3.getTimezoneOffset() * 6e4).toISOString().split("T")[0];
+ if ((field.key === "check_date" || field.key === "survey:date") && date !== today) {
+ wrap2.selectAll(".date-set-today").data([0]).enter().append("button").attr("class", "form-field-button date-set-today").call(svgIcon("#fas-rotate")).call(uiTooltip().title(() => _t.append("inspector.set_today"))).on("click", () => {
+ utilGetSetValue(input, today);
+ change()();
+ updateDateField();
+ });
+ } else {
+ wrap2.selectAll(".date-set-today").remove();
+ }
+ if (!isDateValid(date) && date !== "") {
+ wrap2.selectAll("input.date-selector").remove();
+ wrap2.selectAll(".date-calendar").remove();
+ return;
+ }
+ if (utilDetect().browser !== "Safari") {
+ var dateSelector = wrap2.selectAll(".date-selector").data([0]);
+ dateSelector.enter().append("input").attr("type", "date").attr("class", "date-selector").on("input", debounce_default(function(d3_event) {
+ d3_event.preventDefault();
+ var date2 = this.value;
+ if (!isDateValid(date2)) return;
+ utilGetSetValue(input, this.value);
+ change()();
+ updateDateField();
+ }, 100));
+ wrap2.selectAll("input.date-selector").attr("value", date);
+ var calendarButton = wrap2.selectAll(".date-calendar").data([date]);
+ calendarButton = calendarButton.enter().append("button").attr("class", "form-field-button date-calendar").call(svgIcon("#fas-calendar-days"));
+ calendarButton.on("click", () => wrap2.select(".date-selector").node().showPicker());
+ }
+ }
+ function updatePhonePlaceholder() {
+ if (input.empty() || !Object.keys(_phoneFormats).length) return;
+ var extent = combinedEntityExtent();
+ var countryCode = extent && iso1A2Code(extent.center());
+ var format2 = countryCode && _phoneFormats[countryCode.toLowerCase()];
+ if (format2) input.attr("placeholder", format2);
+ }
+ function validIdentifierValueForLink() {
+ var _a3;
+ const value = utilGetSetValue(input).trim();
+ if (field.type === "url" && value) {
+ try {
+ return new URL(value).href;
+ } catch {
+ return null;
+ }
+ }
+ if (field.type === "identifier" && field.pattern) {
+ return value && ((_a3 = value.match(new RegExp(field.pattern))) == null ? void 0 : _a3[0]);
+ }
+ return null;
+ }
+ function clamped(num) {
+ if (field.minValue !== void 0) {
+ num = Math.max(num, field.minValue);
+ }
+ if (field.maxValue !== void 0) {
+ num = Math.min(num, field.maxValue);
+ }
+ return num;
+ }
+ function getVals(tags) {
+ if (field.keys) {
+ const multiSelection = context.selectedIDs();
+ tags = multiSelection.length > 1 ? context.selectedIDs().map((id2) => context.graph().entity(id2)).map((entity) => entity.tags) : [tags];
+ return tags.map((tags2) => new Set(field.keys.reduce((acc, key) => acc.concat(tags2[key]), []).filter(Boolean))).map((vals) => vals.size === 0 ? /* @__PURE__ */ new Set([void 0]) : vals).reduce((a2, b2) => /* @__PURE__ */ new Set([...a2, ...b2]));
+ } else {
+ return new Set([].concat(tags[field.key]));
+ }
+ }
+ function change(onInput) {
+ return function() {
+ var t2 = {};
+ var val = utilGetSetValue(input);
+ if (!onInput) val = context.cleanTagValue(val);
+ if (!val && getVals(_tags).size > 1) return;
+ var displayVal = val;
+ if (field.type === "number" && val) {
+ var numbers2 = val.split(";");
+ numbers2 = numbers2.map(function(v2) {
+ if (likelyRawNumberFormat.test(v2)) {
+ return v2;
+ }
+ var num = parseLocaleFloat(v2);
+ const fractionDigits = countDecimalPlaces(v2);
+ return isFinite(num) ? clamped(num).toFixed(fractionDigits) : v2;
+ });
+ val = numbers2.join(";");
+ }
+ if (!onInput) utilGetSetValue(input, displayVal);
+ t2[field.key] = val || void 0;
+ if (field.keys) {
+ dispatch14.call("change", this, (tags) => {
+ if (field.keys.some((key) => tags[key])) {
+ field.keys.filter((key) => tags[key]).forEach((key) => {
+ tags[key] = val || void 0;
+ });
+ } else {
+ tags[field.key] = val || void 0;
+ }
+ return tags;
+ }, onInput);
+ } else {
+ dispatch14.call("change", this, t2, onInput);
+ }
+ };
+ }
+ i3.entityIDs = function(val) {
+ if (!arguments.length) return _entityIDs;
+ _entityIDs = val;
+ return i3;
+ };
+ i3.tags = function(tags) {
+ var _a3;
+ _tags = tags;
+ const vals = getVals(tags);
+ const isMixed = vals.size > 1;
+ var val = vals.size === 1 ? (_a3 = [...vals][0]) != null ? _a3 : "" : "";
+ var shouldUpdate;
+ if (field.type === "number" && val) {
+ var numbers2 = val.split(";");
+ var oriNumbers = utilGetSetValue(input).split(";");
+ if (numbers2.length !== oriNumbers.length) shouldUpdate = true;
+ numbers2 = numbers2.map(function(v2) {
+ v2 = v2.trim();
+ var num = Number(v2);
+ if (!isFinite(num) || v2 === "") return v2;
+ const fractionDigits = v2.includes(".") ? v2.split(".")[1].length : 0;
+ return formatFloat(num, fractionDigits);
+ });
+ val = numbers2.join(";");
+ shouldUpdate = (inputValue, setValue) => {
+ const inputNums = inputValue.split(";").map(
+ (setVal) => likelyRawNumberFormat.test(setVal) ? parseFloat(setVal) : parseLocaleFloat(setVal)
+ );
+ const setNums = setValue.split(";").map(parseLocaleFloat);
+ return !isEqual_default(inputNums, setNums);
+ };
+ }
+ utilGetSetValue(input, val, shouldUpdate).attr("title", isMixed ? [...vals].join("\n") : void 0).attr("placeholder", isMixed ? _t("inspector.multiple_values") : field.placeholder() || _t("inspector.unknown")).classed("mixed", isMixed);
+ if (field.type === "number") {
+ const buttons = wrap2.selectAll(".increment, .decrement");
+ if (isMixed) {
+ buttons.attr("disabled", "disabled").classed("disabled", true);
+ } else {
+ var raw_vals = tags[field.key] || "0";
+ const canIncDec = raw_vals.split(";").some((val2) => isFinite(Number(val2)) || isDirectionField && cardinal[val2.trim().toLowerCase()]);
+ buttons.attr("disabled", canIncDec ? null : "disabled").classed("disabled", !canIncDec);
+ }
+ }
+ if (field.type === "tel") updatePhonePlaceholder();
+ if (field.type === "colour") updateColourPreview();
+ if (field.type === "date") updateDateField();
+ if (outlinkButton && !outlinkButton.empty()) {
+ var disabled = !validIdentifierValueForLink();
+ outlinkButton.classed("disabled", disabled);
+ }
+ if (!isMixed) {
+ _lengthIndicator.update(tags[field.key]);
+ }
+ };
+ i3.focus = function() {
+ var node = input.node();
+ if (node) node.focus();
+ };
+ function combinedEntityExtent() {
+ return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
+ }
+ return utilRebind(i3, dispatch14, "on");
+ }
+
+ // modules/ui/fields/access.js
+ function uiFieldAccess(field, context) {
+ var dispatch14 = dispatch_default("change");
+ var items = select_default2(null);
+ var _tags;
+ function access(selection2) {
+ var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
+ wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
+ var list2 = wrap2.selectAll("ul").data([0]);
+ list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
+ items = list2.selectAll("li").data(field.keys);
+ var enter = items.enter().append("li").attr("class", function(d2) {
+ return "labeled-input preset-access-" + d2;
+ });
+ enter.append("div").attr("class", "label preset-label-access").attr("for", function(d2) {
+ return "preset-input-access-" + d2;
+ }).html(function(d2) {
+ return field.t.html("types." + d2);
+ });
+ enter.append("div").attr("class", "preset-input-access-wrap").append("input").attr("type", "text").attr("class", function(d2) {
+ return "preset-input-access preset-input-access-" + d2;
+ }).call(utilNoAuto).each(function(d2) {
+ select_default2(this).call(
+ uiCombobox(context, "access-" + d2).data(access.options(d2))
+ );
+ });
+ items = items.merge(enter);
+ wrap2.selectAll(".preset-input-access").on("change", change).on("blur", change);
+ }
+ function change(d3_event, d2) {
+ var tag2 = {};
+ var value = context.cleanTagValue(utilGetSetValue(select_default2(this)));
+ if (!value && typeof _tags[d2] !== "string") return;
+ tag2[d2] = value || void 0;
+ dispatch14.call("change", this, tag2);
+ }
+ access.options = function(type2) {
+ var options2 = [
+ "yes",
+ "no",
+ "designated",
+ "permissive",
+ "destination",
+ "customers",
+ "private",
+ "permit",
+ "unknown"
+ ];
+ if (type2 === "access") {
+ options2 = options2.filter((v2) => v2 !== "yes" && v2 !== "designated");
+ }
+ if (type2 === "bicycle") {
+ options2.splice(options2.length - 4, 0, "dismount");
+ }
+ var stringsField = field.resolveReference("stringsCrossReference");
+ return options2.map(function(option) {
+ return {
+ title: stringsField.t("options." + option + ".description"),
+ value: option
+ };
+ });
+ };
+ const placeholdersByTag = {
+ highway: {
+ footway: {
+ foot: "designated",
+ motor_vehicle: "no"
+ },
+ steps: {
+ foot: "yes",
+ motor_vehicle: "no",
+ bicycle: "no",
+ horse: "no"
+ },
+ ladder: {
+ foot: "yes",
+ motor_vehicle: "no",
+ bicycle: "no",
+ horse: "no"
+ },
+ pedestrian: {
+ foot: "yes",
+ motor_vehicle: "no"
+ },
+ cycleway: {
+ motor_vehicle: "no",
+ bicycle: "designated"
+ },
+ bridleway: {
+ motor_vehicle: "no",
+ horse: "designated"
+ },
+ path: {
+ foot: "yes",
+ motor_vehicle: "no",
+ bicycle: "yes",
+ horse: "yes"
+ },
+ motorway: {
+ foot: "no",
+ motor_vehicle: "yes",
+ bicycle: "no",
+ horse: "no"
+ },
+ trunk: {
+ motor_vehicle: "yes"
+ },
+ primary: {
+ foot: "yes",
+ motor_vehicle: "yes",
+ bicycle: "yes",
+ horse: "yes"
+ },
+ secondary: {
+ foot: "yes",
+ motor_vehicle: "yes",
+ bicycle: "yes",
+ horse: "yes"
+ },
+ tertiary: {
+ foot: "yes",
+ motor_vehicle: "yes",
+ bicycle: "yes",
+ horse: "yes"
+ },
+ residential: {
+ foot: "yes",
+ motor_vehicle: "yes",
+ bicycle: "yes",
+ horse: "yes"
+ },
+ unclassified: {
+ foot: "yes",
+ motor_vehicle: "yes",
+ bicycle: "yes",
+ horse: "yes"
+ },
+ service: {
+ foot: "yes",
+ motor_vehicle: "yes",
+ bicycle: "yes",
+ horse: "yes"
+ },
+ motorway_link: {
+ foot: "no",
+ motor_vehicle: "yes",
+ bicycle: "no",
+ horse: "no"
+ },
+ trunk_link: {
+ motor_vehicle: "yes"
+ },
+ primary_link: {
+ foot: "yes",
+ motor_vehicle: "yes",
+ bicycle: "yes",
+ horse: "yes"
+ },
+ secondary_link: {
+ foot: "yes",
+ motor_vehicle: "yes",
+ bicycle: "yes",
+ horse: "yes"
+ },
+ tertiary_link: {
+ foot: "yes",
+ motor_vehicle: "yes",
+ bicycle: "yes",
+ horse: "yes"
+ },
+ construction: {
+ access: "no"
+ },
+ busway: {
+ access: "no",
+ bus: "designated",
+ emergency: "yes"
+ }
+ },
+ barrier: {
+ bollard: {
+ access: "no",
+ bicycle: "yes",
+ foot: "yes"
+ },
+ bus_trap: {
+ motor_vehicle: "no",
+ psv: "yes",
+ foot: "yes",
+ bicycle: "yes"
+ },
+ city_wall: {
+ access: "no"
+ },
+ coupure: {
+ access: "yes"
+ },
+ cycle_barrier: {
+ motor_vehicle: "no"
+ },
+ ditch: {
+ access: "no"
+ },
+ entrance: {
+ access: "yes"
+ },
+ fence: {
+ access: "no"
+ },
+ hedge: {
+ access: "no"
+ },
+ jersey_barrier: {
+ access: "no"
+ },
+ motorcycle_barrier: {
+ motor_vehicle: "no"
+ },
+ rail_guard: {
+ access: "no"
+ }
+ }
+ };
+ access.tags = function(tags) {
+ _tags = tags;
+ utilGetSetValue(items.selectAll(".preset-input-access"), function(d2) {
+ return typeof tags[d2] === "string" ? tags[d2] : "";
+ }).classed("mixed", function(d2) {
+ return tags[d2] && Array.isArray(tags[d2]);
+ }).attr("title", function(d2) {
+ return tags[d2] && Array.isArray(tags[d2]) && tags[d2].filter(Boolean).join("\n");
+ }).attr("placeholder", function(d2) {
+ if (tags[d2] && Array.isArray(tags[d2])) {
+ return _t("inspector.multiple_values");
+ }
+ if (d2 === "bicycle" || d2 === "motor_vehicle") {
+ if (tags.vehicle && typeof tags.vehicle === "string") {
+ return tags.vehicle;
+ }
+ }
+ if (tags.access && typeof tags.access === "string") {
+ return tags.access;
+ }
+ function getPlaceholdersByTag(key, placeholdersByKey) {
+ if (typeof tags[key] === "string") {
+ if (placeholdersByKey[tags[key]] && placeholdersByKey[tags[key]][d2]) {
+ return placeholdersByKey[tags[key]][d2];
+ }
+ } else {
+ var impliedAccesses = tags[key].filter(Boolean).map(function(val) {
+ return placeholdersByKey[val] && placeholdersByKey[val][d2];
+ }).filter(Boolean);
+ if (impliedAccesses.length === tags[key].length && new Set(impliedAccesses).size === 1) {
+ return impliedAccesses[0];
+ }
+ }
+ }
+ for (const key in placeholdersByTag) {
+ if (tags[key]) {
+ const impliedAccess = getPlaceholdersByTag(key, placeholdersByTag[key]);
+ if (impliedAccess) {
+ return impliedAccess;
+ }
+ }
+ }
+ if (d2 === "access" && !tags.barrier) {
+ return "yes";
+ }
+ return field.placeholder();
+ });
+ };
+ access.focus = function() {
+ items.selectAll(".preset-input-access").node().focus();
+ };
+ return utilRebind(access, dispatch14, "on");
+ }
+
+ // modules/ui/fields/address.js
+ function uiFieldAddress(field, context) {
+ var dispatch14 = dispatch_default("change");
+ var _selection = select_default2(null);
+ var _wrap = select_default2(null);
+ var addrField = _mainPresetIndex.field("address");
+ var _entityIDs = [];
+ var _tags;
+ var _countryCode;
+ var _addressFormats = [{
+ format: [
+ ["housenumber", "street"],
+ ["city", "postcode"]
+ ]
+ }];
+ _mainFileFetcher.get("address_formats").then(function(d2) {
+ _addressFormats = d2;
+ if (!_selection.empty()) {
+ _selection.call(address);
+ }
+ }).catch(function() {
+ });
+ function getNear(isAddressable, type2, searchRadius, resultProp) {
+ var extent = combinedEntityExtent();
+ var l2 = extent.center();
+ var box = geoExtent(l2).padByMeters(searchRadius);
+ var features = context.history().intersects(box).filter(isAddressable).map((d2) => {
+ let dist = geoSphericalDistance(d2.extent(context.graph()).center(), l2);
+ if (d2.geometry(context.graph()) === "line") {
+ var loc = context.projection([
+ (extent[0][0] + extent[1][0]) / 2,
+ (extent[0][1] + extent[1][1]) / 2
+ ]);
+ var choice = geoChooseEdge(context.graph().childNodes(d2), loc, context.projection);
+ dist = geoSphericalDistance(choice.loc, l2);
+ }
+ const value = resultProp && d2.tags[resultProp] ? d2.tags[resultProp] : d2.tags.name;
+ let title = value;
+ if (type2 === "street") {
+ title = "".concat(addrField.t("placeholders.street"), ": ").concat(title);
+ } else if (type2 === "place") {
+ title = "".concat(addrField.t("placeholders.place"), ": ").concat(title);
+ }
+ return {
+ title,
+ value,
+ dist,
+ type: type2,
+ klass: "address-".concat(type2)
+ };
+ }).sort(function(a2, b2) {
+ return a2.dist - b2.dist;
+ });
+ return utilArrayUniqBy(features, "value");
+ }
+ function getNearStreets() {
+ function isAddressable(d2) {
+ return d2.tags.highway && d2.tags.name && d2.type === "way";
+ }
+ return getNear(isAddressable, "street", 200);
+ }
+ function getNearPlaces() {
+ function isAddressable(d2) {
+ if (d2.tags.name) {
+ if (d2.tags.place) return true;
+ if (d2.tags.boundary === "administrative" && d2.tags.admin_level > 8) return true;
+ }
+ return false;
+ }
+ return getNear(isAddressable, "place", 200);
+ }
+ function getNearCities() {
+ function isAddressable(d2) {
+ if (d2.tags.name) {
+ if (d2.tags.boundary === "administrative" && d2.tags.admin_level === "8") return true;
+ if (d2.tags.border_type === "city") return true;
+ if (d2.tags.place === "city" || d2.tags.place === "town" || d2.tags.place === "village") return true;
+ }
+ if (d2.tags["".concat(field.key, ":city")]) return true;
+ return false;
+ }
+ return getNear(isAddressable, "city", 200, "".concat(field.key, ":city"));
+ }
+ function getNearPostcodes() {
+ return [...new Set([].concat(getNearValues("postcode")).concat(getNear((d2) => d2.tags.postal_code, "postcode", 200, "postal_code")))];
+ }
+ function getNearValues(key) {
+ const tagKey = "".concat(field.key, ":").concat(key);
+ function hasTag(d2) {
+ return _entityIDs.indexOf(d2.id) === -1 && d2.tags[tagKey];
+ }
+ return getNear(hasTag, key, 200, tagKey);
+ }
+ function updateForCountryCode() {
+ if (!_countryCode) return;
+ var addressFormat;
+ for (var i3 = 0; i3 < _addressFormats.length; i3++) {
+ var format2 = _addressFormats[i3];
+ if (!format2.countryCodes) {
+ addressFormat = format2;
+ } else if (format2.countryCodes.indexOf(_countryCode) !== -1) {
+ addressFormat = format2;
+ break;
+ }
+ }
+ var dropdowns = addressFormat.dropdowns || [
+ "city",
+ "county",
+ "country",
+ "district",
+ "hamlet",
+ "neighbourhood",
+ "place",
+ "postcode",
+ "province",
+ "quarter",
+ "state",
+ "street",
+ "street+place",
+ "subdistrict",
+ "suburb"
+ ];
+ var widths = addressFormat.widths || {
+ housenumber: 1 / 5,
+ unit: 1 / 5,
+ street: 1 / 2,
+ place: 1 / 2,
+ city: 2 / 3,
+ state: 1 / 4,
+ postcode: 1 / 3
+ };
+ function row(r2) {
+ var total = r2.reduce(function(sum, key) {
+ return sum + (widths[key] || 0.5);
+ }, 0);
+ return r2.map(function(key) {
+ return {
+ id: key,
+ width: (widths[key] || 0.5) / total
+ };
+ });
+ }
+ var rows = _wrap.selectAll(".addr-row").data(addressFormat.format, function(d2) {
+ return d2.toString();
+ });
+ rows.exit().remove();
+ rows.enter().append("div").attr("class", "addr-row").selectAll("input").data(row).enter().append("input").property("type", "text").call(updatePlaceholder).attr("class", function(d2) {
+ return "addr-" + d2.id;
+ }).call(utilNoAuto).each(addDropdown).style("width", function(d2) {
+ return d2.width * 100 + "%";
+ });
+ function addDropdown(d2) {
+ if (dropdowns.indexOf(d2.id) === -1) return;
+ var nearValues;
+ switch (d2.id) {
+ case "street":
+ nearValues = getNearStreets;
+ break;
+ case "place":
+ nearValues = getNearPlaces;
+ break;
+ case "street+place":
+ nearValues = () => [].concat(getNearStreets()).concat(getNearPlaces());
+ d2.isAutoStreetPlace = true;
+ d2.id = _tags["".concat(field.key, ":place")] ? "place" : "street";
+ break;
+ case "city":
+ nearValues = getNearCities;
+ break;
+ case "postcode":
+ nearValues = getNearPostcodes;
+ break;
+ default:
+ nearValues = getNearValues;
+ }
+ select_default2(this).call(
+ uiCombobox(context, "address-".concat(d2.isAutoStreetPlace ? "street-place" : d2.id)).minItems(1).caseSensitive(true).fetcher(function(typedValue, callback) {
+ typedValue = typedValue.toLowerCase();
+ callback(nearValues(d2.id).filter((v2) => v2.value.toLowerCase().indexOf(typedValue) !== -1));
+ }).on("accept", function(selected) {
+ if (d2.isAutoStreetPlace) {
+ d2.id = selected ? selected.type : "street";
+ utilTriggerEvent(select_default2(this), "change");
+ }
+ })
+ );
+ }
+ _wrap.selectAll("input").on("blur", change()).on("change", change());
+ _wrap.selectAll("input:not(.combobox-input)").on("input", change(true));
+ if (_tags) updateTags(_tags);
+ }
+ function address(selection2) {
+ _selection = selection2;
+ _wrap = selection2.selectAll(".form-field-input-wrap").data([0]);
+ _wrap = _wrap.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(_wrap);
+ var extent = combinedEntityExtent();
+ if (extent) {
+ var countryCode;
+ if (context.inIntro()) {
+ countryCode = _t("intro.graph.countrycode");
+ } else {
+ var center = extent.center();
+ countryCode = iso1A2Code(center);
+ }
+ if (countryCode) {
+ _countryCode = countryCode.toLowerCase();
+ updateForCountryCode();
+ }
+ }
+ }
+ function change(onInput) {
+ return function() {
+ var tags = {};
+ _wrap.selectAll("input").each(function(subfield) {
+ var key = field.key + ":" + subfield.id;
+ var value = this.value;
+ if (!onInput) value = context.cleanTagValue(value);
+ if (Array.isArray(_tags[key]) && !value) return;
+ if (subfield.isAutoStreetPlace) {
+ if (subfield.id === "street") {
+ tags["".concat(field.key, ":place")] = void 0;
+ } else if (subfield.id === "place") {
+ tags["".concat(field.key, ":street")] = void 0;
+ }
+ }
+ tags[key] = value || void 0;
+ });
+ Object.keys(tags).filter((k2) => tags[k2]).forEach((k2) => _tags[k2] = tags[k2]);
+ dispatch14.call("change", this, tags, onInput);
+ };
+ }
+ function updatePlaceholder(inputSelection) {
+ return inputSelection.attr("placeholder", function(subfield) {
+ if (_tags && Array.isArray(_tags[field.key + ":" + subfield.id])) {
+ return _t("inspector.multiple_values");
+ }
+ if (subfield.isAutoStreetPlace) {
+ return "".concat(getLocalPlaceholder("street"), " / ").concat(getLocalPlaceholder("place"));
+ }
+ return getLocalPlaceholder(subfield.id);
+ });
+ }
+ function getLocalPlaceholder(key) {
+ if (_countryCode) {
+ var localkey = key + "!" + _countryCode;
+ var tkey = addrField.hasTextForStringId("placeholders." + localkey) ? localkey : key;
+ return addrField.t("placeholders." + tkey);
+ }
+ }
+ function updateTags(tags) {
+ utilGetSetValue(_wrap.selectAll("input"), (subfield) => {
+ var val;
+ if (subfield.isAutoStreetPlace) {
+ const streetKey = "".concat(field.key, ":street");
+ const placeKey = "".concat(field.key, ":place");
+ if (tags[streetKey] !== void 0 || tags[placeKey] === void 0) {
+ val = tags[streetKey];
+ subfield.id = "street";
+ } else {
+ val = tags[placeKey];
+ subfield.id = "place";
+ }
+ } else {
+ val = tags["".concat(field.key, ":").concat(subfield.id)];
+ }
+ return typeof val === "string" ? val : "";
+ }).attr("title", function(subfield) {
+ var val = tags[field.key + ":" + subfield.id];
+ return val && Array.isArray(val) ? val.filter(Boolean).join("\n") : void 0;
+ }).classed("mixed", function(subfield) {
+ return Array.isArray(tags[field.key + ":" + subfield.id]);
+ }).call(updatePlaceholder);
+ }
+ function combinedEntityExtent() {
+ return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
+ }
+ address.entityIDs = function(val) {
+ if (!arguments.length) return _entityIDs;
+ _entityIDs = val;
+ return address;
+ };
+ address.tags = function(tags) {
+ _tags = tags;
+ updateTags(tags);
+ };
+ address.focus = function() {
+ var node = _wrap.selectAll("input").node();
+ if (node) node.focus();
+ };
+ return utilRebind(address, dispatch14, "on");
+ }
+
+ // modules/ui/fields/directional_combo.js
+ function uiFieldDirectionalCombo(field, context) {
+ var dispatch14 = dispatch_default("change");
+ var items = select_default2(null);
+ var wrap2 = select_default2(null);
+ var _tags;
+ var _combos = {};
+ if (field.type === "cycleway") {
+ field = {
+ ...field,
+ key: field.keys[0],
+ keys: field.keys.slice(1)
+ };
+ }
+ function directionalCombo(selection2) {
+ function stripcolon(s2) {
+ return s2.replace(":", "");
+ }
+ wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
+ wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
+ var div = wrap2.selectAll("ul").data([0]);
+ div = div.enter().append("ul").attr("class", "rows rows-table").merge(div);
+ items = div.selectAll("li").data(field.keys);
+ var enter = items.enter().append("li").attr("class", function(d2) {
+ return "labeled-input preset-directionalcombo-" + stripcolon(d2);
+ });
+ enter.append("div").attr("class", "label preset-label-directionalcombo").attr("for", function(d2) {
+ return "preset-input-directionalcombo-" + stripcolon(d2);
+ }).html(function(d2) {
+ return field.t.html("types." + d2);
+ });
+ enter.append("div").attr("class", "preset-input-directionalcombo-wrap form-field-input-wrap").each(function(key) {
+ const subField = {
+ ...field,
+ type: "combo",
+ key
+ };
+ const combo = uiFieldCombo(subField, context);
+ combo.on("change", (t2) => change(key, t2[key]));
+ _combos[key] = combo;
+ select_default2(this).call(combo);
+ });
+ items = items.merge(enter);
+ wrap2.selectAll(".preset-input-directionalcombo").on("change", change).on("blur", change);
+ }
+ function change(key, newValue) {
+ const commonKey = field.key;
+ const otherKey = key === field.keys[0] ? field.keys[1] : field.keys[0];
+ dispatch14.call("change", this, (tags) => {
+ const otherValue = tags[otherKey] || tags[commonKey];
+ if (newValue === otherValue) {
+ tags[commonKey] = newValue;
+ delete tags[key];
+ delete tags[otherKey];
+ } else {
+ tags[key] = newValue;
+ delete tags[commonKey];
+ tags[otherKey] = otherValue;
+ }
+ return tags;
+ });
+ }
+ directionalCombo.tags = function(tags) {
+ _tags = tags;
+ const commonKey = field.key;
+ for (let key in _combos) {
+ const uniqueValues = [...new Set([].concat(_tags[commonKey]).concat(_tags[key]).filter(Boolean))];
+ _combos[key].tags({ [key]: uniqueValues.length > 1 ? uniqueValues : uniqueValues[0] });
+ }
+ };
+ directionalCombo.focus = function() {
+ var node = wrap2.selectAll("input").node();
+ if (node) node.focus();
+ };
+ return utilRebind(directionalCombo, dispatch14, "on");
+ }
+
+ // modules/ui/fields/lanes.js
+ function uiFieldLanes(field, context) {
+ var dispatch14 = dispatch_default("change");
+ var LANE_WIDTH = 40;
+ var LANE_HEIGHT = 200;
+ var _entityIDs = [];
+ function lanes(selection2) {
+ var lanesData = context.entity(_entityIDs[0]).lanes();
+ if (!context.container().select(".inspector-wrap.inspector-hidden").empty() || !selection2.node().parentNode) {
+ selection2.call(lanes.off);
+ return;
+ }
+ var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
+ wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
+ var surface = wrap2.selectAll(".surface").data([0]);
+ var d2 = utilGetDimensions(wrap2);
+ var freeSpace = d2[0] - lanesData.lanes.length * LANE_WIDTH * 1.5 + LANE_WIDTH * 0.5;
+ surface = surface.enter().append("svg").attr("width", d2[0]).attr("height", 300).attr("class", "surface").merge(surface);
+ var lanesSelection = surface.selectAll(".lanes").data([0]);
+ lanesSelection = lanesSelection.enter().append("g").attr("class", "lanes").merge(lanesSelection);
+ lanesSelection.attr("transform", function() {
+ return "translate(" + freeSpace / 2 + ", 0)";
+ });
+ var lane = lanesSelection.selectAll(".lane").data(lanesData.lanes);
+ lane.exit().remove();
+ var enter = lane.enter().append("g").attr("class", "lane");
+ enter.append("g").append("rect").attr("y", 50).attr("width", LANE_WIDTH).attr("height", LANE_HEIGHT);
+ enter.append("g").attr("class", "forward").append("text").attr("y", 40).attr("x", 14).text("\u25B2");
+ enter.append("g").attr("class", "bothways").append("text").attr("y", 40).attr("x", 14).text("\u25B2\u25BC");
+ enter.append("g").attr("class", "backward").append("text").attr("y", 40).attr("x", 14).text("\u25BC");
+ lane = lane.merge(enter);
+ lane.attr("transform", function(d4) {
+ return "translate(" + LANE_WIDTH * d4.index * 1.5 + ", 0)";
+ });
+ lane.select(".forward").style("visibility", function(d4) {
+ return d4.direction === "forward" ? "visible" : "hidden";
+ });
+ lane.select(".bothways").style("visibility", function(d4) {
+ return d4.direction === "bothways" ? "visible" : "hidden";
+ });
+ lane.select(".backward").style("visibility", function(d4) {
+ return d4.direction === "backward" ? "visible" : "hidden";
+ });
+ }
+ lanes.entityIDs = function(val) {
+ _entityIDs = val;
+ };
+ lanes.tags = function() {
+ };
+ lanes.focus = function() {
+ };
+ lanes.off = function() {
+ };
+ return utilRebind(lanes, dispatch14, "on");
+ }
+ uiFieldLanes.supportsMultiselection = false;
+
+ // modules/ui/fields/localized.js
+ var _languagesArray = [];
+ var LANGUAGE_SUFFIX_REGEX = /^(.*):([a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2})?)$/;
+ function uiFieldLocalized(field, context) {
+ var dispatch14 = dispatch_default("change", "input");
+ var wikipedia = services.wikipedia;
+ var input = select_default2(null);
+ var localizedInputs = select_default2(null);
+ var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue());
+ var _countryCode;
+ var _tags;
+ _mainFileFetcher.get("languages").then(loadLanguagesArray).catch(function() {
+ });
+ var _territoryLanguages = {};
+ _mainFileFetcher.get("territory_languages").then(function(d2) {
+ _territoryLanguages = d2;
+ }).catch(function() {
+ });
+ var langCombo = uiCombobox(context, "localized-lang").fetcher(fetchLanguages).minItems(0);
+ var _selection = select_default2(null);
+ var _multilingual = [];
+ var _buttonTip = uiTooltip().title(() => _t.append("translate.translate")).placement("left");
+ var _wikiTitles;
+ var _entityIDs = [];
+ function loadLanguagesArray(dataLanguages) {
+ if (_languagesArray.length !== 0) return;
+ var replacements = {
+ sr: "sr-Cyrl",
+ // in OSM, `sr` implies Cyrillic
+ "sr-Cyrl": false
+ // `sr-Cyrl` isn't used in OSM
+ };
+ for (var code in dataLanguages) {
+ if (replacements[code] === false) continue;
+ var metaCode = code;
+ if (replacements[code]) metaCode = replacements[code];
+ _languagesArray.push({
+ localName: _mainLocalizer.languageName(metaCode, { localOnly: true }),
+ nativeName: dataLanguages[metaCode].nativeName,
+ code,
+ label: _mainLocalizer.languageName(metaCode)
+ });
+ }
+ }
+ function calcLocked() {
+ var isLocked = field.id === "name" && _entityIDs.length && _entityIDs.some(function(entityID) {
+ var entity = context.graph().hasEntity(entityID);
+ if (!entity) return false;
+ if (entity.tags.wikidata) return true;
+ if (entity.tags["name:etymology:wikidata"]) return true;
+ var preset = _mainPresetIndex.match(entity, context.graph());
+ if (preset) {
+ var isSuggestion = preset.suggestion;
+ var fields = preset.fields(entity.extent(context.graph()).center());
+ var showsBrandField = fields.some(function(d2) {
+ return d2.id === "brand";
+ });
+ var showsOperatorField = fields.some(function(d2) {
+ return d2.id === "operator";
+ });
+ var setsName = preset.addTags.name;
+ var setsBrandWikidata = preset.addTags["brand:wikidata"];
+ var setsOperatorWikidata = preset.addTags["operator:wikidata"];
+ return isSuggestion && setsName && (setsBrandWikidata && !showsBrandField || setsOperatorWikidata && !showsOperatorField);
+ }
+ return false;
+ });
+ field.locked(isLocked);
+ }
+ function calcMultilingual(tags) {
+ var existingLangsOrdered = _multilingual.map(function(item2) {
+ return item2.lang;
+ });
+ var existingLangs = new Set(existingLangsOrdered.filter(Boolean));
+ for (var k2 in tags) {
+ var m2 = k2.match(LANGUAGE_SUFFIX_REGEX);
+ if (m2 && m2[1] === field.key && m2[2]) {
+ var item = { lang: m2[2], value: tags[k2] };
+ if (existingLangs.has(item.lang)) {
+ _multilingual[existingLangsOrdered.indexOf(item.lang)].value = item.value;
+ existingLangs.delete(item.lang);
+ } else {
+ _multilingual.push(item);
+ }
+ }
+ }
+ _multilingual.forEach(function(item2) {
+ if (item2.lang && existingLangs.has(item2.lang)) {
+ item2.value = "";
+ }
+ });
+ }
+ function localized(selection2) {
+ _selection = selection2;
+ calcLocked();
+ var isLocked = field.locked();
+ var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
+ wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
+ input = wrap2.selectAll(".localized-main").data([0]);
+ input = input.enter().append("input").attr("type", "text").attr("id", field.domId).attr("class", "localized-main").call(utilNoAuto).merge(input);
+ input.classed("disabled", !!isLocked).attr("readonly", isLocked || null).on("input", change(true)).on("blur", change()).on("change", change());
+ wrap2.call(_lengthIndicator);
+ var translateButton = wrap2.selectAll(".localized-add").data([0]);
+ translateButton = translateButton.enter().append("button").attr("class", "localized-add form-field-button").attr("aria-label", _t("icons.plus")).call(svgIcon("#iD-icon-plus")).merge(translateButton);
+ translateButton.classed("disabled", !!isLocked).call(isLocked ? _buttonTip.destroy : _buttonTip).on("click", addNew);
+ if (_tags && !_multilingual.length) {
+ calcMultilingual(_tags);
+ }
+ localizedInputs = selection2.selectAll(".localized-multilingual").data([0]);
+ localizedInputs = localizedInputs.enter().append("div").attr("class", "localized-multilingual").merge(localizedInputs);
+ localizedInputs.call(renderMultilingual);
+ localizedInputs.selectAll("button, input").classed("disabled", !!isLocked).attr("readonly", isLocked || null);
+ selection2.selectAll(".combobox-caret").classed("nope", true);
+ function addNew(d3_event) {
+ d3_event.preventDefault();
+ if (field.locked()) return;
+ var defaultLang = _mainLocalizer.languageCode().toLowerCase();
+ var langExists = _multilingual.find(function(datum2) {
+ return datum2.lang === defaultLang;
+ });
+ var isLangEn = defaultLang.indexOf("en") > -1;
+ if (isLangEn || langExists) {
+ defaultLang = "";
+ langExists = _multilingual.find(function(datum2) {
+ return datum2.lang === defaultLang;
+ });
+ }
+ if (!langExists) {
+ _multilingual.unshift({ lang: defaultLang, value: "" });
+ localizedInputs.call(renderMultilingual);
+ }
+ }
+ function change(onInput) {
+ return function(d3_event) {
+ if (field.locked()) {
+ d3_event.preventDefault();
+ return;
+ }
+ var val = utilGetSetValue(select_default2(this));
+ if (!onInput) val = context.cleanTagValue(val);
+ if (!val && Array.isArray(_tags[field.key])) return;
+ var t2 = {};
+ t2[field.key] = val || void 0;
+ dispatch14.call("change", this, t2, onInput);
+ };
+ }
+ }
+ function key(lang) {
+ return field.key + ":" + lang;
+ }
+ function changeLang(d3_event, d2) {
+ var tags = {};
+ var lang = utilGetSetValue(select_default2(this)).toLowerCase();
+ var language = _languagesArray.find(function(d4) {
+ return d4.label.toLowerCase() === lang || d4.localName && d4.localName.toLowerCase() === lang || d4.nativeName && d4.nativeName.toLowerCase() === lang;
+ });
+ if (language) lang = language.code;
+ if (d2.lang && d2.lang !== lang) {
+ tags[key(d2.lang)] = void 0;
+ }
+ var newKey = lang && context.cleanTagKey(key(lang));
+ var value = utilGetSetValue(select_default2(this.parentNode).selectAll(".localized-value"));
+ if (newKey && value) {
+ tags[newKey] = value;
+ } else if (newKey && _wikiTitles && _wikiTitles[d2.lang]) {
+ tags[newKey] = _wikiTitles[d2.lang];
+ }
+ d2.lang = lang;
+ dispatch14.call("change", this, tags);
+ }
+ function changeValue(d3_event, d2) {
+ if (!d2.lang) return;
+ var value = context.cleanTagValue(utilGetSetValue(select_default2(this))) || void 0;
+ if (!value && Array.isArray(d2.value)) return;
+ var t2 = {};
+ t2[key(d2.lang)] = value;
+ d2.value = value;
+ dispatch14.call("change", this, t2);
+ }
+ function fetchLanguages(value, cb) {
+ var v2 = value.toLowerCase();
+ var langCodes = [_mainLocalizer.localeCode(), _mainLocalizer.languageCode()];
+ if (_countryCode && _territoryLanguages[_countryCode]) {
+ langCodes = langCodes.concat(_territoryLanguages[_countryCode]);
+ }
+ var langItems = [];
+ langCodes.forEach(function(code) {
+ var langItem = _languagesArray.find(function(item) {
+ return item.code === code;
+ });
+ if (langItem) langItems.push(langItem);
+ });
+ langItems = utilArrayUniq(langItems.concat(_languagesArray));
+ cb(langItems.filter(function(d2) {
+ return d2.label.toLowerCase().indexOf(v2) >= 0 || d2.localName && d2.localName.toLowerCase().indexOf(v2) >= 0 || d2.nativeName && d2.nativeName.toLowerCase().indexOf(v2) >= 0 || d2.code.toLowerCase().indexOf(v2) >= 0;
+ }).map(function(d2) {
+ return { value: d2.label };
+ }));
+ }
+ function renderMultilingual(selection2) {
+ var entries = selection2.selectAll("div.entry").data(_multilingual, function(d2) {
+ return d2.lang;
+ });
+ entries.exit().style("top", "0").style("max-height", "240px").transition().duration(200).style("opacity", "0").style("max-height", "0px").remove();
+ var entriesEnter = entries.enter().append("div").attr("class", "entry").each(function(_2, index) {
+ var wrap2 = select_default2(this);
+ var domId = utilUniqueDomId(index);
+ var label = wrap2.append("label").attr("class", "field-label").attr("for", domId);
+ var text = label.append("span").attr("class", "label-text");
+ text.append("span").attr("class", "label-textvalue").call(_t.append("translate.localized_translation_label"));
+ text.append("span").attr("class", "label-textannotation");
+ label.append("button").attr("class", "remove-icon-multilingual").attr("title", _t("icons.remove")).on("click", function(d3_event, d2) {
+ if (field.locked()) return;
+ d3_event.preventDefault();
+ _multilingual.splice(_multilingual.indexOf(d2), 1);
+ var langKey = d2.lang && key(d2.lang);
+ if (langKey && langKey in _tags) {
+ delete _tags[langKey];
+ var t2 = {};
+ t2[langKey] = void 0;
+ dispatch14.call("change", this, t2);
+ return;
+ }
+ renderMultilingual(selection2);
+ }).call(svgIcon("#iD-operation-delete"));
+ wrap2.append("input").attr("class", "localized-lang").attr("id", domId).attr("type", "text").attr("placeholder", _t("translate.localized_translation_language")).on("blur", changeLang).on("change", changeLang).call(langCombo);
+ wrap2.append("input").attr("type", "text").attr("class", "localized-value").on("blur", changeValue).on("change", changeValue);
+ });
+ entriesEnter.style("margin-top", "0px").style("max-height", "0px").style("opacity", "0").transition().duration(200).style("margin-top", "10px").style("max-height", "240px").style("opacity", "1").on("end", function() {
+ select_default2(this).style("max-height", "").style("overflow", "visible");
+ });
+ entries = entries.merge(entriesEnter);
+ entries.order();
+ entries.classed("present", true);
+ utilGetSetValue(entries.select(".localized-lang"), function(d2) {
+ var langItem = _languagesArray.find(function(item) {
+ return item.code === d2.lang;
+ });
+ if (langItem) return langItem.label;
+ return d2.lang;
+ });
+ utilGetSetValue(entries.select(".localized-value"), function(d2) {
+ return typeof d2.value === "string" ? d2.value : "";
+ }).attr("title", function(d2) {
+ return Array.isArray(d2.value) ? d2.value.filter(Boolean).join("\n") : null;
+ }).attr("placeholder", function(d2) {
+ return Array.isArray(d2.value) ? _t("inspector.multiple_values") : _t("translate.localized_translation_name");
+ }).classed("mixed", function(d2) {
+ return Array.isArray(d2.value);
+ });
+ }
+ localized.tags = function(tags) {
+ _tags = tags;
+ if (typeof tags.wikipedia === "string" && !_wikiTitles) {
+ _wikiTitles = {};
+ var wm = tags.wikipedia.match(/([^:]+):(.+)/);
+ if (wm && wm[0] && wm[1]) {
+ wikipedia.translations(wm[1], wm[2], function(err, d2) {
+ if (err || !d2) return;
+ _wikiTitles = d2;
+ });
+ }
+ }
+ var isMixed = Array.isArray(tags[field.key]);
+ utilGetSetValue(input, typeof tags[field.key] === "string" ? tags[field.key] : "").attr("title", isMixed ? tags[field.key].filter(Boolean).join("\n") : void 0).attr("placeholder", isMixed ? _t("inspector.multiple_values") : field.placeholder()).classed("mixed", isMixed);
+ calcMultilingual(tags);
+ _selection.call(localized);
+ if (!isMixed) {
+ _lengthIndicator.update(tags[field.key]);
+ }
+ };
+ localized.focus = function() {
+ input.node().focus();
+ };
+ localized.entityIDs = function(val) {
+ if (!arguments.length) return _entityIDs;
+ _entityIDs = val;
+ _multilingual = [];
+ loadCountryCode();
+ return localized;
+ };
+ function loadCountryCode() {
+ var extent = combinedEntityExtent();
+ var countryCode = extent && iso1A2Code(extent.center());
+ _countryCode = countryCode && countryCode.toLowerCase();
+ }
+ function combinedEntityExtent() {
+ return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
+ }
+ return utilRebind(localized, dispatch14, "on");
+ }
+
+ // modules/ui/fields/roadheight.js
+ function uiFieldRoadheight(field, context) {
+ var dispatch14 = dispatch_default("change");
+ var primaryUnitInput = select_default2(null);
+ var primaryInput = select_default2(null);
+ var secondaryInput = select_default2(null);
+ var secondaryUnitInput = select_default2(null);
+ var _entityIDs = [];
+ var _tags;
+ var _isImperial;
+ var formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
+ var parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
+ var primaryUnits = [
+ {
+ value: "m",
+ title: _t("inspector.roadheight.meter")
+ },
+ {
+ value: "ft",
+ title: _t("inspector.roadheight.foot")
+ }
+ ];
+ var unitCombo = uiCombobox(context, "roadheight-unit").data(primaryUnits);
+ function roadheight(selection2) {
+ var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
+ wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
+ primaryInput = wrap2.selectAll("input.roadheight-number").data([0]);
+ primaryInput = primaryInput.enter().append("input").attr("type", "text").attr("class", "roadheight-number").attr("id", field.domId).call(utilNoAuto).merge(primaryInput);
+ primaryInput.on("change", change).on("blur", change);
+ var loc = combinedEntityExtent().center();
+ _isImperial = roadHeightUnit(loc) === "ft";
+ primaryUnitInput = wrap2.selectAll("input.roadheight-unit").data([0]);
+ primaryUnitInput = primaryUnitInput.enter().append("input").attr("type", "text").attr("class", "roadheight-unit").call(unitCombo).merge(primaryUnitInput);
+ primaryUnitInput.on("blur", changeUnits).on("change", changeUnits);
+ secondaryInput = wrap2.selectAll("input.roadheight-secondary-number").data([0]);
+ secondaryInput = secondaryInput.enter().append("input").attr("type", "text").attr("class", "roadheight-secondary-number").call(utilNoAuto).merge(secondaryInput);
+ secondaryInput.on("change", change).on("blur", change);
+ secondaryUnitInput = wrap2.selectAll("input.roadheight-secondary-unit").data([0]);
+ secondaryUnitInput = secondaryUnitInput.enter().append("input").attr("type", "text").call(utilNoAuto).classed("disabled", true).classed("roadheight-secondary-unit", true).attr("readonly", "readonly").merge(secondaryUnitInput);
+ function changeUnits() {
+ var primaryUnit = utilGetSetValue(primaryUnitInput);
+ if (primaryUnit === "m") {
+ _isImperial = false;
+ } else if (primaryUnit === "ft") {
+ _isImperial = true;
+ }
+ utilGetSetValue(primaryUnitInput, _isImperial ? "ft" : "m");
+ setUnitSuggestions();
+ change();
+ }
+ }
+ function setUnitSuggestions() {
+ utilGetSetValue(primaryUnitInput, _isImperial ? "ft" : "m");
+ }
+ function change() {
+ var tag2 = {};
+ var primaryValue = utilGetSetValue(primaryInput).trim();
+ var secondaryValue = utilGetSetValue(secondaryInput).trim();
+ if (!primaryValue && !secondaryValue && Array.isArray(_tags[field.key])) return;
+ if (!primaryValue && !secondaryValue) {
+ tag2[field.key] = void 0;
+ } else {
+ var rawPrimaryValue = likelyRawNumberFormat.test(primaryValue) ? parseFloat(primaryValue) : parseLocaleFloat(primaryValue);
+ if (isNaN(rawPrimaryValue)) rawPrimaryValue = primaryValue;
+ var rawSecondaryValue = likelyRawNumberFormat.test(secondaryValue) ? parseFloat(secondaryValue) : parseLocaleFloat(secondaryValue);
+ if (isNaN(rawSecondaryValue)) rawSecondaryValue = secondaryValue;
+ if (isNaN(rawPrimaryValue) || isNaN(rawSecondaryValue) || !_isImperial) {
+ tag2[field.key] = context.cleanTagValue(rawPrimaryValue);
+ } else {
+ if (rawPrimaryValue !== "") {
+ rawPrimaryValue = rawPrimaryValue + "'";
+ }
+ if (rawSecondaryValue !== "") {
+ rawSecondaryValue = rawSecondaryValue + '"';
+ }
+ tag2[field.key] = context.cleanTagValue(rawPrimaryValue + rawSecondaryValue);
+ }
+ }
+ dispatch14.call("change", this, tag2);
+ }
+ roadheight.tags = function(tags) {
+ _tags = tags;
+ var primaryValue = tags[field.key];
+ var secondaryValue;
+ var isMixed = Array.isArray(primaryValue);
+ if (!isMixed) {
+ if (primaryValue && (primaryValue.indexOf("'") >= 0 || primaryValue.indexOf('"') >= 0)) {
+ secondaryValue = primaryValue.match(/(-?[\d.]+)"/);
+ if (secondaryValue !== null) {
+ secondaryValue = formatFloat(parseFloat(secondaryValue[1]));
+ }
+ primaryValue = primaryValue.match(/(-?[\d.]+)'/);
+ if (primaryValue !== null) {
+ primaryValue = formatFloat(parseFloat(primaryValue[1]));
+ }
+ _isImperial = true;
+ } else if (primaryValue) {
+ var rawValue = primaryValue;
+ primaryValue = parseFloat(rawValue);
+ if (isNaN(primaryValue)) {
+ primaryValue = rawValue;
+ } else {
+ primaryValue = formatFloat(primaryValue);
+ }
+ _isImperial = false;
+ }
+ }
+ setUnitSuggestions();
+ var inchesPlaceholder = formatFloat(0);
+ utilGetSetValue(primaryInput, typeof primaryValue === "string" ? primaryValue : "").attr("title", isMixed ? primaryValue.filter(Boolean).join("\n") : null).attr("placeholder", isMixed ? _t("inspector.multiple_values") : _t("inspector.unknown")).classed("mixed", isMixed);
+ utilGetSetValue(secondaryInput, typeof secondaryValue === "string" ? secondaryValue : "").attr("placeholder", isMixed ? _t("inspector.multiple_values") : _isImperial ? inchesPlaceholder : null).classed("mixed", isMixed).classed("disabled", !_isImperial).attr("readonly", _isImperial ? null : "readonly");
+ secondaryUnitInput.attr("value", _isImperial ? _t("inspector.roadheight.inch") : null);
+ };
+ roadheight.focus = function() {
+ primaryInput.node().focus();
+ };
+ roadheight.entityIDs = function(val) {
+ _entityIDs = val;
+ };
+ function combinedEntityExtent() {
+ return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
+ }
+ return utilRebind(roadheight, dispatch14, "on");
+ }
+
+ // modules/ui/fields/roadspeed.js
+ function uiFieldRoadspeed(field, context) {
+ var dispatch14 = dispatch_default("change");
+ var unitInput = select_default2(null);
+ var input = select_default2(null);
+ var _entityIDs = [];
+ var _tags;
+ var _isImperial;
+ var formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
+ var parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
+ var speedCombo = uiCombobox(context, "roadspeed");
+ var unitCombo = uiCombobox(context, "roadspeed-unit").data(["km/h", "mph"].map(comboValues));
+ var metricValues = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120];
+ var imperialValues = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80];
+ function roadspeed(selection2) {
+ var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
+ wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
+ input = wrap2.selectAll("input.roadspeed-number").data([0]);
+ input = input.enter().append("input").attr("type", "text").attr("class", "roadspeed-number").attr("id", field.domId).call(utilNoAuto).call(speedCombo).merge(input);
+ input.on("change", change).on("blur", change);
+ var loc = combinedEntityExtent().center();
+ _isImperial = roadSpeedUnit(loc) === "mph";
+ unitInput = wrap2.selectAll("input.roadspeed-unit").data([0]);
+ unitInput = unitInput.enter().append("input").attr("type", "text").attr("class", "roadspeed-unit").attr("aria-label", _t("inspector.speed_unit")).call(unitCombo).merge(unitInput);
+ unitInput.on("blur", changeUnits).on("change", changeUnits);
+ function changeUnits() {
+ var unit2 = utilGetSetValue(unitInput);
+ if (unit2 === "km/h") {
+ _isImperial = false;
+ } else if (unit2 === "mph") {
+ _isImperial = true;
+ }
+ utilGetSetValue(unitInput, _isImperial ? "mph" : "km/h");
+ setUnitSuggestions();
+ change();
+ }
+ }
+ function setUnitSuggestions() {
+ speedCombo.data((_isImperial ? imperialValues : metricValues).map(comboValues));
+ utilGetSetValue(unitInput, _isImperial ? "mph" : "km/h");
+ }
+ function comboValues(d2) {
+ return {
+ value: formatFloat(d2),
+ title: formatFloat(d2)
+ };
+ }
+ function change() {
+ var tag2 = {};
+ var value = utilGetSetValue(input).trim();
+ if (!value && Array.isArray(_tags[field.key])) return;
+ if (!value) {
+ tag2[field.key] = void 0;
+ } else {
+ var rawValue = likelyRawNumberFormat.test(value) ? parseFloat(value) : parseLocaleFloat(value);
+ if (isNaN(rawValue)) rawValue = value;
+ if (isNaN(rawValue) || !_isImperial) {
+ tag2[field.key] = context.cleanTagValue(rawValue);
+ } else {
+ tag2[field.key] = context.cleanTagValue(rawValue + " mph");
+ }
+ }
+ dispatch14.call("change", this, tag2);
+ }
+ roadspeed.tags = function(tags) {
+ _tags = tags;
+ var rawValue = tags[field.key];
+ var value = rawValue;
+ var isMixed = Array.isArray(value);
+ if (!isMixed) {
+ if (rawValue && rawValue.indexOf("mph") >= 0) {
+ _isImperial = true;
+ } else if (rawValue) {
+ _isImperial = false;
+ }
+ value = parseInt(value, 10);
+ if (isNaN(value)) {
+ value = rawValue;
+ } else {
+ value = formatFloat(value);
+ }
+ }
+ setUnitSuggestions();
+ utilGetSetValue(input, typeof value === "string" ? value : "").attr("title", isMixed ? value.filter(Boolean).join("\n") : null).attr("placeholder", isMixed ? _t("inspector.multiple_values") : field.placeholder()).classed("mixed", isMixed);
+ };
+ roadspeed.focus = function() {
+ input.node().focus();
+ };
+ roadspeed.entityIDs = function(val) {
+ _entityIDs = val;
+ };
+ function combinedEntityExtent() {
+ return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
+ }
+ return utilRebind(roadspeed, dispatch14, "on");
+ }
+
+ // modules/ui/fields/radio.js
+ function uiFieldRadio(field, context) {
+ var dispatch14 = dispatch_default("change");
+ var placeholder = select_default2(null);
+ var wrap2 = select_default2(null);
+ var labels = select_default2(null);
+ var radios = select_default2(null);
+ var radioData = (field.options || field.keys).slice();
+ var typeField;
+ var layerField;
+ var _oldType = {};
+ var _entityIDs = [];
+ function selectedKey() {
+ var node = wrap2.selectAll(".form-field-input-radio label.active input");
+ return !node.empty() && node.datum();
+ }
+ function radio(selection2) {
+ selection2.classed("preset-radio", true);
+ wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
+ var enter = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-radio");
+ enter.append("span").attr("class", "placeholder");
+ wrap2 = wrap2.merge(enter);
+ placeholder = wrap2.selectAll(".placeholder");
+ labels = wrap2.selectAll("label").data(radioData);
+ enter = labels.enter().append("label");
+ var stringsField = field.resolveReference("stringsCrossReference");
+ enter.append("input").attr("type", "radio").attr("name", field.id).attr("value", function(d2) {
+ return stringsField.t("options." + d2, { "default": d2 });
+ }).attr("checked", false);
+ enter.append("span").each(function(d2) {
+ stringsField.t.append("options." + d2, { "default": d2 })(select_default2(this));
+ });
+ labels = labels.merge(enter);
+ radios = labels.selectAll("input").on("change", changeRadio);
+ }
+ function structureExtras(selection2, tags) {
+ var selected = selectedKey() || tags.layer !== void 0;
+ var type2 = _mainPresetIndex.field(selected);
+ var layer = _mainPresetIndex.field("layer");
+ var showLayer = selected === "bridge" || selected === "tunnel" || tags.layer !== void 0;
+ var extrasWrap = selection2.selectAll(".structure-extras-wrap").data(selected ? [0] : []);
+ extrasWrap.exit().remove();
+ extrasWrap = extrasWrap.enter().append("div").attr("class", "structure-extras-wrap").merge(extrasWrap);
+ var list2 = extrasWrap.selectAll("ul").data([0]);
+ list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
+ if (type2) {
+ if (!typeField || typeField.id !== selected) {
+ typeField = uiField(context, type2, _entityIDs, { wrap: false }).on("change", changeType);
+ }
+ typeField.tags(tags);
+ } else {
+ typeField = null;
+ }
+ var typeItem = list2.selectAll(".structure-type-item").data(typeField ? [typeField] : [], function(d2) {
+ return d2.id;
+ });
+ typeItem.exit().remove();
+ var typeEnter = typeItem.enter().insert("li", ":first-child").attr("class", "labeled-input structure-type-item");
+ typeEnter.append("div").attr("class", "label structure-label-type").attr("for", "preset-input-" + selected).call(_t.append("inspector.radio.structure.type"));
+ typeEnter.append("div").attr("class", "structure-input-type-wrap");
+ typeItem = typeItem.merge(typeEnter);
+ if (typeField) {
+ typeItem.selectAll(".structure-input-type-wrap").call(typeField.render);
+ }
+ if (layer && showLayer) {
+ if (!layerField) {
+ layerField = uiField(context, layer, _entityIDs, { wrap: false }).on("change", changeLayer);
+ }
+ layerField.tags(tags);
+ field.keys = utilArrayUnion(field.keys, ["layer"]);
+ } else {
+ layerField = null;
+ field.keys = field.keys.filter(function(k2) {
+ return k2 !== "layer";
+ });
+ }
+ var layerItem = list2.selectAll(".structure-layer-item").data(layerField ? [layerField] : []);
+ layerItem.exit().remove();
+ var layerEnter = layerItem.enter().append("li").attr("class", "labeled-input structure-layer-item");
+ layerEnter.append("div").attr("class", "label structure-label-layer").attr("for", "preset-input-layer").call(_t.append("inspector.radio.structure.layer"));
+ layerEnter.append("div").attr("class", "structure-input-layer-wrap");
+ layerItem = layerItem.merge(layerEnter);
+ if (layerField) {
+ layerItem.selectAll(".structure-input-layer-wrap").call(layerField.render);
+ }
+ }
+ function changeType(t2, onInput) {
+ var key = selectedKey();
+ if (!key) return;
+ var val = t2[key];
+ if (val !== "no") {
+ _oldType[key] = val;
+ }
+ if (field.type === "structureRadio") {
+ if (val === "no" || key !== "bridge" && key !== "tunnel" || key === "tunnel" && val === "building_passage") {
+ t2.layer = void 0;
+ }
+ if (t2.layer === void 0) {
+ if (key === "bridge" && val !== "no") {
+ t2.layer = "1";
+ }
+ if (key === "tunnel" && val !== "no" && val !== "building_passage") {
+ t2.layer = "-1";
+ }
+ }
+ }
+ dispatch14.call("change", this, t2, onInput);
+ }
+ function changeLayer(t2, onInput) {
+ if (t2.layer === "0") {
+ t2.layer = void 0;
+ }
+ dispatch14.call("change", this, t2, onInput);
+ }
+ function changeRadio() {
+ var t2 = {};
+ var activeKey;
+ if (field.key) {
+ t2[field.key] = void 0;
+ }
+ radios.each(function(d2) {
+ var active = select_default2(this).property("checked");
+ if (active) activeKey = d2;
+ if (field.key) {
+ if (active) t2[field.key] = d2;
+ } else {
+ var val = _oldType[activeKey] || "yes";
+ t2[d2] = active ? val : void 0;
+ }
+ });
+ if (field.type === "structureRadio") {
+ if (activeKey === "bridge") {
+ t2.layer = "1";
+ } else if (activeKey === "tunnel" && t2.tunnel !== "building_passage") {
+ t2.layer = "-1";
+ } else {
+ t2.layer = void 0;
+ }
+ }
+ dispatch14.call("change", this, t2);
+ }
+ radio.tags = function(tags) {
+ function isOptionChecked(d2) {
+ if (field.key) {
+ return tags[field.key] === d2;
+ }
+ return !!(typeof tags[d2] === "string" && tags[d2].toLowerCase() !== "no");
+ }
+ function isMixed(d2) {
+ if (field.key) {
+ return Array.isArray(tags[field.key]) && tags[field.key].includes(d2);
+ }
+ return Array.isArray(tags[d2]);
+ }
+ radios.property("checked", function(d2) {
+ return isOptionChecked(d2) && (field.key || field.options.filter(isOptionChecked).length === 1);
+ });
+ labels.classed("active", function(d2) {
+ if (field.key) {
+ return Array.isArray(tags[field.key]) && tags[field.key].includes(d2) || tags[field.key] === d2;
+ }
+ return Array.isArray(tags[d2]) && tags[d2].some((v2) => typeof v2 === "string" && v2.toLowerCase() !== "no") || !!(typeof tags[d2] === "string" && tags[d2].toLowerCase() !== "no");
+ }).classed("mixed", isMixed).attr("title", function(d2) {
+ return isMixed(d2) ? _t("inspector.unshared_value_tooltip") : null;
+ });
+ var selection2 = radios.filter(function() {
+ return this.checked;
+ });
+ if (selection2.empty()) {
+ placeholder.text("");
+ placeholder.call(_t.append("inspector.none"));
+ } else {
+ placeholder.text(selection2.attr("value"));
+ _oldType[selection2.datum()] = tags[selection2.datum()];
+ }
+ if (field.type === "structureRadio") {
+ if (!!tags.waterway && !_oldType.tunnel) {
+ _oldType.tunnel = "culvert";
+ }
+ wrap2.call(structureExtras, tags);
+ }
+ };
+ radio.focus = function() {
+ radios.node().focus();
+ };
+ radio.entityIDs = function(val) {
+ if (!arguments.length) return _entityIDs;
+ _entityIDs = val;
+ _oldType = {};
+ return radio;
+ };
+ radio.isAllowed = function() {
+ return _entityIDs.length === 1;
+ };
+ return utilRebind(radio, dispatch14, "on");
+ }
+
+ // modules/ui/fields/restrictions.js
+ function uiFieldRestrictions(field, context) {
+ var dispatch14 = dispatch_default("change");
+ var breathe = behaviorBreathe(context);
+ corePreferences("turn-restriction-via-way", null);
+ var storedViaWay = corePreferences("turn-restriction-via-way0");
+ var storedDistance = corePreferences("turn-restriction-distance");
+ var _maxViaWay = storedViaWay !== null ? +storedViaWay : 0;
+ var _maxDistance = storedDistance ? +storedDistance : 30;
+ var _initialized3 = false;
+ var _parent = select_default2(null);
+ var _container = select_default2(null);
+ var _oldTurns;
+ var _graph;
+ var _vertexID;
+ var _intersection;
+ var _fromWayID;
+ var _lastXPos;
+ function restrictions(selection2) {
+ _parent = selection2;
+ if (_vertexID && (context.graph() !== _graph || !_intersection)) {
+ _graph = context.graph();
+ _intersection = osmIntersection(_graph, _vertexID, _maxDistance);
+ }
+ var isOK = _intersection && _intersection.vertices.length && // has vertices
+ _intersection.vertices.filter(function(vertex) {
+ return vertex.id === _vertexID;
+ }).length && _intersection.ways.length > 2;
+ select_default2(selection2.node().parentNode).classed("hide", !isOK);
+ if (!isOK || !context.container().select(".inspector-wrap.inspector-hidden").empty() || !selection2.node().parentNode || !selection2.node().parentNode.parentNode) {
+ selection2.call(restrictions.off);
+ return;
+ }
+ var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
+ wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
+ var container = wrap2.selectAll(".restriction-container").data([0]);
+ var containerEnter = container.enter().append("div").attr("class", "restriction-container");
+ containerEnter.append("div").attr("class", "restriction-help");
+ _container = containerEnter.merge(container).call(renderViewer);
+ var controls = wrap2.selectAll(".restriction-controls").data([0]);
+ controls.enter().append("div").attr("class", "restriction-controls-container").append("div").attr("class", "restriction-controls").merge(controls).call(renderControls);
+ }
+ function renderControls(selection2) {
+ var distControl = selection2.selectAll(".restriction-distance").data([0]);
+ distControl.exit().remove();
+ var distControlEnter = distControl.enter().append("div").attr("class", "restriction-control restriction-distance");
+ distControlEnter.append("span").attr("class", "restriction-control-label restriction-distance-label").call(_t.append("restriction.controls.distance", { suffix: ":" }));
+ distControlEnter.append("input").attr("class", "restriction-distance-input").attr("type", "range").attr("min", "20").attr("max", "50").attr("step", "5");
+ distControlEnter.append("span").attr("class", "restriction-distance-text");
+ selection2.selectAll(".restriction-distance-input").property("value", _maxDistance).on("input", function() {
+ var val = select_default2(this).property("value");
+ _maxDistance = +val;
+ _intersection = null;
+ _container.selectAll(".layer-osm .layer-turns *").remove();
+ corePreferences("turn-restriction-distance", _maxDistance);
+ _parent.call(restrictions);
+ });
+ selection2.selectAll(".restriction-distance-text").call(displayMaxDistance(_maxDistance));
+ var viaControl = selection2.selectAll(".restriction-via-way").data([0]);
+ viaControl.exit().remove();
+ var viaControlEnter = viaControl.enter().append("div").attr("class", "restriction-control restriction-via-way");
+ viaControlEnter.append("span").attr("class", "restriction-control-label restriction-via-way-label").call(_t.append("restriction.controls.via", { suffix: ":" }));
+ viaControlEnter.append("input").attr("class", "restriction-via-way-input").attr("type", "range").attr("min", "0").attr("max", "2").attr("step", "1");
+ viaControlEnter.append("span").attr("class", "restriction-via-way-text");
+ selection2.selectAll(".restriction-via-way-input").property("value", _maxViaWay).on("input", function() {
+ var val = select_default2(this).property("value");
+ _maxViaWay = +val;
+ _container.selectAll(".layer-osm .layer-turns *").remove();
+ corePreferences("turn-restriction-via-way0", _maxViaWay);
+ _parent.call(restrictions);
+ });
+ selection2.selectAll(".restriction-via-way-text").call(displayMaxVia(_maxViaWay));
+ }
+ function renderViewer(selection2) {
+ if (!_intersection) return;
+ var vgraph = _intersection.graph;
+ var filter2 = utilFunctor(true);
+ var projection2 = geoRawMercator();
+ var sdims = utilGetDimensions(context.container().select(".sidebar"));
+ var d2 = [sdims[0] - 50, 370];
+ var c2 = geoVecScale(d2, 0.5);
+ var z2 = 22;
+ projection2.scale(geoZoomToScale(z2));
+ var extent = geoExtent();
+ for (var i3 = 0; i3 < _intersection.vertices.length; i3++) {
+ extent._extend(_intersection.vertices[i3].extent());
+ }
+ var padTop = 35;
+ if (_intersection.vertices.length > 1) {
+ var hPadding = Math.min(160, Math.max(110, d2[0] * 0.4));
+ var vPadding = 160;
+ var tl = projection2([extent[0][0], extent[1][1]]);
+ var br2 = projection2([extent[1][0], extent[0][1]]);
+ var hFactor = (br2[0] - tl[0]) / (d2[0] - hPadding);
+ var vFactor = (br2[1] - tl[1]) / (d2[1] - vPadding - padTop);
+ var hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2;
+ var vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2;
+ z2 = z2 - Math.max(hZoomDiff, vZoomDiff);
+ projection2.scale(geoZoomToScale(z2));
+ }
+ var extentCenter = projection2(extent.center());
+ extentCenter[1] = extentCenter[1] - padTop / 2;
+ projection2.translate(geoVecSubtract(c2, extentCenter)).clipExtent([[0, 0], d2]);
+ var drawLayers = svgLayers(projection2, context).only(["osm", "touch"]).dimensions(d2);
+ var drawVertices = svgVertices(projection2, context);
+ var drawLines = svgLines(projection2, context);
+ var drawTurns = svgTurns(projection2, context);
+ var firstTime = selection2.selectAll(".surface").empty();
+ selection2.call(drawLayers);
+ var surface = selection2.selectAll(".surface").classed("tr", true);
+ if (firstTime) {
+ _initialized3 = true;
+ surface.call(breathe);
+ }
+ if (_fromWayID && !vgraph.hasEntity(_fromWayID)) {
+ _fromWayID = null;
+ _oldTurns = null;
+ }
+ surface.call(utilSetDimensions, d2).call(drawVertices, vgraph, _intersection.vertices, filter2, extent, z2).call(drawLines, vgraph, _intersection.ways, filter2).call(drawTurns, vgraph, _intersection.turns(_fromWayID, _maxViaWay));
+ surface.on("click.restrictions", click).on("mouseover.restrictions", mouseover);
+ surface.selectAll(".selected").classed("selected", false);
+ surface.selectAll(".related").classed("related", false);
+ var way;
+ if (_fromWayID) {
+ way = vgraph.entity(_fromWayID);
+ surface.selectAll("." + _fromWayID).classed("selected", true).classed("related", true);
+ }
+ document.addEventListener("resizeWindow", function() {
+ utilSetDimensions(_container, null);
+ redraw(1);
+ }, false);
+ updateHints(null);
+ function click(d3_event) {
+ surface.call(breathe.off).call(breathe);
+ var datum2 = d3_event.target.__data__;
+ var entity = datum2 && datum2.properties && datum2.properties.entity;
+ if (entity) {
+ datum2 = entity;
+ }
+ if (datum2 instanceof osmWay && (datum2.__from || datum2.__via)) {
+ _fromWayID = datum2.id;
+ _oldTurns = null;
+ redraw();
+ } else if (datum2 instanceof osmTurn) {
+ var actions, extraActions, turns, i4;
+ var restrictionType = osmInferRestriction(vgraph, datum2, projection2);
+ if (datum2.restrictionID && !datum2.direct) {
+ return;
+ } else if (datum2.restrictionID && !datum2.only) {
+ var seen = {};
+ var datumOnly = JSON.parse(JSON.stringify(datum2));
+ datumOnly.only = true;
+ restrictionType = restrictionType.replace(/^no/, "only");
+ turns = _intersection.turns(_fromWayID, 2);
+ extraActions = [];
+ _oldTurns = [];
+ for (i4 = 0; i4 < turns.length; i4++) {
+ var turn = turns[i4];
+ if (seen[turn.restrictionID]) continue;
+ if (turn.direct && turn.path[1] === datum2.path[1]) {
+ seen[turns[i4].restrictionID] = true;
+ turn.restrictionType = osmInferRestriction(vgraph, turn, projection2);
+ _oldTurns.push(turn);
+ extraActions.push(actionUnrestrictTurn(turn));
+ }
+ }
+ actions = _intersection.actions.concat(extraActions, [
+ actionRestrictTurn(datumOnly, restrictionType),
+ _t("operations.restriction.annotation.create")
+ ]);
+ } else if (datum2.restrictionID) {
+ turns = _oldTurns || [];
+ extraActions = [];
+ for (i4 = 0; i4 < turns.length; i4++) {
+ if (turns[i4].key !== datum2.key) {
+ extraActions.push(actionRestrictTurn(turns[i4], turns[i4].restrictionType));
+ }
+ }
+ _oldTurns = null;
+ actions = _intersection.actions.concat(extraActions, [
+ actionUnrestrictTurn(datum2),
+ _t("operations.restriction.annotation.delete")
+ ]);
+ } else {
+ actions = _intersection.actions.concat([
+ actionRestrictTurn(datum2, restrictionType),
+ _t("operations.restriction.annotation.create")
+ ]);
+ }
+ context.perform.apply(context, actions);
+ var s2 = surface.selectAll("." + datum2.key);
+ datum2 = s2.empty() ? null : s2.datum();
+ updateHints(datum2);
+ } else {
+ _fromWayID = null;
+ _oldTurns = null;
+ redraw();
+ }
+ }
+ function mouseover(d3_event) {
+ var datum2 = d3_event.target.__data__;
+ updateHints(datum2);
+ }
+ _lastXPos = _lastXPos || sdims[0];
+ function redraw(minChange) {
+ var xPos = -1;
+ if (minChange) {
+ xPos = utilGetDimensions(context.container().select(".sidebar"))[0];
+ }
+ if (!minChange || minChange && Math.abs(xPos - _lastXPos) >= minChange) {
+ if (context.hasEntity(_vertexID)) {
+ _lastXPos = xPos;
+ _container.call(renderViewer);
+ }
+ }
+ }
+ function highlightPathsFrom(wayID) {
+ surface.selectAll(".related").classed("related", false).classed("allow", false).classed("restrict", false).classed("only", false);
+ surface.selectAll("." + wayID).classed("related", true);
+ if (wayID) {
+ var turns = _intersection.turns(wayID, _maxViaWay);
+ for (var i4 = 0; i4 < turns.length; i4++) {
+ var turn = turns[i4];
+ var ids = [turn.to.way];
+ var klass = turn.no ? "restrict" : turn.only ? "only" : "allow";
+ if (turn.only || turns.length === 1) {
+ if (turn.via.ways) {
+ ids = ids.concat(turn.via.ways);
+ }
+ } else if (turn.to.way === wayID) {
+ continue;
+ }
+ surface.selectAll(utilEntitySelector(ids)).classed("related", true).classed("allow", klass === "allow").classed("restrict", klass === "restrict").classed("only", klass === "only");
+ }
+ }
+ }
+ function updateHints(datum2) {
+ var help = _container.selectAll(".restriction-help").html("");
+ var placeholders = {};
+ ["from", "via", "to"].forEach(function(k2) {
+ placeholders[k2] = { html: '<span class="qualifier">' + _t("restriction.help." + k2) + "</span>" };
+ });
+ var entity = datum2 && datum2.properties && datum2.properties.entity;
+ if (entity) {
+ datum2 = entity;
+ }
+ if (_fromWayID) {
+ way = vgraph.entity(_fromWayID);
+ surface.selectAll("." + _fromWayID).classed("selected", true).classed("related", true);
+ }
+ if (datum2 instanceof osmWay && datum2.__from) {
+ way = datum2;
+ highlightPathsFrom(_fromWayID ? null : way.id);
+ surface.selectAll("." + way.id).classed("related", true);
+ var clickSelect = !_fromWayID || _fromWayID !== way.id;
+ help.append("div").html(_t.html("restriction.help." + (clickSelect ? "select_from_name" : "from_name"), {
+ from: placeholders.from,
+ fromName: displayName(way.id, vgraph)
+ }));
+ } else if (datum2 instanceof osmTurn) {
+ var restrictionType = osmInferRestriction(vgraph, datum2, projection2);
+ var turnType = restrictionType.replace(/^(only|no)\_/, "");
+ var indirect = datum2.direct === false ? _t.html("restriction.help.indirect") : "";
+ var klass, turnText, nextText;
+ if (datum2.no) {
+ klass = "restrict";
+ turnText = _t.html("restriction.help.turn.no_" + turnType, { indirect: { html: indirect } });
+ nextText = _t.html("restriction.help.turn.only_" + turnType, { indirect: "" });
+ } else if (datum2.only) {
+ klass = "only";
+ turnText = _t.html("restriction.help.turn.only_" + turnType, { indirect: { html: indirect } });
+ nextText = _t.html("restriction.help.turn.allowed_" + turnType, { indirect: "" });
+ } else {
+ klass = "allow";
+ turnText = _t.html("restriction.help.turn.allowed_" + turnType, { indirect: { html: indirect } });
+ nextText = _t.html("restriction.help.turn.no_" + turnType, { indirect: "" });
+ }
+ help.append("div").attr("class", "qualifier " + klass).html(turnText);
+ help.append("div").html(_t.html("restriction.help.from_name_to_name", {
+ from: placeholders.from,
+ fromName: displayName(datum2.from.way, vgraph),
+ to: placeholders.to,
+ toName: displayName(datum2.to.way, vgraph)
+ }));
+ if (datum2.via.ways && datum2.via.ways.length) {
+ var names = [];
+ for (var i4 = 0; i4 < datum2.via.ways.length; i4++) {
+ var prev = names[names.length - 1];
+ var curr = displayName(datum2.via.ways[i4], vgraph);
+ if (!prev || curr !== prev) {
+ names.push(curr);
+ }
+ }
+ help.append("div").html(_t.html("restriction.help.via_names", {
+ via: placeholders.via,
+ viaNames: names.join(", ")
+ }));
+ }
+ if (!indirect) {
+ help.append("div").html(_t.html("restriction.help.toggle", { turn: { html: nextText.trim() } }));
+ }
+ highlightPathsFrom(null);
+ var alongIDs = datum2.path.slice();
+ surface.selectAll(utilEntitySelector(alongIDs)).classed("related", true).classed("allow", klass === "allow").classed("restrict", klass === "restrict").classed("only", klass === "only");
+ } else {
+ highlightPathsFrom(null);
+ if (_fromWayID) {
+ help.append("div").html(_t.html("restriction.help.from_name", {
+ from: placeholders.from,
+ fromName: displayName(_fromWayID, vgraph)
+ }));
+ } else {
+ help.append("div").html(_t.html("restriction.help.select_from", {
+ from: placeholders.from
+ }));
+ }
+ }
+ }
+ }
+ function displayMaxDistance(maxDist) {
+ return (selection2) => {
+ var isImperial = !_mainLocalizer.usesMetric();
+ var opts;
+ if (isImperial) {
+ var distToFeet = {
+ // imprecise conversion for prettier display
+ 20: 70,
+ 25: 85,
+ 30: 100,
+ 35: 115,
+ 40: 130,
+ 45: 145,
+ 50: 160
+ }[maxDist];
+ opts = { distance: _t("units.feet", { quantity: distToFeet }) };
+ } else {
+ opts = { distance: _t("units.meters", { quantity: maxDist }) };
+ }
+ return selection2.html("").call(_t.append("restriction.controls.distance_up_to", opts));
+ };
+ }
+ function displayMaxVia(maxVia) {
+ return (selection2) => {
+ selection2 = selection2.html("");
+ return maxVia === 0 ? selection2.call(_t.append("restriction.controls.via_node_only")) : maxVia === 1 ? selection2.call(_t.append("restriction.controls.via_up_to_one")) : selection2.call(_t.append("restriction.controls.via_up_to_two"));
+ };
+ }
+ function displayName(entityID, graph) {
+ var entity = graph.entity(entityID);
+ var name = utilDisplayName(entity) || "";
+ var matched = _mainPresetIndex.match(entity, graph);
+ var type2 = matched && matched.name() || utilDisplayType(entity.id);
+ return name || type2;
+ }
+ restrictions.entityIDs = function(val) {
+ _intersection = null;
+ _fromWayID = null;
+ _oldTurns = null;
+ _vertexID = val[0];
+ };
+ restrictions.tags = function() {
+ };
+ restrictions.focus = function() {
+ };
+ restrictions.off = function(selection2) {
+ if (!_initialized3) return;
+ selection2.selectAll(".surface").call(breathe.off).on("click.restrictions", null).on("mouseover.restrictions", null);
+ select_default2(window).on("resize.restrictions", null);
+ };
+ return utilRebind(restrictions, dispatch14, "on");
+ }
+ uiFieldRestrictions.supportsMultiselection = false;
+
+ // modules/ui/fields/textarea.js
+ function uiFieldTextarea(field, context) {
+ var dispatch14 = dispatch_default("change");
+ var input = select_default2(null);
+ var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue()).silent(field.usage === "changeset" && field.key === "comment");
+ var _tags;
+ function textarea(selection2) {
+ var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
+ wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).style("position", "relative").merge(wrap2);
+ input = wrap2.selectAll("textarea").data([0]);
+ input = input.enter().append("textarea").attr("id", field.domId).call(utilNoAuto).on("input", change(true)).on("blur", change()).on("change", change()).merge(input);
+ wrap2.call(_lengthIndicator);
+ function change(onInput) {
+ return function() {
+ var val = utilGetSetValue(input);
+ if (!onInput) val = context.cleanTagValue(val);
+ if (!val && Array.isArray(_tags[field.key])) return;
+ var t2 = {};
+ t2[field.key] = val || void 0;
+ dispatch14.call("change", this, t2, onInput);
+ };
+ }
+ }
+ textarea.tags = function(tags) {
+ _tags = tags;
+ var isMixed = Array.isArray(tags[field.key]);
+ utilGetSetValue(input, !isMixed && tags[field.key] ? tags[field.key] : "").attr("title", isMixed ? tags[field.key].filter(Boolean).join("\n") : void 0).attr("placeholder", isMixed ? _t("inspector.multiple_values") : field.placeholder() || _t("inspector.unknown")).classed("mixed", isMixed);
+ if (!isMixed) {
+ _lengthIndicator.update(tags[field.key]);
+ }
+ };
+ textarea.focus = function() {
+ input.node().focus();
+ };
+ return utilRebind(textarea, dispatch14, "on");
+ }
+
+ // modules/ui/fields/wikidata.js
+ function uiFieldWikidata(field, context) {
+ var wikidata = services.wikidata;
+ var dispatch14 = dispatch_default("change");
+ var _selection = select_default2(null);
+ var _searchInput = select_default2(null);
+ var _qid = null;
+ var _wikidataEntity = null;
+ var _wikiURL = "";
+ var _entityIDs = [];
+ var _wikipediaKey = field.keys && field.keys.find(function(key) {
+ return key.includes("wikipedia");
+ });
+ var _hintKey = field.key === "wikidata" ? "name" : field.key.split(":")[0];
+ var combobox = uiCombobox(context, "combo-" + field.safeid).caseSensitive(true).minItems(1);
+ function wiki(selection2) {
+ _selection = selection2;
+ var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
+ wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
+ var list2 = wrap2.selectAll("ul").data([0]);
+ list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
+ var searchRow = list2.selectAll("li.wikidata-search").data([0]);
+ var searchRowEnter = searchRow.enter().append("li").attr("class", "wikidata-search");
+ searchRowEnter.append("input").attr("type", "text").attr("id", field.domId).style("flex", "1").call(utilNoAuto).on("focus", function() {
+ var node = select_default2(this).node();
+ node.setSelectionRange(0, node.value.length);
+ }).on("blur", function() {
+ setLabelForEntity();
+ }).call(combobox.fetcher(fetchWikidataItems));
+ combobox.on("accept", function(d2) {
+ if (d2) {
+ _qid = d2.id;
+ change();
+ }
+ }).on("cancel", function() {
+ setLabelForEntity();
+ });
+ searchRowEnter.append("button").attr("class", "form-field-button wiki-link").attr("title", _t("icons.view_on", { domain: "wikidata.org" })).call(svgIcon("#iD-icon-out-link")).on("click", function(d3_event) {
+ d3_event.preventDefault();
+ if (_wikiURL) window.open(_wikiURL, "_blank");
+ });
+ searchRow = searchRow.merge(searchRowEnter);
+ _searchInput = searchRow.select("input");
+ var wikidataProperties = ["description", "identifier"];
+ var items = list2.selectAll("li.labeled-input").data(wikidataProperties);
+ var enter = items.enter().append("li").attr("class", function(d2) {
+ return "labeled-input preset-wikidata-" + d2;
+ });
+ enter.append("div").attr("class", "label").html(function(d2) {
+ return _t.html("wikidata." + d2);
+ });
+ enter.append("input").attr("type", "text").call(utilNoAuto).classed("disabled", "true").attr("readonly", "true");
+ enter.append("button").attr("class", "form-field-button").attr("title", _t("icons.copy")).call(svgIcon("#iD-operation-copy")).on("click", function(d3_event) {
+ d3_event.preventDefault();
+ select_default2(this.parentNode).select("input").node().select();
+ document.execCommand("copy");
+ });
+ }
+ function fetchWikidataItems(q2, callback) {
+ if (!q2 && _hintKey) {
+ for (var i3 in _entityIDs) {
+ var entity = context.hasEntity(_entityIDs[i3]);
+ if (entity.tags[_hintKey]) {
+ q2 = entity.tags[_hintKey];
+ break;
+ }
+ }
+ }
+ wikidata.itemsForSearchQuery(q2, function(err, data) {
+ if (err) {
+ if (err !== "No query") console.error(err);
+ return;
+ }
+ var result = data.map(function(item) {
+ return {
+ id: item.id,
+ value: item.display.label.value + " (" + item.id + ")",
+ display: (selection2) => selection2.append("span").attr("class", "localized-text").attr("lang", item.display.label.language).text(item.display.label.value),
+ title: item.display.description && item.display.description.value,
+ terms: item.aliases
+ };
+ });
+ if (callback) callback(result);
+ });
+ }
+ function change() {
+ var syncTags = {};
+ syncTags[field.key] = _qid;
+ dispatch14.call("change", this, syncTags);
+ var initGraph = context.graph();
+ var initEntityIDs = _entityIDs;
+ wikidata.entityByQID(_qid, function(err, entity) {
+ if (err) return;
+ if (context.graph() !== initGraph) return;
+ if (!entity.sitelinks) return;
+ var langs = wikidata.languagesToQuery();
+ ["labels", "descriptions"].forEach(function(key) {
+ if (!entity[key]) return;
+ var valueLangs = Object.keys(entity[key]);
+ if (valueLangs.length === 0) return;
+ var valueLang = valueLangs[0];
+ if (langs.indexOf(valueLang) === -1) {
+ langs.push(valueLang);
+ }
+ });
+ var newWikipediaValue;
+ if (_wikipediaKey) {
+ var foundPreferred;
+ for (var i3 in langs) {
+ var lang = langs[i3];
+ var siteID = lang.replace("-", "_") + "wiki";
+ if (entity.sitelinks[siteID]) {
+ foundPreferred = true;
+ newWikipediaValue = lang + ":" + entity.sitelinks[siteID].title;
+ break;
+ }
+ }
+ if (!foundPreferred) {
+ var wikiSiteKeys = Object.keys(entity.sitelinks).filter(function(site) {
+ return site.endsWith("wiki");
+ });
+ if (wikiSiteKeys.length === 0) {
+ newWikipediaValue = null;
+ } else {
+ var wikiLang = wikiSiteKeys[0].slice(0, -4).replace("_", "-");
+ var wikiTitle = entity.sitelinks[wikiSiteKeys[0]].title;
+ newWikipediaValue = wikiLang + ":" + wikiTitle;
+ }
+ }
+ }
+ if (newWikipediaValue) {
+ newWikipediaValue = context.cleanTagValue(newWikipediaValue);
+ }
+ if (typeof newWikipediaValue === "undefined") return;
+ var actions = initEntityIDs.map(function(entityID) {
+ var entity2 = context.hasEntity(entityID);
+ if (!entity2) return null;
+ var currTags = Object.assign({}, entity2.tags);
+ if (newWikipediaValue === null) {
+ if (!currTags[_wikipediaKey]) return null;
+ delete currTags[_wikipediaKey];
+ } else {
+ currTags[_wikipediaKey] = newWikipediaValue;
+ }
+ return actionChangeTags(entityID, currTags);
+ }).filter(Boolean);
+ if (!actions.length) return;
+ context.overwrite(
+ function actionUpdateWikipediaTags(graph) {
+ actions.forEach(function(action) {
+ graph = action(graph);
+ });
+ return graph;
+ },
+ context.history().undoAnnotation()
+ );
+ });
+ }
+ function setLabelForEntity() {
+ var label = "";
+ if (_wikidataEntity) {
+ label = entityPropertyForDisplay(_wikidataEntity, "labels");
+ if (label.length === 0) {
+ label = _wikidataEntity.id.toString();
+ }
+ }
+ utilGetSetValue(_searchInput, label);
+ }
+ wiki.tags = function(tags) {
+ var isMixed = Array.isArray(tags[field.key]);
+ _searchInput.attr("title", isMixed ? tags[field.key].filter(Boolean).join("\n") : null).attr("placeholder", isMixed ? _t("inspector.multiple_values") : "").classed("mixed", isMixed);
+ _qid = typeof tags[field.key] === "string" && tags[field.key] || "";
+ if (!/^Q[0-9]*$/.test(_qid)) {
+ unrecognized();
+ return;
+ }
+ _wikiURL = "https://wikidata.org/wiki/" + _qid;
+ wikidata.entityByQID(_qid, function(err, entity) {
+ if (err) {
+ unrecognized();
+ return;
+ }
+ _wikidataEntity = entity;
+ setLabelForEntity();
+ var description = entityPropertyForDisplay(entity, "descriptions");
+ _selection.select("button.wiki-link").classed("disabled", false);
+ _selection.select(".preset-wikidata-description").style("display", function() {
+ return description.length > 0 ? "flex" : "none";
+ }).select("input").attr("value", description);
+ _selection.select(".preset-wikidata-identifier").style("display", function() {
+ return entity.id ? "flex" : "none";
+ }).select("input").attr("value", entity.id);
+ });
+ function unrecognized() {
+ _wikidataEntity = null;
+ setLabelForEntity();
+ _selection.select(".preset-wikidata-description").style("display", "none");
+ _selection.select(".preset-wikidata-identifier").style("display", "none");
+ _selection.select("button.wiki-link").classed("disabled", true);
+ if (_qid && _qid !== "") {
+ _wikiURL = "https://wikidata.org/wiki/Special:Search?search=" + _qid;
+ } else {
+ _wikiURL = "";
+ }
+ }
+ };
+ function entityPropertyForDisplay(wikidataEntity, propKey) {
+ if (!wikidataEntity[propKey]) return "";
+ var propObj = wikidataEntity[propKey];
+ var langKeys = Object.keys(propObj);
+ if (langKeys.length === 0) return "";
+ var langs = wikidata.languagesToQuery();
+ for (var i3 in langs) {
+ var lang = langs[i3];
+ var valueObj = propObj[lang];
+ if (valueObj && valueObj.value && valueObj.value.length > 0) return valueObj.value;
+ }
+ return propObj[langKeys[0]].value;
+ }
+ wiki.entityIDs = function(val) {
+ if (!arguments.length) return _entityIDs;
+ _entityIDs = val;
+ return wiki;
+ };
+ wiki.focus = function() {
+ _searchInput.node().focus();
+ };
+ return utilRebind(wiki, dispatch14, "on");
+ }
+
+ // modules/ui/fields/wikipedia.js
+ function uiFieldWikipedia(field, context) {
+ const scheme = "https://";
+ const domain = "wikipedia.org";
+ const dispatch14 = dispatch_default("change");
+ const wikipedia = services.wikipedia;
+ const wikidata = services.wikidata;
+ let _langInput = select_default2(null);
+ let _titleInput = select_default2(null);
+ let _wikiURL = "";
+ let _entityIDs;
+ let _tags;
+ let _dataWikipedia = [];
+ _mainFileFetcher.get("wmf_sitematrix").then((d2) => {
+ _dataWikipedia = d2;
+ if (_tags) updateForTags(_tags);
+ }).catch(() => {
+ });
+ const langCombo = uiCombobox(context, "wikipedia-lang").fetcher((value, callback) => {
+ const v2 = value.toLowerCase();
+ callback(
+ _dataWikipedia.filter((d2) => {
+ return d2[0].toLowerCase().indexOf(v2) >= 0 || d2[1].toLowerCase().indexOf(v2) >= 0 || d2[2].toLowerCase().indexOf(v2) >= 0;
+ }).map((d2) => ({ value: d2[1] }))
+ );
+ });
+ const titleCombo = uiCombobox(context, "wikipedia-title").fetcher((value, callback) => {
+ if (!value) {
+ value = "";
+ for (let i3 in _entityIDs) {
+ let entity = context.hasEntity(_entityIDs[i3]);
+ if (entity.tags.name) {
+ value = entity.tags.name;
+ break;
+ }
+ }
+ }
+ const searchfn = value.length > 7 ? wikipedia.search : wikipedia.suggestions;
+ searchfn(language()[2], value, (query, data) => {
+ callback(data.map((d2) => ({ value: d2 })));
+ });
+ });
+ function wiki(selection2) {
+ let wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
+ wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-".concat(field.type)).merge(wrap2);
+ let langContainer = wrap2.selectAll(".wiki-lang-container").data([0]);
+ langContainer = langContainer.enter().append("div").attr("class", "wiki-lang-container").merge(langContainer);
+ _langInput = langContainer.selectAll("input.wiki-lang").data([0]);
+ _langInput = _langInput.enter().append("input").attr("type", "text").attr("class", "wiki-lang").attr("placeholder", _t("translate.localized_translation_language")).call(utilNoAuto).call(langCombo).merge(_langInput);
+ _langInput.on("blur", changeLang).on("change", changeLang);
+ let titleContainer = wrap2.selectAll(".wiki-title-container").data([0]);
+ titleContainer = titleContainer.enter().append("div").attr("class", "wiki-title-container").merge(titleContainer);
+ _titleInput = titleContainer.selectAll("input.wiki-title").data([0]);
+ _titleInput = _titleInput.enter().append("input").attr("type", "text").attr("class", "wiki-title").attr("id", field.domId).call(utilNoAuto).call(titleCombo).merge(_titleInput);
+ _titleInput.on("blur", function() {
+ change(true);
+ }).on("change", function() {
+ change(false);
+ });
+ let link3 = titleContainer.selectAll(".wiki-link").data([0]);
+ link3 = link3.enter().append("button").attr("class", "form-field-button wiki-link").attr("title", _t("icons.view_on", { domain })).call(svgIcon("#iD-icon-out-link")).merge(link3);
+ link3.on("click", (d3_event) => {
+ d3_event.preventDefault();
+ if (_wikiURL) window.open(_wikiURL, "_blank");
+ });
+ }
+ function defaultLanguageInfo(skipEnglishFallback) {
+ const langCode = _mainLocalizer.languageCode().toLowerCase();
+ for (let i3 in _dataWikipedia) {
+ let d2 = _dataWikipedia[i3];
+ if (d2[2] === langCode) return d2;
+ }
+ return skipEnglishFallback ? ["", "", ""] : ["English", "English", "en"];
+ }
+ function language(skipEnglishFallback) {
+ const value = utilGetSetValue(_langInput).toLowerCase();
+ for (let i3 in _dataWikipedia) {
+ let d2 = _dataWikipedia[i3];
+ if (d2[0].toLowerCase() === value || d2[1].toLowerCase() === value || d2[2] === value) return d2;
+ }
+ return defaultLanguageInfo(skipEnglishFallback);
+ }
+ function changeLang() {
+ utilGetSetValue(_langInput, language()[1]);
+ change(true);
+ }
+ function change(skipWikidata) {
+ let value = utilGetSetValue(_titleInput);
+ const m2 = value.match(/https?:\/\/([-a-z]+)\.wikipedia\.org\/(?:wiki|\1-[-a-z]+)\/([^#]+)(?:#(.+))?/);
+ const langInfo = m2 && _dataWikipedia.find((d2) => m2[1] === d2[2]);
+ let syncTags = {};
+ if (langInfo) {
+ const nativeLangName = langInfo[1];
+ value = decodeURIComponent(m2[2]).replace(/_/g, " ");
+ if (m2[3]) {
+ let anchor;
+ anchor = decodeURIComponent(m2[3]);
+ value += "#" + anchor.replace(/_/g, " ");
+ }
+ value = value.slice(0, 1).toUpperCase() + value.slice(1);
+ utilGetSetValue(_langInput, nativeLangName);
+ utilGetSetValue(_titleInput, value);
+ }
+ if (value) {
+ syncTags.wikipedia = context.cleanTagValue(language()[2] + ":" + value);
+ } else {
+ syncTags.wikipedia = void 0;
+ }
+ dispatch14.call("change", this, syncTags);
+ if (skipWikidata || !value || !language()[2]) return;
+ const initGraph = context.graph();
+ const initEntityIDs = _entityIDs;
+ wikidata.itemsByTitle(language()[2], value, (err, data) => {
+ if (err || !data || !Object.keys(data).length) return;
+ if (context.graph() !== initGraph) return;
+ const qids = Object.keys(data);
+ const value2 = qids && qids.find((id2) => id2.match(/^Q\d+$/));
+ let actions = initEntityIDs.map((entityID) => {
+ let entity = context.entity(entityID).tags;
+ let currTags = Object.assign({}, entity);
+ if (currTags.wikidata !== value2) {
+ currTags.wikidata = value2;
+ return actionChangeTags(entityID, currTags);
+ }
+ return null;
+ }).filter(Boolean);
+ if (!actions.length) return;
+ context.overwrite(
+ function actionUpdateWikidataTags(graph) {
+ actions.forEach(function(action) {
+ graph = action(graph);
+ });
+ return graph;
+ },
+ context.history().undoAnnotation()
+ );
+ });
+ }
+ wiki.tags = (tags) => {
+ _tags = tags;
+ updateForTags(tags);
+ };
+ function updateForTags(tags) {
+ const value = typeof tags[field.key] === "string" ? tags[field.key] : "";
+ const m2 = value.match(/([^:]+):([^#]+)(?:#(.+))?/);
+ const tagLang = m2 && m2[1];
+ const tagArticleTitle = m2 && m2[2];
+ let anchor = m2 && m2[3];
+ const tagLangInfo = tagLang && _dataWikipedia.find((d2) => tagLang === d2[2]);
+ if (tagLangInfo) {
+ const nativeLangName = tagLangInfo[1];
+ utilGetSetValue(_langInput, nativeLangName);
+ utilGetSetValue(_titleInput, tagArticleTitle + (anchor ? "#" + anchor : ""));
+ _wikiURL = "".concat(scheme).concat(tagLang, ".").concat(domain, "/wiki/").concat(wiki.encodePath(tagArticleTitle, anchor));
+ } else {
+ utilGetSetValue(_titleInput, value);
+ if (value && value !== "") {
+ utilGetSetValue(_langInput, "");
+ const defaultLangInfo = defaultLanguageInfo();
+ _wikiURL = "".concat(scheme).concat(defaultLangInfo[2], ".").concat(domain, "/w/index.php?fulltext=1&search=").concat(value);
+ } else {
+ const shownOrDefaultLangInfo = language(
+ true
+ /* skipEnglishFallback */
+ );
+ utilGetSetValue(_langInput, shownOrDefaultLangInfo[1]);
+ _wikiURL = "";
+ }
+ }
+ }
+ wiki.encodePath = (tagArticleTitle, anchor) => {
+ const underscoredTitle = tagArticleTitle.replace(/ /g, "_");
+ const uriEncodedUnderscoredTitle = encodeURIComponent(underscoredTitle);
+ const uriEncodedAnchorFragment = wiki.encodeURIAnchorFragment(anchor);
+ return "".concat(uriEncodedUnderscoredTitle).concat(uriEncodedAnchorFragment);
+ };
+ wiki.encodeURIAnchorFragment = (anchor) => {
+ if (!anchor) return "";
+ const underscoredAnchor = anchor.replace(/ /g, "_");
+ return "#" + encodeURIComponent(underscoredAnchor);
+ };
+ wiki.entityIDs = (val) => {
+ if (!arguments.length) return _entityIDs;
+ _entityIDs = val;
+ return wiki;
+ };
+ wiki.focus = () => {
+ _titleInput.node().focus();
+ };
+ return utilRebind(wiki, dispatch14, "on");
+ }
+ uiFieldWikipedia.supportsMultiselection = false;
+
+ // modules/ui/fields/index.js
+ var uiFields = {
+ access: uiFieldAccess,
+ address: uiFieldAddress,
+ check: uiFieldCheck,
+ colour: uiFieldText,
+ combo: uiFieldCombo,
+ cycleway: uiFieldDirectionalCombo,
+ date: uiFieldText,
+ defaultCheck: uiFieldCheck,
+ directionalCombo: uiFieldDirectionalCombo,
+ email: uiFieldText,
+ identifier: uiFieldText,
+ lanes: uiFieldLanes,
+ localized: uiFieldLocalized,
+ roadheight: uiFieldRoadheight,
+ roadspeed: uiFieldRoadspeed,
+ manyCombo: uiFieldCombo,
+ multiCombo: uiFieldCombo,
+ networkCombo: uiFieldCombo,
+ number: uiFieldText,
+ onewayCheck: uiFieldCheck,
+ radio: uiFieldRadio,
+ restrictions: uiFieldRestrictions,
+ semiCombo: uiFieldCombo,
+ structureRadio: uiFieldRadio,
+ tel: uiFieldText,
+ text: uiFieldText,
+ textarea: uiFieldTextarea,
+ typeCombo: uiFieldCombo,
+ url: uiFieldText,
+ wikidata: uiFieldWikidata,
+ wikipedia: uiFieldWikipedia
+ };
+
+ // modules/ui/field.js
+ function uiField(context, presetField2, entityIDs, options2) {
+ options2 = Object.assign({
+ show: true,
+ wrap: true,
+ remove: true,
+ revert: true,
+ info: true
+ }, options2);
+ var dispatch14 = dispatch_default("change", "revert");
+ var field = Object.assign({}, presetField2);
+ field.domId = utilUniqueDomId("form-field-" + field.safeid);
+ var _show = options2.show;
+ var _state = "";
+ var _tags = {};
+ var _entityExtent;
+ if (entityIDs && entityIDs.length) {
+ _entityExtent = entityIDs.reduce(function(extent, entityID) {
+ var entity = context.graph().entity(entityID);
+ return extent.extend(entity.extent(context.graph()));
+ }, geoExtent());
+ }
+ var _locked = false;
+ var _lockedTip = uiTooltip().title(() => _t.append("inspector.lock.suggestion", { label: field.title })).placement("bottom");
+ if (_show && !field.impl) {
+ createField();
+ }
+ function createField() {
+ field.impl = uiFields[field.type](field, context).on("change", function(t2, onInput) {
+ dispatch14.call("change", field, t2, onInput);
+ });
+ if (entityIDs) {
+ field.entityIDs = entityIDs;
+ if (field.impl.entityIDs) {
+ field.impl.entityIDs(entityIDs);
+ }
+ }
+ }
+ function allKeys() {
+ let keys2 = field.keys || [field.key];
+ if (field.type === "directionalCombo" && field.key) {
+ keys2 = keys2.concat(field.key);
+ }
+ return keys2;
+ }
+ function isModified() {
+ if (!entityIDs || !entityIDs.length) return false;
+ return entityIDs.some(function(entityID) {
+ var original = context.graph().base().entities[entityID];
+ var latest = context.graph().entity(entityID);
+ return allKeys().some(function(key) {
+ return original ? latest.tags[key] !== original.tags[key] : latest.tags[key];
+ });
+ });
+ }
+ function tagsContainFieldKey() {
+ return allKeys().some(function(key) {
+ if (field.type === "multiCombo") {
+ for (var tagKey in _tags) {
+ if (tagKey.indexOf(key) === 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+ if (field.type === "localized") {
+ for (let tagKey2 in _tags) {
+ let match = tagKey2.match(LANGUAGE_SUFFIX_REGEX);
+ if (match && match[1] === field.key && match[2]) {
+ return true;
+ }
+ }
+ }
+ return _tags[key] !== void 0;
+ });
+ }
+ function revert(d3_event, d2) {
+ d3_event.stopPropagation();
+ d3_event.preventDefault();
+ if (!entityIDs || _locked) return;
+ dispatch14.call("revert", d2, allKeys());
+ }
+ function remove2(d3_event, d2) {
+ d3_event.stopPropagation();
+ d3_event.preventDefault();
+ if (_locked) return;
+ var t2 = {};
+ allKeys().forEach(function(key) {
+ t2[key] = void 0;
+ });
+ dispatch14.call("change", d2, t2);
+ }
+ field.render = function(selection2) {
+ var container = selection2.selectAll(".form-field").data([field]);
+ var enter = container.enter().append("div").attr("class", function(d2) {
+ return "form-field form-field-" + d2.safeid;
+ }).classed("nowrap", !options2.wrap);
+ if (options2.wrap) {
+ var labelEnter = enter.append("label").attr("class", "field-label").attr("for", function(d2) {
+ return d2.domId;
+ });
+ var textEnter = labelEnter.append("span").attr("class", "label-text");
+ textEnter.append("span").attr("class", "label-textvalue").each(function(d2) {
+ d2.label()(select_default2(this));
+ });
+ textEnter.append("span").attr("class", "label-textannotation");
+ if (options2.remove) {
+ labelEnter.append("button").attr("class", "remove-icon").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete"));
+ }
+ if (options2.revert) {
+ labelEnter.append("button").attr("class", "modified-icon").attr("title", _t("icons.undo")).call(svgIcon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-redo" : "#iD-icon-undo"));
+ }
+ }
+ container = container.merge(enter);
+ container.select(".field-label > .remove-icon").on("click", remove2);
+ container.select(".field-label > .modified-icon").on("click", revert);
+ container.each(function(d2) {
+ var selection3 = select_default2(this);
+ if (!d2.impl) {
+ createField();
+ }
+ var reference, help;
+ if (options2.wrap && field.type === "restrictions") {
+ help = uiFieldHelp(context, "restrictions");
+ }
+ if (options2.wrap && options2.info) {
+ var referenceKey = d2.key || "";
+ if (d2.type === "multiCombo") {
+ referenceKey = referenceKey.replace(/:$/, "");
+ }
+ var referenceOptions = d2.reference || {
+ key: referenceKey,
+ value: _tags[referenceKey]
+ };
+ reference = uiTagReference(referenceOptions, context);
+ if (_state === "hover") {
+ reference.showing(false);
+ }
+ }
+ selection3.call(d2.impl);
+ if (help) {
+ selection3.call(help.body).select(".field-label").call(help.button);
+ }
+ if (reference) {
+ selection3.call(reference.body).select(".field-label").call(reference.button);
+ }
+ d2.impl.tags(_tags);
+ });
+ container.classed("locked", _locked).classed("modified", isModified()).classed("present", tagsContainFieldKey());
+ var annotation = container.selectAll(".field-label .label-textannotation");
+ var icon2 = annotation.selectAll(".icon").data(_locked ? [0] : []);
+ icon2.exit().remove();
+ icon2.enter().append("svg").attr("class", "icon").append("use").attr("xlink:href", "#fas-lock");
+ container.call(_locked ? _lockedTip : _lockedTip.destroy);
+ };
+ field.state = function(val) {
+ if (!arguments.length) return _state;
+ _state = val;
+ return field;
+ };
+ field.tags = function(val) {
+ if (!arguments.length) return _tags;
+ _tags = val;
+ if (tagsContainFieldKey() && !_show) {
+ _show = true;
+ if (!field.impl) {
+ createField();
+ }
+ }
+ return field;
+ };
+ field.locked = function(val) {
+ if (!arguments.length) return _locked;
+ _locked = val;
+ return field;
+ };
+ field.show = function() {
+ _show = true;
+ if (!field.impl) {
+ createField();
+ }
+ if (field.default && field.key && _tags[field.key] !== field.default) {
+ var t2 = {};
+ t2[field.key] = field.default;
+ dispatch14.call("change", this, t2);
+ }
+ };
+ field.isShown = function() {
+ return _show;
+ };
+ field.isAllowed = function() {
+ if (entityIDs && entityIDs.length > 1 && uiFields[field.type].supportsMultiselection === false) return false;
+ if (field.geometry && !entityIDs.every(function(entityID) {
+ return field.matchGeometry(context.graph().geometry(entityID));
+ })) return false;
+ if (entityIDs && _entityExtent && field.locationSetID) {
+ var validHere = _sharedLocationManager.locationSetsAt(_entityExtent.center());
+ if (!validHere[field.locationSetID]) return false;
+ }
+ var prerequisiteTag = field.prerequisiteTag;
+ if (entityIDs && !tagsContainFieldKey() && // ignore tagging prerequisites if a value is already present
+ prerequisiteTag) {
+ if (!entityIDs.every(function(entityID) {
+ var entity = context.graph().entity(entityID);
+ if (prerequisiteTag.key) {
+ var value = entity.tags[prerequisiteTag.key];
+ if (!value) return false;
+ if (prerequisiteTag.valueNot) {
+ return prerequisiteTag.valueNot !== value;
+ }
+ if (prerequisiteTag.value) {
+ return prerequisiteTag.value === value;
+ }
+ } else if (prerequisiteTag.keyNot) {
+ if (entity.tags[prerequisiteTag.keyNot]) return false;
+ }
+ return true;
+ })) return false;
+ }
+ return true;
+ };
+ field.focus = function() {
+ if (field.impl) {
+ field.impl.focus();
+ }
+ };
+ return utilRebind(field, dispatch14, "on");
+ }
+
+ // modules/ui/changeset_editor.js
+ function uiChangesetEditor(context) {
+ var dispatch14 = dispatch_default("change");
+ var formFields = uiFormFields(context);
+ var commentCombo = uiCombobox(context, "comment").caseSensitive(true);
+ var _fieldsArr;
+ var _tags;
+ var _changesetID;
+ function changesetEditor(selection2) {
+ render(selection2);
+ }
+ function render(selection2) {
+ var initial = false;
+ if (!_fieldsArr) {
+ initial = true;
+ var presets = _mainPresetIndex;
+ _fieldsArr = [
+ uiField(context, presets.field("comment"), null, { show: true, revert: false }),
+ uiField(context, presets.field("source"), null, { show: true, revert: false }),
+ uiField(context, presets.field("hashtags"), null, { show: false, revert: false })
+ ];
+ _fieldsArr.forEach(function(field) {
+ field.on("change", function(t2, onInput) {
+ dispatch14.call("change", field, void 0, t2, onInput);
+ });
+ });
+ }
+ _fieldsArr.forEach(function(field) {
+ field.tags(_tags);
+ });
+ selection2.call(formFields.fieldsArr(_fieldsArr));
+ if (initial) {
+ var commentField = selection2.select(".form-field-comment textarea");
+ var commentNode = commentField.node();
+ if (commentNode) {
+ commentNode.focus();
+ commentNode.select();
+ }
+ utilTriggerEvent(commentField, "blur");
+ var osm = context.connection();
+ if (osm) {
+ osm.userChangesets(function(err, changesets) {
+ if (err) return;
+ var comments = changesets.map(function(changeset) {
+ var comment = changeset.tags.comment;
+ return comment ? { title: comment, value: comment } : null;
+ }).filter(Boolean);
+ commentField.call(
+ commentCombo.data(utilArrayUniqBy(comments, "title"))
+ );
+ });
+ }
+ }
+ const warnings = [];
+ if (_tags.comment.match(/google/i)) {
+ warnings.push({
+ id: 'contains "google"',
+ msg: _t.append("commit.google_warning"),
+ link: _t("commit.google_warning_link")
+ });
+ }
+ const maxChars = context.maxCharsForTagValue();
+ const strLen = utilUnicodeCharsCount(utilCleanOsmString(_tags.comment, Number.POSITIVE_INFINITY));
+ if (strLen > maxChars || false) {
+ warnings.push({
+ id: "message too long",
+ msg: _t.append("commit.changeset_comment_length_warning", { maxChars })
+ });
+ }
+ var commentWarning = selection2.select(".form-field-comment").selectAll(".comment-warning").data(warnings, (d2) => d2.id);
+ commentWarning.exit().transition().duration(200).style("opacity", 0).remove();
+ var commentEnter = commentWarning.enter().insert("div", ".comment-warning").attr("class", "comment-warning field-warning").style("opacity", 0);
+ commentEnter.call(svgIcon("#iD-icon-alert", "inline")).append("span");
+ commentEnter.transition().duration(200).style("opacity", 1);
+ commentWarning.merge(commentEnter).selectAll("div > span").text("").each(function(d2) {
+ let selection3 = select_default2(this);
+ if (d2.link) {
+ selection3 = selection3.append("a").attr("target", "_blank").attr("href", d2.link);
+ }
+ selection3.call(d2.msg);
+ });
+ }
+ changesetEditor.tags = function(_2) {
+ if (!arguments.length) return _tags;
+ _tags = _2;
+ return changesetEditor;
+ };
+ changesetEditor.changesetID = function(_2) {
+ if (!arguments.length) return _changesetID;
+ if (_changesetID === _2) return changesetEditor;
+ _changesetID = _2;
+ _fieldsArr = null;
+ return changesetEditor;
+ };
+ return utilRebind(changesetEditor, dispatch14, "on");
+ }
+
+ // modules/ui/sections/changes.js
+ function uiSectionChanges(context) {
+ var _discardTags = {};
+ _mainFileFetcher.get("discarded").then(function(d2) {
+ _discardTags = d2;
+ }).catch(function() {
+ });
+ var section = uiSection("changes-list", context).label(function() {
+ var history = context.history();
+ var summary = history.difference().summary();
+ return _t.append("inspector.title_count", { title: _t("commit.changes"), count: summary.length });
+ }).disclosureContent(renderDisclosureContent);
+ function renderDisclosureContent(selection2) {
+ var history = context.history();
+ var summary = history.difference().summary();
+ var container = selection2.selectAll(".commit-section").data([0]);
+ var containerEnter = container.enter().append("div").attr("class", "commit-section");
+ containerEnter.append("ul").attr("class", "changeset-list");
+ container = containerEnter.merge(container);
+ var items = container.select("ul").selectAll("li").data(summary);
+ var itemsEnter = items.enter().append("li").attr("class", "change-item");
+ var buttons = itemsEnter.append("button").on("mouseover", mouseover).on("mouseout", mouseout).on("click", click);
+ buttons.each(function(d2) {
+ select_default2(this).call(svgIcon("#iD-icon-" + d2.entity.geometry(d2.graph), "pre-text " + d2.changeType));
+ });
+ buttons.append("span").attr("class", "change-type").html(function(d2) {
+ return _t.html("commit." + d2.changeType) + " ";
+ });
+ buttons.append("strong").attr("class", "entity-type").text(function(d2) {
+ var matched = _mainPresetIndex.match(d2.entity, d2.graph);
+ return matched && matched.name() || utilDisplayType(d2.entity.id);
+ });
+ buttons.append("span").attr("class", "entity-name").text(function(d2) {
+ var name = utilDisplayName(d2.entity) || "", string = "";
+ if (name !== "") {
+ string += ":";
+ }
+ return string += " " + name;
+ });
+ items = itemsEnter.merge(items);
+ var changeset = new osmChangeset().update({ id: void 0 });
+ var changes = history.changes(actionDiscardTags(history.difference(), _discardTags));
+ delete changeset.id;
+ var data = JXON.stringify(changeset.osmChangeJXON(changes));
+ var blob = new Blob([data], { type: "text/xml;charset=utf-8;" });
+ var fileName = "changes.osc";
+ var linkEnter = container.selectAll(".download-changes").data([0]).enter().append("a").attr("class", "download-changes");
+ linkEnter.attr("href", window.URL.createObjectURL(blob)).attr("download", fileName);
+ linkEnter.call(svgIcon("#iD-icon-load", "inline")).append("span").call(_t.append("commit.download_changes"));
+ function mouseover(d2) {
+ if (d2.entity) {
+ context.surface().selectAll(
+ utilEntityOrMemberSelector([d2.entity.id], context.graph())
+ ).classed("hover", true);
+ }
+ }
+ function mouseout() {
+ context.surface().selectAll(".hover").classed("hover", false);
+ }
+ function click(d3_event, change) {
+ if (change.changeType !== "deleted") {
+ var entity = change.entity;
+ context.map().zoomToEase(entity);
+ context.surface().selectAll(utilEntityOrMemberSelector([entity.id], context.graph())).classed("hover", true);
+ }
+ }
+ }
+ return section;
+ }
+
+ // modules/ui/commit.js
+ var readOnlyTags = [
+ /^changesets_count$/,
+ /^created_by$/,
+ /^ideditor:/,
+ /^imagery_used$/,
+ /^host$/,
+ /^locale$/,
+ /^warnings:/,
+ /^resolved:/,
+ /^closed:note$/,
+ /^closed:keepright$/,
+ /^closed:osmose:/
+ ];
+ var hashtagRegex = /(#[^\u2000-\u206F\u2E00-\u2E7F\s\\'!"#$%()*,.\/:;<=>?@\[\]^`{|}~]+)/g;
+ function uiCommit(context) {
+ var dispatch14 = dispatch_default("cancel");
+ var _userDetails2;
+ var _selection;
+ var changesetEditor = uiChangesetEditor(context).on("change", changeTags);
+ var rawTagEditor = uiSectionRawTagEditor("changeset-tag-editor", context).on("change", changeTags).readOnlyTags(readOnlyTags);
+ var commitChanges = uiSectionChanges(context);
+ var commitWarnings = uiCommitWarnings(context);
+ function commit(selection2) {
+ _selection = selection2;
+ if (!context.changeset) initChangeset();
+ loadDerivedChangesetTags();
+ selection2.call(render);
+ }
+ function initChangeset() {
+ var commentDate = +corePreferences("commentDate") || 0;
+ var currDate = Date.now();
+ var cutoff = 2 * 86400 * 1e3;
+ if (commentDate > currDate || currDate - commentDate > cutoff) {
+ corePreferences("comment", null);
+ corePreferences("hashtags", null);
+ corePreferences("source", null);
+ }
+ if (context.defaultChangesetComment()) {
+ corePreferences("comment", context.defaultChangesetComment());
+ corePreferences("commentDate", Date.now());
+ }
+ if (context.defaultChangesetSource()) {
+ corePreferences("source", context.defaultChangesetSource());
+ corePreferences("commentDate", Date.now());
+ }
+ if (context.defaultChangesetHashtags()) {
+ corePreferences("hashtags", context.defaultChangesetHashtags());
+ corePreferences("commentDate", Date.now());
+ }
+ var detected = utilDetect();
+ var tags = {
+ comment: corePreferences("comment") || "",
+ created_by: context.cleanTagValue("iD " + context.version),
+ host: context.cleanTagValue(detected.host),
+ locale: context.cleanTagValue(_mainLocalizer.localeCode())
+ };
+ findHashtags(tags, true);
+ var hashtags = corePreferences("hashtags");
+ if (hashtags) {
+ tags.hashtags = hashtags;
+ }
+ var source = corePreferences("source");
+ if (source) {
+ tags.source = source;
+ }
+ var photoOverlaysUsed = context.history().photoOverlaysUsed();
+ if (photoOverlaysUsed.length) {
+ var sources = (tags.source || "").split(";");
+ if (sources.indexOf("streetlevel imagery") === -1) {
+ sources.push("streetlevel imagery");
+ }
+ photoOverlaysUsed.forEach(function(photoOverlay) {
+ if (sources.indexOf(photoOverlay) === -1) {
+ sources.push(photoOverlay);
+ }
+ });
+ tags.source = context.cleanTagValue(sources.join(";"));
+ }
+ context.changeset = new osmChangeset({ tags });
+ }
+ function loadDerivedChangesetTags() {
+ var osm = context.connection();
+ if (!osm) return;
+ var tags = Object.assign({}, context.changeset.tags);
+ var imageryUsed = context.cleanTagValue(context.history().imageryUsed().join(";"));
+ tags.imagery_used = imageryUsed || "None";
+ var osmClosed = osm.getClosedIDs();
+ var itemType;
+ if (osmClosed.length) {
+ tags["closed:note"] = context.cleanTagValue(osmClosed.join(";"));
+ }
+ if (services.keepRight) {
+ var krClosed = services.keepRight.getClosedIDs();
+ if (krClosed.length) {
+ tags["closed:keepright"] = context.cleanTagValue(krClosed.join(";"));
+ }
+ }
+ if (services.osmose) {
+ var osmoseClosed = services.osmose.getClosedCounts();
+ for (itemType in osmoseClosed) {
+ tags["closed:osmose:" + itemType] = context.cleanTagValue(osmoseClosed[itemType].toString());
+ }
+ }
+ for (var key in tags) {
+ if (key.match(/(^warnings:)|(^resolved:)/)) {
+ delete tags[key];
+ }
+ }
+ function addIssueCounts(issues, prefix) {
+ var issuesByType = utilArrayGroupBy(issues, "type");
+ for (var issueType in issuesByType) {
+ var issuesOfType = issuesByType[issueType];
+ if (issuesOfType[0].subtype) {
+ var issuesBySubtype = utilArrayGroupBy(issuesOfType, "subtype");
+ for (var issueSubtype in issuesBySubtype) {
+ var issuesOfSubtype = issuesBySubtype[issueSubtype];
+ tags[prefix + ":" + issueType + ":" + issueSubtype] = context.cleanTagValue(issuesOfSubtype.length.toString());
+ }
+ } else {
+ tags[prefix + ":" + issueType] = context.cleanTagValue(issuesOfType.length.toString());
+ }
+ }
+ }
+ var warnings = context.validator().getIssuesBySeverity({ what: "edited", where: "all", includeIgnored: true, includeDisabledRules: true }).warning.filter(function(issue) {
+ return issue.type !== "help_request";
+ });
+ addIssueCounts(warnings, "warnings");
+ var resolvedIssues = context.validator().getResolvedIssues();
+ addIssueCounts(resolvedIssues, "resolved");
+ context.changeset = context.changeset.update({ tags });
+ }
+ function render(selection2) {
+ var osm = context.connection();
+ if (!osm) return;
+ var header = selection2.selectAll(".header").data([0]);
+ var headerTitle = header.enter().append("div").attr("class", "header fillL");
+ headerTitle.append("div").append("h2").call(_t.append("commit.title"));
+ headerTitle.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
+ dispatch14.call("cancel", this);
+ }).call(svgIcon("#iD-icon-close"));
+ var body = selection2.selectAll(".body").data([0]);
+ body = body.enter().append("div").attr("class", "body").merge(body);
+ var changesetSection = body.selectAll(".changeset-editor").data([0]);
+ changesetSection = changesetSection.enter().append("div").attr("class", "modal-section changeset-editor").merge(changesetSection);
+ changesetSection.call(
+ changesetEditor.changesetID(context.changeset.id).tags(context.changeset.tags)
+ );
+ body.call(commitWarnings);
+ var saveSection = body.selectAll(".save-section").data([0]);
+ saveSection = saveSection.enter().append("div").attr("class", "modal-section save-section fillL").merge(saveSection);
+ var prose = saveSection.selectAll(".commit-info").data([0]);
+ if (prose.enter().size()) {
+ _userDetails2 = null;
+ }
+ prose = prose.enter().append("p").attr("class", "commit-info").call(_t.append("commit.upload_explanation")).merge(prose);
+ osm.userDetails(function(err, user) {
+ if (err) return;
+ if (_userDetails2 === user) return;
+ _userDetails2 = user;
+ var userLink = select_default2(document.createElement("div"));
+ if (user.image_url) {
+ userLink.append("img").attr("src", user.image_url).attr("class", "icon pre-text user-icon");
+ }
+ userLink.append("a").attr("class", "user-info").text(user.display_name).attr("href", osm.userURL(user.display_name)).attr("target", "_blank");
+ prose.html(_t.html("commit.upload_explanation_with_user", { user: { html: userLink.html() } }));
+ });
+ var requestReview = saveSection.selectAll(".request-review").data([0]);
+ var requestReviewEnter = requestReview.enter().append("div").attr("class", "request-review");
+ var requestReviewDomId = utilUniqueDomId("commit-input-request-review");
+ var labelEnter = requestReviewEnter.append("label").attr("for", requestReviewDomId);
+ if (!labelEnter.empty()) {
+ labelEnter.call(uiTooltip().title(() => _t.append("commit.request_review_info")).placement("top"));
+ }
+ labelEnter.append("input").attr("type", "checkbox").attr("id", requestReviewDomId);
+ labelEnter.append("span").call(_t.append("commit.request_review"));
+ requestReview = requestReview.merge(requestReviewEnter);
+ var requestReviewInput = requestReview.selectAll("input").property("checked", isReviewRequested(context.changeset.tags)).on("change", toggleRequestReview);
+ var buttonSection = saveSection.selectAll(".buttons").data([0]);
+ var buttonEnter = buttonSection.enter().append("div").attr("class", "buttons fillL");
+ buttonEnter.append("button").attr("class", "secondary-action button cancel-button").append("span").attr("class", "label").call(_t.append("commit.cancel"));
+ var uploadButton = buttonEnter.append("button").attr("class", "action button save-button");
+ uploadButton.append("span").attr("class", "label").call(_t.append("commit.save"));
+ var uploadBlockerTooltipText = getUploadBlockerMessage();
+ buttonSection = buttonSection.merge(buttonEnter);
+ buttonSection.selectAll(".cancel-button").on("click.cancel", function() {
+ dispatch14.call("cancel", this);
+ });
+ buttonSection.selectAll(".save-button").classed("disabled", uploadBlockerTooltipText !== null).on("click.save", function() {
+ if (!select_default2(this).classed("disabled")) {
+ this.blur();
+ for (var key in context.changeset.tags) {
+ if (!key) delete context.changeset.tags[key];
+ }
+ context.uploader().save(context.changeset);
+ }
+ });
+ uiTooltip().destroyAny(buttonSection.selectAll(".save-button"));
+ if (uploadBlockerTooltipText) {
+ buttonSection.selectAll(".save-button").call(uiTooltip().title(() => uploadBlockerTooltipText).placement("top"));
+ }
+ var tagSection = body.selectAll(".tag-section.raw-tag-editor").data([0]);
+ tagSection = tagSection.enter().append("div").attr("class", "modal-section tag-section raw-tag-editor").merge(tagSection);
+ tagSection.call(
+ rawTagEditor.tags(Object.assign({}, context.changeset.tags)).render
+ );
+ var changesSection = body.selectAll(".commit-changes-section").data([0]);
+ changesSection = changesSection.enter().append("div").attr("class", "modal-section commit-changes-section").merge(changesSection);
+ changesSection.call(commitChanges.render);
+ function toggleRequestReview() {
+ var rr = requestReviewInput.property("checked");
+ updateChangeset({ review_requested: rr ? "yes" : void 0 });
+ tagSection.call(
+ rawTagEditor.tags(Object.assign({}, context.changeset.tags)).render
+ );
+ }
+ }
+ function getUploadBlockerMessage() {
+ var errors = context.validator().getIssuesBySeverity({ what: "edited", where: "all" }).error;
+ if (errors.length) {
+ return _t.append("commit.outstanding_errors_message", { count: errors.length });
+ } else {
+ var hasChangesetComment = context.changeset && context.changeset.tags.comment && context.changeset.tags.comment.trim().length;
+ if (!hasChangesetComment) {
+ return _t.append("commit.comment_needed_message");
+ }
+ }
+ return null;
+ }
+ function changeTags(_2, changed, onInput) {
+ if (changed.hasOwnProperty("comment")) {
+ if (changed.comment === void 0) {
+ changed.comment = "";
+ }
+ if (!onInput) {
+ corePreferences("comment", changed.comment);
+ corePreferences("commentDate", Date.now());
+ }
+ }
+ if (changed.hasOwnProperty("source")) {
+ if (changed.source === void 0) {
+ corePreferences("source", null);
+ } else if (!onInput) {
+ corePreferences("source", changed.source);
+ corePreferences("commentDate", Date.now());
+ }
+ }
+ updateChangeset(changed, onInput);
+ if (_selection) {
+ _selection.call(render);
+ }
+ }
+ function findHashtags(tags, commentOnly) {
+ var detectedHashtags = commentHashtags();
+ if (detectedHashtags.length) {
+ corePreferences("hashtags", null);
+ }
+ if (!detectedHashtags.length || !commentOnly) {
+ detectedHashtags = detectedHashtags.concat(hashtagHashtags());
+ }
+ var allLowerCase = /* @__PURE__ */ new Set();
+ return detectedHashtags.filter(function(hashtag) {
+ var lowerCase = hashtag.toLowerCase();
+ if (!allLowerCase.has(lowerCase)) {
+ allLowerCase.add(lowerCase);
+ return true;
+ }
+ return false;
+ });
+ function commentHashtags() {
+ var matches = (tags.comment || "").replace(/http\S*/g, "").match(hashtagRegex);
+ return matches || [];
+ }
+ function hashtagHashtags() {
+ var matches = (tags.hashtags || "").split(/[,;\s]+/).map(function(s2) {
+ if (s2[0] !== "#") {
+ s2 = "#" + s2;
+ }
+ var matched = s2.match(hashtagRegex);
+ return matched && matched[0];
+ }).filter(Boolean);
+ return matches || [];
+ }
+ }
+ function isReviewRequested(tags) {
+ var rr = tags.review_requested;
+ if (rr === void 0) return false;
+ rr = rr.trim().toLowerCase();
+ return !(rr === "" || rr === "no");
+ }
+ function updateChangeset(changed, onInput) {
+ var tags = Object.assign({}, context.changeset.tags);
+ Object.keys(changed).forEach(function(k2) {
+ var v2 = changed[k2];
+ k2 = context.cleanTagKey(k2);
+ if (readOnlyTags.indexOf(k2) !== -1) return;
+ if (v2 === void 0) {
+ delete tags[k2];
+ } else if (onInput) {
+ tags[k2] = v2;
+ } else {
+ tags[k2] = context.cleanTagValue(v2);
+ }
+ });
+ if (!onInput) {
+ var commentOnly = changed.hasOwnProperty("comment") && changed.comment !== "";
+ var arr = findHashtags(tags, commentOnly);
+ if (arr.length) {
+ tags.hashtags = context.cleanTagValue(arr.join(";"));
+ corePreferences("hashtags", tags.hashtags);
+ } else {
+ delete tags.hashtags;
+ corePreferences("hashtags", null);
+ }
+ }
+ if (_userDetails2 && _userDetails2.changesets_count !== void 0) {
+ var changesetsCount = parseInt(_userDetails2.changesets_count, 10) + 1;
+ tags.changesets_count = String(changesetsCount);
+ if (changesetsCount <= 100) {
+ var s2;
+ s2 = corePreferences("walkthrough_completed");
+ if (s2) {
+ tags["ideditor:walkthrough_completed"] = s2;
+ }
+ s2 = corePreferences("walkthrough_progress");
+ if (s2) {
+ tags["ideditor:walkthrough_progress"] = s2;
+ }
+ s2 = corePreferences("walkthrough_started");
+ if (s2) {
+ tags["ideditor:walkthrough_started"] = s2;
+ }
+ }
+ } else {
+ delete tags.changesets_count;
+ }
+ if (!(0, import_fast_deep_equal10.default)(context.changeset.tags, tags)) {
+ context.changeset = context.changeset.update({ tags });
+ }
+ }
+ commit.reset = function() {
+ context.changeset = null;
+ };
+ return utilRebind(commit, dispatch14, "on");
+ }
+
+ // modules/modes/save.js
+ function modeSave(context) {
+ var mode = { id: "save" };
+ var keybinding = utilKeybinding("modeSave");
+ var commit = uiCommit(context).on("cancel", cancel);
+ var _conflictsUi;
+ var _location;
+ var _success;
+ var uploader = context.uploader().on("saveStarted.modeSave", function() {
+ keybindingOff();
+ }).on("willAttemptUpload.modeSave", prepareForSuccess).on("progressChanged.modeSave", showProgress).on("resultNoChanges.modeSave", function() {
+ cancel();
+ }).on("resultErrors.modeSave", showErrors).on("resultConflicts.modeSave", showConflicts).on("resultSuccess.modeSave", showSuccess);
+ function cancel() {
+ context.enter(modeBrowse(context));
+ }
+ function showProgress(num, total) {
+ var modal = context.container().select(".loading-modal .modal-section");
+ var progress = modal.selectAll(".progress").data([0]);
+ progress.enter().append("div").attr("class", "progress").merge(progress).text(_t("save.conflict_progress", { num, total }));
+ }
+ function showConflicts(changeset, conflicts, origChanges) {
+ var selection2 = context.container().select(".sidebar").append("div").attr("class", "sidebar-component");
+ context.container().selectAll(".main-content").classed("active", true).classed("inactive", false);
+ _conflictsUi = uiConflicts(context).conflictList(conflicts).origChanges(origChanges).on("cancel", function() {
+ context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
+ selection2.remove();
+ keybindingOn();
+ uploader.cancelConflictResolution();
+ }).on("save", function() {
+ context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
+ selection2.remove();
+ uploader.processResolvedConflicts(changeset);
+ });
+ selection2.call(_conflictsUi);
+ }
+ function showErrors(errors) {
+ keybindingOn();
+ var selection2 = uiConfirm(context.container());
+ selection2.select(".modal-section.header").append("h3").text(_t("save.error"));
+ addErrors(selection2, errors);
+ selection2.okButton();
+ }
+ function addErrors(selection2, data) {
+ var message = selection2.select(".modal-section.message-text");
+ var items = message.selectAll(".error-container").data(data);
+ var enter = items.enter().append("div").attr("class", "error-container");
+ enter.append("a").attr("class", "error-description").attr("href", "#").classed("hide-toggle", true).text(function(d2) {
+ return d2.msg || _t("save.unknown_error_details");
+ }).on("click", function(d3_event) {
+ d3_event.preventDefault();
+ var error = select_default2(this);
+ var detail = select_default2(this.nextElementSibling);
+ var exp2 = error.classed("expanded");
+ detail.style("display", exp2 ? "none" : "block");
+ error.classed("expanded", !exp2);
+ });
+ var details = enter.append("div").attr("class", "error-detail-container").style("display", "none");
+ details.append("ul").attr("class", "error-detail-list").selectAll("li").data(function(d2) {
+ return d2.details || [];
+ }).enter().append("li").attr("class", "error-detail-item").text(function(d2) {
+ return d2;
+ });
+ items.exit().remove();
+ }
+ function showSuccess(changeset) {
+ commit.reset();
+ var ui = _success.changeset(changeset).location(_location).on("cancel", function() {
+ context.ui().sidebar.hide();
+ });
+ context.enter(modeBrowse(context).sidebar(ui));
+ }
+ function keybindingOn() {
+ select_default2(document).call(keybinding.on("\u238B", cancel, true));
+ }
+ function keybindingOff() {
+ select_default2(document).call(keybinding.unbind);
+ }
+ function prepareForSuccess() {
+ _success = uiSuccess(context);
+ _location = null;
+ if (!services.geocoder) return;
+ services.geocoder.reverse(context.map().center(), function(err, result) {
+ if (err || !result || !result.address) return;
+ var addr = result.address;
+ var place = addr && (addr.town || addr.city || addr.county) || "";
+ var region = addr && (addr.state || addr.country) || "";
+ var separator = place && region ? _t("success.thank_you_where.separator") : "";
+ _location = _t(
+ "success.thank_you_where.format",
+ { place, separator, region }
+ );
+ });
+ }
+ mode.selectedIDs = function() {
+ return _conflictsUi ? _conflictsUi.shownEntityIds() : [];
+ };
+ mode.enter = function() {
+ context.ui().sidebar.expand();
+ function done() {
+ context.ui().sidebar.show(commit);
+ }
+ keybindingOn();
+ context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
+ var osm = context.connection();
+ if (!osm) {
+ cancel();
+ return;
+ }
+ if (osm.authenticated()) {
+ done();
+ } else {
+ osm.authenticate(function(err) {
+ if (err) {
+ cancel();
+ } else {
+ done();
+ }
+ });
+ }
+ };
+ mode.exit = function() {
+ keybindingOff();
+ context.container().selectAll(".main-content").classed("active", true).classed("inactive", false);
+ context.ui().sidebar.hide();
+ };
+ return mode;
+ }
+
+ // modules/modes/select_error.js
+ function modeSelectError(context, selectedErrorID, selectedErrorService) {
+ var mode = {
+ id: "select-error",
+ button: "browse"
+ };
+ var keybinding = utilKeybinding("select-error");
+ var errorService = services[selectedErrorService];
+ var errorEditor;
+ switch (selectedErrorService) {
+ case "keepRight":
+ errorEditor = uiKeepRightEditor(context).on("change", function() {
+ context.map().pan([0, 0]);
+ var error = checkSelectedID();
+ if (!error) return;
+ context.ui().sidebar.show(errorEditor.error(error));
+ });
+ break;
+ case "osmose":
+ errorEditor = uiOsmoseEditor(context).on("change", function() {
+ context.map().pan([0, 0]);
+ var error = checkSelectedID();
+ if (!error) return;
+ context.ui().sidebar.show(errorEditor.error(error));
+ });
+ break;
+ }
+ var behaviors = [
+ behaviorBreathe(context),
+ behaviorHover(context),
+ behaviorSelect(context),
+ behaviorLasso(context),
+ modeDragNode(context).behavior,
+ modeDragNote(context).behavior
+ ];
+ function checkSelectedID() {
+ if (!errorService) return;
+ var error = errorService.getError(selectedErrorID);
+ if (!error) {
+ context.enter(modeBrowse(context));
+ }
+ return error;
+ }
+ mode.zoomToSelected = function() {
+ if (!errorService) return;
+ var error = errorService.getError(selectedErrorID);
+ if (error) {
+ context.map().centerZoomEase(error.loc, 20);
+ }
+ };
+ mode.enter = function() {
+ var error = checkSelectedID();
+ if (!error) return;
+ behaviors.forEach(context.install);
+ keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true);
+ select_default2(document).call(keybinding);
+ selectError();
+ var sidebar = context.ui().sidebar;
+ sidebar.show(errorEditor.error(error));
+ context.map().on("drawn.select-error", selectError);
+ function selectError(d3_event, drawn) {
+ if (!checkSelectedID()) return;
+ var selection2 = context.surface().selectAll(".itemId-" + selectedErrorID + "." + selectedErrorService);
+ if (selection2.empty()) {
+ var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent;
+ if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) {
+ context.enter(modeBrowse(context));
+ }
+ } else {
+ selection2.classed("selected", true);
+ context.selectedErrorID(selectedErrorID);
+ }
+ }
+ function esc() {
+ if (context.container().select(".combobox").size()) return;
+ context.enter(modeBrowse(context));
+ }
+ };
+ mode.exit = function() {
+ behaviors.forEach(context.uninstall);
+ select_default2(document).call(keybinding.unbind);
+ context.surface().selectAll(".qaItem.selected").classed("selected hover", false);
+ context.map().on("drawn.select-error", null);
+ context.ui().sidebar.hide();
+ context.selectedErrorID(null);
+ context.features().forceVisible([]);
+ };
+ return mode;
+ }
+
+ // modules/core/context.js
+ function coreContext() {
+ const dispatch14 = dispatch_default("enter", "exit", "change");
+ let context = utilRebind({}, dispatch14, "on");
+ let _deferred2 = /* @__PURE__ */ new Set();
+ context.version = package_default.version;
+ context.privacyVersion = "20201202";
+ context.initialHashParams = window.location.hash ? utilStringQs(window.location.hash) : {};
+ context.changeset = null;
+ let _defaultChangesetComment = context.initialHashParams.comment;
+ let _defaultChangesetSource = context.initialHashParams.source;
+ let _defaultChangesetHashtags = context.initialHashParams.hashtags;
+ context.defaultChangesetComment = function(val) {
+ if (!arguments.length) return _defaultChangesetComment;
+ _defaultChangesetComment = val;
+ return context;
+ };
+ context.defaultChangesetSource = function(val) {
+ if (!arguments.length) return _defaultChangesetSource;
+ _defaultChangesetSource = val;
+ return context;
+ };
+ context.defaultChangesetHashtags = function(val) {
+ if (!arguments.length) return _defaultChangesetHashtags;
+ _defaultChangesetHashtags = val;
+ return context;
+ };
+ let _setsDocumentTitle = true;
+ context.setsDocumentTitle = function(val) {
+ if (!arguments.length) return _setsDocumentTitle;
+ _setsDocumentTitle = val;
+ return context;
+ };
+ let _documentTitleBase = document.title;
+ context.documentTitleBase = function(val) {
+ if (!arguments.length) return _documentTitleBase;
+ _documentTitleBase = val;
+ return context;
+ };
+ let _ui;
+ context.ui = () => _ui;
+ context.lastPointerType = () => _ui.lastPointerType();
+ let _keybinding = utilKeybinding("context");
+ context.keybinding = () => _keybinding;
+ select_default2(document).call(_keybinding);
+ let _connection = services.osm;
+ let _history;
+ let _validator;
+ let _uploader;
+ context.connection = () => _connection;
+ context.history = () => _history;
+ context.validator = () => _validator;
+ context.uploader = () => _uploader;
+ context.preauth = (options2) => {
+ if (_connection) {
+ _connection.switch(options2);
+ }
+ return context;
+ };
+ context.locale = function(locale2) {
+ if (!arguments.length) return _mainLocalizer.localeCode();
+ _mainLocalizer.preferredLocaleCodes(locale2);
+ return context;
+ };
+ function afterLoad(cid, callback) {
+ return (err, result) => {
+ if (err) {
+ if (err.status === 400 || err.status === 401 || err.status === 403) {
+ if (_connection) {
+ _connection.logout();
+ }
+ }
+ if (typeof callback === "function") {
+ callback(err);
+ }
+ return;
+ } else if (_connection && _connection.getConnectionId() !== cid) {
+ if (typeof callback === "function") {
+ callback({ message: "Connection Switched", status: -1 });
+ }
+ return;
+ } else {
+ _history.merge(result.data, result.extent);
+ if (typeof callback === "function") {
+ callback(err, result);
+ }
+ return;
+ }
+ };
+ }
+ context.loadTiles = (projection2, callback) => {
+ const handle = window.requestIdleCallback(() => {
+ _deferred2.delete(handle);
+ if (_connection && context.editableDataEnabled()) {
+ const cid = _connection.getConnectionId();
+ _connection.loadTiles(projection2, afterLoad(cid, callback));
+ }
+ });
+ _deferred2.add(handle);
+ };
+ context.loadTileAtLoc = (loc, callback) => {
+ const handle = window.requestIdleCallback(() => {
+ _deferred2.delete(handle);
+ if (_connection && context.editableDataEnabled()) {
+ const cid = _connection.getConnectionId();
+ _connection.loadTileAtLoc(loc, afterLoad(cid, callback));
+ }
+ });
+ _deferred2.add(handle);
+ };
+ context.loadEntity = (entityID, callback) => {
+ if (_connection) {
+ const cid = _connection.getConnectionId();
+ _connection.loadEntity(entityID, afterLoad(cid, callback));
+ _connection.loadEntityRelations(entityID, afterLoad(cid, callback));
+ }
+ };
+ context.loadNote = (entityID, callback) => {
+ if (_connection) {
+ const cid = _connection.getConnectionId();
+ _connection.loadEntityNote(entityID, afterLoad(cid, callback));
+ }
+ };
+ context.zoomToEntity = (entityID, zoomTo) => {
+ context.zoomToEntities([entityID], zoomTo);
+ };
+ context.zoomToEntities = (entityIDs, zoomTo) => {
+ let loadedEntities = [];
+ const throttledZoomTo = throttle_default(() => _map.zoomTo(loadedEntities), 500);
+ entityIDs.forEach((entityID) => context.loadEntity(entityID, (err, result) => {
+ if (err) return;
+ const entity = result.data.find((e3) => e3.id === entityID);
+ if (!entity) return;
+ loadedEntities.push(entity);
+ if (zoomTo !== false) {
+ throttledZoomTo();
+ }
+ }));
+ _map.on("drawn.zoomToEntity", () => {
+ if (!entityIDs.every((entityID) => context.hasEntity(entityID))) return;
+ _map.on("drawn.zoomToEntity", null);
+ context.on("enter.zoomToEntity", null);
+ context.enter(modeSelect(context, entityIDs));
+ });
+ context.on("enter.zoomToEntity", () => {
+ if (_mode.id !== "browse") {
+ _map.on("drawn.zoomToEntity", null);
+ context.on("enter.zoomToEntity", null);
+ }
+ });
+ };
+ context.zoomToNote = (noteId, zoomTo) => {
+ context.loadNote(noteId, (err, result) => {
+ if (err) return;
+ const entity = result.data.find((e3) => e3.id === noteId);
+ if (entity) {
+ const note = services.osm.getNote(noteId);
+ if (zoomTo !== false) {
+ context.map().centerZoom(note.loc, 15);
+ }
+ const noteLayer = context.layers().layer("notes");
+ noteLayer.enabled(true);
+ context.enter(modeSelectNote(context, noteId));
+ }
+ });
+ };
+ let _minEditableZoom = 16;
+ context.minEditableZoom = function(val) {
+ if (!arguments.length) return _minEditableZoom;
+ _minEditableZoom = val;
+ if (_connection) {
+ _connection.tileZoom(val);
+ }
+ return context;
+ };
+ context.maxCharsForTagKey = () => 255;
+ context.maxCharsForTagValue = () => 255;
+ context.maxCharsForRelationRole = () => 255;
+ context.cleanTagKey = (val) => utilCleanOsmString(val, context.maxCharsForTagKey());
+ context.cleanTagValue = (val) => utilCleanOsmString(val, context.maxCharsForTagValue());
+ context.cleanRelationRole = (val) => utilCleanOsmString(val, context.maxCharsForRelationRole());
+ let _inIntro = false;
+ context.inIntro = function(val) {
+ if (!arguments.length) return _inIntro;
+ _inIntro = val;
+ return context;
+ };
+ context.save = () => {
+ if (_inIntro || context.container().select(".modal").size()) return;
+ let canSave;
+ if (_mode && _mode.id === "save") {
+ canSave = false;
+ if (services.osm && services.osm.isChangesetInflight()) {
+ _history.clearSaved();
+ return;
+ }
+ } else {
+ canSave = context.selectedIDs().every((id2) => {
+ const entity = context.hasEntity(id2);
+ return entity && !entity.isDegenerate();
+ });
+ }
+ if (canSave) {
+ _history.save();
+ }
+ if (_history.hasChanges()) {
+ return _t("save.unsaved_changes");
+ }
+ };
+ context.debouncedSave = debounce_default(context.save, 350);
+ function withDebouncedSave(fn) {
+ return function() {
+ const result = fn.apply(_history, arguments);
+ context.debouncedSave();
+ return result;
+ };
+ }
+ context.hasEntity = (id2) => _history.graph().hasEntity(id2);
+ context.entity = (id2) => _history.graph().entity(id2);
+ let _mode;
+ context.mode = () => _mode;
+ context.enter = (newMode) => {
+ if (_mode) {
+ _mode.exit();
+ dispatch14.call("exit", this, _mode);
+ }
+ _mode = newMode;
+ _mode.enter();
+ dispatch14.call("enter", this, _mode);
+ };
+ context.selectedIDs = () => _mode && _mode.selectedIDs && _mode.selectedIDs() || [];
+ context.activeID = () => _mode && _mode.activeID && _mode.activeID();
+ let _selectedNoteID;
+ context.selectedNoteID = function(noteID) {
+ if (!arguments.length) return _selectedNoteID;
+ _selectedNoteID = noteID;
+ return context;
+ };
+ let _selectedErrorID;
+ context.selectedErrorID = function(errorID) {
+ if (!arguments.length) return _selectedErrorID;
+ _selectedErrorID = errorID;
+ return context;
+ };
+ context.install = (behavior) => context.surface().call(behavior);
+ context.uninstall = (behavior) => context.surface().call(behavior.off);
+ let _copyGraph;
+ context.copyGraph = () => _copyGraph;
+ let _copyIDs = [];
+ context.copyIDs = function(val) {
+ if (!arguments.length) return _copyIDs;
+ _copyIDs = val;
+ _copyGraph = _history.graph();
+ return context;
+ };
+ let _copyLonLat;
+ context.copyLonLat = function(val) {
+ if (!arguments.length) return _copyLonLat;
+ _copyLonLat = val;
+ return context;
+ };
+ let _background;
+ context.background = () => _background;
+ let _features;
+ context.features = () => _features;
+ context.hasHiddenConnections = (id2) => {
+ const graph = _history.graph();
+ const entity = graph.entity(id2);
+ return _features.hasHiddenConnections(entity, graph);
+ };
+ let _photos;
+ context.photos = () => _photos;
+ let _map;
+ context.map = () => _map;
+ context.layers = () => _map.layers();
+ context.surface = () => _map.surface;
+ context.editableDataEnabled = () => _map.editableDataEnabled();
+ context.surfaceRect = () => _map.surface.node().getBoundingClientRect();
+ context.editable = () => {
+ const mode = context.mode();
+ if (!mode || mode.id === "save") return false;
+ return _map.editableDataEnabled();
+ };
+ let _debugFlags = {
+ tile: false,
+ // tile boundaries
+ collision: false,
+ // label collision bounding boxes
+ imagery: false,
+ // imagery bounding polygons
+ target: false,
+ // touch targets
+ downloaded: false
+ // downloaded data from osm
+ };
+ context.debugFlags = () => _debugFlags;
+ context.getDebug = (flag) => flag && _debugFlags[flag];
+ context.setDebug = function(flag, val) {
+ if (arguments.length === 1) val = true;
+ _debugFlags[flag] = val;
+ dispatch14.call("change");
+ return context;
+ };
+ let _container = select_default2(null);
+ context.container = function(val) {
+ if (!arguments.length) return _container;
+ _container = val;
+ _container.classed("ideditor", true);
+ return context;