#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>

namespace Web::Bindings {

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

private:
};

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

private:
    JS_DECLARE_NATIVE_FUNCTION(url_getter);
    JS_DECLARE_NATIVE_FUNCTION(with_credentials_getter);
    JS_DECLARE_NATIVE_FUNCTION(ready_state_getter);
    JS_DECLARE_NATIVE_FUNCTION(onopen_getter);
    JS_DECLARE_NATIVE_FUNCTION(onopen_setter);
    JS_DECLARE_NATIVE_FUNCTION(onmessage_getter);
    JS_DECLARE_NATIVE_FUNCTION(onmessage_setter);
    JS_DECLARE_NATIVE_FUNCTION(onerror_getter);
    JS_DECLARE_NATIVE_FUNCTION(onerror_setter);
    JS_DECLARE_NATIVE_FUNCTION(close);
};

struct EventSourceInit {
    bool with_credentials { false };
};

JS::ThrowCompletionOr<EventSourceInit> convert_to_idl_value_for_event_source_init(JS::VM&, JS::Value);

} // namespace Web::Bindings
