// WARNING: Please don't edit this file. It was generated by Python/WinRT v3.1.0

#include "py.Windows.UI.Core.Preview.h"

namespace py::cpp::Windows::UI::Core::Preview
{
    // ----- CoreAppWindowPreview class --------------------

    static PyObject* _new_CoreAppWindowPreview(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::UI::Core::Preview::CoreAppWindowPreview>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::UI::Core::Preview::CoreAppWindowPreview>::type_name);
        return nullptr;
    }

    static void _dealloc_CoreAppWindowPreview(py::wrapper::Windows::UI::Core::Preview::CoreAppWindowPreview* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* CoreAppWindowPreview_GetIdFromWindow(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.UI.Core.Preview.CoreAppWindowPreview", L"GetIdFromWindow", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::UI::WindowManagement::AppWindow>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::UI::Core::Preview::CoreAppWindowPreview::GetIdFromWindow(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* _assign_array_CoreAppWindowPreview(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::UI::Core::Preview::CoreAppWindowPreview>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_CoreAppWindowPreview(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::UI::Core::Preview::CoreAppWindowPreview>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_CoreAppWindowPreview[] = {
        { "_assign_array_", _assign_array_CoreAppWindowPreview, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_CoreAppWindowPreview), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_CoreAppWindowPreview[] = {
        { }};

    static PyType_Slot _type_slots_CoreAppWindowPreview[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_CoreAppWindowPreview) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_CoreAppWindowPreview) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_CoreAppWindowPreview) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_CoreAppWindowPreview) },
        { }};

    static PyType_Spec type_spec_CoreAppWindowPreview = {
        "winrt._winrt_windows_ui_core_preview.CoreAppWindowPreview",
        sizeof(py::wrapper::Windows::UI::Core::Preview::CoreAppWindowPreview),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_CoreAppWindowPreview};

    static PyGetSetDef getset_CoreAppWindowPreview_Static[] = {
        { }};

    static PyMethodDef methods_CoreAppWindowPreview_Static[] = {
        { "get_id_from_window", reinterpret_cast<PyCFunction>(CoreAppWindowPreview_GetIdFromWindow), METH_VARARGS, nullptr },
        { }};

    static PyType_Slot type_slots_CoreAppWindowPreview_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_CoreAppWindowPreview_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_CoreAppWindowPreview_Static) },
        { }
    };

    static PyType_Spec type_spec_CoreAppWindowPreview_Static = {
        "winrt._winrt_windows_ui_core_preview.CoreAppWindowPreview_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_CoreAppWindowPreview_Static};

    // ----- SystemNavigationCloseRequestedPreviewEventArgs class --------------------

    static PyObject* _new_SystemNavigationCloseRequestedPreviewEventArgs(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::UI::Core::Preview::SystemNavigationCloseRequestedPreviewEventArgs>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::UI::Core::Preview::SystemNavigationCloseRequestedPreviewEventArgs>::type_name);
        return nullptr;
    }

    static void _dealloc_SystemNavigationCloseRequestedPreviewEventArgs(py::wrapper::Windows::UI::Core::Preview::SystemNavigationCloseRequestedPreviewEventArgs* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* SystemNavigationCloseRequestedPreviewEventArgs_GetDeferral(py::wrapper::Windows::UI::Core::Preview::SystemNavigationCloseRequestedPreviewEventArgs* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.UI.Core.Preview.SystemNavigationCloseRequestedPreviewEventArgs", L"GetDeferral", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.GetDeferral();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* SystemNavigationCloseRequestedPreviewEventArgs_get_Handled(py::wrapper::Windows::UI::Core::Preview::SystemNavigationCloseRequestedPreviewEventArgs* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Core.Preview.SystemNavigationCloseRequestedPreviewEventArgs", L"Handled");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Handled();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int SystemNavigationCloseRequestedPreviewEventArgs_put_Handled(py::wrapper::Windows::UI::Core::Preview::SystemNavigationCloseRequestedPreviewEventArgs* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Core.Preview.SystemNavigationCloseRequestedPreviewEventArgs", L"Handled");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<bool>(arg);

            {
                auto _gil = release_gil();
                self->obj.Handled(param0);
            }

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* _assign_array_SystemNavigationCloseRequestedPreviewEventArgs(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::UI::Core::Preview::SystemNavigationCloseRequestedPreviewEventArgs>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_SystemNavigationCloseRequestedPreviewEventArgs(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::UI::Core::Preview::SystemNavigationCloseRequestedPreviewEventArgs>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_SystemNavigationCloseRequestedPreviewEventArgs[] = {
        { "get_deferral", reinterpret_cast<PyCFunction>(SystemNavigationCloseRequestedPreviewEventArgs_GetDeferral), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_SystemNavigationCloseRequestedPreviewEventArgs, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_SystemNavigationCloseRequestedPreviewEventArgs), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_SystemNavigationCloseRequestedPreviewEventArgs[] = {
        { "handled", reinterpret_cast<getter>(SystemNavigationCloseRequestedPreviewEventArgs_get_Handled), reinterpret_cast<setter>(SystemNavigationCloseRequestedPreviewEventArgs_put_Handled), nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_SystemNavigationCloseRequestedPreviewEventArgs[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_SystemNavigationCloseRequestedPreviewEventArgs) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_SystemNavigationCloseRequestedPreviewEventArgs) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_SystemNavigationCloseRequestedPreviewEventArgs) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_SystemNavigationCloseRequestedPreviewEventArgs) },
        { }};

    static PyType_Spec type_spec_SystemNavigationCloseRequestedPreviewEventArgs = {
        "winrt._winrt_windows_ui_core_preview.SystemNavigationCloseRequestedPreviewEventArgs",
        sizeof(py::wrapper::Windows::UI::Core::Preview::SystemNavigationCloseRequestedPreviewEventArgs),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_SystemNavigationCloseRequestedPreviewEventArgs};

    // ----- SystemNavigationManagerPreview class --------------------

    static PyObject* _new_SystemNavigationManagerPreview(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::UI::Core::Preview::SystemNavigationManagerPreview>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::UI::Core::Preview::SystemNavigationManagerPreview>::type_name);
        return nullptr;
    }

    static void _dealloc_SystemNavigationManagerPreview(py::wrapper::Windows::UI::Core::Preview::SystemNavigationManagerPreview* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* SystemNavigationManagerPreview_GetForCurrentView(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.UI.Core.Preview.SystemNavigationManagerPreview", L"GetForCurrentView", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::UI::Core::Preview::SystemNavigationManagerPreview::GetForCurrentView();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* SystemNavigationManagerPreview_add_CloseRequested(py::wrapper::Windows::UI::Core::Preview::SystemNavigationManagerPreview* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.UI.Core.Preview.SystemNavigationManagerPreview", L"CloseRequested");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::Windows::Foundation::EventHandler<winrt::Windows::UI::Core::Preview::SystemNavigationCloseRequestedPreviewEventArgs>>(arg);

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.CloseRequested(param0);
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* SystemNavigationManagerPreview_remove_CloseRequested(py::wrapper::Windows::UI::Core::Preview::SystemNavigationManagerPreview* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.UI.Core.Preview.SystemNavigationManagerPreview", L"CloseRequested");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::event_token>(arg);

            {
                auto _gil = release_gil();
                self->obj.CloseRequested(param0);
            }

            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_SystemNavigationManagerPreview(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::UI::Core::Preview::SystemNavigationManagerPreview>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_SystemNavigationManagerPreview(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::UI::Core::Preview::SystemNavigationManagerPreview>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_SystemNavigationManagerPreview[] = {
        { "add_close_requested", reinterpret_cast<PyCFunction>(SystemNavigationManagerPreview_add_CloseRequested), METH_O, nullptr },
        { "remove_close_requested", reinterpret_cast<PyCFunction>(SystemNavigationManagerPreview_remove_CloseRequested), METH_O, nullptr },
        { "_assign_array_", _assign_array_SystemNavigationManagerPreview, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_SystemNavigationManagerPreview), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_SystemNavigationManagerPreview[] = {
        { }};

    static PyType_Slot _type_slots_SystemNavigationManagerPreview[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_SystemNavigationManagerPreview) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_SystemNavigationManagerPreview) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_SystemNavigationManagerPreview) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_SystemNavigationManagerPreview) },
        { }};

    static PyType_Spec type_spec_SystemNavigationManagerPreview = {
        "winrt._winrt_windows_ui_core_preview.SystemNavigationManagerPreview",
        sizeof(py::wrapper::Windows::UI::Core::Preview::SystemNavigationManagerPreview),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_SystemNavigationManagerPreview};

    static PyGetSetDef getset_SystemNavigationManagerPreview_Static[] = {
        { }};

    static PyMethodDef methods_SystemNavigationManagerPreview_Static[] = {
        { "get_for_current_view", reinterpret_cast<PyCFunction>(SystemNavigationManagerPreview_GetForCurrentView), METH_VARARGS, nullptr },
        { }};

    static PyType_Slot type_slots_SystemNavigationManagerPreview_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_SystemNavigationManagerPreview_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_SystemNavigationManagerPreview_Static) },
        { }
    };

    static PyType_Spec type_spec_SystemNavigationManagerPreview_Static = {
        "winrt._winrt_windows_ui_core_preview.SystemNavigationManagerPreview_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_SystemNavigationManagerPreview_Static};

    // ----- Windows.UI.Core.Preview Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.UI.Core.Preview");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_ui_core_preview",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::UI::Core::Preview

PyMODINIT_FUNC PyInit__winrt_windows_ui_core_preview(void) noexcept
{
    using namespace py::cpp::Windows::UI::Core::Preview;

    if (py::import_winrt_runtime() == -1)
    {
        return nullptr;
    }

    py::pyobj_handle module{PyModule_Create(&module_def)};

    if (!module)
    {
        return nullptr;
    }

    auto inspectable_meta_type = py::get_inspectable_meta_type();
    if (!inspectable_meta_type)
    {
        return nullptr;
    }

    auto object_type = py::get_object_type();
    if (!object_type)
    {
        return nullptr;
    }

    py::pyobj_handle object_bases{PyTuple_Pack(1, object_type)};

    if (!object_bases)
    {
        return nullptr;
    }

    py::pyobj_handle CoreAppWindowPreview_Static_bases{PyTuple_Pack(1, reinterpret_cast<PyObject*>(inspectable_meta_type))};
    if (!CoreAppWindowPreview_Static_bases)
    {
        return nullptr;
    }

    py::pyobj_handle type_CoreAppWindowPreview_Static{PyType_FromSpecWithBases(&type_spec_CoreAppWindowPreview_Static, CoreAppWindowPreview_Static_bases.get())};
    if (!type_CoreAppWindowPreview_Static)
    {
        return nullptr;
    }

    py::pytype_handle CoreAppWindowPreview_type{py::register_python_type(module.get(), &type_spec_CoreAppWindowPreview, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_CoreAppWindowPreview_Static.get()))};
    if (!CoreAppWindowPreview_type)
    {
        return nullptr;
    }

    py::pytype_handle SystemNavigationCloseRequestedPreviewEventArgs_type{py::register_python_type(module.get(), &type_spec_SystemNavigationCloseRequestedPreviewEventArgs, object_bases.get(), inspectable_meta_type)};
    if (!SystemNavigationCloseRequestedPreviewEventArgs_type)
    {
        return nullptr;
    }

    py::pyobj_handle SystemNavigationManagerPreview_Static_bases{PyTuple_Pack(1, reinterpret_cast<PyObject*>(inspectable_meta_type))};
    if (!SystemNavigationManagerPreview_Static_bases)
    {
        return nullptr;
    }

    py::pyobj_handle type_SystemNavigationManagerPreview_Static{PyType_FromSpecWithBases(&type_spec_SystemNavigationManagerPreview_Static, SystemNavigationManagerPreview_Static_bases.get())};
    if (!type_SystemNavigationManagerPreview_Static)
    {
        return nullptr;
    }

    py::pytype_handle SystemNavigationManagerPreview_type{py::register_python_type(module.get(), &type_spec_SystemNavigationManagerPreview, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_SystemNavigationManagerPreview_Static.get()))};
    if (!SystemNavigationManagerPreview_type)
    {
        return nullptr;
    }


    return module.detach();
}
