"use strict";(self["indexManagementDashboards_bundle_jsonpfunction"]=self["indexManagementDashboards_bundle_jsonpfunction"]||[]).push([["2"],{62961:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{"default":()=>__WEBPACK_DEFAULT_EXPORT__});var _swc_helpers_object_without_properties__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(61227);var _swc_helpers_sliced_to_array__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(77135);var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(31085);var react__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(46933);var react__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);var _elastic_eui__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(1350);var _elastic_eui__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(_elastic_eui__WEBPACK_IMPORTED_MODULE_2__);var _CustomFormRow__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(23294);var JSONDiffEditor=(0,react__WEBPACK_IMPORTED_MODULE_1__.forwardRef)(function(_param,ref){var value=_param.value,onChange=_param.onChange,others=(0,_swc_helpers_object_without_properties__WEBPACK_IMPORTED_MODULE_4__._)(_param,["value","onChange"]);var _useState=(0,_swc_helpers_sliced_to_array__WEBPACK_IMPORTED_MODULE_5__._)((0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false),2),confirmModalVisible=_useState[0],setConfirmModalVisible=_useState[1];var _useState1=(0,_swc_helpers_sliced_to_array__WEBPACK_IMPORTED_MODULE_5__._)((0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(value),2),editorValue=_useState1[0],setEditorValue=_useState1[1];var valueRef=(0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(editorValue);valueRef.current=editorValue;(0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(function(){setEditorValue(value)},[value]);(0,react__WEBPACK_IMPORTED_MODULE_1__.useImperativeHandle)(ref,function(){return{validate:function(){return new Promise(function(resolve,reject){try{JSON.parse(valueRef.current||"{}");resolve("")}catch(e){setConfirmModalVisible(true);reject("Format validate error")}})},getValue:function(){return valueRef.current},setValue:function(val){return setEditorValue(val)}}});return(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("textarea",{style:{display:"none"},value:editorValue,onChange:function(e){setEditorValue(e.target.value)},onBlur:function(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")}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{style:{display:"flex",marginBottom:12},children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{style:{flexGrow:1},children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_CustomFormRow__WEBPACK_IMPORTED_MODULE_3__.A,{label:"Original",helpText:"The original value",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment,{})})}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{style:{flexGrow:1},children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_CustomFormRow__WEBPACK_IMPORTED_MODULE_3__.A,{label:"Modified",helpText:"The value you modified",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment,{})})})]}),confirmModalVisible&&(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_elastic_eui__WEBPACK_IMPORTED_MODULE_2__.EuiCompressedFormRow,{fullWidth:true,isInvalid:confirmModalVisible,error:"Your input does not match the validation of json format, please fix the error line with error aside.",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment,{})})]})});const __WEBPACK_DEFAULT_EXPORT__=JSONDiffEditor}}]);