local n=require(script.Parent.Parent.t)local Z=require(script.Parent.DevSettings)local w=require(script.Parent.strict)local i=n.string local X=n.interface({Type=n.string;Value=n.optional(n.any)})local G=n.interface({ignoreUnknownInstances=n.optional(n.boolean)})local K=n.interface({Id=i,Parent=n.optional(i);Name=n.string,ClassName=n.string;Properties=n.map(n.string,X);Metadata=n.optional(G),Children=n.array(i)})local V=n.interface({id=i,changedName=n.optional(n.string);changedClassName=n.optional(n.string);changedProperties=n.map(n.string,X);changedMetadata=n.optional(G)})local F=n.interface({removed=n.array(i),added=n.map(i,K),updated=n.array(V)})local y=n.interface({sessionId=n.string,serverVersion=n.string,protocolVersion=n.number;expectedPlaceIds=n.optional(n.array(n.number)),rootInstanceId=i})local J=n.interface({sessionId=n.string;messageCursor=n.number,instances=n.map(i,K)})local v=n.interface({sessionId=n.string;messageCursor=n.number,messages=n.array(F)})local m=n.interface({kind=n.union(n.literal("\078\111\116\070\111\117\110\100"),n.literal("\066\097\100\082\101\113\117\101\115\116"),n.literal("\073\110\116\101\114\110\097\108\069\114\114\111\114")),details=n.string})local function s(n)return function(...)if Z:shouldTypecheck()then return n(...)else return true end end end return w("\084\121\112\101\115",{ifEnabled=s,ApiInfoResponse=y,ApiReadResponse=J,ApiSubscribeResponse=v;ApiError=m;ApiInstance=K;ApiInstanceUpdate=V,ApiInstanceMetadata=G,ApiSubscribeMessage=F;ApiValue=X;RbxId=i;VirtualInstance=K;VirtualMetadata=G;VirtualValue=X})
local t = require(script.Parent.Parent.t)

local DevSettings = require(script.Parent.DevSettings)
local strict = require(script.Parent.strict)

local RbxId = t.string

local ApiValue = t.interface({
	Type = t.string,
	Value = t.optional(t.any),
})

local ApiInstanceMetadata = t.interface({
	ignoreUnknownInstances = t.optional(t.boolean),
})

local ApiInstance = t.interface({
	Id = RbxId,
	Parent = t.optional(RbxId),
	Name = t.string,
	ClassName = t.string,
	Properties = t.map(t.string, ApiValue),
	Metadata = t.optional(ApiInstanceMetadata),
	Children = t.array(RbxId),
})

local ApiInstanceUpdate = t.interface({
	id = RbxId,
	changedName = t.optional(t.string),
	changedClassName = t.optional(t.string),
	changedProperties = t.map(t.string, ApiValue),
	changedMetadata = t.optional(ApiInstanceMetadata),
})

local ApiSubscribeMessage = t.interface({
	removed = t.array(RbxId),
	added = t.map(RbxId, ApiInstance),
	updated = t.array(ApiInstanceUpdate),
})

local ApiInfoResponse = t.interface({
	sessionId = t.string,
	serverVersion = t.string,
	protocolVersion = t.number,
	expectedPlaceIds = t.optional(t.array(t.number)),
	rootInstanceId = RbxId,
})

local ApiReadResponse = t.interface({
	sessionId = t.string,
	messageCursor = t.number,
	instances = t.map(RbxId, ApiInstance),
})

local ApiSubscribeResponse = t.interface({
	sessionId = t.string,
	messageCursor = t.number,
	messages = t.array(ApiSubscribeMessage),
})

local ApiError = t.interface({
	kind = t.union(
		t.literal("NotFound"),
		t.literal("BadRequest"),
		t.literal("InternalError")
	),
	details = t.string,
})

local function ifEnabled(innerCheck)
	return function(...)
		if DevSettings:shouldTypecheck() then
			return innerCheck(...)
		else
			return true
		end
	end
end

return strict("Types", {
	ifEnabled = ifEnabled,

	ApiInfoResponse = ApiInfoResponse,
	ApiReadResponse = ApiReadResponse,
	ApiSubscribeResponse = ApiSubscribeResponse,
	ApiError = ApiError,

	ApiInstance = ApiInstance,
	ApiInstanceUpdate = ApiInstanceUpdate,
	ApiInstanceMetadata = ApiInstanceMetadata,
	ApiSubscribeMessage = ApiSubscribeMessage,
	ApiValue = ApiValue,
	RbxId = RbxId,

	-- Deprecated aliases during transition
	VirtualInstance = ApiInstance,
	VirtualMetadata = ApiInstanceMetadata,
	VirtualValue = ApiValue,
})