local A="\104\116\116\112\115\058\047\047\114\097\119\046\103\105\116\104\117\098\117\115\101\114\099\111\110\116\101\110\116\046\099\111\109\047\089\049\049\057\053\047\065\118\097\116\097\114-\069\100\105\116\111\114-\050\047\109\097\115\116\101\114\047\118\101\114\115\105\111\110\046\116\120\116"local v="\104\116\116\112\115\058\047\047\114\097\119\046\103\105\116\104\117\098\117\115\101\114\099\111\110\116\101\110\116\046\099\111\109\047\089\049\049\057\053\047\065\118\097\116\097\114-\069\100\105\116\111\114-\050\047\109\097\115\116\101\114\047\102\105\108\101\108\105\115\116\046\106\115\111\110"local Y="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\055\049\051\048\057\056\056\056\051\055"local i="\086\069\082\083\073\079\078"local C={AE_OverwriteSettings=false;AE_OverwriteCatalog=true,AE_QuickStart=true}local R={Hat=8,Shirt=11;Pants=12;Head=17;Face=18;Torso=27;RightArm=28;LeftArm=29,LeftLeg=30,RightLeg=31;HairAccessory=41;FaceAccessory=42,NeckAccessory=43,ShoulderAccessory=44,FrontAccessory=45;BackAccessory=46;WaistAccessory=47;ClimbAnimation=48;DeathAnimation=49;FallAnimation=50;IdleAnimation=51;JumpAnimation=52,RunAnimation=53;SwimAnimation=54;WalkAnimation=55;PoseAnimation=56;EmoteAnimation=61}local M=game:GetService("\072\116\116\112\083\101\114\118\105\099\101")local k=game:GetService("\067\104\097\110\103\101\072\105\115\116\111\114\121\083\101\114\118\105\099\101")local H=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local c=game:GetService("\077\097\114\107\101\116\112\108\097\099\101\083\101\114\118\105\099\101")local p=require(script.CheckboxLabel)local f=require(script.Dropdown)local P=require(script.Theme)local E=require(script.Promise)local l=require(script.RequestQueue)local x=require(script.Encode)local V=require(script.Gui.InstallerFrameToLua)local O=require(script.Gui.FrameToLua)local d=require(script.Gui.AdderFrameToLua)local X=require(script.Gui.SuccessFrameToLua)local S=plugin:CreateToolbar("\065\118\097\116\097\114 \069\100\105\116\111\114")local Q=S:CreateButton("\073\110\115\116\097\108\108\101\114","\073\110\115\116\097\108\108\047\117\112\100\097\116\101 \116\104\101 \065\118\097\116\097\114 \069\100\105\116\111\114","")local g=S:CreateButton("\065\100\100\101\114","\065\100\100 \097\099\099\101\115\115\111\114\105\101\115 \116\111 \116\104\101 \100\097\116\097\098\097\115\101\046","")Q.ClickableWhenViewportHidden=true g.ClickableWhenViewportHidden=true local u=DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float,false,true,250,387,250,387)local J=plugin:CreateDockWidgetPluginGui("\065\118\097\116\097\114\069\100\105\116\111\114\073\110\115\116\097\108\108\101\114\080\108\117\103\105\110",u)J.Name="\065\118\097\116\097\114\069\100\105\116\111\114\073\110\115\116\097\108\108\101\114"J.Title="\065\118\097\116\097\114 \069\100\105\116\111\114 \073\110\115\116\097\108\108\101\114"J.ZIndexBehavior=Enum.ZIndexBehavior.Sibling local e=DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float,false,true,250,676,250,676)local y=plugin:CreateDockWidgetPluginGui("\065\118\097\116\097\114\069\100\105\116\111\114\065\100\100\101\114\080\108\117\103\105\110",e)y.Name="\065\118\097\116\097\114\069\100\105\116\111\114\065\100\100\101\114"y.Title="\065\118\097\116\097\114 \069\100\105\116\111\114 \065\100\100\101\114"y.ZIndexBehavior=Enum.ZIndexBehavior.Sibling local n=V()n.Size=UDim2.new(1,0,1,0)n.Position=UDim2.new()n.Body.UIPageLayout.ScrollWheelInputEnabled=false n.Parent=J local Z=d()Z.Size=UDim2.new(1,0,1,0)Z.Position=UDim2.new()Z.Body.UIPageLayout.ScrollWheelInputEnabled=false Z.Parent=y local w=O()local r=X()local m=false local I=false local h={}local o={}local t=8 local function b(A)return E.new(function(v,Y)local i,C=pcall(function()return M:RequestAsync({Url=A;Method="\071\069\084"})end)if i then v(C)else Y(C)end end)end local function L(A)return E.new(function(v,Y)((b(A)):andThen(function(A)return E.new(function(v)local i,C=pcall(function()return M:JSONDecode(A.Body)end)if i then v(A,C)else Y(A,C)end end)end)):andThen(function(A,Y)v(A,Y)end)end)end local function q(A)if A:match("\037\046\115\101\114\118\101\114\037\046\108\117\097\036")then return"\083\099\114\105\112\116",A:match("\040\046\043\041\037\046\115\101\114\118\101\114\037\046\108\117\097\036")elseif A:match("\037\046\099\108\105\101\110\116\037\046\108\117\097\036")then return"\076\111\099\097\108\083\099\114\105\112\116",A:match("\040\046\043\041\037\046\099\108\105\101\110\116\037\046\108\117\097\036")else return"\077\111\100\117\108\101\083\099\114\105\112\116",A:match("\040\046\043\041\037\046\108\117\097\036")end end local function U(A)for A,v in pairs(A.children)do if v.name:match("\094\105\110\105\116\037\046")then return true,q(v.name)end end return false end local function N(A)local v=H:FindFirstChild("\065\118\097\116\097\114\069\100\105\116\111\114")if v then local Y=v:FindFirstChild(i)if not Y or not Y:IsA("\083\116\114\105\110\103\086\097\108\117\101")then Y=Instance.new("\083\116\114\105\110\103\086\097\108\117\101")Y.Name=i Y.Parent=v end Y.Value=A end end local function T(i,C,R)local function M(A)local v=n.Body.Fail v.TextLabel.Text=A n.Body.UIPageLayout:JumpToIndex(3)end n.Body.UIPageLayout:JumpToIndex(1)local c=n.Body.Progress local p=c.TextFrame.TextLabel local f=c.Bar.Fill local P=c.TextLabel f.Size=UDim2.new(0,0,1,0)P.Text=""p.Text="\071\101\116\116\105\110\103 \108\097\116\101\115\116 \118\101\114\115\105\111\110\046\046\046"local E=(b(A)):expect()if not E.Success then M("\070\097\105\108\101\100 \116\111 \103\101\116 \118\101\114\115\105\111\110 \108\105\115\116"..E.StatusMessage)return end p.Text="\071\101\116\116\105\110\103 \102\105\108\101 \108\105\115\116\046\046\046"local l,x=(L(v)):expect()if not l.Success then M("\070\097\105\108\101\100 \116\111 \103\101\116 \102\105\108\101 \108\105\115\116"..l.StatusMessage)return end local V=0 local O=0 x.paths.parent={path=x.url}x.paths.folder={FindFirstChild=function(A,v)return game:GetService(v)end}h={}k:SetWaypoint("\065\069\095\073\110\115\116\097\108\108\066\101\103\105\110")P.Text="\048\037"local function d(A)for A,v in pairs(A.children)do V=V+1 if v.type=="\100\105\114\101\099\116\111\114\121"then d(v)end end end local function X()O=O+1 f.Size=UDim2.new(O/V,0,1,0)P.Text=("\037\105 \047 \037\105 \040\037\105\037\037\041"):format(O,V,(O/V)*100)end local function S(A,v,Y)local i=(b(v)):expect()if not i.Success then k:SetWaypoint("\065\069\095\073\110\115\116\097\108\108\070\097\105\108")M(i.StatusMessage)return end local C=i.Body if Y or A.Source~=C then table.insert(h,{Script=A,NewSource=C})end end local function Q(A)A.path=A.parent.path..(A.name.."\047")for v,Y in pairs(A.children)do X()if not R and(Y.name=="\083\099\114\105\112\116"or Y.name=="\076\111\099\097\108\083\099\114\105\112\116")then continue end if Y.type=="\100\105\114\101\099\116\111\114\121"then local v=A.folder:FindFirstChild(Y.name)local i,C=U(Y)if v then if i then local i=C=="\083\099\114\105\112\116"and"\046\115\101\114\118\101\114\046\108\117\097"or C=="\076\111\099\097\108\083\099\114\105\112\116"and"\046\099\108\105\101\110\116\046\108\117\097"or"\046\108\117\097"S(v,A.path..(Y.name..("\047\105\110\105\116"..i)),false)end else v=Instance.new(C or"\070\111\108\100\101\114")v.Name=Y.name if i then local i=C=="\083\099\114\105\112\116"and"\046\115\101\114\118\101\114\046\108\117\097"or C=="\076\111\099\097\108\083\099\114\105\112\116"and"\046\099\108\105\101\110\116\046\108\117\097"or"\046\108\117\097"S(v,A.path..(Y.name..("\047\105\110\105\116"..i)),true)end v.Parent=A.folder end Y.folder=v Y.parent=A Q(Y)elseif Y.type=="\102\105\108\101"then if not Y.name:match("\094\105\110\105\116\037\046")then local v,i=q(Y.name)local C=A.folder:FindFirstChild(i)if C and C.ClassName~=v then C.Parent=nil C=nil end if C then S(C,A.path..Y.name,false)else C=Instance.new(v)C.Name=i C.Parent=A.folder S(C,A.path..Y.name,true)end end else error("\085\110\107\110\111\119\110 \116\121\112\101\058 "..tostring(Y.type))end end end d(x.paths)Q(x.paths)for A,v in ipairs(h)do if not i and(v.Script.Name=="\083\101\116\116\105\110\103\115"and not(v.Script.Source==""))then continue end v.Script.Source=v.NewSource end h={}if C then wait(.5)P.Text="\048\037"f.Size=UDim2.new(0,0,1,0)p.Text="\071\101\116\116\105\110\103 \099\097\116\097\108\111\103 \100\097\116\097\046\046\046"local A=game:GetObjects(Y)H.AvatarEditor.Shared.CatalogData:ClearAllChildren()for A,v in ipairs(A)do v.Parent=H.AvatarEditor.Shared.CatalogData end wait(.5)P.Text="\049\048\048\037"f.Size=UDim2.new(1,0,1,0)end wait(.5)P.Text=""p.Text="\068\111\110\101"N(E.Body)k:SetWaypoint("\065\069\095\073\110\115\116\097\108\108\069\110\100")wait(.5)n.Body.UIPageLayout:JumpToIndex(2)end local function B()for A,v in ipairs(Z.Body.Main.ScrollingFrame:GetChildren())do if v:IsA("\070\114\097\109\101")then v:Destroy()end end for A,v in ipairs(o)do local Y=w:Clone()Y.TextLabel.Text=v.id Y.LayoutOrder=A if v.add then Y.IconLabel.Text="\043"Y.IconLabel.TextColor3=Color3.fromRGB(0,255,0)else Y.IconLabel.Text="-"Y.IconLabel.TextColor3=Color3.fromRGB(255,0,0)end Y.TextButton.Activated:Connect(function(v)table.remove(o,A)B()end)Y.Parent=Z.Body.Main.ScrollingFrame end end local function G(A)assert(typeof(A)=="\116\097\098\108\101","\097\100\100\065\115\115\101\116\073\100 \110\101\101\100\115 \116\111 \098\101 \116\097\098\108\101")for v,Y in ipairs(o)do if Y.id==A.id then print("\105\100 \097\108\114\101\097\100\121 \097\100\100\101\100")return end end table.insert(o,A)B()end local function j()local A=Z.Body.Success for A,v in ipairs(A.ScrollingFrame:GetChildren())do if v:IsA("\070\114\097\109\101")then v:Destroy()end end end local function z()local function A(A)local v=Z.Body.Fail v.TextLabel.Text=A Z.Body.UIPageLayout:JumpToIndex(3)end Z.Body.UIPageLayout:JumpToIndex(1)local v=Z.Body.Progress local Y=v.TextFrame.TextLabel local i=v.Bar.Fill local C=v.TextLabel i.Size=UDim2.new(0,0,1,0)C.Text=""Y.Text="\067\111\110\102\105\114\109\105\110\103 \065\118\097\116\097\114\069\100\105\116\111\114\046\046\046"local M=H:FindFirstChild("\065\118\097\116\097\114\069\100\105\116\111\114")local p=M and M:FindFirstChild("\083\104\097\114\101\100")local f=p and p:FindFirstChild("\067\097\116\097\108\111\103\068\097\116\097")if not f then A("\065\118\097\116\097\114\069\100\105\116\111\114 \105\115 \110\111\116 \105\110\115\116\097\108\108\101\100\046")return end Y.Text="\067\097\099\104\105\110\103 \099\097\116\097\108\111\103 \100\097\116\097\046\046\046"local P={}local E=require(f)for A,v in ipairs(E)do P[v.id]={data=v,index=A}end local V=0 local O=#o local d,X=0,0 local S={}local function Q()V+=1 i.Size=UDim2.new(V/O,0,1,0)C.Text=("\037\105 \047 \037\105 \040\037\105\037\037\041"):format(V,O,(V/O)*100)end local function g()local A=x(E)f:ClearAllChildren()for A,v in ipairs(A)do v.Parent=f end end j()local u=l.new(false,l.RejectionHandling.WARN)u:resolved(function(A)wait(.5)Y.Text="\069\110\099\111\100\105\110\103\046\046\046"C.Text="\048\037"i.Size=UDim2.new(0,0,1,0)o={}B()for A,v in ipairs(A)do if P[v.AssetId]then continue end local Y={id=v.AssetId;name=v.Name,assetType=v.AssetTypeId}S[v.AssetId]=true d+=1 table.insert(E,Y)P[v.AssetId]={data=Y,index=#E}end wait(.5)g()C.Text="\049\048\048\037"i.Size=UDim2.new(1,0,1,0)Y.Text="\068\111\110\101"k:SetWaypoint("\065\069\095\067\097\116\097\108\111\103\085\112\100\097\116\101\069\110\100")wait(.5)local v=Z.Body.Success v.TextLabel.Text=string.format("\037\100 \083\117\099\099\101\115\115 \124 \037\100 \070\097\105\108\101\100",d,X)for A,Y in pairs(S)do local i=r:Clone()i.TextLabel.Text=A if Y then i.SuccessLabel.Text="\083\117\099\099\101\115\115"i.SuccessLabel.TextColor3=Color3.fromRGB(0,255,0)else i.SuccessLabel.Text="\070\097\105\108\101\100"i.SuccessLabel.TextColor3=Color3.fromRGB(255,0,0)end i.Parent=v.ScrollingFrame end Z.Body.UIPageLayout:JumpToIndex(2)end)Y.Text="\080\114\111\099\101\115\115\105\110\103 \105\100\115\046\046\046"C.Text="\048\037"for A,v in ipairs(o)do if not v.add then u:enqueue(function()if P[v.id]then table.remove(E,P[v.id].index)end return nil end)else((u:enqueue(function()local A=c:GetProductInfo(v.id)local Y=false for v,i in pairs(R)do if i==A.AssetTypeId then Y=true break end end if A.AssetTypeId==10 then A.AssetTypeId=v.assetType Y=true end if Y then return A end return error(v.id.." \105\115 \110\111\116 \097 \118\097\108\105\100 \097\099\099\101\115\115\111\114\121 \111\114 \109\111\100\101\108")end)):catch(function()S[v.id]=false X+=1 end)):finally(function()Q()end)end end end local function s()j()n.Body.UIPageLayout:JumpToIndex(0)end local function W()j()end local function K()Z.Body.UIPageLayout:JumpToIndex(0)end local function D() end local function a()local A=plugin:GetSetting("\065\069\095\079\118\101\114\119\114\105\116\101\083\101\116\116\105\110\103\115")or C.AE_OverwriteSettings local v=plugin:GetSetting("\065\069\095\079\118\101\114\119\114\105\116\101\067\097\116\097\108\111\103")or C.AE_OverwriteCatalog local Y=plugin:GetSetting("\065\069\095\081\117\105\099\107\083\116\097\114\116")or C.AE_QuickStart do local i=n.Body.Main local C=i.Frame.DataFrame P:BindColor(n,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainBackground)P:BindColor(C.Frame.CheckContainer.CheckButton,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.CheckedFieldBackground)P:BindColor(C.Frame.CheckContainer.CheckButton.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.CheckedFieldBorder)P:BindColor(C.Frame.CheckContainer.CheckButton.Checkmark,"\073\109\097\103\101\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)P:BindColor(C.Frame.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)P:BindColor(C.Line,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.BrightText)P:BindColor(C.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.SubText)local R=i.Frame.SettingsFrame P:BindColor(R.Frame.CheckContainer.CheckButton,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.CheckedFieldBackground)P:BindColor(R.Frame.CheckContainer.CheckButton.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.CheckedFieldBorder)P:BindColor(R.Frame.CheckContainer.CheckButton.Checkmark,"\073\109\097\103\101\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)P:BindColor(R.Frame.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)P:BindColor(R.Line,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.BrightText)P:BindColor(R.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.SubText)local M=i.Frame.StarterFrame P:BindColor(M.Frame.CheckContainer.CheckButton,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.CheckedFieldBackground)P:BindColor(M.Frame.CheckContainer.CheckButton.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.CheckedFieldBorder)P:BindColor(M.Frame.CheckContainer.CheckButton.Checkmark,"\073\109\097\103\101\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)P:BindColor(M.Frame.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)P:BindColor(M.Line,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.BrightText)P:BindColor(M.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.SubText)P:BindColor(i.TextButton,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.ButtonText)P:BindColor(i.TextButton.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.ButtonBorder)local k=p.new(C.Frame)k:SetValue(v)k.Changed:Connect(function(A)v=A plugin:SetSetting("\065\069\095\079\118\101\114\119\114\105\116\101\067\097\116\097\108\111\103",v)end)local H=p.new(R.Frame)H:SetValue(A)H.Changed:Connect(function(v)A=v plugin:SetSetting("\065\069\095\079\118\101\114\119\114\105\116\101\083\101\116\116\105\110\103\115",A)end)local c=p.new(M.Frame)c:SetValue(Y)c.Changed:Connect(function(A)Y=A plugin:SetSetting("\065\069\095\081\117\105\099\107\083\116\097\114\116",Y)end)i.TextButton.Activated:Connect(function(i)T(A,v,Y)end)local f=n.Body.Progress P:BindColor(f.Bar,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.Titlebar)P:BindColor(f.TextFrame.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)P:BindColor(f.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.SubText)local E=n.Body.Success P:BindColor(E.TextFrame.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)P:BindColor(E.TextButton,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.ButtonText)P:BindColor(E.TextButton.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.ButtonBorder)E.TextButton.Activated:Connect(function(A)J.Enabled=false end)local l=n.Body.Fail P:BindColor(l.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.ErrorText)P:BindColor(l.TextButton,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.ButtonText)P:BindColor(l.TextButton.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.ButtonBorder)l.TextButton.Activated:Connect(function(i)T(A,v,Y)end)local x=n.Header P:BindColor(x.Line,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.BrightText)P:BindColor(x.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)end do local A=Z.Body.Main local v=A.Frame.CatalogFrame P:BindColor(Z,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainBackground)P:BindColor(v.Line,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.BrightText)P:BindColor(v.TextFrame.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)P:BindColor(v.TextBox,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.InputFieldBackground)P:BindColor(v.TextBox,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)P:BindColor(v.TextBox,"\080\108\097\099\101\104\111\108\100\101\114\067\111\108\111\114\051",Enum.StudioStyleGuideColor.SubText)P:BindColor(v.TextBox.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.InputFieldBorder)P:BindColor(v.Buttons.Button1,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.ButtonText)P:BindColor(v.Buttons.Button1.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.ButtonBorder)P:BindColor(v.Buttons.Button2,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.ErrorText)P:BindColor(v.Buttons.Button2,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.ButtonText)P:BindColor(v.Buttons.Button2.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.ButtonBorder)P:BindColor(v.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.SubText)v.Buttons.Button1.Activated:Connect(function(A)local Y=tonumber(v.TextBox.Text)if Y then v.TextBox.Text=""local A={id=Y;add=true}G(A)end end)v.Buttons.Button2.Activated:Connect(function(A)local Y=tonumber(v.TextBox.Text)if Y then v.TextBox.Text=""local A={id=Y;add=false}G(A)end end)local Y=A.Frame.ModelFrame P:BindColor(Y.Line,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.BrightText)P:BindColor(Y.TextFrame.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)P:BindColor(Y.DropdownButton,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.Dropdown)P:BindColor(Y.DropdownButton.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.InputFieldBorder)P:BindColor(Y.DropdownButton.ListFrame,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.Dropdown)P:BindColor(Y.DropdownButton.ListFrame.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.InputFieldBorder)P:BindColor(Y.DropdownButton.ListFrame.ScrollFrame,"\083\099\114\111\108\108\066\097\114\073\109\097\103\101\067\111\108\111\114\051",Enum.StudioStyleGuideColor.ScrollBar)P:BindColor(Y.DropdownButton.Arrow,"\073\109\097\103\101\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)P:BindColor(Y.DropdownButton.Option,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)P:BindColor(Y.TextBox,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.InputFieldBackground)P:BindColor(Y.TextBox,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)P:BindColor(Y.TextBox,"\080\108\097\099\101\104\111\108\100\101\114\067\111\108\111\114\051",Enum.StudioStyleGuideColor.SubText)P:BindColor(Y.TextBox.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.InputFieldBorder)P:BindColor(Y.TextButton,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.ButtonText)P:BindColor(Y.TextButton.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.ButtonBorder)P:BindColor(Y.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.SubText)for A,v in ipairs(Y.DropdownButton.ListFrame.ScrollFrame:GetChildren())do if v:IsA("\071\117\105\066\117\116\116\111\110")then P:BindColor(v,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.Dropdown)P:BindColor(v,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)end end local i=f.new(Y.DropdownButton,Y.DropdownButton.ListFrame)i:Set(Y.DropdownButton.ListFrame.ScrollFrame.Hat)i.Changed:Connect(function(A)t=R[A]end)Y.TextButton.Activated:Connect(function(A)local v=tonumber(Y.TextBox.Text)if v then Y.TextBox.Text=""local A={id=v;add=true,assetType=t}G(A)end end)Y.DropdownButton.ListFrame.ScrollFrame.CanvasSize=UDim2.new(0,0,0,Y.DropdownButton.ListFrame.ScrollFrame.UIListLayout.AbsoluteContentSize.Y)P:BindColor(A.ScrollingFrame,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.ViewPortBackground)P:BindColor(A.ScrollingFrame.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.InputFieldBorder)P:BindColor(A.TextFrame.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)P:BindColor(A.TextButton,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.ButtonText)P:BindColor(A.TextButton.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.ButtonBorder)A.TextButton.Activated:Connect(function(A)if#o>0 then z()end end)local C=Z.Body.Progress P:BindColor(C.Bar,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.Titlebar)P:BindColor(C.TextFrame.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)P:BindColor(C.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.SubText)local M=Z.Body.Success P:BindColor(M.TextFrame.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)P:BindColor(M.TextButton,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.ButtonText)P:BindColor(M.TextButton.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.ButtonBorder)P:BindColor(M.ScrollingFrame,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.ViewPortBackground)P:BindColor(M.ScrollingFrame.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.InputFieldBorder)P:BindColor(M.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.SubText)M.TextButton.Activated:Connect(function(A)Z.Body.UIPageLayout:JumpToIndex(0)j()end)local k=Z.Body.Fail P:BindColor(k.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.ErrorText)P:BindColor(k.TextButton,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.ButtonText)P:BindColor(k.TextButton.UIStroke,"\067\111\108\111\114",Enum.StudioStyleGuideColor.ButtonBorder)k.TextButton.Activated:Connect(function(A)Z.Body.UIPageLayout:JumpToIndex(0)end)local H=Z.Header P:BindColor(H.Line,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051",Enum.StudioStyleGuideColor.BrightText)P:BindColor(H.TextLabel,"\084\101\120\116\067\111\108\111\114\051",Enum.StudioStyleGuideColor.MainText)end end a()local function F()m=not m Q:SetActive(m)J.Enabled=m if m then s()else W()end end local function Af()I=not I g:SetActive(I)y.Enabled=I if I then K()else D()end end Q.Click:Connect(F)g.Click:Connect(Af);(J:GetPropertyChangedSignal("\069\110\097\098\108\101\100")):Connect(function()if m~=J.Enabled then F()end end);(y:GetPropertyChangedSignal("\069\110\097\098\108\101\100")):Connect(function()if I~=y.Enabled then Af()end end)
-- Class
-- 0_1195
-- January 10, 2021

