local A=(require(script.Parent.loader)).load(script)local N=game:GetService("\082\117\110\083\101\114\118\105\099\101")local E=game:GetService("\087\111\114\107\115\112\097\099\101")local I=A("\066\097\115\105\099\080\097\110\101")local e=A("\066\108\101\110\100")local s=A("\083\112\114\105\110\103\079\098\106\101\099\116")local W=A("\082\120")local p=A("\077\097\116\104")local Y=setmetatable({},I)Y.ClassName="\083\111\102\116\083\104\117\116\100\111\119\110\085\073"Y.__index=Y function Y.new()local A=setmetatable(I.new(),Y)A._title=Instance.new("\083\116\114\105\110\103\086\097\108\117\101")A._title.Value=""A._maid:GiveTask(A._title)A._subtitle=Instance.new("\083\116\114\105\110\103\086\097\108\117\101")A._subtitle.Value=""A._maid:GiveTask(A._subtitle)A._percentVisible=s.new(0,40)A._maid:GiveTask(A._percentVisible)A._maid:GiveTask(A.VisibleChanged:Connect(function(N,E)A._percentVisible.t=N and 1 or 0 if E then A._percentVisible.p=A._percentVisible.t A._percentVisible.v=0 end end))A._blur=Instance.new("\066\108\117\114\069\102\102\101\099\116")A._blur.Name="\083\111\102\116\083\104\117\116\100\111\119\110\066\108\117\114"A._blur.Enabled=false A._blur.Size=0 A._blur.Parent=E.CurrentCamera A._maid:GiveTask(A._blur)A._maid:GiveTask((A:_render()):Subscribe(function(N)A.Gui=N end))return A end function Y.SetTitle(N,A)N._title.Value=A end function Y.SetSubtitle(N,A)N._subtitle.Value=A end function Y._render(A)local E=A._percentVisible:ObserveRenderStepped()local I=e.Computed(E,function(A)return 1-A end)local s=Color3.new(0,0,0)local Y=Color3.new(.9,.9,.9)A._maid:GiveTask(E:Subscribe(function(N)A._blur.Size=N*30 A._blur.Enabled=N>0 end))return(e.New("\070\114\097\109\101"))({Name="\083\111\102\116\083\104\117\116\100\111\119\110\085\073",Size=UDim2.new(1,0,1,0);AnchorPoint=Vector2.new(.5,.5),Position=UDim2.fromScale(.5,.5);Active=e.Computed(E,function(A)return A>0 end);Visible=e.Computed(E,function(A)return A>0 end);BackgroundColor3=s,BackgroundTransparency=e.Computed(E,function(A)return p.map(A,0,1,1,.4)end),[e.Children]={(e.New("\085\073\080\097\100\100\105\110\103"))({PaddingLeft=UDim.new(0,20),PaddingRight=UDim.new(0,20);PaddingTop=UDim.new(0,20),PaddingBottom=UDim.new(0,20)});(e.New("\070\114\097\109\101"))({Name="\067\111\110\116\101\110\116\067\111\110\116\097\105\110\101\114",Size=UDim2.new(1,0,1,0),AnchorPoint=Vector2.new(.5,.5);Position=UDim2.fromScale(.5,.5),BackgroundTransparency=1;[e.Children]={(e.New("\085\073\083\099\097\108\101"))({Scale=e.Computed(E,function(A)return.7+.3*A end)});(e.New("\070\114\097\109\101"))({Name="\073\109\097\103\101\076\097\098\101\108\067\111\110\116\097\105\110\101\114";Size=UDim2.new(0,80,0,80);BackgroundTransparency=1;LayoutOrder=1,[e.Children]={(e.New("\073\109\097\103\101\076\097\098\101\108"))({Size=UDim2.new(1,0,1,0),ImageTransparency=I,BackgroundTransparency=1,Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\054\048\051\049\051\048\050\057\049\054"})}});(e.New("\070\114\097\109\101"))({Name="\076\097\098\101\108\067\111\110\116\097\105\110\101\114",Size=UDim2.new(1,0,0,80),Position=UDim2.new(.5,0,.5,0);AnchorPoint=Vector2.new(.5,.5),BackgroundTransparency=1;LayoutOrder=2,[e.Children]={(e.New("\084\101\120\116\076\097\098\101\108"))({Name="\084\105\116\108\101\076\097\098\101\108";BackgroundTransparency=1,Position=UDim2.fromScale(.5,0),Size=UDim2.new(1,0,.6,0),AnchorPoint=Vector2.new(.5,0),Text=A._title;Font=Enum.Font.SourceSansBold;TextTransparency=I;TextColor3=Y;LayoutOrder=1;TextScaled=true});(e.New("\084\101\120\116\076\097\098\101\108"))({Name="\083\117\098\116\105\116\108\101\076\097\098\101\108";BackgroundTransparency=1,Position=UDim2.fromScale(.5,1);Size=UDim2.new(1,0,.3,0);AnchorPoint=Vector2.new(.5,1),Text=A._subtitle;Font=Enum.Font.SourceSansLight,TextTransparency=I,TextColor3=Y;LayoutOrder=2;TextScaled=true}),(e.New("\085\073\065\115\112\101\099\116\082\097\116\105\111\067\111\110\115\116\114\097\105\110\116"))({AspectRatio=5})}}),(e.New("\070\114\097\109\101"))({Name="\083\112\097\099\101\114";BackgroundTransparency=1;Size=UDim2.new(0,0,0,50),LayoutOrder=3}),(e.New("\070\114\097\109\101"))({Name="\076\111\097\100\105\110\103\076\097\098\101\108",Position=UDim2.fromScale(.5,.5),AnchorPoint=Vector2.new(.5,.5),LayoutOrder=4,Size=UDim2.fromScale(.25,.25),BackgroundTransparency=1,[e.Children]={(e.New("\070\114\097\109\101"))({Name="\082\111\098\108\111\120\076\111\103\111";Size=UDim2.new(1,0,1,0);BackgroundColor3=Y;AnchorPoint=Vector2.new(.5,.5);Position=UDim2.fromScale(.5,.5),BackgroundTransparency=I;Rotation=(W.fromSignal(N.RenderStepped)):Pipe({W.map(function()local A=(tick()*math.pi)*1.5 local N=math.sin(A)local E=(math.sin(A-math.pi/2)+1)/2 if N>0 then return 15+E*360 else return 15 end end)}),[e.Children]={(e.New("\070\114\097\109\101"))({BackgroundColor3=s,Size=UDim2.fromScale(.2,.2),AnchorPoint=Vector2.new(.5,.5),Position=UDim2.fromScale(.5,.5),BackgroundTransparency=I})}});(e.New("\085\073\065\115\112\101\099\116\082\097\116\105\111\067\111\110\115\116\114\097\105\110\116"))({AspectRatio=1}),(e.New("\085\073\083\105\122\101\067\111\110\115\116\114\097\105\110\116"))({MaxSize=Vector2.new(math.huge,50)})}});(e.New("\085\073\076\105\115\116\076\097\121\111\117\116"))({FillDirection=Enum.FillDirection.Vertical;SortOrder=Enum.SortOrder.LayoutOrder;HorizontalAlignment=Enum.HorizontalAlignment.Center,VerticalAlignment=Enum.VerticalAlignment.Center;Padding=UDim.new(0,10)})}})}})end return Y


local require = require(script.Parent.loader).load(script)

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

local BasicPane = require("BasicPane")
local Blend = require("Blend")
local SpringObject = require("SpringObject")
local Rx = require("Rx")
local Math = require("Math")

local SoftShutdownUI = setmetatable({}, BasicPane)
SoftShutdownUI.ClassName = "SoftShutdownUI"
SoftShutdownUI.__index = SoftShutdownUI

function SoftShutdownUI.new()
	local self = setmetatable(BasicPane.new(), SoftShutdownUI)

	self._title = Instance.new("StringValue")
	self._title.Value = ""
	self._maid:GiveTask(self._title)

	self._subtitle = Instance.new("StringValue")
	self._subtitle.Value = ""
	self._maid:GiveTask(self._subtitle)

	self._percentVisible = SpringObject.new(0, 40)
	self._maid:GiveTask(self._percentVisible)

	self._maid:GiveTask(self.VisibleChanged:Connect(function(isVisible, doNotAnimate)
		self._percentVisible.t = isVisible and 1 or 0
		if doNotAnimate then
			self._percentVisible.p = self._percentVisible.t
			self._percentVisible.v = 0
		end
	end))

	self._blur = Instance.new("BlurEffect")
	self._blur.Name = "SoftShutdownBlur"
	self._blur.Enabled = false
	self._blur.Size = 0
	self._blur.Parent = Workspace.CurrentCamera
	self._maid:GiveTask(self._blur)

	self._maid:GiveTask(self:_render():Subscribe(function(gui)
		self.Gui = gui
	end))

	return self
end

function SoftShutdownUI:SetTitle(text)
	self._title.Value = text
end

function SoftShutdownUI:SetSubtitle(text)
	self._subtitle.Value = text
end

function SoftShutdownUI:_render()
	local percentVisible = self._percentVisible:ObserveRenderStepped()
	local transparency = Blend.Computed(percentVisible, function(value)
		return 1 - value
	end)
	local backgroundColor = Color3.new(0, 0, 0)
	local foregroundColor = Color3.new(0.9, 0.9, 0.9)

	self._maid:GiveTask(percentVisible:Subscribe(function(percent)
		self._blur.Size = percent*30
		self._blur.Enabled = percent > 0
	end))

	return Blend.New "Frame" {
		Name = "SoftShutdownUI";
		Size = UDim2.new(1, 0, 1, 0);
		AnchorPoint = Vector2.new(0.5, 0.5);
		Position = UDim2.fromScale(0.5, 0.5);
		Active = Blend.Computed(percentVisible, function(visible)
			return visible > 0
		end);
		Visible = Blend.Computed(percentVisible, function(visible)
			return visible > 0
		end);
		BackgroundColor3 = backgroundColor;
		BackgroundTransparency = Blend.Computed(percentVisible, function(visible)
			return Math.map(visible, 0, 1, 1, 0.4)
		end);

		[Blend.Children] = {
			Blend.New "UIPadding" {
				PaddingLeft = UDim.new(0, 20);
				PaddingRight = UDim.new(0, 20);
				PaddingTop = UDim.new(0, 20);
				PaddingBottom = UDim.new(0, 20);
			};

			Blend.New "Frame" {
				Name = "ContentContainer";
				Size = UDim2.new(1, 0, 1, 0);
				AnchorPoint = Vector2.new(0.5, 0.5);
				Position = UDim2.fromScale(0.5, 0.5);
				BackgroundTransparency = 1;

				[Blend.Children] = {
					Blend.New "UIScale" {
						Scale = Blend.Computed(percentVisible, function(visible)
							return 0.7 + 0.3*visible
						end);
					};

					Blend.New "Frame" {
						Name = "ImageLabelContainer";
						Size = UDim2.new(0, 80, 0, 80);
						BackgroundTransparency = 1;
						LayoutOrder = 1;

						[Blend.Children] = {
							Blend.New "ImageLabel" {
								Size = UDim2.new(1, 0, 1, 0);
								ImageTransparency = transparency;
								BackgroundTransparency = 1;
								Image = "rbxassetid://6031302916";
							};
						};
					};

					Blend.New "Frame" {
						Name = "LabelContainer";
						Size = UDim2.new(1, 0, 0, 80);
						Position = UDim2.new(0.5, 0, 0.5,0);
						AnchorPoint = Vector2.new(0.5, 0.5);
						BackgroundTransparency = 1;
						LayoutOrder = 2;

						[Blend.Children] = {
							Blend.New "TextLabel" {
								Name = "TitleLabel";
								BackgroundTransparency = 1;
								Position = UDim2.fromScale(0.5, 0);
								Size = UDim2.new(1, 0, 0.6, 0);
								AnchorPoint = Vector2.new(0.5, 0);
								Text = self._title;
								Font = Enum.Font.SourceSansBold;
								TextTransparency = transparency;
								TextColor3 = foregroundColor;
								LayoutOrder = 1;
								TextScaled = true;
							};

							Blend.New "TextLabel" {
								Name = "SubtitleLabel";
								BackgroundTransparency = 1;
								Position = UDim2.fromScale(0.5, 1);
								Size = UDim2.new(1, 0, 0.3, 0);
								AnchorPoint = Vector2.new(0.5, 1);
								Text = self._subtitle;
								Font = Enum.Font.SourceSansLight;
								TextTransparency = transparency;
								TextColor3 = foregroundColor;
								LayoutOrder = 2;
								TextScaled = true;
							};

							Blend.New "UIAspectRatioConstraint" {
								AspectRatio = 5;
							};
						};
					};

					Blend.New "Frame" {
						Name = "Spacer";
						BackgroundTransparency = 1;
						Size = UDim2.new(0, 0, 0, 50);
						LayoutOrder = 3;
					};

					Blend.New "Frame" {
						Name = "LoadingLabel";
						Position = UDim2.fromScale(0.5, 0.5);
						AnchorPoint = Vector2.new(0.5, 0.5);
						LayoutOrder = 4;
						Size = UDim2.fromScale(0.25, 0.25);
						BackgroundTransparency = 1;

						[Blend.Children] = {
							Blend.New "Frame" {
								Name = "RobloxLogo";
								Size = UDim2.new(1, 0, 1, 0);
								BackgroundColor3 = foregroundColor;
								AnchorPoint = Vector2.new(0.5, 0.5);
								Position = UDim2.fromScale(0.5, 0.5);

								BackgroundTransparency = transparency;
								Rotation = Rx.fromSignal(RunService.RenderStepped):Pipe({
									Rx.map(function()
										-- tick persists between sessions
										local t = tick()*math.pi*1.5
										local smallerWave = math.sin(t)
										local percent = (math.sin(t - math.pi/2) + 1)/2

										if smallerWave > 0 then
											return 15 + percent*360
										else
											return 15
										end
									end);
								});

								[Blend.Children] = {
									Blend.New "Frame" {
										BackgroundColor3 = backgroundColor;
										Size = UDim2.fromScale(1/5, 1/5);
										AnchorPoint = Vector2.new(0.5, 0.5);
										Position = UDim2.fromScale(0.5, 0.5);
										BackgroundTransparency = transparency;
									};
								}
							};

							Blend.New "UIAspectRatioConstraint" {
								AspectRatio = 1;
							};

							Blend.New "UISizeConstraint" {
								MaxSize = Vector2.new(math.huge, 50);
							};
						};
					};

					Blend.New "UIListLayout" {
						FillDirection = Enum.FillDirection.Vertical;
						SortOrder = Enum.SortOrder.LayoutOrder;
						HorizontalAlignment = Enum.HorizontalAlignment.Center;
						VerticalAlignment = Enum.VerticalAlignment.Center;
						Padding = UDim.new(0, 10);
					};
				};
			};
		};
	}
end

return SoftShutdownUI
