function Blend.mount(M,n)assert(typeof(M)=="\073\110\115\116\097\110\099\101","\066\097\100 \105\110\115\116\097\110\099\101")local e=Maid.new()local a=nil local F={}for n,Y in pairs(n)do if type(n)=="\115\116\114\105\110\103"then if n=="\080\097\114\101\110\116"then a=Y else local a=Blend.toPropertyObservable(Y)if a then e:GiveTask(a:Subscribe(function(e)task.spawn(function()M[n]=e end)end))else task.spawn(function()M[n]=Y end)end end elseif type(n)=="\102\117\110\099\116\105\111\110"then local e=Blend.toEventObservable(n(M,Y))if Observable.isObservable(e)then table.insert(F,{e,Y})else warn(("\085\110\097\098\108\101 \116\111 \097\112\112\108\121 \101\118\101\110\116 \108\105\115\116\101\110\101\114 \037\113"):format(tostring(n)))end elseif type(n)=="\110\117\109\098\101\114"then table.insert(F,{Blend.Children(M,Y),Y})else warn(("\085\110\097\098\108\101 \116\111 \097\112\112\108\121 \112\114\111\112\101\114\116\121 \037\113"):format(tostring(n)))end end for M,n in pairs(F)do e:GiveTask(n[1]:Subscribe(Blend.toEventHandler(n[2])))end if a then local n=Blend.toPropertyObservable(a)if n then e:GiveTask(n:Subscribe(function(n)M.Parent=n end))else M.Parent=a end end return e end return Blend
--[=[
	Mounts the instance to the props. This handles mounting children, and events.

	The contract is that the props table is turned into observables. Note the following.

	* Keys of strings are turned into properties
		* If this can be turned into an observable, it will be used to subscribe to this event
		* Otherwise, we assign directly
	* Keys of functions are invoked on the instance in question
		* `(instance, value) -> Observable
		* If this returns an observable (or can be turned into one), we subscribe the event immediately
	* Keys of numbers (array components) are treated as implicit children
	* If the key is [Blend.Children] then we invoke mountChildren on it.

	```lua
	maid:GiveTask(Blend.mount(frame, {
		BackgroundTransparency = 1;

		-- All items named InventoryItem
		Blend.Find "InventoryItem" {

			-- Apply the following properties
			Blend.New "UIScale" {
				Scale = 0.5;
			};
		};
	}))
	```

	@param instance Instance
	@param props table
	@return Maid
]=]
function Blend.mount(instance, props)
	assert(typeof(instance) == "Instance", "Bad instance")

	local maid = Maid.new()

	local parent = nil
	local dependentObservables = {}

	for key, value in pairs(props) do
		if type(key) == "string" then
			if key == "Parent" then
				parent = value
			else
				local observable = Blend.toPropertyObservable(value)
				if observable then
					maid:GiveTask(observable:Subscribe(function(result)
						task.spawn(function()
							instance[key] = result
						end)
					end))
				else
					task.spawn(function()
						instance[key] = value
					end)
				end
			end
		elseif type(key) == "function" then
			local observable = Blend.toEventObservable(key(instance, value))

			if Observable.isObservable(observable) then
				table.insert(dependentObservables, { observable, value })
			else
				warn(("Unable to apply event listener %q"):format(tostring(key)))
			end
		elseif type(key) == "number" then
			-- Treat this as an implicit children contract
			-- Thus, we don't need an explicit [Blend.Children] call.
			table.insert(dependentObservables, { Blend.Children(instance, value), value })
		else
			warn(("Unable to apply property %q"):format(tostring(key)))
		end
	end

	-- Subscribe dependentObservables (which includes adding children)
	for _, event in pairs(dependentObservables) do
		maid:GiveTask(event[1]:Subscribe(Blend.toEventHandler(event[2])))
	end

	if parent then
		local observable = Blend.toPropertyObservable(parent)
		if observable then
			maid:GiveTask(observable:Subscribe(function(result)
				instance.Parent = result
			end))
		else
			instance.Parent = parent
		end
	end

	return maid
end

return Blend
