#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 ElementInternalsConstructor {
public:
    static void initialize(JS::Realm&, JS::NativeFunction&);
    static JS::ThrowCompletionOr<GC::Ref<JS::Object>> construct(InterfaceConstructor&, JS::FunctionObject&);

private:
};

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

private:
    JS_DECLARE_NATIVE_FUNCTION(shadow_root_getter);
    JS_DECLARE_NATIVE_FUNCTION(form_getter);
    JS_DECLARE_NATIVE_FUNCTION(will_validate_getter);
    JS_DECLARE_NATIVE_FUNCTION(validity_getter);
    JS_DECLARE_NATIVE_FUNCTION(validation_message_getter);
    JS_DECLARE_NATIVE_FUNCTION(labels_getter);
    JS_DECLARE_NATIVE_FUNCTION(states_getter);
    JS_DECLARE_NATIVE_FUNCTION(set_form_value);
    JS_DECLARE_NATIVE_FUNCTION(set_validity);
    JS_DECLARE_NATIVE_FUNCTION(check_validity);
    JS_DECLARE_NATIVE_FUNCTION(report_validity);
};

struct ValidityStateFlags {
    bool bad_input { false };
    bool custom_error { false };
    bool pattern_mismatch { false };
    bool range_overflow { false };
    bool range_underflow { false };
    bool step_mismatch { false };
    bool too_long { false };
    bool too_short { false };
    bool type_mismatch { false };
    bool value_missing { false };
};

JS::ThrowCompletionOr<ValidityStateFlags> convert_to_idl_value_for_validity_state_flags(JS::VM&, JS::Value);

} // namespace Web::Bindings
