local version = GetResourceMetadata(GetCurrentResourceName(), 'version', 0)
if not version then
    print('^1[Version Check]^7 Could not retrieve version information.')
    return
end

local function checkVersion()
    local url = 'https://raw.githubusercontent.com/muhammadusman357/starlabs-museum-mlo/main/README.md'
    PerformHttpRequest(url, function(statusCode, responseText, headers)
        if statusCode == 200 then
            local latestVersion = responseText:match('Version:(%d+%.%d+%.%d+)')
            if latestVersion then
                if latestVersion ~= version then
                    print("^2==============================================^7")
                    print("^2["..GetCurrentResourceName().."] - New Update Available.^7")
                    print("Current Version: "..version..".")
                    print("New Version: "..latestVersion..".")
                    print("Notes: Soon")
                    print("^2==============================================^7")
                else
                    print('^2[Version Check]^7 You are using the latest version: ' .. version .. '.')
                end
            else
                print('^1[Version Check]^7 Could not find version information in the response.')
            end
        else
            print('^1[Version Check]^7 Failed to check for updates. HTTP Status Code: ' .. statusCode)
        end
    end, 'GET', '', { ['Content-Type'] = 'application/json' })
end

checkVersion()