'use strict';require('./es.array.map-4cfed4ef.js'),require('./es.array.filter-6fabfac0.js'),require('./es.object.to-string-f27a75a8.js'),require('./es.array.includes-3990bfec.js'),require('./es.string.includes-ec03e639.js');var BaseButton=require('./BaseButton-914daba0.js'),normalizeComponent=require('./normalize-component-d9981c57.js');require('./export-61511812.js'),require('./array-iteration-f8b4483d.js'),require('./function-bind-context-e4685306.js'),require('./array-species-create-c414c2ec.js'),require('./array-method-has-species-support-983ac207.js'),require('./classof-819fc780.js'),require('./object-keys-12f2c5e5.js'),require('./is-regexp-d6f1551e.js'),require('./es.symbol.description-bf683260.js'),require('./set-to-string-tag-240bb3b0.js'),require('./utils-2e136d65.js'),require('./typeof-6b9e62b8.js'),require('./unsupportedIterableToArray-40a00645.js'),require('./es.array.join-88750c41.js'),require('./array-method-is-strict-99341ee3.js'),require('./regexp-exec-abstract-216cd44a.js'),require('./string-multibyte-a2dff6e3.js'),require('./regexp-flags-abc49c4a.js'),require('./es.string.split-98e29ede.js'),require('./create-property-240c71a5.js'),require('./es.regexp.to-string-5606f728.js'),require('./es.string.replace-25e9e098.js'),require('./es.array.sort-7d68b195.js'),require('./web.dom-collections.for-each-c07b0e22.js'),require('./dom-iterables-e2602b7e.js'),require('./es.object.keys-c57f02bd.js'),require('./BaseIcon-1ed3bf6e.js'),require('./es.array.concat-bb8715dc.js'),require('./BaseBoxTooltip-320d8773.js');/**
 * component to enable display of selected items and a select all
 */

var script = {
  name: 'BaseSelectOptions',
  components: {
    BaseButton: BaseButton["default"]
  },
  props: {
    /**
     * specify the text displayed for number of selected entries
     * x {selectText}
     */
    selectedNumberText: {
      type: String,
      default: 'entries selected'
    },

    /**
     * the text displayed for select / deselect all
     */
    selectText: {
      type: String,
      default: 'All'
    },

    /**
     * the text displayed for select / deselect all
     */
    deselectText: {
      type: String,
      default: 'None'
    },

    /**
     * provide a list of currently visible entries
     */
    list: {
      type: Array,
      default: function _default() {
        return [];
      }
    },

    /**
     * provide a list of selected entries
     */
    selectedList: {
      type: Array,
      default: function _default() {
        return [];
      }
    },

    /**
     * disable the button by setting this prop to true
     */
    selectAllDisabled: {
      type: Boolean,
      default: false
    },

    /**
     * By default, the "All/None" button appears on the right, and the counter of
     * selected items appears on the left. Set this to `true` to reverse the order.
     */
    reverse: {
      type: Boolean,
      default: false
    }
  },
  data: function data() {
    return {
      selectedInt: false,
      // used to change the flex direction of select options from 'row' to 'row-reverse' (#1692)
      flexDirection: 'row'
    };
  },
  computed: {
    numberSelected: function numberSelected() {
      return this.selectedList.length;
    },
    allSelected: function allSelected() {
      // not just calc comparing selectedList with list because with pagination
      // selectedList can contain entries that are currently not incluced in list
      var idList = this.selectedList.length && this.selectedList[0].id ? this.selectedList.map(function (entry) {
        return entry.id;
      }) : this.selectedList;
      var unselectedLength = this.list.filter(function (entry) {
        return !idList.includes(entry.id);
      }).length;
      return unselectedLength === 0;
    }
  },
  watch: {
    allSelected: {
      handler: function handler(val) {
        if (val !== this.selectedInt) {
          this.selectedInt = val;
        }
      },
      immediate: true
    }
  },
  created: function created() {
    // swap position of select options based on the 'reverse' prop (#1692)
    this.flexDirection = this.reverse ? 'row-reverse' : 'row';
  },
  methods: {
    select: function select() {
      this.selectedInt = !this.selectedInt;
      /**
       * emitted on select all button click
       *
       * @event selected
       * @param {boolean} selectedInt
       */

      this.$emit('selected', this.selectedInt);
    }
  }
};/* script */
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: "base-select-options",
    style: {
      '--direction': _vm.flexDirection
    }
  }, [_vm._ssrNode("<div class=\"base-select-options__number-selected\" data-v-384cd160>", "</div>", [_vm._t("selectedText", function () {
    return [_vm._v("\n      " + _vm._s(_vm.numberSelected + " " + _vm.selectedNumberText) + "\n    ")];
  })], 2), _vm._ssrNode(" "), _c('BaseButton', {
    staticClass: "base-select-options__select-button",
    attrs: {
      "text": _vm.allSelected ? _vm.deselectText : _vm.selectText,
      "disabled": _vm.selectAllDisabled,
      "button-style": "secondary"
    },
    on: {
      "clicked": _vm.select
    }
  })], 2);
};

var __vue_staticRenderFns__ = [];
/* style */

var __vue_inject_styles__ = undefined;
/* scoped */

var __vue_scope_id__ = "data-v-384cd160";
/* module identifier */

var __vue_module_identifier__ = "data-v-384cd160";
/* functional template */

var __vue_is_functional_template__ = false;
/* style inject */

/* style inject SSR */

/* style inject shadow dom */

var __vue_component__ = /*#__PURE__*/normalizeComponent.n({
  render: __vue_render__,
  staticRenderFns: __vue_staticRenderFns__
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);

var BaseSelectOptions = __vue_component__;exports["default"]=BaseSelectOptions;