'use strict';

var normalizeComponent = require('./normalize-component-6fa50395.js');
var ThemeMixin = require('./ThemeMixin-a2f817cd.js');

var script = {
  name: 'OutsideClickAtom',
  methods: {
    onClickAnything: function onClickAnything(e) {
      var _this$$slots$default = ThemeMixin._slicedToArray(this.$slots.default, 1),
          target = _this$$slots$default[0];

      if (!target) return;
      var currentNode = e.target;

      while (currentNode.parentNode) {
        currentNode = currentNode.parentNode;
        if (target.elm === currentNode.parentNode) break;

        if (!currentNode.parentNode) {
          this.$emit('click');
          break;
        }
      }
    }
  },
  beforeMount: function beforeMount() {
    document.body.addEventListener('click', this.onClickAnything);
  },
  beforeDestroy: function beforeDestroy() {
    document.body.removeEventListener('click', this.onClickAnything);
  },
  render: function render() {
    return this.$slots.default;
  }
};

/* script */
const __vue_script__ = script;

/* template */

  /* 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__ = undefined;
  /* style inject */
  
  /* style inject SSR */
  

  
  var OutsideClickAtom = normalizeComponent.__vue_normalize__(
    {},
    __vue_inject_styles__,
    __vue_script__,
    __vue_scope_id__,
    __vue_is_functional_template__,
    __vue_module_identifier__,
    undefined,
    undefined
  );

exports.OutsideClickAtom = OutsideClickAtom;
