var e=6371008.8,r={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:39.37*e,kilometers:6371.0088,kilometres:6371.0088,meters:e,metres:e,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:e/1852,radians:1,yards:6967335.223679999},t={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046};function n(e,r,t){void 0===t&&(t={});var n={type:"Feature"};return(0===t.id||t.id)&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.properties=r||{},n.geometry=e,n}function o(e,r,t){switch(e){case"Point":return i(r).geometry;case"LineString":return s(r).geometry;case"Polygon":return a(r).geometry;case"MultiPoint":return y(r).geometry;case"MultiLineString":return g(r).geometry;case"MultiPolygon":return d(r).geometry;default:throw new Error(e+" is invalid")}}function i(e,r,t){if(void 0===t&&(t={}),!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(!E(e[0])||!E(e[1]))throw new Error("coordinates must contain numbers");return n({type:"Point",coordinates:e},r,t)}function u(e,r,t){return void 0===t&&(t={}),f(e.map((function(e){return i(e,r)})),t)}function a(e,r,t){void 0===t&&(t={});for(var o=0,i=e;o<i.length;o++){var u=i[o];if(u.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var a=0;a<u[u.length-1].length;a++)if(u[u.length-1][a]!==u[0][a])throw new Error("First and last Position are not equivalent.")}return n({type:"Polygon",coordinates:e},r,t)}function l(e,r,t){return void 0===t&&(t={}),f(e.map((function(e){return a(e,r)})),t)}function s(e,r,t){if(void 0===t&&(t={}),e.length<2)throw new Error("coordinates must be an array of two or more positions");return n({type:"LineString",coordinates:e},r,t)}function c(e,r,t){return void 0===t&&(t={}),f(e.map((function(e){return s(e,r)})),t)}function f(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 g(e,r,t){return void 0===t&&(t={}),n({type:"MultiLineString",coordinates:e},r,t)}function y(e,r,t){return void 0===t&&(t={}),n({type:"MultiPoint",coordinates:e},r,t)}function d(e,r,t){return void 0===t&&(t={}),n({type:"MultiPolygon",coordinates:e},r,t)}function m(e,r,t){return void 0===t&&(t={}),n({type:"GeometryCollection",geometries:e},r,t)}function h(e,t){void 0===t&&(t="kilometers");var n=r[t];if(!n)throw new Error(t+" units is invalid");return e*n}function v(e,t){void 0===t&&(t="kilometers");var n=r[t];if(!n)throw new Error(t+" units is invalid");return e/n}function p(e,r){return v(e,r)%(2*Math.PI)*180/Math.PI}function w(e){var r=e%360;return r<0&&(r+=360),r}function b(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 h(v(e,r),t)}function P(e,r,n){if(void 0===r&&(r="meters"),void 0===n&&(n="kilometers"),!(e>=0))throw new Error("area must be a positive number");var o=t[r];if(!o)throw new Error("invalid original units");var i=t[n];if(!i)throw new Error("invalid final units");return e/o*i}function E(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function M(e){return!!e&&e.constructor===Object}function F(e,r,t){if(null!==e)for(var n,o,i,u,a,l,s,c,f=0,g=0,y=e.type,d="FeatureCollection"===y,m="Feature"===y,h=d?e.features.length:1,v=0;v<h;v++){a=(c=!!(s=d?e.features[v].geometry:m?e.geometry:e)&&"GeometryCollection"===s.type)?s.geometries.length:1;for(var p=0;p<a;p++){var w=0,b=0;if(null!==(u=c?s.geometries[p]:s)){l=u.coordinates;var P=u.type;switch(f=!t||"Polygon"!==P&&"MultiPolygon"!==P?0:1,P){case null:break;case"Point":if(!1===r(l,g,v,w,b))return!1;g++,w++;break;case"LineString":case"MultiPoint":for(n=0;n<l.length;n++){if(!1===r(l[n],g,v,w,b))return!1;g++,"MultiPoint"===P&&w++}"LineString"===P&&w++;break;case"Polygon":case"MultiLineString":for(n=0;n<l.length;n++){for(o=0;o<l[n].length-f;o++){if(!1===r(l[n][o],g,v,w,b))return!1;g++}"MultiLineString"===P&&w++,"Polygon"===P&&b++}"Polygon"===P&&w++;break;case"MultiPolygon":for(n=0;n<l.length;n++){for(b=0,o=0;o<l[n].length;o++){for(i=0;i<l[n][o].length-f;i++){if(!1===r(l[n][o][i],g,v,w,b))return!1;g++}b++}w++}break;case"GeometryCollection":for(n=0;n<u.geometries.length;n++)if(!1===F(u.geometries[n],r,t))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function k(e,r,t,n){var o=t;return F(e,(function(e,n,i,u,a){o=0===n&&void 0===t?e:r(o,e,n,i,u,a)}),n),o}function S(e,r){var t;switch(e.type){case"FeatureCollection":for(t=0;t<e.features.length&&!1!==r(e.features[t].properties,t);t++);break;case"Feature":r(e.properties,0)}}function L(e,r,t){var n=t;return S(e,(function(e,o){n=0===o&&void 0===t?e:r(n,e,o)})),n}function x(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 A(e,r,t){var n=t;return x(e,(function(e,o){n=0===o&&void 0===t?e:r(n,e,o)})),n}function C(e){var r=[];return F(e,(function(e){r.push(e)})),r}function I(e,r){var t,n,o,i,u,a,l,s,c,f,g=0,y="FeatureCollection"===e.type,d="Feature"===e.type,m=y?e.features.length:1;for(t=0;t<m;t++){for(a=y?e.features[t].geometry:d?e.geometry:e,s=y?e.features[t].properties:d?e.properties:{},c=y?e.features[t].bbox:d?e.bbox:void 0,f=y?e.features[t].id:d?e.id:void 0,u=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,o=0;o<u;o++)if(null!==(i=l?a.geometries[o]:a))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===r(i,g,s,c,f))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===r(i.geometries[n],g,s,c,f))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===r(null,g,s,c,f))return!1;g++}}function q(e,r,t){var n=t;return I(e,(function(e,o,i,u,a){n=0===o&&void 0===t?e:r(n,e,o,i,u,a)})),n}function G(e,r){I(e,(function(e,t,o,i,u){var a,l=null===e?null:e.type;switch(l){case null:case"Point":case"LineString":case"Polygon":return!1!==r(n(e,o,{bbox:i,id:u}),t,0)&&void 0}switch(l){case"MultiPoint":a="Point";break;case"MultiLineString":a="LineString";break;case"MultiPolygon":a="Polygon"}for(var s=0;s<e.coordinates.length;s++){var c=e.coordinates[s];if(!1===r(n({type:a,coordinates:c},o),t,s))return!1}}))}function N(e,r,t){var n=t;return G(e,(function(e,o,i){n=0===o&&0===i&&void 0===t?e:r(n,e,o,i)})),n}function j(e,r){G(e,(function(e,t,n){var o=0;if(e.geometry){var i=e.geometry.type;if("Point"!==i&&"MultiPoint"!==i){var u,a=0,l=0,c=0;return!1!==F(e,(function(i,f,g,y,d){if(void 0===u||t>a||y>l||d>c)return u=i,a=t,l=y,c=d,void(o=0);var m=s([u,i],e.properties);if(!1===r(m,t,n,d,o))return!1;o++,u=i}))&&void 0}}}))}function O(e,r,t){var n=t,o=!1;return j(e,(function(e,i,u,a,l){n=!1===o&&void 0===t?e:r(n,e,i,u,a,l),o=!0})),n}function B(e,r){if(!e)throw new Error("geojson is required");G(e,(function(e,t,n){if(null!==e.geometry){var o=e.geometry.type,i=e.geometry.coordinates;switch(o){case"LineString":if(!1===r(e,t,n,0,0))return!1;break;case"Polygon":for(var u=0;u<i.length;u++)if(!1===r(s(i[u],e.properties),t,n,u))return!1}}}))}function J(e,r,t){var n=t;return B(e,(function(e,o,i,u){n=0===o&&void 0===t?e:r(n,e,o,i,u)})),n}function T(e,r){if(!M(r=r||{}))throw new Error("options is invalid");var t,n=r.featureIndex||0,o=r.multiFeatureIndex||0,i=r.geometryIndex||0,u=r.segmentIndex||0,a=r.properties;switch(e.type){case"FeatureCollection":n<0&&(n=e.features.length+n),a=a||e.features[n].properties,t=e.features[n].geometry;break;case"Feature":a=a||e.properties,t=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":t=e;break;default:throw new Error("geojson is invalid")}if(null===t)return null;var l=t.coordinates;switch(t.type){case"Point":case"MultiPoint":return null;case"LineString":return u<0&&(u=l.length+u-1),s([l[u],l[u+1]],a,r);case"Polygon":return i<0&&(i=l.length+i),u<0&&(u=l[i].length+u-1),s([l[i][u],l[i][u+1]],a,r);case"MultiLineString":return o<0&&(o=l.length+o),u<0&&(u=l[o].length+u-1),s([l[o][u],l[o][u+1]],a,r);case"MultiPolygon":return o<0&&(o=l.length+o),i<0&&(i=l[o].length+i),u<0&&(u=l[o][i].length-u-1),s([l[o][i][u],l[o][i][u+1]],a,r)}throw new Error("geojson is invalid")}function U(e,r){if(!M(r=r||{}))throw new Error("options is invalid");var t,n=r.featureIndex||0,o=r.multiFeatureIndex||0,u=r.geometryIndex||0,a=r.coordIndex||0,l=r.properties;switch(e.type){case"FeatureCollection":n<0&&(n=e.features.length+n),l=l||e.features[n].properties,t=e.features[n].geometry;break;case"Feature":l=l||e.properties,t=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":t=e;break;default:throw new Error("geojson is invalid")}if(null===t)return null;var s=t.coordinates;switch(t.type){case"Point":return i(s,l,r);case"MultiPoint":return o<0&&(o=s.length+o),i(s[o],l,r);case"LineString":return a<0&&(a=s.length+a),i(s[a],l,r);case"Polygon":return u<0&&(u=s.length+u),a<0&&(a=s[u].length+a),i(s[u][a],l,r);case"MultiLineString":return o<0&&(o=s.length+o),a<0&&(a=s[o].length+a),i(s[o][a],l,r);case"MultiPolygon":return o<0&&(o=s.length+o),u<0&&(u=s[o].length+u),a<0&&(a=s[o][u].length-a),i(s[o][u][a],l,r)}throw new Error("geojson is invalid")}function R(e){var r=[1/0,1/0,-1/0,-1/0];return F(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 z(e,r){void 0===r&&(r={});var t=Number(e[0]),n=Number(e[1]),o=Number(e[2]),i=Number(e[3]);if(6===e.length)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var u=[t,n];return a([[u,[o,n],[o,i],[t,i],u]],r.properties,{bbox:e,id:r.id})}function D(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){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&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function H(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function K(e){if(e.length>1&&E(e[0])&&E(e[1]))return!0;if(Array.isArray(e[0])&&e[0].length)return K(e[0]);throw new Error("coordinates must only contain numbers")}function Q(e,r,t){if(!r||!t)throw new Error("type and name required");if(!e||e.type!==r)throw new Error("Invalid input to "+t+": must be a "+r+", given "+e.type)}function V(e,r,t){if(!e)throw new Error("No feature passed");if(!t)throw new Error(".featureOf() requires a name");if(!e||"Feature"!==e.type||!e.geometry)throw new Error("Invalid input to "+t+", Feature with geometry required");if(!e.geometry||e.geometry.type!==r)throw new Error("Invalid input to "+t+": must be a "+r+", given "+e.geometry.type)}function W(e,r,t){if(!e)throw new Error("No featureCollection passed");if(!t)throw new Error(".collectionOf() requires a name");if(!e||"FeatureCollection"!==e.type)throw new Error("Invalid input to "+t+", FeatureCollection required");for(var n=0,o=e.features;n<o.length;n++){var i=o[n];if(!i||"Feature"!==i.type||!i.geometry)throw new Error("Invalid input to "+t+", Feature with geometry required");if(!i.geometry||i.geometry.type!==r)throw new Error("Invalid input to "+t+": must be a "+r+", given "+i.geometry.type)}}function X(e){return"Feature"===e.type?e.geometry:e}function Y(e,r){return"FeatureCollection"===e.type?"FeatureCollection":"GeometryCollection"===e.type?"GeometryCollection":"Feature"===e.type&&null!==e.geometry?e.geometry.type:e.type}function Z(e,r,t){if(void 0===t&&(t={}),!e)throw new Error("point is required");if(!r)throw new Error("polygon is required");var n=D(e),o=X(r),i=o.type,u=r.bbox,a=o.coordinates;if(u&&!1===function(e,r){return r[0]<=e[0]&&r[1]<=e[1]&&r[2]>=e[0]&&r[3]>=e[1]}(n,u))return!1;"Polygon"===i&&(a=[a]);for(var l=!1,s=0;s<a.length&&!l;s++)if($(n,a[s][0],t.ignoreBoundary)){for(var c=!1,f=1;f<a[s].length&&!c;)$(n,a[s][f],!t.ignoreBoundary)&&(c=!0),f++;c||(l=!0)}return l}function $(e,r,t){var n=!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 o=0,i=r.length-1;o<r.length;i=o++){var u=r[o][0],a=r[o][1],l=r[i][0],s=r[i][1];if(e[1]*(u-l)+a*(l-e[0])+s*(e[0]-u)==0&&(u-e[0])*(l-e[0])<=0&&(a-e[1])*(s-e[1])<=0)return!t;a>e[1]!=s>e[1]&&e[0]<(l-u)*(e[1]-a)/(s-a)+u&&(n=!n)}return n}R.default=R;export{R as bbox,z as bboxPolygon,w as bearingToAzimuth,Z as booleanPointInPolygon,W as collectionOf,K as containsNumber,P as convertArea,b as convertLength,C as coordAll,F as coordEach,k as coordReduce,n as feature,f as featureCollection,x as featureEach,V as featureOf,A as featureReduce,U as findPoint,T as findSegment,G as flattenEach,N as flattenReduce,Q as geojsonType,I as geomEach,q as geomReduce,o as geometry,m as geometryCollection,D as getCoord,H as getCoords,X as getGeom,Y as getType,p as lengthToDegrees,v as lengthToRadians,B as lineEach,J as lineReduce,s as lineString,c as lineStrings,g as multiLineString,y as multiPoint,d as multiPolygon,i as point,u as points,a as polygon,l as polygons,S as propEach,L as propReduce,h as radiansToLength,j as segmentEach,O as segmentReduce};
