function RxInstanceUtils.observeFirstAncestorBrio(N,p)assert(typeof(N)=="\073\110\115\116\097\110\099\101","\066\097\100 \105\110\115\116\097\110\099\101")assert(type(p)=="\115\116\114\105\110\103","\066\097\100 \099\108\097\115\115\078\097\109\101")return Observable.new(function(f)local z=Maid.new()local D=nil local function y()local y=N:FindFirstAncestorWhichIsA(p)if y then if y~=D then D=y local N=Brio.new(y)z._current=N f:Fire(N)end elseif D then z._current=nil D=nil end end z:GiveTask(N.AncestryChanged:Connect(y))y()return z end)end
--[=[
	Observes an instance's ancestry

	@param instance Instance
	@param className string
	@return Observable<Instance>
]=]
function RxInstanceUtils.observeFirstAncestorBrio(instance, className)
	assert(typeof(instance) == "Instance", "Bad instance")
	assert(type(className) == "string", "Bad className")

	return Observable.new(function(sub)
		local maid = Maid.new()

		local lastFound = nil
		local function handleAncestryChanged()
			local found = instance:FindFirstAncestorWhichIsA(className)

			if found then
				if found ~= lastFound then
					lastFound = found
					local brio = Brio.new(found)
					maid._current = brio
					sub:Fire(brio)
				end
			elseif lastFound then
				maid._current = nil
				lastFound = nil
			end
		end

		maid:GiveTask(instance.AncestryChanged:Connect(handleAncestryChanged))
		handleAncestryChanged()

		return maid
	end)
end
