Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.115/designer/js/definition-builder/diagram-builder/components/sidebar/sections/timers/Timer",["module","exports","require","@frontend-taglib-clay$clayui/button","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../../../DiagramBuilderContext","./TimerAction","./TimerDuration","./TimerInfo"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=_interopRequireWildcard(r("@frontend-taglib-clay$clayui/button")),n=(_interopRequireDefault(r("liferay!frontend-js-react-web$prop-types")),_interopRequireWildcard(r("liferay!frontend-js-react-web$react"))),a=r("../../../../DiagramBuilderContext"),o=_interopRequireDefault(r("./TimerAction")),c=_interopRequireDefault(r("./TimerDuration")),l=_interopRequireDefault(r("./TimerInfo"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}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 r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var a=i?Object.getOwnPropertyDescriptor(e,n):null;a&&(a.get||a.set)?Object.defineProperty(r,n,a):r[n]=e[n]}return r.default=e,t&&t.set(e,r),r}var _default=({description:e,duration:t,durationScale:r,name:d,recurrence:u,recurrenceScale:s,sectionsLength:f,setContentName:m,setErrors:p,setTimerSections:y,timerActions:g,timerIdentifier:b,timersIndex:h})=>{const{selectedItem:w}=(0,n.useContext)(a.DiagramBuilderContext),[_,v]=(0,n.useState)((null==g?void 0:g.length)?g:[{actionType:"timerActions",identifier:"".concat(Date.now(),"-0")}]);(0,n.useEffect)((()=>{if(_.length){const e=[];_.forEach((t=>{Object.keys(t).filter((e=>"identifier"!==e&&"actionType"!==e)).length&&e.push(t)})),e.length&&y((t=>{const r=[...t],i=t.find((({identifier:e})=>e===b));return i.timerActions=e,r.splice(h,1,i),r}))}}),[_]);return n.default.createElement("div",{className:"panel"},n.default.createElement(l.default,{description:e,name:d,selectedItem:w,setTimerSections:y,timerIdentifier:b,timersIndex:h}),n.default.createElement(c.default,{duration:t,durationScale:r,recurrence:u,recurrenceScale:s,selectedItem:w,setTimerSections:y,timerIdentifier:b,timersIndex:h}),_.map(((e,t)=>n.default.createElement(o.default,{actionData:e,actionSectionsIndex:t,key:"section-".concat(e.identifier),reassignments:_.some((({actionType:e})=>"reassignments"===e)),sectionsLength:null==_?void 0:_.length,setActionSections:v,setContentName:m,setErrors:p,timersIndex:h}))),n.default.createElement("div",{className:"sheet-subtitle"}),n.default.createElement("div",{className:"autofit-float autofit-padded-no-gutters-x autofit-row autofit-row-center mb-3"},n.default.createElement("div",{className:"autofit-col"},n.default.createElement(i.default,{displayType:"secondary",onClick:()=>{y((e=>(e=>[...e,{identifier:"".concat(Date.now(),"-").concat(e.length)}])(e)))}},Liferay.Language.get("new-timer"))),f>1&&n.default.createElement("div",{className:"autofit-col autofit-col-end"},n.default.createElement(i.ClayButtonWithIcon,{className:"delete-button",displayType:"unstyled",onClick:()=>{y((e=>e.filter((e=>e.identifier!==b))))},symbol:"trash"}))))};t.default=_default}}));
//# sourceMappingURL=Timer.js.map