'use strict'
!(function(require, directRequire) {
  const a = require('./0634ee2ebd3e560d9d4804ecc960160f.js'),
    b = require('./15ba1827c7f6564a45df6bd44da3a977.js'),
    c = require('./3bfffbe88b3d923921f851c0697974fe.js'),
    d = require('./f171257bbcaef547a3cf27266ccb0db2.js'),
    e = require('./df6d0ff021a69fb541c733de4dbba0fe.js'),
    f = require('./d3976cc01aeebc5b09e11c4135b6bd8d.js')
  module.exports = {
    addCard: async function(e, g) {
      let h = g.args,
        j = h.cardList || [],
        k = {},
        l = []
      for (let a, b = 0, c = j.length; b < c; b++)
        (a = j[b]),
          (a.card_id = a.cardId),
          (a.card_ext = a.cardExt),
          delete a.cardId,
          delete a.cardExt,
          k[a.card_id] ? k[a.card_id]++ : (l.push(a), (k[a.card_id] = 1))
      let i = { appid: c.getProjectAppID(), getitem_list: l },
        { body: m } = await b({
          url: `${d.batchGetCardInfoURL}?isapp=1`,
          method: 'post',
          body: JSON.stringify(i),
          needToken: 1,
          needAppID: 1,
          needCheckErrCode: -1
        }),
        n = m.baseresponse,
        o = n.errcode
      if (0 === o) {
        let b = m.json_ret_list.map(a => {
          return (a = JSON.parse(a)), (a.amount = k[a.card_tp_id]), a
        })
        return void e({
          type: a.SIMULATOR_SET_CARD_VIEW,
          data: {
            show: 'addcard',
            api: g.api,
            args: g.args,
            callbackID: g.callbackID,
            cardInfo: b
          }
        })
      }
      let p = f.parseCgiErrorCode(o, n.errmsg)
      return { errMsg: `${g.api}:fail ${p}` }
    },
    openCard: async function(e, g) {
      let h = g.args.cardList || [],
        i = h.map(a => {
          return { card_tp_id: a.cardId, code: a.code }
        }),
        j = { appid: c.getProjectAppID(), items: i },
        k = {
          url: `${d.batchViewCardURL}?isapp=1`,
          body: JSON.stringify(j),
          method: 'post',
          needToken: 1,
          needAppID: 1
        },
        { body: l } = await b(k),
        m = l,
        n = m.baseresponse,
        o = n.errcode
      if (0 === o) {
        let b = m.json_ret ? JSON.parse(m.json_ret) : { card_array: [] },
          c = m.error_json_ret_list.map(a => {
            return JSON.parse(a)
          })
        return (
          e({
            type: a.SIMULATOR_SET_CARD_VIEW,
            data: {
              show: 'viewcard',
              errData: c,
              cardInfo: b.card_array,
              args: {},
              callbackID: null
            }
          }),
          { errMsg: `${g.api}:ok` }
        )
      }
      let p = f.parseCgiErrorCode(o, n.errmsg)
      return { errMsg: `${g.api}:fail ${p}` }
    }
  }
})(require('lazyload'), require)
