Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.83/designer/js/definition-builder/source-builder/deserializeUtil",["module","exports","require","portal-workflow-kaleo-designer-web$react-flow-renderer","../constants","../util/utils","./constants","./utils","./xmlDefinition"],(function(e,t,i){var a;window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=u;var n=i("portal-workflow-kaleo-designer-web$react-flow-renderer"),s=i("../constants"),r=i("../util/utils"),o=i("./constants"),l=i("./utils"),d=(a=i("./xmlDefinition"))&&a.__esModule?a:{default:a};function u(e){this.definition=new d.default({value:e})}u.prototype={getElements(e){const t=[],i=[],a=[];return this.definition.forEachField(((e,t)=>{t.results.forEach((e=>{a.push(e.name)}))})),this.definition.forEachField(((d,u)=>{u.results.forEach((u=>{var c,f,p;(null===(c=u.actions)||void 0===c?void 0:c.length)&&(u.notifications=u.actions.filter((e=>{if(e.template)return e})),u.actions=u.actions.filter((e=>{if(e.script)return e})));const g={};let m=d;u.initial&&(m="start");const v=u.metadata&&JSON.parse(u.metadata);((null==v?void 0:v.terminal)||"state"===m&&!u.transitions&&!v)&&(m="end"),g.x=(null==v?void 0:v.xy[0])||Math.floor(800*Math.random()),g.y=(null==v?void 0:v.xy[1])||Math.floor(500*Math.random());let h={};var w;Array.isArray(u.labels)?null===(w=u.labels)||void 0===w||w.map((e=>{Object.entries(e).map((([e,t])=>{h[e]=(0,r.replaceTabSpaces)((0,r.removeNewLine)(t))}))})):h={[s.defaultLanguageId]:u.name};const b={description:u.description,label:h,script:u.script};let L;if("condition"===m&&(b.scriptLanguage=u.scriptLanguage||o.DEFAULT_LANGUAGE),"task"===m&&(u.assignments&&(b.assignments=(0,l.parseAssignments)(u)),u.taskTimers&&(b.taskTimers=(0,l.parseTimers)(u)),b.scriptLanguage=u.scriptLanguage||o.DEFAULT_LANGUAGE),b.actions=(null===(f=u.actions)||void 0===f?void 0:f.length)&&(0,l.parseActions)(u),b.notifications=(null===(p=u.notifications)||void 0===p?void 0:p.length)&&(0,l.parseNotifications)(u,e),u.id)L=u.id;else{if(!u.name)return;L=u.name}t.push({data:b,id:L,position:g,type:m}),u.transitions&&u.transitions.forEach((e=>{let o={};var l;Array.isArray(e.labels)?null===(l=e.labels)||void 0===l||l.map((e=>{Object.entries(e).map((([e,t])=>{o[e]=(0,r.replaceTabSpaces)((0,r.removeNewLine)(t))}))})):o={[s.defaultLanguageId]:e.name};let d;if(e.id)d=e.id;else{if(!e.name)return;d=e.name}i.includes(d)||a.includes(d)?d="".concat(L,"_").concat(d,"_").concat(e.target):i.push(d);const u=t.find((e=>(0,n.isEdge)(e)&&e.source===L&&e.data.defaultEdge));t.push({arrowHeadType:"arrowclosed",data:{defaultEdge:"true"===(null==e?void 0:e.default)||!u,label:o},id:d,source:L,target:e.target,type:"transition"})}))}))})),t},getMetadata(){return this.definition.getDefinitionMetadata()},updateXMLDefinition(e){this.definition=new d.default({value:e})}}}}));
//# sourceMappingURL=deserializeUtil.js.map