Liferay.Loader.define("dynamic-data-mapping-form-field-type@6.0.145/RichText/RichText.es",["module","exports","require","frontend-editor-ckeditor-web","liferay!frontend-js-react-web$react","../FieldBase/ReactFieldBase.es"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r("frontend-editor-ckeditor-web"),a=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var i=n?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(r,a,i):r[a]=e[a]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),i=r("../FieldBase/ReactFieldBase.es");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function _objectWithoutProperties(e,t){if(null==e)return{};var r,n,a=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,a={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}const e=/alert\((.*?)\)/,o=/<%[\s\S]*?%>/g,l=/(<asp:[^]+>[\s|\S]*?<\/asp:[^]+>)|(<asp:[^]+\/>)/gi,c=/<[^>]+?(\s+\bon\w+=(?:'[^']*'|"[^"]*"|[^'"\s>]+))*\s*\/?>/gi,d=/innerHTML\s*=\s*.*?/,u=/(\s+\bon\w+=(?:'[^']*'|"[^"]*"|[^'"\s>]+))/gi,s=/<\?[\s\S]*?\?>/g;var _default=t=>{let{editable:r,editingLanguageId:f,editorConfig:p,id:g,name:y,onBlur:b,onChange:v,onFocus:O,predefinedValue:h="",readOnly:j,value:m,visible:w}=t,_=_objectWithoutProperties(t,["editable","editingLanguageId","editorConfig","id","name","onBlur","onChange","onFocus","predefinedValue","readOnly","value","visible"]);const L=(0,a.useRef)(),P=(0,a.useMemo)((()=>r?h:null!=m?m:h),[r,h,m]);function sanitizeHTML(t){return t.replace(c,(e=>e.replace(u,""))).replace(e,"").replace(d,"").replace(s,"").replace(o,"").replace(l,"")}return(0,a.useEffect)((()=>{var e;const t=null===(e=L.current)||void 0===e?void 0:e.editor;t&&(t.config.contentsLangDirection=Liferay.Language.direction[f],t.config.contentsLanguage=f,t.setData(P))}),[f,h]),a.default.createElement(i.FieldBase,_extends({},_,{id:g,name:y,readOnly:j,style:j?{pointerEvents:"none"}:null,visible:w}),a.default.createElement(n.ClassicEditor,{contents:P,editorConfig:p,name:y,onBlur:b,onChange:e=>{if(P!==e){const t=sanitizeHTML(e);v({target:{value:t}})}},onFocus:O,onSetData:({data:{dataValue:e},editor:{mode:t}})=>{if("source"===t){const t=sanitizeHTML(e);v({target:{value:t}})}},readOnly:j,ref:L}),a.default.createElement("input",{name:y,type:"hidden",value:P}))};t.default=_default}}));
//# sourceMappingURL=RichText.es.js.map