/* script */
//
//
//
//
//
//
//
//
//
//
import { componentMixin, createComponentName } from '../_utils/component';
import udesk from './udesk';
const __vue_script__ = {
  name: createComponentName('udesk'),
  mixins: [componentMixin],
  udesk,
  props: {
    // 默认配置 [参考](http://www.udesk.cn/doc/thirdparty/webim/#_11)
    config: {
      type: Object,
      default: () => ({})
    }
  },

  data() {
    return {
      udesk: udesk
    };
  },

  computed: {
    label() {
      if (!this.udesk) return '';
      return this.udesk.label;
    },

    unread() {
      if (!this.udesk) return 0;
      return this.udesk.unread;
    }

  },
  watch: {
    label(v, o) {
      if (v !== o) this.$emit('label', v);
    },

    unread(v, o) {
      if (v !== o) this.$emit('unread', v);
    },

    config(c) {
      udesk.setConfig(c);
    }

  },

  mounted() {
    udesk.setConfig(this.config);
  },

  beforeDestroy() {
    this.udesk.destroy();
  },

  methods: {
    showPanel() {
      this.udesk.show();
    },

    hidePanel() {
      this.udesk.hide();
    }

  }
};
/* template */

var __vue_render__ = function () {
  var _vm = this;

  var _h = _vm.$createElement;

  var _c = _vm._self._c || _h;

  return _c("div", {
    class: _vm.bem(),
    on: {
      click: _vm.showPanel
    }
  }, [_vm._t("default", [_c("gd-button", {
    attrs: {
      rect: ""
    }
  }, [_vm._v(_vm._s(_vm.label))])], {
    showPanel: _vm.showPanel,
    label: _vm.label,
    unread: _vm.unread
  })], 2);
};

var __vue_staticRenderFns__ = [];
__vue_render__._withStripped = true;
/* style */

const __vue_inject_styles__ = undefined;
/* scoped */

const __vue_scope_id__ = undefined;
/* module identifier */

const __vue_module_identifier__ = undefined;
/* functional template */

const __vue_is_functional_template__ = false;
/* component normalizer */

import __vue_normalize__ from '../_utils/vue-normalize-component.js';
/* style inject */

/* style inject SSR */

export default __vue_normalize__({
  render: __vue_render__,
  staticRenderFns: __vue_staticRenderFns__
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, undefined, undefined);