{"version":3,"sources":["jsdelivr-header.js","/npm/@turf/union@7.3.5/index.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,+KCqDA,SAAS,EACP,EACA,EAA8B,IAE9B,MAAM,EAAyB,GAK3B,GAJK,EAAA,GAAW,IACZ,EAAA,KAAK,EAAK,YAA4B,IAG1C,EAAM,OAAS,EACX,UAAI,MAAM,mCAGZ,MAAA,EAAmB,EAAA,MAAM,EAAM,MAAO,EAAM,MAAM,IACpD,OAAmB,IAAnB,EAAQ,OAAqB,KACV,IAAnB,EAAQ,OAAqB,EAAQ,EAAQ,GAAI,EAAQ,YACjD,EAAa,EAAS,EAAQ,WAC5C,CAGA,IAAO,EAAQ,S","file":"/npm/@turf/union@7.3.5/dist/esm/index.js/+esm","sourceRoot":"","sourcesContent":["/**\n * Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.39.0.\n * Original file: /npm/@turf/union@7.3.5/dist/esm/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import * as polyclip from \"polyclip-ts\";\nimport { multiPolygon, polygon } from \"@turf/helpers\";\nimport { geomEach } from \"@turf/meta\";\nimport {\n  FeatureCollection,\n  Feature,\n  Polygon,\n  MultiPolygon,\n  GeoJsonProperties,\n} from \"geojson\";\n\n/**\n * Takes a collection of input polygons and returns a combined polygon. If the\n * input polygons are not contiguous, this function returns a multi-polygon\n * feature.\n *\n * @function\n * @param {FeatureCollection<Polygon|MultiPolygon>} features input polygon features\n * @param {Object} [options={}] Optional Parameters\n * @param {GeoJsonProperties} [options.properties={}] properties to assign to output feature\n * @returns {Feature<(Polygon|MultiPolygon)>|null} a combined polygon or multi-polygon feature, or null if there were no input polygons to combine\n * @example\n *\n * const poly1 = turf.polygon(\n *   [\n *     [\n *       [-82.574787, 35.594087],\n *       [-82.574787, 35.615581],\n *       [-82.545261, 35.615581],\n *       [-82.545261, 35.594087],\n *       [-82.574787, 35.594087],\n *     ],\n *   ],\n *   { fill: \"#0f0\" }\n * );\n *\n * const poly2 = turf.polygon(\n *   [\n *     [\n *       [-82.560024, 35.585153],\n *       [-82.560024, 35.602602],\n *       [-82.52964, 35.602602],\n *       [-82.52964, 35.585153],\n *       [-82.560024, 35.585153],\n *     ],\n *   ],\n * );\n *\n * const union = turf.union(turf.featureCollection([poly1, poly2]));\n *\n * //addToMap\n * const addToMap = { poly1, poly2, union };\n *\n * poly1.properties.fill = \"#0f0\";\n * poly2.properties.fill = \"#00f\";\n * union.properties.stroke = \"red\";\n * union.properties[\"stroke-width\"] = 4;\n * union.properties.fill = \"transparent\";\n */\nfunction union<P extends GeoJsonProperties = GeoJsonProperties>(\n  features: FeatureCollection<Polygon | MultiPolygon>,\n  options: { properties?: P } = {}\n): Feature<Polygon | MultiPolygon, P> | null {\n  const geoms: polyclip.Geom[] = [];\n  geomEach(features, (geom) => {\n    geoms.push(geom.coordinates as polyclip.Geom);\n  });\n\n  if (geoms.length < 2) {\n    throw new Error(\"Must have at least 2 geometries\");\n  }\n\n  const unioned = polyclip.union(geoms[0], ...geoms.slice(1));\n  if (unioned.length === 0) return null;\n  if (unioned.length === 1) return polygon(unioned[0], options.properties);\n  else return multiPolygon(unioned, options.properties);\n}\n\nexport { union };\nexport default union;\n"]}