'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var env_env = require('../env/env.js');
var launchGame_helper = require('./helper.js');
require('@babel/runtime/helpers/defineProperty');
require('../game/game.js');
require('../constant/gid.js');
require('../loader/little-loader.js');
require('../msdk/msdk.js');
require('@babel/runtime/helpers/typeof');
require('../url/url.js');

/**
 * 拉起 GP
 * @param {object} params 拉起参数
 * @param {string} params.roomId 房间 Id
 * @param {string} params.roomPwd 房间 Pwd
 * @param {string} params.source 来源
 * @param {string} [params.wxJSLink] wx js link
 * @param {object} [params.env] 环境对象
 * @param {object} [params.useGPHelperSchemePrefix] 是否使用特殊 scheme
 * @param {object} [params.justLaunchGame] 是否仅拉起 app，不进入房间
 * @returns Promise<boolean | number>
 *
 * @example
 * ```ts
 * launchGPGameRoom({
 *   roomId: '12',
 *   roomPwd: '123'
 * })
 * ```
 */
function launchGPGameRoom(_ref) {
  var _ref$roomId = _ref.roomId,
    roomId = _ref$roomId === void 0 ? '' : _ref$roomId,
    _ref$roomPwd = _ref.roomPwd,
    roomPwd = _ref$roomPwd === void 0 ? '' : _ref$roomPwd,
    _ref$source = _ref.source,
    source = _ref$source === void 0 ? launchGame_helper.LAUNCH_GP_SOURCE_MAP.NORMAL : _ref$source,
    _ref$wxJSLink = _ref.wxJSLink,
    wxJSLink = _ref$wxJSLink === void 0 ? launchGame_helper.DEFAULT_WX_JS_SDK : _ref$wxJSLink,
    _ref$env = _ref.env,
    env = _ref$env === void 0 ? env_env.initEnv() : _ref$env,
    _ref$useGPHelperSchem = _ref.useGPHelperSchemePrefix,
    useGPHelperSchemePrefix = _ref$useGPHelperSchem === void 0 ? false : _ref$useGPHelperSchem,
    _ref$useTrialSchemePr = _ref.useTrialSchemePrefix,
    useTrialSchemePrefix = _ref$useTrialSchemePr === void 0 ? false : _ref$useTrialSchemePr,
    _ref$justLaunchGame = _ref.justLaunchGame,
    justLaunchGame = _ref$justLaunchGame === void 0 ? false : _ref$justLaunchGame;
  var schemeParam = launchGame_helper.getGPSchemeParam(roomId, roomPwd, {
    source: source
  });
  var getScheme = function getScheme() {
    if (useTrialSchemePrefix) {
      return launchGame_helper.GAME_SCHEME_PREFIX_MAP.GP_TRIAL;
    }
    if (useGPHelperSchemePrefix) {
      return launchGame_helper.GAME_SCHEME_PREFIX_MAP.GP_IN_HELPER;
    }
    return launchGame_helper.GAME_SCHEME_PREFIX_MAP.GP;
  };
  return launchGame_helper.launchCore({
    launchParams: {
      roomId: roomId,
      roomPwd: roomPwd
    },
    schemeParam: justLaunchGame ? '' : schemeParam,
    schemePrefix: getScheme(),
    wxJSLink: wxJSLink,
    env: env
  });
}

exports.launchGPGameRoom = launchGPGameRoom;
