#pragma once

#include <vector>
#include <random>

#include "common/fixed_keys.hpp"

class HumanCurveGenerator {
private:
    std::mt19937 m_rng;
    std::normal_distribution<float> m_jitterDist;
    std::normal_distribution<float> m_dwellDist;

public:
    HumanCurveGenerator();

    // Sinh danh sách các bước di chuyển tương đối (dx, dy) theo đường cong Bézier (Zero Heap Allocation)
    void GenerateTrajectory(
        Vector2D start,
        Vector2D target,
        common::TrajectoryBuffer& outBuf,
        int steps = 25,
        bool enableOvershoot = true
    );

    // Sinh danh sách các bước di chuyển tương đối (dx, dy) theo đường cong Bézier (Legacy std::vector)
    std::vector<Vector2D> GenerateTrajectory(
        Vector2D start,
        Vector2D target,
        int steps = 25,
        bool enableOvershoot = true
    );

    // Sinh thời gian giữ phím/chuột ngẫu nhiên theo phân phối sinh học (ms)
    int GenerateDwellTimeMs(float meanMs = 75.0f, float stdDevMs = 15.0f);

private:
    Vector2D CalculateCubicBezier(float t, Vector2D p0, Vector2D p1, Vector2D p2, Vector2D p3);
};
