local h=script.Parent.Parent local z=require(h.Constants)local r=require(h.Vendor.Roact)local k=require(h.Vendor.StudioComponents)local P=k.ScrollFrame local x=require(script.Item)local function w(h)local k={}for P,w in pairs(h.Layers)do table.insert(k,r.createElement(x,{Layer=w,SelectedLayer=w.Id==h.SelectedLayerId,NumLayers=#h.Layers,Opacity=w.Properties.Transparency,LayoutOrder=z.MaxLayers-w.Id,OnActivated=function()if not h.Disabled then h.SetSelectedLayerId(w.Id)end end;OnVisibilityToggled=function()if not h.Disabled then h.ToggleVisibility(w.Id)end end;OnLockToggled=function()if not h.Disabled then h.ToggleLock(w.Id)end end,MoveLayerUp=function()if not h.Disabled then h.MoveLayerUp(w.Id)end end,MoveLayerDown=function()if not h.Disabled then h.MoveLayerDown(w.Id)end end,Disabled=h.Disabled}))end return r.createFragment({Frame=r.createElement(P,{Size=h.Size or UDim2.new(1,0,1,0),Disabled=h.Disabled},k)})end return w
local Plugin = script.Parent.Parent
local Constants = require(Plugin.Constants)

local Roact = require(Plugin.Vendor.Roact)
local StudioComponents = require(Plugin.Vendor.StudioComponents)

local ScrollFrame = StudioComponents.ScrollFrame
local Item = require(script.Item)

local function List(props)
	local children = {}

	for _, layer in pairs(props.Layers) do
		table.insert(
			children,
			Roact.createElement(Item, {
				Layer = layer,
				SelectedLayer = (layer.Id == props.SelectedLayerId),
				NumLayers = #props.Layers,
				Opacity = layer.Properties.Transparency,
				LayoutOrder = (Constants.MaxLayers - layer.Id),
				OnActivated = function()
					if not props.Disabled then
						props.SetSelectedLayerId(layer.Id)
					end
				end,
				OnVisibilityToggled = function()
					if not props.Disabled then
						props.ToggleVisibility(layer.Id)
					end
				end,
				OnLockToggled = function()
					if not props.Disabled then
						props.ToggleLock(layer.Id)
					end
				end,
				MoveLayerUp = function()
					if not props.Disabled then
						props.MoveLayerUp(layer.Id)
					end
				end,
				MoveLayerDown = function()
					if not props.Disabled then
						props.MoveLayerDown(layer.Id)
					end
				end,
				Disabled = props.Disabled
			})
		)
	end

	return Roact.createFragment({
		Frame = Roact.createElement(ScrollFrame, {
			Size = props.Size or UDim2.new(1, 0, 1, 0),
			Disabled = props.Disabled
		}, children)
	})
end

return List