/**
 * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
 * 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
 */

import { queryParse } from "../util";
var _queryParse = queryParse(),
  _light_sandbox = _queryParse._light_sandbox,
  groupId = _queryParse.groupId,
  host = _queryParse.requestHost;
export var requestHost = {
  local: 'http://imgs-63.sggz00b.dev.alipay.net/mgw.htm',
  dev: host || 'http://imgs-63.sggz00b.dev.alipay.net/mgw.htm',
  sit: host || 'http://imgs-9.sggz00a.test.alipay.net/mgw.htm',
  pre: 'https://imgs-sea-pre.alipay.com/mgw.htm',
  prod: 'https://imgs-sea-global.alipay.com/mgw.htm',
  sandbox: 'https://imgs-sea-global.alipay.com/mgw.htm'
};
export var clientId = '5J5Y8X4E2Y25GR00690';
export var tntInstId = 'ALIPW3SG';
export var appId = 'ANTOM_PAYMENT_WEB';
export var sofaId = groupId || 'GROUP_20240627151021';
export var hostSignMap = function hostSignMap(hostSign, env) {
  var map = {
    SG: 'https://imgs-sea-global.alipay.com/mgw.htm',
    US: 'https://imgs-na-global.alipay.com/mgw.htm',
    DE: 'https://imgs-de-global.alipay.com/mgw.htm',
    // QK 和 ID 机房未经过验证
    QK: 'https://imgs-qk.alipay.com/mgw.htm',
    // https://imgs-qk.alipay.com/mgw.htm
    ID: 'https://imgs-id.alipay.com/mgw.htm',
    // https://imgs-id.alipay.com/mgw.htm
    SA: 'https://imgs-sa.alipay.com/mgw.htm' // https://imgs-sa.alipay.com/mgw.htm
  };
  var preMap = {
    SG: 'https://imgs-sea-pre.alipay.com/mgw.htm',
    US: 'https://imgs-pre.alipay.com/mgw.htm',
    DE: 'https://imgs-de-pre.alipay.com/mgw.htm',
    // QK 和 ID 机房未经过验证
    QK: 'https://iopengw-qkgz99p.alipay.com/mgw.htm',
    // https://iopengw-qkgz99p.alipay.com/mgw.htm
    ID: 'https://imgs-id-pre.alipay.com/mgw.htm',
    // https://imgs-id-pre.alipay.com/mgw.htm
    SA: 'https://imgs-sa-pre.alipay.com/mgw.htm' // https://imgs-sa-pre.alipay.com/mgw.htm
  };
  if (env === 'prod' || env === 'sandbox' || env === 'light_sandbox') {
    return map[hostSign || 'SG'];
  } else if (env === 'pre') {
    return preMap[hostSign || 'SG'];
  } else return '';
};
export var lightSandboxMap = function lightSandboxMap() {
  var operationType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  var env = arguments.length > 1 ? arguments[1] : undefined;
  var map = {
    pre: 'https://imgs-sea-pre.alipay.com/mgw.htm',
    sit: host || 'http://imgs-9.sggz00a.test.alipay.net/mgw.htm',
    dev: host || 'http://imgs-13.sggz00b.stable.alipay.net/mgw.htm'
  };
  var typeMap = {
    'com.ipay.iexpcashier.sdkAction.query': 'com.ipay.iopensandbox.sdk.paymentSession.query'
  };
  var appId = 'SDK_MOCK_SANDBOX';
  var sofaId = groupId || 'GROUP_20230315210531';
  if (typeMap[operationType] && env === 'light_sandbox' || _light_sandbox === 'true') return {
    appId: appId,
    sofaId: sofaId,
    baseURL: map[env],
    'Operation-Type': typeMap[operationType]
  };else return {
    appId: '',
    sofaId: '',
    baseURL: '',
    'Operation-Type': ''
  };
};