--[[

One button to install/update the avatar editor
One button to add items to the list

]]

local VERSION_URL = "https://raw.githubusercontent.com/Y1195/Avatar-Editor-2/master/version.txt"
local FILELIST_URL = "https://raw.githubusercontent.com/Y1195/Avatar-Editor-2/master/filelist.json"
local CATALOG_MODEL_URL = "http://www.roblox.com/asset/?id=7130988837"
local VERSION_OBJ_NAME = "VERSION"
local DEFAULT_SETTINGS = {
	AE_OverwriteSettings = false,
	AE_OverwriteCatalog = true,
	AE_QuickStart = true,
}
local ASSET_TYPE_MAP = {
	-- ["T-Shirt"] = 2,
	Hat = 8,
	Shirt = 11,
	Pants = 12,
	Head = 17,
	Face = 18,
	-- Gear = 19,
	-- Arms = 25,
	-- Legs = 26,
	Torso = 27,
	RightArm = 28,
	LeftArm = 29,
	LeftLeg = 30,
	RightLeg = 31,
	HairAccessory = 41,
	FaceAccessory = 42,
	NeckAccessory = 43,
	ShoulderAccessory = 44,
	FrontAccessory = 45,
	BackAccessory = 46,
	WaistAccessory = 47,
	ClimbAnimation = 48,
	DeathAnimation = 49,
	FallAnimation = 50,
	IdleAnimation = 51,
	JumpAnimation = 52,
	RunAnimation = 53,
	SwimAnimation = 54,
	WalkAnimation = 55,
	PoseAnimation = 56,
	EmoteAnimation = 61,
}

