'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) {
  async function a(a, c, d) {
    let { api: e, args: g = {}, callbackID: f } = c
    const h = d(),
      i = h.simulator.coverViewTree
    return i[g.viewId]
      ? 'image' == i[g.viewId].type
        ? (a({
            type: b.SIMULATOR_REMOVE_COVERVIEW,
            data: { viewId: g.viewId }
          }),
          { errMsg: `${e}:ok` })
        : { errMsg: `${e}:fail not image view` }
      : { errMsg: `${e}:fail ${g.viewId} not found` }
  }
  const b = require('./0634ee2ebd3e560d9d4804ecc960160f.js'),
    c = function(a = {}) {
      let b = []
      return (
        ['height', 'width', 'top', 'left'].forEach(c => {
          'number' != typeof a[c] && b.push(`position.${c} should be Number`)
        }),
        b.join(' ')
      )
    }
  module.exports = {
    insertTextView: async function(a, d, e) {
      let { api: f, args: h = {}, callbackID: g } = d,
        i = h.position || {}
      const j = c(i)
      if (j) return `${f}:fail ${j}`
      const k = e(),
        l = k.simulator.coverViewTree
      return l[h.parentId]
        ? l[h.viewId]
          ? { errMsg: `${f}:fail already exist` }
          : (a({
              type: b.SIMUALTOR_INSERT_COVERVIEW,
              data: {
                type: 'text',
                parentId: h.parentId,
                viewId: h.viewId,
                hide: h.hide,
                position: {
                  height: -1 == i.height ? 'auto' : i.height || 0,
                  width: -1 == i.width ? 'auto' : i.width || 0,
                  left: i.left || 0,
                  top: i.top || 0
                },
                style: h.style || {},
                label: h.label || {},
                clickable: !!h.clickable,
                transEvt: !!h.transEvt,
                data: h.data
              }
            }),
            { errMsg: `${f}:ok`, viewId: h.viewId })
        : { errMsg: `${f}:fail parent ${h.parentId} not found` }
    },
    updateTextView: async function(a, d, e) {
      let { api: f, args: h = {}, callbackID: g } = d
      const i = e(),
        j = i.simulator.coverViewTree
      if (!j[h.viewId]) return { errMsg: `${f}:fail ${h.viewId} not found` }
      if ('text' != j[h.viewId].type)
        return { errMsg: `${f}:fail not text view` }
      let k = _extends({}, h)
      if (h.position) {
        let a = h.position
        const b = c(a)
        if (b) return `${f}:fail ${b}`
        k.position = {
          height: -1 == a.height ? 'auto' : a.height || 0,
          width: -1 == a.width ? 'auto' : a.width || 0,
          left: a.left || 0,
          top: a.top || 0
        }
      }
      return (
        a({ type: b.SIMULATOR_UPDATE_COVERVIEW, data: k }),
        { errMsg: `${f}:ok` }
      )
    },
    removeTextView: async function(a, c, d) {
      let { api: e, args: g = {}, callbackID: f } = c
      const h = d(),
        i = h.simulator.coverViewTree
      return i[g.viewId]
        ? 'text' == i[g.viewId].type
          ? (a({
              type: b.SIMULATOR_REMOVE_COVERVIEW,
              data: { viewId: g.viewId }
            }),
            { errMsg: `${e}:ok` })
          : { errMsg: `${e}:fail not text view` }
        : { errMsg: `${e}:fail ${g.viewId} not found` }
    },
    insertImageView: async function(a, d, e) {
      let { api: f, args: h = {}, callbackID: g } = d,
        i = h.position || {}
      const j = c(i)
      if (j) return `${f}:fail ${j}`
      const k = e(),
        l = k.simulator.coverViewTree
      return l[h.parentId]
        ? l[h.viewId]
          ? { errMsg: `${f}:fail already exist` }
          : (a({
              type: b.SIMUALTOR_INSERT_COVERVIEW,
              data: {
                type: 'image',
                parentId: h.parentId,
                viewId: h.viewId,
                hide: h.hide,
                position: {
                  height: -1 == i.height ? 'auto' : i.height || 0,
                  width: -1 == i.width ? 'auto' : i.width || 0,
                  left: i.left || 0,
                  top: i.top || 0
                },
                style: h.style || {},
                iconPath: h.iconPath || '',
                clickable: !!h.clickable,
                transEvt: !!h.transEvt,
                data: h.data
              }
            }),
            { errMsg: `${f}:ok`, viewId: h.viewId })
        : { errMsg: `${f}:fail parent ${h.parentId} not found` }
    },
    updateImageView: async function(a, d, e) {
      let { api: f, args: h = {}, callbackID: g } = d,
        i = h.position || {}
      const j = e(),
        k = j.simulator.coverViewTree
      if (!k[h.viewId]) return { errMsg: `${f}:fail ${h.viewId} not found` }
      if ('image' != k[h.viewId].type)
        return { errMsg: `${f}:fail not image view` }
      let l = _extends({}, h)
      if (h.position) {
        let a = h.position
        const b = c(a)
        if (b) return `${f}:fail ${b}`
        l.position = {
          height: -1 == a.height ? 'auto' : a.height || 0,
          width: -1 == a.width ? 'auto' : a.width || 0,
          left: a.left || 0,
          top: a.top || 0
        }
      }
      return (
        a({ type: b.SIMULATOR_UPDATE_COVERVIEW, data: l }),
        { errMsg: `${f}:ok` }
      )
    },
    removeImageView: a,
    removeImageView: a,
    animateCoverView: async function(a, c, d) {
      let { api: e, args: g = {}, callbackID: f } = c
      const h = d(),
        i = h.simulator.coverViewTree
      return i[g.viewId]
        ? void a({
            type: b.SIMULATOR_ANIMATE_COVERVIEW,
            data: {
              viewId: g.viewId,
              animation: {
                finalStyle: g.finalStyle,
                duration: g.duration,
                easing: g.easing
              }
            }
          })
        : { errMsg: `${e}:fail ${g.viewId} not found` }
    }
  }
})(require('lazyload'), require)
