'use strict'
var _extends =
  Object.assign ||
  function(a) {
    for (var b, c = 1; c < arguments.length; c++)
      for (var d in ((b = arguments[c]), b))
        Object.prototype.hasOwnProperty.call(b, d) && (a[d] = b[d])
    return a
  }
!(function(require, directRequire) {
  const a = require('./15ba1827c7f6564a45df6bd44da3a977.js'),
    b = require('./0b01a3ff1572567a994a0ceae64dfef3.js'),
    c = require('./822bc5aa1823c9aa222d9ffad72e7f17.js')
  module.exports = {
    batchAddCard: async function(d, e) {
      let { api: f, args: g, callbackID: h, runtimeID: i } = e,
        j = g.card_list || [],
        k = g.appId,
        l = {},
        m = []
      for (let a, b = 0, c = j.length; b < c; b++)
        (a = j[b]),
          l[a.card_id] ? l[a.card_id]++ : (m.push(a), (l[a.card_id] = 1))
      let n = {
          url: b.batchGetCardInfoURL,
          body: JSON.stringify({ appid: k, getitem_list: m }),
          method: 'post',
          needToken: 1
        },
        { body: o } = await a(n),
        p = o.json_ret_list.map(a => {
          return (a = JSON.parse(a)), (a.amount = l[a.card_tp_id]), a
        })
      d({
        type: c.WEBDEBUGGER_SET_CARD_VIEW,
        data: {
          show: 'addcard',
          appid: k,
          api: f,
          args: _extends({}, g, { cardList: j }),
          callbackID: h,
          runtimeID: i,
          cardInfo: p
        }
      })
    },
    chooseCard: async function(d, e) {
      let { api: f, args: g, callbackID: h, runtimeID: i } = e,
        j = g.appId,
        k = {
          appid: j,
          shop_id: g.location_id || 0,
          sign_type: g.sign_type,
          card_sign: g.card_sign,
          time_stamp: g.time_stamp,
          nonce_str: g.nonce_str,
          card_tp_id: g.card_id,
          card_type: g.card_type
        },
        l = {
          url: b.chooseCardURL,
          body: JSON.stringify(k),
          method: 'post',
          needToken: 1
        },
        { body: m } = await a(l),
        n = JSON.parse(m.json_ret)
      d({
        type: c.WEBDEBUGGER_SET_CARD_VIEW,
        data: {
          show: 'choosecard',
          cardInfo: n.available_cards || [],
          errData: [],
          api: f,
          args: g,
          callbackID: h,
          runtimeID: i
        }
      })
    },
    batchViewCard: async function(d, e) {
      let { api: f, args: g, callbackID: h, runtimeID: i } = e,
        j = g.appId
      g.card_list = g.card_list || []
      let k = g.card_list.map(a => {
          return { card_tp_id: a.card_id, code: a.code }
        }),
        l = {
          url: b.batchViewCardURL,
          body: JSON.stringify({ appid: j, items: k }),
          method: 'post',
          needToken: 1
        },
        { body: m } = await a(l),
        n = m,
        o = n.json_ret ? JSON.parse(n.json_ret) : { card_array: [] },
        p = n.error_json_ret_list.map(a => {
          return JSON.parse(a)
        })
      return (
        d({
          type: c.WEBDEBUGGER_SET_CARD_VIEW,
          data: {
            show: 'viewcard',
            cardInfo: o.card_array,
            errData: p || [],
            args: {},
            callbackID: null
          }
        }),
        { errMsg: `${f}:ok` }
      )
    }
  }
})(require('lazyload'), require)
