"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),r=require("@material-ui/core"),n=require("./utils.js"),u=require("react/jsx-runtime");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=a(e),i=r.makeStyles((function(){return{customTextarea:{display:"flex",flexWrap:"wrap",alignItems:"center",width:"442px",maxWidth:"442px",minHeight:"90px",overflowWrap:"anywhere",whiteSpace:"normal",margin:"-8px 0",padding:function(e){return e.isEmptyValue?"31px 24px 24px 16px":"16px 24px 16px 16px"},fontSize:"16px",lineHeight:"24px",borderRadius:"8px",outline:"0px",border:function(e){var t=e.color;return"1px solid ".concat(t)}}}}));exports.default=function(e){var r=e.initFormula,a=e.cursorPos,s=e.color,c=e.suggestions,l=e.isValueUpdated,p=e.setIsValueUpdated,f=e.onChange,d=t.useMemo((function(){return n.convertStringToEditorValue(r,c)}),[r,c]),x=t.useState(d),m=o.default(x,2),g=m[0],y=m[1],h=t.useMemo((function(){return n.getUpdatedHtmlValue(g)}),[g]),v=o.default(h,2),S=v[0],T=v[1],b=t.useRef(),E=t.useRef(!1),V=i({color:s,isEmptyValue:T});return t.useEffect((function(){l&&(E.current=!0,y(d),p(!1))}),[d,l]),t.useEffect((function(){n.setCaret(b.current,a),E.current&&b.current.focus()}),[S]),u.jsx("span",{ref:b,contentEditable:!0,onInput:function(e){var t=n.getCaret(b.current);y(e.target.innerHTML),f(n.convertEditorValueToString(e.target.innerHTML,c),t)},onKeyPress:function(e){13===e.charCode&&e.preventDefault()},className:V.customTextarea,dangerouslySetInnerHTML:{__html:S}})},exports.useStyles=i;
//# sourceMappingURL=FormulaTextEditor.js.map
