var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var get_arc_line_features_exports = {};
__export(get_arc_line_features_exports, {
  getArcLineFeatures: () => getArcLineFeatures
});
module.exports = __toCommonJS(get_arc_line_features_exports);
var import_bearing = __toESM(require("@turf/bearing"));
var import_destination = __toESM(require("@turf/destination"));
var import_distance = __toESM(require("@turf/distance"));
var import_helpers = require("@turf/helpers");
var import_length = __toESM(require("@turf/length"));
var import_line_arc = __toESM(require("@turf/line-arc"));
var import_midpoint = __toESM(require("@turf/midpoint"));
var import_projection = require("@turf/projection");
const getArcFeatureItem = (coordinates) => {
  const feature = (0, import_helpers.lineString)(coordinates);
  const parsedLineString = (0, import_projection.toWgs84)(feature);
  const {
    geometry: {
      coordinates: [start, end]
    }
  } = parsedLineString;
  const lineDistance = (0, import_length.default)(parsedLineString);
  const midPoint = (0, import_midpoint.default)(start, end);
  const bearing = (0, import_bearing.default)(start, end) - 90;
  const center = (0, import_destination.default)(midPoint, lineDistance, bearing);
  const lineArc = (0, import_line_arc.default)(
    center,
    (0, import_distance.default)(center, start),
    (0, import_bearing.default)(center, end),
    (0, import_bearing.default)(center, start),
    { steps: 256 }
  );
  return (0, import_projection.toMercator)(lineArc);
};
const getArcLineFeatures = (path, featureProperties) => {
  if (path.length < 2) {
    return [];
  }
  const finalCoordinates = [];
  for (let i = 0; i < path.length - 1; i++) {
    const start = path[i];
    const end = path[i + 1];
    const coordinates = [
      [start.longitude, start.latitude],
      [end.longitude, end.latitude]
    ];
    const feature = getArcFeatureItem(coordinates);
    finalCoordinates.push(...feature.geometry.coordinates.reverse());
  }
  const finalFeature = (0, import_helpers.lineString)(finalCoordinates, {
    ...featureProperties
  });
  return [finalFeature];
};
