import { b64Vecs, lerp } from "@tldraw/editor";
const interpolateSegments = (startSegments, endSegments, progress) => {
  const startPoints = [];
  const endPoints = [];
  startSegments.forEach((segment) => startPoints.push(...b64Vecs.decodePoints(segment.points)));
  endSegments.forEach((segment) => endPoints.push(...b64Vecs.decodePoints(segment.points)));
  const maxLength = Math.max(startPoints.length, endPoints.length);
  const pointsToUseStart = [];
  const pointsToUseEnd = [];
  for (let i = 0; i < maxLength; i++) {
    pointsToUseStart.push(startPoints[i] || startPoints[startPoints.length - 1]);
    pointsToUseEnd.push(endPoints[i] || endPoints[endPoints.length - 1]);
  }
  const interpolatedPoints = pointsToUseStart.map((point, k) => {
    let z = 0.5;
    if (pointsToUseEnd[k].z !== void 0 && point.z !== void 0) {
      z = lerp(point.z, pointsToUseEnd[k].z, progress);
    }
    return {
      x: lerp(point.x, pointsToUseEnd[k].x, progress),
      y: lerp(point.y, pointsToUseEnd[k].y, progress),
      z
    };
  });
  return [
    {
      type: "free",
      points: b64Vecs.encodePoints(interpolatedPoints)
    }
  ];
};
export {
  interpolateSegments
};
//# sourceMappingURL=interpolate-props.mjs.map
