Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.98/designer/js/definition-builder/diagram-builder/util/populateNotificationsData",["module","exports","require","portal-workflow-kaleo-designer-web$react-flow-renderer","../../util/fetchUtil"],(function(e,i,t){window;Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var a=t("portal-workflow-kaleo-designer-web$react-flow-renderer"),n=t("../../util/fetchUtil");var _default=(e,i,t)=>{for(let o=0;o<i.length;o++){const r=i[o];if((0,a.isNode)(r)&&r.data.notifications){r.data.notifications.recipients.map(((a,r)=>{var s,l,d;if("roleId"===(null==a||null===(s=a.assignmentType)||void 0===s?void 0:s[0]))(0,n.retrieveRoleById)(a.roleId).then((e=>e.json())).then((e=>{i[o].data.notifications.recipients[r].sectionsData={id:e.id,name:e.name,roleType:e.roleType},t([...i])}));else if("roleType"===(null==a||null===(l=a.assignmentType)||void 0===l?void 0:l[0]))Promise.all([(0,n.retrieveRoles)(),(0,n.retrieveAccountRoles)(e)]).then((([e,a])=>Promise.all([e.json(),a.json()]).then((([e,a])=>{const n=e.items.concat(a.items);i[o].data.notifications.recipients[r].roleKey.forEach((e=>{const t=n.find((i=>i.externalReferenceCode===e||i.displayName===e));i[o].data.notifications.recipients[r].roleName||(i[o].data.notifications.recipients[r].roleName=[]),i[o].data.notifications.recipients[r].roleName.push(null==t?void 0:t.name)})),t([...i])}))));else if("user"===(null==a||null===(d=a.assignmentType)||void 0===d?void 0:d[0])&&(a.emailAddress||a.screenName||a.userId)){const e=[];let s=Object.keys(a)[1];const l=Object.values(a)[1];"screenName"===s?s="alternateName":"userId"===s&&(s=s.toLocaleLowerCase().replace("user","")),(0,n.retrieveUsersBy)(s,l).then((e=>e.json())).then((({items:i})=>{i.forEach(((i,t)=>{e.push({emailAddress:i.emailAddress,identifier:"".concat(Date.now(),"-").concat(t),name:i.name,screenName:i.alternateName,userId:i.id})}))})).then((()=>{i[o].data.notifications.recipients[r].sectionsData=e,t([...i])}))}}))}}};i.default=_default}));
//# sourceMappingURL=populateNotificationsData.js.map