#pragma once

#include <LibJS/Runtime/NativeFunction.h>
#include <LibJS/Runtime/Object.h>
#include <LibWeb/Bindings/InterfaceObject.h>

namespace Web::Bindings {

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

private:
};

class DedicatedWorkerGlobalScopePrototype : public JS::Object {
    JS_OBJECT(DedicatedWorkerGlobalScopePrototype, JS::Object);
    GC_DECLARE_ALLOCATOR(DedicatedWorkerGlobalScopePrototype);

public:
    static void define_unforgeable_attributes(JS::Realm&, JS::Object&);

    explicit DedicatedWorkerGlobalScopePrototype(JS::Realm&);
    virtual void initialize(JS::Realm&) override;
    virtual ~DedicatedWorkerGlobalScopePrototype() override;
    virtual JS::ThrowCompletionOr<bool> internal_set_prototype_of(JS::Object*) override;

private:
    JS_DECLARE_NATIVE_FUNCTION(name_getter);
    JS_DECLARE_NATIVE_FUNCTION(name_setter);
    JS_DECLARE_NATIVE_FUNCTION(onmessage_getter);
    JS_DECLARE_NATIVE_FUNCTION(onmessage_setter);
    JS_DECLARE_NATIVE_FUNCTION(onmessageerror_getter);
    JS_DECLARE_NATIVE_FUNCTION(onmessageerror_setter);
    JS_DECLARE_NATIVE_FUNCTION(post_message);
    JS_DECLARE_NATIVE_FUNCTION(post_message0);
    JS_DECLARE_NATIVE_FUNCTION(post_message1);
    JS_DECLARE_NATIVE_FUNCTION(close);
};

class DedicatedWorkerGlobalScopeGlobalMixin {
public:
    void initialize(JS::Realm&, JS::Object&);
    void define_unforgeable_attributes(JS::Realm&, JS::Object&);
    DedicatedWorkerGlobalScopeGlobalMixin();
    virtual ~DedicatedWorkerGlobalScopeGlobalMixin();

private:
    JS_DECLARE_NATIVE_FUNCTION(name_getter);
    JS_DECLARE_NATIVE_FUNCTION(name_setter);
    JS_DECLARE_NATIVE_FUNCTION(onmessage_getter);
    JS_DECLARE_NATIVE_FUNCTION(onmessage_setter);
    JS_DECLARE_NATIVE_FUNCTION(onmessageerror_getter);
    JS_DECLARE_NATIVE_FUNCTION(onmessageerror_setter);
    JS_DECLARE_NATIVE_FUNCTION(post_message);
    JS_DECLARE_NATIVE_FUNCTION(post_message0);
    JS_DECLARE_NATIVE_FUNCTION(post_message1);
    JS_DECLARE_NATIVE_FUNCTION(close);
};

} // namespace Web::Bindings
