local M=game:GetService("\080\108\097\121\101\114\115")local O=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local y=game:GetService("\072\116\116\112\083\101\114\118\105\099\101")local K=O.AvatarEditor local e=require(K.Shared.Util.Promise)local d=require(K.Shared.Colors)local P=M.LocalPlayer local h=nil local o=nil local i=nil local v={"\066\097\099\107\065\099\099\101\115\115\111\114\121";"\070\097\099\101\065\099\099\101\115\115\111\114\121";"\070\114\111\110\116\065\099\099\101\115\115\111\114\121";"\072\097\105\114\065\099\099\101\115\115\111\114\121";"\072\097\116\065\099\099\101\115\115\111\114\121";"\078\101\099\107\065\099\099\101\115\115\111\114\121";"\083\104\111\117\108\100\101\114\115\065\099\099\101\115\115\111\114\121","\087\097\105\115\116\065\099\099\101\115\115\111\114\121","\070\097\099\101";"\072\101\097\100";"\076\101\102\116\065\114\109","\076\101\102\116\076\101\103";"\082\105\103\104\116\065\114\109";"\082\105\103\104\116\076\101\103";"\084\111\114\115\111";"\067\108\105\109\098\065\110\105\109\097\116\105\111\110","\070\097\108\108\065\110\105\109\097\116\105\111\110";"\073\100\108\101\065\110\105\109\097\116\105\111\110";"\074\117\109\112\065\110\105\109\097\116\105\111\110";"\082\117\110\065\110\105\109\097\116\105\111\110";"\083\119\105\109\065\110\105\109\097\116\105\111\110","\087\097\108\107\065\110\105\109\097\116\105\111\110";"\080\097\110\116\115";"\083\104\105\114\116"}local C={"\066\111\100\121\084\121\112\101\083\099\097\108\101";"\072\101\097\100\083\099\097\108\101","\072\101\105\103\104\116\083\099\097\108\101","\080\114\111\112\111\114\116\105\111\110\083\099\097\108\101","\087\105\100\116\104\083\099\097\108\101"}local L={}L.UID=y:GenerateGUID(false)local function X()local M=P.Character local O=M and M:FindFirstChildWhichIsA("\072\117\109\097\110\111\105\100")if O then return O end end local function A()return(((e.new(function(M,O)local y=X()if not y then return e.reject("\110\111 \104\117\109\097\110\111\105\100")end local K=y:GetAppliedDescription()if K then M(K)else O("\100\101\115\099\114\105\112\116\105\111\110 \110\111\116 \102\111\117\110\100")end end)):andThen(function(M)h={}for O,y in ipairs(v)do local K=string.split(M[y],"\044")for M,O in ipairs(K)do if O==""or O=="\048"then continue end h[tonumber(O)]=true end end i={}for O,y in ipairs(C)do i[y]=M[y]end o=M.HeadColor end)):catch(warn)):finally(function()if h==nil then h={}end end)end function L.Get(M)if h==nil then(A()):await()end return h end function L.GetTone(M)if o==nil then(A()):await()end return o end function L.GetScale(M)if i==nil then(A()):await()end return i end function L.Update(M)(A()):await()M.UID=y:GenerateGUID(false)end return L
--[[



]]

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Http = game:GetService("HttpService")

local AvatarEditor = ReplicatedStorage.AvatarEditor
local Promise = require(AvatarEditor.Shared.Util.Promise)
local Colors = require(AvatarEditor.Shared.Colors)

local player = Players.LocalPlayer

local ids = nil
local skintone = nil
local scales = nil

local idProperties = {
	"BackAccessory",
	"FaceAccessory",
	"FrontAccessory",
	"HairAccessory",
	"HatAccessory",
	"NeckAccessory",
	"ShouldersAccessory",
	"WaistAccessory",
	"Face",
	"Head",
	"LeftArm",
	"LeftLeg",
	"RightArm",
	"RightLeg",
	"Torso",
	"ClimbAnimation",
	"FallAnimation",
	"IdleAnimation",
	"JumpAnimation",
	"RunAnimation",
	"SwimAnimation",
	"WalkAnimation",
	"Pants",
	"Shirt",
}

local scaleProperties = {
	"BodyTypeScale",
	--"DepthScale",
	"HeadScale",
	"HeightScale",
	"ProportionScale",
	"WidthScale",
}

local module = {}
module.UID = Http:GenerateGUID(false)

local function getHumanoid()
	local character = player.Character
	local humanoid = character and character:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		return humanoid
	end
end

local function getHumanoidDescription()
	return Promise.new(function(resolve, reject)
		local humanoid = getHumanoid()
		if not humanoid then
			return Promise.reject("no humanoid")
		end

		local description = humanoid:GetAppliedDescription()
		if description then
			resolve(description)
		else
			reject("description not found")
		end
	end)
		:andThen(function(description)
			ids = {}
			for i, v in ipairs(idProperties) do
				local values = string.split(description[v], ",")
				for j, k in ipairs(values) do
					if k == "" or k == "0" then
						continue
					end
					ids[tonumber(k)] = true
				end
			end
			scales = {}
			for i, v in ipairs(scaleProperties) do
				scales[v] = description[v]
			end
			skintone = description.HeadColor
		end)
		:catch(warn)
		:finally(function()
			if ids == nil then
				ids = {}
			end
		end)
end

function module:Get()
	if ids == nil then
		getHumanoidDescription():await()
	end
	return ids
end

function module:GetTone()
	if skintone == nil then
		getHumanoidDescription():await()
	end
	return skintone
end

function module:GetScale()
	if scales == nil then
		getHumanoidDescription():await()
	end
	return scales
end

function module:Update()
	getHumanoidDescription():await()
	self.UID = Http:GenerateGUID(false)
end

return module
