#include <iostream>
#include <vector>
#include <curl/curl.h>
#include "histogram.h"
#include "text.h"
#include "svg.h"
struct Input {
    vector<double> numbers;
    size_t bin_count{};
};

Input input_data(std::istream& in, bool prompt)
{
    Input data;
    size_t number_count;
    if(prompt)
    {
        cerr << "Enter the number of elements: ";
    }
    in >> number_count;

    data.numbers.resize(number_count);
    if(prompt)
    {
        cerr << "\nEnter " << number_count << " elements:" << endl;
    }
    for (size_t i = 0; i < number_count; i++)
    {
        in >> data.numbers[i];
    }
    if(prompt)
    {
        cerr << "Enter the number of bins: ";
    }
    in >> data.bin_count;

    return data;
}

int main() {
    curl_global_init(CURL_GLOBAL_ALL);
    using namespace std;
    auto in = input_data(cin,true);
    auto bins = make_histogram(in.bin_count, in.numbers);
    show_histogram_svg(bins);
    return 0;
}
