(window["indexManagementDashboards_bundle_jsonpfunction"]=window["indexManagementDashboards_bundle_jsonpfunction"]||[]).push([[4],{122:function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__);var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(11);var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__);var _babel_runtime_helpers_objectWithoutProperties__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(58);var _babel_runtime_helpers_objectWithoutProperties__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(_babel_runtime_helpers_objectWithoutProperties__WEBPACK_IMPORTED_MODULE_1__);var react__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(1);var react__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);var _elastic_eui__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(4);var _elastic_eui__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(_elastic_eui__WEBPACK_IMPORTED_MODULE_3__);var _CustomFormRow__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(59);var _excluded=["value","onChange"];var JSONDiffEditor=Object(react__WEBPACK_IMPORTED_MODULE_2__["forwardRef"])((function(_ref,ref){var value=_ref.value,onChange=_ref.onChange,others=_babel_runtime_helpers_objectWithoutProperties__WEBPACK_IMPORTED_MODULE_1___default()(_ref,_excluded);var _useState=Object(react__WEBPACK_IMPORTED_MODULE_2__["useState"])(false),_useState2=_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default()(_useState,2),confirmModalVisible=_useState2[0],setConfirmModalVisible=_useState2[1];var _useState3=Object(react__WEBPACK_IMPORTED_MODULE_2__["useState"])(value),_useState4=_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default()(_useState3,2),editorValue=_useState4[0],setEditorValue=_useState4[1];var valueRef=Object(react__WEBPACK_IMPORTED_MODULE_2__["useRef"])(editorValue);valueRef.current=editorValue;Object(react__WEBPACK_IMPORTED_MODULE_2__["useEffect"])((function(){setEditorValue(value)}),[value]);Object(react__WEBPACK_IMPORTED_MODULE_2__["useImperativeHandle"])(ref,(function(){return{validate:function validate(){return new Promise((function(resolve,reject){try{JSON.parse(valueRef.current||"{}");resolve("")}catch(e){setConfirmModalVisible(true);reject("Format validate error")}}))},getValue:function getValue(){return valueRef.current},setValue:function setValue(val){return setEditorValue(val)}}}));return react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement("div",null,react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement("textarea",{style:{display:"none"},value:editorValue,onChange:function onChange(e){setEditorValue(e.target.value)},onBlur:function onBlur(e){try{JSON.parse(e.target.value);onChange&&onChange(e.target.value)}catch(e){setConfirmModalVisible(true)}},title:"editor-is-ready-true","data-test-subj":"".concat(others["data-test-subj"]||"jsonEditor","-valueDisplay")}),react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement("div",{style:{display:"flex",marginBottom:12}},react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement("div",{style:{flexGrow:1}},react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(_CustomFormRow__WEBPACK_IMPORTED_MODULE_4__["a"],{label:"Original",helpText:"The original value"},react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_2___default.a.Fragment,null))),react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement("div",{style:{flexGrow:1}},react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(_CustomFormRow__WEBPACK_IMPORTED_MODULE_4__["a"],{label:"Modified",helpText:"The value you modified"},react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_2___default.a.Fragment,null)))),confirmModalVisible&&react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(_elastic_eui__WEBPACK_IMPORTED_MODULE_3__["EuiFormRow"],{fullWidth:true,isInvalid:confirmModalVisible,error:"Your input does not match the validation of json format, please fix the error line with error aside."},react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_2___default.a.Fragment,null)))}));__webpack_exports__["default"]=JSONDiffEditor}}]);