/**
 * @Author: Caow
 * @Date: 2019-12-27 14:29:05
 */

const install = function(BC) {
  if (!BC) {
    throw new Error('Missing Base SDK')
  }

  BC.init(() => {
    require('./Loader.Base')
  })

  /**
   * start
   */
  BC.ready = callback => {
    try {
      if (!BC.Initialized) {
        BC.init(() => {
          require('../thirdpart')
          require('./Loader')
          BC.Initialized = true
          callback && callback()
        })
      } else {
        callback && callback()
      }
    } catch (e) {
      // eslint-disable-next-line no-console
      console.error(e)
    }
  }
}
/* istanbul ignore if */
if (typeof window !== 'undefined' && window.BC) {
  install(window.BC)
}

export default {
  install
}
