{"version":3,"file":"mapbox-gl-draw.js","sources":["../src/lib/mode_handler.js","../node_modules/wgs84/index.js","../node_modules/@mapbox/geojson-area/index.js","../src/constants.js","../src/lib/sort_features.js","../src/lib/map_event_to_bounding_box.js","../src/lib/string_set.js","../src/lib/features_at.js","../src/lib/get_features_and_set_cursor.js","../src/lib/euclidean_distance.js","../src/lib/is_click.js","../src/lib/is_tap.js","../src/lib/id.js","../node_modules/nanoid/non-secure/index.js","../src/feature_types/feature.js","../src/feature_types/point.js","../src/feature_types/line_string.js","../src/feature_types/polygon.js","../src/feature_types/multi_feature.js","../src/modes/mode_interface_accessors.js","../src/modes/mode_interface.js","../src/modes/object_to_mode.js","../src/lib/to_dense_array.js","../src/render.js","../src/store.js","../src/ui.js","../src/setup.js","../src/events.js","../src/lib/theme.js","../src/lib/common_selectors.js","../node_modules/@mapbox/point-geometry/index.js","../src/lib/mouse_event_point.js","../src/lib/create_vertex.js","../src/lib/create_midpoint.js","../src/lib/create_supplementary_points.js","../src/lib/double_click_zoom.js","../src/lib/constrain_feature_movement.js","../src/lib/move_features.js","../src/modes/simple_select.js","../src/modes/direct_select.js","../src/modes/draw_point.js","../src/lib/is_event_at_coordinates.js","../src/modes/draw_polygon.js","../src/modes/draw_line_string.js","../src/modes/index.js","../src/options.js","../node_modules/fast-deep-equal/index.js","../node_modules/@mapbox/geojson-normalize/index.js","../src/lib/string_sets_are_equal.js","../src/api.js","../index.js"],"sourcesContent":["\nconst ModeHandler = function(mode, DrawContext) {\n\n const handlers = {\n drag: [],\n click: [],\n mousemove: [],\n mousedown: [],\n mouseup: [],\n mouseout: [],\n keydown: [],\n keyup: [],\n touchstart: [],\n touchmove: [],\n touchend: [],\n tap: []\n };\n\n const ctx = {\n on(event, selector, fn) {\n if (handlers[event] === undefined) {\n throw new Error(`Invalid event type: ${event}`);\n }\n handlers[event].push({\n selector,\n fn\n });\n },\n render(id) {\n DrawContext.store.featureChanged(id);\n }\n };\n\n const delegate = function (eventName, event) {\n const handles = handlers[eventName];\n let iHandle = handles.length;\n while (iHandle--) {\n const handle = handles[iHandle];\n if (handle.selector(event)) {\n const skipRender = handle.fn.call(ctx, event);\n if (!skipRender) {\n DrawContext.store.render();\n }\n DrawContext.ui.updateMapClasses();\n\n // ensure an event is only handled once\n // we do this to let modes have multiple overlapping selectors\n // and relay on order of oppertations to filter\n break;\n }\n }\n };\n\n mode.start.call(ctx);\n\n return {\n render: mode.render,\n stop() {\n if (mode.stop) mode.stop();\n },\n trash() {\n if (mode.trash) {\n mode.trash();\n DrawContext.store.render();\n }\n },\n combineFeatures() {\n if (mode.combineFeatures) {\n mode.combineFeatures();\n }\n },\n uncombineFeatures() {\n if (mode.uncombineFeatures) {\n mode.uncombineFeatures();\n }\n },\n drag(event) {\n delegate('drag', event);\n },\n click(event) {\n delegate('click', event);\n },\n mousemove(event) {\n delegate('mousemove', event);\n },\n mousedown(event) {\n delegate('mousedown', event);\n },\n mouseup(event) {\n delegate('mouseup', event);\n },\n mouseout(event) {\n delegate('mouseout', event);\n },\n keydown(event) {\n delegate('keydown', event);\n },\n keyup(event) {\n delegate('keyup', event);\n },\n touchstart(event) {\n delegate('touchstart', event);\n },\n touchmove(event) {\n delegate('touchmove', event);\n },\n touchend(event) {\n delegate('touchend', event);\n },\n tap(event) {\n delegate('tap', event);\n }\n };\n};\n\nexport default ModeHandler;\n","module.exports.RADIUS = 6378137;\nmodule.exports.FLATTENING = 1/298.257223563;\nmodule.exports.POLAR_RADIUS = 6356752.3142;\n","var wgs84 = require('wgs84');\n\nmodule.exports.geometry = geometry;\nmodule.exports.ring = ringArea;\n\nfunction geometry(_) {\n var area = 0, i;\n switch (_.type) {\n case 'Polygon':\n return polygonArea(_.coordinates);\n case 'MultiPolygon':\n for (i = 0; i < _.coordinates.length; i++) {\n area += polygonArea(_.coordinates[i]);\n }\n return area;\n case 'Point':\n case 'MultiPoint':\n case 'LineString':\n case 'MultiLineString':\n return 0;\n case 'GeometryCollection':\n for (i = 0; i < _.geometries.length; i++) {\n area += geometry(_.geometries[i]);\n }\n return area;\n }\n}\n\nfunction polygonArea(coords) {\n var area = 0;\n if (coords && coords.length > 0) {\n area += Math.abs(ringArea(coords[0]));\n for (var i = 1; i < coords.length; i++) {\n area -= Math.abs(ringArea(coords[i]));\n }\n }\n return area;\n}\n\n/**\n * Calculate the approximate area of the polygon were it projected onto\n * the earth. Note that this area will be positive if ring is oriented\n * clockwise, otherwise it will be negative.\n *\n * Reference:\n * Robert. G. Chamberlain and William H. Duquette, \"Some Algorithms for\n * Polygons on a Sphere\", JPL Publication 07-03, Jet Propulsion\n * Laboratory, Pasadena, CA, June 2007 http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409\n *\n * Returns:\n * {float} The approximate signed geodesic area of the polygon in square\n * meters.\n */\n\nfunction ringArea(coords) {\n var p1, p2, p3, lowerIndex, middleIndex, upperIndex, i,\n area = 0,\n coordsLength = coords.length;\n\n if (coordsLength > 2) {\n for (i = 0; i < coordsLength; i++) {\n if (i === coordsLength - 2) {// i = N-2\n lowerIndex = coordsLength - 2;\n middleIndex = coordsLength -1;\n upperIndex = 0;\n } else if (i === coordsLength - 1) {// i = N-1\n lowerIndex = coordsLength - 1;\n middleIndex = 0;\n upperIndex = 1;\n } else { // i = 0 to N-3\n lowerIndex = i;\n middleIndex = i+1;\n upperIndex = i+2;\n }\n p1 = coords[lowerIndex];\n p2 = coords[middleIndex];\n p3 = coords[upperIndex];\n area += ( rad(p3[0]) - rad(p1[0]) ) * Math.sin( rad(p2[1]));\n }\n\n area = area * wgs84.RADIUS * wgs84.RADIUS / 2;\n }\n\n return area;\n}\n\nfunction rad(_) {\n return _ * Math.PI / 180;\n}","export const classes = {\n CANVAS: 'mapboxgl-canvas',\n CONTROL_BASE: 'mapboxgl-ctrl',\n CONTROL_PREFIX: 'mapboxgl-ctrl-',\n CONTROL_BUTTON: 'mapbox-gl-draw_ctrl-draw-btn',\n CONTROL_BUTTON_LINE: 'mapbox-gl-draw_line',\n CONTROL_BUTTON_POLYGON: 'mapbox-gl-draw_polygon',\n CONTROL_BUTTON_POINT: 'mapbox-gl-draw_point',\n CONTROL_BUTTON_TRASH: 'mapbox-gl-draw_trash',\n CONTROL_BUTTON_COMBINE_FEATURES: 'mapbox-gl-draw_combine',\n CONTROL_BUTTON_UNCOMBINE_FEATURES: 'mapbox-gl-draw_uncombine',\n CONTROL_GROUP: 'mapboxgl-ctrl-group',\n ATTRIBUTION: 'mapboxgl-ctrl-attrib',\n ACTIVE_BUTTON: 'active',\n BOX_SELECT: 'mapbox-gl-draw_boxselect'\n};\n\nexport const sources = {\n HOT: 'mapbox-gl-draw-hot',\n COLD: 'mapbox-gl-draw-cold'\n};\n\nexport const cursors = {\n ADD: 'add',\n MOVE: 'move',\n DRAG: 'drag',\n POINTER: 'pointer',\n NONE: 'none'\n};\n\nexport const types = {\n POLYGON: 'polygon',\n LINE: 'line_string',\n POINT: 'point'\n};\n\nexport const geojsonTypes = {\n FEATURE: 'Feature',\n POLYGON: 'Polygon',\n LINE_STRING: 'LineString',\n POINT: 'Point',\n FEATURE_COLLECTION: 'FeatureCollection',\n MULTI_PREFIX: 'Multi',\n MULTI_POINT: 'MultiPoint',\n MULTI_LINE_STRING: 'MultiLineString',\n MULTI_POLYGON: 'MultiPolygon'\n};\n\nexport const modes = {\n DRAW_LINE_STRING: 'draw_line_string',\n DRAW_POLYGON: 'draw_polygon',\n DRAW_POINT: 'draw_point',\n SIMPLE_SELECT: 'simple_select',\n DIRECT_SELECT: 'direct_select'\n};\n\nexport const events = {\n CREATE: 'draw.create',\n DELETE: 'draw.delete',\n UPDATE: 'draw.update',\n SELECTION_CHANGE: 'draw.selectionchange',\n MODE_CHANGE: 'draw.modechange',\n ACTIONABLE: 'draw.actionable',\n RENDER: 'draw.render',\n COMBINE_FEATURES: 'draw.combine',\n UNCOMBINE_FEATURES: 'draw.uncombine'\n};\n\nexport const updateActions = {\n MOVE: 'move',\n CHANGE_PROPERTIES: 'change_properties',\n CHANGE_COORDINATES: 'change_coordinates'\n};\n\nexport const meta = {\n FEATURE: 'feature',\n MIDPOINT: 'midpoint',\n VERTEX: 'vertex'\n};\n\nexport const activeStates = {\n ACTIVE: 'true',\n INACTIVE: 'false'\n};\n\nexport const interactions = [\n 'scrollZoom',\n 'boxZoom',\n 'dragRotate',\n 'dragPan',\n 'keyboard',\n 'doubleClickZoom',\n 'touchZoomRotate'\n];\n\nexport const LAT_MIN = -90;\nexport const LAT_RENDERED_MIN = -85;\nexport const LAT_MAX = 90;\nexport const LAT_RENDERED_MAX = 85;\nexport const LNG_MIN = -270;\nexport const LNG_MAX = 270;\n","import area from '@mapbox/geojson-area';\nimport * as Constants from '../constants.js';\n\nconst FEATURE_SORT_RANKS = {\n Point: 0,\n LineString: 1,\n MultiLineString: 1,\n Polygon: 2\n};\n\nfunction comparator(a, b) {\n const score = FEATURE_SORT_RANKS[a.geometry.type] - FEATURE_SORT_RANKS[b.geometry.type];\n\n if (score === 0 && a.geometry.type === Constants.geojsonTypes.POLYGON) {\n return a.area - b.area;\n }\n\n return score;\n}\n\n// Sort in the order above, then sort polygons by area ascending.\nfunction sortFeatures(features) {\n return features.map((feature) => {\n if (feature.geometry.type === Constants.geojsonTypes.POLYGON) {\n feature.area = area.geometry({\n type: Constants.geojsonTypes.FEATURE,\n property: {},\n geometry: feature.geometry\n });\n }\n return feature;\n }).sort(comparator).map((feature) => {\n delete feature.area;\n return feature;\n });\n}\n\nexport default sortFeatures;\n","/**\n * Returns a bounding box representing the event's location.\n *\n * @param {Event} mapEvent - Mapbox GL JS map event, with a point properties.\n * @return {Array>} Bounding box.\n */\nfunction mapEventToBoundingBox(mapEvent, buffer = 0) {\n return [\n [mapEvent.point.x - buffer, mapEvent.point.y - buffer],\n [mapEvent.point.x + buffer, mapEvent.point.y + buffer]\n ];\n}\n\nexport default mapEventToBoundingBox;\n","function StringSet(items) {\n this._items = {};\n this._nums = {};\n this._length = items ? items.length : 0;\n if (!items) return;\n for (let i = 0, l = items.length; i < l; i++) {\n this.add(items[i]);\n if (items[i] === undefined) continue;\n if (typeof items[i] === 'string') this._items[items[i]] = i;\n else this._nums[items[i]] = i;\n\n }\n}\n\nStringSet.prototype.add = function(x) {\n if (this.has(x)) return this;\n this._length++;\n if (typeof x === 'string') this._items[x] = this._length;\n else this._nums[x] = this._length;\n return this;\n};\n\nStringSet.prototype.delete = function(x) {\n if (this.has(x) === false) return this;\n this._length--;\n delete this._items[x];\n delete this._nums[x];\n return this;\n};\n\nStringSet.prototype.has = function(x) {\n if (typeof x !== 'string' && typeof x !== 'number') return false;\n return this._items[x] !== undefined || this._nums[x] !== undefined;\n};\n\nStringSet.prototype.values = function() {\n const values = [];\n Object.keys(this._items).forEach((k) => {\n values.push({ k, v: this._items[k] });\n });\n Object.keys(this._nums).forEach((k) => {\n values.push({ k: JSON.parse(k), v: this._nums[k] });\n });\n\n return values.sort((a, b) => a.v - b.v).map(a => a.k);\n};\n\nStringSet.prototype.clear = function() {\n this._length = 0;\n this._items = {};\n this._nums = {};\n return this;\n};\n\nexport default StringSet;\n","import sortFeatures from './sort_features.js';\nimport mapEventToBoundingBox from './map_event_to_bounding_box.js';\nimport * as Constants from '../constants.js';\nimport StringSet from './string_set.js';\n\nconst META_TYPES = [\n Constants.meta.FEATURE,\n Constants.meta.MIDPOINT,\n Constants.meta.VERTEX\n];\n\n// Requires either event or bbox\nexport default {\n click: featuresAtClick,\n touch: featuresAtTouch\n};\n\nfunction featuresAtClick(event, bbox, ctx) {\n return featuresAt(event, bbox, ctx, ctx.options.clickBuffer);\n}\n\nfunction featuresAtTouch(event, bbox, ctx) {\n return featuresAt(event, bbox, ctx, ctx.options.touchBuffer);\n}\n\nfunction featuresAt(event, bbox, ctx, buffer) {\n if (ctx.map === null) return [];\n\n const box = (event) ? mapEventToBoundingBox(event, buffer) : bbox;\n\n const queryParams = {};\n\n if (ctx.options.styles) queryParams.layers = ctx.options.styles.map(s => s.id).filter(id => ctx.map.getLayer(id) != null);\n\n const features = ctx.map.queryRenderedFeatures(box, queryParams)\n .filter(feature => META_TYPES.indexOf(feature.properties.meta) !== -1);\n\n const featureIds = new StringSet();\n const uniqueFeatures = [];\n features.forEach((feature) => {\n const featureId = feature.properties.id;\n if (featureIds.has(featureId)) return;\n featureIds.add(featureId);\n uniqueFeatures.push(feature);\n });\n\n return sortFeatures(uniqueFeatures);\n}\n","import featuresAt from './features_at.js';\nimport * as Constants from '../constants.js';\n\nexport default function getFeatureAtAndSetCursors(event, ctx) {\n const features = featuresAt.click(event, null, ctx);\n const classes = { mouse: Constants.cursors.NONE };\n\n if (features[0]) {\n classes.mouse = (features[0].properties.active === Constants.activeStates.ACTIVE) ?\n Constants.cursors.MOVE : Constants.cursors.POINTER;\n classes.feature = features[0].properties.meta;\n }\n\n if (ctx.events.currentModeName().indexOf('draw') !== -1) {\n classes.mouse = Constants.cursors.ADD;\n }\n\n ctx.ui.queueMapClasses(classes);\n ctx.ui.updateMapClasses();\n\n return features[0];\n}\n","export default function(a, b) {\n const x = a.x - b.x;\n const y = a.y - b.y;\n return Math.sqrt((x * x) + (y * y));\n}\n","import euclideanDistance from './euclidean_distance.js';\n\nconst FINE_TOLERANCE = 4;\nconst GROSS_TOLERANCE = 12;\nconst INTERVAL = 500;\n\nexport default function isClick(start, end, options = {}) {\n const fineTolerance = (options.fineTolerance != null) ? options.fineTolerance : FINE_TOLERANCE;\n const grossTolerance = (options.grossTolerance != null) ? options.grossTolerance : GROSS_TOLERANCE;\n const interval = (options.interval != null) ? options.interval : INTERVAL;\n\n start.point = start.point || end.point;\n start.time = start.time || end.time;\n const moveDistance = euclideanDistance(start.point, end.point);\n\n return moveDistance < fineTolerance ||\n (moveDistance < grossTolerance && (end.time - start.time) < interval);\n}\n","import euclideanDistance from './euclidean_distance.js';\n\nexport const TAP_TOLERANCE = 25;\nexport const TAP_INTERVAL = 250;\n\nexport default function isTap(start, end, options = {}) {\n const tolerance = (options.tolerance != null) ? options.tolerance : TAP_TOLERANCE;\n const interval = (options.interval != null) ? options.interval : TAP_INTERVAL;\n\n start.point = start.point || end.point;\n start.time = start.time || end.time;\n const moveDistance = euclideanDistance(start.point, end.point);\n\n return moveDistance < tolerance && (end.time - start.time) < interval;\n}\n","import {customAlphabet} from 'nanoid/non-secure';\n\nconst nanoid = customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 32);\n\nexport function generateID() {\n return nanoid();\n}\n","let urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\nexport let customAlphabet = (alphabet, defaultSize = 21) => {\n return (size = defaultSize) => {\n let id = ''\n let i = size | 0\n while (i--) {\n id += alphabet[(Math.random() * alphabet.length) | 0]\n }\n return id\n }\n}\nexport let nanoid = (size = 21) => {\n let id = ''\n let i = size | 0\n while (i--) {\n id += urlAlphabet[(Math.random() * 64) | 0]\n }\n return id\n}\n","import {generateID} from '../lib/id.js';\nimport * as Constants from '../constants.js';\n\nconst Feature = function(ctx, geojson) {\n this.ctx = ctx;\n this.properties = geojson.properties || {};\n this.coordinates = geojson.geometry.coordinates;\n this.id = geojson.id || generateID();\n this.type = geojson.geometry.type;\n};\n\nFeature.prototype.changed = function() {\n this.ctx.store.featureChanged(this.id);\n};\n\nFeature.prototype.incomingCoords = function(coords) {\n this.setCoordinates(coords);\n};\n\nFeature.prototype.setCoordinates = function(coords) {\n this.coordinates = coords;\n this.changed();\n};\n\nFeature.prototype.getCoordinates = function() {\n return JSON.parse(JSON.stringify(this.coordinates));\n};\n\nFeature.prototype.setProperty = function(property, value) {\n this.properties[property] = value;\n};\n\nFeature.prototype.toGeoJSON = function() {\n return JSON.parse(JSON.stringify({\n id: this.id,\n type: Constants.geojsonTypes.FEATURE,\n properties: this.properties,\n geometry: {\n coordinates: this.getCoordinates(),\n type: this.type\n }\n }));\n};\n\nFeature.prototype.internal = function(mode) {\n const properties = {\n id: this.id,\n meta: Constants.meta.FEATURE,\n 'meta:type': this.type,\n active: Constants.activeStates.INACTIVE,\n mode\n };\n\n if (this.ctx.options.userProperties) {\n for (const name in this.properties) {\n properties[`user_${name}`] = this.properties[name];\n }\n }\n\n return {\n type: Constants.geojsonTypes.FEATURE,\n properties,\n geometry: {\n coordinates: this.getCoordinates(),\n type: this.type\n }\n };\n};\n\nexport default Feature;\n","import Feature from './feature.js';\n\nconst Point = function(ctx, geojson) {\n Feature.call(this, ctx, geojson);\n};\n\nPoint.prototype = Object.create(Feature.prototype);\n\nPoint.prototype.isValid = function() {\n return typeof this.coordinates[0] === 'number' &&\n typeof this.coordinates[1] === 'number';\n};\n\nPoint.prototype.updateCoordinate = function(pathOrLng, lngOrLat, lat) {\n if (arguments.length === 3) {\n this.coordinates = [lngOrLat, lat];\n } else {\n this.coordinates = [pathOrLng, lngOrLat];\n }\n this.changed();\n};\n\nPoint.prototype.getCoordinate = function() {\n return this.getCoordinates();\n};\n\nexport default Point;\n","import Feature from './feature.js';\n\nconst LineString = function(ctx, geojson) {\n Feature.call(this, ctx, geojson);\n};\n\nLineString.prototype = Object.create(Feature.prototype);\n\nLineString.prototype.isValid = function() {\n return this.coordinates.length > 1;\n};\n\nLineString.prototype.addCoordinate = function(path, lng, lat) {\n this.changed();\n const id = parseInt(path, 10);\n this.coordinates.splice(id, 0, [lng, lat]);\n};\n\nLineString.prototype.getCoordinate = function(path) {\n const id = parseInt(path, 10);\n return JSON.parse(JSON.stringify(this.coordinates[id]));\n};\n\nLineString.prototype.removeCoordinate = function(path) {\n this.changed();\n this.coordinates.splice(parseInt(path, 10), 1);\n};\n\nLineString.prototype.updateCoordinate = function(path, lng, lat) {\n const id = parseInt(path, 10);\n this.coordinates[id] = [lng, lat];\n this.changed();\n};\n\nexport default LineString;\n","import Feature from './feature.js';\n\nconst Polygon = function(ctx, geojson) {\n Feature.call(this, ctx, geojson);\n this.coordinates = this.coordinates.map(ring => ring.slice(0, -1));\n};\n\nPolygon.prototype = Object.create(Feature.prototype);\n\nPolygon.prototype.isValid = function() {\n if (this.coordinates.length === 0) return false;\n return this.coordinates.every(ring => ring.length > 2);\n};\n\n// Expects valid geoJSON polygon geometry: first and last positions must be equivalent.\nPolygon.prototype.incomingCoords = function(coords) {\n this.coordinates = coords.map(ring => ring.slice(0, -1));\n this.changed();\n};\n\n// Does NOT expect valid geoJSON polygon geometry: first and last positions should not be equivalent.\nPolygon.prototype.setCoordinates = function(coords) {\n this.coordinates = coords;\n this.changed();\n};\n\nPolygon.prototype.addCoordinate = function(path, lng, lat) {\n this.changed();\n const ids = path.split('.').map(x => parseInt(x, 10));\n\n const ring = this.coordinates[ids[0]];\n\n ring.splice(ids[1], 0, [lng, lat]);\n};\n\nPolygon.prototype.removeCoordinate = function(path) {\n this.changed();\n const ids = path.split('.').map(x => parseInt(x, 10));\n const ring = this.coordinates[ids[0]];\n if (ring) {\n ring.splice(ids[1], 1);\n if (ring.length < 3) {\n this.coordinates.splice(ids[0], 1);\n }\n }\n};\n\nPolygon.prototype.getCoordinate = function(path) {\n const ids = path.split('.').map(x => parseInt(x, 10));\n const ring = this.coordinates[ids[0]];\n return JSON.parse(JSON.stringify(ring[ids[1]]));\n};\n\nPolygon.prototype.getCoordinates = function() {\n return this.coordinates.map(coords => coords.concat([coords[0]]));\n};\n\nPolygon.prototype.updateCoordinate = function(path, lng, lat) {\n this.changed();\n const parts = path.split('.');\n const ringId = parseInt(parts[0], 10);\n const coordId = parseInt(parts[1], 10);\n\n if (this.coordinates[ringId] === undefined) {\n this.coordinates[ringId] = [];\n }\n\n this.coordinates[ringId][coordId] = [lng, lat];\n};\n\nexport default Polygon;\n","import {generateID} from '../lib/id.js';\nimport Feature from './feature.js';\nimport * as Constants from '../constants.js';\n\nimport MultiPoint from './point.js';\nimport MultiLineString from './line_string.js';\nimport MultiPolygon from './polygon.js';\n\nconst models = {\n MultiPoint,\n MultiLineString,\n MultiPolygon\n};\n\nconst takeAction = (features, action, path, lng, lat) => {\n const parts = path.split('.');\n const idx = parseInt(parts[0], 10);\n const tail = (!parts[1]) ? null : parts.slice(1).join('.');\n return features[idx][action](tail, lng, lat);\n};\n\nconst MultiFeature = function(ctx, geojson) {\n Feature.call(this, ctx, geojson);\n\n delete this.coordinates;\n this.model = models[geojson.geometry.type];\n if (this.model === undefined) throw new TypeError(`${geojson.geometry.type} is not a valid type`);\n this.features = this._coordinatesToFeatures(geojson.geometry.coordinates);\n};\n\nMultiFeature.prototype = Object.create(Feature.prototype);\n\nMultiFeature.prototype._coordinatesToFeatures = function(coordinates) {\n const Model = this.model.bind(this);\n return coordinates.map(coords => new Model(this.ctx, {\n id: generateID(),\n type: Constants.geojsonTypes.FEATURE,\n properties: {},\n geometry: {\n coordinates: coords,\n type: this.type.replace('Multi', '')\n }\n }));\n};\n\nMultiFeature.prototype.isValid = function() {\n return this.features.every(f => f.isValid());\n};\n\nMultiFeature.prototype.setCoordinates = function(coords) {\n this.features = this._coordinatesToFeatures(coords);\n this.changed();\n};\n\nMultiFeature.prototype.getCoordinate = function(path) {\n return takeAction(this.features, 'getCoordinate', path);\n};\n\nMultiFeature.prototype.getCoordinates = function() {\n return JSON.parse(JSON.stringify(this.features.map((f) => {\n if (f.type === Constants.geojsonTypes.POLYGON) return f.getCoordinates();\n return f.coordinates;\n })));\n};\n\nMultiFeature.prototype.updateCoordinate = function(path, lng, lat) {\n takeAction(this.features, 'updateCoordinate', path, lng, lat);\n this.changed();\n};\n\nMultiFeature.prototype.addCoordinate = function(path, lng, lat) {\n takeAction(this.features, 'addCoordinate', path, lng, lat);\n this.changed();\n};\n\nMultiFeature.prototype.removeCoordinate = function(path) {\n takeAction(this.features, 'removeCoordinate', path);\n this.changed();\n};\n\nMultiFeature.prototype.getFeatures = function() {\n return this.features;\n};\n\nexport default MultiFeature;\n","import * as Constants from '../constants.js';\nimport featuresAt from '../lib/features_at.js';\nimport Point from '../feature_types/point.js';\nimport LineString from '../feature_types/line_string.js';\nimport Polygon from '../feature_types/polygon.js';\nimport MultiFeature from '../feature_types/multi_feature.js';\n\nexport default function ModeInterface(ctx) {\n this.map = ctx.map;\n this.drawConfig = JSON.parse(JSON.stringify(ctx.options || {}));\n this._ctx = ctx;\n}\n\n/**\n * Sets Draw's interal selected state\n * @name this.setSelected\n * @param {DrawFeature[]} - whats selected as a [DrawFeature](https://github.com/mapbox/mapbox-gl-draw/blob/main/src/feature_types/feature.js)\n */\nModeInterface.prototype.setSelected = function(features) {\n return this._ctx.store.setSelected(features);\n};\n\n/**\n * Sets Draw's internal selected coordinate state\n * @name this.setSelectedCoordinates\n * @param {Object[]} coords - a array of {coord_path: 'string', feature_id: 'string'}\n */\nModeInterface.prototype.setSelectedCoordinates = function(coords) {\n this._ctx.store.setSelectedCoordinates(coords);\n coords.reduce((m, c) => {\n if (m[c.feature_id] === undefined) {\n m[c.feature_id] = true;\n this._ctx.store.get(c.feature_id).changed();\n }\n return m;\n }, {});\n};\n\n/**\n * Get all selected features as a [DrawFeature](https://github.com/mapbox/mapbox-gl-draw/blob/main/src/feature_types/feature.js)\n * @name this.getSelected\n * @returns {DrawFeature[]}\n */\nModeInterface.prototype.getSelected = function() {\n return this._ctx.store.getSelected();\n};\n\n/**\n * Get the ids of all currently selected features\n * @name this.getSelectedIds\n * @returns {String[]}\n */\nModeInterface.prototype.getSelectedIds = function() {\n return this._ctx.store.getSelectedIds();\n};\n\n/**\n * Check if a feature is selected\n * @name this.isSelected\n * @param {String} id - a feature id\n * @returns {Boolean}\n */\nModeInterface.prototype.isSelected = function(id) {\n return this._ctx.store.isSelected(id);\n};\n\n/**\n * Get a [DrawFeature](https://github.com/mapbox/mapbox-gl-draw/blob/main/src/feature_types/feature.js) by its id\n * @name this.getFeature\n * @param {String} id - a feature id\n * @returns {DrawFeature}\n */\nModeInterface.prototype.getFeature = function(id) {\n return this._ctx.store.get(id);\n};\n\n/**\n * Add a feature to draw's internal selected state\n * @name this.select\n * @param {String} id\n */\nModeInterface.prototype.select = function(id) {\n return this._ctx.store.select(id);\n};\n\n/**\n * Remove a feature from draw's internal selected state\n * @name this.delete\n * @param {String} id\n */\nModeInterface.prototype.deselect = function(id) {\n return this._ctx.store.deselect(id);\n};\n\n/**\n * Delete a feature from draw\n * @name this.deleteFeature\n * @param {String} id - a feature id\n */\nModeInterface.prototype.deleteFeature = function(id, opts = {}) {\n return this._ctx.store.delete(id, opts);\n};\n\n/**\n * Add a [DrawFeature](https://github.com/mapbox/mapbox-gl-draw/blob/main/src/feature_types/feature.js) to draw.\n * See `this.newFeature` for converting geojson into a DrawFeature\n * @name this.addFeature\n * @param {DrawFeature} feature - the feature to add\n */\nModeInterface.prototype.addFeature = function(feature, opts = {}) {\n return this._ctx.store.add(feature, opts);\n};\n\n/**\n * Clear all selected features\n */\nModeInterface.prototype.clearSelectedFeatures = function() {\n return this._ctx.store.clearSelected();\n};\n\n/**\n * Clear all selected coordinates\n */\nModeInterface.prototype.clearSelectedCoordinates = function() {\n return this._ctx.store.clearSelectedCoordinates();\n};\n\n/**\n * Indicate if the different action are currently possible with your mode\n * See [draw.actionalbe](https://github.com/mapbox/mapbox-gl-draw/blob/main/API.md#drawactionable) for a list of possible actions. All undefined actions are set to **false** by default\n * @name this.setActionableState\n * @param {Object} actions\n */\nModeInterface.prototype.setActionableState = function(actions = {}) {\n const newSet = {\n trash: actions.trash || false,\n combineFeatures: actions.combineFeatures || false,\n uncombineFeatures: actions.uncombineFeatures || false\n };\n return this._ctx.events.actionable(newSet);\n};\n\n/**\n * Trigger a mode change\n * @name this.changeMode\n * @param {String} mode - the mode to transition into\n * @param {Object} opts - the options object to pass to the new mode\n * @param {Object} eventOpts - used to control what kind of events are emitted.\n */\nModeInterface.prototype.changeMode = function(mode, opts = {}, eventOpts = {}) {\n return this._ctx.events.changeMode(mode, opts, eventOpts);\n};\n\n/**\n * Fire a map event\n * @name this.fire\n * @param {String} eventName - the event name.\n * @param {Object} eventData - the event data object.\n */\nModeInterface.prototype.fire = function(eventName, eventData) {\n return this._ctx.events.fire(eventName, eventData);\n};\n\n/**\n * Update the state of draw map classes\n * @name this.updateUIClasses\n * @param {Object} opts\n */\nModeInterface.prototype.updateUIClasses = function(opts) {\n return this._ctx.ui.queueMapClasses(opts);\n};\n\n/**\n * If a name is provided it makes that button active, else if makes all buttons inactive\n * @name this.activateUIButton\n * @param {String?} name - name of the button to make active, leave as undefined to set buttons to be inactive\n */\nModeInterface.prototype.activateUIButton = function(name) {\n return this._ctx.ui.setActiveButton(name);\n};\n\n/**\n * Get the features at the location of an event object or in a bbox\n * @name this.featuresAt\n * @param {Event||NULL} event - a mapbox-gl event object\n * @param {BBOX||NULL} bbox - the area to get features from\n * @param {String} bufferType - is this `click` or `tap` event, defaults to click\n */\nModeInterface.prototype.featuresAt = function(event, bbox, bufferType = 'click') {\n if (bufferType !== 'click' && bufferType !== 'touch') throw new Error('invalid buffer type');\n return featuresAt[bufferType](event, bbox, this._ctx);\n};\n\n/**\n * Create a new [DrawFeature](https://github.com/mapbox/mapbox-gl-draw/blob/main/src/feature_types/feature.js) from geojson\n * @name this.newFeature\n * @param {GeoJSONFeature} geojson\n * @returns {DrawFeature}\n */\nModeInterface.prototype.newFeature = function(geojson) {\n const type = geojson.geometry.type;\n if (type === Constants.geojsonTypes.POINT) return new Point(this._ctx, geojson);\n if (type === Constants.geojsonTypes.LINE_STRING) return new LineString(this._ctx, geojson);\n if (type === Constants.geojsonTypes.POLYGON) return new Polygon(this._ctx, geojson);\n return new MultiFeature(this._ctx, geojson);\n};\n\n/**\n * Check is an object is an instance of a [DrawFeature](https://github.com/mapbox/mapbox-gl-draw/blob/main/src/feature_types/feature.js)\n * @name this.isInstanceOf\n * @param {String} type - `Point`, `LineString`, `Polygon`, `MultiFeature`\n * @param {Object} feature - the object that needs to be checked\n * @returns {Boolean}\n */\nModeInterface.prototype.isInstanceOf = function(type, feature) {\n if (type === Constants.geojsonTypes.POINT) return feature instanceof Point;\n if (type === Constants.geojsonTypes.LINE_STRING) return feature instanceof LineString;\n if (type === Constants.geojsonTypes.POLYGON) return feature instanceof Polygon;\n if (type === 'MultiFeature') return feature instanceof MultiFeature;\n throw new Error(`Unknown feature class: ${type}`);\n};\n\n/**\n * Force draw to rerender the feature of the provided id\n * @name this.doRender\n * @param {String} id - a feature id\n */\nModeInterface.prototype.doRender = function(id) {\n return this._ctx.store.featureChanged(id);\n};\n\n","import ModeInterface from './mode_interface_accessors.js';\nexport default ModeInterface;\n\n/**\n * Triggered while a mode is being transitioned into.\n * @param opts {Object} - this is the object passed via `draw.changeMode('mode', opts)`;\n * @name MODE.onSetup\n * @returns {Object} - this object will be passed to all other life cycle functions\n */\nModeInterface.prototype.onSetup = function() {};\n\n/**\n * Triggered when a drag event is detected on the map\n * @name MODE.onDrag\n * @param state {Object} - a mutible state object created by onSetup\n * @param e {Object} - the captured event that is triggering this life cycle event\n */\nModeInterface.prototype.onDrag = function() {};\n\n/**\n * Triggered when the mouse is clicked\n * @name MODE.onClick\n * @param state {Object} - a mutible state object created by onSetup\n * @param e {Object} - the captured event that is triggering this life cycle event\n */\nModeInterface.prototype.onClick = function() {};\n\n/**\n * Triggered with the mouse is moved\n * @name MODE.onMouseMove\n * @param state {Object} - a mutible state object created by onSetup\n * @param e {Object} - the captured event that is triggering this life cycle event\n */\nModeInterface.prototype.onMouseMove = function() {};\n\n/**\n * Triggered when the mouse button is pressed down\n * @name MODE.onMouseDown\n * @param state {Object} - a mutible state object created by onSetup\n * @param e {Object} - the captured event that is triggering this life cycle event\n */\nModeInterface.prototype.onMouseDown = function() {};\n\n/**\n * Triggered when the mouse button is released\n * @name MODE.onMouseUp\n * @param state {Object} - a mutible state object created by onSetup\n * @param e {Object} - the captured event that is triggering this life cycle event\n */\nModeInterface.prototype.onMouseUp = function() {};\n\n/**\n * Triggered when the mouse leaves the map's container\n * @name MODE.onMouseOut\n * @param state {Object} - a mutible state object created by onSetup\n * @param e {Object} - the captured event that is triggering this life cycle event\n */\nModeInterface.prototype.onMouseOut = function() {};\n\n/**\n * Triggered when a key up event is detected\n * @name MODE.onKeyUp\n * @param state {Object} - a mutible state object created by onSetup\n * @param e {Object} - the captured event that is triggering this life cycle event\n */\nModeInterface.prototype.onKeyUp = function() {};\n\n/**\n * Triggered when a key down event is detected\n * @name MODE.onKeyDown\n * @param state {Object} - a mutible state object created by onSetup\n * @param e {Object} - the captured event that is triggering this life cycle event\n */\nModeInterface.prototype.onKeyDown = function() {};\n\n/**\n * Triggered when a touch event is started\n * @name MODE.onTouchStart\n * @param state {Object} - a mutible state object created by onSetup\n * @param e {Object} - the captured event that is triggering this life cycle event\n */\nModeInterface.prototype.onTouchStart = function() {};\n\n/**\n * Triggered when one drags thier finger on a mobile device\n * @name MODE.onTouchMove\n * @param state {Object} - a mutible state object created by onSetup\n * @param e {Object} - the captured event that is triggering this life cycle event\n */\nModeInterface.prototype.onTouchMove = function() {};\n\n/**\n * Triggered when one removes their finger from the map\n * @name MODE.onTouchEnd\n * @param state {Object} - a mutible state object created by onSetup\n * @param e {Object} - the captured event that is triggering this life cycle event\n */\nModeInterface.prototype.onTouchEnd = function() {};\n\n/**\n * Triggered when one quicly taps the map\n * @name MODE.onTap\n * @param state {Object} - a mutible state object created by onSetup\n * @param e {Object} - the captured event that is triggering this life cycle event\n */\nModeInterface.prototype.onTap = function() {};\n\n/**\n * Triggered when the mode is being exited, to be used for cleaning up artifacts such as invalid features\n * @name MODE.onStop\n * @param state {Object} - a mutible state object created by onSetup\n */\nModeInterface.prototype.onStop = function() {};\n\n/**\n * Triggered when [draw.trash()](https://github.com/mapbox/mapbox-gl-draw/blob/main/API.md#trash-draw) is called.\n * @name MODE.onTrash\n * @param state {Object} - a mutible state object created by onSetup\n */\nModeInterface.prototype.onTrash = function() {};\n\n/**\n * Triggered when [draw.combineFeatures()](https://github.com/mapbox/mapbox-gl-draw/blob/main/API.md#combinefeatures-draw) is called.\n * @name MODE.onCombineFeature\n * @param state {Object} - a mutible state object created by onSetup\n */\nModeInterface.prototype.onCombineFeature = function() {};\n\n/**\n * Triggered when [draw.uncombineFeatures()](https://github.com/mapbox/mapbox-gl-draw/blob/main/API.md#uncombinefeatures-draw) is called.\n * @name MODE.onUncombineFeature\n * @param state {Object} - a mutible state object created by onSetup\n */\nModeInterface.prototype.onUncombineFeature = function() {};\n\n/**\n * Triggered per feature on render to convert raw features into set of features for display on the map\n * See [styling draw](https://github.com/mapbox/mapbox-gl-draw/blob/main/API.md#styling-draw) for information about what geojson properties Draw uses as part of rendering.\n * @name MODE.toDisplayFeatures\n * @param state {Object} - a mutible state object created by onSetup\n * @param geojson {Object} - a geojson being evaulated. To render, pass to `display`.\n * @param display {Function} - all geojson objects passed to this be rendered onto the map\n */\nModeInterface.prototype.toDisplayFeatures = function() {\n throw new Error('You must overwrite toDisplayFeatures');\n};\n\n","import ModeInterface from './mode_interface.js';\n\nconst eventMapper = {\n drag: 'onDrag',\n click: 'onClick',\n mousemove: 'onMouseMove',\n mousedown: 'onMouseDown',\n mouseup: 'onMouseUp',\n mouseout: 'onMouseOut',\n keyup: 'onKeyUp',\n keydown: 'onKeyDown',\n touchstart: 'onTouchStart',\n touchmove: 'onTouchMove',\n touchend: 'onTouchEnd',\n tap: 'onTap'\n};\n\nconst eventKeys = Object.keys(eventMapper);\n\nexport default function(modeObject) {\n const modeObjectKeys = Object.keys(modeObject);\n\n return function(ctx, startOpts = {}) {\n let state = {};\n\n const mode = modeObjectKeys.reduce((m, k) => {\n m[k] = modeObject[k];\n return m;\n }, new ModeInterface(ctx));\n\n function wrapper(eh) {\n return e => mode[eh](state, e);\n }\n\n return {\n start() {\n state = mode.onSetup(startOpts); // this should set ui buttons\n\n // Adds event handlers for all event options\n // add sets the selector to false for all\n // handlers that are not present in the mode\n // to reduce on render calls for functions that\n // have no logic\n eventKeys.forEach((key) => {\n const modeHandler = eventMapper[key];\n let selector = () => false;\n if (modeObject[modeHandler]) {\n selector = () => true;\n }\n this.on(key, selector, wrapper(modeHandler));\n });\n\n },\n stop() {\n mode.onStop(state);\n },\n trash() {\n mode.onTrash(state);\n },\n combineFeatures() {\n mode.onCombineFeatures(state);\n },\n uncombineFeatures() {\n mode.onUncombineFeatures(state);\n },\n render(geojson, push) {\n mode.toDisplayFeatures(state, geojson, push);\n }\n };\n };\n}\n","/**\n * Derive a dense array (no `undefined`s) from a single value or array.\n *\n * @param {any} x\n * @return {Array}\n */\nfunction toDenseArray(x) {\n return [].concat(x).filter(y => y !== undefined);\n}\n\nexport default toDenseArray;\n","import * as Constants from './constants.js';\n\nexport default function render() {\n // eslint-disable-next-line no-invalid-this\n const store = this;\n const mapExists = store.ctx.map && store.ctx.map.getSource(Constants.sources.HOT) !== undefined;\n if (!mapExists) return cleanup();\n\n const mode = store.ctx.events.currentModeName();\n\n store.ctx.ui.queueMapClasses({ mode });\n\n let newHotIds = [];\n let newColdIds = [];\n\n if (store.isDirty) {\n newColdIds = store.getAllIds();\n } else {\n newHotIds = store.getChangedIds().filter(id => store.get(id) !== undefined);\n newColdIds = store.sources.hot.filter(geojson => geojson.properties.id && newHotIds.indexOf(geojson.properties.id) === -1 && store.get(geojson.properties.id) !== undefined).map(geojson => geojson.properties.id);\n }\n\n store.sources.hot = [];\n const lastColdCount = store.sources.cold.length;\n store.sources.cold = store.isDirty ? [] : store.sources.cold.filter((geojson) => {\n const id = geojson.properties.id || geojson.properties.parent;\n return newHotIds.indexOf(id) === -1;\n });\n\n const coldChanged = lastColdCount !== store.sources.cold.length || newColdIds.length > 0;\n newHotIds.forEach(id => renderFeature(id, 'hot'));\n newColdIds.forEach(id => renderFeature(id, 'cold'));\n\n function renderFeature(id, source) {\n const feature = store.get(id);\n const featureInternal = feature.internal(mode);\n store.ctx.events.currentModeRender(featureInternal, (geojson) => {\n geojson.properties.mode = mode;\n store.sources[source].push(geojson);\n });\n }\n\n if (coldChanged) {\n store.ctx.map.getSource(Constants.sources.COLD).setData({\n type: Constants.geojsonTypes.FEATURE_COLLECTION,\n features: store.sources.cold\n });\n }\n\n store.ctx.map.getSource(Constants.sources.HOT).setData({\n type: Constants.geojsonTypes.FEATURE_COLLECTION,\n features: store.sources.hot\n });\n\n cleanup();\n\n function cleanup() {\n store.isDirty = false;\n store.clearChangedIds();\n }\n}\n","import toDenseArray from './lib/to_dense_array.js';\nimport StringSet from './lib/string_set.js';\nimport render from './render.js';\nimport * as Constants from './constants.js';\n\nexport default function Store(ctx) {\n this._features = {};\n this._featureIds = new StringSet();\n this._selectedFeatureIds = new StringSet();\n this._selectedCoordinates = [];\n this._changedFeatureIds = new StringSet();\n this._emitSelectionChange = false;\n this._mapInitialConfig = {};\n this.ctx = ctx;\n this.sources = {\n hot: [],\n cold: []\n };\n\n // Deduplicate requests to render and tie them to animation frames.\n let renderRequest;\n this.render = () => {\n if (!renderRequest) {\n renderRequest = requestAnimationFrame(() => {\n renderRequest = null;\n render.call(this);\n\n // Fire deduplicated selection change event\n if (this._emitSelectionChange) {\n this.ctx.events.fire(Constants.events.SELECTION_CHANGE, {\n features: this.getSelected().map(feature => feature.toGeoJSON()),\n points: this.getSelectedCoordinates().map(coordinate => ({\n type: Constants.geojsonTypes.FEATURE,\n properties: {},\n geometry: {\n type: Constants.geojsonTypes.POINT,\n coordinates: coordinate.coordinates\n }\n }))\n });\n\n this._emitSelectionChange = false;\n }\n\n // Fire render event\n this.ctx.events.fire(Constants.events.RENDER, {});\n });\n }\n };\n\n this.isDirty = false;\n}\n\n/**\n * Delays all rendering until the returned function is invoked\n * @return {Function} renderBatch\n */\nStore.prototype.createRenderBatch = function() {\n const holdRender = this.render;\n let numRenders = 0;\n this.render = function() {\n numRenders++;\n };\n\n return () => {\n this.render = holdRender;\n if (numRenders > 0) {\n this.render();\n }\n };\n};\n\n/**\n * Sets the store's state to dirty.\n * @return {Store} this\n */\nStore.prototype.setDirty = function() {\n this.isDirty = true;\n return this;\n};\n\n/**\n * Sets a feature's state to changed.\n * @param {string} featureId\n * @return {Store} this\n */\nStore.prototype.featureCreated = function(featureId, options = {}) {\n this._changedFeatureIds.add(featureId);\n\n const silent = options.silent != null ? options.silent : this.ctx.options.suppressAPIEvents;\n if (silent !== true) {\n const feature = this.get(featureId);\n this.ctx.events.fire(Constants.events.CREATE, {\n features: [feature.toGeoJSON()]\n });\n }\n\n return this;\n};\n\n/**\n * Sets a feature's state to changed.\n * @param {string} featureId\n * @return {Store} this\n */\nStore.prototype.featureChanged = function(featureId, options = {}) {\n this._changedFeatureIds.add(featureId);\n\n const silent = options.silent != null ? options.silent : this.ctx.options.suppressAPIEvents;\n if (silent !== true) {\n this.ctx.events.fire(Constants.events.UPDATE, {\n action: options.action ? options.action : Constants.updateActions.CHANGE_COORDINATES,\n features: [this.get(featureId).toGeoJSON()]\n });\n }\n\n return this;\n};\n\n/**\n * Gets the ids of all features currently in changed state.\n * @return {Store} this\n */\nStore.prototype.getChangedIds = function() {\n return this._changedFeatureIds.values();\n};\n\n/**\n * Sets all features to unchanged state.\n * @return {Store} this\n */\nStore.prototype.clearChangedIds = function() {\n this._changedFeatureIds.clear();\n return this;\n};\n\n/**\n * Gets the ids of all features in the store.\n * @return {Store} this\n */\nStore.prototype.getAllIds = function() {\n return this._featureIds.values();\n};\n\n/**\n * Adds a feature to the store.\n * @param {Object} feature\n * @param {Object} [options]\n * @param {Object} [options.silent] - If `true`, this invocation will not fire an event.\n *\n * @return {Store} this\n */\nStore.prototype.add = function(feature, options = {}) {\n this._features[feature.id] = feature;\n this._featureIds.add(feature.id);\n this.featureCreated(feature.id, {silent: options.silent});\n return this;\n};\n\n/**\n * Deletes a feature or array of features from the store.\n * Cleans up after the deletion by deselecting the features.\n * If changes were made, sets the state to the dirty\n * and fires an event.\n * @param {string | Array} featureIds\n * @param {Object} [options]\n * @param {Object} [options.silent] - If `true`, this invocation will not fire an event.\n * @return {Store} this\n */\nStore.prototype.delete = function(featureIds, options = {}) {\n const deletedFeaturesToEmit = [];\n toDenseArray(featureIds).forEach((id) => {\n if (!this._featureIds.has(id)) return;\n this._featureIds.delete(id);\n this._selectedFeatureIds.delete(id);\n if (!options.silent) {\n if (deletedFeaturesToEmit.indexOf(this._features[id]) === -1) {\n deletedFeaturesToEmit.push(this._features[id].toGeoJSON());\n }\n }\n delete this._features[id];\n this.isDirty = true;\n });\n\n if (deletedFeaturesToEmit.length) {\n this.ctx.events.fire(Constants.events.DELETE, {features: deletedFeaturesToEmit});\n }\n\n refreshSelectedCoordinates(this, options);\n return this;\n};\n\n/**\n * Returns a feature in the store matching the specified value.\n * @return {Object | undefined} feature\n */\nStore.prototype.get = function(id) {\n return this._features[id];\n};\n\n/**\n * Returns all features in the store.\n * @return {Array}\n */\nStore.prototype.getAll = function() {\n return Object.keys(this._features).map(id => this._features[id]);\n};\n\n/**\n * Adds features to the current selection.\n * @param {string | Array} featureIds\n * @param {Object} [options]\n * @param {Object} [options.silent] - If `true`, this invocation will not fire an event.\n * @return {Store} this\n */\nStore.prototype.select = function(featureIds, options = {}) {\n toDenseArray(featureIds).forEach((id) => {\n if (this._selectedFeatureIds.has(id)) return;\n this._selectedFeatureIds.add(id);\n this._changedFeatureIds.add(id);\n if (!options.silent) {\n this._emitSelectionChange = true;\n }\n });\n return this;\n};\n\n/**\n * Deletes features from the current selection.\n * @param {string | Array} featureIds\n * @param {Object} [options]\n * @param {Object} [options.silent] - If `true`, this invocation will not fire an event.\n * @return {Store} this\n */\nStore.prototype.deselect = function(featureIds, options = {}) {\n toDenseArray(featureIds).forEach((id) => {\n if (!this._selectedFeatureIds.has(id)) return;\n this._selectedFeatureIds.delete(id);\n this._changedFeatureIds.add(id);\n if (!options.silent) {\n this._emitSelectionChange = true;\n }\n });\n refreshSelectedCoordinates(this, options);\n return this;\n};\n\n/**\n * Clears the current selection.\n * @param {Object} [options]\n * @param {Object} [options.silent] - If `true`, this invocation will not fire an event.\n * @return {Store} this\n */\nStore.prototype.clearSelected = function(options = {}) {\n this.deselect(this._selectedFeatureIds.values(), { silent: options.silent });\n return this;\n};\n\n/**\n * Sets the store's selection, clearing any prior values.\n * If no feature ids are passed, the store is just cleared.\n * @param {string | Array | undefined} featureIds\n * @param {Object} [options]\n * @param {Object} [options.silent] - If `true`, this invocation will not fire an event.\n * @return {Store} this\n */\nStore.prototype.setSelected = function(featureIds, options = {}) {\n featureIds = toDenseArray(featureIds);\n\n // Deselect any features not in the new selection\n this.deselect(this._selectedFeatureIds.values().filter(id => featureIds.indexOf(id) === -1), { silent: options.silent });\n\n // Select any features in the new selection that were not already selected\n this.select(featureIds.filter(id => !this._selectedFeatureIds.has(id)), { silent: options.silent });\n\n return this;\n};\n\n/**\n * Sets the store's coordinates selection, clearing any prior values.\n * @param {Array>} coordinates\n * @return {Store} this\n */\nStore.prototype.setSelectedCoordinates = function(coordinates) {\n this._selectedCoordinates = coordinates;\n this._emitSelectionChange = true;\n return this;\n};\n\n/**\n * Clears the current coordinates selection.\n * @param {Object} [options]\n * @return {Store} this\n */\nStore.prototype.clearSelectedCoordinates = function() {\n this._selectedCoordinates = [];\n this._emitSelectionChange = true;\n return this;\n};\n\n/**\n * Returns the ids of features in the current selection.\n * @return {Array} Selected feature ids.\n */\nStore.prototype.getSelectedIds = function() {\n return this._selectedFeatureIds.values();\n};\n\n/**\n * Returns features in the current selection.\n * @return {Array} Selected features.\n */\nStore.prototype.getSelected = function() {\n return this.getSelectedIds().map(id => this.get(id));\n};\n\n/**\n * Returns selected coordinates in the currently selected feature.\n * @return {Array} Selected coordinates.\n */\nStore.prototype.getSelectedCoordinates = function() {\n const selected = this._selectedCoordinates.map((coordinate) => {\n const feature = this.get(coordinate.feature_id);\n return {\n coordinates: feature.getCoordinate(coordinate.coord_path)\n };\n });\n return selected;\n};\n\n/**\n * Indicates whether a feature is selected.\n * @param {string} featureId\n * @return {boolean} `true` if the feature is selected, `false` if not.\n */\nStore.prototype.isSelected = function(featureId) {\n return this._selectedFeatureIds.has(featureId);\n};\n\n/**\n * Sets a property on the given feature\n * @param {string} featureId\n * @param {string} property property\n * @param {string} property value\n * @param {Object} [options]\n * @param {Object} [options.silent] - If `true`, this invocation will not fire an event.\n*/\nStore.prototype.setFeatureProperty = function(featureId, property, value, options = {}) {\n this.get(featureId).setProperty(property, value);\n\n this.featureChanged(featureId, {\n silent: options.silent,\n action: Constants.updateActions.CHANGE_PROPERTIES\n });\n};\n\nfunction refreshSelectedCoordinates(store, options = {}) {\n const newSelectedCoordinates = store._selectedCoordinates.filter(point => store._selectedFeatureIds.has(point.feature_id));\n if (store._selectedCoordinates.length !== newSelectedCoordinates.length && !options.silent) {\n store._emitSelectionChange = true;\n }\n store._selectedCoordinates = newSelectedCoordinates;\n}\n\n/**\n * Stores the initial config for a map, so that we can set it again after we're done.\n*/\nStore.prototype.storeMapConfig = function() {\n Constants.interactions.forEach((interaction) => {\n const interactionSet = this.ctx.map[interaction];\n if (interactionSet) {\n this._mapInitialConfig[interaction] = this.ctx.map[interaction].isEnabled();\n }\n });\n};\n\n/**\n * Restores the initial config for a map, ensuring all is well.\n*/\nStore.prototype.restoreMapConfig = function() {\n Object.keys(this._mapInitialConfig).forEach((key) => {\n const value = this._mapInitialConfig[key];\n if (value) {\n this.ctx.map[key].enable();\n } else {\n this.ctx.map[key].disable();\n }\n });\n};\n\n/**\n * Returns the initial state of an interaction setting.\n * @param {string} interaction\n * @return {boolean} `true` if the interaction is enabled, `false` if not.\n * Defaults to `true`. (Todo: include defaults.)\n*/\nStore.prototype.getInitialConfigValue = function(interaction) {\n if (this._mapInitialConfig[interaction] !== undefined) {\n return this._mapInitialConfig[interaction];\n } else {\n // This needs to be set to whatever the default is for that interaction\n // It seems to be true for all cases currently, so let's send back `true`.\n return true;\n }\n};\n","import * as Constants from './constants.js';\n\nconst classTypes = ['mode', 'feature', 'mouse'];\n\nexport default function(ctx) {\n\n\n const buttonElements = {};\n let activeButton = null;\n\n let currentMapClasses = {\n mode: null, // e.g. mode-direct_select\n feature: null, // e.g. feature-vertex\n mouse: null // e.g. mouse-move\n };\n\n let nextMapClasses = {\n mode: null,\n feature: null,\n mouse: null\n };\n\n function clearMapClasses() {\n queueMapClasses({mode:null, feature:null, mouse:null});\n updateMapClasses();\n }\n\n function queueMapClasses(options) {\n nextMapClasses = Object.assign(nextMapClasses, options);\n }\n\n function updateMapClasses() {\n if (!ctx.container) return;\n\n const classesToRemove = [];\n const classesToAdd = [];\n\n classTypes.forEach((type) => {\n if (nextMapClasses[type] === currentMapClasses[type]) return;\n\n classesToRemove.push(`${type}-${currentMapClasses[type]}`);\n if (nextMapClasses[type] !== null) {\n classesToAdd.push(`${type}-${nextMapClasses[type]}`);\n }\n });\n\n if (classesToRemove.length > 0) {\n ctx.container.classList.remove(...classesToRemove);\n }\n\n if (classesToAdd.length > 0) {\n ctx.container.classList.add(...classesToAdd);\n }\n\n currentMapClasses = Object.assign(currentMapClasses, nextMapClasses);\n }\n\n function createControlButton(id, options = {}) {\n const button = document.createElement('button');\n button.className = `${Constants.classes.CONTROL_BUTTON} ${options.className}`;\n button.setAttribute('title', options.title);\n options.container.appendChild(button);\n\n button.addEventListener('click', (e) => {\n e.preventDefault();\n e.stopPropagation();\n\n const clickedButton = e.target;\n if (clickedButton === activeButton) {\n deactivateButtons();\n options.onDeactivate();\n return;\n }\n\n setActiveButton(id);\n options.onActivate();\n }, true);\n\n return button;\n }\n\n function deactivateButtons() {\n if (!activeButton) return;\n activeButton.classList.remove(Constants.classes.ACTIVE_BUTTON);\n activeButton = null;\n }\n\n function setActiveButton(id) {\n deactivateButtons();\n\n const button = buttonElements[id];\n if (!button) return;\n\n if (button && id !== 'trash') {\n button.classList.add(Constants.classes.ACTIVE_BUTTON);\n activeButton = button;\n }\n }\n\n function addButtons() {\n const controls = ctx.options.controls;\n const controlGroup = document.createElement('div');\n controlGroup.className = `${Constants.classes.CONTROL_GROUP} ${Constants.classes.CONTROL_BASE}`;\n\n if (!controls) return controlGroup;\n\n if (controls[Constants.types.LINE]) {\n buttonElements[Constants.types.LINE] = createControlButton(Constants.types.LINE, {\n container: controlGroup,\n className: Constants.classes.CONTROL_BUTTON_LINE,\n title: `LineString tool ${ctx.options.keybindings ? '(l)' : ''}`,\n onActivate: () => ctx.events.changeMode(Constants.modes.DRAW_LINE_STRING),\n onDeactivate: () => ctx.events.trash()\n });\n }\n\n if (controls[Constants.types.POLYGON]) {\n buttonElements[Constants.types.POLYGON] = createControlButton(Constants.types.POLYGON, {\n container: controlGroup,\n className: Constants.classes.CONTROL_BUTTON_POLYGON,\n title: `Polygon tool ${ctx.options.keybindings ? '(p)' : ''}`,\n onActivate: () => ctx.events.changeMode(Constants.modes.DRAW_POLYGON),\n onDeactivate: () => ctx.events.trash()\n });\n }\n\n if (controls[Constants.types.POINT]) {\n buttonElements[Constants.types.POINT] = createControlButton(Constants.types.POINT, {\n container: controlGroup,\n className: Constants.classes.CONTROL_BUTTON_POINT,\n title: `Marker tool ${ctx.options.keybindings ? '(m)' : ''}`,\n onActivate: () => ctx.events.changeMode(Constants.modes.DRAW_POINT),\n onDeactivate: () => ctx.events.trash()\n });\n }\n\n if (controls.trash) {\n buttonElements.trash = createControlButton('trash', {\n container: controlGroup,\n className: Constants.classes.CONTROL_BUTTON_TRASH,\n title: 'Delete',\n onActivate: () => {\n ctx.events.trash();\n }\n });\n }\n\n if (controls.combine_features) {\n buttonElements.combine_features = createControlButton('combineFeatures', {\n container: controlGroup,\n className: Constants.classes.CONTROL_BUTTON_COMBINE_FEATURES,\n title: 'Combine',\n onActivate: () => {\n ctx.events.combineFeatures();\n }\n });\n }\n\n if (controls.uncombine_features) {\n buttonElements.uncombine_features = createControlButton('uncombineFeatures', {\n container: controlGroup,\n className: Constants.classes.CONTROL_BUTTON_UNCOMBINE_FEATURES,\n title: 'Uncombine',\n onActivate: () => {\n ctx.events.uncombineFeatures();\n }\n });\n }\n\n return controlGroup;\n }\n\n function removeButtons() {\n Object.keys(buttonElements).forEach((buttonId) => {\n const button = buttonElements[buttonId];\n if (button.parentNode) {\n button.parentNode.removeChild(button);\n }\n delete buttonElements[buttonId];\n });\n }\n\n return {\n setActiveButton,\n queueMapClasses,\n updateMapClasses,\n clearMapClasses,\n addButtons,\n removeButtons\n };\n}\n","import events from './events.js';\nimport Store from './store.js';\nimport ui from './ui.js';\nimport * as Constants from './constants.js';\n\nexport default function(ctx) {\n\n let controlContainer = null;\n let mapLoadedInterval = null;\n\n const setup = {\n onRemove() {\n // Stop connect attempt in the event that control is removed before map is loaded\n ctx.map.off('load', setup.connect);\n clearInterval(mapLoadedInterval);\n\n setup.removeLayers();\n ctx.store.restoreMapConfig();\n ctx.ui.removeButtons();\n ctx.events.removeEventListeners();\n ctx.ui.clearMapClasses();\n if (ctx.boxZoomInitial) ctx.map.boxZoom.enable();\n ctx.map = null;\n ctx.container = null;\n ctx.store = null;\n\n if (controlContainer && controlContainer.parentNode) controlContainer.parentNode.removeChild(controlContainer);\n controlContainer = null;\n\n return this;\n },\n connect() {\n ctx.map.off('load', setup.connect);\n clearInterval(mapLoadedInterval);\n setup.addLayers();\n ctx.store.storeMapConfig();\n ctx.events.addEventListeners();\n },\n onAdd(map) {\n ctx.map = map;\n ctx.events = events(ctx);\n ctx.ui = ui(ctx);\n ctx.container = map.getContainer();\n ctx.store = new Store(ctx);\n\n\n controlContainer = ctx.ui.addButtons();\n\n if (ctx.options.boxSelect) {\n ctx.boxZoomInitial = map.boxZoom.isEnabled();\n map.boxZoom.disable();\n const dragPanIsEnabled = map.dragPan.isEnabled();\n // Need to toggle dragPan on and off or else first\n // dragPan disable attempt in simple_select doesn't work\n map.dragPan.disable();\n map.dragPan.enable();\n if (!dragPanIsEnabled) {\n map.dragPan.disable();\n }\n }\n\n if (map.loaded()) {\n setup.connect();\n } else {\n map.on('load', setup.connect);\n mapLoadedInterval = setInterval(() => { if (map.loaded()) setup.connect(); }, 16);\n }\n\n ctx.events.start();\n return controlContainer;\n },\n addLayers() {\n // drawn features style\n ctx.map.addSource(Constants.sources.COLD, {\n data: {\n type: Constants.geojsonTypes.FEATURE_COLLECTION,\n features: []\n },\n type: 'geojson'\n });\n\n // hot features style\n ctx.map.addSource(Constants.sources.HOT, {\n data: {\n type: Constants.geojsonTypes.FEATURE_COLLECTION,\n features: []\n },\n type: 'geojson'\n });\n\n ctx.options.styles.forEach((style) => {\n ctx.map.addLayer(style);\n });\n\n ctx.store.setDirty(true);\n ctx.store.render();\n },\n // Check for layers and sources before attempting to remove\n // If user adds draw control and removes it before the map is loaded, layers and sources will be missing\n removeLayers() {\n ctx.options.styles.forEach((style) => {\n if (ctx.map.getLayer(style.id)) {\n ctx.map.removeLayer(style.id);\n }\n });\n\n if (ctx.map.getSource(Constants.sources.COLD)) {\n ctx.map.removeSource(Constants.sources.COLD);\n }\n\n if (ctx.map.getSource(Constants.sources.HOT)) {\n ctx.map.removeSource(Constants.sources.HOT);\n }\n }\n };\n\n ctx.setup = setup;\n\n return setup;\n}\n","import setupModeHandler from './lib/mode_handler.js';\nimport getFeaturesAndSetCursor from './lib/get_features_and_set_cursor.js';\nimport featuresAt from './lib/features_at.js';\nimport isClick from './lib/is_click.js';\nimport isTap from './lib/is_tap.js';\nimport * as Constants from './constants.js';\nimport objectToMode from './modes/object_to_mode.js';\n\nexport default function(ctx) {\n\n const modes = Object.keys(ctx.options.modes).reduce((m, k) => {\n m[k] = objectToMode(ctx.options.modes[k]);\n return m;\n }, {});\n\n let mouseDownInfo = {};\n let touchStartInfo = {};\n const events = {};\n let currentModeName = null;\n let currentMode = null;\n\n events.drag = function(event, isDrag) {\n if (isDrag({\n point: event.point,\n time: new Date().getTime()\n })) {\n ctx.ui.queueMapClasses({ mouse: Constants.cursors.DRAG });\n currentMode.drag(event);\n } else {\n event.originalEvent.stopPropagation();\n }\n };\n\n events.mousedrag = function(event) {\n events.drag(event, endInfo => !isClick(mouseDownInfo, endInfo));\n };\n\n events.touchdrag = function(event) {\n events.drag(event, endInfo => !isTap(touchStartInfo, endInfo));\n };\n\n events.mousemove = function(event) {\n const button = event.originalEvent.buttons !== undefined ? event.originalEvent.buttons : event.originalEvent.which;\n if (button === 1) {\n return events.mousedrag(event);\n }\n const target = getFeaturesAndSetCursor(event, ctx);\n event.featureTarget = target;\n currentMode.mousemove(event);\n };\n\n events.mousedown = function(event) {\n mouseDownInfo = {\n time: new Date().getTime(),\n point: event.point\n };\n const target = getFeaturesAndSetCursor(event, ctx);\n event.featureTarget = target;\n currentMode.mousedown(event);\n };\n\n events.mouseup = function(event) {\n const target = getFeaturesAndSetCursor(event, ctx);\n event.featureTarget = target;\n\n if (isClick(mouseDownInfo, {\n point: event.point,\n time: new Date().getTime()\n })) {\n currentMode.click(event);\n } else {\n currentMode.mouseup(event);\n }\n };\n\n events.mouseout = function(event) {\n currentMode.mouseout(event);\n };\n\n events.touchstart = function(event) {\n if (!ctx.options.touchEnabled) {\n return;\n }\n\n touchStartInfo = {\n time: new Date().getTime(),\n point: event.point\n };\n const target = featuresAt.touch(event, null, ctx)[0];\n event.featureTarget = target;\n currentMode.touchstart(event);\n };\n\n events.touchmove = function(event) {\n if (!ctx.options.touchEnabled) {\n return;\n }\n\n currentMode.touchmove(event);\n return events.touchdrag(event);\n };\n\n events.touchend = function(event) {\n // Prevent emulated mouse events because we will fully handle the touch here.\n // This does not stop the touch events from propogating to mapbox though.\n event.originalEvent.preventDefault();\n if (!ctx.options.touchEnabled) {\n return;\n }\n\n const target = featuresAt.touch(event, null, ctx)[0];\n event.featureTarget = target;\n if (isTap(touchStartInfo, {\n time: new Date().getTime(),\n point: event.point\n })) {\n currentMode.tap(event);\n } else {\n currentMode.touchend(event);\n }\n };\n\n // 8 - Backspace\n // 46 - Delete\n const isKeyModeValid = code => !(code === 8 || code === 46 || (code >= 48 && code <= 57));\n\n events.keydown = function(event) {\n const isMapElement = (event.srcElement || event.target).classList.contains(Constants.classes.CANVAS);\n if (!isMapElement) return; // we only handle events on the map\n\n if ((event.keyCode === 8 || event.keyCode === 46) && ctx.options.controls.trash) {\n event.preventDefault();\n currentMode.trash();\n } else if (isKeyModeValid(event.keyCode)) {\n currentMode.keydown(event);\n } else if (event.keyCode === 49 && ctx.options.controls.point) {\n changeMode(Constants.modes.DRAW_POINT);\n } else if (event.keyCode === 50 && ctx.options.controls.line_string) {\n changeMode(Constants.modes.DRAW_LINE_STRING);\n } else if (event.keyCode === 51 && ctx.options.controls.polygon) {\n changeMode(Constants.modes.DRAW_POLYGON);\n }\n };\n\n events.keyup = function(event) {\n if (isKeyModeValid(event.keyCode)) {\n currentMode.keyup(event);\n }\n };\n\n events.zoomend = function() {\n ctx.store.changeZoom();\n };\n\n events.data = function(event) {\n if (event.dataType === 'style') {\n const { setup, map, options, store } = ctx;\n const hasLayers = options.styles.some(style => map.getLayer(style.id));\n if (!hasLayers) {\n setup.addLayers();\n store.setDirty();\n store.render();\n }\n }\n };\n\n function changeMode(modename, nextModeOptions, eventOptions = {}) {\n currentMode.stop();\n\n const modebuilder = modes[modename];\n if (modebuilder === undefined) {\n throw new Error(`${modename} is not valid`);\n }\n currentModeName = modename;\n const mode = modebuilder(ctx, nextModeOptions);\n currentMode = setupModeHandler(mode, ctx);\n\n if (!eventOptions.silent) {\n ctx.map.fire(Constants.events.MODE_CHANGE, { mode: modename});\n }\n\n ctx.store.setDirty();\n ctx.store.render();\n }\n\n const actionState = {\n trash: false,\n combineFeatures: false,\n uncombineFeatures: false\n };\n\n function actionable(actions) {\n let changed = false;\n Object.keys(actions).forEach((action) => {\n if (actionState[action] === undefined) throw new Error('Invalid action type');\n if (actionState[action] !== actions[action]) changed = true;\n actionState[action] = actions[action];\n });\n if (changed) ctx.map.fire(Constants.events.ACTIONABLE, { actions: actionState });\n }\n\n const api = {\n start() {\n currentModeName = ctx.options.defaultMode;\n currentMode = setupModeHandler(modes[currentModeName](ctx), ctx);\n },\n changeMode,\n actionable,\n currentModeName() {\n return currentModeName;\n },\n currentModeRender(geojson, push) {\n return currentMode.render(geojson, push);\n },\n fire(eventName, eventData) {\n if (!ctx.map) return;\n ctx.map.fire(eventName, eventData);\n },\n addEventListeners() {\n ctx.map.on('mousemove', events.mousemove);\n ctx.map.on('mousedown', events.mousedown);\n ctx.map.on('mouseup', events.mouseup);\n ctx.map.on('data', events.data);\n\n ctx.map.on('touchmove', events.touchmove);\n ctx.map.on('touchstart', events.touchstart);\n ctx.map.on('touchend', events.touchend);\n\n ctx.container.addEventListener('mouseout', events.mouseout);\n\n if (ctx.options.keybindings) {\n ctx.container.addEventListener('keydown', events.keydown);\n ctx.container.addEventListener('keyup', events.keyup);\n }\n },\n removeEventListeners() {\n ctx.map.off('mousemove', events.mousemove);\n ctx.map.off('mousedown', events.mousedown);\n ctx.map.off('mouseup', events.mouseup);\n ctx.map.off('data', events.data);\n\n ctx.map.off('touchmove', events.touchmove);\n ctx.map.off('touchstart', events.touchstart);\n ctx.map.off('touchend', events.touchend);\n\n ctx.container.removeEventListener('mouseout', events.mouseout);\n\n if (ctx.options.keybindings) {\n ctx.container.removeEventListener('keydown', events.keydown);\n ctx.container.removeEventListener('keyup', events.keyup);\n }\n },\n trash(options) {\n currentMode.trash(options);\n },\n combineFeatures() {\n currentMode.combineFeatures();\n },\n uncombineFeatures() {\n currentMode.uncombineFeatures();\n },\n getMode() {\n return currentModeName;\n }\n };\n\n return api;\n}\n","/* eslint comma-dangle: [\"error\", \"always-multiline\"] */\n\nconst blue = '#3bb2d0';\nconst orange = '#fbb03b';\nconst white = '#fff';\n\nexport default [\n // Polygons\n // Solid fill\n // Active state defines color\n {\n 'id': 'gl-draw-polygon-fill',\n 'type': 'fill',\n 'filter': [\n 'all',\n ['==', '$type', 'Polygon'],\n ],\n 'paint': {\n 'fill-color': [\n 'case',\n ['==', ['get', 'active'], 'true'], orange,\n blue,\n ],\n 'fill-opacity': 0.1,\n },\n },\n // Lines\n // Polygon\n // Matches Lines AND Polygons\n // Active state defines color\n {\n 'id': 'gl-draw-lines',\n 'type': 'line',\n 'filter': [\n 'any',\n ['==', '$type', 'LineString'],\n ['==', '$type', 'Polygon'],\n ],\n 'layout': {\n 'line-cap': 'round',\n 'line-join': 'round',\n },\n 'paint': {\n 'line-color': [\n 'case',\n ['==', ['get', 'active'], 'true'], orange,\n blue,\n ],\n 'line-dasharray': [\n 'case',\n ['==', ['get', 'active'], 'true'], [0.2, 2],\n [2, 0],\n ],\n 'line-width': 2,\n },\n },\n // Points\n // Circle with an outline\n // Active state defines size and color\n {\n 'id': 'gl-draw-point-outer',\n 'type': 'circle',\n 'filter': [\n 'all',\n ['==', '$type', 'Point'],\n ['==', 'meta', 'feature'],\n ],\n 'paint': {\n 'circle-radius': [\n 'case',\n ['==', ['get', 'active'], 'true'], 7,\n 5,\n ],\n 'circle-color': white,\n },\n },\n {\n 'id': 'gl-draw-point-inner',\n 'type': 'circle',\n 'filter': [\n 'all',\n ['==', '$type', 'Point'],\n ['==', 'meta', 'feature'],\n ],\n 'paint': {\n 'circle-radius': [\n 'case',\n ['==', ['get', 'active'], 'true'], 5,\n 3,\n ],\n 'circle-color': [\n 'case',\n ['==', ['get', 'active'], 'true'], orange,\n blue,\n ],\n },\n },\n // Vertex\n // Visible when editing polygons and lines\n // Similar behaviour to Points\n // Active state defines size\n {\n 'id': 'gl-draw-vertex-outer',\n 'type': 'circle',\n 'filter': [\n 'all',\n ['==', '$type', 'Point'],\n ['==', 'meta', 'vertex'],\n ['!=', 'mode', 'simple_select'],\n ],\n 'paint': {\n 'circle-radius': [\n 'case',\n ['==', ['get', 'active'], 'true'], 7,\n 5,\n ],\n 'circle-color': white,\n },\n },\n {\n 'id': 'gl-draw-vertex-inner',\n 'type': 'circle',\n 'filter': [\n 'all',\n ['==', '$type', 'Point'],\n ['==', 'meta', 'vertex'],\n ['!=', 'mode', 'simple_select'],\n ],\n 'paint': {\n 'circle-radius': [\n 'case',\n ['==', ['get', 'active'], 'true'], 5,\n 3,\n ],\n 'circle-color': orange,\n },\n },\n // Midpoint\n // Visible when editing polygons and lines\n // Tapping or dragging them adds a new vertex to the feature\n {\n 'id': 'gl-draw-midpoint',\n 'type': 'circle',\n 'filter': [\n 'all',\n ['==', 'meta', 'midpoint'],\n ],\n 'paint': {\n 'circle-radius': 3,\n 'circle-color': orange,\n },\n },\n];\n","import * as Constants from '../constants.js';\n\nexport function isOfMetaType(type) {\n return function(e) {\n const featureTarget = e.featureTarget;\n if (!featureTarget) return false;\n if (!featureTarget.properties) return false;\n return featureTarget.properties.meta === type;\n };\n}\n\nexport function isShiftMousedown(e) {\n if (!e.originalEvent) return false;\n if (!e.originalEvent.shiftKey) return false;\n return e.originalEvent.button === 0;\n}\n\nexport function isActiveFeature(e) {\n if (!e.featureTarget) return false;\n if (!e.featureTarget.properties) return false;\n return e.featureTarget.properties.active === Constants.activeStates.ACTIVE &&\n e.featureTarget.properties.meta === Constants.meta.FEATURE;\n}\n\nexport function isInactiveFeature(e) {\n if (!e.featureTarget) return false;\n if (!e.featureTarget.properties) return false;\n return e.featureTarget.properties.active === Constants.activeStates.INACTIVE &&\n e.featureTarget.properties.meta === Constants.meta.FEATURE;\n}\n\nexport function noTarget(e) {\n return e.featureTarget === undefined;\n}\n\nexport function isFeature(e) {\n if (!e.featureTarget) return false;\n if (!e.featureTarget.properties) return false;\n return e.featureTarget.properties.meta === Constants.meta.FEATURE;\n}\n\nexport function isVertex(e) {\n const featureTarget = e.featureTarget;\n if (!featureTarget) return false;\n if (!featureTarget.properties) return false;\n return featureTarget.properties.meta === Constants.meta.VERTEX;\n}\n\nexport function isShiftDown(e) {\n if (!e.originalEvent) return false;\n return e.originalEvent.shiftKey === true;\n}\n\nexport function isEscapeKey(e) {\n return e.keyCode === 27;\n}\n\nexport function isEnterKey(e) {\n return e.keyCode === 13;\n}\n\nexport function isTrue() {\n return true;\n}\n","/**\n * A standalone point geometry with useful accessor, comparison, and\n * modification methods.\n *\n * @class\n * @param {number} x the x-coordinate. This could be longitude or screen pixels, or any other sort of unit.\n * @param {number} y the y-coordinate. This could be latitude or screen pixels, or any other sort of unit.\n *\n * @example\n * const point = new Point(-77, 38);\n */\nexport default function Point(x, y) {\n this.x = x;\n this.y = y;\n}\n\nPoint.prototype = {\n /**\n * Clone this point, returning a new point that can be modified\n * without affecting the old one.\n * @return {Point} the clone\n */\n clone() { return new Point(this.x, this.y); },\n\n /**\n * Add this point's x & y coordinates to another point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n add(p) { return this.clone()._add(p); },\n\n /**\n * Subtract this point's x & y coordinates to from point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n sub(p) { return this.clone()._sub(p); },\n\n /**\n * Multiply this point's x & y coordinates by point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n multByPoint(p) { return this.clone()._multByPoint(p); },\n\n /**\n * Divide this point's x & y coordinates by point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n divByPoint(p) { return this.clone()._divByPoint(p); },\n\n /**\n * Multiply this point's x & y coordinates by a factor,\n * yielding a new point.\n * @param {number} k factor\n * @return {Point} output point\n */\n mult(k) { return this.clone()._mult(k); },\n\n /**\n * Divide this point's x & y coordinates by a factor,\n * yielding a new point.\n * @param {number} k factor\n * @return {Point} output point\n */\n div(k) { return this.clone()._div(k); },\n\n /**\n * Rotate this point around the 0, 0 origin by an angle a,\n * given in radians\n * @param {number} a angle to rotate around, in radians\n * @return {Point} output point\n */\n rotate(a) { return this.clone()._rotate(a); },\n\n /**\n * Rotate this point around p point by an angle a,\n * given in radians\n * @param {number} a angle to rotate around, in radians\n * @param {Point} p Point to rotate around\n * @return {Point} output point\n */\n rotateAround(a, p) { return this.clone()._rotateAround(a, p); },\n\n /**\n * Multiply this point by a 4x1 transformation matrix\n * @param {[number, number, number, number]} m transformation matrix\n * @return {Point} output point\n */\n matMult(m) { return this.clone()._matMult(m); },\n\n /**\n * Calculate this point but as a unit vector from 0, 0, meaning\n * that the distance from the resulting point to the 0, 0\n * coordinate will be equal to 1 and the angle from the resulting\n * point to the 0, 0 coordinate will be the same as before.\n * @return {Point} unit vector point\n */\n unit() { return this.clone()._unit(); },\n\n /**\n * Compute a perpendicular point, where the new y coordinate\n * is the old x coordinate and the new x coordinate is the old y\n * coordinate multiplied by -1\n * @return {Point} perpendicular point\n */\n perp() { return this.clone()._perp(); },\n\n /**\n * Return a version of this point with the x & y coordinates\n * rounded to integers.\n * @return {Point} rounded point\n */\n round() { return this.clone()._round(); },\n\n /**\n * Return the magnitude of this point: this is the Euclidean\n * distance from the 0, 0 coordinate to this point's x and y\n * coordinates.\n * @return {number} magnitude\n */\n mag() {\n return Math.sqrt(this.x * this.x + this.y * this.y);\n },\n\n /**\n * Judge whether this point is equal to another point, returning\n * true or false.\n * @param {Point} other the other point\n * @return {boolean} whether the points are equal\n */\n equals(other) {\n return this.x === other.x &&\n this.y === other.y;\n },\n\n /**\n * Calculate the distance from this point to another point\n * @param {Point} p the other point\n * @return {number} distance\n */\n dist(p) {\n return Math.sqrt(this.distSqr(p));\n },\n\n /**\n * Calculate the distance from this point to another point,\n * without the square root step. Useful if you're comparing\n * relative distances.\n * @param {Point} p the other point\n * @return {number} distance\n */\n distSqr(p) {\n const dx = p.x - this.x,\n dy = p.y - this.y;\n return dx * dx + dy * dy;\n },\n\n /**\n * Get the angle from the 0, 0 coordinate to this point, in radians\n * coordinates.\n * @return {number} angle\n */\n angle() {\n return Math.atan2(this.y, this.x);\n },\n\n /**\n * Get the angle from this point to another point, in radians\n * @param {Point} b the other point\n * @return {number} angle\n */\n angleTo(b) {\n return Math.atan2(this.y - b.y, this.x - b.x);\n },\n\n /**\n * Get the angle between this point and another point, in radians\n * @param {Point} b the other point\n * @return {number} angle\n */\n angleWith(b) {\n return this.angleWithSep(b.x, b.y);\n },\n\n /**\n * Find the angle of the two vectors, solving the formula for\n * the cross product a x b = |a||b|sin(θ) for θ.\n * @param {number} x the x-coordinate\n * @param {number} y the y-coordinate\n * @return {number} the angle in radians\n */\n angleWithSep(x, y) {\n return Math.atan2(\n this.x * y - this.y * x,\n this.x * x + this.y * y);\n },\n\n /** @param {[number, number, number, number]} m */\n _matMult(m) {\n const x = m[0] * this.x + m[1] * this.y,\n y = m[2] * this.x + m[3] * this.y;\n this.x = x;\n this.y = y;\n return this;\n },\n\n /** @param {Point} p */\n _add(p) {\n this.x += p.x;\n this.y += p.y;\n return this;\n },\n\n /** @param {Point} p */\n _sub(p) {\n this.x -= p.x;\n this.y -= p.y;\n return this;\n },\n\n /** @param {number} k */\n _mult(k) {\n this.x *= k;\n this.y *= k;\n return this;\n },\n\n /** @param {number} k */\n _div(k) {\n this.x /= k;\n this.y /= k;\n return this;\n },\n\n /** @param {Point} p */\n _multByPoint(p) {\n this.x *= p.x;\n this.y *= p.y;\n return this;\n },\n\n /** @param {Point} p */\n _divByPoint(p) {\n this.x /= p.x;\n this.y /= p.y;\n return this;\n },\n\n _unit() {\n this._div(this.mag());\n return this;\n },\n\n _perp() {\n const y = this.y;\n this.y = this.x;\n this.x = -y;\n return this;\n },\n\n /** @param {number} angle */\n _rotate(angle) {\n const cos = Math.cos(angle),\n sin = Math.sin(angle),\n x = cos * this.x - sin * this.y,\n y = sin * this.x + cos * this.y;\n this.x = x;\n this.y = y;\n return this;\n },\n\n /**\n * @param {number} angle\n * @param {Point} p\n */\n _rotateAround(angle, p) {\n const cos = Math.cos(angle),\n sin = Math.sin(angle),\n x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y),\n y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);\n this.x = x;\n this.y = y;\n return this;\n },\n\n _round() {\n this.x = Math.round(this.x);\n this.y = Math.round(this.y);\n return this;\n },\n\n constructor: Point\n};\n\n/**\n * Construct a point from an array if necessary, otherwise if the input\n * is already a Point, return it unchanged.\n * @param {Point | [number, number] | {x: number, y: number}} p input value\n * @return {Point} constructed point.\n * @example\n * // this\n * var point = Point.convert([0, 1]);\n * // is equivalent to\n * var point = new Point(0, 1);\n */\nPoint.convert = function (p) {\n if (p instanceof Point) {\n return /** @type {Point} */ (p);\n }\n if (Array.isArray(p)) {\n return new Point(+p[0], +p[1]);\n }\n if (p.x !== undefined && p.y !== undefined) {\n return new Point(+p.x, +p.y);\n }\n throw new Error('Expected [x, y] or {x, y} point format');\n};\n","import Point from '@mapbox/point-geometry';\n\n/**\n * Returns a Point representing a mouse event's position\n * relative to a containing element.\n *\n * @param {MouseEvent} mouseEvent\n * @param {Node} container\n * @returns {Point}\n */\nfunction mouseEventPoint(mouseEvent, container) {\n const rect = container.getBoundingClientRect();\n return new Point(\n mouseEvent.clientX - rect.left - (container.clientLeft || 0),\n mouseEvent.clientY - rect.top - (container.clientTop || 0)\n );\n}\n\nexport default mouseEventPoint;\n","import * as Constants from '../constants.js';\n\n/**\n * Returns GeoJSON for a Point representing the\n * vertex of another feature.\n *\n * @param {string} parentId\n * @param {Array} coordinates\n * @param {string} path - Dot-separated numbers indicating exactly\n * where the point exists within its parent feature's coordinates.\n * @param {boolean} selected\n * @return {GeoJSON} Point\n */\n\nexport default function(parentId, coordinates, path, selected) {\n return {\n type: Constants.geojsonTypes.FEATURE,\n properties: {\n meta: Constants.meta.VERTEX,\n parent: parentId,\n coord_path: path,\n active: (selected) ? Constants.activeStates.ACTIVE : Constants.activeStates.INACTIVE\n },\n geometry: {\n type: Constants.geojsonTypes.POINT,\n coordinates\n }\n };\n}\n","import * as Constants from '../constants.js';\n\nexport default function(parent, startVertex, endVertex) {\n const startCoord = startVertex.geometry.coordinates;\n const endCoord = endVertex.geometry.coordinates;\n\n // If a coordinate exceeds the projection, we can't calculate a midpoint,\n // so run away\n if (startCoord[1] > Constants.LAT_RENDERED_MAX ||\n startCoord[1] < Constants.LAT_RENDERED_MIN ||\n endCoord[1] > Constants.LAT_RENDERED_MAX ||\n endCoord[1] < Constants.LAT_RENDERED_MIN) {\n return null;\n }\n\n const mid = {\n lng: (startCoord[0] + endCoord[0]) / 2,\n lat: (startCoord[1] + endCoord[1]) / 2\n };\n\n return {\n type: Constants.geojsonTypes.FEATURE,\n properties: {\n meta: Constants.meta.MIDPOINT,\n parent,\n lng: mid.lng,\n lat: mid.lat,\n coord_path: endVertex.properties.coord_path\n },\n geometry: {\n type: Constants.geojsonTypes.POINT,\n coordinates: [mid.lng, mid.lat]\n }\n };\n}\n","import createVertex from './create_vertex.js';\nimport createMidpoint from './create_midpoint.js';\nimport * as Constants from '../constants.js';\n\nfunction createSupplementaryPoints(geojson, options = {}, basePath = null) {\n const { type, coordinates } = geojson.geometry;\n const featureId = geojson.properties && geojson.properties.id;\n\n let supplementaryPoints = [];\n\n if (type === Constants.geojsonTypes.POINT) {\n // For points, just create a vertex\n supplementaryPoints.push(createVertex(featureId, coordinates, basePath, isSelectedPath(basePath)));\n } else if (type === Constants.geojsonTypes.POLYGON) {\n // Cycle through a Polygon's rings and\n // process each line\n coordinates.forEach((line, lineIndex) => {\n processLine(line, (basePath !== null) ? `${basePath}.${lineIndex}` : String(lineIndex));\n });\n } else if (type === Constants.geojsonTypes.LINE_STRING) {\n processLine(coordinates, basePath);\n } else if (type.indexOf(Constants.geojsonTypes.MULTI_PREFIX) === 0) {\n processMultiGeometry();\n }\n\n function processLine(line, lineBasePath) {\n let firstPointString = '';\n let lastVertex = null;\n line.forEach((point, pointIndex) => {\n const pointPath = (lineBasePath !== undefined && lineBasePath !== null) ? `${lineBasePath}.${pointIndex}` : String(pointIndex);\n const vertex = createVertex(featureId, point, pointPath, isSelectedPath(pointPath));\n\n // If we're creating midpoints, check if there was a\n // vertex before this one. If so, add a midpoint\n // between that vertex and this one.\n if (options.midpoints && lastVertex) {\n const midpoint = createMidpoint(featureId, lastVertex, vertex);\n if (midpoint) {\n supplementaryPoints.push(midpoint);\n }\n }\n lastVertex = vertex;\n\n // A Polygon line's last point is the same as the first point. If we're on the last\n // point, we want to draw a midpoint before it but not another vertex on it\n // (since we already a vertex there, from the first point).\n const stringifiedPoint = JSON.stringify(point);\n if (firstPointString !== stringifiedPoint) {\n supplementaryPoints.push(vertex);\n }\n if (pointIndex === 0) {\n firstPointString = stringifiedPoint;\n }\n });\n }\n\n function isSelectedPath(path) {\n if (!options.selectedPaths) return false;\n return options.selectedPaths.indexOf(path) !== -1;\n }\n\n // Split a multi-geometry into constituent\n // geometries, and accumulate the supplementary points\n // for each of those constituents\n function processMultiGeometry() {\n const subType = type.replace(Constants.geojsonTypes.MULTI_PREFIX, '');\n coordinates.forEach((subCoordinates, index) => {\n const subFeature = {\n type: Constants.geojsonTypes.FEATURE,\n properties: geojson.properties,\n geometry: {\n type: subType,\n coordinates: subCoordinates\n }\n };\n supplementaryPoints = supplementaryPoints.concat(createSupplementaryPoints(subFeature, options, index));\n });\n }\n\n return supplementaryPoints;\n}\n\nexport default createSupplementaryPoints;\n","export default {\n enable(ctx) {\n setTimeout(() => {\n // First check we've got a map and some context.\n if (!ctx.map || !ctx.map.doubleClickZoom || !ctx._ctx || !ctx._ctx.store || !ctx._ctx.store.getInitialConfigValue) return;\n // Now check initial state wasn't false (we leave it disabled if so)\n if (!ctx._ctx.store.getInitialConfigValue('doubleClickZoom')) return;\n ctx.map.doubleClickZoom.enable();\n }, 0);\n },\n disable(ctx) {\n setTimeout(() => {\n if (!ctx.map || !ctx.map.doubleClickZoom) return;\n // Always disable here, as it's necessary in some cases.\n ctx.map.doubleClickZoom.disable();\n }, 0);\n }\n};\n","import * as Constants from '../constants.js';\n\nconst {\n LAT_MIN,\n LAT_MAX,\n LAT_RENDERED_MIN,\n LAT_RENDERED_MAX,\n LNG_MIN,\n LNG_MAX,\n} = Constants;\nfunction extent(feature) {\n const depth = {\n Point: 0,\n LineString: 1,\n Polygon: 2,\n MultiPoint: 1,\n MultiLineString: 2,\n MultiPolygon: 3,\n }[feature.geometry.type];\n\n const coords = [feature.geometry.coordinates].flat(depth);\n const lngs = coords.map(coord => coord[0]);\n const lats = coords.map(coord => coord[1]);\n const min = vals => Math.min.apply(null, vals);\n const max = vals => Math.max.apply(null, vals);\n return [min(lngs), min(lats), max(lngs), max(lats)];\n}\n\n// Ensure that we do not drag north-south far enough for\n// - any part of any feature to exceed the poles\n// - any feature to be completely lost in the space between the projection's\n// edge and the poles, such that it couldn't be re-selected and moved back\nexport default function(geojsonFeatures, delta) {\n // \"inner edge\" = a feature's latitude closest to the equator\n let northInnerEdge = LAT_MIN;\n let southInnerEdge = LAT_MAX;\n // \"outer edge\" = a feature's latitude furthest from the equator\n let northOuterEdge = LAT_MIN;\n let southOuterEdge = LAT_MAX;\n\n let westEdge = LNG_MAX;\n let eastEdge = LNG_MIN;\n\n geojsonFeatures.forEach((feature) => {\n const bounds = extent(feature);\n const featureSouthEdge = bounds[1];\n const featureNorthEdge = bounds[3];\n const featureWestEdge = bounds[0];\n const featureEastEdge = bounds[2];\n if (featureSouthEdge > northInnerEdge) northInnerEdge = featureSouthEdge;\n if (featureNorthEdge < southInnerEdge) southInnerEdge = featureNorthEdge;\n if (featureNorthEdge > northOuterEdge) northOuterEdge = featureNorthEdge;\n if (featureSouthEdge < southOuterEdge) southOuterEdge = featureSouthEdge;\n if (featureWestEdge < westEdge) westEdge = featureWestEdge;\n if (featureEastEdge > eastEdge) eastEdge = featureEastEdge;\n });\n\n\n // These changes are not mutually exclusive: we might hit the inner\n // edge but also have hit the outer edge and therefore need\n // another readjustment\n const constrainedDelta = delta;\n if (northInnerEdge + constrainedDelta.lat > LAT_RENDERED_MAX) {\n constrainedDelta.lat = LAT_RENDERED_MAX - northInnerEdge;\n }\n if (northOuterEdge + constrainedDelta.lat > LAT_MAX) {\n constrainedDelta.lat = LAT_MAX - northOuterEdge;\n }\n if (southInnerEdge + constrainedDelta.lat < LAT_RENDERED_MIN) {\n constrainedDelta.lat = LAT_RENDERED_MIN - southInnerEdge;\n }\n if (southOuterEdge + constrainedDelta.lat < LAT_MIN) {\n constrainedDelta.lat = LAT_MIN - southOuterEdge;\n }\n if (westEdge + constrainedDelta.lng <= LNG_MIN) {\n constrainedDelta.lng += Math.ceil(Math.abs(constrainedDelta.lng) / 360) * 360;\n }\n if (eastEdge + constrainedDelta.lng >= LNG_MAX) {\n constrainedDelta.lng -= Math.ceil(Math.abs(constrainedDelta.lng) / 360) * 360;\n }\n\n return constrainedDelta;\n}\n","import constrainFeatureMovement from './constrain_feature_movement.js';\nimport * as Constants from '../constants.js';\n\nexport default function(features, delta) {\n const constrainedDelta = constrainFeatureMovement(features.map(feature => feature.toGeoJSON()), delta);\n\n features.forEach((feature) => {\n const currentCoordinates = feature.getCoordinates();\n\n const moveCoordinate = (coord) => {\n const point = {\n lng: coord[0] + constrainedDelta.lng,\n lat: coord[1] + constrainedDelta.lat\n };\n return [point.lng, point.lat];\n };\n const moveRing = ring => ring.map(coord => moveCoordinate(coord));\n const moveMultiPolygon = multi => multi.map(ring => moveRing(ring));\n\n let nextCoordinates;\n if (feature.type === Constants.geojsonTypes.POINT) {\n nextCoordinates = moveCoordinate(currentCoordinates);\n } else if (feature.type === Constants.geojsonTypes.LINE_STRING || feature.type === Constants.geojsonTypes.MULTI_POINT) {\n nextCoordinates = currentCoordinates.map(moveCoordinate);\n } else if (feature.type === Constants.geojsonTypes.POLYGON || feature.type === Constants.geojsonTypes.MULTI_LINE_STRING) {\n nextCoordinates = currentCoordinates.map(moveRing);\n } else if (feature.type === Constants.geojsonTypes.MULTI_POLYGON) {\n nextCoordinates = currentCoordinates.map(moveMultiPolygon);\n }\n\n feature.incomingCoords(nextCoordinates);\n });\n}\n","import * as CommonSelectors from '../lib/common_selectors.js';\nimport mouseEventPoint from '../lib/mouse_event_point.js';\nimport createSupplementaryPoints from '../lib/create_supplementary_points.js';\nimport StringSet from '../lib/string_set.js';\nimport doubleClickZoom from '../lib/double_click_zoom.js';\nimport moveFeatures from '../lib/move_features.js';\nimport * as Constants from '../constants.js';\n\nconst SimpleSelect = {};\n\nSimpleSelect.onSetup = function(opts) {\n // turn the opts into state.\n const state = {\n dragMoveLocation: null,\n boxSelectStartLocation: null,\n boxSelectElement: undefined,\n boxSelecting: false,\n canBoxSelect: false,\n dragMoving: false,\n canDragMove: false,\n initialDragPanState: this.map.dragPan.isEnabled(),\n initiallySelectedFeatureIds: opts.featureIds || []\n };\n\n this.setSelected(state.initiallySelectedFeatureIds.filter(id => this.getFeature(id) !== undefined));\n this.fireActionable();\n\n this.setActionableState({\n combineFeatures: true,\n uncombineFeatures: true,\n trash: true\n });\n\n return state;\n};\n\nSimpleSelect.fireUpdate = function() {\n this.fire(Constants.events.UPDATE, {\n action: Constants.updateActions.MOVE,\n features: this.getSelected().map(f => f.toGeoJSON())\n });\n};\n\nSimpleSelect.fireActionable = function() {\n const selectedFeatures = this.getSelected();\n\n const multiFeatures = selectedFeatures.filter(\n feature => this.isInstanceOf('MultiFeature', feature)\n );\n\n let combineFeatures = false;\n\n if (selectedFeatures.length > 1) {\n combineFeatures = true;\n const featureType = selectedFeatures[0].type.replace('Multi', '');\n selectedFeatures.forEach((feature) => {\n if (feature.type.replace('Multi', '') !== featureType) {\n combineFeatures = false;\n }\n });\n }\n\n const uncombineFeatures = multiFeatures.length > 0;\n const trash = selectedFeatures.length > 0;\n\n this.setActionableState({\n combineFeatures, uncombineFeatures, trash\n });\n};\n\nSimpleSelect.getUniqueIds = function(allFeatures) {\n if (!allFeatures.length) return [];\n const ids = allFeatures.map(s => s.properties.id)\n .filter(id => id !== undefined)\n .reduce((memo, id) => {\n memo.add(id);\n return memo;\n }, new StringSet());\n\n return ids.values();\n};\n\nSimpleSelect.stopExtendedInteractions = function(state) {\n if (state.boxSelectElement) {\n if (state.boxSelectElement.parentNode) state.boxSelectElement.parentNode.removeChild(state.boxSelectElement);\n state.boxSelectElement = null;\n }\n\n if ((state.canDragMove || state.canBoxSelect) && state.initialDragPanState === true) {\n this.map.dragPan.enable();\n }\n\n state.boxSelecting = false;\n state.canBoxSelect = false;\n state.dragMoving = false;\n state.canDragMove = false;\n};\n\nSimpleSelect.onStop = function() {\n doubleClickZoom.enable(this);\n};\n\nSimpleSelect.onMouseMove = function(state, e) {\n const isFeature = CommonSelectors.isFeature(e);\n if (isFeature && state.dragMoving) this.fireUpdate();\n\n // On mousemove that is not a drag, stop extended interactions.\n // This is useful if you drag off the canvas, release the button,\n // then move the mouse back over the canvas --- we don't allow the\n // interaction to continue then, but we do let it continue if you held\n // the mouse button that whole time\n this.stopExtendedInteractions(state);\n\n // Skip render\n return true;\n};\n\nSimpleSelect.onMouseOut = function(state) {\n // As soon as you mouse leaves the canvas, update the feature\n if (state.dragMoving) return this.fireUpdate();\n\n // Skip render\n return true;\n};\n\nSimpleSelect.onTap = SimpleSelect.onClick = function(state, e) {\n // Click (with or without shift) on no feature\n if (CommonSelectors.noTarget(e)) return this.clickAnywhere(state, e); // also tap\n if (CommonSelectors.isOfMetaType(Constants.meta.VERTEX)(e)) return this.clickOnVertex(state, e); //tap\n if (CommonSelectors.isFeature(e)) return this.clickOnFeature(state, e);\n};\n\nSimpleSelect.clickAnywhere = function (state) {\n // Clear the re-render selection\n const wasSelected = this.getSelectedIds();\n if (wasSelected.length) {\n this.clearSelectedFeatures();\n wasSelected.forEach(id => this.doRender(id));\n }\n doubleClickZoom.enable(this);\n this.stopExtendedInteractions(state);\n};\n\nSimpleSelect.clickOnVertex = function(state, e) {\n // Enter direct select mode\n this.changeMode(Constants.modes.DIRECT_SELECT, {\n featureId: e.featureTarget.properties.parent,\n coordPath: e.featureTarget.properties.coord_path,\n startPos: e.lngLat\n });\n this.updateUIClasses({ mouse: Constants.cursors.MOVE });\n};\n\nSimpleSelect.startOnActiveFeature = function(state, e) {\n // Stop any already-underway extended interactions\n this.stopExtendedInteractions(state);\n\n // Disable map.dragPan immediately so it can't start\n this.map.dragPan.disable();\n\n // Re-render it and enable drag move\n this.doRender(e.featureTarget.properties.id);\n\n // Set up the state for drag moving\n state.canDragMove = true;\n state.dragMoveLocation = e.lngLat;\n};\n\nSimpleSelect.clickOnFeature = function(state, e) {\n // Stop everything\n doubleClickZoom.disable(this);\n this.stopExtendedInteractions(state);\n\n const isShiftClick = CommonSelectors.isShiftDown(e);\n const selectedFeatureIds = this.getSelectedIds();\n const featureId = e.featureTarget.properties.id;\n const isFeatureSelected = this.isSelected(featureId);\n\n // Click (without shift) on any selected feature but a point\n if (!isShiftClick && isFeatureSelected && this.getFeature(featureId).type !== Constants.geojsonTypes.POINT) {\n // Enter direct select mode\n return this.changeMode(Constants.modes.DIRECT_SELECT, {\n featureId\n });\n }\n\n // Shift-click on a selected feature\n if (isFeatureSelected && isShiftClick) {\n // Deselect it\n this.deselect(featureId);\n this.updateUIClasses({ mouse: Constants.cursors.POINTER });\n if (selectedFeatureIds.length === 1) {\n doubleClickZoom.enable(this);\n }\n // Shift-click on an unselected feature\n } else if (!isFeatureSelected && isShiftClick) {\n // Add it to the selection\n this.select(featureId);\n this.updateUIClasses({ mouse: Constants.cursors.MOVE });\n // Click (without shift) on an unselected feature\n } else if (!isFeatureSelected && !isShiftClick) {\n // Make it the only selected feature\n selectedFeatureIds.forEach(id => this.doRender(id));\n this.setSelected(featureId);\n this.updateUIClasses({ mouse: Constants.cursors.MOVE });\n }\n\n // No matter what, re-render the clicked feature\n this.doRender(featureId);\n};\n\nSimpleSelect.onMouseDown = function(state, e) {\n state.initialDragPanState = this.map.dragPan.isEnabled();\n if (CommonSelectors.isActiveFeature(e)) return this.startOnActiveFeature(state, e);\n if (this.drawConfig.boxSelect && CommonSelectors.isShiftMousedown(e)) return this.startBoxSelect(state, e);\n};\n\nSimpleSelect.startBoxSelect = function(state, e) {\n this.stopExtendedInteractions(state);\n this.map.dragPan.disable();\n // Enable box select\n state.boxSelectStartLocation = mouseEventPoint(e.originalEvent, this.map.getContainer());\n state.canBoxSelect = true;\n};\n\nSimpleSelect.onTouchStart = function(state, e) {\n if (CommonSelectors.isActiveFeature(e)) return this.startOnActiveFeature(state, e);\n};\n\nSimpleSelect.onDrag = function(state, e) {\n if (state.canDragMove) return this.dragMove(state, e);\n if (this.drawConfig.boxSelect && state.canBoxSelect) return this.whileBoxSelect(state, e);\n};\n\nSimpleSelect.whileBoxSelect = function(state, e) {\n state.boxSelecting = true;\n this.updateUIClasses({ mouse: Constants.cursors.ADD });\n\n // Create the box node if it doesn't exist\n if (!state.boxSelectElement) {\n state.boxSelectElement = document.createElement('div');\n state.boxSelectElement.classList.add(Constants.classes.BOX_SELECT);\n this.map.getContainer().appendChild(state.boxSelectElement);\n }\n\n // Adjust the box node's width and xy position\n const current = mouseEventPoint(e.originalEvent, this.map.getContainer());\n const minX = Math.min(state.boxSelectStartLocation.x, current.x);\n const maxX = Math.max(state.boxSelectStartLocation.x, current.x);\n const minY = Math.min(state.boxSelectStartLocation.y, current.y);\n const maxY = Math.max(state.boxSelectStartLocation.y, current.y);\n const translateValue = `translate(${minX}px, ${minY}px)`;\n state.boxSelectElement.style.transform = translateValue;\n state.boxSelectElement.style.WebkitTransform = translateValue;\n state.boxSelectElement.style.width = `${maxX - minX}px`;\n state.boxSelectElement.style.height = `${maxY - minY}px`;\n};\n\nSimpleSelect.dragMove = function(state, e) {\n // Dragging when drag move is enabled\n state.dragMoving = true;\n e.originalEvent.stopPropagation();\n\n const delta = {\n lng: e.lngLat.lng - state.dragMoveLocation.lng,\n lat: e.lngLat.lat - state.dragMoveLocation.lat\n };\n\n moveFeatures(this.getSelected(), delta);\n\n state.dragMoveLocation = e.lngLat;\n};\n\nSimpleSelect.onTouchEnd = SimpleSelect.onMouseUp = function(state, e) {\n // End any extended interactions\n if (state.dragMoving) {\n this.fireUpdate();\n } else if (state.boxSelecting) {\n const bbox = [\n state.boxSelectStartLocation,\n mouseEventPoint(e.originalEvent, this.map.getContainer())\n ];\n const featuresInBox = this.featuresAt(null, bbox, 'click');\n const idsToSelect = this.getUniqueIds(featuresInBox)\n .filter(id => !this.isSelected(id));\n\n if (idsToSelect.length) {\n this.select(idsToSelect);\n idsToSelect.forEach(id => this.doRender(id));\n this.updateUIClasses({ mouse: Constants.cursors.MOVE });\n }\n }\n this.stopExtendedInteractions(state);\n};\n\nSimpleSelect.toDisplayFeatures = function(state, geojson, display) {\n geojson.properties.active = (this.isSelected(geojson.properties.id)) ?\n Constants.activeStates.ACTIVE : Constants.activeStates.INACTIVE;\n display(geojson);\n this.fireActionable();\n if (geojson.properties.active !== Constants.activeStates.ACTIVE ||\n geojson.geometry.type === Constants.geojsonTypes.POINT) return;\n createSupplementaryPoints(geojson).forEach(display);\n};\n\nSimpleSelect.onTrash = function() {\n this.deleteFeature(this.getSelectedIds());\n this.fireActionable();\n};\n\nSimpleSelect.onCombineFeatures = function() {\n const selectedFeatures = this.getSelected();\n\n if (selectedFeatures.length === 0 || selectedFeatures.length < 2) return;\n\n const coordinates = [], featuresCombined = [];\n const featureType = selectedFeatures[0].type.replace('Multi', '');\n\n for (let i = 0; i < selectedFeatures.length; i++) {\n const feature = selectedFeatures[i];\n\n if (feature.type.replace('Multi', '') !== featureType) {\n return;\n }\n if (feature.type.includes('Multi')) {\n feature.getCoordinates().forEach((subcoords) => {\n coordinates.push(subcoords);\n });\n } else {\n coordinates.push(feature.getCoordinates());\n }\n\n featuresCombined.push(feature.toGeoJSON());\n }\n\n if (featuresCombined.length > 1) {\n const multiFeature = this.newFeature({\n type: Constants.geojsonTypes.FEATURE,\n properties: featuresCombined[0].properties,\n geometry: {\n type: `Multi${featureType}`,\n coordinates\n }\n });\n\n this.addFeature(multiFeature);\n this.deleteFeature(this.getSelectedIds(), { silent: true });\n this.setSelected([multiFeature.id]);\n\n this.fire(Constants.events.COMBINE_FEATURES, {\n createdFeatures: [multiFeature.toGeoJSON()],\n deletedFeatures: featuresCombined\n });\n }\n this.fireActionable();\n};\n\nSimpleSelect.onUncombineFeatures = function() {\n const selectedFeatures = this.getSelected();\n if (selectedFeatures.length === 0) return;\n\n const createdFeatures = [];\n const featuresUncombined = [];\n\n for (let i = 0; i < selectedFeatures.length; i++) {\n const feature = selectedFeatures[i];\n\n if (this.isInstanceOf('MultiFeature', feature)) {\n feature.getFeatures().forEach((subFeature) => {\n this.addFeature(subFeature);\n subFeature.properties = feature.properties;\n createdFeatures.push(subFeature.toGeoJSON());\n this.select([subFeature.id]);\n });\n this.deleteFeature(feature.id, { silent: true });\n featuresUncombined.push(feature.toGeoJSON());\n }\n }\n\n if (createdFeatures.length > 1) {\n this.fire(Constants.events.UNCOMBINE_FEATURES, {\n createdFeatures,\n deletedFeatures: featuresUncombined\n });\n }\n this.fireActionable();\n};\n\nexport default SimpleSelect;\n","import { noTarget, isOfMetaType, isActiveFeature, isInactiveFeature, isShiftDown } from '../lib/common_selectors.js';\nimport createSupplementaryPoints from '../lib/create_supplementary_points.js';\nimport constrainFeatureMovement from '../lib/constrain_feature_movement.js';\nimport doubleClickZoom from '../lib/double_click_zoom.js';\nimport * as Constants from '../constants.js';\nimport moveFeatures from '../lib/move_features.js';\n\nconst isVertex = isOfMetaType(Constants.meta.VERTEX);\nconst isMidpoint = isOfMetaType(Constants.meta.MIDPOINT);\n\nconst DirectSelect = {};\n\n// INTERNAL FUCNTIONS\n\nDirectSelect.fireUpdate = function() {\n this.fire(Constants.events.UPDATE, {\n action: Constants.updateActions.CHANGE_COORDINATES,\n features: this.getSelected().map(f => f.toGeoJSON())\n });\n};\n\nDirectSelect.fireActionable = function(state) {\n this.setActionableState({\n combineFeatures: false,\n uncombineFeatures: false,\n trash: state.selectedCoordPaths.length > 0\n });\n};\n\nDirectSelect.startDragging = function(state, e) {\n state.initialDragPanState = this.map.dragPan.isEnabled();\n\n this.map.dragPan.disable();\n state.canDragMove = true;\n state.dragMoveLocation = e.lngLat;\n};\n\nDirectSelect.stopDragging = function(state) {\n if (state.canDragMove && state.initialDragPanState === true) {\n this.map.dragPan.enable();\n }\n state.dragMoving = false;\n state.canDragMove = false;\n state.dragMoveLocation = null;\n};\n\nDirectSelect.onVertex = function (state, e) {\n this.startDragging(state, e);\n const about = e.featureTarget.properties;\n const selectedIndex = state.selectedCoordPaths.indexOf(about.coord_path);\n if (!isShiftDown(e) && selectedIndex === -1) {\n state.selectedCoordPaths = [about.coord_path];\n } else if (isShiftDown(e) && selectedIndex === -1) {\n state.selectedCoordPaths.push(about.coord_path);\n }\n\n const selectedCoordinates = this.pathsToCoordinates(state.featureId, state.selectedCoordPaths);\n this.setSelectedCoordinates(selectedCoordinates);\n};\n\nDirectSelect.onMidpoint = function(state, e) {\n this.startDragging(state, e);\n const about = e.featureTarget.properties;\n state.feature.addCoordinate(about.coord_path, about.lng, about.lat);\n this.fireUpdate();\n state.selectedCoordPaths = [about.coord_path];\n};\n\nDirectSelect.pathsToCoordinates = function(featureId, paths) {\n return paths.map(coord_path => ({ feature_id: featureId, coord_path }));\n};\n\nDirectSelect.onFeature = function(state, e) {\n if (state.selectedCoordPaths.length === 0) this.startDragging(state, e);\n else this.stopDragging(state);\n};\n\nDirectSelect.dragFeature = function(state, e, delta) {\n moveFeatures(this.getSelected(), delta);\n state.dragMoveLocation = e.lngLat;\n};\n\nDirectSelect.dragVertex = function(state, e, delta) {\n const selectedCoords = state.selectedCoordPaths.map(coord_path => state.feature.getCoordinate(coord_path));\n const selectedCoordPoints = selectedCoords.map(coords => ({\n type: Constants.geojsonTypes.FEATURE,\n properties: {},\n geometry: {\n type: Constants.geojsonTypes.POINT,\n coordinates: coords\n }\n }));\n\n const constrainedDelta = constrainFeatureMovement(selectedCoordPoints, delta);\n for (let i = 0; i < selectedCoords.length; i++) {\n const coord = selectedCoords[i];\n state.feature.updateCoordinate(state.selectedCoordPaths[i], coord[0] + constrainedDelta.lng, coord[1] + constrainedDelta.lat);\n }\n};\n\nDirectSelect.clickNoTarget = function () {\n this.changeMode(Constants.modes.SIMPLE_SELECT);\n};\n\nDirectSelect.clickInactive = function () {\n this.changeMode(Constants.modes.SIMPLE_SELECT);\n};\n\nDirectSelect.clickActiveFeature = function (state) {\n state.selectedCoordPaths = [];\n this.clearSelectedCoordinates();\n state.feature.changed();\n};\n\n// EXTERNAL FUNCTIONS\n\nDirectSelect.onSetup = function(opts) {\n const featureId = opts.featureId;\n const feature = this.getFeature(featureId);\n\n if (!feature) {\n throw new Error('You must provide a featureId to enter direct_select mode');\n }\n\n if (feature.type === Constants.geojsonTypes.POINT) {\n throw new TypeError('direct_select mode doesn\\'t handle point features');\n }\n\n const state = {\n featureId,\n feature,\n dragMoveLocation: opts.startPos || null,\n dragMoving: false,\n canDragMove: false,\n selectedCoordPaths: opts.coordPath ? [opts.coordPath] : [],\n };\n\n this.setSelectedCoordinates(this.pathsToCoordinates(featureId, state.selectedCoordPaths));\n this.setSelected(featureId);\n doubleClickZoom.disable(this);\n\n this.setActionableState({\n trash: true\n });\n\n return state;\n};\n\nDirectSelect.onStop = function() {\n doubleClickZoom.enable(this);\n this.clearSelectedCoordinates();\n};\n\nDirectSelect.toDisplayFeatures = function(state, geojson, push) {\n if (state.featureId === geojson.properties.id) {\n geojson.properties.active = Constants.activeStates.ACTIVE;\n push(geojson);\n createSupplementaryPoints(geojson, {\n map: this.map,\n midpoints: true,\n selectedPaths: state.selectedCoordPaths\n }).forEach(push);\n } else {\n geojson.properties.active = Constants.activeStates.INACTIVE;\n push(geojson);\n }\n this.fireActionable(state);\n};\n\nDirectSelect.onTrash = function(state) {\n // Uses number-aware sorting to make sure '9' < '10'. Comparison is reversed because we want them\n // in reverse order so that we can remove by index safely.\n state.selectedCoordPaths\n .sort((a, b) => b.localeCompare(a, 'en', { numeric: true }))\n .forEach(id => state.feature.removeCoordinate(id));\n this.fireUpdate();\n state.selectedCoordPaths = [];\n this.clearSelectedCoordinates();\n this.fireActionable(state);\n if (state.feature.isValid() === false) {\n this.deleteFeature([state.featureId]);\n this.changeMode(Constants.modes.SIMPLE_SELECT, {});\n }\n};\n\nDirectSelect.onMouseMove = function(state, e) {\n // On mousemove that is not a drag, stop vertex movement.\n const isFeature = isActiveFeature(e);\n const onVertex = isVertex(e);\n const isMidPoint = isMidpoint(e);\n const noCoords = state.selectedCoordPaths.length === 0;\n if (isFeature && noCoords) this.updateUIClasses({ mouse: Constants.cursors.MOVE });\n else if (onVertex && !noCoords) this.updateUIClasses({ mouse: Constants.cursors.MOVE });\n else this.updateUIClasses({ mouse: Constants.cursors.NONE });\n\n const isDraggableItem = onVertex || isFeature || isMidPoint;\n if (isDraggableItem && state.dragMoving) this.fireUpdate();\n\n this.stopDragging(state);\n\n // Skip render\n return true;\n};\n\nDirectSelect.onMouseOut = function(state) {\n // As soon as you mouse leaves the canvas, update the feature\n if (state.dragMoving) this.fireUpdate();\n\n // Skip render\n return true;\n};\n\nDirectSelect.onTouchStart = DirectSelect.onMouseDown = function(state, e) {\n if (isVertex(e)) return this.onVertex(state, e);\n if (isActiveFeature(e)) return this.onFeature(state, e);\n if (isMidpoint(e)) return this.onMidpoint(state, e);\n};\n\nDirectSelect.onDrag = function(state, e) {\n if (state.canDragMove !== true) return;\n state.dragMoving = true;\n e.originalEvent.stopPropagation();\n\n const delta = {\n lng: e.lngLat.lng - state.dragMoveLocation.lng,\n lat: e.lngLat.lat - state.dragMoveLocation.lat\n };\n if (state.selectedCoordPaths.length > 0) this.dragVertex(state, e, delta);\n else this.dragFeature(state, e, delta);\n\n state.dragMoveLocation = e.lngLat;\n};\n\nDirectSelect.onClick = function(state, e) {\n if (noTarget(e)) return this.clickNoTarget(state, e);\n if (isActiveFeature(e)) return this.clickActiveFeature(state, e);\n if (isInactiveFeature(e)) return this.clickInactive(state, e);\n this.stopDragging(state);\n};\n\nDirectSelect.onTap = function(state, e) {\n if (noTarget(e)) return this.clickNoTarget(state, e);\n if (isActiveFeature(e)) return this.clickActiveFeature(state, e);\n if (isInactiveFeature(e)) return this.clickInactive(state, e);\n};\n\nDirectSelect.onTouchEnd = DirectSelect.onMouseUp = function(state) {\n if (state.dragMoving) {\n this.fireUpdate();\n }\n this.stopDragging(state);\n};\n\nexport default DirectSelect;\n\n","import * as CommonSelectors from '../lib/common_selectors.js';\nimport * as Constants from '../constants.js';\n\nconst DrawPoint = {};\n\nDrawPoint.onSetup = function() {\n const point = this.newFeature({\n type: Constants.geojsonTypes.FEATURE,\n properties: {},\n geometry: {\n type: Constants.geojsonTypes.POINT,\n coordinates: []\n }\n });\n\n this.addFeature(point);\n\n this.clearSelectedFeatures();\n this.updateUIClasses({ mouse: Constants.cursors.ADD });\n this.activateUIButton(Constants.types.POINT);\n\n this.setActionableState({\n trash: true\n });\n\n return { point };\n};\n\nDrawPoint.stopDrawingAndRemove = function(state) {\n this.deleteFeature([state.point.id], { silent: true });\n this.changeMode(Constants.modes.SIMPLE_SELECT);\n};\n\nDrawPoint.onTap = DrawPoint.onClick = function(state, e) {\n this.updateUIClasses({ mouse: Constants.cursors.MOVE });\n state.point.updateCoordinate('', e.lngLat.lng, e.lngLat.lat);\n this.fire(Constants.events.CREATE, {\n features: [state.point.toGeoJSON()]\n });\n this.changeMode(Constants.modes.SIMPLE_SELECT, { featureIds: [state.point.id] });\n};\n\nDrawPoint.onStop = function(state) {\n this.activateUIButton();\n if (!state.point.getCoordinate().length) {\n this.deleteFeature([state.point.id], { silent: true });\n }\n};\n\nDrawPoint.toDisplayFeatures = function(state, geojson, display) {\n // Never render the point we're drawing\n const isActivePoint = geojson.properties.id === state.point.id;\n geojson.properties.active = (isActivePoint) ? Constants.activeStates.ACTIVE : Constants.activeStates.INACTIVE;\n if (!isActivePoint) return display(geojson);\n};\n\nDrawPoint.onTrash = DrawPoint.stopDrawingAndRemove;\n\nDrawPoint.onKeyUp = function(state, e) {\n if (CommonSelectors.isEscapeKey(e) || CommonSelectors.isEnterKey(e)) {\n return this.stopDrawingAndRemove(state, e);\n }\n};\n\nexport default DrawPoint;\n","function isEventAtCoordinates(event, coordinates) {\n if (!event.lngLat) return false;\n return event.lngLat.lng === coordinates[0] && event.lngLat.lat === coordinates[1];\n}\n\nexport default isEventAtCoordinates;\n","import * as CommonSelectors from '../lib/common_selectors.js';\nimport doubleClickZoom from '../lib/double_click_zoom.js';\nimport * as Constants from '../constants.js';\nimport isEventAtCoordinates from '../lib/is_event_at_coordinates.js';\nimport createVertex from '../lib/create_vertex.js';\n\nconst DrawPolygon = {};\n\nDrawPolygon.onSetup = function() {\n const polygon = this.newFeature({\n type: Constants.geojsonTypes.FEATURE,\n properties: {},\n geometry: {\n type: Constants.geojsonTypes.POLYGON,\n coordinates: [[]]\n }\n });\n\n this.addFeature(polygon);\n\n this.clearSelectedFeatures();\n doubleClickZoom.disable(this);\n this.updateUIClasses({ mouse: Constants.cursors.ADD });\n this.activateUIButton(Constants.types.POLYGON);\n this.setActionableState({\n trash: true\n });\n\n return {\n polygon,\n currentVertexPosition: 0\n };\n};\n\nDrawPolygon.clickAnywhere = function(state, e) {\n if (state.currentVertexPosition > 0 && isEventAtCoordinates(e, state.polygon.coordinates[0][state.currentVertexPosition - 1])) {\n return this.changeMode(Constants.modes.SIMPLE_SELECT, { featureIds: [state.polygon.id] });\n }\n this.updateUIClasses({ mouse: Constants.cursors.ADD });\n state.polygon.updateCoordinate(`0.${state.currentVertexPosition}`, e.lngLat.lng, e.lngLat.lat);\n state.currentVertexPosition++;\n state.polygon.updateCoordinate(`0.${state.currentVertexPosition}`, e.lngLat.lng, e.lngLat.lat);\n};\n\nDrawPolygon.clickOnVertex = function(state) {\n return this.changeMode(Constants.modes.SIMPLE_SELECT, { featureIds: [state.polygon.id] });\n};\n\nDrawPolygon.onMouseMove = function(state, e) {\n state.polygon.updateCoordinate(`0.${state.currentVertexPosition}`, e.lngLat.lng, e.lngLat.lat);\n if (CommonSelectors.isVertex(e)) {\n this.updateUIClasses({ mouse: Constants.cursors.POINTER });\n }\n};\n\nDrawPolygon.onTap = DrawPolygon.onClick = function(state, e) {\n if (CommonSelectors.isVertex(e)) return this.clickOnVertex(state, e);\n return this.clickAnywhere(state, e);\n};\n\nDrawPolygon.onKeyUp = function(state, e) {\n if (CommonSelectors.isEscapeKey(e)) {\n this.deleteFeature([state.polygon.id], { silent: true });\n this.changeMode(Constants.modes.SIMPLE_SELECT);\n } else if (CommonSelectors.isEnterKey(e)) {\n this.changeMode(Constants.modes.SIMPLE_SELECT, { featureIds: [state.polygon.id] });\n }\n};\n\nDrawPolygon.onStop = function(state) {\n this.updateUIClasses({ mouse: Constants.cursors.NONE });\n doubleClickZoom.enable(this);\n this.activateUIButton();\n\n // check to see if we've deleted this feature\n if (this.getFeature(state.polygon.id) === undefined) return;\n\n //remove last added coordinate\n state.polygon.removeCoordinate(`0.${state.currentVertexPosition}`);\n if (state.polygon.isValid()) {\n this.fire(Constants.events.CREATE, {\n features: [state.polygon.toGeoJSON()]\n });\n } else {\n this.deleteFeature([state.polygon.id], { silent: true });\n this.changeMode(Constants.modes.SIMPLE_SELECT, {}, { silent: true });\n }\n};\n\nDrawPolygon.toDisplayFeatures = function(state, geojson, display) {\n const isActivePolygon = geojson.properties.id === state.polygon.id;\n geojson.properties.active = (isActivePolygon) ? Constants.activeStates.ACTIVE : Constants.activeStates.INACTIVE;\n if (!isActivePolygon) return display(geojson);\n\n // Don't render a polygon until it has two positions\n // (and a 3rd which is just the first repeated)\n if (geojson.geometry.coordinates.length === 0) return;\n\n const coordinateCount = geojson.geometry.coordinates[0].length;\n // 2 coordinates after selecting a draw type\n // 3 after creating the first point\n if (coordinateCount < 3) {\n return;\n }\n geojson.properties.meta = Constants.meta.FEATURE;\n display(createVertex(state.polygon.id, geojson.geometry.coordinates[0][0], '0.0', false));\n if (coordinateCount > 3) {\n // Add a start position marker to the map, clicking on this will finish the feature\n // This should only be shown when we're in a valid spot\n const endPos = geojson.geometry.coordinates[0].length - 3;\n display(createVertex(state.polygon.id, geojson.geometry.coordinates[0][endPos], `0.${endPos}`, false));\n }\n if (coordinateCount <= 4) {\n // If we've only drawn two positions (plus the closer),\n // make a LineString instead of a Polygon\n const lineCoordinates = [\n [geojson.geometry.coordinates[0][0][0], geojson.geometry.coordinates[0][0][1]], [geojson.geometry.coordinates[0][1][0], geojson.geometry.coordinates[0][1][1]]\n ];\n // create an initial vertex so that we can track the first point on mobile devices\n display({\n type: Constants.geojsonTypes.FEATURE,\n properties: geojson.properties,\n geometry: {\n coordinates: lineCoordinates,\n type: Constants.geojsonTypes.LINE_STRING\n }\n });\n if (coordinateCount === 3) {\n return;\n }\n }\n // render the Polygon\n return display(geojson);\n};\n\nDrawPolygon.onTrash = function(state) {\n this.deleteFeature([state.polygon.id], { silent: true });\n this.changeMode(Constants.modes.SIMPLE_SELECT);\n};\n\nexport default DrawPolygon;\n","import * as CommonSelectors from '../lib/common_selectors.js';\nimport isEventAtCoordinates from '../lib/is_event_at_coordinates.js';\nimport doubleClickZoom from '../lib/double_click_zoom.js';\nimport * as Constants from '../constants.js';\nimport createVertex from '../lib/create_vertex.js';\n\nconst DrawLineString = {};\n\nDrawLineString.onSetup = function(opts) {\n opts = opts || {};\n const featureId = opts.featureId;\n\n let line, currentVertexPosition;\n let direction = 'forward';\n if (featureId) {\n line = this.getFeature(featureId);\n if (!line) {\n throw new Error('Could not find a feature with the provided featureId');\n }\n let from = opts.from;\n if (from && from.type === 'Feature' && from.geometry && from.geometry.type === 'Point') {\n from = from.geometry;\n }\n if (from && from.type === 'Point' && from.coordinates && from.coordinates.length === 2) {\n from = from.coordinates;\n }\n if (!from || !Array.isArray(from)) {\n throw new Error('Please use the `from` property to indicate which point to continue the line from');\n }\n const lastCoord = line.coordinates.length - 1;\n if (line.coordinates[lastCoord][0] === from[0] && line.coordinates[lastCoord][1] === from[1]) {\n currentVertexPosition = lastCoord + 1;\n // add one new coordinate to continue from\n line.addCoordinate(currentVertexPosition, ...line.coordinates[lastCoord]);\n } else if (line.coordinates[0][0] === from[0] && line.coordinates[0][1] === from[1]) {\n direction = 'backwards';\n currentVertexPosition = 0;\n // add one new coordinate to continue from\n line.addCoordinate(currentVertexPosition, ...line.coordinates[0]);\n } else {\n throw new Error('`from` should match the point at either the start or the end of the provided LineString');\n }\n } else {\n line = this.newFeature({\n type: Constants.geojsonTypes.FEATURE,\n properties: {},\n geometry: {\n type: Constants.geojsonTypes.LINE_STRING,\n coordinates: []\n }\n });\n currentVertexPosition = 0;\n this.addFeature(line);\n }\n\n this.clearSelectedFeatures();\n doubleClickZoom.disable(this);\n this.updateUIClasses({ mouse: Constants.cursors.ADD });\n this.activateUIButton(Constants.types.LINE);\n this.setActionableState({\n trash: true\n });\n\n return {\n line,\n currentVertexPosition,\n direction\n };\n};\n\nDrawLineString.clickAnywhere = function(state, e) {\n if (state.currentVertexPosition > 0 && isEventAtCoordinates(e, state.line.coordinates[state.currentVertexPosition - 1]) ||\n state.direction === 'backwards' && isEventAtCoordinates(e, state.line.coordinates[state.currentVertexPosition + 1])) {\n return this.changeMode(Constants.modes.SIMPLE_SELECT, { featureIds: [state.line.id] });\n }\n this.updateUIClasses({ mouse: Constants.cursors.ADD });\n state.line.updateCoordinate(state.currentVertexPosition, e.lngLat.lng, e.lngLat.lat);\n if (state.direction === 'forward') {\n state.currentVertexPosition++;\n state.line.updateCoordinate(state.currentVertexPosition, e.lngLat.lng, e.lngLat.lat);\n } else {\n state.line.addCoordinate(0, e.lngLat.lng, e.lngLat.lat);\n }\n};\n\nDrawLineString.clickOnVertex = function(state) {\n return this.changeMode(Constants.modes.SIMPLE_SELECT, { featureIds: [state.line.id] });\n};\n\nDrawLineString.onMouseMove = function(state, e) {\n state.line.updateCoordinate(state.currentVertexPosition, e.lngLat.lng, e.lngLat.lat);\n if (CommonSelectors.isVertex(e)) {\n this.updateUIClasses({ mouse: Constants.cursors.POINTER });\n }\n};\n\nDrawLineString.onTap = DrawLineString.onClick = function(state, e) {\n if (CommonSelectors.isVertex(e)) return this.clickOnVertex(state, e);\n this.clickAnywhere(state, e);\n};\n\nDrawLineString.onKeyUp = function(state, e) {\n if (CommonSelectors.isEnterKey(e)) {\n this.changeMode(Constants.modes.SIMPLE_SELECT, { featureIds: [state.line.id] });\n } else if (CommonSelectors.isEscapeKey(e)) {\n this.deleteFeature([state.line.id], { silent: true });\n this.changeMode(Constants.modes.SIMPLE_SELECT);\n }\n};\n\nDrawLineString.onStop = function(state) {\n doubleClickZoom.enable(this);\n this.activateUIButton();\n\n // check to see if we've deleted this feature\n if (this.getFeature(state.line.id) === undefined) return;\n\n //remove last added coordinate\n state.line.removeCoordinate(`${state.currentVertexPosition}`);\n if (state.line.isValid()) {\n this.fire(Constants.events.CREATE, {\n features: [state.line.toGeoJSON()]\n });\n } else {\n this.deleteFeature([state.line.id], { silent: true });\n this.changeMode(Constants.modes.SIMPLE_SELECT, {}, { silent: true });\n }\n};\n\nDrawLineString.onTrash = function(state) {\n this.deleteFeature([state.line.id], { silent: true });\n this.changeMode(Constants.modes.SIMPLE_SELECT);\n};\n\nDrawLineString.toDisplayFeatures = function(state, geojson, display) {\n const isActiveLine = geojson.properties.id === state.line.id;\n geojson.properties.active = (isActiveLine) ? Constants.activeStates.ACTIVE : Constants.activeStates.INACTIVE;\n if (!isActiveLine) return display(geojson);\n // Only render the line if it has at least one real coordinate\n if (geojson.geometry.coordinates.length < 2) return;\n geojson.properties.meta = Constants.meta.FEATURE;\n display(createVertex(\n state.line.id,\n geojson.geometry.coordinates[state.direction === 'forward' ? geojson.geometry.coordinates.length - 2 : 1],\n `${state.direction === 'forward' ? geojson.geometry.coordinates.length - 2 : 1}`,\n false\n ));\n\n display(geojson);\n};\n\nexport default DrawLineString;\n","\nimport simple_select from './simple_select.js';\nimport direct_select from './direct_select.js';\nimport draw_point from './draw_point.js';\nimport draw_polygon from './draw_polygon.js';\nimport draw_line_string from './draw_line_string.js';\n\nexport default {\n simple_select,\n direct_select,\n draw_point,\n draw_polygon,\n draw_line_string,\n};\n","import * as Constants from './constants.js';\n\nimport styles from './lib/theme.js';\nimport modes from './modes/index.js';\n\nconst defaultOptions = {\n defaultMode: Constants.modes.SIMPLE_SELECT,\n keybindings: true,\n touchEnabled: true,\n clickBuffer: 2,\n touchBuffer: 25,\n boxSelect: true,\n displayControlsDefault: true,\n styles,\n modes,\n controls: {},\n userProperties: false,\n suppressAPIEvents: true\n};\n\nconst showControls = {\n point: true,\n line_string: true,\n polygon: true,\n trash: true,\n combine_features: true,\n uncombine_features: true\n};\n\nconst hideControls = {\n point: false,\n line_string: false,\n polygon: false,\n trash: false,\n combine_features: false,\n uncombine_features: false\n};\n\nfunction addSources(styles, sourceBucket) {\n return styles.map((style) => {\n if (style.source) return style;\n return Object.assign({}, style, {\n id: `${style.id}.${sourceBucket}`,\n source: (sourceBucket === 'hot') ? Constants.sources.HOT : Constants.sources.COLD\n });\n });\n}\n\nexport default function(options = {}) {\n let withDefaults = Object.assign({}, options);\n\n if (!options.controls) {\n withDefaults.controls = {};\n }\n\n if (options.displayControlsDefault === false) {\n withDefaults.controls = Object.assign({}, hideControls, options.controls);\n } else {\n withDefaults.controls = Object.assign({}, showControls, options.controls);\n }\n\n withDefaults = Object.assign({}, defaultOptions, withDefaults);\n\n // Layers with a shared source should be adjacent for performance reasons\n withDefaults.styles = addSources(withDefaults.styles, 'cold').concat(addSources(withDefaults.styles, 'hot'));\n\n return withDefaults;\n}\n","'use strict';\n\n// do not edit .js files directly - edit src/index.jst\n\n\n\nmodule.exports = function equal(a, b) {\n if (a === b) return true;\n\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n if (a.constructor !== b.constructor) return false;\n\n var length, i, keys;\n if (Array.isArray(a)) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n\n\n if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;\n if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();\n if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();\n\n keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length) return false;\n\n for (i = length; i-- !== 0;)\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;\n\n for (i = length; i-- !== 0;) {\n var key = keys[i];\n\n if (!equal(a[key], b[key])) return false;\n }\n\n return true;\n }\n\n // true if both NaN, false otherwise\n return a!==a && b!==b;\n};\n","module.exports = normalize;\n\nvar types = {\n Point: 'geometry',\n MultiPoint: 'geometry',\n LineString: 'geometry',\n MultiLineString: 'geometry',\n Polygon: 'geometry',\n MultiPolygon: 'geometry',\n GeometryCollection: 'geometry',\n Feature: 'feature',\n FeatureCollection: 'featurecollection'\n};\n\n/**\n * Normalize a GeoJSON feature into a FeatureCollection.\n *\n * @param {object} gj geojson data\n * @returns {object} normalized geojson data\n */\nfunction normalize(gj) {\n if (!gj || !gj.type) return null;\n var type = types[gj.type];\n if (!type) return null;\n\n if (type === 'geometry') {\n return {\n type: 'FeatureCollection',\n features: [{\n type: 'Feature',\n properties: {},\n geometry: gj\n }]\n };\n } else if (type === 'feature') {\n return {\n type: 'FeatureCollection',\n features: [gj]\n };\n } else if (type === 'featurecollection') {\n return gj;\n }\n}\n","export default function(a, b) {\n if (a.length !== b.length) return false;\n return JSON.stringify(a.map(id => id).sort()) === JSON.stringify(b.map(id => id).sort());\n}\n","import isEqual from 'fast-deep-equal';\nimport normalize from '@mapbox/geojson-normalize';\nimport {generateID} from './lib/id.js';\nimport featuresAt from './lib/features_at.js';\nimport stringSetsAreEqual from './lib/string_sets_are_equal.js';\nimport * as Constants from './constants.js';\nimport StringSet from './lib/string_set.js';\n\nimport Polygon from './feature_types/polygon.js';\nimport LineString from './feature_types/line_string.js';\nimport Point from './feature_types/point.js';\nimport MultiFeature from './feature_types/multi_feature.js';\n\nconst featureTypes = {\n Polygon,\n LineString,\n Point,\n MultiPolygon: MultiFeature,\n MultiLineString: MultiFeature,\n MultiPoint: MultiFeature\n};\n\nexport default function(ctx, api) {\n api.modes = Constants.modes;\n\n // API doesn't emit events by default\n const silent = ctx.options.suppressAPIEvents !== undefined ? !!ctx.options.suppressAPIEvents : true;\n\n api.getFeatureIdsAt = function(point) {\n const features = featuresAt.click({ point }, null, ctx);\n return features.map(feature => feature.properties.id);\n };\n\n api.getSelectedIds = function() {\n return ctx.store.getSelectedIds();\n };\n\n api.getSelected = function() {\n return {\n type: Constants.geojsonTypes.FEATURE_COLLECTION,\n features: ctx.store.getSelectedIds().map(id => ctx.store.get(id)).map(feature => feature.toGeoJSON())\n };\n };\n\n api.getSelectedPoints = function() {\n return {\n type: Constants.geojsonTypes.FEATURE_COLLECTION,\n features: ctx.store.getSelectedCoordinates().map(coordinate => ({\n type: Constants.geojsonTypes.FEATURE,\n properties: {},\n geometry: {\n type: Constants.geojsonTypes.POINT,\n coordinates: coordinate.coordinates\n }\n }))\n };\n };\n\n api.set = function(featureCollection) {\n if (featureCollection.type === undefined || featureCollection.type !== Constants.geojsonTypes.FEATURE_COLLECTION || !Array.isArray(featureCollection.features)) {\n throw new Error('Invalid FeatureCollection');\n }\n const renderBatch = ctx.store.createRenderBatch();\n let toDelete = ctx.store.getAllIds().slice();\n const newIds = api.add(featureCollection);\n const newIdsLookup = new StringSet(newIds);\n\n toDelete = toDelete.filter(id => !newIdsLookup.has(id));\n if (toDelete.length) {\n api.delete(toDelete);\n }\n\n renderBatch();\n return newIds;\n };\n\n api.add = function(geojson) {\n const featureCollection = JSON.parse(JSON.stringify(normalize(geojson)));\n\n const ids = featureCollection.features.map((feature) => {\n feature.id = feature.id || generateID();\n\n if (feature.geometry === null) {\n throw new Error('Invalid geometry: null');\n }\n\n if (ctx.store.get(feature.id) === undefined || ctx.store.get(feature.id).type !== feature.geometry.type) {\n // If the feature has not yet been created ...\n const Model = featureTypes[feature.geometry.type];\n if (Model === undefined) {\n throw new Error(`Invalid geometry type: ${feature.geometry.type}.`);\n }\n const internalFeature = new Model(ctx, feature);\n ctx.store.add(internalFeature, { silent });\n } else {\n // If a feature of that id has already been created, and we are swapping it out ...\n const internalFeature = ctx.store.get(feature.id);\n const originalProperties = internalFeature.properties;\n internalFeature.properties = feature.properties;\n if (!isEqual(originalProperties, feature.properties)) {\n ctx.store.featureChanged(internalFeature.id, { silent });\n }\n if (!isEqual(internalFeature.getCoordinates(), feature.geometry.coordinates)) {\n internalFeature.incomingCoords(feature.geometry.coordinates);\n }\n }\n return feature.id;\n });\n\n ctx.store.render();\n return ids;\n };\n\n\n api.get = function(id) {\n const feature = ctx.store.get(id);\n if (feature) {\n return feature.toGeoJSON();\n }\n };\n\n api.getAll = function() {\n return {\n type: Constants.geojsonTypes.FEATURE_COLLECTION,\n features: ctx.store.getAll().map(feature => feature.toGeoJSON())\n };\n };\n\n api.delete = function(featureIds) {\n ctx.store.delete(featureIds, { silent });\n // If we were in direct select mode and our selected feature no longer exists\n // (because it was deleted), we need to get out of that mode.\n if (api.getMode() === Constants.modes.DIRECT_SELECT && !ctx.store.getSelectedIds().length) {\n ctx.events.changeMode(Constants.modes.SIMPLE_SELECT, undefined, { silent });\n } else {\n ctx.store.render();\n }\n\n return api;\n };\n\n api.deleteAll = function() {\n ctx.store.delete(ctx.store.getAllIds(), { silent });\n // If we were in direct select mode, now our selected feature no longer exists,\n // so escape that mode.\n if (api.getMode() === Constants.modes.DIRECT_SELECT) {\n ctx.events.changeMode(Constants.modes.SIMPLE_SELECT, undefined, { silent });\n } else {\n ctx.store.render();\n }\n\n return api;\n };\n\n api.changeMode = function(mode, modeOptions = {}) {\n // Avoid changing modes just to re-select what's already selected\n if (mode === Constants.modes.SIMPLE_SELECT && api.getMode() === Constants.modes.SIMPLE_SELECT) {\n if (stringSetsAreEqual((modeOptions.featureIds || []), ctx.store.getSelectedIds())) return api;\n // And if we are changing the selection within simple_select mode, just change the selection,\n // instead of stopping and re-starting the mode\n ctx.store.setSelected(modeOptions.featureIds, { silent });\n ctx.store.render();\n return api;\n }\n\n if (mode === Constants.modes.DIRECT_SELECT && api.getMode() === Constants.modes.DIRECT_SELECT &&\n modeOptions.featureId === ctx.store.getSelectedIds()[0]) {\n return api;\n }\n\n ctx.events.changeMode(mode, modeOptions, { silent });\n return api;\n };\n\n api.getMode = function() {\n return ctx.events.getMode();\n };\n\n api.trash = function() {\n ctx.events.trash({ silent });\n return api;\n };\n\n api.combineFeatures = function() {\n ctx.events.combineFeatures({ silent });\n return api;\n };\n\n api.uncombineFeatures = function() {\n ctx.events.uncombineFeatures({ silent });\n return api;\n };\n\n api.setFeatureProperty = function(featureId, property, value) {\n ctx.store.setFeatureProperty(featureId, property, value, { silent });\n return api;\n };\n\n return api;\n}\n","import runSetup from './src/setup.js';\nimport setupOptions from './src/options.js';\nimport setupAPI from './src/api.js';\nimport modes from './src/modes/index.js';\nimport * as Constants from './src/constants.js';\nimport * as lib from './src/lib/index.js';\n\nconst setupDraw = function(options, api) {\n options = setupOptions(options);\n\n const ctx = {\n options\n };\n\n api = setupAPI(ctx, api);\n ctx.api = api;\n\n const setup = runSetup(ctx);\n\n api.onAdd = setup.onAdd;\n api.onRemove = setup.onRemove;\n api.types = Constants.types;\n api.options = options;\n\n return api;\n};\n\nfunction MapboxDraw(options) {\n setupDraw(options, this);\n}\n\nMapboxDraw.modes = modes;\nMapboxDraw.constants = Constants;\nMapboxDraw.lib = lib;\n\nexport default MapboxDraw;\n"],"names":["ModeHandler","mode","DrawContext","handlers","drag","click","mousemove","mousedown","mouseup","mouseout","keydown","keyup","touchstart","touchmove","touchend","tap","ctx","on","event","selector","fn","undefined","Error","push","render","id","store","featureChanged","delegate","eventName","handles","iHandle","length","handle","call","ui","updateMapClasses","start","stop","trash","combineFeatures","uncombineFeatures","wgs84","RADIUS","FLATTENING","POLAR_RADIUS","require$$0","polygonArea","coords","area","Math","abs","ringArea","i","p1","p2","lowerIndex","middleIndex","upperIndex","coordsLength","rad","sin","_","PI","geojsonArea","geometry","type","coordinates","geometries","ring","classes","CANVAS","CONTROL_BASE","CONTROL_PREFIX","CONTROL_BUTTON","CONTROL_BUTTON_LINE","CONTROL_BUTTON_POLYGON","CONTROL_BUTTON_POINT","CONTROL_BUTTON_TRASH","CONTROL_BUTTON_COMBINE_FEATURES","CONTROL_BUTTON_UNCOMBINE_FEATURES","CONTROL_GROUP","ATTRIBUTION","ACTIVE_BUTTON","BOX_SELECT","sources","HOT","COLD","cursors","ADD","MOVE","DRAG","POINTER","NONE","types","POLYGON","LINE","POINT","geojsonTypes","FEATURE","LINE_STRING","FEATURE_COLLECTION","MULTI_PREFIX","MULTI_POINT","MULTI_LINE_STRING","MULTI_POLYGON","modes","DRAW_LINE_STRING","DRAW_POLYGON","DRAW_POINT","SIMPLE_SELECT","DIRECT_SELECT","events","CREATE","DELETE","UPDATE","SELECTION_CHANGE","MODE_CHANGE","ACTIONABLE","RENDER","COMBINE_FEATURES","UNCOMBINE_FEATURES","updateActions","CHANGE_PROPERTIES","CHANGE_COORDINATES","meta","MIDPOINT","VERTEX","activeStates","ACTIVE","INACTIVE","interactions","LAT_RENDERED_MIN","LAT_RENDERED_MAX","FEATURE_SORT_RANKS","Point","LineString","MultiLineString","Polygon","comparator","a","b","score","Constants.geojsonTypes","sortFeatures","features","map","feature","property","sort","mapEventToBoundingBox","mapEvent","buffer","point","x","y","StringSet","items","this","_items","_nums","_length","l","add","prototype","has","delete","values","Object","keys","forEach","k","v","JSON","parse","clear","META_TYPES","Constants.meta","featuresAt","bbox","options","clickBuffer","touch","touchBuffer","box","queryParams","styles","layers","s","filter","getLayer","queryRenderedFeatures","indexOf","properties","featureIds","uniqueFeatures","featureId","getFeatureAtAndSetCursors","mouse","Constants.cursors","active","Constants.activeStates","currentModeName","queueMapClasses","euclideanDistance","sqrt","FINE_TOLERANCE","GROSS_TOLERANCE","INTERVAL","isClick","end","fineTolerance","grossTolerance","interval","time","moveDistance","TAP_TOLERANCE","TAP_INTERVAL","isTap","tolerance","nanoid","alphabet","defaultSize","size","random","customAlphabet","generateID","Feature","geojson","changed","incomingCoords","setCoordinates","getCoordinates","stringify","setProperty","value","toGeoJSON","internal","userProperties","name","create","isValid","updateCoordinate","pathOrLng","lngOrLat","lat","arguments","getCoordinate","addCoordinate","path","lng","parseInt","splice","removeCoordinate","slice","every","ids","split","concat","parts","ringId","coordId","models","MultiPoint","MultiPolygon","takeAction","action","idx","tail","join","MultiFeature","model","TypeError","_coordinatesToFeatures","ModeInterface","drawConfig","_ctx","Model","bind","replace","f","getFeatures","setSelected","setSelectedCoordinates","reduce","m","c","feature_id","get","getSelected","getSelectedIds","isSelected","getFeature","select","deselect","deleteFeature","opts","addFeature","clearSelectedFeatures","clearSelected","clearSelectedCoordinates","setActionableState","actions","newSet","actionable","changeMode","eventOpts","fire","eventData","updateUIClasses","activateUIButton","setActiveButton","bufferType","newFeature","isInstanceOf","doRender","onSetup","onDrag","onClick","onMouseMove","onMouseDown","onMouseUp","onMouseOut","onKeyUp","onKeyDown","onTouchStart","onTouchMove","onTouchEnd","onTap","onStop","onTrash","onCombineFeature","onUncombineFeature","toDisplayFeatures","eventMapper","eventKeys","objectToMode","modeObject","modeObjectKeys","startOpts","state","key","modeHandler","eh","e","onCombineFeatures","onUncombineFeatures","toDenseArray","getSource","Constants.sources","cleanup","newHotIds","newColdIds","isDirty","getAllIds","getChangedIds","hot","lastColdCount","cold","parent","coldChanged","renderFeature","source","featureInternal","currentModeRender","clearChangedIds","setData","Store","renderRequest","_features","_featureIds","_selectedFeatureIds","_selectedCoordinates","_changedFeatureIds","_emitSelectionChange","_mapInitialConfig","requestAnimationFrame","Constants.events","points","getSelectedCoordinates","coordinate","refreshSelectedCoordinates","newSelectedCoordinates","silent","createRenderBatch","holdRender","numRenders","setDirty","featureCreated","suppressAPIEvents","Constants.updateActions","deletedFeaturesToEmit","getAll","coord_path","setFeatureProperty","storeMapConfig","Constants.interactions","interaction","isEnabled","restoreMapConfig","enable","disable","getInitialConfigValue","classTypes","runSetup","controlContainer","mapLoadedInterval","setup","onRemove","off","connect","clearInterval","removeLayers","removeButtons","removeEventListeners","clearMapClasses","boxZoomInitial","boxZoom","container","parentNode","removeChild","addLayers","addEventListeners","onAdd","mouseDownInfo","touchStartInfo","currentMode","isDrag","Date","getTime","originalEvent","stopPropagation","mousedrag","endInfo","touchdrag","buttons","which","target","getFeaturesAndSetCursor","featureTarget","touchEnabled","preventDefault","isKeyModeValid","code","modename","nextModeOptions","eventOptions","modebuilder","setupModeHandler","srcElement","classList","contains","Constants.classes","keyCode","controls","Constants.modes","line_string","polygon","zoomend","changeZoom","data","dataType","some","style","actionState","defaultMode","addEventListener","keybindings","removeEventListener","getMode","buttonElements","activeButton","currentMapClasses","nextMapClasses","assign","classesToRemove","classesToAdd","remove","createControlButton","button","document","createElement","className","setAttribute","title","appendChild","deactivateButtons","onDeactivate","onActivate","addButtons","controlGroup","Constants.types","combine_features","uncombine_features","buttonId","getContainer","boxSelect","dragPanIsEnabled","dragPan","loaded","setInterval","addSource","addLayer","removeLayer","removeSource","blue","orange","white","paint","layout","isOfMetaType","isShiftMousedown","shiftKey","isActiveFeature","isInactiveFeature","noTarget","isFeature","isVertex","isShiftDown","isEscapeKey","isEnterKey","mouseEventPoint","mouseEvent","rect","getBoundingClientRect","clientX","left","clientLeft","clientY","top","clientTop","createVertex","parentId","selected","createMidpoint","startVertex","endVertex","startCoord","endCoord","Constants.LAT_RENDERED_MAX","Constants.LAT_RENDERED_MIN","mid","createSupplementaryPoints","basePath","supplementaryPoints","processLine","line","lineBasePath","firstPointString","lastVertex","pointIndex","pointPath","String","vertex","isSelectedPath","midpoints","midpoint","stringifiedPoint","selectedPaths","lineIndex","subType","subCoordinates","index","subFeature","processMultiGeometry","clone","p","_add","sub","_sub","multByPoint","_multByPoint","divByPoint","_divByPoint","mult","_mult","div","_div","rotate","_rotate","rotateAround","_rotateAround","matMult","_matMult","unit","_unit","perp","_perp","round","_round","mag","equals","other","dist","distSqr","dx","dy","angle","atan2","angleTo","angleWith","angleWithSep","cos","constructor","convert","Array","isArray","doubleClickZoom","setTimeout","LAT_MIN","LAT_MAX","LNG_MIN","LNG_MAX","Constants","constrainFeatureMovement","geojsonFeatures","delta","northInnerEdge","southInnerEdge","northOuterEdge","southOuterEdge","westEdge","eastEdge","bounds","depth","flat","lngs","coord","lats","min","vals","apply","max","extent","featureSouthEdge","featureNorthEdge","featureWestEdge","featureEastEdge","constrainedDelta","ceil","moveFeatures","currentCoordinates","moveCoordinate","moveRing","moveMultiPolygon","multi","nextCoordinates","SimpleSelect","dragMoveLocation","boxSelectStartLocation","boxSelectElement","boxSelecting","canBoxSelect","dragMoving","canDragMove","initialDragPanState","initiallySelectedFeatureIds","fireActionable","selectedFeatures","multiFeatures","featureType","allFeatures","memo","CommonSelectors.isFeature","fireUpdate","stopExtendedInteractions","CommonSelectors.noTarget","clickAnywhere","CommonSelectors.isOfMetaType","clickOnVertex","clickOnFeature","wasSelected","coordPath","startPos","lngLat","startOnActiveFeature","isShiftClick","CommonSelectors.isShiftDown","selectedFeatureIds","isFeatureSelected","CommonSelectors.isActiveFeature","CommonSelectors.isShiftMousedown","startBoxSelect","dragMove","whileBoxSelect","current","minX","maxX","minY","maxY","translateValue","transform","WebkitTransform","width","height","featuresInBox","idsToSelect","getUniqueIds","display","featuresCombined","includes","subcoords","multiFeature","createdFeatures","deletedFeatures","featuresUncombined","isMidpoint","DirectSelect","selectedCoordPaths","startDragging","about","selectedIndex","selectedCoordinates","pathsToCoordinates","paths","stopDragging","selectedCoords","localeCompare","numeric","onVertex","isMidPoint","noCoords","onFeature","onMidpoint","dragVertex","dragFeature","clickNoTarget","clickActiveFeature","clickInactive","DrawPoint","isEventAtCoordinates","stopDrawingAndRemove","isActivePoint","CommonSelectors.isEscapeKey","CommonSelectors.isEnterKey","DrawPolygon","currentVertexPosition","CommonSelectors.isVertex","isActivePolygon","coordinateCount","endPos","lineCoordinates","DrawLineString","direction","from","lastCoord","isActiveLine","simple_select","direct_select","draw_point","draw_polygon","draw_line_string","defaultOptions","displayControlsDefault","showControls","hideControls","addSources","sourceBucket","fastDeepEqual","equal","RegExp","flags","valueOf","toString","hasOwnProperty","geojsonNormalize","gj","GeometryCollection","FeatureCollection","stringSetsAreEqual","featureTypes","setupDraw","api","withDefaults","setupOptions","getFeatureIdsAt","getSelectedPoints","set","featureCollection","renderBatch","toDelete","newIds","newIdsLookup","normalize","internalFeature","originalProperties","isEqual","deleteAll","modeOptions","setupAPI","MapboxDraw","constants","lib"],"mappings":"4BACA,MAAMA,EAAc,SAASC,EAAMC,GAEjC,MAAMC,EAAW,CACfC,KAAM,GACNC,MAAO,GACPC,UAAW,GACXC,UAAW,GACXC,QAAS,GACTC,SAAU,GACVC,QAAS,GACTC,MAAO,GACPC,WAAY,GACZC,UAAW,GACXC,SAAU,GACVC,IAAK,IAGDC,EAAM,CACV,EAAAC,CAAGC,EAAOC,EAAUC,GAClB,QAAwBC,IAApBlB,EAASe,GACX,MAAM,IAAII,MAAM,uBAAuBJ,KAEzCf,EAASe,GAAOK,KAAK,CACnBJ,WACAC,MAEH,EACD,MAAAI,CAAOC,GACLvB,EAAYwB,MAAMC,eAAeF,EACvC,GAGQG,EAAW,SAAUC,EAAWX,GACpC,MAAMY,EAAU3B,EAAS0B,GACzB,IAAIE,EAAUD,EAAQE,OACtB,KAAOD,KAAW,CACh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