local g=require((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")):WaitForChild("\078\101\118\101\114\109\111\114\101"))local C=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local Q=game:GetService("\082\117\110\083\101\114\118\105\099\101")local D=g("\071\101\116\082\101\109\111\116\101\069\118\101\110\116")local q=g("\080\114\111\109\105\115\101")local S=g("\082\101\115\111\117\114\099\101\067\111\110\115\116\097\110\116\115")if Q:IsServer()then return function(g)return q.resolved(D(g))end else return function(g)assert(type(g)=="\115\116\114\105\110\103")local Q=C:FindFirstChild(S.REMOTE_EVENT_STORAGE_NAME)if Q then local C=Q:FindFirstChild(g)if C then return q.resolved(C)end end return q.spawn(function(C,Q)C(D(g))end)end end
--- Retrieves a remote event as a promise
-- @module PromiseGetRemoteEvent

local require = require(game:GetService("ReplicatedStorage"):WaitForChild("Nevermore"))

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

local GetRemoteEvent = require("GetRemoteEvent")
local Promise = require("Promise")
local ResourceConstants = require("ResourceConstants")

if RunService:IsServer() then
	return function(name)
		return Promise.resolved(GetRemoteEvent(name))
	end
else -- RunService:IsClient()
	return function(name)
		assert(type(name) == "string")

		local storage = ReplicatedStorage:FindFirstChild(ResourceConstants.REMOTE_EVENT_STORAGE_NAME)
		if storage then
			local obj = storage:FindFirstChild(name)
			if obj then
				return Promise.resolved(obj)
			end
		end

		return Promise.spawn(function(resolve, reject)
			resolve(GetRemoteEvent(name))
		end)
	end
end