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