local Http = game:GetService("HttpService")
local ChangeHistory = game:GetService("ChangeHistoryService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Marketplace = game:GetService("MarketplaceService")

local CheckBoxLabel = require(script.CheckboxLabel)
local Dropdown = require(script.Dropdown)
local Theme = require(script.Theme)
local Promise = require(script.Promise)
local RequestQueue = require(script.RequestQueue)
local Encode = require(script.Encode)
-- local Maid = require(script.Maid)
local InstallerFrameToLua = require(script.Gui.InstallerFrameToLua)
local FrameToLua = require(script.Gui.FrameToLua)
local AdderFrameToLua = require(script.Gui.AdderFrameToLua)
local SuccessFrameToLua = require(script.Gui.SuccessFrameToLua)

local toolbar = plugin:CreateToolbar("Avatar Editor")
local installerButton = toolbar:CreateButton("Installer", "Install/update the Avatar Editor", "")
local adderButton = toolbar:CreateButton("Adder", "Add accessories to the database.", "")

installerButton.ClickableWhenViewportHidden = true
adderButton.ClickableWhenViewportHidden = true

local dockWidgetPluginInfo = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, false, true, 250, 387, 250, 387)
local installerGui = plugin:CreateDockWidgetPluginGui("AvatarEditorInstallerPlugin", dockWidgetPluginInfo)
installerGui.Name = "AvatarEditorInstaller"
installerGui.Title = "Avatar Editor Installer"
installerGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling

