"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("../polyfills/tslib.js");
var chunk_853b4351_js_1 = require("./chunk-853b4351.js");
var chunk_53560ba7_js_1 = require("./chunk-53560ba7.js");
function coordEach(e, r, t) { if (null !== e)
    for (var o, n, i, s, a, u, l, c, h = 0, d = 0, f = e.type, p = "FeatureCollection" === f, m = "Feature" === f, g = p ? e.features.length : 1, y = 0; y < g; y++) {
        a = (c = !!(l = p ? e.features[y].geometry : m ? e.geometry : e) && "GeometryCollection" === l.type) ? l.geometries.length : 1;
        for (var b = 0; b < a; b++) {
            var w = 0, v = 0;
            if (null !== (s = c ? l.geometries[b] : l)) {
                u = s.coordinates;
                var E = s.type;
                switch (h = !t || "Polygon" !== E && "MultiPolygon" !== E ? 0 : 1, E) {
                    case null: break;
                    case "Point":
                        if (!1 === r(u, d, y, w, v))
                            return !1;
                        d++, w++;
                        break;
                    case "LineString":
                    case "MultiPoint":
                        for (o = 0; o < u.length; o++) {
                            if (!1 === r(u[o], d, y, w, v))
                                return !1;
                            d++, "MultiPoint" === E && w++;
                        }
                        "LineString" === E && w++;
                        break;
                    case "Polygon":
                    case "MultiLineString":
                        for (o = 0; o < u.length; o++) {
                            for (n = 0; n < u[o].length - h; n++) {
                                if (!1 === r(u[o][n], d, y, w, v))
                                    return !1;
                                d++;
                            }
                            "MultiLineString" === E && w++, "Polygon" === E && v++;
                        }
                        "Polygon" === E && w++;
                        break;
                    case "MultiPolygon":
                        for (o = 0; o < u.length; o++) {
                            for ("MultiPolygon" === E && (v = 0), n = 0; n < u[o].length; n++) {
                                for (i = 0; i < u[o][n].length - h; i++) {
                                    if (!1 === r(u[o][n][i], d, y, w, v))
                                        return !1;
                                    d++;
                                }
                                v++;
                            }
                            w++;
                        }
                        break;
                    case "GeometryCollection":
                        for (o = 0; o < s.geometries.length; o++)
                            if (!1 === coordEach(s.geometries[o], r, t))
                                return !1;
                        break;
                    default: throw new Error("Unknown Geometry Type");
                }
            }
        }
    } }
function featureEach(e, r) { if ("Feature" === e.type)
    r(e, 0);
else if ("FeatureCollection" === e.type)
    for (var t = 0; t < e.features.length && !1 !== r(e.features[t], t); t++)
        ; }
function feature(e, r, t) { if (!isObject(t = t || {}))
    throw new Error("options is invalid"); var o = t.bbox, n = t.id; if (void 0 === e)
    throw new Error("geometry is required"); if (r && r.constructor !== Object)
    throw new Error("properties must be an Object"); o && validateBBox(o), n && validateId(n); var i = { type: "Feature" }; return n && (i.id = n), o && (i.bbox = o), i.properties = r || {}, i.geometry = e, i; }
function point(e, r, t) { if (!e)
    throw new Error("coordinates is required"); if (!Array.isArray(e))
    throw new Error("coordinates must be an Array"); if (e.length < 2)
    throw new Error("coordinates must be at least 2 numbers long"); if (!isNumber(e[0]) || !isNumber(e[1]))
    throw new Error("coordinates must contain numbers"); return feature({ type: "Point", coordinates: e }, r, t); }
function featureCollection(e, r) { if (!isObject(r = r || {}))
    throw new Error("options is invalid"); var t = r.bbox, o = r.id; if (!e)
    throw new Error("No features passed"); if (!Array.isArray(e))
    throw new Error("features must be an Array"); t && validateBBox(t), o && validateId(o); var n = { type: "FeatureCollection" }; return o && (n.id = o), t && (n.bbox = t), n.features = e, n; }
