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

#include "py.Windows.ApplicationModel.AppService.h"

namespace py::cpp::Windows::ApplicationModel::AppService
{
    // ----- AppServiceCatalog class --------------------

    static PyObject* _new_AppServiceCatalog(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::ApplicationModel::AppService::AppServiceCatalog>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::ApplicationModel::AppService::AppServiceCatalog>::type_name);
        return nullptr;
    }

    static PyObject* AppServiceCatalog_FindAppServiceProvidersAsync(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.ApplicationModel.AppService.AppServiceCatalog", L"FindAppServiceProvidersAsync", 1);
                }

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

                auto param0 = py::convert_to<winrt::hstring>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::ApplicationModel::AppService::AppServiceCatalog::FindAppServiceProvidersAsync(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyMethodDef _methods_AppServiceCatalog[] = {
        { }};

    static PyGetSetDef _getset_AppServiceCatalog[] = {
        { }};

    static PyType_Slot _type_slots_AppServiceCatalog[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_AppServiceCatalog) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_AppServiceCatalog) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_AppServiceCatalog) },
        { }};

    static PyType_Spec type_spec_AppServiceCatalog = {
        "winrt._winrt_windows_applicationmodel_appservice.AppServiceCatalog",
        0,
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_AppServiceCatalog};

    static PyGetSetDef getset_AppServiceCatalog_Static[] = {
        { }};

    static PyMethodDef methods_AppServiceCatalog_Static[] = {
        { "find_app_service_providers_async", reinterpret_cast<PyCFunction>(AppServiceCatalog_FindAppServiceProvidersAsync), METH_VARARGS, nullptr },
        { }};

    static PyType_Slot type_slots_AppServiceCatalog_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_AppServiceCatalog_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_AppServiceCatalog_Static) },
        { }
    };

    static PyType_Spec type_spec_AppServiceCatalog_Static = {
        "winrt._winrt_windows_applicationmodel_appservice.AppServiceCatalog_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_AppServiceCatalog_Static};

    // ----- AppServiceClosedEventArgs class --------------------

    static PyObject* _new_AppServiceClosedEventArgs(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::ApplicationModel::AppService::AppServiceClosedEventArgs>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::ApplicationModel::AppService::AppServiceClosedEventArgs>::type_name);
        return nullptr;
    }

    static void _dealloc_AppServiceClosedEventArgs(py::wrapper::Windows::ApplicationModel::AppService::AppServiceClosedEventArgs* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* AppServiceClosedEventArgs_get_Status(py::wrapper::Windows::ApplicationModel::AppService::AppServiceClosedEventArgs* 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.ApplicationModel.AppService.AppServiceClosedEventArgs", L"Status");
            }

            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.Status();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_AppServiceClosedEventArgs(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::ApplicationModel::AppService::AppServiceClosedEventArgs>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_AppServiceClosedEventArgs(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::ApplicationModel::AppService::AppServiceClosedEventArgs>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_AppServiceClosedEventArgs[] = {
        { "_assign_array_", _assign_array_AppServiceClosedEventArgs, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_AppServiceClosedEventArgs), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_AppServiceClosedEventArgs[] = {
        { "status", reinterpret_cast<getter>(AppServiceClosedEventArgs_get_Status), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_AppServiceClosedEventArgs[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_AppServiceClosedEventArgs) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_AppServiceClosedEventArgs) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_AppServiceClosedEventArgs) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_AppServiceClosedEventArgs) },
        { }};

    static PyType_Spec type_spec_AppServiceClosedEventArgs = {
        "winrt._winrt_windows_applicationmodel_appservice.AppServiceClosedEventArgs",
        sizeof(py::wrapper::Windows::ApplicationModel::AppService::AppServiceClosedEventArgs),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_AppServiceClosedEventArgs};

    // ----- AppServiceConnection class --------------------

    static PyObject* _new_AppServiceConnection(PyTypeObject* type, PyObject* args, PyObject* kwds) noexcept
    {
        if (kwds)
        {
            py::set_invalid_kwd_args_error();
            return nullptr;
        }

        auto arg_count = PyTuple_GET_SIZE(args);
        if (arg_count == 0)
        {
            try
            {
                winrt::Windows::ApplicationModel::AppService::AppServiceConnection instance{};
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static void _dealloc_AppServiceConnection(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* AppServiceConnection_Close(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection* 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.ApplicationModel.AppService.AppServiceConnection", L"Close", 0);
                }

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

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

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

    static PyObject* AppServiceConnection_OpenAsync(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection* 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.ApplicationModel.AppService.AppServiceConnection", L"OpenAsync", 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.OpenAsync();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* AppServiceConnection_OpenRemoteAsync(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection* self, 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.ApplicationModel.AppService.AppServiceConnection", L"OpenRemoteAsync", 1);
                }

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

                auto param0 = py::convert_to<winrt::Windows::System::RemoteSystems::RemoteSystemConnectionRequest>(args, 0);

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

    static PyObject* AppServiceConnection_SendMessageAsync(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection* self, 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.ApplicationModel.AppService.AppServiceConnection", L"SendMessageAsync", 1);
                }

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

                auto param0 = py::convert_to<winrt::Windows::Foundation::Collections::ValueSet>(args, 0);

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

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

        if (arg_count == 3)
        {
            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.ApplicationModel.AppService.AppServiceConnection", L"SendStatelessMessageAsync", 3);
                }

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

                auto param0 = py::convert_to<winrt::Windows::ApplicationModel::AppService::AppServiceConnection>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::System::RemoteSystems::RemoteSystemConnectionRequest>(args, 1);
                auto param2 = py::convert_to<winrt::Windows::Foundation::Collections::ValueSet>(args, 2);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::ApplicationModel::AppService::AppServiceConnection::SendStatelessMessageAsync(param0, param1, param2);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* AppServiceConnection_get_PackageFamilyName(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection* 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.ApplicationModel.AppService.AppServiceConnection", L"PackageFamilyName");
            }

            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.PackageFamilyName();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int AppServiceConnection_put_PackageFamilyName(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection* 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.ApplicationModel.AppService.AppServiceConnection", L"PackageFamilyName");
            }

            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<winrt::hstring>(arg);

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

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

    static PyObject* AppServiceConnection_get_AppServiceName(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection* 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.ApplicationModel.AppService.AppServiceConnection", L"AppServiceName");
            }

            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.AppServiceName();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int AppServiceConnection_put_AppServiceName(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection* 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.ApplicationModel.AppService.AppServiceConnection", L"AppServiceName");
            }

            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<winrt::hstring>(arg);

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

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

    static PyObject* AppServiceConnection_get_User(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection* 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.ApplicationModel.AppService.AppServiceConnection", L"User");
            }

            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.User();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int AppServiceConnection_put_User(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection* 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.ApplicationModel.AppService.AppServiceConnection", L"User");
            }

            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<winrt::Windows::System::User>(arg);

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

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

    static PyObject* AppServiceConnection_add_RequestReceived(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection* 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.ApplicationModel.AppService.AppServiceConnection", L"RequestReceived");
            }

            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::TypedEventHandler<winrt::Windows::ApplicationModel::AppService::AppServiceConnection, winrt::Windows::ApplicationModel::AppService::AppServiceRequestReceivedEventArgs>>(arg);

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

    static PyObject* AppServiceConnection_remove_RequestReceived(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection* 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.ApplicationModel.AppService.AppServiceConnection", L"RequestReceived");
            }

            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.RequestReceived(param0);
            }

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

    static PyObject* AppServiceConnection_add_ServiceClosed(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection* 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.ApplicationModel.AppService.AppServiceConnection", L"ServiceClosed");
            }

            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::TypedEventHandler<winrt::Windows::ApplicationModel::AppService::AppServiceConnection, winrt::Windows::ApplicationModel::AppService::AppServiceClosedEventArgs>>(arg);

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

    static PyObject* AppServiceConnection_remove_ServiceClosed(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection* 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.ApplicationModel.AppService.AppServiceConnection", L"ServiceClosed");
            }

            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.ServiceClosed(param0);
            }

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

    static PyObject* _assign_array_AppServiceConnection(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::ApplicationModel::AppService::AppServiceConnection>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_AppServiceConnection(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::ApplicationModel::AppService::AppServiceConnection>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _enter_AppServiceConnection(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection* self, PyObject* /*unused*/) noexcept
    {
        return Py_NewRef(self);
    }

    static PyObject* _exit_AppServiceConnection(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection* self, PyObject* /*unused*/) noexcept
    {
        try
        {
            {
                auto _gil = py::release_gil();
                self->obj.Close();
            }

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

    static PyMethodDef _methods_AppServiceConnection[] = {
        { "close", reinterpret_cast<PyCFunction>(AppServiceConnection_Close), METH_VARARGS, nullptr },
        { "open_async", reinterpret_cast<PyCFunction>(AppServiceConnection_OpenAsync), METH_VARARGS, nullptr },
        { "open_remote_async", reinterpret_cast<PyCFunction>(AppServiceConnection_OpenRemoteAsync), METH_VARARGS, nullptr },
        { "send_message_async", reinterpret_cast<PyCFunction>(AppServiceConnection_SendMessageAsync), METH_VARARGS, nullptr },
        { "add_request_received", reinterpret_cast<PyCFunction>(AppServiceConnection_add_RequestReceived), METH_O, nullptr },
        { "remove_request_received", reinterpret_cast<PyCFunction>(AppServiceConnection_remove_RequestReceived), METH_O, nullptr },
        { "add_service_closed", reinterpret_cast<PyCFunction>(AppServiceConnection_add_ServiceClosed), METH_O, nullptr },
        { "remove_service_closed", reinterpret_cast<PyCFunction>(AppServiceConnection_remove_ServiceClosed), METH_O, nullptr },
        { "_assign_array_", _assign_array_AppServiceConnection, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_AppServiceConnection), METH_O | METH_STATIC, nullptr },
        { "__enter__", reinterpret_cast<PyCFunction>(_enter_AppServiceConnection), METH_NOARGS, nullptr },
        { "__exit__", reinterpret_cast<PyCFunction>(_exit_AppServiceConnection), METH_VARARGS, nullptr },
        { }};

    static PyGetSetDef _getset_AppServiceConnection[] = {
        { "package_family_name", reinterpret_cast<getter>(AppServiceConnection_get_PackageFamilyName), reinterpret_cast<setter>(AppServiceConnection_put_PackageFamilyName), nullptr, nullptr },
        { "app_service_name", reinterpret_cast<getter>(AppServiceConnection_get_AppServiceName), reinterpret_cast<setter>(AppServiceConnection_put_AppServiceName), nullptr, nullptr },
        { "user", reinterpret_cast<getter>(AppServiceConnection_get_User), reinterpret_cast<setter>(AppServiceConnection_put_User), nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_AppServiceConnection[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_AppServiceConnection) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_AppServiceConnection) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_AppServiceConnection) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_AppServiceConnection) },
        { }};

    static PyType_Spec type_spec_AppServiceConnection = {
        "winrt._winrt_windows_applicationmodel_appservice.AppServiceConnection",
        sizeof(py::wrapper::Windows::ApplicationModel::AppService::AppServiceConnection),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_AppServiceConnection};

    static PyGetSetDef getset_AppServiceConnection_Static[] = {
        { }};

    static PyMethodDef methods_AppServiceConnection_Static[] = {
        { "send_stateless_message_async", reinterpret_cast<PyCFunction>(AppServiceConnection_SendStatelessMessageAsync), METH_VARARGS, nullptr },
        { }};

    static PyType_Slot type_slots_AppServiceConnection_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_AppServiceConnection_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_AppServiceConnection_Static) },
        { }
    };

    static PyType_Spec type_spec_AppServiceConnection_Static = {
        "winrt._winrt_windows_applicationmodel_appservice.AppServiceConnection_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_AppServiceConnection_Static};

    // ----- AppServiceDeferral class --------------------

    static PyObject* _new_AppServiceDeferral(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::ApplicationModel::AppService::AppServiceDeferral>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::ApplicationModel::AppService::AppServiceDeferral>::type_name);
        return nullptr;
    }

    static void _dealloc_AppServiceDeferral(py::wrapper::Windows::ApplicationModel::AppService::AppServiceDeferral* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* AppServiceDeferral_Complete(py::wrapper::Windows::ApplicationModel::AppService::AppServiceDeferral* 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.ApplicationModel.AppService.AppServiceDeferral", L"Complete", 0);
                }

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

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

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

    static PyObject* _assign_array_AppServiceDeferral(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::ApplicationModel::AppService::AppServiceDeferral>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_AppServiceDeferral(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::ApplicationModel::AppService::AppServiceDeferral>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_AppServiceDeferral[] = {
        { "complete", reinterpret_cast<PyCFunction>(AppServiceDeferral_Complete), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_AppServiceDeferral, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_AppServiceDeferral), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_AppServiceDeferral[] = {
        { }};

    static PyType_Slot _type_slots_AppServiceDeferral[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_AppServiceDeferral) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_AppServiceDeferral) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_AppServiceDeferral) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_AppServiceDeferral) },
        { }};

    static PyType_Spec type_spec_AppServiceDeferral = {
        "winrt._winrt_windows_applicationmodel_appservice.AppServiceDeferral",
        sizeof(py::wrapper::Windows::ApplicationModel::AppService::AppServiceDeferral),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_AppServiceDeferral};

    // ----- AppServiceRequest class --------------------

    static PyObject* _new_AppServiceRequest(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::ApplicationModel::AppService::AppServiceRequest>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::ApplicationModel::AppService::AppServiceRequest>::type_name);
        return nullptr;
    }

    static void _dealloc_AppServiceRequest(py::wrapper::Windows::ApplicationModel::AppService::AppServiceRequest* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* AppServiceRequest_SendResponseAsync(py::wrapper::Windows::ApplicationModel::AppService::AppServiceRequest* self, 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.ApplicationModel.AppService.AppServiceRequest", L"SendResponseAsync", 1);
                }

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

                auto param0 = py::convert_to<winrt::Windows::Foundation::Collections::ValueSet>(args, 0);

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

    static PyObject* AppServiceRequest_get_Message(py::wrapper::Windows::ApplicationModel::AppService::AppServiceRequest* 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.ApplicationModel.AppService.AppServiceRequest", L"Message");
            }

            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.Message();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_AppServiceRequest(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::ApplicationModel::AppService::AppServiceRequest>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_AppServiceRequest(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::ApplicationModel::AppService::AppServiceRequest>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_AppServiceRequest[] = {
        { "send_response_async", reinterpret_cast<PyCFunction>(AppServiceRequest_SendResponseAsync), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_AppServiceRequest, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_AppServiceRequest), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_AppServiceRequest[] = {
        { "message", reinterpret_cast<getter>(AppServiceRequest_get_Message), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_AppServiceRequest[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_AppServiceRequest) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_AppServiceRequest) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_AppServiceRequest) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_AppServiceRequest) },
        { }};

    static PyType_Spec type_spec_AppServiceRequest = {
        "winrt._winrt_windows_applicationmodel_appservice.AppServiceRequest",
        sizeof(py::wrapper::Windows::ApplicationModel::AppService::AppServiceRequest),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_AppServiceRequest};

    // ----- AppServiceRequestReceivedEventArgs class --------------------

    static PyObject* _new_AppServiceRequestReceivedEventArgs(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::ApplicationModel::AppService::AppServiceRequestReceivedEventArgs>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::ApplicationModel::AppService::AppServiceRequestReceivedEventArgs>::type_name);
        return nullptr;
    }

    static void _dealloc_AppServiceRequestReceivedEventArgs(py::wrapper::Windows::ApplicationModel::AppService::AppServiceRequestReceivedEventArgs* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* AppServiceRequestReceivedEventArgs_GetDeferral(py::wrapper::Windows::ApplicationModel::AppService::AppServiceRequestReceivedEventArgs* 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.ApplicationModel.AppService.AppServiceRequestReceivedEventArgs", 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* AppServiceRequestReceivedEventArgs_get_Request(py::wrapper::Windows::ApplicationModel::AppService::AppServiceRequestReceivedEventArgs* 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.ApplicationModel.AppService.AppServiceRequestReceivedEventArgs", L"Request");
            }

            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.Request();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_AppServiceRequestReceivedEventArgs(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::ApplicationModel::AppService::AppServiceRequestReceivedEventArgs>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_AppServiceRequestReceivedEventArgs(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::ApplicationModel::AppService::AppServiceRequestReceivedEventArgs>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_AppServiceRequestReceivedEventArgs[] = {
        { "get_deferral", reinterpret_cast<PyCFunction>(AppServiceRequestReceivedEventArgs_GetDeferral), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_AppServiceRequestReceivedEventArgs, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_AppServiceRequestReceivedEventArgs), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_AppServiceRequestReceivedEventArgs[] = {
        { "request", reinterpret_cast<getter>(AppServiceRequestReceivedEventArgs_get_Request), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_AppServiceRequestReceivedEventArgs[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_AppServiceRequestReceivedEventArgs) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_AppServiceRequestReceivedEventArgs) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_AppServiceRequestReceivedEventArgs) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_AppServiceRequestReceivedEventArgs) },
        { }};

    static PyType_Spec type_spec_AppServiceRequestReceivedEventArgs = {
        "winrt._winrt_windows_applicationmodel_appservice.AppServiceRequestReceivedEventArgs",
        sizeof(py::wrapper::Windows::ApplicationModel::AppService::AppServiceRequestReceivedEventArgs),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_AppServiceRequestReceivedEventArgs};

    // ----- AppServiceResponse class --------------------

    static PyObject* _new_AppServiceResponse(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::ApplicationModel::AppService::AppServiceResponse>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::ApplicationModel::AppService::AppServiceResponse>::type_name);
        return nullptr;
    }

    static void _dealloc_AppServiceResponse(py::wrapper::Windows::ApplicationModel::AppService::AppServiceResponse* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* AppServiceResponse_get_Message(py::wrapper::Windows::ApplicationModel::AppService::AppServiceResponse* 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.ApplicationModel.AppService.AppServiceResponse", L"Message");
            }

            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.Message();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* AppServiceResponse_get_Status(py::wrapper::Windows::ApplicationModel::AppService::AppServiceResponse* 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.ApplicationModel.AppService.AppServiceResponse", L"Status");
            }

            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.Status();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_AppServiceResponse(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::ApplicationModel::AppService::AppServiceResponse>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_AppServiceResponse(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::ApplicationModel::AppService::AppServiceResponse>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_AppServiceResponse[] = {
        { "_assign_array_", _assign_array_AppServiceResponse, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_AppServiceResponse), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_AppServiceResponse[] = {
        { "message", reinterpret_cast<getter>(AppServiceResponse_get_Message), nullptr, nullptr, nullptr },
        { "status", reinterpret_cast<getter>(AppServiceResponse_get_Status), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_AppServiceResponse[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_AppServiceResponse) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_AppServiceResponse) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_AppServiceResponse) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_AppServiceResponse) },
        { }};

    static PyType_Spec type_spec_AppServiceResponse = {
        "winrt._winrt_windows_applicationmodel_appservice.AppServiceResponse",
        sizeof(py::wrapper::Windows::ApplicationModel::AppService::AppServiceResponse),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_AppServiceResponse};

    // ----- AppServiceTriggerDetails class --------------------

    static PyObject* _new_AppServiceTriggerDetails(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::ApplicationModel::AppService::AppServiceTriggerDetails>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::ApplicationModel::AppService::AppServiceTriggerDetails>::type_name);
        return nullptr;
    }

    static void _dealloc_AppServiceTriggerDetails(py::wrapper::Windows::ApplicationModel::AppService::AppServiceTriggerDetails* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* AppServiceTriggerDetails_CheckCallerForCapabilityAsync(py::wrapper::Windows::ApplicationModel::AppService::AppServiceTriggerDetails* self, 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.ApplicationModel.AppService.AppServiceTriggerDetails", L"CheckCallerForCapabilityAsync", 1);
                }

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

                auto param0 = py::convert_to<winrt::hstring>(args, 0);

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

    static PyObject* AppServiceTriggerDetails_get_AppServiceConnection(py::wrapper::Windows::ApplicationModel::AppService::AppServiceTriggerDetails* 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.ApplicationModel.AppService.AppServiceTriggerDetails", L"AppServiceConnection");
            }

            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.AppServiceConnection();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* AppServiceTriggerDetails_get_CallerPackageFamilyName(py::wrapper::Windows::ApplicationModel::AppService::AppServiceTriggerDetails* 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.ApplicationModel.AppService.AppServiceTriggerDetails", L"CallerPackageFamilyName");
            }

            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.CallerPackageFamilyName();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* AppServiceTriggerDetails_get_Name(py::wrapper::Windows::ApplicationModel::AppService::AppServiceTriggerDetails* 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.ApplicationModel.AppService.AppServiceTriggerDetails", L"Name");
            }

            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.Name();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* AppServiceTriggerDetails_get_IsRemoteSystemConnection(py::wrapper::Windows::ApplicationModel::AppService::AppServiceTriggerDetails* 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.ApplicationModel.AppService.AppServiceTriggerDetails", L"IsRemoteSystemConnection");
            }

            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.IsRemoteSystemConnection();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* AppServiceTriggerDetails_get_CallerRemoteConnectionToken(py::wrapper::Windows::ApplicationModel::AppService::AppServiceTriggerDetails* 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.ApplicationModel.AppService.AppServiceTriggerDetails", L"CallerRemoteConnectionToken");
            }

            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.CallerRemoteConnectionToken();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_AppServiceTriggerDetails(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::ApplicationModel::AppService::AppServiceTriggerDetails>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_AppServiceTriggerDetails(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::ApplicationModel::AppService::AppServiceTriggerDetails>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_AppServiceTriggerDetails[] = {
        { "check_caller_for_capability_async", reinterpret_cast<PyCFunction>(AppServiceTriggerDetails_CheckCallerForCapabilityAsync), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_AppServiceTriggerDetails, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_AppServiceTriggerDetails), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_AppServiceTriggerDetails[] = {
        { "app_service_connection", reinterpret_cast<getter>(AppServiceTriggerDetails_get_AppServiceConnection), nullptr, nullptr, nullptr },
        { "caller_package_family_name", reinterpret_cast<getter>(AppServiceTriggerDetails_get_CallerPackageFamilyName), nullptr, nullptr, nullptr },
        { "name", reinterpret_cast<getter>(AppServiceTriggerDetails_get_Name), nullptr, nullptr, nullptr },
        { "is_remote_system_connection", reinterpret_cast<getter>(AppServiceTriggerDetails_get_IsRemoteSystemConnection), nullptr, nullptr, nullptr },
        { "caller_remote_connection_token", reinterpret_cast<getter>(AppServiceTriggerDetails_get_CallerRemoteConnectionToken), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_AppServiceTriggerDetails[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_AppServiceTriggerDetails) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_AppServiceTriggerDetails) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_AppServiceTriggerDetails) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_AppServiceTriggerDetails) },
        { }};

    static PyType_Spec type_spec_AppServiceTriggerDetails = {
        "winrt._winrt_windows_applicationmodel_appservice.AppServiceTriggerDetails",
        sizeof(py::wrapper::Windows::ApplicationModel::AppService::AppServiceTriggerDetails),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_AppServiceTriggerDetails};

    // ----- StatelessAppServiceResponse class --------------------

    static PyObject* _new_StatelessAppServiceResponse(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::ApplicationModel::AppService::StatelessAppServiceResponse>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::ApplicationModel::AppService::StatelessAppServiceResponse>::type_name);
        return nullptr;
    }

    static void _dealloc_StatelessAppServiceResponse(py::wrapper::Windows::ApplicationModel::AppService::StatelessAppServiceResponse* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* StatelessAppServiceResponse_get_Message(py::wrapper::Windows::ApplicationModel::AppService::StatelessAppServiceResponse* 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.ApplicationModel.AppService.StatelessAppServiceResponse", L"Message");
            }

            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.Message();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* StatelessAppServiceResponse_get_Status(py::wrapper::Windows::ApplicationModel::AppService::StatelessAppServiceResponse* 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.ApplicationModel.AppService.StatelessAppServiceResponse", L"Status");
            }

            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.Status();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_StatelessAppServiceResponse(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::ApplicationModel::AppService::StatelessAppServiceResponse>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_StatelessAppServiceResponse(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::ApplicationModel::AppService::StatelessAppServiceResponse>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_StatelessAppServiceResponse[] = {
        { "_assign_array_", _assign_array_StatelessAppServiceResponse, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_StatelessAppServiceResponse), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_StatelessAppServiceResponse[] = {
        { "message", reinterpret_cast<getter>(StatelessAppServiceResponse_get_Message), nullptr, nullptr, nullptr },
        { "status", reinterpret_cast<getter>(StatelessAppServiceResponse_get_Status), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_StatelessAppServiceResponse[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_StatelessAppServiceResponse) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_StatelessAppServiceResponse) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_StatelessAppServiceResponse) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_StatelessAppServiceResponse) },
        { }};

    static PyType_Spec type_spec_StatelessAppServiceResponse = {
        "winrt._winrt_windows_applicationmodel_appservice.StatelessAppServiceResponse",
        sizeof(py::wrapper::Windows::ApplicationModel::AppService::StatelessAppServiceResponse),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_StatelessAppServiceResponse};

    // ----- Windows.ApplicationModel.AppService Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.ApplicationModel.AppService");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_applicationmodel_appservice",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::ApplicationModel::AppService

PyMODINIT_FUNC PyInit__winrt_windows_applicationmodel_appservice(void) noexcept
{
    using namespace py::cpp::Windows::ApplicationModel::AppService;

    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 AppServiceCatalog_Static_bases{PyTuple_Pack(1, reinterpret_cast<PyObject*>(inspectable_meta_type))};
    if (!AppServiceCatalog_Static_bases)
    {
        return nullptr;
    }

    py::pyobj_handle type_AppServiceCatalog_Static{PyType_FromSpecWithBases(&type_spec_AppServiceCatalog_Static, AppServiceCatalog_Static_bases.get())};
    if (!type_AppServiceCatalog_Static)
    {
        return nullptr;
    }

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

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

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

    py::pyobj_handle type_AppServiceConnection_Static{PyType_FromSpecWithBases(&type_spec_AppServiceConnection_Static, AppServiceConnection_Static_bases.get())};
    if (!type_AppServiceConnection_Static)
    {
        return nullptr;
    }

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

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

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

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

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

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

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


    return module.detach();
}
