var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var parse_direction_data_to_geo_json_exports = {};
__export(parse_direction_data_to_geo_json_exports, {
  parseDirectionDataToGeoJSON: () => parseDirectionDataToGeoJSON
});
module.exports = __toCommonJS(parse_direction_data_to_geo_json_exports);
var import_helpers = require("@turf/helpers");
var import_get_arrows_angles = require("./get-arrows-angles.js");
const getConnectionGeoJSONFeature = (feature, angle, coordinates) => (0, import_helpers.point)(coordinates, { ...feature.properties, __angle: angle });
const parseDirectionDataToGeoJSON = (props) => {
  const { geoJsonData, directionIndicator } = props;
  const features = [];
  for (let i = 0; i < geoJsonData.features.length; i++) {
    const feature = geoJsonData.features[i];
    const { coordinates } = feature.geometry;
    const { endMarkerAngle, startMarkerAngle } = (0, import_get_arrows_angles.getArrowsAngles)(coordinates);
    const showStartArrow = directionIndicator !== "end";
    const showEndArrow = directionIndicator !== "start";
    const startCoordinate = coordinates[0];
    const endCoordinate = coordinates[coordinates.length - 1];
    if (showStartArrow) {
      const startPoint = getConnectionGeoJSONFeature(
        feature,
        startMarkerAngle,
        startCoordinate
      );
      features.push({
        ...startPoint,
        properties: {
          ...startPoint.properties,
          id: `${feature.properties.id}-direction-start`
        }
      });
    }
    if (showEndArrow) {
      const endPoint = getConnectionGeoJSONFeature(
        feature,
        endMarkerAngle,
        endCoordinate
      );
      features.push({
        ...endPoint,
        properties: {
          ...endPoint.properties,
          id: `${feature.properties.id}-direction-end`
        }
      });
    }
  }
  return {
    ...geoJsonData,
    features
  };
};