function isNumber(e) { return !isNaN(e) && null !== e && !Array.isArray(e); }
function isObject(e) { return !!e && e.constructor === Object; }
function validateBBox(e) { if (!e)
    throw new Error("bbox is required"); if (!Array.isArray(e))
    throw new Error("bbox must be an Array"); if (4 !== e.length && 6 !== e.length)
    throw new Error("bbox must be an Array of 4 or 6 numbers"); e.forEach(function (e) { if (!isNumber(e))
    throw new Error("bbox must only contain numbers"); }); }
function validateId(e) { if (!e)
    throw new Error("id is required"); if (-1 === ["string", "number"].indexOf(typeof e))
    throw new Error("id must be a number or a string"); }
function explode(e) { var r = []; return "FeatureCollection" === e.type ? featureEach(e, function (e) { coordEach(e, function (t) { r.push(point(t, e.properties)); }); }) : coordEach(e, function (t) { r.push(point(t, e.properties)); }), featureCollection(r); }
function bbox(e) { var r = [1 / 0, 1 / 0, -1 / 0, -1 / 0]; return coordEach(e, function (e) { r[0] > e[0] && (r[0] = e[0]), r[1] > e[1] && (r[1] = e[1]), r[2] < e[0] && (r[2] = e[0]), r[3] < e[1] && (r[3] = e[1]); }), r; }
function feature$1(e, r, t) { if (!isObject$1(t = t || {}))
    throw new Error("options is invalid"); var o = t.bbox, n = t.id; if (void 0 === e)
    throw new Error("geometry is required"); if (r && r.constructor !== Object)
    throw new Error("properties must be an Object"); o && validateBBox$1(o), n && validateId$1(n); var i = { type: "Feature" }; return n && (i.id = n), o && (i.bbox = o), i.properties = r || {}, i.geometry = e, i; }
function point$1(e, r, t) { if (!e)
    throw new Error("coordinates is required"); if (!Array.isArray(e))
    throw new Error("coordinates must be an Array"); if (e.length < 2)
    throw new Error("coordinates must be at least 2 numbers long"); if (!isNumber$1(e[0]) || !isNumber$1(e[1]))
    throw new Error("coordinates must contain numbers"); return feature$1({ type: "Point", coordinates: e }, r, t); }
function isNumber$1(e) { return !isNaN(e) && null !== e && !Array.isArray(e); }
function isObject$1(e) { return !!e && e.constructor === Object; }
function validateBBox$1(e) { if (!e)
    throw new Error("bbox is required"); if (!Array.isArray(e))
    throw new Error("bbox must be an Array"); if (4 !== e.length && 6 !== e.length)
    throw new Error("bbox must be an Array of 4 or 6 numbers"); e.forEach(function (e) { if (!isNumber$1(e))
    throw new Error("bbox must only contain numbers"); }); }
function validateId$1(e) { if (!e)
    throw new Error("id is required"); if (-1 === ["string", "number"].indexOf(typeof e))
    throw new Error("id must be a number or a string"); }
function center(e, r) { if (!isObject$1(r = r || {}))
    throw new Error("options is invalid"); var t = r.properties; if (!e)
    throw new Error("geojson is required"); var o = bbox(e); return point$1([(o[0] + o[2]) / 2, (o[1] + o[3]) / 2], t); }
function clone(e) { if (!e)
    throw new Error("geojson is required"); switch (e.type) {
    case "Feature": return cloneFeature(e);
    case "FeatureCollection": return cloneFeatureCollection(e);
    case "Point":
    case "LineString":
    case "Polygon":
    case "MultiPoint":
    case "MultiLineString":
    case "MultiPolygon":
    case "GeometryCollection": return cloneGeometry(e);
    default: throw new Error("unknown GeoJSON type");
} }
function cloneFeature(e) { var r = { type: "Feature" }; return Object.keys(e).forEach(function (t) { switch (t) {
    case "type":
    case "properties":
    case "geometry": return;
    default: r[t] = e[t];
} }), r.properties = cloneProperties(e.properties), r.geometry = cloneGeometry(e.geometry), r; }
function cloneProperties(e) { var r = {}; return e ? (Object.keys(e).forEach(function (t) { var o = e[t]; r[t] = "object" == typeof o ? null === o ? null : o.length ? o.map(function (e) { return e; }) : cloneProperties(o) : o; }), r) : r; }
function cloneFeatureCollection(e) { var r = { type: "FeatureCollection" }; return Object.keys(e).forEach(function (t) { switch (t) {
    case "type":
    case "features": return;
    default: r[t] = e[t];
} }), r.features = e.features.map(function (e) { return cloneFeature(e); }), r; }
function cloneGeometry(e) { var r = { type: e.type }; return e.bbox && (r.bbox = e.bbox), "GeometryCollection" === e.type ? (r.geometries = e.geometries.map(function (e) { return cloneGeometry(e); }), r) : (r.coordinates = deepSlice(e.coordinates), r); }
function deepSlice(e) { return "object" != typeof e[0] ? e.slice() : e.map(function (e) { return deepSlice(e); }); }
function getCoord(e) { if (!e)
    throw new Error("coord is required"); if ("Feature" === e.type && null !== e.geometry && "Point" === e.geometry.type)
    return e.geometry.coordinates; if ("Point" === e.type)
    return e.coordinates; if (Array.isArray(e) && e.length >= 2 && void 0 === e[0].length && void 0 === e[1].length)
    return e; throw new Error("coord must be GeoJSON Point or an Array of numbers"); }
