"use strict";(self["indexManagementDashboards_bundle_jsonpfunction"]=self["indexManagementDashboards_bundle_jsonpfunction"]||[]).push([[0],{2961(__unused_rspack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);var _swc_helpers_object_without_properties__rspack_import_5=__webpack_require__(2608);var _swc_helpers_sliced_to_array__rspack_import_6=__webpack_require__(7543);var _swc_helpers_to_array__rspack_import_4=__webpack_require__(7200);var react_jsx_runtime__rspack_import_0=__webpack_require__(1085);var react__rspack_import_1=__webpack_require__(6933);var react__rspack_import_1_default=__webpack_require__.n(react__rspack_import_1);var _elastic_eui__rspack_import_2=__webpack_require__(1350);var _elastic_eui__rspack_import_2_default=__webpack_require__.n(_elastic_eui__rspack_import_2);var _CustomFormRow__rspack_import_3=__webpack_require__(3294);var JSONDiffEditor=(0,react__rspack_import_1.forwardRef)(function(_0,_1){var _ref=[_0,_1],_ref1=(0,_swc_helpers_to_array__rspack_import_4._)(_ref),_ref2=_ref1[0],_rest=_ref1.slice(1),value=_ref2.value,onChange=_ref2.onChange,others=(0,_swc_helpers_object_without_properties__rspack_import_5._)(_ref2,["value","onChange"]),_rest1=(0,_swc_helpers_sliced_to_array__rspack_import_6._)(_rest,1),ref=_rest1[0];var _useState=(0,_swc_helpers_sliced_to_array__rspack_import_6._)((0,react__rspack_import_1.useState)(false),2),confirmModalVisible=_useState[0],setConfirmModalVisible=_useState[1];var _useState1=(0,_swc_helpers_sliced_to_array__rspack_import_6._)((0,react__rspack_import_1.useState)(value),2),editorValue=_useState1[0],setEditorValue=_useState1[1];var valueRef=(0,react__rspack_import_1.useRef)(editorValue);valueRef.current=editorValue;(0,react__rspack_import_1.useEffect)(function(){setEditorValue(value)},[value]);(0,react__rspack_import_1.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(0,react_jsx_runtime__rspack_import_0.jsxs)("div",{children:[(0,react_jsx_runtime__rspack_import_0.jsx)("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")}),(0,react_jsx_runtime__rspack_import_0.jsxs)("div",{style:{display:"flex",marginBottom:12},children:[(0,react_jsx_runtime__rspack_import_0.jsx)("div",{style:{flexGrow:1},children:(0,react_jsx_runtime__rspack_import_0.jsx)(_CustomFormRow__rspack_import_3.A,{label:"Original",helpText:"The original value",children:(0,react_jsx_runtime__rspack_import_0.jsx)(react_jsx_runtime__rspack_import_0.Fragment,{})})}),(0,react_jsx_runtime__rspack_import_0.jsx)("div",{style:{flexGrow:1},children:(0,react_jsx_runtime__rspack_import_0.jsx)(_CustomFormRow__rspack_import_3.A,{label:"Modified",helpText:"The value you modified",children:(0,react_jsx_runtime__rspack_import_0.jsx)(react_jsx_runtime__rspack_import_0.Fragment,{})})})]}),confirmModalVisible&&(0,react_jsx_runtime__rspack_import_0.jsx)(_elastic_eui__rspack_import_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__rspack_import_0.jsx)(react_jsx_runtime__rspack_import_0.Fragment,{})})]})});const __rspack_default_export=JSONDiffEditor;__webpack_require__.d(__webpack_exports__,{},{"default":__rspack_default_export})}}]);