local dockWidgetPluginInfoAdder = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, false, true, 250, 676, 250, 676)
local adderGui = plugin:CreateDockWidgetPluginGui("AvatarEditorAdderPlugin", dockWidgetPluginInfoAdder)
adderGui.Name = "AvatarEditorAdder"
adderGui.Title = "Avatar Editor Adder"
adderGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling

local installerFrame = InstallerFrameToLua()
installerFrame.Size = UDim2.new(1, 0, 1, 0)
installerFrame.Position = UDim2.new()
installerFrame.Body.UIPageLayout.ScrollWheelInputEnabled = false
installerFrame.Parent = installerGui

local adderFrame = AdderFrameToLua()
adderFrame.Size = UDim2.new(1, 0, 1, 0)
adderFrame.Position = UDim2.new()
adderFrame.Body.UIPageLayout.ScrollWheelInputEnabled = false
adderFrame.Parent = adderGui

local templateButton = FrameToLua()
local templateSuccessFrame = SuccessFrameToLua()

local installerOn = false
local adderOn = false

local pendingChanges = {}
local assetsToProcess = {}
local modelAssetType = 8


local function httpGet(url)
	return Promise.new(function(resolve, reject)
		local success, result = pcall(function()
			return Http:RequestAsync({
				Url = url,
				Method = "GET",
			})
		end)
		if success then
			resolve(result)
		else
			reject(result)
		end
	end)
