(window["customImportMapDashboards_bundle_jsonpfunction"]=window["customImportMapDashboards_bundle_jsonpfunction"]||[]).push([[13],{1050:function(module,exports,__webpack_require__){"use strict";var _interopRequireDefault=__webpack_require__(0);Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _defineProperty2=_interopRequireDefault(__webpack_require__(1));var _eui=__webpack_require__(7);var _react=__webpack_require__(16);var _react2=_interopRequireWildcard(__webpack_require__(3));var _common=__webpack_require__(6);var _filter_bar=__webpack_require__(305);var _query=__webpack_require__(118);function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap;var cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj}}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj)}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc)}else{newObj[key]=obj[key]}}}newObj.default=obj;if(cache){cache.set(obj,newObj)}return newObj}class ApplyFiltersPopoverContent extends _react2.Component{constructor(props){super(props);(0,_defineProperty2.default)(this,"isFilterSelected",i=>this.state.isFilterSelected[i]);(0,_defineProperty2.default)(this,"toggleFilterSelected",i=>{const isFilterSelected=[...this.state.isFilterSelected];isFilterSelected[i]=!isFilterSelected[i];this.setState({isFilterSelected:isFilterSelected})});(0,_defineProperty2.default)(this,"onSubmit",()=>{const selectedFilters=this.props.filters.filter((filter,i)=>this.state.isFilterSelected[i]);this.props.onSubmit(selectedFilters)});this.state={isFilterSelected:props.filters.map(()=>true)}}getLabel(filter){const valueLabel=(0,_common.getDisplayValueFromFilter)(filter,this.props.indexPatterns);return _react2.default.createElement(_filter_bar.FilterLabel,{filter:filter,valueLabel:valueLabel})}render(){if(this.props.filters.length===0){return""}const mappedFilters=(0,_query.mapAndFlattenFilters)(this.props.filters);const form=_react2.default.createElement(_eui.EuiForm,null,mappedFilters.map((filter,i)=>_react2.default.createElement(_eui.EuiFormRow,{key:i},_react2.default.createElement(_eui.EuiSwitch,{label:this.getLabel(filter),checked:this.isFilterSelected(i),onChange:()=>this.toggleFilterSelected(i)}))));return _react2.default.createElement(_react2.default.Fragment,null,_react2.default.createElement(_eui.EuiModalHeader,null,_react2.default.createElement(_eui.EuiModalHeaderTitle,null,_react2.default.createElement(_react.FormattedMessage,{id:"data.filter.applyFilters.popupHeader",defaultMessage:"Select filters to apply"}))),_react2.default.createElement(_eui.EuiModalBody,null,form),_react2.default.createElement(_eui.EuiModalFooter,null,_react2.default.createElement(_eui.EuiButtonEmpty,{onClick:this.props.onCancel},_react2.default.createElement(_react.FormattedMessage,{id:"data.filter.applyFiltersPopup.cancelButtonLabel",defaultMessage:"Cancel"})),_react2.default.createElement(_eui.EuiButton,{onClick:this.onSubmit,"data-test-subj":"applyFiltersPopoverButton",fill:true},_react2.default.createElement(_react.FormattedMessage,{id:"data.filter.applyFiltersPopup.saveButtonLabel",defaultMessage:"Apply"}))))}}exports.default=ApplyFiltersPopoverContent;(0,_defineProperty2.default)(ApplyFiltersPopoverContent,"defaultProps",{filters:[]});module.exports=exports.default}}]);