#include "main.h"

napi_value init(napi_env env, napi_value exports) {
    napi_status status;
    napi_value fn;

    status = napi_create_function(env, nullptr, 0, getActiveWindow, nullptr, &fn);
    if (status != napi_ok) return nullptr;

    status = napi_set_named_property(env, exports, "getActiveWindow", fn);
    if (status != napi_ok) return nullptr;

    status = napi_create_function(env, nullptr, 0, getChildWindows, nullptr, &fn);
    if (status != napi_ok) return nullptr;

    status = napi_set_named_property(env, exports, "getChildWindows", fn);
    if (status != napi_ok) return nullptr;

    status = napi_create_function(env, nullptr, 0, findWindowVisible, nullptr, &fn);
    if (status != napi_ok) return nullptr;

    status = napi_set_named_property(env, exports, "findWindowVisible", fn);
    if (status != napi_ok) return nullptr;

    status = napi_create_function(env, nullptr, 0, isWindowVisible, nullptr, &fn);
    if (status != napi_ok) return nullptr;

    status = napi_set_named_property(env, exports, "isWindowVisible", fn);
    if (status != napi_ok) return nullptr;

    status = napi_create_function(env, nullptr, 0, isWindowMinimized, nullptr, &fn);
    if (status != napi_ok) return nullptr;

    status = napi_set_named_property(env, exports, "isWindowMinimized", fn);
    if (status != napi_ok) return nullptr;

    status = napi_create_function(env, nullptr, 0, minimizeWindow, nullptr, &fn);
    if (status != napi_ok) return nullptr;

    status = napi_set_named_property(env, exports, "minimizeWindow", fn);
    if (status != napi_ok) return nullptr;

    status = napi_create_function(env, nullptr, 0, countWindowsByProcess, nullptr, &fn);
    if (status != napi_ok) return nullptr;

    status = napi_set_named_property(env, exports, "countWindowsByProcess", fn);
    if (status != napi_ok) return nullptr;

    return exports;
}

NAPI_MODULE(NODE_GYP_MODULE_NAME, init)