Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.85/designer/js/definition-builder/source-builder/SourceBuilder",["module","exports","require","@frontend-taglib-clay$clayui/alert","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/layout","@frontend-taglib-clay$clayui/link","@frontend-taglib-clay$clayui/toolbar","frontend-editor-ckeditor-web","liferay!frontend-js-react-web$react","portal-workflow-kaleo-designer-web$react-flow-renderer","../DefinitionBuilderContext","../constants","./constants","./serializeUtil"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){const{currentEditor:e,definitionDescription:t,definitionName:n,elements:m,setCurrentEditor:p,setShowInvalidContentMessage:b,showInvalidContentMessage:w,version:E}=(0,f.useContext)(d.DefinitionBuilderContext),v=(0,f.useRef)(),[L,k]=(0,f.useState)(!1);(0,f.useEffect)((()=>{if(m){const a=(0,g.serializeDefinition)(y.xmlNamespace,{description:t,name:n,version:E},m.filter(c.isNode),m.filter(c.isEdge));a&&e&&e.setData(a)}}),[e,n,m,E]),(0,f.useEffect)((()=>{if(w)return document.addEventListener("keydown",(()=>{b(!1)})),()=>{document.removeEventListener("keydown",(()=>{b(!1)}))}}),[b,w]);const C=Liferay.Language.get("write-your-definition-or-x").substring(0,25),$=Liferay.Language.get("import-a-file").toLowerCase();return f.default.createElement(f.default.Fragment,null,f.default.createElement(o.default,{className:"source-toolbar"},f.default.createElement(r.default.ContainerFluid,null,f.default.createElement(o.default.Nav,null,f.default.createElement(o.default.Item,null,f.default.createElement("span",null,Liferay.Language.get("source"))),w&&f.default.createElement(o.default.Item,{className:"error ml-4"},f.default.createElement("span",null,Liferay.Language.get("please-enter-valid-content"))),f.default.createElement(o.default.Item,null,f.default.createElement("div",{className:"import-file"},f.default.createElement(l.default,{symbol:"document-code"}),f.default.createElement("span",null,C),f.default.createElement("label",{className:"pt-1",htmlFor:"fileInput"},f.default.createElement(i.default,{className:"ml-1"},"".concat($,"."))),f.default.createElement("input",{id:"fileInput",onChange:t=>function(t){b(!1);const n=t.target.files;if("text/xml"===n[0].type){const t=new FileReader;t.onloadend=t=>{t.target.readyState===FileReader.DONE&&(e.setData(t.target.result),document.querySelector("#fileInput").value="",k(!0))},t.readAsText(n[0])}}(t),type:"file"})))))),f.default.createElement(u.Editor,{config:s.editorConfig,onInstanceReady:({editor:e})=>{p(e),e.setMode("source")},ref:v}),L&&f.default.createElement(a.default.ToastContainer,null,f.default.createElement(a.default,{autoClose:5e3,displayType:"success",onClose:()=>k(!1),title:"".concat(Liferay.Language.get("success"),":")},Liferay.Language.get("definition-imported-successfully"))))};var a=p(n("@frontend-taglib-clay$clayui/alert")),l=p(n("@frontend-taglib-clay$clayui/icon")),r=p(n("@frontend-taglib-clay$clayui/layout")),i=p(n("@frontend-taglib-clay$clayui/link")),o=p(n("@frontend-taglib-clay$clayui/toolbar")),u=n("frontend-editor-ckeditor-web"),f=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=m();if(t&&t.has(e))return t.get(e);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in e)if(Object.prototype.hasOwnProperty.call(e,l)){var r=a?Object.getOwnPropertyDescriptor(e,l):null;r&&(r.get||r.set)?Object.defineProperty(n,l,r):n[l]=e[l]}n.default=e,t&&t.set(e,n);return n}(n("liferay!frontend-js-react-web$react")),c=n("portal-workflow-kaleo-designer-web$react-flow-renderer"),d=n("../DefinitionBuilderContext"),s=n("../constants"),y=n("./constants"),g=n("./serializeUtil");function m(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return m=function(){return e},e}function p(e){return e&&e.__esModule?e:{default:e}}}}));
//# sourceMappingURL=SourceBuilder.js.map