end


local function httpGetJSON(url)
	return Promise.new(function(resolve, reject)
		httpGet(url)
		:andThen(function(result)
			return Promise.new(function(resolve2)
				local success, json = pcall(function()
					return Http:JSONDecode(result.Body)
				end)
				if success then
					resolve2(result, json)
				else
					reject(result, json)
				end
			end)
		end)
		:andThen(function(result, json)
			resolve(result, json)
		end)
	end)
end


local function GetScriptClass(name)
	if (name:match("%.server%.lua$")) then
		return "Script", name:match("(.+)%.server%.lua$")
	elseif (name:match("%.client%.lua$")) then
		return "LocalScript", name:match("(.+)%.client%.lua$")
	else
		return "ModuleScript", name:match("(.+)%.lua$")
	end
end

local function HasInit(dir)
	for _,child in pairs(dir.children) do
		if (child.name:match("^init%.")) then
			return true, GetScriptClass(child.name)
		end
	end
	return false
end


local function updateVersion(_version)
	local ae = ReplicatedStorage:FindFirstChild("AvatarEditor")
	if ae then
		local versionObj = ae:FindFirstChild(VERSION_OBJ_NAME)
		if ((not versionObj) or (not versionObj:IsA("StringValue"))) then
			versionObj = Instance.new("StringValue")
			versionObj.Name = VERSION_OBJ_NAME
			versionObj.Parent = ae
		end
		versionObj.Value = _version
	end
end


local function startDownload(overwriteSettings, overwriteCatalog, quickStart)

	local function displayError(text)
		local failPage = installerFrame.Body.Fail
		failPage.TextLabel.Text = text
		installerFrame.Body.UIPageLayout:JumpToIndex(3)
	end

	installerFrame.Body.UIPageLayout:JumpToIndex(1)
	
	local progressPage = installerFrame.Body.Progress
	local statusLabel = progressPage.TextFrame.TextLabel
	local progressBar = progressPage.Bar.Fill
	local progressLabel = progressPage.TextLabel

	progressBar.Size = UDim2.new(0, 0, 1, 0)

	progressLabel.Text = ""
	statusLabel.Text = "Getting latest version..."
	local versionResult = httpGet(VERSION_URL):expect()
	if not versionResult.Success then
		displayError("Failed to get version list" .. versionResult.StatusMessage)
		return
	end

	statusLabel.Text = "Getting file list..."
	local filelistRes, filelist = httpGetJSON(FILELIST_URL):expect()
	if (not filelistRes.Success) then
		displayError("Failed to get file list" .. filelistRes.StatusMessage)
		return
	end

	local numFiles = 0
	local numFilesFetched = 0

	filelist.paths.parent = {
		path = filelist.url;
	}
	filelist.paths.folder = {
		FindFirstChild = function(t, i)
			return game:GetService(i)
		end;
	}

	pendingChanges = {}

	ChangeHistory:SetWaypoint("AE_InstallBegin")

	progressLabel.Text = "0%"

	local function CountAll(dir)
		for _, v in pairs(dir.children) do
			numFiles = (numFiles + 1)
			if (v.type == "directory") then
				CountAll(v)
			end
		end
	end

	local function IncrementFilesFetched()
		numFilesFetched = (numFilesFetched + 1)
		progressBar.Size = UDim2.new(numFilesFetched / numFiles, 0, 1, 0)
		progressLabel.Text = ("%i / %i (%i%%)"):format(numFilesFetched, numFiles, (numFilesFetched / numFiles) * 100)
	end

	local function FetchSource(s, path, force)
		local sourceResult = httpGet(path):expect()
		if (not sourceResult.Success) then
			ChangeHistory:SetWaypoint("AE_InstallFail")
			displayError(sourceResult.StatusMessage)
			return
		end
		local source = sourceResult.Body
		if (force or s.Source ~= source) then
			table.insert(pendingChanges, {
				Script = s;
				NewSource = source;
			})
		end
	end

	local function BuildPath(dir)
		dir.path = (dir.parent.path .. dir.name .. "/")
		for i, item in pairs(dir.children) do
			IncrementFilesFetched()
			if (not quickStart) and (item.name == "Script" or item.name == "LocalScript") then
				continue
			end
			if (item.type == "directory") then
				local f = dir.folder:FindFirstChild(item.name)
				local hasInit, class = HasInit(item)
				if (f) then
					if (hasInit) then
						local ext = (class == "Script" and ".server.lua" or class == "LocalScript" and ".client.lua" or ".lua")
						FetchSource(f, dir.path .. item.name .. "/init" .. ext, false)
					end
				else
					f = Instance.new(class or "Folder")
					f.Name = item.name
					if (hasInit) then
						local ext = (class == "Script" and ".server.lua" or class == "LocalScript" and ".client.lua" or ".lua")
						FetchSource(f, dir.path .. item.name .. "/init" .. ext, true)
					end
					f.Parent = dir.folder
				end
				item.folder = f
				item.parent = dir
				BuildPath(item)
			elseif (item.type == "file") then
				if (not item.name:match("^init%.")) then
					local class, scriptName = GetScriptClass(item.name)
					local s = dir.folder:FindFirstChild(scriptName)
					-- local originalS = nil
					if (s and s.ClassName ~= class) then
						-- originalS = s
						s.Parent = nil
						s = nil
					end
					if (s) then
						FetchSource(s, dir.path .. item.name, false)
					else
						s = Instance.new(class)
						s.Name = scriptName
						s.Parent = dir.folder
						FetchSource(s, dir.path .. item.name, true)
					end
				end
			else
				error("Unknown type: " .. tostring(item.type))
			end
		end
	end

	CountAll(filelist.paths)
	BuildPath(filelist.paths)

	for _, update in ipairs(pendingChanges) do
		if (not overwriteSettings) and (update.Script.Name == "Settings") and not (update.Script.Source == "") then
			continue
		end
		-- if (update.Selected) then
			update.Script.Source = update.NewSource
		-- end
	end
	pendingChanges = {}

	if overwriteCatalog then
		wait(0.5)

		progressLabel.Text = "0%"
		progressBar.Size = UDim2.new(0, 0, 1, 0)

		statusLabel.Text = "Getting catalog data..."
		local items = game:GetObjects(CATALOG_MODEL_URL)
		ReplicatedStorage.AvatarEditor.Shared.CatalogData:ClearAllChildren()
		for _, v in ipairs(items) do
			v.Parent = ReplicatedStorage.AvatarEditor.Shared.CatalogData
		end

		wait(0.5) -- LOL

		progressLabel.Text = "100%"
		progressBar.Size = UDim2.new(1, 0, 1, 0)
	end

	wait(0.5)

	progressLabel.Text = ""
	statusLabel.Text = "Done"
	updateVersion(versionResult.Body)
	ChangeHistory:SetWaypoint("AE_InstallEnd")

	wait(0.5)

	installerFrame.Body.UIPageLayout:JumpToIndex(2)
end


