text: define(["exports","../../../@polymer/polymer/lib/utils/async.js","../../../@polymer/polymer/polymer-element.js"],function(_exports,_async,_polymerElement){"use strict";Object.defineProperty(_exports,"__esModule",{value:!0});_exports.SortMixin=void 0;_exports.SortMixin=function SortMixin(superClass){return function(_superClass){babelHelpers.inherits(SortMixin,_superClass);function SortMixin(){babelHelpers.classCallCheck(this,SortMixin);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(SortMixin).apply(this,arguments))}babelHelpers.createClass(SortMixin,[{key:"ready",value:function ready(){var _this=this;babelHelpers.get(babelHelpers.getPrototypeOf(SortMixin.prototype),"ready",this).call(this);this.addEventListener("sorter-changed",this._onSorterChanged);if(window.ShadyDOM){_async.microTask.run(function(){var sorters=_this.querySelectorAll("vaadin-grid-sorter");Array.from(sorters).forEach(function(sorter){if(babelHelpers.instanceof(sorter,_polymerElement.PolymerElement)){sorter.dispatchEvent(new CustomEvent("sorter-changed",{bubbles:!0,composed:!0}))}})})}}},{key:"_onSorterChanged",value:function _onSorterChanged(e){var _this2=this,sorter=e.target;this._removeArrayItem(this._sorters,sorter);sorter._order=null;if(this.multiSort){if(sorter.direction){this._sorters.unshift(sorter)}this._sorters.forEach(function(sorter,index){return sorter._order=1<_this2._sorters.length?index:null},this)}else{if(sorter.direction){this._sorters.forEach(function(sorter){sorter._order=null;sorter.direction=null});this._sorters=[sorter]}}e.stopPropagation();if(this.dataProvider&&JSON.stringify(this._previousSorters)!==JSON.stringify(this._mapSorters())){this.clearCache()}this._a11yUpdateSorters();this._previousSorters=this._mapSorters()}},{key:"_mapSorters",value:function _mapSorters(){return this._sorters.map(function(sorter){return{path:sorter.path,direction:sorter.direction}})}},{key:"_removeArrayItem",value:function _removeArrayItem(array,item){var index=array.indexOf(item);if(-1<index){array.splice(index,1)}}}],[{key:"properties",get:function get(){return{multiSort:{type:Boolean,value:!1},_sorters:{type:Array,value:function value(){return[]}},_previousSorters:{type:Array,value:function value(){return[]}}}}}]);return SortMixin}(superClass)}});