"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_useNativeAPI=require("../helpers/hooks/useNativeAPI"),_utils=require("./utils");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ownKeys(t,e){var r,i=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)),i}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach(function(e){_defineProperty(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:String(e)}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!=_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(0,_baseComponent.default)({useExport:!0,properties:_objectSpread({height:{type:Number,value:270}},(0,_utils.getDefaultProps)()),data:{startIndex:0,endIndex:-1},observers:{options:function(e){var t=this;(0,_useNativeAPI.nextTick)(function(){return t.renderVirtualList(e)})}},methods:{onVirtualChange:function(e){var t=e.detail,r=t.startIndex,t=t.endIndex;this.data.startIndex===r&&this.data.endIndex===t||(this.setData(e.detail),this.triggerEvent("virtualChange",_objectSpread({},e.detail)))},renderVirtualList:function(e){var t=this.querySelector("#wux-virtual-list");t&&t.render(e)},onValueChange:function(e){var t=this.data,r=t.max,t=t.multiple,e=e.detail.selectedValue;t&&1<=r&&r<e.length||this.triggerEvent("selectChange",this.getValue(e))},getValue:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.data.value,t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.data.options;return this.picker=this.picker||this.querySelector(_utils.POPUP_SELECTOR),this.picker&&this.picker.getValue(e,t)},expose:function(){var r=this;return{scrollToItem:function(e){var t=r.querySelector("#wux-virtual-list");if(t)return t.scrollToIndex(e)},getValue:this.getValue.bind(this)}}},ready:function(){var e=this,t=this.data.options;(0,_useNativeAPI.nextTick)(function(){return e.renderVirtualList(t)})}});