'use strict'
!(function(require, directRequire) {
  const a = require('./0634ee2ebd3e560d9d4804ecc960160f.js'),
    b = require('./bc78839ccca8df9e5ceeb7fae11b7be2.js'),
    c = require('./a15851ca252a104aad8b3fd3fc114574.js'),
    d = /^#[0-9A-Fa-f]{6}$/,
    e = () => {
      const a = b.getState()
      let c = a.simulator.webviewInfos[a.simulator.currentWebviewID] || {}
      return -1 != c.tabbarIndex
    }
  module.exports = {
    setNavigationBarTitle: async function(b, c) {
      return (
        b({
          type: a.SIMULATOR_SET_NAVIGATION_BAR,
          data: { title: c.args.title }
        }),
        { errMsg: `${c.api}:ok` }
      )
    },
    setNavigationBarColor: async function(b, c) {
      let d,
        e = c.args,
        { frontColor: f, backgroundColor: g, alpha: h, animation: i } = e,
        j = '#000000' == f ? 'black' : 'white'
      if (i) {
        let a = i.duration || 0,
          b = i.timingFunc || 'linear'
        'easeIn' === b
          ? (b = 'ease-in')
          : 'easeOut' === b
            ? (b = 'ease-out')
            : 'easeInOut' === b && (b = 'ease-in-out'),
          (d = `all ${a}ms ${b}`)
      }
      return (
        b({
          type: a.SIMULATOR_SET_NAVIGATION_BAR,
          data: {
            frontColor: f,
            backgroundColor: g,
            alpha: h,
            transition: d,
            titleStyle: j
          }
        }),
        { errMsg: `${c.api}:ok` }
      )
    },
    setNavigationBarRightButton: async function(b, c) {
      let { iconPath: d, text: e, hide: f } = c.args
      return (
        b({
          type: a.SIMULATOR_SET_NAVIGATION_BAR,
          data: { showRightBtn: !f, rightBtnText: e, rightBtnIconPath: d }
        }),
        { errMsg: `${c.api}:ok` }
      )
    },
    showNavigationBarLoading: async function(b, c) {
      return (
        b({ type: a.SIMULATOR_SET_NAVIGATION_BAR, data: { showLoading: !0 } }),
        { errMsg: `${c.api}:ok` }
      )
    },
    hideNavigationBarLoading: async function(b, c) {
      return (
        b({ type: a.SIMULATOR_SET_NAVIGATION_BAR, data: { showLoading: !1 } }),
        { errMsg: `${c.api}:ok` }
      )
    },
    startPullDownRefresh: async function(a, d) {
      const e = b.getState(),
        f = e.simulator.currentWebviewID
      return (
        c.send(f, { command: 'START_PULLDOWN_REFRESH' }),
        { errMsg: `${d.api}:ok` }
      )
    },
    stopPullDownRefresh: async function(a, d) {
      const e = b.getState(),
        f = e.simulator.currentWebviewID
      return (
        c.send(f, { command: 'STOP_PULLDOWN_REFRESH' }),
        { errMsg: `${d.api}:ok` }
      )
    },
    showTabBar: async function(b, c) {
      return e()
        ? (b({ type: a.SIMULATOR_SET_TABBAR, data: c }),
          { errMsg: `${c.api}:ok` })
        : { errMsg: `${c.api}:fail not TabBar page` }
    },
    hideTabBar: async function(b, c) {
      return e()
        ? (b({ type: a.SIMULATOR_SET_TABBAR, data: c }),
          { errMsg: `${c.api}:ok` })
        : { errMsg: `${c.api}:fail not TabBar page` }
    },
    setTabBarBadge: async function(c, d) {
      if (!e()) return { errMsg: `${d.api}:fail not TabBar page` }
      const f = b.getState(),
        g = d.args,
        h = f.simulator.tabbar,
        i = h.list[g.index]
      return i
        ? g.badgeColor && !/^#[0-9A-Fa-f]{6}$/.test(g.badgeColor)
          ? { errMsg: `${d.api}:fail invalid badgeColor` }
          : g.badgeValue && 4 < g.badgeValue.length
            ? { errMsg: `${d.api}:fail badgeValue should be less than 4` }
            : 0 > ['redDot', 'none', 'text'].indexOf(g.type)
              ? { errMsg: `${d.api}:fail invalid type` }
              : (c({ type: a.SIMULATOR_SET_TABBAR, data: d }),
                { errMsg: `${d.api}:ok` })
        : { errMsg: `${d.api}:fail tabbar item not found` }
    },
    setTabBarItem: async function(c, d) {
      if (!e()) return { errMsg: `${d.api}:fail not TabBar page` }
      const f = b.getState(),
        g = d.args,
        h = f.simulator.tabbar,
        i = h.list[g.index]
      return i
        ? (c({ type: a.SIMULATOR_SET_TABBAR, data: d }),
          { errMsg: `${d.api}:ok` })
        : { errMsg: `${d.api}:fail tabbar item not found` }
    },
    setTabBarStyle: async function(b, c) {
      if (!e()) return { errMsg: `${c.api}:fail not TabBar page` }
      const f = c.args
      let g = []
      return (['color', 'selectedColor', 'backgroundColor'].forEach(a => {
        f[a] && !d.test(f[a]) && g.push(`invalid ${a}`)
      }),
      0 < g.length)
        ? { errMsg: `${c.api}:fail ${g.join(' ')}` }
        : f.borderStyle && 0 > ['white', 'black'].indexOf(f.borderStyle)
          ? { errMsg: `${c.api}:fail invalid borderStyle` }
          : (b({ type: a.SIMULATOR_SET_TABBAR, data: c }),
            { errMsg: `${c.api}:ok` })
    },
    setBackgroundColor: async function(a, b, e) {
      const { api: f, args: g } = b,
        h = e(),
        i = h.simulator.currentWebviewID
      let j = []
      return ([
        'backgroundColor',
        'backgroundColorTop',
        'backgroundColorBottom'
      ].forEach(a => {
        g[a] && !d.test(g[a]) && j.push(`invalid ${a}`)
      }),
      0 < j.length)
        ? { errMsg: `${f}:fail ${j.join(' ')}` }
        : (c.send(i, { command: 'SET_BACKGROUND_COLOR', data: g }),
          { errMsg: `${f}:ok` })
    },
    setBackgroundTextStyle: async function(a, b, d) {
      const { api: e, args: f } = b,
        g = d(),
        h = g.simulator.currentWebviewID
      return 0 > ['dark', 'light'].indexOf(f.textStyle)
        ? { errMsg: `${e}:fail invalid textStyle` }
        : (c.send(h, { command: 'SET_BACKGROUND_TEXT_STYLE', data: f }),
          { errMsg: `${e}:ok` })
    }
  }
})(require('lazyload'), require)
