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