(window["alertingDashboards_bundle_jsonpfunction"]=window["alertingDashboards_bundle_jsonpfunction"]||[]).push([[19],{2846:function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _eui=__webpack_require__(2);var _react=__webpack_require__(8);var _react2=_interopRequireWildcard(__webpack_require__(0));var _common=__webpack_require__(6);var _filter_bar=__webpack_require__(766);var _query=__webpack_require__(330);function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap,t=new WeakMap;return(_getRequireWildcardCache=function(e){return e?t:r})(e)}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u]}return n.default=e,t&&t.set(e,n),n}function _defineProperty(obj,key,value){key=_toPropertyKey(key);if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return typeof key==="symbol"?key:String(key)}function _toPrimitive(input,hint){if(typeof input!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(typeof res!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.")}return(hint==="string"?String:Number)(input)}class ApplyFiltersPopoverContent extends _react2.Component{constructor(props){super(props);_defineProperty(this,"isFilterSelected",i=>this.state.isFilterSelected[i]);_defineProperty(this,"toggleFilterSelected",i=>{const isFilterSelected=[...this.state.isFilterSelected];isFilterSelected[i]=!isFilterSelected[i];this.setState({isFilterSelected:isFilterSelected})});_defineProperty(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.EuiCompressedFormRow,{key:i},_react2.default.createElement(_eui.EuiCompressedSwitch,{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(_eui.EuiText,{size:"s"},_react2.default.createElement("h2",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.EuiSmallButtonEmpty,{onClick:this.props.onCancel},_react2.default.createElement(_react.FormattedMessage,{id:"data.filter.applyFiltersPopup.cancelButtonLabel",defaultMessage:"Cancel"})),_react2.default.createElement(_eui.EuiSmallButton,{onClick:this.onSubmit,"data-test-subj":"applyFiltersPopoverButton",fill:true},_react2.default.createElement(_react.FormattedMessage,{id:"data.filter.applyFiltersPopup.saveButtonLabel",defaultMessage:"Apply"}))))}}exports.default=ApplyFiltersPopoverContent;_defineProperty(ApplyFiltersPopoverContent,"defaultProps",{filters:[]});module.exports=exports.default}}]);