function getCoords(e) { if (!e)
    throw new Error("coords is required"); if ("Feature" === e.type && null !== e.geometry)
    return e.geometry.coordinates; if (e.coordinates)
    return e.coordinates; if (Array.isArray(e))
    return e; throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array"); }
var earthRadius = 6371008.8, factors = { meters: earthRadius, metres: earthRadius, millimeters: 1e3 * earthRadius, millimetres: 1e3 * earthRadius, centimeters: 100 * earthRadius, centimetres: 100 * earthRadius, kilometers: earthRadius / 1e3, kilometres: earthRadius / 1e3, miles: earthRadius / 1609.344, nauticalmiles: earthRadius / 1852, inches: 39.37 * earthRadius, yards: earthRadius / 1.0936, feet: 3.28084 * earthRadius, radians: 1, degrees: earthRadius / 111325 };
function radiansToLength(e, r) { if (null == e)
    throw new Error("radians is required"); if (r && "string" != typeof r)
    throw new Error("units must be a string"); var t = factors[r || "kilometers"]; if (!t)
    throw new Error(r + " units is invalid"); return e * t; }
function degreesToRadians(e) { if (null == e)
    throw new Error("degrees is required"); return e % 360 * Math.PI / 180; }
function isObject$2(e) { return !!e && e.constructor === Object; }
function distance(e, r, t) { if (!isObject$2(t = t || {}))
    throw new Error("options is invalid"); var o = t.units, n = getCoord(e), i = getCoord(r), s = degreesToRadians(i[1] - n[1]), a = degreesToRadians(i[0] - n[0]), u = degreesToRadians(n[1]), l = degreesToRadians(i[1]), c = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(a / 2), 2) * Math.cos(u) * Math.cos(l); return radiansToLength(2 * Math.atan2(Math.sqrt(c), Math.sqrt(1 - c)), o); }
function nearestPoint(e, r) { if (!e)
    throw new Error("targetPoint is required"); if (!r)
    throw new Error("points is required"); var t, o = 1 / 0; return featureEach(r, function (r, n) { var i = distance(e, r); i < o && ((t = clone(r)).properties.featureIndex = n, t.properties.distanceToPoint = i, o = i); }), t; }
function booleanPointInPolygon(e, r, t) { if ("object" != typeof (t = t || {}))
    throw new Error("options is invalid"); var o = t.ignoreBoundary; if (!e)
    throw new Error("point is required"); if (!r)
    throw new Error("polygon is required"); var n = getCoord(e), i = getCoords(r), s = r.geometry ? r.geometry.type : r.type, a = r.bbox; if (a && !1 === inBBox(n, a))
    return !1; "Polygon" === s && (i = [i]); for (var u = 0, l = !1; u < i.length && !l; u++)
    if (inRing(n, i[u][0], o)) {
        for (var c = !1, h = 1; h < i[u].length && !c;)
            inRing(n, i[u][h], !o) && (c = !0), h++;
        c || (l = !0);
    } return l; }
