+ function entityGeometries() {
+ var counts = {};
+ for (var i3 in _entityIDs) {
+ var geometry = context.graph().geometry(_entityIDs[i3]);
+ if (!counts[geometry])
+ counts[geometry] = 0;
+ counts[geometry] += 1;
+ }
+ return Object.keys(counts).sort(function(geom1, geom2) {
+ return counts[geom2] - counts[geom1];
+ });
+ }
+ return utilRebind(section, dispatch14, "on");
+ }
+
+ // modules/ui/sections/preset_fields.js
+ function uiSectionPresetFields(context) {
+ var section = uiSection("preset-fields", context).label(() => _t.append("inspector.fields")).disclosureContent(renderDisclosureContent);
+ var dispatch14 = dispatch_default("change", "revert");
+ var formFields = uiFormFields(context);
+ var _state;
+ var _fieldsArr;
+ var _presets = [];
+ var _tags;
+ var _entityIDs;
+ function renderDisclosureContent(selection2) {
+ if (!_fieldsArr) {
+ var graph = context.graph();
+ var geometries = Object.keys(_entityIDs.reduce(function(geoms, entityID) {
+ geoms[graph.entity(entityID).geometry(graph)] = true;
+ return geoms;
+ }, {}));
+ const loc = _entityIDs.reduce(function(extent, entityID) {
+ var entity = context.graph().entity(entityID);
+ return extent.extend(entity.extent(context.graph()));
+ }, geoExtent()).center();
+ var presetsManager = _mainPresetIndex;
+ var allFields = [];
+ var allMoreFields = [];
+ var sharedTotalFields;
+ _presets.forEach(function(preset) {
+ var fields = preset.fields(loc);
+ var moreFields = preset.moreFields(loc);
+ allFields = utilArrayUnion(allFields, fields);
+ allMoreFields = utilArrayUnion(allMoreFields, moreFields);
+ if (!sharedTotalFields) {
+ sharedTotalFields = utilArrayUnion(fields, moreFields);
+ } else {
+ sharedTotalFields = sharedTotalFields.filter(function(field) {
+ return fields.indexOf(field) !== -1 || moreFields.indexOf(field) !== -1;
+ });
+ }
+ });
+ var sharedFields = allFields.filter(function(field) {
+ return sharedTotalFields.indexOf(field) !== -1;
+ });
+ var sharedMoreFields = allMoreFields.filter(function(field) {
+ return sharedTotalFields.indexOf(field) !== -1;
+ });
+ _fieldsArr = [];
+ sharedFields.forEach(function(field) {
+ if (field.matchAllGeometry(geometries)) {
+ _fieldsArr.push(
+ uiField(context, field, _entityIDs)
+ );
+ }
+ });
+ var singularEntity = _entityIDs.length === 1 && graph.hasEntity(_entityIDs[0]);
+ if (singularEntity && singularEntity.isHighwayIntersection(graph) && presetsManager.field("restrictions")) {
+ _fieldsArr.push(
+ uiField(context, presetsManager.field("restrictions"), _entityIDs)
+ );
+ }
+ var additionalFields = utilArrayUnion(sharedMoreFields, presetsManager.universal());
+ additionalFields.sort(function(field1, field2) {
+ return field1.title().localeCompare(field2.title(), _mainLocalizer.localeCode());
+ });
+ additionalFields.forEach(function(field) {
+ if (sharedFields.indexOf(field) === -1 && field.matchAllGeometry(geometries)) {
+ _fieldsArr.push(
+ uiField(context, field, _entityIDs, { show: false })
+ );
+ }
+ });
+ _fieldsArr.forEach(function(field) {
+ field.on("change", function(t2, onInput) {
+ dispatch14.call("change", field, _entityIDs, t2, onInput);
+ }).on("revert", function(keys2) {
+ dispatch14.call("revert", field, keys2);
+ });
+ });
+ }
+ _fieldsArr.forEach(function(field) {
+ field.state(_state).tags(_tags);
+ });
+ selection2.call(
+ formFields.fieldsArr(_fieldsArr).state(_state).klass("grouped-items-area")
+ );
+ }
+ section.presets = function(val) {
+ if (!arguments.length)
+ return _presets;
+ if (!_presets || !val || !utilArrayIdentical(_presets, val)) {
+ _presets = val;
+ _fieldsArr = null;
+ }
+ return section;
+ };
+ section.state = function(val) {
+ if (!arguments.length)
+ return _state;
+ _state = val;
+ return section;
+ };
+ section.tags = function(val) {
+ if (!arguments.length)
+ return _tags;
+ _tags = val;
+ return section;
+ };
+ section.entityIDs = function(val) {
+ if (!arguments.length)
+ return _entityIDs;
+ if (!val || !_entityIDs || !utilArrayIdentical(_entityIDs, val)) {
+ _entityIDs = val;
+ _fieldsArr = null;
+ }
+ return section;
+ };
+ return utilRebind(section, dispatch14, "on");
+ }
+
+ // modules/ui/sections/raw_member_editor.js
+ function uiSectionRawMemberEditor(context) {
+ var section = uiSection("raw-member-editor", context).shouldDisplay(function() {
+ if (!_entityIDs || _entityIDs.length !== 1)
+ return false;
+ var entity = context.hasEntity(_entityIDs[0]);
+ return entity && entity.type === "relation";
+ }).label(function() {
+ var entity = context.hasEntity(_entityIDs[0]);
+ if (!entity)
+ return "";
+ var gt2 = entity.members.length > _maxMembers ? ">" : "";
+ var count = gt2 + entity.members.slice(0, _maxMembers).length;
+ return _t.append("inspector.title_count", { title: _t("inspector.members"), count });
+ }).disclosureContent(renderDisclosureContent);
+ var taginfo = services.taginfo;
+ var _entityIDs;
+ var _maxMembers = 1e3;
+ function downloadMember(d3_event, d2) {
+ d3_event.preventDefault();
+ select_default2(this.parentNode).classed("tag-reference-loading", true);
+ context.loadEntity(d2.id, function() {
+ section.reRender();
+ });
+ }
+ function zoomToMember(d3_event, d2) {
+ d3_event.preventDefault();
+ var entity = context.entity(d2.id);
+ context.map().zoomToEase(entity);
+ utilHighlightEntities([d2.id], true, context);
+ }
+ function selectMember(d3_event, d2) {
+ d3_event.preventDefault();
+ utilHighlightEntities([d2.id], false, context);
+ var entity = context.entity(d2.id);
+ var mapExtent = context.map().extent();
+ if (!entity.intersects(mapExtent, context.graph())) {
+ context.map().zoomToEase(entity);
+ }
+ context.enter(modeSelect(context, [d2.id]));
+ }
+ function changeRole(d3_event, d2) {
+ var oldRole = d2.role;
+ var newRole = context.cleanRelationRole(select_default2(this).property("value"));
+ if (oldRole !== newRole) {
+ var member = { id: d2.id, type: d2.type, role: newRole };
+ context.perform(
+ actionChangeMember(d2.relation.id, member, d2.index),
+ _t("operations.change_role.annotation", {
+ n: 1
+ })
+ );
+ context.validator().validate();
+ }
+ }
+ function deleteMember(d3_event, d2) {
+ utilHighlightEntities([d2.id], false, context);
+ context.perform(
+ actionDeleteMember(d2.relation.id, d2.index),
+ _t("operations.delete_member.annotation", {
+ n: 1
+ })
+ );
+ if (!context.hasEntity(d2.relation.id)) {
+ context.enter(modeBrowse(context));
+ } else {
+ context.validator().validate();
+ }
+ }
+ function renderDisclosureContent(selection2) {
+ var entityID = _entityIDs[0];
+ var memberships = [];
+ var entity = context.entity(entityID);
+ entity.members.slice(0, _maxMembers).forEach(function(member, index) {
+ memberships.push({
+ index,
+ id: member.id,
+ type: member.type,
+ role: member.role,
+ relation: entity,
+ member: context.hasEntity(member.id),
+ domId: utilUniqueDomId(entityID + "-member-" + index)
+ });
+ });
+ var list2 = selection2.selectAll(".member-list").data([0]);
+ list2 = list2.enter().append("ul").attr("class", "member-list").merge(list2);
+ var items = list2.selectAll("li").data(memberships, function(d2) {
+ return osmEntity.key(d2.relation) + "," + d2.index + "," + (d2.member ? osmEntity.key(d2.member) : "incomplete");
+ });
+ items.exit().each(unbind).remove();
+ var itemsEnter = items.enter().append("li").attr("class", "member-row form-field").classed("member-incomplete", function(d2) {
+ return !d2.member;
+ });
+ itemsEnter.each(function(d2) {
+ var item = select_default2(this);
+ var label = item.append("label").attr("class", "field-label").attr("for", d2.domId);
+ if (d2.member) {
+ item.on("mouseover", function() {
+ utilHighlightEntities([d2.id], true, context);
+ }).on("mouseout", function() {
+ utilHighlightEntities([d2.id], false, context);
+ });
+ var labelLink = label.append("span").attr("class", "label-text").append("a").attr("href", "#").on("click", selectMember);
+ labelLink.append("span").attr("class", "member-entity-type").text(function(d4) {
+ var matched = _mainPresetIndex.match(d4.member, context.graph());
+ return matched && matched.name() || utilDisplayType(d4.member.id);
+ });
+ labelLink.append("span").attr("class", "member-entity-name").classed("has-colour", (d4) => d4.member.type === "relation" && d4.member.tags.colour && isColourValid(d4.member.tags.colour)).style("border-color", (d4) => d4.member.type === "relation" && d4.member.tags.colour).text(function(d4) {
+ return utilDisplayName(d4.member);
+ });
+ label.append("button").attr("title", _t("icons.remove")).attr("class", "remove member-delete").call(svgIcon("#iD-operation-delete"));
+ label.append("button").attr("class", "member-zoom").attr("title", _t("icons.zoom_to")).call(svgIcon("#iD-icon-framed-dot", "monochrome")).on("click", zoomToMember);
+ } else {
+ var labelText = label.append("span").attr("class", "label-text");
+ labelText.append("span").attr("class", "member-entity-type").call(_t.append("inspector." + d2.type, { id: d2.id }));
+ labelText.append("span").attr("class", "member-entity-name").call(_t.append("inspector.incomplete", { id: d2.id }));
+ label.append("button").attr("class", "member-download").attr("title", _t("icons.download")).call(svgIcon("#iD-icon-load")).on("click", downloadMember);
+ }
+ });
+ var wrapEnter = itemsEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
+ wrapEnter.append("input").attr("class", "member-role").attr("id", function(d2) {
+ return d2.domId;
+ }).property("type", "text").attr("placeholder", _t("inspector.role")).call(utilNoAuto);
+ if (taginfo) {
+ wrapEnter.each(bindTypeahead);
+ }
+ items = items.merge(itemsEnter).order();
+ items.select("input.member-role").property("value", function(d2) {
+ return d2.role;
+ }).on("blur", changeRole).on("change", changeRole);
+ items.select("button.member-delete").on("click", deleteMember);
+ var dragOrigin, targetIndex;
+ items.call(
+ drag_default().on("start", function(d3_event) {
+ dragOrigin = {
+ x: d3_event.x,
+ y: d3_event.y
+ };
+ targetIndex = null;
+ }).on("drag", function(d3_event) {
+ var x2 = d3_event.x - dragOrigin.x, y2 = d3_event.y - dragOrigin.y;
+ if (!select_default2(this).classed("dragging") && // don't display drag until dragging beyond a distance threshold
+ Math.sqrt(Math.pow(x2, 2) + Math.pow(y2, 2)) <= 5)
+ return;
+ var index = items.nodes().indexOf(this);
+ select_default2(this).classed("dragging", true);
+ targetIndex = null;
+ selection2.selectAll("li.member-row").style("transform", function(d2, index2) {
+ var node = select_default2(this).node();
+ if (index === index2) {
+ return "translate(" + x2 + "px, " + y2 + "px)";
+ } else if (index2 > index && d3_event.y > node.offsetTop) {
+ if (targetIndex === null || index2 > targetIndex) {
+ targetIndex = index2;
+ }
+ return "translateY(-100%)";
+ } else if (index2 < index && d3_event.y < node.offsetTop + node.offsetHeight) {
+ if (targetIndex === null || index2 < targetIndex) {
+ targetIndex = index2;
+ }
+ return "translateY(100%)";
+ }
+ return null;
+ });
+ }).on("end", function(d3_event, d2) {
+ if (!select_default2(this).classed("dragging"))
+ return;
+ var index = items.nodes().indexOf(this);
+ select_default2(this).classed("dragging", false);
+ selection2.selectAll("li.member-row").style("transform", null);
+ if (targetIndex !== null) {
+ context.perform(
+ actionMoveMember(d2.relation.id, index, targetIndex),
+ _t("operations.reorder_members.annotation")
+ );
+ context.validator().validate();
+ }
+ })
+ );
+ function bindTypeahead(d2) {
+ var row = select_default2(this);
+ var role = row.selectAll("input.member-role");
+ var origValue = role.property("value");
+ function sort(value, data) {
+ var sameletter = [];
+ var other = [];
+ for (var i3 = 0; i3 < data.length; i3++) {
+ if (data[i3].value.substring(0, value.length) === value) {
+ sameletter.push(data[i3]);
+ } else {
+ other.push(data[i3]);
+ }
+ }
+ return sameletter.concat(other);
+ }
+ role.call(
+ uiCombobox(context, "member-role").fetcher(function(role2, callback) {
+ var geometry;
+ if (d2.member) {
+ geometry = context.graph().geometry(d2.member.id);
+ } else if (d2.type === "relation") {
+ geometry = "relation";
+ } else if (d2.type === "way") {
+ geometry = "line";
+ } else {
+ geometry = "point";
+ }
+ var rtype = entity.tags.type;
+ taginfo.roles({
+ debounce: true,
+ rtype: rtype || "",
+ geometry,
+ query: role2
+ }, function(err, data) {
+ if (!err)
+ callback(sort(role2, data));
+ });
+ }).on("cancel", function() {
+ role.property("value", origValue);
+ })
+ );
+ }
+ function unbind() {
+ var row = select_default2(this);
+ row.selectAll("input.member-role").call(uiCombobox.off, context);
+ }
+ }
+ section.entityIDs = function(val) {
+ if (!arguments.length)
+ return _entityIDs;
+ _entityIDs = val;
+ return section;
+ };
+ return section;
+ }
+
+ // modules/actions/delete_members.js
+ function actionDeleteMembers(relationId, memberIndexes) {
+ return function(graph) {
+ memberIndexes.sort((a2, b2) => b2 - a2);
+ for (var i3 in memberIndexes) {
+ graph = actionDeleteMember(relationId, memberIndexes[i3])(graph);
+ }
+ return graph;
+ };
+ }
+
+ // modules/ui/sections/raw_membership_editor.js
+ function uiSectionRawMembershipEditor(context) {
+ var section = uiSection("raw-membership-editor", context).shouldDisplay(function() {
+ return _entityIDs && _entityIDs.length;
+ }).label(function() {
+ var parents = getSharedParentRelations();
+ var gt2 = parents.length > _maxMemberships ? ">" : "";
+ var count = gt2 + parents.slice(0, _maxMemberships).length;
+ return _t.append("inspector.title_count", { title: _t("inspector.relations"), count });
+ }).disclosureContent(renderDisclosureContent);
+ var taginfo = services.taginfo;
+ var nearbyCombo = uiCombobox(context, "parent-relation").minItems(1).fetcher(fetchNearbyRelations).itemsMouseEnter(function(d3_event, d2) {
+ if (d2.relation)
+ utilHighlightEntities([d2.relation.id], true, context);
+ }).itemsMouseLeave(function(d3_event, d2) {
+ if (d2.relation)
+ utilHighlightEntities([d2.relation.id], false, context);
+ });
+ var _inChange = false;
+ var _entityIDs = [];
+ var _showBlank;
+ var _maxMemberships = 1e3;
+ function getSharedParentRelations() {
+ var parents = [];
+ for (var i3 = 0; i3 < _entityIDs.length; i3++) {
+ var entity = context.graph().hasEntity(_entityIDs[i3]);
+ if (!entity)
+ continue;
+ if (i3 === 0) {
+ parents = context.graph().parentRelations(entity);
+ } else {
+ parents = utilArrayIntersection(parents, context.graph().parentRelations(entity));
+ }
+ if (!parents.length)
+ break;
+ }
+ return parents;
+ }
+ function getMemberships() {
+ var memberships = [];
+ var relations = getSharedParentRelations().slice(0, _maxMemberships);
+ var isMultiselect = _entityIDs.length > 1;
+ var i3, relation, membership, index, member, indexedMember;
+ for (i3 = 0; i3 < relations.length; i3++) {
+ relation = relations[i3];
+ membership = {
+ relation,
+ members: [],
+ hash: osmEntity.key(relation)
+ };
+ for (index = 0; index < relation.members.length; index++) {
+ member = relation.members[index];
+ if (_entityIDs.indexOf(member.id) !== -1) {
+ indexedMember = Object.assign({}, member, { index });
+ membership.members.push(indexedMember);
+ membership.hash += "," + index.toString();
+ if (!isMultiselect) {
+ memberships.push(membership);
+ membership = {
+ relation,
+ members: [],
+ hash: osmEntity.key(relation)
+ };
+ }
+ }
+ }
+ if (membership.members.length)
+ memberships.push(membership);
+ }
+ memberships.forEach(function(membership2) {
+ membership2.domId = utilUniqueDomId("membership-" + membership2.relation.id);
+ var roles = [];
+ membership2.members.forEach(function(member2) {
+ if (roles.indexOf(member2.role) === -1)
+ roles.push(member2.role);
+ });
+ membership2.role = roles.length === 1 ? roles[0] : roles;
+ });
+ return memberships;
+ }
+ function selectRelation(d3_event, d2) {
+ d3_event.preventDefault();
+ utilHighlightEntities([d2.relation.id], false, context);
+ context.enter(modeSelect(context, [d2.relation.id]));
+ }
+ function zoomToRelation(d3_event, d2) {
+ d3_event.preventDefault();
+ var entity = context.entity(d2.relation.id);
+ context.map().zoomToEase(entity);
+ utilHighlightEntities([d2.relation.id], true, context);
+ }
+ function changeRole(d3_event, d2) {
+ if (d2 === 0)
+ return;
+ if (_inChange)
+ return;
+ var newRole = context.cleanRelationRole(select_default2(this).property("value"));
+ if (!newRole.trim() && typeof d2.role !== "string")
+ return;
+ var membersToUpdate = d2.members.filter(function(member) {
+ return member.role !== newRole;
+ });
+ if (membersToUpdate.length) {
+ _inChange = true;
+ context.perform(
+ function actionChangeMemberRoles(graph) {
+ membersToUpdate.forEach(function(member) {
+ var newMember = Object.assign({}, member, { role: newRole });
+ delete newMember.index;
+ graph = actionChangeMember(d2.relation.id, newMember, member.index)(graph);
+ });
+ return graph;
+ },
+ _t("operations.change_role.annotation", {
+ n: membersToUpdate.length
+ })
+ );
+ context.validator().validate();
+ }
+ _inChange = false;
+ }
+ function addMembership(d2, role) {
+ this.blur();
+ _showBlank = false;
+ function actionAddMembers(relationId, ids, role2) {
+ return function(graph) {
+ for (var i3 in ids) {
+ var member = { id: ids[i3], type: graph.entity(ids[i3]).type, role: role2 };
+ graph = actionAddMember(relationId, member)(graph);
+ }
+ return graph;
+ };
+ }
+ if (d2.relation) {
+ context.perform(
+ actionAddMembers(d2.relation.id, _entityIDs, role),
+ _t("operations.add_member.annotation", {
+ n: _entityIDs.length
+ })
+ );
+ context.validator().validate();
+ } else {
+ var relation = osmRelation();
+ context.perform(
+ actionAddEntity(relation),
+ actionAddMembers(relation.id, _entityIDs, role),
+ _t("operations.add.annotation.relation")
+ );
+ context.enter(modeSelect(context, [relation.id]).newFeature(true));
+ }
+ }
+ function deleteMembership(d3_event, d2) {
+ this.blur();
+ if (d2 === 0)
+ return;
+ utilHighlightEntities([d2.relation.id], false, context);
+ var indexes = d2.members.map(function(member) {
+ return member.index;
+ });
+ context.perform(
+ actionDeleteMembers(d2.relation.id, indexes),
+ _t("operations.delete_member.annotation", {
+ n: _entityIDs.length
+ })
+ );
+ context.validator().validate();
+ }
+ function fetchNearbyRelations(q2, callback) {
+ var newRelation = {
+ relation: null,
+ value: _t("inspector.new_relation"),
+ display: _t.append("inspector.new_relation")
+ };
+ var entityID = _entityIDs[0];
+ var result = [];
+ var graph = context.graph();
+ function baseDisplayValue(entity) {
+ var matched = _mainPresetIndex.match(entity, graph);
+ var presetName = matched && matched.name() || _t("inspector.relation");
+ var entityName = utilDisplayName(entity) || "";
+ return presetName + " " + entityName;
+ }
+ function baseDisplayLabel(entity) {
+ var matched = _mainPresetIndex.match(entity, graph);
+ var presetName = matched && matched.name() || _t("inspector.relation");
+ var entityName = utilDisplayName(entity) || "";
+ return (selection2) => {
+ selection2.append("b").text(presetName + " ");
+ selection2.append("span").classed("has-colour", entity.tags.colour && isColourValid(entity.tags.colour)).style("border-color", entity.tags.colour).text(entityName);
+ };
+ }
+ var explicitRelation = q2 && context.hasEntity(q2.toLowerCase());
+ if (explicitRelation && explicitRelation.type === "relation" && explicitRelation.id !== entityID) {
+ result.push({
+ relation: explicitRelation,
+ value: baseDisplayValue(explicitRelation) + " " + explicitRelation.id,
+ display: baseDisplayLabel(explicitRelation)
+ });
+ } else {
+ context.history().intersects(context.map().extent()).forEach(function(entity) {
+ if (entity.type !== "relation" || entity.id === entityID)
+ return;
+ var value = baseDisplayValue(entity);
+ if (q2 && (value + " " + entity.id).toLowerCase().indexOf(q2.toLowerCase()) === -1)
+ return;
+ result.push({
+ relation: entity,
+ value,
+ display: baseDisplayLabel(entity)
+ });
+ });
+ result.sort(function(a2, b2) {
+ return osmRelation.creationOrder(a2.relation, b2.relation);
+ });
+ var dupeGroups = Object.values(utilArrayGroupBy(result, "value")).filter(function(v2) {
+ return v2.length > 1;
+ });
+ dupeGroups.forEach(function(group) {
+ group.forEach(function(obj) {
+ obj.value += " " + obj.relation.id;
+ });
+ });
+ }
+ result.forEach(function(obj) {
+ obj.title = obj.value;
+ });
+ result.unshift(newRelation);
+ callback(result);
+ }
+ function renderDisclosureContent(selection2) {
+ var memberships = getMemberships();
+ var list2 = selection2.selectAll(".member-list").data([0]);
+ list2 = list2.enter().append("ul").attr("class", "member-list").merge(list2);
+ var items = list2.selectAll("li.member-row-normal").data(memberships, function(d2) {
+ return d2.hash;
+ });
+ items.exit().each(unbind).remove();
+ var itemsEnter = items.enter().append("li").attr("class", "member-row member-row-normal form-field");
+ itemsEnter.on("mouseover", function(d3_event, d2) {
+ utilHighlightEntities([d2.relation.id], true, context);
+ }).on("mouseout", function(d3_event, d2) {
+ utilHighlightEntities([d2.relation.id], false, context);
+ });
+ var labelEnter = itemsEnter.append("label").attr("class", "field-label").attr("for", function(d2) {
+ return d2.domId;
+ });
+ var labelLink = labelEnter.append("span").attr("class", "label-text").append("a").attr("href", "#").on("click", selectRelation);
+ labelLink.append("span").attr("class", "member-entity-type").text(function(d2) {
+ var matched = _mainPresetIndex.match(d2.relation, context.graph());
+ return matched && matched.name() || _t.html("inspector.relation");
+ });
+ labelLink.append("span").attr("class", "member-entity-name").classed("has-colour", (d2) => d2.relation.tags.colour && isColourValid(d2.relation.tags.colour)).style("border-color", (d2) => d2.relation.tags.colour).text(function(d2) {
+ return utilDisplayName(d2.relation);
+ });
+ labelEnter.append("button").attr("class", "remove member-delete").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")).on("click", deleteMembership);
+ labelEnter.append("button").attr("class", "member-zoom").attr("title", _t("icons.zoom_to")).call(svgIcon("#iD-icon-framed-dot", "monochrome")).on("click", zoomToRelation);
+ var wrapEnter = itemsEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
+ wrapEnter.append("input").attr("class", "member-role").attr("id", function(d2) {
+ return d2.domId;
+ }).property("type", "text").property("value", function(d2) {
+ return typeof d2.role === "string" ? d2.role : "";
+ }).attr("title", function(d2) {
+ return Array.isArray(d2.role) ? d2.role.filter(Boolean).join("\n") : d2.role;
+ }).attr("placeholder", function(d2) {
+ return Array.isArray(d2.role) ? _t("inspector.multiple_roles") : _t("inspector.role");
+ }).classed("mixed", function(d2) {
+ return Array.isArray(d2.role);
+ }).call(utilNoAuto).on("blur", changeRole).on("change", changeRole);
+ if (taginfo) {
+ wrapEnter.each(bindTypeahead);
+ }
+ var newMembership = list2.selectAll(".member-row-new").data(_showBlank ? [0] : []);
+ newMembership.exit().remove();
+ var newMembershipEnter = newMembership.enter().append("li").attr("class", "member-row member-row-new form-field");
+ var newLabelEnter = newMembershipEnter.append("label").attr("class", "field-label");
+ newLabelEnter.append("input").attr("placeholder", _t("inspector.choose_relation")).attr("type", "text").attr("class", "member-entity-input").call(utilNoAuto);
+ newLabelEnter.append("button").attr("class", "remove member-delete").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")).on("click", function() {
+ list2.selectAll(".member-row-new").remove();
+ });
+ var newWrapEnter = newMembershipEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
+ newWrapEnter.append("input").attr("class", "member-role").property("type", "text").attr("placeholder", _t("inspector.role")).call(utilNoAuto);
+ newMembership = newMembership.merge(newMembershipEnter);
+ newMembership.selectAll(".member-entity-input").on("blur", cancelEntity).call(
+ nearbyCombo.on("accept", acceptEntity).on("cancel", cancelEntity)
+ );
+ var addRow = selection2.selectAll(".add-row").data([0]);
+ var addRowEnter = addRow.enter().append("div").attr("class", "add-row");
+ var addRelationButton = addRowEnter.append("button").attr("class", "add-relation").attr("aria-label", _t("inspector.add_to_relation"));
+ addRelationButton.call(svgIcon("#iD-icon-plus", "light"));
+ addRelationButton.call(uiTooltip().title(() => _t.append("inspector.add_to_relation")).placement(_mainLocalizer.textDirection() === "ltr" ? "right" : "left"));
+ addRowEnter.append("div").attr("class", "space-value");
+ addRowEnter.append("div").attr("class", "space-buttons");
+ addRow = addRow.merge(addRowEnter);
+ addRow.select(".add-relation").on("click", function() {
+ _showBlank = true;
+ section.reRender();
+ list2.selectAll(".member-entity-input").node().focus();
+ });
+ function acceptEntity(d2) {
+ if (!d2) {
+ cancelEntity();
+ return;
+ }
+ if (d2.relation)
+ utilHighlightEntities([d2.relation.id], false, context);
+ var role = context.cleanRelationRole(list2.selectAll(".member-row-new .member-role").property("value"));
+ addMembership(d2, role);
+ }
+ function cancelEntity() {
+ var input = newMembership.selectAll(".member-entity-input");
+ input.property("value", "");
+ context.surface().selectAll(".highlighted").classed("highlighted", false);
+ }
+ function bindTypeahead(d2) {
+ var row = select_default2(this);
+ var role = row.selectAll("input.member-role");
+ var origValue = role.property("value");
+ function sort(value, data) {
+ var sameletter = [];
+ var other = [];
+ for (var i3 = 0; i3 < data.length; i3++) {
+ if (data[i3].value.substring(0, value.length) === value) {
+ sameletter.push(data[i3]);
+ } else {
+ other.push(data[i3]);
+ }
+ }
+ return sameletter.concat(other);
+ }
+ role.call(
+ uiCombobox(context, "member-role").fetcher(function(role2, callback) {
+ var rtype = d2.relation.tags.type;
+ taginfo.roles({
+ debounce: true,
+ rtype: rtype || "",
+ geometry: context.graph().geometry(_entityIDs[0]),
+ query: role2
+ }, function(err, data) {
+ if (!err)
+ callback(sort(role2, data));
+ });
+ }).on("cancel", function() {
+ role.property("value", origValue);
+ })
+ );
+ }
+ function unbind() {
+ var row = select_default2(this);
+ row.selectAll("input.member-role").call(uiCombobox.off, context);
+ }
+ }
+ section.entityIDs = function(val) {
+ if (!arguments.length)
+ return _entityIDs;
+ _entityIDs = val;
+ _showBlank = false;
+ return section;
+ };
+ return section;
+ }
+
+ // modules/ui/sections/selection_list.js
+ function uiSectionSelectionList(context) {
+ var _selectedIDs = [];
+ var section = uiSection("selected-features", context).shouldDisplay(function() {
+ return _selectedIDs.length > 1;
+ }).label(function() {
+ return _t.append("inspector.title_count", { title: _t("inspector.features"), count: _selectedIDs.length });
+ }).disclosureContent(renderDisclosureContent);
+ context.history().on("change.selectionList", function(difference2) {
+ if (difference2) {
+ section.reRender();
+ }
+ });
+ section.entityIDs = function(val) {
+ if (!arguments.length)
+ return _selectedIDs;
+ _selectedIDs = val;
+ return section;
+ };
+ function selectEntity(d3_event, entity) {
+ context.enter(modeSelect(context, [entity.id]));
+ }
+ function deselectEntity(d3_event, entity) {
+ var selectedIDs = _selectedIDs.slice();
+ var index = selectedIDs.indexOf(entity.id);
+ if (index > -1) {
+ selectedIDs.splice(index, 1);
+ context.enter(modeSelect(context, selectedIDs));
+ }
+ }
+ function renderDisclosureContent(selection2) {
+ var list2 = selection2.selectAll(".feature-list").data([0]);
+ list2 = list2.enter().append("ul").attr("class", "feature-list").merge(list2);
+ var entities = _selectedIDs.map(function(id2) {
+ return context.hasEntity(id2);
+ }).filter(Boolean);
+ var items = list2.selectAll(".feature-list-item").data(entities, osmEntity.key);
+ items.exit().remove();
+ var enter = items.enter().append("li").attr("class", "feature-list-item").each(function(d2) {
+ select_default2(this).on("mouseover", function() {
+ utilHighlightEntities([d2.id], true, context);
+ }).on("mouseout", function() {
+ utilHighlightEntities([d2.id], false, context);
+ });
+ });
+ var label = enter.append("button").attr("class", "label").on("click", selectEntity);
+ label.append("span").attr("class", "entity-geom-icon").call(svgIcon("", "pre-text"));
+ label.append("span").attr("class", "entity-type");
+ label.append("span").attr("class", "entity-name");
+ enter.append("button").attr("class", "close").attr("title", _t("icons.deselect")).on("click", deselectEntity).call(svgIcon("#iD-icon-close"));
+ items = items.merge(enter);
+ items.selectAll(".entity-geom-icon use").attr("href", function() {
+ var entity = this.parentNode.parentNode.__data__;
+ return "#iD-icon-" + entity.geometry(context.graph());
+ });
+ items.selectAll(".entity-type").text(function(entity) {
+ return _mainPresetIndex.match(entity, context.graph()).name();
+ });
+ items.selectAll(".entity-name").text(function(d2) {
+ var entity = context.entity(d2.id);
+ return utilDisplayName(entity);
+ });
+ }
+ return section;
+ }
+
+ // modules/ui/entity_editor.js
+ function uiEntityEditor(context) {
+ var dispatch14 = dispatch_default("choose");
+ var _state = "select";
+ var _coalesceChanges = false;
+ var _modified = false;
+ var _base;
+ var _entityIDs;
+ var _activePresets = [];
+ var _newFeature;
+ var _sections;
+ function entityEditor(selection2) {
+ var combinedTags = utilCombinedTags(_entityIDs, context.graph());
+ var header = selection2.selectAll(".header").data([0]);
+ var headerEnter = header.enter().append("div").attr("class", "header fillL");
+ var direction = _mainLocalizer.textDirection() === "rtl" ? "forward" : "backward";
+ headerEnter.append("button").attr("class", "preset-reset preset-choose").attr("title", _t("inspector.back_tooltip")).call(svgIcon("#iD-icon-".concat(direction)));
+ headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
+ context.enter(modeBrowse(context));
+ }).call(svgIcon(_modified ? "#iD-icon-apply" : "#iD-icon-close"));
+ headerEnter.append("h2");
+ header = header.merge(headerEnter);
+ header.selectAll("h2").text("").call(_entityIDs.length === 1 ? _t.append("inspector.edit") : _t.append("inspector.edit_features"));
+ header.selectAll(".preset-reset").on("click", function() {
+ dispatch14.call("choose", this, _activePresets);
+ });
+ var body = selection2.selectAll(".inspector-body").data([0]);
+ var bodyEnter = body.enter().append("div").attr("class", "entity-editor inspector-body sep-top");
+ body = body.merge(bodyEnter);
+ if (!_sections) {
+ _sections = [
+ uiSectionSelectionList(context),
+ uiSectionFeatureType(context).on("choose", function(presets) {
+ dispatch14.call("choose", this, presets);
+ }),
+ uiSectionEntityIssues(context),
+ uiSectionPresetFields(context).on("change", changeTags).on("revert", revertTags),
+ uiSectionRawTagEditor("raw-tag-editor", context).on("change", changeTags),
+ uiSectionRawMemberEditor(context),
+ uiSectionRawMembershipEditor(context)
+ ];
+ }
+ _sections.forEach(function(section) {
+ if (section.entityIDs) {
+ section.entityIDs(_entityIDs);
+ }
+ if (section.presets) {
+ section.presets(_activePresets);
+ }
+ if (section.tags) {
+ section.tags(combinedTags);
+ }
+ if (section.state) {
+ section.state(_state);
+ }
+ body.call(section.render);
+ });
+ context.history().on("change.entity-editor", historyChanged);
+ function historyChanged(difference2) {
+ if (selection2.selectAll(".entity-editor").empty())
+ return;
+ if (_state === "hide")
+ return;
+ var significant = !difference2 || difference2.didChange.properties || difference2.didChange.addition || difference2.didChange.deletion;
+ if (!significant)
+ return;
+ _entityIDs = _entityIDs.filter(context.hasEntity);
+ if (!_entityIDs.length)
+ return;
+ var priorActivePreset = _activePresets.length === 1 && _activePresets[0];
+ loadActivePresets();
+ var graph = context.graph();
+ entityEditor.modified(_base !== graph);
+ entityEditor(selection2);
+ if (priorActivePreset && _activePresets.length === 1 && priorActivePreset !== _activePresets[0]) {
+ context.container().selectAll(".entity-editor button.preset-reset .label").style("background-color", "#fff").transition().duration(750).style("background-color", null);
+ }
+ }
+ }
+ function changeTags(entityIDs, changed, onInput) {
+ var actions = [];
+ for (var i3 in entityIDs) {
+ var entityID = entityIDs[i3];
+ var entity = context.entity(entityID);
+ var tags = Object.assign({}, entity.tags);
+ if (typeof changed === "function") {
+ tags = changed(tags);
+ } else {
+ for (var k2 in changed) {
+ if (!k2)
+ continue;
+ var v2 = changed[k2];
+ if (typeof v2 === "object") {
+ tags[k2] = tags[v2.oldKey];
+ } else if (v2 !== void 0 || tags.hasOwnProperty(k2)) {
+ tags[k2] = v2;
+ }
+ }
+ }
+ if (!onInput) {
+ tags = utilCleanTags(tags);
+ }
+ if (!(0, import_fast_deep_equal10.default)(entity.tags, tags)) {
+ actions.push(actionChangeTags(entityID, tags));
+ }
+ }
+ if (actions.length) {
+ var combinedAction = function(graph) {
+ actions.forEach(function(action) {
+ graph = action(graph);
+ });
+ return graph;
+ };
+ var annotation = _t("operations.change_tags.annotation");
+ if (_coalesceChanges) {
+ context.overwrite(combinedAction, annotation);
+ } else {
+ context.perform(combinedAction, annotation);
+ _coalesceChanges = !!onInput;
+ }
+ }
+ if (!onInput) {
+ context.validator().validate();
+ }
+ }
+ function revertTags(keys2) {
+ var actions = [];
+ for (var i3 in _entityIDs) {
+ var entityID = _entityIDs[i3];
+ var original = context.graph().base().entities[entityID];
+ var changed = {};
+ for (var j2 in keys2) {
+ var key = keys2[j2];
+ changed[key] = original ? original.tags[key] : void 0;
+ }
+ var entity = context.entity(entityID);
+ var tags = Object.assign({}, entity.tags);
+ for (var k2 in changed) {
+ if (!k2)
+ continue;
+ var v2 = changed[k2];
+ if (v2 !== void 0 || tags.hasOwnProperty(k2)) {
+ tags[k2] = v2;
+ }
+ }
+ tags = utilCleanTags(tags);
+ if (!(0, import_fast_deep_equal10.default)(entity.tags, tags)) {
+ actions.push(actionChangeTags(entityID, tags));
+ }
+ }
+ if (actions.length) {
+ var combinedAction = function(graph) {
+ actions.forEach(function(action) {
+ graph = action(graph);
+ });
+ return graph;
+ };
+ var annotation = _t("operations.change_tags.annotation");
+ if (_coalesceChanges) {
+ context.overwrite(combinedAction, annotation);
+ } else {
+ context.perform(combinedAction, annotation);
+ _coalesceChanges = false;
+ }
+ }
+ context.validator().validate();
+ }
+ entityEditor.modified = function(val) {
+ if (!arguments.length)
+ return _modified;
+ _modified = val;
+ return entityEditor;
+ };
+ entityEditor.state = function(val) {
+ if (!arguments.length)
+ return _state;
+ _state = val;
+ return entityEditor;
+ };
+ entityEditor.entityIDs = function(val) {
+ if (!arguments.length)
+ return _entityIDs;
+ _base = context.graph();
+ _coalesceChanges = false;
+ if (val && _entityIDs && utilArrayIdentical(_entityIDs, val))
+ return entityEditor;
+ _entityIDs = val;
+ loadActivePresets(true);
+ return entityEditor.modified(false);
+ };
+ entityEditor.newFeature = function(val) {
+ if (!arguments.length)
+ return _newFeature;
+ _newFeature = val;
+ return entityEditor;
+ };
+ function loadActivePresets(isForNewSelection) {
+ var graph = context.graph();
+ var counts = {};
+ for (var i3 in _entityIDs) {
+ var entity = graph.hasEntity(_entityIDs[i3]);
+ if (!entity)
+ return;
+ var match = _mainPresetIndex.match(entity, graph);
+ if (!counts[match.id])
+ counts[match.id] = 0;
+ counts[match.id] += 1;
+ }
+ var matches = Object.keys(counts).sort(function(p1, p2) {
+ return counts[p2] - counts[p1];
+ }).map(function(pID) {
+ return _mainPresetIndex.item(pID);
+ });
+ if (!isForNewSelection) {
+ var weakPreset = _activePresets.length === 1 && !_activePresets[0].isFallback() && Object.keys(_activePresets[0].addTags || {}).length === 0;
+ if (weakPreset && matches.length === 1 && matches[0].isFallback())
+ return;
+ }
+ entityEditor.presets(matches);
+ }
+ entityEditor.presets = function(val) {
+ if (!arguments.length)
+ return _activePresets;
+ if (!utilArrayIdentical(val, _activePresets)) {
+ _activePresets = val;
+ }
+ return entityEditor;
+ };
+ return utilRebind(entityEditor, dispatch14, "on");
+ }
+
+ // modules/ui/feature_list.js
+ var sexagesimal = __toESM(require_sexagesimal());
+
+ // modules/modes/draw_area.js
+ function modeDrawArea(context, wayID, startGraph, button) {
+ var mode = {
+ button,
+ id: "draw-area"
+ };
+ var behavior = behaviorDrawWay(context, wayID, mode, startGraph).on("rejectedSelfIntersection.modeDrawArea", function() {
+ context.ui().flash.iconName("#iD-icon-no").label(_t.append("self_intersection.error.areas"))();
+ });
+ mode.wayID = wayID;
+ mode.enter = function() {
+ context.install(behavior);
+ };
+ mode.exit = function() {
+ context.uninstall(behavior);
+ };
+ mode.selectedIDs = function() {
+ return [wayID];
+ };
+ mode.activeID = function() {
+ return behavior && behavior.activeID() || [];
+ };
+ return mode;
+ }
+
+ // modules/modes/add_area.js
+ function modeAddArea(context, mode) {
+ mode.id = "add-area";
+ var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode);
+ function defaultTags(loc) {
+ var defaultTags2 = { area: "yes" };
+ if (mode.preset)
+ defaultTags2 = mode.preset.setTags(defaultTags2, "area", false, loc);
+ return defaultTags2;
+ }
+ function actionClose(wayId) {
+ return function(graph) {
+ return graph.replace(graph.entity(wayId).close());
+ };
+ }
+ function start2(loc) {
+ var startGraph = context.graph();
+ var node = osmNode({ loc });
+ var way = osmWay({ tags: defaultTags(loc) });
+ context.perform(
+ actionAddEntity(node),
+ actionAddEntity(way),
+ actionAddVertex(way.id, node.id),
+ actionClose(way.id)
+ );
+ context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
+ }
+ function startFromWay(loc, edge) {
+ var startGraph = context.graph();
+ var node = osmNode({ loc });
+ var way = osmWay({ tags: defaultTags(loc) });
+ context.perform(
+ actionAddEntity(node),
+ actionAddEntity(way),
+ actionAddVertex(way.id, node.id),
+ actionClose(way.id),
+ actionAddMidpoint({ loc, edge }, node)
+ );
+ context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
+ }
+ function startFromNode(node) {
+ var startGraph = context.graph();
+ var way = osmWay({ tags: defaultTags(node.loc) });
+ context.perform(
+ actionAddEntity(way),
+ actionAddVertex(way.id, node.id),
+ actionClose(way.id)
+ );
+ context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
+ }
+ mode.enter = function() {
+ context.install(behavior);
+ };
+ mode.exit = function() {
+ context.uninstall(behavior);
+ };
+ return mode;
+ }
+
+ // modules/modes/add_line.js
+ function modeAddLine(context, mode) {
+ mode.id = "add-line";
+ var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode);
+ function defaultTags(loc) {
+ var defaultTags2 = {};
+ if (mode.preset)
+ defaultTags2 = mode.preset.setTags(defaultTags2, "line", false, loc);
+ return defaultTags2;
+ }
+ function start2(loc) {
+ var startGraph = context.graph();
+ var node = osmNode({ loc });
+ var way = osmWay({ tags: defaultTags(loc) });
+ context.perform(
+ actionAddEntity(node),
+ actionAddEntity(way),
+ actionAddVertex(way.id, node.id)
+ );
+ context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
+ }
+ function startFromWay(loc, edge) {
+ var startGraph = context.graph();
+ var node = osmNode({ loc });
+ var way = osmWay({ tags: defaultTags(loc) });
+ context.perform(
+ actionAddEntity(node),
+ actionAddEntity(way),
+ actionAddVertex(way.id, node.id),
+ actionAddMidpoint({ loc, edge }, node)
+ );
+ context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
+ }
+ function startFromNode(node) {
+ var startGraph = context.graph();
+ var way = osmWay({ tags: defaultTags(node.loc) });
+ context.perform(
+ actionAddEntity(way),
+ actionAddVertex(way.id, node.id)
+ );
+ context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
+ }
+ mode.enter = function() {
+ context.install(behavior);
+ };
+ mode.exit = function() {
+ context.uninstall(behavior);
+ };
+ return mode;
+ }
+
+ // modules/modes/add_point.js
+ function modeAddPoint(context, mode) {
+ mode.id = "add-point";
+ var behavior = behaviorDraw(context).on("click", add).on("clickWay", addWay).on("clickNode", addNode).on("cancel", cancel).on("finish", cancel);
+ function defaultTags(loc) {
+ var defaultTags2 = {};
+ if (mode.preset)
+ defaultTags2 = mode.preset.setTags(defaultTags2, "point", false, loc);
+ return defaultTags2;
+ }
+ function add(loc) {
+ var node = osmNode({ loc, tags: defaultTags(loc) });
+ context.perform(
+ actionAddEntity(node),
+ _t("operations.add.annotation.point")
+ );
+ enterSelectMode(node);
+ }
+ function addWay(loc, edge) {
+ var node = osmNode({ tags: defaultTags(loc) });
+ context.perform(
+ actionAddMidpoint({ loc, edge }, node),
+ _t("operations.add.annotation.vertex")
+ );
+ enterSelectMode(node);
+ }
+ function enterSelectMode(node) {
+ context.enter(
+ modeSelect(context, [node.id]).newFeature(true)
+ );
+ }
+ function addNode(node) {
+ const _defaultTags = defaultTags(node.loc);
+ if (Object.keys(_defaultTags).length === 0) {
+ enterSelectMode(node);
+ return;
+ }
+ var tags = Object.assign({}, node.tags);
+ for (var key in _defaultTags) {
+ tags[key] = _defaultTags[key];
+ }
+ context.perform(
+ actionChangeTags(node.id, tags),
+ _t("operations.add.annotation.point")
+ );
+ enterSelectMode(node);
+ }
+ function cancel() {
+ context.enter(modeBrowse(context));
+ }
+ mode.enter = function() {
+ context.install(behavior);
+ };
+ mode.exit = function() {
+ context.uninstall(behavior);
+ };
+ return mode;
+ }
+
+ // modules/ui/note_comments.js
+ function uiNoteComments() {
+ var _note;
+ function noteComments(selection2) {
+ if (_note.isNew())
+ return;
+ var comments = selection2.selectAll(".comments-container").data([0]);
+ comments = comments.enter().append("div").attr("class", "comments-container").merge(comments);
+ var commentEnter = comments.selectAll(".comment").data(_note.comments).enter().append("div").attr("class", "comment");
+ commentEnter.append("div").attr("class", function(d2) {
+ return "comment-avatar user-" + d2.uid;
+ }).call(svgIcon("#iD-icon-avatar", "comment-avatar-icon"));
+ var mainEnter = commentEnter.append("div").attr("class", "comment-main");
+ var metadataEnter = mainEnter.append("div").attr("class", "comment-metadata");
+ metadataEnter.append("div").attr("class", "comment-author").each(function(d2) {
+ var selection3 = select_default2(this);
+ var osm = services.osm;
+ if (osm && d2.user) {
+ selection3 = selection3.append("a").attr("class", "comment-author-link").attr("href", osm.userURL(d2.user)).attr("target", "_blank");
+ }
+ if (d2.user) {
+ selection3.text(d2.user);
+ } else {
+ selection3.call(_t.append("note.anonymous"));
+ }
+ });
+ metadataEnter.append("div").attr("class", "comment-date").html(function(d2) {
+ return _t.html("note.status." + d2.action, { when: localeDateString2(d2.date) });
+ });
+ mainEnter.append("div").attr("class", "comment-text").html(function(d2) {
+ return d2.html;
+ }).selectAll("a").attr("rel", "noopener nofollow").attr("target", "_blank");
+ comments.call(replaceAvatars);
+ }
+ function replaceAvatars(selection2) {
+ var showThirdPartyIcons = corePreferences("preferences.privacy.thirdpartyicons") || "true";
+ var osm = services.osm;
+ if (showThirdPartyIcons !== "true" || !osm)
+ return;
+ var uids = {};
+ _note.comments.forEach(function(d2) {
+ if (d2.uid)
+ uids[d2.uid] = true;
+ });
+ Object.keys(uids).forEach(function(uid) {
+ osm.loadUser(uid, function(err, user) {
+ if (!user || !user.image_url)
+ return;
+ selection2.selectAll(".comment-avatar.user-" + uid).html("").append("img").attr("class", "icon comment-avatar-icon").attr("src", user.image_url).attr("alt", user.display_name);
+ });
+ });
+ }
+ function localeDateString2(s2) {
+ if (!s2)
+ return null;
+ var options2 = { day: "numeric", month: "short", year: "numeric" };
+ s2 = s2.replace(/-/g, "/");
+ var d2 = new Date(s2);
+ if (isNaN(d2.getTime()))
+ return null;
+ return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2);
+ }
+ noteComments.note = function(val) {
+ if (!arguments.length)
+ return _note;
+ _note = val;
+ return noteComments;
+ };
+ return noteComments;
+ }
+
+ // modules/ui/note_header.js
+ function uiNoteHeader() {
+ var _note;
+ function noteHeader(selection2) {
+ var header = selection2.selectAll(".note-header").data(
+ _note ? [_note] : [],
+ function(d2) {
+ return d2.status + d2.id;
+ }
+ );
+ header.exit().remove();
+ var headerEnter = header.enter().append("div").attr("class", "note-header");
+ var iconEnter = headerEnter.append("div").attr("class", function(d2) {
+ return "note-header-icon " + d2.status;
+ }).classed("new", function(d2) {
+ return d2.id < 0;
+ });
+ iconEnter.append("div").attr("class", "preset-icon-28").call(svgIcon("#iD-icon-note", "note-fill"));
+ iconEnter.each(function(d2) {
+ var statusIcon;
+ if (d2.id < 0) {
+ statusIcon = "#iD-icon-plus";
+ } else if (d2.status === "open") {
+ statusIcon = "#iD-icon-close";
+ } else {
+ statusIcon = "#iD-icon-apply";
+ }
+ iconEnter.append("div").attr("class", "note-icon-annotation").attr("title", _t("icons.close")).call(svgIcon(statusIcon, "icon-annotation"));
+ });
+ headerEnter.append("div").attr("class", "note-header-label").html(function(d2) {
+ if (_note.isNew()) {
+ return _t.html("note.new");
+ }
+ return _t.html("note.note") + " " + d2.id + " " + (d2.status === "closed" ? _t.html("note.closed") : "");
+ });
+ }
+ noteHeader.note = function(val) {
+ if (!arguments.length)
+ return _note;
+ _note = val;
+ return noteHeader;
+ };
+ return noteHeader;
+ }
+
+ // modules/ui/note_report.js
+ function uiNoteReport() {
+ var _note;
+ function noteReport(selection2) {
+ var url;
+ if (services.osm && _note instanceof osmNote && !_note.isNew()) {
+ url = services.osm.noteReportURL(_note);
+ }
+ var link3 = selection2.selectAll(".note-report").data(url ? [url] : []);
+ link3.exit().remove();
+ var linkEnter = link3.enter().append("a").attr("class", "note-report").attr("target", "_blank").attr("href", function(d2) {
+ return d2;
+ }).call(svgIcon("#iD-icon-out-link", "inline"));
+ linkEnter.append("span").call(_t.append("note.report"));
+ }
+ noteReport.note = function(val) {
+ if (!arguments.length)
+ return _note;
+ _note = val;
+ return noteReport;
+ };
+ return noteReport;
+ }
+
+ // modules/ui/view_on_osm.js
+ function uiViewOnOSM(context) {
+ var _what;
+ function viewOnOSM(selection2) {
+ var url;
+ if (_what instanceof osmEntity) {
+ url = context.connection().entityURL(_what);
+ } else if (_what instanceof osmNote) {
+ url = context.connection().noteURL(_what);
+ }
+ var data = !_what || _what.isNew() ? [] : [_what];
+ var link3 = selection2.selectAll(".view-on-osm").data(data, function(d2) {
+ return d2.id;
+ });
+ link3.exit().remove();
+ var linkEnter = link3.enter().append("a").attr("class", "view-on-osm").attr("target", "_blank").attr("href", url).call(svgIcon("#iD-icon-out-link", "inline"));
+ linkEnter.append("span").call(_t.append("inspector.view_on_osm"));
+ }
+ viewOnOSM.what = function(_2) {
+ if (!arguments.length)
+ return _what;
+ _what = _2;
+ return viewOnOSM;
+ };
+ return viewOnOSM;
+ }
+
+ // modules/ui/note_editor.js
+ function uiNoteEditor(context) {
+ var dispatch14 = dispatch_default("change");
+ var noteComments = uiNoteComments(context);
+ var noteHeader = uiNoteHeader();
+ var _note;
+ var _newNote;
+ function noteEditor(selection2) {
+ var header = selection2.selectAll(".header").data([0]);
+ var headerEnter = header.enter().append("div").attr("class", "header fillL");
+ headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
+ context.enter(modeBrowse(context));
+ }).call(svgIcon("#iD-icon-close"));
+ headerEnter.append("h2").call(_t.append("note.title"));
+ var body = selection2.selectAll(".body").data([0]);
+ body = body.enter().append("div").attr("class", "body").merge(body);
+ var editor = body.selectAll(".note-editor").data([0]);
+ editor.enter().append("div").attr("class", "modal-section note-editor").merge(editor).call(noteHeader.note(_note)).call(noteComments.note(_note)).call(noteSaveSection);
+ var footer = selection2.selectAll(".footer").data([0]);
+ footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnOSM(context).what(_note)).call(uiNoteReport(context).note(_note));
+ var osm = services.osm;
+ if (osm) {
+ osm.on("change.note-save", function() {
+ selection2.call(noteEditor);
+ });
+ }
+ }
+ function noteSaveSection(selection2) {
+ var isSelected = _note && _note.id === context.selectedNoteID();
+ var noteSave = selection2.selectAll(".note-save").data(isSelected ? [_note] : [], function(d2) {
+ return d2.status + d2.id;
+ });
+ noteSave.exit().remove();
+ var noteSaveEnter = noteSave.enter().append("div").attr("class", "note-save save-section cf");
+ noteSaveEnter.append("h4").attr("class", ".note-save-header").html(function() {
+ return _note.isNew() ? _t.html("note.newDescription") : _t.html("note.newComment");
+ });
+ var commentTextarea = noteSaveEnter.append("textarea").attr("class", "new-comment-input").attr("placeholder", _t("note.inputPlaceholder")).attr("maxlength", 1e3).property("value", function(d2) {
+ return d2.newComment;
+ }).call(utilNoAuto).on("keydown.note-input", keydown).on("input.note-input", changeInput).on("blur.note-input", changeInput);
+ if (!commentTextarea.empty() && _newNote) {
+ commentTextarea.node().focus();
+ }
+ noteSave = noteSaveEnter.merge(noteSave).call(userDetails).call(noteSaveButtons);
+ function keydown(d3_event) {
+ if (!(d3_event.keyCode === 13 && // ↩ Return
+ d3_event.metaKey))
+ return;
+ var osm = services.osm;
+ if (!osm)
+ return;
+ var hasAuth = osm.authenticated();
+ if (!hasAuth)
+ return;
+ if (!_note.newComment)
+ return;
+ d3_event.preventDefault();
+ select_default2(this).on("keydown.note-input", null);
+ window.setTimeout(function() {
+ if (_note.isNew()) {
+ noteSave.selectAll(".save-button").node().focus();
+ clickSave(_note);
+ } else {
+ noteSave.selectAll(".comment-button").node().focus();
+ clickComment(_note);
+ }
+ }, 10);
+ }
+ function changeInput() {
+ var input = select_default2(this);
+ var val = input.property("value").trim() || void 0;
+ _note = _note.update({ newComment: val });
+ var osm = services.osm;
+ if (osm) {
+ osm.replaceNote(_note);
+ }
+ noteSave.call(noteSaveButtons);
+ }
+ }
+ function userDetails(selection2) {
+ var detailSection = selection2.selectAll(".detail-section").data([0]);
+ detailSection = detailSection.enter().append("div").attr("class", "detail-section").merge(detailSection);
+ var osm = services.osm;
+ if (!osm)
+ return;
+ var hasAuth = osm.authenticated();
+ var authWarning = detailSection.selectAll(".auth-warning").data(hasAuth ? [] : [0]);
+ authWarning.exit().transition().duration(200).style("opacity", 0).remove();
+ var authEnter = authWarning.enter().insert("div", ".tag-reference-body").attr("class", "field-warning auth-warning").style("opacity", 0);
+ authEnter.call(svgIcon("#iD-icon-alert", "inline"));
+ authEnter.append("span").call(_t.append("note.login"));
+ authEnter.append("a").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).append("span").call(_t.append("login")).on("click.note-login", function(d3_event) {
+ d3_event.preventDefault();
+ osm.authenticate();
+ });
+ authEnter.transition().duration(200).style("opacity", 1);
+ var prose = detailSection.selectAll(".note-save-prose").data(hasAuth ? [0] : []);
+ prose.exit().remove();
+ prose = prose.enter().append("p").attr("class", "note-save-prose").call(_t.append("note.upload_explanation")).merge(prose);
+ osm.userDetails(function(err, user) {
+ if (err)
+ return;
+ 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("note.upload_explanation_with_user", { user: { html: userLink.html() } }));
+ });
+ }
+ function noteSaveButtons(selection2) {
+ var osm = services.osm;
+ var hasAuth = osm && osm.authenticated();
+ var isSelected = _note && _note.id === context.selectedNoteID();
+ var buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_note] : [], function(d2) {
+ return d2.status + d2.id;
+ });
+ buttonSection.exit().remove();
+ var buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
+ if (_note.isNew()) {
+ buttonEnter.append("button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel"));
+ buttonEnter.append("button").attr("class", "button save-button action").call(_t.append("note.save"));
+ } else {
+ buttonEnter.append("button").attr("class", "button status-button action");
+ buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("note.comment"));
+ }
+ buttonSection = buttonSection.merge(buttonEnter);
+ buttonSection.select(".cancel-button").on("click.cancel", clickCancel);
+ buttonSection.select(".save-button").attr("disabled", isSaveDisabled).on("click.save", clickSave);
+ buttonSection.select(".status-button").attr("disabled", hasAuth ? null : true).html(function(d2) {
+ var action = d2.status === "open" ? "close" : "open";
+ var andComment = d2.newComment ? "_comment" : "";
+ return _t.html("note." + action + andComment);
+ }).on("click.status", clickStatus);
+ buttonSection.select(".comment-button").attr("disabled", isSaveDisabled).on("click.comment", clickComment);
+ function isSaveDisabled(d2) {
+ return hasAuth && d2.status === "open" && d2.newComment ? null : true;
+ }
+ }
+ function clickCancel(d3_event, d2) {
+ this.blur();
+ var osm = services.osm;
+ if (osm) {
+ osm.removeNote(d2);
+ }
+ context.enter(modeBrowse(context));
+ dispatch14.call("change");
+ }
+ function clickSave(d3_event, d2) {
+ this.blur();
+ var osm = services.osm;
+ if (osm) {
+ osm.postNoteCreate(d2, function(err, note) {
+ dispatch14.call("change", note);
+ });
+ }
+ }
+ function clickStatus(d3_event, d2) {
+ this.blur();
+ var osm = services.osm;
+ if (osm) {
+ var setStatus = d2.status === "open" ? "closed" : "open";
+ osm.postNoteUpdate(d2, setStatus, function(err, note) {
+ dispatch14.call("change", note);
+ });
+ }
+ }
+ function clickComment(d3_event, d2) {
+ this.blur();
+ var osm = services.osm;
+ if (osm) {
+ osm.postNoteUpdate(d2, d2.status, function(err, note) {
+ dispatch14.call("change", note);
+ });
+ }
+ }
+ noteEditor.note = function(val) {
+ if (!arguments.length)
+ return _note;
+ _note = val;
+ return noteEditor;
+ };
+ noteEditor.newNote = function(val) {
+ if (!arguments.length)
+ return _newNote;
+ _newNote = val;
+ return noteEditor;
+ };
+ return utilRebind(noteEditor, dispatch14, "on");
+ }
+
+ // modules/modes/select_note.js
+ function modeSelectNote(context, selectedNoteID) {
+ var mode = {
+ id: "select-note",
+ button: "browse"
+ };
+ var _keybinding = utilKeybinding("select-note");
+ var _noteEditor = uiNoteEditor(context).on("change", function() {
+ context.map().pan([0, 0]);
+ var note = checkSelectedID();
+ if (!note)
+ return;
+ context.ui().sidebar.show(_noteEditor.note(note));
+ });
+ var _behaviors = [
+ behaviorBreathe(context),
+ behaviorHover(context),
+ behaviorSelect(context),
+ behaviorLasso(context),
+ modeDragNode(context).behavior,
+ modeDragNote(context).behavior
+ ];
+ var _newFeature = false;
+ function checkSelectedID() {
+ if (!services.osm)
+ return;
+ var note = services.osm.getNote(selectedNoteID);
+ if (!note) {
+ context.enter(modeBrowse(context));
+ }
+ return note;
+ }
+ function selectNote(d3_event, drawn) {
+ if (!checkSelectedID())
+ return;
+ var selection2 = context.surface().selectAll(".layer-notes .note-" + selectedNoteID);
+ if (selection2.empty()) {
+ var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent;
+ if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) {
+ context.enter(modeBrowse(context));
+ }
+ } else {
+ selection2.classed("selected", true);
+ context.selectedNoteID(selectedNoteID);
+ }
+ }
+ function esc() {
+ if (context.container().select(".combobox").size())
+ return;
+ context.enter(modeBrowse(context));
+ }
+ mode.zoomToSelected = function() {
+ if (!services.osm)
+ return;
+ var note = services.osm.getNote(selectedNoteID);
+ if (note) {
+ context.map().centerZoomEase(note.loc, 20);
+ }
+ };
+ mode.newFeature = function(val) {
+ if (!arguments.length)
+ return _newFeature;
+ _newFeature = val;
+ return mode;
+ };
+ mode.enter = function() {
+ var note = checkSelectedID();
+ if (!note)
+ return;
+ _behaviors.forEach(context.install);
+ _keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true);
+ select_default2(document).call(_keybinding);
+ selectNote();
+ var sidebar = context.ui().sidebar;
+ sidebar.show(_noteEditor.note(note).newNote(_newFeature));
+ sidebar.expand(sidebar.intersects(note.extent()));
+ context.map().on("drawn.select", selectNote);
+ };
+ mode.exit = function() {
+ _behaviors.forEach(context.uninstall);
+ select_default2(document).call(_keybinding.unbind);
+ context.surface().selectAll(".layer-notes .selected").classed("selected hover", false);
+ context.map().on("drawn.select", null);
+ context.ui().sidebar.hide();
+ context.selectedNoteID(null);
+ };
+ return mode;
+ }
+
+ // modules/modes/add_note.js
+ function modeAddNote(context) {
+ var mode = {
+ id: "add-note",
+ button: "note",
+ description: _t.append("modes.add_note.description"),
+ key: _t("modes.add_note.key")
+ };
+ var behavior = behaviorDraw(context).on("click", add).on("cancel", cancel).on("finish", cancel);
+ function add(loc) {
+ var osm = services.osm;
+ if (!osm)
+ return;
+ var note = osmNote({ loc, status: "open", comments: [] });
+ osm.replaceNote(note);
+ context.map().pan([0, 0]);
+ context.selectedNoteID(note.id).enter(modeSelectNote(context, note.id).newFeature(true));
+ }
+ function cancel() {
+ context.enter(modeBrowse(context));
+ }
+ mode.enter = function() {
+ context.install(behavior);
+ };
+ mode.exit = function() {
+ context.uninstall(behavior);
+ };
+ return mode;
+ }
+
+ // node_modules/osm-community-index/lib/simplify.js
+ var import_diacritics2 = __toESM(require_diacritics(), 1);
+ function simplify(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/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/ui/improveOSM_comments.js
+ function uiImproveOsmComments() {
+ let _qaItem;
+ function issueComments(selection2) {
+ let comments = selection2.selectAll(".comments-container").data([0]);
+ comments = comments.enter().append("div").attr("class", "comments-container").merge(comments);
+ services.improveOSM.getComments(_qaItem).then((d2) => {
+ if (!d2.comments)
+ return;
+ const commentEnter = comments.selectAll(".comment").data(d2.comments).enter().append("div").attr("class", "comment");
+ commentEnter.append("div").attr("class", "comment-avatar").call(svgIcon("#iD-icon-avatar", "comment-avatar-icon"));
+ const mainEnter = commentEnter.append("div").attr("class", "comment-main");
+ const metadataEnter = mainEnter.append("div").attr("class", "comment-metadata");
+ metadataEnter.append("div").attr("class", "comment-author").each(function(d4) {
+ const osm = services.osm;
+ let selection3 = select_default2(this);
+ if (osm && d4.username) {
+ selection3 = selection3.append("a").attr("class", "comment-author-link").attr("href", osm.userURL(d4.username)).attr("target", "_blank");
+ }
+ selection3.text((d5) => d5.username);
+ });
+ metadataEnter.append("div").attr("class", "comment-date").html((d4) => _t.html("note.status.commented", { when: localeDateString2(d4.timestamp) }));
+ mainEnter.append("div").attr("class", "comment-text").append("p").text((d4) => d4.text);
+ }).catch((err) => {
+ console.log(err);
+ });
+ }
+ function localeDateString2(s2) {
+ if (!s2)
+ return null;
+ const options2 = { day: "numeric", month: "short", year: "numeric" };
+ const d2 = new Date(s2 * 1e3);
+ if (isNaN(d2.getTime()))
+ return null;
+ return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2);
+ }
+ issueComments.issue = function(val) {
+ if (!arguments.length)
+ return _qaItem;
+ _qaItem = val;
+ return issueComments;
+ };
+ return issueComments;
+ }
+
+ // modules/ui/improveOSM_details.js
+ function uiImproveOsmDetails(context) {
+ let _qaItem;
+ function issueDetail(d2) {
+ if (d2.desc)
+ return d2.desc;
+ const issueKey = d2.issueKey;
+ d2.replacements = d2.replacements || {};
+ d2.replacements.default = { html: _t.html("inspector.unknown") };
+ return _t.html("QA.improveOSM.error_types.".concat(issueKey, ".description"), d2.replacements);
+ }
+ function improveOsmDetails(selection2) {
+ const details = selection2.selectAll(".error-details").data(
+ _qaItem ? [_qaItem] : [],
+ (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
+ );
+ details.exit().remove();
+ const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container");
+ const descriptionEnter = detailsEnter.append("div").attr("class", "qa-details-subsection");
+ descriptionEnter.append("h4").call(_t.append("QA.keepRight.detail_description"));
+ descriptionEnter.append("div").attr("class", "qa-details-description-text").html(issueDetail);
+ let relatedEntities = [];
+ descriptionEnter.selectAll(".error_entity_link, .error_object_link").attr("href", "#").each(function() {
+ const link3 = select_default2(this);
+ const isObjectLink = link3.classed("error_object_link");
+ const entityID = isObjectLink ? utilEntityRoot(_qaItem.objectType) + _qaItem.objectId : this.textContent;
+ const entity = context.hasEntity(entityID);
+ relatedEntities.push(entityID);
+ link3.on("mouseenter", () => {
+ utilHighlightEntities([entityID], true, context);
+ }).on("mouseleave", () => {
+ utilHighlightEntities([entityID], false, context);
+ }).on("click", (d3_event) => {
+ d3_event.preventDefault();
+ utilHighlightEntities([entityID], false, context);
+ const osmlayer = context.layers().layer("osm");
+ if (!osmlayer.enabled()) {
+ osmlayer.enabled(true);
+ }
+ context.map().centerZoom(_qaItem.loc, 20);
+ if (entity) {
+ context.enter(modeSelect(context, [entityID]));
+ } else {
+ context.loadEntity(entityID, (err, result) => {
+ if (err)
+ return;
+ const entity2 = result.data.find((e3) => e3.id === entityID);
+ if (entity2)
+ context.enter(modeSelect(context, [entityID]));
+ });
+ }
+ });
+ if (entity) {
+ let name = utilDisplayName(entity);
+ if (!name && !isObjectLink) {
+ const preset = _mainPresetIndex.match(entity, context.graph());
+ name = preset && !preset.isFallback() && preset.name();
+ }
+ if (name) {
+ this.innerText = name;
+ }
+ }
+ });
+ context.features().forceVisible(relatedEntities);
+ context.map().pan([0, 0]);
+ }
+ improveOsmDetails.issue = function(val) {
+ if (!arguments.length)
+ return _qaItem;
+ _qaItem = val;
+ return improveOsmDetails;
+ };
+ return improveOsmDetails;
+ }
+
+ // modules/ui/improveOSM_header.js
+ function uiImproveOsmHeader() {
+ let _qaItem;
+ function issueTitle(d2) {
+ const issueKey = d2.issueKey;
+ d2.replacements = d2.replacements || {};
+ d2.replacements.default = { html: _t.html("inspector.unknown") };
+ return _t.html("QA.improveOSM.error_types.".concat(issueKey, ".title"), d2.replacements);
+ }
+ function improveOsmHeader(selection2) {
+ const header = selection2.selectAll(".qa-header").data(
+ _qaItem ? [_qaItem] : [],
+ (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
+ );
+ header.exit().remove();
+ const headerEnter = header.enter().append("div").attr("class", "qa-header");
+ const svgEnter = headerEnter.append("div").attr("class", "qa-header-icon").classed("new", (d2) => d2.id < 0).append("svg").attr("width", "20px").attr("height", "30px").attr("viewbox", "0 0 20 30").attr("class", (d2) => "preset-icon-28 qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.itemType));
+ svgEnter.append("polygon").attr("fill", "currentColor").attr("class", "qaItem-fill").attr("points", "16,3 4,3 1,6 1,17 4,20 7,20 10,27 13,20 16,20 19,17.033 19,6");
+ svgEnter.append("use").attr("class", "icon-annotation").attr("width", "12px").attr("height", "12px").attr("transform", "translate(4, 5.5)").attr("xlink:href", (d2) => d2.icon ? "#" + d2.icon : "");
+ headerEnter.append("div").attr("class", "qa-header-label").html(issueTitle);
+ }
+ improveOsmHeader.issue = function(val) {
+ if (!arguments.length)
+ return _qaItem;
+ _qaItem = val;
+ return improveOsmHeader;
+ };
+ return improveOsmHeader;
+ }
+
+ // modules/ui/improveOSM_editor.js
+ function uiImproveOsmEditor(context) {
+ const dispatch14 = dispatch_default("change");
+ const qaDetails = uiImproveOsmDetails(context);
+ const qaComments = uiImproveOsmComments(context);
+ const qaHeader = uiImproveOsmHeader(context);
+ let _qaItem;
+ function improveOsmEditor(selection2) {
+ const headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL");
+ headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close"));
+ headerEnter.append("h2").call(_t.append("QA.improveOSM.title"));
+ let body = selection2.selectAll(".body").data([0]);
+ body = body.enter().append("div").attr("class", "body").merge(body);
+ const editor = body.selectAll(".qa-editor").data([0]);
+ editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(qaComments.issue(_qaItem)).call(improveOsmSaveSection);
+ }
+ function improveOsmSaveSection(selection2) {
+ const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
+ const isShown = _qaItem && (isSelected || _qaItem.newComment || _qaItem.comment);
+ let saveSection = selection2.selectAll(".qa-save").data(
+ isShown ? [_qaItem] : [],
+ (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
+ );
+ saveSection.exit().remove();
+ const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf");
+ saveSectionEnter.append("h4").attr("class", ".qa-save-header").call(_t.append("note.newComment"));
+ saveSectionEnter.append("textarea").attr("class", "new-comment-input").attr("placeholder", _t("QA.keepRight.comment_placeholder")).attr("maxlength", 1e3).property("value", (d2) => d2.newComment).call(utilNoAuto).on("input", changeInput).on("blur", changeInput);
+ saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons);
+ function changeInput() {
+ const input = select_default2(this);
+ let val = input.property("value").trim();
+ if (val === "") {
+ val = void 0;
+ }
+ _qaItem = _qaItem.update({ newComment: val });
+ const qaService = services.improveOSM;
+ if (qaService) {
+ qaService.replaceItem(_qaItem);
+ }
+ saveSection.call(qaSaveButtons);
+ }
+ }
+ function qaSaveButtons(selection2) {
+ const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
+ let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id);
+ buttonSection.exit().remove();
+ const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
+ buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("QA.keepRight.save_comment"));
+ buttonEnter.append("button").attr("class", "button close-button action");
+ buttonEnter.append("button").attr("class", "button ignore-button action");
+ buttonSection = buttonSection.merge(buttonEnter);
+ buttonSection.select(".comment-button").attr("disabled", (d2) => d2.newComment ? null : true).on("click.comment", function(d3_event, d2) {
+ this.blur();
+ const qaService = services.improveOSM;
+ if (qaService) {
+ qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
+ }
+ });
+ buttonSection.select(".close-button").html((d2) => {
+ const andComment = d2.newComment ? "_comment" : "";
+ return _t.html("QA.keepRight.close".concat(andComment));
+ }).on("click.close", function(d3_event, d2) {
+ this.blur();
+ const qaService = services.improveOSM;
+ if (qaService) {
+ d2.newStatus = "SOLVED";
+ qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
+ }
+ });
+ buttonSection.select(".ignore-button").html((d2) => {
+ const andComment = d2.newComment ? "_comment" : "";
+ return _t.html("QA.keepRight.ignore".concat(andComment));
+ }).on("click.ignore", function(d3_event, d2) {
+ this.blur();
+ const qaService = services.improveOSM;
+ if (qaService) {
+ d2.newStatus = "INVALID";
+ qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
+ }
+ });
+ }
+ improveOsmEditor.error = function(val) {
+ if (!arguments.length)
+ return _qaItem;
+ _qaItem = val;
+ return improveOsmEditor;
+ };
+ return utilRebind(improveOsmEditor, dispatch14, "on");
+ }
+
+ // modules/ui/keepRight_details.js
+ function uiKeepRightDetails(context) {
+ let _qaItem;
+ function issueDetail(d2) {
+ const { itemType, parentIssueType } = d2;
+ const unknown = { html: _t.html("inspector.unknown") };
+ let replacements = d2.replacements || {};
+ replacements.default = unknown;
+ if (_mainLocalizer.hasTextForStringId("QA.keepRight.errorTypes.".concat(itemType, ".title"))) {
+ return _t.html("QA.keepRight.errorTypes.".concat(itemType, ".description"), replacements);
+ } else {
+ return _t.html("QA.keepRight.errorTypes.".concat(parentIssueType, ".description"), replacements);
+ }
+ }
+ function keepRightDetails(selection2) {
+ const details = selection2.selectAll(".error-details").data(
+ _qaItem ? [_qaItem] : [],
+ (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
+ );
+ details.exit().remove();
+ const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container");
+ const descriptionEnter = detailsEnter.append("div").attr("class", "qa-details-subsection");
+ descriptionEnter.append("h4").call(_t.append("QA.keepRight.detail_description"));
+ descriptionEnter.append("div").attr("class", "qa-details-description-text").html(issueDetail);
+ let relatedEntities = [];
+ descriptionEnter.selectAll(".error_entity_link, .error_object_link").attr("href", "#").each(function() {
+ const link3 = select_default2(this);
+ const isObjectLink = link3.classed("error_object_link");
+ const entityID = isObjectLink ? utilEntityRoot(_qaItem.objectType) + _qaItem.objectId : this.textContent;
+ const entity = context.hasEntity(entityID);
+ relatedEntities.push(entityID);
+ link3.on("mouseenter", () => {
+ utilHighlightEntities([entityID], true, context);
+ }).on("mouseleave", () => {
+ utilHighlightEntities([entityID], false, context);
+ }).on("click", (d3_event) => {
+ d3_event.preventDefault();
+ utilHighlightEntities([entityID], false, context);
+ const osmlayer = context.layers().layer("osm");
+ if (!osmlayer.enabled()) {
+ osmlayer.enabled(true);
+ }
+ context.map().centerZoomEase(_qaItem.loc, 20);
+ if (entity) {
+ context.enter(modeSelect(context, [entityID]));
+ } else {
+ context.loadEntity(entityID, (err, result) => {
+ if (err)
+ return;
+ const entity2 = result.data.find((e3) => e3.id === entityID);
+ if (entity2)
+ context.enter(modeSelect(context, [entityID]));
+ });
+ }
+ });
+ if (entity) {
+ let name = utilDisplayName(entity);
+ if (!name && !isObjectLink) {
+ const preset = _mainPresetIndex.match(entity, context.graph());
+ name = preset && !preset.isFallback() && preset.name();
+ }
+ if (name) {
+ this.innerText = name;
+ }
+ }
+ });
+ context.features().forceVisible(relatedEntities);
+ context.map().pan([0, 0]);
+ }
+ keepRightDetails.issue = function(val) {
+ if (!arguments.length)
+ return _qaItem;
+ _qaItem = val;
+ return keepRightDetails;
+ };
+ return keepRightDetails;
+ }
+
+ // modules/ui/keepRight_header.js
+ function uiKeepRightHeader() {
+ let _qaItem;
+ function issueTitle(d2) {
+ const { itemType, parentIssueType } = d2;
+ const unknown = _t.html("inspector.unknown");
+ let replacements = d2.replacements || {};
+ replacements.default = { html: unknown };
+ if (_mainLocalizer.hasTextForStringId("QA.keepRight.errorTypes.".concat(itemType, ".title"))) {
+ return _t.html("QA.keepRight.errorTypes.".concat(itemType, ".title"), replacements);
+ } else {
+ return _t.html("QA.keepRight.errorTypes.".concat(parentIssueType, ".title"), replacements);
+ }
+ }
+ function keepRightHeader(selection2) {
+ const header = selection2.selectAll(".qa-header").data(
+ _qaItem ? [_qaItem] : [],
+ (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
+ );
+ header.exit().remove();
+ const headerEnter = header.enter().append("div").attr("class", "qa-header");
+ const iconEnter = headerEnter.append("div").attr("class", "qa-header-icon").classed("new", (d2) => d2.id < 0);
+ iconEnter.append("div").attr("class", (d2) => "preset-icon-28 qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.parentIssueType)).call(svgIcon("#iD-icon-bolt", "qaItem-fill"));
+ headerEnter.append("div").attr("class", "qa-header-label").html(issueTitle);
+ }
+ keepRightHeader.issue = function(val) {
+ if (!arguments.length)
+ return _qaItem;
+ _qaItem = val;
+ return keepRightHeader;
+ };
+ return keepRightHeader;
+ }
+
+ // modules/ui/view_on_keepRight.js
+ function uiViewOnKeepRight() {
+ let _qaItem;
+ function viewOnKeepRight(selection2) {
+ let url;
+ if (services.keepRight && _qaItem instanceof QAItem) {
+ url = services.keepRight.issueURL(_qaItem);
+ }
+ const link3 = selection2.selectAll(".view-on-keepRight").data(url ? [url] : []);
+ link3.exit().remove();
+ const linkEnter = link3.enter().append("a").attr("class", "view-on-keepRight").attr("target", "_blank").attr("rel", "noopener").attr("href", (d2) => d2).call(svgIcon("#iD-icon-out-link", "inline"));
+ linkEnter.append("span").call(_t.append("inspector.view_on_keepRight"));
+ }
+ viewOnKeepRight.what = function(val) {
+ if (!arguments.length)
+ return _qaItem;
+ _qaItem = val;
+ return viewOnKeepRight;
+ };
+ return viewOnKeepRight;
+ }
+
+ // modules/ui/keepRight_editor.js
+ function uiKeepRightEditor(context) {
+ const dispatch14 = dispatch_default("change");
+ const qaDetails = uiKeepRightDetails(context);
+ const qaHeader = uiKeepRightHeader(context);
+ let _qaItem;
+ function keepRightEditor(selection2) {
+ const headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL");
+ headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close"));
+ headerEnter.append("h2").call(_t.append("QA.keepRight.title"));
+ let body = selection2.selectAll(".body").data([0]);
+ body = body.enter().append("div").attr("class", "body").merge(body);
+ const editor = body.selectAll(".qa-editor").data([0]);
+ editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(keepRightSaveSection);
+ const footer = selection2.selectAll(".footer").data([0]);
+ footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnKeepRight(context).what(_qaItem));
+ }
+ function keepRightSaveSection(selection2) {
+ const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
+ const isShown = _qaItem && (isSelected || _qaItem.newComment || _qaItem.comment);
+ let saveSection = selection2.selectAll(".qa-save").data(
+ isShown ? [_qaItem] : [],
+ (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
+ );
+ saveSection.exit().remove();
+ const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf");
+ saveSectionEnter.append("h4").attr("class", ".qa-save-header").call(_t.append("QA.keepRight.comment"));
+ saveSectionEnter.append("textarea").attr("class", "new-comment-input").attr("placeholder", _t("QA.keepRight.comment_placeholder")).attr("maxlength", 1e3).property("value", (d2) => d2.newComment || d2.comment).call(utilNoAuto).on("input", changeInput).on("blur", changeInput);
+ saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons);
+ function changeInput() {
+ const input = select_default2(this);
+ let val = input.property("value").trim();
+ if (val === _qaItem.comment) {
+ val = void 0;
+ }
+ _qaItem = _qaItem.update({ newComment: val });
+ const qaService = services.keepRight;
+ if (qaService) {
+ qaService.replaceItem(_qaItem);
+ }
+ saveSection.call(qaSaveButtons);
+ }
+ }
+ function qaSaveButtons(selection2) {
+ const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
+ let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id);
+ buttonSection.exit().remove();
+ const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
+ buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("QA.keepRight.save_comment"));
+ buttonEnter.append("button").attr("class", "button close-button action");
+ buttonEnter.append("button").attr("class", "button ignore-button action");
+ buttonSection = buttonSection.merge(buttonEnter);
+ buttonSection.select(".comment-button").attr("disabled", (d2) => d2.newComment ? null : true).on("click.comment", function(d3_event, d2) {
+ this.blur();
+ const qaService = services.keepRight;
+ if (qaService) {
+ qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
+ }
+ });
+ buttonSection.select(".close-button").html((d2) => {
+ const andComment = d2.newComment ? "_comment" : "";
+ return _t.html("QA.keepRight.close".concat(andComment));
+ }).on("click.close", function(d3_event, d2) {
+ this.blur();
+ const qaService = services.keepRight;
+ if (qaService) {
+ d2.newStatus = "ignore_t";
+ qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
+ }
+ });
+ buttonSection.select(".ignore-button").html((d2) => {
+ const andComment = d2.newComment ? "_comment" : "";
+ return _t.html("QA.keepRight.ignore".concat(andComment));
+ }).on("click.ignore", function(d3_event, d2) {
+ this.blur();
+ const qaService = services.keepRight;
+ if (qaService) {
+ d2.newStatus = "ignore";
+ qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
+ }
+ });
+ }
+ keepRightEditor.error = function(val) {
+ if (!arguments.length)
+ return _qaItem;
+ _qaItem = val;
+ return keepRightEditor;
+ };
+ return utilRebind(keepRightEditor, dispatch14, "on");
+ }
+
+ // modules/ui/osmose_details.js
+ function uiOsmoseDetails(context) {
+ let _qaItem;
+ function issueString(d2, type2) {
+ if (!d2)
+ return "";
+ const s2 = services.osmose.getStrings(d2.itemType);
+ return type2 in s2 ? s2[type2] : "";
+ }
+ function osmoseDetails(selection2) {
+ const details = selection2.selectAll(".error-details").data(
+ _qaItem ? [_qaItem] : [],
+ (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
+ );
+ details.exit().remove();
+ const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container");
+ if (issueString(_qaItem, "detail")) {
+ const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
+ div.append("h4").call(_t.append("QA.keepRight.detail_description"));
+ div.append("p").attr("class", "qa-details-description-text").html((d2) => issueString(d2, "detail")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
+ }
+ const detailsDiv = detailsEnter.append("div").attr("class", "qa-details-subsection");
+ const elemsDiv = detailsEnter.append("div").attr("class", "qa-details-subsection");
+ if (issueString(_qaItem, "fix")) {
+ const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
+ div.append("h4").call(_t.append("QA.osmose.fix_title"));
+ div.append("p").html((d2) => issueString(d2, "fix")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
+ }
+ if (issueString(_qaItem, "trap")) {
+ const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
+ div.append("h4").call(_t.append("QA.osmose.trap_title"));
+ div.append("p").html((d2) => issueString(d2, "trap")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
+ }
+ const thisItem = _qaItem;
+ services.osmose.loadIssueDetail(_qaItem).then((d2) => {
+ if (!d2.elems || d2.elems.length === 0)
+ return;
+ if (context.selectedErrorID() !== thisItem.id && context.container().selectAll(".qaItem.osmose.hover.itemId-".concat(thisItem.id)).empty())
+ return;
+ if (d2.detail) {
+ detailsDiv.append("h4").call(_t.append("QA.osmose.detail_title"));
+ detailsDiv.append("p").html((d4) => d4.detail).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
+ }
+ elemsDiv.append("h4").call(_t.append("QA.osmose.elems_title"));
+ elemsDiv.append("ul").selectAll("li").data(d2.elems).enter().append("li").append("a").attr("href", "#").attr("class", "error_entity_link").text((d4) => d4).each(function() {
+ const link3 = select_default2(this);
+ const entityID = this.textContent;
+ const entity = context.hasEntity(entityID);
+ link3.on("mouseenter", () => {
+ utilHighlightEntities([entityID], true, context);
+ }).on("mouseleave", () => {
+ utilHighlightEntities([entityID], false, context);
+ }).on("click", (d3_event) => {
+ d3_event.preventDefault();
+ utilHighlightEntities([entityID], false, context);
+ const osmlayer = context.layers().layer("osm");
+ if (!osmlayer.enabled()) {
+ osmlayer.enabled(true);
+ }
+ context.map().centerZoom(d2.loc, 20);
+ if (entity) {
+ context.enter(modeSelect(context, [entityID]));
+ } else {
+ context.loadEntity(entityID, (err, result) => {
+ if (err)
+ return;
+ const entity2 = result.data.find((e3) => e3.id === entityID);
+ if (entity2)
+ context.enter(modeSelect(context, [entityID]));
+ });
+ }
+ });
+ if (entity) {
+ let name = utilDisplayName(entity);
+ if (!name) {
+ const preset = _mainPresetIndex.match(entity, context.graph());
+ name = preset && !preset.isFallback() && preset.name();
+ }
+ if (name) {
+ this.innerText = name;
+ }
+ }
+ });
+ context.features().forceVisible(d2.elems);
+ context.map().pan([0, 0]);
+ }).catch((err) => {
+ console.log(err);
+ });
+ }
+ osmoseDetails.issue = function(val) {
+ if (!arguments.length)
+ return _qaItem;
+ _qaItem = val;
+ return osmoseDetails;
+ };
+ return osmoseDetails;
+ }
+
+ // modules/ui/osmose_header.js
+ function uiOsmoseHeader() {
+ let _qaItem;
+ function issueTitle(d2) {
+ const unknown = _t("inspector.unknown");
+ if (!d2)
+ return unknown;
+ const s2 = services.osmose.getStrings(d2.itemType);
+ return "title" in s2 ? s2.title : unknown;
+ }
+ function osmoseHeader(selection2) {
+ const header = selection2.selectAll(".qa-header").data(
+ _qaItem ? [_qaItem] : [],
+ (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
+ );
+ header.exit().remove();
+ const headerEnter = header.enter().append("div").attr("class", "qa-header");
+ const svgEnter = headerEnter.append("div").attr("class", "qa-header-icon").classed("new", (d2) => d2.id < 0).append("svg").attr("width", "20px").attr("height", "30px").attr("viewbox", "0 0 20 30").attr("class", (d2) => "preset-icon-28 qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.itemType));
+ svgEnter.append("polygon").attr("fill", (d2) => services.osmose.getColor(d2.item)).attr("class", "qaItem-fill").attr("points", "16,3 4,3 1,6 1,17 4,20 7,20 10,27 13,20 16,20 19,17.033 19,6");
+ svgEnter.append("use").attr("class", "icon-annotation").attr("width", "12px").attr("height", "12px").attr("transform", "translate(4, 5.5)").attr("xlink:href", (d2) => d2.icon ? "#" + d2.icon : "");
+ headerEnter.append("div").attr("class", "qa-header-label").text(issueTitle);
+ }
+ osmoseHeader.issue = function(val) {
+ if (!arguments.length)
+ return _qaItem;
+ _qaItem = val;
+ return osmoseHeader;
+ };
+ return osmoseHeader;
+ }
+
+ // modules/ui/view_on_osmose.js
+ function uiViewOnOsmose() {
+ let _qaItem;
+ function viewOnOsmose(selection2) {
+ let url;
+ if (services.osmose && _qaItem instanceof QAItem) {
+ url = services.osmose.itemURL(_qaItem);
+ }
+ const link3 = selection2.selectAll(".view-on-osmose").data(url ? [url] : []);
+ link3.exit().remove();
+ const linkEnter = link3.enter().append("a").attr("class", "view-on-osmose").attr("target", "_blank").attr("rel", "noopener").attr("href", (d2) => d2).call(svgIcon("#iD-icon-out-link", "inline"));
+ linkEnter.append("span").call(_t.append("inspector.view_on_osmose"));
+ }
+ viewOnOsmose.what = function(val) {
+ if (!arguments.length)
+ return _qaItem;
+ _qaItem = val;
+ return viewOnOsmose;
+ };
+ return viewOnOsmose;
+ }
+
+ // modules/ui/osmose_editor.js
+ function uiOsmoseEditor(context) {
+ const dispatch14 = dispatch_default("change");
+ const qaDetails = uiOsmoseDetails(context);
+ const qaHeader = uiOsmoseHeader(context);
+ let _qaItem;
+ function osmoseEditor(selection2) {
+ const header = selection2.selectAll(".header").data([0]);
+ const headerEnter = header.enter().append("div").attr("class", "header fillL");
+ headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close"));
+ headerEnter.append("h2").call(_t.append("QA.osmose.title"));
+ let body = selection2.selectAll(".body").data([0]);
+ body = body.enter().append("div").attr("class", "body").merge(body);
+ let editor = body.selectAll(".qa-editor").data([0]);
+ editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(osmoseSaveSection);
+ const footer = selection2.selectAll(".footer").data([0]);
+ footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnOsmose(context).what(_qaItem));
+ }
+ function osmoseSaveSection(selection2) {
+ const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
+ const isShown = _qaItem && isSelected;
+ let saveSection = selection2.selectAll(".qa-save").data(
+ isShown ? [_qaItem] : [],
+ (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
+ );
+ saveSection.exit().remove();
+ const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf");
+ saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons);
+ }
+ function qaSaveButtons(selection2) {
+ const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
+ let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id);
+ buttonSection.exit().remove();
+ const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
+ buttonEnter.append("button").attr("class", "button close-button action");
+ buttonEnter.append("button").attr("class", "button ignore-button action");
+ buttonSection = buttonSection.merge(buttonEnter);
+ buttonSection.select(".close-button").call(_t.append("QA.keepRight.close")).on("click.close", function(d3_event, d2) {
+ this.blur();
+ const qaService = services.osmose;
+ if (qaService) {
+ d2.newStatus = "done";
+ qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
+ }
+ });
+ buttonSection.select(".ignore-button").call(_t.append("QA.keepRight.ignore")).on("click.ignore", function(d3_event, d2) {
+ this.blur();
+ const qaService = services.osmose;
+ if (qaService) {
+ d2.newStatus = "false";
+ qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
+ }
+ });
+ }
+ osmoseEditor.error = function(val) {
+ if (!arguments.length)
+ return _qaItem;
+ _qaItem = val;
+ return osmoseEditor;
+ };
+ return utilRebind(osmoseEditor, dispatch14, "on");
+ }
+
+ // modules/modes/select_error.js
+ function modeSelectError(context, selectedErrorID, selectedErrorService) {
+ var mode = {
+ id: "select-error",
+ button: "browse"
+ };
+ var keybinding = utilKeybinding("select-error");
+ var errorService = services[selectedErrorService];
+ var errorEditor;
+ switch (selectedErrorService) {
+ case "improveOSM":
+ errorEditor = uiImproveOsmEditor(context).on("change", function() {
+ context.map().pan([0, 0]);
+ var error = checkSelectedID();
+ if (!error)
+ return;
+ context.ui().sidebar.show(errorEditor.error(error));
+ });
+ break;
+ case "keepRight":
+ errorEditor = uiKeepRightEditor(context).on("change", function() {
+ context.map().pan([0, 0]);
+ var error = checkSelectedID();
+ if (!error)
+ return;
+ context.ui().sidebar.show(errorEditor.error(error));
+ });
+ break;
+ case "osmose":
+ errorEditor = uiOsmoseEditor(context).on("change", function() {
+ context.map().pan([0, 0]);
+ var error = checkSelectedID();
+ if (!error)
+ return;
+ context.ui().sidebar.show(errorEditor.error(error));
+ });
+ break;
+ }
+ var behaviors = [
+ behaviorBreathe(context),
+ behaviorHover(context),
+ behaviorSelect(context),
+ behaviorLasso(context),
+ modeDragNode(context).behavior,
+ modeDragNote(context).behavior
+ ];
+ function checkSelectedID() {
+ if (!errorService)
+ return;
+ var error = errorService.getError(selectedErrorID);
+ if (!error) {
+ 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/ui/feature_list.js
+ function uiFeatureList(context) {
+ var _geocodeResults;
+ function featureList(selection2) {
+ var header = selection2.append("div").attr("class", "header fillL");
+ header.append("h2").call(_t.append("inspector.feature_list"));
+ var searchWrap = selection2.append("div").attr("class", "search-header");
+ searchWrap.call(svgIcon("#iD-icon-search", "pre-text"));
+ var search = searchWrap.append("input").attr("placeholder", _t("inspector.search")).attr("type", "search").call(utilNoAuto).on("keypress", keypress).on("keydown", keydown).on("input", inputevent);
+ var listWrap = selection2.append("div").attr("class", "inspector-body");
+ var list2 = listWrap.append("div").attr("class", "feature-list");
+ context.on("exit.feature-list", clearSearch);
+ context.map().on("drawn.feature-list", mapDrawn);
+ context.keybinding().on(uiCmd("\u2318F"), focusSearch);
+ function focusSearch(d3_event) {
+ var mode = context.mode() && context.mode().id;
+ if (mode !== "browse")
+ return;
+ d3_event.preventDefault();
+ search.node().focus();
+ }
+ function keydown(d3_event) {
+ if (d3_event.keyCode === 27) {
+ search.node().blur();
+ }
+ }
+ function keypress(d3_event) {
+ var q2 = search.property("value"), items = list2.selectAll(".feature-list-item");
+ if (d3_event.keyCode === 13 && // ↩ Return
+ q2.length && items.size()) {
+ click(d3_event, items.datum());
+ }
+ }
+ function inputevent() {
+ _geocodeResults = void 0;
+ drawList();
+ }
+ function clearSearch() {
+ search.property("value", "");
+ drawList();
+ }
+ function mapDrawn(e3) {
+ if (e3.full) {
+ drawList();
+ }
+ }
+ function features() {
+ var result = [];
+ var graph = context.graph();
+ var visibleCenter = context.map().extent().center();
+ var q2 = search.property("value").toLowerCase();
+ if (!q2)
+ return result;
+ var locationMatch = sexagesimal.pair(q2.toUpperCase()) || dmsMatcher(q2);
+ if (locationMatch) {
+ var loc = [Number(locationMatch[0]), Number(locationMatch[1])];
+ result.push({
+ id: -1,
+ geometry: "point",
+ type: _t("inspector.location"),
+ name: dmsCoordinatePair([loc[1], loc[0]]),
+ location: loc
+ });
+ }
+ var idMatch = !locationMatch && q2.match(/(?:^|\W)(node|way|relation|note|[nwr])\W{0,2}0*([1-9]\d*)(?:\W|$)/i);
+ if (idMatch) {
+ var elemType = idMatch[1] === "note" ? idMatch[1] : idMatch[1].charAt(0);
+ var elemId = idMatch[2];
+ result.push({
+ id: elemType + elemId,
+ geometry: elemType === "n" ? "point" : elemType === "w" ? "line" : elemType === "note" ? "note" : "relation",
+ type: elemType === "n" ? _t("inspector.node") : elemType === "w" ? _t("inspector.way") : elemType === "note" ? _t("note.note") : _t("inspector.relation"),
+ name: elemId
+ });
+ }
+ var allEntities = graph.entities;
+ var localResults = [];
+ for (var id2 in allEntities) {
+ var entity = allEntities[id2];
+ if (!entity)
+ continue;
+ var name = utilDisplayName(entity) || "";
+ if (name.toLowerCase().indexOf(q2) < 0)
+ continue;
+ var matched = _mainPresetIndex.match(entity, graph);
+ var type2 = matched && matched.name() || utilDisplayType(entity.id);
+ var extent = entity.extent(graph);
+ var distance = extent ? geoSphericalDistance(visibleCenter, extent.center()) : 0;
+ localResults.push({
+ id: entity.id,
+ entity,
+ geometry: entity.geometry(graph),
+ type: type2,
+ name,
+ distance
+ });
+ if (localResults.length > 100)
+ break;
+ }
+ localResults = localResults.sort(function byDistance(a2, b2) {
+ return a2.distance - b2.distance;
+ });
+ result = result.concat(localResults);
+ (_geocodeResults || []).forEach(function(d2) {
+ if (d2.osm_type && d2.osm_id) {
+ var id3 = osmEntity.id.fromOSM(d2.osm_type, d2.osm_id);
+ var tags = {};
+ tags[d2.class] = d2.type;
+ var attrs = { id: id3, type: d2.osm_type, tags };
+ if (d2.osm_type === "way") {
+ attrs.nodes = ["a", "a"];
+ }
+ var tempEntity = osmEntity(attrs);
+ var tempGraph = coreGraph([tempEntity]);
+ var matched2 = _mainPresetIndex.match(tempEntity, tempGraph);
+ var type3 = matched2 && matched2.name() || utilDisplayType(id3);
+ result.push({
+ id: tempEntity.id,
+ geometry: tempEntity.geometry(tempGraph),
+ type: type3,
+ name: d2.display_name,
+ extent: new geoExtent(
+ [Number(d2.boundingbox[3]), Number(d2.boundingbox[0])],
+ [Number(d2.boundingbox[2]), Number(d2.boundingbox[1])]
+ )
+ });
+ }
+ });
+ if (q2.match(/^[0-9]+$/)) {
+ result.push({
+ id: "n" + q2,
+ geometry: "point",
+ type: _t("inspector.node"),
+ name: q2
+ });
+ result.push({
+ id: "w" + q2,
+ geometry: "line",
+ type: _t("inspector.way"),
+ name: q2
+ });
+ result.push({
+ id: "r" + q2,
+ geometry: "relation",
+ type: _t("inspector.relation"),
+ name: q2
+ });
+ result.push({
+ id: "note" + q2,
+ geometry: "note",
+ type: _t("note.note"),
+ name: q2
+ });
+ }
+ return result;
+ }
+ function drawList() {
+ var value = search.property("value");
+ var results = features();
+ list2.classed("filtered", value.length);
+ var resultsIndicator = list2.selectAll(".no-results-item").data([0]).enter().append("button").property("disabled", true).attr("class", "no-results-item").call(svgIcon("#iD-icon-alert", "pre-text"));
+ resultsIndicator.append("span").attr("class", "entity-name");
+ list2.selectAll(".no-results-item .entity-name").html("").call(_t.append("geocoder.no_results_worldwide"));
+ if (services.geocoder) {
+ list2.selectAll(".geocode-item").data([0]).enter().append("button").attr("class", "geocode-item secondary-action").on("click", geocoderSearch).append("div").attr("class", "label").append("span").attr("class", "entity-name").call(_t.append("geocoder.search"));
+ }
+ list2.selectAll(".no-results-item").style("display", value.length && !results.length ? "block" : "none");
+ list2.selectAll(".geocode-item").style("display", value && _geocodeResults === void 0 ? "block" : "none");
+ list2.selectAll(".feature-list-item").data([-1]).remove();
+ var items = list2.selectAll(".feature-list-item").data(results, function(d2) {
+ return d2.id;
+ });
+ var enter = items.enter().insert("button", ".geocode-item").attr("class", "feature-list-item").on("mouseover", mouseover).on("mouseout", mouseout).on("click", click);
+ var label = enter.append("div").attr("class", "label");
+ label.each(function(d2) {
+ select_default2(this).call(svgIcon("#iD-icon-" + d2.geometry, "pre-text"));
+ });
+ label.append("span").attr("class", "entity-type").text(function(d2) {
+ return d2.type;
+ });
+ label.append("span").attr("class", "entity-name").classed("has-colour", (d2) => d2.entity && d2.entity.type === "relation" && d2.entity.tags.colour && isColourValid(d2.entity.tags.colour)).style("border-color", (d2) => d2.entity && d2.entity.type === "relation" && d2.entity.tags.colour).text(function(d2) {
+ return d2.name;
+ });
+ enter.style("opacity", 0).transition().style("opacity", 1);
+ items.order();
+ items.exit().remove();
+ }
+ function mouseover(d3_event, d2) {
+ if (d2.id === -1)
+ return;
+ utilHighlightEntities([d2.id], true, context);
+ }
+ function mouseout(d3_event, d2) {
+ if (d2.id === -1)
+ return;
+ utilHighlightEntities([d2.id], false, context);
+ }
+ function click(d3_event, d2) {
+ d3_event.preventDefault();
+ if (d2.location) {
+ context.map().centerZoomEase([d2.location[1], d2.location[0]], 19);
+ } else if (d2.entity) {
+ utilHighlightEntities([d2.id], false, context);
+ context.enter(modeSelect(context, [d2.entity.id]));
+ context.map().zoomToEase(d2.entity);
+ } else if (d2.geometry === "note") {
+ const noteId = d2.id.replace(/\D/g, "");
+ context.loadNote(noteId, (err, result) => {
+ if (err)
+ return;
+ const entity = result.data.find((e3) => e3.id === noteId);
+ if (entity) {
+ const note = services.osm.getNote(noteId);
+ context.map().centerZoom(note.loc, 15);
+ const noteLayer = context.layers().layer("notes");
+ noteLayer.enabled(true);
+ context.enter(modeSelectNote(context, noteId));
+ }
+ });
+ } else {
+ context.zoomToEntity(d2.id);
+ }
+ }
+ function geocoderSearch() {
+ services.geocoder.search(search.property("value"), function(err, resp) {
+ _geocodeResults = resp || [];
+ drawList();
+ });
+ }
+ }
+ return featureList;
+ }
+
+ // modules/ui/preset_list.js
+ function uiPresetList(context) {
+ var dispatch14 = dispatch_default("cancel", "choose");
+ var _entityIDs;
+ var _currLoc;
+ var _currentPresets;
+ var _autofocus = false;
+ function presetList(selection2) {
+ if (!_entityIDs)
+ return;
+ var presets = _mainPresetIndex.matchAllGeometry(entityGeometries());
+ selection2.html("");
+ var messagewrap = selection2.append("div").attr("class", "header fillL");
+ var message = messagewrap.append("h2").call(_t.append("inspector.choose"));
+ var direction = _mainLocalizer.textDirection() === "rtl" ? "backward" : "forward";
+ messagewrap.append("button").attr("class", "preset-choose").attr("title", _entityIDs.length === 1 ? _t("inspector.edit") : _t("inspector.edit_features")).on("click", function() {
+ dispatch14.call("cancel", this);
+ }).call(svgIcon("#iD-icon-".concat(direction)));
+ function initialKeydown(d3_event) {
+ if (search.property("value").length === 0 && (d3_event.keyCode === utilKeybinding.keyCodes["\u232B"] || d3_event.keyCode === utilKeybinding.keyCodes["\u2326"])) {
+ d3_event.preventDefault();
+ d3_event.stopPropagation();
+ operationDelete(context, _entityIDs)();
+ } else if (search.property("value").length === 0 && (d3_event.ctrlKey || d3_event.metaKey) && d3_event.keyCode === utilKeybinding.keyCodes.z) {
+ d3_event.preventDefault();
+ d3_event.stopPropagation();
+ context.undo();
+ } else if (!d3_event.ctrlKey && !d3_event.metaKey) {
+ select_default2(this).on("keydown", keydown);
+ keydown.call(this, d3_event);
+ }
+ }
+ function keydown(d3_event) {
+ if (d3_event.keyCode === utilKeybinding.keyCodes["\u2193"] && // if insertion point is at the end of the string
+ search.node().selectionStart === search.property("value").length) {
+ d3_event.preventDefault();
+ d3_event.stopPropagation();
+ var buttons = list2.selectAll(".preset-list-button");
+ if (!buttons.empty())
+ buttons.nodes()[0].focus();
+ }
+ }
+ function keypress(d3_event) {
+ var value = search.property("value");
+ if (d3_event.keyCode === 13 && // ↩ Return
+ value.length) {
+ list2.selectAll(".preset-list-item:first-child").each(function(d2) {
+ d2.choose.call(this);
+ });
+ }
+ }
+ function inputevent() {
+ var value = search.property("value");
+ list2.classed("filtered", value.length);
+ var results, messageText;
+ if (value.length) {
+ results = presets.search(value, entityGeometries()[0], _currLoc);
+ messageText = _t.html("inspector.results", {
+ n: results.collection.length,
+ search: value
+ });
+ } else {
+ var entityPresets2 = _entityIDs.map((entityID) => _mainPresetIndex.match(context.graph().entity(entityID), context.graph()));
+ results = _mainPresetIndex.defaults(entityGeometries()[0], 36, !context.inIntro(), _currLoc, entityPresets2);
+ messageText = _t.html("inspector.choose");
+ }
+ list2.call(drawList, results);
+ message.html(messageText);
+ }
+ var searchWrap = selection2.append("div").attr("class", "search-header");
+ searchWrap.call(svgIcon("#iD-icon-search", "pre-text"));
+ var search = searchWrap.append("input").attr("class", "preset-search-input").attr("placeholder", _t("inspector.search")).attr("type", "search").call(utilNoAuto).on("keydown", initialKeydown).on("keypress", keypress).on("input", debounce_default(inputevent));
+ if (_autofocus) {
+ search.node().focus();
+ setTimeout(function() {
+ search.node().focus();
+ }, 0);
+ }
+ var listWrap = selection2.append("div").attr("class", "inspector-body");
+ var entityPresets = _entityIDs.map((entityID) => _mainPresetIndex.match(context.graph().entity(entityID), context.graph()));
+ var list2 = listWrap.append("div").attr("class", "preset-list").call(drawList, _mainPresetIndex.defaults(entityGeometries()[0], 36, !context.inIntro(), _currLoc, entityPresets));
+ context.features().on("change.preset-list", updateForFeatureHiddenState);
+ }
+ function drawList(list2, presets) {
+ presets = presets.matchAllGeometry(entityGeometries());
+ var collection = presets.collection.reduce(function(collection2, preset) {
+ if (!preset)
+ return collection2;
+ if (preset.members) {
+ if (preset.members.collection.filter(function(preset2) {
+ return preset2.addable();
+ }).length > 1) {
+ collection2.push(CategoryItem(preset));
+ }
+ } else if (preset.addable()) {
+ collection2.push(PresetItem(preset));
+ }
+ return collection2;
+ }, []);
+ var items = list2.selectAll(".preset-list-item").data(collection, function(d2) {
+ return d2.preset.id;
+ });
+ items.order();
+ items.exit().remove();
+ items.enter().append("div").attr("class", function(item) {
+ return "preset-list-item preset-" + item.preset.id.replace("/", "-");
+ }).classed("current", function(item) {
+ return _currentPresets.indexOf(item.preset) !== -1;
+ }).each(function(item) {
+ select_default2(this).call(item);
+ }).style("opacity", 0).transition().style("opacity", 1);
+ updateForFeatureHiddenState();
+ }
+ function itemKeydown(d3_event) {
+ var item = select_default2(this.closest(".preset-list-item"));
+ var parentItem = select_default2(item.node().parentNode.closest(".preset-list-item"));
+ if (d3_event.keyCode === utilKeybinding.keyCodes["\u2193"]) {
+ d3_event.preventDefault();
+ d3_event.stopPropagation();
+ var nextItem = select_default2(item.node().nextElementSibling);
+ if (nextItem.empty()) {
+ if (!parentItem.empty()) {
+ nextItem = select_default2(parentItem.node().nextElementSibling);
+ }
+ } else if (select_default2(this).classed("expanded")) {
+ nextItem = item.select(".subgrid .preset-list-item:first-child");
+ }
+ if (!nextItem.empty()) {
+ nextItem.select(".preset-list-button").node().focus();
+ }
+ } else if (d3_event.keyCode === utilKeybinding.keyCodes["\u2191"]) {
+ d3_event.preventDefault();
+ d3_event.stopPropagation();
+ var previousItem = select_default2(item.node().previousElementSibling);
+ if (previousItem.empty()) {
+ if (!parentItem.empty()) {
+ previousItem = parentItem;
+ }
+ } else if (previousItem.select(".preset-list-button").classed("expanded")) {
+ previousItem = previousItem.select(".subgrid .preset-list-item:last-child");
+ }
+ if (!previousItem.empty()) {
+ previousItem.select(".preset-list-button").node().focus();
+ } else {
+ var search = select_default2(this.closest(".preset-list-pane")).select(".preset-search-input");
+ search.node().focus();
+ }
+ } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2192" : "\u2190"]) {
+ d3_event.preventDefault();
+ d3_event.stopPropagation();
+ if (!parentItem.empty()) {
+ parentItem.select(".preset-list-button").node().focus();
+ }
+ } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2190" : "\u2192"]) {
+ d3_event.preventDefault();
+ d3_event.stopPropagation();
+ item.datum().choose.call(select_default2(this).node());
+ }
+ }
+ function CategoryItem(preset) {
+ var box, sublist, shown = false;
+ function item(selection2) {
+ var wrap2 = selection2.append("div").attr("class", "preset-list-button-wrap category");
+ function click() {
+ var isExpanded = select_default2(this).classed("expanded");
+ var iconName = isExpanded ? _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward" : "#iD-icon-down";
+ select_default2(this).classed("expanded", !isExpanded).attr("title", !isExpanded ? _t("icons.collapse") : _t("icons.expand"));
+ select_default2(this).selectAll("div.label-inner svg.icon use").attr("href", iconName);
+ item.choose();
+ }
+ var geometries = entityGeometries();
+ var button = wrap2.append("button").attr("class", "preset-list-button").attr("title", _t("icons.expand")).classed("expanded", false).call(uiPresetIcon().geometry(geometries.length === 1 && geometries[0]).preset(preset)).on("click", click).on("keydown", function(d3_event) {
+ if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2190" : "\u2192"]) {
+ d3_event.preventDefault();
+ d3_event.stopPropagation();
+ if (!select_default2(this).classed("expanded")) {
+ click.call(this, d3_event);
+ }
+ } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2192" : "\u2190"]) {
+ d3_event.preventDefault();
+ d3_event.stopPropagation();
+ if (select_default2(this).classed("expanded")) {
+ click.call(this, d3_event);
+ }
+ } else {
+ itemKeydown.call(this, d3_event);
+ }
+ });
+ var label = button.append("div").attr("class", "label").append("div").attr("class", "label-inner");
+ label.append("div").attr("class", "namepart").call(svgIcon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward", "inline")).append("span").call(preset.nameLabel()).append("span").text("\u2026");
+ box = selection2.append("div").attr("class", "subgrid").style("max-height", "0px").style("opacity", 0);
+ box.append("div").attr("class", "arrow");
+ sublist = box.append("div").attr("class", "preset-list fillL3");
+ }
+ item.choose = function() {
+ if (!box || !sublist)
+ return;
+ if (shown) {
+ shown = false;
+ box.transition().duration(200).style("opacity", "0").style("max-height", "0px").style("padding-bottom", "0px");
+ } else {
+ shown = true;
+ var members = preset.members.matchAllGeometry(entityGeometries());
+ sublist.call(drawList, members);
+ box.transition().duration(200).style("opacity", "1").style("max-height", 200 + members.collection.length * 190 + "px").style("padding-bottom", "10px");
+ }
+ };
+ item.preset = preset;
+ return item;
+ }
+ function PresetItem(preset) {
+ function item(selection2) {
+ var wrap2 = selection2.append("div").attr("class", "preset-list-button-wrap");
+ var geometries = entityGeometries();
+ var button = wrap2.append("button").attr("class", "preset-list-button").call(uiPresetIcon().geometry(geometries.length === 1 && geometries[0]).preset(preset)).on("click", item.choose).on("keydown", itemKeydown);
+ var label = button.append("div").attr("class", "label").append("div").attr("class", "label-inner");
+ var nameparts = [
+ preset.nameLabel(),
+ preset.subtitleLabel()
+ ].filter(Boolean);
+ label.selectAll(".namepart").data(nameparts, (d2) => d2.stringId).enter().append("div").attr("class", "namepart").text("").each(function(d2) {
+ d2(select_default2(this));
+ });
+ wrap2.call(item.reference.button);
+ selection2.call(item.reference.body);
+ }
+ item.choose = function() {
+ if (select_default2(this).classed("disabled"))
+ return;
+ if (!context.inIntro()) {
+ _mainPresetIndex.setMostRecent(preset, entityGeometries()[0]);
+ }
+ context.perform(
+ function(graph) {
+ for (var i3 in _entityIDs) {
+ var entityID = _entityIDs[i3];
+ var oldPreset = _mainPresetIndex.match(graph.entity(entityID), graph);
+ graph = actionChangePreset(entityID, oldPreset, preset)(graph);
+ }
+ return graph;
+ },
+ _t("operations.change_tags.annotation")
+ );
+ context.validator().validate();
+ dispatch14.call("choose", this, preset);
+ };
+ item.help = function(d3_event) {
+ d3_event.stopPropagation();
+ item.reference.toggle();
+ };
+ item.preset = preset;
+ item.reference = uiTagReference(preset.reference(), context);
+ return item;
+ }
+ function updateForFeatureHiddenState() {
+ if (!_entityIDs.every(context.hasEntity))
+ return;
+ var geometries = entityGeometries();
+ var button = context.container().selectAll(".preset-list .preset-list-button");
+ button.call(uiTooltip().destroyAny);
+ button.each(function(item, index) {
+ var hiddenPresetFeaturesId;
+ for (var i3 in geometries) {
+ hiddenPresetFeaturesId = context.features().isHiddenPreset(item.preset, geometries[i3]);
+ if (hiddenPresetFeaturesId)
+ break;
+ }
+ var isHiddenPreset = !context.inIntro() && !!hiddenPresetFeaturesId && (_currentPresets.length !== 1 || item.preset !== _currentPresets[0]);
+ select_default2(this).classed("disabled", isHiddenPreset);
+ if (isHiddenPreset) {
+ var isAutoHidden = context.features().autoHidden(hiddenPresetFeaturesId);
+ select_default2(this).call(
+ uiTooltip().title(() => _t.append("inspector.hidden_preset." + (isAutoHidden ? "zoom" : "manual"), {
+ features: _t("feature." + hiddenPresetFeaturesId + ".description")
+ })).placement(index < 2 ? "bottom" : "top")
+ );
+ }
+ });
+ }
+ presetList.autofocus = function(val) {
+ if (!arguments.length)
+ return _autofocus;
+ _autofocus = val;
+ return presetList;
+ };
+ presetList.entityIDs = function(val) {
+ if (!arguments.length)
+ return _entityIDs;
+ _entityIDs = val;
+ _currLoc = null;
+ if (_entityIDs && _entityIDs.length) {
+ const extent = _entityIDs.reduce(function(extent2, entityID) {
+ var entity = context.graph().entity(entityID);
+ return extent2.extend(entity.extent(context.graph()));
+ }, geoExtent());
+ _currLoc = extent.center();
+ var presets = _entityIDs.map(function(entityID) {
+ return _mainPresetIndex.match(context.entity(entityID), context.graph());
+ });
+ presetList.presets(presets);
+ }
+ return presetList;
+ };
+ presetList.presets = function(val) {
+ if (!arguments.length)
+ return _currentPresets;
+ _currentPresets = val;
+ return presetList;
+ };
+ function entityGeometries() {
+ var counts = {};
+ for (var i3 in _entityIDs) {
+ var entityID = _entityIDs[i3];
+ var entity = context.entity(entityID);
+ var geometry = entity.geometry(context.graph());
+ if (geometry === "vertex" && entity.isOnAddressLine(context.graph())) {
+ geometry = "point";
+ }
+ if (!counts[geometry])
+ counts[geometry] = 0;
+ counts[geometry] += 1;
+ }
+ return Object.keys(counts).sort(function(geom1, geom2) {
+ return counts[geom2] - counts[geom1];
+ });
+ }
+ return utilRebind(presetList, dispatch14, "on");
+ }
+
+ // modules/ui/inspector.js
+ function uiInspector(context) {
+ var presetList = uiPresetList(context);
+ var entityEditor = uiEntityEditor(context);
+ var wrap2 = select_default2(null), presetPane = select_default2(null), editorPane = select_default2(null);
+ var _state = "select";
+ var _entityIDs;
+ var _newFeature = false;
+ function inspector(selection2) {
+ presetList.entityIDs(_entityIDs).autofocus(_newFeature).on("choose", inspector.setPreset).on("cancel", function() {
+ inspector.setPreset();
+ });
+ entityEditor.state(_state).entityIDs(_entityIDs).on("choose", inspector.showList);
+ wrap2 = selection2.selectAll(".panewrap").data([0]);
+ var enter = wrap2.enter().append("div").attr("class", "panewrap");
+ enter.append("div").attr("class", "preset-list-pane pane");
+ enter.append("div").attr("class", "entity-editor-pane pane");
+ wrap2 = wrap2.merge(enter);
+ presetPane = wrap2.selectAll(".preset-list-pane");
+ editorPane = wrap2.selectAll(".entity-editor-pane");
+ function shouldDefaultToPresetList() {
+ if (_state !== "select")
+ return false;
+ if (_entityIDs.length !== 1)
+ return false;
+ var entityID = _entityIDs[0];
+ var entity = context.hasEntity(entityID);
+ if (!entity)
+ return false;
+ if (entity.hasNonGeometryTags())
+ return false;
+ if (_newFeature)
+ return true;
+ if (entity.geometry(context.graph()) !== "vertex")
+ return false;
+ if (context.graph().parentRelations(entity).length)
+ return false;
+ if (context.validator().getEntityIssues(entityID).length)
+ return false;
+ if (entity.isHighwayIntersection(context.graph()))
+ return false;
+ return true;
+ }
+ if (shouldDefaultToPresetList()) {
+ wrap2.style("right", "-100%");
+ editorPane.classed("hide", true);
+ presetPane.classed("hide", false).call(presetList);
+ } else {
+ wrap2.style("right", "0%");
+ presetPane.classed("hide", true);
+ editorPane.classed("hide", false).call(entityEditor);
+ }
+ var footer = selection2.selectAll(".footer").data([0]);
+ footer = footer.enter().append("div").attr("class", "footer").merge(footer);
+ footer.call(
+ uiViewOnOSM(context).what(context.hasEntity(_entityIDs.length === 1 && _entityIDs[0]))
+ );
+ }
+ inspector.showList = function(presets) {
+ presetPane.classed("hide", false);
+ wrap2.transition().styleTween("right", function() {
+ return value_default("0%", "-100%");
+ }).on("end", function() {
+ editorPane.classed("hide", true);
+ });
+ if (presets) {
+ presetList.presets(presets);
+ }
+ presetPane.call(presetList.autofocus(true));
+ };
+ inspector.setPreset = function(preset) {
+ if (preset && preset.id === "type/multipolygon") {
+ presetPane.call(presetList.autofocus(true));
+ } else {
+ editorPane.classed("hide", false);
+ wrap2.transition().styleTween("right", function() {
+ return value_default("-100%", "0%");
+ }).on("end", function() {
+ presetPane.classed("hide", true);
+ });
+ if (preset) {
+ entityEditor.presets([preset]);
+ }
+ editorPane.call(entityEditor);
+ }
+ };
+ inspector.state = function(val) {
+ if (!arguments.length)
+ return _state;
+ _state = val;
+ entityEditor.state(_state);
+ context.container().selectAll(".field-help-body").remove();
+ return inspector;
+ };
+ inspector.entityIDs = function(val) {
+ if (!arguments.length)
+ return _entityIDs;
+ _entityIDs = val;
+ return inspector;
+ };
+ inspector.newFeature = function(val) {
+ if (!arguments.length)
+ return _newFeature;
+ _newFeature = val;
+ return inspector;
+ };
+ return inspector;
+ }
+
+ // modules/ui/lasso.js
+ function uiLasso(context) {
+ var group, polygon2;
+ lasso.coordinates = [];
+ function lasso(selection2) {
+ context.container().classed("lasso", true);
+ group = selection2.append("g").attr("class", "lasso hide");
+ polygon2 = group.append("path").attr("class", "lasso-path");
+ group.call(uiToggle(true));
+ }
+ function draw() {
+ if (polygon2) {
+ polygon2.data([lasso.coordinates]).attr("d", function(d2) {
+ return "M" + d2.join(" L") + " Z";
+ });
+ }
+ }
+ lasso.extent = function() {
+ return lasso.coordinates.reduce(function(extent, point2) {
+ return extent.extend(geoExtent(point2));
+ }, geoExtent());
+ };
+ 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;
+ }
+
+ // modules/ui/source_switch.js
+ function uiSourceSwitch(context) {
+ var keys2;
+ function click(d3_event) {
+ d3_event.preventDefault();
+ var osm = context.connection();
+ if (!osm)
+ return;
+ if (context.inIntro())
+ return;
+ if (context.history().hasChanges() && !window.confirm(_t("source_switch.lose_changes")))
+ return;
+ var isLive = select_default2(this).classed("live");
+ isLive = !isLive;
+ context.enter(modeBrowse(context));
+ context.history().clearSaved();
+ context.flush();
+ select_default2(this).html(isLive ? _t.html("source_switch.live") : _t.html("source_switch.dev")).classed("live", isLive).classed("chip", isLive);
+ osm.switch(isLive ? keys2[0] : keys2[1]);
+ }
+ var sourceSwitch = function(selection2) {
+ selection2.append("a").attr("href", "#").call(_t.append("source_switch.live")).attr("class", "live chip").on("click", click);
+ };
+ sourceSwitch.keys = function(_2) {
+ if (!arguments.length)
+ return keys2;
+ keys2 = _2;
+ return sourceSwitch;
+ };
+ return sourceSwitch;
+ }
+
+ // modules/ui/spinner.js
+ function uiSpinner(context) {
+ var osm = context.connection();
+ return function(selection2) {
+ var img = selection2.append("img").attr("src", context.imagePath("loader-black.gif")).style("opacity", 0);
+ if (osm) {
+ osm.on("loading.spinner", function() {
+ img.transition().style("opacity", 1);
+ }).on("loaded.spinner", function() {
+ img.transition().style("opacity", 0);
+ });
+ }
+ };
+ }
+
+ // modules/ui/sections/privacy.js
+ function uiSectionPrivacy(context) {
+ let section = uiSection("preferences-third-party", context).label(() => _t.append("preferences.privacy.title")).disclosureContent(renderDisclosureContent);
+ function renderDisclosureContent(selection2) {
+ selection2.selectAll(".privacy-options-list").data([0]).enter().append("ul").attr("class", "layer-list privacy-options-list");
+ let thirdPartyIconsEnter = selection2.select(".privacy-options-list").selectAll(".privacy-third-party-icons-item").data([corePreferences("preferences.privacy.thirdpartyicons") || "true"]).enter().append("li").attr("class", "privacy-third-party-icons-item").append("label").call(
+ uiTooltip().title(() => _t.append("preferences.privacy.third_party_icons.tooltip")).placement("bottom")
+ );
+ thirdPartyIconsEnter.append("input").attr("type", "checkbox").on("change", (d3_event, d2) => {
+ d3_event.preventDefault();
+ corePreferences("preferences.privacy.thirdpartyicons", d2 === "true" ? "false" : "true");
+ });
+ thirdPartyIconsEnter.append("span").call(_t.append("preferences.privacy.third_party_icons.description"));
+ selection2.selectAll(".privacy-third-party-icons-item").classed("active", (d2) => d2 === "true").select("input").property("checked", (d2) => d2 === "true");
+ selection2.selectAll(".privacy-link").data([0]).enter().append("div").attr("class", "privacy-link").append("a").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).attr("href", "https://github.com/openstreetmap/iD/blob/release/PRIVACY.md").append("span").call(_t.append("preferences.privacy.privacy_link"));
+ }
+ corePreferences.onChange("preferences.privacy.thirdpartyicons", section.reRender);
+ return section;
+ }
+
+ // modules/ui/splash.js
+ function uiSplash(context) {
+ return (selection2) => {
+ if (context.history().hasRestorableChanges())
+ return;
+ let updateMessage = "";
+ const sawPrivacyVersion = corePreferences("sawPrivacyVersion");
+ let showSplash = !corePreferences("sawSplash");
+ if (sawPrivacyVersion !== context.privacyVersion) {
+ updateMessage = _t("splash.privacy_update");
+ showSplash = true;
+ }
+ if (!showSplash)
+ return;
+ corePreferences("sawSplash", true);
+ corePreferences("sawPrivacyVersion", context.privacyVersion);
+ _mainFileFetcher.get("intro_graph");
+ let modalSelection = uiModal(selection2);
+ modalSelection.select(".modal").attr("class", "modal-splash modal");
+ let introModal = modalSelection.select(".content").append("div").attr("class", "fillL");
+ introModal.append("div").attr("class", "modal-section").append("h3").call(_t.append("splash.welcome"));
+ let modalSection = introModal.append("div").attr("class", "modal-section");
+ modalSection.append("p").html(_t.html("splash.text", {
+ version: context.version,
+ website: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/blob/develop/CHANGELOG.md#whats-new">' + _t.html("splash.changelog") + "</a>" },
+ github: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/issues">github.com</a>' }
+ }));
+ modalSection.append("p").html(_t.html("splash.privacy", {
+ updateMessage,
+ privacyLink: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/blob/release/PRIVACY.md">' + _t("splash.privacy_policy") + "</a>" }
+ }));
+ uiSectionPrivacy(context).label(() => _t.append("splash.privacy_settings")).render(modalSection);
+ let buttonWrap = introModal.append("div").attr("class", "modal-actions");
+ let walkthrough = buttonWrap.append("button").attr("class", "walkthrough").on("click", () => {
+ context.container().call(uiIntro(context));
+ modalSelection.close();
+ });
+ walkthrough.append("svg").attr("class", "logo logo-walkthrough").append("use").attr("xlink:href", "#iD-logo-walkthrough");
+ walkthrough.append("div").call(_t.append("splash.walkthrough"));
+ let startEditing = buttonWrap.append("button").attr("class", "start-editing").on("click", modalSelection.close);
+ startEditing.append("svg").attr("class", "logo logo-features").append("use").attr("xlink:href", "#iD-logo-features");
+ startEditing.append("div").call(_t.append("splash.start"));
+ modalSelection.select("button.close").attr("class", "hide");
+ };
+ }
+
+ // modules/ui/status.js
+ function uiStatus(context) {
+ var osm = context.connection();
+ return function(selection2) {
+ if (!osm)
+ return;
+ function update(err, apiStatus) {
+ selection2.html("");
+ if (err) {
+ if (apiStatus === "connectionSwitched") {
+ return;
+ } else if (apiStatus === "rateLimited") {
+ selection2.call(_t.append("osm_api_status.message.rateLimit")).append("a").attr("href", "#").attr("class", "api-status-login").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).append("span").call(_t.append("login")).on("click.login", function(d3_event) {
+ d3_event.preventDefault();
+ osm.authenticate();
+ });
+ } else {
+ var throttledRetry = throttle_default(function() {
+ context.loadTiles(context.projection);
+ osm.reloadApiStatus();
+ }, 2e3);
+ selection2.call(_t.append("osm_api_status.message.error", { suffix: " " })).append("a").attr("href", "#").call(_t.append("osm_api_status.retry")).on("click.retry", function(d3_event) {
+ d3_event.preventDefault();
+ throttledRetry();
+ });
+ }
+ } else if (apiStatus === "readonly") {
+ selection2.call(_t.append("osm_api_status.message.readonly"));
+ } else if (apiStatus === "offline") {
+ selection2.call(_t.append("osm_api_status.message.offline"));
+ }
+ selection2.attr("class", "api-status " + (err ? "error" : apiStatus));
+ }
+ osm.on("apiStatusChange.uiStatus", update);
+ context.history().on("storage_error", () => {
+ selection2.selectAll("span.local-storage-full").remove();
+ selection2.append("span").attr("class", "local-storage-full").call(_t.append("osm_api_status.message.local_storage_full"));
+ selection2.classed("error", true);
+ });
+ window.setInterval(function() {
+ osm.reloadApiStatus();
+ }, 9e4);
+ osm.reloadApiStatus();
+ };
+ }
+
+ // modules/ui/version.js
+ var sawVersion = null;
+ var isNewVersion = false;
+ var isNewUser = false;
+ function uiVersion(context) {
+ var currVersion = context.version;
+ var matchedVersion = currVersion.match(/\d+\.\d+\.\d+.*/);
+ if (sawVersion === null && matchedVersion !== null) {
+ if (corePreferences("sawVersion")) {
+ isNewUser = false;
+ isNewVersion = corePreferences("sawVersion") !== currVersion && currVersion.indexOf("-") === -1;
+ } else {
+ isNewUser = true;
+ isNewVersion = true;
+ }
+ corePreferences("sawVersion", currVersion);
+ sawVersion = currVersion;
+ }
+ return function(selection2) {
+ selection2.append("a").attr("target", "_blank").attr("href", "https://github.com/openstreetmap/iD").text(currVersion);
+ if (isNewVersion && !isNewUser) {
+ selection2.append("a").attr("class", "badge").attr("target", "_blank").attr("href", "https://github.com/openstreetmap/iD/blob/release/CHANGELOG.md#whats-new").call(svgIcon("#maki-gift")).call(
+ uiTooltip().title(() => _t.append("version.whats_new", { version: currVersion })).placement("top").scrollContainer(context.container().select(".main-footer-wrap"))
+ );
+ }
+ };
+ }
+
+ // modules/ui/zoom.js
+ function uiZoom(context) {
+ var zooms = [{
+ id: "zoom-in",
+ icon: "iD-icon-plus",
+ title: _t.append("zoom.in"),
+ action: zoomIn,
+ disabled: function() {
+ return !context.map().canZoomIn();
+ },
+ disabledTitle: _t.append("zoom.disabled.in"),
+ key: "+"
+ }, {
+ id: "zoom-out",
+ icon: "iD-icon-minus",
+ title: _t.append("zoom.out"),
+ action: zoomOut,
+ disabled: function() {
+ return !context.map().canZoomOut();
+ },
+ disabledTitle: _t.append("zoom.disabled.out"),
+ key: "-"
+ }];
+ function zoomIn(d3_event) {
+ if (d3_event.shiftKey)
+ return;
+ d3_event.preventDefault();
+ context.map().zoomIn();
+ }
+ function zoomOut(d3_event) {
+ if (d3_event.shiftKey)
+ return;
+ d3_event.preventDefault();
+ context.map().zoomOut();
+ }
+ function zoomInFurther(d3_event) {
+ if (d3_event.shiftKey)
+ return;
+ d3_event.preventDefault();
+ context.map().zoomInFurther();
+ }
+ function zoomOutFurther(d3_event) {
+ if (d3_event.shiftKey)
+ return;
+ d3_event.preventDefault();
+ context.map().zoomOutFurther();
+ }
+ return function(selection2) {
+ var tooltipBehavior = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(function(d2) {
+ if (d2.disabled()) {
+ return d2.disabledTitle;
+ }
+ return d2.title;
+ }).keys(function(d2) {
+ return [d2.key];
+ });
+ var lastPointerUpType;
+ var buttons = selection2.selectAll("button").data(zooms).enter().append("button").attr("class", function(d2) {
+ return d2.id;
+ }).on("pointerup.editor", function(d3_event) {
+ lastPointerUpType = d3_event.pointerType;
+ }).on("click.editor", function(d3_event, d2) {
+ if (!d2.disabled()) {
+ d2.action(d3_event);
+ } else if (lastPointerUpType === "touch" || lastPointerUpType === "pen") {
+ context.ui().flash.duration(2e3).iconName("#" + d2.icon).iconClass("disabled").label(d2.disabledTitle)();
+ }
+ lastPointerUpType = null;
+ }).call(tooltipBehavior);
+ buttons.each(function(d2) {
+ select_default2(this).call(svgIcon("#" + d2.icon, "light"));
+ });
+ utilKeybinding.plusKeys.forEach(function(key) {
+ context.keybinding().on([key], zoomIn);
+ context.keybinding().on([uiCmd("\u2325" + key)], zoomInFurther);
+ });
+ utilKeybinding.minusKeys.forEach(function(key) {
+ context.keybinding().on([key], zoomOut);
+ context.keybinding().on([uiCmd("\u2325" + key)], zoomOutFurther);
+ });
+ function updateButtonStates() {
+ buttons.classed("disabled", function(d2) {
+ return d2.disabled();
+ }).each(function() {
+ var selection3 = select_default2(this);
+ if (!selection3.select(".tooltip.in").empty()) {
+ selection3.call(tooltipBehavior.updateContent);
+ }
+ });
+ }
+ updateButtonStates();
+ context.map().on("move.uiZoom", updateButtonStates);
+ };
+ }
+
+ // modules/ui/sections/raw_tag_editor.js
+ function uiSectionRawTagEditor(id2, context) {
+ var section = uiSection(id2, context).classes("raw-tag-editor").label(function() {
+ var count = Object.keys(_tags).filter(function(d2) {
+ return d2;
+ }).length;
+ return _t.append("inspector.title_count", { title: _t("inspector.tags"), count });
+ }).expandedByDefault(false).disclosureContent(renderDisclosureContent);
+ var taginfo = services.taginfo;
+ var dispatch14 = dispatch_default("change");
+ var availableViews = [
+ { id: "list", icon: "#fas-th-list" },
+ { id: "text", icon: "#fas-i-cursor" }
+ ];
+ let _discardTags = {};
+ _mainFileFetcher.get("discarded").then((d2) => {
+ _discardTags = d2;
+ }).catch(() => {
+ });
+ var _tagView = corePreferences("raw-tag-editor-view") || "list";
+ var _readOnlyTags = [];
+ var _orderedKeys = [];
+ var _showBlank = false;
+ var _pendingChange = null;
+ var _state;
+ var _presets;
+ var _tags;
+ var _entityIDs;
+ var _didInteract = false;
+ function interacted() {
+ _didInteract = true;
+ }
+ function renderDisclosureContent(wrap2) {
+ _orderedKeys = _orderedKeys.filter(function(key) {
+ return _tags[key] !== void 0;
+ });
+ var all = Object.keys(_tags).sort();
+ var missingKeys = utilArrayDifference(all, _orderedKeys);
+ for (var i3 in missingKeys) {
+ _orderedKeys.push(missingKeys[i3]);
+ }
+ var rowData = _orderedKeys.map(function(key, i4) {
+ return { index: i4, key, value: _tags[key] };
+ });
+ if (!rowData.length || _showBlank) {
+ _showBlank = false;
+ rowData.push({ index: rowData.length, key: "", value: "" });
+ }
+ var options2 = wrap2.selectAll(".raw-tag-options").data([0]);
+ options2.exit().remove();
+ var optionsEnter = options2.enter().insert("div", ":first-child").attr("class", "raw-tag-options").attr("role", "tablist");
+ var optionEnter = optionsEnter.selectAll(".raw-tag-option").data(availableViews, function(d2) {
+ return d2.id;
+ }).enter();
+ optionEnter.append("button").attr("class", function(d2) {
+ return "raw-tag-option raw-tag-option-" + d2.id + (_tagView === d2.id ? " selected" : "");
+ }).attr("aria-selected", function(d2) {
+ return _tagView === d2.id;
+ }).attr("role", "tab").attr("title", function(d2) {
+ return _t("icons." + d2.id);
+ }).on("click", function(d3_event, d2) {
+ _tagView = d2.id;
+ corePreferences("raw-tag-editor-view", d2.id);
+ wrap2.selectAll(".raw-tag-option").classed("selected", function(datum2) {
+ return datum2 === d2;
+ }).attr("aria-selected", function(datum2) {
+ return datum2 === d2;
+ });
+ wrap2.selectAll(".tag-text").classed("hide", d2.id !== "text").each(setTextareaHeight);
+ wrap2.selectAll(".tag-list, .add-row").classed("hide", d2.id !== "list");
+ }).each(function(d2) {
+ select_default2(this).call(svgIcon(d2.icon));
+ });
+ var textData = rowsToText(rowData);
+ var textarea = wrap2.selectAll(".tag-text").data([0]);
+ textarea = textarea.enter().append("textarea").attr("class", "tag-text" + (_tagView !== "text" ? " hide" : "")).call(utilNoAuto).attr("placeholder", _t("inspector.key_value")).attr("spellcheck", "false").merge(textarea);
+ textarea.call(utilGetSetValue, textData).each(setTextareaHeight).on("input", setTextareaHeight).on("focus", interacted).on("blur", textChanged).on("change", textChanged);
+ var list2 = wrap2.selectAll(".tag-list").data([0]);
+ list2 = list2.enter().append("ul").attr("class", "tag-list" + (_tagView !== "list" ? " hide" : "")).merge(list2);
+ var addRowEnter = wrap2.selectAll(".add-row").data([0]).enter().append("div").attr("class", "add-row" + (_tagView !== "list" ? " hide" : ""));
+ addRowEnter.append("button").attr("class", "add-tag").attr("aria-label", _t("inspector.add_to_tag")).call(svgIcon("#iD-icon-plus", "light")).call(uiTooltip().title(() => _t.append("inspector.add_to_tag")).placement(_mainLocalizer.textDirection() === "ltr" ? "right" : "left")).on("click", addTag);
+ addRowEnter.append("div").attr("class", "space-value");
+ addRowEnter.append("div").attr("class", "space-buttons");
+ var items = list2.selectAll(".tag-row").data(rowData, function(d2) {
+ return d2.key;
+ });
+ items.exit().each(unbind).remove();
+ var itemsEnter = items.enter().append("li").attr("class", "tag-row").classed("readonly", isReadOnly);
+ var innerWrap = itemsEnter.append("div").attr("class", "inner-wrap");
+ innerWrap.append("div").attr("class", "key-wrap").append("input").property("type", "text").attr("class", "key").call(utilNoAuto).on("focus", interacted).on("blur", keyChange).on("change", keyChange);
+ innerWrap.append("div").attr("class", "value-wrap").append("input").property("type", "text").attr("class", "value").call(utilNoAuto).on("focus", interacted).on("blur", valueChange).on("change", valueChange).on("keydown.push-more", pushMore);
+ innerWrap.append("button").attr("class", "form-field-button remove").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete"));
+ items = items.merge(itemsEnter).sort(function(a2, b2) {
+ return a2.index - b2.index;
+ });
+ items.each(function(d2) {
+ var row = select_default2(this);
+ var key = row.select("input.key");
+ var value = row.select("input.value");
+ if (_entityIDs && taginfo && _state !== "hover") {
+ bindTypeahead(key, value);
+ }
+ var referenceOptions = { key: d2.key };
+ if (typeof d2.value === "string") {
+ referenceOptions.value = d2.value;
+ }
+ var reference = uiTagReference(referenceOptions, context);
+ if (_state === "hover") {
+ reference.showing(false);
+ }
+ row.select(".inner-wrap").call(reference.button);
+ row.call(reference.body);
+ row.select("button.remove");
+ });
+ items.selectAll("input.key").attr("title", function(d2) {
+ return d2.key;
+ }).call(utilGetSetValue, function(d2) {
+ return d2.key;
+ }).attr("readonly", function(d2) {
+ return isReadOnly(d2) || null;
+ });
+ items.selectAll("input.value").attr("title", function(d2) {
+ return Array.isArray(d2.value) ? d2.value.filter(Boolean).join("\n") : d2.value;
+ }).classed("mixed", function(d2) {
+ return Array.isArray(d2.value);
+ }).attr("placeholder", function(d2) {
+ return typeof d2.value === "string" ? null : _t("inspector.multiple_values");
+ }).call(utilGetSetValue, function(d2) {
+ return typeof d2.value === "string" ? d2.value : "";
+ }).attr("readonly", function(d2) {
+ return isReadOnly(d2) || null;
+ });
+ items.selectAll("button.remove").on(
+ ("PointerEvent" in window ? "pointer" : "mouse") + "down",
+ // 'click' fires too late - #5878
+ (d3_event, d2) => {
+ if (d3_event.button !== 0)
+ return;
+ removeTag(d3_event, d2);
+ }
+ );
+ }
+ function isReadOnly(d2) {
+ for (var i3 = 0; i3 < _readOnlyTags.length; i3++) {
+ if (d2.key.match(_readOnlyTags[i3]) !== null) {
+ return true;
+ }
+ }
+ return false;
+ }
+ function setTextareaHeight() {
+ if (_tagView !== "text")
+ return;
+ var selection2 = select_default2(this);
+ var matches = selection2.node().value.match(/\n/g);
+ var lineCount = 2 + Number(matches && matches.length);
+ var lineHeight = 20;
+ selection2.style("height", lineCount * lineHeight + "px");
+ }
+ function stringify3(s2) {
+ return JSON.stringify(s2).slice(1, -1);
+ }
+ function unstringify(s2) {
+ var leading = "";
+ var trailing = "";
+ if (s2.length < 1 || s2.charAt(0) !== '"') {
+ leading = '"';
+ }
+ if (s2.length < 2 || s2.charAt(s2.length - 1) !== '"' || s2.charAt(s2.length - 1) === '"' && s2.charAt(s2.length - 2) === "\\") {
+ trailing = '"';
+ }
+ return JSON.parse(leading + s2 + trailing);
+ }
+ function rowsToText(rows) {
+ var str = rows.filter(function(row) {
+ return row.key && row.key.trim() !== "";
+ }).map(function(row) {
+ var rawVal = row.value;
+ if (typeof rawVal !== "string")
+ rawVal = "*";
+ var val = rawVal ? stringify3(rawVal) : "";
+ return stringify3(row.key) + "=" + val;
+ }).join("\n");
+ if (_state !== "hover" && str.length) {
+ return str + "\n";
+ }
+ return str;
+ }
+ function textChanged() {
+ var newText = this.value.trim();
+ var newTags = {};
+ newText.split("\n").forEach(function(row) {
+ var m2 = row.match(/^\s*([^=]+)=(.*)$/);
+ if (m2 !== null) {
+ var k2 = context.cleanTagKey(unstringify(m2[1].trim()));
+ var v2 = context.cleanTagValue(unstringify(m2[2].trim()));
+ newTags[k2] = v2;
+ }
+ });
+ var tagDiff = utilTagDiff(_tags, newTags);
+ if (!tagDiff.length)
+ return;
+ _pendingChange = _pendingChange || {};
+ tagDiff.forEach(function(change) {
+ if (isReadOnly({ key: change.key }))
+ return;
+ if (change.newVal === "*" && typeof change.oldVal !== "string")
+ return;
+ if (change.type === "-") {
+ _pendingChange[change.key] = void 0;
+ } else if (change.type === "+") {
+ _pendingChange[change.key] = change.newVal || "";
+ }
+ });
+ if (Object.keys(_pendingChange).length === 0) {
+ _pendingChange = null;
+ return;
+ }
+ scheduleChange();
+ }
+ function pushMore(d3_event) {
+ if (d3_event.keyCode === 9 && !d3_event.shiftKey && section.selection().selectAll(".tag-list li:last-child input.value").node() === this && utilGetSetValue(select_default2(this))) {
+ addTag();
+ }
+ }
+ function bindTypeahead(key, value) {
+ if (isReadOnly(key.datum()))
+ return;
+ if (Array.isArray(value.datum().value)) {
+ value.call(uiCombobox(context, "tag-value").minItems(1).fetcher(function(value2, callback) {
+ var keyString = utilGetSetValue(key);
+ if (!_tags[keyString])
+ return;
+ var data = _tags[keyString].map(function(tagValue) {
+ if (!tagValue) {
+ return {
+ value: " ",
+ title: _t("inspector.empty"),
+ display: (selection2) => selection2.text("").classed("virtual-option", true).call(_t.append("inspector.empty"))
+ };
+ }
+ return {
+ value: tagValue,
+ title: tagValue
+ };
+ });
+ callback(data);
+ }));
+ return;
+ }
+ var geometry = context.graph().geometry(_entityIDs[0]);
+ key.call(uiCombobox(context, "tag-key").fetcher(function(value2, callback) {
+ taginfo.keys({
+ debounce: true,
+ geometry,
+ query: value2
+ }, function(err, data) {
+ if (!err) {
+ const filtered = data.filter((d2) => _tags[d2.value] === void 0).filter((d2) => !(d2.value in _discardTags)).filter((d2) => !/_\d$/.test(d2)).filter((d2) => d2.value.toLowerCase().includes(value2.toLowerCase()));
+ callback(sort(value2, filtered));
+ }
+ });
+ }));
+ value.call(uiCombobox(context, "tag-value").fetcher(function(value2, callback) {
+ taginfo.values({
+ debounce: true,
+ key: utilGetSetValue(key),
+ geometry,
+ query: value2
+ }, function(err, data) {
+ if (!err) {
+ const filtered = data.filter((d2) => d2.value.toLowerCase().includes(value2.toLowerCase()));
+ callback(sort(value2, filtered));
+ }
+ });
+ }).caseSensitive(allowUpperCaseTagValues.test(utilGetSetValue(key))));
+ function sort(value2, data) {
+ var sameletter = [];
+ var other = [];
+ for (var i3 = 0; i3 < data.length; i3++) {
+ if (data[i3].value.substring(0, value2.length) === value2) {
+ sameletter.push(data[i3]);
+ } else {
+ other.push(data[i3]);
+ }
+ }
+ return sameletter.concat(other);
+ }
+ }
+ function unbind() {
+ var row = select_default2(this);
+ row.selectAll("input.key").call(uiCombobox.off, context);
+ row.selectAll("input.value").call(uiCombobox.off, context);
+ }
+ function keyChange(d3_event, d2) {
+ if (select_default2(this).attr("readonly"))
+ return;
+ var kOld = d2.key;
+ if (_pendingChange && _pendingChange.hasOwnProperty(kOld) && _pendingChange[kOld] === void 0)
+ return;
+ var kNew = context.cleanTagKey(this.value.trim());
+ if (isReadOnly({ key: kNew })) {
+ this.value = kOld;
+ return;
+ }
+ if (kNew && kNew !== kOld && _tags[kNew] !== void 0) {
+ this.value = kOld;
+ section.selection().selectAll(".tag-list input.value").each(function(d4) {
+ if (d4.key === kNew) {
+ var input = select_default2(this).node();
+ input.focus();
+ input.select();
+ }
+ });
+ return;
+ }
+ _pendingChange = _pendingChange || {};
+ if (kOld) {
+ if (kOld === kNew)
+ return;
+ _pendingChange[kNew] = _pendingChange[kOld] || { oldKey: kOld };
+ _pendingChange[kOld] = void 0;
+ } else {
+ let row = this.parentNode.parentNode;
+ let inputVal = select_default2(row).selectAll("input.value");
+ let vNew = context.cleanTagValue(utilGetSetValue(inputVal));
+ _pendingChange[kNew] = vNew;
+ utilGetSetValue(inputVal, vNew);
+ }
+ var existingKeyIndex = _orderedKeys.indexOf(kOld);
+ if (existingKeyIndex !== -1)
+ _orderedKeys[existingKeyIndex] = kNew;
+ d2.key = kNew;
+ this.value = kNew;
+ scheduleChange();
+ }
+ function valueChange(d3_event, d2) {
+ if (isReadOnly(d2))
+ return;
+ if (typeof d2.value !== "string" && !this.value)
+ return;
+ if (!this.value.trim())
+ return removeTag(d3_event, d2);
+ if (_pendingChange && _pendingChange.hasOwnProperty(d2.key) && _pendingChange[d2.key] === void 0)
+ return;
+ _pendingChange = _pendingChange || {};
+ _pendingChange[d2.key] = context.cleanTagValue(this.value);
+ scheduleChange();
+ }
+ function removeTag(d3_event, d2) {
+ if (isReadOnly(d2))
+ return;
+ if (d2.key === "") {
+ _showBlank = false;
+ section.reRender();
+ } else {
+ _orderedKeys = _orderedKeys.filter(function(key) {
+ return key !== d2.key;
+ });
+ _pendingChange = _pendingChange || {};
+ _pendingChange[d2.key] = void 0;
+ scheduleChange();
+ }
+ }
+ function addTag() {
+ window.setTimeout(function() {
+ _showBlank = true;
+ section.reRender();
+ section.selection().selectAll(".tag-list li:last-child input.key").node().focus();
+ }, 20);
+ }
+ function scheduleChange() {
+ var entityIDs = _entityIDs;
+ window.setTimeout(function() {
+ if (!_pendingChange)
+ return;
+ dispatch14.call("change", this, entityIDs, _pendingChange);
+ _pendingChange = null;
+ }, 10);
+ }
+ section.state = function(val) {
+ if (!arguments.length)
+ return _state;
+ if (_state !== val) {
+ _orderedKeys = [];
+ _state = val;
+ }
+ return section;
+ };
+ section.presets = function(val) {
+ if (!arguments.length)
+ return _presets;
+ _presets = val;
+ if (_presets && _presets.length && _presets[0].isFallback()) {
+ section.disclosureExpanded(true);
+ } else if (!_didInteract) {
+ section.disclosureExpanded(null);
+ }
+ return section;
+ };
+ section.tags = function(val) {
+ if (!arguments.length)
+ return _tags;
+ _tags = val;
+ return section;
+ };
+ section.entityIDs = function(val) {
+ if (!arguments.length)
+ return _entityIDs;
+ if (!_entityIDs || !val || !utilArrayIdentical(_entityIDs, val)) {
+ _entityIDs = val;
+ _orderedKeys = [];
+ }
+ return section;
+ };
+ section.readOnlyTags = function(val) {
+ if (!arguments.length)
+ return _readOnlyTags;
+ _readOnlyTags = val;
+ return section;
+ };
+ return utilRebind(section, dispatch14, "on");
+ }
+
+ // modules/ui/data_editor.js
+ function uiDataEditor(context) {
+ var dataHeader = uiDataHeader();
+ var rawTagEditor = uiSectionRawTagEditor("custom-data-tag-editor", context).expandedByDefault(true).readOnlyTags([/./]);
+ var _datum;
+ function dataEditor(selection2) {
+ var header = selection2.selectAll(".header").data([0]);
+ var headerEnter = header.enter().append("div").attr("class", "header fillL");
+ headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
+ context.enter(modeBrowse(context));
+ }).call(svgIcon("#iD-icon-close"));
+ headerEnter.append("h2").call(_t.append("map_data.title"));
+ var body = selection2.selectAll(".body").data([0]);
+ body = body.enter().append("div").attr("class", "body").merge(body);
+ var editor = body.selectAll(".data-editor").data([0]);
+ editor.enter().append("div").attr("class", "modal-section data-editor").merge(editor).call(dataHeader.datum(_datum));
+ var rte = body.selectAll(".raw-tag-editor").data([0]);
+ rte.enter().append("div").attr("class", "raw-tag-editor data-editor").merge(rte).call(
+ rawTagEditor.tags(_datum && _datum.properties || {}).state("hover").render
+ ).selectAll("textarea.tag-text").attr("readonly", true).classed("readonly", true);
+ }
+ dataEditor.datum = function(val) {
+ if (!arguments.length)
+ return _datum;
+ _datum = val;
+ return this;
+ };
+ return dataEditor;
+ }
+
+ // modules/ui/sidebar.js
+ function uiSidebar(context) {
+ var inspector = uiInspector(context);
+ var dataEditor = uiDataEditor(context);
+ var noteEditor = uiNoteEditor(context);
+ var improveOsmEditor = uiImproveOsmEditor(context);
+ var keepRightEditor = uiKeepRightEditor(context);
+ var osmoseEditor = uiOsmoseEditor(context);
+ var _current;
+ var _wasData = false;
+ var _wasNote = false;
+ var _wasQaItem = false;
+ var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
+ function sidebar(selection2) {
+ var container = context.container();
+ var minWidth = 240;
+ var sidebarWidth;
+ var containerWidth;
+ var dragOffset;
+ selection2.style("min-width", minWidth + "px").style("max-width", "400px").style("width", "33.3333%");
+ var resizer = selection2.append("div").attr("class", "sidebar-resizer").on(_pointerPrefix + "down.sidebar-resizer", pointerdown);
+ var downPointerId, lastClientX, containerLocGetter;
+ function pointerdown(d3_event) {
+ if (downPointerId)
+ return;
+ if ("button" in d3_event && d3_event.button !== 0)
+ return;
+ downPointerId = d3_event.pointerId || "mouse";
+ lastClientX = d3_event.clientX;
+ containerLocGetter = utilFastMouse(container.node());
+ dragOffset = utilFastMouse(resizer.node())(d3_event)[0] - 1;
+ sidebarWidth = selection2.node().getBoundingClientRect().width;
+ containerWidth = container.node().getBoundingClientRect().width;
+ var widthPct = sidebarWidth / containerWidth * 100;
+ selection2.style("width", widthPct + "%").style("max-width", "85%");
+ resizer.classed("dragging", true);
+ select_default2(window).on("touchmove.sidebar-resizer", function(d3_event2) {
+ d3_event2.preventDefault();
+ }, { passive: false }).on(_pointerPrefix + "move.sidebar-resizer", pointermove).on(_pointerPrefix + "up.sidebar-resizer pointercancel.sidebar-resizer", pointerup);
+ }
+ function pointermove(d3_event) {
+ if (downPointerId !== (d3_event.pointerId || "mouse"))
+ return;
+ d3_event.preventDefault();
+ var dx = d3_event.clientX - lastClientX;
+ lastClientX = d3_event.clientX;
+ var isRTL = _mainLocalizer.textDirection() === "rtl";
+ var scaleX = isRTL ? 0 : 1;
+ var xMarginProperty = isRTL ? "margin-right" : "margin-left";
+ var x2 = containerLocGetter(d3_event)[0] - dragOffset;
+ sidebarWidth = isRTL ? containerWidth - x2 : x2;
+ var isCollapsed = selection2.classed("collapsed");
+ var shouldCollapse = sidebarWidth < minWidth;
+ selection2.classed("collapsed", shouldCollapse);
+ if (shouldCollapse) {
+ if (!isCollapsed) {
+ selection2.style(xMarginProperty, "-400px").style("width", "400px");
+ context.ui().onResize([(sidebarWidth - dx) * scaleX, 0]);
+ }
+ } else {
+ var widthPct = sidebarWidth / containerWidth * 100;
+ selection2.style(xMarginProperty, null).style("width", widthPct + "%");
+ if (isCollapsed) {
+ context.ui().onResize([-sidebarWidth * scaleX, 0]);
+ } else {
+ context.ui().onResize([-dx * scaleX, 0]);
+ }
+ }
+ }
+ function pointerup(d3_event) {
+ if (downPointerId !== (d3_event.pointerId || "mouse"))
+ return;
+ downPointerId = null;
+ resizer.classed("dragging", false);
+ select_default2(window).on("touchmove.sidebar-resizer", null).on(_pointerPrefix + "move.sidebar-resizer", null).on(_pointerPrefix + "up.sidebar-resizer pointercancel.sidebar-resizer", null);
+ }
+ var featureListWrap = selection2.append("div").attr("class", "feature-list-pane").call(uiFeatureList(context));
+ var inspectorWrap = selection2.append("div").attr("class", "inspector-hidden inspector-wrap");
+ var hoverModeSelect = function(targets) {
+ context.container().selectAll(".feature-list-item button").classed("hover", false);
+ if (context.selectedIDs().length > 1 && targets && targets.length) {
+ var elements = context.container().selectAll(".feature-list-item button").filter(function(node) {
+ return targets.indexOf(node) !== -1;
+ });
+ if (!elements.empty()) {
+ elements.classed("hover", true);
+ }
+ }
+ };
+ sidebar.hoverModeSelect = throttle_default(hoverModeSelect, 200);
+ function hover(targets) {
+ var datum2 = targets && targets.length && targets[0];
+ if (datum2 && datum2.__featurehash__) {
+ _wasData = true;
+ sidebar.show(dataEditor.datum(datum2));
+ selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
+ } else if (datum2 instanceof osmNote) {
+ if (context.mode().id === "drag-note")
+ return;
+ _wasNote = true;
+ var osm = services.osm;
+ if (osm) {
+ datum2 = osm.getNote(datum2.id);
+ }
+ sidebar.show(noteEditor.note(datum2));
+ selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
+ } else if (datum2 instanceof QAItem) {
+ _wasQaItem = true;
+ var errService = services[datum2.service];
+ if (errService) {
+ datum2 = errService.getError(datum2.id);
+ }
+ var errEditor;
+ if (datum2.service === "keepRight") {
+ errEditor = keepRightEditor;
+ } else if (datum2.service === "osmose") {
+ errEditor = osmoseEditor;
+ } else {
+ errEditor = improveOsmEditor;
+ }
+ context.container().selectAll(".qaItem." + datum2.service).classed("hover", function(d2) {
+ return d2.id === datum2.id;
+ });
+ sidebar.show(errEditor.error(datum2));
+ selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
+ } else if (!_current && datum2 instanceof osmEntity) {
+ featureListWrap.classed("inspector-hidden", true);
+ inspectorWrap.classed("inspector-hidden", false).classed("inspector-hover", true);
+ if (!inspector.entityIDs() || !utilArrayIdentical(inspector.entityIDs(), [datum2.id]) || inspector.state() !== "hover") {
+ inspector.state("hover").entityIDs([datum2.id]).newFeature(false);
+ inspectorWrap.call(inspector);
+ }
+ } else if (!_current) {
+ featureListWrap.classed("inspector-hidden", false);
+ inspectorWrap.classed("inspector-hidden", true);
+ inspector.state("hide");
+ } else if (_wasData || _wasNote || _wasQaItem) {
+ _wasNote = false;
+ _wasData = false;
+ _wasQaItem = false;
+ context.container().selectAll(".note").classed("hover", false);
+ context.container().selectAll(".qaItem").classed("hover", false);
+ sidebar.hide();
+ }
+ }
+ sidebar.hover = throttle_default(hover, 200);
+ sidebar.intersects = function(extent) {
+ var rect = selection2.node().getBoundingClientRect();
+ return extent.intersects([
+ context.projection.invert([0, rect.height]),
+ context.projection.invert([rect.width, 0])
+ ]);
+ };
+ sidebar.select = function(ids, newFeature) {
+ sidebar.hide();
+ if (ids && ids.length) {
+ var entity = ids.length === 1 && context.entity(ids[0]);
+ if (entity && newFeature && selection2.classed("collapsed")) {
+ var extent = entity.extent(context.graph());
+ sidebar.expand(sidebar.intersects(extent));
+ }
+ featureListWrap.classed("inspector-hidden", true);
+ inspectorWrap.classed("inspector-hidden", false).classed("inspector-hover", false);
+ inspector.state("select").entityIDs(ids).newFeature(newFeature);
+ inspectorWrap.call(inspector);
+ } else {
+ inspector.state("hide");
+ }
+ };
+ sidebar.showPresetList = function() {
+ inspector.showList();
+ };
+ sidebar.show = function(component, element) {
+ featureListWrap.classed("inspector-hidden", true);
+ inspectorWrap.classed("inspector-hidden", true);
+ if (_current)
+ _current.remove();
+ _current = selection2.append("div").attr("class", "sidebar-component").call(component, element);
+ };
+ sidebar.hide = function() {
+ featureListWrap.classed("inspector-hidden", false);
+ inspectorWrap.classed("inspector-hidden", true);
+ if (_current)
+ _current.remove();
+ _current = null;
+ };
+ sidebar.expand = function(moveMap) {
+ if (selection2.classed("collapsed")) {
+ sidebar.toggle(moveMap);
+ }
+ };
+ sidebar.collapse = function(moveMap) {
+ if (!selection2.classed("collapsed")) {
+ sidebar.toggle(moveMap);
+ }
+ };
+ sidebar.toggle = function(moveMap) {
+ if (context.inIntro())
+ return;
+ var isCollapsed = selection2.classed("collapsed");
+ var isCollapsing = !isCollapsed;
+ var isRTL = _mainLocalizer.textDirection() === "rtl";
+ var scaleX = isRTL ? 0 : 1;
+ var xMarginProperty = isRTL ? "margin-right" : "margin-left";
+ sidebarWidth = selection2.node().getBoundingClientRect().width;
+ selection2.style("width", sidebarWidth + "px");
+ var startMargin, endMargin, lastMargin;
+ if (isCollapsing) {
+ startMargin = lastMargin = 0;
+ endMargin = -sidebarWidth;
+ } else {
+ startMargin = lastMargin = -sidebarWidth;
+ endMargin = 0;
+ }
+ if (!isCollapsing) {
+ selection2.classed("collapsed", isCollapsing);
+ }
+ selection2.transition().style(xMarginProperty, endMargin + "px").tween("panner", function() {
+ var i3 = number_default(startMargin, endMargin);
+ return function(t2) {
+ var dx = lastMargin - Math.round(i3(t2));
+ lastMargin = lastMargin - dx;
+ context.ui().onResize(moveMap ? void 0 : [dx * scaleX, 0]);
+ };
+ }).on("end", function() {
+ if (isCollapsing) {
+ selection2.classed("collapsed", isCollapsing);
+ }
+ if (!isCollapsing) {
+ var containerWidth2 = container.node().getBoundingClientRect().width;
+ var widthPct = sidebarWidth / containerWidth2 * 100;
+ selection2.style(xMarginProperty, null).style("width", widthPct + "%");
+ }
+ });
+ };
+ resizer.on("dblclick", function(d3_event) {
+ d3_event.preventDefault();
+ if (d3_event.sourceEvent) {
+ d3_event.sourceEvent.preventDefault();
+ }
+ sidebar.toggle();
+ });
+ context.map().on("crossEditableZoom.sidebar", function(within) {
+ if (!within && !selection2.select(".inspector-hover").empty()) {
+ hover([]);
+ }
+ });
+ }
+ sidebar.showPresetList = function() {
+ };
+ sidebar.hover = function() {
+ };
+ sidebar.hover.cancel = function() {
+ };
+ sidebar.intersects = function() {
+ };
+ sidebar.select = function() {
+ };
+ sidebar.show = function() {
+ };
+ sidebar.hide = function() {
+ };
+ sidebar.expand = function() {
+ };
+ sidebar.collapse = function() {
+ };
+ sidebar.toggle = function() {
+ };
+ return sidebar;
+ }
+
+ // modules/ui/tools/modes.js
+ function uiToolDrawModes(context) {
+ var tool = {
+ id: "old_modes",
+ label: _t.append("toolbar.add_feature")
+ };
+ var modes = [
+ modeAddPoint(context, {
+ title: _t.append("modes.add_point.title"),
+ button: "point",
+ description: _t.append("modes.add_point.description"),
+ preset: _mainPresetIndex.item("point"),
+ key: "1"
+ }),
+ modeAddLine(context, {
+ title: _t.append("modes.add_line.title"),
+ button: "line",
+ description: _t.append("modes.add_line.description"),
+ preset: _mainPresetIndex.item("line"),
+ key: "2"
+ }),
+ modeAddArea(context, {
+ title: _t.append("modes.add_area.title"),
+ button: "area",
+ description: _t.append("modes.add_area.description"),
+ preset: _mainPresetIndex.item("area"),
+ key: "3"
+ })
+ ];
+ function enabled(_mode) {
+ return osmEditable();
+ }
+ function osmEditable() {
+ return context.editable();
+ }
+ modes.forEach(function(mode) {
+ context.keybinding().on(mode.key, function() {
+ if (!enabled(mode))
+ return;
+ if (mode.id === context.mode().id) {
+ context.enter(modeBrowse(context));
+ } else {
+ context.enter(mode);
+ }
+ });
+ });
+ tool.render = function(selection2) {
+ var wrap2 = selection2.append("div").attr("class", "joined").style("display", "flex");
+ var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
+ context.map().on("move.modes", debouncedUpdate).on("drawn.modes", debouncedUpdate);
+ context.on("enter.modes", update);
+ update();
+ function update() {
+ var buttons = wrap2.selectAll("button.add-button").data(modes, function(d2) {
+ return d2.id;
+ });
+ buttons.exit().remove();
+ var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) {
+ return d2.id + " add-button bar-button";
+ }).on("click.mode-buttons", function(d3_event, d2) {
+ if (!enabled(d2))
+ return;
+ var currMode = context.mode().id;
+ if (/^draw/.test(currMode))
+ return;
+ if (d2.id === currMode) {
+ context.enter(modeBrowse(context));
+ } else {
+ context.enter(d2);
+ }
+ }).call(
+ uiTooltip().placement("bottom").title(function(d2) {
+ return d2.description;
+ }).keys(function(d2) {
+ return [d2.key];
+ }).scrollContainer(context.container().select(".top-toolbar"))
+ );
+ buttonsEnter.each(function(d2) {
+ select_default2(this).call(svgIcon("#iD-icon-" + d2.button));
+ });
+ buttonsEnter.append("span").attr("class", "label").text("").each(function(mode) {
+ mode.title(select_default2(this));
+ });
+ if (buttons.enter().size() || buttons.exit().size()) {
+ context.ui().checkOverflow(".top-toolbar", true);
+ }
+ buttons = buttons.merge(buttonsEnter).attr("aria-disabled", function(d2) {
+ return !enabled(d2);
+ }).classed("disabled", function(d2) {
+ return !enabled(d2);
+ }).attr("aria-pressed", function(d2) {
+ return context.mode() && context.mode().button === d2.button;
+ }).classed("active", function(d2) {
+ return context.mode() && context.mode().button === d2.button;
+ });
+ }
+ };
+ return tool;
+ }
+
+ // modules/ui/tools/notes.js
+ function uiToolNotes(context) {
+ var tool = {
+ id: "notes",
+ label: _t.append("modes.add_note.label")
+ };
+ var mode = modeAddNote(context);
+ function enabled() {
+ return notesEnabled() && notesEditable();
+ }
+ function notesEnabled() {
+ var noteLayer = context.layers().layer("notes");
+ return noteLayer && noteLayer.enabled();
+ }
+ function notesEditable() {
+ var mode2 = context.mode();
+ return context.map().notesEditable() && mode2 && mode2.id !== "save";
+ }
+ context.keybinding().on(mode.key, function() {
+ if (!enabled())
+ return;
+ if (mode.id === context.mode().id) {
+ context.enter(modeBrowse(context));
+ } else {
+ context.enter(mode);
+ }
+ });
+ tool.render = function(selection2) {
+ var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
+ context.map().on("move.notes", debouncedUpdate).on("drawn.notes", debouncedUpdate);
+ context.on("enter.notes", update);
+ update();
+ function update() {
+ var showNotes = notesEnabled();
+ var data = showNotes ? [mode] : [];
+ var buttons = selection2.selectAll("button.add-button").data(data, function(d2) {
+ return d2.id;
+ });
+ buttons.exit().remove();
+ var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) {
+ return d2.id + " add-button bar-button";
+ }).on("click.notes", function(d3_event, d2) {
+ if (!enabled())
+ return;
+ var currMode = context.mode().id;
+ if (/^draw/.test(currMode))
+ return;
+ if (d2.id === currMode) {
+ context.enter(modeBrowse(context));
+ } else {
+ context.enter(d2);
+ }
+ }).call(
+ uiTooltip().placement("bottom").title(function(d2) {
+ return d2.description;
+ }).keys(function(d2) {
+ return [d2.key];
+ }).scrollContainer(context.container().select(".top-toolbar"))
+ );
+ buttonsEnter.each(function(d2) {
+ select_default2(this).call(svgIcon(d2.icon || "#iD-icon-" + d2.button));
+ });
+ if (buttons.enter().size() || buttons.exit().size()) {
+ context.ui().checkOverflow(".top-toolbar", true);
+ }
+ buttons = buttons.merge(buttonsEnter).classed("disabled", function() {
+ return !enabled();
+ }).attr("aria-disabled", function() {
+ return !enabled();
+ }).classed("active", function(d2) {
+ return context.mode() && context.mode().button === d2.button;
+ }).attr("aria-pressed", function(d2) {
+ return context.mode() && context.mode().button === d2.button;
+ });
+ }
+ };
+ tool.uninstall = function() {
+ context.on("enter.editor.notes", null).on("exit.editor.notes", null).on("enter.notes", null);
+ context.map().on("move.notes", null).on("drawn.notes", null);
+ };
+ return tool;
+ }
+
+ // modules/ui/tools/save.js
+ function uiToolSave(context) {
+ var tool = {
+ id: "save",
+ label: _t.append("save.title")
+ };
+ var button = null;
+ var tooltipBehavior = null;
+ var history = context.history();
+ var key = uiCmd("\u2318S");
+ var _numChanges = 0;
+ function isSaving() {
+ var mode = context.mode();
+ return mode && mode.id === "save";
+ }
+ function isDisabled() {
+ return _numChanges === 0 || isSaving();
+ }
+ function save(d3_event) {
+ d3_event.preventDefault();
+ if (!context.inIntro() && !isSaving() && history.hasChanges()) {
+ context.enter(modeSave(context));
+ }
+ }
+ function bgColor(numChanges) {
+ var step;
+ if (numChanges === 0) {
+ return null;
+ } else if (numChanges <= 50) {
+ step = numChanges / 50;
+ return rgb_default("#fff", "#ff8")(step);
+ } else {
+ step = Math.min((numChanges - 50) / 50, 1);
+ return rgb_default("#ff8", "#f88")(step);
+ }
+ }
+ function updateCount() {
+ var val = history.difference().summary().length;
+ if (val === _numChanges)
+ return;
+ _numChanges = val;
+ if (tooltipBehavior) {
+ tooltipBehavior.title(() => _t.append(_numChanges > 0 ? "save.help" : "save.no_changes")).keys([key]);
+ }
+ if (button) {
+ button.classed("disabled", isDisabled()).style("background", bgColor(_numChanges));
+ button.select("span.count").text(_numChanges);
+ }
+ }
+ tool.render = function(selection2) {
+ tooltipBehavior = uiTooltip().placement("bottom").title(() => _t.append("save.no_changes")).keys([key]).scrollContainer(context.container().select(".top-toolbar"));
+ var lastPointerUpType;
+ button = selection2.append("button").attr("class", "save disabled bar-button").on("pointerup", function(d3_event) {
+ lastPointerUpType = d3_event.pointerType;
+ }).on("click", function(d3_event) {
+ save(d3_event);
+ if (_numChanges === 0 && (lastPointerUpType === "touch" || lastPointerUpType === "pen")) {
+ context.ui().flash.duration(2e3).iconName("#iD-icon-save").iconClass("disabled").label(_t.append("save.no_changes"))();
+ }
+ lastPointerUpType = null;
+ }).call(tooltipBehavior);
+ button.call(svgIcon("#iD-icon-save"));
+ button.append("span").attr("class", "count").attr("aria-hidden", "true").text("0");
+ updateCount();
+ context.keybinding().on(key, save, true);
+ context.history().on("change.save", updateCount);
+ context.on("enter.save", function() {
+ if (button) {
+ button.classed("disabled", isDisabled());
+ if (isSaving()) {
+ button.call(tooltipBehavior.hide);
+ }
+ }
+ });
+ };
+ tool.uninstall = function() {
+ context.keybinding().off(key, true);
+ context.history().on("change.save", null);
+ context.on("enter.save", null);
+ button = null;
+ tooltipBehavior = null;
+ };
+ return tool;
+ }
+
+ // modules/ui/tools/sidebar_toggle.js
+ function uiToolSidebarToggle(context) {
+ var tool = {
+ id: "sidebar_toggle",
+ label: _t.append("toolbar.inspect")
+ };
+ tool.render = function(selection2) {
+ selection2.append("button").attr("class", "bar-button").attr("aria-label", _t("sidebar.tooltip")).on("click", function() {
+ context.ui().sidebar.toggle();
+ }).call(
+ uiTooltip().placement("bottom").title(() => _t.append("sidebar.tooltip")).keys([_t("sidebar.key")]).scrollContainer(context.container().select(".top-toolbar"))
+ ).call(svgIcon("#iD-icon-sidebar-" + (_mainLocalizer.textDirection() === "rtl" ? "right" : "left")));
+ };
+ return tool;
+ }
+
+ // modules/ui/tools/undo_redo.js
+ function uiToolUndoRedo(context) {
+ var tool = {
+ id: "undo_redo",
+ label: _t.append("toolbar.undo_redo")
+ };
+ var commands = [{
+ id: "undo",
+ cmd: uiCmd("\u2318Z"),
+ action: function() {
+ context.undo();
+ },
+ annotation: function() {
+ return context.history().undoAnnotation();
+ },
+ icon: "iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")
+ }, {
+ id: "redo",
+ cmd: uiCmd("\u2318\u21E7Z"),
+ action: function() {
+ context.redo();
+ },
+ annotation: function() {
+ return context.history().redoAnnotation();
+ },
+ icon: "iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "undo" : "redo")
+ }];
+ function editable() {
+ return context.mode() && context.mode().id !== "save" && context.map().editableDataEnabled(
+ true
+ /* ignore min zoom */
+ );
+ }
+ tool.render = function(selection2) {
+ var tooltipBehavior = uiTooltip().placement("bottom").title(function(d2) {
+ return d2.annotation() ? _t.append(d2.id + ".tooltip", { action: d2.annotation() }) : _t.append(d2.id + ".nothing");
+ }).keys(function(d2) {
+ return [d2.cmd];
+ }).scrollContainer(context.container().select(".top-toolbar"));
+ var lastPointerUpType;
+ var buttons = selection2.selectAll("button").data(commands).enter().append("button").attr("class", function(d2) {
+ return "disabled " + d2.id + "-button bar-button";
+ }).on("pointerup", function(d3_event) {
+ lastPointerUpType = d3_event.pointerType;
+ }).on("click", function(d3_event, d2) {
+ d3_event.preventDefault();
+ var annotation = d2.annotation();
+ if (editable() && annotation) {
+ d2.action();
+ }
+ if (editable() && (lastPointerUpType === "touch" || lastPointerUpType === "pen")) {
+ var label = annotation ? _t.append(d2.id + ".tooltip", { action: annotation }) : _t.append(d2.id + ".nothing");
+ context.ui().flash.duration(2e3).iconName("#" + d2.icon).iconClass(annotation ? "" : "disabled").label(label)();
+ }
+ lastPointerUpType = null;
+ }).call(tooltipBehavior);
+ buttons.each(function(d2) {
+ select_default2(this).call(svgIcon("#" + d2.icon));
+ });
+ context.keybinding().on(commands[0].cmd, function(d3_event) {
+ d3_event.preventDefault();
+ if (editable())
+ commands[0].action();
+ }).on(commands[1].cmd, function(d3_event) {
+ d3_event.preventDefault();
+ if (editable())
+ commands[1].action();
+ });
+ var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
+ context.map().on("move.undo_redo", debouncedUpdate).on("drawn.undo_redo", debouncedUpdate);
+ context.history().on("change.undo_redo", function(difference2) {
+ if (difference2)
+ update();
+ });
+ context.on("enter.undo_redo", update);
+ function update() {
+ buttons.classed("disabled", function(d2) {
+ return !editable() || !d2.annotation();
+ }).each(function() {
+ var selection3 = select_default2(this);
+ if (!selection3.select(".tooltip.in").empty()) {
+ selection3.call(tooltipBehavior.updateContent);
+ }
+ });
+ }
+ };
+ tool.uninstall = function() {
+ context.keybinding().off(commands[0].cmd).off(commands[1].cmd);
+ context.map().on("move.undo_redo", null).on("drawn.undo_redo", null);
+ context.history().on("change.undo_redo", null);
+ context.on("enter.undo_redo", null);
+ };
+ return tool;
+ }
+
+ // modules/ui/top_toolbar.js
+ function uiTopToolbar(context) {
+ var sidebarToggle = uiToolSidebarToggle(context), modes = uiToolDrawModes(context), notes = uiToolNotes(context), undoRedo = uiToolUndoRedo(context), save = uiToolSave(context);
+ function notesEnabled() {
+ var noteLayer = context.layers().layer("notes");
+ return noteLayer && noteLayer.enabled();
+ }
+ function topToolbar(bar) {
+ bar.on("wheel.topToolbar", function(d3_event) {
+ if (!d3_event.deltaX) {
+ bar.node().scrollLeft += d3_event.deltaY;
+ }
+ });
+ var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
+ context.layers().on("change.topToolbar", debouncedUpdate);
+ update();
+ function update() {
+ var tools = [
+ sidebarToggle,
+ "spacer",
+ modes
+ ];
+ tools.push("spacer");
+ if (notesEnabled()) {
+ tools = tools.concat([notes, "spacer"]);
+ }
+ tools = tools.concat([undoRedo, save]);
+ var toolbarItems = bar.selectAll(".toolbar-item").data(tools, function(d2) {
+ return d2.id || d2;
+ });
+ toolbarItems.exit().each(function(d2) {
+ if (d2.uninstall) {
+ d2.uninstall();
+ }
+ }).remove();
+ var itemsEnter = toolbarItems.enter().append("div").attr("class", function(d2) {
+ var classes = "toolbar-item " + (d2.id || d2).replace("_", "-");
+ if (d2.klass)
+ classes += " " + d2.klass;
+ return classes;
+ });
+ var actionableItems = itemsEnter.filter(function(d2) {
+ return d2 !== "spacer";
+ });
+ actionableItems.append("div").attr("class", "item-content").each(function(d2) {
+ select_default2(this).call(d2.render, bar);
+ });
+ actionableItems.append("div").attr("class", "item-label").each(function(d2) {
+ d2.label(select_default2(this));
+ });
+ }
+ }
+ return topToolbar;
+ }
+
+ // modules/ui/zoom_to_selection.js
+ function uiZoomToSelection(context) {
+ function isDisabled() {
+ var mode = context.mode();
+ return !mode || !mode.zoomToSelected;
+ }
+ var _lastPointerUpType;
+ function pointerup(d3_event) {
+ _lastPointerUpType = d3_event.pointerType;
+ }
+ function click(d3_event) {
+ d3_event.preventDefault();
+ if (isDisabled()) {
+ if (_lastPointerUpType === "touch" || _lastPointerUpType === "pen") {
+ context.ui().flash.duration(2e3).iconName("#iD-icon-framed-dot").iconClass("disabled").label(_t.append("inspector.zoom_to.no_selection"))();
+ }
+ } else {
+ var mode = context.mode();
+ if (mode && mode.zoomToSelected) {
+ mode.zoomToSelected();
+ }
+ }
+ _lastPointerUpType = null;
+ }
+ return function(selection2) {
+ var tooltipBehavior = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(function() {
+ if (isDisabled()) {
+ return _t.append("inspector.zoom_to.no_selection");
+ }
+ return _t.append("inspector.zoom_to.title");
+ }).keys([_t("inspector.zoom_to.key")]);
+ var button = selection2.append("button").on("pointerup", pointerup).on("click", click).call(svgIcon("#iD-icon-framed-dot", "light")).call(tooltipBehavior);
+ function setEnabledState() {
+ button.classed("disabled", isDisabled());
+ if (!button.select(".tooltip.in").empty()) {
+ button.call(tooltipBehavior.updateContent);
+ }
+ }
+ context.on("enter.uiZoomToSelection", setEnabledState);
+ setEnabledState();
+ };
+ }
+
+ // modules/ui/pane.js
+ function uiPane(id2, context) {
+ var _key;
+ var _label = "";
+ var _description = "";
+ var _iconName = "";
+ var _sections;
+ var _paneSelection = select_default2(null);
+ var _paneTooltip;
+ var pane = {
+ id: id2
+ };
+ pane.label = function(val) {
+ if (!arguments.length)
+ return _label;
+ _label = val;
+ return pane;
+ };
+ pane.key = function(val) {
+ if (!arguments.length)
+ return _key;
+ _key = val;
+ return pane;
+ };
+ pane.description = function(val) {
+ if (!arguments.length)
+ return _description;
+ _description = val;
+ return pane;
+ };
+ pane.iconName = function(val) {
+ if (!arguments.length)
+ return _iconName;
+ _iconName = val;
+ return pane;
+ };
+ pane.sections = function(val) {
+ if (!arguments.length)
+ return _sections;
+ _sections = val;
+ return pane;
+ };
+ pane.selection = function() {
+ return _paneSelection;
+ };
+ function hidePane() {
+ context.ui().togglePanes();
+ }
+ pane.togglePane = function(d3_event) {
+ if (d3_event)
+ d3_event.preventDefault();
+ _paneTooltip.hide();
+ context.ui().togglePanes(!_paneSelection.classed("shown") ? _paneSelection : void 0);
+ };
+ pane.renderToggleButton = function(selection2) {
+ if (!_paneTooltip) {
+ _paneTooltip = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(() => _description).keys([_key]);
+ }
+ selection2.append("button").on("click", pane.togglePane).call(svgIcon("#" + _iconName, "light")).call(_paneTooltip);
+ };
+ pane.renderContent = function(selection2) {
+ if (_sections) {
+ _sections.forEach(function(section) {
+ selection2.call(section.render);
+ });
+ }
+ };
+ pane.renderPane = function(selection2) {
+ _paneSelection = selection2.append("div").attr("class", "fillL map-pane hide " + id2 + "-pane").attr("pane", id2);
+ var heading2 = _paneSelection.append("div").attr("class", "pane-heading");
+ heading2.append("h2").text("").call(_label);
+ heading2.append("button").attr("title", _t("icons.close")).on("click", hidePane).call(svgIcon("#iD-icon-close"));
+ _paneSelection.append("div").attr("class", "pane-content").call(pane.renderContent);
+ if (_key) {
+ context.keybinding().on(_key, pane.togglePane);
+ }
+ };
+ return pane;
+ }
+
+ // modules/ui/sections/background_display_options.js
+ function uiSectionBackgroundDisplayOptions(context) {
+ var section = uiSection("background-display-options", context).label(() => _t.append("background.display_options")).disclosureContent(renderDisclosureContent);
+ var _storedOpacity = corePreferences("background-opacity");
+ var _minVal = 0;
+ var _maxVal = 3;
+ var _sliders = ["brightness", "contrast", "saturation", "sharpness"];
+ var _options = {
+ brightness: _storedOpacity !== null ? +_storedOpacity : 1,
+ contrast: 1,
+ saturation: 1,
+ sharpness: 1
+ };
+ function clamp3(x2, min3, max3) {
+ return Math.max(min3, Math.min(x2, max3));
+ }
+ function updateValue(d2, val) {
+ val = clamp3(val, _minVal, _maxVal);
+ _options[d2] = val;
+ context.background()[d2](val);
+ if (d2 === "brightness") {
+ corePreferences("background-opacity", val);
+ }
+ section.reRender();
+ }
+ function renderDisclosureContent(selection2) {
+ var container = selection2.selectAll(".display-options-container").data([0]);
+ var containerEnter = container.enter().append("div").attr("class", "display-options-container controls-list");
+ var slidersEnter = containerEnter.selectAll(".display-control").data(_sliders).enter().append("label").attr("class", function(d2) {
+ return "display-control display-control-" + d2;
+ });
+ slidersEnter.html(function(d2) {
+ return _t.html("background." + d2);
+ }).append("span").attr("class", function(d2) {
+ return "display-option-value display-option-value-" + d2;
+ });
+ var sildersControlEnter = slidersEnter.append("div").attr("class", "control-wrap");
+ sildersControlEnter.append("input").attr("class", function(d2) {
+ return "display-option-input display-option-input-" + d2;
+ }).attr("type", "range").attr("min", _minVal).attr("max", _maxVal).attr("step", "0.05").on("input", function(d3_event, d2) {
+ var val = select_default2(this).property("value");
+ if (!val && d3_event && d3_event.target) {
+ val = d3_event.target.value;
+ }
+ updateValue(d2, val);
+ });
+ sildersControlEnter.append("button").attr("title", function(d2) {
+ return "".concat(_t("background.reset"), " ").concat(_t("background." + d2));
+ }).attr("class", function(d2) {
+ return "display-option-reset display-option-reset-" + d2;
+ }).on("click", function(d3_event, d2) {
+ if (d3_event.button !== 0)
+ return;
+ updateValue(d2, 1);
+ }).call(svgIcon("#iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")));
+ containerEnter.append("a").attr("class", "display-option-resetlink").attr("role", "button").attr("href", "#").call(_t.append("background.reset_all")).on("click", function(d3_event) {
+ d3_event.preventDefault();
+ for (var i3 = 0; i3 < _sliders.length; i3++) {
+ updateValue(_sliders[i3], 1);
+ }
+ });
+ container = containerEnter.merge(container);
+ container.selectAll(".display-option-input").property("value", function(d2) {
+ return _options[d2];
+ });
+ container.selectAll(".display-option-value").text(function(d2) {
+ return Math.floor(_options[d2] * 100) + "%";
+ });
+ container.selectAll(".display-option-reset").classed("disabled", function(d2) {
+ return _options[d2] === 1;
+ });
+ if (containerEnter.size() && _options.brightness !== 1) {
+ context.background().brightness(_options.brightness);
+ }
+ }
+ return section;
+ }
+
+ // modules/ui/settings/custom_background.js
+ function uiSettingsCustomBackground() {
+ var dispatch14 = dispatch_default("change");
+ function render(selection2) {
+ var _origSettings = {
+ template: corePreferences("background-custom-template")
+ };
+ var _currSettings = {
+ template: corePreferences("background-custom-template")
+ };
+ var example = "https://tile.openstreetmap.org/{zoom}/{x}/{y}.png";
+ var modal = uiConfirm(selection2).okButton();
+ modal.classed("settings-modal settings-custom-background", true);
+ modal.select(".modal-section.header").append("h3").call(_t.append("settings.custom_background.header"));
+ var textSection = modal.select(".modal-section.message-text");
+ var instructions = "".concat(_t.html("settings.custom_background.instructions.info"), "\n") + "\n" + "#### ".concat(_t.html("settings.custom_background.instructions.wms.tokens_label"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.wms.tokens.proj"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.wms.tokens.wkid"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.wms.tokens.dimensions"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.wms.tokens.bbox"), "\n") + "\n" + "#### ".concat(_t.html("settings.custom_background.instructions.tms.tokens_label"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.tms.tokens.xyz"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.tms.tokens.flipped_y"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.tms.tokens.switch"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.tms.tokens.quadtile"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.tms.tokens.scale_factor"), "\n") + "\n" + "#### ".concat(_t.html("settings.custom_background.instructions.example"), "\n") + "`".concat(example, "`");
+ textSection.append("div").attr("class", "instructions-template").html(marked(instructions));
+ textSection.append("textarea").attr("class", "field-template").attr("placeholder", _t("settings.custom_background.template.placeholder")).call(utilNoAuto).property("value", _currSettings.template);
+ var buttonSection = modal.select(".modal-section.buttons");
+ buttonSection.insert("button", ".ok-button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel"));
+ buttonSection.select(".cancel-button").on("click.cancel", clickCancel);
+ buttonSection.select(".ok-button").attr("disabled", isSaveDisabled).on("click.save", clickSave);
+ function isSaveDisabled() {
+ return null;
+ }
+ function clickCancel() {
+ textSection.select(".field-template").property("value", _origSettings.template);
+ corePreferences("background-custom-template", _origSettings.template);
+ this.blur();
+ modal.close();
+ }
+ function clickSave() {
+ _currSettings.template = textSection.select(".field-template").property("value");
+ corePreferences("background-custom-template", _currSettings.template);
+ this.blur();
+ modal.close();
+ dispatch14.call("change", this, _currSettings);
+ }
+ }
+ return utilRebind(render, dispatch14, "on");
+ }
+
+ // modules/ui/sections/background_list.js
+ function uiSectionBackgroundList(context) {
+ var _backgroundList = select_default2(null);
+ var _customSource = context.background().findSource("custom");
+ var _settingsCustomBackground = uiSettingsCustomBackground(context).on("change", customChanged);
+ var section = uiSection("background-list", context).label(() => _t.append("background.backgrounds")).disclosureContent(renderDisclosureContent);
+ function previousBackgroundID() {
+ return corePreferences("background-last-used-toggle");
+ }
+ function renderDisclosureContent(selection2) {
+ var container = selection2.selectAll(".layer-background-list").data([0]);
+ _backgroundList = container.enter().append("ul").attr("class", "layer-list layer-background-list").attr("dir", "auto").merge(container);
+ var bgExtrasListEnter = selection2.selectAll(".bg-extras-list").data([0]).enter().append("ul").attr("class", "layer-list bg-extras-list");
+ var minimapLabelEnter = bgExtrasListEnter.append("li").attr("class", "minimap-toggle-item").append("label").call(
+ uiTooltip().title(() => _t.append("background.minimap.tooltip")).keys([_t("background.minimap.key")]).placement("top")
+ );
+ minimapLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
+ d3_event.preventDefault();
+ uiMapInMap.toggle();
+ });
+ minimapLabelEnter.append("span").call(_t.append("background.minimap.description"));
+ var panelLabelEnter = bgExtrasListEnter.append("li").attr("class", "background-panel-toggle-item").append("label").call(
+ uiTooltip().title(() => _t.append("background.panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.background.key"))]).placement("top")
+ );
+ panelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
+ d3_event.preventDefault();
+ context.ui().info.toggle("background");
+ });
+ panelLabelEnter.append("span").call(_t.append("background.panel.description"));
+ var locPanelLabelEnter = bgExtrasListEnter.append("li").attr("class", "location-panel-toggle-item").append("label").call(
+ uiTooltip().title(() => _t.append("background.location_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.location.key"))]).placement("top")
+ );
+ locPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
+ d3_event.preventDefault();
+ context.ui().info.toggle("location");
+ });
+ locPanelLabelEnter.append("span").call(_t.append("background.location_panel.description"));
+ selection2.selectAll(".imagery-faq").data([0]).enter().append("div").attr("class", "imagery-faq").append("a").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).attr("href", "https://github.com/openstreetmap/iD/blob/develop/FAQ.md#how-can-i-report-an-issue-with-background-imagery").append("span").call(_t.append("background.imagery_problem_faq"));
+ _backgroundList.call(drawListItems, "radio", function(d3_event, d2) {
+ chooseBackground(d2);
+ }, function(d2) {
+ return !d2.isHidden() && !d2.overlay;
+ });
+ }
+ function setTooltips(selection2) {
+ selection2.each(function(d2, i3, nodes) {
+ var item = select_default2(this).select("label");
+ var span = item.select("span");
+ var placement = i3 < nodes.length / 2 ? "bottom" : "top";
+ var hasDescription = d2.hasDescription();
+ var isOverflowing = span.property("clientWidth") !== span.property("scrollWidth");
+ item.call(uiTooltip().destroyAny);
+ if (d2.id === previousBackgroundID()) {
+ item.call(
+ uiTooltip().placement(placement).title(() => _t.append("background.switch")).keys([uiCmd("\u2318" + _t("background.key"))])
+ );
+ } else if (hasDescription || isOverflowing) {
+ item.call(
+ uiTooltip().placement(placement).title(() => hasDescription ? d2.description() : d2.label())
+ );
+ }
+ });
+ }
+ function drawListItems(layerList, type2, change, filter2) {
+ var sources = context.background().sources(context.map().extent(), context.map().zoom(), true).filter(filter2).sort(function(a2, b2) {
+ return a2.best() && !b2.best() ? -1 : b2.best() && !a2.best() ? 1 : descending(a2.area(), b2.area()) || ascending(a2.name(), b2.name()) || 0;
+ });
+ var layerLinks = layerList.selectAll("li").data(sources, function(d2, i3) {
+ return d2.id + "---" + i3;
+ });
+ layerLinks.exit().remove();
+ var enter = layerLinks.enter().append("li").classed("layer-custom", function(d2) {
+ return d2.id === "custom";
+ }).classed("best", function(d2) {
+ return d2.best();
+ });
+ var label = enter.append("label");
+ label.append("input").attr("type", type2).attr("name", "background-layer").attr("value", function(d2) {
+ return d2.id;
+ }).on("change", change);
+ label.append("span").each(function(d2) {
+ d2.label()(select_default2(this));
+ });
+ enter.filter(function(d2) {
+ return d2.id === "custom";
+ }).append("button").attr("class", "layer-browse").call(
+ uiTooltip().title(() => _t.append("settings.custom_background.tooltip")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
+ ).on("click", function(d3_event) {
+ d3_event.preventDefault();
+ editCustom();
+ }).call(svgIcon("#iD-icon-more"));
+ enter.filter(function(d2) {
+ return d2.best();
+ }).append("div").attr("class", "best").call(
+ uiTooltip().title(() => _t.append("background.best_imagery")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
+ ).append("span").text("\u2605");
+ layerList.call(updateLayerSelections);
+ }
+ function updateLayerSelections(selection2) {
+ function active(d2) {
+ return context.background().showsLayer(d2);
+ }
+ selection2.selectAll("li").classed("active", active).classed("switch", function(d2) {
+ return d2.id === previousBackgroundID();
+ }).call(setTooltips).selectAll("input").property("checked", active);
+ }
+ function chooseBackground(d2) {
+ if (d2.id === "custom" && !d2.template()) {
+ return editCustom();
+ }
+ var previousBackground = context.background().baseLayerSource();
+ corePreferences("background-last-used-toggle", previousBackground.id);
+ corePreferences("background-last-used", d2.id);
+ context.background().baseLayerSource(d2);
+ }
+ function customChanged(d2) {
+ if (d2 && d2.template) {
+ _customSource.template(d2.template);
+ chooseBackground(_customSource);
+ } else {
+ _customSource.template("");
+ chooseBackground(context.background().findSource("none"));
+ }
+ }
+ function editCustom() {
+ context.container().call(_settingsCustomBackground);
+ }
+ context.background().on("change.background_list", function() {
+ _backgroundList.call(updateLayerSelections);
+ });
+ context.map().on(
+ "move.background_list",
+ debounce_default(function() {
+ window.requestIdleCallback(section.reRender);
+ }, 1e3)
+ );
+ return section;
+ }
+
+ // modules/ui/sections/background_offset.js
+ function uiSectionBackgroundOffset(context) {
+ var section = uiSection("background-offset", context).label(() => _t.append("background.fix_misalignment")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
+ var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
+ var _directions = [
+ ["top", [0, -0.5]],
+ ["left", [-0.5, 0]],
+ ["right", [0.5, 0]],
+ ["bottom", [0, 0.5]]
+ ];
+ function updateValue() {
+ var meters = geoOffsetToMeters(context.background().offset());
+ var x2 = +meters[0].toFixed(2);
+ var y2 = +meters[1].toFixed(2);
+ context.container().selectAll(".nudge-inner-rect").select("input").classed("error", false).property("value", x2 + ", " + y2);
+ context.container().selectAll(".nudge-reset").classed("disabled", function() {
+ return x2 === 0 && y2 === 0;
+ });
+ }
+ function resetOffset() {
+ context.background().offset([0, 0]);
+ updateValue();
+ }
+ function nudge(d2) {
+ context.background().nudge(d2, context.map().zoom());
+ updateValue();
+ }
+ function inputOffset() {
+ var input = select_default2(this);
+ var d2 = input.node().value;
+ if (d2 === "")
+ return resetOffset();
+ d2 = d2.replace(/;/g, ",").split(",").map(function(n3) {
+ return !isNaN(n3) && n3;
+ });
+ if (d2.length !== 2 || !d2[0] || !d2[1]) {
+ input.classed("error", true);
+ return;
+ }
+ context.background().offset(geoMetersToOffset(d2));
+ updateValue();
+ }
+ function dragOffset(d3_event) {
+ if (d3_event.button !== 0)
+ return;
+ var origin = [d3_event.clientX, d3_event.clientY];
+ var pointerId = d3_event.pointerId || "mouse";
+ context.container().append("div").attr("class", "nudge-surface");
+ select_default2(window).on(_pointerPrefix + "move.drag-bg-offset", pointermove).on(_pointerPrefix + "up.drag-bg-offset", pointerup);
+ if (_pointerPrefix === "pointer") {
+ select_default2(window).on("pointercancel.drag-bg-offset", pointerup);
+ }
+ function pointermove(d3_event2) {
+ if (pointerId !== (d3_event2.pointerId || "mouse"))
+ return;
+ var latest = [d3_event2.clientX, d3_event2.clientY];
+ var d2 = [
+ -(origin[0] - latest[0]) / 4,
+ -(origin[1] - latest[1]) / 4
+ ];
+ origin = latest;
+ nudge(d2);
+ }
+ function pointerup(d3_event2) {
+ if (pointerId !== (d3_event2.pointerId || "mouse"))
+ return;
+ if (d3_event2.button !== 0)
+ return;
+ context.container().selectAll(".nudge-surface").remove();
+ select_default2(window).on(".drag-bg-offset", null);
+ }
+ }
+ function renderDisclosureContent(selection2) {
+ var container = selection2.selectAll(".nudge-container").data([0]);
+ var containerEnter = container.enter().append("div").attr("class", "nudge-container");
+ containerEnter.append("div").attr("class", "nudge-instructions").call(_t.append("background.offset"));
+ var nudgeWrapEnter = containerEnter.append("div").attr("class", "nudge-controls-wrap");
+ var nudgeEnter = nudgeWrapEnter.append("div").attr("class", "nudge-outer-rect").on(_pointerPrefix + "down", dragOffset);
+ nudgeEnter.append("div").attr("class", "nudge-inner-rect").append("input").attr("type", "text").attr("aria-label", _t("background.offset_label")).on("change", inputOffset);
+ nudgeWrapEnter.append("div").selectAll("button").data(_directions).enter().append("button").attr("title", function(d2) {
+ return _t("background.nudge.".concat(d2[0]));
+ }).attr("class", function(d2) {
+ return d2[0] + " nudge";
+ }).on("click", function(d3_event, d2) {
+ nudge(d2[1]);
+ });
+ nudgeWrapEnter.append("button").attr("title", _t("background.reset")).attr("class", "nudge-reset disabled").on("click", function(d3_event) {
+ d3_event.preventDefault();
+ resetOffset();
+ }).call(svgIcon("#iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")));
+ updateValue();
+ }
+ context.background().on("change.backgroundOffset-update", updateValue);
+ return section;
+ }
+
+ // modules/ui/sections/overlay_list.js
+ function uiSectionOverlayList(context) {
+ var section = uiSection("overlay-list", context).label(() => _t.append("background.overlays")).disclosureContent(renderDisclosureContent);
+ var _overlayList = select_default2(null);
+ function setTooltips(selection2) {
+ selection2.each(function(d2, i3, nodes) {
+ var item = select_default2(this).select("label");
+ var span = item.select("span");
+ var placement = i3 < nodes.length / 2 ? "bottom" : "top";
+ var description = d2.description();
+ var isOverflowing = span.property("clientWidth") !== span.property("scrollWidth");
+ item.call(uiTooltip().destroyAny);
+ if (description || isOverflowing) {
+ item.call(
+ uiTooltip().placement(placement).title(() => description || d2.name())
+ );
+ }
+ });
+ }
+ function updateLayerSelections(selection2) {
+ function active(d2) {
+ return context.background().showsLayer(d2);
+ }
+ selection2.selectAll("li").classed("active", active).call(setTooltips).selectAll("input").property("checked", active);
+ }
+ function chooseOverlay(d3_event, d2) {
+ d3_event.preventDefault();
+ context.background().toggleOverlayLayer(d2);
+ _overlayList.call(updateLayerSelections);
+ document.activeElement.blur();
+ }
+ function drawListItems(layerList, type2, change, filter2) {
+ var sources = context.background().sources(context.map().extent(), context.map().zoom(), true).filter(filter2);
+ var layerLinks = layerList.selectAll("li").data(sources, function(d2) {
+ return d2.name();
+ });
+ layerLinks.exit().remove();
+ var enter = layerLinks.enter().append("li");
+ var label = enter.append("label");
+ label.append("input").attr("type", type2).attr("name", "layers").on("change", change);
+ label.append("span").each(function(d2) {
+ d2.label()(select_default2(this));
+ });
+ layerList.selectAll("li").sort(sortSources);
+ layerList.call(updateLayerSelections);
+ function sortSources(a2, b2) {
+ return a2.best() && !b2.best() ? -1 : b2.best() && !a2.best() ? 1 : descending(a2.area(), b2.area()) || ascending(a2.name(), b2.name()) || 0;
+ }
+ }
+ function renderDisclosureContent(selection2) {
+ var container = selection2.selectAll(".layer-overlay-list").data([0]);
+ _overlayList = container.enter().append("ul").attr("class", "layer-list layer-overlay-list").attr("dir", "auto").merge(container);
+ _overlayList.call(drawListItems, "checkbox", chooseOverlay, function(d2) {
+ return !d2.isHidden() && d2.overlay;
+ });
+ }
+ context.map().on(
+ "move.overlay_list",
+ debounce_default(function() {
+ window.requestIdleCallback(section.reRender);
+ }, 1e3)
+ );
+ return section;
+ }
+
+ // 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", "improveOSM", "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 _a2;
+ function locationUnavailable(d2) {
+ return !(isArray_default(d2.loc) && isNumber_default(d2.loc[0]) && isNumber_default(d2.loc[1]));
+ }
+ container.selectAll("li.placeholder").remove();
+ let selection2 = container.selectAll("li").data((_a2 = photoLayer.getPhotos()) != null ? _a2 : [], (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 _a2, _b, _c;
+ return (_c = (_b = (_a2 = d2.layer).rendered) == null ? void 0 : _b.call(_a2, context.map().zoom())) != null ? _c : true;
+ }
+ var ul = selection2.selectAll(".layer-list-photos").data([0]);
+ ul = ul.enter().append("ul").attr("class", "layer-list layer-list-photos").merge(ul);
+ var li = ul.selectAll(".list-item-photos").data(data);
+ 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/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.loadEntity(entityID, (err, result) => {
+ if (err)
+ return;
+ if (zoomTo !== false) {
+ const entity = result.data.find((e3) => e3.id === entityID);
+ if (entity) {
+ _map.zoomTo(entity);
+ }
+ }
+ });
+ _map.on("drawn.zoomToEntity", () => {
+ if (!context.hasEntity(entityID))
+ return;
+ _map.on("drawn.zoomToEntity", null);
+ context.on("enter.zoomToEntity", null);
+ context.enter(modeSelect(context, [entityID]));
+ });
+ context.on("enter.zoomToEntity", () => {
+ if (_mode.id !== "browse") {
+ _map.on("drawn.zoomToEntity", null);
+ context.on("enter.zoomToEntity", null);
+ }
+ });
+ };
+ 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;
+ };
+ context.containerNode = function(val) {
+ if (!arguments.length)
+ return context.container().node();
+ context.container(select_default2(val));
+ return context;
+ };
+ let _embed;
+ context.embed = function(val) {
+ if (!arguments.length)
+ return _embed;
+ _embed = val;
+ return context;
+ };
+ let _assetPath = "";
+ context.assetPath = function(val) {
+ if (!arguments.length)
+ return _assetPath;
+ _assetPath = val;
+ _mainFileFetcher.assetPath(val);
+ return context;
+ };
+ let _assetMap = {};
+ context.assetMap = function(val) {
+ if (!arguments.length)
+ return _assetMap;
+ _assetMap = val;
+ _mainFileFetcher.assetMap(val);
+ return context;
+ };
+ context.asset = (val) => {
+ if (/^http(s)?:\/\//i.test(val))
+ return val;
+ const filename = _assetPath + val;
+ return _assetMap[filename] || filename;
+ };
+ context.imagePath = (val) => context.asset("img/".concat(val));
+ context.reset = context.flush = () => {
+ context.debouncedSave.cancel();
+ Array.from(_deferred2).forEach((handle) => {
+ window.cancelIdleCallback(handle);
+ _deferred2.delete(handle);
+ });
+ Object.values(services).forEach((service) => {
+ if (service && typeof service.reset === "function") {
+ service.reset(context);
+ }
+ });
+ context.changeset = null;
+ _validator.reset();
+ _features.reset();
+ _history.reset();
+ _uploader.reset();
+ context.container().select(".inspector-wrap *").remove();
+ return context;
+ };
+ context.projection = geoRawMercator();
+ context.curtainProjection = geoRawMercator();
+ context.init = () => {
+ instantiateInternal();
+ initializeDependents();
+ return context;
+ function instantiateInternal() {
+ _history = coreHistory(context);
+ context.graph = _history.graph;
+ context.pauseChangeDispatch = _history.pauseChangeDispatch;
+ context.resumeChangeDispatch = _history.resumeChangeDispatch;
+ context.perform = withDebouncedSave(_history.perform);
+ context.replace = withDebouncedSave(_history.replace);
+ context.pop = withDebouncedSave(_history.pop);
+ context.overwrite = withDebouncedSave(_history.overwrite);
+ context.undo = withDebouncedSave(_history.undo);
+ context.redo = withDebouncedSave(_history.redo);
+ _validator = coreValidator(context);
+ _uploader = coreUploader(context);
+ _background = rendererBackground(context);
+ _features = rendererFeatures(context);
+ _map = rendererMap(context);
+ _photos = rendererPhotos(context);
+ _ui = uiInit(context);
+ }
+ function initializeDependents() {
+ if (context.initialHashParams.presets) {
+ _mainPresetIndex.addablePresetIDs(new Set(context.initialHashParams.presets.split(",")));
+ }
+ if (context.initialHashParams.locale) {
+ _mainLocalizer.preferredLocaleCodes(context.initialHashParams.locale);
+ }
+ _mainLocalizer.ensureLoaded();
+ _mainPresetIndex.ensureLoaded();
+ _background.ensureLoaded();
+ Object.values(services).forEach((service) => {
+ if (service && typeof service.init === "function") {
+ service.init();
+ }
+ });
+ _map.init();
+ _validator.init();
+ _features.init();
+ if (services.maprules && context.initialHashParams.maprules) {
+ json_default(context.initialHashParams.maprules).then((mapcss) => {
+ services.maprules.init();
+ mapcss.forEach((mapcssSelector) => services.maprules.addRule(mapcssSelector));
+ }).catch(() => {
+ });
+ }
+ if (!context.container().empty()) {
+ _ui.ensureLoaded().then(() => {
+ _background.init();
+ _photos.init();
+ });
+ }
+ }
+ };
+ return context;
+ }
+
+ // modules/services/nominatim.js
+ var apibase = nominatimApiUrl;
+ var _inflight = {};
+ var _nominatimCache;
+ var nominatim_default = {
+ init: function() {
+ _inflight = {};
+ _nominatimCache = new import_rbush7.default();
+ },
+ reset: function() {
+ Object.values(_inflight).forEach(function(controller) {
+ controller.abort();
+ });
+ _inflight = {};
+ _nominatimCache = new import_rbush7.default();
+ },
+ countryCode: function(location, callback) {
+ this.reverse(location, function(err, result) {
+ if (err) {
+ return callback(err);
+ } else if (result.address) {
+ return callback(null, result.address.country_code);
+ } else {
+ return callback("Unable to geocode", null);
+ }
+ });
+ },
+ reverse: function(loc, callback) {
+ var cached = _nominatimCache.search(
+ { minX: loc[0], minY: loc[1], maxX: loc[0], maxY: loc[1] }
+ );
+ if (cached.length > 0) {
+ if (callback)
+ callback(null, cached[0].data);
+ return;
+ }
+ var params = { zoom: 13, format: "json", addressdetails: 1, lat: loc[1], lon: loc[0] };
+ var url = apibase + "reverse?" + utilQsString(params);
+ if (_inflight[url])
+ return;
+ var controller = new AbortController();
+ _inflight[url] = controller;
+ json_default(url, {
+ signal: controller.signal,
+ headers: {
+ "Accept-Language": _mainLocalizer.localeCodes().join(",")
+ }
+ }).then(function(result) {
+ delete _inflight[url];
+ if (result && result.error) {
+ throw new Error(result.error);
+ }
+ var extent = geoExtent(loc).padByMeters(200);
+ _nominatimCache.insert(Object.assign(extent.bbox(), { data: result }));
+ if (callback)
+ callback(null, result);
+ }).catch(function(err) {
+ delete _inflight[url];
+ if (err.name === "AbortError")
+ return;
+ if (callback)
+ callback(err.message);
+ });
+ },
+ search: function(val, callback) {
+ const params = {
+ q: val,
+ limit: 10,
+ format: "json"
+ };
+ var url = apibase + "search?" + utilQsString(params);
+ if (_inflight[url])
+ return;
+ var controller = new AbortController();
+ _inflight[url] = controller;
+ json_default(url, {
+ signal: controller.signal,
+ headers: {
+ "Accept-Language": _mainLocalizer.localeCodes().join(",")
+ }
+ }).then(function(result) {
+ delete _inflight[url];
+ if (result && result.error) {
+ throw new Error(result.error);
+ }
+ if (callback)
+ callback(null, result);
+ }).catch(function(err) {
+ delete _inflight[url];
+ if (err.name === "AbortError")
+ return;
+ if (callback)
+ callback(err.message);
+ });
+ }
+ };
+
+ // node_modules/name-suggestion-index/lib/matcher.js
+ var import_which_polygon4 = __toESM(require_which_polygon(), 1);
+
+ // node_modules/name-suggestion-index/lib/simplify.js
+ var import_diacritics3 = __toESM(require_diacritics(), 1);
+ function simplify2(str) {
+ if (typeof str !== "string")
+ return "";
+ return import_diacritics3.default.remove(
+ str.replace(/&/g, "and").replace(/İ/ig, "i").replace(/[\s\-=_!"#%'*{},.\/:;?\(\)\[\]@\\$\^*+<>«»~`’\u00a1\u00a7\u00b6\u00b7\u00bf\u037e\u0387\u055a-\u055f\u0589\u05c0\u05c3\u05c6\u05f3\u05f4\u0609\u060a\u060c\u060d\u061b\u061e\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0830-\u083e\u085e\u0964\u0965\u0970\u0af0\u0df4\u0e4f\u0e5a\u0e5b\u0f04-\u0f12\u0f14\u0f85\u0fd0-\u0fd4\u0fd9\u0fda\u104a-\u104f\u10fb\u1360-\u1368\u166d\u166e\u16eb-\u16ed\u1735\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u1805\u1807-\u180a\u1944\u1945\u1a1e\u1a1f\u1aa0-\u1aa6\u1aa8-\u1aad\u1b5a-\u1b60\u1bfc-\u1bff\u1c3b-\u1c3f\u1c7e\u1c7f\u1cc0-\u1cc7\u1cd3\u2000-\u206f\u2cf9-\u2cfc\u2cfe\u2cff\u2d70\u2e00-\u2e7f\u3001-\u3003\u303d\u30fb\ua4fe\ua4ff\ua60d-\ua60f\ua673\ua67e\ua6f2-\ua6f7\ua874-\ua877\ua8ce\ua8cf\ua8f8-\ua8fa\ua92e\ua92f\ua95f\ua9c1-\ua9cd\ua9de\ua9df\uaa5c-\uaa5f\uaade\uaadf\uaaf0\uaaf1\uabeb\ufe10-\ufe16\ufe19\ufe30\ufe45\ufe46\ufe49-\ufe4c\ufe50-\ufe52\ufe54-\ufe57\ufe5f-\ufe61\ufe68\ufe6a\ufe6b\ufeff\uff01-\uff03\uff05-\uff07\uff0a\uff0c\uff0e\uff0f\uff1a\uff1b\uff1f\uff20\uff3c\uff61\uff64\uff65]+/g, "").toLowerCase()
+ );
+ }
+
+ // node_modules/name-suggestion-index/config/matchGroups.json
+ var matchGroups_default = {
+ matchGroups: {
+ adult_gaming_centre: [
+ "amenity/casino",
+ "amenity/gambling",
+ "leisure/adult_gaming_centre"
+ ],
+ beauty: [
+ "shop/beauty",
+ "shop/hairdresser_supply"
+ ],
+ bed: [
+ "shop/bed",
+ "shop/furniture"
+ ],
+ beverages: [
+ "shop/alcohol",
+ "shop/beer",
+ "shop/beverages",
+ "shop/kiosk",
+ "shop/wine"
+ ],
+ camping: [
+ "tourism/camp_site",
+ "tourism/caravan_site"
+ ],
+ car_parts: [
+ "shop/car_parts",
+ "shop/car_repair",
+ "shop/tires",
+ "shop/tyres"
+ ],
+ clinic: [
+ "amenity/clinic",
+ "amenity/doctors",
+ "healthcare/clinic",
+ "healthcare/laboratory",
+ "healthcare/physiotherapist",
+ "healthcare/sample_collection",
+ "healthcare/dialysis"
+ ],
+ convenience: [
+ "shop/beauty",
+ "shop/chemist",
+ "shop/convenience",
+ "shop/cosmetics",
+ "shop/grocery",
+ "shop/kiosk",
+ "shop/newsagent",
+ "shop/perfumery"
+ ],
+ coworking: [
+ "amenity/coworking_space",
+ "office/coworking",
+ "office/coworking_space"
+ ],
+ dentist: [
+ "amenity/dentist",
+ "amenity/doctors",
+ "healthcare/dentist"
+ ],
+ electronics: [
+ "office/telecommunication",
+ "shop/computer",
+ "shop/electronics",
+ "shop/hifi",
+ "shop/kiosk",
+ "shop/mobile",
+ "shop/mobile_phone",
+ "shop/telecommunication"
+ ],
+ fabric: [
+ "shop/fabric",
+ "shop/haberdashery",
+ "shop/sewing"
+ ],
+ fashion: [
+ "shop/accessories",
+ "shop/bag",
+ "shop/boutique",
+ "shop/clothes",
+ "shop/department_store",
+ "shop/fashion",
+ "shop/fashion_accessories",
+ "shop/sports",
+ "shop/shoes"
+ ],
+ financial: [
+ "amenity/bank",
+ "office/accountant",
+ "office/financial",
+ "office/financial_advisor",
+ "office/tax_advisor",
+ "shop/tax"
+ ],
+ fitness: [
+ "leisure/fitness_centre",
+ "leisure/fitness_center",
+ "leisure/sports_centre",
+ "leisure/sports_center"
+ ],
+ food: [
+ "amenity/bar",
+ "amenity/cafe",
+ "amenity/fast_food",
+ "amenity/ice_cream",
+ "amenity/pub",
+ "amenity/restaurant",
+ "shop/bakery",
+ "shop/candy",
+ "shop/chocolate",
+ "shop/coffee",
+ "shop/confectionary",
+ "shop/confectionery",
+ "shop/food",
+ "shop/kiosk",
+ "shop/ice_cream",
+ "shop/pastry",
+ "shop/tea"
+ ],
+ fuel: [
+ "amenity/fuel",
+ "shop/gas",
+ "shop/convenience;gas",
+ "shop/gas;convenience"
+ ],
+ gift: [
+ "shop/gift",
+ "shop/card",
+ "shop/cards",
+ "shop/kiosk",
+ "shop/stationery"
+ ],
+ hardware: [
+ "shop/bathroom_furnishing",
+ "shop/carpet",
+ "shop/diy",
+ "shop/doityourself",
+ "shop/doors",
+ "shop/electrical",
+ "shop/flooring",
+ "shop/hardware",
+ "shop/hardware_store",
+ "shop/power_tools",
+ "shop/tool_hire",
+ "shop/tools",
+ "shop/trade"
+ ],
+ health_food: [
+ "shop/health",
+ "shop/health_food",
+ "shop/herbalist",
+ "shop/nutrition_supplements"
+ ],
+ hobby: [
+ "shop/electronics",
+ "shop/hobby",
+ "shop/books",
+ "shop/games",
+ "shop/collector",
+ "shop/toys",
+ "shop/model",
+ "shop/video_games",
+ "shop/anime"
+ ],
+ hospital: [
+ "amenity/doctors",
+ "amenity/hospital",
+ "healthcare/hospital"
+ ],
+ houseware: [
+ "shop/houseware",
+ "shop/interior_decoration"
+ ],
+ lifeboat_station: [
+ "amenity/lifeboat_station",
+ "emergency/lifeboat_station",
+ "emergency/marine_rescue"
+ ],
+ lodging: [
+ "tourism/hotel",
+ "tourism/motel"
+ ],
+ money_transfer: [
+ "amenity/money_transfer",
+ "shop/money_transfer"
+ ],
+ office_supplies: [
+ "shop/office_supplies",
+ "shop/stationary",
+ "shop/stationery"
+ ],
+ outdoor: [
+ "shop/clothes",
+ "shop/outdoor",
+ "shop/sports"
+ ],
+ parcel_locker: [
+ "amenity/parcel_locker",
+ "amenity/vending_machine"
+ ],
+ pharmacy: [
+ "amenity/doctors",
+ "amenity/pharmacy",
+ "healthcare/pharmacy"
+ ],
+ playground: [
+ "amenity/theme_park",
+ "leisure/amusement_arcade",
+ "leisure/playground"
+ ],
+ rental: [
+ "amenity/bicycle_rental",
+ "amenity/boat_rental",
+ "amenity/car_rental",
+ "amenity/truck_rental",
+ "amenity/vehicle_rental",
+ "shop/kiosk",
+ "shop/rental"
+ ],
+ school: [
+ "amenity/childcare",
+ "amenity/college",
+ "amenity/kindergarten",
+ "amenity/language_school",
+ "amenity/prep_school",
+ "amenity/school",
+ "amenity/university"
+ ],
+ storage: [
+ "shop/storage_units",
+ "shop/storage_rental"
+ ],
+ substation: [
+ "power/station",
+ "power/substation",
+ "power/sub_station"
+ ],
+ supermarket: [
+ "shop/food",
+ "shop/frozen_food",
+ "shop/greengrocer",
+ "shop/grocery",
+ "shop/supermarket",
+ "shop/wholesale"
+ ],
+ variety_store: [
+ "shop/variety_store",
+ "shop/discount",
+ "shop/convenience"
+ ],
+ vending: [
+ "amenity/vending_machine",
+ "shop/kiosk",
+ "shop/vending_machine"
+ ],
+ weight_loss: [
+ "amenity/clinic",
+ "amenity/doctors",
+ "amenity/weight_clinic",
+ "healthcare/counselling",
+ "leisure/fitness_centre",
+ "office/therapist",
+ "shop/beauty",
+ "shop/diet",
+ "shop/food",
+ "shop/health_food",
+ "shop/herbalist",
+ "shop/nutrition",
+ "shop/nutrition_supplements",
+ "shop/weight_loss"
+ ],
+ wholesale: [
+ "shop/wholesale",
+ "shop/supermarket",
+ "shop/department_store"
+ ]
+ }
+ };
+
+ // node_modules/name-suggestion-index/config/genericWords.json
+ var genericWords_default = {
+ genericWords: [
+ "^(barn|bazaa?r|bench|bou?tique|building|casa|church)$",
+ "^(baseball|basketball|football|soccer|softball|tennis(halle)?)\\s?(field|court)?$",
+ "^(club|green|out|ware)\\s?house$",
+ "^(driveway|el \xE1rbol|fountain|generic|golf|government|graveyard)$",
+ "^(fixme|n\\s?\\/?\\s?a|name|no\\s?name|none|null|temporary|test|unknown)$",
+ "^(hofladen|librairie|magazine?|maison)$",
+ "^(mobile home|skate)?\\s?park$",
+ "^(obuwie|pond|pool|sale|shops?|sklep|stores?)$",
+ "^\\?+$",
+ "^private$",
+ "^tattoo( studio)?$",
+ "^windmill$",
+ "^\u0446\u0435\u0440\u043A\u043E\u0432\u043D\u0430\u044F( \u043B\u0430\u0432\u043A\u0430)?$"
+ ]
+ };
+
+ // node_modules/name-suggestion-index/config/trees.json
+ var trees_default = {
+ trees: {
+ brands: {
+ emoji: "\u{1F354}",
+ mainTag: "brand:wikidata",
+ sourceTags: ["brand", "name"],
+ nameTags: {
+ primary: "^(name|name:\\w+)$",
+ alternate: "^(brand|brand:\\w+|operator|operator:\\w+|\\w+_name|\\w+_name:\\w+)$"
+ }
+ },
+ flags: {
+ emoji: "\u{1F6A9}",
+ mainTag: "flag:wikidata",
+ nameTags: {
+ primary: "^(flag:name|flag:name:\\w+)$",
+ alternate: "^(country|country:\\w+|flag|flag:\\w+|subject|subject:\\w+)$"
+ }
+ },
+ operators: {
+ emoji: "\u{1F4BC}",
+ mainTag: "operator:wikidata",
+ sourceTags: ["operator"],
+ nameTags: {
+ primary: "^(name|name:\\w+|operator|operator:\\w+)$",
+ alternate: "^(brand|brand:\\w+|\\w+_name|\\w+_name:\\w+)$"
+ }
+ },
+ transit: {
+ emoji: "\u{1F687}",
+ mainTag: "network:wikidata",
+ sourceTags: ["network"],
+ nameTags: {
+ primary: "^network$",
+ alternate: "^(operator|operator:\\w+|network:\\w+|\\w+_name|\\w+_name:\\w+)$"
+ }
+ }
+ }
+ };
+
+ // node_modules/name-suggestion-index/lib/matcher.js
+ var matchGroups = matchGroups_default.matchGroups;
+ var trees = trees_default.trees;
+ var Matcher = class {
+ //
+ // `constructor`
+ // initialize the genericWords regexes
+ constructor() {
+ this.matchIndex = void 0;
+ this.genericWords = /* @__PURE__ */ new Map();
+ (genericWords_default.genericWords || []).forEach((s2) => this.genericWords.set(s2, new RegExp(s2, "i")));
+ this.itemLocation = void 0;
+ this.locationSets = void 0;
+ this.locationIndex = void 0;
+ this.warnings = [];
+ }
+ //
+ // `buildMatchIndex()`
+ // Call this to prepare the matcher for use
+ //
+ // `data` needs to be an Object indexed on a 'tree/key/value' path.
+ // (e.g. cache filled by `fileTree.read` or data found in `dist/nsi.json`)
+ // {
+ // 'brands/amenity/bank': { properties: {}, items: [ {}, {}, … ] },
+ // 'brands/amenity/bar': { properties: {}, items: [ {}, {}, … ] },
+ // …
+ // }
+ //
+ buildMatchIndex(data) {
+ const that = this;
+ if (that.matchIndex)
+ return;
+ that.matchIndex = /* @__PURE__ */ new Map();
+ const seenTree = /* @__PURE__ */ new Map();
+ Object.keys(data).forEach((tkv) => {
+ const category = data[tkv];
+ const parts = tkv.split("/", 3);
+ const t2 = parts[0];
+ const k2 = parts[1];
+ const v2 = parts[2];
+ const thiskv = "".concat(k2, "/").concat(v2);
+ const tree = trees[t2];
+ let branch = that.matchIndex.get(thiskv);
+ if (!branch) {
+ branch = {
+ primary: /* @__PURE__ */ new Map(),
+ alternate: /* @__PURE__ */ new Map(),
+ excludeGeneric: /* @__PURE__ */ new Map(),
+ excludeNamed: /* @__PURE__ */ new Map()
+ };
+ that.matchIndex.set(thiskv, branch);
+ }
+ const properties = category.properties || {};
+ const exclude = properties.exclude || {};
+ (exclude.generic || []).forEach((s2) => branch.excludeGeneric.set(s2, new RegExp(s2, "i")));
+ (exclude.named || []).forEach((s2) => branch.excludeNamed.set(s2, new RegExp(s2, "i")));
+ const excludeRegexes = [...branch.excludeGeneric.values(), ...branch.excludeNamed.values()];
+ let items = category.items;
+ if (!Array.isArray(items) || !items.length)
+ return;
+ const primaryName = new RegExp(tree.nameTags.primary, "i");
+ const alternateName = new RegExp(tree.nameTags.alternate, "i");
+ const notName = /:(colou?r|type|forward|backward|left|right|etymology|pronunciation|wikipedia)$/i;
+ const skipGenericKV = skipGenericKVMatches(t2, k2, v2);
+ const genericKV = /* @__PURE__ */ new Set(["".concat(k2, "/yes"), "building/yes"]);
+ const matchGroupKV = /* @__PURE__ */ new Set();
+ Object.values(matchGroups).forEach((matchGroup) => {
+ const inGroup = matchGroup.some((otherkv) => otherkv === thiskv);
+ if (!inGroup)
+ return;
+ matchGroup.forEach((otherkv) => {
+ if (otherkv === thiskv)
+ return;
+ matchGroupKV.add(otherkv);
+ const otherk = otherkv.split("/", 2)[0];
+ genericKV.add("".concat(otherk, "/yes"));
+ });
+ });
+ items.forEach((item) => {
+ if (!item.id)
+ return;
+ if (Array.isArray(item.matchTags) && item.matchTags.length) {
+ item.matchTags = item.matchTags.filter((matchTag) => !matchGroupKV.has(matchTag) && !genericKV.has(matchTag));
+ if (!item.matchTags.length)
+ delete item.matchTags;