local this = {}

function this.createPage(name, path)
  return L_UI:createPage(name, path)
end

function this.createModule(name, path)
  return L_UI:createModule(name, path)
end

function this.sendMsg(eveId, pageName)
  L_UI:sendEvent(eveId, pageName)
end

function this.setSceneVisible(isActive)
  if not G_Launcher.gameplayRequired then
    return
  end
  if AzurWorld.visbleMgr then
    L_SceneManager:setSceneActive(isActive)
  end
  if AzurWorld.HomeMgr then
    L_HomeManager:setHomeRootActive(isActive)
  end
end

function this.createPreviewNpc(uid, go)
  local entity = require(L_EcsConst.aliveType.previewNpc).new(L_EcsConst.aliveType.previewNpc)
  entity:initPreview(uid, go)
  return entity
end

local m_result = true
local _setResult = function(result)
  m_result = result
end

function this.checkUIOpen(path, options)
  local lua = require(path)
  m_result = true
  if lua.check then
    lua.check(lua, options, _setResult)
  end
  return m_result
end

CS.Azur.Gameplay.UI.UIManager.luaMiddleware:InitLuaAdapter(this)
