--------------------------------------------------------------------------------


local Tooltip = {}

function Tooltip:Set(Text: string)
	ChangeId += 1
	
	Frame:WaitForChild("TextLabel").Text = Text
	Frame.GroupTransparency = 1
	Frame.Visible = true
	Tween:Play(Frame, {0.3, "Exponential"}, {GroupTransparency = 0})
	Tween:Play(Frame:WaitForChild("UIStroke"), {0.3, "Exponential"}, {Transparency = 0})
end

function Tooltip:Clear()
	local Id = ChangeId
	
	Tween:Play(Frame:WaitForChild("UIStroke"), {0.3, "Exponential"}, {Transparency = 1})
	Tween:Play(Frame, {0.3, "Exponential"}, {GroupTransparency = 1}).Completed:Once(function()
		if ChangeId == Id then
			Frame.Visible = false
		end
	end)
end

local function GetTooltipPosition(): UDim2
	local MouseLocation = UserInputService:GetMouseLocation()
	local ViewportSize = workspace.CurrentCamera.ViewportSize
	local TooltipSize = Frame:WaitForChild("TextLabel").AbsoluteSize
	
	return UDim2.fromOffset(
		math.clamp(MouseLocation.X + 16, 0, ViewportSize.X - (TooltipSize.X+24)),
		math.clamp(MouseLocation.Y + 16, 0, ViewportSize.Y - (TooltipSize.Y+24))
	)
end
