local function j(j,F,I,n,w)local W if w then W=0 else W=.3 end local A=TweenInfo.new(W,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)local k=subPageOrders[j.Name]local x if tonumber(F)then x=j[k[F]]end local v=j[k[I]]local e if x and x:IsA("\083\099\114\111\108\108\105\110\103\070\114\097\109\101")then x.ScrollBarImageTransparency=1 end if v:IsA("\083\099\114\111\108\108\105\110\103\070\114\097\109\101")then v.ScrollBarImageTransparency=0 end local m=j:FindFirstChild("\083\101\097\114\099\104\066\097\114")if m then if v.Size.Y.Scale<.85 then m.Visible=true else m.Visible=false end end for F,I in pairs(k)do local n=j[I]if n~=v and n~=x then n.Position=UDim2.new(-2,0,n.Position.Y.Scale,0)end end if n=="\082\105\103\104\116"then e=1 elseif n=="\076\101\102\116"then e=-1 end local z=e*-1 j.NavigateButtons.TextLabel.Text=string.upper(v.Name)v.Position=UDim2.new(e,0,v.Position.Y.Scale,v.Position.Y.Offset)local G=main.tweenService:Create(v,A,{Position=UDim2.new(0,0,v.Position.Y.Scale,0)})G:Play()if x then local j=main.tweenService:Create(x,A,{Position=UDim2.new(z,0,x.Position.Y.Scale,0)})j:Play()spawn(function()j.Completed:Wait()if x.Position.X.Scale==z then x.Position=UDim2.new(-2,0,x.Position.Y.Scale,0)end end)end end for F,I in pairs(pages:GetChildren())do if I:FindFirstChild("\078\097\118\105\103\097\116\101\066\117\116\116\111\110\115")then local F=1 local n=0 local w=subPageOrders[I.Name]for j,F in pairs(w)do local w=I[F]if j==1 then I.NavigateButtons.TextLabel.Text=string.upper(F)else n=1 end w.Position=UDim2.new(n,0,w.Position.Y.Scale,0)w.Visible=true end for n,W in pairs(I.NavigateButtons:GetChildren())do if W:IsA("\084\101\120\116\066\117\116\116\111\110")then W.MouseButton1Down:Connect(function()local n=F if W.Name=="\082\105\103\104\116"then F=F+1 if F>#w then F=1 end elseif W.Name=="\076\101\102\116"then F=F-1 if F<1 then F=#w end end j(I,n,F,W.Name)end)end end end end for j,F in pairs(mainFrame.DragBar:GetChildren())do if F:IsA("\084\101\120\116\066\117\116\116\111\110")then F.MouseButton1Down:Connect(function()if guiDe then guiDe=false if F.Name=="\077\105\110\105\109\105\115\101"then if F.TextLabel.Text=="-"then(main.tweenService:Create(pages,TweenInfo.new(.5),{Position=UDim2.new(0,0,-0.8,0)})):Play()F.TextLabel.Text="\043"else pages.Parent.Visible=true;(main.tweenService:Create(pages,TweenInfo.new(.5),{Position=UDim2.new(0,0,.1,0)})):Play()F.TextLabel.Text="-"end elseif F.Name=="\067\108\111\115\101"then module:CloseMainFrame()elseif F.Name=="\066\097\099\107"then tweenPages(UDim2.new(1,0,0,0),pages.Home)end guiDe=true end end)end end
-- Navigate SubPages (using NavigateButtons)
local function navigateNewPage(page, oldPos, newPos, direction, instantTween)
	local tweenTime
	if instantTween then
		tweenTime = 0
	else
		tweenTime = 0.3
	end
	local tweenInfo = TweenInfo.new(tweenTime, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
	local subPageNames = subPageOrders[page.Name]
	local pageOut
	if tonumber(oldPos) then
		pageOut = page[subPageNames[oldPos]]
	end
	local pageIn = page[subPageNames[newPos]]
	local startX
	if pageOut and pageOut:IsA("ScrollingFrame") then
		pageOut.ScrollBarImageTransparency = 1
	end
	if pageIn:IsA("ScrollingFrame") then
		pageIn.ScrollBarImageTransparency = 0
	end
	local searchBar = page:FindFirstChild("SearchBar")
	if searchBar then
		if pageIn.Size.Y.Scale < 0.85 then
			searchBar.Visible = true
		else
			searchBar.Visible = false
		end
	end
	--
	for i, v in pairs(subPageNames) do
		local subPage = page[v]
		if subPage ~= pageIn and subPage ~= pageOut then
			subPage.Position = UDim2.new(-2, 0, subPage.Position.Y.Scale, 0)
		end
	end
	--
	if direction == "Right" then
		startX = 1
	elseif direction == "Left" then
		startX = -1
	end
	local endX = startX * -1
	page.NavigateButtons.TextLabel.Text = string.upper(pageIn.Name)
	pageIn.Position = UDim2.new(startX, 0, pageIn.Position.Y.Scale, pageIn.Position.Y.Offset)
	local tweenIn =
		main.tweenService:Create(pageIn, tweenInfo, { Position = UDim2.new(0, 0, pageIn.Position.Y.Scale, 0) })
	tweenIn:Play()
	if pageOut then
		local tweenOut =
			main.tweenService:Create(pageOut, tweenInfo, { Position = UDim2.new(endX, 0, pageOut.Position.Y.Scale, 0) })
		tweenOut:Play()
		spawn(function()
			tweenOut.Completed:Wait()
			if pageOut.Position.X.Scale == endX then
				pageOut.Position = UDim2.new(-2, 0, pageOut.Position.Y.Scale, 0)
			end
		end)
	end
end
for a, b in pairs(pages:GetChildren()) do
	if b:FindFirstChild("NavigateButtons") then
		local pos = 1
		local pageX = 0
		local subPages = subPageOrders[b.Name]
		for i, v in pairs(subPages) do
			local subPage = b[v]
			if i == 1 then
				b.NavigateButtons.TextLabel.Text = string.upper(v)
			else
				pageX = 1
			end
			subPage.Position = UDim2.new(pageX, 0, subPage.Position.Y.Scale, 0)
			subPage.Visible = true
		end
		for c, d in pairs(b.NavigateButtons:GetChildren()) do
			if d:IsA("TextButton") then
				d.MouseButton1Down:Connect(function()
					local oldPos = pos
					if d.Name == "Right" then
						pos = pos + 1
						if pos > #subPages then
							pos = 1
						end
					elseif d.Name == "Left" then
						pos = pos - 1
						if pos < 1 then
							pos = #subPages
						end
					end
					navigateNewPage(b, oldPos, pos, d.Name)
				end)
			end
		end
	end
end

for a, b in pairs(mainFrame.DragBar:GetChildren()) do
	if b:IsA("TextButton") then
		b.MouseButton1Down:Connect(function()
			if guiDe then
				guiDe = false
				if b.Name == "Minimise" then
					if b.TextLabel.Text == "-" then
						main.tweenService
							:Create(pages, TweenInfo.new(0.5), { Position = UDim2.new(0, 0, -0.8, 0) })
							:Play()
						b.TextLabel.Text = "+"
					else
						pages.Parent.Visible = true
						main.tweenService
							:Create(pages, TweenInfo.new(0.5), { Position = UDim2.new(0, 0, 0.1, 0) })
							:Play()
						b.TextLabel.Text = "-"
					end
				elseif b.Name == "Close" then
					module:CloseMainFrame()
				elseif b.Name == "Back" then
					tweenPages(UDim2.new(1, 0, 0, 0), pages.Home)
				end
				guiDe = true
			end
		end)
	end
end
