local p=require(script.Parent.Parent.Configuration)local m=p.Roact local O=p.RoactAnimate local j="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\051\049\056\048\055\052\057\050\049"local q=TweenInfo.new(.2,Enum.EasingStyle.Linear,Enum.EasingDirection.In)local f=UDim2.fromScale(2,2)local Y=m.PureComponent:extend("\077\097\116\101\114\105\097\108\073\110\107")Y.defaultProps={Size=UDim2.fromScale(1,1);AnchorPoint=Vector2.new(.5,.5);Position=UDim2.fromScale(.5,.5),ZIndex=1,InkColor3=Color3.new(.4,.4,.4),Origin=UDim2.fromScale(.5,.5);InkTransparency=.5}function Y.init(p)p:setState({_transparency=O.Value.new(1),_size=O.Value.new(UDim2.new())})end function Y.render(p)return m.createElement("\070\114\097\109\101",{BackgroundTransparency=1,ClipsDescendants=true;Size=p.props.Size;AnchorPoint=p.props.AnchorPoint,Position=p.props.Position;ZIndex=p.props.ZIndex;[m.Ref]=function(m)p._container=m end},{Rippler=m.createElement(O.ImageLabel,{BackgroundTransparency=1;Image=j,ImageColor3=p.props.InkColor3,ImageTransparency=p.state._transparency,Size=p.state._size,Position=p.props.Origin,AnchorPoint=Vector2.new(.5,.5),[m.Ref]=function(m)p._rbx=m end})})end function Y.willUpdate(m,p)local j=f local Y=m.props.InkTransparency local S=m._container.AbsoluteSize if S.X>S.Y then m._rbx.SizeConstraint=Enum.SizeConstraint.RelativeXX else m._rbx.SizeConstraint=Enum.SizeConstraint.RelativeYY end if p.Rippling then m._rbx.Size=UDim2.new()m._rbx.Position=p.Origin or UDim2.fromScale(.5,.5)m._rbx.ImageTransparency=m.props.InkTransparency else Y=1 end local X=table.create(2)X[1]=O(m.state._transparency,q,Y)X[2]=O(m.state._size,q,j);(O.Parallel(X)):Start()end return Y
local Configuration = require(script.Parent.Parent.Configuration)
local Roact = Configuration.Roact
local RoactAnimate = Configuration.RoactAnimate

local RIPPLE_IMAGE = "rbxassetid://1318074921"
local RIPPLE_TWEEN_INFO = TweenInfo.new(
	0.2,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.In
)

local RIPPLE_MAX_SIZE = UDim2.fromScale(2, 2)

local Ink = Roact.PureComponent:extend("MaterialInk")
Ink.defaultProps = {
	Size = UDim2.fromScale(1, 1),
	AnchorPoint = Vector2.new(0.5, 0.5),
	Position = UDim2.fromScale(0.5, 0.5),
	ZIndex = 1,
	InkColor3 = Color3.new(0.4, 0.4, 0.4),
	Origin = UDim2.fromScale(0.5, 0.5),
	InkTransparency = 0.5,
}

function Ink:init()
	self:setState({
		_transparency = RoactAnimate.Value.new(1),
		_size = RoactAnimate.Value.new(UDim2.new()),
	})
end

function Ink:render()
	return Roact.createElement("Frame", {
		BackgroundTransparency = 1,
		ClipsDescendants = true,
		Size = self.props.Size,
		AnchorPoint = self.props.AnchorPoint,
		Position = self.props.Position,
		ZIndex = self.props.ZIndex,

		[Roact.Ref] = function(rbx)
			self._container = rbx
		end,
	}, {
		Rippler = Roact.createElement(RoactAnimate.ImageLabel, {
			BackgroundTransparency = 1,
			Image = RIPPLE_IMAGE,
			ImageColor3 = self.props.InkColor3,
			ImageTransparency = self.state._transparency,
			Size = self.state._size,
			Position = self.props.Origin,
			AnchorPoint = Vector2.new(0.5, 0.5),

			[Roact.Ref] = function(rbx)
				self._rbx = rbx
			end,
		}),
	})
end

function Ink:willUpdate(nextProps)
	local goalSize = RIPPLE_MAX_SIZE
	local goalTransparency = self.props.InkTransparency

	local containerSize = self._container.AbsoluteSize
	if containerSize.X > containerSize.Y then
		self._rbx.SizeConstraint = Enum.SizeConstraint.RelativeXX
	else
		self._rbx.SizeConstraint = Enum.SizeConstraint.RelativeYY
	end

	if nextProps.Rippling then
		self._rbx.Size = UDim2.new()
		self._rbx.Position = nextProps.Origin or UDim2.fromScale(0.5, 0.5)
		self._rbx.ImageTransparency = self.props.InkTransparency
	else
		goalTransparency = 1
	end

	local animation = table.create(2)
	animation[1] = RoactAnimate(self.state._transparency, RIPPLE_TWEEN_INFO, goalTransparency)
	animation[2] = RoactAnimate(self.state._size, RIPPLE_TWEEN_INFO, goalSize)

	RoactAnimate.Parallel(animation):Start()
end

return Ink
