@boltic/swirl 1.0.2-uat.81 → 1.0.2-uat.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/swirl.es.js +2391 -2380
- package/dist/swirl.umd.js +1 -1
- package/package.json +1 -1
package/dist/swirl.umd.js
CHANGED
|
@@ -646,7 +646,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
646
646
|
`),we>0&&ht(wt)&&(Ye+=`
|
|
647
647
|
`)}),Ye},He=function(lt,Ye){je(Ye),Re.current=!0;var ht=_e.selection;if(!ht){var Ot=Fe(Ye);it.current=!1,lt?.(Ot);return}try{var wt=Le.node(_e,ht),we=wt[0],We=wt[1];if(!Xi.isElement(we)&&"text"in we)for(var Ze=we.text,De=Array.from(Ze.matchAll(Xe)),st=De.length-1;st>=0;st--){var yt=De[st],zt=yt[1].trim();if(zt){var cn=yt.index,Rn=cn+yt[0].length,hr={type:"chip",suggestion:{id:Date.now()+Math.random(),activityNumber:1,label:zt,value:zt,icon:C.createElement(Xn,{src:"ic_function",width:20,height:20,sx:{path:{fill:qe.palette.primary.main}}})},children:[{text:""}]};Ut.delete(_e,{at:{anchor:{path:We,offset:cn},focus:{path:We,offset:Rn}}}),Ut.insertNodes(_e,hr,{at:{path:We,offset:cn}}),Ut.move(_e)}}}catch{}var sr=Fe(Ye);it.current=!1,lt?.(sr),X?.({field:o,value:sr,fieldData:t})},dt=C.useCallback(function(Ke){ge(function(zt){var cn=zt.filter(function(Rn){return Rn.id!==Ke});return J?.(cn),cn});var lt=Array.from(Le.nodes(_e,{at:[],match:function(cn){var Rn;return Xi.isElement(cn)&&cn.type==="chip"&&((Rn=cn.suggestion)===null||Rn===void 0?void 0:Rn.id)===Ke}}))[0];if(lt){var Ye=lt[1],ht=pt.parent(Ye),Ot=Ye[Ye.length-1],wt=Le.node(_e,ht),we=wt[0],We=null,Ze=0;if(Ot>0){var De=we?.children[Ot-1];Xi.isElement(De)||(We=[].concat(ht,[Ot-1]),Ze=De.text.length)}We||(Ut.insertNodes(_e,{text:""},{at:[].concat(ht,[Ot])}),We=[].concat(ht,[Ot]),Ze=0),Ut.removeNodes(_e,{at:Ye});try{var st={path:We,offset:Ze},yt={anchor:st,focus:st};Ut.select(_e,yt),on.focus(_e)}catch{}}},[_e,J]),Tt=C.useCallback(function(Ke){Ke.key==="Enter"&&M==="xs"&&Ke.preventDefault()},[M]),Ie=C.useCallback(function(Ke){var lt={type:"chip",suggestion:Ke,children:[{text:""}]};Ut.insertNodes(_e,lt),Ut.move(_e);var Ye=_e.selection;if(Ye){var ht=Le.node(_e,Ye),Ot=ht[0];Xi.isElement(Ot)&&Ot.type==="chip"&&Ut.insertNodes(_e,{text:""})}},[_e]),at=function(lt){var Ye=[].concat(xe,[lt]);ge(Ye),J?.(Ye),Ie(lt)},ct=C.useCallback(function(Ke){Ke.preventDefault();var lt=Ke.clipboardData.getData("text/plain"),Ye=lt;M==="xs"&&(Ye=lt.replace(/\r?\n/g," "));try{var ht=JSON.parse(lt);typeof ht=="object"&&ht!==null&&"type"in ht&&"props"in ht||_e.insertText(Ye)}catch{_e.insertText(Ye)}},[_e,M]),nt=C.useCallback(function(Ke){Ke.preventDefault();var lt=_e.getFragment(),Ye="",ht=function(we){return!Xi.isElement(we)||we.type!=="paragraph"?!1:we.children.every(function(We){if("text"in We){var Ze=We.text||"";return Ze===""||Ze.trim()===""||Ze==="\uFEFF"||Ze===""||/^[\s\n\r]*$/.test(Ze)}return!1})},Ot=function(we){if(Xi.isElement(we)){if(we.type==="chip"){var We;return"{{"+(we==null||(We=we.suggestion)===null||We===void 0?void 0:We.label)+"}}"}else if(we.children){var Ze="";return we.children.forEach(function(De){Ze+=Ot(De)}),Ze}}else if("text"in we)return we.text;return""};lt.forEach(function(wt,we){var We=Ot(wt);Ye+=We,we<lt.length-1&&(Ye+=`
|
|
648
648
|
`),we>0&&ht(wt)&&(Ye+=`
|
|
649
|
-
`)}),Ke.clipboardData.setData("text/plain",Ye)},[_e]),Mt=C.useCallback(function(){ne(!0)},[ne]),Ht=C.useCallback(function(){ne(!1)},[ne]),St=C.useCallback(function(Ke){var lt=Ke.element,Ye=!1;if(lt.type==="chip"&&_e.selection)try{var ht=on.findPath(_e,lt),Ot=_e.selection;if(Ot&&!qt.isCollapsed(Ot)){var wt=qt.edges(Ot),we=wt[0],We=wt[1],Ze={path:ht,offset:0};Ye=pt.compare(Ze.path,we.path)>=0&&pt.compare(Ze.path,We.path)<=0}}catch{Ye=!1}switch(lt.type){case"chip":return C.createElement(bit,Object.assign({},Ke,{suggestion:lt.suggestion,onDelete:function(){return!V&&!v&&!_&&dt(lt.suggestion.id)},isSelected:Ye}));case"paragraph":return C.createElement(_it,Object.assign({},Ke,{size:M}));default:return C.createElement(Cit,Object.assign({},Ke,{size:M}))}},[dt,M,_e]),Me=C.useCallback(function(){try{var Ke=_e.children[0],lt=_e.children.length===1&&Xi.isElement(Ke)&&Ke.children.length===1&&"text"in Ke.children[0]&&Ke.children[0].text==="";return lt?"100%":"auto"}catch{return"auto"}},[_e]);return C.createElement(E.FormControl,{className:"meta-form-control "+u,sx:{width:"100%",maxWidth:"100%",position:"relative"},fullWidth:!0,key:o,ref:et},(f||Q)&&C.createElement(E.Stack,{direction:"row",justifyContent:"space-between",alignItems:q},C.createElement(Go,{className:"meta-select-label",required:P,description:O,label:f}),C.createElement(E.Typography,{sx:{fontSize:"0.75rem",lineHeight:"1.125rem",fontWeight:500},pb:4,color:"neutral.80"},Q)),C.createElement(E.Paper,{elevation:0,sx:an(an(an(an(an({border:"1px solid "+(pe&&$e?dr.error.main:dr.neutral.outlined.border),":hover":{borderColor:dr.text.primary}},Z&&{border:"1px solid "+qe.palette.primary.main,":hover":{borderColor:V||v||_?dr.text.secondary:qe.palette.primary.main}}),{},{display:"flex"},(V||v||_)&&rt&&{opacity:.4}),(V||v||_)&&{cursor:"not-allowed"}),{},{justifyContent:"center",gap:"1rem"},yit[M]),M!=="xs"&&R&&{resize:"vertical",overflowY:"auto",position:"relative","&::after":{content:'""',display:"block",position:"absolute",width:"18px",height:"18px",bottom:"2px",right:"2px",cursor:"nwse-resize",backgroundImage:"linear-gradient(135deg, transparent 0px, transparent 3px, "+qe.palette.grey[500]+" 3px, "+qe.palette.grey[500]+" 4px,)",pointerEvents:"none"}})},C.createElement(E.Box,{sx:an(an(an(an({flex:1,overflow:"auto"},M==="xs"&&{overflowX:"auto",overflowY:"hidden","-ms-overflow-style":"none","scrollbar-width":"none"}),R&&M!=="xs"?{height:"100%"}:{maxHeight:vit[M]}),{},{"&::-webkit-scrollbar":{display:"none"},'& [data-slate-node="text"]':{minWidth:"2px",minHeight:"16px",display:"inline-block",position:"relative",marginRight:"6px",width:Me}},M==="xs"&&{"&::-webkit-scrollbar":{display:"none"},'& [data-testid="paragraph-element"]::-webkit-scrollbar':{display:"none"}}),{},{'& [data-slate-node="text"]:empty::before, & [data-slate-zero-width="n"]::before':{content:'""',display:"inline-block",minWidth:"1px",minHeight:"16px",position:"relative"},'& [data-slate-placeholder="true"] [data-slate-node="text"]:empty::before, & [data-slate-placeholder="true"] [data-slate-zero-width="n"]::before':{display:"none !important"},'& [data-testid="paragraph-element"]':{marginBottom:M==="xs"?"0":"1px"},'& [data-testid="paragraph-element"]:not(:last-child)':{marginBottom:M==="xs"?"0":"2px"}})},C.createElement(Cs,{name:o,control:$,rules:vt(j)?{}:an(an({},j),{},{validate:function(lt){return/^\s*$/.test(lt)&&P?"Field cannot consist solely of spaces. Please include some characters.":lt&&h==="url"?hx(lt)?!0:"Enter a valid URL":lt&&h==="email"?Ax(lt)?!0:"Enter a valid email":!0}}),render:function(lt){var Ye=lt.field,ht=Ye.onChange,Ot=Za(Ye,Sit);return C.createElement(v7,Object.assign({editor:_e,initialValue:Te,onChange:function(we){return He(ht,we)}},Ot),C.createElement(E7,Object.assign({id:ae,renderElement:St,onKeyDown:Tt,onPaste:ct,onClick:function(we){return!V&&!v&&!_&&oe(we.currentTarget)},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",onCopy:nt,"data-testid":"suggestion-input-"+o,placeholder:b,readOnly:V||v||_,style:an({outline:"none",wordWrap:M==="xs"?"normal":"break-word",whiteSpace:M==="xs"?"pre":"pre-wrap",overflowWrap:M==="xs"?"normal":"break-word",fontWeight:500,fontSize:14,lineHeight:"20px",fontFamily:"Inter"},v&&{opacity:.45}),onFocus:Mt,onBlur:Ht},ue)))}})),W&&!V&&!v&&C.createElement(E.IconButton,{size:"small",onClick:function(lt){return oe(function(Ye){return Ye?null:lt.currentTarget})},"data-testid":"add-suggestion-btn",title:"Click to add dynamic values",sx:an({height:"1rem",width:"1rem",alignItems:"center",justifyContent:"center",padding:"0.5rem",border:"1px solid "+dr.neutral.outlined.border,borderRadius:"0.25rem"},M==="xs"&&{":hover":{backgroundColor:"transparent"}})},C.createElement(Xn,{src:"ic_plus",width:16,height:16}))),C.createElement(E.Stack,null,pe&&$e&&C.createElement(E.FormHelperText,{component:"span",error:!0,dangerouslySetInnerHTML:{__html:Eo($e)}})),C.createElement(Cte,{anchorEl:ve,setAnchorEl:oe,handleSuggestionClick:at,suggestionsData:z,ref:et,handleCustom:re,isLoading:le}))},bit=function(t){var n=t.attributes,r=t.children,i=t.suggestion,o=t.onDelete,s=t.isSelected,a=function(u){u.stopPropagation(),u.preventDefault(),o()};return C.createElement("span",Object.assign({},n,{contentEditable:!1,"data-testid":i?.label+"-chip",style:{display:"inline",marginRight:4}}),C.createElement(Oit,{suggestion:i,onDelete:a,isSelected:s}),r)},Cit=function(t){var n=t.attributes,r=t.children,i=t.size;return C.createElement("span",Object.assign({},n,{"data-testid":"default-element",style:an({minWidth:"2px",minHeight:"16px",display:"inline-block",position:"relative"},i==="xs"&&{flexWrap:"nowrap",gap:"2px 0"})}),r)},_it=function(t){var n=t.attributes,r=t.children,i=t.size;return C.createElement("div",Object.assign({},n,{"data-testid":"paragraph-element",style:an(an({margin:0,padding:0},i!=="xs"&&{display:"flex",flexWrap:"wrap"}),{},{gap:i==="xs"?"4px":"4px 0px",alignItems:"center",minHeight:"20px",position:"relative"},i==="xs"&&{overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",msOverflowStyle:"none"})}),r)},wit=function(t){var n=t.name,r=t.control,i=t.meta,o=t.onFocus,s=t.handleChange,a=t.validationRules,l=t.viewOnly,u=l===void 0?!1:l,c=t.MCP_INTEGRATION_FORM,f=i||{},p=f.displayName,h=p===void 0?"":p,A=f.value,g=A===void 0?!1:A,m=f.description,O=m===void 0?"":m,y=f.error,v=y===void 0?{}:y,T=f.readOnly,_=T===void 0?!1:T,x=f.isDisabled,b=x===void 0?!1:x,w=f.validation,D=w===void 0?{}:w,I=D.disabled,P=I===void 0?!1:I,k=D.required,N=k===void 0?!1:k,L=f.htmlProps,M=L===void 0?{}:L,B=f.htmlProps,Q=B===void 0?{}:B,U=Q.allowDynamic,q=U===void 0?!1:U,F=Eo(O),W=C.useState(!1),G=W[0],R=W[1];C.useEffect(function(){typeof g=="string"&&g==="true"?R(!0):typeof g=="boolean"&&R(g)},[]);var j=function(Y){o(Y,n)};return C.createElement(E.FormControl,{fullWidth:!0,error:v!=null&&v.hasError?!0:void 0,sx:{marginTop:"8px"}},C.createElement(Cs,{name:n,control:r,rules:a,defaultValue:G,render:function(Y){var z=Y.field,H=Y.fieldState,V=H===void 0?{}:H,X=V.error;return C.createElement(E.Stack,{spacing:"0.25rem"},C.createElement(E.Stack,{sx:{width:"100%",flexDirection:"row",alignItems:"center",justifyContent:q?"flex-end":"space-between"}},!q&&h&&C.createElement(Go,{required:N,label:h,description:F}),C.createElement(E.FormControlLabel,Object.assign({disabled:P,label:c?"":z.value?"On":"Off",labelPlacement:"start",control:C.createElement(E.Switch,Object.assign({},z,{onFocus:j,onChange:function(ee){var le=ee.target.checked;(!u||n==="advanced_options")&&(z.onChange(le),s({field:n,value:z.value,fieldData:t}))},onBlur:z.onBlur,value:z.value,checked:z.value,name:n,readOnly:_,disabled:b||u&&n!=="advanced_options","data-testid":"ripple-switch-"+n}))},M,{htmlFor:n}))),X?.message&&C.createElement(E.FormHelperText,{error:!!(X!=null&&X.message)},X?.message))}}))},kte=C.createContext({fieldControlStates:{},setFieldControlState:function(){},getFieldControlState:function(){return""},transformFormData:function(t,n){return n}}),Iit=function(t){var n=t.children,r=C.useState({}),i=r[0],o=r[1],s=function(c,f){o(function(p){var h;return an(an({},p),{},(h={},h[c]=f,h))})},a=function(c){return i[c]||""},l=function(c,f){if(!c||!f)return f;var p=an({},f);return c.forEach(function(h){var A,g,m,O,y=h.name,v=f[y],T=a(y);if(v?p[y]=v:(!T||T==="")&&!v?p[y]="BOLTIC_AI":["BOLTIC_AI","BOLTIC_AI_IGNORE"].includes(T)&&(p[y]=T),(h==null||(A=h.meta)===null||A===void 0?void 0:A.displayType)==="array"&&Array.isArray(v)&&(g=h.meta)!==null&&g!==void 0&&g.children)p[y]=v.map(function(x){var b;return l((b=h.meta)===null||b===void 0?void 0:b.children,x)});else if((h==null||(m=h.meta)===null||m===void 0?void 0:m.displayType)==="object"&&typeof v=="object"&&v!==null&&(O=h.meta)!==null&&O!==void 0&&O.children){var _;p[y]=l((_=h.meta)===null||_===void 0?void 0:_.children,v)}}),p};return C.createElement(kte.Provider,{value:{fieldControlStates:i,setFieldControlState:s,getFieldControlState:a,transformFormData:l}},n)},Mte=function(){return C.useContext(kte)},Dit=function(t){return function(r){var i,o,s,a,l=r.MCP_INTEGRATION_FORM,u=l===void 0?!1:l,c=r.name,f=c===void 0?"":c,p=r.MCP_EXCLUDED_FIELDS,h=p===void 0?[]:p,A=r.field,g=A===void 0?{}:A,m=r.handleChange,O=r.meta,y=O===void 0?{}:O,v=y.displayName,T=v===void 0?"":v,_=y.description,x=_===void 0?"":_,b=y.htmlProps,w=b===void 0?{}:b,D=ns(),I=D.setValue,P=w.showInfoIcon,k=P===void 0?!1:P,N=w.rightLabel,L=N===void 0?"":N,M=w.rightLabelAlignment,B=M===void 0?"center":M,Q=w.showAddNew,U=Q===void 0?!1:Q,q=Eo(x),F=ns(),W=(i=F.getValues)===null||i===void 0?void 0:i.call(F,f),G=Mte(),R=G.setFieldControlState,j=C.useState(u?"BOLTIC_AI":"specific"),$=j[0],Y=j[1];C.useEffect(function(){if(u){var V="BOLTIC_AI";["BOLTIC_AI","BOLTIC_AI_IGNORE"].includes(W)?V=W:W&&W!==""&&(V="specific"),Y(V),R(f,V)}},[]);var z=function(X){var J=X.target.value;Y(J),R(f,J),["BOLTIC_AI","BOLTIC_AI_IGNORE"].includes(J)?(I(f,J),m?.({field:f,value:J,fieldData:r})):(I(f,""),m?.({field:f,value:"",fieldData:r}))},H=an(an({},r.meta),{},{htmlProps:an(an({},r==null||(o=r.meta)===null||o===void 0?void 0:o.htmlProps),{},{rightLabel:"",showInfoIcon:!1}),validation:{infoDetail:{infoMsg:""}},displayName:""});return u&&!h.includes(f)&&!["array","object","section"].includes(f)&&!g.hidden&&!f.includes("toolParamsMcp")?C.createElement(E.Stack,{spacing:U||L?0:"0.5rem"},C.createElement(E.FormControl,{fullWidth:!0},(T||L||k)&&C.createElement(E.Stack,{direction:"row",justifyContent:"space-between",alignItems:B},C.createElement(Go,{required:r==null||(s=r.meta)===null||s===void 0||(a=s.validation)===null||a===void 0?void 0:a.required,label:T,description:q}),L&&C.createElement(E.Typography,{sx:{fontSize:"0.75rem",lineHeight:"1.125rem",fontWeight:500},pb:"0.25rem",color:"neutral.80"},L)),C.createElement(E.Select,{value:$,onChange:z,label:"Field Value Control"},C.createElement(E.MenuItem,{sx:{py:.8},value:"BOLTIC_AI"},"Have AI generate a value for this field"),C.createElement(E.MenuItem,{sx:{py:.8},value:"BOLTIC_AI_IGNORE"},"Do not include a value for this field"),C.createElement(E.MenuItem,{sx:{py:.8},value:"specific"},"Set a specific value for this field"))),$==="specific"&&C.createElement(t,Object.assign({},r,{meta:an({},H)}))):C.createElement(t,Object.assign({},r))}},oi={ACCORDION:"accordion",DIVIDER:"divider",SECTION:"section",TEXT:"text",SELECT:"select",RADIO:"radio",CHECKBOX:"checkbox",EMAIL:"email",NUMBER:"number",PASSWORD:"password",AUTOCOMPLETE:"autocomplete",FILE:"file",CODE:"code",BUTTON:"button",HIDDEN:"hidden",MULTITEXT:"multitext",TEXTAREA:"textarea",MULTISELECT:"multiselect",TOGGLE:"toggle",RADIOBUTTON:"radiobutton",ARRAY:"array",OBJECT:"object",PHONE:"phone",URL:"url",DATE:"date",TIME:"time",DATETIME:"datetime",KEYVALUE:"keyvalue",SLIDER:"slider"},Rit=function(t){var n,r=t.hidden,i=r===void 0?!0:r,o=t.meta,s=o===void 0?{}:o,a=s.displayType,l=a===void 0?"":a,u=s.displayName,c=u===void 0?"":u,f=s.htmlProps,p=f===void 0?{}:f,h=p.allowDynamic,A=h===void 0?!1:h,g=p.showInfoIcon,m=g===void 0?!1:g,O=p.rightLabel,y=O===void 0?"":O,v=p.size,T=v===void 0?"":v,_=p.overrideDynamicSupport,x=_===void 0?!1:_,b=s.validation,w=b===void 0?{}:b,D=w.infoDetail,I=D===void 0?{}:D,P=I.infoMsg,k=P===void 0?"":P,N=s.validation,L=N===void 0?{}:N,M=s.description,B=M===void 0?"":M,Q=s.readOnly,U=Q===void 0?!1:Q,q=t.suggestions,F=q===void 0?{}:q,W=t.viewOnly,G=W===void 0?!1:W,R=F&&Object?.keys(F),j=["email","password","url","number","code","text","textarea"],$=(A||j.includes(l))&&R?.length>0,Y=!["object"].includes(l),z=an(an({},t.meta),{},{htmlProps:an(an({},t==null||(n=t.meta)===null||n===void 0?void 0:n.htmlProps),{},{rightLabel:$&&Y?"":y,showInfoIcon:$&&Y?!1:m}),validation:an(an({},L),{},{infoDetail:{infoMsg:$&&Y?"":k}}),displayName:$&&Y?"":c}),H=ns(),V=H.getValues,X=H.setValue,J=H.watch,ee=C.useState("static"),le=ee[0],re=ee[1],ue=C.useRef(null),Oe=function(dt,Tt){if(Tt==="static"){var Ie;X(t.name,(t==null||(Ie=t.meta)===null||Ie===void 0?void 0:Ie.value)||"")}else{var at;X(t.name,String((t==null||(at=t.meta)===null||at===void 0?void 0:at.value)||""))}re(Tt)};C.useEffect(function(){var He=V(t.name);typeof He=="string"&&He.startsWith("{{")?re("dynamic"):re("static")},[]);var ve=J(t.name),oe=(A&&!["text","textarea"].includes(l)||["email","password","url","number"].includes(l))&&!["file","code"].includes(l)&&!x&&!G&&!U&&R.length>0,ae=function(dt,Tt){var Ie,at;return Tt===void 0&&(Tt="xs"),C.createElement(E.Stack,{className:"dynamic-wrapper"},C.createElement(E.FormControl,{fullWidth:!0,ref:ue},(A||["email","password","url","number","textarea","text"].includes(l))&&!["file","code"].includes(l)&&R?.length>0&&C.createElement(E.Stack,{alignItems:"flex-end",justifyContent:"space-between",direction:"row",pb:oe?"4px":0},(A||["email","password","url","number","textarea","text"].includes(l))&&!["file","code"].includes(l)&&R?.length>0&&C.createElement(Go,{className:"meta-select-label",required:t==null||(Ie=t.meta)===null||Ie===void 0||(at=Ie.validation)===null||at===void 0?void 0:at.required,label:c,description:B||k}),oe&&C.createElement(E.Tabs,{value:le,onChange:Oe,"aria-label":"select type",TabIndicatorProps:{sx:{display:"none"}}},crt.map(function(ct,nt){return C.createElement(E.Tab,{key:nt,label:ct.label,value:ct.value})}))),(le==="dynamic"&&l!==oi.CODE||["text","textarea"].includes(l))&&!x&&l!=="file"&&R&&R.length>0&&C.createElement(E.Stack,null,C.createElement(xit,Object.assign({},t,{suggestionsData:t.suggestions||{},meta:an(an({},t.meta),{},{displayName:"",htmlProps:an(an({},t.meta.htmlProps),{},{showSuggestions:!0,size:Tt,rightLabel:""}),validation:L}),validationRules:ve!=null&&ve.includes("{")?{}:t?.validationRules}))),(le!=="dynamic"||l===oi.CODE)&&(!["text","textarea"].includes(l)||["text","textarea"].includes(l)&&vt(F)||x)&&dt))};if(i||l==="hidden")return null;var te=function(dt,Tt,Ie){return C.createElement(nit,Object.assign({},t,{type:dt,htmlProps:Tt,textFieldProps:Ie,meta:z}))},Z=function(){var dt,Tt,Ie=(dt=t==null||(Tt=t.validation)===null||Tt===void 0?void 0:Tt.max)!=null?dt:"",at=Ie?{maxLength:Ie}:void 0;return te("text",at)},ne=function(){var dt={type:"password"};return te("password",dt)},se=function(){return te("email")},pe=function(){return te("number")},he=function(){return te("url")},de=function(){var dt,Tt,Ie=t.meta.htmlProps,at={multiline:!0,minRows:(dt=Ie?.minRows)!=null?dt:2,maxRows:(Tt=Ie?.maxRows)!=null?Tt:2};return te("text",{},at)},xe=function(){return C.createElement(pit,Object.assign({},t,{meta:z}))},ge=function(){return C.createElement(Ert,Object.assign({},t,{meta:z}))},Ee=function(){return C.createElement(mit,Object.assign({},t,{meta:z}))},ke=function(){return C.createElement(ait,Object.assign({},t,{meta:z}))},Ge=function(){return C.createElement(grt,Object.assign({},t))},$e=function(){return C.createElement(Jrt,Object.assign({},t))},et=function(){return C.createElement(Xrt,Object.assign({},t,{suggestionsData:t.suggestions||{},meta:an(an({},t.meta),{},{htmlProps:an(an({},t.meta.htmlProps),{},{showSuggestions:!0})})}))},rt=function(){return C.createElement(eit,Object.assign({},t))},it=function(){return C.createElement(hit,Object.assign({},t))},Re=function(){return C.createElement(qrt,Object.assign({},t))},Xe=function(){return C.createElement(wit,Object.assign({},t))},qe=function(){return C.createElement(fit,Object.assign({},t,{meta:z}))},Se=function(){return C.createElement(iit,Object.assign({},t,{meta:z}))},_e=function(){return C.createElement(Yrt,Object.assign({},t,{meta:z}))},be=function(){return C.createElement(dit,Object.assign({},t,{meta:z}))},K=function(){return C.createElement(Art,Object.assign({},t,{meta:z}))},ce=function(){return C.createElement(lit,Object.assign({},t,{meta:z}))},Te=function(){return C.createElement(rit,Object.assign({},t,{meta:z}))},je=function(){return C.createElement(Eit,Object.assign({},t,{meta:z}))},Fe=function(){return C.createElement(irt,Object.assign({},t,{meta:z}))};switch(l){case oi.TEXT:return ae(Z());case oi.PASSWORD:return ae(ne());case oi.EMAIL:return ae(se());case oi.NUMBER:return ae(pe());case oi.URL:return ae(he());case oi.RADIO:return ae(xe());case oi.RADIOBUTTON:return ae(qe());case oi.CHECKBOX:return ae(ge());case oi.CODE:return ae(et(),T||"md");case oi.TEXTAREA:return ae(de(),T||"sm");case oi.SELECT:case oi.AUTOCOMPLETE:return ae(Ee());case oi.MULTISELECT:return ae(ke());case oi.BUTTON:return ae(Ge());case oi.TOGGLE:return ae(Xe());case oi.MULTITEXT:return ae(Se());case oi.HIDDEN:return rt();case oi.FILE:return ae($e());case oi.SECTION:return ae(it());case oi.DIVIDER:return ae(Re());case oi.PHONE:return ae(be());case oi.DATE:return ae(_e());case oi.TIME:return ae(_e());case oi.DATETIME:return ae(_e());case oi.ARRAY:return ae(K(),T||"md");case oi.OBJECT:return ae(ce(),T||"md");case oi.KEYVALUE:return ae(Te(),T||"md");case oi.SLIDER:return ae(je());case oi.ACCORDION:return ae(Fe());default:return C.createElement(E.Box,null,"Display Type: ",l," is not supported!")}},XA=Dit(C.memo(Rit)),Pit=function(t,n){var r=C.useState(t),i=r[0],o=r[1],s=C.useCallback(function(a){return a?.map(function(l){var u,c=l?.meta||{},f=c.dependencies;if(f){var p=f.logic,h=p===void 0?"AND":p,A=f.conditions,g=A===void 0?[]:A,m=h==="AND";g.forEach(function(y){var v,T=y.operator,_=y.field,x=y.value,b=!1,w=art(n,_)||(l==null||(v=l.meta)===null||v===void 0?void 0:v.value);switch(T){case"EQUALS":b=w===x;break;case"NOT_EQUALS":b=w!==x;break;case"GREATER_THAN":b=w>x;break;case"LESS_THAN":b=w<x;break;case"GREATER_THAN_OR_EQUALS":b=w>=x;break;case"LESS_THAN_OR_EQUALS":b=w<=x;break;case"CONTAINS":b=Array.isArray(w)?w.includes(x):w?.toString().includes(x);break;case"NOT_CONTAINS":b=Array.isArray(w)?!w.includes(x):!(w!=null&&w.toString().includes(x));break;case"STARTS_WITH":b=w?.toString().startsWith(x);break;case"ENDS_WITH":b=w?.toString().endsWith(x);break;case"REGEX":b=new RegExp(x).test(w?.toString());break;case"NOT_REGEX":b=!new RegExp(x).test(w?.toString());break;case"EMPTY":b=!w;break;case"NOT_EMPTY":b=!!w;break}m=h==="AND"?m&&b:m||b}),l.hidden=!m}if(["array","object","section"].includes(l==null||(u=l.meta)===null||u===void 0?void 0:u.displayType)){var O;l!=null&&(O=l.meta)!==null&&O!==void 0&&O.children&&(l.meta.children=s(l?.meta.children||[]))}return l})},[n]);return C.useEffect(function(){o(s(t))},[t,n,s]),i},Nit=function(t){var n=t.reduce(function(r,i){return r[i.key]=i.value,r},{});return n},gx=function(t,n){return t.forEach(function(r){var i,o;if(["object","array","section"].includes((i=r.meta)===null||i===void 0?void 0:i.displayType))if(["configure","setup"].includes(r?.name)){var s;gx((s=r.meta)===null||s===void 0?void 0:s.children,n)}else{var a=n[r.name];if(a){var l;gx((l=r.meta)===null||l===void 0?void 0:l.children,a)}}else((o=r.meta)===null||o===void 0?void 0:o.displayType)==="keyvalue"&&Array.isArray(n[r.name])&&(n[r.name]=Nit(n[r.name]))}),n},Lit=C.forwardRef(function(e,t){var n=e.name,r=e.schema,i=r===void 0?[]:r,o=e.form,s=o===void 0?{}:o,a=e.suggestions,l=e.onChange,u=e.onSubmit,c=e.onFocus,f=e.onCustom,p=e.buttonSchema,h=e.loading,A=e.onCancel,g=e.sx,m=e.isLoading,O=m===void 0?!1:m,y=e.useDefaultButtons,v=y===void 0?!0:y,T=e.viewOnly,_=T===void 0?!1:T,x=e.MCP_INTEGRATION_FORM,b=x===void 0?!1:x,w=e.MCP_EXCLUDED_FIELDS,D=w===void 0?[]:w,I=an({},s),P=Mte(),k=P.transformFormData,N=C.useMemo(function(){var X;return(X=SE(i,I))!=null?X:{}},[i,I]),L=rJe({values:N,mode:"all"}),M=QJ({control:L.control,defaultValue:N}),B=C.useState(i),Q=B[0],U=B[1],q=C.useMemo(function(){return i},[i,n]),F=C.useMemo(function(){return M},[M,n]),W=zA(i),G=Pit(q,F);C.useEffect(function(){U(G)},[G,n]);var R=C.useCallback(function(X){c&&c(X)},[c]),j=C.useCallback(function(){A&&A()},[A]),$=C.useCallback(function(X){if(l){var J=L.getValues(),ee=L.getValues(X.field),le=an(an({},X),{},{value:ee});l(le,J)}},[l,L,M]),Y=C.useCallback(function(X){return X===void 0&&(X=""),function(J){var ee=gx(i,J);if(b&&(ee=k(i,ee)),u){var le=gx(i,J);u(le,X)}}},[u,i,k,b]),z=C.useCallback(function(X,J,ee){if(J===void 0&&(J={}),ee===void 0&&(ee=""),f){var le=L.getValues();f(X,an(an({},le),J),ee)}},[f,M]),H=C.useCallback(function(){try{return Promise.resolve(L.trigger()).then(function(X){return!!X})}catch(X){return Promise.reject(X)}},[L,Q]);C.useImperativeHandle(t,function(){return{handleSubmit:function(J){var ee;J===void 0&&(J=""),(ee=L.handleSubmit(Y(J)))===null||ee===void 0||ee()},getValues:L.getValues,isValidated:function(){try{return Promise.resolve(H())}catch(X){return Promise.reject(X)}}}});var V=C.useRef(!1);return C.useEffect(function(){if(!(V.current||!l)){V.current=!0;var X=function(le){le===void 0&&(le=[]);var re=[];return le.forEach(function(ue){var Oe,ve,oe=ue==null||(Oe=ue.meta)===null||Oe===void 0?void 0:Oe.children;oe&&Array.isArray(oe)?re.push.apply(re,X(oe)):(ue==null||(ve=ue.meta)===null||ve===void 0?void 0:ve.displayType)==="hidden"&&re.push(ue)}),re},J=X(i);J.forEach(function(ee){$({field:ee.name,fieldData:ee})})}},[i,l,$]),C.createElement(VZe,Object.assign({},L),C.createElement("form",{key:n,name:"ripple-form",className:"ripple-form",noValidate:!0,style:an({display:"flex",flexDirection:"column",height:"100%"},g)},C.createElement(E.Stack,{gap:1,alignItems:"center",sx:{overflowY:"auto",flexGrow:1},className:"ripple-form-container",width:"100%"},Q&&Q.length>0&&Q.map(function(X,J){var ee,le;return C.createElement(E.Stack,{width:"100%",key:X?.name+"::"+J+"::"+n,sx:{display:(X==null||(ee=X.meta)===null||ee===void 0?void 0:ee.displayType)==="hidden"||X?.hidden===!0?"none":"flex"}},C.createElement(ert,{fieldName:X?.name},C.createElement(XA,Object.assign({},X,{isLoading:O,field:X,hidden:X?.hidden||!1,control:L.control,handleChange:$,onFocus:R,handleCustom:z,viewOnly:_,validationRules:["object","array","keyvalue"].includes(X==null||(le=X.meta)===null||le===void 0?void 0:le.displayType)?W:W[X?.name],suggestions:a,MCP_INTEGRATION_FORM:b,MCP_EXCLUDED_FIELDS:D}))))}),C.createElement(E.Stack,{width:"100%",alignItems:"center"},O&&C.createElement(E.CircularProgress,null))),v&&C.createElement(trt,{buttonSchema:p,onSubmit:function(J){return L.handleSubmit(Y(J))()},onReset:function(){return L.reset()},onCancel:j,loading:h||O,style:{flexShrink:0}})))}),Ex=C.forwardRef(function(e,t){var n=C.useRef(null);return C.useImperativeHandle(t,function(){var r;return{handleSubmit:function(o){var s,a;o===void 0&&(o=""),n==null||(s=n.current)===null||s===void 0||(a=s.handleSubmit)===null||a===void 0||a.call(s,o)},isValidated:n==null||(r=n.current)===null||r===void 0?void 0:r.isValidated}}),C.createElement(Iit,null,C.createElement(Lit,Object.assign({},e,{ref:n})))});const kit=(e,t,n)=>{const r=[Zn.WORKFLOW_EXECUTION_COMPLETED,Zn.ACTIVITY_TASK_COMPLETED],i=[Zn.ACTIVITY_TASK_FAILED,Zn.ACTIVITY_TASK_TIMED_OUT,Zn.WORKFLOW_EXECUTION_FAILED,Zn.WORKFLOW_EXECUTION_TIMED_OUT,Zn.WORKFLOW_EXECUTION_TERMINATED,Zn.WORKFLOW_EXECUTION_CANCELED,Zn.WORKFLOW_TASK_TIMED_OUT];{if(r.includes(e))return n.palette.success.main;if(i.includes(e))return n.palette.error.main}},CE=e=>{const t=[Zn.WORKFLOW_EXECUTION_COMPLETED,Zn.WORKFLOW_EXECUTION_FAILED,Zn.WORKFLOW_EXECUTION_TIMED_OUT,Zn.WORKFLOW_EXECUTION_TERMINATED,Zn.WORKFLOW_EXECUTION_CANCELED,Zn.WORKFLOW_EXECUTION_TERMINATED,Zn.WORKFLOW_TASK_FAILED,Zn.WORKFLOW_TASK_TIMED_OUT];return e?e.some(n=>t.includes(n.eventType)):[]};function Mit(e){const t=e.eventType.replace(/_/g," ").replace("EVENT TYPE","").replace(/\w\S*/g,n=>n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()).trim();if(e.eventType===Zn.ACTIVITY_TASK_SCHEDULED&&e.activityTaskScheduledEventAttributes){const n=e.activityTaskScheduledEventAttributes?.input?.payloads?.[0]?.data?.name;return n?`${t}: ${n}`:t}return t}function Fit(e){if(e==null||typeof e!="object"||Array.isArray(e))return e;const{isBranch:t,branchToExecute:n,...r}=e;return r}const Ox=e=>{if(!(typeof e=="string"||e instanceof String))return;const t=e.match(/\{\{([^{}]+)\}\}/);if(t)return t[1].trim()},Bit=(e,t)=>new Promise((n,r)=>{const i=t.split(".");let o=e;for(const[s,a]of i.entries())if(a.includes("[")){let l,u;if(!a.includes("]"))throw l=a.split("["),u=l[0],r(`Invalid Syntax while using ${u}`),new Error(`Invalid Syntax while using ${u}`);l=a.split("["),u=l[0];const c=parseInt(l[1].replace("]",""));if(!Array.isArray(o[u]))throw r(`${u} should be an array, found ${typeof o[u]}`),new Error(`${u} should be an array, found ${typeof o[u]}`);if(isNaN(c)||c<0)throw r(`Invalid array index for ${a}`),new Error(`Invalid array index for ${a}`);if(c>=o[u].length)throw r(`Invalid array index: ${a}, Max length of ${u} is ${o[u].length}`),new Error(`Invalid array index: ${a}, Max length of ${u} is ${o[u].length}`);o=o[u][c]}else if(a==="uuid4()")o=Z3();else if(o=o[a],o&&s<i.length-1&&Array.isArray(o)){if(i.includes("length")&&i[i.length-1]==="length")continue;throw r(`Invalid Syntax, Use ${a}[${s}]`),new Error(`Invalid Syntax, Use ${a}[${s}]`)}n(o)}),jit=async(e,t)=>{if(typeof e!="string")return e;const n=/{{([^{}]*)}}/g,r=[];let i;for(;(i=n.exec(e))!==null;)r.push(i);for(const o of r){const s=o[1],a=await Bit(t,s),l=a!==void 0?typeof a=="object"?JSON.stringify(a):a.toString():"";e=e.replace(o[0],l)}return e},m8=async(e,t)=>{const n=Array.isArray(e)?[]:{};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const i=e[r];typeof i=="object"&&i!==null?n[r]=await m8(i,t):typeof i=="string"?n[r]=await jit(i,t):n[r]=i}return n},g8=[{name:"activity_name",meta:{displayName:"Custom Name",displayType:"hidden",placeholder:"Enter the custom name",validation:{required:!0},value:""}},{name:"integration_slug",meta:{displayName:"Integration Slug",displayType:"hidden",placeholder:"Enter the integration slug",validation:{required:!0},value:""}}],$it=[{name:"advanced_options",meta:{displayName:"Advanced Options",displayType:"accordion",htmlProps:{headerVariant:"smSemiBold"},children:[{name:"continue_on_failure",meta:{displayName:"Continue on Failure",displayType:"toggle",description:"When enabled, a failure handle appears on this node. If this node fails, workflow continues through the failure path. If disabled and this node fails, the entire workflow stops.",value:!1,readOnly:!1}},{name:"retry_config",meta:{displayType:"object",children:[{name:"maximum_attempts",meta:{displayName:"Maximum Number of Attempts",displayType:"number",placeholder:"Enter the maximum number of tries",description:"The maximum number of times to try the activity, including the first attempt. If set to 3, the activity will run at most 3 times.",validation:{required:!0},htmlProps:{allowDynamic:!1,overrideDynamicSupport:!0},value:1,dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}},{name:"backoff_coefficient",meta:{displayName:"Retry Backoff Rate",displayType:"number",placeholder:"Enter the wait time between tries",description:"Constants factor by which the time delay between the retry attempts increase after the each failure",validation:{required:!0},htmlProps:{allowDynamic:!1,overrideDynamicSupport:!0},value:2,dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}},{name:"initial_interval",meta:{displayName:"Wait Time Before First Retry (seconds)",displayType:"number",placeholder:"Enter the initial wait time",description:"The time to wait before the first retry after a failure. For example, if set to 5 seconds, the first retry will occur 5 seconds after the failure.",validation:{required:!0},htmlProps:{overrideDynamicSupport:!0,allowDynamic:!1},value:1e3,dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}},{name:"maximum_interval",meta:{displayName:"Maximum Wait Between Retries (seconds)",displayType:"number",placeholder:"Enter the maximum wait time",description:"The longest time to wait between retries, regardless of backoff. Prevents the delay from growing indefinitely.",validation:{required:!0},htmlProps:{overrideDynamicSupport:!0,allowDynamic:!1},value:1e5,dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}}],dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}},{name:"maximum_timeout",meta:{displayName:"Maximum Activity Completion Timeout in (m/s)",displayType:"number",placeholder:"Enter the maximum timeout",description:"Maximum time to wait for the Activity to complete",validation:{required:!0},value:6e4,htmlProps:{overrideDynamicSupport:!0,allowDynamic:!1},dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}}],dependencies:{conditions:[{field:"secret",operator:"NOT_EMPTY"},{field:"resource",operator:"NOT_EMPTY"},{field:"operation",operator:"NOT_EMPTY"}]}}}],yx=async(e,t)=>{const{url:n,method:r,body:i}=e,o=r,s=i&&await m8({body:i},{parameters:t}),a={};s&&(o==="post"||o==="put"||o==="patch")&&(a.data=s.body);const{data:l}=await Xt[o](n,a);return l},Uit=async(e,t,n,r,i,o)=>{const{integration_id:s,resource:a,operation:l,integration_slug:u}=e,c=[];if(!s&&!u)throw new Error("integration_slug or integration_id is required in payload");const p=[n,"v1.0",r,"integrations",u||s],h=Yt(...p,"configuration"),{data:A}=await Xt.get(h),g=A.data.content.parameters;if(c.push(...g),a&&p.push("resource",a),!vt(a)){const m=Yt(...p),{data:O}=await Xt.get(m);if(!O.data.content.parameters)throw new Error("No integration schema data found");c.push(...O.data.content.parameters)}if(!vt(a)&&!vt(l)){l&&p.push("operation",l);const m=Yt(...p),{data:O}=await Xt.get(m),y=O?.data?.content;if(!y)throw new Error("No Operation schema found");if(y?.config){const{method:v,urlType:T,body:_,condition:x}=y.config;if(x){const b=Ox(x);if(b){const w=b.split(".")[1];if(t?.[w]){let{url:D}=y.config;D=Yt(n,"v1.0",r,D);const I={..._,...u&&{integration_slug:u},...s&&{integration_id:s}},P=Object.assign({},{url:D,method:v,urlType:T,body:I}),k=await yx(P,t);c.push(...y.parameters,...k)}else c.push(...y.parameters)}}else{let{url:b}=y.config;b=Yt(n,"v1.0",r,b);const w={..._,...u&&{integration_slug:u},...s&&{integration_id:s}},D=Object.assign({},{url:b,method:v,urlType:T,body:w}),I=await yx(D,t);c.push(...y.parameters,...I)}}else c.push(...y.parameters)}return i||o?c.push(...g8):c.push(...g8,...$it),c},Hit=async(e,t,n,r)=>{const{integration_id:i,resource:o="webhook",operation:s,integration_slug:a}=e,l=[];let u;if(!i&&!a)throw new Error("integration_slug or integration_id is required in payload");const f=[n,"v1.0",r,"integrations",a||i];if(o&&o==="webhook"){f.push("webhook");const p=Yt(...f),{data:h}=await Xt.get(p);if(u=h.data.content,!u)throw new Error("No integration schema data found");l.push(...u.parameters)}if(!vt(o)&&!vt(s)){if(u?.config){const{method:h,urlType:A,body:g,condition:m}=u.config;if(m){const O=Ox(m);if(O){const y=O.split(".")[1];if(t?.[y]){let{url:v}=u.config;v=Yt(n,"v1.0",r,v);const T={...g,...a&&{integration_slug:a},...i&&{integration_id:i}},_=Object.assign({},{url:v,method:h,urlType:A,body:T}),x=await yx(_,t);l.push(...u.parameters,...x)}else l.push(...u.parameters)}}else{let{url:O}=u.config;O=Yt(n,"v1.0",r,O);const y={...g,...a&&{integration_slug:a},...i&&{integration_id:i}},v=Object.assign({},{url:O,method:h,urlType:A,body:y}),T=await yx(v,t);l.push(...u.parameters,...T)}}const p=u[s]?.parameters;l.push(...p)}return l.push(...g8),{data:l,polling_interval:u?.polling_interval}},vx=({formData:e,isLoop:t=!1,selectedNode:n,INTEGRATION_DATA:r,SET_INTEGRATION_DATA:i,onClose:o,openIntegrationDrawer:s,handleRunActivity:a,handleCompleteSetup:l,setPollingInterval:u,onSubmit:c,source:f="",MCP_INTEGRATION_FORM:p=!1})=>{const[h,A]=C.useState([]),[g,m]=C.useState({}),[O,y]=C.useState(!1),[v,T]=C.useState({headers:{},query:"",variables:{}}),_=C.useRef(!1),x=C.useRef(null),b=gt.useDispatch(),[w,D]=C.useState(!1),{WORKFLOW_URLS:I,ENTITY_ID:P=""}=Ci(),{VORTEX_MAIN_URL:k,TESSERACT_MAIN_URL:N,FRONTEND_URL:L}=I,M=n?.data?.type,B=n?.data?.properties?.activity_name,Q=n?.data?.properties?.activity_id,U=n?.data?.properties?.integration_slug,q=re=>{if(!re)return{};if(typeof re=="string")try{const ue=JSON.parse(re);return typeof ue=="object"&&ue!==null?ue:{}}catch{return{}}return typeof re=="object"?re:{}},F=(re,ue)=>{m(Oe=>{const ve={...Oe,[re]:ue};return Oe?.properties&&typeof Oe.properties=="object"&&(ve.properties={...Oe.properties,[re]:ue}),ve})},W=()=>{y(!1),T({headers:{},query:"",variables:{}})},G=re=>{F("query",re),T(ue=>({...ue,query:re}))},R=re=>{T(ve=>({...ve,variables:re}));const Oe=typeof g?.variables=="string"&&typeof re!="string"?JSON.stringify(re,null,2):re;F("variables",Oe),W()},j=()=>O?d.jsx(So,{open:O,handleClose:W,title:"GraphQL Inspector",subtitle:"Explore the GraphQL schema and build queries by selecting fields",icon:d.jsx(Ue,{src:"ic_schema"}),sx:{".MuiDialogContent-root":{padding:"16px 24px !important"}},content:d.jsx(_J,{form:g,headers:C4(v.headers||{}),currentQuery:v.query||"",onQueryUpdate:G,onVariablesUpdate:R})}):null,$=async re=>{if(x.current!==re){x.current=re;try{const ue=Yt(N,`/v1/integrations/${re}/validate-token`),Oe=await Xt.get(ue),{data:ve}=Oe.data;if(ve){const{is_revoked:oe}=ve;if(_.current!==oe&&(_.current=oe,h.length>0)){const ae=h.map(te=>te.name==="secret"?{...te,meta:{...te.meta,htmlProps:{...te.meta.htmlProps,showReconnect:oe}}}:te);A(ae)}}}catch(ue){dn(ue,b)}}},Y=async()=>{if(g.secret)if(s)s({_id:g.secret},"edit");else{const re=`${L}/accounts/${P}/integrations/destination/new-destination/${g.secret}/edit`;window.open(re)}},z=async({resource:re,operation:ue,currentFormData:Oe={},schema:ve=[]})=>{try{let oe=ve;if(M!==Je.SERVERLESS){D(!0);const Z={...U&&{integration_slug:U},...Q&&{integration_id:Q},...ue&&{operation:ue},...re&&{resource:re}};let ne={};if(vt(Oe)?ne=vt(g)?e.properties:g:ne=Oe,M===Je.CLOUD_TRIGGER){const{data:se,polling_interval:pe}=await Hit(Z,ne,k,P);oe=se,u&&u?.(pe)}else oe=await Uit(Z,ne,k,P,t,p)}let ae=oe;const te=async(Z,ne=[])=>{if(f?.includes("commerce_")&&M===Je.PLATFORM_FDK_ACTIVITY){const se=f?.split("_"),pe=se&&se.length>1?se[1]:null,he=se&&se.length>2?se.slice(2).join("_"):pe;ae=ae?.map(de=>de.name==="secret"?(delete de.meta.config,{...de,meta:{...de.meta,options:[{value:f,label:he}],value:f,isDisabled:!0,htmlProps:{...de.meta.htmlProps,showReconnect:_.current}}}):de)}for(const se of Z){if((se?.meta?.displayType==="select"||se?.meta?.displayType==="autocomplete"||se?.meta?.displayType==="multiselect")&&se?.meta?.config?.url){const{method:pe,labelKey:he,valueKey:de,urlType:xe,body:ge,condition:Ee}=se.meta.config;let{url:ke}=se.meta.config;xe==="secret"?ke=Yt(N,"v1/integrations/entity",ke):xe==="options"&&(ke=Yt(k,"v1.0",P,ke));const Ge={...ge,...Q&&{integration_id:Q},...U&&{integration_slug:U}},$e=Object.assign({},{url:ke,method:pe,labelKey:he,valueKey:de,body:Ge});if(Ee){const et=Ox(Ee);if(et){const rt=et.split(".")[1];(g[rt]||e?.properties?.[rt])&&(ae=await V(se.name,$e,ae,[...ne,se.name]))}}else ae=await V(se.name,$e,ae,[...ne,se.name])}se?.meta?.children&&se?.meta?.children?.length>0&&await te(se?.meta?.children,[...ne,se.name])}};await te(ae),_.current&&(M===Je.CLOUD_TRIGGER||M===Je.CUSTOM_ACTIVITY)&&(ae=ae.map(Z=>(Z.name==="secret"&&(Z.meta.htmlProps={...Z.meta.htmlProps,showReconnect:_.current}),Z))),A(ae)}catch(oe){dn(oe,b)}finally{D(!1)}},H=async()=>{const re=Yt(k,"v1.0",P,"integrations",U,"configuration"),ue={advanced_options:!0};Xt.get(re,{params:ue}).then(async({data:Oe})=>{if(t){const ve=Oe.data.content.parameters.filter(oe=>!["advanced_options","maximum_attempts","backoff_coefficient","initial_interval","maximum_interval","maximum_timeout"].includes(oe.name));await z({schema:ve})}else await z({schema:Oe.data.content.parameters})})},V=async(re,ue,Oe,ve=[])=>{D(!0);try{const{url:oe,method:ae,labelKey:te,valueKey:Z,body:ne}=ue,se=ae,pe=ne&&await m8({body:ne},{parameters:vt(g)?e.properties:g}),he={};pe&&(se==="post"||se==="put"||se==="patch")&&(he.data=pe.body);const de=await Xt[se](oe,he),ge=(re==="secret"?de.data.data:de.data)?.map(ke=>({value:ke[Z],label:ke[te]}));let Ee=[];if(ve?.length===0)Ee=Oe?.map(ke=>ke.name===re?{...ke,meta:{...ke.meta,options:ge}}:ke);else{Ee=Oe;const ke=(Ge,$e,et,rt=0)=>{Ge.forEach(it=>{it.name===$e[rt]&&(rt===$e.length-1?it.meta={...it.meta,options:et}:it?.meta?.children&&it?.meta?.children?.length>0&&ke(it?.meta?.children,$e,et,rt+1))})};ve?.length>0&&ke(Ee,ve,ge)}return Ee}catch(oe){return dn(oe,b),Oe}finally{D(!1)}};return C.useEffect(()=>{if(x.current=null,_.current=!1,M===Je.SERVERLESS)H();else{async function re(){n&&(A([]),await z({}))}re()}},[n.id,B,Q,U]),C.useEffect(()=>{async function re(){if(r?._id&&r?.meta?.entity===B.toUpperCase()){r?.meta?.auth_status==="ACTIVE"&&(_.current=!1),M===Je.SERVERLESS?await z({schema:h}):await z({});const ue={maximum_attempts:1,backoff_coefficient:2,initial_interval:1e3,maximum_interval:1e5},Oe={...g?.activity_id&&{activity_id:g.activity_id},...U&&{integration_slug:U},...g?.activity_name&&{activity_name:g.activity_name},...M!==Je.CLOUD_TRIGGER?{maximum_timeout:6e4,retry_config:ue}:{}};m({...Oe,secret:r._id})}}re()},[r]),C.useEffect(()=>{const re=async()=>{const{secret:ue,resource:Oe,operation:ve}=e.properties;if(M===Je.SERVERLESS)vt(ue)||await z({schema:h});else if(e?.properties||!vt(ue)){if(M===Je.SERVERLESS&&!vt(ue))await z(h);else if(vt(Oe)||await z({resource:Oe}),!vt(ve)){const[oe,ae]=ve.split(".");await z({resource:oe,operation:ae})}}};vt(e.properties)||(m(e.properties),e.properties.secret&&(M===Je.CLOUD_TRIGGER||M===Je.CUSTOM_ACTIVITY)&&$(e.properties.secret),re())},[e]),C.useEffect(()=>{if(p&&h.length>0){const re=(ue,Oe="")=>{const ve={...g};ue.forEach(oe=>{const ae=oe.name,te=Oe?`${Oe}.${ae}`:ae;if(Zd.includes(ae)||Zd.some(ne=>te.includes(ne)))return;g[ae]||(oe.meta?.displayType==="array"?ve[ae]=["BOLTIC_AI"]:oe.meta?.displayType!=="object"&&(ve[ae]="BOLTIC_AI"));const Z=[];h.forEach(ne=>{ne.meta?.displayType!=="hidden"&&!Zd.includes(ne.name)&&!Zd.some(se=>ne.name.includes(se))&&Z.push({key:ne.name,...ne.meta?.displayType==="array"&&{name:ne.meta?.name||ne.name},description:ne.meta?.description||"",type:ne.meta?.displayType||"",value:ve[ne.name]||null,required:ne?.validation?.required||!1})}),ve.payload=Z,oe?.meta?.children&&oe?.meta?.children?.length>0&&re(oe.meta.children,te)}),m(ve)};re(h)}},[p,h]),{form:g,formSchema:h,loading:w,handleFocus:async re=>{let ue=h;const{fieldData:Oe}=re;if((Oe?.meta?.displayType==="select"||Oe?.meta?.displayType==="autocomplete"||Oe?.meta?.displayType==="multiselect")&&Oe?.meta?.config?.url){const{method:ve,labelKey:oe,valueKey:ae,urlType:te,body:Z,condition:ne}=Oe.meta.config;let{url:se}=Oe.meta.config;te==="secret"?se=Yt(N,"v1/integrations/entity",se):te==="options"&&(se=Yt(k,"v1.0",P,se));const pe={...Z,...Q&&{integration_id:Q},...U&&{integration_slug:U}},he=Object.assign({},{url:se,method:ve,labelKey:oe,valueKey:ae,body:pe});if(D(!0),ne){const de=Ox(ne);if(de){const xe=de.split(".")[1];(g[xe]||e?.properties?.[xe])&&(ue=await V(Oe.name,he,ue))}}else ue=await V(Oe.name,he,ue);D(!1),_.current&&(M===Je.CLOUD_TRIGGER||M===Je.CUSTOM_ACTIVITY)&&(ue=ue.map(de=>de.name==="secret"?{...de,meta:{...de.meta,htmlProps:{...de.meta.htmlProps,showReconnect:_.current}}}:de))}A(ue)},handleChange:async(re,ue)=>{if(M===Je.SERVERLESS){m(ue);return}const{field:Oe,value:ve,fieldData:oe={}}=re,ae={...ue,[Oe]:ve};if(Oe==="secret")m(ae),ve&&(M===Je.CLOUD_TRIGGER||M===Je.CUSTOM_ACTIVITY)&&$(ve);else if(Oe==="resource")m(ae),await z({resource:ve});else if(Oe==="operation"){const[te,Z]=ve.split(".");m(ae),await z({resource:te,operation:Z})}else if(oe?.meta?.loadDynamicParameters){const[te,Z]=g.operation.split(".");m({...ue,[Oe]:ve}),await z({resource:te,operation:Z,currentFormData:{...ue,[Oe]:ve}})}else m(ue)},handleCustom:(re,ue,Oe="")=>{if(Oe==="run_activity"){a?.(ue?.canvasNodeId);return}else if(Oe==="configure_activity"){l?.(ue?.canvasNodeId);return}if(m(ue),re.type==="add-new"){D(!0);let ve=B;const oe=h.find(Z=>Z.name==="secret"&&Z.meta.config);if(oe){const{url:Z}=oe.meta.config;ve=Z.split("?")[0].replace("/","")}const ae={current_page:1,page_size:1,entity:ve.toUpperCase(),state:n.activity_data.status},te=Yt(N,"/v1/catalog");Xt.get(te,{params:ae}).then(Z=>{if(s){s(Z.data.data[0],"create");return}const ne=`${L}/accounts/${P}/integrations/destination/new-destination/${Z.data.data[0]._id}/create?integration_id=${Q}&integration_slug=${U}`;window.open(ne)}).catch(Z=>{dn(Z,b)}).finally(()=>{D(!1)})}else if(re.type==="complete-step")D(!0),b({type:G5,payload:[re.data?.id]}),b({type:Tb,payload:"focused"}),D(!1);else if(re.type==="add-sample-data"){D(!0);const{data:ve}=re;ve.name==="global_variables"?b({type:Q5,payload:ve.data}):ve.name==="payload"?b({type:fd,payload:{id:ve?.id,data:ve.data,loading:!1}}):b({type:fd,payload:{id:ve.id,data:{result:ve.data,events:[]},loading:!1}}),D(!1)}else if(re.type==="reconnect"&&(M===Je.CLOUD_TRIGGER||M===Je.CUSTOM_ACTIVITY))Y();else if(re.type==="graphql-inspector"){const oe=!!ue?.properties&&typeof ue.properties=="object"&&!Array.isArray(ue.properties)?ue.properties:ue,ae=oe?.query,te=oe?.headers,Z=q(oe?.variables);T({headers:te||{},query:typeof ae=="string"?ae:ae?JSON.stringify(ae,null,2):"",variables:Z}),y(!0)}},setForm:m,handleCancel:()=>{o?.(),m({}),A([]),i(null)},setFormSchema:A,GraphQLInspectorModal:j}},Tx=e=>{if(!e||e.length===0)return!1;const t=e.some(r=>["secret","resource","operation"].includes(r.name)),n=e.some(r=>!["secret","resource","operation"].includes(r.name));return t&&n},Sx=(e,t)=>{const n=t?.secret&&!vt(t.secret),r=e.filter(u=>u.name==="operation"?n||!n&&t?.resource:["secret","resource"].includes(u.name)),i=e.filter(u=>!["secret","resource","operation"].includes(u.name)),o=[{name:"setup",meta:{className:"setup-section",displayType:"section",displayName:"Setup",htmlProps:{border:!1,divider:!1,headerVariant:"lgSemiBold"},children:r}}],s=i.length>0,a=t?.resource&&!vt(t.resource),l=t?.operation&&!vt(t.operation);return s&&a&&l&&(o.push({meta:{displayType:"divider",htmlProps:{my:"1rem"}}}),o.push({name:"configure",meta:{className:"configure-section",displayType:"section",displayName:"Configure",htmlProps:{border:!1,divider:!1,headerVariant:"lgSemiBold"},children:i}})),o},Vit=C.forwardRef((e,t)=>{const{formData:n,selectedNode:r,type:i,activity_id:o,initialState:s,isLoop:a=!1,cloudRef:l,suggestionsData:u,SET_INTEGRATION_DATA:c,INTEGRATION_DATA:f,openIntegrationDrawer:p,isLoading:h=!1,onSubmit:A,onClose:g}=e,{loopSuggestionsData:m={}}=gt.useSelector(M=>M.loopActivity),{viewOnly:O}=gt.useSelector(M=>M.canvas),{form:y,formSchema:v,loading:T,handleFocus:_,handleChange:x,handleCustom:b,setForm:w,handleCancel:D,setFormSchema:I,GraphQLInspectorModal:P}=vx({formData:n,selectedNode:r,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:c,onClose:g,openIntegrationDrawer:p,onSubmit:A});C.useImperativeHandle(t,()=>({getData:()=>y,validateForm:()=>!0,resetFormData:()=>{w({}),I([])}}),[y]);const k=(M,B="")=>{if(!a){const Q={type:i,name:r.data.name,activity_id:o,properties:{...s.properties,...M}};e.onSubmit?.(Q,B)}},L=Tx(v)?Sx(v,y):v;return d.jsxs(E.Box,{sx:{overflowY:"auto",height:"100%","& .MuiSwitch-root":{marginLeft:"7px"}},children:[d.jsx(Ex,{ref:l,name:`${r.data.name}-integration-form`,schema:L,form:y,onChange:x,onSubmit:k,isLoading:T||h,onFocus:_,onCustom:b,onCancel:D,useDefaultButtons:!1,suggestions:a?m:u,viewOnly:O}),d.jsx(P,{})]})}),Fte=wo(Vit),Git=({url:e})=>{const t=E.useTheme(),n=gt.useDispatch(),[r,i]=C.useState(!1);C.useEffect(()=>{r&&setTimeout(()=>{i(!1)},2e3)},[r]);const o=()=>{navigator.clipboard.writeText(e).then(()=>{i(!0),n({type:Yn,payload:{open:!0,title:"Copied to clipboard",type:"success"}})}).catch(()=>{n({type:Yn,payload:{open:!0,title:"Failed to copy",type:"error"}})})};return d.jsx(E.Grid,{item:!0,xs:12,children:d.jsxs(E.Stack,{direction:"row",alignItems:"center",spacing:2,sx:{border:s=>`1px solid ${s.palette.grey[200]}`,borderRadius:1,p:2,background:t.palette.neutral.soft.bg,position:"relative",userSelect:"none"},children:[d.jsx(E.Typography,{sx:{color:t.palette.primary.main,px:1,py:.5,borderRadius:"4px",border:"1px solid"},children:"POST"}),d.jsx(E.Tooltip,{title:e,arrow:!0,children:d.jsx(E.Typography,{sx:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",wordBreak:"break-all",maxWidth:"80%"},children:e})}),d.jsx(E.Tooltip,{title:"Copy to clipboard",placement:"top",arrow:!0,children:d.jsx(E.IconButton,{"data-testid":"button-copy-webhook-url",onClick:o,sx:{position:"absolute",right:"6px",top:"6px"},children:d.jsx(Ue,{src:"ic_copy",width:15,height:15,sx:{path:{fill:t.palette.common.black}}})})})]})})},Wit=C.forwardRef((e,t)=>{const n=gt.useDispatch(),r=E.useTheme(),{type:i,TESSERACT_MAIN_URL:o,ENTITY_ID:s,VORTEX_MAIN_URL:a,FRONTEND_URL:l,WORKFLOW_URLS:u,INTEGRATION_DATA:c,viewOnly:f=!1,openIntegrationDrawer:p}=e,[h,A]=C.useState([]),[g,m]=C.useState(!1),[O,y]=C.useState([]),[v,T]=C.useState([]),[_,x]=C.useState(!1),[b,w]=C.useState(!1),[D,I]=C.useState(!1),{control:P,watch:k,setValue:N,trigger:L}=Hn(),M=k("properties.slack_auth_id"),B=k("properties"),[Q,U]=C.useState(!1),[q,F]=C.useState(""),W=()=>{m(!0);const J={page_size:999,current_page:1,type:"BOTH"},ee=Yt(o,"/v1/integrations/entity/SLACK_V2");Xt.get(ee,{params:J}).then(({data:le})=>{const re=Yo(le.data,["integration_meta"]);A(re)}).catch(le=>{dn(le,n)}).finally(()=>{m(!1)})},G=Yt(a,`/v1.0/${s}`,"/implementations/choices"),R=async({slackAuthId:J,inputFieldId:ee,fieldsToFill:le,type:re,refresh:ue=!1})=>{const Oe=`${G}${ue?"?refresh=true":""}`;return Xt.post(Oe,{data:{secret:J,input_field_id:ee,selected_api:"slackAPI",fields_to_fill:le,operation:"get",...re&&{type:re}}})},j=async(J,ee=!1)=>{I(!ee),ee&&U(!0);const{event:le}=B;let re;["public_channel_message","public_channel_message_mention"].includes(le)?re="public_channel":["private_channel_message","private_channel_message_mention"].includes(le)&&(re="private_channel");try{const ue=await R({slackAuthId:J,inputFieldId:"channel",fieldsToFill:Cf,type:re,refresh:ee});y(ue.data)}catch(ue){y([]),dn(ue,n)}finally{I(!1),U(!1)}},$=async(J,ee=!1)=>{I(!ee),ee&&U(!0);try{const[le,re]=await Promise.all([R({slackAuthId:J,inputFieldId:"channel",fieldsToFill:Cf,type:"public_channel",refresh:ee}),R({slackAuthId:J,inputFieldId:"channel",fieldsToFill:Cf,type:"private_channel",refresh:ee})]);y([...le.data,...re.data])}catch(le){y([]),dn(le,n)}finally{I(!1),U(!1)}},Y=async(J,ee=!1)=>{x(!ee),ee&&w(!0);try{const le=await R({slackAuthId:J,inputFieldId:"user",fieldsToFill:H4,refresh:ee});T(le.data)}catch(le){dn(le,n)}finally{x(!1),w(!1)}},z=async J=>{const{slack_auth_id:ee,event:le}=B;if(!ee||!le)return;const re=["public_channel_message","private_channel_message"].includes(le),ue=["public_channel_message_mention","private_channel_message_mention"].includes(le);J==="channel"?re||ue?await j(ee,!0):le==="app_mention"&&await $(ee,!0):J==="user"&&ue&&await Y(ee,!0)};C.useEffect(()=>{(M===""||M===null||M===void 0)&&(N("properties.event",""),N("properties.channel",""),N("properties.username",""),N("properties.word",""),N("properties.listen_workspace",!1),N("properties.listen_for_bot_message",!1),y([]),T([]))},[M,N]),C.useEffect(()=>{B.event&&B.event!==null&&!vt(B)&&(N("properties.channel",""),N("properties.username",""),N("properties.word",""),N("properties.listen_workspace",!1),N("properties.listen_for_bot_message",!1),T([]),y([]))},[B.event,N]),C.useEffect(()=>{const{slack_auth_id:J,event:ee}=B;!vt(J)&&!vt(ee)&&(["public_channel_message","private_channel_message"].includes(ee)?j(J):ee==="app_mention"?$(J):["public_channel_message_mention","private_channel_message_mention"].includes(ee)&&(j(J),Y(J)))},[B.slack_auth_id,B.event]),C.useEffect(()=>{B.listen_workspace&&N("properties.channel","")},[B.listen_workspace,N]),C.useEffect(()=>{W()},[]),C.useEffect(()=>{try{const ee=window.location.pathname.split("/"),le=ee.findIndex(ue=>ue==="version");let re="";if(le>-1&&le<ee.length-1)re=ee[le+1];else{const ue=["draft","published","scheduled"],Oe=ee.findIndex(ve=>ue.includes(ve));re=Oe>-1?ee[Oe+1]:""}u?.VORTEX_WEBHOOK_URL&&s&&re&&F(Yt(u.VORTEX_WEBHOOK_URL,`/v1.0/${s}`,"workflows/execute/",re))}catch{}},[u,s]),C.useEffect(()=>{c?._id&&c?.meta?.entity==="SLACK_V2"&&(W(),N("properties.slack_auth_id",c._id,{shouldValidate:!0}))},[c]);const H=h.find(J=>J.id===B.slack_auth_id),V=H?.integration_meta?.type==="oauth2",X=H?.integration_meta?.bot_name;return d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(no,{children:d.jsx(E.Grid,{container:!0,gap:1.5,children:d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:"properties.slack_auth_id",control:P,meta:{options:jr(h),displayProps:{loading:g},displayName:"Slack Account",value:"",htmlProps:{showAddNew:!0},TESSERACT_MAIN_URL:o,FRONTEND_URL:l,ENTITY_ID:s,openIntegrationDrawer:p,addNewButtonText:"Add new account",searchFieldPlaceholder:"Search Slack Account",authType:"SLACK_V2",description:`Slack is a secure partner with Boltic. Your credentials are encrypted & can be removed at any time. <a href="${u.GYRATE_MAIN_URL}/integrations/Triggers/slack" target="_blank" rel="noopener noreferrer" style="color: ${r.palette.primary.main}">View setup guide</a>`,placeholder:"Select Slack Account"},validationRules:{required:"Slack account is required"},viewOnly:f,id:i,handleChange:()=>{}})})})}),B.slack_auth_id&&d.jsx(E.Divider,{}),B.slack_auth_id&&d.jsx(kr,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[!vt(B.slack_auth_id)&&h.length>0&&(!(h.find(le=>le.id===B.slack_auth_id)?.integration_meta?.type==="oauth2")&&q?d.jsxs(d.Fragment,{children:[d.jsx(E.Grid,{container:!0,gap:1,children:d.jsx(Git,{url:q})}),d.jsx(Fl,{message:'Copy the webhook URL above and paste it into the "Request URL" field on the Event Subscriptions page in your Slack app settings. This enables Slack to send events to your workflow.'})]}):null),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{name:"properties.event",control:P,meta:{options:due,displayName:"Operation",searchFieldPlaceholder:"Search operation",description:"This is what starts the Workflow",placeholder:"Select a operation"},validationRules:{required:"Operation is required"},required:!0,viewOnly:f,handleChange:()=>{}})}),B.event==="app_mention"&&!V&&X&&d.jsx(Fl,{variant:"info",message:`To trigger workflows, mention your bot using @${X} in any Slack channel where the bot is invited.`}),!vt(B.slack_auth_id)&&!vt(B.event)&&d.jsxs(E.Grid,{sx:{mt:1,...mi},children:[d.jsx(vr,{label:"Watch Whole Workspace",description:so("If enabled, triggers across the entire workspace; channel selection is not required."),sx:{fontSize:14,fontWeight:400,color:r.palette.text.primary}}),d.jsx(gn,{name:"properties.listen_workspace",control:P,render:({field:J})=>d.jsx(E.FormControlLabel,{label:J.value?"On":"Off",labelPlacement:"start",control:d.jsx(E.Switch,{...J,checked:!!J.value,disabled:f}),sx:{mr:0,ml:2},componentsProps:{typography:{variant:"smNormal"}}})})]}),!vt(B.slack_auth_id)&&!vt(B.event)&&d.jsxs(d.Fragment,{children:[!B?.listen_workspace&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!B?.listen_workspace,name:"properties.channel",control:P,meta:{options:jr(O),displayName:"Select Channel",displayProps:{loading:D,refreshing:Q},value:"",searchFieldPlaceholder:"Search",description:"Only channels your bot is a member of will appear in this list.",placeholder:"Select Channel"},validationRules:{...B?.listen_workspace?{}:{required:"Channel is required"}},viewOnly:f,id:"channel",refreshOptions:()=>z("channel"),refreshTooltip:"Refresh Channels"})}),["public_channel_message_mention","private_channel_message_mention"].includes(B.event)&&d.jsxs(d.Fragment,{children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{name:"properties.username",control:P,meta:{options:jr((v||[]).map(J=>{let ee="";return J.real_name&&J.name?ee=`${J.real_name} (${J.name})`:ee=J.real_name||J.name||"",{id:J.id,name:ee}})),displayProps:{loading:_,refreshing:b},displayName:"Select User",value:"",searchFieldPlaceholder:"Search User",placeholder:"Select User",description:"Triggers the workflow when this user is mentioned. Specify either a Username, a Highlight Word, or both. If both are set, the workflow triggers only when both appear in the message."},validationRules:{validate:J=>{const ee=k("properties.word");return!J&&(!ee||ee.trim()==="")?"Either User selection or Highlight Word is required":!0}},viewOnly:f,id:"user",virtualized:!0,refreshOptions:()=>z("user"),refreshTooltip:"Refresh Users",handleChange:()=>{L("properties.word")}})}),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Wn,{name:"properties.word",control:P,viewOnly:f,meta:{displayName:"Highlight Word",placeholder:"Enter text...",description:"Triggers the workflow when this word is mentioned (case-insensitive). Specify either a Highlight Word, a Username, or both. If both are set, the workflow triggers only when both appear in the message."},validationRules:{validate:J=>{const ee=k("properties.username"),le=J;return(!le||le.trim()==="")&&!ee?"Either Highlight Word or User selection is required":!0}},handleChange:()=>{L("properties.username")}})})]}),d.jsx(Fl,{message:`Invite ${V?"the Boltic app":"your bot"} to your Slack channel to receive events. In the channel, type: /invite @${V?"Boltic":X||"your-app-name"}`}),B?.event!=="app_mention"&&d.jsxs(d.Fragment,{children:[d.jsxs(E.Grid,{sx:{mt:1,...mi},children:[d.jsx(vr,{label:"Listen for Bot Messages",description:so("If no, only messages sent by users will trigger the Workflow. If yes, messages sent by users and slackbots will trigger the Workflow."),sx:{fontSize:14,fontWeight:400,color:r.palette.text.primary}}),d.jsx(gn,{name:"properties.listen_for_bot_message",control:P,render:({field:J})=>d.jsx(E.FormControlLabel,{label:J.value?"On":"Off",labelPlacement:"start",control:d.jsx(E.Switch,{...J,checked:!!J.value,disabled:f}),sx:{mr:0,ml:2},componentsProps:{typography:{variant:"smNormal"}}})})]}),B?.listen_for_bot_message&&d.jsx(Fl,{textColor:r.palette.text.tertiary,variant:"warning",message:"Avoid infinite loops! If your workflow posts messages to the same channel that triggers it, and 'Listen for Bot Messages' is enabled, it will create an endless loop. Consider disabling bot message listening or posting to a different channel."})]})]})]})})]})}),Bte=({field:e,items:t,type:n,nodeId:r,viewOnly:i=!1,eventType:o,handleArrayItemDelete:s,validationRules:a={},isLoop:l})=>{const u=E.useTheme(),{control:c,formState:{errors:f}}=Hn(),p=C.useMemo(()=>t?.map((h,A)=>`${r}-${e}-${Date.now()}-${A}`),[r,e,t?.length]);return d.jsx(d.Fragment,{children:t.map((h,A)=>d.jsxs(E.Grid,{container:!0,sx:{py:1},alignItems:"center",justifyContent:"space-between",children:[d.jsx(E.Grid,{item:!0,xs:11,children:d.jsx(gn,{name:`properties.${o}.${e}.${A}`,control:c,rules:a,render:({field:g})=>d.jsx(ao,{...g,id:r,fullWidth:!0,required:e==="emails",name:"email",viewOnly:i,label:"Email",isLoop:l,errorMsg:f.properties?.[o]?.[e]?.[A]?.message,showSuggestions:!0,helperText:_r(n,e),editorId:`${n}-${e}-${A}`,__withFieldValueControlApplied:!0})})}),d.jsx(E.Grid,{item:!0,xs:1,sx:{display:"flex",justifyContent:"center",alignSelf:"flex-end",paddingBottom:"2px"},children:e==="emails"&&t.length>1&&d.jsx(E.IconButton,{"data-testid":"delete-email-button",sx:{p:.75,width:28,height:28,"& path":{fill:u.palette.neutral.solid.bg},"&:hover path":{fill:u.palette.error[60]},"&:hover":{backgroundColor:"transparent"}},disabled:i,onClick:()=>s(e,A),children:d.jsx(Ue,{src:"ic_delete",width:20,height:20})})})]},p[A]))})},Qit=e=>{const{field:t,eventType:n,viewOnly:r=!1}=e,i=`properties.${n}.${t}`,{watch:o,setValue:s,unregister:a}=Hn(),{setFieldControlState:l}=oa(),u=o(i),[c,f]=C.useState("BOLTIC_AI"),p=C.useRef([]);C.useEffect(()=>{u==="BOLTIC_AI"||u==="BOLTIC_AI_IGNORE"?f(u):Array.isArray(u)&&f("specific")},[u]);const h=A=>{const g=A.target.value;if(f(g),l(i,g),g==="specific"){const m=Array.isArray(u)&&u.length>0?u:p.current.length>0?p.current:[""];s(i,m)}else Array.isArray(u)&&(p.current=u,u.forEach((m,O)=>{a?.(`${i}.${O}`)}),a?.(i)),s(i,g)};return d.jsxs(E.Stack,{spacing:1.5,children:[d.jsx(E.FormControl,{fullWidth:!0,disabled:r,children:d.jsxs(E.Select,{value:c,onChange:h,children:[d.jsx(E.MenuItem,{sx:{py:.8},value:"BOLTIC_AI",children:"Have AI generate a value for this field"}),d.jsx(E.MenuItem,{sx:{py:.8},value:"BOLTIC_AI_IGNORE",children:"Do not include a value for this field"}),d.jsx(E.MenuItem,{sx:{py:.8},value:"specific",children:"Set a specific value for this field"})]})}),c==="specific"&&d.jsx(Bte,{...e})]})},zit=e=>{const{MCP_INTEGRATION_FORM:t}=oa();return t?d.jsx(Qit,{...e}):d.jsx(Bte,{...e})},jte=C.forwardRef(({property:e,viewOnly:t=!1,value:n,onChange:r},i)=>{const o=E.useTheme(),s=a=>{switch(a){case"add_workflow_link":return"Include Boltic Link at the end of the message";case"pause_workflow":return"Pause the Workflow, once this activity has completed its execution";default:return""}};return d.jsx(E.Grid,{item:!0,xs:12,ref:i,children:d.jsx(E.FormControlLabel,{label:s(e),sx:{display:"block",mr:0,"& .MuiFormControlLabel-label":{fontSize:a=>a.typography.xsNormal.fontSize,color:a=>a.typography.allVariants.color}},control:d.jsx(E.Checkbox,{sx:{p:0,"& .MuiSvgIcon-root":{fontSize:16}},icon:d.jsx(Ue,{src:"ic_unchecked",width:16,height:16,sx:{path:{fill:o.palette.common.white}}}),checkedIcon:d.jsx(Ue,{src:"ic_checked",width:16,height:16}),disabled:t,checked:n,onChange:r})})})}),Xit=wo(({label:e,type:t,eventKey:n,required:r=!1,showExpandOption:i=!0,errorMsg:o="",suggestionsData:s,isLoop:a,viewOnly:l=!1,value:u,onChange:c})=>{const{loopSuggestionsData:f={}}=gt.useSelector(p=>p.loopActivity);return d.jsxs(E.Box,{children:[d.jsxs(E.Grid,{sx:{...mi},children:[d.jsx(vr,{required:r,label:e,description:so(_r(t,"body"))}),d.jsx(E.Typography,{variant:"xsBold",children:d.jsx(E.Link,{href:"https://api.slack.com/block-kit",target:"_blank",rel:"noopener noreferrer",underline:"none",color:p=>p.palette.primary.main,children:"How to use Slack Block Builder?"})})]}),d.jsx(Po,{size:"md",language:"json",showSuggestions:!0,viewOnly:l,value:u,handleChange:p=>c(p),id:`${t}-${n}-body`,suggestionsData:a?f:s,showExpandOption:i}),!!o&&d.jsx(E.FormHelperText,{error:!0,children:o})]})},""),Yit=C.forwardRef((e,t)=>{const n=gt.useDispatch(),r=E.useTheme(),{control:i,setValue:o,watch:s,clearErrors:a,formState:{errors:l}}=Hn(),u=s("properties");lA(s,o);const{VORTEX_MAIN_URL:c,ENTITY_ID:f,TESSERACT_MAIN_URL:p,FRONTEND_URL:h,WORKFLOW_URLS:A,type:g,id:m,isLoop:O=!1,INTEGRATION_DATA:y,viewOnly:v=!1,openIntegrationDrawer:T}=e,[_,x]=C.useState([]),[b,w]=C.useState(!1),[D,I]=C.useState(!1),[P,k]=C.useState(!1),[N,L]=C.useState([]),[M,B]=C.useState([]),[Q,U]=C.useState("Query Params"),[q,F]=C.useState(!1),[W,G]=C.useState(!1),[R,j]=C.useState(!1),$=R?Rb:Rb.filter(oe=>oe.value),Y=async()=>{w(!0);const oe={page_size:999,current_page:1,type:"BOTH"},ae=Yt(p,"/v1/integrations/entity/SLACK_V2");Xt.get(ae,{params:oe}).then(({data:te})=>{const Z=Yo(te.data,["integration_meta"]);x(Z)}).catch(te=>{dn(te,n)}).finally(()=>{w(!1)})},z=async(oe,ae,te=!1)=>{I(!0);let Z=Yt(c,`/v1.0/${f}`,"/implementations/choices");te&&(Z+="?refresh=true");try{const ne=await Xt.post(Z,{data:{secret:oe,input_field_id:"channel",selected_api:"slackAPI",fields_to_fill:Cf,operation:"get",type:ae===Xo.SEND_PUBLIC_CHANNEL_MESSAGE?"public_channel":"private_channel"}});L(jr(ne.data))}catch(ne){L([]),dn(ne,n)}finally{I(!1)}},H=async(oe,ae=!1)=>{I(!0);let te=Yt(c,`/v1.0/${f}`,"/implementations/choices");ae&&(te+="?refresh=true");try{const[Z,ne]=await Promise.all([Xt.post(te,{data:{secret:oe,input_field_id:"channel",selected_api:"slackAPI",fields_to_fill:Cf,operation:"get",type:"public_channel"}}),Xt.post(te,{data:{secret:oe,input_field_id:"channel",selected_api:"slackAPI",fields_to_fill:Cf,operation:"get",type:"private_channel"}})]),se=[...Z.data,...ne.data];L(jr(se))}catch(Z){dn(Z,n)}finally{I(!1)}},V=async(oe,ae=!1)=>{k(!0);let te=Yt(c,`/v1.0/${f}`,"/implementations/choices");ae&&(te+="?refresh=true");try{const Z=await Xt.post(te,{data:{secret:oe,input_field_id:"user",selected_api:"slackAPI",fields_to_fill:H4,operation:"get"}});B(Z.data.map(ne=>({title:ne.real_name?`${ne.real_name} (${ne.name})`:ne.name,value:ne.id})))}catch(Z){dn(Z,n)}finally{k(!1)}},X=(oe,ae)=>{const te=u[u.event][oe].filter((Z,ne)=>ne!==ae);o("properties",{...u,[u.event]:{...u[u.event],[oe]:te}})},J=(oe,ae)=>{o("properties",{...u,[u.event]:{...u[u.event],[oe]:[...u[u.event][oe],ae]}})},ee=oe=>{o(`properties.${u.event}.${oe}`,null)},le=oe=>Zue[oe],re=async(oe,ae,te="",Z=!1)=>{vt(oe)||vt(ae)||(te==="Channel"?F(!0):te==="Users"&&G(!0),!vt(oe)&&!vt(ae)&&[Xo.SEND_PUBLIC_CHANNEL_MESSAGE,Xo.SEND_PRIVATE_CHANNEL_MESSAGE].includes(ae)?await z(oe,ae,Z):ae===Xo.SEND_USER_MESSAGE?await V(oe,Z):ae===Xo.SET_CHANNEL_TOPIC?await H(oe,Z):ae===Xo.INVITE_USERS&&(te==="Channel"?await H(oe,Z):te==="Users"?await V(oe,Z):(!te||te==="")&&await Promise.all([V(oe,Z),H(oe,Z)])),te==="Channel"?F(!1):te==="Users"&&G(!1))},ue=oe=>{const{slack_auth_id:ae,event:te}=u;re(ae,te,oe,!0)};C.useEffect(()=>{vt(u)||(u.event===Xo.SEND_PRIVATE_CHANNEL_MESSAGE&&u?.send_private_channel_message?.attachment&&!u?.send_private_channel_message?.attachments&&(u.send_private_channel_message.attachments=[u.send_private_channel_message.attachment]),u.event===Xo.SEND_PRIVATE_CHANNEL_MESSAGE&&!u?.send_private_channel_message?.attachments&&(u.send_private_channel_message.attachments=[]),u.event===Xo.SEND_PUBLIC_CHANNEL_MESSAGE&&u?.send_public_channel_message?.attachment&&!u?.send_public_channel_message?.attachments&&(u.send_public_channel_message.attachments=[u.send_public_channel_message.attachment]),u.event===Xo.SEND_PUBLIC_CHANNEL_MESSAGE&&!u?.send_public_channel_message?.attachments&&(u.send_public_channel_message.attachments=[]),Y())},[]),C.useEffect(()=>{y?._id&&y?.meta?.entity==="SLACK_V2"&&(Y(),o("properties.slack_auth_id",y._id,{shouldValidate:!0}))},[y]),C.useEffect(()=>{if(_.length>0&&u?.slack_auth_id){const oe=_.find(ae=>ae.id===u.slack_auth_id);j(oe?.integration_meta?.type==="oauth2")}else j(!1)},[_,u?.slack_auth_id]),C.useEffect(()=>{const{slack_auth_id:oe,event:ae}=u;re(oe,ae)},[u.event,u.slack_auth_id]);const Oe=u[u.event]?.attachments==="BOLTIC_AI_IGNORE"||u[u.event]?.attachments==="BOLTIC_AI",ve=u[u.event]?.emails==="BOLTIC_AI_IGNORE"||u[u.event]?.emails==="BOLTIC_AI";return d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(no,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:"properties.slack_auth_id",control:i,meta:{options:jr(_),displayProps:{loading:b},displayName:"Slack Account",value:"",htmlProps:{showAddNew:!0},TESSERACT_MAIN_URL:p,FRONTEND_URL:h,ENTITY_ID:f,openIntegrationDrawer:T,addNewButtonText:"Add new account",searchFieldPlaceholder:"Search Slack account",authType:"SLACK_V2",description:`Slack is a secure partner with Boltic. Your credentials are encrypted & can be removed at any time. <a href="${A?.GYRATE_MAIN_URL}/integrations/Communication/slack" target="_blank" rel="noopener noreferrer" style="color: ${r.palette.primary.main}">View setup guide</a>`,placeholder:"Select Slack Account"},validationRules:{required:"Slack account is required"},handleChange:({field:oe,value:ae})=>{vt(ae)&&(L([]),B([])),vt(ae)?o("properties.event",""):o(oe,ae)},viewOnly:v,id:"slack_auth_id"})}),u.slack_auth_id&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:"properties.event",control:i,meta:{options:fue,displayProps:{loading:b},displayName:"Operation",description:"This is performed when the Workflow runs.",searchFieldPlaceholder:"Search operation",placeholder:"Select a operation"},validationRules:{required:"Operation is required"},handleChange:({value:oe})=>{o("properties",{...u,[oe]:le(oe),event:oe}),L([]),B([])},viewOnly:v})})]})}),u.slack_auth_id&&u.event&&d.jsx(E.Divider,{}),u.slack_auth_id&&u.event&&d.jsx(kr,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[!vt(u.slack_auth_id)&&d.jsxs(d.Fragment,{children:[u.event===Xo.CUSTOM&&d.jsx(d.Fragment,{children:d.jsx(Op,{id:m,type:g,isLoop:O,viewOnly:v,customSelectedTab:Q,setCustomSelectedTab:U})}),que.includes(u.event)&&d.jsx(Wn,{required:!0,id:m,name:`properties.${u.event}.channel_name`,control:i,meta:{displayName:"Channel Name",description:"Name for the channel to be created. Channel names are normalized by converting to lowercase, replacing any non-allowed characters with hyphens or underscore, and truncating to 80 characters.",placeholder:"Enter channel name"},validationRules:{required:"Chanel name is required"},viewOnly:v,editorId:`${g}-slack-channel_name`,showSuggestions:!0,isLoop:O},u.event),Xue.includes(u.event)&&d.jsx(tf,{required:!0,name:`properties.${u.event}.channel_id`,id:m,control:i,isLoading:D,type:g,label:"Channel",viewOnly:v,isLoop:O,virtualized:!0,helperTextForDropdown:R?"channel_id":"channel_id_for_bot",helperTextForTextField:"dynamic_channel_id",isMultiple:!1,data:N,value:u[u.event]?.channel_id,onTabChange:()=>{ee("channel_id")},eventName:u.event,fieldName:"channel_id",refreshData:ue,refreshing:q,willRefresh:!0,refreshTooltip:"Refresh Channels"},u.event),u.event===Xo.SEND_PRIVATE_CHANNEL_MESSAGE&&d.jsx(Fl,{message:`To send a message to a private channel, please invite ${R?"the Boltic app":"your bot"} to the channel.`}),[Xo.SET_CHANNEL_TOPIC].includes(u.event)&&d.jsx(Wn,{required:!0,id:m,name:`properties.${u.event}.topic`,control:i,meta:{displayName:"Topic",description:"Topic to be set for the Slack channel",placeholder:"Enter topic"},validationRules:{required:"Topic is required"},viewOnly:v,editorId:`${g}-slack-topic`,showSuggestions:!0,isLoop:O}),Kue.includes(u.event)&&d.jsx(tf,{name:`properties.${u.event}.user_id`,control:i,required:!0,isMultiple:!0,viewOnly:v,isLoading:P,id:m,type:g,isLoop:O,label:"Users",helperTextForTextField:"user_id",virtualized:!0,helperTextForDropdown:u.event===Xo.SEND_USER_MESSAGE?"user_ids_message":"user_ids_invite",data:M,value:u[u.event]?.user_id,onTabChange:()=>{ee("user_id")},eventName:u.event,fieldName:"user_id",refreshData:ue,refreshing:W,willRefresh:!0,refreshTooltip:"Refresh Users",handleChange:oe=>{const{field:ae,value:te}=oe;o(ae,te,{shouldValidate:!0})}}),Yue.includes(u.event)&&d.jsxs(d.Fragment,{children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:`properties.${u.event}.body_type`,control:i,validationRules:{required:"Message Body type is required"},meta:{options:aue,displayName:"Message Body Type",description:_r(g,"body_type"),searchFieldPlaceholder:"Search",placeholder:"Select Message Body Type"},viewOnly:v,id:g,handleChange:oe=>{const{value:ae}=oe;o(`properties.${u.event}`,{...u[u.event],body:ae===A0.BLOCKS?M4:"",blocks:ae===A0.BLOCKS?[]:u[u.event].blocks}),a(`properties.${u.event}.body`)}})}),d.jsxs(E.Grid,{item:!0,xs:12,children:[u[u.event]?.body_type==="text"&&d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Wn,{required:!0,id:m,multiline:!0,name:`properties.${u.event}.body`,control:i,meta:{displayName:"Message Body",description:"Specify text / Define Slack Blocks of the message to send",placeholder:"Type or add suggestion"},validationRules:{required:"Message Body is required"},viewOnly:v,editorId:`${g}-slack-body`,showSuggestions:!0,isLoop:O,size:"md"})}),d.jsx(E.Grid,{item:!0,xs:12,children:u.event!==Xo.SEND_USER_MESSAGE&&d.jsxs(E.Grid,{item:!0,xs:12,children:[d.jsxs(E.Stack,{width:"100%",direction:"row",alignItems:"center",justifyContent:"space-between",sx:{"& > .MuiStack-root > .MuiStack-root":{pb:0}},children:[d.jsx(vr,{label:"Attachments",description:"The total attachments size limit is 1GB. The maximum number of attachments is 5."}),!Oe&&d.jsx(E.IconButton,{disabled:u[u.event].attachments?.length>=5,onClick:()=>J("attachments",""),sx:{border:oe=>`1px solid ${oe.palette.grey.brainstem}`,width:24,height:24},color:"primary",children:d.jsx(Ue,{src:"ic_plus",width:16,height:16,sx:{path:{fill:r.palette.primary.main}}})})]}),d.jsx(VP,{nodeId:m,type:g,isLoop:O,field:`properties.${u.event}.attachments`})]},u.event)})]}),u[u.event]?.body_type===A0.BLOCKS&&d.jsxs(d.Fragment,{children:[d.jsx(E.Grid,{item:!0,xs:12,sx:{marginBottom:"0.5rem"},children:d.jsx(en,{required:!0,name:`properties.${u.event}.block_type`,control:i,meta:{options:Jue,displayName:"Slack Block Type",searchFieldPlaceholder:"Search Block Type",placeholder:"Select Block Type",description:_r(g,"block_type")},disabled:v,validationRules:{required:"Slack Block Type is required"},handleChange:oe=>{const{value:ae}=oe;o(`properties.${u.event}`,{...u[u.event],body:ae==="message"?M4:Wue,blocks:[]})},viewOnly:v,id:g})}),d.jsx(gn,{name:`properties.${u.event}.body`,control:i,render:({field:oe})=>d.jsx(Xit,{...oe,id:m,label:"Slack Blocks",viewOnly:v,type:g,isLoop:O,eventKey:u.event,required:!0,showExpandOption:!0,errorMsg:l.properties?.[u.event]?.body?.message})})]})]}),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:`properties.${u.event}.send_as_bot`,control:i,meta:{options:$,displayName:"Send as Bot",description:_r(g,"send_as_bot"),placeholder:"Select Send as Bot",showSearch:!1},viewOnly:v,id:g,handleChange:oe=>{const{value:ae}=oe;o(`properties.${u.event}`,{...u[u.event],send_as_bot:ae,bot_name:"",bot_icon:""})}})}),u?.[u.event]?.send_as_bot&&d.jsxs(d.Fragment,{children:[d.jsx(Wn,{id:m,name:`properties.${u.event}.bot_name`,control:i,meta:{displayName:"Bot Name",description:"Specify the bot name which appears as a bold username above the message inside Slack. Defaults to Boltic.",placeholder:"Enter bot name"},viewOnly:v,editorId:`${g}-slack-bot_name`,showSuggestions:!0,isLoop:O}),d.jsx(Wn,{id:m,name:`properties.${u.event}.bot_icon`,control:i,meta:{displayName:"Bot Icon",description:"Either an image url or an emoji available to your team (surrounded by :). For example, https://site.com/icon_256.png or :robot_face:",placeholder:"Enter bot icon"},viewOnly:v,editorId:`${g}-slack-bot_icon`,showSuggestions:!0,isLoop:O})]}),d.jsx(Wn,{id:m,name:`properties.${u.event}.thread_ts`,control:i,meta:{displayName:"Thread Id",description:"If you want this to be part of a thread, you'll need the timestamp (Ts) of the parent message. For example: 1345232312616.1231232",placeholder:"Enter thread id"},viewOnly:v,editorId:`${g}-slack-thread_ts`,showSuggestions:!0,isLoop:O}),u[u.event]?.thread_ts&&u[u.event]?.thread_ts!==""&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:`properties.${u.event}.send_with_thread`,control:i,meta:{options:Rb,displayName:"Send Channel Message?",description:_r(g,"send_with_thread"),placeholder:"Select Send Channel Message",showSearch:!1},viewOnly:v,id:g})}),d.jsx(gn,{name:`properties.${u.event}.add_workflow_link`,control:i,render:({field:oe})=>d.jsx(jte,{...oe,viewOnly:v,property:"add_workflow_link",onChange:ae=>{oe.onChange(ae.target.checked)}})}),u[u.event]?.body_type===A0.BLOCKS&&u?.[u.event].body!==""&&["message",void 0].includes(u?.[u.event]?.block_type)&&d.jsxs(d.Fragment,{children:[d.jsx(gn,{name:`properties.${u.event}.pause_workflow`,control:i,render:({field:oe})=>d.jsx(jte,{...oe,viewOnly:v,property:"pause_workflow",onChange:ae=>{oe.onChange(ae.target.checked)}})}),u[u.event]?.pause_workflow&&d.jsx(Fl,{message:'To enable interactive buttons in Slack, include buttons with action IDs "yes" and "no" in your block layout.'})]}),u?.[u.event]?.pause_workflow&&d.jsx(Fl,{message:'To enable interactive buttons in Slack, include buttons with action IDs "yes" and "no" in your block layout.'})]}),[Xo.FIND_BY_EMAIL].includes(u.event)&&d.jsxs(E.Grid,{item:!0,xs:12,children:[d.jsxs(E.Box,{sx:{display:"flex",alignItems:"center"},children:[d.jsx(E.FormControl,{fullWidth:!0,children:d.jsx(vr,{label:"Add Emails below"})}),!ve&&d.jsx(E.IconButton,{onClick:()=>J("emails",""),disabled:v,sx:{border:oe=>`1px solid ${oe.palette.grey.brainstem}`,width:24,height:24},color:"primary",children:d.jsx(Ue,{src:"ic_plus",width:16,height:16,sx:{path:{fill:r.palette.primary.main}}})})]}),d.jsx(zit,{eventType:u.event,handleArrayItemDelete:X,nodeId:m,type:g,viewOnly:v,field:"emails",items:u[u.event].emails,isLoop:O,validationRules:{required:"Email is required"}})]})]}),!O&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Fi,{viewOnly:v,type:g})})]})})]})}),qit=C.forwardRef((e,t)=>{const{viewOnly:n=!1}=e,{control:r,formState:{errors:i}}=Hn();return d.jsx(kr,{children:d.jsx(gn,{name:"properties.timeout",control:r,rules:{required:"Timeout is required",min:{value:1,message:"Timeout must be greater than or equal to 1"},max:{value:2160*60*60*1e3,message:"Timeout must be less than or equal to 90 days (7,776,000 seconds)"}},render:({field:o})=>d.jsx(ao,{...o,label:"Timeout(seconds)",viewOnly:n,fullWidth:!0,type:"number",id:"timeout",required:!0,errorMsg:i.properties?.timeout.message,value:o.value/1e3||"",onChange:s=>o.onChange(Number(s.target.value)*1e3),inputProps:{step:1,min:1,max:2160*60*60*1e3},helperText:"The time to wait before starting the next Activity Execution"})})})}),Kit=({field:e,items:t,type:n,nodeId:r,requiredValue:i,autoFocus:o,hideLabel:s,placeholder:a="",viewOnly:l=!1,name:u,handleArrayItemDelete:c})=>{const f=E.useTheme(),{control:p}=Hn();return d.jsx(d.Fragment,{children:t.map((h,A)=>d.jsxs(E.Grid,{container:!0,sx:{mb:1},alignItems:"flex-start",justifyContent:"space-between",children:[d.jsx(E.Grid,{item:!0,xs:2.4,children:d.jsx(en,{required:!0,name:`${u}.${A}.caseType`,control:p,meta:{options:Oue,displayName:s?"":"Type",searchFieldPlaceholder:"Search type",description:_r(n,"from_type"),placeholder:s?"":"Select Type"},validationRules:{required:"Type is required"},viewOnly:l,id:n})}),d.jsx(E.Grid,{item:!0,xs:8.2,children:d.jsx(Wn,{meta:{displayName:!s&&"Case",placeholder:`${a} ${A+1}`},name:`${u}.${A}.caseValue`,control:p,validationRules:{required:"Case value is required"},autoFocus:o,id:r,required:i,viewOnly:l,showSuggestions:!0,helperText:_r(n,e),editorId:`${n}-${e}-${A}`})}),d.jsx(E.Grid,{item:!0,xs:1,children:i&&t.length>1&&d.jsx(E.IconButton,{"data-testid":"delete-switch-button",sx:{width:28,height:28,position:"relative",top:24,"&:hover":{backgroundColor:"transparent","& path":{fill:f.palette.error[60]}}},onClick:()=>{c(e,A)},disabled:l,children:d.jsx(Ue,{src:"ic_delete",sx:{"& path":{fill:f.palette.neutral.solid.bg}},width:20,height:20})})})]},`switch-array-${A}`))})},Zit=C.forwardRef((e,t)=>{const{type:n,id:r,isLoop:i,viewOnly:o=!1}=e,{control:s,setValue:a,watch:l,formState:{errors:u}}=Hn(),c=l("properties"),f=l("properties.next_counter"),p=l("properties.cases"),h=m=>{const O=l(`properties.${m}`);a("properties.next_counter",f+1),a(`properties.${m}`,[...O,{caseKey:`case${f+1}Handle`,caseValue:"",caseType:"string"}])},A=(m,O)=>{const y=l(`properties.${m}`).filter((v,T)=>T!==O);a(`properties.${m}`,y)},g=m=>/^.*\{\{[^{}]+\}\}.*$/.test(m);return d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(no,{children:d.jsx(E.Grid,{container:!0,gap:1.5,children:d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(gn,{name:"properties.condition",control:s,rules:{required:"Condition is required",validate:m=>g(m)?!0:"Invalid condition. Dynamic placeholders {{ }} are required."},render:({field:m})=>d.jsx(ao,{...m,id:r,viewOnly:o,showSuggestions:!0,label:"Condition",name:"condition",editorId:`${n}-condition`,placeholder:"Enter a condition",fullWidth:!0,isLoop:i,required:!0,errorMsg:u.properties?.condition?.message,helperText:_r(n,"condition")})})})})}),c.condition&&g(c.condition)&&d.jsx(E.Divider,{}),c.condition&&g(c.condition)&&d.jsx(kr,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsxs(E.Grid,{item:!0,xs:12,pb:1,children:[d.jsx(vr,{label:"Cases"}),d.jsx(Kit,{placeholder:"Case",nodeId:r,viewOnly:o,type:n,field:"cases",requiredValue:!0,isLoop:i,items:p.filter(m=>m.caseValue!=="default"),name:"properties.cases",handleArrayItemDelete:A},p.length),d.jsxs(E.Button,{variant:"text",disabled:o,onClick:()=>h("cases"),sx:{color:m=>m.palette.primary[60],mt:1,"&:hover":{backgroundColor:"transparent",color:m=>m.palette.primary[50],"& .MuiTypography-root":{color:m=>m.palette.primary[50]},"& svg path":{fill:m=>m.palette.primary[50]}}},disableFocusRipple:!0,disableTouchRipple:!0,disableRipple:!0,disableElevation:!0,children:[d.jsx(Ue,{src:"ic_plus",sx:{fontSize:"18px",marginRight:"5px",path:{fill:"currentColor"}}}),d.jsx(E.Typography,{variant:"smNormal",sx:{alignItems:"center"},children:"Add"})]})]}),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Fi,{viewOnly:o,type:n})})]})})]})}),Jit=C.forwardRef((e,t)=>{const{type:n,VORTEX_MAIN_URL:r,ENTITY_ID:i,suggestionsData:o,isLoop:s=!1,viewOnly:a=!1}=e,{loopSuggestionsData:l={}}=gt.useSelector(f=>f.loopActivity),{control:u,formState:{errors:c}}=Hn();return d.jsx(kr,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(gn,{name:"properties.template",control:u,rules:{required:"Template is required"},render:({field:f})=>d.jsx(Po,{...f,label:"Template",suggestionLabel:"Template",id:`${n}-template`,size:"xl",viewOnly:a,activityType:n,VORTEX_MAIN_URL:r,ENTITY_ID:i,language:"html",helperText:d.jsxs(E.Box,{children:["Create dynamic web templates easily using Nunjucks, a powerful JavaScript templating engine.see",d.jsx(E.Link,{href:"https://mozilla.github.io/nunjucks/",target:"_blank",children:" Nunjucks Docs"})]}),error:!!c.properties?.template?.message,errorMsg:c.properties?.template?.message,handleChange:p=>f.onChange(p),required:!0,showSuggestions:!0,suggestionsData:s?l:o,showExpandOption:!0})})}),!s&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Fi,{viewOnly:a,type:n})})]})})}),eot=wo(Jit),tot=C.forwardRef((e,t)=>{const n=gt.useDispatch(),{id:r,type:i,TESSERACT_MAIN_URL:o,ENTITY_ID:s,FRONTEND_URL:a,INTEGRATION_DATA:l,viewOnly:u=!1,openIntegrationDrawer:c}=e,[f,p]=C.useState([]),[h,A]=C.useState(!1),{control:g,resetField:m,watch:O,setValue:y}=Hn(),v=O("properties.auth_type"),T=()=>{A(!0);const _={page_size:999,current_page:1,type:"SOURCE"},x=Yt(o,"/v1/integrations/entity/AUTHENTICATION");Xt.get(x,{params:_}).then(({data:b})=>{const w=Yo(b.data,["integration_meta"]),D=pT(w);p(hT(D))}).catch(b=>{dn(b,n)}).finally(()=>{A(!1)})};return C.useEffect(()=>{l?._id&&l?.meta?.entity==="AUTHENTICATION"&&(T(),y("properties.auth_id",l._id,{shouldValidate:!0}))},[l]),C.useEffect(()=>{!vt(v)&&v!==Pl.NONE?T():m("properties.auth_id")},[v]),d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(no,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:"properties.auth_type",control:g,meta:{options:qO,displayName:"Authentication Type",searchFieldPlaceholder:"Search authentication type",description:"Select Authentication Type (Basic Auth, Header Auth or None)",placeholder:"Select Authentication type"},validationRules:{required:"Auth type is required"},viewOnly:u,id:i})}),v&&v!==Pl.NONE&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:"properties.auth_id",control:g,meta:{options:jr(f),displayProps:{loading:h},displayName:"Authentication",value:"",htmlProps:{showAddNew:!0},TESSERACT_MAIN_URL:o,FRONTEND_URL:a,ENTITY_ID:s,openIntegrationDrawer:c,addNewButtonText:"Add new",searchFieldPlaceholder:"Search authentication",authType:"AUTHENTICATION",description:"Select Authentication you have saved in the Secrets. You can also create a new Secret using Add new button. Your credentials are encrypted & can be removed at any time.",placeholder:"Select Authentication"},validationRules:{required:"Authentication is required"},viewOnly:u,id:i,groupBy:"integration_meta.auth_type"})})]})}),d.jsx(E.Divider,{}),d.jsx(kr,{children:d.jsx(E.Grid,{container:!0,gap:1.5,children:d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Qu,{name:"properties.test_payload",label:"Test Trigger Payload",viewOnly:u,required:!0,id:r,validationRules:{required:"Value is required"},fullScreen:!0,showSuggestions:!0,excludePayloadSuggestions:!0})})})})]})}),YA=({fieldId:e,isOptional:t,type:n,control:r,viewOnly:i,isLoop:o,validationHandlers:s,id:a})=>{const l=Ds(e),u=_r(n,e),c=s?.[e];return d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Wn,{id:a,name:`properties.${e}`,control:r,meta:{displayName:l,description:u,placeholder:""},viewOnly:i,editorId:`${n}-${e}`,showSuggestions:!0,isLoop:o,validationRules:{...!c&&!t&&{required:`${Ds(e)} is required`},...c&&{validate:c}},required:!t})})},not=({isLoop:e,activityType:t,viewOnly:n,suggestionsData:r,id:i})=>{const{control:o,watch:s}=Hn(),a=s("properties"),{createNewThread:l}=a;return d.jsxs(E.Grid,{container:!0,gap:1,children:[d.jsxs(E.Grid,{item:!0,gap:0,children:[d.jsx(gn,{name:"properties.createNewThread",control:o,render:({field:{onChange:u,value:c,...f}})=>d.jsx(E.FormControlLabel,{label:"Continue Conversation",labelPlacement:"end",control:d.jsx(E.Switch,{...f,onChange:()=>u(!c),checked:!c,disabled:n}),componentsProps:{typography:{variant:"smNormal"}}})}),d.jsx(E.FormHelperText,{children:l?"A new conversation thread will be created. You can add a title if you like.":"Enter the Conversation ID to continue where you left off"})]}),d.jsx(YA,{fieldId:l?"title":"conversationId",type:t,control:o,viewOnly:n,isLoop:e,isOptional:l,id:i}),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Qu,{name:"properties.conversationContext",label:"Conversation Context",viewOnly:n,suggestionsData:r,description:"Add extra details to guide the AI agent in this conversation.",id:i,showSuggestions:!0,fullScreen:!0,data:a.conversationContext||{}})})]})},rot=({isLoop:e,activityType:t,viewOnly:n,validationHandlers:r,suggestionsData:i,id:o})=>{const{control:s,watch:a,clearErrors:l}=Hn(),u=E.useTheme(),c=["hostId","email","phone","userId","additionalFields"],f=a("properties"),{email:p,phone:h,createNewUser:A,hostId:g,userId:m,createNewThread:O,conversationId:y,createAnonymousUser:v}=f||{},T=!O&&y?.trim();return d.jsxs(E.Grid,{container:!0,gap:1,children:[d.jsxs(E.Grid,{container:!0,flexDirection:"column",children:[d.jsx(gn,{name:"properties.createAnonymousUser",control:s,render:({field:{onChange:_,value:x,...b}})=>d.jsx(E.FormControlLabel,{label:"Anonymous User",labelPlacement:"end",control:d.jsx(E.Switch,{...b,onChange:w=>{const{checked:D}=w.target;_(!!D),D&&l(c.map(I=>`properties.${I}`))},checked:x,disabled:n}),componentsProps:{typography:{variant:"smNormal"}}})}),v&&d.jsx(E.FormHelperText,{children:"An anonymous user will be created for this conversation."})]}),v?d.jsx(Fl,{message:"An anonymous user will be used for this conversation."}):d.jsxs(E.Box,{display:"flex",flexDirection:"column",gap:1,sx:{border:"1px solid",borderColor:u.palette.grey.brainstem,boxShadow:"none",width:"100%",p:"10px",borderRadius:2.5},children:[d.jsxs(E.Grid,{container:!0,flexDirection:"column",children:[d.jsx(gn,{name:"properties.createNewUser",control:s,render:({field:{onChange:_,value:x,...b}})=>d.jsx(E.FormControlLabel,{label:"Use Existing User",labelPlacement:"end",control:d.jsx(E.Switch,{...b,onChange:()=>_(!x),checked:!x,disabled:n}),componentsProps:{typography:{variant:"smNormal"}}})}),d.jsx(E.FormHelperText,{children:A?"Fill in details to continue with a new user.":"Enter the user's ID to continue with an existing account."})]}),T&&d.jsx(Fl,{message:"Note: You are using an existing conversation thread. If Host ID and User ID is ignored the previous conversation user will be used."}),d.jsx(YA,{fieldId:"hostId",type:t,control:s,viewOnly:n,isLoop:e,validationHandlers:r,isOptional:A?!1:!g&&m?.trim()||T,id:o}),A?d.jsxs(d.Fragment,{children:[d.jsx(YA,{fieldId:"name",type:t,control:s,viewOnly:n,isLoop:e,isOptional:!0,id:o}),d.jsx(YA,{fieldId:"email",type:t,control:s,viewOnly:n,isLoop:e,isOptional:!!h||!p&&h,validationHandlers:r,id:o}),d.jsx(YA,{fieldId:"phone",type:t,control:s,viewOnly:n,isLoop:e,isOptional:!!p,validationHandlers:r,id:o}),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Qu,{name:"properties.additionalFields",label:"Additional Fields",viewOnly:n,description:"Extra information about the user",id:o,showSuggestions:!0,fullScreen:!0,data:f.additionalFields||{},suggestionsData:i})})]}):d.jsxs(d.Fragment,{children:[d.jsx(YA,{fieldId:"userId",type:t,control:s,viewOnly:n,isLoop:e,isOptional:!m&&g?.trim()||T,validationHandlers:r,id:o}),d.jsx(Fl,{message:`${T?"":"You can provide either a Host ID or a User ID. "}If you enter both, the Host ID will be used first.`})]})]})]})},iot=Object.freeze(Object.defineProperty({__proto__:null,CopilotWebhook:CBe,apiActivity:T6e,askAgent:e=>{const t=gt.useDispatch(),n=E.useTheme(),{id:r,formData:i,ENTITY_ID:o,NEO_MAIN_URL:s,type:a,isLoop:l=!1,viewOnly:u=!1,TRINITY_MAIN_DOMAIN:c,TESSERACT_MAIN_URL:f,FRONTEND_URL:p,suggestionsData:h}=e,{control:A,setValue:g,watch:m,formState:{errors:O},clearErrors:y}=Hn(),v=m("properties"),[T,_]=C.useState([]),x=C.useMemo(()=>T.map(V=>({title:V.name,value:V.id,disabled:!V.active,icon:V.icon,active:V.active})),[T]),[b,w]=C.useState(!1),[D,I]=C.useState(""),P=O?.properties,k=async()=>{try{w(!0);const V=Yt(s,`/v1/org/${o}/copilotapps`),J=(await Xt.get(V,{params:{page:1,limit:99}})).data.items;return _(J),J}catch(V){return dn(V,t),[]}finally{w(!1)}};C.useEffect(()=>{k().then(V=>{if(!vt(i?.properties)&&i?.properties?.copilot_id&&!V?.find(J=>J?.id===i?.properties?.copilot_id))throw new Error("Copilot not found")}).catch(V=>{g("properties.copilot_id","",{}),g("properties.copilot_name","",{}),dn({message:V?.message||""},t)})},[]);const N=()=>{const{createNewUser:V,userId:X,hostId:J,conversationId:ee}=v||{};if(!(ee&&!V)&&!V&&!X?.trim()&&!J?.trim())return"User Id is required"},L=()=>{const{createNewUser:V,hostId:X,userId:J,conversationId:ee}=v||{};if(!(ee&&!V)&&(V||!J?.trim())&&!X?.trim())return"Host Id is required"},M=V=>{if(!V)return!1;if(B(V))return!0;const X=V.replace(/[^\d+]/g,"");return/^\+[1-9]\d{7,14}$/.test(X)},B=V=>/^\{\{.*?\}\}$/.test(V),Q=V=>B(V)?!0:pu(V),U=V=>{const{createNewUser:X,email:J,phone:ee}=v||{};if(!X)return;const le=(J||"").trim(),re=(ee||"").trim();if(!le&&!re)return`${Ds(V)} is required.`;if(V==="email"&&le&&!Q(le))return"Provide a valid email address.";if(V==="phone"&&re&&!M(re))return"Provide a valid phone number."},q=(V,X)=>()=>{const J=V(X);return J||y(`properties.${{email:"phone",phone:"email"}[X]}`),J},F=V=>(X,J)=>{I(J?V:"")},W=V=>{const X=`${c}/accounts/${o}/cp/${V}/overview`;window.open(X,"_blank")},G=()=>{const V=`${c}/accounts/${o}/dashboard?create_agent=true`;window.open(V,"_blank")},R={userId:N,email:q(U,"email"),phone:q(U,"phone"),hostId:L},$=(v.createNewUser?["hostId","email","phone"]:["userId","hostId"]).some(V=>P?.[V]),Y=v.createNewThread?[]:["conversationId"],z=Y.some(V=>P?.[V]),H=C.useMemo(()=>[{type:"conversation",Component:not,hasError:z,fields:Y},{type:"user",Component:rot,hasError:$}],[z,$,Y.length]);return d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(no,{children:d.jsx(E.Grid,{container:!0,gap:1.5,children:d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:"properties.copilot_id",control:A,meta:{options:x,displayProps:{loading:b,refreshing:b},displayName:"AI Agent",TESSERACT_MAIN_URL:f,FRONTEND_URL:p,ENTITY_ID:o,addNewButtonText:"Add new AI Agent",searchFieldPlaceholder:"Search AI Agents",authType:"",description:_r(a,"AI Agent"),htmlProps:{showAddNew:!0,onClickAddNew:G},showSearchOnLoad:!0,placeholder:"Select AI Agent"},validationRules:{required:"AI Agent is required"},viewOnly:u,id:"properties.copilot_id",handleChange:({value:V})=>{g("properties.copilot_id",V,{shouldValidate:!0}),g("properties.copilot_name",x.find(X=>X?.value===V)?.title)},renderValueUi:V=>{const X=x.find(J=>J?.value===V);return X?d.jsxs(E.Stack,{direction:"row",alignItems:"center",gap:1,children:[d.jsx(fh,{src:X.icon,alt:X.title,width:24,height:24}),d.jsx(E.Typography,{variant:"smMedium",children:X.title})]}):""},renderOption:V=>d.jsxs(E.MenuItem,{value:V.value,disabled:!V.active,"data-testid":`menu-item-${V.value}`,sx:{display:"flex",width:"100%",justifyContent:"flex-start",mx:1,height:"auto",p:"8px !important",minHeight:"fit-content !important","&.Mui-selected":{backgroundColor:"auto","& .MuiTypography-root":{color:n.palette.primary.main}},"&.Mui-disabled":{opacity:1,"& > :not(.redirect-action-button)":{opacity:.5,pointerEvents:"none"},"& .redirect-action-button, & .redirect-action-button *":{opacity:1,pointerEvents:"auto"}}},children:[d.jsx(fh,{src:V.icon,alt:V.title,width:24,height:24}),d.jsx(E.Typography,{variant:"smMedium",sx:{opacity:V.active?1:.8},children:V.title}),d.jsx(E.IconButton,{onClick:X=>{X.stopPropagation(),W(V.value)},size:"small","data-testid":"copilot-launch-btn",sx:{mr:1,ml:"auto",display:"inline-block"},className:"redirect-action-button",children:d.jsx(Ue,{src:"ic_open_in_new",width:n.icons.md,height:n.icons.md,sx:{path:{fill:n.palette.primary.main}}})})]},V.value),refreshOptions:k,refreshing:b,willRefresh:!0,refreshTooltip:"Refresh AI Agents"})})})}),v.copilot_id&&d.jsxs(d.Fragment,{children:[d.jsx(E.Divider,{}),d.jsx(kr,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Wn,{id:r,name:"properties.query",control:A,meta:{displayName:"Query",description:_r(a,"query"),placeholder:"Type the question or message you'd like to send to the AI agent."},viewOnly:u,editorId:`${a}-query`,showSuggestions:!0,isLoop:l,validationRules:{required:"Query cannot be empty"},multiline:!0,required:!0,size:"sm"})}),H.map(V=>{const{type:X,Component:J,hasError:ee}=V,le=X.toLowerCase();return d.jsx(E.Box,{sx:{border:"1px solid",borderColor:ee?n.palette.error.main:n.palette.grey.brainstem,boxShadow:ee?`0 0 4px ${n.palette.error.main}`:"none",width:"100%",p:"10px",borderRadius:2.5},children:d.jsxs(E.Accordion,{expanded:D===le||ee,onChange:F(le),children:[d.jsx(E.AccordionSummary,{sx:{"& .MuiAccordionSummary-content":{m:0},p:0},expandIcon:d.jsx(Hp.GridExpandMoreIcon,{}),children:d.jsx(E.Box,{sx:{display:"flex",alignItems:"center"},children:d.jsx(E.FormControl,{fullWidth:!0,children:d.jsx(E.Typography,{variant:"smMedium",children:Ds(X)})})})}),d.jsx(E.AccordionDetails,{sx:{mt:2},children:d.jsx(E.Grid,{container:!0,gap:1,children:d.jsx(J,{isLoop:l,activityType:e.type,viewOnly:u,validationHandlers:R,suggestionsData:h,id:r})})})]})},le)}),!l&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Fi,{viewOnly:u,type:a})})]})})]})]})},bolticStorageActivity:x6e,bolticTableActivity:lBe,boltic_storage:S6e,boltic_table:b6e,browserbase:cBe,calendly:dBe,converterActivity:vBe,emailActivity:DBe,executeChildWorkflow:PBe,fp_webhook:UBe,functionActivity:VBe,gmailActivity:QBe,gmail_trigger:GBe,googleCalendarActivity:JKe,googleMeet:eZe,googleSheetsReadActivity:tZe,googleSheetsWriteActivity:nZe,gpt:iZe,graphql:oZe,http:sZe,ifActivity:pZe,logConsole:mZe,loop:OZe,mapper:vZe,mcp:_Ze,monitor:IZe,parallel:DZe,response:PZe,schedule:$Ze,serverless:Fte,slackActivity:Yit,slack_trigger:Wit,sleep:qit,switchActivity:Zit,template:eot,webhook:tot},Symbol.toStringTag,{value:"Module"})),oot=C.forwardRef((e,t)=>{const{type:n,formData:r,selectedNode:i,onClose:o,isLoop:s=!1,cloudRef:a,suggestionsData:l,openIntegrationDrawer:u,INTEGRATION_DATA:c,SET_INTEGRATION_DATA:f,isLoading:p=!1,handleRunActivity:h,handleCompleteSetup:A,MCP_INTEGRATION_FORM:g=!1,onSubmit:m}=e,{viewOnly:O}=gt.useSelector(Q=>Q.canvas),{loopSuggestionsData:y={}}=gt.useSelector(Q=>Q.loopActivity),{form:v,formSchema:T,loading:_,handleFocus:x,handleChange:b,handleCustom:w,setForm:D,handleCancel:I,setFormSchema:P,GraphQLInspectorModal:k}=vx({formData:r,isLoop:s,selectedNode:i,INTEGRATION_DATA:c,SET_INTEGRATION_DATA:f,onClose:o,handleRunActivity:h,handleCompleteSetup:A,openIntegrationDrawer:u,onSubmit:m,MCP_INTEGRATION_FORM:g}),N=()=>{},L=(Q,U="")=>{if(!s){const q={type:n,name:i.data.name,properties:Q};e.onSubmit?.(q,U)}};C.useImperativeHandle(t,()=>({getData:()=>({name:i.data.properties.activity_name,properties:v,type:n}),validateForm:()=>!0,resetFormData:()=>{D({}),P([])}}),[v]);const B=Tx(T)?Sx(T,v):T;return d.jsxs(E.Box,{sx:{overflowY:"auto",height:"100%","& .MuiSwitch-root":{marginLeft:"7px"}},children:[d.jsx(Ex,{ref:a,name:`${i.id}-db-form`,schema:g?T:B,onSubmit:L,onChange:b,onFocus:x,onReset:N,onCancel:I,onCustom:w,form:v,isLoading:_||p,suggestions:s||g?y:l,useDefaultButtons:!1,viewOnly:O,MCP_INTEGRATION_FORM:g,MCP_EXCLUDED_FIELDS:Zd}),d.jsx(k,{})]})}),sot=wo(oot),aot=C.forwardRef(({type:e,formData:t,onSubmit:n,selectedNode:r,onClose:i,cloudRef:o,openIntegrationDrawer:s,INTEGRATION_DATA:a,SET_INTEGRATION_DATA:l,isLoading:u=!1,setPollingInterval:c},f)=>{const{viewOnly:p}=gt.useSelector(k=>k.canvas),{form:h,formSchema:A,loading:g,handleFocus:m,handleChange:O,handleCustom:y,setForm:v,handleCancel:T,setFormSchema:_,GraphQLInspectorModal:x}=vx({formData:t,selectedNode:r,INTEGRATION_DATA:a,SET_INTEGRATION_DATA:l,onClose:i,openIntegrationDrawer:s,onSubmit:n,setPollingInterval:c});C.useImperativeHandle(f,()=>({getData:()=>({name:r.data.properties.activity_name,properties:h,type:e}),validateForm:()=>!0,resetFormData:()=>{v({}),_([])}}),[h]);const b=(k,N="")=>{const L=k,M={type:e,name:r.data.name,properties:{...L}};n?.(M,N)},w=()=>{},I=Tx(A)?Sx(A,h):A,P=h;return d.jsxs(E.Box,{sx:{overflowY:"auto",height:"100%","& .MuiSwitch-root":{marginLeft:"7px"}},children:[d.jsx(Ex,{ref:o,name:`${r.data.name}-trigger-integration-form`,schema:I,onSubmit:b,onChange:O,onFocus:m,onReset:w,onCancel:T,onCustom:y,form:P,isLoading:g||u,useDefaultButtons:!1,viewOnly:p}),d.jsx(x,{})]})}),lot=C.forwardRef((e,t)=>{const{type:n,formData:r,selectedNode:i,isLoop:o=!1,cloudRef:s,suggestionsData:a,onClose:l,openIntegrationDrawer:u,INTEGRATION_DATA:c,SET_INTEGRATION_DATA:f,isLoading:p=!1,handleCompleteSetup:h,handleRunActivity:A,onSubmit:g,source:m,MCP_INTEGRATION_FORM:O=!1}=e,{viewOnly:y}=gt.useSelector(U=>U.canvas),{loopSuggestionsData:v={}}=gt.useSelector(U=>U.loopActivity),{form:T,formSchema:_,loading:x,handleFocus:b,handleChange:w,handleCustom:D,setForm:I,handleCancel:P,setFormSchema:k,GraphQLInspectorModal:N}=vx({formData:r,isLoop:o,selectedNode:i,INTEGRATION_DATA:c,SET_INTEGRATION_DATA:f,onClose:l,handleRunActivity:A,handleCompleteSetup:h,openIntegrationDrawer:u,onSubmit:g,source:m,MCP_INTEGRATION_FORM:O}),L=()=>{},M=(U,q="")=>{if(O&&I(U),!o){const F={type:n,name:i.data.name,properties:U};e.onSubmit?.(F,q)}};C.useImperativeHandle(t,()=>({getData:()=>({name:i.data.properties.activity_name,properties:T,type:n}),validateForm:()=>!0,resetFormData:()=>{I({}),k([])}}),[T]);const Q=Tx(_)?Sx(_,T):_;return d.jsxs(E.Box,{sx:{overflowY:"auto",height:"100%","& .MuiSwitch-root":{marginLeft:"7px"}},children:[d.jsx(Ex,{ref:s,name:`${i.id}-integration-form`,schema:O?_:Q,onSubmit:M,onChange:w,onFocus:b,onReset:L,onCancel:P,viewOnly:y,onCustom:D,form:T,isLoading:x||p,useDefaultButtons:!1,suggestions:o||O?v:a,MCP_INTEGRATION_FORM:O,MCP_EXCLUDED_FIELDS:Zd}),d.jsx(N,{})]})}),uot=wo(lot),$te=C.forwardRef((e,t)=>{const{type:n,selectedNode:r,formData:i,initialState:o,onSubmit:s,onClose:a,openIntegrationDrawer:l,ENTITY_ID:u,WORKFLOW_URLS:c,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,source:h,isExecutionLoading:A=!1,isLoop:g=!1,viewOnly:m,actionRef:O,activityDataRef:y,handleRunActivity:v,handleCompleteSetup:T,setPollingInterval:_,methods:x,activityName:b,MCP_INTEGRATION_FORM:w=!1}=e,{VORTEX_MAIN_URL:D,SERVERLESS_URL:I,TESSERACT_MAIN_URL:P,FRONTEND_URL:k,VORTEX_WEBHOOK_URL:N,VORTEX_SYNC_DOMAIN:L,HITMAN_PUBLIC_DOMAIN:M,HITMAN_PLTM_URL:B,ATHENA_MAIN_URL:Q,NEO_MAIN_URL:U,TRINITY_MAIN_DOMAIN:q}=c||{},F=W=>{let G=W;r.data.type===Je.LOOP&&(G=y.current?.getData());const R=$b(G);s({...r.data,type:r.data.type,name:b||r.data.name,properties:R,id:r.id})};switch(n){case"CloudTrigger":return d.jsx(aot,{id:r.id,ref:y,cloudRef:O,formData:i,onSubmit:s,initialState:o,isLoading:A,type:n,selectedNode:r,VORTEX_MAIN_URL:D,openIntegrationDrawer:l,ENTITY_ID:u,TESSERACT_MAIN_URL:P,onClose:a,FRONTEND_URL:k,SERVERLESS_URL:I,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,setPollingInterval:_});case"platformFdkActivity":case"applicationFdkActivity":case"customActivity":return d.jsx(uot,{id:r.id,ref:y,cloudRef:O,formData:i,handleRunActivity:v,initialState:o,handleCompleteSetup:T,isLoading:A,onSubmit:s,openIntegrationDrawer:l,type:n,FRONTEND_URL:k,selectedNode:r,ENTITY_ID:u,onClose:a,WORKFLOW_URLS:c,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,source:h,isLoop:g,MCP_INTEGRATION_FORM:w,...g?{useDefaultButtons:!1}:{}});case"CloudDatabase":return d.jsx(sot,{id:r.id,ref:y,cloudRef:O,formData:i,initialState:o,handleRunActivity:v,handleCompleteSetup:T,onSubmit:s,openIntegrationDrawer:l,type:n,FRONTEND_URL:k,isLoading:A,selectedNode:r,ENTITY_ID:u,onClose:a,WORKFLOW_URLS:c,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,isLoop:g,MCP_INTEGRATION_FORM:w,...g?{useDefaultButtons:!1}:{}});case"serverless":return d.jsx(Fte,{id:r.id,ref:y,handleRunActivity:v,handleCompleteSetup:T,cloudRef:O,formData:i,isLoading:A,onSubmit:s,type:n,openIntegrationDrawer:l,FRONTEND_URL:k,initialState:o,selectedNode:r,ENTITY_ID:u,onClose:a,WORKFLOW_URLS:c,activity_id:r.data.activity_id,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,isLoop:g,...g?{useDefaultButtons:!1}:{}});default:{const G={...iot}[n];return G?(w&&C.useImperativeHandle(O,()=>({getData:()=>({name:r.data.properties.activity_name,properties:i,type:n}),validateForm:()=>!0,handleSubmit:async()=>{const R=await x?.trigger();if(R){let j=x?.getValues();j=o1(j,Zd),F(j)}return R},isValidated:x?.formState?.isValid}),[i,n,r.data.properties.activity_name,x]),g?d.jsx(G,{ref:y,formData:i,id:r.id,onSubmit:s,onClose:a,type:n,openIntegrationDrawer:l,initialState:o,ENTITY_ID:u,VORTEX_MAIN_URL:D,SERVERLESS_URL:I,TESSERACT_MAIN_URL:P,FRONTEND_URL:k,VORTEX_WEBHOOK_URL:N,VORTEX_SYNC_DOMAIN:L,HITMAN_PUBLIC_DOMAIN:M,HITMAN_PLTM_URL:B,INTEGRATION_DATA:f,WORKFLOW_URLS:c,ATHENA_MAIN_URL:Q,SET_INTEGRATION_DATA:p,source:h,viewOnly:m,isLoop:g,MCP_INTEGRATION_FORM:w}):d.jsx("form",{autoComplete:"off",style:{height:"100%"},onSubmit:x.handleSubmit(F),children:d.jsx(G,{ref:y,formData:i,id:r.id,onSubmit:s,onClose:a,type:n,openIntegrationDrawer:l,initialState:o,ENTITY_ID:u,VORTEX_MAIN_URL:D,SERVERLESS_URL:I,TESSERACT_MAIN_URL:P,FRONTEND_URL:k,VORTEX_WEBHOOK_URL:N,VORTEX_SYNC_DOMAIN:L,HITMAN_PUBLIC_DOMAIN:M,HITMAN_PLTM_URL:B,INTEGRATION_DATA:f,WORKFLOW_URLS:c,ATHENA_MAIN_URL:Q,SET_INTEGRATION_DATA:p,source:h,viewOnly:m,isLoop:g,MCP_INTEGRATION_FORM:w,NEO_MAIN_URL:U,TRINITY_MAIN_DOMAIN:q})})):null}}}),Ute=({onSubmit:e,selectedNode:t,onClose:n,initialState:r,drawerWidth:i,setSelectedNode:o,openIntegrationDrawer:s,INTEGRATION_DATA:a,SET_INTEGRATION_DATA:l,openDocs:u,setOpenDocs:c,source:f,actionRef:p,MCP_INTEGRATION_FORM:h=!1})=>{const A=E.useTheme(),g=gt.useDispatch(),m=Rt.useNodes(),{setNodes:O,getNode:y,getEdges:v}=Rt.useReactFlow(),T=p||C.useRef(null),_=C.useRef(null),x=C.useMemo(()=>vo(),[]),{activities:b,triggers:w,reserved_keywords:D,activity_names:I}=gt.useSelector(Ye=>Ye.activities),{canvasWorkflow:P,activityExecutionData:k,viewOnly:N=!1,triggerNodeTest:L}=gt.useSelector(Ye=>Ye.canvas),M=ui(b?.data?.data,w?.data?.data,t.data,"slug"),{ENTITY_ID:B,WORKFLOW_URLS:Q,openAddonModal:U,currentSubscription:q}=Ci(),{workflow:F}=gt.useSelector(Ye=>Ye.workflows),W=f||F?.source||"",G=JO(t,W),R=H_({defaultValues:G,mode:"onChange"}),j=C.useRef(null),{analytics:$={}}=Ci(),[Y,z]=C.useState(!1),[H,V]=C.useState([]),[X,J]=C.useState(!1),ee=C.useRef(null),le=C.useRef(0),{data:re}=m.find(Ye=>Ye.id===t?.id)||{},{blt_node_states:ue}=re||{},{test:Oe="",setup_and_configure:ve="",node:oe=""}=ue||{},[ae,te]=C.useState(0),[Z,ne]=C.useState([{label:"Setup & Configure",state:"default"},{label:"Test",state:""}]),{initialNodes:se=[]}=gt.useSelector(Ye=>Ye.workflows),pe=C.useMemo(()=>{try{return!xf.includes(t?.data?.type)}catch{return!0}},[t?.data?.type]);C.useEffect(()=>{const Ye=[{label:"Setup & Configure",state:"default"}];ne(pe?[...Ye,{label:"Test",state:""}]:Ye),te(0)},[pe]),C.useEffect(()=>()=>{j.current&&clearTimeout(j.current)},[]);const he=Ye=>{ne(ht=>ht.map((Ot,wt)=>{const We=["setup_and_configure","test"][wt];return Ye[We]?{...Ot,state:qFe(Ye[We])}:Ot}))};C.useEffect(()=>{(ve||Oe||oe)&&he({setup_and_configure:ve||"default",test:Oe||"",node:oe||""})},[ve,Oe,oe]);const de=C.useRef(!1),xe=C.useRef(null);C.useEffect(()=>{if(t?.id)if(L?.nodeId===t.id){te(1);const Ye=`${L.nodeId}-${L.runWithPrevious}`;if(xe.current===Ye){g({type:_b});return}xe.current=Ye,je(L.runWithPrevious),g({type:_b}),de.current=!0}else xe.current=null,de.current?de.current=!1:te(oe==="completed"&&pe?1:0)},[t?.id,L?.nodeId,L?.runWithPrevious,oe,pe]);const{VORTEX_MAIN_URL:ge}=Q,[Ee,ke]=C.useState(!1),[Ge,$e]=C.useState(t?.data?.name||""),[et,rt]=C.useState(null),it=Sr(x),Re=Sr(Pn.VERSION),[Xe,qe]=C.useState(null),Se=async Ye=>await Lue(Ye.trim(),t.data.name,D,I)||null,_e=C.useRef(wa(Ye=>{g({type:Yn,payload:{open:!0,title:Ye,type:"error",width:"30rem",duration:3e3}})},300)).current,be=async Ye=>{$e(Ye);const ht=await Se(Ye.trim());if(ht){rt(ht),_e(ht);return}const Ot=t.data.name;let wt=ko(I);if(wt.includes(Ot)){const we=wt.findIndex(We=>We===Ot);wt=[...wt.slice(0,we),Ye.trim(),...wt.slice(we+1)]}else wt=[...wt,Ye.trim()];g({type:bi.SET_ACTIVITY_NAMES,payload:wt}),O(we=>{const Ze=JSON.stringify(we).replace(new RegExp(`{{${Ot}`,"g"),`{{${Ye.trim()}`).replace(new RegExp(`result.${Ot}`,"g"),`result.${Ye.trim()}`);return JSON.parse(Ze)}),rt(null),ce(Ye.trim())},K=()=>{["error","completed"].includes(Oe)||x===Br.DRAFT&&Ia(O,t,{}),n(),c?.(!1)},ce=Ye=>{const ht=_.current?.getData()||R.getValues();o(Ot=>Ot?{...Ot,data:{...Ot.data,name:Ye,properties:{...ht?.properties}}}:null),O(Ot=>Ot.map(wt=>wt.id===t.id?{...wt,data:{...wt.data,name:Ye}}:{...wt}))},Te=async(Ye,ht,Ot)=>{const wt=[...Array.isArray(m)?m:[]],we={nodes:ht?[Ac({...Ye})]:[Ac({...t,data:Ye})],result:X0(P,m,k,Ye?.id||t?.id,v())};z(!0);const We=Re||it;J(!0);const{success:Ze,isError:De,data:st}=await z0(ht?Ye:t,g,ge,B,wt,m,we,j,$,We,U,q,Ot,void 0,void 0,Ot?v():void 0);if(Ze&&!De)return Me(),z(!1),Ze;if(De&&(setTimeout(()=>{Me()},500),st)){delete st.singleRunFailure,Ia(O,t,{test:"error",node:"failed",setup_and_configure:"completed"});const yt=Object.keys(st);yt&&yt.length>0&&yt.forEach(zt=>{XO(st[zt]).forEach(Rn=>{g({type:Yn,payload:{open:!0,title:typeof Rn!="string"?JSON.stringify(Rn):Rn,type:"error",width:"30rem",duration:3e3}})})})}return z(!1),!1},je=async Ye=>{const ht=await Se(Ge.trim()),Ot=pd(t.data);if(ht&&Ot!==xt.TRIGGER){_e(ht);return}const wt=m.find(We=>We.id===t.id);let we=!0;we=await Te({...wt,outgoingPorts:[Je.IF,Je.SWITCH].includes(t.data.type)?t?.outgoingPorts||wt?.outgoingPorts||[]:[]},!0,Ye),we&&(Ia(O,t,{test:"completed",node:"completed"}),z(!1))},Fe=async(Ye,ht,Ot=!1)=>{Ye.preventDefault();const wt=await Se(Ge.trim()),we=pd(t.data);if(wt&&we!==xt.TRIGGER){_e(wt);return}if(we===xt.TRIGGER||vt(et)){const We=await R.trigger();let Ze;if(t?.data?.type===Je.LOOP&&_.current&&(Ze=await _.current?.validateForm()),We&&(t?.data?.type!==Je.LOOP||Ze!==!1)||Ot){const De=m?.find(yt=>yt.id===t.id)?.data?.properties;let st=R.watch();if(t.data.type===Je.LOOP&&_.current&&(st=_.current.getData()),Ad.includes(t.data.type)&&(st={...st,properties:{...typeof st.properties=="object"&&st.properties?st.properties:{},...typeof De=="object"&&De?De:{}}}),ht==="skip_test"){const yt=$b(st);e({...t.data,type:t.data.type,name:Ge||t.data.name,properties:{...yt,integration_slug:M},id:t.id},ht)}if(ht==="save"){l(null),te(0),ne(yt=>yt.map(zt=>({...zt,state:"default"}))),g({type:dd,payload:null}),n();return}pe&&(te(1),ne(yt=>yt.map(zt=>({...zt,state:zt.state===""?"default":zt.state}))))}}};C.useEffect(()=>{if(h)return;const Ye=m.find(ht=>ht.id===t?.id);(!Ye||Ye?.type===xt.PLACEHOLDER)&&o(null)},[m,o,t?.id,h]),C.useEffect(()=>{if(ke(!1),t?.id){const ht=m.find(we=>we.id===t?.id)||t;if(!ht?.data)return;const Ot=Mb(ht.data);if(ee.current===Ot)return;ee.current=Ot;const wt=JO(ht,W);R.reset(wt,{keepDefaultValues:!1,keepErrors:!1,keepDirty:!1,keepIsSubmitted:!1,keepTouched:!1,keepIsValid:!1,keepSubmitCount:!1}),$e(wt.name)}else ee.current=null},[t?.id,m,R,W]);const He=ui(b?.data?.data,w?.data?.data,t.data),dt=ui(b?.data?.data,w?.data?.data,t.data,"meta"),Tt=C.useMemo(()=>{const Ye=m.find(ht=>ht.id===t?.id);return Ye?{...Ye.data}:{...t.data}},[t?.id,m]);C.useEffect(()=>()=>{l(null)},[]),C.useEffect(()=>{h||t&&(y(t.id)||o(null))},[m,h]);const Ie=ui(b?.data?.data,w?.data?.data,t.data,"status"),at=!!ui(b?.data?.data,w?.data?.data,t.data,"pro"),ct=async(Ye,ht="")=>{const Ot=await Se(Ge.trim()),wt=pd(t.data);if(Ot&&wt!==xt.TRIGGER){_e(Ot);return}if(ht===""){e({...Ye,name:Ee?Ge:t.data.name,id:t.id},ht);return}if(wt===xt.TRIGGER||vt(et)){let we=!0;if(ht==="skip_test")try{const We=se?.find(Ze=>Ze?.id===t?.id);Mb(We?.data)!==Mb(Ye)&&g({type:fd,payload:{type:"replace",data:{...k,[t?.id]:{}}}})}catch{}ht==="test_and_save"&&(we=await Te(Ye,!1)),we&&e({...Ye,name:Ee?Ge:t.data.name,id:t.id},ht)}pe&&(te(1),ne(we=>we.map((We,Ze)=>Ze===0?{...We,state:"completed"}:{...We,state:["error","completed"].includes(Oe)?Oe:"default"})))},nt=Ye=>{g({type:du,payload:{id:Ye}})},Mt=async Ye=>{const ht=m?.find(Ot=>Ot?.id===Ye);await Te(ht,!0)},Ht=()=>{te(0),c?.(!1),n(),ne(Ye=>Ye.map((ht,Ot)=>Ot===0?{...ht,state:"default"}:{...ht,state:"default"}))},St=async(Ye,ht)=>{const Ot=Yt(ge,`/v1.0/${B}/`,`workflows/${Ye}/integrations/${ht}/executions`);return await Xt.get(Ot)},Me=async()=>{const Ye=++le.current;J(!0);const ht=Re||it;try{if(t?.data?.type!=="webhook"&&ht){const{data:Ot}=await St(ht,t.data.properties.integration_slug&&t.id?`${t.data.properties.integration_slug}_${t.id}`:t.id);le.current===Ye&&V(Ot.data)}}catch(Ot){le.current===Ye&&dn(Ot,g)}finally{le.current===Ye&&J(!1)}},Ke=C.useMemo(()=>d.jsx($te,{type:t.data.type,selectedNode:t,formData:Tt,initialState:r,onSubmit:ct,onClose:Ht,openIntegrationDrawer:s,ENTITY_ID:B,WORKFLOW_URLS:Q,INTEGRATION_DATA:a,SET_INTEGRATION_DATA:l,source:f,isExecutionLoading:Y,actionRef:T,activityDataRef:_,handleRunActivity:Mt,handleCompleteSetup:nt,setPollingInterval:qe,methods:R,activityName:Ge,viewOnly:N,MCP_INTEGRATION_FORM:h},t?.id),[t?.id,t.data.type,Tt,r,ct,Ht,s,B,Q,a,l,f,Y,T,_,Mt,nt,qe,R,Ge,N]),lt=C.useMemo(()=>d.jsx(YFe,{activityExecutionList:H,setActivityExecutionList:V,ENTITY_ID:B,VORTEX_MAIN_URL:ge,selectedNode:t,loading:X,fetchActivityExecutions:Me,viewOnly:N}),[H,V,B,ge,t,X,Me,N]);return d.jsx(b1e,{MCP_INTEGRATION_FORM:h,MCP_EXCLUDED_FIELDS:Zd,children:d.jsx(IF,{...R,children:d.jsxs(E.Stack,{position:h?"relative":"absolute",top:0,right:0,sx:{height:"100%",width:"100%",...h?{border:`1px solid ${A.palette.grey[300]}`,borderRadius:2}:{borderLeft:`1px solid ${A.palette.grey[300]}`,borderRight:u?`1px solid ${A.palette.grey[300]}`:0},zIndex:A.zIndex.drawer+2},children:[!h&&d.jsxs(E.Stack,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{position:"sticky",top:0,zIndex:1,py:1.5,px:2,height:48},children:[d.jsxs(E.Stack,{direction:"row",alignItems:"center",gap:1.5,children:[He?d.jsx("img",{src:He,alt:t.data.name,width:30,height:30,style:{border:`1px solid ${A.palette.grey[300]}`,borderRadius:"4px",padding:"2px",width:32,height:32}}):d.jsx(E.Avatar,{variant:"square",sx:{width:32,height:32,p:2},children:t.data.name.slice(0,2).toUpperCase()}),d.jsx(eX,{value:t?.data.name,onSave:be,minWidth:64,maxWidth:240,isEditing:Ee,setIsEditing:Ye=>{ke(Ye),Ye&&rt(null)},disabled:N||t.type===xt.TRIGGER,maxLength:50,error:et,variant:"mdSemiBold",textSx:{color:A.palette.text.primary,maxWidth:240,lineHeight:"32px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},inputSx:{height:"100%",fontSize:"1.5rem",".MuiInputBase-input":{py:"5px",px:1,fontSize:"16px",fontWeight:600},"& .MuiFormHelperText-root.Mui-error":{width:"max-content"},"& .MuiInputBase-root.MuiOutlinedInput-root":{minHeight:"auto"}},autoResize:!0,enableDoubleClick:!0,showEditIcon:!N&&t.type!==xt.TRIGGER}),t?.type===xt.TRIGGER&&dt?.trigger_type===VO.SCHEDULED&&(dt?.polling_interval||Xe)&&d.jsx(E.Tooltip,{arrow:!0,title:`The trigger checks for new data every ${dt?.polling_interval||Xe} minutes.`,children:d.jsxs(E.Box,{display:"flex",alignItems:"center",borderRadius:1,ml:1,px:.5,sx:{border:`1px solid ${A.palette.grey.outlined.border}`},children:[d.jsx(Ue,{src:"ic_schedule",sx:{cursor:"pointer",mr:.5,width:18}}),d.jsxs(E.Typography,{variant:"xsMedium",sx:{fontStyle:"normal",lineHeight:"24px"},children:[dt?.polling_interval||Xe," mins"]})]})})]}),d.jsxs(E.Stack,{alignItems:"center",gap:1.5,flexDirection:"row",children:[Ie===Qp.DRAFT&&d.jsx(E.Stack,{direction:"row",alignItems:"center",sx:{padding:"2px 8px",borderRadius:6,background:Ye=>Ye.palette.grey[200]},children:d.jsx(E.Typography,{variant:"xsNormal",sx:{textTransform:"capitalize"},children:Ie})}),at&&d.jsx(Jd,{}),d.jsxs(E.Button,{onClick:()=>c?.(!u),variant:"outlined",sx:{px:"8px !important",py:"2px !important",borderRadius:"6px","&.MuiButtonBase-root.MuiButton-root.MuiButton-outlined":{border:`1px solid ${u?A.palette.primary.main:A.palette.neutral.outlined.border}`,"& path":{fill:u?A.palette.primary.main:A.palette.neutral.solid.bg}},"&:hover":{"& .MuiTypography-root":{color:A.palette.primary.main},"& path":{fill:A.palette.primary.main},"&.MuiButtonBase-root.MuiButton-root.MuiButton-outlined":{border:`1px solid ${A.palette.primary.main}`,"& path":{fill:A.palette.primary.main}}}},children:[d.jsx(Ue,{src:"ic_document"}),d.jsx(E.Typography,{variant:"smSemiBold",sx:{pl:.5,color:u?A.palette.primary.main:A.palette.neutral.plain},children:"Docs"})]}),d.jsx(E.IconButton,{onClick:K,sx:Di(A),children:d.jsx(Ue,{width:24,height:24,src:"ic_close"})})]})]}),!h&&d.jsx(E.Stack,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{position:"sticky",top:48,zIndex:1,py:1,px:2,height:48,backgroundColor:A.palette.white.smoke},children:d.jsx(o0e,{steps:Z,activeStep:ae,setActiveStep:te})}),d.jsxs(E.Stack,{gap:"12px",sx:{overflowY:"auto",p:2,height:h?"calc(100% - 10px)":"calc(100% - 152px)","&::-webkit-scrollbar":{width:"8px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:A.palette.grey[300],borderRadius:"4px"},"&::-webkit-scrollbar-thumb:hover":{background:A.palette.grey[400]}},children:[(ae===0||h)&&Ke,ae===1&&!h&<]}),!h&&d.jsx(t0e,{isExecutionLoading:Y,selectedNodeType:t.data.type,onClose:Ht,validateAndSubmit:Fe,activityExecutionList:H,isViewOnly:N,drawerWidth:i,selectedNode:t,activeStep:ae,ref:T,setNodes:O,testActivity:je,MCP_INTEGRATION_FORM:h})]})})})},cot=C.memo(e=>{const t=E.useTheme(),n=Rt.useNodes(),r=Rt.useEdges(),{setNodes:i,setEdges:o}=Rt.useReactFlow(),{canvasWorkflow:s}=gt.useSelector(O=>O.canvas),a=s?.meta?.isHorizontal??!0,{fromX:l,fromY:u,toX:c,toY:f,fromNode:p,sourcePosition:h,targetPosition:A}=e;if([l,u,c,f].some(O=>typeof O!="number"||Number.isNaN(O)))return null;C.useEffect(()=>{const{id:O}=p,y=r.filter(v=>v.source===O&&v.type===Un.PLACEHOLDER);if(y.length>0){let v=null,T=1/0;if(y.forEach(_=>{const x=n.find(b=>b.id===_.target);if(x){const b=x.position.y+(x.height||51)/2,w=Math.abs(b-u);w<T&&(T=w,v=_)}}),v&&T<30){const _=v.target,x=r.filter(D=>D.id!==v.id);o(x);const b=n.find(D=>D.id===O),w=n.filter(D=>D.id!==_);if(b){b.outgoingPorts=(b.outgoingPorts||[]).filter(I=>I.id!==_);const D=w.filter(I=>I.id!==O);i([...D,b])}else i(w)}}},[]);const[m]=Rt.getBezierPath({sourceX:a?c:l,sourceY:a?f:u,sourcePosition:a?A:h,targetX:a?l:c,targetY:a?u:f,targetPosition:a?h:A});return d.jsx("path",{fill:"none",stroke:t.palette.primary.main,strokeWidth:1.5,className:"animated",d:m})}),Hte=e=>String(e??"").trim(),dot=e=>String(e??"").split(",").map(t=>Hte(t)).filter(Boolean),_E=(e,t)=>{const n=Hte(e),r=dot(t);return!n||r.length===0?!1:r.includes(n)},xx=({edgeCenterX:e,edgeCenterY:t,onClick:n,isSelected:r=!1})=>{const i=E.useTheme();return d.jsxs("g",{className:`react-flow__edge-delete-button ${r?"selected":""}`,onClick:n,children:[d.jsx("foreignObject",{x:e-12,y:t-12,width:24,height:24,className:"react-flow__edge-delete-square",children:d.jsx("div",{className:"react-flow__edge-delete-square-inner"})}),d.jsx("g",{transform:`translate(${e-8}, ${t-8})`,className:"react-flow__edge-delete-icon",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",children:d.jsx("path",{fill:i.palette.error.main,d:"M11.667 2.5C11.903 2.50007 12.1011 2.57961 12.2607 2.73926C12.4204 2.89891 12.4999 3.09704 12.5 3.33301H15.833C16.0691 3.33301 16.267 3.41352 16.4268 3.57324C16.5865 3.73296 16.667 3.93088 16.667 4.16699C16.6669 4.40296 16.5864 4.60109 16.4268 4.76074C16.2671 4.92025 16.069 5 15.833 5V15.833C15.833 16.2913 15.6701 16.6844 15.3438 17.0107C15.0175 17.3369 14.6251 17.4999 14.167 17.5H5.83301C5.37489 17.4999 4.98253 17.3369 4.65625 17.0107C4.32986 16.6844 4.16699 16.2913 4.16699 15.833V5C3.93104 5 3.73291 4.92025 3.57324 4.76074C3.41359 4.60109 3.33308 4.40296 3.33301 4.16699C3.33301 3.93088 3.41352 3.73296 3.57324 3.57324C3.73296 3.41352 3.93088 3.33301 4.16699 3.33301H7.5C7.50007 3.09704 7.57961 2.89891 7.73926 2.73926C7.89891 2.57961 8.09704 2.50007 8.33301 2.5H11.667ZM5.83301 15.833H14.167V5H5.83301V15.833ZM8.33301 6.66699C8.56904 6.66699 8.76706 6.74664 8.92676 6.90625C9.08648 7.06597 9.16699 7.26389 9.16699 7.5V13.333C9.16699 13.5691 9.08648 13.767 8.92676 13.9268C8.76704 14.0865 8.56912 14.167 8.33301 14.167C8.09704 14.1669 7.89891 14.0864 7.73926 13.9268C7.57975 13.7671 7.5 13.569 7.5 13.333V7.5C7.5 7.26397 7.57964 7.06594 7.73926 6.90625C7.89891 6.7466 8.09704 6.66707 8.33301 6.66699ZM11.667 6.66699C11.903 6.66707 12.1011 6.7466 12.2607 6.90625C12.4204 7.06594 12.5 7.26397 12.5 7.5V13.333C12.5 13.569 12.4202 13.7671 12.2607 13.9268C12.1011 14.0864 11.903 14.1669 11.667 14.167C11.4309 14.167 11.233 14.0865 11.0732 13.9268C10.9135 13.767 10.833 13.5691 10.833 13.333V7.5C10.833 7.26389 10.9135 7.06597 11.0732 6.90625C11.2329 6.74664 11.431 6.66699 11.667 6.66699Z"})})})]})},bx=({edgeCenterX:e,edgeCenterY:t,onClick:n,isSelected:r=!1})=>{const i=E.useTheme();return d.jsxs("g",{className:`react-flow__edge-add-button ${r?"selected":""}`,onClick:n,children:[d.jsx("foreignObject",{x:e-12,y:t-12,width:24,height:24,className:"react-flow__edge-add-square",children:d.jsx("div",{className:"react-flow__edge-add-square-inner"})}),d.jsx("g",{transform:`translate(${e-12}, ${t-12})`,className:"react-flow__edge-add-icon",children:d.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("rect",{x:"0.5",y:"0.5",width:"23",height:"23",rx:"4",ry:"4",fill:"white"}),d.jsx("rect",{className:"add-button-border",x:"0.5",y:"0.5",width:"23",height:"23",rx:"4",ry:"4",stroke:i.palette.neutral?.outlined?.border,fill:"none"}),d.jsx("path",{className:"add-button-icon",fillRule:"evenodd",clipRule:"evenodd",d:"M11.333 14.6663V12.6663H9.33301C9.14412 12.6663 8.98579 12.6025 8.85801 12.4747C8.73023 12.3469 8.66634 12.1886 8.66634 11.9997C8.66634 11.8108 8.73023 11.6525 8.85801 11.5247C8.98579 11.3969 9.14412 11.333 9.33301 11.333H11.333V9.33301C11.333 9.14412 11.3969 8.98579 11.5247 8.85801C11.6525 8.73023 11.8108 8.66634 11.9997 8.66634C12.1886 8.66634 12.3469 8.73023 12.4747 8.85801C12.6025 8.98579 12.6663 9.14412 12.6663 9.33301V11.333H14.6663C14.8552 11.333 15.0136 11.3969 15.1413 11.5247C15.2691 11.6525 15.333 11.8108 15.333 11.9997C15.333 12.1886 15.2691 12.3469 15.1413 12.4747C15.0136 12.6025 14.8552 12.6663 14.6663 12.6663H12.6663V14.6663C12.6663 14.8552 12.6025 15.0136 12.4747 15.1413C12.3469 15.2691 12.1886 15.333 11.9997 15.333C11.8108 15.333 11.6525 15.2691 11.5247 15.1413C11.3969 15.0136 11.333 14.8552 11.333 14.6663ZM9.39967 18.1413C10.2108 18.4913 11.0775 18.6663 11.9997 18.6663C12.9219 18.6663 13.7886 18.4913 14.5997 18.1413C15.4108 17.7913 16.1163 17.3163 16.7163 16.7163C17.3163 16.1163 17.7913 15.4108 18.1413 14.5997C18.4913 13.7886 18.6663 12.9219 18.6663 11.9997C18.6663 11.0775 18.4913 10.2108 18.1413 9.39967C17.7913 8.58856 17.3163 7.88301 16.7163 7.28301C16.1163 6.68301 15.4108 6.20801 14.5997 5.85801C13.7886 5.50801 12.9219 5.33301 11.9997 5.33301C11.0775 5.33301 10.2108 5.50801 9.39967 5.85801C8.58856 6.20801 7.88301 6.68301 7.28301 7.28301C6.68301 7.88301 6.20801 8.58856 5.85801 9.39967C5.50801 10.2108 5.33301 11.0775 5.33301 11.9997C5.33301 12.9219 5.50801 13.7886 5.85801 14.5997C6.20801 15.4108 6.68301 16.1163 7.28301 16.7163C7.88301 17.3163 8.58856 17.7913 9.39967 18.1413ZM15.783 15.783C14.7497 16.8163 13.4886 17.333 11.9997 17.333C10.5108 17.333 9.24967 16.8163 8.21634 15.783C7.18301 14.7497 6.66634 13.4886 6.66634 11.9997C6.66634 10.5108 7.18301 9.24967 8.21634 8.21634C9.24967 7.18301 10.5108 6.66634 11.9997 6.66634C13.4886 6.66634 14.7497 7.18301 15.783 8.21634C16.8163 9.24967 17.333 10.5108 17.333 11.9997C17.333 13.4886 16.8163 14.7497 15.783 15.783Z",fill:i.palette.neutral?.solid?.bg})]})})]})},fot=e=>{const t=E.useTheme(),{canvasWorkflow:n}=gt.useSelector(z=>z.canvas),{ENTITY_ID:r,allowedAccount:i}=Ci(),o=_E(r,i),s=n?.meta?.isHorizontal??!0,{id:a,sourceX:l,sourceY:u,targetX:c,targetY:f,sourcePosition:p,targetPosition:h,style:A={stroke:t.palette.neutral.main},markerEnd:g,source:m,target:O,sourceHandle:y,targetHandle:v}=e;if([l,u,c,f].some(z=>typeof z!="number"||Number.isNaN(z))||!p||!h)return null;const T=Rt.useEdges(),_=Rt.useNodes(),{deleteElements:x}=Rt.useReactFlow(),b=gt.useDispatch(),{viewOnly:w}=gt.useSelector(z=>z.canvas),D=T.find(z=>z.id===a),I=D?.data?.isStraight===!0,P=()=>Rt.getBezierPath({sourceX:l,sourceY:u,sourcePosition:p,targetX:c,targetY:f,targetPosition:h,curvature:.25});let k,N,L;I&&s?Math.abs(u-f)<2?(k=`M ${l},${u} L ${c},${u}`,N=(l+c)/2,L=u):(k=`M ${l},${u} L ${c},${u} L ${c},${f}`,N=(l+c)/2,L=(u+f)/2):[k,N,L]=P();const M=c-l,B=f-u,Q=Math.sqrt(M*M+B*B),U=M/Q,q=B/Q,F=20,W=z=>{z.stopPropagation(),a&&x({nodes:[{id:D.target}],edges:[{id:a}]})},G=z=>{if(z.stopPropagation(),!w){b({type:Yp,payload:{x:z.clientX,y:z.clientY}}),b({type:S0,payload:!1});const H=`placeholder_${Math.trunc(Math.random()*1e9)}`;if(b({type:v0,payload:{id:H,edgeId:a,sourceNodeId:m,targetNodeId:O,sourceHandle:y,targetHandle:v}}),!o){b({type:ss,payload:{type:"activities",active:!0,nodeId:H,edgeId:a,sourceNodeId:m,targetNodeId:O,sourceHandle:y,targetHandle:v}}),b({type:Zs,payload:!0});return}b({type:Zs,payload:!1}),b({type:ss,payload:{type:"",active:!1,nodeId:null,edgeId:null}}),b({type:Rs,payload:"prompt"}),b({type:T0,payload:!0})}},R=_.find(z=>z.id===O),j=T.some(z=>z.source===O&&z.id!==a),$=R?.data?.outgoingPorts,Y=j||Array.isArray($)&&$.length>0;return d.jsxs(d.Fragment,{children:[d.jsx("path",{onClick:W,id:`${a}-interaction`,className:w?"react-flow__edge-interaction viewModeCursor":"react-flow__edge-interaction",d:k,style:{stroke:"transparent",strokeWidth:12,fill:"none",pointerEvents:"stroke"}}),d.jsx("path",{onClick:W,id:a,style:{...A},className:w?"react-flow__edge-path viewModeCursor":"react-flow__edge-path",d:k,markerEnd:g}),!w&&d.jsx(d.Fragment,{children:s?d.jsxs(d.Fragment,{children:[Y&&d.jsx(bx,{edgeCenterX:N-F*U,edgeCenterY:L-F*q,onClick:G}),d.jsx(xx,{edgeCenterX:Y?N+F*U:N,edgeCenterY:Y?L+F*q:L,onClick:W})]}):d.jsxs(d.Fragment,{children:[Y&&d.jsx(bx,{edgeCenterX:N-F*U,edgeCenterY:L-F*q,onClick:G}),d.jsx(xx,{edgeCenterX:Y?N+F*U:N,edgeCenterY:Y?L+F*q:L,onClick:W})]})})]})},pot=e=>{const t=E.useTheme(),{id:n,sourceX:r,sourceY:i,targetX:o,targetY:s,sourcePosition:a,targetPosition:l,style:u={stroke:t.palette.neutral.main},markerEnd:c,source:f,target:p,sourceHandle:h,targetHandle:A}=e,{deleteElements:g}=Rt.useReactFlow(),m=gt.useDispatch(),{ENTITY_ID:O,allowedAccount:y}=Ci(),v=_E(O,y),T=Rt.useNodes(),_=Rt.useEdges(),{viewOnly:x,canvasWorkflow:b,activitiesPopover:w}=gt.useSelector(Y=>Y.canvas),D=b?.meta?.isHorizontal??!0,I=w?.edgeId===n&&w?.active;if([r,i,o,s].some(Y=>typeof Y!="number"||Number.isNaN(Y))||!a||!l)return null;const[P,k,N]=Rt.getBezierPath({sourceX:r,sourceY:i,sourcePosition:a,targetX:o,targetY:s,targetPosition:l,curvature:.25}),L=o-r,M=s-i,B=Math.sqrt(L*L+M*M),Q=L/B,U=M/B,q=20,F=Y=>{Y.stopPropagation(),n&&!x&&g({edges:[{id:n}]})},W=Y=>{if(Y.stopPropagation(),!x){const z=Y.currentTarget?.getBoundingClientRect?.(),H=z&&Number.isFinite(z.left)&&Number.isFinite(z.top)?{x:z.left+z.width/2,y:z.top+z.height/2}:{x:Y.clientX,y:Y.clientY};m({type:Yp,payload:H}),m({type:S0,payload:!1});const V=`ai_prompt_${Math.trunc(Math.random()*1e9)}`,X={id:n,source:f,target:p,sourceHandle:h,targetHandle:A,type:Un.SMOOTH,markerEnd:c,style:u};if(m({type:v0,payload:{id:V,edgeId:n,sourceNodeId:f,targetNodeId:p,sourceHandle:h,targetHandle:A,originalEdge:X}}),!v){m({type:ss,payload:{type:"activities",active:!0,nodeId:V,edgeId:n,sourceNodeId:f,targetNodeId:p,sourceHandle:h,targetHandle:A}}),m({type:Zs,payload:!0});return}m({type:Zs,payload:!1}),m({type:ss,payload:{type:"",active:!1,nodeId:null,edgeId:null}}),m({type:Rs,payload:"prompt"}),m({type:T0,payload:!0})}},G=T.find(Y=>Y.id===p),R=_.some(Y=>Y.source===p&&Y.id!==n),j=G?.data?.outgoingPorts,$=R||Array.isArray(j)&&j.length>0;return d.jsxs(d.Fragment,{children:[d.jsx("path",{onClick:F,id:`${n}-interaction`,className:x?"react-flow__edge-interaction viewModeCursor":"react-flow__edge-interaction",d:P,style:{stroke:"transparent",strokeWidth:12,fill:"none",pointerEvents:"stroke"}}),d.jsx("path",{onClick:F,id:n,style:{...u},className:x?"react-flow__edge-path viewModeCursor":"react-flow__edge-path",d:P,markerEnd:c}),!x&&d.jsx(d.Fragment,{children:D?d.jsxs(d.Fragment,{children:[$&&d.jsx(bx,{edgeCenterX:k-q*Q,edgeCenterY:N-q*U,onClick:W,isSelected:I}),d.jsx(xx,{edgeCenterX:$?k+q*Q:k,edgeCenterY:$?N+q*U:N,onClick:F,isSelected:I})]}):d.jsxs(d.Fragment,{children:[$&&d.jsx(bx,{edgeCenterX:k-q*Q,edgeCenterY:N-q*U,onClick:W,isSelected:I}),d.jsx(xx,{edgeCenterX:$?k+q*Q:k,edgeCenterY:$?N+q*U:N,onClick:F,isSelected:I})]})})]})},wE=e=>e.canvas,Vte=e=>e.activities,Gte=il.createSelector([wE],e=>e.canvasWorkflow);il.createSelector([Gte],e=>e?.meta?.isHorizontal??!0);const hot=il.createSelector([wE],e=>e.activityExecutionData),Aot=il.createSelector([wE],e=>e.selectedActivityId),mot=il.createSelector([wE],e=>e.viewOnly);il.createSelector([wE],e=>e.nodesToFocus);const got=il.createSelector([Vte],e=>e.activities?.data?.data||[]),Eot=il.createSelector([Vte],e=>e.triggers?.data?.data||[]),IE=il.createSelector([got,Eot],(e,t)=>({activities:e,triggers:t})),Oot=il.createSelector([hot,(e,t)=>t],(e,t)=>e?.[t]?.loading??!1),yot=il.createSelector([Gte,mot,Aot],(e,t,n)=>({isHorizontal:e?.meta?.isHorizontal??!0,viewOnly:t,selectedActivityId:n})),Cx=()=>{const e=E.useTheme();return d.jsx(E.Box,{className:"warning",sx:{background:e.palette.neutral.plain,color:e.palette.common.white,p:"2px 5px",margin:"14px 0px 0px",borderRadius:1.5,position:"relative",top:10},children:d.jsx(E.Typography,{variant:"smSemiBold",sx:{display:"block",width:200,fontFamily:"Inter"},children:"An activity can not be connected to more than one other activity"})})},hf=({type:e,position:t,id:n,isConnectable:r,className:i,isValidConnection:o,style:s,onClick:a})=>{const l=E.useTheme(),{viewOnly:u}=gt.useSelector(c=>c.canvas);return d.jsx(Rt.Handle,{onClick:u?void 0:a,type:e,position:t,id:n,isConnectable:r,isValidConnection:o,className:u?i+" viewModeCursor":i,style:{...s,backgroundColor:l.palette.common.white,cursor:u?"not-allowed":"pointer"},children:!u&&d.jsx(E.Box,{className:"handle_icon",sx:{bgcolor:l.palette.common.white,borderRadius:"50%"},children:d.jsx(Ue,{src:"ic_add_circle_outlined",width:"100%",height:"100%",sx:{path:{fill:l.palette.primary.main}}})})})};function vot(e=!1){const t=gt.useDispatch(),{getNodes:n,getEdges:r}=Rt.useReactFlow(),i=n(),o=r(),s=C.useRef({x:0,y:0}),{activity_names:a}=gt.useSelector(m=>m.activities),{setNodes:l,screenToFlowPosition:u}=Rt.useReactFlow(),[c,f]=C.useState([]),p=C.useCallback((m=u({x:s.current.x,y:s.current.y}))=>{const O=i.filter(T=>T.id===m);let y=[...i];const v=O.map(T=>{const _=Math.trunc(Math.random()*20),x=T.position.x+80+_,b=T.position.y+100+_,w=T?.data?.name||T?.data?.type||"node",I=Ra(w,y),P=i1(null,T.data,null,I,y,null,"",[],{x,y:b});return T.activity_data&&(P.activity_data={...T.activity_data}),t({type:bi.SET_ACTIVITY_NAMES,payload:[...a,P.data.name]}),y=[...y,P],P});l([...i.map(T=>({...T,selected:!1})),...v])},[i,l,u]),h=C.useCallback(()=>{const m=i.filter(v=>v.selected);if(m.find(v=>v.type===xt.TRIGGER)){t({type:Yn,payload:{open:!0,title:"Trigger can't be copy",type:"error"}});return}let O=[...i];const y=m.map(v=>{const T=Math.trunc(Math.random()*20),_=v.data.name.split("_")[0],x=Pb(_,O),b=v.position.x+60+T,w=v.position.y+60+T,D=Ra(v?.data?.name||v?.data?.type||"node",O),I={...v,id:D,position:{x:b,y:w},data:{name:x,properties:v.data.properties,type:v.data.type},incomingPorts:[],outgoingPorts:[]};return O=[...O,{...I}],I});f(y),y.length===0?t({type:Yn,payload:{open:!0,title:"Please select a node to copy",type:"error"}}):t({type:Yn,payload:{open:!0,title:"Activity copied successfully",type:"success"}})},[i,o]),A=C.useCallback(({x:m,y:O}=u({x:s.current.x,y:s.current.y}))=>{const y=Math.min(...c.map(_=>_.position.x)),v=Math.min(...c.map(_=>_.position.y)),T=c.map(_=>{const x=_.id,b=m+(_.position.x-y),w=O+(_.position.y-v);return{..._,id:x,position:{x:b,y:w}}});l([...i.map(_=>({..._,selected:!1})),...T])},[c,u,l]),g=i.find(m=>m?.selected);return Wte(e&&g?["Meta+c","Ctrl+c"]:[],h),Wte(e&&g?["Meta+v","Ctrl+v"]:[],A),{copy:h,clone:p,paste:A,bufferedNodes:c}}function Wte(e,t){const[n,r]=C.useState(!1),i=Rt.useKeyPress(e);C.useEffect(()=>{i&&!n?(t(),r(!0)):r(i)},[i,n,t])}const DE=({name:e,id:t,isTriggerNode:n,nodeData:r,handleDeleteNode:i,proIntegration:o=!1,onRunWithPrevious:s})=>{const a=E.useTheme(),l=gt.useDispatch(),{viewOnly:u}=gt.useSelector(U=>U.canvas),{workflow:c}=gt.useSelector(U=>U.workflows),{activities:f,triggers:p}=gt.useSelector(U=>U.activities),A=new URLSearchParams(typeof window<"u"?window.location.search:"").get("source")?.toLowerCase()||c?.source,g=n&&A?.includes("commerce_"),{clone:m}=vot(),O=ui(f?.data?.data,p?.data?.data,r),y=r?.properties?.integration_slug||"",v=r?.type,T=!n&&!xf.includes(v),_=r?.blt_node_states||{},x=_.setup_and_configure||"default",b=_.node||"default",w=T&&x!=="completed"&&b!=="completed",D=Rt.useEdges(),I=C.useMemo(()=>D.some(U=>U.target===t&&U.type!==Un.PLACEHOLDER),[D,t]),P=C.useCallback(()=>{o||w||(l({type:du,payload:{id:t}}),l({type:Sf,payload:!0}),l({type:Cb,payload:{nodeId:t,runWithPrevious:!1}}))},[t,o,w,l]),k=C.useCallback(()=>{o||w||!I||(s?s(t):(l({type:du,payload:{id:t}}),l({type:Sf,payload:!0}),l({type:Cb,payload:{nodeId:t,runWithPrevious:!0}})))},[t,o,w,I,l,s]),N=C.useCallback(()=>{o||m(t)},[t,o,m]),L=C.useCallback(()=>{i([{id:t,name:e,icon:O,integration_slug:y}])},[t,e,O,y,i]),M=C.useCallback(()=>{l({type:Sf,payload:!1}),l({type:ss,payload:{type:"triggers",active:!0,nodeId:t}})},[t,l]);if(u)return null;const B={"&.Mui-disabled":{opacity:1}},Q=a.palette.primary.disabled??a.palette.grey?.normal;return d.jsxs(E.Stack,{direction:"row",alignItems:"center",gap:.5,onClick:U=>U.stopPropagation(),children:[d.jsxs(E.Stack,{direction:"row",alignItems:"center",sx:{backgroundColor:a.palette.common.white,borderRadius:"8px",boxShadow:"0px 2px 8px rgba(0, 0, 0, 0.08)",p:.25},children:[n&&d.jsx(E.Tooltip,{arrow:!0,title:"Switch Trigger",placement:"top",children:d.jsx(E.IconButton,{onClick:M,sx:{p:.5,width:28,height:28,...Di(a)},"data-testid":"node-action-switch-trigger",children:d.jsx(Ue,{src:"ic_swap",width:20,height:20,sx:{path:{fill:a.palette.neutral.solid.bg||"#656A70"}}})})}),T&&d.jsxs(d.Fragment,{children:[d.jsx(E.Tooltip,{arrow:!0,title:w?"Complete configuration to Test Node":"Test Node",placement:"top",children:d.jsx("span",{children:d.jsx(E.IconButton,{onClick:P,disabled:w,sx:{p:.5,width:28,height:28,...B},"data-testid":"node-action-run",children:d.jsx(Ue,{src:"ic_play",width:20,height:20,sx:{path:{fill:w?Q:a.palette.primary.main}}})})})}),d.jsx(E.Tooltip,{arrow:!0,title:w?"Complete configuration to run":I?"Run with previous":"No previous node attached",placement:"top",children:d.jsx("span",{children:d.jsx(E.IconButton,{onClick:k,disabled:w||!I,sx:{p:.5,width:28,height:28,...B},"data-testid":"node-action-run-with-previous",children:d.jsx(Ue,{src:"ic_autoplay",width:20,height:20,sx:{path:{fill:w||!I?Q:a.palette.primary.main}}})})})})]}),!n&&d.jsx(E.Tooltip,{arrow:!0,title:"Duplicate",placement:"top",children:d.jsx(E.IconButton,{onClick:N,disabled:o,sx:{p:.5,width:28,height:28,...Di(a),...B},"data-testid":"node-action-duplicate",children:d.jsx(Ue,{src:"ic_copy",width:20,height:20,sx:{path:{fill:o?a.palette.text?.tertiary??a.palette.neutral?.solid?.bg:a.palette.neutral.solid.bg}}})})})]}),d.jsx(E.Tooltip,{arrow:!0,title:"Delete",placement:"top",children:d.jsx(E.IconButton,{onClick:L,disabled:g,sx:{p:.5,width:28,height:28,backgroundColor:a.palette.common.white,borderRadius:"8px",boxShadow:"0px 2px 8px rgba(0, 0, 0, 0.08)","&:hover":{backgroundColor:a.palette.common.white,"& .inline-svg path":{fill:`${a.palette.error.main} !important`}}},"data-testid":"node-action-delete",children:d.jsx(Ue,{src:"ic_new_delete",width:20,height:20,sx:{path:{fill:a.palette.error.main||"#C41C1C"}}})})})]})},Tot=250,RE=({children:e,id:t,nodeData:n,focused:r,sx:i={},actionBar:o})=>{const s=Rt.useNodes(),[a,l]=C.useState(!1),u=C.useRef(null),c=()=>{u.current&&(clearTimeout(u.current),u.current=null)},f=()=>{c(),u.current=setTimeout(()=>l(!1),Tot)},p=()=>{c(),l(!0)};C.useEffect(()=>()=>c(),[]);const{setNodes:h}=Rt.useReactFlow(),{nodesToFocus:A}=gt.useSelector(b=>b.canvas),g=gt.useDispatch(),m=A.nodes.includes(t),[O,y]=C.useState(n?.activity_comment?.body||""),v=A.type;C.useEffect(()=>{y(n?.activity_comment?.body||"")},[n?.activity_comment?.body]);const T=C.useMemo(()=>wa(w=>{const D=s.map(I=>I.id===t?{...I,data:{...I.data,activity_comment:{...I.data.activity_comment,body:w,visible:w.trim()!==""}}}:I);h(D)},300),[s,t,g]);C.useEffect(()=>()=>{T.cancel()},[T]);const _=b=>{let w=b.target.value;w.length>299&&(w=w.substring(0,299)),y(w),T(w)},x=C.useMemo(()=>m&&A.show||r?{border:b=>`1px solid ${v==="focused"||r?b.palette.primary.main:b.palette.error.main}`,...i}:{border:b=>`1px solid ${b.palette.neutral.outlined.border}`,...i},[m,r,v,A.show,i]);return d.jsxs(E.Box,{className:"nodeContainer",position:"relative",sx:x,onMouseEnter:p,onMouseLeave:f,children:[o&&a&&d.jsx(E.Box,{"data-node-action-bar":!0,onMouseEnter:p,onMouseLeave:f,sx:{position:"absolute",bottom:"100%",left:0,right:0,display:"flex",justifyContent:"flex-end",mb:.75,zIndex:10,pointerEvents:"auto"},children:o}),d.jsxs(E.Box,{sx:{display:"flex",flexDirection:"column",flex:1},children:[e,n?.activity_comment?.visible&&d.jsx(E.Box,{position:"absolute",top:"100%",zIndex:1,width:"100%",height:"auto",mt:.75,mx:0,sx:{userSelect:"all",pointerEvents:"auto"},children:d.jsx(E.TextField,{fullWidth:!0,multiline:!0,variant:"outlined",value:O,placeholder:"Add a comment",autoFocus:O.trim()==="",sx:{width:"100%",background:b=>b.palette.white.ivory,borderRadius:"8px","&:hover":{".MuiInputBase-root":{"&:hover":{".MuiOutlinedInput-notchedOutline":{borderColor:b=>b.palette.primary.main}},boxShadow:b=>`0 0 8px ${b.palette.primary.main}`}},"& .MuiInputBase-root.MuiOutlinedInput-root":{minHeight:"32px",padding:"10px 4px"}},onChange:_,onBlur:b=>{if(O.trim()===""){if(b.relatedTarget?.tagName==="BUTTON")return;const w=s.map(D=>D.id===t?{...D,data:{...D.data,activity_comment:{...D.data.activity_comment,visible:!1}}}:D);h(w)}}})})]})]},t)},Sot=(e,t)=>{try{const n=e.replace(/properties\.([a-zA-Z_]\w*)/g,(i,o)=>{const s=t[o];return s!=null&&s!==""?s.toString():"undefined"});if(n.includes("undefined")||!/^[\d+\-*/().\s]+$/.test(n))return null;const r=new Function(`return ${n}`)();return typeof r=="number"&&!isNaN(r)?r:null}catch{return null}},xot=(e,t,n)=>{if(!e)return{result:e,allReplaced:!1};let r=!0;return{result:e.replace(/\{\{([^}]+)\}\}/g,(o,s)=>{if(/[+\-*/()]/.test(s)){const a=Sot(s,t);return a!==null?a.toString():(r=!1,o)}else{const l=s.replace(/^properties\??\./,"").replace(/\?/g,"").split(".");let u=t;for(const c of l)if(u&&typeof u=="object"&&c in u)u=u[c];else{u=void 0;break}if(u!=null&&u!==""){if(Array.isArray(u)&&u.length>0)return u.join(", ");if(Array.isArray(u)&&u.length===0)return r=!1,o;let c=n;for(const f of l)if(c&&typeof c=="object"&&f in c)c=c[f];else{c=void 0;break}return c&&typeof c=="object"&&u in c?c[u]:typeof u=="string"?E8(u):u}else return r=!1,o}}),allReplaced:r}},E8=e=>{if(!e)return"";const[t,...n]=e.split("."),r=n.length>0?n.join("."):"",i=(a,l=!1)=>{if(!a)return"";const u=a.replace(/[_\-\.]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z0-9]+)/g,"$1 $2").replace(/\s+/g," ").trim();return l?u.replace(/\b\w/g,c=>c.toUpperCase()):u.charAt(0).toUpperCase()+u.slice(1)},o=i(t),s=i(r);return s?`${s} [${o}]`:o},bot=e=>{const t=Sue();if(Ad.includes(e.data?.type))return e.data.properties?.operation?E8(e.data.properties.operation):"Select an operation";if(e.data?.type in t){const n=e.data.properties,r=t[e.data.type];let i={},o="";if(e.type===xt.TRIGGER?(i=r.trigger,o=r?.trigger?.manual_type):(i=r.integration,o=r?.integration?.manual_type),e.data?.type===Je.SCHEDULE){const l=n?.spec;if(l){if(l.calendars&&l.calendars.length>0)return"Calendar Schedule";if(l.cron_expressions&&l.cron_expressions.length>0)return"Cron Schedule";if(l.intervals&&l.intervals.length>0)return"Interval Schedule"}return"Configure Schedule"}const s=Object.keys(i)[0],a=n?.[s];if(o){const{result:l,allReplaced:u}=xot(o,n,i);return u?l:i.default}if(!a||typeof a=="object"&&vt(a))return i.default;if(i[s]){if(Array.isArray(a))return a.map(l=>i[s]?.[typeof l=="object"?l?.value?.toLowerCase():l?.toLowerCase()]).join(", ");if(e.data?.type===Je.BOLTIC_TABLE_ACTIVITY){if(a==="sql_query"||n?.query)return"SQL Query";if(a==="custom_event"||a&&!i[s]?.[a])return E8(a)}return gb.includes(e.data?.type)&&(a==="custom"||e.data?.type===Je.GOOGLE_SHEETS_WRITE&&s==="mode"&&n?.operation==="custom")?"Custom API":i[s]?.[a]}return a}return""},Qte=e=>{switch(e?.node){case"not-configured-yet":return"ic_warning_circle";case"skipped":return"ic_skipped";case"failed":return"ic_error";case"completed":return"ic_success_small";default:return""}},Cot=({nodeData:e})=>{const t=E.useTheme(),n=bot(e);return d.jsxs(E.Stack,{direction:"row",width:"100%",alignItems:"center",justifyContent:"space-between",children:[d.jsx(E.Tooltip,{title:n,arrow:!0,placement:"top",children:d.jsx(E.Typography,{variant:"smNormal",color:t.palette.text.tertiary,sx:{maxWidth:200,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n})}),!vt(Qte(e.data?.blt_node_states))&&d.jsx(E.Stack,{direction:"row",sx:{cursor:"pointer",flexShrink:0},children:d.jsx(E.Tooltip,{arrow:!0,title:Ds(e.data?.blt_node_states?.node),children:d.jsx(Ue,{width:20,height:20,src:Qte(e.data?.blt_node_states)})})})]})},PE=({id:e,nodeData:t,iconSrc:n,title:r,children:i,isTriggerNode:o,meta:s=null,proIntegration:a=!1,pro:l=!1})=>{const u=gt.useDispatch(),c=E.useTheme(),{setNodes:f,getNodes:p}=Rt.useReactFlow(),{activitiesPopover:h}=gt.useSelector(m=>m.canvas),A=C.useMemo(()=>n?nh(n,"t.resize(h:24,w:24)"):"",[n]),g=m=>{u({type:du,payload:{id:m}})};return d.jsxs(E.Stack,{alignItems:"center",p:1.5,gap:1,onClick:m=>{m.stopPropagation(),!a&&(h.nodeId===t.id?u({type:ss,payload:{type:"",active:!1,nodeId:null}}):g(t.id))},sx:{cursor:a?"not-allowed":"pointer"},children:[d.jsxs(E.Stack,{direction:"row",overflow:a?"visible":"hidden",alignItems:"center",width:"100%",justifyContent:"space-between",flex:1,children:[d.jsx(E.Box,{sx:{opacity:a?.5:1,filter:a?"grayscale(1)":"none",flex:1,minWidth:0,display:"flex",alignItems:"center"},children:d.jsxs(E.Stack,{direction:"row",gap:1,alignItems:"center",flex:1,minWidth:0,overflow:"visible",children:[d.jsx(E.Stack,{sx:{...Hi},width:24,height:24,children:n?d.jsx("img",{src:A,alt:r,width:24,height:24,decoding:"async",style:{width:24,height:24,objectFit:"contain",display:"block"}}):d.jsx(E.Box,{sx:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${c.palette.grey.A400}`,borderRadius:1,background:c.palette.grey.A400,padding:.5,color:c.palette.common.white},children:r.slice(0,2).toUpperCase()})}),d.jsx(E.Tooltip,{arrow:!0,title:r,placement:"top",children:d.jsx(E.Typography,{sx:{maxWidth:148,...cu,lineHeight:"142%"},variant:"smSemiBold",color:c.palette.text.primary,children:r})}),l&&d.jsx(E.Box,{flexShrink:0,children:d.jsx(Jd,{})})]})}),d.jsxs(E.Stack,{alignItems:"center",gap:1,flexShrink:0,justifyContent:"self-end",direction:"row",children:[d.jsxs(E.Box,{sx:{opacity:a?.5:1,filter:a?"grayscale(1)":"none",display:"flex",alignItems:"center",gap:1},children:[o&&(t.data.type===Je.GMAIL_TRIGGER||s?.trigger_type===VO.SCHEDULED)&&d.jsx(E.Tooltip,{arrow:!0,title:"The trigger will check for new data in intervals.",children:d.jsx(E.Box,{display:"flex",alignItems:"center",children:d.jsx(E.IconButton,{sx:{p:0},children:d.jsx(Ue,{src:"ic_schedule",width:16,height:16,sx:{cursor:"pointer",path:{fill:c.palette.neutral.solid.bg}}})})})}),d.jsx(E.Tooltip,{arrow:!0,title:"Toggle Comment",children:d.jsx(E.IconButton,{onClick:m=>{if(a)return;m.stopPropagation(),m.preventDefault();const O=p().map(y=>y.id===e?{...y,data:{...y.data,activity_comment:{...y.data?.activity_comment,visible:!y.data?.activity_comment?.visible}}}:y);f(O)},sx:{p:0,...Di(c)},children:d.jsx(Ue,{src:"ic_comment",width:16,height:16})})})]}),d.jsx(E.Box,{sx:{position:"relative",zIndex:1,opacity:1,flexShrink:0},children:i})]})]}),d.jsxs(E.Box,{sx:{width:"100%",opacity:a?.5:1,filter:a?"grayscale(1)":"none"},children:[d.jsx(E.Divider,{sx:{width:"100%"}}),d.jsx(E.Box,{sx:{pt:1},children:d.jsx(Cot,{nodeData:t})})]})]})},_ot=C.memo(e=>{const t=Rt.useNodes(),n=Rt.useEdges(),r=E.useTheme(),{canvasWorkflow:i,activityExecutionData:o,viewOnly:s,selectedActivityId:a}=gt.useSelector(Q=>Q.canvas),l=i?.meta?.isHorizontal??!0,u=Rt.useUpdateNodeInternals(),{setNodes:c}=Rt.useReactFlow(),{id:f,data:p,onHandleClick:h,handleDeleteNode:A,selected:g,pro_integration:m,onRunWithPrevious:O}=e,y=t.find(Q=>Q.id===a),{activities:v,triggers:T}=gt.useSelector(IE),_=Array.isArray(v)?v:[],x=Array.isArray(T)?T:[],b=ui(_,x,p,"pro"),w=!!b&&b!=="",D=w&&m===!1,I=o?.[p.name]?.loading??!1;let P=Array.isArray(p.properties?.branches)?p.properties.branches:[];(p.type===Je.API||p.type===Je.GRAPHQL)&&p.properties?.continue_on_failure===!1&&(P=P.filter(Q=>Q.ref==="success")),C.useEffect(()=>{u(f)},[f,P.length,p.properties?.continue_on_failure]),C.useEffect(()=>{c(Q=>Q.map(U=>{if(U.id===f){const q=D;if(U.draggable!==!q||U.selectable!==!q||U.connectable!==!q)return{...U,draggable:!q,selectable:!q,connectable:!q}}return U}))},[D,f,c]);const k=P.length+1,N=Math.max(k*16,84),L=Q=>{const U=k-1,q=U*8,F=(U-1)*8,W=q+F,R=(N-W+4)/2+Q*16,j=l?R:84;return isNaN(j)?84:j},M=Q=>{const U=k,q=k>4?260+32*(k-4):260,F=l?255:(Q+1)*(q/U);return isNaN(F)?l?254:253:F},B=(Q,U,q)=>{const F=p.type===Je.API||p.type===Je.GRAPHQL;return Q===0?F?"success":"if":Q===U-1?F?"failure":"else":q[Q]?.ref||`branch_${Q}`};return d.jsxs(E.Box,{position:"relative",className:"nowheel",onClick:Q=>{if(D){Q.stopPropagation();return}},sx:{cursor:D?"not-allowed":"default",pointerEvents:"auto",width:"100%",height:"100%"},children:[d.jsx(Rt.Handle,{type:"target",position:l?Rt.Position.Left:Rt.Position.Top,id:"targetHandle",isConnectable:!0,className:s?"targetHandleStyle viewModeCursor":"targetHandleStyle",style:{top:l?"50%":0,left:l?1:"50%",background:r.palette.common.white,border:`1px solid ${r.palette.neutral.main}`,opacity:D?.5:1},isConnectableStart:!1,children:d.jsx(Cx,{})}),d.jsx(RE,{id:f,focused:y?.id===f||g,nodeData:e.data,actionBar:d.jsx(DE,{name:p.name,id:f,isTriggerNode:!1,nodeData:e.data,handleDeleteNode:A,proIntegration:D,onRunWithPrevious:O}),sx:l?{height:N,minHeight:84,width:260}:{width:k>4?260+32*(k-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(PE,{id:f,nodeData:e,iconSrc:ui(_,x,p),title:p.name,running:I,proIntegration:D,pro:w})}),P.map((Q,U)=>{const q=B(U,P.length,P),F=q==="failure"||q==="else";return d.jsx(hf,{type:"source",position:l?Rt.Position.Right:Rt.Position.Bottom,id:q,className:"sourceHandleStyle",style:{position:"absolute",top:L(U),left:M(U),transform:"translateY(-50%)",border:`1px solid ${F?r.palette.error[50]:r.palette.neutral.main}`,opacity:D?.5:1},isConnectable:!D,onClick:()=>{!s&&!D&&h(q,t,n,{top:l?L(U)-25.5:L(U)+48,left:l?M(U)+48:M(U)-25.5+3.5})},isValidConnection:W=>{const G=t.find(H=>W.source===H.id);if(!G||W.source===W.target||hd(W.source,W.target,n))return!1;const j=n.filter(H=>H.type!==Un.PLACEHOLDER);return!(j.some(H=>G.id===H.source&&W.sourceHandle===H.sourceHandle)||j.some(H=>H.target===W.target&&H.source===W.source)||j.some(H=>H.target===W.target&&H.source!==W.source))}},`condition-branch-${U}`)})]})}),wot=C.memo(e=>{const t=Rt.useNodes(),n=Rt.useEdges(),r=E.useTheme(),{isHorizontal:i,viewOnly:o,selectedActivityId:s}=gt.useSelector(yot),{activities:a,triggers:l}=gt.useSelector(IE),u=gt.useSelector(B=>Oot(B,e.data.name)),c=Array.isArray(a)?a:[],f=Array.isArray(l)?l:[],p=Rt.useUpdateNodeInternals(),{id:h,data:A,selected:g,onHandleClick:m,handleDeleteNode:O,pro_integration:y,onRunWithPrevious:v}=e,T=ui(c,f,A,"pro"),_=!!T&&T!=="",x=_&&y===!1;C.useEffect(()=>{p(e.id)},[e.id,e.data?.properties?.continue_on_failure]);const b=C.useMemo(()=>t.find(B=>B.id===s),[t,s]),D=(Array.isArray(A?.properties?.branches)?A.properties.branches:[]).length+1,I=Math.max(D*16,84),N=(e.data.properties?.continue_on_failure===!0?2:1)+1,L=B=>{const Q=N-1,U=Q*8,q=(Q-1)*8,F=U+q,G=(I-F+4)/2+B*16,R=i?G:86;return isNaN(R)?86:R},M=B=>{const U=i?255:(B+1)*(260/N);return isNaN(U)?255:U};return d.jsxs(E.Box,{position:"relative",className:"nowheel",sx:{cursor:x?"not-allowed":"default",pointerEvents:"auto"},children:[d.jsx(Rt.Handle,{type:"target",position:i?Rt.Position.Left:Rt.Position.Top,id:"targetHandle",isConnectable:!0,className:o?"targetHandleStyle viewModeCursor":"targetHandleStyle",style:{top:i?"50%":0,left:i?1:"50%",background:r.palette.common.white,border:`1px solid ${r.palette.neutral.main}`},isConnectableStart:!1,children:d.jsx(Cx,{})}),d.jsx(RE,{id:h,focused:b?.id===h||g,nodeData:e.data,actionBar:d.jsx(DE,{name:A.name,id:h,isTriggerNode:!1,nodeData:e.data,handleDeleteNode:O,proIntegration:x,onRunWithPrevious:v}),sx:i?{height:I,minHeight:84,width:260}:{width:D>4?260+32*(D-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(PE,{id:h,nodeData:e,iconSrc:ui(c,f,A),title:A.name,running:u,proIntegration:x,pro:_})}),e.data.type!==Je.RESPONSE&&d.jsx(hf,{type:"source",position:i?Rt.Position.Right:Rt.Position.Bottom,id:"outHandle",onClick:()=>{!o&&!x&&m("outHandle",t,n,{top:i?L(0)-25.5:L(0)+48,left:i?M(0)+48:M(0)-25.5+3.5})},isConnectable:!0,className:"sourceHandleStyle",style:{position:"absolute",top:L(0),left:M(0),transform:"translateY(-50%)",border:`1px solid ${r.palette.neutral.main}`,opacity:x?.5:1},isValidConnection:B=>{const Q=t.find(W=>B.source===W.id);if(B.source===B.target||hd(B.source,B.target,n))return!1;const q=(Q.outgoingPorts||[]).some(W=>!W.ref||W.ref!=="failure");return!n.some(W=>W.target===B.target&&W.type!==Un.PLACEHOLDER)&&!q}}),e.data.properties?.continue_on_failure===!0&&d.jsx(hf,{type:"source",position:i?Rt.Position.Right:Rt.Position.Bottom,id:"failureHandle",onClick:()=>{!o&&!x&&m("failureHandle",t,n,{top:i?L(1)-25.5:L(1)+48,left:i?M(1)+48:M(1)-25.5+3.5})},isConnectable:!0,className:"sourceHandleStyle failureHandle",style:{position:"absolute",top:L(1),left:M(1),transform:"translateY(-50%)",border:`1px solid ${r.palette.error.main}`,background:r.palette.error.light,opacity:x?.5:1},isValidConnection:B=>{if(!t.find(R=>B.source===R.id)||B.source===B.target||hd(B.source,B.target,n))return!1;const q=n.filter(R=>R.type!==Un.PLACEHOLDER);return!(q.some(R=>R.source===B.source&&R.target===B.target&&R.sourceHandle==="failureHandle")||q.some(R=>R.target===B.target&&R.source===B.source)||q.some(R=>R.target===B.target&&R.source!==B.source))}})]})}),Iot=C.memo(e=>{const t=Rt.useNodes(),n=Rt.useEdges(),r=E.useTheme(),{activityExecutionData:i,canvasWorkflow:o,viewOnly:s,selectedActivityId:a}=gt.useSelector(B=>B.canvas),l=t.find(B=>B.id===a),u=Rt.useUpdateNodeInternals(),{id:c,data:f,selected:p,onHandleClick:h,handleDeleteNode:A,pro_integration:g,onRunWithPrevious:m}=e,{activities:O,triggers:y}=gt.useSelector(IE),v=Array.isArray(O)?O:[],T=Array.isArray(y)?y:[],_=ui(v,T,f,"pro"),x=!!_&&_!=="",b=x&&g===!1,w=o?.meta?.isHorizontal??!0,D=f.properties?.no_of_parallel_threads||0;C.useEffect(()=>{u(c)},[c,D]);const I=i?.[f.name]?.loading??!1,P=B=>`parallel_${B}`,k=D+1,N=Math.max(k*16,84),L=B=>{const Q=k-1,U=Q*8,q=(Q-1)*8,F=U+q,G=(N-F+4)/2+B*16,R=w?G:86;return isNaN(R)?86:R},M=B=>{const Q=D+1,U=D>5?260+32*(D-4):260,q=w?255:(B+1)*(U/Q);return isNaN(q)?255:q};return d.jsxs(E.Box,{position:"relative",className:"nowheel",sx:{cursor:b?"not-allowed":"default",pointerEvents:"auto"},children:[d.jsx(Rt.Handle,{type:"target",position:w?Rt.Position.Left:Rt.Position.Top,id:"targetHandle",isConnectable:!b,className:s?"targetHandleStyle viewModeCursor":"targetHandleStyle",style:{top:w?"50%":0,left:w?1:"50%",background:r.palette.common.white,border:`1px solid ${r.palette.neutral.main}`,opacity:b?.5:1},isConnectableStart:!1,children:d.jsx(Cx,{})}),d.jsx(RE,{id:c,focused:l?.id===c||p,nodeData:e.data,actionBar:d.jsx(DE,{name:f.name,id:c,isTriggerNode:!1,nodeData:e.data,handleDeleteNode:A,proIntegration:b,onRunWithPrevious:m}),sx:w?{height:`${N}px`,minHeight:84,width:260}:{width:D>5?260+32*(D-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(PE,{id:c,nodeData:e,iconSrc:ui(v,T,f),title:f.name,running:I,proIntegration:b,pro:x})}),[...Array(D)].map((B,Q)=>d.jsx(hf,{type:"source",position:w?Rt.Position.Right:Rt.Position.Bottom,id:P(Q),isConnectable:!0,className:"sourceHandleStyle",style:{top:L(Q),left:M(Q),transform:"translateY(-50%)",border:`1px solid ${r.palette.neutral.main}`,opacity:b?.5:1},isValidConnection:U=>{const q=t.find($=>U.source===$.id);if(!q||U.source===U.target||hd(U.source,U.target,n))return!1;const W=n.filter($=>$.type!==Un.PLACEHOLDER);return!(W.some($=>q.id===$.source&&U.sourceHandle===$.sourceHandle)||W.some($=>$.target===U.target&&$.source===U.source)||W.some($=>$.target===U.target&&$.source!==U.source))},onClick:()=>{!s&&!b&&h(P(Q),t,n,{top:w?L(Q)-25.5:L(Q)+48,left:w?M(Q)+48:M(Q)-25.5+3.5})}},`parallel-thread-${Q}`))]})}),zte=({id:e,overlayProps:t,allowDrag:n=!1,hideTargetHandle:r=!1})=>{const i=E.useTheme(),o=Rt.useUpdateNodeInternals(),{canvasWorkflow:s}=gt.useSelector(l=>l.canvas),a=s?.meta?.isHorizontal??!0;return C.useEffect(()=>{e&&o(e)},[e,o]),d.jsxs("div",{style:{pointerEvents:"auto"},children:[!r&&d.jsx(Rt.Handle,{type:"target",id:"targetHandle",position:a?Rt.Position.Left:Rt.Position.Top,isConnectable:!1,className:"targetHandleStyle",style:{top:a?"50%":0,left:a?0:"50%",transform:"translate(-50%, -50%)",background:i.palette.common.white,border:`1px solid ${i.palette.neutral.main}`}}),d.jsx(pde,{open:!0,variant:"inline",draggable:!1,...t}),d.jsx(Rt.Handle,{type:"source",id:"outHandle",position:a?Rt.Position.Right:Rt.Position.Bottom,isConnectable:!1,className:"sourceHandleStyle",style:{top:a?"50%":"100%",left:a?"100%":"50%",transform:"translate(-50%, -50%)",background:i.palette.common.white,border:`1px solid ${i.palette.neutral.main}`}})]})},Dot=e=>{const{handle:t,tooltip:n,toggleListing:r,id:i}=e,o=E.useTheme(),{selectedPlaceholderId:s}=gt.useSelector(a=>a.canvas);return d.jsx(E.Box,{className:"nowheel",sx:{position:"relative",width:51,...s===i&&{"& .MuiButtonBase-root.MuiButton-root":{borderColor:o.palette.primary.main}}},children:d.jsx(E.Tooltip,{arrow:!0,title:n,disableInteractive:!0,children:d.jsxs("span",{children:[d.jsx(E.Button,{sx:{minWidth:50,width:51,height:51,border:`1px solid ${o.palette.grey.outlined.border}`,backgroundColor:o.palette.common.white,"& svg":{width:20,height:20},"&:hover":{backgroundColor:o.palette.common.white,transform:"none"}},onClick:r,children:d.jsx(Ue,{width:24,height:24,src:"ic_add_circle_outlined",sx:{path:{fill:o.palette.primary.main}}})}),t]})})})},Rot=e=>{const{handle:t,toggleListing:n,id:r}=e,i=E.useTheme(),{selectedPlaceholderId:o}=gt.useSelector(s=>s.canvas);return d.jsx(E.Box,{className:"nowheel",children:d.jsxs(E.Stack,{p:1.5,alignItems:"flex-start",border:`1px dashed ${i.palette.neutral.solid.bg}`,borderRadius:2,onClick:n,sx:{backgroundColor:i.palette.common.white,width:260,height:84,...o===r&&{borderColor:i.palette.primary.main}},children:[d.jsxs(E.Stack,{gap:1,width:"100%",children:[d.jsxs(E.Stack,{direction:"row",alignItems:"center",gap:1,children:[d.jsx(Ue,{src:"ic_spark",width:24,height:24,sx:{path:{fill:i.palette.primary.main}}}),d.jsx(E.Stack,{direction:"row",gap:.5,children:d.jsx(E.Typography,{variant:"smMedium",lineHeight:1,children:"Choose trigger"})})]}),d.jsx(E.Divider,{}),d.jsx(E.Typography,{variant:"smNormal",color:i.palette.text.tertiary,children:"Select an event"})]}),t]})})},Pot=({id:e,data:t,onHandleClick:n})=>{const{isTriggerPlaceholder:r}=t,i=E.useTheme(),o=Rt.useNodes(),s=Rt.useEdges(),{ENTITY_ID:a,allowedAccount:l}=Ci(),u=gt.useDispatch(),{activitiesPopover:c,viewOnly:f,canvasWorkflow:p,selectedActivityId:h}=gt.useSelector(O=>O.canvas),A=_E(a,l),g=p?.meta?.isHorizontal??!0,m=O=>{if(f)return;if(h&&u({type:dd,payload:null}),u({type:v0,payload:e}),c?.active&&u({type:ss,payload:{type:"",active:!1,nodeId:null,edgeId:null}}),r&&!A){u({type:ss,payload:{type:"triggers",active:!0,nodeId:e,edgeId:null}}),u({type:Zs,payload:!0});return}if(!A){u({type:ss,payload:{type:"activities",active:!0,nodeId:e,edgeId:null}}),u({type:Zs,payload:!0});return}const y=O?.currentTarget?.getBoundingClientRect?.()??O?.target?.getBoundingClientRect?.();y&&Number.isFinite(y.left)&&Number.isFinite(y.top)?u({type:Yp,payload:{x:y.left+y.width/2,y:y.top+y.height/2}}):O?.clientX&&O?.clientY&&u({type:Yp,payload:{x:O.clientX,y:O.clientY}}),u({type:S0,payload:!1}),u({type:Rs,payload:"prompt"}),u({type:T0,payload:!0})};return r?d.jsx(Rot,{id:e,handle:d.jsx(hf,{type:"source",id:"outHandle",position:g?Rt.Position.Right:Rt.Position.Bottom,isConnectable:!0,className:"sourceHandleStyle",style:{...g?{top:45,left:255,transform:"translateY(-50%)"}:{left:"50%"},border:`1px solid ${i.palette.neutral.main}`},isValidConnection:O=>{if(!o.find(b=>O.source===b.id)||O.source===O.target||hd(O.source,O.target,s))return!1;const T=s.filter(b=>b.type!==Un.PLACEHOLDER);return!(T.some(b=>b.target===O.target&&b.source!==O.source)||T.some(b=>b.source===O.source))},onClick:O=>{O.stopPropagation(),!f&&n("outHandle",o,s,{top:g?42-25.5+2:132,left:g?308:130-25.5})}}),toggleListing:m}):d.jsx(Dot,{id:e,handle:d.jsx(Rt.Handle,{type:"target",id:"targetHandle",position:g?Rt.Position.Left:Rt.Position.Top,isConnectable:!1,className:f?"viewModeCursor":"",style:{position:"absolute",background:"transparent",border:"none",left:g?0:"50%",top:g?"50%":0,transform:g?"translateY(-50%)":"translateX(-50%)"}}),tooltip:"Click here to add action",toggleListing:m})},Not=C.memo(e=>{const{canvasWorkflow:t,activityExecutionData:n,viewOnly:r,selectedActivityId:i}=gt.useSelector(L=>L.canvas),o=t?.meta?.isHorizontal??!0,s=Rt.useNodes(),a=Rt.useEdges(),l=E.useTheme(),u=Rt.useUpdateNodeInternals(),{id:c,data:f,onHandleClick:p,selected:h,handleDeleteNode:A,pro_integration:g,onRunWithPrevious:m}=e,O=s.find(L=>L.id===i),y=(f.properties?.cases?.length||0)+1;C.useEffect(()=>{u(c)},[c,f.properties?.cases?.length,u]);const v=n?.[f.name]?.loading??!1,{activities:T,triggers:_}=gt.useSelector(IE),x=Array.isArray(T)?T:[],b=Array.isArray(_)?_:[],w=ui(x,b,f,"pro"),D=!!w&&w!=="",I=D&&g===!1,P=Math.max(y*16,84),k=L=>o?y===1?P/2:P/(y+1)*(L+1):84,N=L=>{const M=y+1,B=y>4?260+32*(y-5):260;return o?o?254:253:(L+1)*(B/M)};return d.jsxs(E.Stack,{direction:o?"row":"column",alignItems:"center",position:"relative",className:"nowheel",sx:{cursor:I?"not-allowed":"default",pointerEvents:"auto"},children:[d.jsx(Rt.Handle,{type:"target",position:o?Rt.Position.Left:Rt.Position.Top,id:"targetHandle",isConnectable:!0,className:r?"targetHandleStyle viewModeCursor":"targetHandleStyle",style:{top:o?"50%":0,left:o?1:"50%",background:l.palette.common.white,border:`1px solid ${l.palette.neutral.main}`,opacity:I?.5:1},isConnectableStart:!1,children:d.jsx(Cx,{})}),d.jsx(RE,{id:c,focused:O?.id===c||h,nodeData:e.data,actionBar:d.jsx(DE,{name:f.name,id:c,isTriggerNode:!1,nodeData:e.data,handleDeleteNode:A,proIntegration:I,onRunWithPrevious:m}),sx:o?{height:`${P}px`,minHeight:84,width:260}:{width:y>4?260+32*(y-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(PE,{id:c,nodeData:e,running:v,iconSrc:ui(x,b,f),title:f.name,proIntegration:I,pro:D})}),d.jsxs(E.Stack,{gap:o?.5:2,direction:o?"column":"row",children:[(f.properties?.cases||[]).map((L,M)=>{const B=k(M),Q=N(M);return d.jsx(hf,{type:"source",position:o?Rt.Position.Right:Rt.Position.Bottom,id:`${L.caseKey}`,isConnectable:!0,className:"sourceHandleStyle",style:{position:"absolute",top:`${B}px`,left:`${Q}px`,transform:"translateY(-50%)",border:`1px solid ${l.palette.neutral.main}`,opacity:I?.5:1},onClick:()=>{if(!r&&!I&&p){const U=k(M),q=N(M);p(L.caseKey,s,a,{top:o?U-25.5:U+48,left:o?q+48:q-25.5+3.5})}},isValidConnection:U=>{const q=s.find($=>U.source===$.id);if(!q||U.source===U.target||hd(U.source,U.target,a))return!1;const W=a.filter($=>$.type!==Un.PLACEHOLDER);return!(W.some($=>q.id===$.source&&U.sourceHandle===$.sourceHandle)||W.some($=>$.target===U.target&&$.source===U.source)||W.some($=>$.target===U.target&&$.source!==U.source))}},`${L.caseKey}-${M}`)}),d.jsx(hf,{type:"source",position:o?Rt.Position.Right:Rt.Position.Bottom,id:"defaultHandle",isConnectable:!0,className:"sourceHandleStyle",style:{position:"absolute",top:`${k(f.properties?.cases?.length||0)}px`,left:`${N(f.properties?.cases?.length||0)}px`,transform:"translateY(-50%)",border:`1px solid ${l.palette.error[50]}`,opacity:I?.5:1},onClick:()=>{if(!r&&!I&&p){const L=f.properties?.cases?.length||0,M=k(L),B=N(L);p("defaultHandle",s,a,{top:o?M-25.5:M+48,left:o?B+48:B-25.5+3.5})}},isValidConnection:L=>{const M=s.find(W=>L.source===W.id);if(!M||L.source===L.target||hd(L.source,L.target,a))return!1;const Q=a.filter(W=>W.type!==Un.PLACEHOLDER);return!(Q.some(W=>M.id===W.source&&L.sourceHandle===W.sourceHandle)||Q.some(W=>W.target===L.target&&W.source===L.source)||Q.some(W=>W.target===L.target&&W.source!==L.source))}},"defaultHandle")]})]})}),Lot=C.memo(e=>{const{id:t,data:n,selected:r,onHandleClick:i,VORTEX_MAIN_URL:o,ENTITY_ID:s,handleDeleteNode:a,currentSubscription:l,pro_integration:u}=e,c=Sr(Pn.VERSION),f=vo(),p=Sr(f),h=gt.useDispatch(),A=E.useTheme(),{analytics:g}=Ci(),m=Rt.useNodes(),O=Rt.useEdges(),{workflow:y}=gt.useSelector($=>$.workflows),{canvasWorkflow:v,activityExecutionData:T,viewOnly:_,showDebugLogs:x,selectedActivityId:b}=gt.useSelector($=>$.canvas),w=m.find($=>$.id===b),D=v?.meta?.isHorizontal??!0,I=m?.find($=>$?.type===xt.TRIGGER),{activities:P,triggers:k}=gt.useSelector(IE),N=Array.isArray(P)?P:[],L=Array.isArray(k)?k:[],M=ui(N,L,n,"pro"),B=!!M&&M!=="",Q=B&&u===!1,[U,q]=C.useState(!1),F=T?.[n.name]?.loading??!1,W=I?.data?.type,R=(Array.isArray(n?.properties?.branches)?n.properties.branches:[]).length+1,j=Math.max(R*16,84);return d.jsxs(E.Box,{position:"relative",className:"nowheel",sx:{cursor:Q?"not-allowed":"default",pointerEvents:"auto"},children:[p&&I&&W!==Je.HTTP&&d.jsx(E.Tooltip,{arrow:!0,title:l?.workflowExecution?.remaining<=0?"You cannot execute this workflow as you have reached execution limit.":l[0]?.status==="EXPIRED"?"You cannot execute this workflow as your subscription has expired.":l[0]?.status==="CANCELLED"?"You cannot execute this workflow as your subscription has been cancelled.":"Run Workflow",children:d.jsx(E.Box,{sx:{display:"inline-flex",position:"absolute",top:28,left:-44},children:d.jsx(E.IconButton,{color:"primary",sx:{width:32,height:32,color:$=>$.palette.primary.main,opacity:l?.workflowExecution?.remaining<=0||l[0]?.status==="EXPIRED"||l[0]?.status==="CANCELLED"?.3:1,cursor:"pointer",backgroundColor:A.palette.common.white,border:`1px solid ${b||U?A.palette.neutral.outlined.border:A.palette.primary.main}`,"&:hover":{backgroundColor:A.palette.common.white}},onClick:async()=>{if(I)if(x0(I,m)){const Y=vt(c)?p:c;q(!0),await x6(y,Y,[I],h,o,s,c,p,x,g),q(!1)}else h({type:Yn,payload:{open:!0,title:"Please complete all activities configurations to execute this workflow",type:"error"}})},disabled:!!b||U||l?.workflowExecution?.remaining<=0||l[0]?.status==="EXPIRED"||l[0]?.status==="CANCELLED",children:U?d.jsx(E.CircularProgress,{sx:{color:A.palette.grey.normal},size:16}):d.jsx(Ue,{src:"ic_run",sx:{path:{fill:b?"currentColor":A.palette.primary.main}}})})})}),d.jsx(RE,{focused:w?.id===t||r,id:t,nodeData:e.data,actionBar:d.jsx(DE,{name:n.name,id:t,isTriggerNode:!0,nodeData:e.data,handleDeleteNode:a,proIntegration:Q}),sx:D?{height:j,minHeight:84,width:260}:{width:R>4?260+32*(R-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(PE,{id:t,nodeData:e,iconSrc:ui(N,L,n),title:n.name,running:F,isTriggerNode:!0,meta:ui(N,L,n,"meta"),proIntegration:Q,pro:B})}),d.jsx(hf,{type:"source",onClick:()=>{!_&&!Q&&i("outHandle",m,O,{top:D?42-25.5:132,left:D?308:130-25.5})},position:D?Rt.Position.Right:Rt.Position.Bottom,id:"outHandle",isConnectable:!0,className:"sourceHandleStyle",style:{...D?{top:"50%",left:256,transform:"translateY(-50%)"}:{left:"50%"},border:`1px solid ${A.palette.neutral.main}`,opacity:Q?.5:1},isValidConnection:$=>{if(!m.find(J=>$.source===J.id)||$.source===$.target||hd($.source,$.target,O))return!1;const H=O.filter(J=>J.type!==Un.PLACEHOLDER);return!(H.some(J=>J.target===$.target&&J.source!==$.source)||H.some(J=>J.source===$.source))}})]})}),kot=(e,t,n,r,i)=>{const o=E.useTheme(),s=Rt.useNodes(),a=Rt.useEdges(),l=gt.useDispatch(),u=Sr(),{analytics:c,ENTITY_ID:f,WORKFLOW_URLS:p}=Ci(),{activity_names:h}=gt.useSelector(I=>I.activities),{selectedPlaceholderId:A}=gt.useSelector(I=>I.canvas),g=(I,P)=>[...I,P],{captureEvent:m,WORKFLOW_EVENTS:O}=c||{},y=C.useCallback(I=>{I.preventDefault(),A&&l({type:Xp,payload:null});const P=JSON.parse(I.dataTransfer.getData("application/reactflow")),{currentNodeId:k,parentNodeId:N,isTrigger:L}=P,M=s.find($=>$.id===k);let B=k||Ra(P?.name||"node",s);if(P.openingFromPlaceholder){typeof k=="string"&&k.startsWith("placeholder_")&&!M&&(B=Ra(P?.name||"node",s)),M?.type===xt.PLACEHOLDER&&(B=Ra(P?.name||"node",s));const $=i1(I,P,e,B,s,u,i,N?[N]:[],{x:M?.position?.x,y:(M?.position?.y||0)-16});UC(l,$,L,N,M,k,h,r,n,s,a,m,O,f||"",u||void 0,p?.VORTEX_MAIN_URL);return}if(s.some($=>$.type===xt.TRIGGER)&&L){l({type:Yn,payload:{open:!0,title:"Only one trigger is allowed",type:"error"}});return}l({type:dd,payload:null});const U=s.find($=>$.type===xt.PLACEHOLDER&&$.data?.isTriggerPlaceholder),q=U?.id,F=s.filter($=>$.type!==xt.TRIGGER),W=Ra(P?.name||"trigger",F),G=P.type===xt.TRIGGER&&U?.position?U.position:null,R=i1(I,P,e,P.type===xt.TRIGGER?W:B,s,u,i,[],G);l({type:"SET_ACTIVITY_NAMES",payload:[...h,R.data.name]}),t(),l({type:Zs,payload:!1});const j=s.filter($=>$.type!==xt.PLACEHOLDER&&$.type!==xt.TRIGGER);if(u&&j.length===0&&R.type!==xt.TRIGGER&&!P.openingFromPlaceholder){const $=s.find(Y=>Y.type===xt.TRIGGER||Y?.data?.isTriggerPlaceholder);if($){const Y={source:$.id,sourceHandle:"outHandle",target:R.id,targetHandle:"targetHandle",type:$.type===Un.PLACEHOLDER?Un.PLACEHOLDER:Un.SMOOTH},z=[...s,R];m?.(O.WORKFLOW.ACTIVITY_ADD,{"console.product_account_id":f,message:"Activity added to workflow",integration_slug:R?.data?.properties?.integration_slug,name:R?.data?.name}),v(Y,z,a)}}else{let $;U&&R.type===xt.TRIGGER?$=s.map(Y=>Y.type===xt.PLACEHOLDER&&Y.data?.isTriggerPlaceholder?R:Y):$=g(s,R),U&&q&&q!==R.id&&R.type===xt.TRIGGER&&($=$.map(Y=>{if(Array.isArray(Y.incomingPorts)&&Y.incomingPorts.includes(q))return{...Y,incomingPorts:Y.incomingPorts.map(z=>z===q?R.id:z)};if(Y.id===R.id&&U.outgoingPorts){const z=U.outgoingPorts.map(H=>{const V=$.find(X=>Array.isArray(X.incomingPorts)&&X.incomingPorts.includes(q));return V?{...H,id:V.id}:H});return{...Y,outgoingPorts:z}}return Y}),r(Y=>(Y||a).map(z=>({...z,source:z.source===q?R.id:z.source,target:z.target===q?R.id:z.target})))),m?.(O.WORKFLOW.ACTIVITY_ADD,{"console.product_account_id":f,message:"Activity added to workflow",integration_slug:R?.data?.properties?.integration_slug,name:R?.data?.name}),n($)}l({type:du,payload:{id:R.id}})},[s,a,l,e,u,i,h,r,n,m,O,f,p?.VORTEX_MAIN_URL,o]),v=C.useCallback((I,P,k)=>{const N={...I,type:"smooth",id:I4(k||a),markerEnd:{type:Rt.MarkerType.ArrowClosed,color:s4(I,o)}};t();const L=ko(P||s).map(M=>{if(M.id===I.source){const B=(P||s).find(Q=>Q.id===I.target);I.sourceHandle==="failureHandle"?M.outgoingPorts.push({id:B?.id,ref:"failure",name:B?.data.name}):I.sourceHandle!=="outHandle"?M.outgoingPorts.push({id:B?.id,ref:I.sourceHandle,name:B?.data.name}):M.outgoingPorts.push({id:B?.id,name:B?.data.name})}if(M.id===I.target){const B=(P||s).find(Q=>Q.id===I.source);M.incomingPorts.push(B?.id)}return M});n(L),r(Rt.addEdge(N,k||a)),t()},[s,a,n,r,o,t]),T=C.useCallback(()=>{t()},[t]),_=C.useCallback((I,P)=>{n(k=>{const N=!!(I&&(I.shiftKey||I.metaKey||I.ctrlKey)),L=k.reduce((M,B)=>{const Q=B.zIndex??0;return Q>M?Q:M},0)||0;return k.map(M=>M.id===P.id?{...M,zIndex:L+1,style:{...M.style||{},zIndex:L+1},...N?{}:{selected:!0}}:N?M:{...M,selected:!1})}),t()},[n,t]),x=C.useCallback(I=>{I&&I.length>0&&n(P=>{let k=[...P];return I.forEach(N=>{const L=N.target,M=N.source;k=k.map(B=>{if(B.id===L){const{data:Q,...U}=B,{ref:q,...F}=Q;return{...U,data:F,incomingPorts:(B.incomingPorts||[]).filter(W=>W!==M)}}return B.id===M?{...B,outgoingPorts:(B.outgoingPorts||[]).filter(Q=>Q.id!==L)}:B})}),k}),t()},[n,t]),b=C.useCallback(()=>{s.find(P=>P.selected)&&n(P=>P.map(k=>({...k,selected:!1}))),t()},[s,n]),w=C.useCallback(I=>{I.shiftKey&&I.preventDefault()},[]),D=C.useCallback(I=>{const{nodes:P}=I,k=a||[],N=s||[];if(!Array.isArray(P)||P.length===0){t();return}P.forEach(H=>{H.type!==xt.PLACEHOLDER&&l({type:V5,payload:{id:H.id}})});const L=P.map(H=>H.id),M=new Set(L),B=k.filter(H=>M.has(H.source)||M.has(H.target)),Q=new Set;B.forEach(H=>{const V=N.find(J=>J.id===H.source),X=N.find(J=>J.id===H.target);V?.type===xt.PLACEHOLDER&&!M.has(V.id)&&Q.add(V.id),X?.type===xt.PLACEHOLDER&&!M.has(X.id)&&Q.add(X.id)}),N.forEach(H=>{if(H?.type!==xt.PLACEHOLDER)return;const V=Array.isArray(H.incomingPorts)&&H.incomingPorts.some(J=>M.has(J)),X=Array.isArray(H.outgoingPorts)&&H.outgoingPorts.some(J=>M.has(J?.id));(V||X)&&Q.add(H.id)});const U=[];P.forEach(H=>{if(H.type===xt.TRIGGER||H.type===xt.PLACEHOLDER)return;if(!(H.outgoingPorts&&H.outgoingPorts.length>1||H.data?.properties?.continue_on_failure===!0||H.data?.properties?.cases&&H.data.properties.cases.length>0||H.data?.properties?.branches&&H.data.properties.branches.length>1)){const X=B.filter(ee=>ee.target===H.id&&ee.type!==Un.PLACEHOLDER),J=B.filter(ee=>ee.source===H.id&&ee.type!==Un.PLACEHOLDER);if(X.length===1&&J.length===1){const ee=X[0].source,le=J[0].target;if(M.has(ee)||M.has(le)||Q.has(ee)||Q.has(le))return;U.push({sourceNodeId:ee,targetNodeId:le,sourceHandle:X[0].sourceHandle||"outHandle",targetHandle:J[0].targetHandle||"targetHandle"})}}});let q=N.filter(H=>!(M.has(H.id)||Q.has(H.id)));const F=P.find(H=>H.type===xt.TRIGGER);if(F){const H=o4(),V=Ra("trigger-placeholder",q);q=[{...H,id:V,position:F.position},...q]}const W=new Set(q.map(H=>H.id));let G=k.filter(H=>W.has(H.source)&&W.has(H.target));U.length>0&&U.forEach(({sourceNodeId:H,targetNodeId:V,sourceHandle:X,targetHandle:J})=>{if(!W.has(H)||!W.has(V)||G.some(re=>re.source===H&&re.target===V&&(re.sourceHandle||"outHandle")===(X||"outHandle")&&(re.targetHandle||"targetHandle")===(J||"targetHandle")&&re.type!==Un.PLACEHOLDER))return;const le={id:I4(G),source:H,sourceHandle:X,target:V,targetHandle:J,type:Un.SMOOTH,markerEnd:{type:Rt.MarkerType.ArrowClosed,color:s4({sourceHandle:X},o)}};G=Rt.addEdge(le,G)});const R=new Map;q.forEach(H=>R.set(H.id,H?.data?.name));const j=new Map,$=new Map;(G||[]).filter(H=>H.type!==Un.PLACEHOLDER).forEach(H=>{if(!W.has(H.source)||!W.has(H.target))return;const V=j.get(H.target)||new Set;V.add(H.source),j.set(H.target,V);const X=H.sourceHandle==="failureHandle"?"failure":H.sourceHandle&&H.sourceHandle!=="outHandle"?H.sourceHandle:void 0,J=$.get(H.source)||[];J.push({id:H.target,name:R.get(H.target),...X?{ref:X}:{}}),$.set(H.source,J)});const z=q.map(H=>{const V=Array.from(j.get(H.id)||[]),X=$.get(H.id)||[],J=new Set,ee=X.filter(ve=>{const oe=`${ve?.id||""}::${ve?.ref||""}`;return J.has(oe)?!1:(J.add(oe),!0)}),{data:le,...re}=H,{ref:ue,...Oe}=le||{};return{...re,data:Oe,incomingPorts:V,outgoingPorts:ee}});r(G),n(z),t()},[s,a,n,r,t,l,o]);return{onDrop:y,onConnect:v,onSelectionDragStart:T,onEdgesDelete:x,onPaneClick:b,onMouseDown:w,onDelete:D,onNodeDragStart:_}},O8={maxHistorySize:25,enableShortcuts:!0},Mot=({maxHistorySize:e=O8.maxHistorySize,enableShortcuts:t=O8.enableShortcuts}=O8)=>{const{getNodes:n,getEdges:r,setNodes:i,setEdges:o}=Rt.useReactFlow(),{selectedActivityId:s}=gt.useSelector(y=>y.canvas),a=n(),l=r(),[u,c]=C.useState([]),[f,p]=C.useState([]),h=C.useCallback(()=>{c(y=>{const v=y[y.length-1];return v&&v.nodes===a&&v.edges===l?y:[...y.slice(-e+1),{nodes:a,edges:l}]}),p([])},[a,l,e]),A=()=>{c([]),p([])},g=C.useCallback((y,v,T,_)=>{if(s)return;const x=y[y.length-1];if(x){const b=y.slice(0,-1),w=[...v,{nodes:a,edges:l}];T(b),_(w),i(x.nodes),o(x.edges)}},[i,o,a,l]),m=C.useCallback(()=>g(u,f,c,p),[u,f,g]),O=C.useCallback(()=>g(f,u,p,c),[u,f,g]);return C.useEffect(()=>{if(!t)return;const y=v=>{v.key==="z"&&(v.ctrlKey||v.metaKey)&&v.shiftKey?O():v.key==="z"&&(v.ctrlKey||v.metaKey)&&m()};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y)}},[m,O,t]),{undo:m,redo:O,takeSnapshot:h,clearSnapshot:A,canUndo:!u.length,canRedo:!f.length}},Fot=({open:e})=>{const t=sf();return e?d.jsxs(E.Stack,{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center",spacing:1,sx:{backgroundColor:qa(t.palette.common.white,.75),pointerEvents:"auto",zIndex:t.zIndex.modal},children:[d.jsx(Oi,{size:32}),d.jsx(E.Typography,{variant:"smNormal",sx:{color:"text.secondary"},children:"Arranging automation canvas..."})]}):null},NE=["When a new message is posted in Slack","When a new email is received in Gmail","When a webhook is received"],Xte=["Send email via Gmail","Post to Slack channel","Make API call"],Bot=new Set(["maximum_timeout","continue_on_failure","retry_config.maximum_timeout","retry_config.maximum_attempts","retry_config.backoff_coefficient","retry_config.initial_interval","retry_config.maximum_interval"]),jot=e=>{const t=String(e||"").trim();return!!(!t||Bot.has(t))},Yte=(e,t,n="")=>{if(!e||typeof e!="object")return{};const r={},i=Object.entries(e);for(const[o,s]of i){const a=String(o),l=n?`${n}.${a}`:a;if(!t(l)&&!(s==null||s==="")){if(Array.isArray(s)){s.length>0&&(r[l]=s);continue}if(typeof s=="object"){Object.assign(r,Yte(s,t,l));continue}r[l]=s}}return r},qte=e=>e==="prompt"||e==="error"||e===void 0,Kte=({promptKind:e,mode:t,promptValue:n,onPromptChange:r,onClose:i,onSubmit:o,onRetry:s,onAddManually:a,steps:l,suggestions:u,errorText:c,choice:f,setChoice:p,onContinueChoice:h,auth:A,setAuth:g,onContinueAuth:m,parameters:O,setParameters:y,onContinueParameters:v,inferTesseractEntity:T,ENTITY_ID:_,WORKFLOW_URLS:x,openIntegrationDrawer:b,onAddNewAccount:w,vortexMainUrl:D})=>({promptKind:e,mode:t,promptValue:n,onPromptChange:r,onClose:i,onSubmit:o,onRetry:s,onAddManually:a,steps:l,suggestions:u,errorText:c,choice:f?{label:f.label,options:f.options,selected:f.selected,multiSelect:f.multiSelect,selectedMultiple:f.selectedMultiple,onSelect:I=>p(P=>P&&{...P,selected:I}),onSelectMultiple:I=>p(P=>P&&{...P,selectedMultiple:I}),onContinue:h,continueDisabled:f.multiSelect?!(f.selectedMultiple&&f.selectedMultiple.length>0):!f.selected}:null,auth:A?{label:A.label,options:A.options,selected:A.selected,loading:A.loading,errorText:A.errorText,onSelect:I=>g(P=>P&&{...P,selected:I}),onContinue:m,continueDisabled:A.loading||!A.selected,addNewAccount:{type:T(A.integration_slug,A.field_name),ENTITY_ID:String(_||""),FRONTEND_URL:String(x?.FRONTEND_URL??""),TESSERACT_MAIN_URL:String(x?.TESSERACT_MAIN_URL??""),openIntegrationDrawer:b,onClick:w}}:null,parameters:O?{integrationName:O.integrationName,fields:O.fields,values:O.values,resolvedAuth:O.resolvedAuth,entityId:O.entityId,onValuesChange:I=>y(P=>P&&{...P,values:I}),onContinue:I=>v(I),continueDisabled:O.fields.some(I=>{const P=String(I.name??""),k=O.values[P];return I.required&&(k==null||String(k).trim()==="")})}:null,vortexMainUrl:D,workflowUrls:x});async function $ot(e){const{baseUrl:t,body:n,signal:r,onMessage:i}=e;let o="",s=0;const a=f=>{const p=f.split(`
|
|
649
|
+
`)}),Ke.clipboardData.setData("text/plain",Ye)},[_e]),Mt=C.useCallback(function(){ne(!0)},[ne]),Ht=C.useCallback(function(){ne(!1)},[ne]),St=C.useCallback(function(Ke){var lt=Ke.element,Ye=!1;if(lt.type==="chip"&&_e.selection)try{var ht=on.findPath(_e,lt),Ot=_e.selection;if(Ot&&!qt.isCollapsed(Ot)){var wt=qt.edges(Ot),we=wt[0],We=wt[1],Ze={path:ht,offset:0};Ye=pt.compare(Ze.path,we.path)>=0&&pt.compare(Ze.path,We.path)<=0}}catch{Ye=!1}switch(lt.type){case"chip":return C.createElement(bit,Object.assign({},Ke,{suggestion:lt.suggestion,onDelete:function(){return!V&&!v&&!_&&dt(lt.suggestion.id)},isSelected:Ye}));case"paragraph":return C.createElement(_it,Object.assign({},Ke,{size:M}));default:return C.createElement(Cit,Object.assign({},Ke,{size:M}))}},[dt,M,_e]),Me=C.useCallback(function(){try{var Ke=_e.children[0],lt=_e.children.length===1&&Xi.isElement(Ke)&&Ke.children.length===1&&"text"in Ke.children[0]&&Ke.children[0].text==="";return lt?"100%":"auto"}catch{return"auto"}},[_e]);return C.createElement(E.FormControl,{className:"meta-form-control "+u,sx:{width:"100%",maxWidth:"100%",position:"relative"},fullWidth:!0,key:o,ref:et},(f||Q)&&C.createElement(E.Stack,{direction:"row",justifyContent:"space-between",alignItems:q},C.createElement(Go,{className:"meta-select-label",required:P,description:O,label:f}),C.createElement(E.Typography,{sx:{fontSize:"0.75rem",lineHeight:"1.125rem",fontWeight:500},pb:4,color:"neutral.80"},Q)),C.createElement(E.Paper,{elevation:0,sx:an(an(an(an(an({border:"1px solid "+(pe&&$e?dr.error.main:dr.neutral.outlined.border),":hover":{borderColor:dr.text.primary}},Z&&{border:"1px solid "+qe.palette.primary.main,":hover":{borderColor:V||v||_?dr.text.secondary:qe.palette.primary.main}}),{},{display:"flex"},(V||v||_)&&rt&&{opacity:.4}),(V||v||_)&&{cursor:"not-allowed"}),{},{justifyContent:"center",gap:"1rem"},yit[M]),M!=="xs"&&R&&{resize:"vertical",overflowY:"auto",position:"relative","&::after":{content:'""',display:"block",position:"absolute",width:"18px",height:"18px",bottom:"2px",right:"2px",cursor:"nwse-resize",backgroundImage:"linear-gradient(135deg, transparent 0px, transparent 3px, "+qe.palette.grey[500]+" 3px, "+qe.palette.grey[500]+" 4px,)",pointerEvents:"none"}})},C.createElement(E.Box,{sx:an(an(an(an({flex:1,overflow:"auto"},M==="xs"&&{overflowX:"auto",overflowY:"hidden","-ms-overflow-style":"none","scrollbar-width":"none"}),R&&M!=="xs"?{height:"100%"}:{maxHeight:vit[M]}),{},{"&::-webkit-scrollbar":{display:"none"},'& [data-slate-node="text"]':{minWidth:"2px",minHeight:"16px",display:"inline-block",position:"relative",marginRight:"6px",width:Me}},M==="xs"&&{"&::-webkit-scrollbar":{display:"none"},'& [data-testid="paragraph-element"]::-webkit-scrollbar':{display:"none"}}),{},{'& [data-slate-node="text"]:empty::before, & [data-slate-zero-width="n"]::before':{content:'""',display:"inline-block",minWidth:"1px",minHeight:"16px",position:"relative"},'& [data-slate-placeholder="true"] [data-slate-node="text"]:empty::before, & [data-slate-placeholder="true"] [data-slate-zero-width="n"]::before':{display:"none !important"},'& [data-testid="paragraph-element"]':{marginBottom:M==="xs"?"0":"1px"},'& [data-testid="paragraph-element"]:not(:last-child)':{marginBottom:M==="xs"?"0":"2px"}})},C.createElement(Cs,{name:o,control:$,rules:vt(j)?{}:an(an({},j),{},{validate:function(lt){return/^\s*$/.test(lt)&&P?"Field cannot consist solely of spaces. Please include some characters.":lt&&h==="url"?hx(lt)?!0:"Enter a valid URL":lt&&h==="email"?Ax(lt)?!0:"Enter a valid email":!0}}),render:function(lt){var Ye=lt.field,ht=Ye.onChange,Ot=Za(Ye,Sit);return C.createElement(v7,Object.assign({editor:_e,initialValue:Te,onChange:function(we){return He(ht,we)}},Ot),C.createElement(E7,Object.assign({id:ae,renderElement:St,onKeyDown:Tt,onPaste:ct,onClick:function(we){return!V&&!v&&!_&&oe(we.currentTarget)},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",onCopy:nt,"data-testid":"suggestion-input-"+o,placeholder:b,readOnly:V||v||_,style:an({outline:"none",wordWrap:M==="xs"?"normal":"break-word",whiteSpace:M==="xs"?"pre":"pre-wrap",overflowWrap:M==="xs"?"normal":"break-word",fontWeight:500,fontSize:14,lineHeight:"20px",fontFamily:"Inter"},v&&{opacity:.45}),onFocus:Mt,onBlur:Ht},ue)))}})),W&&!V&&!v&&C.createElement(E.IconButton,{size:"small",onClick:function(lt){return oe(function(Ye){return Ye?null:lt.currentTarget})},"data-testid":"add-suggestion-btn",title:"Click to add dynamic values",sx:an({height:"1rem",width:"1rem",alignItems:"center",justifyContent:"center",padding:"0.5rem",border:"1px solid "+dr.neutral.outlined.border,borderRadius:"0.25rem"},M==="xs"&&{":hover":{backgroundColor:"transparent"}})},C.createElement(Xn,{src:"ic_plus",width:16,height:16}))),C.createElement(E.Stack,null,pe&&$e&&C.createElement(E.FormHelperText,{component:"span",error:!0,dangerouslySetInnerHTML:{__html:Eo($e)}})),C.createElement(Cte,{anchorEl:ve,setAnchorEl:oe,handleSuggestionClick:at,suggestionsData:z,ref:et,handleCustom:re,isLoading:le}))},bit=function(t){var n=t.attributes,r=t.children,i=t.suggestion,o=t.onDelete,s=t.isSelected,a=function(u){u.stopPropagation(),u.preventDefault(),o()};return C.createElement("span",Object.assign({},n,{contentEditable:!1,"data-testid":i?.label+"-chip",style:{display:"inline",marginRight:4}}),C.createElement(Oit,{suggestion:i,onDelete:a,isSelected:s}),r)},Cit=function(t){var n=t.attributes,r=t.children,i=t.size;return C.createElement("span",Object.assign({},n,{"data-testid":"default-element",style:an({minWidth:"2px",minHeight:"16px",display:"inline-block",position:"relative"},i==="xs"&&{flexWrap:"nowrap",gap:"2px 0"})}),r)},_it=function(t){var n=t.attributes,r=t.children,i=t.size;return C.createElement("div",Object.assign({},n,{"data-testid":"paragraph-element",style:an(an({margin:0,padding:0},i!=="xs"&&{display:"flex",flexWrap:"wrap"}),{},{gap:i==="xs"?"4px":"4px 0px",alignItems:"center",minHeight:"20px",position:"relative"},i==="xs"&&{overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",msOverflowStyle:"none"})}),r)},wit=function(t){var n=t.name,r=t.control,i=t.meta,o=t.onFocus,s=t.handleChange,a=t.validationRules,l=t.viewOnly,u=l===void 0?!1:l,c=t.MCP_INTEGRATION_FORM,f=i||{},p=f.displayName,h=p===void 0?"":p,A=f.value,g=A===void 0?!1:A,m=f.description,O=m===void 0?"":m,y=f.error,v=y===void 0?{}:y,T=f.readOnly,_=T===void 0?!1:T,x=f.isDisabled,b=x===void 0?!1:x,w=f.validation,D=w===void 0?{}:w,I=D.disabled,P=I===void 0?!1:I,k=D.required,N=k===void 0?!1:k,L=f.htmlProps,M=L===void 0?{}:L,B=f.htmlProps,Q=B===void 0?{}:B,U=Q.allowDynamic,q=U===void 0?!1:U,F=Eo(O),W=C.useState(!1),G=W[0],R=W[1];C.useEffect(function(){typeof g=="string"&&g==="true"?R(!0):typeof g=="boolean"&&R(g)},[]);var j=function(Y){o(Y,n)};return C.createElement(E.FormControl,{fullWidth:!0,error:v!=null&&v.hasError?!0:void 0,sx:{marginTop:"8px"}},C.createElement(Cs,{name:n,control:r,rules:a,defaultValue:G,render:function(Y){var z=Y.field,H=Y.fieldState,V=H===void 0?{}:H,X=V.error;return C.createElement(E.Stack,{spacing:"0.25rem"},C.createElement(E.Stack,{sx:{width:"100%",flexDirection:"row",alignItems:"center",justifyContent:q?"flex-end":"space-between"}},!q&&h&&C.createElement(Go,{required:N,label:h,description:F}),C.createElement(E.FormControlLabel,Object.assign({disabled:P,label:c?"":z.value?"On":"Off",labelPlacement:"start",control:C.createElement(E.Switch,Object.assign({},z,{onFocus:j,onChange:function(ee){var le=ee.target.checked;(!u||n==="advanced_options")&&(z.onChange(le),s({field:n,value:z.value,fieldData:t}))},onBlur:z.onBlur,value:z.value,checked:z.value,name:n,readOnly:_,disabled:b||u&&n!=="advanced_options","data-testid":"ripple-switch-"+n}))},M,{htmlFor:n}))),X?.message&&C.createElement(E.FormHelperText,{error:!!(X!=null&&X.message)},X?.message))}}))},kte=C.createContext({fieldControlStates:{},setFieldControlState:function(){},getFieldControlState:function(){return""},transformFormData:function(t,n){return n}}),Iit=function(t){var n=t.children,r=C.useState({}),i=r[0],o=r[1],s=function(c,f){o(function(p){var h;return an(an({},p),{},(h={},h[c]=f,h))})},a=function(c){return i[c]||""},l=function(c,f){if(!c||!f)return f;var p=an({},f);return c.forEach(function(h){var A,g,m,O,y=h.name,v=f[y],T=a(y);if(v?p[y]=v:(!T||T==="")&&!v?p[y]="BOLTIC_AI":["BOLTIC_AI","BOLTIC_AI_IGNORE"].includes(T)&&(p[y]=T),(h==null||(A=h.meta)===null||A===void 0?void 0:A.displayType)==="array"&&Array.isArray(v)&&(g=h.meta)!==null&&g!==void 0&&g.children)p[y]=v.map(function(x){var b;return l((b=h.meta)===null||b===void 0?void 0:b.children,x)});else if((h==null||(m=h.meta)===null||m===void 0?void 0:m.displayType)==="object"&&typeof v=="object"&&v!==null&&(O=h.meta)!==null&&O!==void 0&&O.children){var _;p[y]=l((_=h.meta)===null||_===void 0?void 0:_.children,v)}}),p};return C.createElement(kte.Provider,{value:{fieldControlStates:i,setFieldControlState:s,getFieldControlState:a,transformFormData:l}},n)},Mte=function(){return C.useContext(kte)},Dit=function(t){return function(r){var i,o,s,a,l=r.MCP_INTEGRATION_FORM,u=l===void 0?!1:l,c=r.name,f=c===void 0?"":c,p=r.MCP_EXCLUDED_FIELDS,h=p===void 0?[]:p,A=r.field,g=A===void 0?{}:A,m=r.handleChange,O=r.meta,y=O===void 0?{}:O,v=y.displayName,T=v===void 0?"":v,_=y.description,x=_===void 0?"":_,b=y.htmlProps,w=b===void 0?{}:b,D=ns(),I=D.setValue,P=w.showInfoIcon,k=P===void 0?!1:P,N=w.rightLabel,L=N===void 0?"":N,M=w.rightLabelAlignment,B=M===void 0?"center":M,Q=w.showAddNew,U=Q===void 0?!1:Q,q=Eo(x),F=ns(),W=(i=F.getValues)===null||i===void 0?void 0:i.call(F,f),G=Mte(),R=G.setFieldControlState,j=C.useState(u?"BOLTIC_AI":"specific"),$=j[0],Y=j[1];C.useEffect(function(){if(u){var V="BOLTIC_AI";["BOLTIC_AI","BOLTIC_AI_IGNORE"].includes(W)?V=W:W&&W!==""&&(V="specific"),Y(V),R(f,V)}},[]);var z=function(X){var J=X.target.value;Y(J),R(f,J),["BOLTIC_AI","BOLTIC_AI_IGNORE"].includes(J)?(I(f,J),m?.({field:f,value:J,fieldData:r})):(I(f,""),m?.({field:f,value:"",fieldData:r}))},H=an(an({},r.meta),{},{htmlProps:an(an({},r==null||(o=r.meta)===null||o===void 0?void 0:o.htmlProps),{},{rightLabel:"",showInfoIcon:!1}),validation:{infoDetail:{infoMsg:""}},displayName:""});return u&&!h.includes(f)&&!["array","object","section"].includes(f)&&!g.hidden&&!f.includes("toolParamsMcp")?C.createElement(E.Stack,{spacing:U||L?0:"0.5rem"},C.createElement(E.FormControl,{fullWidth:!0},(T||L||k)&&C.createElement(E.Stack,{direction:"row",justifyContent:"space-between",alignItems:B},C.createElement(Go,{required:r==null||(s=r.meta)===null||s===void 0||(a=s.validation)===null||a===void 0?void 0:a.required,label:T,description:q}),L&&C.createElement(E.Typography,{sx:{fontSize:"0.75rem",lineHeight:"1.125rem",fontWeight:500},pb:"0.25rem",color:"neutral.80"},L)),C.createElement(E.Select,{value:$,onChange:z,label:"Field Value Control"},C.createElement(E.MenuItem,{sx:{py:.8},value:"BOLTIC_AI"},"Have AI generate a value for this field"),C.createElement(E.MenuItem,{sx:{py:.8},value:"BOLTIC_AI_IGNORE"},"Do not include a value for this field"),C.createElement(E.MenuItem,{sx:{py:.8},value:"specific"},"Set a specific value for this field"))),$==="specific"&&C.createElement(t,Object.assign({},r,{meta:an({},H)}))):C.createElement(t,Object.assign({},r))}},oi={ACCORDION:"accordion",DIVIDER:"divider",SECTION:"section",TEXT:"text",SELECT:"select",RADIO:"radio",CHECKBOX:"checkbox",EMAIL:"email",NUMBER:"number",PASSWORD:"password",AUTOCOMPLETE:"autocomplete",FILE:"file",CODE:"code",BUTTON:"button",HIDDEN:"hidden",MULTITEXT:"multitext",TEXTAREA:"textarea",MULTISELECT:"multiselect",TOGGLE:"toggle",RADIOBUTTON:"radiobutton",ARRAY:"array",OBJECT:"object",PHONE:"phone",URL:"url",DATE:"date",TIME:"time",DATETIME:"datetime",KEYVALUE:"keyvalue",SLIDER:"slider"},Rit=function(t){var n,r=t.hidden,i=r===void 0?!0:r,o=t.meta,s=o===void 0?{}:o,a=s.displayType,l=a===void 0?"":a,u=s.displayName,c=u===void 0?"":u,f=s.htmlProps,p=f===void 0?{}:f,h=p.allowDynamic,A=h===void 0?!1:h,g=p.showInfoIcon,m=g===void 0?!1:g,O=p.rightLabel,y=O===void 0?"":O,v=p.size,T=v===void 0?"":v,_=p.overrideDynamicSupport,x=_===void 0?!1:_,b=s.validation,w=b===void 0?{}:b,D=w.infoDetail,I=D===void 0?{}:D,P=I.infoMsg,k=P===void 0?"":P,N=s.validation,L=N===void 0?{}:N,M=s.description,B=M===void 0?"":M,Q=s.readOnly,U=Q===void 0?!1:Q,q=t.suggestions,F=q===void 0?{}:q,W=t.viewOnly,G=W===void 0?!1:W,R=F&&Object?.keys(F),j=["email","password","url","number","code","text","textarea"],$=(A||j.includes(l))&&R?.length>0,Y=!["object"].includes(l),z=an(an({},t.meta),{},{htmlProps:an(an({},t==null||(n=t.meta)===null||n===void 0?void 0:n.htmlProps),{},{rightLabel:$&&Y?"":y,showInfoIcon:$&&Y?!1:m}),validation:an(an({},L),{},{infoDetail:{infoMsg:$&&Y?"":k}}),displayName:$&&Y?"":c}),H=ns(),V=H.getValues,X=H.setValue,J=H.watch,ee=C.useState("static"),le=ee[0],re=ee[1],ue=C.useRef(null),Oe=function(dt,Tt){if(Tt==="static"){var Ie;X(t.name,(t==null||(Ie=t.meta)===null||Ie===void 0?void 0:Ie.value)||"")}else{var at;X(t.name,String((t==null||(at=t.meta)===null||at===void 0?void 0:at.value)||""))}re(Tt)};C.useEffect(function(){var He=V(t.name);typeof He=="string"&&He.startsWith("{{")?re("dynamic"):re("static")},[]);var ve=J(t.name),oe=(A&&!["text","textarea"].includes(l)||["email","password","url","number"].includes(l))&&!["file","code"].includes(l)&&!x&&!G&&!U&&R.length>0,ae=function(dt,Tt){var Ie,at;return Tt===void 0&&(Tt="xs"),C.createElement(E.Stack,{className:"dynamic-wrapper"},C.createElement(E.FormControl,{fullWidth:!0,ref:ue},(A||["email","password","url","number","textarea","text"].includes(l))&&!["file","code"].includes(l)&&R?.length>0&&C.createElement(E.Stack,{alignItems:"flex-end",justifyContent:"space-between",direction:"row",pb:oe?"4px":0},(A||["email","password","url","number","textarea","text"].includes(l))&&!["file","code"].includes(l)&&R?.length>0&&C.createElement(Go,{className:"meta-select-label",required:t==null||(Ie=t.meta)===null||Ie===void 0||(at=Ie.validation)===null||at===void 0?void 0:at.required,label:c,description:B||k}),oe&&C.createElement(E.Tabs,{value:le,onChange:Oe,"aria-label":"select type",TabIndicatorProps:{sx:{display:"none"}}},crt.map(function(ct,nt){return C.createElement(E.Tab,{key:nt,label:ct.label,value:ct.value})}))),(le==="dynamic"&&l!==oi.CODE||["text","textarea"].includes(l))&&!x&&l!=="file"&&R&&R.length>0&&C.createElement(E.Stack,null,C.createElement(xit,Object.assign({},t,{suggestionsData:t.suggestions||{},meta:an(an({},t.meta),{},{displayName:"",htmlProps:an(an({},t.meta.htmlProps),{},{showSuggestions:!0,size:Tt,rightLabel:""}),validation:L}),validationRules:ve!=null&&ve.includes("{")?{}:t?.validationRules}))),(le!=="dynamic"||l===oi.CODE)&&(!["text","textarea"].includes(l)||["text","textarea"].includes(l)&&vt(F)||x)&&dt))};if(i||l==="hidden")return null;var te=function(dt,Tt,Ie){return C.createElement(nit,Object.assign({},t,{type:dt,htmlProps:Tt,textFieldProps:Ie,meta:z}))},Z=function(){var dt,Tt,Ie=(dt=t==null||(Tt=t.validation)===null||Tt===void 0?void 0:Tt.max)!=null?dt:"",at=Ie?{maxLength:Ie}:void 0;return te("text",at)},ne=function(){var dt={type:"password"};return te("password",dt)},se=function(){return te("email")},pe=function(){return te("number")},he=function(){return te("url")},de=function(){var dt,Tt,Ie=t.meta.htmlProps,at={multiline:!0,minRows:(dt=Ie?.minRows)!=null?dt:2,maxRows:(Tt=Ie?.maxRows)!=null?Tt:2};return te("text",{},at)},xe=function(){return C.createElement(pit,Object.assign({},t,{meta:z}))},ge=function(){return C.createElement(Ert,Object.assign({},t,{meta:z}))},Ee=function(){return C.createElement(mit,Object.assign({},t,{meta:z}))},ke=function(){return C.createElement(ait,Object.assign({},t,{meta:z}))},Ge=function(){return C.createElement(grt,Object.assign({},t))},$e=function(){return C.createElement(Jrt,Object.assign({},t))},et=function(){return C.createElement(Xrt,Object.assign({},t,{suggestionsData:t.suggestions||{},meta:an(an({},t.meta),{},{htmlProps:an(an({},t.meta.htmlProps),{},{showSuggestions:!0})})}))},rt=function(){return C.createElement(eit,Object.assign({},t))},it=function(){return C.createElement(hit,Object.assign({},t))},Re=function(){return C.createElement(qrt,Object.assign({},t))},Xe=function(){return C.createElement(wit,Object.assign({},t))},qe=function(){return C.createElement(fit,Object.assign({},t,{meta:z}))},Se=function(){return C.createElement(iit,Object.assign({},t,{meta:z}))},_e=function(){return C.createElement(Yrt,Object.assign({},t,{meta:z}))},be=function(){return C.createElement(dit,Object.assign({},t,{meta:z}))},K=function(){return C.createElement(Art,Object.assign({},t,{meta:z}))},ce=function(){return C.createElement(lit,Object.assign({},t,{meta:z}))},Te=function(){return C.createElement(rit,Object.assign({},t,{meta:z}))},je=function(){return C.createElement(Eit,Object.assign({},t,{meta:z}))},Fe=function(){return C.createElement(irt,Object.assign({},t,{meta:z}))};switch(l){case oi.TEXT:return ae(Z());case oi.PASSWORD:return ae(ne());case oi.EMAIL:return ae(se());case oi.NUMBER:return ae(pe());case oi.URL:return ae(he());case oi.RADIO:return ae(xe());case oi.RADIOBUTTON:return ae(qe());case oi.CHECKBOX:return ae(ge());case oi.CODE:return ae(et(),T||"md");case oi.TEXTAREA:return ae(de(),T||"sm");case oi.SELECT:case oi.AUTOCOMPLETE:return ae(Ee());case oi.MULTISELECT:return ae(ke());case oi.BUTTON:return ae(Ge());case oi.TOGGLE:return ae(Xe());case oi.MULTITEXT:return ae(Se());case oi.HIDDEN:return rt();case oi.FILE:return ae($e());case oi.SECTION:return ae(it());case oi.DIVIDER:return ae(Re());case oi.PHONE:return ae(be());case oi.DATE:return ae(_e());case oi.TIME:return ae(_e());case oi.DATETIME:return ae(_e());case oi.ARRAY:return ae(K(),T||"md");case oi.OBJECT:return ae(ce(),T||"md");case oi.KEYVALUE:return ae(Te(),T||"md");case oi.SLIDER:return ae(je());case oi.ACCORDION:return ae(Fe());default:return C.createElement(E.Box,null,"Display Type: ",l," is not supported!")}},XA=Dit(C.memo(Rit)),Pit=function(t,n){var r=C.useState(t),i=r[0],o=r[1],s=C.useCallback(function(a){return a?.map(function(l){var u,c=l?.meta||{},f=c.dependencies;if(f){var p=f.logic,h=p===void 0?"AND":p,A=f.conditions,g=A===void 0?[]:A,m=h==="AND";g.forEach(function(y){var v,T=y.operator,_=y.field,x=y.value,b=!1,w=art(n,_)||(l==null||(v=l.meta)===null||v===void 0?void 0:v.value);switch(T){case"EQUALS":b=w===x;break;case"NOT_EQUALS":b=w!==x;break;case"GREATER_THAN":b=w>x;break;case"LESS_THAN":b=w<x;break;case"GREATER_THAN_OR_EQUALS":b=w>=x;break;case"LESS_THAN_OR_EQUALS":b=w<=x;break;case"CONTAINS":b=Array.isArray(w)?w.includes(x):w?.toString().includes(x);break;case"NOT_CONTAINS":b=Array.isArray(w)?!w.includes(x):!(w!=null&&w.toString().includes(x));break;case"STARTS_WITH":b=w?.toString().startsWith(x);break;case"ENDS_WITH":b=w?.toString().endsWith(x);break;case"REGEX":b=new RegExp(x).test(w?.toString());break;case"NOT_REGEX":b=!new RegExp(x).test(w?.toString());break;case"EMPTY":b=!w;break;case"NOT_EMPTY":b=!!w;break}m=h==="AND"?m&&b:m||b}),l.hidden=!m}if(["array","object","section"].includes(l==null||(u=l.meta)===null||u===void 0?void 0:u.displayType)){var O;l!=null&&(O=l.meta)!==null&&O!==void 0&&O.children&&(l.meta.children=s(l?.meta.children||[]))}return l})},[n]);return C.useEffect(function(){o(s(t))},[t,n,s]),i},Nit=function(t){var n=t.reduce(function(r,i){return r[i.key]=i.value,r},{});return n},gx=function(t,n){return t.forEach(function(r){var i,o;if(["object","array","section"].includes((i=r.meta)===null||i===void 0?void 0:i.displayType))if(["configure","setup"].includes(r?.name)){var s;gx((s=r.meta)===null||s===void 0?void 0:s.children,n)}else{var a=n[r.name];if(a){var l;gx((l=r.meta)===null||l===void 0?void 0:l.children,a)}}else((o=r.meta)===null||o===void 0?void 0:o.displayType)==="keyvalue"&&Array.isArray(n[r.name])&&(n[r.name]=Nit(n[r.name]))}),n},Lit=C.forwardRef(function(e,t){var n=e.name,r=e.schema,i=r===void 0?[]:r,o=e.form,s=o===void 0?{}:o,a=e.suggestions,l=e.onChange,u=e.onSubmit,c=e.onFocus,f=e.onCustom,p=e.buttonSchema,h=e.loading,A=e.onCancel,g=e.sx,m=e.isLoading,O=m===void 0?!1:m,y=e.useDefaultButtons,v=y===void 0?!0:y,T=e.viewOnly,_=T===void 0?!1:T,x=e.MCP_INTEGRATION_FORM,b=x===void 0?!1:x,w=e.MCP_EXCLUDED_FIELDS,D=w===void 0?[]:w,I=an({},s),P=Mte(),k=P.transformFormData,N=C.useMemo(function(){var X;return(X=SE(i,I))!=null?X:{}},[i,I]),L=rJe({values:N,mode:"all"}),M=QJ({control:L.control,defaultValue:N}),B=C.useState(i),Q=B[0],U=B[1],q=C.useMemo(function(){return i},[i,n]),F=C.useMemo(function(){return M},[M,n]),W=zA(i),G=Pit(q,F);C.useEffect(function(){U(G)},[G,n]);var R=C.useCallback(function(X){c&&c(X)},[c]),j=C.useCallback(function(){A&&A()},[A]),$=C.useCallback(function(X){if(l){var J=L.getValues(),ee=L.getValues(X.field),le=an(an({},X),{},{value:ee});l(le,J)}},[l,L,M]),Y=C.useCallback(function(X){return X===void 0&&(X=""),function(J){var ee=gx(i,J);if(b&&(ee=k(i,ee)),u){var le=gx(i,J);u(le,X)}}},[u,i,k,b]),z=C.useCallback(function(X,J,ee){if(J===void 0&&(J={}),ee===void 0&&(ee=""),f){var le=L.getValues();f(X,an(an({},le),J),ee)}},[f,M]),H=C.useCallback(function(){try{return Promise.resolve(L.trigger()).then(function(X){return!!X})}catch(X){return Promise.reject(X)}},[L,Q]);C.useImperativeHandle(t,function(){return{handleSubmit:function(J){var ee;J===void 0&&(J=""),(ee=L.handleSubmit(Y(J)))===null||ee===void 0||ee()},getValues:L.getValues,isValidated:function(){try{return Promise.resolve(H())}catch(X){return Promise.reject(X)}}}});var V=C.useRef(!1);return C.useEffect(function(){if(!(V.current||!l)){V.current=!0;var X=function(le){le===void 0&&(le=[]);var re=[];return le.forEach(function(ue){var Oe,ve,oe=ue==null||(Oe=ue.meta)===null||Oe===void 0?void 0:Oe.children;oe&&Array.isArray(oe)?re.push.apply(re,X(oe)):(ue==null||(ve=ue.meta)===null||ve===void 0?void 0:ve.displayType)==="hidden"&&re.push(ue)}),re},J=X(i);J.forEach(function(ee){$({field:ee.name,fieldData:ee})})}},[i,l,$]),C.createElement(VZe,Object.assign({},L),C.createElement("form",{key:n,name:"ripple-form",className:"ripple-form",noValidate:!0,style:an({display:"flex",flexDirection:"column",height:"100%"},g)},C.createElement(E.Stack,{gap:1,alignItems:"center",sx:{overflowY:"auto",flexGrow:1},className:"ripple-form-container",width:"100%"},Q&&Q.length>0&&Q.map(function(X,J){var ee,le;return C.createElement(E.Stack,{width:"100%",key:X?.name+"::"+J+"::"+n,sx:{display:(X==null||(ee=X.meta)===null||ee===void 0?void 0:ee.displayType)==="hidden"||X?.hidden===!0?"none":"flex"}},C.createElement(ert,{fieldName:X?.name},C.createElement(XA,Object.assign({},X,{isLoading:O,field:X,hidden:X?.hidden||!1,control:L.control,handleChange:$,onFocus:R,handleCustom:z,viewOnly:_,validationRules:["object","array","keyvalue"].includes(X==null||(le=X.meta)===null||le===void 0?void 0:le.displayType)?W:W[X?.name],suggestions:a,MCP_INTEGRATION_FORM:b,MCP_EXCLUDED_FIELDS:D}))))}),C.createElement(E.Stack,{width:"100%",alignItems:"center"},O&&C.createElement(E.CircularProgress,null))),v&&C.createElement(trt,{buttonSchema:p,onSubmit:function(J){return L.handleSubmit(Y(J))()},onReset:function(){return L.reset()},onCancel:j,loading:h||O,style:{flexShrink:0}})))}),Ex=C.forwardRef(function(e,t){var n=C.useRef(null);return C.useImperativeHandle(t,function(){var r;return{handleSubmit:function(o){var s,a;o===void 0&&(o=""),n==null||(s=n.current)===null||s===void 0||(a=s.handleSubmit)===null||a===void 0||a.call(s,o)},isValidated:n==null||(r=n.current)===null||r===void 0?void 0:r.isValidated}}),C.createElement(Iit,null,C.createElement(Lit,Object.assign({},e,{ref:n})))});const kit=(e,t,n)=>{const r=[Zn.WORKFLOW_EXECUTION_COMPLETED,Zn.ACTIVITY_TASK_COMPLETED],i=[Zn.ACTIVITY_TASK_FAILED,Zn.ACTIVITY_TASK_TIMED_OUT,Zn.WORKFLOW_EXECUTION_FAILED,Zn.WORKFLOW_EXECUTION_TIMED_OUT,Zn.WORKFLOW_EXECUTION_TERMINATED,Zn.WORKFLOW_EXECUTION_CANCELED,Zn.WORKFLOW_TASK_TIMED_OUT];{if(r.includes(e))return n.palette.success.main;if(i.includes(e))return n.palette.error.main}},CE=e=>{const t=[Zn.WORKFLOW_EXECUTION_COMPLETED,Zn.WORKFLOW_EXECUTION_FAILED,Zn.WORKFLOW_EXECUTION_TIMED_OUT,Zn.WORKFLOW_EXECUTION_TERMINATED,Zn.WORKFLOW_EXECUTION_CANCELED,Zn.WORKFLOW_EXECUTION_TERMINATED,Zn.WORKFLOW_TASK_FAILED,Zn.WORKFLOW_TASK_TIMED_OUT];return e?e.some(n=>t.includes(n.eventType)):[]};function Mit(e){const t=e.eventType.replace(/_/g," ").replace("EVENT TYPE","").replace(/\w\S*/g,n=>n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()).trim();if(e.eventType===Zn.ACTIVITY_TASK_SCHEDULED&&e.activityTaskScheduledEventAttributes){const n=e.activityTaskScheduledEventAttributes?.input?.payloads?.[0]?.data?.name;return n?`${t}: ${n}`:t}return t}function Fit(e){if(e==null||typeof e!="object"||Array.isArray(e))return e;const{isBranch:t,branchToExecute:n,...r}=e;return r}const Ox=e=>{if(!(typeof e=="string"||e instanceof String))return;const t=e.match(/\{\{([^{}]+)\}\}/);if(t)return t[1].trim()},Bit=(e,t)=>new Promise((n,r)=>{const i=t.split(".");let o=e;for(const[s,a]of i.entries())if(a.includes("[")){let l,u;if(!a.includes("]"))throw l=a.split("["),u=l[0],r(`Invalid Syntax while using ${u}`),new Error(`Invalid Syntax while using ${u}`);l=a.split("["),u=l[0];const c=parseInt(l[1].replace("]",""));if(!Array.isArray(o[u]))throw r(`${u} should be an array, found ${typeof o[u]}`),new Error(`${u} should be an array, found ${typeof o[u]}`);if(isNaN(c)||c<0)throw r(`Invalid array index for ${a}`),new Error(`Invalid array index for ${a}`);if(c>=o[u].length)throw r(`Invalid array index: ${a}, Max length of ${u} is ${o[u].length}`),new Error(`Invalid array index: ${a}, Max length of ${u} is ${o[u].length}`);o=o[u][c]}else if(a==="uuid4()")o=Z3();else if(o=o[a],o&&s<i.length-1&&Array.isArray(o)){if(i.includes("length")&&i[i.length-1]==="length")continue;throw r(`Invalid Syntax, Use ${a}[${s}]`),new Error(`Invalid Syntax, Use ${a}[${s}]`)}n(o)}),jit=async(e,t)=>{if(typeof e!="string")return e;const n=/{{([^{}]*)}}/g,r=[];let i;for(;(i=n.exec(e))!==null;)r.push(i);for(const o of r){const s=o[1],a=await Bit(t,s),l=a!==void 0?typeof a=="object"?JSON.stringify(a):a.toString():"";e=e.replace(o[0],l)}return e},m8=async(e,t)=>{const n=Array.isArray(e)?[]:{};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const i=e[r];typeof i=="object"&&i!==null?n[r]=await m8(i,t):typeof i=="string"?n[r]=await jit(i,t):n[r]=i}return n},g8=[{name:"activity_name",meta:{displayName:"Custom Name",displayType:"hidden",placeholder:"Enter the custom name",validation:{required:!0},value:""}},{name:"integration_slug",meta:{displayName:"Integration Slug",displayType:"hidden",placeholder:"Enter the integration slug",validation:{required:!0},value:""}}],$it=[{name:"advanced_options",meta:{displayName:"Advanced Options",displayType:"accordion",htmlProps:{headerVariant:"smSemiBold"},children:[{name:"continue_on_failure",meta:{displayName:"Continue on Failure",displayType:"toggle",description:"When enabled, a failure handle appears on this node. If this node fails, workflow continues through the failure path. If disabled and this node fails, the entire workflow stops.",value:!1,readOnly:!1}},{name:"retry_config",meta:{displayType:"object",children:[{name:"maximum_attempts",meta:{displayName:"Maximum Number of Attempts",displayType:"number",placeholder:"Enter the maximum number of tries",description:"The maximum number of times to try the activity, including the first attempt. If set to 3, the activity will run at most 3 times.",validation:{required:!0},htmlProps:{allowDynamic:!1,overrideDynamicSupport:!0},value:1,dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}},{name:"backoff_coefficient",meta:{displayName:"Retry Backoff Rate",displayType:"number",placeholder:"Enter the wait time between tries",description:"Constants factor by which the time delay between the retry attempts increase after the each failure",validation:{required:!0},htmlProps:{allowDynamic:!1,overrideDynamicSupport:!0},value:2,dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}},{name:"initial_interval",meta:{displayName:"Wait Time Before First Retry (seconds)",displayType:"number",placeholder:"Enter the initial wait time",description:"The time to wait before the first retry after a failure. For example, if set to 5 seconds, the first retry will occur 5 seconds after the failure.",validation:{required:!0},htmlProps:{overrideDynamicSupport:!0,allowDynamic:!1},value:1e3,dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}},{name:"maximum_interval",meta:{displayName:"Maximum Wait Between Retries (seconds)",displayType:"number",placeholder:"Enter the maximum wait time",description:"The longest time to wait between retries, regardless of backoff. Prevents the delay from growing indefinitely.",validation:{required:!0},htmlProps:{overrideDynamicSupport:!0,allowDynamic:!1},value:1e5,dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}}],dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}},{name:"maximum_timeout",meta:{displayName:"Maximum Activity Completion Timeout in (m/s)",displayType:"number",placeholder:"Enter the maximum timeout",description:"Maximum time to wait for the Activity to complete",validation:{required:!0},value:6e4,htmlProps:{overrideDynamicSupport:!0,allowDynamic:!1},dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}}],dependencies:{conditions:[{field:"secret",operator:"NOT_EMPTY"},{field:"resource",operator:"NOT_EMPTY"},{field:"operation",operator:"NOT_EMPTY"}]}}}],yx=async(e,t)=>{const{url:n,method:r,body:i}=e,o=r,s=i&&await m8({body:i},{parameters:t}),a={};s&&(o==="post"||o==="put"||o==="patch")&&(a.data=s.body);const{data:l}=await Xt[o](n,a);return l},Uit=async(e,t,n,r,i,o)=>{const{integration_id:s,resource:a,operation:l,integration_slug:u}=e,c=[];if(!s&&!u)throw new Error("integration_slug or integration_id is required in payload");const p=[n,"v1.0",r,"integrations",u||s],h=Yt(...p,"configuration"),{data:A}=await Xt.get(h),g=A.data.content.parameters;if(c.push(...g),a&&p.push("resource",a),!vt(a)){const m=Yt(...p),{data:O}=await Xt.get(m);if(!O.data.content.parameters)throw new Error("No integration schema data found");c.push(...O.data.content.parameters)}if(!vt(a)&&!vt(l)){l&&p.push("operation",l);const m=Yt(...p),{data:O}=await Xt.get(m),y=O?.data?.content;if(!y)throw new Error("No Operation schema found");if(y?.config){const{method:v,urlType:T,body:_,condition:x}=y.config;if(x){const b=Ox(x);if(b){const w=b.split(".")[1];if(t?.[w]){let{url:D}=y.config;D=Yt(n,"v1.0",r,D);const I={..._,...u&&{integration_slug:u},...s&&{integration_id:s}},P=Object.assign({},{url:D,method:v,urlType:T,body:I}),k=await yx(P,t);c.push(...y.parameters,...k)}else c.push(...y.parameters)}}else{let{url:b}=y.config;b=Yt(n,"v1.0",r,b);const w={..._,...u&&{integration_slug:u},...s&&{integration_id:s}},D=Object.assign({},{url:b,method:v,urlType:T,body:w}),I=await yx(D,t);c.push(...y.parameters,...I)}}else c.push(...y.parameters)}return i||o?c.push(...g8):c.push(...g8,...$it),c},Hit=async(e,t,n,r)=>{const{integration_id:i,resource:o="webhook",operation:s,integration_slug:a}=e,l=[];let u;if(!i&&!a)throw new Error("integration_slug or integration_id is required in payload");const f=[n,"v1.0",r,"integrations",a||i];if(o&&o==="webhook"){f.push("webhook");const p=Yt(...f),{data:h}=await Xt.get(p);if(u=h.data.content,!u)throw new Error("No integration schema data found");l.push(...u.parameters)}if(!vt(o)&&!vt(s)){if(u?.config){const{method:h,urlType:A,body:g,condition:m}=u.config;if(m){const O=Ox(m);if(O){const y=O.split(".")[1];if(t?.[y]){let{url:v}=u.config;v=Yt(n,"v1.0",r,v);const T={...g,...a&&{integration_slug:a},...i&&{integration_id:i}},_=Object.assign({},{url:v,method:h,urlType:A,body:T}),x=await yx(_,t);l.push(...u.parameters,...x)}else l.push(...u.parameters)}}else{let{url:O}=u.config;O=Yt(n,"v1.0",r,O);const y={...g,...a&&{integration_slug:a},...i&&{integration_id:i}},v=Object.assign({},{url:O,method:h,urlType:A,body:y}),T=await yx(v,t);l.push(...u.parameters,...T)}}const p=u[s]?.parameters;l.push(...p)}return l.push(...g8),{data:l,polling_interval:u?.polling_interval}},vx=({formData:e,isLoop:t=!1,selectedNode:n,INTEGRATION_DATA:r,SET_INTEGRATION_DATA:i,onClose:o,openIntegrationDrawer:s,handleRunActivity:a,handleCompleteSetup:l,setPollingInterval:u,onSubmit:c,source:f="",MCP_INTEGRATION_FORM:p=!1})=>{const[h,A]=C.useState([]),[g,m]=C.useState({}),[O,y]=C.useState(!1),[v,T]=C.useState({headers:{},query:"",variables:{}}),_=C.useRef(!1),x=C.useRef(null),b=gt.useDispatch(),[w,D]=C.useState(!1),{WORKFLOW_URLS:I,ENTITY_ID:P=""}=Ci(),{VORTEX_MAIN_URL:k,TESSERACT_MAIN_URL:N,FRONTEND_URL:L}=I,M=n?.data?.type,B=n?.data?.properties?.activity_name,Q=n?.data?.properties?.activity_id,U=n?.data?.properties?.integration_slug,q=re=>{if(!re)return{};if(typeof re=="string")try{const ue=JSON.parse(re);return typeof ue=="object"&&ue!==null?ue:{}}catch{return{}}return typeof re=="object"?re:{}},F=(re,ue)=>{m(Oe=>{const ve={...Oe,[re]:ue};return Oe?.properties&&typeof Oe.properties=="object"&&(ve.properties={...Oe.properties,[re]:ue}),ve})},W=()=>{y(!1),T({headers:{},query:"",variables:{}})},G=re=>{F("query",re),T(ue=>({...ue,query:re}))},R=re=>{T(ve=>({...ve,variables:re}));const Oe=typeof g?.variables=="string"&&typeof re!="string"?JSON.stringify(re,null,2):re;F("variables",Oe),W()},j=()=>O?d.jsx(So,{open:O,handleClose:W,title:"GraphQL Inspector",subtitle:"Explore the GraphQL schema and build queries by selecting fields",icon:d.jsx(Ue,{src:"ic_schema"}),sx:{".MuiDialogContent-root":{padding:"16px 24px !important"}},content:d.jsx(_J,{form:g,headers:C4(v.headers||{}),currentQuery:v.query||"",onQueryUpdate:G,onVariablesUpdate:R})}):null,$=async re=>{if(x.current!==re){x.current=re;try{const ue=Yt(N,`/v1/integrations/${re}/validate-token`),Oe=await Xt.get(ue),{data:ve}=Oe.data;if(ve){const{is_revoked:oe}=ve;if(_.current!==oe&&(_.current=oe,h.length>0)){const ae=h.map(te=>te.name==="secret"?{...te,meta:{...te.meta,htmlProps:{...te.meta.htmlProps,showReconnect:oe}}}:te);A(ae)}}}catch(ue){dn(ue,b)}}},Y=async()=>{if(g.secret)if(s)s({_id:g.secret},"edit");else{const re=`${L}/accounts/${P}/integrations/destination/new-destination/${g.secret}/edit`;window.open(re)}},z=async({resource:re,operation:ue,currentFormData:Oe={},schema:ve=[]})=>{try{let oe=ve;if(M!==Je.SERVERLESS){D(!0);const Z={...U&&{integration_slug:U},...Q&&{integration_id:Q},...ue&&{operation:ue},...re&&{resource:re}};let ne={};if(vt(Oe)?ne=vt(g)?e.properties:g:ne=Oe,M===Je.CLOUD_TRIGGER){const{data:se,polling_interval:pe}=await Hit(Z,ne,k,P);oe=se,u&&u?.(pe)}else oe=await Uit(Z,ne,k,P,t,p)}let ae=oe;const te=async(Z,ne=[])=>{if(f?.includes("commerce_")&&M===Je.PLATFORM_FDK_ACTIVITY){const se=f?.split("_"),pe=se&&se.length>1?se[1]:null,he=se&&se.length>2?se.slice(2).join("_"):pe;ae=ae?.map(de=>de.name==="secret"?(delete de.meta.config,{...de,meta:{...de.meta,options:[{value:f,label:he}],value:f,isDisabled:!0,htmlProps:{...de.meta.htmlProps,showReconnect:_.current}}}):de)}for(const se of Z){if((se?.meta?.displayType==="select"||se?.meta?.displayType==="autocomplete"||se?.meta?.displayType==="multiselect")&&se?.meta?.config?.url){const{method:pe,labelKey:he,valueKey:de,urlType:xe,body:ge,condition:Ee}=se.meta.config;let{url:ke}=se.meta.config;xe==="secret"?ke=Yt(N,"v1/integrations/entity",ke):xe==="options"&&(ke=Yt(k,"v1.0",P,ke));const Ge={...ge,...Q&&{integration_id:Q},...U&&{integration_slug:U}},$e=Object.assign({},{url:ke,method:pe,labelKey:he,valueKey:de,body:Ge});if(Ee){const et=Ox(Ee);if(et){const rt=et.split(".")[1];(g[rt]||e?.properties?.[rt])&&(ae=await V(se.name,$e,ae,[...ne,se.name]))}}else ae=await V(se.name,$e,ae,[...ne,se.name])}se?.meta?.children&&se?.meta?.children?.length>0&&await te(se?.meta?.children,[...ne,se.name])}};await te(ae),_.current&&(M===Je.CLOUD_TRIGGER||M===Je.CUSTOM_ACTIVITY)&&(ae=ae.map(Z=>(Z.name==="secret"&&(Z.meta.htmlProps={...Z.meta.htmlProps,showReconnect:_.current}),Z))),A(ae)}catch(oe){dn(oe,b)}finally{D(!1)}},H=async()=>{const re=Yt(k,"v1.0",P,"integrations",U,"configuration"),ue={advanced_options:!0};Xt.get(re,{params:ue}).then(async({data:Oe})=>{if(t){const ve=Oe.data.content.parameters.filter(oe=>!["advanced_options","maximum_attempts","backoff_coefficient","initial_interval","maximum_interval","maximum_timeout"].includes(oe.name));await z({schema:ve})}else await z({schema:Oe.data.content.parameters})})},V=async(re,ue,Oe,ve=[])=>{D(!0);try{const{url:oe,method:ae,labelKey:te,valueKey:Z,body:ne}=ue,se=ae,pe=ne&&await m8({body:ne},{parameters:vt(g)?e.properties:g}),he={};pe&&(se==="post"||se==="put"||se==="patch")&&(he.data=pe.body);const de=await Xt[se](oe,he),ge=(re==="secret"?de.data.data:de.data)?.map(ke=>({value:ke[Z],label:ke[te]}));let Ee=[];if(ve?.length===0)Ee=Oe?.map(ke=>ke.name===re?{...ke,meta:{...ke.meta,options:ge}}:ke);else{Ee=Oe;const ke=(Ge,$e,et,rt=0)=>{Ge.forEach(it=>{it.name===$e[rt]&&(rt===$e.length-1?it.meta={...it.meta,options:et}:it?.meta?.children&&it?.meta?.children?.length>0&&ke(it?.meta?.children,$e,et,rt+1))})};ve?.length>0&&ke(Ee,ve,ge)}return Ee}catch(oe){return dn(oe,b),Oe}finally{D(!1)}};return C.useEffect(()=>{if(x.current=null,_.current=!1,M===Je.SERVERLESS)H();else{async function re(){n&&(A([]),await z({}))}re()}},[n.id,B,Q,U]),C.useEffect(()=>{async function re(){if(r?._id&&r?.meta?.entity===B.toUpperCase()){r?.meta?.auth_status==="ACTIVE"&&(_.current=!1),M===Je.SERVERLESS?await z({schema:h}):await z({});const ue={maximum_attempts:1,backoff_coefficient:2,initial_interval:1e3,maximum_interval:1e5},Oe={...g?.activity_id&&{activity_id:g.activity_id},...U&&{integration_slug:U},...g?.activity_name&&{activity_name:g.activity_name},...M!==Je.CLOUD_TRIGGER?{maximum_timeout:6e4,retry_config:ue}:{}};m({...Oe,secret:r._id})}}re()},[r]),C.useEffect(()=>{const re=async()=>{const{secret:ue,resource:Oe,operation:ve}=e.properties;if(M===Je.SERVERLESS)vt(ue)||await z({schema:h});else if(e?.properties||!vt(ue)){if(M===Je.SERVERLESS&&!vt(ue))await z(h);else if(vt(Oe)||await z({resource:Oe}),!vt(ve)){const[oe,ae]=ve.split(".");await z({resource:oe,operation:ae})}}};vt(e.properties)||(m(e.properties),e.properties.secret&&(M===Je.CLOUD_TRIGGER||M===Je.CUSTOM_ACTIVITY)&&$(e.properties.secret),re())},[e]),C.useEffect(()=>{if(p&&h.length>0){const re=(ue,Oe="")=>{const ve={...g};ue.forEach(oe=>{const ae=oe.name,te=Oe?`${Oe}.${ae}`:ae;if(Zd.includes(ae)||Zd.some(ne=>te.includes(ne)))return;g[ae]||(oe.meta?.displayType==="array"?ve[ae]=["BOLTIC_AI"]:oe.meta?.displayType!=="object"&&(ve[ae]="BOLTIC_AI"));const Z=[];h.forEach(ne=>{ne.meta?.displayType!=="hidden"&&!Zd.includes(ne.name)&&!Zd.some(se=>ne.name.includes(se))&&Z.push({key:ne.name,...ne.meta?.displayType==="array"&&{name:ne.meta?.name||ne.name},description:ne.meta?.description||"",type:ne.meta?.displayType||"",value:ve[ne.name]||null,required:ne?.validation?.required||!1})}),ve.payload=Z,oe?.meta?.children&&oe?.meta?.children?.length>0&&re(oe.meta.children,te)}),m(ve)};re(h)}},[p,h]),{form:g,formSchema:h,loading:w,handleFocus:async re=>{let ue=h;const{fieldData:Oe}=re;if((Oe?.meta?.displayType==="select"||Oe?.meta?.displayType==="autocomplete"||Oe?.meta?.displayType==="multiselect")&&Oe?.meta?.config?.url){const{method:ve,labelKey:oe,valueKey:ae,urlType:te,body:Z,condition:ne}=Oe.meta.config;let{url:se}=Oe.meta.config;te==="secret"?se=Yt(N,"v1/integrations/entity",se):te==="options"&&(se=Yt(k,"v1.0",P,se));const pe={...Z,...Q&&{integration_id:Q},...U&&{integration_slug:U}},he=Object.assign({},{url:se,method:ve,labelKey:oe,valueKey:ae,body:pe});if(D(!0),ne){const de=Ox(ne);if(de){const xe=de.split(".")[1];(g[xe]||e?.properties?.[xe])&&(ue=await V(Oe.name,he,ue))}}else ue=await V(Oe.name,he,ue);D(!1),_.current&&(M===Je.CLOUD_TRIGGER||M===Je.CUSTOM_ACTIVITY)&&(ue=ue.map(de=>de.name==="secret"?{...de,meta:{...de.meta,htmlProps:{...de.meta.htmlProps,showReconnect:_.current}}}:de))}A(ue)},handleChange:async(re,ue)=>{if(M===Je.SERVERLESS){m(ue);return}const{field:Oe,value:ve,fieldData:oe={}}=re,ae={...ue,[Oe]:ve};if(Oe==="secret")m(ae),ve&&(M===Je.CLOUD_TRIGGER||M===Je.CUSTOM_ACTIVITY)&&$(ve);else if(Oe==="resource")m(ae),await z({resource:ve});else if(Oe==="operation"){const[te,Z]=ve.split(".");m(ae),await z({resource:te,operation:Z})}else if(oe?.meta?.loadDynamicParameters){const[te,Z]=g.operation.split(".");m({...ue,[Oe]:ve}),await z({resource:te,operation:Z,currentFormData:{...ue,[Oe]:ve}})}else m(ue)},handleCustom:(re,ue,Oe="")=>{if(Oe==="run_activity"){a?.(ue?.canvasNodeId);return}else if(Oe==="configure_activity"){l?.(ue?.canvasNodeId);return}if(m(ue),re.type==="add-new"){D(!0);let ve=B;const oe=h.find(Z=>Z.name==="secret"&&Z.meta.config);if(oe){const{url:Z}=oe.meta.config;ve=Z.split("?")[0].replace("/","")}const ae={current_page:1,page_size:1,entity:ve.toUpperCase(),state:n.activity_data.status},te=Yt(N,"/v1/catalog");Xt.get(te,{params:ae}).then(Z=>{if(s){s(Z.data.data[0],"create");return}const ne=`${L}/accounts/${P}/integrations/destination/new-destination/${Z.data.data[0]._id}/create?integration_id=${Q}&integration_slug=${U}`;window.open(ne)}).catch(Z=>{dn(Z,b)}).finally(()=>{D(!1)})}else if(re.type==="complete-step")D(!0),b({type:G5,payload:[re.data?.id]}),b({type:Tb,payload:"focused"}),D(!1);else if(re.type==="add-sample-data"){D(!0);const{data:ve}=re;ve.name==="global_variables"?b({type:Q5,payload:ve.data}):ve.name==="payload"?b({type:fd,payload:{id:ve?.id,data:ve.data,loading:!1}}):b({type:fd,payload:{id:ve.id,data:{result:ve.data,events:[]},loading:!1}}),D(!1)}else if(re.type==="reconnect"&&(M===Je.CLOUD_TRIGGER||M===Je.CUSTOM_ACTIVITY))Y();else if(re.type==="graphql-inspector"){const oe=!!ue?.properties&&typeof ue.properties=="object"&&!Array.isArray(ue.properties)?ue.properties:ue,ae=oe?.query,te=oe?.headers,Z=q(oe?.variables);T({headers:te||{},query:typeof ae=="string"?ae:ae?JSON.stringify(ae,null,2):"",variables:Z}),y(!0)}},setForm:m,handleCancel:()=>{o?.(),m({}),A([]),i(null)},setFormSchema:A,GraphQLInspectorModal:j}},Tx=e=>{if(!e||e.length===0)return!1;const t=e.some(r=>["secret","resource","operation"].includes(r.name)),n=e.some(r=>!["secret","resource","operation"].includes(r.name));return t&&n},Sx=(e,t)=>{const n=t?.secret&&!vt(t.secret),r=e.filter(u=>u.name==="operation"?n||!n&&t?.resource:["secret","resource"].includes(u.name)),i=e.filter(u=>!["secret","resource","operation"].includes(u.name)),o=[{name:"setup",meta:{className:"setup-section",displayType:"section",displayName:"Setup",htmlProps:{border:!1,divider:!1,headerVariant:"lgSemiBold"},children:r}}],s=i.length>0,a=t?.resource&&!vt(t.resource),l=t?.operation&&!vt(t.operation);return s&&a&&l&&(o.push({meta:{displayType:"divider",htmlProps:{my:"1rem"}}}),o.push({name:"configure",meta:{className:"configure-section",displayType:"section",displayName:"Configure",htmlProps:{border:!1,divider:!1,headerVariant:"lgSemiBold"},children:i}})),o},Vit=C.forwardRef((e,t)=>{const{formData:n,selectedNode:r,type:i,activity_id:o,initialState:s,isLoop:a=!1,cloudRef:l,suggestionsData:u,SET_INTEGRATION_DATA:c,INTEGRATION_DATA:f,openIntegrationDrawer:p,isLoading:h=!1,onSubmit:A,onClose:g}=e,{loopSuggestionsData:m={}}=gt.useSelector(M=>M.loopActivity),{viewOnly:O}=gt.useSelector(M=>M.canvas),{form:y,formSchema:v,loading:T,handleFocus:_,handleChange:x,handleCustom:b,setForm:w,handleCancel:D,setFormSchema:I,GraphQLInspectorModal:P}=vx({formData:n,selectedNode:r,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:c,onClose:g,openIntegrationDrawer:p,onSubmit:A});C.useImperativeHandle(t,()=>({getData:()=>y,validateForm:()=>!0,resetFormData:()=>{w({}),I([])}}),[y]);const k=(M,B="")=>{if(!a){const Q={type:i,name:r.data.name,activity_id:o,properties:{...s.properties,...M}};e.onSubmit?.(Q,B)}},L=Tx(v)?Sx(v,y):v;return d.jsxs(E.Box,{sx:{overflowY:"auto",height:"100%","& .MuiSwitch-root":{marginLeft:"7px"}},children:[d.jsx(Ex,{ref:l,name:`${r.data.name}-integration-form`,schema:L,form:y,onChange:x,onSubmit:k,isLoading:T||h,onFocus:_,onCustom:b,onCancel:D,useDefaultButtons:!1,suggestions:a?m:u,viewOnly:O}),d.jsx(P,{})]})}),Fte=wo(Vit),Git=({url:e})=>{const t=E.useTheme(),n=gt.useDispatch(),[r,i]=C.useState(!1);C.useEffect(()=>{r&&setTimeout(()=>{i(!1)},2e3)},[r]);const o=()=>{navigator.clipboard.writeText(e).then(()=>{i(!0),n({type:Yn,payload:{open:!0,title:"Copied to clipboard",type:"success"}})}).catch(()=>{n({type:Yn,payload:{open:!0,title:"Failed to copy",type:"error"}})})};return d.jsx(E.Grid,{item:!0,xs:12,children:d.jsxs(E.Stack,{direction:"row",alignItems:"center",spacing:2,sx:{border:s=>`1px solid ${s.palette.grey[200]}`,borderRadius:1,p:2,background:t.palette.neutral.soft.bg,position:"relative",userSelect:"none"},children:[d.jsx(E.Typography,{sx:{color:t.palette.primary.main,px:1,py:.5,borderRadius:"4px",border:"1px solid"},children:"POST"}),d.jsx(E.Tooltip,{title:e,arrow:!0,children:d.jsx(E.Typography,{sx:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",wordBreak:"break-all",maxWidth:"80%"},children:e})}),d.jsx(E.Tooltip,{title:"Copy to clipboard",placement:"top",arrow:!0,children:d.jsx(E.IconButton,{"data-testid":"button-copy-webhook-url",onClick:o,sx:{position:"absolute",right:"6px",top:"6px"},children:d.jsx(Ue,{src:"ic_copy",width:15,height:15,sx:{path:{fill:t.palette.common.black}}})})})]})})},Wit=C.forwardRef((e,t)=>{const n=gt.useDispatch(),r=E.useTheme(),{type:i,TESSERACT_MAIN_URL:o,ENTITY_ID:s,VORTEX_MAIN_URL:a,FRONTEND_URL:l,WORKFLOW_URLS:u,INTEGRATION_DATA:c,viewOnly:f=!1,openIntegrationDrawer:p}=e,[h,A]=C.useState([]),[g,m]=C.useState(!1),[O,y]=C.useState([]),[v,T]=C.useState([]),[_,x]=C.useState(!1),[b,w]=C.useState(!1),[D,I]=C.useState(!1),{control:P,watch:k,setValue:N,trigger:L}=Hn(),M=k("properties.slack_auth_id"),B=k("properties"),[Q,U]=C.useState(!1),[q,F]=C.useState(""),W=()=>{m(!0);const J={page_size:999,current_page:1,type:"BOTH"},ee=Yt(o,"/v1/integrations/entity/SLACK_V2");Xt.get(ee,{params:J}).then(({data:le})=>{const re=Yo(le.data,["integration_meta"]);A(re)}).catch(le=>{dn(le,n)}).finally(()=>{m(!1)})},G=Yt(a,`/v1.0/${s}`,"/implementations/choices"),R=async({slackAuthId:J,inputFieldId:ee,fieldsToFill:le,type:re,refresh:ue=!1})=>{const Oe=`${G}${ue?"?refresh=true":""}`;return Xt.post(Oe,{data:{secret:J,input_field_id:ee,selected_api:"slackAPI",fields_to_fill:le,operation:"get",...re&&{type:re}}})},j=async(J,ee=!1)=>{I(!ee),ee&&U(!0);const{event:le}=B;let re;["public_channel_message","public_channel_message_mention"].includes(le)?re="public_channel":["private_channel_message","private_channel_message_mention"].includes(le)&&(re="private_channel");try{const ue=await R({slackAuthId:J,inputFieldId:"channel",fieldsToFill:Cf,type:re,refresh:ee});y(ue.data)}catch(ue){y([]),dn(ue,n)}finally{I(!1),U(!1)}},$=async(J,ee=!1)=>{I(!ee),ee&&U(!0);try{const[le,re]=await Promise.all([R({slackAuthId:J,inputFieldId:"channel",fieldsToFill:Cf,type:"public_channel",refresh:ee}),R({slackAuthId:J,inputFieldId:"channel",fieldsToFill:Cf,type:"private_channel",refresh:ee})]);y([...le.data,...re.data])}catch(le){y([]),dn(le,n)}finally{I(!1),U(!1)}},Y=async(J,ee=!1)=>{x(!ee),ee&&w(!0);try{const le=await R({slackAuthId:J,inputFieldId:"user",fieldsToFill:H4,refresh:ee});T(le.data)}catch(le){dn(le,n)}finally{x(!1),w(!1)}},z=async J=>{const{slack_auth_id:ee,event:le}=B;if(!ee||!le)return;const re=["public_channel_message","private_channel_message"].includes(le),ue=["public_channel_message_mention","private_channel_message_mention"].includes(le);J==="channel"?re||ue?await j(ee,!0):le==="app_mention"&&await $(ee,!0):J==="user"&&ue&&await Y(ee,!0)};C.useEffect(()=>{(M===""||M===null||M===void 0)&&(N("properties.event",""),N("properties.channel",""),N("properties.username",""),N("properties.word",""),N("properties.listen_workspace",!1),N("properties.listen_for_bot_message",!1),y([]),T([]))},[M,N]),C.useEffect(()=>{B.event&&B.event!==null&&!vt(B)&&(N("properties.channel",""),N("properties.username",""),N("properties.word",""),N("properties.listen_workspace",!1),N("properties.listen_for_bot_message",!1),T([]),y([]))},[B.event,N]),C.useEffect(()=>{const{slack_auth_id:J,event:ee}=B;!vt(J)&&!vt(ee)&&(["public_channel_message","private_channel_message"].includes(ee)?j(J):ee==="app_mention"?$(J):["public_channel_message_mention","private_channel_message_mention"].includes(ee)&&(j(J),Y(J)))},[B.slack_auth_id,B.event]),C.useEffect(()=>{B.listen_workspace&&N("properties.channel","")},[B.listen_workspace,N]),C.useEffect(()=>{W()},[]),C.useEffect(()=>{try{const ee=window.location.pathname.split("/"),le=ee.findIndex(ue=>ue==="version");let re="";if(le>-1&&le<ee.length-1)re=ee[le+1];else{const ue=["draft","published","scheduled"],Oe=ee.findIndex(ve=>ue.includes(ve));re=Oe>-1?ee[Oe+1]:""}u?.VORTEX_WEBHOOK_URL&&s&&re&&F(Yt(u.VORTEX_WEBHOOK_URL,`/v1.0/${s}`,"workflows/execute/",re))}catch{}},[u,s]),C.useEffect(()=>{c?._id&&c?.meta?.entity==="SLACK_V2"&&(W(),N("properties.slack_auth_id",c._id,{shouldValidate:!0}))},[c]);const H=h.find(J=>J.id===B.slack_auth_id),V=H?.integration_meta?.type==="oauth2",X=H?.integration_meta?.bot_name;return d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(no,{children:d.jsx(E.Grid,{container:!0,gap:1.5,children:d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:"properties.slack_auth_id",control:P,meta:{options:jr(h),displayProps:{loading:g},displayName:"Slack Account",value:"",htmlProps:{showAddNew:!0},TESSERACT_MAIN_URL:o,FRONTEND_URL:l,ENTITY_ID:s,openIntegrationDrawer:p,addNewButtonText:"Add new account",searchFieldPlaceholder:"Search Slack Account",authType:"SLACK_V2",description:`Slack is a secure partner with Boltic. Your credentials are encrypted & can be removed at any time. <a href="${u.GYRATE_MAIN_URL}/integrations/Triggers/slack" target="_blank" rel="noopener noreferrer" style="color: ${r.palette.primary.main}">View setup guide</a>`,placeholder:"Select Slack Account"},validationRules:{required:"Slack account is required"},viewOnly:f,id:i,handleChange:()=>{}})})})}),B.slack_auth_id&&d.jsx(E.Divider,{}),B.slack_auth_id&&d.jsx(kr,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[!vt(B.slack_auth_id)&&h.length>0&&(!(h.find(le=>le.id===B.slack_auth_id)?.integration_meta?.type==="oauth2")&&q?d.jsxs(d.Fragment,{children:[d.jsx(E.Grid,{container:!0,gap:1,children:d.jsx(Git,{url:q})}),d.jsx(Fl,{message:'Copy the webhook URL above and paste it into the "Request URL" field on the Event Subscriptions page in your Slack app settings. This enables Slack to send events to your workflow.'})]}):null),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{name:"properties.event",control:P,meta:{options:due,displayName:"Operation",searchFieldPlaceholder:"Search operation",description:"This is what starts the Workflow",placeholder:"Select a operation"},validationRules:{required:"Operation is required"},required:!0,viewOnly:f,handleChange:()=>{}})}),B.event==="app_mention"&&!V&&X&&d.jsx(Fl,{variant:"info",message:`To trigger workflows, mention your bot using @${X} in any Slack channel where the bot is invited.`}),!vt(B.slack_auth_id)&&!vt(B.event)&&d.jsxs(E.Grid,{sx:{mt:1,...mi},children:[d.jsx(vr,{label:"Watch Whole Workspace",description:so("If enabled, triggers across the entire workspace; channel selection is not required."),sx:{fontSize:14,fontWeight:400,color:r.palette.text.primary}}),d.jsx(gn,{name:"properties.listen_workspace",control:P,render:({field:J})=>d.jsx(E.FormControlLabel,{label:J.value?"On":"Off",labelPlacement:"start",control:d.jsx(E.Switch,{...J,checked:!!J.value,disabled:f}),sx:{mr:0,ml:2},componentsProps:{typography:{variant:"smNormal"}}})})]}),!vt(B.slack_auth_id)&&!vt(B.event)&&d.jsxs(d.Fragment,{children:[!B?.listen_workspace&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!B?.listen_workspace,name:"properties.channel",control:P,meta:{options:jr(O),displayName:"Select Channel",displayProps:{loading:D,refreshing:Q},value:"",searchFieldPlaceholder:"Search",description:"Only channels your bot is a member of will appear in this list.",placeholder:"Select Channel"},validationRules:{...B?.listen_workspace?{}:{required:"Channel is required"}},viewOnly:f,id:"channel",refreshOptions:()=>z("channel"),refreshTooltip:"Refresh Channels"})}),["public_channel_message_mention","private_channel_message_mention"].includes(B.event)&&d.jsxs(d.Fragment,{children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{name:"properties.username",control:P,meta:{options:jr((v||[]).map(J=>{let ee="";return J.real_name&&J.name?ee=`${J.real_name} (${J.name})`:ee=J.real_name||J.name||"",{id:J.id,name:ee}})),displayProps:{loading:_,refreshing:b},displayName:"Select User",value:"",searchFieldPlaceholder:"Search User",placeholder:"Select User",description:"Triggers the workflow when this user is mentioned. Specify either a Username, a Highlight Word, or both. If both are set, the workflow triggers only when both appear in the message."},validationRules:{validate:J=>{const ee=k("properties.word");return!J&&(!ee||ee.trim()==="")?"Either User selection or Highlight Word is required":!0}},viewOnly:f,id:"user",virtualized:!0,refreshOptions:()=>z("user"),refreshTooltip:"Refresh Users",handleChange:()=>{L("properties.word")}})}),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Wn,{name:"properties.word",control:P,viewOnly:f,meta:{displayName:"Highlight Word",placeholder:"Enter text...",description:"Triggers the workflow when this word is mentioned (case-insensitive). Specify either a Highlight Word, a Username, or both. If both are set, the workflow triggers only when both appear in the message."},validationRules:{validate:J=>{const ee=k("properties.username"),le=J;return(!le||le.trim()==="")&&!ee?"Either Highlight Word or User selection is required":!0}},handleChange:()=>{L("properties.username")}})})]}),d.jsx(Fl,{message:`Invite ${V?"the Boltic app":"your bot"} to your Slack channel to receive events. In the channel, type: /invite @${V?"Boltic":X||"your-app-name"}`}),B?.event!=="app_mention"&&d.jsxs(d.Fragment,{children:[d.jsxs(E.Grid,{sx:{mt:1,...mi},children:[d.jsx(vr,{label:"Listen for Bot Messages",description:so("If no, only messages sent by users will trigger the Workflow. If yes, messages sent by users and slackbots will trigger the Workflow."),sx:{fontSize:14,fontWeight:400,color:r.palette.text.primary}}),d.jsx(gn,{name:"properties.listen_for_bot_message",control:P,render:({field:J})=>d.jsx(E.FormControlLabel,{label:J.value?"On":"Off",labelPlacement:"start",control:d.jsx(E.Switch,{...J,checked:!!J.value,disabled:f}),sx:{mr:0,ml:2},componentsProps:{typography:{variant:"smNormal"}}})})]}),B?.listen_for_bot_message&&d.jsx(Fl,{textColor:r.palette.text.tertiary,variant:"warning",message:"Avoid infinite loops! If your workflow posts messages to the same channel that triggers it, and 'Listen for Bot Messages' is enabled, it will create an endless loop. Consider disabling bot message listening or posting to a different channel."})]})]})]})})]})}),Bte=({field:e,items:t,type:n,nodeId:r,viewOnly:i=!1,eventType:o,handleArrayItemDelete:s,validationRules:a={},isLoop:l})=>{const u=E.useTheme(),{control:c,formState:{errors:f}}=Hn(),p=C.useMemo(()=>t?.map((h,A)=>`${r}-${e}-${Date.now()}-${A}`),[r,e,t?.length]);return d.jsx(d.Fragment,{children:t.map((h,A)=>d.jsxs(E.Grid,{container:!0,sx:{py:1},alignItems:"center",justifyContent:"space-between",children:[d.jsx(E.Grid,{item:!0,xs:11,children:d.jsx(gn,{name:`properties.${o}.${e}.${A}`,control:c,rules:a,render:({field:g})=>d.jsx(ao,{...g,id:r,fullWidth:!0,required:e==="emails",name:"email",viewOnly:i,label:"Email",isLoop:l,errorMsg:f.properties?.[o]?.[e]?.[A]?.message,showSuggestions:!0,helperText:_r(n,e),editorId:`${n}-${e}-${A}`,__withFieldValueControlApplied:!0})})}),d.jsx(E.Grid,{item:!0,xs:1,sx:{display:"flex",justifyContent:"center",alignSelf:"flex-end",paddingBottom:"2px"},children:e==="emails"&&t.length>1&&d.jsx(E.IconButton,{"data-testid":"delete-email-button",sx:{p:.75,width:28,height:28,"& path":{fill:u.palette.neutral.solid.bg},"&:hover path":{fill:u.palette.error[60]},"&:hover":{backgroundColor:"transparent"}},disabled:i,onClick:()=>s(e,A),children:d.jsx(Ue,{src:"ic_delete",width:20,height:20})})})]},p[A]))})},Qit=e=>{const{field:t,eventType:n,viewOnly:r=!1}=e,i=`properties.${n}.${t}`,{watch:o,setValue:s,unregister:a}=Hn(),{setFieldControlState:l}=oa(),u=o(i),[c,f]=C.useState("BOLTIC_AI"),p=C.useRef([]);C.useEffect(()=>{u==="BOLTIC_AI"||u==="BOLTIC_AI_IGNORE"?f(u):Array.isArray(u)&&f("specific")},[u]);const h=A=>{const g=A.target.value;if(f(g),l(i,g),g==="specific"){const m=Array.isArray(u)&&u.length>0?u:p.current.length>0?p.current:[""];s(i,m)}else Array.isArray(u)&&(p.current=u,u.forEach((m,O)=>{a?.(`${i}.${O}`)}),a?.(i)),s(i,g)};return d.jsxs(E.Stack,{spacing:1.5,children:[d.jsx(E.FormControl,{fullWidth:!0,disabled:r,children:d.jsxs(E.Select,{value:c,onChange:h,children:[d.jsx(E.MenuItem,{sx:{py:.8},value:"BOLTIC_AI",children:"Have AI generate a value for this field"}),d.jsx(E.MenuItem,{sx:{py:.8},value:"BOLTIC_AI_IGNORE",children:"Do not include a value for this field"}),d.jsx(E.MenuItem,{sx:{py:.8},value:"specific",children:"Set a specific value for this field"})]})}),c==="specific"&&d.jsx(Bte,{...e})]})},zit=e=>{const{MCP_INTEGRATION_FORM:t}=oa();return t?d.jsx(Qit,{...e}):d.jsx(Bte,{...e})},jte=C.forwardRef(({property:e,viewOnly:t=!1,value:n,onChange:r},i)=>{const o=E.useTheme(),s=a=>{switch(a){case"add_workflow_link":return"Include Boltic Link at the end of the message";case"pause_workflow":return"Pause the Workflow, once this activity has completed its execution";default:return""}};return d.jsx(E.Grid,{item:!0,xs:12,ref:i,children:d.jsx(E.FormControlLabel,{label:s(e),sx:{display:"block",mr:0,"& .MuiFormControlLabel-label":{fontSize:a=>a.typography.xsNormal.fontSize,color:a=>a.typography.allVariants.color}},control:d.jsx(E.Checkbox,{sx:{p:0,"& .MuiSvgIcon-root":{fontSize:16}},icon:d.jsx(Ue,{src:"ic_unchecked",width:16,height:16,sx:{path:{fill:o.palette.common.white}}}),checkedIcon:d.jsx(Ue,{src:"ic_checked",width:16,height:16}),disabled:t,checked:n,onChange:r})})})}),Xit=wo(({label:e,type:t,eventKey:n,required:r=!1,showExpandOption:i=!0,errorMsg:o="",suggestionsData:s,isLoop:a,viewOnly:l=!1,value:u,onChange:c})=>{const{loopSuggestionsData:f={}}=gt.useSelector(p=>p.loopActivity);return d.jsxs(E.Box,{children:[d.jsxs(E.Grid,{sx:{...mi},children:[d.jsx(vr,{required:r,label:e,description:so(_r(t,"body"))}),d.jsx(E.Typography,{variant:"xsBold",children:d.jsx(E.Link,{href:"https://api.slack.com/block-kit",target:"_blank",rel:"noopener noreferrer",underline:"none",color:p=>p.palette.primary.main,children:"How to use Slack Block Builder?"})})]}),d.jsx(Po,{size:"md",language:"json",showSuggestions:!0,viewOnly:l,value:u,handleChange:p=>c(p),id:`${t}-${n}-body`,suggestionsData:a?f:s,showExpandOption:i}),!!o&&d.jsx(E.FormHelperText,{error:!0,children:o})]})},""),Yit=C.forwardRef((e,t)=>{const n=gt.useDispatch(),r=E.useTheme(),{control:i,setValue:o,watch:s,clearErrors:a,formState:{errors:l}}=Hn(),u=s("properties");lA(s,o);const{VORTEX_MAIN_URL:c,ENTITY_ID:f,TESSERACT_MAIN_URL:p,FRONTEND_URL:h,WORKFLOW_URLS:A,type:g,id:m,isLoop:O=!1,INTEGRATION_DATA:y,viewOnly:v=!1,openIntegrationDrawer:T}=e,[_,x]=C.useState([]),[b,w]=C.useState(!1),[D,I]=C.useState(!1),[P,k]=C.useState(!1),[N,L]=C.useState([]),[M,B]=C.useState([]),[Q,U]=C.useState("Query Params"),[q,F]=C.useState(!1),[W,G]=C.useState(!1),[R,j]=C.useState(!1),$=R?Rb:Rb.filter(oe=>oe.value),Y=async()=>{w(!0);const oe={page_size:999,current_page:1,type:"BOTH"},ae=Yt(p,"/v1/integrations/entity/SLACK_V2");Xt.get(ae,{params:oe}).then(({data:te})=>{const Z=Yo(te.data,["integration_meta"]);x(Z)}).catch(te=>{dn(te,n)}).finally(()=>{w(!1)})},z=async(oe,ae,te=!1)=>{I(!0);let Z=Yt(c,`/v1.0/${f}`,"/implementations/choices");te&&(Z+="?refresh=true");try{const ne=await Xt.post(Z,{data:{secret:oe,input_field_id:"channel",selected_api:"slackAPI",fields_to_fill:Cf,operation:"get",type:ae===Xo.SEND_PUBLIC_CHANNEL_MESSAGE?"public_channel":"private_channel"}});L(jr(ne.data))}catch(ne){L([]),dn(ne,n)}finally{I(!1)}},H=async(oe,ae=!1)=>{I(!0);let te=Yt(c,`/v1.0/${f}`,"/implementations/choices");ae&&(te+="?refresh=true");try{const[Z,ne]=await Promise.all([Xt.post(te,{data:{secret:oe,input_field_id:"channel",selected_api:"slackAPI",fields_to_fill:Cf,operation:"get",type:"public_channel"}}),Xt.post(te,{data:{secret:oe,input_field_id:"channel",selected_api:"slackAPI",fields_to_fill:Cf,operation:"get",type:"private_channel"}})]),se=[...Z.data,...ne.data];L(jr(se))}catch(Z){dn(Z,n)}finally{I(!1)}},V=async(oe,ae=!1)=>{k(!0);let te=Yt(c,`/v1.0/${f}`,"/implementations/choices");ae&&(te+="?refresh=true");try{const Z=await Xt.post(te,{data:{secret:oe,input_field_id:"user",selected_api:"slackAPI",fields_to_fill:H4,operation:"get"}});B(Z.data.map(ne=>({title:ne.real_name?`${ne.real_name} (${ne.name})`:ne.name,value:ne.id})))}catch(Z){dn(Z,n)}finally{k(!1)}},X=(oe,ae)=>{const te=u[u.event][oe].filter((Z,ne)=>ne!==ae);o("properties",{...u,[u.event]:{...u[u.event],[oe]:te}})},J=(oe,ae)=>{o("properties",{...u,[u.event]:{...u[u.event],[oe]:[...u[u.event][oe],ae]}})},ee=oe=>{o(`properties.${u.event}.${oe}`,null)},le=oe=>Zue[oe],re=async(oe,ae,te="",Z=!1)=>{vt(oe)||vt(ae)||(te==="Channel"?F(!0):te==="Users"&&G(!0),!vt(oe)&&!vt(ae)&&[Xo.SEND_PUBLIC_CHANNEL_MESSAGE,Xo.SEND_PRIVATE_CHANNEL_MESSAGE].includes(ae)?await z(oe,ae,Z):ae===Xo.SEND_USER_MESSAGE?await V(oe,Z):ae===Xo.SET_CHANNEL_TOPIC?await H(oe,Z):ae===Xo.INVITE_USERS&&(te==="Channel"?await H(oe,Z):te==="Users"?await V(oe,Z):(!te||te==="")&&await Promise.all([V(oe,Z),H(oe,Z)])),te==="Channel"?F(!1):te==="Users"&&G(!1))},ue=oe=>{const{slack_auth_id:ae,event:te}=u;re(ae,te,oe,!0)};C.useEffect(()=>{vt(u)||(u.event===Xo.SEND_PRIVATE_CHANNEL_MESSAGE&&u?.send_private_channel_message?.attachment&&!u?.send_private_channel_message?.attachments&&(u.send_private_channel_message.attachments=[u.send_private_channel_message.attachment]),u.event===Xo.SEND_PRIVATE_CHANNEL_MESSAGE&&!u?.send_private_channel_message?.attachments&&(u.send_private_channel_message.attachments=[]),u.event===Xo.SEND_PUBLIC_CHANNEL_MESSAGE&&u?.send_public_channel_message?.attachment&&!u?.send_public_channel_message?.attachments&&(u.send_public_channel_message.attachments=[u.send_public_channel_message.attachment]),u.event===Xo.SEND_PUBLIC_CHANNEL_MESSAGE&&!u?.send_public_channel_message?.attachments&&(u.send_public_channel_message.attachments=[]),Y())},[]),C.useEffect(()=>{y?._id&&y?.meta?.entity==="SLACK_V2"&&(Y(),o("properties.slack_auth_id",y._id,{shouldValidate:!0}))},[y]),C.useEffect(()=>{if(_.length>0&&u?.slack_auth_id){const oe=_.find(ae=>ae.id===u.slack_auth_id);j(oe?.integration_meta?.type==="oauth2")}else j(!1)},[_,u?.slack_auth_id]),C.useEffect(()=>{const{slack_auth_id:oe,event:ae}=u;re(oe,ae)},[u.event,u.slack_auth_id]);const Oe=u[u.event]?.attachments==="BOLTIC_AI_IGNORE"||u[u.event]?.attachments==="BOLTIC_AI",ve=u[u.event]?.emails==="BOLTIC_AI_IGNORE"||u[u.event]?.emails==="BOLTIC_AI";return d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(no,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:"properties.slack_auth_id",control:i,meta:{options:jr(_),displayProps:{loading:b},displayName:"Slack Account",value:"",htmlProps:{showAddNew:!0},TESSERACT_MAIN_URL:p,FRONTEND_URL:h,ENTITY_ID:f,openIntegrationDrawer:T,addNewButtonText:"Add new account",searchFieldPlaceholder:"Search Slack account",authType:"SLACK_V2",description:`Slack is a secure partner with Boltic. Your credentials are encrypted & can be removed at any time. <a href="${A?.GYRATE_MAIN_URL}/integrations/Communication/slack" target="_blank" rel="noopener noreferrer" style="color: ${r.palette.primary.main}">View setup guide</a>`,placeholder:"Select Slack Account"},validationRules:{required:"Slack account is required"},handleChange:({field:oe,value:ae})=>{vt(ae)&&(L([]),B([])),vt(ae)?o("properties.event",""):o(oe,ae)},viewOnly:v,id:"slack_auth_id"})}),u.slack_auth_id&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:"properties.event",control:i,meta:{options:fue,displayProps:{loading:b},displayName:"Operation",description:"This is performed when the Workflow runs.",searchFieldPlaceholder:"Search operation",placeholder:"Select a operation"},validationRules:{required:"Operation is required"},handleChange:({value:oe})=>{o("properties",{...u,[oe]:le(oe),event:oe}),L([]),B([])},viewOnly:v})})]})}),u.slack_auth_id&&u.event&&d.jsx(E.Divider,{}),u.slack_auth_id&&u.event&&d.jsx(kr,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[!vt(u.slack_auth_id)&&d.jsxs(d.Fragment,{children:[u.event===Xo.CUSTOM&&d.jsx(d.Fragment,{children:d.jsx(Op,{id:m,type:g,isLoop:O,viewOnly:v,customSelectedTab:Q,setCustomSelectedTab:U})}),que.includes(u.event)&&d.jsx(Wn,{required:!0,id:m,name:`properties.${u.event}.channel_name`,control:i,meta:{displayName:"Channel Name",description:"Name for the channel to be created. Channel names are normalized by converting to lowercase, replacing any non-allowed characters with hyphens or underscore, and truncating to 80 characters.",placeholder:"Enter channel name"},validationRules:{required:"Chanel name is required"},viewOnly:v,editorId:`${g}-slack-channel_name`,showSuggestions:!0,isLoop:O},u.event),Xue.includes(u.event)&&d.jsx(tf,{required:!0,name:`properties.${u.event}.channel_id`,id:m,control:i,isLoading:D,type:g,label:"Channel",viewOnly:v,isLoop:O,virtualized:!0,helperTextForDropdown:R?"channel_id":"channel_id_for_bot",helperTextForTextField:"dynamic_channel_id",isMultiple:!1,data:N,value:u[u.event]?.channel_id,onTabChange:()=>{ee("channel_id")},eventName:u.event,fieldName:"channel_id",refreshData:ue,refreshing:q,willRefresh:!0,refreshTooltip:"Refresh Channels"},u.event),u.event===Xo.SEND_PRIVATE_CHANNEL_MESSAGE&&d.jsx(Fl,{message:`To send a message to a private channel, please invite ${R?"the Boltic app":"your bot"} to the channel.`}),[Xo.SET_CHANNEL_TOPIC].includes(u.event)&&d.jsx(Wn,{required:!0,id:m,name:`properties.${u.event}.topic`,control:i,meta:{displayName:"Topic",description:"Topic to be set for the Slack channel",placeholder:"Enter topic"},validationRules:{required:"Topic is required"},viewOnly:v,editorId:`${g}-slack-topic`,showSuggestions:!0,isLoop:O}),Kue.includes(u.event)&&d.jsx(tf,{name:`properties.${u.event}.user_id`,control:i,required:!0,isMultiple:!0,viewOnly:v,isLoading:P,id:m,type:g,isLoop:O,label:"Users",helperTextForTextField:"user_id",virtualized:!0,helperTextForDropdown:u.event===Xo.SEND_USER_MESSAGE?"user_ids_message":"user_ids_invite",data:M,value:u[u.event]?.user_id,onTabChange:()=>{ee("user_id")},eventName:u.event,fieldName:"user_id",refreshData:ue,refreshing:W,willRefresh:!0,refreshTooltip:"Refresh Users",handleChange:oe=>{const{field:ae,value:te}=oe;o(ae,te,{shouldValidate:!0})}}),Yue.includes(u.event)&&d.jsxs(d.Fragment,{children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:`properties.${u.event}.body_type`,control:i,validationRules:{required:"Message Body type is required"},meta:{options:aue,displayName:"Message Body Type",description:_r(g,"body_type"),searchFieldPlaceholder:"Search",placeholder:"Select Message Body Type"},viewOnly:v,id:g,handleChange:oe=>{const{value:ae}=oe;o(`properties.${u.event}`,{...u[u.event],body:ae===A0.BLOCKS?M4:"",blocks:ae===A0.BLOCKS?[]:u[u.event].blocks}),a(`properties.${u.event}.body`)}})}),d.jsxs(E.Grid,{item:!0,xs:12,children:[u[u.event]?.body_type==="text"&&d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Wn,{required:!0,id:m,multiline:!0,name:`properties.${u.event}.body`,control:i,meta:{displayName:"Message Body",description:"Specify text / Define Slack Blocks of the message to send",placeholder:"Type or add suggestion"},validationRules:{required:"Message Body is required"},viewOnly:v,editorId:`${g}-slack-body`,showSuggestions:!0,isLoop:O,size:"md"})}),d.jsx(E.Grid,{item:!0,xs:12,children:u.event!==Xo.SEND_USER_MESSAGE&&d.jsxs(E.Grid,{item:!0,xs:12,children:[d.jsxs(E.Stack,{width:"100%",direction:"row",alignItems:"center",justifyContent:"space-between",sx:{"& > .MuiStack-root > .MuiStack-root":{pb:0}},children:[d.jsx(vr,{label:"Attachments",description:"The total attachments size limit is 1GB. The maximum number of attachments is 5."}),!Oe&&d.jsx(E.IconButton,{disabled:u[u.event].attachments?.length>=5,onClick:()=>J("attachments",""),sx:{border:oe=>`1px solid ${oe.palette.grey.brainstem}`,width:24,height:24},color:"primary",children:d.jsx(Ue,{src:"ic_plus",width:16,height:16,sx:{path:{fill:r.palette.primary.main}}})})]}),d.jsx(VP,{nodeId:m,type:g,isLoop:O,field:`properties.${u.event}.attachments`})]},u.event)})]}),u[u.event]?.body_type===A0.BLOCKS&&d.jsxs(d.Fragment,{children:[d.jsx(E.Grid,{item:!0,xs:12,sx:{marginBottom:"0.5rem"},children:d.jsx(en,{required:!0,name:`properties.${u.event}.block_type`,control:i,meta:{options:Jue,displayName:"Slack Block Type",searchFieldPlaceholder:"Search Block Type",placeholder:"Select Block Type",description:_r(g,"block_type")},disabled:v,validationRules:{required:"Slack Block Type is required"},handleChange:oe=>{const{value:ae}=oe;o(`properties.${u.event}`,{...u[u.event],body:ae==="message"?M4:Wue,blocks:[]})},viewOnly:v,id:g})}),d.jsx(gn,{name:`properties.${u.event}.body`,control:i,render:({field:oe})=>d.jsx(Xit,{...oe,id:m,label:"Slack Blocks",viewOnly:v,type:g,isLoop:O,eventKey:u.event,required:!0,showExpandOption:!0,errorMsg:l.properties?.[u.event]?.body?.message})})]})]}),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:`properties.${u.event}.send_as_bot`,control:i,meta:{options:$,displayName:"Send as Bot",description:_r(g,"send_as_bot"),placeholder:"Select Send as Bot",showSearch:!1},viewOnly:v,id:g,handleChange:oe=>{const{value:ae}=oe;o(`properties.${u.event}`,{...u[u.event],send_as_bot:ae,bot_name:"",bot_icon:""})}})}),u?.[u.event]?.send_as_bot&&d.jsxs(d.Fragment,{children:[d.jsx(Wn,{id:m,name:`properties.${u.event}.bot_name`,control:i,meta:{displayName:"Bot Name",description:"Specify the bot name which appears as a bold username above the message inside Slack. Defaults to Boltic.",placeholder:"Enter bot name"},viewOnly:v,editorId:`${g}-slack-bot_name`,showSuggestions:!0,isLoop:O}),d.jsx(Wn,{id:m,name:`properties.${u.event}.bot_icon`,control:i,meta:{displayName:"Bot Icon",description:"Either an image url or an emoji available to your team (surrounded by :). For example, https://site.com/icon_256.png or :robot_face:",placeholder:"Enter bot icon"},viewOnly:v,editorId:`${g}-slack-bot_icon`,showSuggestions:!0,isLoop:O})]}),d.jsx(Wn,{id:m,name:`properties.${u.event}.thread_ts`,control:i,meta:{displayName:"Thread Id",description:"If you want this to be part of a thread, you'll need the timestamp (Ts) of the parent message. For example: 1345232312616.1231232",placeholder:"Enter thread id"},viewOnly:v,editorId:`${g}-slack-thread_ts`,showSuggestions:!0,isLoop:O}),u[u.event]?.thread_ts&&u[u.event]?.thread_ts!==""&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:`properties.${u.event}.send_with_thread`,control:i,meta:{options:Rb,displayName:"Send Channel Message?",description:_r(g,"send_with_thread"),placeholder:"Select Send Channel Message",showSearch:!1},viewOnly:v,id:g})}),d.jsx(gn,{name:`properties.${u.event}.add_workflow_link`,control:i,render:({field:oe})=>d.jsx(jte,{...oe,viewOnly:v,property:"add_workflow_link",onChange:ae=>{oe.onChange(ae.target.checked)}})}),u[u.event]?.body_type===A0.BLOCKS&&u?.[u.event].body!==""&&["message",void 0].includes(u?.[u.event]?.block_type)&&d.jsxs(d.Fragment,{children:[d.jsx(gn,{name:`properties.${u.event}.pause_workflow`,control:i,render:({field:oe})=>d.jsx(jte,{...oe,viewOnly:v,property:"pause_workflow",onChange:ae=>{oe.onChange(ae.target.checked)}})}),u[u.event]?.pause_workflow&&d.jsx(Fl,{message:'To enable interactive buttons in Slack, include buttons with action IDs "yes" and "no" in your block layout.'})]}),u?.[u.event]?.pause_workflow&&d.jsx(Fl,{message:'To enable interactive buttons in Slack, include buttons with action IDs "yes" and "no" in your block layout.'})]}),[Xo.FIND_BY_EMAIL].includes(u.event)&&d.jsxs(E.Grid,{item:!0,xs:12,children:[d.jsxs(E.Box,{sx:{display:"flex",alignItems:"center"},children:[d.jsx(E.FormControl,{fullWidth:!0,children:d.jsx(vr,{label:"Add Emails below"})}),!ve&&d.jsx(E.IconButton,{onClick:()=>J("emails",""),disabled:v,sx:{border:oe=>`1px solid ${oe.palette.grey.brainstem}`,width:24,height:24},color:"primary",children:d.jsx(Ue,{src:"ic_plus",width:16,height:16,sx:{path:{fill:r.palette.primary.main}}})})]}),d.jsx(zit,{eventType:u.event,handleArrayItemDelete:X,nodeId:m,type:g,viewOnly:v,field:"emails",items:u[u.event].emails,isLoop:O,validationRules:{required:"Email is required"}})]})]}),!O&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Fi,{viewOnly:v,type:g})})]})})]})}),qit=C.forwardRef((e,t)=>{const{viewOnly:n=!1}=e,{control:r,formState:{errors:i}}=Hn();return d.jsx(kr,{children:d.jsx(gn,{name:"properties.timeout",control:r,rules:{required:"Timeout is required",min:{value:1,message:"Timeout must be greater than or equal to 1"},max:{value:2160*60*60*1e3,message:"Timeout must be less than or equal to 90 days (7,776,000 seconds)"}},render:({field:o})=>d.jsx(ao,{...o,label:"Timeout(seconds)",viewOnly:n,fullWidth:!0,type:"number",id:"timeout",required:!0,errorMsg:i.properties?.timeout.message,value:o.value/1e3||"",onChange:s=>o.onChange(Number(s.target.value)*1e3),inputProps:{step:1,min:1,max:2160*60*60*1e3},helperText:"The time to wait before starting the next Activity Execution"})})})}),Kit=({field:e,items:t,type:n,nodeId:r,requiredValue:i,autoFocus:o,hideLabel:s,placeholder:a="",viewOnly:l=!1,name:u,handleArrayItemDelete:c})=>{const f=E.useTheme(),{control:p}=Hn();return d.jsx(d.Fragment,{children:t.map((h,A)=>d.jsxs(E.Grid,{container:!0,sx:{mb:1},alignItems:"flex-start",justifyContent:"space-between",children:[d.jsx(E.Grid,{item:!0,xs:2.4,children:d.jsx(en,{required:!0,name:`${u}.${A}.caseType`,control:p,meta:{options:Oue,displayName:s?"":"Type",searchFieldPlaceholder:"Search type",description:_r(n,"from_type"),placeholder:s?"":"Select Type"},validationRules:{required:"Type is required"},viewOnly:l,id:n})}),d.jsx(E.Grid,{item:!0,xs:8.2,children:d.jsx(Wn,{meta:{displayName:!s&&"Case",placeholder:`${a} ${A+1}`},name:`${u}.${A}.caseValue`,control:p,validationRules:{required:"Case value is required"},autoFocus:o,id:r,required:i,viewOnly:l,showSuggestions:!0,helperText:_r(n,e),editorId:`${n}-${e}-${A}`})}),d.jsx(E.Grid,{item:!0,xs:1,children:i&&t.length>1&&d.jsx(E.IconButton,{"data-testid":"delete-switch-button",sx:{width:28,height:28,position:"relative",top:24,"&:hover":{backgroundColor:"transparent","& path":{fill:f.palette.error[60]}}},onClick:()=>{c(e,A)},disabled:l,children:d.jsx(Ue,{src:"ic_delete",sx:{"& path":{fill:f.palette.neutral.solid.bg}},width:20,height:20})})})]},`switch-array-${A}`))})},Zit=C.forwardRef((e,t)=>{const{type:n,id:r,isLoop:i,viewOnly:o=!1}=e,{control:s,setValue:a,watch:l,formState:{errors:u}}=Hn(),c=l("properties"),f=l("properties.next_counter"),p=l("properties.cases"),h=m=>{const O=l(`properties.${m}`);a("properties.next_counter",f+1),a(`properties.${m}`,[...O,{caseKey:`case${f+1}Handle`,caseValue:"",caseType:"string"}])},A=(m,O)=>{const y=l(`properties.${m}`).filter((v,T)=>T!==O);a(`properties.${m}`,y)},g=m=>/^.*\{\{[^{}]+\}\}.*$/.test(m);return d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(no,{children:d.jsx(E.Grid,{container:!0,gap:1.5,children:d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(gn,{name:"properties.condition",control:s,rules:{required:"Condition is required",validate:m=>g(m)?!0:"Invalid condition. Dynamic placeholders {{ }} are required."},render:({field:m})=>d.jsx(ao,{...m,id:r,viewOnly:o,showSuggestions:!0,label:"Condition",name:"condition",editorId:`${n}-condition`,placeholder:"Enter a condition",fullWidth:!0,isLoop:i,required:!0,errorMsg:u.properties?.condition?.message,helperText:_r(n,"condition")})})})})}),c.condition&&g(c.condition)&&d.jsx(E.Divider,{}),c.condition&&g(c.condition)&&d.jsx(kr,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsxs(E.Grid,{item:!0,xs:12,pb:1,children:[d.jsx(vr,{label:"Cases"}),d.jsx(Kit,{placeholder:"Case",nodeId:r,viewOnly:o,type:n,field:"cases",requiredValue:!0,isLoop:i,items:p.filter(m=>m.caseValue!=="default"),name:"properties.cases",handleArrayItemDelete:A},p.length),d.jsxs(E.Button,{variant:"text",disabled:o,onClick:()=>h("cases"),sx:{color:m=>m.palette.primary[60],mt:1,"&:hover":{backgroundColor:"transparent",color:m=>m.palette.primary[50],"& .MuiTypography-root":{color:m=>m.palette.primary[50]},"& svg path":{fill:m=>m.palette.primary[50]}}},disableFocusRipple:!0,disableTouchRipple:!0,disableRipple:!0,disableElevation:!0,children:[d.jsx(Ue,{src:"ic_plus",sx:{fontSize:"18px",marginRight:"5px",path:{fill:"currentColor"}}}),d.jsx(E.Typography,{variant:"smNormal",sx:{alignItems:"center"},children:"Add"})]})]}),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Fi,{viewOnly:o,type:n})})]})})]})}),Jit=C.forwardRef((e,t)=>{const{type:n,VORTEX_MAIN_URL:r,ENTITY_ID:i,suggestionsData:o,isLoop:s=!1,viewOnly:a=!1}=e,{loopSuggestionsData:l={}}=gt.useSelector(f=>f.loopActivity),{control:u,formState:{errors:c}}=Hn();return d.jsx(kr,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(gn,{name:"properties.template",control:u,rules:{required:"Template is required"},render:({field:f})=>d.jsx(Po,{...f,label:"Template",suggestionLabel:"Template",id:`${n}-template`,size:"xl",viewOnly:a,activityType:n,VORTEX_MAIN_URL:r,ENTITY_ID:i,language:"html",helperText:d.jsxs(E.Box,{children:["Create dynamic web templates easily using Nunjucks, a powerful JavaScript templating engine.see",d.jsx(E.Link,{href:"https://mozilla.github.io/nunjucks/",target:"_blank",children:" Nunjucks Docs"})]}),error:!!c.properties?.template?.message,errorMsg:c.properties?.template?.message,handleChange:p=>f.onChange(p),required:!0,showSuggestions:!0,suggestionsData:s?l:o,showExpandOption:!0})})}),!s&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Fi,{viewOnly:a,type:n})})]})})}),eot=wo(Jit),tot=C.forwardRef((e,t)=>{const n=gt.useDispatch(),{id:r,type:i,TESSERACT_MAIN_URL:o,ENTITY_ID:s,FRONTEND_URL:a,INTEGRATION_DATA:l,viewOnly:u=!1,openIntegrationDrawer:c}=e,[f,p]=C.useState([]),[h,A]=C.useState(!1),{control:g,resetField:m,watch:O,setValue:y}=Hn(),v=O("properties.auth_type"),T=()=>{A(!0);const _={page_size:999,current_page:1,type:"SOURCE"},x=Yt(o,"/v1/integrations/entity/AUTHENTICATION");Xt.get(x,{params:_}).then(({data:b})=>{const w=Yo(b.data,["integration_meta"]),D=pT(w);p(hT(D))}).catch(b=>{dn(b,n)}).finally(()=>{A(!1)})};return C.useEffect(()=>{l?._id&&l?.meta?.entity==="AUTHENTICATION"&&(T(),y("properties.auth_id",l._id,{shouldValidate:!0}))},[l]),C.useEffect(()=>{!vt(v)&&v!==Pl.NONE?T():m("properties.auth_id")},[v]),d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(no,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:"properties.auth_type",control:g,meta:{options:qO,displayName:"Authentication Type",searchFieldPlaceholder:"Search authentication type",description:"Select Authentication Type (Basic Auth, Header Auth or None)",placeholder:"Select Authentication type"},validationRules:{required:"Auth type is required"},viewOnly:u,id:i})}),v&&v!==Pl.NONE&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:"properties.auth_id",control:g,meta:{options:jr(f),displayProps:{loading:h},displayName:"Authentication",value:"",htmlProps:{showAddNew:!0},TESSERACT_MAIN_URL:o,FRONTEND_URL:a,ENTITY_ID:s,openIntegrationDrawer:c,addNewButtonText:"Add new",searchFieldPlaceholder:"Search authentication",authType:"AUTHENTICATION",description:"Select Authentication you have saved in the Secrets. You can also create a new Secret using Add new button. Your credentials are encrypted & can be removed at any time.",placeholder:"Select Authentication"},validationRules:{required:"Authentication is required"},viewOnly:u,id:i,groupBy:"integration_meta.auth_type"})})]})}),d.jsx(E.Divider,{}),d.jsx(kr,{children:d.jsx(E.Grid,{container:!0,gap:1.5,children:d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Qu,{name:"properties.test_payload",label:"Test Trigger Payload",viewOnly:u,required:!0,id:r,validationRules:{required:"Value is required"},fullScreen:!0,showSuggestions:!0,excludePayloadSuggestions:!0})})})})]})}),YA=({fieldId:e,isOptional:t,type:n,control:r,viewOnly:i,isLoop:o,validationHandlers:s,id:a})=>{const l=Ds(e),u=_r(n,e),c=s?.[e];return d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Wn,{id:a,name:`properties.${e}`,control:r,meta:{displayName:l,description:u,placeholder:""},viewOnly:i,editorId:`${n}-${e}`,showSuggestions:!0,isLoop:o,validationRules:{...!c&&!t&&{required:`${Ds(e)} is required`},...c&&{validate:c}},required:!t})})},not=({isLoop:e,activityType:t,viewOnly:n,suggestionsData:r,id:i})=>{const{control:o,watch:s}=Hn(),a=s("properties"),{createNewThread:l}=a;return d.jsxs(E.Grid,{container:!0,gap:1,children:[d.jsxs(E.Grid,{item:!0,gap:0,children:[d.jsx(gn,{name:"properties.createNewThread",control:o,render:({field:{onChange:u,value:c,...f}})=>d.jsx(E.FormControlLabel,{label:"Continue Conversation",labelPlacement:"end",control:d.jsx(E.Switch,{...f,onChange:()=>u(!c),checked:!c,disabled:n}),componentsProps:{typography:{variant:"smNormal"}}})}),d.jsx(E.FormHelperText,{children:l?"A new conversation thread will be created. You can add a title if you like.":"Enter the Conversation ID to continue where you left off"})]}),d.jsx(YA,{fieldId:l?"title":"conversationId",type:t,control:o,viewOnly:n,isLoop:e,isOptional:l,id:i}),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Qu,{name:"properties.conversationContext",label:"Conversation Context",viewOnly:n,suggestionsData:r,description:"Add extra details to guide the AI agent in this conversation.",id:i,showSuggestions:!0,fullScreen:!0,data:a.conversationContext||{}})})]})},rot=({isLoop:e,activityType:t,viewOnly:n,validationHandlers:r,suggestionsData:i,id:o})=>{const{control:s,watch:a,clearErrors:l}=Hn(),u=E.useTheme(),c=["hostId","email","phone","userId","additionalFields"],f=a("properties"),{email:p,phone:h,createNewUser:A,hostId:g,userId:m,createNewThread:O,conversationId:y,createAnonymousUser:v}=f||{},T=!O&&y?.trim();return d.jsxs(E.Grid,{container:!0,gap:1,children:[d.jsxs(E.Grid,{container:!0,flexDirection:"column",children:[d.jsx(gn,{name:"properties.createAnonymousUser",control:s,render:({field:{onChange:_,value:x,...b}})=>d.jsx(E.FormControlLabel,{label:"Anonymous User",labelPlacement:"end",control:d.jsx(E.Switch,{...b,onChange:w=>{const{checked:D}=w.target;_(!!D),D&&l(c.map(I=>`properties.${I}`))},checked:x,disabled:n}),componentsProps:{typography:{variant:"smNormal"}}})}),v&&d.jsx(E.FormHelperText,{children:"An anonymous user will be created for this conversation."})]}),v?d.jsx(Fl,{message:"An anonymous user will be used for this conversation."}):d.jsxs(E.Box,{display:"flex",flexDirection:"column",gap:1,sx:{border:"1px solid",borderColor:u.palette.grey.brainstem,boxShadow:"none",width:"100%",p:"10px",borderRadius:2.5},children:[d.jsxs(E.Grid,{container:!0,flexDirection:"column",children:[d.jsx(gn,{name:"properties.createNewUser",control:s,render:({field:{onChange:_,value:x,...b}})=>d.jsx(E.FormControlLabel,{label:"Use Existing User",labelPlacement:"end",control:d.jsx(E.Switch,{...b,onChange:()=>_(!x),checked:!x,disabled:n}),componentsProps:{typography:{variant:"smNormal"}}})}),d.jsx(E.FormHelperText,{children:A?"Fill in details to continue with a new user.":"Enter the user's ID to continue with an existing account."})]}),T&&d.jsx(Fl,{message:"Note: You are using an existing conversation thread. If Host ID and User ID is ignored the previous conversation user will be used."}),d.jsx(YA,{fieldId:"hostId",type:t,control:s,viewOnly:n,isLoop:e,validationHandlers:r,isOptional:A?!1:!g&&m?.trim()||T,id:o}),A?d.jsxs(d.Fragment,{children:[d.jsx(YA,{fieldId:"name",type:t,control:s,viewOnly:n,isLoop:e,isOptional:!0,id:o}),d.jsx(YA,{fieldId:"email",type:t,control:s,viewOnly:n,isLoop:e,isOptional:!!h||!p&&h,validationHandlers:r,id:o}),d.jsx(YA,{fieldId:"phone",type:t,control:s,viewOnly:n,isLoop:e,isOptional:!!p,validationHandlers:r,id:o}),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Qu,{name:"properties.additionalFields",label:"Additional Fields",viewOnly:n,description:"Extra information about the user",id:o,showSuggestions:!0,fullScreen:!0,data:f.additionalFields||{},suggestionsData:i})})]}):d.jsxs(d.Fragment,{children:[d.jsx(YA,{fieldId:"userId",type:t,control:s,viewOnly:n,isLoop:e,isOptional:!m&&g?.trim()||T,validationHandlers:r,id:o}),d.jsx(Fl,{message:`${T?"":"You can provide either a Host ID or a User ID. "}If you enter both, the Host ID will be used first.`})]})]})]})},iot=Object.freeze(Object.defineProperty({__proto__:null,CopilotWebhook:CBe,apiActivity:T6e,askAgent:e=>{const t=gt.useDispatch(),n=E.useTheme(),{id:r,formData:i,ENTITY_ID:o,NEO_MAIN_URL:s,type:a,isLoop:l=!1,viewOnly:u=!1,TRINITY_MAIN_DOMAIN:c,TESSERACT_MAIN_URL:f,FRONTEND_URL:p,suggestionsData:h}=e,{control:A,setValue:g,watch:m,formState:{errors:O},clearErrors:y}=Hn(),v=m("properties"),[T,_]=C.useState([]),x=C.useMemo(()=>T.map(V=>({title:V.name,value:V.id,disabled:!V.active,icon:V.icon,active:V.active})),[T]),[b,w]=C.useState(!1),[D,I]=C.useState(""),P=O?.properties,k=async()=>{try{w(!0);const V=Yt(s,`/v1/org/${o}/copilotapps`),J=(await Xt.get(V,{params:{page:1,limit:99}})).data.items;return _(J),J}catch(V){return dn(V,t),[]}finally{w(!1)}};C.useEffect(()=>{k().then(V=>{if(!vt(i?.properties)&&i?.properties?.copilot_id&&!V?.find(J=>J?.id===i?.properties?.copilot_id))throw new Error("Copilot not found")}).catch(V=>{g("properties.copilot_id","",{}),g("properties.copilot_name","",{}),dn({message:V?.message||""},t)})},[]);const N=()=>{const{createNewUser:V,userId:X,hostId:J,conversationId:ee}=v||{};if(!(ee&&!V)&&!V&&!X?.trim()&&!J?.trim())return"User Id is required"},L=()=>{const{createNewUser:V,hostId:X,userId:J,conversationId:ee}=v||{};if(!(ee&&!V)&&(V||!J?.trim())&&!X?.trim())return"Host Id is required"},M=V=>{if(!V)return!1;if(B(V))return!0;const X=V.replace(/[^\d+]/g,"");return/^\+[1-9]\d{7,14}$/.test(X)},B=V=>/^\{\{.*?\}\}$/.test(V),Q=V=>B(V)?!0:pu(V),U=V=>{const{createNewUser:X,email:J,phone:ee}=v||{};if(!X)return;const le=(J||"").trim(),re=(ee||"").trim();if(!le&&!re)return`${Ds(V)} is required.`;if(V==="email"&&le&&!Q(le))return"Provide a valid email address.";if(V==="phone"&&re&&!M(re))return"Provide a valid phone number."},q=(V,X)=>()=>{const J=V(X);return J||y(`properties.${{email:"phone",phone:"email"}[X]}`),J},F=V=>(X,J)=>{I(J?V:"")},W=V=>{const X=`${c}/accounts/${o}/cp/${V}/overview`;window.open(X,"_blank")},G=()=>{const V=`${c}/accounts/${o}/dashboard?create_agent=true`;window.open(V,"_blank")},R={userId:N,email:q(U,"email"),phone:q(U,"phone"),hostId:L},$=(v.createNewUser?["hostId","email","phone"]:["userId","hostId"]).some(V=>P?.[V]),Y=v.createNewThread?[]:["conversationId"],z=Y.some(V=>P?.[V]),H=C.useMemo(()=>[{type:"conversation",Component:not,hasError:z,fields:Y},{type:"user",Component:rot,hasError:$}],[z,$,Y.length]);return d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(no,{children:d.jsx(E.Grid,{container:!0,gap:1.5,children:d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(en,{required:!0,name:"properties.copilot_id",control:A,meta:{options:x,displayProps:{loading:b,refreshing:b},displayName:"AI Agent",TESSERACT_MAIN_URL:f,FRONTEND_URL:p,ENTITY_ID:o,addNewButtonText:"Add new AI Agent",searchFieldPlaceholder:"Search AI Agents",authType:"",description:_r(a,"AI Agent"),htmlProps:{showAddNew:!0,onClickAddNew:G},showSearchOnLoad:!0,placeholder:"Select AI Agent"},validationRules:{required:"AI Agent is required"},viewOnly:u,id:"properties.copilot_id",handleChange:({value:V})=>{g("properties.copilot_id",V,{shouldValidate:!0}),g("properties.copilot_name",x.find(X=>X?.value===V)?.title)},renderValueUi:V=>{const X=x.find(J=>J?.value===V);return X?d.jsxs(E.Stack,{direction:"row",alignItems:"center",gap:1,children:[d.jsx(fh,{src:X.icon,alt:X.title,width:24,height:24}),d.jsx(E.Typography,{variant:"smMedium",children:X.title})]}):""},renderOption:V=>d.jsxs(E.MenuItem,{value:V.value,disabled:!V.active,"data-testid":`menu-item-${V.value}`,sx:{display:"flex",width:"100%",justifyContent:"flex-start",mx:1,height:"auto",p:"8px !important",minHeight:"fit-content !important","&.Mui-selected":{backgroundColor:"auto","& .MuiTypography-root":{color:n.palette.primary.main}},"&.Mui-disabled":{opacity:1,"& > :not(.redirect-action-button)":{opacity:.5,pointerEvents:"none"},"& .redirect-action-button, & .redirect-action-button *":{opacity:1,pointerEvents:"auto"}}},children:[d.jsx(fh,{src:V.icon,alt:V.title,width:24,height:24}),d.jsx(E.Typography,{variant:"smMedium",sx:{opacity:V.active?1:.8},children:V.title}),d.jsx(E.IconButton,{onClick:X=>{X.stopPropagation(),W(V.value)},size:"small","data-testid":"copilot-launch-btn",sx:{mr:1,ml:"auto",display:"inline-block"},className:"redirect-action-button",children:d.jsx(Ue,{src:"ic_open_in_new",width:n.icons.md,height:n.icons.md,sx:{path:{fill:n.palette.primary.main}}})})]},V.value),refreshOptions:k,refreshing:b,willRefresh:!0,refreshTooltip:"Refresh AI Agents"})})})}),v.copilot_id&&d.jsxs(d.Fragment,{children:[d.jsx(E.Divider,{}),d.jsx(kr,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Wn,{id:r,name:"properties.query",control:A,meta:{displayName:"Query",description:_r(a,"query"),placeholder:"Type the question or message you'd like to send to the AI agent."},viewOnly:u,editorId:`${a}-query`,showSuggestions:!0,isLoop:l,validationRules:{required:"Query cannot be empty"},multiline:!0,required:!0,size:"sm"})}),H.map(V=>{const{type:X,Component:J,hasError:ee}=V,le=X.toLowerCase();return d.jsx(E.Box,{sx:{border:"1px solid",borderColor:ee?n.palette.error.main:n.palette.grey.brainstem,boxShadow:ee?`0 0 4px ${n.palette.error.main}`:"none",width:"100%",p:"10px",borderRadius:2.5},children:d.jsxs(E.Accordion,{expanded:D===le||ee,onChange:F(le),children:[d.jsx(E.AccordionSummary,{sx:{"& .MuiAccordionSummary-content":{m:0},p:0},expandIcon:d.jsx(Hp.GridExpandMoreIcon,{}),children:d.jsx(E.Box,{sx:{display:"flex",alignItems:"center"},children:d.jsx(E.FormControl,{fullWidth:!0,children:d.jsx(E.Typography,{variant:"smMedium",children:Ds(X)})})})}),d.jsx(E.AccordionDetails,{sx:{mt:2},children:d.jsx(E.Grid,{container:!0,gap:1,children:d.jsx(J,{isLoop:l,activityType:e.type,viewOnly:u,validationHandlers:R,suggestionsData:h,id:r})})})]})},le)}),!l&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Fi,{viewOnly:u,type:a})})]})})]})]})},bolticStorageActivity:x6e,bolticTableActivity:lBe,boltic_storage:S6e,boltic_table:b6e,browserbase:cBe,calendly:dBe,converterActivity:vBe,emailActivity:DBe,executeChildWorkflow:PBe,fp_webhook:UBe,functionActivity:VBe,gmailActivity:QBe,gmail_trigger:GBe,googleCalendarActivity:JKe,googleMeet:eZe,googleSheetsReadActivity:tZe,googleSheetsWriteActivity:nZe,gpt:iZe,graphql:oZe,http:sZe,ifActivity:pZe,logConsole:mZe,loop:OZe,mapper:vZe,mcp:_Ze,monitor:IZe,parallel:DZe,response:PZe,schedule:$Ze,serverless:Fte,slackActivity:Yit,slack_trigger:Wit,sleep:qit,switchActivity:Zit,template:eot,webhook:tot},Symbol.toStringTag,{value:"Module"})),oot=C.forwardRef((e,t)=>{const{type:n,formData:r,selectedNode:i,onClose:o,isLoop:s=!1,cloudRef:a,suggestionsData:l,openIntegrationDrawer:u,INTEGRATION_DATA:c,SET_INTEGRATION_DATA:f,isLoading:p=!1,handleRunActivity:h,handleCompleteSetup:A,MCP_INTEGRATION_FORM:g=!1,onSubmit:m}=e,{viewOnly:O}=gt.useSelector(Q=>Q.canvas),{loopSuggestionsData:y={}}=gt.useSelector(Q=>Q.loopActivity),{form:v,formSchema:T,loading:_,handleFocus:x,handleChange:b,handleCustom:w,setForm:D,handleCancel:I,setFormSchema:P,GraphQLInspectorModal:k}=vx({formData:r,isLoop:s,selectedNode:i,INTEGRATION_DATA:c,SET_INTEGRATION_DATA:f,onClose:o,handleRunActivity:h,handleCompleteSetup:A,openIntegrationDrawer:u,onSubmit:m,MCP_INTEGRATION_FORM:g}),N=()=>{},L=(Q,U="")=>{if(!s){const q={type:n,name:i.data.name,properties:Q};e.onSubmit?.(q,U)}};C.useImperativeHandle(t,()=>({getData:()=>({name:i.data.properties.activity_name,properties:v,type:n}),validateForm:()=>!0,resetFormData:()=>{D({}),P([])}}),[v]);const B=Tx(T)?Sx(T,v):T;return d.jsxs(E.Box,{sx:{overflowY:"auto",height:"100%","& .MuiSwitch-root":{marginLeft:"7px"}},children:[d.jsx(Ex,{ref:a,name:`${i.id}-db-form`,schema:g?T:B,onSubmit:L,onChange:b,onFocus:x,onReset:N,onCancel:I,onCustom:w,form:v,isLoading:_||p,suggestions:s||g?y:l,useDefaultButtons:!1,viewOnly:O,MCP_INTEGRATION_FORM:g,MCP_EXCLUDED_FIELDS:Zd}),d.jsx(k,{})]})}),sot=wo(oot),aot=C.forwardRef(({type:e,formData:t,onSubmit:n,selectedNode:r,onClose:i,cloudRef:o,openIntegrationDrawer:s,INTEGRATION_DATA:a,SET_INTEGRATION_DATA:l,isLoading:u=!1,setPollingInterval:c},f)=>{const{viewOnly:p}=gt.useSelector(k=>k.canvas),{form:h,formSchema:A,loading:g,handleFocus:m,handleChange:O,handleCustom:y,setForm:v,handleCancel:T,setFormSchema:_,GraphQLInspectorModal:x}=vx({formData:t,selectedNode:r,INTEGRATION_DATA:a,SET_INTEGRATION_DATA:l,onClose:i,openIntegrationDrawer:s,onSubmit:n,setPollingInterval:c});C.useImperativeHandle(f,()=>({getData:()=>({name:r.data.properties.activity_name,properties:h,type:e}),validateForm:()=>!0,resetFormData:()=>{v({}),_([])}}),[h]);const b=(k,N="")=>{const L=k,M={type:e,name:r.data.name,properties:{...L}};n?.(M,N)},w=()=>{},I=Tx(A)?Sx(A,h):A,P=h;return d.jsxs(E.Box,{sx:{overflowY:"auto",height:"100%","& .MuiSwitch-root":{marginLeft:"7px"}},children:[d.jsx(Ex,{ref:o,name:`${r.data.name}-trigger-integration-form`,schema:I,onSubmit:b,onChange:O,onFocus:m,onReset:w,onCancel:T,onCustom:y,form:P,isLoading:g||u,useDefaultButtons:!1,viewOnly:p}),d.jsx(x,{})]})}),lot=C.forwardRef((e,t)=>{const{type:n,formData:r,selectedNode:i,isLoop:o=!1,cloudRef:s,suggestionsData:a,onClose:l,openIntegrationDrawer:u,INTEGRATION_DATA:c,SET_INTEGRATION_DATA:f,isLoading:p=!1,handleCompleteSetup:h,handleRunActivity:A,onSubmit:g,source:m,MCP_INTEGRATION_FORM:O=!1}=e,{viewOnly:y}=gt.useSelector(U=>U.canvas),{loopSuggestionsData:v={}}=gt.useSelector(U=>U.loopActivity),{form:T,formSchema:_,loading:x,handleFocus:b,handleChange:w,handleCustom:D,setForm:I,handleCancel:P,setFormSchema:k,GraphQLInspectorModal:N}=vx({formData:r,isLoop:o,selectedNode:i,INTEGRATION_DATA:c,SET_INTEGRATION_DATA:f,onClose:l,handleRunActivity:A,handleCompleteSetup:h,openIntegrationDrawer:u,onSubmit:g,source:m,MCP_INTEGRATION_FORM:O}),L=()=>{},M=(U,q="")=>{if(O&&I(U),!o){const F={type:n,name:i.data.name,properties:U};e.onSubmit?.(F,q)}};C.useImperativeHandle(t,()=>({getData:()=>({name:i.data.properties.activity_name,properties:T,type:n}),validateForm:()=>!0,resetFormData:()=>{I({}),k([])}}),[T]);const Q=Tx(_)?Sx(_,T):_;return d.jsxs(E.Box,{sx:{overflowY:"auto",height:"100%","& .MuiSwitch-root":{marginLeft:"7px"}},children:[d.jsx(Ex,{ref:s,name:`${i.id}-integration-form`,schema:O?_:Q,onSubmit:M,onChange:w,onFocus:b,onReset:L,onCancel:P,viewOnly:y,onCustom:D,form:T,isLoading:x||p,useDefaultButtons:!1,suggestions:o||O?v:a,MCP_INTEGRATION_FORM:O,MCP_EXCLUDED_FIELDS:Zd}),d.jsx(N,{})]})}),uot=wo(lot),$te=C.forwardRef((e,t)=>{const{type:n,selectedNode:r,formData:i,initialState:o,onSubmit:s,onClose:a,openIntegrationDrawer:l,ENTITY_ID:u,WORKFLOW_URLS:c,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,source:h,isExecutionLoading:A=!1,isLoop:g=!1,viewOnly:m,actionRef:O,activityDataRef:y,handleRunActivity:v,handleCompleteSetup:T,setPollingInterval:_,methods:x,activityName:b,MCP_INTEGRATION_FORM:w=!1}=e,{VORTEX_MAIN_URL:D,SERVERLESS_URL:I,TESSERACT_MAIN_URL:P,FRONTEND_URL:k,VORTEX_WEBHOOK_URL:N,VORTEX_SYNC_DOMAIN:L,HITMAN_PUBLIC_DOMAIN:M,HITMAN_PLTM_URL:B,ATHENA_MAIN_URL:Q,NEO_MAIN_URL:U,TRINITY_MAIN_DOMAIN:q}=c||{},F=W=>{let G=W;r.data.type===Je.LOOP&&(G=y.current?.getData());const R=$b(G);s({...r.data,type:r.data.type,name:b||r.data.name,properties:R,id:r.id})};switch(n){case"CloudTrigger":return d.jsx(aot,{id:r.id,ref:y,cloudRef:O,formData:i,onSubmit:s,initialState:o,isLoading:A,type:n,selectedNode:r,VORTEX_MAIN_URL:D,openIntegrationDrawer:l,ENTITY_ID:u,TESSERACT_MAIN_URL:P,onClose:a,FRONTEND_URL:k,SERVERLESS_URL:I,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,setPollingInterval:_});case"platformFdkActivity":case"applicationFdkActivity":case"customActivity":return d.jsx(uot,{id:r.id,ref:y,cloudRef:O,formData:i,handleRunActivity:v,initialState:o,handleCompleteSetup:T,isLoading:A,onSubmit:s,openIntegrationDrawer:l,type:n,FRONTEND_URL:k,selectedNode:r,ENTITY_ID:u,onClose:a,WORKFLOW_URLS:c,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,source:h,isLoop:g,MCP_INTEGRATION_FORM:w,...g?{useDefaultButtons:!1}:{}});case"CloudDatabase":return d.jsx(sot,{id:r.id,ref:y,cloudRef:O,formData:i,initialState:o,handleRunActivity:v,handleCompleteSetup:T,onSubmit:s,openIntegrationDrawer:l,type:n,FRONTEND_URL:k,isLoading:A,selectedNode:r,ENTITY_ID:u,onClose:a,WORKFLOW_URLS:c,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,isLoop:g,MCP_INTEGRATION_FORM:w,...g?{useDefaultButtons:!1}:{}});case"serverless":return d.jsx(Fte,{id:r.id,ref:y,handleRunActivity:v,handleCompleteSetup:T,cloudRef:O,formData:i,isLoading:A,onSubmit:s,type:n,openIntegrationDrawer:l,FRONTEND_URL:k,initialState:o,selectedNode:r,ENTITY_ID:u,onClose:a,WORKFLOW_URLS:c,activity_id:r.data.activity_id,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,isLoop:g,...g?{useDefaultButtons:!1}:{}});default:{const G={...iot}[n];return G?(w&&C.useImperativeHandle(O,()=>({getData:()=>({name:r.data.properties.activity_name,properties:i,type:n}),validateForm:()=>!0,handleSubmit:async()=>{const R=await x?.trigger();if(R){let j=x?.getValues();j=o1(j,Zd),F(j)}return R},isValidated:x?.formState?.isValid}),[i,n,r.data.properties.activity_name,x]),g?d.jsx(G,{ref:y,formData:i,id:r.id,onSubmit:s,onClose:a,type:n,openIntegrationDrawer:l,initialState:o,ENTITY_ID:u,VORTEX_MAIN_URL:D,SERVERLESS_URL:I,TESSERACT_MAIN_URL:P,FRONTEND_URL:k,VORTEX_WEBHOOK_URL:N,VORTEX_SYNC_DOMAIN:L,HITMAN_PUBLIC_DOMAIN:M,HITMAN_PLTM_URL:B,INTEGRATION_DATA:f,WORKFLOW_URLS:c,ATHENA_MAIN_URL:Q,SET_INTEGRATION_DATA:p,source:h,viewOnly:m,isLoop:g,MCP_INTEGRATION_FORM:w}):d.jsx("form",{autoComplete:"off",style:{height:"100%"},onSubmit:x.handleSubmit(F),children:d.jsx(G,{ref:y,formData:i,id:r.id,onSubmit:s,onClose:a,type:n,openIntegrationDrawer:l,initialState:o,ENTITY_ID:u,VORTEX_MAIN_URL:D,SERVERLESS_URL:I,TESSERACT_MAIN_URL:P,FRONTEND_URL:k,VORTEX_WEBHOOK_URL:N,VORTEX_SYNC_DOMAIN:L,HITMAN_PUBLIC_DOMAIN:M,HITMAN_PLTM_URL:B,INTEGRATION_DATA:f,WORKFLOW_URLS:c,ATHENA_MAIN_URL:Q,SET_INTEGRATION_DATA:p,source:h,viewOnly:m,isLoop:g,MCP_INTEGRATION_FORM:w,NEO_MAIN_URL:U,TRINITY_MAIN_DOMAIN:q})})):null}}}),Ute=({onSubmit:e,selectedNode:t,onClose:n,initialState:r,drawerWidth:i,setSelectedNode:o,openIntegrationDrawer:s,INTEGRATION_DATA:a,SET_INTEGRATION_DATA:l,openDocs:u,setOpenDocs:c,source:f,actionRef:p,MCP_INTEGRATION_FORM:h=!1})=>{const A=E.useTheme(),g=gt.useDispatch(),m=Rt.useNodes(),{setNodes:O,getNode:y,getEdges:v}=Rt.useReactFlow(),T=p||C.useRef(null),_=C.useRef(null),x=C.useMemo(()=>vo(),[]),{activities:b,triggers:w,reserved_keywords:D,activity_names:I}=gt.useSelector(Ye=>Ye.activities),{canvasWorkflow:P,activityExecutionData:k,viewOnly:N=!1,triggerNodeTest:L}=gt.useSelector(Ye=>Ye.canvas),M=ui(b?.data?.data,w?.data?.data,t.data,"slug"),{ENTITY_ID:B,WORKFLOW_URLS:Q,openAddonModal:U,currentSubscription:q}=Ci(),{workflow:F}=gt.useSelector(Ye=>Ye.workflows),W=f||F?.source||"",G=JO(t,W),R=H_({defaultValues:G,mode:"onChange"}),j=C.useRef(null),{analytics:$={}}=Ci(),[Y,z]=C.useState(!1),[H,V]=C.useState([]),[X,J]=C.useState(!1),ee=C.useRef(null),le=C.useRef(0),{data:re}=m.find(Ye=>Ye.id===t?.id)||{},{blt_node_states:ue}=re||{},{test:Oe="",setup_and_configure:ve="",node:oe=""}=ue||{},[ae,te]=C.useState(0),[Z,ne]=C.useState([{label:"Setup & Configure",state:"default"},{label:"Test",state:""}]),{initialNodes:se=[]}=gt.useSelector(Ye=>Ye.workflows),pe=C.useMemo(()=>{try{return!xf.includes(t?.data?.type)}catch{return!0}},[t?.data?.type]);C.useEffect(()=>{const Ye=[{label:"Setup & Configure",state:"default"}];ne(pe?[...Ye,{label:"Test",state:""}]:Ye),te(0)},[pe]),C.useEffect(()=>()=>{j.current&&clearTimeout(j.current)},[]);const he=Ye=>{ne(ht=>ht.map((Ot,wt)=>{const We=["setup_and_configure","test"][wt];return Ye[We]?{...Ot,state:qFe(Ye[We])}:Ot}))};C.useEffect(()=>{(ve||Oe||oe)&&he({setup_and_configure:ve||"default",test:Oe||"",node:oe||""})},[ve,Oe,oe]);const de=C.useRef(!1),xe=C.useRef(null);C.useEffect(()=>{if(t?.id)if(L?.nodeId===t.id){te(1);const Ye=`${L.nodeId}-${L.runWithPrevious}`;if(xe.current===Ye){g({type:_b});return}xe.current=Ye,je(L.runWithPrevious),g({type:_b}),de.current=!0}else xe.current=null,de.current?de.current=!1:te(oe==="completed"&&pe?1:0)},[t?.id,L?.nodeId,L?.runWithPrevious,oe,pe]);const{VORTEX_MAIN_URL:ge}=Q,[Ee,ke]=C.useState(!1),[Ge,$e]=C.useState(t?.data?.name||""),[et,rt]=C.useState(null),it=Sr(x),Re=Sr(Pn.VERSION),[Xe,qe]=C.useState(null),Se=async Ye=>await Lue(Ye.trim(),t.data.name,D,I)||null,_e=C.useRef(wa(Ye=>{g({type:Yn,payload:{open:!0,title:Ye,type:"error",width:"30rem",duration:3e3}})},300)).current,be=async Ye=>{$e(Ye);const ht=await Se(Ye.trim());if(ht){rt(ht),_e(ht);return}const Ot=t.data.name;let wt=ko(I);if(wt.includes(Ot)){const we=wt.findIndex(We=>We===Ot);wt=[...wt.slice(0,we),Ye.trim(),...wt.slice(we+1)]}else wt=[...wt,Ye.trim()];g({type:bi.SET_ACTIVITY_NAMES,payload:wt}),O(we=>{const Ze=JSON.stringify(we).replace(new RegExp(`{{${Ot}`,"g"),`{{${Ye.trim()}`).replace(new RegExp(`result.${Ot}`,"g"),`result.${Ye.trim()}`);return JSON.parse(Ze)}),rt(null),ce(Ye.trim())},K=()=>{["error","completed"].includes(Oe)||x===Br.DRAFT&&Ia(O,t,{}),n(),c?.(!1)},ce=Ye=>{const ht=_.current?.getData()||R.getValues();o(Ot=>Ot?{...Ot,data:{...Ot.data,name:Ye,properties:{...ht?.properties}}}:null),O(Ot=>Ot.map(wt=>wt.id===t.id?{...wt,data:{...wt.data,name:Ye}}:{...wt}))},Te=async(Ye,ht,Ot)=>{const wt=[...Array.isArray(m)?m:[]],we={nodes:ht?[Ac({...Ye})]:[Ac({...t,data:Ye})],result:X0(P,m,k,Ye?.id||t?.id,v())};z(!0);const We=Re||it;J(!0);const{success:Ze,isError:De,data:st}=await z0(ht?Ye:t,g,ge,B,wt,m,we,j,$,We,U,q,Ot,void 0,void 0,Ot?v():void 0);if(Ze&&!De)return Me(),z(!1),Ze;if(De&&(setTimeout(()=>{Me()},500),st)){delete st.singleRunFailure,Ia(O,t,{test:"error",node:"failed",setup_and_configure:"completed"});const yt=Object.keys(st);yt&&yt.length>0&&yt.forEach(zt=>{XO(st[zt]).forEach(Rn=>{g({type:Yn,payload:{open:!0,title:typeof Rn!="string"?JSON.stringify(Rn):Rn,type:"error",width:"30rem",duration:3e3}})})})}return z(!1),!1},je=async Ye=>{const ht=await Se(Ge.trim()),Ot=pd(t.data);if(ht&&Ot!==xt.TRIGGER){_e(ht);return}const wt=m.find(We=>We.id===t.id);let we=!0;we=await Te({...wt,outgoingPorts:[Je.IF,Je.SWITCH].includes(t.data.type)?t?.outgoingPorts||wt?.outgoingPorts||[]:[]},!0,Ye),we&&(Ia(O,t,{test:"completed",node:"completed"}),z(!1))},Fe=async(Ye,ht,Ot=!1)=>{Ye.preventDefault();const wt=await Se(Ge.trim()),we=pd(t.data);if(wt&&we!==xt.TRIGGER){_e(wt);return}if(we===xt.TRIGGER||vt(et)){const We=await R.trigger();let Ze;if(t?.data?.type===Je.LOOP&&_.current&&(Ze=await _.current?.validateForm()),We&&(t?.data?.type!==Je.LOOP||Ze!==!1)||Ot){const De=m?.find(yt=>yt.id===t.id)?.data?.properties;let st=R.watch();if(t.data.type===Je.LOOP&&_.current&&(st=_.current.getData()),Ad.includes(t.data.type)&&(st={...st,properties:{...typeof st.properties=="object"&&st.properties?st.properties:{},...typeof De=="object"&&De?De:{}}}),ht==="skip_test"){const yt=$b(st);e({...t.data,type:t.data.type,name:Ge||t.data.name,properties:{...yt,integration_slug:M},id:t.id},ht)}if(ht==="save"){l(null),te(0),ne(yt=>yt.map(zt=>({...zt,state:"default"}))),g({type:dd,payload:null}),n();return}pe&&(te(1),ne(yt=>yt.map(zt=>({...zt,state:zt.state===""?"default":zt.state}))))}}};C.useEffect(()=>{if(h)return;const Ye=m.find(ht=>ht.id===t?.id);(!Ye||Ye?.type===xt.PLACEHOLDER)&&o(null)},[m,o,t?.id,h]),C.useEffect(()=>{if(ke(!1),t?.id){const ht=m.find(we=>we.id===t?.id)||t;if(!ht?.data)return;const Ot=Mb(ht.data);if(ee.current===Ot)return;ee.current=Ot;const wt=JO(ht,W);R.reset(wt,{keepDefaultValues:!1,keepErrors:!1,keepDirty:!1,keepIsSubmitted:!1,keepTouched:!1,keepIsValid:!1,keepSubmitCount:!1}),$e(wt.name)}else ee.current=null},[t?.id,m,R,W]);const He=ui(b?.data?.data,w?.data?.data,t.data),dt=ui(b?.data?.data,w?.data?.data,t.data,"meta"),Tt=C.useMemo(()=>{const Ye=m.find(ht=>ht.id===t?.id);return Ye?{...Ye.data}:{...t.data}},[t?.id,m]);C.useEffect(()=>()=>{l(null)},[]),C.useEffect(()=>{h||t&&(y(t.id)||o(null))},[m,h]);const Ie=ui(b?.data?.data,w?.data?.data,t.data,"status"),at=!!ui(b?.data?.data,w?.data?.data,t.data,"pro"),ct=async(Ye,ht="")=>{const Ot=await Se(Ge.trim()),wt=pd(t.data);if(Ot&&wt!==xt.TRIGGER){_e(Ot);return}if(ht===""){e({...Ye,name:Ee?Ge:t.data.name,id:t.id},ht);return}if(wt===xt.TRIGGER||vt(et)){let we=!0;if(ht==="skip_test")try{const We=se?.find(Ze=>Ze?.id===t?.id);Mb(We?.data)!==Mb(Ye)&&g({type:fd,payload:{type:"replace",data:{...k,[t?.id]:{}}}})}catch{}ht==="test_and_save"&&(we=await Te(Ye,!1)),we&&e({...Ye,name:Ee?Ge:t.data.name,id:t.id},ht)}pe&&(te(1),ne(we=>we.map((We,Ze)=>Ze===0?{...We,state:"completed"}:{...We,state:["error","completed"].includes(Oe)?Oe:"default"})))},nt=Ye=>{g({type:du,payload:{id:Ye}})},Mt=async Ye=>{const ht=m?.find(Ot=>Ot?.id===Ye);await Te(ht,!0)},Ht=()=>{te(0),c?.(!1),n(),ne(Ye=>Ye.map((ht,Ot)=>Ot===0?{...ht,state:"default"}:{...ht,state:"default"}))},St=async(Ye,ht)=>{const Ot=Yt(ge,`/v1.0/${B}/`,`workflows/${Ye}/integrations/${ht}/executions`);return await Xt.get(Ot)},Me=async()=>{const Ye=++le.current;J(!0);const ht=Re||it;try{if(t?.data?.type!=="webhook"&&ht){const{data:Ot}=await St(ht,t.data.properties.integration_slug&&t.id?`${t.data.properties.integration_slug}_${t.id}`:t.id);le.current===Ye&&V(Ot.data)}}catch(Ot){le.current===Ye&&dn(Ot,g)}finally{le.current===Ye&&J(!1)}},Ke=C.useMemo(()=>d.jsx($te,{type:t.data.type,selectedNode:t,formData:Tt,initialState:r,onSubmit:ct,onClose:Ht,openIntegrationDrawer:s,ENTITY_ID:B,WORKFLOW_URLS:Q,INTEGRATION_DATA:a,SET_INTEGRATION_DATA:l,source:f,isExecutionLoading:Y,actionRef:T,activityDataRef:_,handleRunActivity:Mt,handleCompleteSetup:nt,setPollingInterval:qe,methods:R,activityName:Ge,viewOnly:N,MCP_INTEGRATION_FORM:h},t?.id),[t?.id,t.data.type,Tt,r,ct,Ht,s,B,Q,a,l,f,Y,T,_,Mt,nt,qe,R,Ge,N]),lt=C.useMemo(()=>d.jsx(YFe,{activityExecutionList:H,setActivityExecutionList:V,ENTITY_ID:B,VORTEX_MAIN_URL:ge,selectedNode:t,loading:X,fetchActivityExecutions:Me,viewOnly:N}),[H,V,B,ge,t,X,Me,N]);return d.jsx(b1e,{MCP_INTEGRATION_FORM:h,MCP_EXCLUDED_FIELDS:Zd,children:d.jsx(IF,{...R,children:d.jsxs(E.Stack,{position:h?"relative":"absolute",top:0,right:0,sx:{height:"100%",width:"100%",...h?{border:`1px solid ${A.palette.grey[300]}`,borderRadius:2}:{borderLeft:`1px solid ${A.palette.grey[300]}`,borderRight:u?`1px solid ${A.palette.grey[300]}`:0},zIndex:A.zIndex.drawer+2},children:[!h&&d.jsxs(E.Stack,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{position:"sticky",top:0,zIndex:1,py:1.5,px:2,height:48},children:[d.jsxs(E.Stack,{direction:"row",alignItems:"center",gap:1.5,children:[He?d.jsx("img",{src:He,alt:t.data.name,width:30,height:30,style:{border:`1px solid ${A.palette.grey[300]}`,borderRadius:"4px",padding:"2px",width:32,height:32}}):d.jsx(E.Avatar,{variant:"square",sx:{width:32,height:32,p:2},children:t.data.name.slice(0,2).toUpperCase()}),d.jsx(eX,{value:t?.data.name,onSave:be,minWidth:64,maxWidth:240,isEditing:Ee,setIsEditing:Ye=>{ke(Ye),Ye&&rt(null)},disabled:N||t.type===xt.TRIGGER,maxLength:50,error:et,variant:"mdSemiBold",textSx:{color:A.palette.text.primary,maxWidth:240,lineHeight:"32px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},inputSx:{height:"100%",fontSize:"1.5rem",".MuiInputBase-input":{py:"5px",px:1,fontSize:"16px",fontWeight:600},"& .MuiFormHelperText-root.Mui-error":{width:"max-content"},"& .MuiInputBase-root.MuiOutlinedInput-root":{minHeight:"auto"}},autoResize:!0,enableDoubleClick:!0,showEditIcon:!N&&t.type!==xt.TRIGGER}),t?.type===xt.TRIGGER&&dt?.trigger_type===VO.SCHEDULED&&(dt?.polling_interval||Xe)&&d.jsx(E.Tooltip,{arrow:!0,title:`The trigger checks for new data every ${dt?.polling_interval||Xe} minutes.`,children:d.jsxs(E.Box,{display:"flex",alignItems:"center",borderRadius:1,ml:1,px:.5,sx:{border:`1px solid ${A.palette.grey.outlined.border}`},children:[d.jsx(Ue,{src:"ic_schedule",sx:{cursor:"pointer",mr:.5,width:18}}),d.jsxs(E.Typography,{variant:"xsMedium",sx:{fontStyle:"normal",lineHeight:"24px"},children:[dt?.polling_interval||Xe," mins"]})]})})]}),d.jsxs(E.Stack,{alignItems:"center",gap:1.5,flexDirection:"row",children:[Ie===Qp.DRAFT&&d.jsx(E.Stack,{direction:"row",alignItems:"center",sx:{padding:"2px 8px",borderRadius:6,background:Ye=>Ye.palette.grey[200]},children:d.jsx(E.Typography,{variant:"xsNormal",sx:{textTransform:"capitalize"},children:Ie})}),at&&d.jsx(Jd,{}),d.jsxs(E.Button,{onClick:()=>c?.(!u),variant:"outlined",sx:{px:"8px !important",py:"2px !important",borderRadius:"6px","&.MuiButtonBase-root.MuiButton-root.MuiButton-outlined":{border:`1px solid ${u?A.palette.primary.main:A.palette.neutral.outlined.border}`,"& path":{fill:u?A.palette.primary.main:A.palette.neutral.solid.bg}},"&:hover":{"& .MuiTypography-root":{color:A.palette.primary.main},"& path":{fill:A.palette.primary.main},"&.MuiButtonBase-root.MuiButton-root.MuiButton-outlined":{border:`1px solid ${A.palette.primary.main}`,"& path":{fill:A.palette.primary.main}}}},children:[d.jsx(Ue,{src:"ic_document"}),d.jsx(E.Typography,{variant:"smSemiBold",sx:{pl:.5,color:u?A.palette.primary.main:A.palette.neutral.plain},children:"Docs"})]}),d.jsx(E.IconButton,{onClick:K,sx:Di(A),children:d.jsx(Ue,{width:24,height:24,src:"ic_close"})})]})]}),!h&&d.jsx(E.Stack,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{position:"sticky",top:48,zIndex:1,py:1,px:2,height:48,backgroundColor:A.palette.white.smoke},children:d.jsx(o0e,{steps:Z,activeStep:ae,setActiveStep:te})}),d.jsxs(E.Stack,{gap:"12px",sx:{overflowY:"auto",p:2,height:h?"calc(100% - 10px)":"calc(100% - 152px)","&::-webkit-scrollbar":{width:"8px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:A.palette.grey[300],borderRadius:"4px"},"&::-webkit-scrollbar-thumb:hover":{background:A.palette.grey[400]}},children:[(ae===0||h)&&Ke,ae===1&&!h&<]}),!h&&d.jsx(t0e,{isExecutionLoading:Y,selectedNodeType:t.data.type,onClose:Ht,validateAndSubmit:Fe,activityExecutionList:H,isViewOnly:N,drawerWidth:i,selectedNode:t,activeStep:ae,ref:T,setNodes:O,testActivity:je,MCP_INTEGRATION_FORM:h})]})})})},cot=C.memo(e=>{const t=E.useTheme(),n=Rt.useNodes(),r=Rt.useEdges(),{setNodes:i,setEdges:o}=Rt.useReactFlow(),{canvasWorkflow:s}=gt.useSelector(O=>O.canvas),a=s?.meta?.isHorizontal??!0,{fromX:l,fromY:u,toX:c,toY:f,fromNode:p,sourcePosition:h,targetPosition:A}=e;if([l,u,c,f].some(O=>typeof O!="number"||Number.isNaN(O)))return null;C.useEffect(()=>{const{id:O}=p,y=r.filter(v=>v.source===O&&v.type===Un.PLACEHOLDER);if(y.length>0){let v=null,T=1/0;if(y.forEach(_=>{const x=n.find(b=>b.id===_.target);if(x){const b=x.position.y+(x.height||51)/2,w=Math.abs(b-u);w<T&&(T=w,v=_)}}),v&&T<30){const _=v.target,x=r.filter(D=>D.id!==v.id);o(x);const b=n.find(D=>D.id===O),w=n.filter(D=>D.id!==_);if(b){b.outgoingPorts=(b.outgoingPorts||[]).filter(I=>I.id!==_);const D=w.filter(I=>I.id!==O);i([...D,b])}else i(w)}}},[]);const[m]=Rt.getBezierPath({sourceX:a?c:l,sourceY:a?f:u,sourcePosition:a?A:h,targetX:a?l:c,targetY:a?u:f,targetPosition:a?h:A});return d.jsx("path",{fill:"none",stroke:t.palette.primary.main,strokeWidth:1.5,className:"animated",d:m})}),Hte=e=>String(e??"").trim(),dot=e=>String(e??"").split(",").map(t=>Hte(t)).filter(Boolean),_E=(e,t)=>{const n=Hte(e),r=dot(t);return!n||r.length===0?!1:r.includes(n)},xx=({edgeCenterX:e,edgeCenterY:t,onClick:n,isSelected:r=!1})=>{const i=E.useTheme();return d.jsxs("g",{className:`react-flow__edge-delete-button ${r?"selected":""}`,onClick:n,children:[d.jsx("foreignObject",{x:e-12,y:t-12,width:24,height:24,className:"react-flow__edge-delete-square",children:d.jsx("div",{className:"react-flow__edge-delete-square-inner"})}),d.jsx("g",{transform:`translate(${e-8}, ${t-8})`,className:"react-flow__edge-delete-icon",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",children:d.jsx("path",{fill:i.palette.error.main,d:"M11.667 2.5C11.903 2.50007 12.1011 2.57961 12.2607 2.73926C12.4204 2.89891 12.4999 3.09704 12.5 3.33301H15.833C16.0691 3.33301 16.267 3.41352 16.4268 3.57324C16.5865 3.73296 16.667 3.93088 16.667 4.16699C16.6669 4.40296 16.5864 4.60109 16.4268 4.76074C16.2671 4.92025 16.069 5 15.833 5V15.833C15.833 16.2913 15.6701 16.6844 15.3438 17.0107C15.0175 17.3369 14.6251 17.4999 14.167 17.5H5.83301C5.37489 17.4999 4.98253 17.3369 4.65625 17.0107C4.32986 16.6844 4.16699 16.2913 4.16699 15.833V5C3.93104 5 3.73291 4.92025 3.57324 4.76074C3.41359 4.60109 3.33308 4.40296 3.33301 4.16699C3.33301 3.93088 3.41352 3.73296 3.57324 3.57324C3.73296 3.41352 3.93088 3.33301 4.16699 3.33301H7.5C7.50007 3.09704 7.57961 2.89891 7.73926 2.73926C7.89891 2.57961 8.09704 2.50007 8.33301 2.5H11.667ZM5.83301 15.833H14.167V5H5.83301V15.833ZM8.33301 6.66699C8.56904 6.66699 8.76706 6.74664 8.92676 6.90625C9.08648 7.06597 9.16699 7.26389 9.16699 7.5V13.333C9.16699 13.5691 9.08648 13.767 8.92676 13.9268C8.76704 14.0865 8.56912 14.167 8.33301 14.167C8.09704 14.1669 7.89891 14.0864 7.73926 13.9268C7.57975 13.7671 7.5 13.569 7.5 13.333V7.5C7.5 7.26397 7.57964 7.06594 7.73926 6.90625C7.89891 6.7466 8.09704 6.66707 8.33301 6.66699ZM11.667 6.66699C11.903 6.66707 12.1011 6.7466 12.2607 6.90625C12.4204 7.06594 12.5 7.26397 12.5 7.5V13.333C12.5 13.569 12.4202 13.7671 12.2607 13.9268C12.1011 14.0864 11.903 14.1669 11.667 14.167C11.4309 14.167 11.233 14.0865 11.0732 13.9268C10.9135 13.767 10.833 13.5691 10.833 13.333V7.5C10.833 7.26389 10.9135 7.06597 11.0732 6.90625C11.2329 6.74664 11.431 6.66699 11.667 6.66699Z"})})})]})},bx=({edgeCenterX:e,edgeCenterY:t,onClick:n,isSelected:r=!1})=>{const i=E.useTheme();return d.jsxs("g",{className:`react-flow__edge-add-button ${r?"selected":""}`,onClick:n,children:[d.jsx("foreignObject",{x:e-12,y:t-12,width:24,height:24,className:"react-flow__edge-add-square",children:d.jsx("div",{className:"react-flow__edge-add-square-inner"})}),d.jsx("g",{transform:`translate(${e-12}, ${t-12})`,className:"react-flow__edge-add-icon",children:d.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("rect",{x:"0.5",y:"0.5",width:"23",height:"23",rx:"4",ry:"4",fill:"white"}),d.jsx("rect",{className:"add-button-border",x:"0.5",y:"0.5",width:"23",height:"23",rx:"4",ry:"4",stroke:i.palette.neutral?.outlined?.border,fill:"none"}),d.jsx("path",{className:"add-button-icon",fillRule:"evenodd",clipRule:"evenodd",d:"M11.333 14.6663V12.6663H9.33301C9.14412 12.6663 8.98579 12.6025 8.85801 12.4747C8.73023 12.3469 8.66634 12.1886 8.66634 11.9997C8.66634 11.8108 8.73023 11.6525 8.85801 11.5247C8.98579 11.3969 9.14412 11.333 9.33301 11.333H11.333V9.33301C11.333 9.14412 11.3969 8.98579 11.5247 8.85801C11.6525 8.73023 11.8108 8.66634 11.9997 8.66634C12.1886 8.66634 12.3469 8.73023 12.4747 8.85801C12.6025 8.98579 12.6663 9.14412 12.6663 9.33301V11.333H14.6663C14.8552 11.333 15.0136 11.3969 15.1413 11.5247C15.2691 11.6525 15.333 11.8108 15.333 11.9997C15.333 12.1886 15.2691 12.3469 15.1413 12.4747C15.0136 12.6025 14.8552 12.6663 14.6663 12.6663H12.6663V14.6663C12.6663 14.8552 12.6025 15.0136 12.4747 15.1413C12.3469 15.2691 12.1886 15.333 11.9997 15.333C11.8108 15.333 11.6525 15.2691 11.5247 15.1413C11.3969 15.0136 11.333 14.8552 11.333 14.6663ZM9.39967 18.1413C10.2108 18.4913 11.0775 18.6663 11.9997 18.6663C12.9219 18.6663 13.7886 18.4913 14.5997 18.1413C15.4108 17.7913 16.1163 17.3163 16.7163 16.7163C17.3163 16.1163 17.7913 15.4108 18.1413 14.5997C18.4913 13.7886 18.6663 12.9219 18.6663 11.9997C18.6663 11.0775 18.4913 10.2108 18.1413 9.39967C17.7913 8.58856 17.3163 7.88301 16.7163 7.28301C16.1163 6.68301 15.4108 6.20801 14.5997 5.85801C13.7886 5.50801 12.9219 5.33301 11.9997 5.33301C11.0775 5.33301 10.2108 5.50801 9.39967 5.85801C8.58856 6.20801 7.88301 6.68301 7.28301 7.28301C6.68301 7.88301 6.20801 8.58856 5.85801 9.39967C5.50801 10.2108 5.33301 11.0775 5.33301 11.9997C5.33301 12.9219 5.50801 13.7886 5.85801 14.5997C6.20801 15.4108 6.68301 16.1163 7.28301 16.7163C7.88301 17.3163 8.58856 17.7913 9.39967 18.1413ZM15.783 15.783C14.7497 16.8163 13.4886 17.333 11.9997 17.333C10.5108 17.333 9.24967 16.8163 8.21634 15.783C7.18301 14.7497 6.66634 13.4886 6.66634 11.9997C6.66634 10.5108 7.18301 9.24967 8.21634 8.21634C9.24967 7.18301 10.5108 6.66634 11.9997 6.66634C13.4886 6.66634 14.7497 7.18301 15.783 8.21634C16.8163 9.24967 17.333 10.5108 17.333 11.9997C17.333 13.4886 16.8163 14.7497 15.783 15.783Z",fill:i.palette.neutral?.solid?.bg})]})})]})},fot=e=>{const t=E.useTheme(),{canvasWorkflow:n}=gt.useSelector(z=>z.canvas),{ENTITY_ID:r,allowedAccount:i}=Ci(),o=_E(r,i),s=n?.meta?.isHorizontal??!0,{id:a,sourceX:l,sourceY:u,targetX:c,targetY:f,sourcePosition:p,targetPosition:h,style:A={stroke:t.palette.neutral.main},markerEnd:g,source:m,target:O,sourceHandle:y,targetHandle:v}=e;if([l,u,c,f].some(z=>typeof z!="number"||Number.isNaN(z))||!p||!h)return null;const T=Rt.useEdges(),_=Rt.useNodes(),{deleteElements:x}=Rt.useReactFlow(),b=gt.useDispatch(),{viewOnly:w}=gt.useSelector(z=>z.canvas),D=T.find(z=>z.id===a),I=D?.data?.isStraight===!0,P=()=>Rt.getBezierPath({sourceX:l,sourceY:u,sourcePosition:p,targetX:c,targetY:f,targetPosition:h,curvature:.25});let k,N,L;I&&s?Math.abs(u-f)<2?(k=`M ${l},${u} L ${c},${u}`,N=(l+c)/2,L=u):(k=`M ${l},${u} L ${c},${u} L ${c},${f}`,N=(l+c)/2,L=(u+f)/2):[k,N,L]=P();const M=c-l,B=f-u,Q=Math.sqrt(M*M+B*B),U=M/Q,q=B/Q,F=20,W=z=>{z.stopPropagation(),a&&x({nodes:[{id:D.target}],edges:[{id:a}]})},G=z=>{if(z.stopPropagation(),!w){b({type:Yp,payload:{x:z.clientX,y:z.clientY}}),b({type:S0,payload:!1});const H=`placeholder_${Math.trunc(Math.random()*1e9)}`;if(b({type:v0,payload:{id:H,edgeId:a,sourceNodeId:m,targetNodeId:O,sourceHandle:y,targetHandle:v}}),!o){b({type:ss,payload:{type:"activities",active:!0,nodeId:H,edgeId:a,sourceNodeId:m,targetNodeId:O,sourceHandle:y,targetHandle:v}}),b({type:Zs,payload:!0});return}b({type:Zs,payload:!1}),b({type:ss,payload:{type:"",active:!1,nodeId:null,edgeId:null}}),b({type:Rs,payload:"prompt"}),b({type:T0,payload:!0})}},R=_.find(z=>z.id===O),j=T.some(z=>z.source===O&&z.id!==a),$=R?.data?.outgoingPorts,Y=j||Array.isArray($)&&$.length>0;return d.jsxs(d.Fragment,{children:[d.jsx("path",{onClick:W,id:`${a}-interaction`,className:w?"react-flow__edge-interaction viewModeCursor":"react-flow__edge-interaction",d:k,style:{stroke:"transparent",strokeWidth:12,fill:"none",pointerEvents:"stroke"}}),d.jsx("path",{onClick:W,id:a,style:{...A},className:w?"react-flow__edge-path viewModeCursor":"react-flow__edge-path",d:k,markerEnd:g}),!w&&d.jsx(d.Fragment,{children:s?d.jsxs(d.Fragment,{children:[Y&&d.jsx(bx,{edgeCenterX:N-F*U,edgeCenterY:L-F*q,onClick:G}),d.jsx(xx,{edgeCenterX:Y?N+F*U:N,edgeCenterY:Y?L+F*q:L,onClick:W})]}):d.jsxs(d.Fragment,{children:[Y&&d.jsx(bx,{edgeCenterX:N-F*U,edgeCenterY:L-F*q,onClick:G}),d.jsx(xx,{edgeCenterX:Y?N+F*U:N,edgeCenterY:Y?L+F*q:L,onClick:W})]})})]})},pot=e=>{const t=E.useTheme(),{id:n,sourceX:r,sourceY:i,targetX:o,targetY:s,sourcePosition:a,targetPosition:l,style:u={stroke:t.palette.neutral.main},markerEnd:c,source:f,target:p,sourceHandle:h,targetHandle:A}=e,{deleteElements:g}=Rt.useReactFlow(),m=gt.useDispatch(),{ENTITY_ID:O,allowedAccount:y}=Ci(),v=_E(O,y),T=Rt.useNodes(),_=Rt.useEdges(),{viewOnly:x,canvasWorkflow:b,activitiesPopover:w}=gt.useSelector(Y=>Y.canvas),D=b?.meta?.isHorizontal??!0,I=w?.edgeId===n&&w?.active;if([r,i,o,s].some(Y=>typeof Y!="number"||Number.isNaN(Y))||!a||!l)return null;const[P,k,N]=Rt.getBezierPath({sourceX:r,sourceY:i,sourcePosition:a,targetX:o,targetY:s,targetPosition:l,curvature:.25}),L=o-r,M=s-i,B=Math.sqrt(L*L+M*M),Q=L/B,U=M/B,q=20,F=Y=>{Y.stopPropagation(),n&&!x&&g({edges:[{id:n}]})},W=Y=>{if(Y.stopPropagation(),!x){const z=Y.currentTarget?.getBoundingClientRect?.(),H=z&&Number.isFinite(z.left)&&Number.isFinite(z.top)?{x:z.left+z.width/2,y:z.top+z.height/2}:{x:Y.clientX,y:Y.clientY};m({type:Yp,payload:H}),m({type:S0,payload:!1});const V=`ai_prompt_${Math.trunc(Math.random()*1e9)}`,X={id:n,source:f,target:p,sourceHandle:h,targetHandle:A,type:Un.SMOOTH,markerEnd:c,style:u};if(m({type:v0,payload:{id:V,edgeId:n,sourceNodeId:f,targetNodeId:p,sourceHandle:h,targetHandle:A,originalEdge:X}}),!v){m({type:ss,payload:{type:"activities",active:!0,nodeId:V,edgeId:n,sourceNodeId:f,targetNodeId:p,sourceHandle:h,targetHandle:A}}),m({type:Zs,payload:!0});return}m({type:Zs,payload:!1}),m({type:ss,payload:{type:"",active:!1,nodeId:null,edgeId:null}}),m({type:Rs,payload:"prompt"}),m({type:T0,payload:!0})}},G=T.find(Y=>Y.id===p),R=_.some(Y=>Y.source===p&&Y.id!==n),j=G?.data?.outgoingPorts,$=R||Array.isArray(j)&&j.length>0;return d.jsxs(d.Fragment,{children:[d.jsx("path",{onClick:F,id:`${n}-interaction`,className:x?"react-flow__edge-interaction viewModeCursor":"react-flow__edge-interaction",d:P,style:{stroke:"transparent",strokeWidth:12,fill:"none",pointerEvents:"stroke"}}),d.jsx("path",{onClick:F,id:n,style:{...u},className:x?"react-flow__edge-path viewModeCursor":"react-flow__edge-path",d:P,markerEnd:c}),!x&&d.jsx(d.Fragment,{children:D?d.jsxs(d.Fragment,{children:[$&&d.jsx(bx,{edgeCenterX:k-q*Q,edgeCenterY:N-q*U,onClick:W,isSelected:I}),d.jsx(xx,{edgeCenterX:$?k+q*Q:k,edgeCenterY:$?N+q*U:N,onClick:F,isSelected:I})]}):d.jsxs(d.Fragment,{children:[$&&d.jsx(bx,{edgeCenterX:k-q*Q,edgeCenterY:N-q*U,onClick:W,isSelected:I}),d.jsx(xx,{edgeCenterX:$?k+q*Q:k,edgeCenterY:$?N+q*U:N,onClick:F,isSelected:I})]})})]})},wE=e=>e.canvas,Vte=e=>e.activities,Gte=il.createSelector([wE],e=>e.canvasWorkflow);il.createSelector([Gte],e=>e?.meta?.isHorizontal??!0);const hot=il.createSelector([wE],e=>e.activityExecutionData),Aot=il.createSelector([wE],e=>e.selectedActivityId),mot=il.createSelector([wE],e=>e.viewOnly);il.createSelector([wE],e=>e.nodesToFocus);const got=il.createSelector([Vte],e=>e.activities?.data?.data||[]),Eot=il.createSelector([Vte],e=>e.triggers?.data?.data||[]),IE=il.createSelector([got,Eot],(e,t)=>({activities:e,triggers:t})),Oot=il.createSelector([hot,(e,t)=>t],(e,t)=>e?.[t]?.loading??!1),yot=il.createSelector([Gte,mot,Aot],(e,t,n)=>({isHorizontal:e?.meta?.isHorizontal??!0,viewOnly:t,selectedActivityId:n})),Cx=()=>{const e=E.useTheme();return d.jsx(E.Box,{className:"warning",sx:{background:e.palette.neutral.plain,color:e.palette.common.white,p:"2px 5px",margin:"14px 0px 0px",borderRadius:1.5,position:"relative",top:10},children:d.jsx(E.Typography,{variant:"smSemiBold",sx:{display:"block",width:200,fontFamily:"Inter"},children:"An activity can not be connected to more than one other activity"})})},hf=({type:e,position:t,id:n,isConnectable:r,className:i,isValidConnection:o,style:s,onClick:a})=>{const l=E.useTheme(),{viewOnly:u}=gt.useSelector(c=>c.canvas);return d.jsx(Rt.Handle,{onClick:u?void 0:a,type:e,position:t,id:n,isConnectable:r,isValidConnection:o,className:u?i+" viewModeCursor":i,style:{...s,backgroundColor:l.palette.common.white,cursor:u?"not-allowed":"pointer"},children:!u&&d.jsx(E.Box,{className:"handle_icon",sx:{bgcolor:l.palette.common.white,borderRadius:"50%"},children:d.jsx(Ue,{src:"ic_add_circle_outlined",width:"100%",height:"100%",sx:{path:{fill:l.palette.primary.main}}})})})};function vot(e=!1){const t=gt.useDispatch(),{getNodes:n,getEdges:r}=Rt.useReactFlow(),i=n(),o=r(),s=C.useRef({x:0,y:0}),{activity_names:a}=gt.useSelector(m=>m.activities),{setNodes:l,screenToFlowPosition:u}=Rt.useReactFlow(),[c,f]=C.useState([]),p=C.useCallback((m=u({x:s.current.x,y:s.current.y}))=>{const O=i.filter(T=>T.id===m);let y=[...i];const v=O.map(T=>{const _=Math.trunc(Math.random()*20),x=T.position.x+80+_,b=T.position.y+100+_,w=T?.data?.name||T?.data?.type||"node",I=Ra(w,y),P=i1(null,T.data,null,I,y,null,"",[],{x,y:b});return T.activity_data&&(P.activity_data={...T.activity_data}),t({type:bi.SET_ACTIVITY_NAMES,payload:[...a,P.data.name]}),y=[...y,P],P});l([...i.map(T=>({...T,selected:!1})),...v])},[i,l,u]),h=C.useCallback(()=>{const m=i.filter(v=>v.selected);if(m.find(v=>v.type===xt.TRIGGER)){t({type:Yn,payload:{open:!0,title:"Trigger can't be copy",type:"error"}});return}let O=[...i];const y=m.map(v=>{const T=Math.trunc(Math.random()*20),_=v.data.name.split("_")[0],x=Pb(_,O),b=v.position.x+60+T,w=v.position.y+60+T,D=Ra(v?.data?.name||v?.data?.type||"node",O),I={...v,id:D,position:{x:b,y:w},data:{name:x,properties:v.data.properties,type:v.data.type},incomingPorts:[],outgoingPorts:[]};return O=[...O,{...I}],I});f(y),y.length===0?t({type:Yn,payload:{open:!0,title:"Please select a node to copy",type:"error"}}):t({type:Yn,payload:{open:!0,title:"Activity copied successfully",type:"success"}})},[i,o]),A=C.useCallback(({x:m,y:O}=u({x:s.current.x,y:s.current.y}))=>{const y=Math.min(...c.map(_=>_.position.x)),v=Math.min(...c.map(_=>_.position.y)),T=c.map(_=>{const x=_.id,b=m+(_.position.x-y),w=O+(_.position.y-v);return{..._,id:x,position:{x:b,y:w}}});l([...i.map(_=>({..._,selected:!1})),...T])},[c,u,l]),g=i.find(m=>m?.selected);return Wte(e&&g?["Meta+c","Ctrl+c"]:[],h),Wte(e&&g?["Meta+v","Ctrl+v"]:[],A),{copy:h,clone:p,paste:A,bufferedNodes:c}}function Wte(e,t){const[n,r]=C.useState(!1),i=Rt.useKeyPress(e);C.useEffect(()=>{i&&!n?(t(),r(!0)):r(i)},[i,n,t])}const DE=({name:e,id:t,isTriggerNode:n,nodeData:r,handleDeleteNode:i,proIntegration:o=!1,onRunWithPrevious:s})=>{const a=E.useTheme(),l=gt.useDispatch(),{viewOnly:u}=gt.useSelector(U=>U.canvas),{workflow:c}=gt.useSelector(U=>U.workflows),{activities:f,triggers:p}=gt.useSelector(U=>U.activities),A=new URLSearchParams(typeof window<"u"?window.location.search:"").get("source")?.toLowerCase()||c?.source,g=n&&A?.includes("commerce_"),{clone:m}=vot(),O=ui(f?.data?.data,p?.data?.data,r),y=r?.properties?.integration_slug||"",v=r?.type,T=!n&&!xf.includes(v),_=r?.blt_node_states||{},x=_.setup_and_configure||"default",b=_.node||"default",w=T&&x!=="completed"&&b!=="completed",D=Rt.useEdges(),I=C.useMemo(()=>D.some(U=>U.target===t&&U.type!==Un.PLACEHOLDER),[D,t]),P=C.useCallback(()=>{o||w||(l({type:du,payload:{id:t}}),l({type:Sf,payload:!0}),l({type:Cb,payload:{nodeId:t,runWithPrevious:!1}}))},[t,o,w,l]),k=C.useCallback(()=>{o||w||!I||(s?s(t):(l({type:du,payload:{id:t}}),l({type:Sf,payload:!0}),l({type:Cb,payload:{nodeId:t,runWithPrevious:!0}})))},[t,o,w,I,l,s]),N=C.useCallback(()=>{o||m(t)},[t,o,m]),L=C.useCallback(()=>{i([{id:t,name:e,icon:O,integration_slug:y}])},[t,e,O,y,i]),M=C.useCallback(()=>{l({type:Sf,payload:!1}),l({type:ss,payload:{type:"triggers",active:!0,nodeId:t}})},[t,l]);if(u)return null;const B={"&.Mui-disabled":{opacity:1}},Q=a.palette.primary.disabled??a.palette.grey?.normal;return d.jsxs(E.Stack,{direction:"row",alignItems:"center",gap:.5,onClick:U=>U.stopPropagation(),children:[d.jsxs(E.Stack,{direction:"row",alignItems:"center",sx:{backgroundColor:a.palette.common.white,borderRadius:"8px",boxShadow:"0px 2px 8px rgba(0, 0, 0, 0.08)",p:.25},children:[n&&d.jsx(E.Tooltip,{arrow:!0,title:"Switch Trigger",placement:"top",children:d.jsx(E.IconButton,{onClick:M,sx:{p:.5,width:28,height:28,...Di(a)},"data-testid":"node-action-switch-trigger",children:d.jsx(Ue,{src:"ic_swap",width:20,height:20,sx:{path:{fill:a.palette.neutral.solid.bg||"#656A70"}}})})}),T&&d.jsxs(d.Fragment,{children:[d.jsx(E.Tooltip,{arrow:!0,title:w?"Complete configuration to Test Node":"Test Node",placement:"top",children:d.jsx("span",{children:d.jsx(E.IconButton,{onClick:P,disabled:w,sx:{p:.5,width:28,height:28,...B},"data-testid":"node-action-run",children:d.jsx(Ue,{src:"ic_play",width:20,height:20,sx:{path:{fill:w?Q:a.palette.primary.main}}})})})}),d.jsx(E.Tooltip,{arrow:!0,title:w?"Complete configuration to run":I?"Run with previous":"No previous node attached",placement:"top",children:d.jsx("span",{children:d.jsx(E.IconButton,{onClick:k,disabled:w||!I,sx:{p:.5,width:28,height:28,...B},"data-testid":"node-action-run-with-previous",children:d.jsx(Ue,{src:"ic_autoplay",width:20,height:20,sx:{path:{fill:w||!I?Q:a.palette.primary.main}}})})})})]}),!n&&d.jsx(E.Tooltip,{arrow:!0,title:"Duplicate",placement:"top",children:d.jsx(E.IconButton,{onClick:N,disabled:o,sx:{p:.5,width:28,height:28,...Di(a),...B},"data-testid":"node-action-duplicate",children:d.jsx(Ue,{src:"ic_copy",width:20,height:20,sx:{path:{fill:o?a.palette.text?.tertiary??a.palette.neutral?.solid?.bg:a.palette.neutral.solid.bg}}})})})]}),d.jsx(E.Tooltip,{arrow:!0,title:"Delete",placement:"top",children:d.jsx(E.IconButton,{onClick:L,disabled:g,sx:{p:.5,width:28,height:28,backgroundColor:a.palette.common.white,borderRadius:"8px",boxShadow:"0px 2px 8px rgba(0, 0, 0, 0.08)","&:hover":{backgroundColor:a.palette.common.white,"& .inline-svg path":{fill:`${a.palette.error.main} !important`}}},"data-testid":"node-action-delete",children:d.jsx(Ue,{src:"ic_new_delete",width:20,height:20,sx:{path:{fill:a.palette.error.main||"#C41C1C"}}})})})]})},Tot=250,RE=({children:e,id:t,nodeData:n,focused:r,sx:i={},actionBar:o})=>{const s=Rt.useNodes(),[a,l]=C.useState(!1),u=C.useRef(null),c=()=>{u.current&&(clearTimeout(u.current),u.current=null)},f=()=>{c(),u.current=setTimeout(()=>l(!1),Tot)},p=()=>{c(),l(!0)};C.useEffect(()=>()=>c(),[]);const{setNodes:h}=Rt.useReactFlow(),{nodesToFocus:A}=gt.useSelector(P=>P.canvas),g=gt.useDispatch(),m=A.nodes.includes(t),[O,y]=C.useState(n?.activity_comment?.body||""),v=A.type,T=C.useRef(null),_=C.useRef(!1),[x,b]=C.useState(!1);C.useEffect(()=>{_.current||y(n?.activity_comment?.body||"")},[n?.activity_comment?.body]),C.useLayoutEffect(()=>{if(x&&_.current&&T.current&&document.activeElement!==T.current){const P=T.current;P.focus();const k=P.value.length;P.setSelectionRange(k,k)}});const w=C.useMemo(()=>wa(k=>{const N=s.map(L=>L.id===t?{...L,data:{...L.data,activity_comment:{...L.data.activity_comment,body:k,visible:k.trim()!==""}}}:L);h(N)},300),[s,t,g]);C.useEffect(()=>()=>{w.cancel()},[w]);const D=P=>{let k=P.target.value;k.length>299&&(k=k.substring(0,299)),y(k),w(k)},I=C.useMemo(()=>m&&A.show||r?{border:P=>`1px solid ${v==="focused"||r?P.palette.primary.main:P.palette.error.main}`,...i}:{border:P=>`1px solid ${P.palette.neutral.outlined.border}`,...i},[m,r,v,A.show,i]);return d.jsxs(E.Box,{className:"nodeContainer",position:"relative",sx:I,onMouseEnter:p,onMouseLeave:f,children:[o&&a&&d.jsx(E.Box,{"data-node-action-bar":!0,onMouseEnter:p,onMouseLeave:f,sx:{position:"absolute",bottom:"100%",left:0,right:0,display:"flex",justifyContent:"flex-end",mb:.75,zIndex:10,pointerEvents:"auto"},children:o}),d.jsxs(E.Box,{sx:{display:"flex",flexDirection:"column",flex:1},children:[e,(n?.activity_comment?.visible||x)&&d.jsx(E.Box,{position:"absolute",top:"100%",zIndex:1,width:"100%",height:"auto",mt:.75,mx:0,sx:{userSelect:"all",pointerEvents:"auto"},children:d.jsx(E.TextField,{fullWidth:!0,multiline:!0,variant:"outlined",value:O,inputRef:T,placeholder:"Add a comment",autoFocus:O.trim()==="",sx:{width:"100%",background:P=>P.palette.white.ivory,borderRadius:"8px","&:hover":{".MuiInputBase-root":{"&:hover":{".MuiOutlinedInput-notchedOutline":{borderColor:P=>P.palette.primary.main}},boxShadow:P=>`0 0 8px ${P.palette.primary.main}`}},"& .MuiInputBase-root.MuiOutlinedInput-root":{minHeight:"32px",padding:"10px 4px"}},onChange:D,onFocus:()=>{_.current=!0,b(!0)},onBlur:P=>{if(_.current=!1,b(!1),P.relatedTarget?.tagName==="BUTTON")return;w.cancel();const k=s.map(N=>N.id===t?{...N,data:{...N.data,activity_comment:{...N.data.activity_comment,body:O,visible:O.trim()!==""}}}:N);h(k)}})})]})]},t)},Sot=(e,t)=>{try{const n=e.replace(/properties\.([a-zA-Z_]\w*)/g,(i,o)=>{const s=t[o];return s!=null&&s!==""?s.toString():"undefined"});if(n.includes("undefined")||!/^[\d+\-*/().\s]+$/.test(n))return null;const r=new Function(`return ${n}`)();return typeof r=="number"&&!isNaN(r)?r:null}catch{return null}},xot=(e,t,n)=>{if(!e)return{result:e,allReplaced:!1};let r=!0;return{result:e.replace(/\{\{([^}]+)\}\}/g,(o,s)=>{if(/[+\-*/()]/.test(s)){const a=Sot(s,t);return a!==null?a.toString():(r=!1,o)}else{const l=s.replace(/^properties\??\./,"").replace(/\?/g,"").split(".");let u=t;for(const c of l)if(u&&typeof u=="object"&&c in u)u=u[c];else{u=void 0;break}if(u!=null&&u!==""){if(Array.isArray(u)&&u.length>0)return u.join(", ");if(Array.isArray(u)&&u.length===0)return r=!1,o;let c=n;for(const f of l)if(c&&typeof c=="object"&&f in c)c=c[f];else{c=void 0;break}return c&&typeof c=="object"&&u in c?c[u]:typeof u=="string"?E8(u):u}else return r=!1,o}}),allReplaced:r}},E8=e=>{if(!e)return"";const[t,...n]=e.split("."),r=n.length>0?n.join("."):"",i=(a,l=!1)=>{if(!a)return"";const u=a.replace(/[_\-\.]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z0-9]+)/g,"$1 $2").replace(/\s+/g," ").trim();return l?u.replace(/\b\w/g,c=>c.toUpperCase()):u.charAt(0).toUpperCase()+u.slice(1)},o=i(t),s=i(r);return s?`${s} [${o}]`:o},bot=e=>{const t=Sue();if(Ad.includes(e.data?.type))return e.data.properties?.operation?E8(e.data.properties.operation):"Select an operation";if(e.data?.type in t){const n=e.data.properties,r=t[e.data.type];let i={},o="";if(e.type===xt.TRIGGER?(i=r.trigger,o=r?.trigger?.manual_type):(i=r.integration,o=r?.integration?.manual_type),e.data?.type===Je.SCHEDULE){const l=n?.spec;if(l){if(l.calendars&&l.calendars.length>0)return"Calendar Schedule";if(l.cron_expressions&&l.cron_expressions.length>0)return"Cron Schedule";if(l.intervals&&l.intervals.length>0)return"Interval Schedule"}return"Configure Schedule"}const s=Object.keys(i)[0],a=n?.[s];if(o){const{result:l,allReplaced:u}=xot(o,n,i);return u?l:i.default}if(!a||typeof a=="object"&&vt(a))return i.default;if(i[s]){if(Array.isArray(a))return a.map(l=>i[s]?.[typeof l=="object"?l?.value?.toLowerCase():l?.toLowerCase()]).join(", ");if(e.data?.type===Je.BOLTIC_TABLE_ACTIVITY){if(a==="sql_query"||n?.query)return"SQL Query";if(a==="custom_event"||a&&!i[s]?.[a])return E8(a)}return gb.includes(e.data?.type)&&(a==="custom"||e.data?.type===Je.GOOGLE_SHEETS_WRITE&&s==="mode"&&n?.operation==="custom")?"Custom API":i[s]?.[a]}return a}return""},Qte=e=>{switch(e?.node){case"not-configured-yet":return"ic_warning_circle";case"skipped":return"ic_skipped";case"failed":return"ic_error";case"completed":return"ic_success_small";default:return""}},Cot=({nodeData:e})=>{const t=E.useTheme(),n=bot(e);return d.jsxs(E.Stack,{direction:"row",width:"100%",alignItems:"center",justifyContent:"space-between",children:[d.jsx(E.Tooltip,{title:n,arrow:!0,placement:"top",children:d.jsx(E.Typography,{variant:"smNormal",color:t.palette.text.tertiary,sx:{maxWidth:200,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n})}),!vt(Qte(e.data?.blt_node_states))&&d.jsx(E.Stack,{direction:"row",sx:{cursor:"pointer",flexShrink:0},children:d.jsx(E.Tooltip,{arrow:!0,title:Ds(e.data?.blt_node_states?.node),children:d.jsx(Ue,{width:20,height:20,src:Qte(e.data?.blt_node_states)})})})]})},PE=({id:e,nodeData:t,iconSrc:n,title:r,children:i,isTriggerNode:o,meta:s=null,proIntegration:a=!1,pro:l=!1})=>{const u=gt.useDispatch(),c=E.useTheme(),{setNodes:f,getNodes:p}=Rt.useReactFlow(),{activitiesPopover:h}=gt.useSelector(m=>m.canvas),A=C.useMemo(()=>n?nh(n,"t.resize(h:24,w:24)"):"",[n]),g=m=>{u({type:du,payload:{id:m}})};return d.jsxs(E.Stack,{alignItems:"center",p:1.5,gap:1,onClick:m=>{m.stopPropagation(),!a&&(h.nodeId===t.id?u({type:ss,payload:{type:"",active:!1,nodeId:null}}):g(t.id))},sx:{cursor:a?"not-allowed":"pointer"},children:[d.jsxs(E.Stack,{direction:"row",overflow:a?"visible":"hidden",alignItems:"center",width:"100%",justifyContent:"space-between",flex:1,children:[d.jsx(E.Box,{sx:{opacity:a?.5:1,filter:a?"grayscale(1)":"none",flex:1,minWidth:0,display:"flex",alignItems:"center"},children:d.jsxs(E.Stack,{direction:"row",gap:1,alignItems:"center",flex:1,minWidth:0,overflow:"visible",children:[d.jsx(E.Stack,{sx:{...Hi},width:24,height:24,children:n?d.jsx("img",{src:A,alt:r,width:24,height:24,decoding:"async",style:{width:24,height:24,objectFit:"contain",display:"block"}}):d.jsx(E.Box,{sx:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${c.palette.grey.A400}`,borderRadius:1,background:c.palette.grey.A400,padding:.5,color:c.palette.common.white},children:r.slice(0,2).toUpperCase()})}),d.jsx(E.Tooltip,{arrow:!0,title:r,placement:"top",children:d.jsx(E.Typography,{sx:{maxWidth:148,...cu,lineHeight:"142%"},variant:"smSemiBold",color:c.palette.text.primary,children:r})}),l&&d.jsx(E.Box,{flexShrink:0,children:d.jsx(Jd,{})})]})}),d.jsxs(E.Stack,{alignItems:"center",gap:1,flexShrink:0,justifyContent:"self-end",direction:"row",children:[d.jsxs(E.Box,{sx:{opacity:a?.5:1,filter:a?"grayscale(1)":"none",display:"flex",alignItems:"center",gap:1},children:[o&&(t.data.type===Je.GMAIL_TRIGGER||s?.trigger_type===VO.SCHEDULED)&&d.jsx(E.Tooltip,{arrow:!0,title:"The trigger will check for new data in intervals.",children:d.jsx(E.Box,{display:"flex",alignItems:"center",children:d.jsx(E.IconButton,{sx:{p:0},children:d.jsx(Ue,{src:"ic_schedule",width:16,height:16,sx:{cursor:"pointer",path:{fill:c.palette.neutral.solid.bg}}})})})}),d.jsx(E.Tooltip,{arrow:!0,title:"Toggle Comment",children:d.jsx(E.IconButton,{onClick:m=>{if(a)return;m.stopPropagation(),m.preventDefault();const O=p().map(y=>y.id===e?{...y,data:{...y.data,activity_comment:{...y.data?.activity_comment,visible:!y.data?.activity_comment?.visible}}}:y);f(O)},sx:{p:0,...Di(c)},children:d.jsx(Ue,{src:"ic_comment",width:16,height:16})})})]}),d.jsx(E.Box,{sx:{position:"relative",zIndex:1,opacity:1,flexShrink:0},children:i})]})]}),d.jsxs(E.Box,{sx:{width:"100%",opacity:a?.5:1,filter:a?"grayscale(1)":"none"},children:[d.jsx(E.Divider,{sx:{width:"100%"}}),d.jsx(E.Box,{sx:{pt:1},children:d.jsx(Cot,{nodeData:t})})]})]})},_ot=C.memo(e=>{const t=Rt.useNodes(),n=Rt.useEdges(),r=E.useTheme(),{canvasWorkflow:i,activityExecutionData:o,viewOnly:s,selectedActivityId:a}=gt.useSelector(Q=>Q.canvas),l=i?.meta?.isHorizontal??!0,u=Rt.useUpdateNodeInternals(),{setNodes:c}=Rt.useReactFlow(),{id:f,data:p,onHandleClick:h,handleDeleteNode:A,selected:g,pro_integration:m,onRunWithPrevious:O}=e,y=t.find(Q=>Q.id===a),{activities:v,triggers:T}=gt.useSelector(IE),_=Array.isArray(v)?v:[],x=Array.isArray(T)?T:[],b=ui(_,x,p,"pro"),w=!!b&&b!=="",D=w&&m===!1,I=o?.[p.name]?.loading??!1;let P=Array.isArray(p.properties?.branches)?p.properties.branches:[];(p.type===Je.API||p.type===Je.GRAPHQL)&&p.properties?.continue_on_failure===!1&&(P=P.filter(Q=>Q.ref==="success")),C.useEffect(()=>{u(f)},[f,P.length,p.properties?.continue_on_failure]),C.useEffect(()=>{c(Q=>Q.map(U=>{if(U.id===f){const q=D;if(U.draggable!==!q||U.selectable!==!q||U.connectable!==!q)return{...U,draggable:!q,selectable:!q,connectable:!q}}return U}))},[D,f,c]);const k=P.length+1,N=Math.max(k*16,84),L=Q=>{const U=k-1,q=U*8,F=(U-1)*8,W=q+F,R=(N-W+4)/2+Q*16,j=l?R:84;return isNaN(j)?84:j},M=Q=>{const U=k,q=k>4?260+32*(k-4):260,F=l?255:(Q+1)*(q/U);return isNaN(F)?l?254:253:F},B=(Q,U,q)=>{const F=p.type===Je.API||p.type===Je.GRAPHQL;return Q===0?F?"success":"if":Q===U-1?F?"failure":"else":q[Q]?.ref||`branch_${Q}`};return d.jsxs(E.Box,{position:"relative",className:"nowheel",onClick:Q=>{if(D){Q.stopPropagation();return}},sx:{cursor:D?"not-allowed":"default",pointerEvents:"auto",width:"100%",height:"100%"},children:[d.jsx(Rt.Handle,{type:"target",position:l?Rt.Position.Left:Rt.Position.Top,id:"targetHandle",isConnectable:!0,className:s?"targetHandleStyle viewModeCursor":"targetHandleStyle",style:{top:l?"50%":0,left:l?1:"50%",background:r.palette.common.white,border:`1px solid ${r.palette.neutral.main}`,opacity:D?.5:1},isConnectableStart:!1,children:d.jsx(Cx,{})}),d.jsx(RE,{id:f,focused:y?.id===f||g,nodeData:e.data,actionBar:d.jsx(DE,{name:p.name,id:f,isTriggerNode:!1,nodeData:e.data,handleDeleteNode:A,proIntegration:D,onRunWithPrevious:O}),sx:l?{height:N,minHeight:84,width:260}:{width:k>4?260+32*(k-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(PE,{id:f,nodeData:e,iconSrc:ui(_,x,p),title:p.name,running:I,proIntegration:D,pro:w})}),P.map((Q,U)=>{const q=B(U,P.length,P),F=q==="failure"||q==="else";return d.jsx(hf,{type:"source",position:l?Rt.Position.Right:Rt.Position.Bottom,id:q,className:"sourceHandleStyle",style:{position:"absolute",top:L(U),left:M(U),transform:"translateY(-50%)",border:`1px solid ${F?r.palette.error[50]:r.palette.neutral.main}`,opacity:D?.5:1},isConnectable:!D,onClick:()=>{!s&&!D&&h(q,t,n,{top:l?L(U)-25.5:L(U)+48,left:l?M(U)+48:M(U)-25.5+3.5})},isValidConnection:W=>{const G=t.find(H=>W.source===H.id);if(!G||W.source===W.target||hd(W.source,W.target,n))return!1;const j=n.filter(H=>H.type!==Un.PLACEHOLDER);return!(j.some(H=>G.id===H.source&&W.sourceHandle===H.sourceHandle)||j.some(H=>H.target===W.target&&H.source===W.source)||j.some(H=>H.target===W.target&&H.source!==W.source))}},`condition-branch-${U}`)})]})}),wot=C.memo(e=>{const t=Rt.useNodes(),n=Rt.useEdges(),r=E.useTheme(),{isHorizontal:i,viewOnly:o,selectedActivityId:s}=gt.useSelector(yot),{activities:a,triggers:l}=gt.useSelector(IE),u=gt.useSelector(B=>Oot(B,e.data.name)),c=Array.isArray(a)?a:[],f=Array.isArray(l)?l:[],p=Rt.useUpdateNodeInternals(),{id:h,data:A,selected:g,onHandleClick:m,handleDeleteNode:O,pro_integration:y,onRunWithPrevious:v}=e,T=ui(c,f,A,"pro"),_=!!T&&T!=="",x=_&&y===!1;C.useEffect(()=>{p(e.id)},[e.id,e.data?.properties?.continue_on_failure]);const b=C.useMemo(()=>t.find(B=>B.id===s),[t,s]),D=(Array.isArray(A?.properties?.branches)?A.properties.branches:[]).length+1,I=Math.max(D*16,84),N=(e.data.properties?.continue_on_failure===!0?2:1)+1,L=B=>{const Q=N-1,U=Q*8,q=(Q-1)*8,F=U+q,G=(I-F+4)/2+B*16,R=i?G:86;return isNaN(R)?86:R},M=B=>{const U=i?255:(B+1)*(260/N);return isNaN(U)?255:U};return d.jsxs(E.Box,{position:"relative",className:"nowheel",sx:{cursor:x?"not-allowed":"default",pointerEvents:"auto"},children:[d.jsx(Rt.Handle,{type:"target",position:i?Rt.Position.Left:Rt.Position.Top,id:"targetHandle",isConnectable:!0,className:o?"targetHandleStyle viewModeCursor":"targetHandleStyle",style:{top:i?"50%":0,left:i?1:"50%",background:r.palette.common.white,border:`1px solid ${r.palette.neutral.main}`},isConnectableStart:!1,children:d.jsx(Cx,{})}),d.jsx(RE,{id:h,focused:b?.id===h||g,nodeData:e.data,actionBar:d.jsx(DE,{name:A.name,id:h,isTriggerNode:!1,nodeData:e.data,handleDeleteNode:O,proIntegration:x,onRunWithPrevious:v}),sx:i?{height:I,minHeight:84,width:260}:{width:D>4?260+32*(D-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(PE,{id:h,nodeData:e,iconSrc:ui(c,f,A),title:A.name,running:u,proIntegration:x,pro:_})}),e.data.type!==Je.RESPONSE&&d.jsx(hf,{type:"source",position:i?Rt.Position.Right:Rt.Position.Bottom,id:"outHandle",onClick:()=>{!o&&!x&&m("outHandle",t,n,{top:i?L(0)-25.5:L(0)+48,left:i?M(0)+48:M(0)-25.5+3.5})},isConnectable:!0,className:"sourceHandleStyle",style:{position:"absolute",top:L(0),left:M(0),transform:"translateY(-50%)",border:`1px solid ${r.palette.neutral.main}`,opacity:x?.5:1},isValidConnection:B=>{const Q=t.find(W=>B.source===W.id);if(B.source===B.target||hd(B.source,B.target,n))return!1;const q=(Q.outgoingPorts||[]).some(W=>!W.ref||W.ref!=="failure");return!n.some(W=>W.target===B.target&&W.type!==Un.PLACEHOLDER)&&!q}}),e.data.properties?.continue_on_failure===!0&&d.jsx(hf,{type:"source",position:i?Rt.Position.Right:Rt.Position.Bottom,id:"failureHandle",onClick:()=>{!o&&!x&&m("failureHandle",t,n,{top:i?L(1)-25.5:L(1)+48,left:i?M(1)+48:M(1)-25.5+3.5})},isConnectable:!0,className:"sourceHandleStyle failureHandle",style:{position:"absolute",top:L(1),left:M(1),transform:"translateY(-50%)",border:`1px solid ${r.palette.error.main}`,background:r.palette.error.light,opacity:x?.5:1},isValidConnection:B=>{if(!t.find(R=>B.source===R.id)||B.source===B.target||hd(B.source,B.target,n))return!1;const q=n.filter(R=>R.type!==Un.PLACEHOLDER);return!(q.some(R=>R.source===B.source&&R.target===B.target&&R.sourceHandle==="failureHandle")||q.some(R=>R.target===B.target&&R.source===B.source)||q.some(R=>R.target===B.target&&R.source!==B.source))}})]})}),Iot=C.memo(e=>{const t=Rt.useNodes(),n=Rt.useEdges(),r=E.useTheme(),{activityExecutionData:i,canvasWorkflow:o,viewOnly:s,selectedActivityId:a}=gt.useSelector(B=>B.canvas),l=t.find(B=>B.id===a),u=Rt.useUpdateNodeInternals(),{id:c,data:f,selected:p,onHandleClick:h,handleDeleteNode:A,pro_integration:g,onRunWithPrevious:m}=e,{activities:O,triggers:y}=gt.useSelector(IE),v=Array.isArray(O)?O:[],T=Array.isArray(y)?y:[],_=ui(v,T,f,"pro"),x=!!_&&_!=="",b=x&&g===!1,w=o?.meta?.isHorizontal??!0,D=f.properties?.no_of_parallel_threads||0;C.useEffect(()=>{u(c)},[c,D]);const I=i?.[f.name]?.loading??!1,P=B=>`parallel_${B}`,k=D+1,N=Math.max(k*16,84),L=B=>{const Q=k-1,U=Q*8,q=(Q-1)*8,F=U+q,G=(N-F+4)/2+B*16,R=w?G:86;return isNaN(R)?86:R},M=B=>{const Q=D+1,U=D>5?260+32*(D-4):260,q=w?255:(B+1)*(U/Q);return isNaN(q)?255:q};return d.jsxs(E.Box,{position:"relative",className:"nowheel",sx:{cursor:b?"not-allowed":"default",pointerEvents:"auto"},children:[d.jsx(Rt.Handle,{type:"target",position:w?Rt.Position.Left:Rt.Position.Top,id:"targetHandle",isConnectable:!b,className:s?"targetHandleStyle viewModeCursor":"targetHandleStyle",style:{top:w?"50%":0,left:w?1:"50%",background:r.palette.common.white,border:`1px solid ${r.palette.neutral.main}`,opacity:b?.5:1},isConnectableStart:!1,children:d.jsx(Cx,{})}),d.jsx(RE,{id:c,focused:l?.id===c||p,nodeData:e.data,actionBar:d.jsx(DE,{name:f.name,id:c,isTriggerNode:!1,nodeData:e.data,handleDeleteNode:A,proIntegration:b,onRunWithPrevious:m}),sx:w?{height:`${N}px`,minHeight:84,width:260}:{width:D>5?260+32*(D-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(PE,{id:c,nodeData:e,iconSrc:ui(v,T,f),title:f.name,running:I,proIntegration:b,pro:x})}),[...Array(D)].map((B,Q)=>d.jsx(hf,{type:"source",position:w?Rt.Position.Right:Rt.Position.Bottom,id:P(Q),isConnectable:!0,className:"sourceHandleStyle",style:{top:L(Q),left:M(Q),transform:"translateY(-50%)",border:`1px solid ${r.palette.neutral.main}`,opacity:b?.5:1},isValidConnection:U=>{const q=t.find($=>U.source===$.id);if(!q||U.source===U.target||hd(U.source,U.target,n))return!1;const W=n.filter($=>$.type!==Un.PLACEHOLDER);return!(W.some($=>q.id===$.source&&U.sourceHandle===$.sourceHandle)||W.some($=>$.target===U.target&&$.source===U.source)||W.some($=>$.target===U.target&&$.source!==U.source))},onClick:()=>{!s&&!b&&h(P(Q),t,n,{top:w?L(Q)-25.5:L(Q)+48,left:w?M(Q)+48:M(Q)-25.5+3.5})}},`parallel-thread-${Q}`))]})}),zte=({id:e,overlayProps:t,allowDrag:n=!1,hideTargetHandle:r=!1})=>{const i=E.useTheme(),o=Rt.useUpdateNodeInternals(),{canvasWorkflow:s}=gt.useSelector(l=>l.canvas),a=s?.meta?.isHorizontal??!0;return C.useEffect(()=>{e&&o(e)},[e,o]),d.jsxs("div",{style:{pointerEvents:"auto"},children:[!r&&d.jsx(Rt.Handle,{type:"target",id:"targetHandle",position:a?Rt.Position.Left:Rt.Position.Top,isConnectable:!1,className:"targetHandleStyle",style:{top:a?"50%":0,left:a?0:"50%",transform:"translate(-50%, -50%)",background:i.palette.common.white,border:`1px solid ${i.palette.neutral.main}`}}),d.jsx(pde,{open:!0,variant:"inline",draggable:!1,...t}),d.jsx(Rt.Handle,{type:"source",id:"outHandle",position:a?Rt.Position.Right:Rt.Position.Bottom,isConnectable:!1,className:"sourceHandleStyle",style:{top:a?"50%":"100%",left:a?"100%":"50%",transform:"translate(-50%, -50%)",background:i.palette.common.white,border:`1px solid ${i.palette.neutral.main}`}})]})},Dot=e=>{const{handle:t,tooltip:n,toggleListing:r,id:i}=e,o=E.useTheme(),{selectedPlaceholderId:s}=gt.useSelector(a=>a.canvas);return d.jsx(E.Box,{className:"nowheel",sx:{position:"relative",width:51,...s===i&&{"& .MuiButtonBase-root.MuiButton-root":{borderColor:o.palette.primary.main}}},children:d.jsx(E.Tooltip,{arrow:!0,title:n,disableInteractive:!0,children:d.jsxs("span",{children:[d.jsx(E.Button,{sx:{minWidth:50,width:51,height:51,border:`1px solid ${o.palette.grey.outlined.border}`,backgroundColor:o.palette.common.white,"& svg":{width:20,height:20},"&:hover":{backgroundColor:o.palette.common.white,transform:"none"}},onClick:r,children:d.jsx(Ue,{width:24,height:24,src:"ic_add_circle_outlined",sx:{path:{fill:o.palette.primary.main}}})}),t]})})})},Rot=e=>{const{handle:t,toggleListing:n,id:r}=e,i=E.useTheme(),{selectedPlaceholderId:o}=gt.useSelector(s=>s.canvas);return d.jsx(E.Box,{className:"nowheel",children:d.jsxs(E.Stack,{p:1.5,alignItems:"flex-start",border:`1px dashed ${i.palette.neutral.solid.bg}`,borderRadius:2,onClick:n,sx:{backgroundColor:i.palette.common.white,width:260,height:84,...o===r&&{borderColor:i.palette.primary.main}},children:[d.jsxs(E.Stack,{gap:1,width:"100%",children:[d.jsxs(E.Stack,{direction:"row",alignItems:"center",gap:1,children:[d.jsx(Ue,{src:"ic_spark",width:24,height:24,sx:{path:{fill:i.palette.primary.main}}}),d.jsx(E.Stack,{direction:"row",gap:.5,children:d.jsx(E.Typography,{variant:"smMedium",lineHeight:1,children:"Choose trigger"})})]}),d.jsx(E.Divider,{}),d.jsx(E.Typography,{variant:"smNormal",color:i.palette.text.tertiary,children:"Select an event"})]}),t]})})},Pot=({id:e,data:t,onHandleClick:n})=>{const{isTriggerPlaceholder:r}=t,i=E.useTheme(),o=Rt.useNodes(),s=Rt.useEdges(),{ENTITY_ID:a,allowedAccount:l}=Ci(),u=gt.useDispatch(),{activitiesPopover:c,viewOnly:f,canvasWorkflow:p,selectedActivityId:h}=gt.useSelector(O=>O.canvas),A=_E(a,l),g=p?.meta?.isHorizontal??!0,m=O=>{if(f)return;if(h&&u({type:dd,payload:null}),u({type:v0,payload:e}),c?.active&&u({type:ss,payload:{type:"",active:!1,nodeId:null,edgeId:null}}),r&&!A){u({type:ss,payload:{type:"triggers",active:!0,nodeId:e,edgeId:null}}),u({type:Zs,payload:!0});return}if(!A){u({type:ss,payload:{type:"activities",active:!0,nodeId:e,edgeId:null}}),u({type:Zs,payload:!0});return}const y=O?.currentTarget?.getBoundingClientRect?.()??O?.target?.getBoundingClientRect?.();y&&Number.isFinite(y.left)&&Number.isFinite(y.top)?u({type:Yp,payload:{x:y.left+y.width/2,y:y.top+y.height/2}}):O?.clientX&&O?.clientY&&u({type:Yp,payload:{x:O.clientX,y:O.clientY}}),u({type:S0,payload:!1}),u({type:Rs,payload:"prompt"}),u({type:T0,payload:!0})};return r?d.jsx(Rot,{id:e,handle:d.jsx(hf,{type:"source",id:"outHandle",position:g?Rt.Position.Right:Rt.Position.Bottom,isConnectable:!0,className:"sourceHandleStyle",style:{...g?{top:45,left:255,transform:"translateY(-50%)"}:{left:"50%"},border:`1px solid ${i.palette.neutral.main}`},isValidConnection:O=>{if(!o.find(b=>O.source===b.id)||O.source===O.target||hd(O.source,O.target,s))return!1;const T=s.filter(b=>b.type!==Un.PLACEHOLDER);return!(T.some(b=>b.target===O.target&&b.source!==O.source)||T.some(b=>b.source===O.source))},onClick:O=>{O.stopPropagation(),!f&&n("outHandle",o,s,{top:g?42-25.5+2:132,left:g?308:130-25.5})}}),toggleListing:m}):d.jsx(Dot,{id:e,handle:d.jsx(Rt.Handle,{type:"target",id:"targetHandle",position:g?Rt.Position.Left:Rt.Position.Top,isConnectable:!1,className:f?"viewModeCursor":"",style:{position:"absolute",background:"transparent",border:"none",left:g?0:"50%",top:g?"50%":0,transform:g?"translateY(-50%)":"translateX(-50%)"}}),tooltip:"Click here to add action",toggleListing:m})},Not=C.memo(e=>{const{canvasWorkflow:t,activityExecutionData:n,viewOnly:r,selectedActivityId:i}=gt.useSelector(L=>L.canvas),o=t?.meta?.isHorizontal??!0,s=Rt.useNodes(),a=Rt.useEdges(),l=E.useTheme(),u=Rt.useUpdateNodeInternals(),{id:c,data:f,onHandleClick:p,selected:h,handleDeleteNode:A,pro_integration:g,onRunWithPrevious:m}=e,O=s.find(L=>L.id===i),y=(f.properties?.cases?.length||0)+1;C.useEffect(()=>{u(c)},[c,f.properties?.cases?.length,u]);const v=n?.[f.name]?.loading??!1,{activities:T,triggers:_}=gt.useSelector(IE),x=Array.isArray(T)?T:[],b=Array.isArray(_)?_:[],w=ui(x,b,f,"pro"),D=!!w&&w!=="",I=D&&g===!1,P=Math.max(y*16,84),k=L=>o?y===1?P/2:P/(y+1)*(L+1):84,N=L=>{const M=y+1,B=y>4?260+32*(y-5):260;return o?o?254:253:(L+1)*(B/M)};return d.jsxs(E.Stack,{direction:o?"row":"column",alignItems:"center",position:"relative",className:"nowheel",sx:{cursor:I?"not-allowed":"default",pointerEvents:"auto"},children:[d.jsx(Rt.Handle,{type:"target",position:o?Rt.Position.Left:Rt.Position.Top,id:"targetHandle",isConnectable:!0,className:r?"targetHandleStyle viewModeCursor":"targetHandleStyle",style:{top:o?"50%":0,left:o?1:"50%",background:l.palette.common.white,border:`1px solid ${l.palette.neutral.main}`,opacity:I?.5:1},isConnectableStart:!1,children:d.jsx(Cx,{})}),d.jsx(RE,{id:c,focused:O?.id===c||h,nodeData:e.data,actionBar:d.jsx(DE,{name:f.name,id:c,isTriggerNode:!1,nodeData:e.data,handleDeleteNode:A,proIntegration:I,onRunWithPrevious:m}),sx:o?{height:`${P}px`,minHeight:84,width:260}:{width:y>4?260+32*(y-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(PE,{id:c,nodeData:e,running:v,iconSrc:ui(x,b,f),title:f.name,proIntegration:I,pro:D})}),d.jsxs(E.Stack,{gap:o?.5:2,direction:o?"column":"row",children:[(f.properties?.cases||[]).map((L,M)=>{const B=k(M),Q=N(M);return d.jsx(hf,{type:"source",position:o?Rt.Position.Right:Rt.Position.Bottom,id:`${L.caseKey}`,isConnectable:!0,className:"sourceHandleStyle",style:{position:"absolute",top:`${B}px`,left:`${Q}px`,transform:"translateY(-50%)",border:`1px solid ${l.palette.neutral.main}`,opacity:I?.5:1},onClick:()=>{if(!r&&!I&&p){const U=k(M),q=N(M);p(L.caseKey,s,a,{top:o?U-25.5:U+48,left:o?q+48:q-25.5+3.5})}},isValidConnection:U=>{const q=s.find($=>U.source===$.id);if(!q||U.source===U.target||hd(U.source,U.target,a))return!1;const W=a.filter($=>$.type!==Un.PLACEHOLDER);return!(W.some($=>q.id===$.source&&U.sourceHandle===$.sourceHandle)||W.some($=>$.target===U.target&&$.source===U.source)||W.some($=>$.target===U.target&&$.source!==U.source))}},`${L.caseKey}-${M}`)}),d.jsx(hf,{type:"source",position:o?Rt.Position.Right:Rt.Position.Bottom,id:"defaultHandle",isConnectable:!0,className:"sourceHandleStyle",style:{position:"absolute",top:`${k(f.properties?.cases?.length||0)}px`,left:`${N(f.properties?.cases?.length||0)}px`,transform:"translateY(-50%)",border:`1px solid ${l.palette.error[50]}`,opacity:I?.5:1},onClick:()=>{if(!r&&!I&&p){const L=f.properties?.cases?.length||0,M=k(L),B=N(L);p("defaultHandle",s,a,{top:o?M-25.5:M+48,left:o?B+48:B-25.5+3.5})}},isValidConnection:L=>{const M=s.find(W=>L.source===W.id);if(!M||L.source===L.target||hd(L.source,L.target,a))return!1;const Q=a.filter(W=>W.type!==Un.PLACEHOLDER);return!(Q.some(W=>M.id===W.source&&L.sourceHandle===W.sourceHandle)||Q.some(W=>W.target===L.target&&W.source===L.source)||Q.some(W=>W.target===L.target&&W.source!==L.source))}},"defaultHandle")]})]})}),Lot=C.memo(e=>{const{id:t,data:n,selected:r,onHandleClick:i,VORTEX_MAIN_URL:o,ENTITY_ID:s,handleDeleteNode:a,currentSubscription:l,pro_integration:u}=e,c=Sr(Pn.VERSION),f=vo(),p=Sr(f),h=gt.useDispatch(),A=E.useTheme(),{analytics:g}=Ci(),m=Rt.useNodes(),O=Rt.useEdges(),{workflow:y}=gt.useSelector($=>$.workflows),{canvasWorkflow:v,activityExecutionData:T,viewOnly:_,showDebugLogs:x,selectedActivityId:b}=gt.useSelector($=>$.canvas),w=m.find($=>$.id===b),D=v?.meta?.isHorizontal??!0,I=m?.find($=>$?.type===xt.TRIGGER),{activities:P,triggers:k}=gt.useSelector(IE),N=Array.isArray(P)?P:[],L=Array.isArray(k)?k:[],M=ui(N,L,n,"pro"),B=!!M&&M!=="",Q=B&&u===!1,[U,q]=C.useState(!1),F=T?.[n.name]?.loading??!1,W=I?.data?.type,R=(Array.isArray(n?.properties?.branches)?n.properties.branches:[]).length+1,j=Math.max(R*16,84);return d.jsxs(E.Box,{position:"relative",className:"nowheel",sx:{cursor:Q?"not-allowed":"default",pointerEvents:"auto"},children:[p&&I&&W!==Je.HTTP&&d.jsx(E.Tooltip,{arrow:!0,title:l?.workflowExecution?.remaining<=0?"You cannot execute this workflow as you have reached execution limit.":l[0]?.status==="EXPIRED"?"You cannot execute this workflow as your subscription has expired.":l[0]?.status==="CANCELLED"?"You cannot execute this workflow as your subscription has been cancelled.":"Run Workflow",children:d.jsx(E.Box,{sx:{display:"inline-flex",position:"absolute",top:28,left:-44},children:d.jsx(E.IconButton,{color:"primary",sx:{width:32,height:32,color:$=>$.palette.primary.main,opacity:l?.workflowExecution?.remaining<=0||l[0]?.status==="EXPIRED"||l[0]?.status==="CANCELLED"?.3:1,cursor:"pointer",backgroundColor:A.palette.common.white,border:`1px solid ${b||U?A.palette.neutral.outlined.border:A.palette.primary.main}`,"&:hover":{backgroundColor:A.palette.common.white}},onClick:async()=>{if(I)if(x0(I,m)){const Y=vt(c)?p:c;q(!0),await x6(y,Y,[I],h,o,s,c,p,x,g),q(!1)}else h({type:Yn,payload:{open:!0,title:"Please complete all activities configurations to execute this workflow",type:"error"}})},disabled:!!b||U||l?.workflowExecution?.remaining<=0||l[0]?.status==="EXPIRED"||l[0]?.status==="CANCELLED",children:U?d.jsx(E.CircularProgress,{sx:{color:A.palette.grey.normal},size:16}):d.jsx(Ue,{src:"ic_run",sx:{path:{fill:b?"currentColor":A.palette.primary.main}}})})})}),d.jsx(RE,{focused:w?.id===t||r,id:t,nodeData:e.data,actionBar:d.jsx(DE,{name:n.name,id:t,isTriggerNode:!0,nodeData:e.data,handleDeleteNode:a,proIntegration:Q}),sx:D?{height:j,minHeight:84,width:260}:{width:R>4?260+32*(R-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(PE,{id:t,nodeData:e,iconSrc:ui(N,L,n),title:n.name,running:F,isTriggerNode:!0,meta:ui(N,L,n,"meta"),proIntegration:Q,pro:B})}),d.jsx(hf,{type:"source",onClick:()=>{!_&&!Q&&i("outHandle",m,O,{top:D?42-25.5:132,left:D?308:130-25.5})},position:D?Rt.Position.Right:Rt.Position.Bottom,id:"outHandle",isConnectable:!0,className:"sourceHandleStyle",style:{...D?{top:"50%",left:256,transform:"translateY(-50%)"}:{left:"50%"},border:`1px solid ${A.palette.neutral.main}`,opacity:Q?.5:1},isValidConnection:$=>{if(!m.find(J=>$.source===J.id)||$.source===$.target||hd($.source,$.target,O))return!1;const H=O.filter(J=>J.type!==Un.PLACEHOLDER);return!(H.some(J=>J.target===$.target&&J.source!==$.source)||H.some(J=>J.source===$.source))}})]})}),kot=(e,t,n,r,i)=>{const o=E.useTheme(),s=Rt.useNodes(),a=Rt.useEdges(),l=gt.useDispatch(),u=Sr(),{analytics:c,ENTITY_ID:f,WORKFLOW_URLS:p}=Ci(),{activity_names:h}=gt.useSelector(I=>I.activities),{selectedPlaceholderId:A}=gt.useSelector(I=>I.canvas),g=(I,P)=>[...I,P],{captureEvent:m,WORKFLOW_EVENTS:O}=c||{},y=C.useCallback(I=>{I.preventDefault(),A&&l({type:Xp,payload:null});const P=JSON.parse(I.dataTransfer.getData("application/reactflow")),{currentNodeId:k,parentNodeId:N,isTrigger:L}=P,M=s.find($=>$.id===k);let B=k||Ra(P?.name||"node",s);if(P.openingFromPlaceholder){typeof k=="string"&&k.startsWith("placeholder_")&&!M&&(B=Ra(P?.name||"node",s)),M?.type===xt.PLACEHOLDER&&(B=Ra(P?.name||"node",s));const $=i1(I,P,e,B,s,u,i,N?[N]:[],{x:M?.position?.x,y:(M?.position?.y||0)-16});UC(l,$,L,N,M,k,h,r,n,s,a,m,O,f||"",u||void 0,p?.VORTEX_MAIN_URL);return}if(s.some($=>$.type===xt.TRIGGER)&&L){l({type:Yn,payload:{open:!0,title:"Only one trigger is allowed",type:"error"}});return}l({type:dd,payload:null});const U=s.find($=>$.type===xt.PLACEHOLDER&&$.data?.isTriggerPlaceholder),q=U?.id,F=s.filter($=>$.type!==xt.TRIGGER),W=Ra(P?.name||"trigger",F),G=P.type===xt.TRIGGER&&U?.position?U.position:null,R=i1(I,P,e,P.type===xt.TRIGGER?W:B,s,u,i,[],G);l({type:"SET_ACTIVITY_NAMES",payload:[...h,R.data.name]}),t(),l({type:Zs,payload:!1});const j=s.filter($=>$.type!==xt.PLACEHOLDER&&$.type!==xt.TRIGGER);if(u&&j.length===0&&R.type!==xt.TRIGGER&&!P.openingFromPlaceholder){const $=s.find(Y=>Y.type===xt.TRIGGER||Y?.data?.isTriggerPlaceholder);if($){const Y={source:$.id,sourceHandle:"outHandle",target:R.id,targetHandle:"targetHandle",type:$.type===Un.PLACEHOLDER?Un.PLACEHOLDER:Un.SMOOTH},z=[...s,R];m?.(O.WORKFLOW.ACTIVITY_ADD,{"console.product_account_id":f,message:"Activity added to workflow",integration_slug:R?.data?.properties?.integration_slug,name:R?.data?.name}),v(Y,z,a)}}else{let $;U&&R.type===xt.TRIGGER?$=s.map(Y=>Y.type===xt.PLACEHOLDER&&Y.data?.isTriggerPlaceholder?R:Y):$=g(s,R),U&&q&&q!==R.id&&R.type===xt.TRIGGER&&($=$.map(Y=>{if(Array.isArray(Y.incomingPorts)&&Y.incomingPorts.includes(q))return{...Y,incomingPorts:Y.incomingPorts.map(z=>z===q?R.id:z)};if(Y.id===R.id&&U.outgoingPorts){const z=U.outgoingPorts.map(H=>{const V=$.find(X=>Array.isArray(X.incomingPorts)&&X.incomingPorts.includes(q));return V?{...H,id:V.id}:H});return{...Y,outgoingPorts:z}}return Y}),r(Y=>(Y||a).map(z=>({...z,source:z.source===q?R.id:z.source,target:z.target===q?R.id:z.target})))),m?.(O.WORKFLOW.ACTIVITY_ADD,{"console.product_account_id":f,message:"Activity added to workflow",integration_slug:R?.data?.properties?.integration_slug,name:R?.data?.name}),n($)}l({type:du,payload:{id:R.id}})},[s,a,l,e,u,i,h,r,n,m,O,f,p?.VORTEX_MAIN_URL,o]),v=C.useCallback((I,P,k)=>{const N={...I,type:"smooth",id:I4(k||a),markerEnd:{type:Rt.MarkerType.ArrowClosed,color:s4(I,o)}};t();const L=ko(P||s).map(M=>{if(M.id===I.source){const B=(P||s).find(Q=>Q.id===I.target);I.sourceHandle==="failureHandle"?M.outgoingPorts.push({id:B?.id,ref:"failure",name:B?.data.name}):I.sourceHandle!=="outHandle"?M.outgoingPorts.push({id:B?.id,ref:I.sourceHandle,name:B?.data.name}):M.outgoingPorts.push({id:B?.id,name:B?.data.name})}if(M.id===I.target){const B=(P||s).find(Q=>Q.id===I.source);M.incomingPorts.push(B?.id)}return M});n(L),r(Rt.addEdge(N,k||a)),t()},[s,a,n,r,o,t]),T=C.useCallback(()=>{t()},[t]),_=C.useCallback((I,P)=>{n(k=>{const N=!!(I&&(I.shiftKey||I.metaKey||I.ctrlKey)),L=k.reduce((M,B)=>{const Q=B.zIndex??0;return Q>M?Q:M},0)||0;return k.map(M=>M.id===P.id?{...M,zIndex:L+1,style:{...M.style||{},zIndex:L+1},...N?{}:{selected:!0}}:N?M:{...M,selected:!1})}),t()},[n,t]),x=C.useCallback(I=>{I&&I.length>0&&n(P=>{let k=[...P];return I.forEach(N=>{const L=N.target,M=N.source;k=k.map(B=>{if(B.id===L){const{data:Q,...U}=B,{ref:q,...F}=Q;return{...U,data:F,incomingPorts:(B.incomingPorts||[]).filter(W=>W!==M)}}return B.id===M?{...B,outgoingPorts:(B.outgoingPorts||[]).filter(Q=>Q.id!==L)}:B})}),k}),t()},[n,t]),b=C.useCallback(()=>{s.find(P=>P.selected)&&n(P=>P.map(k=>({...k,selected:!1}))),t()},[s,n]),w=C.useCallback(I=>{I.shiftKey&&I.preventDefault()},[]),D=C.useCallback(I=>{const{nodes:P}=I,k=a||[],N=s||[];if(!Array.isArray(P)||P.length===0){t();return}P.forEach(H=>{H.type!==xt.PLACEHOLDER&&l({type:V5,payload:{id:H.id}})});const L=P.map(H=>H.id),M=new Set(L),B=k.filter(H=>M.has(H.source)||M.has(H.target)),Q=new Set;B.forEach(H=>{const V=N.find(J=>J.id===H.source),X=N.find(J=>J.id===H.target);V?.type===xt.PLACEHOLDER&&!M.has(V.id)&&Q.add(V.id),X?.type===xt.PLACEHOLDER&&!M.has(X.id)&&Q.add(X.id)}),N.forEach(H=>{if(H?.type!==xt.PLACEHOLDER)return;const V=Array.isArray(H.incomingPorts)&&H.incomingPorts.some(J=>M.has(J)),X=Array.isArray(H.outgoingPorts)&&H.outgoingPorts.some(J=>M.has(J?.id));(V||X)&&Q.add(H.id)});const U=[];P.forEach(H=>{if(H.type===xt.TRIGGER||H.type===xt.PLACEHOLDER)return;if(!(H.outgoingPorts&&H.outgoingPorts.length>1||H.data?.properties?.continue_on_failure===!0||H.data?.properties?.cases&&H.data.properties.cases.length>0||H.data?.properties?.branches&&H.data.properties.branches.length>1)){const X=B.filter(ee=>ee.target===H.id&&ee.type!==Un.PLACEHOLDER),J=B.filter(ee=>ee.source===H.id&&ee.type!==Un.PLACEHOLDER);if(X.length===1&&J.length===1){const ee=X[0].source,le=J[0].target;if(M.has(ee)||M.has(le)||Q.has(ee)||Q.has(le))return;U.push({sourceNodeId:ee,targetNodeId:le,sourceHandle:X[0].sourceHandle||"outHandle",targetHandle:J[0].targetHandle||"targetHandle"})}}});let q=N.filter(H=>!(M.has(H.id)||Q.has(H.id)));const F=P.find(H=>H.type===xt.TRIGGER);if(F){const H=o4(),V=Ra("trigger-placeholder",q);q=[{...H,id:V,position:F.position},...q]}const W=new Set(q.map(H=>H.id));let G=k.filter(H=>W.has(H.source)&&W.has(H.target));U.length>0&&U.forEach(({sourceNodeId:H,targetNodeId:V,sourceHandle:X,targetHandle:J})=>{if(!W.has(H)||!W.has(V)||G.some(re=>re.source===H&&re.target===V&&(re.sourceHandle||"outHandle")===(X||"outHandle")&&(re.targetHandle||"targetHandle")===(J||"targetHandle")&&re.type!==Un.PLACEHOLDER))return;const le={id:I4(G),source:H,sourceHandle:X,target:V,targetHandle:J,type:Un.SMOOTH,markerEnd:{type:Rt.MarkerType.ArrowClosed,color:s4({sourceHandle:X},o)}};G=Rt.addEdge(le,G)});const R=new Map;q.forEach(H=>R.set(H.id,H?.data?.name));const j=new Map,$=new Map;(G||[]).filter(H=>H.type!==Un.PLACEHOLDER).forEach(H=>{if(!W.has(H.source)||!W.has(H.target))return;const V=j.get(H.target)||new Set;V.add(H.source),j.set(H.target,V);const X=H.sourceHandle==="failureHandle"?"failure":H.sourceHandle&&H.sourceHandle!=="outHandle"?H.sourceHandle:void 0,J=$.get(H.source)||[];J.push({id:H.target,name:R.get(H.target),...X?{ref:X}:{}}),$.set(H.source,J)});const z=q.map(H=>{const V=Array.from(j.get(H.id)||[]),X=$.get(H.id)||[],J=new Set,ee=X.filter(ve=>{const oe=`${ve?.id||""}::${ve?.ref||""}`;return J.has(oe)?!1:(J.add(oe),!0)}),{data:le,...re}=H,{ref:ue,...Oe}=le||{};return{...re,data:Oe,incomingPorts:V,outgoingPorts:ee}});r(G),n(z),t()},[s,a,n,r,t,l,o]);return{onDrop:y,onConnect:v,onSelectionDragStart:T,onEdgesDelete:x,onPaneClick:b,onMouseDown:w,onDelete:D,onNodeDragStart:_}},O8={maxHistorySize:25,enableShortcuts:!0},Mot=({maxHistorySize:e=O8.maxHistorySize,enableShortcuts:t=O8.enableShortcuts}=O8)=>{const{getNodes:n,getEdges:r,setNodes:i,setEdges:o}=Rt.useReactFlow(),{selectedActivityId:s}=gt.useSelector(y=>y.canvas),a=n(),l=r(),[u,c]=C.useState([]),[f,p]=C.useState([]),h=C.useCallback(()=>{c(y=>{const v=y[y.length-1];return v&&v.nodes===a&&v.edges===l?y:[...y.slice(-e+1),{nodes:a,edges:l}]}),p([])},[a,l,e]),A=()=>{c([]),p([])},g=C.useCallback((y,v,T,_)=>{if(s)return;const x=y[y.length-1];if(x){const b=y.slice(0,-1),w=[...v,{nodes:a,edges:l}];T(b),_(w),i(x.nodes),o(x.edges)}},[i,o,a,l]),m=C.useCallback(()=>g(u,f,c,p),[u,f,g]),O=C.useCallback(()=>g(f,u,p,c),[u,f,g]);return C.useEffect(()=>{if(!t)return;const y=v=>{v.key==="z"&&(v.ctrlKey||v.metaKey)&&v.shiftKey?O():v.key==="z"&&(v.ctrlKey||v.metaKey)&&m()};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y)}},[m,O,t]),{undo:m,redo:O,takeSnapshot:h,clearSnapshot:A,canUndo:!u.length,canRedo:!f.length}},Fot=({open:e})=>{const t=sf();return e?d.jsxs(E.Stack,{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center",spacing:1,sx:{backgroundColor:qa(t.palette.common.white,.75),pointerEvents:"auto",zIndex:t.zIndex.modal},children:[d.jsx(Oi,{size:32}),d.jsx(E.Typography,{variant:"smNormal",sx:{color:"text.secondary"},children:"Arranging automation canvas..."})]}):null},NE=["When a new message is posted in Slack","When a new email is received in Gmail","When a webhook is received"],Xte=["Send email via Gmail","Post to Slack channel","Make API call"],Bot=new Set(["maximum_timeout","continue_on_failure","retry_config.maximum_timeout","retry_config.maximum_attempts","retry_config.backoff_coefficient","retry_config.initial_interval","retry_config.maximum_interval"]),jot=e=>{const t=String(e||"").trim();return!!(!t||Bot.has(t))},Yte=(e,t,n="")=>{if(!e||typeof e!="object")return{};const r={},i=Object.entries(e);for(const[o,s]of i){const a=String(o),l=n?`${n}.${a}`:a;if(!t(l)&&!(s==null||s==="")){if(Array.isArray(s)){s.length>0&&(r[l]=s);continue}if(typeof s=="object"){Object.assign(r,Yte(s,t,l));continue}r[l]=s}}return r},qte=e=>e==="prompt"||e==="error"||e===void 0,Kte=({promptKind:e,mode:t,promptValue:n,onPromptChange:r,onClose:i,onSubmit:o,onRetry:s,onAddManually:a,steps:l,suggestions:u,errorText:c,choice:f,setChoice:p,onContinueChoice:h,auth:A,setAuth:g,onContinueAuth:m,parameters:O,setParameters:y,onContinueParameters:v,inferTesseractEntity:T,ENTITY_ID:_,WORKFLOW_URLS:x,openIntegrationDrawer:b,onAddNewAccount:w,vortexMainUrl:D})=>({promptKind:e,mode:t,promptValue:n,onPromptChange:r,onClose:i,onSubmit:o,onRetry:s,onAddManually:a,steps:l,suggestions:u,errorText:c,choice:f?{label:f.label,options:f.options,selected:f.selected,multiSelect:f.multiSelect,selectedMultiple:f.selectedMultiple,onSelect:I=>p(P=>P&&{...P,selected:I}),onSelectMultiple:I=>p(P=>P&&{...P,selectedMultiple:I}),onContinue:h,continueDisabled:f.multiSelect?!(f.selectedMultiple&&f.selectedMultiple.length>0):!f.selected}:null,auth:A?{label:A.label,options:A.options,selected:A.selected,loading:A.loading,errorText:A.errorText,onSelect:I=>g(P=>P&&{...P,selected:I}),onContinue:m,continueDisabled:A.loading||!A.selected,addNewAccount:{type:T(A.integration_slug,A.field_name),ENTITY_ID:String(_||""),FRONTEND_URL:String(x?.FRONTEND_URL??""),TESSERACT_MAIN_URL:String(x?.TESSERACT_MAIN_URL??""),openIntegrationDrawer:b,onClick:w}}:null,parameters:O?{integrationName:O.integrationName,fields:O.fields,values:O.values,resolvedAuth:O.resolvedAuth,entityId:O.entityId,onValuesChange:I=>y(P=>P&&{...P,values:I}),onContinue:I=>v(I),continueDisabled:O.fields.some(I=>{const P=String(I.name??""),k=O.values[P];return I.required&&(k==null||String(k).trim()==="")})}:null,vortexMainUrl:D,workflowUrls:x});async function $ot(e){const{baseUrl:t,body:n,signal:r,onMessage:i}=e;let o="",s=0;const a=f=>{const p=f.split(`
|
|
650
650
|
`).map(O=>O.trimEnd()).filter(O=>O.length>0);let h=null;const A=[];for(const O of p)O.startsWith("event:")?h=O.slice(6).trim():O.startsWith("data:")&&A.push(O.slice(5).trim());if(!h)return;const g=A.join(`
|
|
651
651
|
`);let m=g;try{m=g?JSON.parse(g):{}}catch{}i({event:h,data:m})},l=()=>{let f;for(;(f=o.indexOf(`
|
|
652
652
|
|