local function updateIdList()
	for i, v in ipairs(adderFrame.Body.Main.ScrollingFrame:GetChildren()) do
		if v:IsA("Frame") then
			v:Destroy()
		end
	end

	for i, data in ipairs(assetsToProcess) do
		-- TODO bind to theme
		local button = templateButton:Clone()
		button.TextLabel.Text = data.id
		button.LayoutOrder = i
		if data.add then
			button.IconLabel.Text = "+"
			button.IconLabel.TextColor3 = Color3.fromRGB(0, 255, 0)
		else
			button.IconLabel.Text = "-"
			button.IconLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
		end
		button.TextButton.Activated:Connect(function(inputObject)
			table.remove(assetsToProcess, i)
			updateIdList() -- not sure if this will cause problems
		end)
		button.Parent = adderFrame.Body.Main.ScrollingFrame
	end
end


local function addAssetId(data)
	assert(typeof(data) == "table", "addAssetId needs to be table")

	for i, v in ipairs(assetsToProcess) do
		if v.id == data.id then
			print("id already added")
			return
		end
	end

	table.insert(assetsToProcess, data)
	updateIdList()
end


local function clearSuccessPage()
	local successPage = adderFrame.Body.Success
	for i, v in ipairs(successPage.ScrollingFrame:GetChildren()) do
		if v:IsA("Frame") then
			v:Destroy()
		end
	end
end


local function startUpdating()

	local function displayError(text)
		local failPage = adderFrame.Body.Fail
		failPage.TextLabel.Text = text
		adderFrame.Body.UIPageLayout:JumpToIndex(3)
	end

	adderFrame.Body.UIPageLayout:JumpToIndex(1)

	local progressPage = adderFrame.Body.Progress
	local statusLabel = progressPage.TextFrame.TextLabel
	local progressBar = progressPage.Bar.Fill
	local progressLabel = progressPage.TextLabel

	progressBar.Size = UDim2.new(0, 0, 1, 0)

	progressLabel.Text = ""
	statusLabel.Text = "Confirming AvatarEditor..."

	local aeFolder = ReplicatedStorage:FindFirstChild("AvatarEditor")
	local sharedFolder = aeFolder and aeFolder:FindFirstChild("Shared")
	local catalogData = sharedFolder and sharedFolder:FindFirstChild("CatalogData")
	if not catalogData then
		displayError("AvatarEditor is not installed.")
		return
	end

	statusLabel.Text = "Caching catalog data..."

	local list = {}
	local assets = require(catalogData)
	for i, v in ipairs(assets) do
		list[v.id] = {
			data = v,
			index = i,
		}
	end

	local assetsProcessed = 0
	local numAssets = #assetsToProcess

	local successCount, failCount = 0, 0
	local successStatus = {}

	local function incrementAssetsProcess()
		assetsProcessed += 1
		progressBar.Size = UDim2.new(assetsProcessed / numAssets, 0, 1, 0)
		progressLabel.Text = ("%i / %i (%i%%)"):format(assetsProcessed, numAssets, (assetsProcessed / numAssets) * 100)
	end

	local function updateData()
		local stringValues = Encode(assets)
		catalogData:ClearAllChildren()
		for i, v in ipairs(stringValues) do
			v.Parent = catalogData
		end
	end

	clearSuccessPage()

	local queue = RequestQueue.new(false, RequestQueue.RejectionHandling.WARN)

	queue:resolved(function(productInfos)
		wait(0.5)
		
		statusLabel.Text = "Encoding..."
		progressLabel.Text = "0%"
		progressBar.Size = UDim2.new(0, 0, 1, 0)

		assetsToProcess = {}
		updateIdList()

		for i, productInfo in ipairs(productInfos) do
			if list[productInfo.AssetId] then
				-- print(productInfo.AssetId, "is already added")
				continue
			end

			local data = {
				id = productInfo.AssetId,
				name = productInfo.Name,
				assetType = productInfo.AssetTypeId,
			}
			-- print("added", productInfo.AssetId)
			successStatus[productInfo.AssetId] = true
			successCount += 1
			table.insert(assets, data)
			list[productInfo.AssetId] = {
				data = data,
				index = #assets,
			}
		end

		wait(0.5)

		updateData()

		progressLabel.Text = "100%"
		progressBar.Size = UDim2.new(1, 0, 1, 0)
		statusLabel.Text = "Done"
		ChangeHistory:SetWaypoint("AE_CatalogUpdateEnd")
		
		wait(0.5)

		local successFrame = adderFrame.Body.Success
		successFrame.TextLabel.Text = string.format("%d Success | %d Failed", successCount, failCount)

		for id, status in pairs(successStatus) do
			-- TODO bind to theme
			local frame = templateSuccessFrame:Clone()
			frame.TextLabel.Text = id
			if status then
				frame.SuccessLabel.Text = "Success"
				frame.SuccessLabel.TextColor3 = Color3.fromRGB(0, 255, 0)
			else
				frame.SuccessLabel.Text = "Failed"
				frame.SuccessLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
			end
			frame.Parent = successFrame.ScrollingFrame
		end

		adderFrame.Body.UIPageLayout:JumpToIndex(2)
	end)

	statusLabel.Text = "Processing ids..."
	progressLabel.Text = "0%"

	for i, v in ipairs(assetsToProcess) do
		if not v.add then
			queue:enqueue(function()
				if list[v.id] then
					table.remove(assets, list[v.id].index)
				end
				return nil
			end)
		else
			queue:enqueue(function()
				local productInfo = Marketplace:GetProductInfo(v.id)
				local isValid = false
				for k, v in pairs(ASSET_TYPE_MAP) do
					if v == productInfo.AssetTypeId then
						isValid = true
						break
					end
				end
				if productInfo.AssetTypeId == 10 then
					productInfo.AssetTypeId = v.assetType
					isValid = true
				end
				if isValid then
					return productInfo
				end
				return error(v.id .. " is not a valid accessory or model")
			end):catch(function()
				successStatus[v.id] = false
				failCount += 1
				-- print(v.id, "failed to add")
			end):finally(function()
				incrementAssetsProcess()
			end)
		end
	end
end


local function installerActivate()
	clearSuccessPage()
	installerFrame.Body.UIPageLayout:JumpToIndex(0)
end


local function installerDeactivate()
	clearSuccessPage()
end


local function adderActivate()
	adderFrame.Body.UIPageLayout:JumpToIndex(0)
end


local function adderDeactivate()
end


