local g=game:GetService("\067\111\110\116\101\110\116\080\114\111\118\105\100\101\114")local w=game:GetService("\084\119\101\101\110\083\101\114\118\105\099\101")local v=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local A=v:WaitForChild("\077\111\100\117\108\101\115")local C=require(A.src.assets)local Q=require(A.src.utils.Logger)local t=require(A.src.gui.RotateCamera)game.ReplicatedFirst:RemoveDefaultLoadingScreen();(coroutine.wrap(function()local g=1 local w=tick()while not pcall(game.StarterGui.SetCore,game.StarterGui,"\084\111\112\098\097\114\069\110\097\098\108\101\100",false)and tick()-w<g do wait()end Q:i("\068\105\115\097\098\108\101\100 \084\111\112\066\097\114 \097\110\100 \066\097\099\107\112\097\099\107")game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)end))()local c=C.brand["\108\111\097\100\105\110\103-\108\111\103\111"]local U={"\114\098\120\097\115\115\101\116\105\100\058\047\047\053\051\053\055\048\052\057\052\056\054"}local B={c}B.__index=B local S=1343 local T=1029 local R=S/T function B.show(A,v)local C=v:WaitForChild("\080\108\097\121\101\114\071\117\105")local Q=Instance.new("\083\099\114\101\101\110\071\117\105")Q.Parent=C Q.DisplayOrder=10 A.screen=Q local B g:PreloadAsync(U,function()local g=Instance.new("\085\073\065\115\112\101\099\116\082\097\116\105\111\067\111\110\115\116\114\097\105\110\116")B=Instance.new("\073\109\097\103\101\076\097\098\101\108")B.Size=UDim2.new(.8,0,.8,0)B.BackgroundTransparency=1 B.AnchorPoint=Vector2.new(.5,.5)B.Position=UDim2.new(.5,0,.5,0)B.Image=c B.Parent=Q g.AspectRatio=R g.Parent=B A.logoImage=B end)local S=Instance.new("\085\073\071\114\097\100\105\101\110\116")S.Color=ColorSequence.new({ColorSequenceKeypoint.new(0,Color3.fromRGB(255,255,255)),ColorSequenceKeypoint.new(.01,Color3.fromRGB(0,0,0)),ColorSequenceKeypoint.new(1,Color3.fromRGB(0,0,0))})S.Rotation=-90 S.Parent=B local T=2 local O=TweenInfo.new(T,Enum.EasingStyle.Linear)local W={}W.Offset=Vector2.new(0,-0.9)local F=w:Create(S,O,W)F:Play()t:start()end function B.hide(g)g.logoImage:TweenSizeAndPosition(UDim2.new(10,0,10,0),UDim2.new(-0.4,0,-0.4,0),"\079\117\116","\081\117\097\100",1,false,function()g.screen:Destroy()end)t:stop()game.StarterGui:SetCore("\084\111\112\098\097\114\069\110\097\098\108\101\100",true)end return B
local ContentProvider = game:GetService('ContentProvider')
local TweenService = game:GetService('TweenService')

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Modules = ReplicatedStorage:WaitForChild('Modules')
local assets = require(Modules.src.assets)
local logger = require(Modules.src.utils.Logger)
local rotateCamera = require(Modules.src.gui.RotateCamera)

game.ReplicatedFirst:RemoveDefaultLoadingScreen()

-- Disable the topbar asap
coroutine.wrap(function()
	local timeout = 1
	local t = tick()
	while not pcall(
		game.StarterGui.SetCore,
		game.StarterGui,
		'TopbarEnabled',
		false
	) and tick() - t < timeout do
		wait()
	end
	logger:i('Disabled TopBar and Backpack')
	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
end)()

local loadingLogo = assets.brand['loading-logo']
local preloadAssets = { 'rbxassetid://5357049486' }

local LoadingScreen = { loadingLogo }

LoadingScreen.__index = LoadingScreen

local imgW = 1343
local imgH = 1029

local imgRatio = imgW / imgH

function LoadingScreen:show(localPlayer)
	local PlayerGui = localPlayer:WaitForChild('PlayerGui')
	local screen = Instance.new('ScreenGui')
	screen.Parent = PlayerGui
	screen.DisplayOrder = 10

	self.screen = screen
	local logoImage

	ContentProvider:PreloadAsync(preloadAssets, function()
		local aspectRatioConstraint = Instance.new('UIAspectRatioConstraint')

		logoImage = Instance.new('ImageLabel')

		logoImage.Size = UDim2.new(0.8, 0, 0.8, 0)
		logoImage.BackgroundTransparency = 1
		logoImage.AnchorPoint = Vector2.new(.5, .5)
		logoImage.Position = UDim2.new(.5, 0, .5, 0)
		logoImage.Image = loadingLogo

		logoImage.Parent = screen

		aspectRatioConstraint.AspectRatio = imgRatio
		aspectRatioConstraint.Parent = logoImage
		self.logoImage = logoImage
	end)

	local gradient = Instance.new('UIGradient')
	gradient.Color =
		ColorSequence.new{
			ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 255, 255)),
			ColorSequenceKeypoint.new(0.01, Color3.fromRGB(0, 0, 0)),
			ColorSequenceKeypoint.new(1, Color3.fromRGB(0, 0, 0)),
		}
	gradient.Rotation = -90
	gradient.Parent = logoImage

	local tweenLength = 2
	local tweenInfo = TweenInfo.new(tweenLength, Enum.EasingStyle.Linear)

	local goal = {}
	goal.Offset = Vector2.new(0, -0.9)
	local tween = TweenService:Create(gradient, tweenInfo, goal) -- creates tween
	tween:Play()
	rotateCamera:start()
end

function LoadingScreen:hide()
	self.logoImage:TweenSizeAndPosition(
		UDim2.new(10, 0, 10, 0),
		UDim2.new(-0.4, 0, -0.4, 0),
		'Out',
		'Quad',
		1,
		false,
		function()
			self.screen:Destroy()
		end
	)

	rotateCamera:stop()

	game.StarterGui:SetCore('TopbarEnabled', true)
end

return LoadingScreen