local a=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 L=game:GetService("\080\108\097\121\101\114\115")local I=a("\080\114\111\109\105\115\101")local R={}R.ThumbnailPollerName="\080\108\097\121\101\114\084\104\117\109\098\110\097\105\108\115"R.__index=R R.MAX_TRIES=5 function R.new()local a=setmetatable({},R)return a end function R.GetUserThumbnail(P,a,R,X)assert(a)assert(R)assert(X)local A A=I.spawn(function(I,i)local q=0 repeat q=q+1 local k,d local C,j=pcall(function()k,d=L:GetUserThumbnailAsync(a,R,X)end)if not C then return i(j)end if d then return I(k)else wait(.05)end until q>=P.MAX_TRIES or not A:IsPending()i()end)return A end return R.new()
--- Reimplementation of Player:GetUserThumbnailAsync but as a promise with
--  retry logic
-- @module PlayerThumbnails

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

local Players = game:GetService("Players")

local Promise = require("Promise")

local PlayerThumbnails = {}
PlayerThumbnails.ThumbnailPollerName = "PlayerThumbnails"
PlayerThumbnails.__index = PlayerThumbnails
PlayerThumbnails.MAX_TRIES = 5

function PlayerThumbnails.new()
	local self = setmetatable({}, PlayerThumbnails)

	return self
end

function PlayerThumbnails:GetUserThumbnail(userId, thumbnailType, thumbnailSize)
	assert(userId)
	assert(thumbnailType)
	assert(thumbnailSize)

	local promise
	promise = Promise.spawn(function(resolve, reject)
		local tries = 0
		repeat
			tries = tries + 1
			local content, isReady
			local ok, err = pcall(function()
				content, isReady = Players:GetUserThumbnailAsync(userId, thumbnailType, thumbnailSize)
			end)

			-- Don't retry if we immediately error (timeout exceptions!)
			if not ok then
				return reject(err)
			end

			if isReady then
				return resolve(content)
			else
				wait(0.05)
			end
		until tries >= self.MAX_TRIES or (not promise:IsPending())
		reject()
	end)

	return promise
end


return PlayerThumbnails.new()