'use strict';require('./es.array.map-9ed24b81.js'),require('./es.array.filter-09db7a5b.js'),require('./es.object.to-string-36cdf22d.js'),require('./es.array.includes-8b336760.js'),require('./es.string.includes-42971fd6.js');var BaseButton=require('./BaseButton-351caf8b.js'),normalizeComponent=require('./normalize-component-ebe0c011.js');require('./well-known-symbol-d17f132e.js'),require('./array-iteration-7bef1cbf.js'),require('./function-bind-context-e4685306.js'),require('./array-species-create-cd337f69.js'),require('./array-method-has-species-support-73df5c77.js'),require('./classof-5cc7a6a8.js'),require('./object-keys-68ce563f.js'),require('./is-regexp-3bdf4eae.js'),require('./es.symbol.description-8b46cca4.js'),require('./set-to-string-tag-7ddc8966.js'),require('./utils-b175a405.js'),require('./typeof-6b9e62b8.js'),require('./unsupportedIterableToArray-40a00645.js'),require('./es.array.join-443a49dd.js'),require('./array-method-is-strict-46936434.js'),require('./regexp-exec-abstract-f1889c3e.js'),require('./string-multibyte-7b9a9b5a.js'),require('./regexp-flags-cc8e8e8b.js'),require('./es.string.split-a55a52d4.js'),require('./create-property-843cca47.js'),require('./es.regexp.to-string-bb35129d.js'),require('./es.string.replace-9de5b0e2.js'),require('./es.array.sort-904aa90f.js'),require('./web.dom-collections.for-each-56c57b78.js'),require('./dom-iterables-e2602b7e.js'),require('./es.object.keys-bf503f80.js'),require('./BaseIcon-2385428f.js'),require('./es.array.concat-dd2e767c.js'),require('./BaseBoxTooltip-9cd31b0b.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;