log("\082\101\116\117\114\110 \105\110\105\116 \102\117\110\099\116\105\111\110")return service.NewProxy({__call=function(w,f)log("\066\101\103\105\110 \105\110\105\116")local Q,I=string.match(f.Name,"\040\046\042\041\092\040\046\042\041")Folder=service.Wrap(f.Folder or Folder)setfenv(1,setmetatable({},{__metatable=unique}))client.Folder=Folder client.UIFolder=Folder:WaitForChild("\085\073",9000000000.0)client.Shared=Folder:WaitForChild("\083\104\097\114\101\100",9000000000.0)client.Loader=f.Loader client.Module=f.Module client.DepsName=I client.TrueStart=f.Start client.LoadingTime=f.LoadingTime client.RemoteName=Q client.Changelog=oldReq(service_UnWrap(client.Shared.Changelog))do local w=oldReq(service_UnWrap(client.Shared.MatIcons))client.MatIcons=setmetatable({},{__index=function(f,Q)local I=w[Q]if I then f[Q]=string.format("\114\098\120\097\115\115\101\116\105\100\058\047\047\037\100",I)return f[Q]end end;__metatable="\065\100\111\110\105\115"})end log("\071\101\116 \100\101\112\101\110\100\101\110\099\105\101\115")for w,f in ipairs((Folder:WaitForChild("\068\101\112\101\110\100\101\110\099\105\101\115",9000000000.0)):GetChildren())do client.Deps[f.Name]=f end log("\068\101\115\116\114\111\121 \115\099\114\105\112\116 \111\098\106\101\099\116")script.Parent=nil log("\073\110\105\116\105\097\108 \115\101\114\118\105\099\101\115 \099\097\099\104\105\110\103")for w,f in ipairs(ServicesWeUse)do local Q=service[f]end log("\065\100\100 \115\101\114\118\105\099\101 \115\112\101\099\105\102\105\099")ServiceSpecific.Player=service.Players.LocalPlayer or(function()(service.Players:GetPropertyChangedSignal("\076\111\099\097\108\080\108\097\121\101\114")):Wait()return service.Players.LocalPlayer end)()ServiceSpecific.PlayerGui=ServiceSpecific.Player:FindFirstChildWhichIsA("\080\108\097\121\101\114\071\117\105")if not ServiceSpecific.PlayerGui then Routine(function()local w=ServiceSpecific.Player:WaitForChild("\080\108\097\121\101\114\071\117\105",120)if not w then logError("\080\108\097\121\101\114\071\117\105 \117\110\097\098\108\101 \116\111 \098\101 \102\101\116\099\104\101\100\063 \091\087\097\105\116\101\100 \049\050\048 \083\101\099\111\110\100\115\093")return end ServiceSpecific.PlayerGui=w end)end ServiceSpecific.Filter=function(w,f,Q)return client.Remote.Get("\070\105\108\116\101\114",w,Q and f or service.Player,Q or f)end ServiceSpecific.LaxFilter=function(w,f)return service.Filter(w,f or service.Player,f or service.Player)end ServiceSpecific.BroadcastFilter=function(w,f)return client.Remote.Get("\066\114\111\097\100\099\097\115\116\070\105\108\116\101\114",w,f or service.Player)end ServiceSpecific.IsMobile=function()return service.UserInputService.TouchEnabled and(not service.UserInputService.MouseEnabled and not service.UserInputService.KeyboardEnabled)end ServiceSpecific.LocalContainer=function()if not client.Variables.LocalContainer or not client.Variables.LocalContainer.Parent then client.Variables.LocalContainer=service.New("\070\111\108\100\101\114")client.Variables.LocalContainer.Name="\095\095\065\068\079\078\073\083\095\076\079\067\065\076\067\079\078\084\065\073\078\069\082\095"..client.Functions.GetRandom()client.Variables.LocalContainer.Parent=workspace end return client.Variables.LocalContainer end log("\076\111\097\100\105\110\103 \099\111\114\101 \109\111\100\117\108\101\115")for w,f in ipairs(LoadingOrder)do local Q=Folder.Core:FindFirstChild(f)if Q then log("~\033 \076\111\097\100\105\110\103 \067\111\114\101 \077\111\100\117\108\101\058 "..tostring(f))LoadModule(Q,true,{script=script})end end local n={}local s={}local O={}local B={}client.Finish_Loading=function()log("\067\108\105\101\110\116 \102\105\114\101\100 \102\105\110\105\115\104\101\100 \108\111\097\100\105\110\103")if client.Core.Key then log("~\033 \068\111\105\110\103 \114\117\110 \097\102\116\101\114 \108\111\097\100\101\100")for w,Q in pairs(O)do Pcall(Q,f)end log("~\033 \068\111\105\110\103 \114\117\110 \108\097\115\116")for w,Q in pairs(n)do Pcall(Q,f)end log("\070\105\110\105\115\104 \108\111\097\100\105\110\103")clientLocked=true client.Finish_Loading=function() end client.LoadingTime()service.Events.FinishedLoading:Fire(os.time())log("~\033 \070\073\078\073\083\072\069\068 \076\079\065\068\073\078\071\033")else log("\067\108\105\101\110\116 \109\105\115\115\105\110\103 \114\101\109\111\116\101 \107\101\121");(client.Kill())("\077\105\115\115\105\110\103 \114\101\109\111\116\101 \107\101\121")end end log("~\033 \073\110\105\116 \099\111\114\101\115")for w,Q in ipairs(LoadingOrder)do local I=client[Q]log("~\033 \073\078\073\084\058 "..tostring(Q))if I then if type(I)=="\116\097\098\108\101"or type(I)=="\117\115\101\114\100\097\116\097"and getmetatable(I)=="\082\101\097\100\079\110\108\121\095\084\097\098\108\101"then if I.RunLast then table.insert(n,I.RunLast)I.RunLast=nil end if I.RunAfterInit then table.insert(s,I.RunAfterInit)I.RunAfterInit=nil end if I.RunAfterPlugins then table.insert(B,I.RunAfterPlugins)I.RunAfterPlugins=nil end if I.RunAfterLoaded then table.insert(O,I.RunAfterLoaded)I.RunAfterLoaded=nil end if I.Init then log("\082\117\110 \105\110\105\116 \102\111\114 "..tostring(Q))Pcall(I.Init,f)I.Init=nil end end end end log("~\033 \082\117\110\110\105\110\103 \097\102\116\101\114 \105\110\105\116")for w,Q in pairs(s)do Pcall(Q,f)end log("~\033 \082\117\110\110\105\110\103 \112\108\117\103\105\110\115")for w,f in ipairs(Folder.Plugins:GetChildren())do LoadModule(f,false,{script=f})end log("~\033 \082\117\110\110\105\110\103 \097\102\116\101\114 \112\108\117\103\105\110\115")for w,Q in pairs(B)do Pcall(Q,f)end log("\073\110\105\116\105\097\108 \108\111\097\100\105\110\103 \099\111\109\112\108\101\116\101")client.AllModulesLoaded=true service.Events.AllModulesLoaded:Fire(os.time())service.Events.ClientInitialized:Fire()log("~\033 \082\101\116\117\114\110 \115\117\099\099\101\115\115")return"\083\085\067\067\069\083\083"end;__metatable="\065\100\111\110\105\115",__tostring=function()return"\065\100\111\110\105\115"end})
--// Init
log("Return init function")
return service.NewProxy({
	__call = function(self, data)
		log("Begin init")

		local remoteName, depsName = string.match(data.Name, "(.*)\\(.*)")
		Folder = service.Wrap(data.Folder --[[or folder and folder:Clone()]] or Folder)

		setfenv(1, setmetatable({}, { __metatable = unique }))
		client.Folder = Folder
		client.UIFolder = Folder:WaitForChild("UI", 9e9)
		client.Shared = Folder:WaitForChild("Shared", 9e9)
		client.Loader = data.Loader
		client.Module = data.Module
		client.DepsName = depsName
		client.TrueStart = data.Start
		client.LoadingTime = data.LoadingTime
		client.RemoteName = remoteName

		client.Changelog = oldReq(service_UnWrap(client.Shared.Changelog))
		do
			local MaterialIcons = oldReq(service_UnWrap(client.Shared.MatIcons))
			client.MatIcons = setmetatable({}, {
				__index = function(self, ind)
					local materialIcon = MaterialIcons[ind]
					if materialIcon then
						self[ind] = string.format("rbxassetid://%d", materialIcon)
						return self[ind]
					end
				end,
				__metatable = "Adonis",
			})
		end

		--// Toss deps into a table so we don't need to directly deal with the Folder instance they're in
		log("Get dependencies")
		for ind, obj in ipairs(Folder:WaitForChild("Dependencies", 9e9):GetChildren()) do
			client.Deps[obj.Name] = obj
		end

		--// Do this before we start hooking up events
		log("Destroy script object")
		--folder:Destroy()
		script.Parent = nil --script:Destroy()

		--// Intial setup
		log("Initial services caching")
		for ind, serv in ipairs(ServicesWeUse) do
			local temp = service[serv]
		end

		--// Client specific service variables/functions
		log("Add service specific")
		ServiceSpecific.Player = service.Players.LocalPlayer
			or (function()
				service.Players:GetPropertyChangedSignal("LocalPlayer"):Wait()
				return service.Players.LocalPlayer
			end)()
		ServiceSpecific.PlayerGui = ServiceSpecific.Player:FindFirstChildWhichIsA("PlayerGui")
		if not ServiceSpecific.PlayerGui then
			Routine(function()
				local PlayerGui = ServiceSpecific.Player:WaitForChild("PlayerGui", 120)
				if not PlayerGui then
					logError("PlayerGui unable to be fetched? [Waited 120 Seconds]")
					return
				end
				ServiceSpecific.PlayerGui = PlayerGui
			end)
		end
		--[[
		-- // Doesn't seem to be used anymore

		ServiceSpecific.SafeTweenSize = function(obj, ...)
			pcall(obj.TweenSize, obj, ...)
		end;
		ServiceSpecific.SafeTweenPos = function(obj, ...)
			pcall(obj.TweenPosition, obj, ...)
		end;
		]]

		ServiceSpecific.Filter = function(str, from, to)
			return client.Remote.Get("Filter", str, (to and from) or service.Player, to or from)
		end
		ServiceSpecific.LaxFilter = function(str, from)
			return service.Filter(str, from or service.Player, from or service.Player)
		end

		ServiceSpecific.BroadcastFilter = function(str, from)
			return client.Remote.Get("BroadcastFilter", str, from or service.Player)
		end

		ServiceSpecific.IsMobile = function()
			return service.UserInputService.TouchEnabled
				and not service.UserInputService.MouseEnabled
				and not service.UserInputService.KeyboardEnabled
		end

		ServiceSpecific.LocalContainer = function()
			if not client.Variables.LocalContainer or not client.Variables.LocalContainer.Parent then
				client.Variables.LocalContainer = service.New("Folder")
				client.Variables.LocalContainer.Name = "__ADONIS_LOCALCONTAINER_" .. client.Functions.GetRandom()
				client.Variables.LocalContainer.Parent = workspace
			end
			return client.Variables.LocalContainer
		end

		--// Load Core Modules
		log("Loading core modules")
		for ind, load in ipairs(LoadingOrder) do
			local modu = Folder.Core:FindFirstChild(load)
			if modu then
				log("~! Loading Core Module: " .. tostring(load))
				LoadModule(modu, true, { script = script })
			end
		end

		--// Start of module loading and server connection process
		local runLast = {}
		local runAfterInit = {}
		local runAfterLoaded = {}
		local runAfterPlugins = {}

		--// Loading Finisher
		client.Finish_Loading = function()
			log("Client fired finished loading")
			if client.Core.Key then
				--// Run anything from core modules that needs to be done after the client has finished loading
				log("~! Doing run after loaded")
				for i, f in pairs(runAfterLoaded) do
					Pcall(f, data)
				end

				--// Stuff to run after absolutely everything else
				log("~! Doing run last")
				for i, f in pairs(runLast) do
					Pcall(f, data)
				end

				--// Finished loading
				log("Finish loading")
				clientLocked = true
				client.Finish_Loading = function() end
				client.LoadingTime() --origWarn(tostring(time()-(client.TrueStart or startTime)))
				service.Events.FinishedLoading:Fire(os.time())

				log("~! FINISHED LOADING!")
			else
				log("Client missing remote key")
				client.Kill()("Missing remote key")
			end
		end

		--// Initialize Cores
		log("~! Init cores")
		for i, name in ipairs(LoadingOrder) do
			local core = client[name]
			log("~! INIT: " .. tostring(name))

			if core then
				if type(core) == "table" or (type(core) == "userdata" and getmetatable(core) == "ReadOnly_Table") then
					if core.RunLast then
						table.insert(runLast, core.RunLast)
						core.RunLast = nil
					end

					if core.RunAfterInit then
						table.insert(runAfterInit, core.RunAfterInit)
						core.RunAfterInit = nil
					end

					if core.RunAfterPlugins then
						table.insert(runAfterPlugins, core.RunAfterPlugins)
						core.RunAfterPlugins = nil
					end

					if core.RunAfterLoaded then
						table.insert(runAfterLoaded, core.RunAfterLoaded)
						core.RunAfterLoaded = nil
					end

					if core.Init then
						log("Run init for " .. tostring(name))
						Pcall(core.Init, data)
						core.Init = nil
					end
				end
			end
		end

		--// Load any afterinit functions from modules (init steps that require other modules to have finished loading)
		log("~! Running after init")
		for i, f in pairs(runAfterInit) do
			Pcall(f, data)
		end

		--// Load Plugins
		log("~! Running plugins")
		for index, plugin in ipairs(Folder.Plugins:GetChildren()) do
			LoadModule(plugin, false, { script = plugin }) --noenv
		end

		--// We need to do some stuff *after* plugins are loaded (in case we need to be able to account for stuff they may have changed before doing something, such as determining the max length of remote commands)
		log("~! Running after plugins")
		for i, f in pairs(runAfterPlugins) do
			Pcall(f, data)
		end

		log("Initial loading complete")

		--// Below can be used to determine when all modules and plugins have finished loading; service.Events.AllModulesLoaded:Connect(function() doSomething end)
		client.AllModulesLoaded = true
		service.Events.AllModulesLoaded:Fire(os.time())

		--[[client = service.ReadOnly(client, {
			[client.Variables] = true;
			[client.Handlers] = true;
			G_API = true;
			G_Access = true;
			G_Access_Key = true;
			G_Access_Perms = true;
			Allowed_API_Calls = true;
			HelpButtonImage = true;
			Finish_Loading = true;
			RemoteEvent = true;
			ScriptCache = true;
			Returns = true;
			PendingReturns = true;
			EncodeCache = true;
			DecodeCache = true;
			Received = true;
			Sent = true;
			Service = true;
			Holder = true;
			GUIs = true;
			LastUpdate = true;
			RateLimits = true;

			Init = true;
			RunAfterInit = true;
			RunAfterLoaded = true;
			RunAfterPlugins = true;
		}, true)--]]

		service.Events.ClientInitialized:Fire()

		log("~! Return success")
		return "SUCCESS"
	end,
	__metatable = "Adonis",
	__tostring = function()
		return "Adonis"
	end,
})
