#pragma once

#include <LibJS/Forward.h>
#include <LibJS/Runtime/NativeFunction.h>
#include <LibJS/Runtime/Object.h>
#include <LibJS/Runtime/Value.h>
#include <LibWeb/Bindings/InterfaceObject.h>
#include <LibWeb/WebIDL/Types.h>

namespace Web::Bindings {

struct AudioBufferConstructor {
public:
    static void initialize(JS::Realm&, JS::NativeFunction&);
    static JS::ThrowCompletionOr<GC::Ref<JS::Object>> construct(InterfaceConstructor&, JS::FunctionObject&);

private:
};

struct AudioBufferPrototype {
public:
    static void initialize(JS::Realm&, JS::Object&);
    static void define_unforgeable_attributes(JS::Realm&, JS::Object&);

private:
    JS_DECLARE_NATIVE_FUNCTION(sample_rate_getter);
    JS_DECLARE_NATIVE_FUNCTION(length_getter);
    JS_DECLARE_NATIVE_FUNCTION(duration_getter);
    JS_DECLARE_NATIVE_FUNCTION(number_of_channels_getter);
    JS_DECLARE_NATIVE_FUNCTION(get_channel_data);
    JS_DECLARE_NATIVE_FUNCTION(copy_from_channel);
    JS_DECLARE_NATIVE_FUNCTION(copy_to_channel);
};

struct AudioBufferOptions {
    WebIDL::UnsignedLong length;
    WebIDL::UnsignedLong number_of_channels { 1 };
    float sample_rate;
};

JS::ThrowCompletionOr<AudioBufferOptions> convert_to_idl_value_for_audio_buffer_options(JS::VM&, JS::Value);

} // namespace Web::Bindings
