function ProfileService.GetProfileStore(D,h)local M local U=nil if type(D)=="\115\116\114\105\110\103"then M=D elseif type(D)=="\116\097\098\108\101"then M=D.Name U=D.Scope else error("\091\080\114\111\102\105\108\101\083\101\114\118\105\099\101\093\058 \073\110\118\097\108\105\100 \111\114 \109\105\115\115\105\110\103 \112\114\111\102\105\108\101\095\115\116\111\114\101\095\105\110\100\101\120")end if M==nil or type(M)~="\115\116\114\105\110\103"then error("\091\080\114\111\102\105\108\101\083\101\114\118\105\099\101\093\058 \077\105\115\115\105\110\103 \111\114 \105\110\118\097\108\105\100 \"\078\097\109\101\" \112\097\114\097\109\101\116\101\114")elseif string.len(M)==0 then error("\091\080\114\111\102\105\108\101\083\101\114\118\105\099\101\093\058 \080\114\111\102\105\108\101\083\116\111\114\101 \110\097\109\101 \099\097\110\110\111\116 \098\101 \097\110 \101\109\112\116\121 \115\116\114\105\110\103")end if U~=nil and(type(U)~="\115\116\114\105\110\103"or string.len(U)==0)then error("\091\080\114\111\102\105\108\101\083\101\114\118\105\099\101\093\058 \073\110\118\097\108\105\100 \"\083\099\111\112\101\" \112\097\114\097\109\101\116\101\114")end if type(h)~="\116\097\098\108\101"then error("\091\080\114\111\102\105\108\101\083\101\114\118\105\099\101\093\058 \073\110\118\097\108\105\100 \112\114\111\102\105\108\101\095\116\101\109\112\108\097\116\101")end local u u={Mock={LoadProfileAsync=function(D,h,M)return u:LoadProfileAsync(h,M,UseMockTag)end,GlobalUpdateProfileAsync=function(D,h,M)return u:GlobalUpdateProfileAsync(h,M,UseMockTag)end,ViewProfileAsync=function(D,h,M)return u:ViewProfileAsync(h,M,UseMockTag)end;FindProfileVersionAsync=function(D,h,M,U,R)return u:FindProfileVersionAsync(h,M,U,R,UseMockTag)end;WipeProfileAsync=function(D,h)return u:WipeProfileAsync(h,UseMockTag)end},_profile_store_name=M,_profile_store_scope=U,_profile_store_lookup=M..("\000"..(U or""));_profile_template=h,_global_data_store=nil,_loaded_profiles={};_profile_load_jobs={},_mock_loaded_profiles={},_mock_profile_load_jobs={};_is_pending=false}setmetatable(u,ProfileStore)local R=Instance.new("\068\097\116\097\083\116\111\114\101\079\112\116\105\111\110\115")R:SetExperimentalFeatures({v2=true})if IsLiveCheckActive==true then u._is_pending=true task.spawn(function()WaitForLiveAccessCheck()if UseMockDataStore==false then u._global_data_store=DataStoreService:GetDataStore(M,U,R)end u._is_pending=false end)else if UseMockDataStore==false then u._global_data_store=DataStoreService:GetDataStore(M,U,R)end end return u end function ProfileService.IsLive()WaitForLiveAccessCheck()return UseMockDataStore==false end


function ProfileService.GetProfileStore(profile_store_index, profile_template) --> [ProfileStore]

	local profile_store_name
	local profile_store_scope = nil

	-- Parsing profile_store_index:
	if type(profile_store_index) == "string" then
		-- profile_store_index as string:
		profile_store_name = profile_store_index
	elseif type(profile_store_index) == "table" then
		-- profile_store_index as table:
		profile_store_name = profile_store_index.Name
		profile_store_scope = profile_store_index.Scope
	else
		error("[ProfileService]: Invalid or missing profile_store_index")
	end

	-- Type checking:
	if profile_store_name == nil or type(profile_store_name) ~= "string" then
		error("[ProfileService]: Missing or invalid \"Name\" parameter")
	elseif string.len(profile_store_name) == 0 then
		error("[ProfileService]: ProfileStore name cannot be an empty string")
	end

	if profile_store_scope ~= nil and (type(profile_store_scope) ~= "string" or string.len(profile_store_scope) == 0) then
		error("[ProfileService]: Invalid \"Scope\" parameter")
	end

	if type(profile_template) ~= "table" then
		error("[ProfileService]: Invalid profile_template")
	end

	local profile_store
	profile_store = {
		Mock = {
			LoadProfileAsync = function(_, profile_key, not_released_handler)
				return profile_store:LoadProfileAsync(profile_key, not_released_handler, UseMockTag)
			end,
			GlobalUpdateProfileAsync = function(_, profile_key, update_handler)
				return profile_store:GlobalUpdateProfileAsync(profile_key, update_handler, UseMockTag)
			end,
			ViewProfileAsync = function(_, profile_key, version)
				return profile_store:ViewProfileAsync(profile_key, version, UseMockTag)
			end,
			FindProfileVersionAsync = function(_, profile_key, sort_direction, min_date, max_date)
				return profile_store:FindProfileVersionAsync(profile_key, sort_direction, min_date, max_date, UseMockTag)
			end,
			WipeProfileAsync = function(_, profile_key)
				return profile_store:WipeProfileAsync(profile_key, UseMockTag)
			end
		},

		_profile_store_name = profile_store_name,
		_profile_store_scope = profile_store_scope,
		_profile_store_lookup = profile_store_name .. "\0" .. (profile_store_scope or ""),

		_profile_template = profile_template,
		_global_data_store = nil,
		_loaded_profiles = {},
		_profile_load_jobs = {},
		_mock_loaded_profiles = {},
		_mock_profile_load_jobs = {},
		_is_pending = false,
	}
	setmetatable(profile_store, ProfileStore)

	local options = Instance.new("DataStoreOptions")
	options:SetExperimentalFeatures({v2 = true})

	if IsLiveCheckActive == true then
		profile_store._is_pending = true
		task.spawn(function()
			WaitForLiveAccessCheck()
			if UseMockDataStore == false then
				profile_store._global_data_store = DataStoreService:GetDataStore(profile_store_name, profile_store_scope, options)
			end
			profile_store._is_pending = false
		end)
	else
		if UseMockDataStore == false then
			profile_store._global_data_store = DataStoreService:GetDataStore(profile_store_name, profile_store_scope, options)
		end
	end

	return profile_store
end

function ProfileService.IsLive() --> [bool] -- (CAN YIELD!!!)

	WaitForLiveAccessCheck()

	return UseMockDataStore == false

end