function inRing(e, r, t) { var o = !1; r[0][0] === r[r.length - 1][0] && r[0][1] === r[r.length - 1][1] && (r = r.slice(0, r.length - 1)); for (var n = 0, i = r.length - 1; n < r.length; i = n++) {
    var s = r[n][0], a = r[n][1], u = r[i][0], l = r[i][1];
    if (e[1] * (s - u) + a * (u - e[0]) + l * (e[0] - s) == 0 && (s - e[0]) * (u - e[0]) <= 0 && (a - e[1]) * (l - e[1]) <= 0)
        return !t;
    a > e[1] != l > e[1] && e[0] < (u - s) * (e[1] - a) / (l - a) + s && (o = !o);
} return o; }
function inBBox(e, r) { return r[0] <= e[0] && r[1] <= e[1] && r[2] >= e[0] && r[3] >= e[1]; }
function feature$2(e, r, t) { if (!isObject$3(t = t || {}))
    throw new Error("options is invalid"); var o = t.bbox, n = t.id; if (void 0 === e)
    throw new Error("geometry is required"); if (r && r.constructor !== Object)
    throw new Error("properties must be an Object"); o && validateBBox$2(o), n && validateId$2(n); var i = { type: "Feature" }; return n && (i.id = n), o && (i.bbox = o), i.properties = r || {}, i.geometry = e, i; }
function point$2(e, r, t) { if (!e)
    throw new Error("coordinates is required"); if (!Array.isArray(e))
    throw new Error("coordinates must be an Array"); if (e.length < 2)
    throw new Error("coordinates must be at least 2 numbers long"); if (!isNumber$2(e[0]) || !isNumber$2(e[1]))
    throw new Error("coordinates must contain numbers"); return feature$2({ type: "Point", coordinates: e }, r, t); }
function featureCollection$1(e, r) { if (!isObject$3(r = r || {}))
    throw new Error("options is invalid"); var t = r.bbox, o = r.id; if (!e)
    throw new Error("No features passed"); if (!Array.isArray(e))
    throw new Error("features must be an Array"); t && validateBBox$2(t), o && validateId$2(o); var n = { type: "FeatureCollection" }; return o && (n.id = o), t && (n.bbox = t), n.features = e, n; }
function isNumber$2(e) { return !isNaN(e) && null !== e && !Array.isArray(e); }
function isObject$3(e) { return !!e && e.constructor === Object; }
function validateBBox$2(e) { if (!e)
    throw new Error("bbox is required"); if (!Array.isArray(e))
    throw new Error("bbox must be an Array"); if (4 !== e.length && 6 !== e.length)
    throw new Error("bbox must be an Array of 4 or 6 numbers"); e.forEach(function (e) { if (!isNumber$2(e))
    throw new Error("bbox must only contain numbers"); }); }
function validateId$2(e) { if (!e)
    throw new Error("id is required"); if (-1 === ["string", "number"].indexOf(typeof e))
    throw new Error("id must be a number or a string"); }
function pointOnFeature(e) { for (var r = normalize(e), t = center(r), o = !1, n = 0; !o && n < r.features.length;) {
    var i, s = r.features[n].geometry, a = !1;
    if ("Point" === s.type)
        t.geometry.coordinates[0] === s.coordinates[0] && t.geometry.coordinates[1] === s.coordinates[1] && (o = !0);
    else if ("MultiPoint" === s.type) {
        var u = !1;
        for (i = 0; !u && i < s.coordinates.length;)
            t.geometry.coordinates[0] === s.coordinates[i][0] && t.geometry.coordinates[1] === s.coordinates[i][1] && (o = !0, u = !0), i++;
    }
    else if ("LineString" === s.type)
        for (i = 0; !a && i < s.coordinates.length - 1;)
            pointOnSegment(t.geometry.coordinates[0], t.geometry.coordinates[1], s.coordinates[i][0], s.coordinates[i][1], s.coordinates[i + 1][0], s.coordinates[i + 1][1]) && (a = !0, o = !0), i++;
    else if ("MultiLineString" === s.type)
        for (var l = 0; l < s.coordinates.length;) {
            a = !1, i = 0;
            for (var c = s.coordinates[l]; !a && i < c.length - 1;)
                pointOnSegment(t.geometry.coordinates[0], t.geometry.coordinates[1], c[i][0], c[i][1], c[i + 1][0], c[i + 1][1]) && (a = !0, o = !0), i++;
            l++;
        }
    else
        "Polygon" !== s.type && "MultiPolygon" !== s.type || booleanPointInPolygon(t, s) && (o = !0);
    n++;
} if (o)
    return t; var h = featureCollection$1([]); for (n = 0; n < r.features.length; n++)
    h.features = h.features.concat(explode(r.features[n]).features); return point$2(nearestPoint(t, h).geometry.coordinates); }
