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