/*! bxs-vue-ui v3.3.0 */
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

require('../utils/entry-virtual.js');
var normalizeComponent = require('../utils/normalize-component.js');
require('../utils/sloppy-array-method.js');
var indexOf = require('../utils/index-of.js');
var icon = require('../icon/index.js');
var emitter = require('../utils/emitter.js');

var _components;

var onlyValues = function onlyValues(values) {
  return function (str) {
    return indexOf._indexOfInstanceProperty(values).call(values, str) !== -1;
  };
};

var script = normalizeComponent.create({
  name: 'protocol',
  mixins: [emitter.Emitter],
  props: {
    // 协议列表
    protocolList: {
      type: Array,
      default: []
    },
    value: {
      type: Boolean,
      default: false
    },
    // 高亮颜色
    highlightColor: {
      type: String,
      default: ''
    },
    type: {
      type: String,
      default: 'primary',
      validator: onlyValues(['primary', 'minor'])
    }
  },
  data: function data() {
    return {};
  },
  computed: {
    color: function color() {
      return this.highlightColor || this.type === 'primary' && '#508CEE' || this.type === 'minor' && '#FF5000';
    }
  },
  methods: {
    onClick: function onClick(item) {
      if (!item.url && item.onClick) {
        item.onClick();
      }
    },
    changeSelect: function changeSelect() {
      this.$emit('input', !this.value);
      this.dispatch('bxs-form-item', 'form.item.validate');
    }
  },
  components: (_components = {}, _components[icon.default.name] = icon.default, _components)
});

var __vue_script__ = script;
/* template */

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

  var _h = _vm.$createElement;

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

  return _c('div', {
    staticClass: "bx-protocol"
  }, [_c('span', {
    on: {
      "click": _vm.changeSelect
    }
  }, [_c('bxs-icon', {
    attrs: {
      "name": _vm.value ? 'check-solid' : 'circle',
      "color": _vm.value ? _vm.color : '',
      "size": "18px"
    }
  })], 1), _c('span', {
    staticClass: "bx-protocol-primary"
  }, [_c('span', [_vm._v("我已认真阅读")]), _vm._l(_vm.protocolList, function (item, index) {
    return _c('a', {
      key: index,
      style: 'color:' + _vm.color,
      attrs: {
        "href": item.url,
        "target": item.target
      },
      on: {
        "click": function click($event) {
          _vm.onClick(item);
        }
      }
    }, [_vm._v("\n      " + _vm._s(item.name) + "\n    ")]);
  }), _c('span', [_vm._v(",并同意上述协议约定")])], 2), _c('div', {
    staticClass: "bx-protocol-sub"
  }, [_vm._t("subText")], 2)]);
};

var __vue_staticRenderFns__ = [];
/* style */

var __vue_inject_styles__ = undefined;
/* scoped */

var __vue_scope_id__ = undefined;
/* module identifier */

var __vue_module_identifier__ = undefined;
/* functional template */

var __vue_is_functional_template__ = false;
/* style inject */

/* style inject SSR */

var index = normalizeComponent.__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);

exports.default = index;
