local function B(B,d,...)assert(type(B)=="\110\117\109\098\101\114","\066\097\100 \116\105\109\101\111\117\116\073\110\083\101\099\111\110\100\115")assert(type(d)=="\102\117\110\099\116\105\111\110","\066\097\100 \102\117\110\099")local Y=table.pack(...)local g task.spawn(function()g=coroutine.running()task.wait(B)local U=Y g=nil Y=nil d(table.unpack(U,1,U.n))end)return function()if g then coroutine.close(g)g=nil Y=nil end end end return B
--[=[
	@function cancellableDelay
	@param timeoutInSeconds number
	@param func function
	@param ... any -- Args to pass into the function
	@return function? -- Can be used to cancel
	@within cancellableDelay
]=]
local function cancellableDelay(timeoutInSeconds, func, ...)
	assert(type(timeoutInSeconds) == "number", "Bad timeoutInSeconds")
	assert(type(func) == "function", "Bad func")

	local args = table.pack(...)

	local running
	task.spawn(function()
		running = coroutine.running()
		task.wait(timeoutInSeconds)
		local localArgs = args
		running = nil
		args = nil
		func(table.unpack(localArgs, 1, localArgs.n))
	end)

	return function()
		if running then
			coroutine.close(running)
			running = nil
			args = nil
		end
	end
end

return cancellableDelay