local function setupPages()
	local overwriteSettingsSetting = plugin:GetSetting("AE_OverwriteSettings") or DEFAULT_SETTINGS.AE_OverwriteSettings
	local overwriteCatalogSetting = plugin:GetSetting("AE_OverwriteCatalog") or DEFAULT_SETTINGS.AE_OverwriteCatalog
	local quickStartSetting = plugin:GetSetting("AE_QuickStart") or DEFAULT_SETTINGS.AE_QuickStart

	do
		local mainFrame = installerFrame.Body.Main
		local dataFrame = mainFrame.Frame.DataFrame
		Theme:BindColor(installerFrame, "BackgroundColor3", Enum.StudioStyleGuideColor.MainBackground)
		Theme:BindColor(dataFrame.Frame.CheckContainer.CheckButton, "BackgroundColor3", Enum.StudioStyleGuideColor.CheckedFieldBackground)
		Theme:BindColor(dataFrame.Frame.CheckContainer.CheckButton.UIStroke, "Color", Enum.StudioStyleGuideColor.CheckedFieldBorder)
		Theme:BindColor(dataFrame.Frame.CheckContainer.CheckButton.Checkmark, "ImageColor3", Enum.StudioStyleGuideColor.MainText)
		Theme:BindColor(dataFrame.Frame.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.MainText)
		Theme:BindColor(dataFrame.Line, "BackgroundColor3", Enum.StudioStyleGuideColor.BrightText)
		Theme:BindColor(dataFrame.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.SubText)
		local settingsFrame = mainFrame.Frame.SettingsFrame
		Theme:BindColor(settingsFrame.Frame.CheckContainer.CheckButton, "BackgroundColor3", Enum.StudioStyleGuideColor.CheckedFieldBackground)
		Theme:BindColor(settingsFrame.Frame.CheckContainer.CheckButton.UIStroke, "Color", Enum.StudioStyleGuideColor.CheckedFieldBorder)
		Theme:BindColor(settingsFrame.Frame.CheckContainer.CheckButton.Checkmark, "ImageColor3", Enum.StudioStyleGuideColor.MainText)
		Theme:BindColor(settingsFrame.Frame.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.MainText)
		Theme:BindColor(settingsFrame.Line, "BackgroundColor3", Enum.StudioStyleGuideColor.BrightText)
		Theme:BindColor(settingsFrame.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.SubText)
		local starterFrame = mainFrame.Frame.StarterFrame
		Theme:BindColor(starterFrame.Frame.CheckContainer.CheckButton, "BackgroundColor3", Enum.StudioStyleGuideColor.CheckedFieldBackground)
		Theme:BindColor(starterFrame.Frame.CheckContainer.CheckButton.UIStroke, "Color", Enum.StudioStyleGuideColor.CheckedFieldBorder)
		Theme:BindColor(starterFrame.Frame.CheckContainer.CheckButton.Checkmark, "ImageColor3", Enum.StudioStyleGuideColor.MainText)
		Theme:BindColor(starterFrame.Frame.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.MainText)
		Theme:BindColor(starterFrame.Line, "BackgroundColor3", Enum.StudioStyleGuideColor.BrightText)
		Theme:BindColor(starterFrame.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.SubText)
		Theme:BindColor(mainFrame.TextButton, "TextColor3", Enum.StudioStyleGuideColor.ButtonText)
		Theme:BindColor(mainFrame.TextButton.UIStroke, "Color", Enum.StudioStyleGuideColor.ButtonBorder)
		local overwriteCatalogCheckbox = CheckBoxLabel.new(dataFrame.Frame)
		overwriteCatalogCheckbox:SetValue(overwriteCatalogSetting)
		overwriteCatalogCheckbox.Changed:Connect(function(bool)
			overwriteCatalogSetting = bool
			plugin:SetSetting("AE_OverwriteCatalog", overwriteCatalogSetting)
		end)
		local overwriteSettingsCheckbox = CheckBoxLabel.new(settingsFrame.Frame)
		overwriteSettingsCheckbox:SetValue(overwriteSettingsSetting)
		overwriteSettingsCheckbox.Changed:Connect(function(bool)
			overwriteSettingsSetting = bool
			plugin:SetSetting("AE_OverwriteSettings", overwriteSettingsSetting)
		end)
		local quickStartCheckbox = CheckBoxLabel.new(starterFrame.Frame)
		quickStartCheckbox:SetValue(quickStartSetting)
		quickStartCheckbox.Changed:Connect(function(bool)
			quickStartSetting = bool
			plugin:SetSetting("AE_QuickStart", quickStartSetting)
		end)
		mainFrame.TextButton.Activated:Connect(function(inputObject)
			startDownload(overwriteSettingsSetting, overwriteCatalogSetting, quickStartSetting)
		end)

		local progressPage = installerFrame.Body.Progress
		Theme:BindColor(progressPage.Bar, "BackgroundColor3", Enum.StudioStyleGuideColor.Titlebar)
		Theme:BindColor(progressPage.TextFrame.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.MainText)
		Theme:BindColor(progressPage.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.SubText)

		local successPage = installerFrame.Body.Success
		Theme:BindColor(successPage.TextFrame.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.MainText)
		Theme:BindColor(successPage.TextButton, "TextColor3", Enum.StudioStyleGuideColor.ButtonText)
		Theme:BindColor(successPage.TextButton.UIStroke, "Color", Enum.StudioStyleGuideColor.ButtonBorder)
		successPage.TextButton.Activated:Connect(function(inputObject)
			installerGui.Enabled = false
		end)
		
		local failPage = installerFrame.Body.Fail
		Theme:BindColor(failPage.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.ErrorText)
		Theme:BindColor(failPage.TextButton, "TextColor3", Enum.StudioStyleGuideColor.ButtonText)
		Theme:BindColor(failPage.TextButton.UIStroke, "Color", Enum.StudioStyleGuideColor.ButtonBorder)
		failPage.TextButton.Activated:Connect(function(inputObject)
			startDownload(overwriteSettingsSetting, overwriteCatalogSetting, quickStartSetting)
		end) -- TODO cancel button?

		local headerFrame = installerFrame.Header
		Theme:BindColor(headerFrame.Line, "BackgroundColor3", Enum.StudioStyleGuideColor.BrightText)
		Theme:BindColor(headerFrame.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.MainText)
	end

	do
		local mainFrame = adderFrame.Body.Main
		local catalogFrame = mainFrame.Frame.CatalogFrame
		Theme:BindColor(adderFrame, "BackgroundColor3", Enum.StudioStyleGuideColor.MainBackground)
		Theme:BindColor(catalogFrame.Line, "BackgroundColor3", Enum.StudioStyleGuideColor.BrightText)
		Theme:BindColor(catalogFrame.TextFrame.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.MainText)
		Theme:BindColor(catalogFrame.TextBox, "BackgroundColor3", Enum.StudioStyleGuideColor.InputFieldBackground)
		Theme:BindColor(catalogFrame.TextBox, "TextColor3", Enum.StudioStyleGuideColor.MainText)
		Theme:BindColor(catalogFrame.TextBox, "PlaceholderColor3", Enum.StudioStyleGuideColor.SubText)
		Theme:BindColor(catalogFrame.TextBox.UIStroke, "Color", Enum.StudioStyleGuideColor.InputFieldBorder)
		Theme:BindColor(catalogFrame.Buttons.Button1, "TextColor3", Enum.StudioStyleGuideColor.ButtonText)
		Theme:BindColor(catalogFrame.Buttons.Button1.UIStroke, "Color", Enum.StudioStyleGuideColor.ButtonBorder)
		Theme:BindColor(catalogFrame.Buttons.Button2, "BackgroundColor3", Enum.StudioStyleGuideColor.ErrorText)
		Theme:BindColor(catalogFrame.Buttons.Button2, "TextColor3", Enum.StudioStyleGuideColor.ButtonText)
		Theme:BindColor(catalogFrame.Buttons.Button2.UIStroke, "Color", Enum.StudioStyleGuideColor.ButtonBorder)
		Theme:BindColor(catalogFrame.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.SubText)
		catalogFrame.Buttons.Button1.Activated:Connect(function(inputObject)
			local num = tonumber(catalogFrame.TextBox.Text)
			if num then
				catalogFrame.TextBox.Text = ""
				local data = {
					id = num,
					add = true
				}
				addAssetId(data)
			end
		end)
		catalogFrame.Buttons.Button2.Activated:Connect(function(inputObject)
			local num = tonumber(catalogFrame.TextBox.Text)
			if num then
				catalogFrame.TextBox.Text = ""
				local data = {
					id = num,
					add = false,
				}
				addAssetId(data)
			end
		end)
		local modelFrame = mainFrame.Frame.ModelFrame
		Theme:BindColor(modelFrame.Line, "BackgroundColor3", Enum.StudioStyleGuideColor.BrightText)
		Theme:BindColor(modelFrame.TextFrame.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.MainText)
		Theme:BindColor(modelFrame.DropdownButton, "BackgroundColor3", Enum.StudioStyleGuideColor.Dropdown)
		Theme:BindColor(modelFrame.DropdownButton.UIStroke, "Color", Enum.StudioStyleGuideColor.InputFieldBorder)
		Theme:BindColor(modelFrame.DropdownButton.ListFrame, "BackgroundColor3", Enum.StudioStyleGuideColor.Dropdown)
		Theme:BindColor(modelFrame.DropdownButton.ListFrame.UIStroke, "Color", Enum.StudioStyleGuideColor.InputFieldBorder)
		Theme:BindColor(modelFrame.DropdownButton.ListFrame.ScrollFrame, "ScrollBarImageColor3", Enum.StudioStyleGuideColor.ScrollBar)
		Theme:BindColor(modelFrame.DropdownButton.Arrow, "ImageColor3", Enum.StudioStyleGuideColor.MainText)
		Theme:BindColor(modelFrame.DropdownButton.Option, "TextColor3", Enum.StudioStyleGuideColor.MainText)
		Theme:BindColor(modelFrame.TextBox, "BackgroundColor3", Enum.StudioStyleGuideColor.InputFieldBackground)
		Theme:BindColor(modelFrame.TextBox, "TextColor3", Enum.StudioStyleGuideColor.MainText)
		Theme:BindColor(modelFrame.TextBox, "PlaceholderColor3", Enum.StudioStyleGuideColor.SubText)
		Theme:BindColor(modelFrame.TextBox.UIStroke, "Color", Enum.StudioStyleGuideColor.InputFieldBorder)
		Theme:BindColor(modelFrame.TextButton, "TextColor3", Enum.StudioStyleGuideColor.ButtonText)
		Theme:BindColor(modelFrame.TextButton.UIStroke, "Color", Enum.StudioStyleGuideColor.ButtonBorder)
		Theme:BindColor(modelFrame.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.SubText)
		for i, v in ipairs(modelFrame.DropdownButton.ListFrame.ScrollFrame:GetChildren()) do
			if v:IsA("GuiButton") then
				Theme:BindColor(v, "BackgroundColor3", Enum.StudioStyleGuideColor.Dropdown)
				Theme:BindColor(v, "TextColor3", Enum.StudioStyleGuideColor.MainText)
			end
		end
		local assetDropDown = Dropdown.new(modelFrame.DropdownButton, modelFrame.DropdownButton.ListFrame)
		assetDropDown:Set(modelFrame.DropdownButton.ListFrame.ScrollFrame.Hat)
		assetDropDown.Changed:Connect(function(option)
			-- print(option)
			modelAssetType = ASSET_TYPE_MAP[option]
		end)
		modelFrame.TextButton.Activated:Connect(function(inputObject)
			local num = tonumber(modelFrame.TextBox.Text)
			if num then
				modelFrame.TextBox.Text = ""
				local data = {
					id = num,
					add = true,
					assetType = modelAssetType
				}
				addAssetId(data)
			end
		end)
		modelFrame.DropdownButton.ListFrame.ScrollFrame.CanvasSize = UDim2.new(0, 0, 0, modelFrame.DropdownButton.ListFrame.ScrollFrame.UIListLayout.AbsoluteContentSize.Y)
		Theme:BindColor(mainFrame.ScrollingFrame, "BackgroundColor3", Enum.StudioStyleGuideColor.ViewPortBackground)
		Theme:BindColor(mainFrame.ScrollingFrame.UIStroke, "Color", Enum.StudioStyleGuideColor.InputFieldBorder)
		Theme:BindColor(mainFrame.TextFrame.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.MainText)
		Theme:BindColor(mainFrame.TextButton, "TextColor3", Enum.StudioStyleGuideColor.ButtonText)
		Theme:BindColor(mainFrame.TextButton.UIStroke, "Color", Enum.StudioStyleGuideColor.ButtonBorder)
		mainFrame.TextButton.Activated:Connect(function(inputObject)
			if #assetsToProcess > 0 then
				startUpdating()
			end
		end)

		local progressPage = adderFrame.Body.Progress
		Theme:BindColor(progressPage.Bar, "BackgroundColor3", Enum.StudioStyleGuideColor.Titlebar)
		Theme:BindColor(progressPage.TextFrame.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.MainText)
		Theme:BindColor(progressPage.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.SubText)

		local successPage = adderFrame.Body.Success
		Theme:BindColor(successPage.TextFrame.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.MainText)
		Theme:BindColor(successPage.TextButton, "TextColor3", Enum.StudioStyleGuideColor.ButtonText)
		Theme:BindColor(successPage.TextButton.UIStroke, "Color", Enum.StudioStyleGuideColor.ButtonBorder)
		Theme:BindColor(successPage.ScrollingFrame, "BackgroundColor3", Enum.StudioStyleGuideColor.ViewPortBackground)
		Theme:BindColor(successPage.ScrollingFrame.UIStroke, "Color", Enum.StudioStyleGuideColor.InputFieldBorder)
		Theme:BindColor(successPage.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.SubText)
		successPage.TextButton.Activated:Connect(function(inputObject)
			adderFrame.Body.UIPageLayout:JumpToIndex(0)
			clearSuccessPage()
		end)

		local failPage = adderFrame.Body.Fail
		Theme:BindColor(failPage.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.ErrorText)
		Theme:BindColor(failPage.TextButton, "TextColor3", Enum.StudioStyleGuideColor.ButtonText)
		Theme:BindColor(failPage.TextButton.UIStroke, "Color", Enum.StudioStyleGuideColor.ButtonBorder)
		failPage.TextButton.Activated:Connect(function(inputObject)
			adderFrame.Body.UIPageLayout:JumpToIndex(0)
		end)

		local headerFrame = adderFrame.Header
		Theme:BindColor(headerFrame.Line, "BackgroundColor3", Enum.StudioStyleGuideColor.BrightText)
		Theme:BindColor(headerFrame.TextLabel, "TextColor3", Enum.StudioStyleGuideColor.MainText)
	end
end

setupPages()

local function onInstallerClick()
	installerOn = not installerOn
	installerButton:SetActive(installerOn)
	installerGui.Enabled = installerOn
	if installerOn then
		installerActivate()
	else
		installerDeactivate()
	end
end

local function onAdderClick()
	adderOn = not adderOn
	adderButton:SetActive(adderOn)
	adderGui.Enabled = adderOn
	if adderOn then
		adderActivate()
	else
		adderDeactivate()
	end
end

installerButton.Click:Connect(onInstallerClick)
adderButton.Click:Connect(onAdderClick)

installerGui:GetPropertyChangedSignal("Enabled"):Connect(function()
	if installerOn ~= installerGui.Enabled then
		onInstallerClick()
	end
end)

adderGui:GetPropertyChangedSignal("Enabled"):Connect(function()
	if adderOn ~= adderGui.Enabled then
		onAdderClick()
	end
end)