function normalize(e) { return "FeatureCollection" !== e.type ? featureCollection$1("Feature" !== e.type ? [feature$2(e)] : [e]) : e; }
function pointOnSegment(e, r, t, o, n, i) { return Math.sqrt((n - t) * (n - t) + (i - o) * (i - o)) === Math.sqrt((e - t) * (e - t) + (r - o) * (r - o)) + Math.sqrt((n - e) * (n - e) + (i - r) * (i - r)); }
var helpers = chunk_53560ba7_js_1.a(function (e, r) { function t(e, r, t) { void 0 === t && (t = {}); var o = { type: "Feature" }; return (0 === t.id || t.id) && (o.id = t.id), t.bbox && (o.bbox = t.bbox), o.properties = r || {}, o.geometry = e, o; } function o(e, r, o) { return void 0 === o && (o = {}), t({ type: "Point", coordinates: e }, r, o); } function n(e, r, o) { void 0 === o && (o = {}); for (var n = 0, i = e; n < i.length; n++) {
    var s = i[n];
    if (s.length < 4)
        throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");
    for (var a = 0; a < s[s.length - 1].length; a++)
        if (s[s.length - 1][a] !== s[0][a])
            throw new Error("First and last Position are not equivalent.");
} return t({ type: "Polygon", coordinates: e }, r, o); } function i(e, r, o) { if (void 0 === o && (o = {}), e.length < 2)
    throw new Error("coordinates must be an array of two or more positions"); return t({ type: "LineString", coordinates: e }, r, o); } function s(e, r) { void 0 === r && (r = {}); var t = { type: "FeatureCollection" }; return r.id && (t.id = r.id), r.bbox && (t.bbox = r.bbox), t.features = e, t; } function a(e, r, o) { return void 0 === o && (o = {}), t({ type: "MultiLineString", coordinates: e }, r, o); } function u(e, r, o) { return void 0 === o && (o = {}), t({ type: "MultiPoint", coordinates: e }, r, o); } function l(e, r, o) { return void 0 === o && (o = {}), t({ type: "MultiPolygon", coordinates: e }, r, o); } function c(e, t) { void 0 === t && (t = "kilometers"); var o = r.factors[t]; if (!o)
    throw new Error(t + " units is invalid"); return e * o; } function h(e, t) { void 0 === t && (t = "kilometers"); var o = r.factors[t]; if (!o)
    throw new Error(t + " units is invalid"); return e / o; } function d(e) { return e % (2 * Math.PI) * 180 / Math.PI; } function f(e) { return !isNaN(e) && null !== e && !Array.isArray(e) && !/^\s*$/.test(e); } Object.defineProperty(r, "__esModule", { value: !0 }), r.earthRadius = 6371008.8, r.factors = { centimeters: 100 * r.earthRadius, centimetres: 100 * r.earthRadius, degrees: r.earthRadius / 111325, feet: 3.28084 * r.earthRadius, inches: 39.37 * r.earthRadius, kilometers: r.earthRadius / 1e3, kilometres: r.earthRadius / 1e3, meters: r.earthRadius, metres: r.earthRadius, miles: r.earthRadius / 1609.344, millimeters: 1e3 * r.earthRadius, millimetres: 1e3 * r.earthRadius, nauticalmiles: r.earthRadius / 1852, radians: 1, yards: r.earthRadius / 1.0936 }, r.unitsFactors = { centimeters: 100, centimetres: 100, degrees: 1 / 111325, feet: 3.28084, inches: 39.37, kilometers: .001, kilometres: .001, meters: 1, metres: 1, miles: 1 / 1609.344, millimeters: 1e3, millimetres: 1e3, nauticalmiles: 1 / 1852, radians: 1 / r.earthRadius, yards: 1 / 1.0936 }, r.areaFactors = { acres: 247105e-9, centimeters: 1e4, centimetres: 1e4, feet: 10.763910417, inches: 1550.003100006, kilometers: 1e-6, kilometres: 1e-6, meters: 1, metres: 1, miles: 3.86e-7, millimeters: 1e6, millimetres: 1e6, yards: 1.195990046 }, r.feature = t, r.geometry = function (e, r, t) { switch (void 0 === t && (t = {}), e) {
    case "Point": return o(r).geometry;
    case "LineString": return i(r).geometry;
    case "Polygon": return n(r).geometry;
    case "MultiPoint": return u(r).geometry;
    case "MultiLineString": return a(r).geometry;
    case "MultiPolygon": return l(r).geometry;
    default: throw new Error(e + " is invalid");
} }, r.point = o, r.points = function (e, r, t) { return void 0 === t && (t = {}), s(e.map(function (e) { return o(e, r); }), t); }, r.polygon = n, r.polygons = function (e, r, t) { return void 0 === t && (t = {}), s(e.map(function (e) { return n(e, r); }), t); }, r.lineString = i, r.lineStrings = function (e, r, t) { return void 0 === t && (t = {}), s(e.map(function (e) { return i(e, r); }), t); }, r.featureCollection = s, r.multiLineString = a, r.multiPoint = u, r.multiPolygon = l, r.geometryCollection = function (e, r, o) { return void 0 === o && (o = {}), t({ type: "GeometryCollection", geometries: e }, r, o); }, r.round = function (e, r) { if (void 0 === r && (r = 0), r && !(r >= 0))
    throw new Error("precision must be a positive number"); var t = Math.pow(10, r || 0); return Math.round(e * t) / t; }, r.radiansToLength = c, r.lengthToRadians = h, r.lengthToDegrees = function (e, r) { return d(h(e, r)); }, r.bearingToAzimuth = function (e) { var r = e % 360; return r < 0 && (r += 360), r; }, r.radiansToDegrees = d, r.degreesToRadians = function (e) { return e % 360 * Math.PI / 180; }, r.convertLength = function (e, r, t) { if (void 0 === r && (r = "kilometers"), void 0 === t && (t = "kilometers"), !(e >= 0))
    throw new Error("length must be a positive number"); return c(h(e, r), t); }, r.convertArea = function (e, t, o) { if (void 0 === t && (t = "meters"), void 0 === o && (o = "kilometers"), !(e >= 0))
    throw new Error("area must be a positive number"); var n = r.areaFactors[t]; if (!n)
    throw new Error("invalid original units"); var i = r.areaFactors[o]; if (!i)
    throw new Error("invalid final units"); return e / n * i; }, r.isNumber = f, r.isObject = function (e) { return !!e && e.constructor === Object; }, r.validateBBox = function (e) { if (!e)
    throw new Error("bbox is required"); if (!Array.isArray(e))
    throw new Error("bbox must be an Array"); if (4 !== e.length && 6 !== e.length)
    throw new Error("bbox must be an Array of 4 or 6 numbers"); e.forEach(function (e) { if (!f(e))
    throw new Error("bbox must only contain numbers"); }); }, r.validateId = function (e) { if (!e)
    throw new Error("id is required"); if (-1 === ["string", "number"].indexOf(typeof e))
    throw new Error("id must be a number or a string"); }, r.radians2degrees = function () { throw new Error("method has been renamed to `radiansToDegrees`"); }, r.degrees2radians = function () { throw new Error("method has been renamed to `degreesToRadians`"); }, r.distanceToDegrees = function () { throw new Error("method has been renamed to `lengthToDegrees`"); }, r.distanceToRadians = function () { throw new Error("method has been renamed to `lengthToRadians`"); }, r.radiansToDistance = function () { throw new Error("method has been renamed to `radiansToLength`"); }, r.bearingToAngle = function () { throw new Error("method has been renamed to `bearingToAzimuth`"); }, r.convertDistance = function () { throw new Error("method has been renamed to `convertLength`"); }; }), helpers$1 = chunk_53560ba7_js_1.b(helpers), helpers_1 = helpers.earthRadius, helpers_2 = helpers.factors, helpers_3 = helpers.unitsFactors, helpers_4 = helpers.areaFactors, helpers_5 = helpers.feature, helpers_6 = helpers.geometry, helpers_7 = helpers.point, helpers_8 = helpers.points, helpers_9 = helpers.polygon, helpers_10 = helpers.polygons, helpers_11 = helpers.lineString, helpers_12 = helpers.lineStrings, helpers_13 = helpers.featureCollection, helpers_14 = helpers.multiLineString, helpers_15 = helpers.multiPoint, helpers_16 = helpers.multiPolygon, helpers_17 = helpers.geometryCollection, helpers_18 = helpers.round, helpers_19 = helpers.radiansToLength, helpers_20 = helpers.lengthToRadians, helpers_21 = helpers.lengthToDegrees, helpers_22 = helpers.bearingToAzimuth, helpers_23 = helpers.radiansToDegrees, helpers_24 = helpers.degreesToRadians, helpers_25 = helpers.convertLength, helpers_26 = helpers.convertArea, helpers_27 = helpers.isNumber, helpers_28 = helpers.isObject, helpers_29 = helpers.validateBBox, helpers_30 = helpers.validateId, helpers_31 = helpers.radians2degrees, helpers_32 = helpers.degrees2radians, helpers_33 = helpers.distanceToDegrees, helpers_34 = helpers.distanceToRadians, helpers_35 = helpers.radiansToDistance, helpers_36 = helpers.bearingToAngle, helpers_37 = helpers.convertDistance, Popup = function () { function e() { this.features = [], this.clickEventDelay = 50, this.closeKey = 27, this.maxWidth = "none"; } return e.prototype.getOptions = function () { return "string" == typeof this.componentOptions ? JSON.parse(this.componentOptions) : this.componentOptions || {}; }, e.prototype.handleFeatureClick = function (e) { var r = this, t = this.el.closest("gl-style"), o = chunk_853b4351_js_1.b(this.layers).map(function (e) { return t.id + ":" + e; }), n = e.detail.features.filter(function (e) { return -1 !== o.indexOf(e.layer.id); }); n.length && (this.clickEventDelay ? (Array.prototype.push.apply(this.features, n), this.popupTimeout || (this.popupTimeout = window.setTimeout(function () { return tslib_1.__awaiter(r, void 0, void 0, function () { return tslib_1.__generator(this, function (e) { return this.popupTimeout = null, this.features.length && this.openPopup(this.features), this.features = [], [2]; }); }); }, this.clickEventDelay))) : this.openPopup(n)); }, e.prototype.handleKeyup = function (e) { e.keyCode === this.closeKey && this.removePopup(); }, e.prototype.isOpen = function () { return tslib_1.__awaiter(this, void 0, void 0, function () { return tslib_1.__generator(this, function (e) { return [2, !!this.popup && this.popup.isOpen()]; }); }); }, e.prototype.removePopup = function () { return tslib_1.__awaiter(this, void 0, void 0, function () { return tslib_1.__generator(this, function (e) { return this.popup && this.popup.remove(), [2]; }); }); }, e.prototype.openPopup = function (e) { var r = pointOnFeature(helpers$1.featureCollection(e)), t = document.createElement(this.component); t.features = e; var o = this.getOptions(); for (var n in this.getOptions())
    t[n] = o[n]; this.popup = new mapboxgl.Popup({ maxWidth: this.maxWidth }).setLngLat(r.geometry.coordinates).setDOMContent(t).addTo(this.el.closest("gl-map").map); }, Object.defineProperty(e, "is", { get: function () { return "gl-popup"; }, enumerable: !0, configurable: !0 }), Object.defineProperty(e, "properties", { get: function () { return { clickEventDelay: { type: Number, attr: "click-event-delay" }, closeKey: { type: Number, attr: "close-key" }, component: { type: String, attr: "component" }, componentOptions: { type: "Any", attr: "component-options" }, el: { elementRef: !0 }, isOpen: { method: !0 }, layers: { type: String, attr: "layers" }, maxWidth: { type: String, attr: "max-width" }, removePopup: { method: !0 } }; }, enumerable: !0, configurable: !0 }), Object.defineProperty(e, "listeners", { get: function () { return [{ name: "body:glFeatureClick", method: "handleFeatureClick" }, { name: "body:keyup", method: "handleKeyup" }]; }, enumerable: !0, configurable: !0 }), Object.defineProperty(e, "style", { get: function () { return "gl-popup{display:none}gl-map .mapboxgl-popup-content h2{font-size:1.3em}"; }, enumerable: !0, configurable: !0 }), e; }();
exports.GlPopup = Popup;
