Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.115/designer/js/definition-builder/diagram-builder/components/sidebar/sections/assignments/CurrentAssignments",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/layout","@frontend-taglib-clay$clayui/link","liferay!frontend-js-react-web$react","../../../../../util/lang","../../../../DiagramBuilderContext","../utils","./select-assignment/SelectAssignment","./utils"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=n("@frontend-taglib-clay$clayui/button"),a=_interopRequireDefault(n("@frontend-taglib-clay$clayui/layout")),i=_interopRequireDefault(n("@frontend-taglib-clay$clayui/link")),o=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 n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var i=r?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(n,a,i):n[a]=e[a]}n.default=e,t&&t.set(e,n);return n}(n("liferay!frontend-js-react-web$react")),l=_interopRequireDefault(n("../../../../../util/lang")),s=n("../../../../DiagramBuilderContext"),u=n("../utils"),c=n("./select-assignment/SelectAssignment"),d=n("./utils");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}}function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach((function(t){_defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var _default=({assignments:e,setContentName:t})=>{var n;const{setSelectedItem:f}=(0,o.useContext)(s.DiagramBuilderContext),y=(0,d.getAssignmentType)(e),[p,g]=(0,o.useState)(null);return(0,o.useEffect)((()=>{if("resourceActions"===y){const t=e.resourceAction.split(/(?:,| )+/);g({assignmentsCount:t.length,firstName:t[0]})}else"roleId"===y?g({assignmentsCount:1,firstName:e.sectionsData.name}):"user"===y&&((0,u.sortElements)(e.sectionsData,"name"),g({assignmentsCount:e.sectionsData.length,firstName:e.sectionsData[0].name.split(" ")[0]}))}),[y,e]),o.default.createElement(a.default.ContentCol,{className:"current-node-data-area",float:!0},o.default.createElement(a.default.Row,{className:"current-node-data-row",justify:"between"},o.default.createElement(i.default,{button:!1,displayType:"secondary",href:"#",onClick:()=>t("assignments")},o.default.createElement("div",{className:"d-flex"},null===(n=c.options.find((e=>e.assignmentType===y)))||void 0===n?void 0:n.label,"assetCreator"!==y&&":",(()=>{if("assetCreator"===y)return[""];if(p){const e=[p.firstName||""];return 1!==p.assignmentsCount&&e.push(" "+l.default.sub(Liferay.Language.get("and-x-more"),[p.assignmentsCount-1])),e}if("roleType"===y){const t=e.roleName,n=[null==t?void 0:t[0]];return(null==t?void 0:t.length)>1&&n.push(" "+l.default.sub(Liferay.Language.get("and-x-more"),[(null==t?void 0:t.length)-1])),n}return[e[Object.keys(e)[1]]]})().map(((e,t)=>o.default.createElement("div",{className:"ml-2 truncate-container",key:t},e))))),o.default.createElement(r.ClayButtonWithIcon,{className:"delete-button text-secondary trash-button",disabled:!0,displayType:"unstyled",onClick:()=>{f((e=>_objectSpread(_objectSpread({},e),{},{data:_objectSpread(_objectSpread({},e.data),{},{assignments:null})})))},symbol:"trash"})))};t.default=_default}}));
//# sourceMappingURL=CurrentAssignments.js.map