@notmrabhi/flowforge 0.1.6 → 0.1.7
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/{GatewayBranchEdge-DHqcdxpD.js → GatewayBranchEdge-C9tybnDE.js} +2 -2
- package/dist/GatewayBranchEdge-DJql3GUT.js +1 -0
- package/dist/canvas.cjs +1 -1
- package/dist/canvas.js +2 -2
- package/dist/defaultUi.cjs +1 -1
- package/dist/defaultUi.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/{templateSkeletons-Ce90PFaV.js → templateSkeletons-BIQDennR.js} +2 -2
- package/dist/{templateSkeletons-BLzZ5u00.js → templateSkeletons-DQGmO1Yu.js} +1 -1
- package/package.json +1 -1
- package/dist/GatewayBranchEdge-C-gffuVA.js +0 -1
|
@@ -159,7 +159,7 @@ const Ae = ({ data: t }) => {
|
|
|
159
159
|
children: /* @__PURE__ */ e(de, { size: 16, color: "#388e3c" })
|
|
160
160
|
}
|
|
161
161
|
),
|
|
162
|
-
/* @__PURE__ */ e("span", { style: { fontSize: 14, fontWeight:
|
|
162
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 14, fontWeight: 500, color: "#212121" }, children: a })
|
|
163
163
|
] }),
|
|
164
164
|
/* @__PURE__ */ e("div", { className: "ff-d-flex ff-align-items-center", children: v })
|
|
165
165
|
] }),
|
|
@@ -286,7 +286,7 @@ const Ae = ({ data: t }) => {
|
|
|
286
286
|
/* @__PURE__ */ n("div", { className: "ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-1", children: [
|
|
287
287
|
/* @__PURE__ */ n("div", { className: "ff-d-flex ff-align-items-center ff-gap-2", children: [
|
|
288
288
|
v && /* @__PURE__ */ e("div", { style: { display: "flex", alignItems: "center" }, children: v }),
|
|
289
|
-
/* @__PURE__ */ e("span", { className: "ff-
|
|
289
|
+
/* @__PURE__ */ e("span", { className: "ff-text-dark", style: { fontSize: 14, fontWeight: 400 }, children: h })
|
|
290
290
|
] }),
|
|
291
291
|
/* @__PURE__ */ n("div", { className: "node-actions ff-d-flex ff-align-items-center", children: [
|
|
292
292
|
/* @__PURE__ */ e(
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),l=require("reactflow"),T=require("@mui/material"),ce=require("react-icons/gr"),V=require("react"),de=require("./messages-O9Tw_XXR.js"),y=require("react-icons/md"),L=require("react-icons/fa"),ae=require("react-icons/fi"),C=require("./canvasTokens-gKNYrPl4.js"),Z=V.createContext({onEditNode:()=>{},onDeleteNode:()=>{},onAddStep:()=>{},onClickAddTrigger:()=>{},messages:de.defaultFlowForgeMessages,nodeRegistry:null,nodeBody:"full"}),w=()=>V.useContext(Z),Y=()=>e.jsxs("div",{style:{width:350,display:"flex",justifyContent:"center"},children:[e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0,left:"50%"}}),e.jsx("div",{style:{padding:"8px 28px",borderRadius:999,background:"#f5f5f5",border:"1.5px solid #bdbdbd",fontSize:13,fontWeight:500,color:"#424242",userSelect:"none"},children:"Start"})]}),J=()=>e.jsxs("div",{style:{width:350,display:"flex",justifyContent:"center"},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0,left:"50%"}}),e.jsx("div",{style:{padding:"8px 28px",borderRadius:999,background:"#f5f5f5",border:"1.5px solid #bdbdbd",fontSize:13,fontWeight:500,color:"#424242",userSelect:"none"},children:"End"})]}),Q=()=>{const{onClickAddTrigger:t,messages:o}=w();return e.jsxs("div",{style:{width:350,display:"flex",justifyContent:"center"},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0,left:"50%"}}),e.jsx(T.Tooltip,{title:o.addTriggerTooltip,placement:"top",arrow:!0,children:e.jsxs("div",{onClick:t,role:"button",tabIndex:0,onKeyDown:f=>{f.key==="Enter"&&t()},style:{padding:"10px 24px",borderRadius:8,border:"1.5px dashed #d0d0d0",background:"#fff",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[e.jsx(ce.GrTrigger,{size:16}),e.jsx("span",{className:"ff-text-black",style:{fontSize:13},"data-testid":"add-trigger-btn-text",children:o.addTriggerButton})]})}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0,left:"50%"}})]})},pe=({id:t})=>{const{onAddStep:o}=w();return e.jsxs("div",{onClick:()=>o(t),role:"button",tabIndex:0,onKeyDown:f=>{f.key==="Enter"&&o(t)},style:{width:28,height:28,borderRadius:"50%",border:"1.5px solid #9e9e9e",background:"#fff",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:18,color:"#757575",lineHeight:1,userSelect:"none"},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),"+",e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})};function xe(t){return t?t==="END_USER_CREATION"?"New User Registration":t==="END_USER_UPDATION"?"On User Update":t.replace(/[_-]+/g," ").replace(/\b\w/g,o=>o.toUpperCase()):""}function he(t){const o=typeof t=="string"?t:t.value??"";return o==="SIGNUP_FLOW"?"User Self-Registration":o==="ADMIN_CREATION_FLOW"?"Create User via Admin Portal":o==="SHEDULAR"?"Scheduler":typeof t!="string"&&t.label?t.label:o.replace(/[_-]+/g," ").replace(/\b\w/g,f=>f.toUpperCase())}const X=({data:t})=>{const{onClickAddTrigger:o}=w(),{type:f,eventType:p,sources:r,label:i,source:x,previewWorkflow:s,executionStatus:n,infoText:d="This node decides the flow trigger type and configuration."}=t??{},g=m=>{m==null||m.stopPropagation(),o()},h=Array.isArray(r)&&r.length>0,j=!!(i||x),a=f==="scheduler"?"Scheduler Trigger":f==="event"||h||j?"Event Trigger Source":"Select Trigger",c=f==="scheduler"?e.jsx("span",{children:"Scheduler to be configured"}):f==="event"||h?e.jsxs("div",{children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center",children:[e.jsx("span",{style:{fontWeight:600},children:xe(p)}),e.jsx("span",{className:"ff-ms-2 ff-text-muted",style:{fontSize:12},children:"via"})]}),e.jsx("div",{className:"ff-d-flex ff-flex-wrap ff-mt-2",style:{gap:4},children:h?r.map((m,k)=>e.jsx(T.Chip,{label:he(m),variant:"outlined",size:"small",className:"ff-text-dark"},k)):e.jsx("span",{className:"ff-text-muted",style:{fontSize:12},children:"No source selected"})})]}):j?e.jsxs("div",{className:"ff-d-flex ff-flex-wrap ff-align-items-center",style:{gap:6},children:[i&&e.jsx("span",{style:{fontWeight:600},children:i}),x&&e.jsx(T.Chip,{label:x,variant:"outlined",size:"small"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:g,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&g(m)},style:{cursor:"pointer",color:"#1e88e5"},children:"Click to select a trigger to start your workflow"}),N=n?e.jsxs(e.Fragment,{children:[n.status==="success"&&e.jsx(L.FaCheckCircle,{size:16,color:"#1DBF60",style:{marginRight:8}}),n.status==="failed"&&e.jsx(L.FaTimesCircle,{size:16,color:"#f44336",style:{marginRight:8}})]}):e.jsxs("div",{className:"ff-d-flex ff-align-items-center",children:[!s&&e.jsx("div",{role:"button",tabIndex:0,onClick:g,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&g(m)},className:"ff-me-2",style:{cursor:"pointer",color:"#212121"},"aria-label":"Edit trigger",children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx(T.Tooltip,{title:e.jsx("div",{children:d}),placement:"right",arrow:!0,children:e.jsx("span",{children:e.jsx(y.MdInfoOutline,{color:"gray",size:16})})})]});return e.jsxs("div",{style:{width:350},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #a5d6a7",borderRadius:8,background:"#fff",overflow:"hidden"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"rgba(76,175,80,0.1)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(y.MdInput,{size:16,color:"#388e3c"})}),e.jsx("span",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:a})]}),e.jsx("div",{className:"ff-d-flex ff-align-items-center",children:N})]}),e.jsx("div",{style:{background:"#f5f5f5",fontSize:12,color:"#212121",padding:"10px 6px",margin:"0 12px 12px",borderRadius:6},children:c})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0},id:"1"})]})},ee=({rail:t,cardWidth:o})=>{const f=o/2;o/2+t.indent;const p="var(--ff-edge-color, #b0bec5)";return e.jsxs("svg",{width:o+t.indent+200,height:t.height,style:{position:"absolute",left:0,top:"100%",pointerEvents:"none",overflow:"visible"},children:[e.jsx("line",{x1:f,y1:0,x2:f,y2:t.height,stroke:p,strokeWidth:1.5}),t.branches.map((r,i)=>{const x=r.y;return e.jsxs("g",{transform:`translate(0, ${x})`,children:[e.jsx("rect",{x:f-5,y:-5,width:10,height:10,fill:"#fff",stroke:p,strokeWidth:1.5,transform:`rotate(45, ${f}, 0)`}),e.jsx("text",{x:f+14,y:4,fontSize:12,fontWeight:500,fill:"var(--ff-text, #212121)",style:{fontFamily:"sans-serif"},children:r.label})]},i)})]})},te=({id:t,data:o})=>{const{onEditNode:f,onDeleteNode:p}=w(),{conditions:r=[],infoText:i="Filter conditions applied to workflow data",_branchRail:x}=o;return e.jsxs("div",{style:{width:350,position:"relative"},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #ffe082",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-mb-2 ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center",children:[e.jsx("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded",style:{width:25,height:25,background:"rgba(255,160,0,0.1)"},children:e.jsx(ae.FiFilter,{className:"ff-text-warning",size:16})}),e.jsx("span",{className:"ff-ms-2 ff-fw-medium ff-text-dark",style:{fontSize:14},children:"Filter"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:s=>{s.stopPropagation(),f(t)},onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),f(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:s=>{s.stopPropagation(),p(t)},onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})}),e.jsx(T.Tooltip,{title:i,placement:"right",arrow:!0,children:e.jsx("div",{className:"ff-ms-2",children:e.jsx(y.MdInfoOutline,{color:"gray",size:16})})})]})]}),e.jsx("div",{className:"ff-p-2 ff-mx-2 ff-mb-2 ff-rounded",style:{background:"#fafafa",fontSize:12},children:r.length===0?e.jsx("span",{className:"ff-text-muted",children:"No conditions configured"}):r.map((s,n)=>e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-mb-1",children:[e.jsx("p",{className:"ff-m-0 ff-fw-bold ff-me-1 ff-text-truncate",style:{maxWidth:100},title:s.field,children:s.field}),e.jsx("span",{className:"ff-text-muted",children:s.operator}),e.jsx("p",{className:"ff-text-dark ff-text-truncate ff-mx-1 ff-m-0",title:s.value,children:s.value}),n<r.length-1&&e.jsx("p",{className:"ff-bg-primary ff-text-white ff-fw-bold ff-ms-1 ff-px-1 ff-rounded-1 ff-m-0",children:s.logicalOperator})]},n))})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}}),x&&e.jsx(ee,{rail:x,cardWidth:350})]})},se=({id:t,data:o})=>{const{onEditNode:f,onDeleteNode:p,nodeRegistry:r,nodeBody:i="full"}=w(),{title:x="Task",descriptorType:s,groupBlocks:n,groups:d,roles:g,groupId:h,roleId:j,infoText:a=""}=o,c=s?r==null?void 0:r.forType(s):void 0,N=c==null?void 0:c.icon,m=u=>u==null?"":typeof u=="string"?u:typeof u=="object"&&"label"in u?String(u.label):String(u),k=u=>Array.isArray(u)?u.map(m).filter(Boolean):u!=null&&u!==""?[m(u)]:[],b=(n==null?void 0:n.flatMap(u=>u.groups??[]))??[...k(d),...k(g),...k(h),...k(j)],P=b.length>0;return e.jsxs("div",{style:{width:350},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b0bec5",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[N&&e.jsx("div",{style:{display:"flex",alignItems:"center"},children:N}),e.jsx("span",{className:"ff-text-dark",style:{fontSize:14,fontWeight:400},children:x})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:u=>{u.stopPropagation(),f(t)},onKeyDown:u=>{u.key==="Enter"&&(u.stopPropagation(),f(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:u=>{u.stopPropagation(),p(t)},onKeyDown:u=>{u.key==="Enter"&&(u.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})}),a&&e.jsx(T.Tooltip,{title:a,placement:"right",arrow:!0,children:e.jsx("div",{className:"ff-ms-2",children:e.jsx(y.MdInfoOutline,{color:"gray",size:16})})})]})]}),i!=="title-only"&&e.jsx("div",{className:"ff-mx-2 ff-mb-2 ff-p-2 ff-rounded",style:{background:"#fafafa",fontSize:12},children:c!=null&&c.renderNode?c.renderNode(o):P?e.jsx("div",{className:"ff-d-flex ff-flex-wrap ff-gap-1",children:b.map((u,E)=>e.jsx("span",{className:"ff-badge ff-bg-dark ff-text-white ff-py-1 ff-px-2 ff-rounded",style:{fontSize:11},title:u,children:u},E))}):e.jsx("span",{className:"ff-text-muted",children:"Not configured"})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},W=5,ne=({id:t,data:o})=>{const{onEditNode:f,onDeleteNode:p}=w(),{approvalData:r,isPreview:i=!1,_branchRail:x}=o,s=(r==null?void 0:r.policy)??{},n=s.stages??[],d=n.length,g=n.slice(0,W),h=d-W,j=s.name??s.policyName??"Untitled Policy";return e.jsxs("div",{style:{width:350,position:"relative"},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #ffe082",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-mb-2 ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded",style:{width:25,height:25,background:"rgba(251,192,45,0.2)"},children:e.jsx(y.MdCheckCircle,{style:{color:"#FBC02D"},size:16})}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:"Approval Policy"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[!i&&e.jsx("div",{role:"button",tabIndex:0,style:{cursor:"pointer"},onClick:a=>{a.stopPropagation(),f(t)},onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),f(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16,className:"ff-text-secondary"})}),!i&&e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,style:{cursor:"pointer"},onClick:a=>{a.stopPropagation(),p(t)},onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})}),e.jsx(T.Tooltip,{title:"This approval policy determines who must approve a request before the workflow continues.",arrow:!0,placement:"right",children:e.jsx("span",{className:"ff-ms-2 ff-d-inline-flex",children:e.jsx(y.MdInfoOutline,{color:"gray",size:16})})})]})]}),e.jsxs("div",{className:"ff-p-2 ff-rounded ff-mx-2 ff-mb-2",style:{background:"#FCFCFC"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-start ff-align-items-center ff-mb-2",children:[e.jsx("h6",{className:"ff-text-dark ff-mb-0 ff-text-truncate ff-flex-grow-1 ff-me-2",style:{fontSize:13,fontWeight:700},title:j,children:j}),e.jsxs("span",{className:"ff-badge ff-rounded-pill ff-px-2 ff-py-1 ff-flex-shrink-0",style:{background:"#FFF9C4",color:"#616161",fontSize:11,fontWeight:600},children:[d," Stage",d!==1?"s":""]})]}),n.length>0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[g.map((a,c)=>{var E,I,S;const N=((E=a.stageName)==null?void 0:E.trim())||`Stage ${c+1}`,m=Array.isArray(a.userIds)?a.userIds.length:0,k=((I=a.groupName)==null?void 0:I.trim())??"",b=((S=a.roleName)==null?void 0:S.trim())??"",P=m>0||k||b;let u="Not configured";return k?u=`Group: ${k}`:b?u=`Role: ${b}`:m>0&&(u=`${m} approver${m!==1?"s":""}`),e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{className:"ff-rounded-circle ff-d-flex ff-align-items-center ff-justify-content-center ff-flex-shrink-0",style:{width:28,height:28,background:"#FFF9C4",color:"#5D4037",fontSize:12,fontWeight:700},children:c+1}),e.jsxs("div",{className:"ff-flex-grow-1 ff-rounded ff-p-2 ff-d-flex ff-justify-content-between ff-align-items-center ff-border",style:{background:"#FFFDE7",borderColor:"#FEE79A"},children:[e.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#212121"},children:N}),e.jsxs("span",{className:`ff-d-flex ff-align-items-center ff-gap-1 ${P?"ff-text-dark":"ff-text-muted"}`,style:{fontSize:12},children:[e.jsx(y.MdPeople,{size:16,className:"ff-flex-shrink-0",style:{color:P?"#5D4037":"#9E9E9E"}}),u]})]})]},c)}),h>0&&e.jsxs("div",{className:"ff-text-center ff-fw-bold ff-py-2 ff-border ff-rounded",style:{fontSize:11,color:"#1976d2",borderColor:"#FEE79A",background:"#FFFDE7",borderStyle:"dashed",cursor:i?"default":"pointer"},role:i?void 0:"button",tabIndex:i?void 0:0,onClick:a=>{i||(a.stopPropagation(),f(t))},onKeyDown:a=>{i||a.key!=="Enter"||(a.stopPropagation(),f(t))},children:["+ ",h," More Stage",h>1?"s":""]})]}):e.jsx("div",{className:"ff-text-center ff-py-3 ff-rounded ff-border",style:{fontSize:12,color:"#9e9e9e",background:"#FFFDE7",borderColor:"#FEE79A",borderStyle:"dashed"},children:"No stages configured"})]})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}}),x&&e.jsx(ee,{rail:x,cardWidth:350})]})},oe=({id:t,data:o})=>{const{onEditNode:f,onDeleteNode:p}=w(),{duration:r,unit:i}=o,x=r!=null&&i,s=x?`Wait ${r} ${i}`:"Not configured";return e.jsxs("div",{style:{width:350},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b0bec5",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded",style:{width:25,height:25,background:"rgba(33,150,243,0.1)"},children:e.jsx(y.MdSchedule,{size:16,color:"#1976d2"})}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:"Delay"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:n=>{n.stopPropagation(),f(t)},onKeyDown:n=>{n.key==="Enter"&&(n.stopPropagation(),f(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:n=>{n.stopPropagation(),p(t)},onKeyDown:n=>{n.key==="Enter"&&(n.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{className:"ff-mx-2 ff-mb-2 ff-p-2 ff-rounded",style:{background:"#fafafa",fontSize:12},children:e.jsx("span",{className:x?"ff-text-dark ff-fw-medium":"ff-text-muted",children:s})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},F={email:{label:"Email",bg:"#e3f2fd",color:"#1565c0",iconType:y.MdEmail},slack:{label:"Slack",bg:"#e8f5e9",color:"#2e7d32",iconType:y.MdNotifications},teams:{label:"MS Teams",bg:"#ede7f6",color:"#4527a0",iconType:y.MdNotifications},sms:{label:"SMS",bg:"#fce4ec",color:"#880e4f",iconType:y.MdSms},"in-app":{label:"In-App",bg:"#fff3e0",color:"#e65100",iconType:y.MdNotifications},webhook:{label:"Webhook",bg:"#f3e5f5",color:"#6a1b9a",iconType:y.MdWebhook}},ge={label:"Notification",bg:"rgba(156,39,176,0.1)",color:"#7b1fa2",iconType:y.MdNotifications};function ue(t){var o;switch(t.channel){case"email":return((o=t.emailTo)==null?void 0:o.join(", "))??t.recipient??null;case"slack":return t.slackChannel??null;case"teams":return t.teamsMessage?"Message configured":null;case"sms":return t.smsTo??null;case"in-app":return t.inAppRecipient??null;case"webhook":return t.webhookUrl??null;default:return t.recipient??null}}function ye(t){switch(t.channel){case"email":return t.emailSubject??t.subject??null;case"slack":{const o=t.slackMessage;return o?o.length>60?`${o.slice(0,60)}…`:o:null}case"in-app":return t.inAppTitle??null;default:return t.subject??null}}const ie=({id:t,data:o})=>{const{onEditNode:f,onDeleteNode:p}=w(),r=o,i=r.channel&&F[r.channel]?F[r.channel]:ge,x=ue(r),s=ye(r),n=!!(r.channel&&x),d=i.iconType;return e.jsxs("div",{style:{width:C.NODE_WIDTH},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b0bec5",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded",style:{width:25,height:25,background:i.bg},children:e.jsx(d,{size:16,color:i.color})}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:r.channel?`${i.label} Notification`:"Notification"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),f(t)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.stopPropagation(),f(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),p(t)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{className:"ff-mx-2 ff-mb-2 ff-p-2 ff-rounded",style:{background:"#fafafa",fontSize:12},children:n?e.jsxs("div",{className:"ff-d-flex ff-flex-column ff-gap-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("span",{className:"ff-px-2 ff-py-1 ff-rounded",style:{fontSize:10,background:i.bg,color:i.color,fontWeight:600,flexShrink:0},children:i.label}),e.jsx("span",{className:"ff-text-dark ff-text-truncate",style:{maxWidth:220},children:x})]}),s&&e.jsx("span",{className:"ff-text-muted ff-text-truncate",style:{maxWidth:280},children:s})]}):e.jsx("span",{className:"ff-text-muted",children:"Not configured"})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},R={"api-key":"API Key",hmac:"HMAC"},le=({data:t})=>{const{onClickAddTrigger:o}=w(),{label:f="Webhook Trigger",endpointUrl:p,authMethod:r,source:i}=t,x=n=>{n.stopPropagation(),o()},s=n=>{n.stopPropagation(),p&&navigator.clipboard.writeText(p).catch(()=>{})};return e.jsxs("div",{style:{width:C.NODE_WIDTH},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #90caf9",borderRadius:8,background:"#fff",overflow:"hidden"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-2",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"rgba(33,150,243,0.1)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(y.MdWebhook,{size:16,color:"#1565c0"})}),e.jsx("span",{style:{fontSize:13,fontWeight:600,color:"#212121"},children:"Webhook Trigger"})]}),e.jsx("div",{role:"button",tabIndex:0,onClick:x,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&x(n)},className:"ff-d-flex ff-align-items-center",style:{paddingRight:4,cursor:"pointer"},children:e.jsx(y.MdOutlineModeEdit,{size:16,color:"#555"})})]}),e.jsxs("div",{className:"ff-mx-2 ff-mb-2 ff-p-2 ff-rounded",style:{background:"#e3f2fd",border:"1px solid #90caf9"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-flex-wrap ff-gap-2 ff-mb-1",children:[e.jsx("span",{style:{fontSize:12,color:"#1565c0",fontWeight:600},children:f}),i&&e.jsx("span",{className:"ff-px-2 ff-py-1 ff-rounded",style:{fontSize:11,background:"#fff",border:"1px solid #90caf9",color:"#1565c0"},children:i}),r&&r!=="none"&&R[r]&&e.jsx("span",{className:"ff-px-2 ff-py-1 ff-rounded",style:{fontSize:10,background:"#1565c0",color:"#fff",fontWeight:600},children:R[r]})]}),p&&e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-1",style:{marginTop:4},children:[e.jsx("span",{style:{fontSize:10,color:"#1565c0",fontFamily:"monospace",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}),e.jsx(T.Tooltip,{title:"Copy URL",placement:"top",arrow:!0,children:e.jsx("div",{role:"button",tabIndex:0,onClick:s,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&s(n)},style:{cursor:"pointer",flexShrink:0},children:e.jsx(y.MdContentCopy,{size:12,color:"#1565c0"})})})]})]})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},re=({id:t,data:o})=>{var j;const{onEditNode:f,onDeleteNode:p,nodeRegistry:r}=w(),{method:i,url:x,descriptorType:s}=o,n=s?(j=r==null?void 0:r.forType(s))==null?void 0:j.icon:e.jsx(y.MdHttp,{size:16,color:"#546e7a"}),d=!!(i&&x),g=(i==null?void 0:i.toUpperCase())??"",h=C.HTTP_METHOD_STYLE[g]??null;return e.jsxs("div",{style:{width:C.NODE_WIDTH},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b0bec5",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:25,height:25,display:"flex",alignItems:"center",justifyContent:"center"},children:n}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:"REST API Call"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),f(t)},onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.stopPropagation(),f(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),p(t)},onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{className:"ff-mx-2 ff-mb-2 ff-p-2 ff-rounded",style:{background:"#fafafa",fontSize:12},children:d?e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[h&&e.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:4,background:h.bg,color:h.color,flexShrink:0},children:g}),e.jsx("span",{className:"ff-text-dark ff-text-truncate",style:{fontFamily:"monospace",fontSize:11},title:x,children:x})]}):e.jsx("span",{className:"ff-text-muted",children:"Not configured"})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},me={eq:"=",neq:"≠",gt:">",gte:"≥",lt:"<",lte:"≤",contains:"contains",startsWith:"starts with",endsWith:"ends with",isEmpty:"is empty",isNotEmpty:"is not empty"},je=({id:t,data:o})=>{const{onEditNode:f,onDeleteNode:p}=w(),{title:r="Condition Branch",branchConfigs:i=[],defaultBranch:x}=o,s=i.length>0;return e.jsxs("div",{style:{width:C.NODE_WIDTH},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b39ddb",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:25,height:25,borderRadius:6,background:"rgba(103,58,183,0.1)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(y.MdCallSplit,{size:16,color:"#512da8"})}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:r})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:n=>{n.stopPropagation(),f(t)},onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.stopPropagation(),f(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:n=>{n.stopPropagation(),p(t)},onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{className:"ff-mx-2 ff-mb-2 ff-p-2 ff-rounded",style:{background:"#fafafa",fontSize:12},children:s?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[i.map((n,d)=>{var a,c;const g=C.BRANCH_PALETTE[d%C.BRANCH_PALETTE.length],h=(a=n.conditions)==null?void 0:a[0],j=(((c=n.conditions)==null?void 0:c.length)??0)-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:10,background:g.bg,color:g.color,flexShrink:0},children:n.label||n.key}),h?e.jsxs("span",{style:{fontSize:11,color:"#616161",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[h.field," ",me[h.operator]??h.operator,h.value?` ${h.value}`:"",j>0?` +${j} more`:""]}):e.jsx("span",{style:{fontSize:11,color:"#9e9e9e"},children:"No conditions yet"})]},n.key)}),x&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:2},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:10,background:"#f5f5f5",color:"#757575",flexShrink:0},children:"Default"}),e.jsx("span",{style:{fontSize:11,color:"#9e9e9e"},children:"fallback path"})]})]}):e.jsx("span",{className:"ff-text-muted",children:"Not configured — click edit to add branches"})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},be=({id:t,data:o})=>{var a;const{onEditNode:f,onDeleteNode:p,nodeRegistry:r}=w(),{title:i="Sub-Workflow",workflowId:x,workflowLabel:s,descriptorType:n,onPreview:d}=o,g=n?(a=r==null?void 0:r.forType(n))==null?void 0:a.icon:e.jsx(y.MdAccountTree,{size:16,color:"#00695c"}),h=!!x,j=c=>{c.stopPropagation(),x&&d&&d(x)};return e.jsxs("div",{style:{width:C.NODE_WIDTH},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #80cbc4",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:25,height:25,borderRadius:6,background:"rgba(0,137,123,0.1)",display:"flex",alignItems:"center",justifyContent:"center"},children:g}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:i})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:c=>{c.stopPropagation(),f(t)},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.stopPropagation(),f(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:c=>{c.stopPropagation(),p(t)},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{className:"ff-mx-2 ff-mb-2 ff-p-2 ff-rounded",style:{background:h?"#e0f2f1":"#fafafa",fontSize:12,border:h?"1px solid #b2dfdb":"none"},children:h?e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-between",children:[e.jsxs("div",{className:"ff-d-flex ff-flex-column ff-gap-1",children:[e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#00695c"},children:s||x}),e.jsxs("span",{style:{fontSize:10,color:"#80cbc4",fontFamily:"monospace"},children:["ID: ",x]})]}),d&&e.jsxs("div",{role:"button",tabIndex:0,onClick:j,onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&j(c)},style:{cursor:"pointer",display:"flex",alignItems:"center",gap:3,fontSize:11,color:"#00897b"},children:[e.jsx(y.MdOpenInNew,{size:13}),"Preview"]})]}):e.jsx("span",{className:"ff-text-muted",children:"Not configured — select a workflow"})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},Ne={startNode:Y,endNode:J,addTriggerNode:Q,addStepNode:pe,triggerNode:X,filterNode:te,actionNode:se,approvalNode:ne,delayNode:oe,notificationNode:ie,webhookTriggerNode:le,restApiNode:re,conditionBranchNode:je,subWorkflowNode:be},ke=11.5,H=2,D=6,$=40,B=20,O=4,ve=({id:t,sourceX:o,sourceY:f,targetX:p,targetY:r,sourcePosition:i,targetPosition:x,source:s,target:n,data:d})=>{const[g,h,j]=l.getStraightPath({sourceX:o,sourceY:f,targetX:p,targetY:r}),a=d==null?void 0:d.label,c=a==="Pass",N=c||a==="Fail",m=o+(p-o)/3,k=f+(r-f)/3,b=o+2*(p-o)/3,P=f+2*(r-f)/3,u=d==null?void 0:d.onAddStepClick,E=z=>{if(z.stopPropagation(),typeof u!="function")return;const fe={edgeId:t,nodeId:s,sourceNodeId:s,targetNodeId:n,position:"between",referenceNodeId:s,referenceNodeType:d==null?void 0:d.referenceNodeType,stepVisibility:d==null?void 0:d.stepVisibility};u(s,fe)},I=z=>{(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),E(z))},S=()=>e.jsxs(e.Fragment,{children:[e.jsxs("g",{className:"plus-icon-container",children:[e.jsx("circle",{r:ke,className:"edge-plus-circle"}),e.jsx("line",{x1:0,y1:-D,x2:0,y2:D,strokeWidth:H,strokeLinecap:"round",className:"plus-line"}),e.jsx("line",{x1:-D,y1:0,x2:D,y2:0,strokeWidth:H,strokeLinecap:"round",className:"plus-line"})]}),e.jsxs("g",{className:"edge-plus-tooltip",transform:"translate(18, 0)",children:[e.jsx("rect",{x:0,y:-10,width:65,height:20,rx:4,className:"tooltip-bg"}),e.jsx("path",{d:"M0 -4 L-4 0 L0 4 Z",className:"tooltip-bg"}),e.jsx("text",{x:32,y:0,textAnchor:"middle",dominantBaseline:"central",fill:"white",style:{fontSize:10,fontWeight:600,pointerEvents:"none"},children:"Add Step"})]})]}),v=u?{onClick:E,onKeyDown:I,role:"button",tabIndex:0,style:{cursor:"pointer",pointerEvents:"all"}}:{style:{cursor:"default",pointerEvents:"all"}};return e.jsxs("g",{className:"edge-with-plus-wrapper",children:[e.jsx(l.BaseEdge,{id:t,path:g}),N?e.jsxs(e.Fragment,{children:[e.jsxs("g",{transform:`translate(${m}, ${k})`,children:[e.jsx("rect",{x:-$/2,y:-B/2,width:$,height:B,rx:O,ry:O,fill:c?"#ADE6C5":"#FDBFBF"}),e.jsx("text",{textAnchor:"middle",dominantBaseline:"central",fill:c?"#1DBF60":"#C50000",style:{fontSize:12,fontWeight:500},children:a})]}),e.jsx("g",{className:"nodrag nopan edge-plus-svg",transform:`translate(${b}, ${P})`,"data-testid":"plus-node-icon",...v,children:e.jsx(S,{})})]}):e.jsx("g",{className:"nodrag nopan edge-plus-svg",transform:`translate(${h}, ${j})`,"data-testid":"plus-node-icon",...v,children:e.jsx(S,{})})]})},we=11.5,_=2,A=6,Se=({id:t,sourceX:o,sourceY:f,targetX:p,targetY:r,source:i,target:x,data:s})=>{const[n,d,g]=l.getStraightPath({sourceX:o,sourceY:f,targetX:p,targetY:r}),h=s==null?void 0:s.onAddStepClick,j=c=>{c.stopPropagation(),typeof h=="function"&&h(i,{edgeId:t,nodeId:i,sourceNodeId:i,targetNodeId:x,position:"between",referenceNodeId:i,referenceNodeType:s==null?void 0:s.referenceNodeType,stepVisibility:s==null?void 0:s.stepVisibility,filterId:s==null?void 0:s.filterId,branch:s==null?void 0:s.branch})},a=c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),j(c))};return e.jsxs("g",{className:"edge-with-plus-wrapper",children:[e.jsx(l.BaseEdge,{id:t,path:n,style:{stroke:"#b0bec5"}}),e.jsxs("g",{className:"nodrag nopan edge-plus-svg",transform:`translate(${d}, ${g})`,style:{cursor:h?"pointer":"default",pointerEvents:"all",outline:"none"},onClick:h?j:void 0,onKeyDown:h?a:void 0,role:h?"button":void 0,tabIndex:h?0:void 0,"data-testid":"plus-node-icon",children:[e.jsx("circle",{r:we,className:"edge-plus-circle"}),e.jsx("line",{x1:0,y1:-A,x2:0,y2:A,strokeWidth:_,strokeLinecap:"round",className:"plus-line"}),e.jsx("line",{x1:-A,y1:0,x2:A,y2:0,strokeWidth:_,strokeLinecap:"round",className:"plus-line"}),e.jsxs("g",{className:"edge-plus-tooltip",transform:"translate(18, 0)",children:[e.jsx("rect",{x:0,y:-10,width:65,height:20,rx:4,className:"tooltip-bg"}),e.jsx("path",{d:"M0 -4 L-4 0 L0 4 Z",className:"tooltip-bg"}),e.jsx("text",{x:32,y:0,textAnchor:"middle",dominantBaseline:"central",fill:"white",style:{fontSize:10,fontWeight:600,pointerEvents:"none"},children:"Add Step"})]})]})]})},Ee=({id:t,sourceX:o,sourceY:f,targetX:p,targetY:r})=>{const[i]=l.getStraightPath({sourceX:o,sourceY:f,targetX:p,targetY:r});return e.jsx(l.BaseEdge,{id:t,path:i,style:{stroke:"#b0bec5"}})},Pe=11.5,K=2,M=6,Te=-24,U=40,q=20,G=4,Ce=({id:t,sourceX:o,sourceY:f,targetX:p,targetY:r,source:i,target:x,data:s})=>{const[n,d,g]=l.getStraightPath({sourceX:o,sourceY:f,targetX:p,targetY:r}),h=s==null?void 0:s.label,j=h==="Pass",a=j||h==="Fail",c=s==null?void 0:s.onAddStepClick,N=(s==null?void 0:s.showPlus)!==!1&&!!c,m=b=>{b.stopPropagation(),typeof c=="function"&&c(i,{edgeId:t,nodeId:i,sourceNodeId:i,targetNodeId:x,position:"between",referenceNodeId:i,referenceNodeType:s==null?void 0:s.referenceNodeType,stepVisibility:s==null?void 0:s.stepVisibility})},k=b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),m(b))};return e.jsxs("g",{className:"edge-with-plus-wrapper",children:[e.jsx(l.BaseEdge,{id:t,path:n,style:{stroke:"#b0bec5"}}),e.jsxs("g",{className:"nodrag nopan edge-plus-svg",transform:`translate(${d}, ${g})`,style:{cursor:c?"pointer":"default",pointerEvents:"all",outline:"none"},onClick:c?m:void 0,onKeyDown:c?k:void 0,role:c?"button":void 0,tabIndex:c?0:void 0,children:[a&&e.jsxs("g",{transform:`translate(0, ${N?Te:0})`,children:[e.jsx("rect",{x:-U/2,y:-q/2,width:U,height:q,rx:G,ry:G,fill:j?"#ADE6C5":"#FDBFBF"}),e.jsx("text",{textAnchor:"middle",dominantBaseline:"central",fill:j?"#1DBF60":"#C50000",style:{fontSize:12,fontWeight:500},children:h})]}),N&&e.jsxs("g",{className:"plus-icon-container",children:[e.jsx("circle",{r:Pe,className:"edge-plus-circle"}),e.jsx("line",{x1:0,y1:-M,x2:0,y2:M,strokeWidth:K,strokeLinecap:"round",className:"plus-line"}),e.jsx("line",{x1:-M,y1:0,x2:M,y2:0,strokeWidth:K,strokeLinecap:"round",className:"plus-line"})]}),N&&e.jsxs("g",{className:"edge-plus-tooltip",transform:"translate(22, 0)",children:[e.jsx("rect",{x:0,y:-10,width:65,height:20,rx:4,className:"tooltip-bg"}),e.jsx("path",{d:"M0 -4 L-4 0 L0 4 Z",className:"tooltip-bg"}),e.jsx("text",{x:32,y:0,textAnchor:"middle",dominantBaseline:"central",fill:"white",style:{fontSize:10,fontWeight:600,pointerEvents:"none"},children:"Add Step"})]})]})]})},Ie=({id:t,source:o,target:f,sourceX:p,sourceY:r,targetX:i,targetY:x,style:s={},markerEnd:n,data:d})=>{const g=(d==null?void 0:d.verticalRouting)??!1,h=30,j=g?(()=>{const v=x-h;return`M ${p},${v} L ${i},${v} L ${i},${x}`})():(()=>{const v=r+30;return`M ${p},${r} L ${p},${v} L ${i},${v} L ${i},${x}`})(),a=s.stroke||"#d1d5db",c=d==null?void 0:d.label,N=(d==null?void 0:d.isFirst)??!1,m=d==null?void 0:d.onAddStepClick,k=g?x-h:r+30,b=p+(i-p)*(g?.25:.35),P=p+(i-p)*(g?.65:.7),u=k,E=v=>{v.stopPropagation(),m&&m(o,{edgeId:t,nodeId:o,sourceNodeId:o,targetNodeId:f,position:"between",referenceNodeId:o,filterId:d==null?void 0:d.filterId,branch:d==null?void 0:d.branch})},I=11.5,S=6;return e.jsxs("g",{children:[e.jsx("path",{id:t,d:j,fill:"none",stroke:a,strokeWidth:1.5,markerEnd:n}),c&&!g&&e.jsx("g",{transform:`translate(${b}, ${u})`,children:(()=>{const v=Math.max(44,c.length*7+20);return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:-v/2,y:-11,width:v,height:22,rx:11,fill:N?"#e8f5e9":"#ffebee",stroke:N?"#81c784":"#e57373",strokeWidth:1}),e.jsx("text",{x:0,y:4,textAnchor:"middle",fontSize:10,fontWeight:600,fill:N?"#2e7d32":"#c62828",style:{fontFamily:"sans-serif",pointerEvents:"none"},children:c})]})})()}),m&&e.jsxs("g",{transform:`translate(${P}, ${u})`,onClick:E,style:{cursor:"pointer",pointerEvents:"all"},className:"nodrag nopan edge-plus-svg",children:[e.jsx("circle",{r:I,className:"edge-plus-circle"}),e.jsx("line",{x1:0,y1:-S,x2:0,y2:S,strokeWidth:2,strokeLinecap:"round",className:"plus-line"}),e.jsx("line",{x1:-S,y1:0,x2:S,y2:0,strokeWidth:2,strokeLinecap:"round",className:"plus-line"})]})]})};exports.ActionNode=se;exports.AddTriggerNode=Q;exports.ApprovalNode=ne;exports.DelayNode=oe;exports.EdgeWithPlusLabel=ve;exports.EndNode=J;exports.FilterNode=te;exports.GatewayBranchEdge=Ie;exports.LabelPlusEdge=Ce;exports.NotificationNode=ie;exports.PlainEdge=Ee;exports.PlusEdge=Se;exports.RestApiNode=re;exports.StartNode=Y;exports.TriggerNode=X;exports.WebhookTriggerNode=le;exports.WorkflowCanvasContext=Z;exports.builtInNodeTypes=Ne;
|
package/dist/canvas.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./templateSkeletons-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./templateSkeletons-DQGmO1Yu.js"),t=require("./messages-O9Tw_XXR.js"),r=require("./bpmn-CcuE2X_Q.js"),e=require("./GatewayBranchEdge-DJql3GUT.js");exports.FlowForgeCanvas=o.FlowForgeCanvas;exports.SubWorkflowPreviewDrawer=o.SubWorkflowPreviewDrawer;exports.WorkflowCanvas=o.FlowForgeCanvas;exports.WorkflowExecutionHistory=o.WorkflowExecutionHistory;exports.WorkflowTemplateLibrary=o.WorkflowTemplateLibrary;exports.accessRequestSkeleton=o.accessRequestSkeleton;exports.offboardingSkeleton=o.offboardingSkeleton;exports.userOnboardingSkeleton=o.userOnboardingSkeleton;exports.webhookIntegrationSkeleton=o.webhookIntegrationSkeleton;exports.defaultFlowForgeMessages=t.defaultFlowForgeMessages;exports.loadWorkflowFromBpmn=r.loadWorkflowFromBpmn;exports.saveWorkflowToBpmn=r.saveWorkflowToBpmn;exports.ActionNode=e.ActionNode;exports.ApprovalNode=e.ApprovalNode;exports.EdgeWithPlusLabel=e.EdgeWithPlusLabel;exports.EndNode=e.EndNode;exports.FilterNode=e.FilterNode;exports.RestApiNode=e.RestApiNode;exports.StartNode=e.StartNode;exports.TriggerNode=e.TriggerNode;exports.WebhookTriggerNode=e.WebhookTriggerNode;exports.builtInNodeTypes=e.builtInNodeTypes;
|
package/dist/canvas.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { F as a, S as s, F as r, W as t, a as l, b as n, o as d, u as i, w as f } from "./templateSkeletons-
|
|
1
|
+
import { F as a, S as s, F as r, W as t, a as l, b as n, o as d, u as i, w as f } from "./templateSkeletons-BIQDennR.js";
|
|
2
2
|
import { d as w } from "./messages-CO299wPN.js";
|
|
3
3
|
import { l as p, s as b } from "./bpmn-CtfWDaOY.js";
|
|
4
|
-
import { A as F, b as N, E as m, c as u, F as S, R as T, S as c, T as v, W as x, e as A } from "./GatewayBranchEdge-
|
|
4
|
+
import { A as F, b as N, E as m, c as u, F as S, R as T, S as c, T as v, W as x, e as A } from "./GatewayBranchEdge-C9tybnDE.js";
|
|
5
5
|
export {
|
|
6
6
|
F as ActionNode,
|
|
7
7
|
N as ApprovalNode,
|
package/dist/defaultUi.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./GatewayBranchEdge-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./GatewayBranchEdge-DJql3GUT.js");exports.ActionNode=e.ActionNode;exports.AddTriggerNode=e.AddTriggerNode;exports.ApprovalNode=e.ApprovalNode;exports.DelayNode=e.DelayNode;exports.EdgeWithPlusLabel=e.EdgeWithPlusLabel;exports.EndNode=e.EndNode;exports.FilterNode=e.FilterNode;exports.GatewayBranchEdge=e.GatewayBranchEdge;exports.LabelPlusEdge=e.LabelPlusEdge;exports.NotificationNode=e.NotificationNode;exports.PlainEdge=e.PlainEdge;exports.PlusEdge=e.PlusEdge;exports.StartNode=e.StartNode;exports.TriggerNode=e.TriggerNode;exports.builtInNodeTypes=e.builtInNodeTypes;
|
package/dist/defaultUi.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as d, a as s, b as o, D as N, E as i, c as l, F as r, G as t, L as g, N as E, P as n, d as P, S as b, T as c, e as p } from "./GatewayBranchEdge-
|
|
1
|
+
import { A as d, a as s, b as o, D as N, E as i, c as l, F as r, G as t, L as g, N as E, P as n, d as P, S as b, T as c, e as p } from "./GatewayBranchEdge-C9tybnDE.js";
|
|
2
2
|
export {
|
|
3
3
|
d as ActionNode,
|
|
4
4
|
s as AddTriggerNode,
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-ucLEoH8L.js"),t=require("./SchemaBuilderDrawer-CP-Lqo0S.js");require("react/jsx-runtime");require("react");require("@mui/material");require("react-icons/md");const r=require("./nodeRegistry.cjs"),l=require("./templateRegistry.cjs"),i=require("./templateSkeletons-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-ucLEoH8L.js"),t=require("./SchemaBuilderDrawer-CP-Lqo0S.js");require("react/jsx-runtime");require("react");require("@mui/material");require("react-icons/md");const r=require("./nodeRegistry.cjs"),l=require("./templateRegistry.cjs"),i=require("./templateSkeletons-DQGmO1Yu.js"),d=require("./messages-O9Tw_XXR.js"),n=require("./bpmn-CcuE2X_Q.js"),o=require("./GatewayBranchEdge-DJql3GUT.js");class u{constructor(){this.channels=new Map}register(a,s){this.channels.set(a,s)}get(a){return this.channels.get(a)}list(){return Array.from(this.channels.entries()).map(([a,s])=>({key:a,...s}))}has(a){return this.channels.has(a)}}const c=new u;exports.DynamicFormRenderer=e.DynamicFormRenderer;exports.FF=e.FF;exports.FlowForm=e.FlowForm;exports.FormulaInput=e.FormulaInput;exports.InfiniteSelectField=e.InfiniteSelectField;exports.VariablePicker=e.VariablePicker;exports.VariablePickerProvider=e.VariablePickerProvider;exports.astHasRefs=e.astHasRefs;exports.astToTokens=e.astToTokens;exports.buildEvaluationPayload=e.buildEvaluationPayload;exports.buildFieldConfig=e.buildFieldConfig;exports.buildFormulaPath=e.buildFormulaPath;exports.buildSelectStyles=e.buildSelectStyles;exports.errorTextStyle=e.errorTextStyle;exports.extractLabel=e.extractLabel;exports.fieldRegistry=e.fieldRegistry;exports.hasFormulaTokens=e.hasFormulaTokens;exports.helperTextStyle=e.helperTextStyle;exports.inputStyle=e.inputStyle;exports.isFormula=e.isFormula;exports.parseToAST=e.parseToAST;exports.serializeAST=e.serializeAST;exports.serializeASTAsConfig=e.serializeASTAsConfig;exports.serializeConditionExpressions=e.serializeConditionExpressions;exports.stripFormulaTokens=e.stripFormulaTokens;exports.tokenize=e.tokenize;exports.unwrapFormula=e.unwrapFormula;exports.useVariablePickerContext=e.useVariablePickerContext;exports.wrapFormula=e.wrapFormula;exports.FIELD_TYPE_OPTIONS=t.FIELD_TYPE_OPTIONS;exports.FlowForgeRegistry=t.FlowForgeRegistry;exports.SchemaBuilder=t.SchemaBuilder;exports.SchemaBuilderDrawer=t.SchemaBuilderDrawer;exports.TablePickerField=t.TablePickerField;exports.buildValidationSchema=t.buildValidationSchema;exports.dataSourceRegistry=t.dataSourceRegistry;exports.useFlowForm=t.useFlowForm;exports.NodeTypeRegistry=r.NodeTypeRegistry;exports.baseNodeDefaults=r.baseNodeDefaults;exports.conditionBranchDescriptor=r.conditionBranchDescriptor;exports.defineNode=r.defineNode;exports.endEventDescriptor=r.endEventDescriptor;exports.makeSubWorkflowDescriptor=r.makeSubWorkflowDescriptor;exports.nodeTypeRegistry=r.nodeTypeRegistry;exports.notificationDescriptor=r.notificationDescriptor;exports.restApiDescriptor=r.restApiDescriptor;exports.startEventDescriptor=r.startEventDescriptor;exports.subWorkflowDescriptor=r.subWorkflowDescriptor;exports.webhookTriggerDescriptor=r.webhookTriggerDescriptor;exports.webhookTriggerTemplate=r.webhookTriggerTemplate;exports.TemplateRegistry=l.TemplateRegistry;exports.templateRegistry=l.templateRegistry;exports.FlowForgeCanvas=i.FlowForgeCanvas;exports.SubWorkflowPreviewDrawer=i.SubWorkflowPreviewDrawer;exports.WorkflowCanvas=i.FlowForgeCanvas;exports.WorkflowExecutionHistory=i.WorkflowExecutionHistory;exports.WorkflowTemplateLibrary=i.WorkflowTemplateLibrary;exports.accessRequestSkeleton=i.accessRequestSkeleton;exports.offboardingSkeleton=i.offboardingSkeleton;exports.userOnboardingSkeleton=i.userOnboardingSkeleton;exports.webhookIntegrationSkeleton=i.webhookIntegrationSkeleton;exports.defaultFlowForgeMessages=d.defaultFlowForgeMessages;exports.loadWorkflowFromBpmn=n.loadWorkflowFromBpmn;exports.saveWorkflowToBpmn=n.saveWorkflowToBpmn;exports.ActionNode=o.ActionNode;exports.ApprovalNode=o.ApprovalNode;exports.EdgeWithPlusLabel=o.EdgeWithPlusLabel;exports.EndNode=o.EndNode;exports.FilterNode=o.FilterNode;exports.RestApiNode=o.RestApiNode;exports.StartNode=o.StartNode;exports.TriggerNode=o.TriggerNode;exports.WebhookTriggerNode=o.WebhookTriggerNode;exports.builtInNodeTypes=o.builtInNodeTypes;exports.notificationChannelRegistry=c;
|
package/dist/index.js
CHANGED
|
@@ -6,10 +6,10 @@ import "@mui/material";
|
|
|
6
6
|
import "react-icons/md";
|
|
7
7
|
import { NodeTypeRegistry as U, baseNodeDefaults as X, conditionBranchDescriptor as Z, defineNode as $, endEventDescriptor as ee, makeSubWorkflowDescriptor as ae, nodeTypeRegistry as se, notificationDescriptor as re, restApiDescriptor as oe, startEventDescriptor as te, subWorkflowDescriptor as ie, webhookTriggerDescriptor as le, webhookTriggerTemplate as ne } from "./nodeRegistry.js";
|
|
8
8
|
import { TemplateRegistry as de, templateRegistry as ce } from "./templateRegistry.js";
|
|
9
|
-
import { F as me, S as fe, F as ge, W as Fe, a as be, b as he, o as ke, u as Te, w as we } from "./templateSkeletons-
|
|
9
|
+
import { F as me, S as fe, F as ge, W as Fe, a as be, b as he, o as ke, u as Te, w as we } from "./templateSkeletons-BIQDennR.js";
|
|
10
10
|
import { d as ye } from "./messages-CO299wPN.js";
|
|
11
11
|
import { l as De, s as Ne } from "./bpmn-CtfWDaOY.js";
|
|
12
|
-
import { A as We, b as Pe, E as ve, c as Ae, F as Ee, R as Ce, S as Ie, T as Be, W as Ve, e as ze } from "./GatewayBranchEdge-
|
|
12
|
+
import { A as We, b as Pe, E as ve, c as Ae, F as Ee, R as Ce, S as Ie, T as Be, W as Ve, e as ze } from "./GatewayBranchEdge-C9tybnDE.js";
|
|
13
13
|
class s {
|
|
14
14
|
constructor() {
|
|
15
15
|
this.channels = /* @__PURE__ */ new Map();
|
|
@@ -2,7 +2,7 @@ import { jsxs as m, jsx as f, Fragment as Lt } from "react/jsx-runtime";
|
|
|
2
2
|
import P, { useRef as pt, useEffect as ie, useState as j, useMemo as W, useCallback as Y } from "react";
|
|
3
3
|
import _r, { useStore as Tr, useReactFlow as Nr, Background as Cr, Controls as Sr, MiniMap as Ir } from "reactflow";
|
|
4
4
|
import "reactflow/dist/style.css";
|
|
5
|
-
import { e as Or, G as Mr, E as jr, P as Fr, L as zr, d as Rr, f as Dr } from "./GatewayBranchEdge-
|
|
5
|
+
import { e as Or, G as Mr, E as jr, P as Fr, L as zr, d as Rr, f as Dr } from "./GatewayBranchEdge-C9tybnDE.js";
|
|
6
6
|
import { Dialog as Lr, Box as te, Drawer as Ar, Typography as Pr, IconButton as bt, Button as yt } from "@mui/material";
|
|
7
7
|
import { MdClose as Br, MdCalendarToday as Wr, MdBolt as Gr, MdArrowBack as $r, MdChevronRight as At, MdAddCircleOutline as Yr, MdApps as Kr, MdErrorOutline as Ur, MdAccountTree as Vr, MdAdd as Hr, MdSearch as qr, MdCategory as Xr, MdCancel as Pt, MdError as Bt, MdCheckCircle as Wt, MdPlayArrow as Gt, MdHourglassEmpty as Jr, MdSchedule as mt, MdPerson as Zr, MdExpandLess as Qr, MdExpandMore as en } from "react-icons/md";
|
|
8
8
|
import { GrTrigger as tn } from "react-icons/gr";
|
|
@@ -1659,7 +1659,7 @@ const Fi = (e) => {
|
|
|
1659
1659
|
}, Se = ({ isOpen: e, onClose: t, title: r, icon: n, children: o, footer: i, width: s = 600 }) => {
|
|
1660
1660
|
const [l, d] = j(!1), a = () => d((h) => !h), c = () => /* @__PURE__ */ m(te, { sx: { display: "flex", alignItems: "center", p: 2, pt: 3, borderBottom: "1px solid #e0e0e0", mb: 0, flexShrink: 0 }, children: [
|
|
1661
1661
|
n && /* @__PURE__ */ f(te, { sx: { mr: 1.5, display: "flex", alignItems: "center", fontSize: "1.25rem", color: "#1DBF60" }, children: n }),
|
|
1662
|
-
/* @__PURE__ */ f(Pr, { variant: "h6", component: "div", sx: { flexGrow: 1, fontSize: "0.875rem", fontWeight:
|
|
1662
|
+
/* @__PURE__ */ f(Pr, { variant: "h6", component: "div", sx: { flexGrow: 1, fontSize: "0.875rem", fontWeight: 500 }, children: r }),
|
|
1663
1663
|
/* @__PURE__ */ f(bt, { onClick: a, size: "small", sx: { mr: 1 }, title: l ? "Collapse" : "Expand", "data-testid": "expand-collapse-base-drawer-btn", children: l ? /* @__PURE__ */ f(rn, {}) : /* @__PURE__ */ f(nn, {}) }),
|
|
1664
1664
|
/* @__PURE__ */ f(bt, { onClick: t, size: "small", "data-testid": "close-drawer-button", children: /* @__PURE__ */ f(Br, {}) })
|
|
1665
1665
|
] }), u = () => i ? /* @__PURE__ */ f(te, { sx: { flexShrink: 0, p: 2, borderTop: "1px solid #e0e0e0", display: "flex", justifyContent: "flex-end", gap: 2 }, children: i }) : null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const u=require("react/jsx-runtime"),b=require("react"),ae=require("reactflow");require("reactflow/dist/style.css");const te=require("./GatewayBranchEdge-C-gffuVA.js"),P=require("@mui/material"),I=require("react-icons/md"),gr=require("react-icons/gr"),gt=require("react-icons/bi"),pr=require("./index-ucLEoH8L.js"),br=require("./messages-O9Tw_XXR.js"),$=require("./canvasTokens-gKNYrPl4.js");var Mt=Object.defineProperty,yr=(e,t,r)=>t in e?Mt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,mr=(e,t)=>{for(var r in t)Mt(e,r,{get:t[r],enumerable:!0})},xr=(e,t,r)=>yr(e,t+"",r),Rt={};mr(Rt,{Graph:()=>W,alg:()=>qe,json:()=>Lt,version:()=>Er});var wr=Object.defineProperty,Ft=(e,t)=>{for(var r in t)wr(e,r,{get:t[r],enumerable:!0})},W=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(r=>{t!==void 0?this.setNode(r,t):this.setNode(r)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=r=>this.removeEdge(this._edgeObjs[r]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(r=>{this.setParent(r)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let r=t;r!==void 0;r=this.parent(r))if(r===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let r=new Set(t);for(let n of this.successors(e))r.add(n);return Array.from(r.values())}}isLeaf(e){let t;return this.isDirected()?t=this.successors(e):t=this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([o,i])=>{e(o)&&t.setNode(o,i)}),Object.values(this._edgeObjs).forEach(o=>{t.hasNode(o.v)&&t.hasNode(o.w)&&t.setEdge(o,this.edge(o))});let r={},n=o=>{let i=this.parent(o);return!i||t.hasNode(i)?(r[o]=i??void 0,i??void 0):i in r?r[i]:n(i)};return this._isCompound&&t.nodes().forEach(o=>t.setParent(o,n(o))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((r,n)=>(t!==void 0?this.setEdge(r,n,t):this.setEdge(r,n),n)),this}setEdge(e,t,r,n){let o,i,s,l,d=!1;typeof e=="object"&&e!==null&&"v"in e?(o=e.v,i=e.w,s=e.name,arguments.length===2&&(l=t,d=!0)):(o=e,i=t,s=n,arguments.length>2&&(l=r,d=!0)),o=""+o,i=""+i,s!==void 0&&(s=""+s);let a=fe(this._isDirected,o,i,s);if(a in this._edgeLabels)return d&&(this._edgeLabels[a]=l),this;if(s!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(o),this.setNode(i),this._edgeLabels[a]=d?l:this._defaultEdgeLabelFn(o,i,s);let c=vr(this._isDirected,o,i,s);return o=c.v,i=c.w,Object.freeze(c),this._edgeObjs[a]=c,pt(this._preds[i],o),pt(this._sucs[o],i),this._in[i][a]=c,this._out[o][a]=c,this._edgeCount++,this}edge(e,t,r){let n=arguments.length===1?Ie(this._isDirected,e):fe(this._isDirected,e,t,r);return this._edgeLabels[n]}edgeAsObj(e,t,r){let n=arguments.length===1?this.edge(e):this.edge(e,t,r);return typeof n!="object"?{label:n}:n}hasEdge(e,t,r){return(arguments.length===1?Ie(this._isDirected,e):fe(this._isDirected,e,t,r))in this._edgeLabels}removeEdge(e,t,r){let n=arguments.length===1?Ie(this._isDirected,e):fe(this._isDirected,e,t,r),o=this._edgeObjs[n];if(o){let i=o.v,s=o.w;delete this._edgeLabels[n],delete this._edgeObjs[n],bt(this._preds[s],i),bt(this._sucs[i],s),delete this._in[s][n],delete this._out[i][n],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,r){if(!e)return;let n=Object.values(e);return r?n.filter(o=>o.v===t&&o.w===r||o.v===r&&o.w===t):n}};function pt(e,t){e[t]?e[t]++:e[t]=1}function bt(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function fe(e,t,r,n){let o=""+t,i=""+r;if(!e&&o>i){let s=o;o=i,i=s}return o+""+i+""+(n===void 0?"\0":n)}function vr(e,t,r,n){let o=""+t,i=""+r;if(!e&&o>i){let l=o;o=i,i=l}let s={v:o,w:i};return n&&(s.name=n),s}function Ie(e,t){return fe(e,t.v,t.w,t.name)}var Er="4.0.1",Lt={};Ft(Lt,{read:()=>_r,write:()=>kr});function kr(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:jr(e),edges:Tr(e)},r=e.graph();return r!==void 0&&(t.value=structuredClone(r)),t}function jr(e){return e.nodes().map(t=>{let r=e.node(t),n=e.parent(t),o={v:t};return r!==void 0&&(o.value=r),n!==void 0&&(o.parent=n),o})}function Tr(e){return e.edges().map(t=>{let r=e.edge(t),n={v:t.v,w:t.w};return t.name!==void 0&&(n.name=t.name),r!==void 0&&(n.value=r),n})}function _r(e){let t=new W(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(r=>{t.setNode(r.v,r.value),r.parent&&t.setParent(r.v,r.parent)}),e.edges.forEach(r=>{t.setEdge({v:r.v,w:r.w,name:r.name},r.value)}),t}var qe={};Ft(qe,{CycleException:()=>Ee,bellmanFord:()=>At,components:()=>Cr,dijkstra:()=>ve,dijkstraAll:()=>Mr,findCycles:()=>Rr,floydWarshall:()=>Lr,isAcyclic:()=>zr,postorder:()=>Pr,preorder:()=>Br,prim:()=>Wr,shortestPaths:()=>Gr,tarjan:()=>Dt,topsort:()=>Pt});var Nr=()=>1;function At(e,t,r,n){return Sr(e,String(t),r||Nr,n||function(o){return e.outEdges(o)})}function Sr(e,t,r,n){let o={},i,s=0,l=e.nodes(),d=function(f){let h=r(f);o[f.v].distance+h<o[f.w].distance&&(o[f.w]={distance:o[f.v].distance+h,predecessor:f.v},i=!0)},a=function(){l.forEach(function(f){n(f).forEach(function(h){let g=h.v===f?h.v:h.w,y=g===h.v?h.w:h.v;d({v:g,w:y})})})};l.forEach(function(f){let h=f===t?0:Number.POSITIVE_INFINITY;o[f]={distance:h,predecessor:""}});let c=l.length;for(let f=1;f<c&&(i=!1,s++,a(),!!i);f++);if(s===c-1&&(i=!1,a(),i))throw new Error("The graph contains a negative weight cycle");return o}function Cr(e){let t={},r=[],n;function o(i){i in t||(t[i]=!0,n.push(i),e.successors(i).forEach(o),e.predecessors(i).forEach(o))}return e.nodes().forEach(function(i){n=[],o(i),n.length&&r.push(n)}),r}var zt=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let r=this._keyIndices,n=String(e);if(!(n in r)){let o=this._arr,i=o.length;return r[n]=i,o.push({key:n,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let r=this._keyIndices[e];if(r===void 0)throw new Error(`Key not found: ${e}`);let n=this._arr[r].priority;if(t>n)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${n} New: ${t}`);this._arr[r].priority=t,this._decrease(r)}_heapify(e){let t=this._arr,r=2*e,n=r+1,o=e;r<t.length&&(o=t[r].priority<t[o].priority?r:o,n<t.length&&(o=t[n].priority<t[o].priority?n:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_decrease(e){let t=this._arr,r=t[e].priority,n;for(;e!==0&&(n=e>>1,!(t[n].priority<r));)this._swap(e,n),e=n}_swap(e,t){let r=this._arr,n=this._keyIndices,o=r[e],i=r[t];r[e]=i,r[t]=o,n[i.key]=e,n[o.key]=t}},Or=()=>1;function ve(e,t,r,n){let o=function(i){return e.outEdges(i)};return Ir(e,String(t),r||Or,n||o)}function Ir(e,t,r,n){let o={},i=new zt,s,l,d=function(a){let c=a.v!==s?a.v:a.w,f=o[c],h=r(a),g=l.distance+h;if(h<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+a+" Weight: "+h);g<f.distance&&(f.distance=g,f.predecessor=s,i.decrease(c,g))};for(e.nodes().forEach(function(a){let c=a===t?0:Number.POSITIVE_INFINITY;o[a]={distance:c,predecessor:""},i.add(a,c)});i.size()>0&&(s=i.removeMin(),l=o[s],l.distance!==Number.POSITIVE_INFINITY);)n(s).forEach(d);return o}function Mr(e,t,r){return e.nodes().reduce(function(n,o){return n[o]=ve(e,o,t,r),n},{})}function Dt(e){let t=0,r=[],n={},o=[];function i(s){let l=n[s]={onStack:!0,lowlink:t,index:t++};if(r.push(s),e.successors(s).forEach(function(d){d in n?n[d].onStack&&(l.lowlink=Math.min(l.lowlink,n[d].index)):(i(d),l.lowlink=Math.min(l.lowlink,n[d].lowlink))}),l.lowlink===l.index){let d=[],a;do a=r.pop(),n[a].onStack=!1,d.push(a);while(s!==a);o.push(d)}}return e.nodes().forEach(function(s){s in n||i(s)}),o}function Rr(e){return Dt(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var Fr=()=>1;function Lr(e,t,r){return Ar(e,t||Fr,r||function(n){return e.outEdges(n)})}function Ar(e,t,r){let n={},o=e.nodes();return o.forEach(function(i){n[i]={},n[i][i]={distance:0,predecessor:""},o.forEach(function(s){i!==s&&(n[i][s]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),r(i).forEach(function(s){let l=s.v===i?s.w:s.v,d=t(s);n[i][l]={distance:d,predecessor:i}})}),o.forEach(function(i){let s=n[i];o.forEach(function(l){let d=n[l];o.forEach(function(a){let c=d[i],f=s[a],h=d[a],g=c.distance+f.distance;g<h.distance&&(h.distance=g,h.predecessor=f.predecessor)})})}),n}var Ee=class extends Error{constructor(...e){super(...e)}};function Pt(e){let t={},r={},n=[];function o(i){if(i in r)throw new Ee;i in t||(r[i]=!0,t[i]=!0,e.predecessors(i).forEach(o),delete r[i],n.push(i))}if(e.sinks().forEach(o),Object.keys(t).length!==e.nodeCount())throw new Ee;return n}function zr(e){try{Pt(e)}catch(t){if(t instanceof Ee)return!1;throw t}return!0}function Dr(e,t,r,n,o){Array.isArray(t)||(t=[t]);let i=l=>{var d;return(d=e.isDirected()?e.successors(l):e.neighbors(l))!=null?d:[]},s={};return t.forEach(function(l){if(!e.hasNode(l))throw new Error("Graph does not have node: "+l);o=Bt(e,l,r==="post",s,i,n,o)}),o}function Bt(e,t,r,n,o,i,s){return t in n||(n[t]=!0,r||(s=i(s,t)),o(t).forEach(function(l){s=Bt(e,l,r,n,o,i,s)}),r&&(s=i(s,t))),s}function Wt(e,t,r){return Dr(e,t,r,function(n,o){return n.push(o),n},[])}function Pr(e,t){return Wt(e,t,"post")}function Br(e,t){return Wt(e,t,"pre")}function Wr(e,t){let r=new W,n={},o=new zt,i;function s(d){let a=d.v===i?d.w:d.v,c=o.priority(a);if(c!==void 0){let f=t(d);f<c&&(n[a]=i,o.decrease(a,f))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(d){o.add(d,Number.POSITIVE_INFINITY),r.setNode(d)}),o.decrease(e.nodes()[0],0);let l=!1;for(;o.size()>0;){if(i=o.removeMin(),i in n)r.setEdge(i,n[i]);else{if(l)throw new Error("Input graph is not connected: "+e);l=!0}e.nodeEdges(i).forEach(s)}return r}function Gr(e,t,r,n){return $r(e,t,r,n??(o=>{let i=e.outEdges(o);return i??[]}))}function $r(e,t,r,n){if(r===void 0)return ve(e,t,r,n);let o=!1,i=e.nodes();for(let s=0;s<i.length;s++){let l=n(i[s]);for(let d=0;d<l.length;d++){let a=l[d],c=a.v===i[s]?a.v:a.w,f=c===a.v?a.w:a.v;r({v:c,w:f})<0&&(o=!0)}if(o)return At(e,t,r,n)}return ve(e,t,r,n)}function ce(e,t,r,n){let o=n;for(;e.hasNode(o);)o=Ke(n);return r.dummy=t,e.setNode(o,r),o}function Yr(e){let t=new W().setGraph(e.graph());return e.nodes().forEach(r=>t.setNode(r,e.node(r))),e.edges().forEach(r=>{let n=t.edge(r.v,r.w)||{weight:0,minlen:1},o=e.edge(r);t.setEdge(r.v,r.w,{weight:n.weight+o.weight,minlen:Math.max(n.minlen,o.minlen)})}),t}function Gt(e){let t=new W({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(r=>{e.children(r).length||t.setNode(r,e.node(r))}),e.edges().forEach(r=>{t.setEdge(r,e.edge(r))}),t}function yt(e,t){let r=e.x,n=e.y,o=t.x-r,i=t.y-n,s=e.width/2,l=e.height/2;if(!o&&!i)throw new Error("Not possible to find intersection inside of the rectangle");let d,a;return Math.abs(i)*s>Math.abs(o)*l?(i<0&&(l=-l),d=l*o/i,a=l):(o<0&&(s=-s),d=s,a=s*i/o),{x:r+d,y:n+a}}function pe(e){let t=he(Yt(e)+1).map(()=>[]);return e.nodes().forEach(r=>{let n=e.node(r),o=n.rank;o!==void 0&&(t[o]||(t[o]=[]),t[o][n.order]=r)}),t}function Ur(e){let t=e.nodes().map(n=>{let o=e.node(n).rank;return o===void 0?Number.MAX_VALUE:o}),r=Y(Math.min,t);e.nodes().forEach(n=>{let o=e.node(n);Object.hasOwn(o,"rank")&&(o.rank-=r)})}function qr(e){let t=e.nodes().map(s=>e.node(s).rank).filter(s=>s!==void 0),r=Y(Math.min,t),n=[];e.nodes().forEach(s=>{let l=e.node(s).rank-r;n[l]||(n[l]=[]),n[l].push(s)});let o=0,i=e.graph().nodeRankFactor;Array.from(n).forEach((s,l)=>{s===void 0&&l%i!==0?--o:s!==void 0&&o&&s.forEach(d=>e.node(d).rank+=o)})}function mt(e,t,r,n){let o={width:0,height:0};return arguments.length>=4&&(o.rank=r,o.order=n),ce(e,"border",o,t)}function Kr(e,t=$t){let r=[];for(let n=0;n<e.length;n+=t){let o=e.slice(n,n+t);r.push(o)}return r}var $t=65535;function Y(e,t){if(t.length>$t){let r=Kr(t);return e(...r.map(n=>e(...n)))}else return e(...t)}function Yt(e){let t=e.nodes().map(r=>{let n=e.node(r).rank;return n===void 0?Number.MIN_VALUE:n});return Y(Math.max,t)}function Xr(e,t){let r={lhs:[],rhs:[]};return e.forEach(n=>{t(n)?r.lhs.push(n):r.rhs.push(n)}),r}function Ut(e,t){let r=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-r)+"ms")}}function qt(e,t){return t()}var Vr=0;function Ke(e){let t=++Vr;return e+(""+t)}function he(e,t,r=1){t==null&&(t=e,e=0);let n=i=>i<t;r<0&&(n=i=>t<i);let o=[];for(let i=e;n(i);i+=r)o.push(i);return o}function ke(e,t){let r={};for(let n of t)e[n]!==void 0&&(r[n]=e[n]);return r}function je(e,t){let r;return typeof t=="string"?r=n=>n[t]:r=t,Object.entries(e).reduce((n,[o,i])=>(n[o]=r(i,o),n),{})}function Hr(e,t){return e.reduce((r,n,o)=>(r[n]=t[o],r),{})}var Te="\0",Jr="3.0.0",Zr=class{constructor(){xr(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return xt(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&xt(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,r=t._prev;for(;r!==t;)e.push(JSON.stringify(r,Qr)),r=r._prev;return"["+e.join(", ")+"]"}};function xt(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Qr(e,t){if(e!=="_next"&&e!=="_prev")return t}var en=Zr,tn=()=>1;function rn(e,t){if(e.nodeCount()<=1)return[];let r=on(e,t||tn);return nn(r.graph,r.buckets,r.zeroIdx).flatMap(n=>e.outEdges(n.v,n.w)||[])}function nn(e,t,r){var n;let o=[],i=t[t.length-1],s=t[0],l;for(;e.nodeCount();){for(;l=s.dequeue();)Me(e,t,r,l);for(;l=i.dequeue();)Me(e,t,r,l);if(e.nodeCount()){for(let d=t.length-2;d>0;--d)if(l=(n=t[d])==null?void 0:n.dequeue(),l){o=o.concat(Me(e,t,r,l,!0)||[]);break}}}return o}function Me(e,t,r,n,o){let i=[],s=o?i:void 0;return(e.inEdges(n.v)||[]).forEach(l=>{let d=e.edge(l),a=e.node(l.v);o&&i.push({v:l.v,w:l.w}),a.out-=d,Be(t,r,a)}),(e.outEdges(n.v)||[]).forEach(l=>{let d=e.edge(l),a=l.w,c=e.node(a);c.in-=d,Be(t,r,c)}),e.removeNode(n.v),s}function on(e,t){let r=new W,n=0,o=0;e.nodes().forEach(l=>{r.setNode(l,{v:l,in:0,out:0})}),e.edges().forEach(l=>{let d=r.edge(l.v,l.w)||0,a=t(l),c=d+a;r.setEdge(l.v,l.w,c);let f=r.node(l.v),h=r.node(l.w);o=Math.max(o,f.out+=a),n=Math.max(n,h.in+=a)});let i=sn(o+n+3).map(()=>new en),s=n+1;return r.nodes().forEach(l=>{Be(i,s,r.node(l))}),{graph:r,buckets:i,zeroIdx:s}}function Be(e,t,r){var n,o,i;r.out?r.in?(i=e[r.out-r.in+t])==null||i.enqueue(r):(o=e[e.length-1])==null||o.enqueue(r):(n=e[0])==null||n.enqueue(r)}function sn(e){let t=[];for(let r=0;r<e;r++)t.push(r);return t}function ln(e){(e.graph().acyclicer==="greedy"?rn(e,t(e)):an(e)).forEach(r=>{let n=e.edge(r);e.removeEdge(r),n.forwardName=r.name,n.reversed=!0,e.setEdge(r.w,r.v,n,Ke("rev"))});function t(r){return n=>r.edge(n).weight}}function an(e){let t=[],r={},n={};function o(i){Object.hasOwn(n,i)||(n[i]=!0,r[i]=!0,e.outEdges(i).forEach(s=>{Object.hasOwn(r,s.w)?t.push(s):o(s.w)}),delete r[i])}return e.nodes().forEach(o),t}function dn(e){e.edges().forEach(t=>{let r=e.edge(t);if(r.reversed){e.removeEdge(t);let n=r.forwardName;delete r.reversed,delete r.forwardName,e.setEdge(t.w,t.v,r,n)}})}function cn(e){e.graph().dummyChains=[],e.edges().forEach(t=>un(e,t))}function un(e,t){let r=t.v,n=e.node(r).rank,o=t.w,i=e.node(o).rank,s=t.name,l=e.edge(t),d=l.labelRank;if(i===n+1)return;e.removeEdge(t);let a,c,f;for(f=0,++n;n<i;++f,++n)l.points=[],c={width:0,height:0,edgeLabel:l,edgeObj:t,rank:n},a=ce(e,"edge",c,"_d"),n===d&&(c.width=l.width,c.height=l.height,c.dummy="edge-label",c.labelpos=l.labelpos),e.setEdge(r,a,{weight:l.weight},s),f===0&&e.graph().dummyChains.push(a),r=a;e.setEdge(r,o,{weight:l.weight},s)}function fn(e){e.graph().dummyChains.forEach(t=>{let r=e.node(t),n=r.edgeLabel,o;for(e.setEdge(r.edgeObj,n);r.dummy;)o=e.successors(t)[0],e.removeNode(t),n.points.push({x:r.x,y:r.y}),r.dummy==="edge-label"&&(n.x=r.x,n.y=r.y,n.width=r.width,n.height=r.height),t=o,r=e.node(t)})}function Xe(e){let t={};function r(n){let o=e.node(n);if(Object.hasOwn(t,n))return o.rank;t[n]=!0;let i=e.outEdges(n),s=i?i.map(d=>d==null?Number.POSITIVE_INFINITY:r(d.w)-e.edge(d).minlen):[],l=Y(Math.min,s);return l===Number.POSITIVE_INFINITY&&(l=0),o.rank=l}e.sources().forEach(r)}function de(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Kt=hn;function hn(e){let t=new W({directed:!1}),r=e.nodes();if(r.length===0)throw new Error("Graph must have at least one node");let n=r[0],o=e.nodeCount();t.setNode(n,{});let i,s;for(;gn(t,e)<o&&(i=pn(t,e),!!i);)s=t.hasNode(i.v)?de(e,i):-de(e,i),bn(t,e,s);return t}function gn(e,t){function r(n){let o=t.nodeEdges(n);o&&o.forEach(i=>{let s=i.v,l=n===s?i.w:s;!e.hasNode(l)&&!de(t,i)&&(e.setNode(l,{}),e.setEdge(n,l,{}),r(l))})}return e.nodes().forEach(r),e.nodeCount()}function pn(e,t){return t.edges().reduce((r,n)=>{let o=Number.POSITIVE_INFINITY;return e.hasNode(n.v)!==e.hasNode(n.w)&&(o=de(t,n)),o<r[0]?[o,n]:r},[Number.POSITIVE_INFINITY,null])[1]}function bn(e,t,r){e.nodes().forEach(n=>t.node(n).rank+=r)}var{preorder:yn,postorder:mn}=qe,xn=ne;ne.initLowLimValues=He;ne.initCutValues=Ve;ne.calcCutValue=Xt;ne.leaveEdge=Ht;ne.enterEdge=Jt;ne.exchangeEdges=Zt;function ne(e){e=Yr(e),Xe(e);let t=Kt(e);He(t),Ve(t,e);let r,n;for(;r=Ht(t);)n=Jt(t,e,r),Zt(t,e,r,n)}function Ve(e,t){let r=mn(e,e.nodes());r=r.slice(0,r.length-1),r.forEach(n=>wn(e,t,n))}function wn(e,t,r){let n=e.node(r).parent,o=e.edge(r,n);o.cutvalue=Xt(e,t,r)}function Xt(e,t,r){let n=e.node(r).parent,o=!0,i=t.edge(r,n),s=0;i||(o=!1,i=t.edge(n,r)),s=i.weight;let l=t.nodeEdges(r);return l&&l.forEach(d=>{let a=d.v===r,c=a?d.w:d.v;if(c!==n){let f=a===o,h=t.edge(d).weight;if(s+=f?h:-h,En(e,r,c)){let g=e.edge(r,c).cutvalue;s+=f?-g:g}}}),s}function He(e,t){arguments.length<2&&(t=e.nodes()[0]),Vt(e,{},1,t)}function Vt(e,t,r,n,o){let i=r,s=e.node(n);t[n]=!0;let l=e.neighbors(n);return l&&l.forEach(d=>{Object.hasOwn(t,d)||(r=Vt(e,t,r,d,n))}),s.low=i,s.lim=r++,o?s.parent=o:delete s.parent,r}function Ht(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Jt(e,t,r){let n=r.v,o=r.w;t.hasEdge(n,o)||(n=r.w,o=r.v);let i=e.node(n),s=e.node(o),l=i,d=!1;return i.lim>s.lim&&(l=s,d=!0),t.edges().filter(a=>d===wt(e,e.node(a.v),l)&&d!==wt(e,e.node(a.w),l)).reduce((a,c)=>de(t,c)<de(t,a)?c:a)}function Zt(e,t,r,n){let o=r.v,i=r.w;e.removeEdge(o,i),e.setEdge(n.v,n.w,{}),He(e),Ve(e,t),vn(e,t)}function vn(e,t){let r=e.nodes().find(o=>!e.node(o).parent);if(!r)return;let n=yn(e,[r]);n=n.slice(1),n.forEach(o=>{let i=e.node(o).parent,s=t.edge(o,i),l=!1;s||(s=t.edge(i,o),l=!0),t.node(o).rank=t.node(i).rank+(l?s.minlen:-s.minlen)})}function En(e,t,r){return e.hasEdge(t,r)}function wt(e,t,r){return r.low<=t.lim&&t.lim<=r.lim}var kn=jn;function jn(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":vt(e);break;case"tight-tree":_n(e);break;case"longest-path":Tn(e);break;case"none":break;default:vt(e)}}var Tn=Xe;function _n(e){Xe(e),Kt(e)}function vt(e){xn(e)}var Nn=Sn;function Sn(e){let t=On(e);e.graph().dummyChains.forEach(r=>{let n=e.node(r),o=n.edgeObj,i=Cn(e,t,o.v,o.w),s=i.path,l=i.lca,d=0,a=s[d],c=!0;for(;r!==o.w;){if(n=e.node(r),c){for(;(a=s[d])!==l&&e.node(a).maxRank<n.rank;)d++;a===l&&(c=!1)}if(!c){for(;d<s.length-1&&e.node(s[d+1]).minRank<=n.rank;)d++;a=s[d]}a!==void 0&&e.setParent(r,a),r=e.successors(r)[0]}})}function Cn(e,t,r,n){let o=[],i=[],s=Math.min(t[r].low,t[n].low),l=Math.max(t[r].lim,t[n].lim),d;d=r;do d=e.parent(d),o.push(d);while(d&&(t[d].low>s||l>t[d].lim));let a=d,c=n;for(;(c=e.parent(c))!==a;)i.push(c);return{path:o.concat(i.reverse()),lca:a}}function On(e){let t={},r=0;function n(o){let i=r;e.children(o).forEach(n),t[o]={low:i,lim:r++}}return e.children(Te).forEach(n),t}function In(e){let t=ce(e,"root",{},"_root"),r=Mn(e),n=Object.values(r),o=Y(Math.max,n)-1,i=2*o+1;e.graph().nestingRoot=t,e.edges().forEach(l=>e.edge(l).minlen*=i);let s=Rn(e)+1;e.children(Te).forEach(l=>Qt(e,t,i,s,o,r,l)),e.graph().nodeRankFactor=i}function Qt(e,t,r,n,o,i,s){var l;let d=e.children(s);if(!d.length){s!==t&&e.setEdge(t,s,{weight:0,minlen:r});return}let a=mt(e,"_bt"),c=mt(e,"_bb"),f=e.node(s);e.setParent(a,s),f.borderTop=a,e.setParent(c,s),f.borderBottom=c,d.forEach(h=>{var g;Qt(e,t,r,n,o,i,h);let y=e.node(h),m=y.borderTop?y.borderTop:h,p=y.borderBottom?y.borderBottom:h,w=y.borderTop?n:2*n,_=m!==p?1:o-((g=i[s])!=null?g:0)+1;e.setEdge(a,m,{weight:w,minlen:_,nestingEdge:!0}),e.setEdge(p,c,{weight:w,minlen:_,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,a,{weight:0,minlen:o+((l=i[s])!=null?l:0)})}function Mn(e){let t={};function r(n,o){let i=e.children(n);i&&i.length&&i.forEach(s=>r(s,o+1)),t[n]=o}return e.children(Te).forEach(n=>r(n,1)),t}function Rn(e){return e.edges().reduce((t,r)=>t+e.edge(r).weight,0)}function Fn(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(r=>{e.edge(r).nestingEdge&&e.removeEdge(r)})}var Ln=An;function An(e){function t(r){let n=e.children(r),o=e.node(r);if(n.length&&n.forEach(t),Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let i=o.minRank,s=o.maxRank+1;i<s;++i)Et(e,"borderLeft","_bl",r,o,i),Et(e,"borderRight","_br",r,o,i)}}e.children(Te).forEach(t)}function Et(e,t,r,n,o,i){let s={width:0,height:0,rank:i,borderType:t},l=o[t][i-1],d=ce(e,"border",s,r);o[t][i]=d,e.setParent(d,n),l&&e.setEdge(l,d,{weight:1})}function zn(e){var t;let r=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(r==="lr"||r==="rl")&&er(e)}function Dn(e){var t;let r=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(r==="bt"||r==="rl")&&Pn(e),(r==="lr"||r==="rl")&&(Bn(e),er(e))}function er(e){e.nodes().forEach(t=>kt(e.node(t))),e.edges().forEach(t=>kt(e.edge(t)))}function kt(e){let t=e.width;e.width=e.height,e.height=t}function Pn(e){e.nodes().forEach(t=>Re(e.node(t))),e.edges().forEach(t=>{var r;let n=e.edge(t);(r=n.points)==null||r.forEach(Re),Object.hasOwn(n,"y")&&Re(n)})}function Re(e){e.y=-e.y}function Bn(e){e.nodes().forEach(t=>Fe(e.node(t))),e.edges().forEach(t=>{var r;let n=e.edge(t);(r=n.points)==null||r.forEach(Fe),Object.hasOwn(n,"x")&&Fe(n)})}function Fe(e){let t=e.x;e.x=e.y,e.y=t}function Wn(e){let t={},r=e.nodes().filter(l=>!e.children(l).length),n=r.map(l=>e.node(l).rank),o=Y(Math.max,n),i=he(o+1).map(()=>[]);function s(l){if(t[l])return;t[l]=!0;let d=e.node(l);i[d.rank].push(l);let a=e.successors(l);a&&a.forEach(s)}return r.sort((l,d)=>e.node(l).rank-e.node(d).rank).forEach(s),i}function Gn(e,t){let r=0;for(let n=1;n<t.length;++n)r+=$n(e,t[n-1],t[n]);return r}function $n(e,t,r){let n=Hr(r,r.map((a,c)=>c)),o=t.flatMap(a=>{let c=e.outEdges(a);return c?c.map(f=>({pos:n[f.w],weight:e.edge(f).weight})).sort((f,h)=>f.pos-h.pos):[]}),i=1;for(;i<r.length;)i<<=1;let s=2*i-1;i-=1;let l=new Array(s).fill(0),d=0;return o.forEach(a=>{let c=a.pos+i;l[c]+=a.weight;let f=0;for(;c>0;)c%2&&(f+=l[c+1]),c=c-1>>1,l[c]+=a.weight;d+=a.weight*f}),d}function Yn(e,t=[]){return t.map(r=>{let n=e.inEdges(r);if(!n||!n.length)return{v:r};{let o=n.reduce((i,s)=>{let l=e.edge(s),d=e.node(s.v);return{sum:i.sum+l.weight*d.order,weight:i.weight+l.weight}},{sum:0,weight:0});return{v:r,barycenter:o.sum/o.weight,weight:o.weight}}})}function Un(e,t){let r={};e.forEach((o,i)=>{let s={indegree:0,in:[],out:[],vs:[o.v],i};o.barycenter!==void 0&&(s.barycenter=o.barycenter,s.weight=o.weight),r[o.v]=s}),t.edges().forEach(o=>{let i=r[o.v],s=r[o.w];i!==void 0&&s!==void 0&&(s.indegree++,i.out.push(s))});let n=Object.values(r).filter(o=>!o.indegree);return qn(n)}function qn(e){let t=[];function r(o){return i=>{i.merged||(i.barycenter===void 0||o.barycenter===void 0||i.barycenter>=o.barycenter)&&Kn(o,i)}}function n(o){return i=>{i.in.push(o),--i.indegree===0&&e.push(i)}}for(;e.length;){let o=e.pop();t.push(o),o.in.reverse().forEach(r(o)),o.out.forEach(n(o))}return t.filter(o=>!o.merged).map(o=>ke(o,["vs","i","barycenter","weight"]))}function Kn(e,t){let r=0,n=0;e.weight&&(r+=e.barycenter*e.weight,n+=e.weight),t.weight&&(r+=t.barycenter*t.weight,n+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=r/n,e.weight=n,e.i=Math.min(t.i,e.i),t.merged=!0}function Xn(e,t){let r=Xr(e,c=>Object.hasOwn(c,"barycenter")),n=r.lhs,o=r.rhs.sort((c,f)=>f.i-c.i),i=[],s=0,l=0,d=0;n.sort(Vn(!!t)),d=jt(i,o,d),n.forEach(c=>{d+=c.vs.length,i.push(c.vs),s+=c.barycenter*c.weight,l+=c.weight,d=jt(i,o,d)});let a={vs:i.flat(1)};return l&&(a.barycenter=s/l,a.weight=l),a}function jt(e,t,r){let n;for(;t.length&&(n=t[t.length-1]).i<=r;)t.pop(),e.push(n.vs),r++;return r}function Vn(e){return(t,r)=>t.barycenter<r.barycenter?-1:t.barycenter>r.barycenter?1:e?r.i-t.i:t.i-r.i}function tr(e,t,r,n){let o=e.children(t),i=e.node(t),s=i?i.borderLeft:void 0,l=i?i.borderRight:void 0,d={};s&&(o=o.filter(h=>h!==s&&h!==l));let a=Yn(e,o);a.forEach(h=>{if(e.children(h.v).length){let g=tr(e,h.v,r,n);d[h.v]=g,Object.hasOwn(g,"barycenter")&&Jn(h,g)}});let c=Un(a,r);Hn(c,d);let f=Xn(c,n);if(s&&l){f.vs=[s,f.vs,l].flat(1);let h=e.predecessors(s);if(h&&h.length){let g=e.node(h[0]),y=e.predecessors(l),m=e.node(y[0]);Object.hasOwn(f,"barycenter")||(f.barycenter=0,f.weight=0),f.barycenter=(f.barycenter*f.weight+g.order+m.order)/(f.weight+2),f.weight+=2}}return f}function Hn(e,t){e.forEach(r=>{r.vs=r.vs.flatMap(n=>t[n]?t[n].vs:n)})}function Jn(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function Zn(e,t,r,n){n||(n=e.nodes());let o=Qn(e),i=new W({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(s=>e.node(s));return n.forEach(s=>{let l=e.node(s),d=e.parent(s);if(l.rank===t||l.minRank<=t&&t<=l.maxRank){i.setNode(s),i.setParent(s,d||o);let a=e[r](s);a&&a.forEach(c=>{let f=c.v===s?c.w:c.v,h=i.edge(f,s),g=h!==void 0?h.weight:0;i.setEdge(f,s,{weight:e.edge(c).weight+g})}),Object.hasOwn(l,"minRank")&&i.setNode(s,{borderLeft:l.borderLeft[t],borderRight:l.borderRight[t]})}}),i}function Qn(e){let t;for(;e.hasNode(t=Ke("_root")););return t}function eo(e,t,r){let n={},o;r.forEach(i=>{let s=e.parent(i),l,d;for(;s;){if(l=e.parent(s),l?(d=n[l],n[l]=s):(d=o,o=s),d&&d!==s){t.setEdge(d,s);return}s=l}})}function rr(e,t={}){if(typeof t.customOrder=="function"){t.customOrder(e,rr);return}let r=Yt(e),n=Tt(e,he(1,r+1),"inEdges"),o=Tt(e,he(r-1,-1,-1),"outEdges"),i=Wn(e);if(_t(e,i),t.disableOptimalOrderHeuristic)return;let s=Number.POSITIVE_INFINITY,l,d=t.constraints||[];for(let a=0,c=0;c<4;++a,++c){to(a%2?n:o,a%4>=2,d),i=pe(e);let f=Gn(e,i);f<s?(c=0,l=Object.assign({},i),s=f):f===s&&(l=structuredClone(i))}_t(e,l)}function Tt(e,t,r){let n=new Map,o=(i,s)=>{n.has(i)||n.set(i,[]),n.get(i).push(s)};for(let i of e.nodes()){let s=e.node(i);if(typeof s.rank=="number"&&o(s.rank,i),typeof s.minRank=="number"&&typeof s.maxRank=="number")for(let l=s.minRank;l<=s.maxRank;l++)l!==s.rank&&o(l,i)}return t.map(function(i){return Zn(e,i,r,n.get(i)||[])})}function to(e,t,r){let n=new W;e.forEach(function(o){r.forEach(l=>n.setEdge(l.left,l.right));let i=o.graph().root,s=tr(o,i,n,t);s.vs.forEach((l,d)=>o.node(l).order=d),eo(o,n,s.vs)})}function _t(e,t){Object.values(t).forEach(r=>r.forEach((n,o)=>e.node(n).order=o))}function ro(e,t){let r={};function n(o,i){let s=0,l=0,d=o.length,a=i[i.length-1];return i.forEach((c,f)=>{let h=oo(e,c),g=h?e.node(h).order:d;(h||c===a)&&(i.slice(l,f+1).forEach(y=>{let m=e.predecessors(y);m&&m.forEach(p=>{let w=e.node(p),_=w.order;(_<s||g<_)&&!(w.dummy&&e.node(y).dummy)&&nr(r,p,y)})}),l=f+1,s=g)}),i}return t.length&&t.reduce(n),r}function no(e,t){let r={};function n(i,s,l,d,a){he(s,l).forEach(c=>{let f=i[c];if(f!==void 0&&e.node(f).dummy){let h=e.predecessors(f);h&&h.forEach(g=>{if(g===void 0)return;let y=e.node(g);y.dummy&&(y.order<d||y.order>a)&&nr(r,g,f)})}})}function o(i,s){let l=-1,d=-1,a=0;return s.forEach((c,f)=>{if(e.node(c).dummy==="border"){let h=e.predecessors(c);if(h&&h.length){let g=h[0];if(g===void 0)return;d=e.node(g).order,n(s,a,f,l,d),a=f,l=d}}n(s,a,s.length,d,i.length)}),s}return t.length&&t.reduce(o),r}function oo(e,t){if(e.node(t).dummy){let r=e.predecessors(t);if(r)return r.find(n=>e.node(n).dummy)}}function nr(e,t,r){if(t>r){let o=t;t=r,r=o}let n=e[t];n||(e[t]=n={}),n[r]=!0}function io(e,t,r){if(t>r){let o=t;t=r,r=o}let n=e[t];return n!==void 0&&Object.hasOwn(n,r)}function so(e,t,r,n){let o={},i={},s={};return t.forEach(l=>{l.forEach((d,a)=>{o[d]=d,i[d]=d,s[d]=a})}),t.forEach(l=>{let d=-1;l.forEach(a=>{let c=n(a);if(c&&c.length){let f=c.sort((g,y)=>{let m=s[g],p=s[y];return(m!==void 0?m:0)-(p!==void 0?p:0)}),h=(f.length-1)/2;for(let g=Math.floor(h),y=Math.ceil(h);g<=y;++g){let m=f[g];if(m===void 0)continue;let p=s[m];if(p!==void 0&&i[a]===a&&d<p&&!io(r,a,m)){let w=o[m];w!==void 0&&(i[m]=a,i[a]=o[a]=w,d=p)}}}})}),{root:o,align:i}}function lo(e,t,r,n,o=!1){let i={},s=ao(e,t,r,o),l=o?"borderLeft":"borderRight";function d(g,y){let m=s.nodes().slice(),p={},w=m.pop();for(;w;){if(p[w])g(w);else{p[w]=!0,m.push(w);for(let _ of y(w))m.push(_)}w=m.pop()}}function a(g){let y=s.inEdges(g);y?i[g]=y.reduce((m,p)=>{var w;let _=(w=i[p.v])!=null?w:0,O=s.edge(p);return Math.max(m,_+(O!==void 0?O:0))},0):i[g]=0}function c(g){let y=s.outEdges(g),m=Number.POSITIVE_INFINITY;y&&(m=y.reduce((w,_)=>{let O=i[_.w],M=s.edge(_);return Math.min(w,(O!==void 0?O:0)-(M!==void 0?M:0))},Number.POSITIVE_INFINITY));let p=e.node(g);m!==Number.POSITIVE_INFINITY&&p.borderType!==l&&(i[g]=Math.max(i[g]!==void 0?i[g]:0,m))}function f(g){return s.predecessors(g)||[]}function h(g){return s.successors(g)||[]}return d(a,f),d(c,h),Object.keys(n).forEach(g=>{var y;let m=r[g];m!==void 0&&(i[g]=(y=i[m])!=null?y:0)}),i}function ao(e,t,r,n){let o=new W,i=e.graph(),s=go(i.nodesep,i.edgesep,n);return t.forEach(l=>{let d;l.forEach(a=>{let c=r[a];if(c!==void 0){if(o.setNode(c),d!==void 0){let f=r[d];if(f!==void 0){let h=o.edge(f,c);o.setEdge(f,c,Math.max(s(e,a,d),h||0))}}d=a}})}),o}function co(e,t){return Object.values(t).reduce((r,n)=>{let o=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(n).forEach(([l,d])=>{let a=po(e,l)/2;o=Math.max(d+a,o),i=Math.min(d-a,i)});let s=o-i;return s<r[0]&&(r=[s,n]),r},[Number.POSITIVE_INFINITY,null])[1]}function uo(e,t){let r=Object.values(t),n=Y(Math.min,r),o=Y(Math.max,r);["u","d"].forEach(i=>{["l","r"].forEach(s=>{let l=i+s,d=e[l];if(!d||d===t)return;let a=Object.values(d),c=n-Y(Math.min,a);s!=="l"&&(c=o-Y(Math.max,a)),c&&(e[l]=je(d,f=>f+c))})})}function fo(e,t=void 0){let r=e.ul;return r?je(r,(n,o)=>{var i,s;if(t){let d=t.toLowerCase(),a=e[d];if(a&&a[o]!==void 0)return a[o]}let l=Object.values(e).map(d=>{let a=d[o];return a!==void 0?a:0}).sort((d,a)=>d-a);return(((i=l[1])!=null?i:0)+((s=l[2])!=null?s:0))/2}):{}}function ho(e){let t=pe(e),r=Object.assign(ro(e,t),no(e,t)),n={},o;["u","d"].forEach(s=>{o=s==="u"?t:Object.values(t).reverse(),["l","r"].forEach(l=>{l==="r"&&(o=o.map(c=>Object.values(c).reverse()));let d=so(e,o,r,c=>(s==="u"?e.predecessors(c):e.successors(c))||[]),a=lo(e,o,d.root,d.align,l==="r");l==="r"&&(a=je(a,c=>-c)),n[s+l]=a})});let i=co(e,n);return uo(n,i),fo(n,e.graph().align)}function go(e,t,r){return(n,o,i)=>{let s=n.node(o),l=n.node(i),d=0,a;if(d+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":a=-s.width/2;break;case"r":a=s.width/2;break}if(a&&(d+=r?a:-a),a=void 0,d+=(s.dummy?t:e)/2,d+=(l.dummy?t:e)/2,d+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":a=l.width/2;break;case"r":a=-l.width/2;break}return a&&(d+=r?a:-a),d}}function po(e,t){return e.node(t).width}function bo(e){e=Gt(e),yo(e),Object.entries(ho(e)).forEach(([t,r])=>e.node(t).x=r)}function yo(e){let t=pe(e),r=e.graph(),n=r.ranksep,o=r.rankalign,i=0;t.forEach(s=>{let l=s.reduce((d,a)=>{var c;let f=(c=e.node(a).height)!=null?c:0;return d>f?d:f},0);s.forEach(d=>{let a=e.node(d);o==="top"?a.y=i+a.height/2:o==="bottom"?a.y=i+l-a.height/2:a.y=i+l/2}),i+=l+n})}function mo(e,t={}){let r=t.debugTiming?Ut:qt;return r("layout",()=>{let n=r(" buildLayoutGraph",()=>So(e));return r(" runLayout",()=>xo(n,r,t)),r(" updateInputGraph",()=>wo(e,n)),n})}function xo(e,t,r){t(" makeSpaceForEdgeLabels",()=>Co(e)),t(" removeSelfEdges",()=>Do(e)),t(" acyclic",()=>ln(e)),t(" nestingGraph.run",()=>In(e)),t(" rank",()=>kn(Gt(e))),t(" injectEdgeLabelProxies",()=>Oo(e)),t(" removeEmptyRanks",()=>qr(e)),t(" nestingGraph.cleanup",()=>Fn(e)),t(" normalizeRanks",()=>Ur(e)),t(" assignRankMinMax",()=>Io(e)),t(" removeEdgeLabelProxies",()=>Mo(e)),t(" normalize.run",()=>cn(e)),t(" parentDummyChains",()=>Nn(e)),t(" addBorderSegments",()=>Ln(e)),t(" order",()=>rr(e,r)),t(" insertSelfEdges",()=>Po(e)),t(" adjustCoordinateSystem",()=>zn(e)),t(" position",()=>bo(e)),t(" positionSelfEdges",()=>Bo(e)),t(" removeBorderNodes",()=>zo(e)),t(" normalize.undo",()=>fn(e)),t(" fixupEdgeLabelCoords",()=>Lo(e)),t(" undoCoordinateSystem",()=>Dn(e)),t(" translateGraph",()=>Ro(e)),t(" assignNodeIntersects",()=>Fo(e)),t(" reversePoints",()=>Ao(e)),t(" acyclic.undo",()=>dn(e))}function wo(e,t){e.nodes().forEach(r=>{let n=e.node(r),o=t.node(r);n&&(n.x=o.x,n.y=o.y,n.order=o.order,n.rank=o.rank,t.children(r).length&&(n.width=o.width,n.height=o.height))}),e.edges().forEach(r=>{let n=e.edge(r),o=t.edge(r);n.points=o.points,Object.hasOwn(o,"x")&&(n.x=o.x,n.y=o.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var vo=["nodesep","edgesep","ranksep","marginx","marginy"],Eo={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},ko=["acyclicer","ranker","rankdir","align","rankalign"],jo=["width","height","rank"],Nt={width:0,height:0},To=["minlen","weight","width","height","labeloffset"],_o={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},No=["labelpos"];function So(e){let t=new W({multigraph:!0,compound:!0}),r=Ae(e.graph());return t.setGraph(Object.assign({},Eo,Le(r,vo),ke(r,ko))),e.nodes().forEach(n=>{let o=Ae(e.node(n)),i=Le(o,jo);Object.keys(Nt).forEach(l=>{i[l]===void 0&&(i[l]=Nt[l])}),t.setNode(n,i);let s=e.parent(n);s!==void 0&&t.setParent(n,s)}),e.edges().forEach(n=>{let o=Ae(e.edge(n));t.setEdge(n,Object.assign({},_o,Le(o,To),ke(o,No)))}),t}function Co(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(r=>{let n=e.edge(r);n.minlen*=2,n.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?n.width+=n.labeloffset:n.height+=n.labeloffset)})}function Oo(e){e.edges().forEach(t=>{let r=e.edge(t);if(r.width&&r.height){let n=e.node(t.v),o={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};ce(e,"edge-proxy",o,"_ep")}})}function Io(e){let t=0;e.nodes().forEach(r=>{let n=e.node(r);n.borderTop&&(n.minRank=e.node(n.borderTop).rank,n.maxRank=e.node(n.borderBottom).rank,t=Math.max(t,n.maxRank))}),e.graph().maxRank=t}function Mo(e){e.nodes().forEach(t=>{let r=e.node(t);if(r.dummy==="edge-proxy"){let n=r;e.edge(n.e).labelRank=r.rank,e.removeNode(t)}})}function Ro(e){let t=Number.POSITIVE_INFINITY,r=0,n=Number.POSITIVE_INFINITY,o=0,i=e.graph(),s=i.marginx||0,l=i.marginy||0;function d(a){let c=a.x,f=a.y,h=a.width,g=a.height;t=Math.min(t,c-h/2),r=Math.max(r,c+h/2),n=Math.min(n,f-g/2),o=Math.max(o,f+g/2)}e.nodes().forEach(a=>d(e.node(a))),e.edges().forEach(a=>{let c=e.edge(a);Object.hasOwn(c,"x")&&d(c)}),t-=s,n-=l,e.nodes().forEach(a=>{let c=e.node(a);c.x-=t,c.y-=n}),e.edges().forEach(a=>{let c=e.edge(a);c.points.forEach(f=>{f.x-=t,f.y-=n}),Object.hasOwn(c,"x")&&(c.x-=t),Object.hasOwn(c,"y")&&(c.y-=n)}),i.width=r-t+s,i.height=o-n+l}function Fo(e){e.edges().forEach(t=>{let r=e.edge(t),n=e.node(t.v),o=e.node(t.w),i,s;r.points?(i=r.points[0],s=r.points[r.points.length-1]):(r.points=[],i=o,s=n),r.points.unshift(yt(n,i)),r.points.push(yt(o,s))})}function Lo(e){e.edges().forEach(t=>{let r=e.edge(t);if(Object.hasOwn(r,"x"))switch((r.labelpos==="l"||r.labelpos==="r")&&(r.width-=r.labeloffset),r.labelpos){case"l":r.x-=r.width/2+r.labeloffset;break;case"r":r.x+=r.width/2+r.labeloffset;break}})}function Ao(e){e.edges().forEach(t=>{let r=e.edge(t);r.reversed&&r.points.reverse()})}function zo(e){e.nodes().forEach(t=>{if(e.children(t).length){let r=e.node(t),n=e.node(r.borderTop),o=e.node(r.borderBottom),i=e.node(r.borderLeft[r.borderLeft.length-1]),s=e.node(r.borderRight[r.borderRight.length-1]);r.width=Math.abs(s.x-i.x),r.height=Math.abs(o.y-n.y),r.x=i.x+r.width/2,r.y=n.y+r.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function Do(e){e.edges().forEach(t=>{if(t.v===t.w){let r=e.node(t.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Po(e){pe(e).forEach(t=>{let r=0;t.forEach((n,o)=>{let i=e.node(n);i.order=o+r,(i.selfEdges||[]).forEach(s=>{ce(e,"selfedge",{width:s.label.width,height:s.label.height,rank:i.rank,order:o+ ++r,e:s.e,label:s.label},"_se")}),delete i.selfEdges})})}function Bo(e){e.nodes().forEach(t=>{let r=e.node(t);if(r.dummy==="selfedge"){let n=r,o=e.node(n.e.v),i=o.x+o.width/2,s=o.y,l=r.x-i,d=o.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:i+2*l/3,y:s-d},{x:i+5*l/6,y:s-d},{x:i+l,y:s},{x:i+5*l/6,y:s+d},{x:i+2*l/3,y:s+d}],n.label.x=r.x,n.label.y=r.y}})}function Le(e,t){return je(ke(e,t),Number)}function Ae(e){let t={};return e&&Object.entries(e).forEach(([r,n])=>{typeof r=="string"&&(r=r.toLowerCase()),t[r]=n}),t}function Wo(e){let t=pe(e),r=new W({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(n=>{r.setNode(n,{label:n}),r.setParent(n,"layer"+e.node(n).rank)}),e.edges().forEach(n=>r.setEdge(n.v,n.w,{},n.name)),t.forEach((n,o)=>{let i="layer"+o;r.setNode(i,{rank:"same"}),n.reduce((s,l)=>(r.setEdge(s,l,{style:"invis"}),l))}),r}var Go={graphlib:Rt,version:Jr,layout:mo,debug:Wo,util:{time:Ut,notime:qt}},St=Go;/*! For license information please see dagre.esm.js.LEGAL.txt */const $o=e=>{const t=[];return e.nodeInternals.forEach((r,n)=>t.push(`${n}:${r.height??0}`)),t.join(",")},Yo=({onHeightsReady:e,nodeCount:t})=>{const r=ae.useStore($o),n=b.useRef("");b.useRef(0);const{fitView:o}=ae.useReactFlow();return b.useEffect(()=>{if(!r||r===n.current)return;const i={};for(const s of r.split(",")){const[l,d]=s.split(":"),a=Number(d);l&&a>0&&(i[l]=a)}Object.keys(i).length!==0&&(n.current=r,e(i))},[r]),null},_e=({isOpen:e,onClose:t,title:r,icon:n,children:o,footer:i,width:s=600})=>{const[l,d]=b.useState(!1),a=()=>d(h=>!h),c=()=>u.jsxs(P.Box,{sx:{display:"flex",alignItems:"center",p:2,pt:3,borderBottom:"1px solid #e0e0e0",mb:0,flexShrink:0},children:[n&&u.jsx(P.Box,{sx:{mr:1.5,display:"flex",alignItems:"center",fontSize:"1.25rem",color:"#1DBF60"},children:n}),u.jsx(P.Typography,{variant:"h6",component:"div",sx:{flexGrow:1,fontSize:"0.875rem",fontWeight:600},children:r}),u.jsx(P.IconButton,{onClick:a,size:"small",sx:{mr:1},title:l?"Collapse":"Expand","data-testid":"expand-collapse-base-drawer-btn",children:l?u.jsx(gt.BiCollapse,{}):u.jsx(gt.BiExpand,{})}),u.jsx(P.IconButton,{onClick:t,size:"small","data-testid":"close-drawer-button",children:u.jsx(I.MdClose,{})})]}),f=()=>i?u.jsx(P.Box,{sx:{flexShrink:0,p:2,borderTop:"1px solid #e0e0e0",display:"flex",justifyContent:"flex-end",gap:2},children:i}):null;return l?u.jsxs(P.Dialog,{open:e,onClose:t,maxWidth:!1,fullWidth:!0,PaperProps:{sx:{display:"flex",flexDirection:"column",height:"80vh",boxShadow:24,width:"750px",maxWidth:"100%"}},children:[u.jsx(c,{}),u.jsx(P.Box,{sx:{flexGrow:1,overflowY:"auto",p:0},children:o}),u.jsx(f,{})]}):u.jsxs(P.Drawer,{anchor:"right",open:e,onClose:t,variant:"persistent",sx:{zIndex:900},ModalProps:{keepMounted:!1},PaperProps:{sx:{width:s,position:"fixed",top:"64px",height:"calc(100% - 74px)",right:"10px",borderRadius:"8px",border:"1px solid #bdbdbd",boxShadow:"none",zIndex:900,display:"flex",flexDirection:"column"}},children:[u.jsx(c,{}),u.jsx(P.Box,{sx:{flexGrow:1,overflowY:"auto",p:0},children:o}),u.jsx(f,{})]})},Uo=({open:e,templates:t,messages:r,onSelect:n,onClose:o})=>u.jsx(_e,{isOpen:e,onClose:o,title:r.addTriggerTitle,icon:u.jsx(gr.GrTrigger,{}),width:500,children:u.jsxs(P.Box,{sx:{p:2},children:[u.jsx("p",{className:"ff-text-muted ff-mb-3",style:{fontSize:13},children:r.chooseTrigger}),u.jsxs("div",{className:"ff-d-flex ff-flex-column ff-gap-2",children:[t.map(i=>u.jsxs("div",{className:"ff-p-3 ff-rounded ff-border ff-d-flex ff-align-items-start ff-gap-3",style:{cursor:"pointer",transition:"background 0.15s"},onClick:()=>n(i),role:"button",tabIndex:0,onKeyDown:s=>{s.key==="Enter"&&n(i)},onMouseEnter:s=>{s.currentTarget.style.background="#f5f5f5"},onMouseLeave:s=>{s.currentTarget.style.background=""},children:[u.jsx("div",{style:{color:i.triggerCategory==="scheduler"?"#1976d2":"#f57c00",marginTop:2,flexShrink:0},children:i.triggerCategory==="scheduler"?u.jsx(I.MdCalendarToday,{size:18}):u.jsx(I.MdBolt,{size:18})}),u.jsxs("div",{children:[u.jsx("div",{style:{fontSize:14,fontWeight:600,color:"#212121"},children:i.label}),i.description&&u.jsx("div",{style:{fontSize:12,color:"#757575",marginTop:2},children:i.description})]})]},i.triggerKey)),t.length===0&&u.jsx("p",{className:"ff-text-muted ff-text-center",style:{fontSize:13},children:r.noTriggers})]})]})}),ze={cursor:"pointer",transition:"background 0.15s"},De="ff-p-3 ff-rounded ff-border ff-d-flex ff-align-items-center ff-gap-3",qo=({open:e,availableDescriptors:t,messages:r,onSelect:n,onClose:o})=>{const{apps:i,ungrouped:s}=b.useMemo(()=>{const f=new Map,h=[];for(const g of t)if(g.app){const y=f.get(g.app.key);y?y.descriptors.push(g):f.set(g.app.key,{key:g.app.key,label:g.app.label,icon:g.app.icon,description:g.app.description,descriptors:[g]})}else h.push(g);return{apps:[...f.values()],ungrouped:h}},[t]),[l,d]=b.useState(null),a=l?i.find(f=>f.key===l)??null:null;b.useEffect(()=>{e||d(null)},[e]),b.useEffect(()=>{d(null)},[t]);const c=!a;return u.jsx(_e,{isOpen:e,onClose:o,title:c?r.addStepTitle:a.label,icon:c?u.jsx(I.MdAddCircleOutline,{}):a.icon??u.jsx(I.MdApps,{}),width:500,children:u.jsxs(P.Box,{sx:{p:2},children:[!c&&u.jsxs("div",{role:"button",tabIndex:0,onClick:()=>d(null),onKeyDown:f=>{f.key==="Enter"&&d(null)},className:"ff-d-flex ff-align-items-center ff-gap-1 ff-mb-3",style:{cursor:"pointer",color:"#0066cc",fontSize:13,fontWeight:500,width:"fit-content"},children:[u.jsx(I.MdArrowBack,{size:16}),u.jsx("span",{children:r.addStepTitle})]}),u.jsx("p",{className:"ff-text-muted ff-mb-3",style:{fontSize:13},children:c?r.chooseAction:`Pick an action from ${a.label}`}),u.jsx("div",{className:"ff-d-flex ff-flex-column ff-gap-2",children:c?u.jsxs(u.Fragment,{children:[i.map(f=>u.jsxs("div",{className:De,style:ze,onClick:()=>d(f.key),role:"button",tabIndex:0,onKeyDown:h=>{h.key==="Enter"&&d(f.key)},onMouseEnter:h=>{h.currentTarget.style.background="#f5f5f5"},onMouseLeave:h=>{h.currentTarget.style.background=""},children:[f.icon&&u.jsx("div",{style:{flexShrink:0},children:f.icon}),u.jsxs("div",{style:{flex:1,minWidth:0},children:[u.jsx("div",{style:{fontSize:14,fontWeight:600,color:"#212121"},children:f.label}),u.jsx("div",{style:{fontSize:12,color:"#757575",marginTop:2},children:f.description??`${f.descriptors.length} action${f.descriptors.length===1?"":"s"}`})]}),u.jsx(I.MdChevronRight,{size:18,color:"#9e9e9e"})]},`app-${f.key}`)),s.map(f=>u.jsxs("div",{className:De,style:ze,onClick:()=>n(f),role:"button",tabIndex:0,onKeyDown:h=>{h.key==="Enter"&&n(f)},onMouseEnter:h=>{h.currentTarget.style.background="#f5f5f5"},onMouseLeave:h=>{h.currentTarget.style.background=""},children:[f.icon&&u.jsx("div",{style:{flexShrink:0},children:f.icon}),u.jsx("span",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:f.label})]},f.type)),i.length===0&&s.length===0&&u.jsx("p",{className:"ff-text-muted ff-text-center",style:{fontSize:13},children:r.noActions})]}):a.descriptors.map(f=>u.jsxs("div",{className:De,style:ze,onClick:()=>n(f),role:"button",tabIndex:0,onKeyDown:h=>{h.key==="Enter"&&n(f)},onMouseEnter:h=>{h.currentTarget.style.background="#f5f5f5"},onMouseLeave:h=>{h.currentTarget.style.background=""},children:[f.icon&&u.jsx("div",{style:{flexShrink:0},children:f.icon}),u.jsx("span",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:f.label})]},f.type))})]})})},Ct="_conditionConfig",Ko=({open:e,nodeId:t,descriptor:r,initialValues:n,messages:o,onSave:i,onClose:s})=>{const[l,d]=b.useState([]),[a,c]=b.useState(!1),[f,h]=b.useState(null),[g,y]=b.useState({});b.useEffect(()=>{y((n==null?void 0:n[Ct])??{})},[n,t]),b.useEffect(()=>{let _=!1;if(h(null),!r||!t){d([]),c(!1);return}const O=r.formSchema;return typeof O=="function"?(c(!0),O(t).then(M=>{_||(d(M),c(!1))}).catch(M=>{_||(d([]),h(M instanceof Error?M.message:"Unable to load configuration."),c(!1))})):(d(O),c(!1)),()=>{_=!0}},[r,t]);const m=t?`node-config-form-${t}`:"node-config-form",p=!a&&!f&&l.length>0,w=p?u.jsxs(u.Fragment,{children:[u.jsx(P.Button,{type:"button",variant:"outlined",size:"small",onClick:s,children:o.cancel}),u.jsx(P.Button,{type:"submit",form:m,variant:"contained",size:"small",children:o.save})]}):null;return u.jsx(_e,{isOpen:e,onClose:s,title:(r==null?void 0:r.label)??o.configureStep,icon:r==null?void 0:r.icon,width:500,footer:w,children:u.jsxs(P.Box,{sx:{p:2},children:[a&&u.jsx("p",{className:"ff-text-muted",style:{fontSize:13},children:o.loadingConfiguration}),!a&&f&&u.jsx("p",{style:{fontSize:13,color:"#d32f2f"},children:f}),!a&&!f&&l.length===0&&u.jsx("p",{className:"ff-text-muted",style:{fontSize:13},children:o.noConfigurationNeeded}),p&&u.jsx(pr.FlowForm,{schema:{layout:"flat",fields:l},initialValues:n??{},formId:m,conditionConfig:g,onConditionConfigChange:y,onSubmit:_=>{if(!t)return;const O=Object.keys(g).length>0;i(t,{..._,[Ct]:O?g:void 0}),s()}})]})})},or=({isOpen:e,onClose:t,workflowId:r,workflowLabel:n,onFetchWorkflow:o})=>{const[i,s]=b.useState({status:"idle"});return b.useEffect(()=>{if(!e||!r){s({status:"idle"});return}s({status:"loading"}),o(r).then(l=>s({status:"loaded",state:l})).catch(l=>s({status:"error",message:(l==null?void 0:l.message)??"Failed to load workflow"}))},[e,r,o]),u.jsx(_e,{isOpen:e,onClose:t,title:n?`Preview: ${n}`:"Sub-Workflow Preview",icon:u.jsx(I.MdAccountTree,{size:18,color:"#00695c"}),width:700,children:u.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:24},children:[i.status==="idle"&&u.jsx("span",{style:{color:"#9e9e9e",fontSize:14},children:"Select a workflow to preview"}),i.status==="loading"&&u.jsxs("div",{style:{textAlign:"center",color:"#9e9e9e"},children:[u.jsx("div",{style:{width:32,height:32,borderRadius:"50%",border:"3px solid #e0e0e0",borderTopColor:"#00897b",animation:"spin 0.8s linear infinite",margin:"0 auto 12px"}}),u.jsx("span",{style:{fontSize:14},children:"Loading workflow…"}),u.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}),i.status==="error"&&u.jsxs("div",{style:{textAlign:"center",color:"#c62828"},children:[u.jsx(I.MdErrorOutline,{size:32,style:{marginBottom:8}}),u.jsx("p",{style:{margin:0,fontSize:14},children:i.message})]}),i.status==="loaded"&&u.jsx("div",{style:{width:"100%",flex:1},children:u.jsx(Xo,{state:i.state})})]})})},Xo=({state:e})=>{const[t,r]=b.useState(null),[n,o]=b.useState(null);return b.useEffect(()=>{Promise.all([Promise.resolve().then(()=>ei).then(i=>i.default),Promise.resolve().then(()=>require("./nodeRegistry.cjs")).then(i=>i.nodeTypeRegistry),Promise.resolve().then(()=>require("./templateRegistry.cjs")).then(i=>i.templateRegistry)]).then(([i,s,l])=>{r(()=>i),o({nodeTypeRegistry:s,templateRegistry:l})})},[]),!t||!n?u.jsx("div",{style:{color:"#9e9e9e",fontSize:13,textAlign:"center"},children:"Loading canvas…"}):u.jsx("div",{style:{width:"100%",height:480,border:"1px solid #e0e0e0",borderRadius:8,overflow:"hidden"},children:u.jsx(t,{nodeRegistry:n.nodeTypeRegistry,templateRegistry:n.templateRegistry,initialValue:e,readOnly:!0})})},ge=350,We=70,Ge=60,$e={startNode:40,endNode:40,addTriggerNode:56,triggerNode:110,actionNode:90,filterNode:90,approvalNode:90,delayNode:80,notificationNode:80},Vo={plusEdge:te.PlusEdge,labelPlusEdge:te.LabelPlusEdge,plainEdge:te.PlainEdge,edgeWithPlusLabel:te.EdgeWithPlusLabel,gatewayBranchEdge:te.GatewayBranchEdge};function Ot(){return[{id:"start",kind:"start",reactFlowType:"startNode"},{id:"addTrigger",kind:"addTrigger",reactFlowType:"addTriggerNode"},{id:"end",kind:"end",reactFlowType:"endNode"}]}function Ho(e,t,r,n="TB"){const o=new St.graphlib.Graph;return o.setGraph({rankdir:n,ranksep:70,nodesep:50}),o.setDefaultEdgeLabel(()=>({})),e.forEach(i=>{const s=r[i.id]??{width:ge,height:$e[i.type??""]??80};o.setNode(i.id,{width:s.width,height:s.height})}),t.forEach(i=>o.setEdge(i.source,i.target)),St.layout(o),e.map(i=>{var a,c;const s=o.node(i.id),l=((a=r[i.id])==null?void 0:a.width)??ge,d=((c=r[i.id])==null?void 0:c.height)??$e[i.type??""]??80;return{...i,position:{x:s.x-l/2,y:s.y-d/2}}})}const re=e=>e==="filter"||e==="approval";function Jo(e,t,r,n){const s=We,l=30,d=30,a={},c={},f=new Map;for(const p of e)f.set(p.id,p);for(const p of Object.values(t))for(const w of Object.values(p))for(const _ of w)f.set(_.id,_);const h=(p,w,_)=>{const O=n[p]??{width:ge,height:80};return a[p]={x:w-O.width/2,y:_},_+O.height},g=(p,w,_)=>{let O=_;for(const M of p)O=h(M.id,w,O)+s,re(M.kind)&&t[M.id]&&(O=y(M.id,w,O));return O},y=(p,w,_)=>{const O=w+180,M=t[p],R=Object.keys(M),B=f.get(p),Q=(B==null?void 0:B.branchLabels)??{pass:"Pass",fail:"Fail"},ue=a[p],F=n[p]??{height:80},be=ue.y+F.height,ye=[];let U=_;return R.forEach((oe,X)=>{const L=M[oe],V=U;ye.push({y:V-be,label:Q[oe]??oe,isPass:X===0}),U=g(L,O,U+d),X<R.length-1&&(U+=l)}),c[p]={branches:ye,height:U-be,indent:180},U};let m=Ge;for(const p of e)m=h(p.id,400,m)+s,re(p.kind)&&t[p.id]&&(m=y(p.id,400,m));return{nodes:r.map(p=>a[p.id]?{...p,position:a[p.id]}:p),railSpecs:c}}function It(e){return{id:e.id,type:e.reactFlowType,position:{x:0,y:0},data:{...e.nodeData,...e.formData,descriptorType:e.descriptorType},draggable:!1,selectable:!1}}function Zo(e,t,r,n,o){return{id:`e-${e.id}-${t.id}`,source:e.id,target:t.id,type:"plusEdge",style:{stroke:r},data:{onAddStepClick:n,referenceNodeType:e.reactFlowType,...o??{}}}}function Qo(e,t,r,n,o={},i="TB",s="horizontal"){const l=o.edgeColor??"#b0bec5",d=[],a=[],c=(y,m)=>{const p=t[y];if(!p)return;const _=m??{pass:"Pass",fail:"Fail"},O=Object.keys(p),M=(R,B,Q,ue)=>{if(R.length!==0){R.forEach(F=>d.push(It(F))),a.push({id:`e-${y}-${B}-start`,source:y,target:R[0].id,type:"gatewayBranchEdge",style:{stroke:l},data:{branch:B,filterId:y,label:Q,isFirst:ue===0,onAddStepClick:r,verticalRouting:s==="vertical"}});for(let F=1;F<R.length;F++)re(R[F-1].kind)||a.push(Zo(R[F-1],R[F],l,r,{filterId:y,branch:B}));for(const F of R)re(F.kind)&&t[F.id]&&c(F.id,F.branchLabels)}};O.forEach((R,B)=>{M(p[R],R,_[R]??R,B)})};for(let y=0;y<e.length;y++){const m=e[y];if(d.push(It(m)),y>0){const p=e[y-1],w=p.kind==="start"||p.kind==="addTrigger";if(p.kind==="filter"||p.kind==="approval")continue;a.push({id:`e-${p.id}-${m.id}`,source:p.id,target:m.id,type:w?"plainEdge":"plusEdge",style:{stroke:l},data:w?{}:{onAddStepClick:r,referenceNodeType:p.reactFlowType}})}(m.kind==="filter"||m.kind==="approval")&&t[m.id]&&c(m.id,m.branchLabels)}const f={};if(d.forEach(y=>{f[y.id]={width:ge,height:n[y.id]??$e[y.type??""]??80}}),!(Object.keys(t).length>0)){if(i==="LR"){let _=Ge;return{nodes:d.map(M=>{const R=f[M.id].width,B=f[M.id].height,Q={...M,position:{x:_,y:300-B/2}};return _+=R+We,Q}),edges:a}}const y=400;let m=Ge;return{nodes:d.map(w=>{const _=f[w.id].height,O={...w,position:{x:y-ge/2,y:m}};return m+=_+We,O}),edges:a}}if(s==="vertical"){const{nodes:y,railSpecs:m}=Jo(e,t,d,f);return{nodes:y.map(w=>m[w.id]?{...w,data:{...w.data,_branchRail:m[w.id]}}:w),edges:a}}return{nodes:Ho(d,a,f,i),edges:a}}const Ye=({nodeRegistry:e,templateRegistry:t,initialValue:r,nodeTypes:n,edgeTypes:o,onSave:i,readOnly:s=!1,theme:l={},messages:d,canvasOptions:a={},renderTriggerSelector:c,renderNodePicker:f,renderNodeConfig:h,onNodeClick:g,maxNodes:y,layoutDirection:m="TB",executionRecord:p,onFetchWorkflow:w})=>{const{fitView:_=!0,fitViewPadding:O=.3,showControls:M=!0,showMiniMap:R=!1,panOnScroll:B=!0,zoomOnScroll:Q=!1,minZoom:ue=.25,maxZoom:F=2,snapToGrid:be=!1,snapGrid:ye=[15,15],branchLayout:U="horizontal",nodeBody:oe="full"}=a,X=b.useMemo(()=>br.mergeMessages(d),[d]),[L,V]=b.useState(()=>(r==null?void 0:r.slots)??Ot()),[q,H]=b.useState(()=>(r==null?void 0:r.branches)??{}),[ie,G]=b.useState(null),[Ne,Je]=b.useState(null),[se,me]=b.useState(null),[Se,Ze]=b.useState(null),[xe,Qe]=b.useState(null),[J,et]=b.useState(()=>{const x=r==null?void 0:r.slots.find(E=>E.kind==="triggerFixed"),v=x!=null&&x.id.startsWith("trigger-")?x.id.slice(8):void 0;return v?t.lookup(v)??null:null}),[tt,sr]=b.useState({}),lr=b.useCallback(x=>{sr(x)},[]),ar=b.useMemo(()=>({...te.builtInNodeTypes,...n}),[n]),dr=b.useMemo(()=>({...Vo,...o}),[o]),cr=b.useMemo(()=>{const x=L.filter(E=>E.kind==="userTask").length,v=Object.values(q).flatMap(E=>Object.values(E).flat()).filter(E=>E.kind==="userTask").length;return x+v},[L,q]),rt=y??(J==null?void 0:J.maxTasks),nt=rt!==void 0&&cr>=rt,ee=b.useCallback(x=>{const v=L.find(E=>E.id===x);if(v)return v;for(const E of Object.values(q)){const N=Object.values(E).flat().find(k=>k.id===x);if(N)return N}return null},[L,q]),Ce=b.useCallback(x=>{s||(Je(x),G("nodeConfig"))},[s]),ot=b.useCallback(x=>{if(!s){if(L.some(v=>v.id===x)){const v=L.find(E=>E.id===x);if((v==null?void 0:v.kind)==="triggerFixed"){V(Ot()),H({}),et(null);return}V(E=>{const N=E.filter(k=>k.id!==x);return re((v==null?void 0:v.kind)??"")&&!N.some(k=>k.kind==="end")?[...N,{id:"end",kind:"end",reactFlowType:"endNode"}]:N}),H(E=>{const N={...E},k=j=>{N[j]&&(Object.values(N[j]).flat().filter(T=>re(T.kind)).forEach(T=>k(T.id)),delete N[j])};return k(x),N});return}H(v=>{const E=(k,j)=>{const T=[];for(const S of k)re(S.kind)&&j[S.id]&&(T.push(S.id),Object.values(j[S.id]).forEach(C=>T.push(...E(C,j))));return T},N={...v};for(const k of Object.keys(N))for(const j of Object.keys(N[k])){const T=N[k][j],S=T.findIndex(D=>D.id===x);if(S===-1||T[S].kind==="end")continue;const C=T[S];let A=T.filter(D=>D.id!==x);return C.kind==="filter"&&((C.id in N?E([C],N):[]).forEach(z=>delete N[z]),delete N[C.id],A.some(z=>z.kind==="end")||(A=[...A,{id:`end-${k}-${j}`,kind:"end",reactFlowType:"endNode"}])),N[k]={...N[k],[j]:A},N}return N})}},[s,L]),Oe=b.useCallback(()=>{s||G("triggerSelect")},[s]),it=b.useCallback((x,v)=>{s||nt||(me(x),Ze(v.filterId&&v.branch?{filterId:v.filterId,branch:v.branch}:null),G("nodePicker"))},[s,nt]),st=b.useCallback(x=>{et(x),G(null),H({}),V([{id:"start",kind:"start",reactFlowType:"startNode"},{id:`trigger-${x.triggerKey}`,kind:"triggerFixed",reactFlowType:"triggerNode",nodeData:{label:x.label,source:x.source},deletable:!1},{id:"end",kind:"end",reactFlowType:"endNode"}])},[]),lt=b.useCallback(()=>{const x=e.list();return(J!=null&&J.availableTasks?x.filter(E=>J.availableTasks.includes(E.type)):x).filter(E=>E.maxPerWorkflow===void 0?!0:L.filter(k=>k.descriptorType===E.type).length+Object.values(q).flatMap(k=>Object.values(k).flat()).filter(k=>k.descriptorType===E.type).length<E.maxPerWorkflow)},[e,J,L,q]),at=b.useCallback(x=>{if(!se)return;const v=`${x.type}-${Date.now()}`,E=x.reactFlowType==="filterNode"||x.reactFlowType==="approvalNode"||x.reactFlowType==="conditionBranchNode",N=x.branchLabels??{pass:"Pass",fail:"Fail"},k={id:v,kind:E?x.reactFlowType==="approvalNode"?"approval":"filter":"userTask",reactFlowType:x.reactFlowType,descriptorType:x.type,formData:{},nodeData:{title:x.label},deletable:!0,branchLabels:N};if(Se){const{filterId:j,branch:T}=Se;H(S=>{const C=[...S[j][T]];if(E){const Z=C.filter(le=>le.kind!=="end"),ht=Z.findIndex(le=>le.id===se),hr=ht===-1?Z.length:ht+1;return Z.splice(hr,0,k),{...S,[j]:{...S[j],[T]:Z},[v]:Object.fromEntries(Object.keys(N).map(le=>[le,[{id:`end-${v}-${le}`,kind:"end",reactFlowType:"endNode"}]]))}}const A=C.findIndex(Z=>Z.id===se),D=C.findIndex(Z=>Z.kind==="end"),z=A===-1?D===-1?C.length:D:A+1;return C.splice(z,0,k),{...S,[j]:{...S[j],[T]:C}}})}else E?(V(j=>{const T=j.findIndex(C=>C.id===se);return[...j.filter(C=>C.kind!=="end").slice(0,T+1),k]}),H(j=>({...j,[v]:Object.fromEntries(Object.keys(N).map(T=>[T,[{id:`end-${v}-${T}`,kind:"end",reactFlowType:"endNode"}]]))}))):V(j=>{const T=j.findIndex(S=>S.id===se);return T===-1?j:[...j.slice(0,T+1),k,...j.slice(T+1)]});me(null),Ze(null),Je(v),G("nodeConfig")},[se,Se]),dt=b.useCallback((x,v)=>{const E=k=>{const j=ee(x);if((j==null?void 0:j.descriptorType)!=="conditionBranch")return k;const T=v.branchConfigs??[],S=T.map(z=>z.key).filter(Boolean);if(S.length===0)return k;const C=k[x]??{},A={};S.forEach(z=>{A[z]=C[z]??[{id:`end-${x}-${z}`,kind:"end",reactFlowType:"endNode"}]});const D={};return T.forEach(z=>{z.key&&(D[z.key]=z.label||z.key)}),{...k,[x]:A}},N=(k,j)=>{if(k.descriptorType!=="conditionBranch")return{...k,formData:j};const T=j.branchConfigs??[],S={};return T.forEach(C=>{C.key&&(S[C.key]=C.label||C.key)}),{...k,formData:j,branchLabels:S}};if(L.some(k=>k.id===x)){H(k=>{const j=E(k);return V(T=>{const S=T.map(C=>C.id===x?N(C,v):C);return i==null||i({slots:S,branches:j}),S}),j});return}H(k=>{const T={...E(k)};for(const S of Object.keys(T)){const C=A=>A.map(D=>D.id===x?N(D,v):D);for(const A of Object.keys(T[S]))if(T[S][A].some(D=>D.id===x))return T[S]={...T[S],[A]:C(T[S][A])},i==null||i({slots:L,branches:T}),T}return T})},[L,q,ee,i]),K=b.useMemo(()=>ee(Ne??""),[ee,Ne]),ct=b.useMemo(()=>K!=null&&K.descriptorType?e.forType(K.descriptorType)??null:null,[K,e]),{nodes:ut,edges:ur}=b.useMemo(()=>Qo(L,q,s?null:it,tt,l,m,U),[L,q,s,it,tt,l,m,U]),ft=b.useMemo(()=>{const x=p?new Map(p.steps.map(v=>[v.nodeId,v])):null;return ut.map(v=>{let E={};if(x){const N=x.get(v.id);N&&(E={_executionStatus:N.status,_executionError:N.error})}return v.type==="subWorkflowNode"&&w&&(E.onPreview=N=>{var j;const k=ee(v.id);Qe({workflowId:N,workflowLabel:((j=k==null?void 0:k.formData)==null?void 0:j.workflowLabel)??void 0})}),Object.keys(E).length>0?{...v,data:{...v.data,...E}}:v})},[ut,p,w,ee]),fr=b.useMemo(()=>({onEditNode:Ce,onDeleteNode:ot,onAddStep:()=>{},onClickAddTrigger:Oe,messages:X,nodeRegistry:e,nodeBody:oe}),[Ce,ot,Oe,X,e,oe]);return u.jsx(te.WorkflowCanvasContext.Provider,{value:fr,children:u.jsxs("div",{style:{width:"100%",height:"100%",position:"relative","--ff-primary":l.primaryColor??"#1dbf60","--ff-edge-color":l.edgeColor??"#b0bec5","--ff-text":l.textColor??"#212121","--ff-muted":l.mutedTextColor??"#9ca3af","--ff-surface":l.surfaceColor??"#fff","--ff-border":l.borderColor??"#dee2e6","--ff-danger":l.dangerColor??"#d32f2f","--ff-radius":`${l.borderRadius??6}px`,"--ff-font-family":l.fontFamily},children:[u.jsxs(ae,{nodes:ft,edges:ur,nodeTypes:ar,edgeTypes:dr,fitView:_,fitViewOptions:{padding:O},nodesDraggable:!1,nodesConnectable:!1,panOnScroll:B,zoomOnScroll:Q,minZoom:ue,maxZoom:F,snapToGrid:be,snapGrid:ye,proOptions:{hideAttribution:!0},onNodeClick:(x,v)=>{const E=ee(v.id);E&&(g!=null&&g(E)||(E.kind==="addTrigger"||E.kind==="triggerFixed"?Oe():(E.kind==="userTask"||E.kind==="filter"||E.kind==="approval")&&Ce(v.id)))},children:[l.background!=="none"&&u.jsx(ae.Background,{variant:l.background,color:l.backgroundColor??"#e0e0e0",gap:20}),M&&u.jsx(ae.Controls,{showInteractive:!1}),R&&u.jsx(ae.MiniMap,{zoomable:!0,pannable:!0}),u.jsx(Yo,{onHeightsReady:lr,nodeCount:ft.length})]}),c?ie==="triggerSelect"&&c(t.list(),st,()=>G(null)):u.jsx(Uo,{open:ie==="triggerSelect",templates:t.list(),messages:X,onSelect:st,onClose:()=>G(null)}),f?ie==="nodePicker"&&f(lt(),at,()=>{G(null),me(null)}):u.jsx(qo,{open:ie==="nodePicker",availableDescriptors:lt(),messages:X,onSelect:at,onClose:()=>{G(null),me(null)}}),h?ie==="nodeConfig"&&h(ct??void 0,K,dt,()=>G(null)):u.jsx(Ko,{open:ie==="nodeConfig",nodeId:Ne,descriptor:ct,initialValues:K==null?void 0:K.formData,messages:X,onSave:dt,onClose:()=>G(null)}),w&&xe&&u.jsx(or,{isOpen:!!xe,onClose:()=>Qe(null),workflowId:xe.workflowId,workflowLabel:xe.workflowLabel,onFetchWorkflow:w})]})})},ei=Object.freeze(Object.defineProperty({__proto__:null,WorkflowCanvas:Ye,default:Ye},Symbol.toStringTag,{value:"Module"})),Pe="All";function ti({template:e,onSelect:t}){var o,i;const r=e.triggerCategory?$.TRIGGER_CATEGORY_STYLE[e.triggerCategory]:null,n=((o=e.skeletonState)==null?void 0:o.slots.filter(s=>s.kind==="userTask").length)??0;return u.jsxs("div",{role:"button",tabIndex:0,onClick:t,onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&t()},style:{border:"1.5px solid #e0e0e0",borderRadius:10,padding:"16px",background:"#fff",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s",display:"flex",flexDirection:"column",gap:8,outline:"none"},onMouseEnter:s=>{s.currentTarget.style.borderColor="#1976d2",s.currentTarget.style.boxShadow="0 2px 8px rgba(25,118,210,0.12)"},onMouseLeave:s=>{s.currentTarget.style.borderColor="#e0e0e0",s.currentTarget.style.boxShadow="none"},children:[u.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[e.icon&&u.jsx("div",{style:{flexShrink:0,width:36,height:36,borderRadius:8,background:"#f5f5f5",display:"flex",alignItems:"center",justifyContent:"center"},children:e.icon}),u.jsxs("div",{style:{flex:1,minWidth:0},children:[u.jsx("div",{style:{fontWeight:600,fontSize:14,color:"#212121",marginBottom:2},children:e.label}),e.description&&u.jsx("div",{style:{fontSize:12,color:"#757575",lineHeight:1.4,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:e.description})]})]}),u.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:4},children:[r&&u.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:10,background:r.bg,color:r.color},children:r.label}),(i=e.tags)==null?void 0:i.map(s=>u.jsx("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:10,background:"#f5f5f5",color:"#616161"},children:s},s)),n>0&&u.jsxs("span",{style:{fontSize:10,color:"#9e9e9e",marginLeft:"auto"},children:[n," step",n!==1?"s":""]})]}),e.author&&u.jsxs("div",{style:{fontSize:11,color:"#bdbdbd"},children:["by ",e.author]})]})}const ri=({templates:e,onSelectTemplate:t,onStartFromScratch:r})=>{const[n,o]=b.useState(""),[i,s]=b.useState(Pe),l=b.useMemo(()=>{const a=new Set;return e.forEach(c=>{c.category&&a.add(c.category)}),[Pe,...Array.from(a)]},[e]),d=b.useMemo(()=>{let a=e;if(i!==Pe&&(a=a.filter(c=>c.category===i)),n.trim()){const c=n.toLowerCase();a=a.filter(f=>{var h,g;return f.label.toLowerCase().includes(c)||((h=f.description)==null?void 0:h.toLowerCase().includes(c))||((g=f.tags)==null?void 0:g.some(y=>y.toLowerCase().includes(c)))})}return[...a].sort((c,f)=>(f.popularity??0)-(c.popularity??0))},[e,i,n]);return u.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:"inherit"},children:[u.jsxs("div",{style:{padding:"24px 24px 0",borderBottom:"1px solid #f0f0f0",paddingBottom:16},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16},children:[u.jsxs("div",{children:[u.jsx("h2",{style:{margin:0,fontSize:20,fontWeight:700,color:"#212121"},children:"Workflow Templates"}),u.jsx("p",{style:{margin:"4px 0 0",fontSize:13,color:"#757575"},children:"Choose a pre-built template or start from scratch"})]}),r&&u.jsxs("button",{onClick:r,style:{display:"flex",alignItems:"center",gap:6,padding:"8px 16px",border:"1.5px solid #1976d2",borderRadius:6,background:"#fff",color:"#1976d2",fontSize:13,fontWeight:600,cursor:"pointer"},children:[u.jsx(I.MdAdd,{size:16}),"Start from Scratch"]})]}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"#f5f5f5",borderRadius:8,padding:"8px 12px",marginBottom:12},children:[u.jsx(I.MdSearch,{size:18,color:"#9e9e9e"}),u.jsx("input",{value:n,onChange:a=>o(a.target.value),placeholder:"Search templates...",style:{border:"none",background:"transparent",outline:"none",fontSize:14,color:"#212121",flex:1}})]}),l.length>1&&u.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:l.map(a=>u.jsx("button",{onClick:()=>s(a),style:{padding:"4px 12px",borderRadius:20,border:"1.5px solid",borderColor:i===a?"#1976d2":"#e0e0e0",background:i===a?"#e3f2fd":"#fff",color:i===a?"#1565c0":"#616161",fontSize:12,fontWeight:i===a?600:400,cursor:"pointer"},children:a},a))})]}),u.jsx("div",{style:{flex:1,overflowY:"auto",padding:24},children:d.length===0?u.jsxs("div",{style:{textAlign:"center",padding:"40px 0",color:"#9e9e9e"},children:[u.jsx(I.MdCategory,{size:36,style:{marginBottom:8}}),u.jsx("p",{style:{margin:0,fontSize:14},children:"No templates found"})]}):u.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:16},children:d.map(a=>u.jsx(ti,{template:a,onSelect:()=>t(a)},a.triggerKey))})})]})},we={running:{label:"Running",color:$.EXECUTION_STATUS_COLOR.running,icon:b.createElement(I.MdPlayArrow,{size:14})},success:{label:"Success",color:$.EXECUTION_STATUS_COLOR.success,icon:b.createElement(I.MdCheckCircle,{size:14})},failed:{label:"Failed",color:$.EXECUTION_STATUS_COLOR.failed,icon:b.createElement(I.MdError,{size:14})},cancelled:{label:"Cancelled",color:$.EXECUTION_STATUS_COLOR.cancelled,icon:b.createElement(I.MdCancel,{size:14})}},ni={pending:{color:$.EXECUTION_STATUS_COLOR.pending,icon:b.createElement(I.MdHourglassEmpty,{size:14})},running:{color:$.EXECUTION_STATUS_COLOR.running,icon:b.createElement(I.MdPlayArrow,{size:14})},success:{color:$.EXECUTION_STATUS_COLOR.success,icon:b.createElement(I.MdCheckCircle,{size:14})},failed:{color:$.EXECUTION_STATUS_COLOR.failed,icon:b.createElement(I.MdError,{size:14})},skipped:{color:$.EXECUTION_STATUS_COLOR.skipped,icon:b.createElement(I.MdCancel,{size:14})}};function Ue(e){try{return new Date(e).toLocaleString()}catch{return e}}function ir(e,t){try{const r=new Date(t??new Date().toISOString()).getTime()-new Date(e).getTime();return r<1e3?`${r}ms`:r<6e4?`${(r/1e3).toFixed(1)}s`:`${Math.floor(r/6e4)}m ${Math.floor(r%6e4/1e3)}s`}catch{return"—"}}function oi({step:e}){const[t,r]=b.useState(!1),n=ni[e.status],o=!!(e.inputs||e.outputs||e.error);return u.jsxs("div",{style:{borderBottom:"1px solid #f5f5f5"},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",cursor:o?"pointer":"default"},onClick:()=>{o&&r(i=>!i)},role:o?"button":void 0,tabIndex:o?0:void 0,onKeyDown:i=>{o&&(i.key==="Enter"||i.key===" ")&&r(s=>!s)},children:[u.jsx("span",{style:{color:n.color,flexShrink:0},children:b.cloneElement(n.icon,{color:n.color})}),u.jsx("span",{style:{flex:1,fontSize:13,color:"#212121"},children:e.label||e.nodeId}),e.branchTaken&&u.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"#e3f2fd",color:"#1565c0",fontWeight:600},children:e.branchTaken}),u.jsx("span",{style:{fontSize:11,color:"#9e9e9e",flexShrink:0},children:e.startedAt?ir(e.startedAt,e.completedAt):"—"}),o&&u.jsx("span",{style:{color:"#9e9e9e",flexShrink:0},children:t?b.createElement(I.MdExpandLess,{size:16}):b.createElement(I.MdExpandMore,{size:16})})]}),t&&o&&u.jsxs("div",{style:{padding:"0 12px 10px 32px",fontSize:12},children:[e.error&&u.jsx("div",{style:{padding:"6px 10px",borderRadius:6,background:"#ffebee",color:"#c62828",marginBottom:6},children:e.error}),e.inputs&&Object.keys(e.inputs).length>0&&u.jsxs("details",{style:{marginBottom:4},children:[u.jsx("summary",{style:{cursor:"pointer",color:"#616161",marginBottom:4},children:"Inputs"}),u.jsx("pre",{style:{margin:0,fontSize:11,background:"#f5f5f5",padding:8,borderRadius:4,overflowX:"auto"},children:JSON.stringify(e.inputs,null,2)})]}),e.outputs&&Object.keys(e.outputs).length>0&&u.jsxs("details",{children:[u.jsx("summary",{style:{cursor:"pointer",color:"#616161",marginBottom:4},children:"Outputs"}),u.jsx("pre",{style:{margin:0,fontSize:11,background:"#f5f5f5",padding:8,borderRadius:4,overflowX:"auto"},children:JSON.stringify(e.outputs,null,2)})]})]})]})}function ii({record:e,selected:t,onSelect:r}){const n=we[e.status];return u.jsxs("div",{role:"button",tabIndex:0,onClick:r,onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&r()},style:{padding:"10px 14px",borderBottom:"1px solid #f0f0f0",cursor:"pointer",background:t?"#e3f2fd":"#fff",display:"flex",alignItems:"center",gap:10,outline:"none"},children:[u.jsx("span",{style:{color:n.color,flexShrink:0},children:b.cloneElement(n.icon,{color:n.color,size:16})}),u.jsxs("div",{style:{flex:1,minWidth:0},children:[u.jsx("div",{style:{fontSize:12,color:"#212121",fontWeight:t?600:400,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Ue(e.triggeredAt)}),u.jsxs("div",{style:{fontSize:11,color:"#9e9e9e"},children:[e.triggeredBy?`by ${e.triggeredBy}`:"System"," · ",e.steps.length," step",e.steps.length!==1?"s":""]})]}),u.jsx("span",{style:{fontSize:11,fontWeight:600,color:n.color,flexShrink:0},children:n.label}),u.jsx(I.MdChevronRight,{size:14,color:"#bdbdbd"})]})}const si=({records:e,onViewOnCanvas:t})=>{var s;const[r,n]=b.useState(((s=e[0])==null?void 0:s.id)??null),o=e.find(l=>l.id===r)??null,i=[...e].sort((l,d)=>new Date(d.triggeredAt).getTime()-new Date(l.triggeredAt).getTime());return e.length===0?u.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:300,color:"#9e9e9e",gap:8},children:[u.jsx(I.MdSchedule,{size:36}),u.jsx("p",{style:{margin:0,fontSize:14},children:"No executions yet"}),u.jsx("p",{style:{margin:0,fontSize:12},children:"Run history will appear here"})]}):u.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:"inherit",border:"1px solid #e0e0e0",borderRadius:8,overflow:"hidden"},children:[u.jsxs("div",{style:{width:260,flexShrink:0,borderRight:"1px solid #e0e0e0",overflowY:"auto",background:"#fafafa"},children:[u.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #e0e0e0",fontWeight:600,fontSize:13,color:"#212121"},children:["Run History (",e.length,")"]}),i.map(l=>u.jsx(ii,{record:l,selected:l.id===r,onSelect:()=>n(l.id)},l.id))]}),u.jsx("div",{style:{flex:1,overflowY:"auto"},children:o?u.jsxs("div",{children:[u.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid #f0f0f0",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12},children:[u.jsxs("div",{children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[b.cloneElement(we[o.status].icon,{color:we[o.status].color,size:18}),u.jsx("span",{style:{fontWeight:700,fontSize:15,color:"#212121"},children:we[o.status].label})]}),u.jsxs("div",{style:{fontSize:12,color:"#757575",display:"flex",flexDirection:"column",gap:2},children:[u.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[u.jsx(I.MdSchedule,{size:13})," ",Ue(o.triggeredAt),o.completedAt&&` → ${Ue(o.completedAt)} (${ir(o.triggeredAt,o.completedAt)})`]}),o.triggeredBy&&u.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[u.jsx(I.MdPerson,{size:13})," ",o.triggeredBy]})]})]}),t&&u.jsx("button",{onClick:()=>t(o),style:{padding:"6px 12px",border:"1.5px solid #1976d2",borderRadius:6,background:"#fff",color:"#1976d2",fontSize:12,fontWeight:600,cursor:"pointer",flexShrink:0},children:"View on Canvas"})]}),o.error&&u.jsx("div",{style:{margin:"12px 16px",padding:"10px 14px",borderRadius:6,background:"#ffebee",color:"#c62828",fontSize:13},children:o.error}),u.jsxs("div",{children:[u.jsxs("div",{style:{padding:"10px 12px",fontSize:12,fontWeight:600,color:"#757575",borderBottom:"1px solid #f0f0f0"},children:["STEPS (",o.steps.length,")"]}),o.steps.map((l,d)=>u.jsx(oi,{step:l},`${l.nodeId}-${d}`))]}),o.inputs&&Object.keys(o.inputs).length>0&&u.jsx("div",{style:{padding:"10px 16px"},children:u.jsxs("details",{children:[u.jsx("summary",{style:{cursor:"pointer",fontSize:12,fontWeight:600,color:"#757575",marginBottom:6},children:"TRIGGER INPUTS"}),u.jsx("pre",{style:{margin:0,fontSize:11,background:"#f5f5f5",padding:10,borderRadius:4,overflowX:"auto"},children:JSON.stringify(o.inputs,null,2)})]})})]}):u.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#9e9e9e",fontSize:14},children:"Select a run to see details"})})]})},li={slots:[{id:"start",kind:"start",reactFlowType:"startNode",deletable:!1},{id:"trigger-END_USER_CREATION",kind:"triggerFixed",reactFlowType:"triggerNode",deletable:!0,label:"New User Registration",nodeData:{label:"New User Registration"}},{id:"notification-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Welcome Email",nodeData:{title:"Welcome Email"}},{id:"approval-1",kind:"approval",reactFlowType:"approvalNode",descriptorType:"approval",deletable:!0,label:"Manager Approval",branchLabels:{pass:"Approved",fail:"Rejected"}},{id:"end",kind:"end",reactFlowType:"endNode",deletable:!1}],branches:{"approval-1":{pass:[{id:"notification-pass-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Approval Confirmed",nodeData:{title:"Approval Confirmed"}}],fail:[{id:"notification-fail-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Rejection Notice",nodeData:{title:"Rejection Notice"}}]}}},ai={slots:[{id:"start",kind:"start",reactFlowType:"startNode",deletable:!1},{id:"trigger-ACCESS_REQUEST",kind:"triggerFixed",reactFlowType:"triggerNode",deletable:!0,label:"Access Request Submitted",nodeData:{label:"Access Request Submitted"}},{id:"approval-1",kind:"approval",reactFlowType:"approvalNode",descriptorType:"approval",deletable:!0,label:"Access Approval",branchLabels:{pass:"Approved",fail:"Denied"}},{id:"end",kind:"end",reactFlowType:"endNode",deletable:!1}],branches:{"approval-1":{pass:[{id:"restApi-1",kind:"userTask",reactFlowType:"restApiNode",descriptorType:"restApi",deletable:!0,label:"Provision Access",nodeData:{title:"Provision Access"}},{id:"notification-pass-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Access Granted Email",nodeData:{title:"Access Granted Email"}}],fail:[{id:"notification-fail-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Access Denied Email",nodeData:{title:"Access Denied Email"}}]}}},di={slots:[{id:"start",kind:"start",reactFlowType:"startNode",deletable:!1},{id:"trigger-USER_DEACTIVATION",kind:"triggerFixed",reactFlowType:"triggerNode",deletable:!0,label:"User Deactivation",nodeData:{label:"User Deactivation"}},{id:"delay-1",kind:"userTask",reactFlowType:"delayNode",descriptorType:"delay",deletable:!0,label:"Grace Period",nodeData:{title:"Grace Period",duration:7,unit:"days"},formData:{duration:7,unit:"days"}},{id:"notification-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Notify IT Team",nodeData:{title:"Notify IT Team"}},{id:"end",kind:"end",reactFlowType:"endNode",deletable:!1}],branches:{}},ci={slots:[{id:"start",kind:"start",reactFlowType:"startNode",deletable:!1},{id:"trigger-WEBHOOK_TRIGGER",kind:"triggerFixed",reactFlowType:"webhookTriggerNode",deletable:!0,label:"Incoming Webhook",nodeData:{label:"Incoming Webhook"}},{id:"restApi-1",kind:"userTask",reactFlowType:"restApiNode",descriptorType:"restApi",deletable:!0,label:"Call External API",nodeData:{title:"Call External API"}},{id:"notification-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Notify on Completion",nodeData:{title:"Notify on Completion"}},{id:"end",kind:"end",reactFlowType:"endNode",deletable:!1}],branches:{}};exports.FlowForgeCanvas=Ye;exports.SubWorkflowPreviewDrawer=or;exports.WorkflowExecutionHistory=si;exports.WorkflowTemplateLibrary=ri;exports.accessRequestSkeleton=ai;exports.offboardingSkeleton=di;exports.userOnboardingSkeleton=li;exports.webhookIntegrationSkeleton=ci;
|
|
1
|
+
"use strict";const u=require("react/jsx-runtime"),b=require("react"),ae=require("reactflow");require("reactflow/dist/style.css");const te=require("./GatewayBranchEdge-DJql3GUT.js"),P=require("@mui/material"),I=require("react-icons/md"),gr=require("react-icons/gr"),gt=require("react-icons/bi"),pr=require("./index-ucLEoH8L.js"),br=require("./messages-O9Tw_XXR.js"),$=require("./canvasTokens-gKNYrPl4.js");var Mt=Object.defineProperty,yr=(e,t,r)=>t in e?Mt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,mr=(e,t)=>{for(var r in t)Mt(e,r,{get:t[r],enumerable:!0})},xr=(e,t,r)=>yr(e,t+"",r),Rt={};mr(Rt,{Graph:()=>W,alg:()=>qe,json:()=>Lt,version:()=>Er});var wr=Object.defineProperty,Ft=(e,t)=>{for(var r in t)wr(e,r,{get:t[r],enumerable:!0})},W=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(r=>{t!==void 0?this.setNode(r,t):this.setNode(r)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=r=>this.removeEdge(this._edgeObjs[r]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(r=>{this.setParent(r)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let r=t;r!==void 0;r=this.parent(r))if(r===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let r=new Set(t);for(let n of this.successors(e))r.add(n);return Array.from(r.values())}}isLeaf(e){let t;return this.isDirected()?t=this.successors(e):t=this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([o,i])=>{e(o)&&t.setNode(o,i)}),Object.values(this._edgeObjs).forEach(o=>{t.hasNode(o.v)&&t.hasNode(o.w)&&t.setEdge(o,this.edge(o))});let r={},n=o=>{let i=this.parent(o);return!i||t.hasNode(i)?(r[o]=i??void 0,i??void 0):i in r?r[i]:n(i)};return this._isCompound&&t.nodes().forEach(o=>t.setParent(o,n(o))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((r,n)=>(t!==void 0?this.setEdge(r,n,t):this.setEdge(r,n),n)),this}setEdge(e,t,r,n){let o,i,s,l,d=!1;typeof e=="object"&&e!==null&&"v"in e?(o=e.v,i=e.w,s=e.name,arguments.length===2&&(l=t,d=!0)):(o=e,i=t,s=n,arguments.length>2&&(l=r,d=!0)),o=""+o,i=""+i,s!==void 0&&(s=""+s);let a=fe(this._isDirected,o,i,s);if(a in this._edgeLabels)return d&&(this._edgeLabels[a]=l),this;if(s!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(o),this.setNode(i),this._edgeLabels[a]=d?l:this._defaultEdgeLabelFn(o,i,s);let c=vr(this._isDirected,o,i,s);return o=c.v,i=c.w,Object.freeze(c),this._edgeObjs[a]=c,pt(this._preds[i],o),pt(this._sucs[o],i),this._in[i][a]=c,this._out[o][a]=c,this._edgeCount++,this}edge(e,t,r){let n=arguments.length===1?Ie(this._isDirected,e):fe(this._isDirected,e,t,r);return this._edgeLabels[n]}edgeAsObj(e,t,r){let n=arguments.length===1?this.edge(e):this.edge(e,t,r);return typeof n!="object"?{label:n}:n}hasEdge(e,t,r){return(arguments.length===1?Ie(this._isDirected,e):fe(this._isDirected,e,t,r))in this._edgeLabels}removeEdge(e,t,r){let n=arguments.length===1?Ie(this._isDirected,e):fe(this._isDirected,e,t,r),o=this._edgeObjs[n];if(o){let i=o.v,s=o.w;delete this._edgeLabels[n],delete this._edgeObjs[n],bt(this._preds[s],i),bt(this._sucs[i],s),delete this._in[s][n],delete this._out[i][n],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,r){if(!e)return;let n=Object.values(e);return r?n.filter(o=>o.v===t&&o.w===r||o.v===r&&o.w===t):n}};function pt(e,t){e[t]?e[t]++:e[t]=1}function bt(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function fe(e,t,r,n){let o=""+t,i=""+r;if(!e&&o>i){let s=o;o=i,i=s}return o+""+i+""+(n===void 0?"\0":n)}function vr(e,t,r,n){let o=""+t,i=""+r;if(!e&&o>i){let l=o;o=i,i=l}let s={v:o,w:i};return n&&(s.name=n),s}function Ie(e,t){return fe(e,t.v,t.w,t.name)}var Er="4.0.1",Lt={};Ft(Lt,{read:()=>_r,write:()=>kr});function kr(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:jr(e),edges:Tr(e)},r=e.graph();return r!==void 0&&(t.value=structuredClone(r)),t}function jr(e){return e.nodes().map(t=>{let r=e.node(t),n=e.parent(t),o={v:t};return r!==void 0&&(o.value=r),n!==void 0&&(o.parent=n),o})}function Tr(e){return e.edges().map(t=>{let r=e.edge(t),n={v:t.v,w:t.w};return t.name!==void 0&&(n.name=t.name),r!==void 0&&(n.value=r),n})}function _r(e){let t=new W(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(r=>{t.setNode(r.v,r.value),r.parent&&t.setParent(r.v,r.parent)}),e.edges.forEach(r=>{t.setEdge({v:r.v,w:r.w,name:r.name},r.value)}),t}var qe={};Ft(qe,{CycleException:()=>Ee,bellmanFord:()=>At,components:()=>Cr,dijkstra:()=>ve,dijkstraAll:()=>Mr,findCycles:()=>Rr,floydWarshall:()=>Lr,isAcyclic:()=>zr,postorder:()=>Pr,preorder:()=>Br,prim:()=>Wr,shortestPaths:()=>Gr,tarjan:()=>Dt,topsort:()=>Pt});var Nr=()=>1;function At(e,t,r,n){return Sr(e,String(t),r||Nr,n||function(o){return e.outEdges(o)})}function Sr(e,t,r,n){let o={},i,s=0,l=e.nodes(),d=function(f){let h=r(f);o[f.v].distance+h<o[f.w].distance&&(o[f.w]={distance:o[f.v].distance+h,predecessor:f.v},i=!0)},a=function(){l.forEach(function(f){n(f).forEach(function(h){let g=h.v===f?h.v:h.w,y=g===h.v?h.w:h.v;d({v:g,w:y})})})};l.forEach(function(f){let h=f===t?0:Number.POSITIVE_INFINITY;o[f]={distance:h,predecessor:""}});let c=l.length;for(let f=1;f<c&&(i=!1,s++,a(),!!i);f++);if(s===c-1&&(i=!1,a(),i))throw new Error("The graph contains a negative weight cycle");return o}function Cr(e){let t={},r=[],n;function o(i){i in t||(t[i]=!0,n.push(i),e.successors(i).forEach(o),e.predecessors(i).forEach(o))}return e.nodes().forEach(function(i){n=[],o(i),n.length&&r.push(n)}),r}var zt=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let r=this._keyIndices,n=String(e);if(!(n in r)){let o=this._arr,i=o.length;return r[n]=i,o.push({key:n,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let r=this._keyIndices[e];if(r===void 0)throw new Error(`Key not found: ${e}`);let n=this._arr[r].priority;if(t>n)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${n} New: ${t}`);this._arr[r].priority=t,this._decrease(r)}_heapify(e){let t=this._arr,r=2*e,n=r+1,o=e;r<t.length&&(o=t[r].priority<t[o].priority?r:o,n<t.length&&(o=t[n].priority<t[o].priority?n:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_decrease(e){let t=this._arr,r=t[e].priority,n;for(;e!==0&&(n=e>>1,!(t[n].priority<r));)this._swap(e,n),e=n}_swap(e,t){let r=this._arr,n=this._keyIndices,o=r[e],i=r[t];r[e]=i,r[t]=o,n[i.key]=e,n[o.key]=t}},Or=()=>1;function ve(e,t,r,n){let o=function(i){return e.outEdges(i)};return Ir(e,String(t),r||Or,n||o)}function Ir(e,t,r,n){let o={},i=new zt,s,l,d=function(a){let c=a.v!==s?a.v:a.w,f=o[c],h=r(a),g=l.distance+h;if(h<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+a+" Weight: "+h);g<f.distance&&(f.distance=g,f.predecessor=s,i.decrease(c,g))};for(e.nodes().forEach(function(a){let c=a===t?0:Number.POSITIVE_INFINITY;o[a]={distance:c,predecessor:""},i.add(a,c)});i.size()>0&&(s=i.removeMin(),l=o[s],l.distance!==Number.POSITIVE_INFINITY);)n(s).forEach(d);return o}function Mr(e,t,r){return e.nodes().reduce(function(n,o){return n[o]=ve(e,o,t,r),n},{})}function Dt(e){let t=0,r=[],n={},o=[];function i(s){let l=n[s]={onStack:!0,lowlink:t,index:t++};if(r.push(s),e.successors(s).forEach(function(d){d in n?n[d].onStack&&(l.lowlink=Math.min(l.lowlink,n[d].index)):(i(d),l.lowlink=Math.min(l.lowlink,n[d].lowlink))}),l.lowlink===l.index){let d=[],a;do a=r.pop(),n[a].onStack=!1,d.push(a);while(s!==a);o.push(d)}}return e.nodes().forEach(function(s){s in n||i(s)}),o}function Rr(e){return Dt(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var Fr=()=>1;function Lr(e,t,r){return Ar(e,t||Fr,r||function(n){return e.outEdges(n)})}function Ar(e,t,r){let n={},o=e.nodes();return o.forEach(function(i){n[i]={},n[i][i]={distance:0,predecessor:""},o.forEach(function(s){i!==s&&(n[i][s]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),r(i).forEach(function(s){let l=s.v===i?s.w:s.v,d=t(s);n[i][l]={distance:d,predecessor:i}})}),o.forEach(function(i){let s=n[i];o.forEach(function(l){let d=n[l];o.forEach(function(a){let c=d[i],f=s[a],h=d[a],g=c.distance+f.distance;g<h.distance&&(h.distance=g,h.predecessor=f.predecessor)})})}),n}var Ee=class extends Error{constructor(...e){super(...e)}};function Pt(e){let t={},r={},n=[];function o(i){if(i in r)throw new Ee;i in t||(r[i]=!0,t[i]=!0,e.predecessors(i).forEach(o),delete r[i],n.push(i))}if(e.sinks().forEach(o),Object.keys(t).length!==e.nodeCount())throw new Ee;return n}function zr(e){try{Pt(e)}catch(t){if(t instanceof Ee)return!1;throw t}return!0}function Dr(e,t,r,n,o){Array.isArray(t)||(t=[t]);let i=l=>{var d;return(d=e.isDirected()?e.successors(l):e.neighbors(l))!=null?d:[]},s={};return t.forEach(function(l){if(!e.hasNode(l))throw new Error("Graph does not have node: "+l);o=Bt(e,l,r==="post",s,i,n,o)}),o}function Bt(e,t,r,n,o,i,s){return t in n||(n[t]=!0,r||(s=i(s,t)),o(t).forEach(function(l){s=Bt(e,l,r,n,o,i,s)}),r&&(s=i(s,t))),s}function Wt(e,t,r){return Dr(e,t,r,function(n,o){return n.push(o),n},[])}function Pr(e,t){return Wt(e,t,"post")}function Br(e,t){return Wt(e,t,"pre")}function Wr(e,t){let r=new W,n={},o=new zt,i;function s(d){let a=d.v===i?d.w:d.v,c=o.priority(a);if(c!==void 0){let f=t(d);f<c&&(n[a]=i,o.decrease(a,f))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(d){o.add(d,Number.POSITIVE_INFINITY),r.setNode(d)}),o.decrease(e.nodes()[0],0);let l=!1;for(;o.size()>0;){if(i=o.removeMin(),i in n)r.setEdge(i,n[i]);else{if(l)throw new Error("Input graph is not connected: "+e);l=!0}e.nodeEdges(i).forEach(s)}return r}function Gr(e,t,r,n){return $r(e,t,r,n??(o=>{let i=e.outEdges(o);return i??[]}))}function $r(e,t,r,n){if(r===void 0)return ve(e,t,r,n);let o=!1,i=e.nodes();for(let s=0;s<i.length;s++){let l=n(i[s]);for(let d=0;d<l.length;d++){let a=l[d],c=a.v===i[s]?a.v:a.w,f=c===a.v?a.w:a.v;r({v:c,w:f})<0&&(o=!0)}if(o)return At(e,t,r,n)}return ve(e,t,r,n)}function ce(e,t,r,n){let o=n;for(;e.hasNode(o);)o=Ke(n);return r.dummy=t,e.setNode(o,r),o}function Yr(e){let t=new W().setGraph(e.graph());return e.nodes().forEach(r=>t.setNode(r,e.node(r))),e.edges().forEach(r=>{let n=t.edge(r.v,r.w)||{weight:0,minlen:1},o=e.edge(r);t.setEdge(r.v,r.w,{weight:n.weight+o.weight,minlen:Math.max(n.minlen,o.minlen)})}),t}function Gt(e){let t=new W({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(r=>{e.children(r).length||t.setNode(r,e.node(r))}),e.edges().forEach(r=>{t.setEdge(r,e.edge(r))}),t}function yt(e,t){let r=e.x,n=e.y,o=t.x-r,i=t.y-n,s=e.width/2,l=e.height/2;if(!o&&!i)throw new Error("Not possible to find intersection inside of the rectangle");let d,a;return Math.abs(i)*s>Math.abs(o)*l?(i<0&&(l=-l),d=l*o/i,a=l):(o<0&&(s=-s),d=s,a=s*i/o),{x:r+d,y:n+a}}function pe(e){let t=he(Yt(e)+1).map(()=>[]);return e.nodes().forEach(r=>{let n=e.node(r),o=n.rank;o!==void 0&&(t[o]||(t[o]=[]),t[o][n.order]=r)}),t}function Ur(e){let t=e.nodes().map(n=>{let o=e.node(n).rank;return o===void 0?Number.MAX_VALUE:o}),r=Y(Math.min,t);e.nodes().forEach(n=>{let o=e.node(n);Object.hasOwn(o,"rank")&&(o.rank-=r)})}function qr(e){let t=e.nodes().map(s=>e.node(s).rank).filter(s=>s!==void 0),r=Y(Math.min,t),n=[];e.nodes().forEach(s=>{let l=e.node(s).rank-r;n[l]||(n[l]=[]),n[l].push(s)});let o=0,i=e.graph().nodeRankFactor;Array.from(n).forEach((s,l)=>{s===void 0&&l%i!==0?--o:s!==void 0&&o&&s.forEach(d=>e.node(d).rank+=o)})}function mt(e,t,r,n){let o={width:0,height:0};return arguments.length>=4&&(o.rank=r,o.order=n),ce(e,"border",o,t)}function Kr(e,t=$t){let r=[];for(let n=0;n<e.length;n+=t){let o=e.slice(n,n+t);r.push(o)}return r}var $t=65535;function Y(e,t){if(t.length>$t){let r=Kr(t);return e(...r.map(n=>e(...n)))}else return e(...t)}function Yt(e){let t=e.nodes().map(r=>{let n=e.node(r).rank;return n===void 0?Number.MIN_VALUE:n});return Y(Math.max,t)}function Xr(e,t){let r={lhs:[],rhs:[]};return e.forEach(n=>{t(n)?r.lhs.push(n):r.rhs.push(n)}),r}function Ut(e,t){let r=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-r)+"ms")}}function qt(e,t){return t()}var Vr=0;function Ke(e){let t=++Vr;return e+(""+t)}function he(e,t,r=1){t==null&&(t=e,e=0);let n=i=>i<t;r<0&&(n=i=>t<i);let o=[];for(let i=e;n(i);i+=r)o.push(i);return o}function ke(e,t){let r={};for(let n of t)e[n]!==void 0&&(r[n]=e[n]);return r}function je(e,t){let r;return typeof t=="string"?r=n=>n[t]:r=t,Object.entries(e).reduce((n,[o,i])=>(n[o]=r(i,o),n),{})}function Hr(e,t){return e.reduce((r,n,o)=>(r[n]=t[o],r),{})}var Te="\0",Jr="3.0.0",Zr=class{constructor(){xr(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return xt(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&xt(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,r=t._prev;for(;r!==t;)e.push(JSON.stringify(r,Qr)),r=r._prev;return"["+e.join(", ")+"]"}};function xt(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Qr(e,t){if(e!=="_next"&&e!=="_prev")return t}var en=Zr,tn=()=>1;function rn(e,t){if(e.nodeCount()<=1)return[];let r=on(e,t||tn);return nn(r.graph,r.buckets,r.zeroIdx).flatMap(n=>e.outEdges(n.v,n.w)||[])}function nn(e,t,r){var n;let o=[],i=t[t.length-1],s=t[0],l;for(;e.nodeCount();){for(;l=s.dequeue();)Me(e,t,r,l);for(;l=i.dequeue();)Me(e,t,r,l);if(e.nodeCount()){for(let d=t.length-2;d>0;--d)if(l=(n=t[d])==null?void 0:n.dequeue(),l){o=o.concat(Me(e,t,r,l,!0)||[]);break}}}return o}function Me(e,t,r,n,o){let i=[],s=o?i:void 0;return(e.inEdges(n.v)||[]).forEach(l=>{let d=e.edge(l),a=e.node(l.v);o&&i.push({v:l.v,w:l.w}),a.out-=d,Be(t,r,a)}),(e.outEdges(n.v)||[]).forEach(l=>{let d=e.edge(l),a=l.w,c=e.node(a);c.in-=d,Be(t,r,c)}),e.removeNode(n.v),s}function on(e,t){let r=new W,n=0,o=0;e.nodes().forEach(l=>{r.setNode(l,{v:l,in:0,out:0})}),e.edges().forEach(l=>{let d=r.edge(l.v,l.w)||0,a=t(l),c=d+a;r.setEdge(l.v,l.w,c);let f=r.node(l.v),h=r.node(l.w);o=Math.max(o,f.out+=a),n=Math.max(n,h.in+=a)});let i=sn(o+n+3).map(()=>new en),s=n+1;return r.nodes().forEach(l=>{Be(i,s,r.node(l))}),{graph:r,buckets:i,zeroIdx:s}}function Be(e,t,r){var n,o,i;r.out?r.in?(i=e[r.out-r.in+t])==null||i.enqueue(r):(o=e[e.length-1])==null||o.enqueue(r):(n=e[0])==null||n.enqueue(r)}function sn(e){let t=[];for(let r=0;r<e;r++)t.push(r);return t}function ln(e){(e.graph().acyclicer==="greedy"?rn(e,t(e)):an(e)).forEach(r=>{let n=e.edge(r);e.removeEdge(r),n.forwardName=r.name,n.reversed=!0,e.setEdge(r.w,r.v,n,Ke("rev"))});function t(r){return n=>r.edge(n).weight}}function an(e){let t=[],r={},n={};function o(i){Object.hasOwn(n,i)||(n[i]=!0,r[i]=!0,e.outEdges(i).forEach(s=>{Object.hasOwn(r,s.w)?t.push(s):o(s.w)}),delete r[i])}return e.nodes().forEach(o),t}function dn(e){e.edges().forEach(t=>{let r=e.edge(t);if(r.reversed){e.removeEdge(t);let n=r.forwardName;delete r.reversed,delete r.forwardName,e.setEdge(t.w,t.v,r,n)}})}function cn(e){e.graph().dummyChains=[],e.edges().forEach(t=>un(e,t))}function un(e,t){let r=t.v,n=e.node(r).rank,o=t.w,i=e.node(o).rank,s=t.name,l=e.edge(t),d=l.labelRank;if(i===n+1)return;e.removeEdge(t);let a,c,f;for(f=0,++n;n<i;++f,++n)l.points=[],c={width:0,height:0,edgeLabel:l,edgeObj:t,rank:n},a=ce(e,"edge",c,"_d"),n===d&&(c.width=l.width,c.height=l.height,c.dummy="edge-label",c.labelpos=l.labelpos),e.setEdge(r,a,{weight:l.weight},s),f===0&&e.graph().dummyChains.push(a),r=a;e.setEdge(r,o,{weight:l.weight},s)}function fn(e){e.graph().dummyChains.forEach(t=>{let r=e.node(t),n=r.edgeLabel,o;for(e.setEdge(r.edgeObj,n);r.dummy;)o=e.successors(t)[0],e.removeNode(t),n.points.push({x:r.x,y:r.y}),r.dummy==="edge-label"&&(n.x=r.x,n.y=r.y,n.width=r.width,n.height=r.height),t=o,r=e.node(t)})}function Xe(e){let t={};function r(n){let o=e.node(n);if(Object.hasOwn(t,n))return o.rank;t[n]=!0;let i=e.outEdges(n),s=i?i.map(d=>d==null?Number.POSITIVE_INFINITY:r(d.w)-e.edge(d).minlen):[],l=Y(Math.min,s);return l===Number.POSITIVE_INFINITY&&(l=0),o.rank=l}e.sources().forEach(r)}function de(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Kt=hn;function hn(e){let t=new W({directed:!1}),r=e.nodes();if(r.length===0)throw new Error("Graph must have at least one node");let n=r[0],o=e.nodeCount();t.setNode(n,{});let i,s;for(;gn(t,e)<o&&(i=pn(t,e),!!i);)s=t.hasNode(i.v)?de(e,i):-de(e,i),bn(t,e,s);return t}function gn(e,t){function r(n){let o=t.nodeEdges(n);o&&o.forEach(i=>{let s=i.v,l=n===s?i.w:s;!e.hasNode(l)&&!de(t,i)&&(e.setNode(l,{}),e.setEdge(n,l,{}),r(l))})}return e.nodes().forEach(r),e.nodeCount()}function pn(e,t){return t.edges().reduce((r,n)=>{let o=Number.POSITIVE_INFINITY;return e.hasNode(n.v)!==e.hasNode(n.w)&&(o=de(t,n)),o<r[0]?[o,n]:r},[Number.POSITIVE_INFINITY,null])[1]}function bn(e,t,r){e.nodes().forEach(n=>t.node(n).rank+=r)}var{preorder:yn,postorder:mn}=qe,xn=ne;ne.initLowLimValues=He;ne.initCutValues=Ve;ne.calcCutValue=Xt;ne.leaveEdge=Ht;ne.enterEdge=Jt;ne.exchangeEdges=Zt;function ne(e){e=Yr(e),Xe(e);let t=Kt(e);He(t),Ve(t,e);let r,n;for(;r=Ht(t);)n=Jt(t,e,r),Zt(t,e,r,n)}function Ve(e,t){let r=mn(e,e.nodes());r=r.slice(0,r.length-1),r.forEach(n=>wn(e,t,n))}function wn(e,t,r){let n=e.node(r).parent,o=e.edge(r,n);o.cutvalue=Xt(e,t,r)}function Xt(e,t,r){let n=e.node(r).parent,o=!0,i=t.edge(r,n),s=0;i||(o=!1,i=t.edge(n,r)),s=i.weight;let l=t.nodeEdges(r);return l&&l.forEach(d=>{let a=d.v===r,c=a?d.w:d.v;if(c!==n){let f=a===o,h=t.edge(d).weight;if(s+=f?h:-h,En(e,r,c)){let g=e.edge(r,c).cutvalue;s+=f?-g:g}}}),s}function He(e,t){arguments.length<2&&(t=e.nodes()[0]),Vt(e,{},1,t)}function Vt(e,t,r,n,o){let i=r,s=e.node(n);t[n]=!0;let l=e.neighbors(n);return l&&l.forEach(d=>{Object.hasOwn(t,d)||(r=Vt(e,t,r,d,n))}),s.low=i,s.lim=r++,o?s.parent=o:delete s.parent,r}function Ht(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Jt(e,t,r){let n=r.v,o=r.w;t.hasEdge(n,o)||(n=r.w,o=r.v);let i=e.node(n),s=e.node(o),l=i,d=!1;return i.lim>s.lim&&(l=s,d=!0),t.edges().filter(a=>d===wt(e,e.node(a.v),l)&&d!==wt(e,e.node(a.w),l)).reduce((a,c)=>de(t,c)<de(t,a)?c:a)}function Zt(e,t,r,n){let o=r.v,i=r.w;e.removeEdge(o,i),e.setEdge(n.v,n.w,{}),He(e),Ve(e,t),vn(e,t)}function vn(e,t){let r=e.nodes().find(o=>!e.node(o).parent);if(!r)return;let n=yn(e,[r]);n=n.slice(1),n.forEach(o=>{let i=e.node(o).parent,s=t.edge(o,i),l=!1;s||(s=t.edge(i,o),l=!0),t.node(o).rank=t.node(i).rank+(l?s.minlen:-s.minlen)})}function En(e,t,r){return e.hasEdge(t,r)}function wt(e,t,r){return r.low<=t.lim&&t.lim<=r.lim}var kn=jn;function jn(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":vt(e);break;case"tight-tree":_n(e);break;case"longest-path":Tn(e);break;case"none":break;default:vt(e)}}var Tn=Xe;function _n(e){Xe(e),Kt(e)}function vt(e){xn(e)}var Nn=Sn;function Sn(e){let t=On(e);e.graph().dummyChains.forEach(r=>{let n=e.node(r),o=n.edgeObj,i=Cn(e,t,o.v,o.w),s=i.path,l=i.lca,d=0,a=s[d],c=!0;for(;r!==o.w;){if(n=e.node(r),c){for(;(a=s[d])!==l&&e.node(a).maxRank<n.rank;)d++;a===l&&(c=!1)}if(!c){for(;d<s.length-1&&e.node(s[d+1]).minRank<=n.rank;)d++;a=s[d]}a!==void 0&&e.setParent(r,a),r=e.successors(r)[0]}})}function Cn(e,t,r,n){let o=[],i=[],s=Math.min(t[r].low,t[n].low),l=Math.max(t[r].lim,t[n].lim),d;d=r;do d=e.parent(d),o.push(d);while(d&&(t[d].low>s||l>t[d].lim));let a=d,c=n;for(;(c=e.parent(c))!==a;)i.push(c);return{path:o.concat(i.reverse()),lca:a}}function On(e){let t={},r=0;function n(o){let i=r;e.children(o).forEach(n),t[o]={low:i,lim:r++}}return e.children(Te).forEach(n),t}function In(e){let t=ce(e,"root",{},"_root"),r=Mn(e),n=Object.values(r),o=Y(Math.max,n)-1,i=2*o+1;e.graph().nestingRoot=t,e.edges().forEach(l=>e.edge(l).minlen*=i);let s=Rn(e)+1;e.children(Te).forEach(l=>Qt(e,t,i,s,o,r,l)),e.graph().nodeRankFactor=i}function Qt(e,t,r,n,o,i,s){var l;let d=e.children(s);if(!d.length){s!==t&&e.setEdge(t,s,{weight:0,minlen:r});return}let a=mt(e,"_bt"),c=mt(e,"_bb"),f=e.node(s);e.setParent(a,s),f.borderTop=a,e.setParent(c,s),f.borderBottom=c,d.forEach(h=>{var g;Qt(e,t,r,n,o,i,h);let y=e.node(h),m=y.borderTop?y.borderTop:h,p=y.borderBottom?y.borderBottom:h,w=y.borderTop?n:2*n,_=m!==p?1:o-((g=i[s])!=null?g:0)+1;e.setEdge(a,m,{weight:w,minlen:_,nestingEdge:!0}),e.setEdge(p,c,{weight:w,minlen:_,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,a,{weight:0,minlen:o+((l=i[s])!=null?l:0)})}function Mn(e){let t={};function r(n,o){let i=e.children(n);i&&i.length&&i.forEach(s=>r(s,o+1)),t[n]=o}return e.children(Te).forEach(n=>r(n,1)),t}function Rn(e){return e.edges().reduce((t,r)=>t+e.edge(r).weight,0)}function Fn(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(r=>{e.edge(r).nestingEdge&&e.removeEdge(r)})}var Ln=An;function An(e){function t(r){let n=e.children(r),o=e.node(r);if(n.length&&n.forEach(t),Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let i=o.minRank,s=o.maxRank+1;i<s;++i)Et(e,"borderLeft","_bl",r,o,i),Et(e,"borderRight","_br",r,o,i)}}e.children(Te).forEach(t)}function Et(e,t,r,n,o,i){let s={width:0,height:0,rank:i,borderType:t},l=o[t][i-1],d=ce(e,"border",s,r);o[t][i]=d,e.setParent(d,n),l&&e.setEdge(l,d,{weight:1})}function zn(e){var t;let r=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(r==="lr"||r==="rl")&&er(e)}function Dn(e){var t;let r=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(r==="bt"||r==="rl")&&Pn(e),(r==="lr"||r==="rl")&&(Bn(e),er(e))}function er(e){e.nodes().forEach(t=>kt(e.node(t))),e.edges().forEach(t=>kt(e.edge(t)))}function kt(e){let t=e.width;e.width=e.height,e.height=t}function Pn(e){e.nodes().forEach(t=>Re(e.node(t))),e.edges().forEach(t=>{var r;let n=e.edge(t);(r=n.points)==null||r.forEach(Re),Object.hasOwn(n,"y")&&Re(n)})}function Re(e){e.y=-e.y}function Bn(e){e.nodes().forEach(t=>Fe(e.node(t))),e.edges().forEach(t=>{var r;let n=e.edge(t);(r=n.points)==null||r.forEach(Fe),Object.hasOwn(n,"x")&&Fe(n)})}function Fe(e){let t=e.x;e.x=e.y,e.y=t}function Wn(e){let t={},r=e.nodes().filter(l=>!e.children(l).length),n=r.map(l=>e.node(l).rank),o=Y(Math.max,n),i=he(o+1).map(()=>[]);function s(l){if(t[l])return;t[l]=!0;let d=e.node(l);i[d.rank].push(l);let a=e.successors(l);a&&a.forEach(s)}return r.sort((l,d)=>e.node(l).rank-e.node(d).rank).forEach(s),i}function Gn(e,t){let r=0;for(let n=1;n<t.length;++n)r+=$n(e,t[n-1],t[n]);return r}function $n(e,t,r){let n=Hr(r,r.map((a,c)=>c)),o=t.flatMap(a=>{let c=e.outEdges(a);return c?c.map(f=>({pos:n[f.w],weight:e.edge(f).weight})).sort((f,h)=>f.pos-h.pos):[]}),i=1;for(;i<r.length;)i<<=1;let s=2*i-1;i-=1;let l=new Array(s).fill(0),d=0;return o.forEach(a=>{let c=a.pos+i;l[c]+=a.weight;let f=0;for(;c>0;)c%2&&(f+=l[c+1]),c=c-1>>1,l[c]+=a.weight;d+=a.weight*f}),d}function Yn(e,t=[]){return t.map(r=>{let n=e.inEdges(r);if(!n||!n.length)return{v:r};{let o=n.reduce((i,s)=>{let l=e.edge(s),d=e.node(s.v);return{sum:i.sum+l.weight*d.order,weight:i.weight+l.weight}},{sum:0,weight:0});return{v:r,barycenter:o.sum/o.weight,weight:o.weight}}})}function Un(e,t){let r={};e.forEach((o,i)=>{let s={indegree:0,in:[],out:[],vs:[o.v],i};o.barycenter!==void 0&&(s.barycenter=o.barycenter,s.weight=o.weight),r[o.v]=s}),t.edges().forEach(o=>{let i=r[o.v],s=r[o.w];i!==void 0&&s!==void 0&&(s.indegree++,i.out.push(s))});let n=Object.values(r).filter(o=>!o.indegree);return qn(n)}function qn(e){let t=[];function r(o){return i=>{i.merged||(i.barycenter===void 0||o.barycenter===void 0||i.barycenter>=o.barycenter)&&Kn(o,i)}}function n(o){return i=>{i.in.push(o),--i.indegree===0&&e.push(i)}}for(;e.length;){let o=e.pop();t.push(o),o.in.reverse().forEach(r(o)),o.out.forEach(n(o))}return t.filter(o=>!o.merged).map(o=>ke(o,["vs","i","barycenter","weight"]))}function Kn(e,t){let r=0,n=0;e.weight&&(r+=e.barycenter*e.weight,n+=e.weight),t.weight&&(r+=t.barycenter*t.weight,n+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=r/n,e.weight=n,e.i=Math.min(t.i,e.i),t.merged=!0}function Xn(e,t){let r=Xr(e,c=>Object.hasOwn(c,"barycenter")),n=r.lhs,o=r.rhs.sort((c,f)=>f.i-c.i),i=[],s=0,l=0,d=0;n.sort(Vn(!!t)),d=jt(i,o,d),n.forEach(c=>{d+=c.vs.length,i.push(c.vs),s+=c.barycenter*c.weight,l+=c.weight,d=jt(i,o,d)});let a={vs:i.flat(1)};return l&&(a.barycenter=s/l,a.weight=l),a}function jt(e,t,r){let n;for(;t.length&&(n=t[t.length-1]).i<=r;)t.pop(),e.push(n.vs),r++;return r}function Vn(e){return(t,r)=>t.barycenter<r.barycenter?-1:t.barycenter>r.barycenter?1:e?r.i-t.i:t.i-r.i}function tr(e,t,r,n){let o=e.children(t),i=e.node(t),s=i?i.borderLeft:void 0,l=i?i.borderRight:void 0,d={};s&&(o=o.filter(h=>h!==s&&h!==l));let a=Yn(e,o);a.forEach(h=>{if(e.children(h.v).length){let g=tr(e,h.v,r,n);d[h.v]=g,Object.hasOwn(g,"barycenter")&&Jn(h,g)}});let c=Un(a,r);Hn(c,d);let f=Xn(c,n);if(s&&l){f.vs=[s,f.vs,l].flat(1);let h=e.predecessors(s);if(h&&h.length){let g=e.node(h[0]),y=e.predecessors(l),m=e.node(y[0]);Object.hasOwn(f,"barycenter")||(f.barycenter=0,f.weight=0),f.barycenter=(f.barycenter*f.weight+g.order+m.order)/(f.weight+2),f.weight+=2}}return f}function Hn(e,t){e.forEach(r=>{r.vs=r.vs.flatMap(n=>t[n]?t[n].vs:n)})}function Jn(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function Zn(e,t,r,n){n||(n=e.nodes());let o=Qn(e),i=new W({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(s=>e.node(s));return n.forEach(s=>{let l=e.node(s),d=e.parent(s);if(l.rank===t||l.minRank<=t&&t<=l.maxRank){i.setNode(s),i.setParent(s,d||o);let a=e[r](s);a&&a.forEach(c=>{let f=c.v===s?c.w:c.v,h=i.edge(f,s),g=h!==void 0?h.weight:0;i.setEdge(f,s,{weight:e.edge(c).weight+g})}),Object.hasOwn(l,"minRank")&&i.setNode(s,{borderLeft:l.borderLeft[t],borderRight:l.borderRight[t]})}}),i}function Qn(e){let t;for(;e.hasNode(t=Ke("_root")););return t}function eo(e,t,r){let n={},o;r.forEach(i=>{let s=e.parent(i),l,d;for(;s;){if(l=e.parent(s),l?(d=n[l],n[l]=s):(d=o,o=s),d&&d!==s){t.setEdge(d,s);return}s=l}})}function rr(e,t={}){if(typeof t.customOrder=="function"){t.customOrder(e,rr);return}let r=Yt(e),n=Tt(e,he(1,r+1),"inEdges"),o=Tt(e,he(r-1,-1,-1),"outEdges"),i=Wn(e);if(_t(e,i),t.disableOptimalOrderHeuristic)return;let s=Number.POSITIVE_INFINITY,l,d=t.constraints||[];for(let a=0,c=0;c<4;++a,++c){to(a%2?n:o,a%4>=2,d),i=pe(e);let f=Gn(e,i);f<s?(c=0,l=Object.assign({},i),s=f):f===s&&(l=structuredClone(i))}_t(e,l)}function Tt(e,t,r){let n=new Map,o=(i,s)=>{n.has(i)||n.set(i,[]),n.get(i).push(s)};for(let i of e.nodes()){let s=e.node(i);if(typeof s.rank=="number"&&o(s.rank,i),typeof s.minRank=="number"&&typeof s.maxRank=="number")for(let l=s.minRank;l<=s.maxRank;l++)l!==s.rank&&o(l,i)}return t.map(function(i){return Zn(e,i,r,n.get(i)||[])})}function to(e,t,r){let n=new W;e.forEach(function(o){r.forEach(l=>n.setEdge(l.left,l.right));let i=o.graph().root,s=tr(o,i,n,t);s.vs.forEach((l,d)=>o.node(l).order=d),eo(o,n,s.vs)})}function _t(e,t){Object.values(t).forEach(r=>r.forEach((n,o)=>e.node(n).order=o))}function ro(e,t){let r={};function n(o,i){let s=0,l=0,d=o.length,a=i[i.length-1];return i.forEach((c,f)=>{let h=oo(e,c),g=h?e.node(h).order:d;(h||c===a)&&(i.slice(l,f+1).forEach(y=>{let m=e.predecessors(y);m&&m.forEach(p=>{let w=e.node(p),_=w.order;(_<s||g<_)&&!(w.dummy&&e.node(y).dummy)&&nr(r,p,y)})}),l=f+1,s=g)}),i}return t.length&&t.reduce(n),r}function no(e,t){let r={};function n(i,s,l,d,a){he(s,l).forEach(c=>{let f=i[c];if(f!==void 0&&e.node(f).dummy){let h=e.predecessors(f);h&&h.forEach(g=>{if(g===void 0)return;let y=e.node(g);y.dummy&&(y.order<d||y.order>a)&&nr(r,g,f)})}})}function o(i,s){let l=-1,d=-1,a=0;return s.forEach((c,f)=>{if(e.node(c).dummy==="border"){let h=e.predecessors(c);if(h&&h.length){let g=h[0];if(g===void 0)return;d=e.node(g).order,n(s,a,f,l,d),a=f,l=d}}n(s,a,s.length,d,i.length)}),s}return t.length&&t.reduce(o),r}function oo(e,t){if(e.node(t).dummy){let r=e.predecessors(t);if(r)return r.find(n=>e.node(n).dummy)}}function nr(e,t,r){if(t>r){let o=t;t=r,r=o}let n=e[t];n||(e[t]=n={}),n[r]=!0}function io(e,t,r){if(t>r){let o=t;t=r,r=o}let n=e[t];return n!==void 0&&Object.hasOwn(n,r)}function so(e,t,r,n){let o={},i={},s={};return t.forEach(l=>{l.forEach((d,a)=>{o[d]=d,i[d]=d,s[d]=a})}),t.forEach(l=>{let d=-1;l.forEach(a=>{let c=n(a);if(c&&c.length){let f=c.sort((g,y)=>{let m=s[g],p=s[y];return(m!==void 0?m:0)-(p!==void 0?p:0)}),h=(f.length-1)/2;for(let g=Math.floor(h),y=Math.ceil(h);g<=y;++g){let m=f[g];if(m===void 0)continue;let p=s[m];if(p!==void 0&&i[a]===a&&d<p&&!io(r,a,m)){let w=o[m];w!==void 0&&(i[m]=a,i[a]=o[a]=w,d=p)}}}})}),{root:o,align:i}}function lo(e,t,r,n,o=!1){let i={},s=ao(e,t,r,o),l=o?"borderLeft":"borderRight";function d(g,y){let m=s.nodes().slice(),p={},w=m.pop();for(;w;){if(p[w])g(w);else{p[w]=!0,m.push(w);for(let _ of y(w))m.push(_)}w=m.pop()}}function a(g){let y=s.inEdges(g);y?i[g]=y.reduce((m,p)=>{var w;let _=(w=i[p.v])!=null?w:0,O=s.edge(p);return Math.max(m,_+(O!==void 0?O:0))},0):i[g]=0}function c(g){let y=s.outEdges(g),m=Number.POSITIVE_INFINITY;y&&(m=y.reduce((w,_)=>{let O=i[_.w],M=s.edge(_);return Math.min(w,(O!==void 0?O:0)-(M!==void 0?M:0))},Number.POSITIVE_INFINITY));let p=e.node(g);m!==Number.POSITIVE_INFINITY&&p.borderType!==l&&(i[g]=Math.max(i[g]!==void 0?i[g]:0,m))}function f(g){return s.predecessors(g)||[]}function h(g){return s.successors(g)||[]}return d(a,f),d(c,h),Object.keys(n).forEach(g=>{var y;let m=r[g];m!==void 0&&(i[g]=(y=i[m])!=null?y:0)}),i}function ao(e,t,r,n){let o=new W,i=e.graph(),s=go(i.nodesep,i.edgesep,n);return t.forEach(l=>{let d;l.forEach(a=>{let c=r[a];if(c!==void 0){if(o.setNode(c),d!==void 0){let f=r[d];if(f!==void 0){let h=o.edge(f,c);o.setEdge(f,c,Math.max(s(e,a,d),h||0))}}d=a}})}),o}function co(e,t){return Object.values(t).reduce((r,n)=>{let o=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(n).forEach(([l,d])=>{let a=po(e,l)/2;o=Math.max(d+a,o),i=Math.min(d-a,i)});let s=o-i;return s<r[0]&&(r=[s,n]),r},[Number.POSITIVE_INFINITY,null])[1]}function uo(e,t){let r=Object.values(t),n=Y(Math.min,r),o=Y(Math.max,r);["u","d"].forEach(i=>{["l","r"].forEach(s=>{let l=i+s,d=e[l];if(!d||d===t)return;let a=Object.values(d),c=n-Y(Math.min,a);s!=="l"&&(c=o-Y(Math.max,a)),c&&(e[l]=je(d,f=>f+c))})})}function fo(e,t=void 0){let r=e.ul;return r?je(r,(n,o)=>{var i,s;if(t){let d=t.toLowerCase(),a=e[d];if(a&&a[o]!==void 0)return a[o]}let l=Object.values(e).map(d=>{let a=d[o];return a!==void 0?a:0}).sort((d,a)=>d-a);return(((i=l[1])!=null?i:0)+((s=l[2])!=null?s:0))/2}):{}}function ho(e){let t=pe(e),r=Object.assign(ro(e,t),no(e,t)),n={},o;["u","d"].forEach(s=>{o=s==="u"?t:Object.values(t).reverse(),["l","r"].forEach(l=>{l==="r"&&(o=o.map(c=>Object.values(c).reverse()));let d=so(e,o,r,c=>(s==="u"?e.predecessors(c):e.successors(c))||[]),a=lo(e,o,d.root,d.align,l==="r");l==="r"&&(a=je(a,c=>-c)),n[s+l]=a})});let i=co(e,n);return uo(n,i),fo(n,e.graph().align)}function go(e,t,r){return(n,o,i)=>{let s=n.node(o),l=n.node(i),d=0,a;if(d+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":a=-s.width/2;break;case"r":a=s.width/2;break}if(a&&(d+=r?a:-a),a=void 0,d+=(s.dummy?t:e)/2,d+=(l.dummy?t:e)/2,d+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":a=l.width/2;break;case"r":a=-l.width/2;break}return a&&(d+=r?a:-a),d}}function po(e,t){return e.node(t).width}function bo(e){e=Gt(e),yo(e),Object.entries(ho(e)).forEach(([t,r])=>e.node(t).x=r)}function yo(e){let t=pe(e),r=e.graph(),n=r.ranksep,o=r.rankalign,i=0;t.forEach(s=>{let l=s.reduce((d,a)=>{var c;let f=(c=e.node(a).height)!=null?c:0;return d>f?d:f},0);s.forEach(d=>{let a=e.node(d);o==="top"?a.y=i+a.height/2:o==="bottom"?a.y=i+l-a.height/2:a.y=i+l/2}),i+=l+n})}function mo(e,t={}){let r=t.debugTiming?Ut:qt;return r("layout",()=>{let n=r(" buildLayoutGraph",()=>So(e));return r(" runLayout",()=>xo(n,r,t)),r(" updateInputGraph",()=>wo(e,n)),n})}function xo(e,t,r){t(" makeSpaceForEdgeLabels",()=>Co(e)),t(" removeSelfEdges",()=>Do(e)),t(" acyclic",()=>ln(e)),t(" nestingGraph.run",()=>In(e)),t(" rank",()=>kn(Gt(e))),t(" injectEdgeLabelProxies",()=>Oo(e)),t(" removeEmptyRanks",()=>qr(e)),t(" nestingGraph.cleanup",()=>Fn(e)),t(" normalizeRanks",()=>Ur(e)),t(" assignRankMinMax",()=>Io(e)),t(" removeEdgeLabelProxies",()=>Mo(e)),t(" normalize.run",()=>cn(e)),t(" parentDummyChains",()=>Nn(e)),t(" addBorderSegments",()=>Ln(e)),t(" order",()=>rr(e,r)),t(" insertSelfEdges",()=>Po(e)),t(" adjustCoordinateSystem",()=>zn(e)),t(" position",()=>bo(e)),t(" positionSelfEdges",()=>Bo(e)),t(" removeBorderNodes",()=>zo(e)),t(" normalize.undo",()=>fn(e)),t(" fixupEdgeLabelCoords",()=>Lo(e)),t(" undoCoordinateSystem",()=>Dn(e)),t(" translateGraph",()=>Ro(e)),t(" assignNodeIntersects",()=>Fo(e)),t(" reversePoints",()=>Ao(e)),t(" acyclic.undo",()=>dn(e))}function wo(e,t){e.nodes().forEach(r=>{let n=e.node(r),o=t.node(r);n&&(n.x=o.x,n.y=o.y,n.order=o.order,n.rank=o.rank,t.children(r).length&&(n.width=o.width,n.height=o.height))}),e.edges().forEach(r=>{let n=e.edge(r),o=t.edge(r);n.points=o.points,Object.hasOwn(o,"x")&&(n.x=o.x,n.y=o.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var vo=["nodesep","edgesep","ranksep","marginx","marginy"],Eo={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},ko=["acyclicer","ranker","rankdir","align","rankalign"],jo=["width","height","rank"],Nt={width:0,height:0},To=["minlen","weight","width","height","labeloffset"],_o={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},No=["labelpos"];function So(e){let t=new W({multigraph:!0,compound:!0}),r=Ae(e.graph());return t.setGraph(Object.assign({},Eo,Le(r,vo),ke(r,ko))),e.nodes().forEach(n=>{let o=Ae(e.node(n)),i=Le(o,jo);Object.keys(Nt).forEach(l=>{i[l]===void 0&&(i[l]=Nt[l])}),t.setNode(n,i);let s=e.parent(n);s!==void 0&&t.setParent(n,s)}),e.edges().forEach(n=>{let o=Ae(e.edge(n));t.setEdge(n,Object.assign({},_o,Le(o,To),ke(o,No)))}),t}function Co(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(r=>{let n=e.edge(r);n.minlen*=2,n.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?n.width+=n.labeloffset:n.height+=n.labeloffset)})}function Oo(e){e.edges().forEach(t=>{let r=e.edge(t);if(r.width&&r.height){let n=e.node(t.v),o={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};ce(e,"edge-proxy",o,"_ep")}})}function Io(e){let t=0;e.nodes().forEach(r=>{let n=e.node(r);n.borderTop&&(n.minRank=e.node(n.borderTop).rank,n.maxRank=e.node(n.borderBottom).rank,t=Math.max(t,n.maxRank))}),e.graph().maxRank=t}function Mo(e){e.nodes().forEach(t=>{let r=e.node(t);if(r.dummy==="edge-proxy"){let n=r;e.edge(n.e).labelRank=r.rank,e.removeNode(t)}})}function Ro(e){let t=Number.POSITIVE_INFINITY,r=0,n=Number.POSITIVE_INFINITY,o=0,i=e.graph(),s=i.marginx||0,l=i.marginy||0;function d(a){let c=a.x,f=a.y,h=a.width,g=a.height;t=Math.min(t,c-h/2),r=Math.max(r,c+h/2),n=Math.min(n,f-g/2),o=Math.max(o,f+g/2)}e.nodes().forEach(a=>d(e.node(a))),e.edges().forEach(a=>{let c=e.edge(a);Object.hasOwn(c,"x")&&d(c)}),t-=s,n-=l,e.nodes().forEach(a=>{let c=e.node(a);c.x-=t,c.y-=n}),e.edges().forEach(a=>{let c=e.edge(a);c.points.forEach(f=>{f.x-=t,f.y-=n}),Object.hasOwn(c,"x")&&(c.x-=t),Object.hasOwn(c,"y")&&(c.y-=n)}),i.width=r-t+s,i.height=o-n+l}function Fo(e){e.edges().forEach(t=>{let r=e.edge(t),n=e.node(t.v),o=e.node(t.w),i,s;r.points?(i=r.points[0],s=r.points[r.points.length-1]):(r.points=[],i=o,s=n),r.points.unshift(yt(n,i)),r.points.push(yt(o,s))})}function Lo(e){e.edges().forEach(t=>{let r=e.edge(t);if(Object.hasOwn(r,"x"))switch((r.labelpos==="l"||r.labelpos==="r")&&(r.width-=r.labeloffset),r.labelpos){case"l":r.x-=r.width/2+r.labeloffset;break;case"r":r.x+=r.width/2+r.labeloffset;break}})}function Ao(e){e.edges().forEach(t=>{let r=e.edge(t);r.reversed&&r.points.reverse()})}function zo(e){e.nodes().forEach(t=>{if(e.children(t).length){let r=e.node(t),n=e.node(r.borderTop),o=e.node(r.borderBottom),i=e.node(r.borderLeft[r.borderLeft.length-1]),s=e.node(r.borderRight[r.borderRight.length-1]);r.width=Math.abs(s.x-i.x),r.height=Math.abs(o.y-n.y),r.x=i.x+r.width/2,r.y=n.y+r.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function Do(e){e.edges().forEach(t=>{if(t.v===t.w){let r=e.node(t.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Po(e){pe(e).forEach(t=>{let r=0;t.forEach((n,o)=>{let i=e.node(n);i.order=o+r,(i.selfEdges||[]).forEach(s=>{ce(e,"selfedge",{width:s.label.width,height:s.label.height,rank:i.rank,order:o+ ++r,e:s.e,label:s.label},"_se")}),delete i.selfEdges})})}function Bo(e){e.nodes().forEach(t=>{let r=e.node(t);if(r.dummy==="selfedge"){let n=r,o=e.node(n.e.v),i=o.x+o.width/2,s=o.y,l=r.x-i,d=o.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:i+2*l/3,y:s-d},{x:i+5*l/6,y:s-d},{x:i+l,y:s},{x:i+5*l/6,y:s+d},{x:i+2*l/3,y:s+d}],n.label.x=r.x,n.label.y=r.y}})}function Le(e,t){return je(ke(e,t),Number)}function Ae(e){let t={};return e&&Object.entries(e).forEach(([r,n])=>{typeof r=="string"&&(r=r.toLowerCase()),t[r]=n}),t}function Wo(e){let t=pe(e),r=new W({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(n=>{r.setNode(n,{label:n}),r.setParent(n,"layer"+e.node(n).rank)}),e.edges().forEach(n=>r.setEdge(n.v,n.w,{},n.name)),t.forEach((n,o)=>{let i="layer"+o;r.setNode(i,{rank:"same"}),n.reduce((s,l)=>(r.setEdge(s,l,{style:"invis"}),l))}),r}var Go={graphlib:Rt,version:Jr,layout:mo,debug:Wo,util:{time:Ut,notime:qt}},St=Go;/*! For license information please see dagre.esm.js.LEGAL.txt */const $o=e=>{const t=[];return e.nodeInternals.forEach((r,n)=>t.push(`${n}:${r.height??0}`)),t.join(",")},Yo=({onHeightsReady:e,nodeCount:t})=>{const r=ae.useStore($o),n=b.useRef("");b.useRef(0);const{fitView:o}=ae.useReactFlow();return b.useEffect(()=>{if(!r||r===n.current)return;const i={};for(const s of r.split(",")){const[l,d]=s.split(":"),a=Number(d);l&&a>0&&(i[l]=a)}Object.keys(i).length!==0&&(n.current=r,e(i))},[r]),null},_e=({isOpen:e,onClose:t,title:r,icon:n,children:o,footer:i,width:s=600})=>{const[l,d]=b.useState(!1),a=()=>d(h=>!h),c=()=>u.jsxs(P.Box,{sx:{display:"flex",alignItems:"center",p:2,pt:3,borderBottom:"1px solid #e0e0e0",mb:0,flexShrink:0},children:[n&&u.jsx(P.Box,{sx:{mr:1.5,display:"flex",alignItems:"center",fontSize:"1.25rem",color:"#1DBF60"},children:n}),u.jsx(P.Typography,{variant:"h6",component:"div",sx:{flexGrow:1,fontSize:"0.875rem",fontWeight:500},children:r}),u.jsx(P.IconButton,{onClick:a,size:"small",sx:{mr:1},title:l?"Collapse":"Expand","data-testid":"expand-collapse-base-drawer-btn",children:l?u.jsx(gt.BiCollapse,{}):u.jsx(gt.BiExpand,{})}),u.jsx(P.IconButton,{onClick:t,size:"small","data-testid":"close-drawer-button",children:u.jsx(I.MdClose,{})})]}),f=()=>i?u.jsx(P.Box,{sx:{flexShrink:0,p:2,borderTop:"1px solid #e0e0e0",display:"flex",justifyContent:"flex-end",gap:2},children:i}):null;return l?u.jsxs(P.Dialog,{open:e,onClose:t,maxWidth:!1,fullWidth:!0,PaperProps:{sx:{display:"flex",flexDirection:"column",height:"80vh",boxShadow:24,width:"750px",maxWidth:"100%"}},children:[u.jsx(c,{}),u.jsx(P.Box,{sx:{flexGrow:1,overflowY:"auto",p:0},children:o}),u.jsx(f,{})]}):u.jsxs(P.Drawer,{anchor:"right",open:e,onClose:t,variant:"persistent",sx:{zIndex:900},ModalProps:{keepMounted:!1},PaperProps:{sx:{width:s,position:"fixed",top:"64px",height:"calc(100% - 74px)",right:"10px",borderRadius:"8px",border:"1px solid #bdbdbd",boxShadow:"none",zIndex:900,display:"flex",flexDirection:"column"}},children:[u.jsx(c,{}),u.jsx(P.Box,{sx:{flexGrow:1,overflowY:"auto",p:0},children:o}),u.jsx(f,{})]})},Uo=({open:e,templates:t,messages:r,onSelect:n,onClose:o})=>u.jsx(_e,{isOpen:e,onClose:o,title:r.addTriggerTitle,icon:u.jsx(gr.GrTrigger,{}),width:500,children:u.jsxs(P.Box,{sx:{p:2},children:[u.jsx("p",{className:"ff-text-muted ff-mb-3",style:{fontSize:13},children:r.chooseTrigger}),u.jsxs("div",{className:"ff-d-flex ff-flex-column ff-gap-2",children:[t.map(i=>u.jsxs("div",{className:"ff-p-3 ff-rounded ff-border ff-d-flex ff-align-items-start ff-gap-3",style:{cursor:"pointer",transition:"background 0.15s"},onClick:()=>n(i),role:"button",tabIndex:0,onKeyDown:s=>{s.key==="Enter"&&n(i)},onMouseEnter:s=>{s.currentTarget.style.background="#f5f5f5"},onMouseLeave:s=>{s.currentTarget.style.background=""},children:[u.jsx("div",{style:{color:i.triggerCategory==="scheduler"?"#1976d2":"#f57c00",marginTop:2,flexShrink:0},children:i.triggerCategory==="scheduler"?u.jsx(I.MdCalendarToday,{size:18}):u.jsx(I.MdBolt,{size:18})}),u.jsxs("div",{children:[u.jsx("div",{style:{fontSize:14,fontWeight:600,color:"#212121"},children:i.label}),i.description&&u.jsx("div",{style:{fontSize:12,color:"#757575",marginTop:2},children:i.description})]})]},i.triggerKey)),t.length===0&&u.jsx("p",{className:"ff-text-muted ff-text-center",style:{fontSize:13},children:r.noTriggers})]})]})}),ze={cursor:"pointer",transition:"background 0.15s"},De="ff-p-3 ff-rounded ff-border ff-d-flex ff-align-items-center ff-gap-3",qo=({open:e,availableDescriptors:t,messages:r,onSelect:n,onClose:o})=>{const{apps:i,ungrouped:s}=b.useMemo(()=>{const f=new Map,h=[];for(const g of t)if(g.app){const y=f.get(g.app.key);y?y.descriptors.push(g):f.set(g.app.key,{key:g.app.key,label:g.app.label,icon:g.app.icon,description:g.app.description,descriptors:[g]})}else h.push(g);return{apps:[...f.values()],ungrouped:h}},[t]),[l,d]=b.useState(null),a=l?i.find(f=>f.key===l)??null:null;b.useEffect(()=>{e||d(null)},[e]),b.useEffect(()=>{d(null)},[t]);const c=!a;return u.jsx(_e,{isOpen:e,onClose:o,title:c?r.addStepTitle:a.label,icon:c?u.jsx(I.MdAddCircleOutline,{}):a.icon??u.jsx(I.MdApps,{}),width:500,children:u.jsxs(P.Box,{sx:{p:2},children:[!c&&u.jsxs("div",{role:"button",tabIndex:0,onClick:()=>d(null),onKeyDown:f=>{f.key==="Enter"&&d(null)},className:"ff-d-flex ff-align-items-center ff-gap-1 ff-mb-3",style:{cursor:"pointer",color:"#0066cc",fontSize:13,fontWeight:500,width:"fit-content"},children:[u.jsx(I.MdArrowBack,{size:16}),u.jsx("span",{children:r.addStepTitle})]}),u.jsx("p",{className:"ff-text-muted ff-mb-3",style:{fontSize:13},children:c?r.chooseAction:`Pick an action from ${a.label}`}),u.jsx("div",{className:"ff-d-flex ff-flex-column ff-gap-2",children:c?u.jsxs(u.Fragment,{children:[i.map(f=>u.jsxs("div",{className:De,style:ze,onClick:()=>d(f.key),role:"button",tabIndex:0,onKeyDown:h=>{h.key==="Enter"&&d(f.key)},onMouseEnter:h=>{h.currentTarget.style.background="#f5f5f5"},onMouseLeave:h=>{h.currentTarget.style.background=""},children:[f.icon&&u.jsx("div",{style:{flexShrink:0},children:f.icon}),u.jsxs("div",{style:{flex:1,minWidth:0},children:[u.jsx("div",{style:{fontSize:14,fontWeight:600,color:"#212121"},children:f.label}),u.jsx("div",{style:{fontSize:12,color:"#757575",marginTop:2},children:f.description??`${f.descriptors.length} action${f.descriptors.length===1?"":"s"}`})]}),u.jsx(I.MdChevronRight,{size:18,color:"#9e9e9e"})]},`app-${f.key}`)),s.map(f=>u.jsxs("div",{className:De,style:ze,onClick:()=>n(f),role:"button",tabIndex:0,onKeyDown:h=>{h.key==="Enter"&&n(f)},onMouseEnter:h=>{h.currentTarget.style.background="#f5f5f5"},onMouseLeave:h=>{h.currentTarget.style.background=""},children:[f.icon&&u.jsx("div",{style:{flexShrink:0},children:f.icon}),u.jsx("span",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:f.label})]},f.type)),i.length===0&&s.length===0&&u.jsx("p",{className:"ff-text-muted ff-text-center",style:{fontSize:13},children:r.noActions})]}):a.descriptors.map(f=>u.jsxs("div",{className:De,style:ze,onClick:()=>n(f),role:"button",tabIndex:0,onKeyDown:h=>{h.key==="Enter"&&n(f)},onMouseEnter:h=>{h.currentTarget.style.background="#f5f5f5"},onMouseLeave:h=>{h.currentTarget.style.background=""},children:[f.icon&&u.jsx("div",{style:{flexShrink:0},children:f.icon}),u.jsx("span",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:f.label})]},f.type))})]})})},Ct="_conditionConfig",Ko=({open:e,nodeId:t,descriptor:r,initialValues:n,messages:o,onSave:i,onClose:s})=>{const[l,d]=b.useState([]),[a,c]=b.useState(!1),[f,h]=b.useState(null),[g,y]=b.useState({});b.useEffect(()=>{y((n==null?void 0:n[Ct])??{})},[n,t]),b.useEffect(()=>{let _=!1;if(h(null),!r||!t){d([]),c(!1);return}const O=r.formSchema;return typeof O=="function"?(c(!0),O(t).then(M=>{_||(d(M),c(!1))}).catch(M=>{_||(d([]),h(M instanceof Error?M.message:"Unable to load configuration."),c(!1))})):(d(O),c(!1)),()=>{_=!0}},[r,t]);const m=t?`node-config-form-${t}`:"node-config-form",p=!a&&!f&&l.length>0,w=p?u.jsxs(u.Fragment,{children:[u.jsx(P.Button,{type:"button",variant:"outlined",size:"small",onClick:s,children:o.cancel}),u.jsx(P.Button,{type:"submit",form:m,variant:"contained",size:"small",children:o.save})]}):null;return u.jsx(_e,{isOpen:e,onClose:s,title:(r==null?void 0:r.label)??o.configureStep,icon:r==null?void 0:r.icon,width:500,footer:w,children:u.jsxs(P.Box,{sx:{p:2},children:[a&&u.jsx("p",{className:"ff-text-muted",style:{fontSize:13},children:o.loadingConfiguration}),!a&&f&&u.jsx("p",{style:{fontSize:13,color:"#d32f2f"},children:f}),!a&&!f&&l.length===0&&u.jsx("p",{className:"ff-text-muted",style:{fontSize:13},children:o.noConfigurationNeeded}),p&&u.jsx(pr.FlowForm,{schema:{layout:"flat",fields:l},initialValues:n??{},formId:m,conditionConfig:g,onConditionConfigChange:y,onSubmit:_=>{if(!t)return;const O=Object.keys(g).length>0;i(t,{..._,[Ct]:O?g:void 0}),s()}})]})})},or=({isOpen:e,onClose:t,workflowId:r,workflowLabel:n,onFetchWorkflow:o})=>{const[i,s]=b.useState({status:"idle"});return b.useEffect(()=>{if(!e||!r){s({status:"idle"});return}s({status:"loading"}),o(r).then(l=>s({status:"loaded",state:l})).catch(l=>s({status:"error",message:(l==null?void 0:l.message)??"Failed to load workflow"}))},[e,r,o]),u.jsx(_e,{isOpen:e,onClose:t,title:n?`Preview: ${n}`:"Sub-Workflow Preview",icon:u.jsx(I.MdAccountTree,{size:18,color:"#00695c"}),width:700,children:u.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:24},children:[i.status==="idle"&&u.jsx("span",{style:{color:"#9e9e9e",fontSize:14},children:"Select a workflow to preview"}),i.status==="loading"&&u.jsxs("div",{style:{textAlign:"center",color:"#9e9e9e"},children:[u.jsx("div",{style:{width:32,height:32,borderRadius:"50%",border:"3px solid #e0e0e0",borderTopColor:"#00897b",animation:"spin 0.8s linear infinite",margin:"0 auto 12px"}}),u.jsx("span",{style:{fontSize:14},children:"Loading workflow…"}),u.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}),i.status==="error"&&u.jsxs("div",{style:{textAlign:"center",color:"#c62828"},children:[u.jsx(I.MdErrorOutline,{size:32,style:{marginBottom:8}}),u.jsx("p",{style:{margin:0,fontSize:14},children:i.message})]}),i.status==="loaded"&&u.jsx("div",{style:{width:"100%",flex:1},children:u.jsx(Xo,{state:i.state})})]})})},Xo=({state:e})=>{const[t,r]=b.useState(null),[n,o]=b.useState(null);return b.useEffect(()=>{Promise.all([Promise.resolve().then(()=>ei).then(i=>i.default),Promise.resolve().then(()=>require("./nodeRegistry.cjs")).then(i=>i.nodeTypeRegistry),Promise.resolve().then(()=>require("./templateRegistry.cjs")).then(i=>i.templateRegistry)]).then(([i,s,l])=>{r(()=>i),o({nodeTypeRegistry:s,templateRegistry:l})})},[]),!t||!n?u.jsx("div",{style:{color:"#9e9e9e",fontSize:13,textAlign:"center"},children:"Loading canvas…"}):u.jsx("div",{style:{width:"100%",height:480,border:"1px solid #e0e0e0",borderRadius:8,overflow:"hidden"},children:u.jsx(t,{nodeRegistry:n.nodeTypeRegistry,templateRegistry:n.templateRegistry,initialValue:e,readOnly:!0})})},ge=350,We=70,Ge=60,$e={startNode:40,endNode:40,addTriggerNode:56,triggerNode:110,actionNode:90,filterNode:90,approvalNode:90,delayNode:80,notificationNode:80},Vo={plusEdge:te.PlusEdge,labelPlusEdge:te.LabelPlusEdge,plainEdge:te.PlainEdge,edgeWithPlusLabel:te.EdgeWithPlusLabel,gatewayBranchEdge:te.GatewayBranchEdge};function Ot(){return[{id:"start",kind:"start",reactFlowType:"startNode"},{id:"addTrigger",kind:"addTrigger",reactFlowType:"addTriggerNode"},{id:"end",kind:"end",reactFlowType:"endNode"}]}function Ho(e,t,r,n="TB"){const o=new St.graphlib.Graph;return o.setGraph({rankdir:n,ranksep:70,nodesep:50}),o.setDefaultEdgeLabel(()=>({})),e.forEach(i=>{const s=r[i.id]??{width:ge,height:$e[i.type??""]??80};o.setNode(i.id,{width:s.width,height:s.height})}),t.forEach(i=>o.setEdge(i.source,i.target)),St.layout(o),e.map(i=>{var a,c;const s=o.node(i.id),l=((a=r[i.id])==null?void 0:a.width)??ge,d=((c=r[i.id])==null?void 0:c.height)??$e[i.type??""]??80;return{...i,position:{x:s.x-l/2,y:s.y-d/2}}})}const re=e=>e==="filter"||e==="approval";function Jo(e,t,r,n){const s=We,l=30,d=30,a={},c={},f=new Map;for(const p of e)f.set(p.id,p);for(const p of Object.values(t))for(const w of Object.values(p))for(const _ of w)f.set(_.id,_);const h=(p,w,_)=>{const O=n[p]??{width:ge,height:80};return a[p]={x:w-O.width/2,y:_},_+O.height},g=(p,w,_)=>{let O=_;for(const M of p)O=h(M.id,w,O)+s,re(M.kind)&&t[M.id]&&(O=y(M.id,w,O));return O},y=(p,w,_)=>{const O=w+180,M=t[p],R=Object.keys(M),B=f.get(p),Q=(B==null?void 0:B.branchLabels)??{pass:"Pass",fail:"Fail"},ue=a[p],F=n[p]??{height:80},be=ue.y+F.height,ye=[];let U=_;return R.forEach((oe,X)=>{const L=M[oe],V=U;ye.push({y:V-be,label:Q[oe]??oe,isPass:X===0}),U=g(L,O,U+d),X<R.length-1&&(U+=l)}),c[p]={branches:ye,height:U-be,indent:180},U};let m=Ge;for(const p of e)m=h(p.id,400,m)+s,re(p.kind)&&t[p.id]&&(m=y(p.id,400,m));return{nodes:r.map(p=>a[p.id]?{...p,position:a[p.id]}:p),railSpecs:c}}function It(e){return{id:e.id,type:e.reactFlowType,position:{x:0,y:0},data:{...e.nodeData,...e.formData,descriptorType:e.descriptorType},draggable:!1,selectable:!1}}function Zo(e,t,r,n,o){return{id:`e-${e.id}-${t.id}`,source:e.id,target:t.id,type:"plusEdge",style:{stroke:r},data:{onAddStepClick:n,referenceNodeType:e.reactFlowType,...o??{}}}}function Qo(e,t,r,n,o={},i="TB",s="horizontal"){const l=o.edgeColor??"#b0bec5",d=[],a=[],c=(y,m)=>{const p=t[y];if(!p)return;const _=m??{pass:"Pass",fail:"Fail"},O=Object.keys(p),M=(R,B,Q,ue)=>{if(R.length!==0){R.forEach(F=>d.push(It(F))),a.push({id:`e-${y}-${B}-start`,source:y,target:R[0].id,type:"gatewayBranchEdge",style:{stroke:l},data:{branch:B,filterId:y,label:Q,isFirst:ue===0,onAddStepClick:r,verticalRouting:s==="vertical"}});for(let F=1;F<R.length;F++)re(R[F-1].kind)||a.push(Zo(R[F-1],R[F],l,r,{filterId:y,branch:B}));for(const F of R)re(F.kind)&&t[F.id]&&c(F.id,F.branchLabels)}};O.forEach((R,B)=>{M(p[R],R,_[R]??R,B)})};for(let y=0;y<e.length;y++){const m=e[y];if(d.push(It(m)),y>0){const p=e[y-1],w=p.kind==="start"||p.kind==="addTrigger";if(p.kind==="filter"||p.kind==="approval")continue;a.push({id:`e-${p.id}-${m.id}`,source:p.id,target:m.id,type:w?"plainEdge":"plusEdge",style:{stroke:l},data:w?{}:{onAddStepClick:r,referenceNodeType:p.reactFlowType}})}(m.kind==="filter"||m.kind==="approval")&&t[m.id]&&c(m.id,m.branchLabels)}const f={};if(d.forEach(y=>{f[y.id]={width:ge,height:n[y.id]??$e[y.type??""]??80}}),!(Object.keys(t).length>0)){if(i==="LR"){let _=Ge;return{nodes:d.map(M=>{const R=f[M.id].width,B=f[M.id].height,Q={...M,position:{x:_,y:300-B/2}};return _+=R+We,Q}),edges:a}}const y=400;let m=Ge;return{nodes:d.map(w=>{const _=f[w.id].height,O={...w,position:{x:y-ge/2,y:m}};return m+=_+We,O}),edges:a}}if(s==="vertical"){const{nodes:y,railSpecs:m}=Jo(e,t,d,f);return{nodes:y.map(w=>m[w.id]?{...w,data:{...w.data,_branchRail:m[w.id]}}:w),edges:a}}return{nodes:Ho(d,a,f,i),edges:a}}const Ye=({nodeRegistry:e,templateRegistry:t,initialValue:r,nodeTypes:n,edgeTypes:o,onSave:i,readOnly:s=!1,theme:l={},messages:d,canvasOptions:a={},renderTriggerSelector:c,renderNodePicker:f,renderNodeConfig:h,onNodeClick:g,maxNodes:y,layoutDirection:m="TB",executionRecord:p,onFetchWorkflow:w})=>{const{fitView:_=!0,fitViewPadding:O=.3,showControls:M=!0,showMiniMap:R=!1,panOnScroll:B=!0,zoomOnScroll:Q=!1,minZoom:ue=.25,maxZoom:F=2,snapToGrid:be=!1,snapGrid:ye=[15,15],branchLayout:U="horizontal",nodeBody:oe="full"}=a,X=b.useMemo(()=>br.mergeMessages(d),[d]),[L,V]=b.useState(()=>(r==null?void 0:r.slots)??Ot()),[q,H]=b.useState(()=>(r==null?void 0:r.branches)??{}),[ie,G]=b.useState(null),[Ne,Je]=b.useState(null),[se,me]=b.useState(null),[Se,Ze]=b.useState(null),[xe,Qe]=b.useState(null),[J,et]=b.useState(()=>{const x=r==null?void 0:r.slots.find(E=>E.kind==="triggerFixed"),v=x!=null&&x.id.startsWith("trigger-")?x.id.slice(8):void 0;return v?t.lookup(v)??null:null}),[tt,sr]=b.useState({}),lr=b.useCallback(x=>{sr(x)},[]),ar=b.useMemo(()=>({...te.builtInNodeTypes,...n}),[n]),dr=b.useMemo(()=>({...Vo,...o}),[o]),cr=b.useMemo(()=>{const x=L.filter(E=>E.kind==="userTask").length,v=Object.values(q).flatMap(E=>Object.values(E).flat()).filter(E=>E.kind==="userTask").length;return x+v},[L,q]),rt=y??(J==null?void 0:J.maxTasks),nt=rt!==void 0&&cr>=rt,ee=b.useCallback(x=>{const v=L.find(E=>E.id===x);if(v)return v;for(const E of Object.values(q)){const N=Object.values(E).flat().find(k=>k.id===x);if(N)return N}return null},[L,q]),Ce=b.useCallback(x=>{s||(Je(x),G("nodeConfig"))},[s]),ot=b.useCallback(x=>{if(!s){if(L.some(v=>v.id===x)){const v=L.find(E=>E.id===x);if((v==null?void 0:v.kind)==="triggerFixed"){V(Ot()),H({}),et(null);return}V(E=>{const N=E.filter(k=>k.id!==x);return re((v==null?void 0:v.kind)??"")&&!N.some(k=>k.kind==="end")?[...N,{id:"end",kind:"end",reactFlowType:"endNode"}]:N}),H(E=>{const N={...E},k=j=>{N[j]&&(Object.values(N[j]).flat().filter(T=>re(T.kind)).forEach(T=>k(T.id)),delete N[j])};return k(x),N});return}H(v=>{const E=(k,j)=>{const T=[];for(const S of k)re(S.kind)&&j[S.id]&&(T.push(S.id),Object.values(j[S.id]).forEach(C=>T.push(...E(C,j))));return T},N={...v};for(const k of Object.keys(N))for(const j of Object.keys(N[k])){const T=N[k][j],S=T.findIndex(D=>D.id===x);if(S===-1||T[S].kind==="end")continue;const C=T[S];let A=T.filter(D=>D.id!==x);return C.kind==="filter"&&((C.id in N?E([C],N):[]).forEach(z=>delete N[z]),delete N[C.id],A.some(z=>z.kind==="end")||(A=[...A,{id:`end-${k}-${j}`,kind:"end",reactFlowType:"endNode"}])),N[k]={...N[k],[j]:A},N}return N})}},[s,L]),Oe=b.useCallback(()=>{s||G("triggerSelect")},[s]),it=b.useCallback((x,v)=>{s||nt||(me(x),Ze(v.filterId&&v.branch?{filterId:v.filterId,branch:v.branch}:null),G("nodePicker"))},[s,nt]),st=b.useCallback(x=>{et(x),G(null),H({}),V([{id:"start",kind:"start",reactFlowType:"startNode"},{id:`trigger-${x.triggerKey}`,kind:"triggerFixed",reactFlowType:"triggerNode",nodeData:{label:x.label,source:x.source},deletable:!1},{id:"end",kind:"end",reactFlowType:"endNode"}])},[]),lt=b.useCallback(()=>{const x=e.list();return(J!=null&&J.availableTasks?x.filter(E=>J.availableTasks.includes(E.type)):x).filter(E=>E.maxPerWorkflow===void 0?!0:L.filter(k=>k.descriptorType===E.type).length+Object.values(q).flatMap(k=>Object.values(k).flat()).filter(k=>k.descriptorType===E.type).length<E.maxPerWorkflow)},[e,J,L,q]),at=b.useCallback(x=>{if(!se)return;const v=`${x.type}-${Date.now()}`,E=x.reactFlowType==="filterNode"||x.reactFlowType==="approvalNode"||x.reactFlowType==="conditionBranchNode",N=x.branchLabels??{pass:"Pass",fail:"Fail"},k={id:v,kind:E?x.reactFlowType==="approvalNode"?"approval":"filter":"userTask",reactFlowType:x.reactFlowType,descriptorType:x.type,formData:{},nodeData:{title:x.label},deletable:!0,branchLabels:N};if(Se){const{filterId:j,branch:T}=Se;H(S=>{const C=[...S[j][T]];if(E){const Z=C.filter(le=>le.kind!=="end"),ht=Z.findIndex(le=>le.id===se),hr=ht===-1?Z.length:ht+1;return Z.splice(hr,0,k),{...S,[j]:{...S[j],[T]:Z},[v]:Object.fromEntries(Object.keys(N).map(le=>[le,[{id:`end-${v}-${le}`,kind:"end",reactFlowType:"endNode"}]]))}}const A=C.findIndex(Z=>Z.id===se),D=C.findIndex(Z=>Z.kind==="end"),z=A===-1?D===-1?C.length:D:A+1;return C.splice(z,0,k),{...S,[j]:{...S[j],[T]:C}}})}else E?(V(j=>{const T=j.findIndex(C=>C.id===se);return[...j.filter(C=>C.kind!=="end").slice(0,T+1),k]}),H(j=>({...j,[v]:Object.fromEntries(Object.keys(N).map(T=>[T,[{id:`end-${v}-${T}`,kind:"end",reactFlowType:"endNode"}]]))}))):V(j=>{const T=j.findIndex(S=>S.id===se);return T===-1?j:[...j.slice(0,T+1),k,...j.slice(T+1)]});me(null),Ze(null),Je(v),G("nodeConfig")},[se,Se]),dt=b.useCallback((x,v)=>{const E=k=>{const j=ee(x);if((j==null?void 0:j.descriptorType)!=="conditionBranch")return k;const T=v.branchConfigs??[],S=T.map(z=>z.key).filter(Boolean);if(S.length===0)return k;const C=k[x]??{},A={};S.forEach(z=>{A[z]=C[z]??[{id:`end-${x}-${z}`,kind:"end",reactFlowType:"endNode"}]});const D={};return T.forEach(z=>{z.key&&(D[z.key]=z.label||z.key)}),{...k,[x]:A}},N=(k,j)=>{if(k.descriptorType!=="conditionBranch")return{...k,formData:j};const T=j.branchConfigs??[],S={};return T.forEach(C=>{C.key&&(S[C.key]=C.label||C.key)}),{...k,formData:j,branchLabels:S}};if(L.some(k=>k.id===x)){H(k=>{const j=E(k);return V(T=>{const S=T.map(C=>C.id===x?N(C,v):C);return i==null||i({slots:S,branches:j}),S}),j});return}H(k=>{const T={...E(k)};for(const S of Object.keys(T)){const C=A=>A.map(D=>D.id===x?N(D,v):D);for(const A of Object.keys(T[S]))if(T[S][A].some(D=>D.id===x))return T[S]={...T[S],[A]:C(T[S][A])},i==null||i({slots:L,branches:T}),T}return T})},[L,q,ee,i]),K=b.useMemo(()=>ee(Ne??""),[ee,Ne]),ct=b.useMemo(()=>K!=null&&K.descriptorType?e.forType(K.descriptorType)??null:null,[K,e]),{nodes:ut,edges:ur}=b.useMemo(()=>Qo(L,q,s?null:it,tt,l,m,U),[L,q,s,it,tt,l,m,U]),ft=b.useMemo(()=>{const x=p?new Map(p.steps.map(v=>[v.nodeId,v])):null;return ut.map(v=>{let E={};if(x){const N=x.get(v.id);N&&(E={_executionStatus:N.status,_executionError:N.error})}return v.type==="subWorkflowNode"&&w&&(E.onPreview=N=>{var j;const k=ee(v.id);Qe({workflowId:N,workflowLabel:((j=k==null?void 0:k.formData)==null?void 0:j.workflowLabel)??void 0})}),Object.keys(E).length>0?{...v,data:{...v.data,...E}}:v})},[ut,p,w,ee]),fr=b.useMemo(()=>({onEditNode:Ce,onDeleteNode:ot,onAddStep:()=>{},onClickAddTrigger:Oe,messages:X,nodeRegistry:e,nodeBody:oe}),[Ce,ot,Oe,X,e,oe]);return u.jsx(te.WorkflowCanvasContext.Provider,{value:fr,children:u.jsxs("div",{style:{width:"100%",height:"100%",position:"relative","--ff-primary":l.primaryColor??"#1dbf60","--ff-edge-color":l.edgeColor??"#b0bec5","--ff-text":l.textColor??"#212121","--ff-muted":l.mutedTextColor??"#9ca3af","--ff-surface":l.surfaceColor??"#fff","--ff-border":l.borderColor??"#dee2e6","--ff-danger":l.dangerColor??"#d32f2f","--ff-radius":`${l.borderRadius??6}px`,"--ff-font-family":l.fontFamily},children:[u.jsxs(ae,{nodes:ft,edges:ur,nodeTypes:ar,edgeTypes:dr,fitView:_,fitViewOptions:{padding:O},nodesDraggable:!1,nodesConnectable:!1,panOnScroll:B,zoomOnScroll:Q,minZoom:ue,maxZoom:F,snapToGrid:be,snapGrid:ye,proOptions:{hideAttribution:!0},onNodeClick:(x,v)=>{const E=ee(v.id);E&&(g!=null&&g(E)||(E.kind==="addTrigger"||E.kind==="triggerFixed"?Oe():(E.kind==="userTask"||E.kind==="filter"||E.kind==="approval")&&Ce(v.id)))},children:[l.background!=="none"&&u.jsx(ae.Background,{variant:l.background,color:l.backgroundColor??"#e0e0e0",gap:20}),M&&u.jsx(ae.Controls,{showInteractive:!1}),R&&u.jsx(ae.MiniMap,{zoomable:!0,pannable:!0}),u.jsx(Yo,{onHeightsReady:lr,nodeCount:ft.length})]}),c?ie==="triggerSelect"&&c(t.list(),st,()=>G(null)):u.jsx(Uo,{open:ie==="triggerSelect",templates:t.list(),messages:X,onSelect:st,onClose:()=>G(null)}),f?ie==="nodePicker"&&f(lt(),at,()=>{G(null),me(null)}):u.jsx(qo,{open:ie==="nodePicker",availableDescriptors:lt(),messages:X,onSelect:at,onClose:()=>{G(null),me(null)}}),h?ie==="nodeConfig"&&h(ct??void 0,K,dt,()=>G(null)):u.jsx(Ko,{open:ie==="nodeConfig",nodeId:Ne,descriptor:ct,initialValues:K==null?void 0:K.formData,messages:X,onSave:dt,onClose:()=>G(null)}),w&&xe&&u.jsx(or,{isOpen:!!xe,onClose:()=>Qe(null),workflowId:xe.workflowId,workflowLabel:xe.workflowLabel,onFetchWorkflow:w})]})})},ei=Object.freeze(Object.defineProperty({__proto__:null,WorkflowCanvas:Ye,default:Ye},Symbol.toStringTag,{value:"Module"})),Pe="All";function ti({template:e,onSelect:t}){var o,i;const r=e.triggerCategory?$.TRIGGER_CATEGORY_STYLE[e.triggerCategory]:null,n=((o=e.skeletonState)==null?void 0:o.slots.filter(s=>s.kind==="userTask").length)??0;return u.jsxs("div",{role:"button",tabIndex:0,onClick:t,onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&t()},style:{border:"1.5px solid #e0e0e0",borderRadius:10,padding:"16px",background:"#fff",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s",display:"flex",flexDirection:"column",gap:8,outline:"none"},onMouseEnter:s=>{s.currentTarget.style.borderColor="#1976d2",s.currentTarget.style.boxShadow="0 2px 8px rgba(25,118,210,0.12)"},onMouseLeave:s=>{s.currentTarget.style.borderColor="#e0e0e0",s.currentTarget.style.boxShadow="none"},children:[u.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[e.icon&&u.jsx("div",{style:{flexShrink:0,width:36,height:36,borderRadius:8,background:"#f5f5f5",display:"flex",alignItems:"center",justifyContent:"center"},children:e.icon}),u.jsxs("div",{style:{flex:1,minWidth:0},children:[u.jsx("div",{style:{fontWeight:600,fontSize:14,color:"#212121",marginBottom:2},children:e.label}),e.description&&u.jsx("div",{style:{fontSize:12,color:"#757575",lineHeight:1.4,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:e.description})]})]}),u.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:4},children:[r&&u.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:10,background:r.bg,color:r.color},children:r.label}),(i=e.tags)==null?void 0:i.map(s=>u.jsx("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:10,background:"#f5f5f5",color:"#616161"},children:s},s)),n>0&&u.jsxs("span",{style:{fontSize:10,color:"#9e9e9e",marginLeft:"auto"},children:[n," step",n!==1?"s":""]})]}),e.author&&u.jsxs("div",{style:{fontSize:11,color:"#bdbdbd"},children:["by ",e.author]})]})}const ri=({templates:e,onSelectTemplate:t,onStartFromScratch:r})=>{const[n,o]=b.useState(""),[i,s]=b.useState(Pe),l=b.useMemo(()=>{const a=new Set;return e.forEach(c=>{c.category&&a.add(c.category)}),[Pe,...Array.from(a)]},[e]),d=b.useMemo(()=>{let a=e;if(i!==Pe&&(a=a.filter(c=>c.category===i)),n.trim()){const c=n.toLowerCase();a=a.filter(f=>{var h,g;return f.label.toLowerCase().includes(c)||((h=f.description)==null?void 0:h.toLowerCase().includes(c))||((g=f.tags)==null?void 0:g.some(y=>y.toLowerCase().includes(c)))})}return[...a].sort((c,f)=>(f.popularity??0)-(c.popularity??0))},[e,i,n]);return u.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:"inherit"},children:[u.jsxs("div",{style:{padding:"24px 24px 0",borderBottom:"1px solid #f0f0f0",paddingBottom:16},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16},children:[u.jsxs("div",{children:[u.jsx("h2",{style:{margin:0,fontSize:20,fontWeight:700,color:"#212121"},children:"Workflow Templates"}),u.jsx("p",{style:{margin:"4px 0 0",fontSize:13,color:"#757575"},children:"Choose a pre-built template or start from scratch"})]}),r&&u.jsxs("button",{onClick:r,style:{display:"flex",alignItems:"center",gap:6,padding:"8px 16px",border:"1.5px solid #1976d2",borderRadius:6,background:"#fff",color:"#1976d2",fontSize:13,fontWeight:600,cursor:"pointer"},children:[u.jsx(I.MdAdd,{size:16}),"Start from Scratch"]})]}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"#f5f5f5",borderRadius:8,padding:"8px 12px",marginBottom:12},children:[u.jsx(I.MdSearch,{size:18,color:"#9e9e9e"}),u.jsx("input",{value:n,onChange:a=>o(a.target.value),placeholder:"Search templates...",style:{border:"none",background:"transparent",outline:"none",fontSize:14,color:"#212121",flex:1}})]}),l.length>1&&u.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:l.map(a=>u.jsx("button",{onClick:()=>s(a),style:{padding:"4px 12px",borderRadius:20,border:"1.5px solid",borderColor:i===a?"#1976d2":"#e0e0e0",background:i===a?"#e3f2fd":"#fff",color:i===a?"#1565c0":"#616161",fontSize:12,fontWeight:i===a?600:400,cursor:"pointer"},children:a},a))})]}),u.jsx("div",{style:{flex:1,overflowY:"auto",padding:24},children:d.length===0?u.jsxs("div",{style:{textAlign:"center",padding:"40px 0",color:"#9e9e9e"},children:[u.jsx(I.MdCategory,{size:36,style:{marginBottom:8}}),u.jsx("p",{style:{margin:0,fontSize:14},children:"No templates found"})]}):u.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:16},children:d.map(a=>u.jsx(ti,{template:a,onSelect:()=>t(a)},a.triggerKey))})})]})},we={running:{label:"Running",color:$.EXECUTION_STATUS_COLOR.running,icon:b.createElement(I.MdPlayArrow,{size:14})},success:{label:"Success",color:$.EXECUTION_STATUS_COLOR.success,icon:b.createElement(I.MdCheckCircle,{size:14})},failed:{label:"Failed",color:$.EXECUTION_STATUS_COLOR.failed,icon:b.createElement(I.MdError,{size:14})},cancelled:{label:"Cancelled",color:$.EXECUTION_STATUS_COLOR.cancelled,icon:b.createElement(I.MdCancel,{size:14})}},ni={pending:{color:$.EXECUTION_STATUS_COLOR.pending,icon:b.createElement(I.MdHourglassEmpty,{size:14})},running:{color:$.EXECUTION_STATUS_COLOR.running,icon:b.createElement(I.MdPlayArrow,{size:14})},success:{color:$.EXECUTION_STATUS_COLOR.success,icon:b.createElement(I.MdCheckCircle,{size:14})},failed:{color:$.EXECUTION_STATUS_COLOR.failed,icon:b.createElement(I.MdError,{size:14})},skipped:{color:$.EXECUTION_STATUS_COLOR.skipped,icon:b.createElement(I.MdCancel,{size:14})}};function Ue(e){try{return new Date(e).toLocaleString()}catch{return e}}function ir(e,t){try{const r=new Date(t??new Date().toISOString()).getTime()-new Date(e).getTime();return r<1e3?`${r}ms`:r<6e4?`${(r/1e3).toFixed(1)}s`:`${Math.floor(r/6e4)}m ${Math.floor(r%6e4/1e3)}s`}catch{return"—"}}function oi({step:e}){const[t,r]=b.useState(!1),n=ni[e.status],o=!!(e.inputs||e.outputs||e.error);return u.jsxs("div",{style:{borderBottom:"1px solid #f5f5f5"},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",cursor:o?"pointer":"default"},onClick:()=>{o&&r(i=>!i)},role:o?"button":void 0,tabIndex:o?0:void 0,onKeyDown:i=>{o&&(i.key==="Enter"||i.key===" ")&&r(s=>!s)},children:[u.jsx("span",{style:{color:n.color,flexShrink:0},children:b.cloneElement(n.icon,{color:n.color})}),u.jsx("span",{style:{flex:1,fontSize:13,color:"#212121"},children:e.label||e.nodeId}),e.branchTaken&&u.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"#e3f2fd",color:"#1565c0",fontWeight:600},children:e.branchTaken}),u.jsx("span",{style:{fontSize:11,color:"#9e9e9e",flexShrink:0},children:e.startedAt?ir(e.startedAt,e.completedAt):"—"}),o&&u.jsx("span",{style:{color:"#9e9e9e",flexShrink:0},children:t?b.createElement(I.MdExpandLess,{size:16}):b.createElement(I.MdExpandMore,{size:16})})]}),t&&o&&u.jsxs("div",{style:{padding:"0 12px 10px 32px",fontSize:12},children:[e.error&&u.jsx("div",{style:{padding:"6px 10px",borderRadius:6,background:"#ffebee",color:"#c62828",marginBottom:6},children:e.error}),e.inputs&&Object.keys(e.inputs).length>0&&u.jsxs("details",{style:{marginBottom:4},children:[u.jsx("summary",{style:{cursor:"pointer",color:"#616161",marginBottom:4},children:"Inputs"}),u.jsx("pre",{style:{margin:0,fontSize:11,background:"#f5f5f5",padding:8,borderRadius:4,overflowX:"auto"},children:JSON.stringify(e.inputs,null,2)})]}),e.outputs&&Object.keys(e.outputs).length>0&&u.jsxs("details",{children:[u.jsx("summary",{style:{cursor:"pointer",color:"#616161",marginBottom:4},children:"Outputs"}),u.jsx("pre",{style:{margin:0,fontSize:11,background:"#f5f5f5",padding:8,borderRadius:4,overflowX:"auto"},children:JSON.stringify(e.outputs,null,2)})]})]})]})}function ii({record:e,selected:t,onSelect:r}){const n=we[e.status];return u.jsxs("div",{role:"button",tabIndex:0,onClick:r,onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&r()},style:{padding:"10px 14px",borderBottom:"1px solid #f0f0f0",cursor:"pointer",background:t?"#e3f2fd":"#fff",display:"flex",alignItems:"center",gap:10,outline:"none"},children:[u.jsx("span",{style:{color:n.color,flexShrink:0},children:b.cloneElement(n.icon,{color:n.color,size:16})}),u.jsxs("div",{style:{flex:1,minWidth:0},children:[u.jsx("div",{style:{fontSize:12,color:"#212121",fontWeight:t?600:400,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Ue(e.triggeredAt)}),u.jsxs("div",{style:{fontSize:11,color:"#9e9e9e"},children:[e.triggeredBy?`by ${e.triggeredBy}`:"System"," · ",e.steps.length," step",e.steps.length!==1?"s":""]})]}),u.jsx("span",{style:{fontSize:11,fontWeight:600,color:n.color,flexShrink:0},children:n.label}),u.jsx(I.MdChevronRight,{size:14,color:"#bdbdbd"})]})}const si=({records:e,onViewOnCanvas:t})=>{var s;const[r,n]=b.useState(((s=e[0])==null?void 0:s.id)??null),o=e.find(l=>l.id===r)??null,i=[...e].sort((l,d)=>new Date(d.triggeredAt).getTime()-new Date(l.triggeredAt).getTime());return e.length===0?u.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:300,color:"#9e9e9e",gap:8},children:[u.jsx(I.MdSchedule,{size:36}),u.jsx("p",{style:{margin:0,fontSize:14},children:"No executions yet"}),u.jsx("p",{style:{margin:0,fontSize:12},children:"Run history will appear here"})]}):u.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:"inherit",border:"1px solid #e0e0e0",borderRadius:8,overflow:"hidden"},children:[u.jsxs("div",{style:{width:260,flexShrink:0,borderRight:"1px solid #e0e0e0",overflowY:"auto",background:"#fafafa"},children:[u.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #e0e0e0",fontWeight:600,fontSize:13,color:"#212121"},children:["Run History (",e.length,")"]}),i.map(l=>u.jsx(ii,{record:l,selected:l.id===r,onSelect:()=>n(l.id)},l.id))]}),u.jsx("div",{style:{flex:1,overflowY:"auto"},children:o?u.jsxs("div",{children:[u.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid #f0f0f0",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12},children:[u.jsxs("div",{children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[b.cloneElement(we[o.status].icon,{color:we[o.status].color,size:18}),u.jsx("span",{style:{fontWeight:700,fontSize:15,color:"#212121"},children:we[o.status].label})]}),u.jsxs("div",{style:{fontSize:12,color:"#757575",display:"flex",flexDirection:"column",gap:2},children:[u.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[u.jsx(I.MdSchedule,{size:13})," ",Ue(o.triggeredAt),o.completedAt&&` → ${Ue(o.completedAt)} (${ir(o.triggeredAt,o.completedAt)})`]}),o.triggeredBy&&u.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[u.jsx(I.MdPerson,{size:13})," ",o.triggeredBy]})]})]}),t&&u.jsx("button",{onClick:()=>t(o),style:{padding:"6px 12px",border:"1.5px solid #1976d2",borderRadius:6,background:"#fff",color:"#1976d2",fontSize:12,fontWeight:600,cursor:"pointer",flexShrink:0},children:"View on Canvas"})]}),o.error&&u.jsx("div",{style:{margin:"12px 16px",padding:"10px 14px",borderRadius:6,background:"#ffebee",color:"#c62828",fontSize:13},children:o.error}),u.jsxs("div",{children:[u.jsxs("div",{style:{padding:"10px 12px",fontSize:12,fontWeight:600,color:"#757575",borderBottom:"1px solid #f0f0f0"},children:["STEPS (",o.steps.length,")"]}),o.steps.map((l,d)=>u.jsx(oi,{step:l},`${l.nodeId}-${d}`))]}),o.inputs&&Object.keys(o.inputs).length>0&&u.jsx("div",{style:{padding:"10px 16px"},children:u.jsxs("details",{children:[u.jsx("summary",{style:{cursor:"pointer",fontSize:12,fontWeight:600,color:"#757575",marginBottom:6},children:"TRIGGER INPUTS"}),u.jsx("pre",{style:{margin:0,fontSize:11,background:"#f5f5f5",padding:10,borderRadius:4,overflowX:"auto"},children:JSON.stringify(o.inputs,null,2)})]})})]}):u.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#9e9e9e",fontSize:14},children:"Select a run to see details"})})]})},li={slots:[{id:"start",kind:"start",reactFlowType:"startNode",deletable:!1},{id:"trigger-END_USER_CREATION",kind:"triggerFixed",reactFlowType:"triggerNode",deletable:!0,label:"New User Registration",nodeData:{label:"New User Registration"}},{id:"notification-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Welcome Email",nodeData:{title:"Welcome Email"}},{id:"approval-1",kind:"approval",reactFlowType:"approvalNode",descriptorType:"approval",deletable:!0,label:"Manager Approval",branchLabels:{pass:"Approved",fail:"Rejected"}},{id:"end",kind:"end",reactFlowType:"endNode",deletable:!1}],branches:{"approval-1":{pass:[{id:"notification-pass-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Approval Confirmed",nodeData:{title:"Approval Confirmed"}}],fail:[{id:"notification-fail-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Rejection Notice",nodeData:{title:"Rejection Notice"}}]}}},ai={slots:[{id:"start",kind:"start",reactFlowType:"startNode",deletable:!1},{id:"trigger-ACCESS_REQUEST",kind:"triggerFixed",reactFlowType:"triggerNode",deletable:!0,label:"Access Request Submitted",nodeData:{label:"Access Request Submitted"}},{id:"approval-1",kind:"approval",reactFlowType:"approvalNode",descriptorType:"approval",deletable:!0,label:"Access Approval",branchLabels:{pass:"Approved",fail:"Denied"}},{id:"end",kind:"end",reactFlowType:"endNode",deletable:!1}],branches:{"approval-1":{pass:[{id:"restApi-1",kind:"userTask",reactFlowType:"restApiNode",descriptorType:"restApi",deletable:!0,label:"Provision Access",nodeData:{title:"Provision Access"}},{id:"notification-pass-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Access Granted Email",nodeData:{title:"Access Granted Email"}}],fail:[{id:"notification-fail-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Access Denied Email",nodeData:{title:"Access Denied Email"}}]}}},di={slots:[{id:"start",kind:"start",reactFlowType:"startNode",deletable:!1},{id:"trigger-USER_DEACTIVATION",kind:"triggerFixed",reactFlowType:"triggerNode",deletable:!0,label:"User Deactivation",nodeData:{label:"User Deactivation"}},{id:"delay-1",kind:"userTask",reactFlowType:"delayNode",descriptorType:"delay",deletable:!0,label:"Grace Period",nodeData:{title:"Grace Period",duration:7,unit:"days"},formData:{duration:7,unit:"days"}},{id:"notification-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Notify IT Team",nodeData:{title:"Notify IT Team"}},{id:"end",kind:"end",reactFlowType:"endNode",deletable:!1}],branches:{}},ci={slots:[{id:"start",kind:"start",reactFlowType:"startNode",deletable:!1},{id:"trigger-WEBHOOK_TRIGGER",kind:"triggerFixed",reactFlowType:"webhookTriggerNode",deletable:!0,label:"Incoming Webhook",nodeData:{label:"Incoming Webhook"}},{id:"restApi-1",kind:"userTask",reactFlowType:"restApiNode",descriptorType:"restApi",deletable:!0,label:"Call External API",nodeData:{title:"Call External API"}},{id:"notification-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Notify on Completion",nodeData:{title:"Notify on Completion"}},{id:"end",kind:"end",reactFlowType:"endNode",deletable:!1}],branches:{}};exports.FlowForgeCanvas=Ye;exports.SubWorkflowPreviewDrawer=or;exports.WorkflowExecutionHistory=si;exports.WorkflowTemplateLibrary=ri;exports.accessRequestSkeleton=ai;exports.offboardingSkeleton=di;exports.userOnboardingSkeleton=li;exports.webhookIntegrationSkeleton=ci;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),l=require("reactflow"),T=require("@mui/material"),ce=require("react-icons/gr"),V=require("react"),de=require("./messages-O9Tw_XXR.js"),y=require("react-icons/md"),L=require("react-icons/fa"),ae=require("react-icons/fi"),C=require("./canvasTokens-gKNYrPl4.js"),Z=V.createContext({onEditNode:()=>{},onDeleteNode:()=>{},onAddStep:()=>{},onClickAddTrigger:()=>{},messages:de.defaultFlowForgeMessages,nodeRegistry:null,nodeBody:"full"}),w=()=>V.useContext(Z),Y=()=>e.jsxs("div",{style:{width:350,display:"flex",justifyContent:"center"},children:[e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0,left:"50%"}}),e.jsx("div",{style:{padding:"8px 28px",borderRadius:999,background:"#f5f5f5",border:"1.5px solid #bdbdbd",fontSize:13,fontWeight:500,color:"#424242",userSelect:"none"},children:"Start"})]}),J=()=>e.jsxs("div",{style:{width:350,display:"flex",justifyContent:"center"},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0,left:"50%"}}),e.jsx("div",{style:{padding:"8px 28px",borderRadius:999,background:"#f5f5f5",border:"1.5px solid #bdbdbd",fontSize:13,fontWeight:500,color:"#424242",userSelect:"none"},children:"End"})]}),Q=()=>{const{onClickAddTrigger:t,messages:o}=w();return e.jsxs("div",{style:{width:350,display:"flex",justifyContent:"center"},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0,left:"50%"}}),e.jsx(T.Tooltip,{title:o.addTriggerTooltip,placement:"top",arrow:!0,children:e.jsxs("div",{onClick:t,role:"button",tabIndex:0,onKeyDown:f=>{f.key==="Enter"&&t()},style:{padding:"10px 24px",borderRadius:8,border:"1.5px dashed #d0d0d0",background:"#fff",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[e.jsx(ce.GrTrigger,{size:16}),e.jsx("span",{className:"ff-text-black",style:{fontSize:13},"data-testid":"add-trigger-btn-text",children:o.addTriggerButton})]})}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0,left:"50%"}})]})},pe=({id:t})=>{const{onAddStep:o}=w();return e.jsxs("div",{onClick:()=>o(t),role:"button",tabIndex:0,onKeyDown:f=>{f.key==="Enter"&&o(t)},style:{width:28,height:28,borderRadius:"50%",border:"1.5px solid #9e9e9e",background:"#fff",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:18,color:"#757575",lineHeight:1,userSelect:"none"},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),"+",e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})};function xe(t){return t?t==="END_USER_CREATION"?"New User Registration":t==="END_USER_UPDATION"?"On User Update":t.replace(/[_-]+/g," ").replace(/\b\w/g,o=>o.toUpperCase()):""}function he(t){const o=typeof t=="string"?t:t.value??"";return o==="SIGNUP_FLOW"?"User Self-Registration":o==="ADMIN_CREATION_FLOW"?"Create User via Admin Portal":o==="SHEDULAR"?"Scheduler":typeof t!="string"&&t.label?t.label:o.replace(/[_-]+/g," ").replace(/\b\w/g,f=>f.toUpperCase())}const X=({data:t})=>{const{onClickAddTrigger:o}=w(),{type:f,eventType:p,sources:r,label:i,source:x,previewWorkflow:s,executionStatus:n,infoText:d="This node decides the flow trigger type and configuration."}=t??{},g=m=>{m==null||m.stopPropagation(),o()},h=Array.isArray(r)&&r.length>0,j=!!(i||x),a=f==="scheduler"?"Scheduler Trigger":f==="event"||h||j?"Event Trigger Source":"Select Trigger",c=f==="scheduler"?e.jsx("span",{children:"Scheduler to be configured"}):f==="event"||h?e.jsxs("div",{children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center",children:[e.jsx("span",{style:{fontWeight:600},children:xe(p)}),e.jsx("span",{className:"ff-ms-2 ff-text-muted",style:{fontSize:12},children:"via"})]}),e.jsx("div",{className:"ff-d-flex ff-flex-wrap ff-mt-2",style:{gap:4},children:h?r.map((m,k)=>e.jsx(T.Chip,{label:he(m),variant:"outlined",size:"small",className:"ff-text-dark"},k)):e.jsx("span",{className:"ff-text-muted",style:{fontSize:12},children:"No source selected"})})]}):j?e.jsxs("div",{className:"ff-d-flex ff-flex-wrap ff-align-items-center",style:{gap:6},children:[i&&e.jsx("span",{style:{fontWeight:600},children:i}),x&&e.jsx(T.Chip,{label:x,variant:"outlined",size:"small"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:g,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&g(m)},style:{cursor:"pointer",color:"#1e88e5"},children:"Click to select a trigger to start your workflow"}),N=n?e.jsxs(e.Fragment,{children:[n.status==="success"&&e.jsx(L.FaCheckCircle,{size:16,color:"#1DBF60",style:{marginRight:8}}),n.status==="failed"&&e.jsx(L.FaTimesCircle,{size:16,color:"#f44336",style:{marginRight:8}})]}):e.jsxs("div",{className:"ff-d-flex ff-align-items-center",children:[!s&&e.jsx("div",{role:"button",tabIndex:0,onClick:g,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&g(m)},className:"ff-me-2",style:{cursor:"pointer",color:"#212121"},"aria-label":"Edit trigger",children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx(T.Tooltip,{title:e.jsx("div",{children:d}),placement:"right",arrow:!0,children:e.jsx("span",{children:e.jsx(y.MdInfoOutline,{color:"gray",size:16})})})]});return e.jsxs("div",{style:{width:350},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #a5d6a7",borderRadius:8,background:"#fff",overflow:"hidden"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"rgba(76,175,80,0.1)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(y.MdInput,{size:16,color:"#388e3c"})}),e.jsx("span",{style:{fontSize:14,fontWeight:600,color:"#212121"},children:a})]}),e.jsx("div",{className:"ff-d-flex ff-align-items-center",children:N})]}),e.jsx("div",{style:{background:"#f5f5f5",fontSize:12,color:"#212121",padding:"10px 6px",margin:"0 12px 12px",borderRadius:6},children:c})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0},id:"1"})]})},ee=({rail:t,cardWidth:o})=>{const f=o/2;o/2+t.indent;const p="var(--ff-edge-color, #b0bec5)";return e.jsxs("svg",{width:o+t.indent+200,height:t.height,style:{position:"absolute",left:0,top:"100%",pointerEvents:"none",overflow:"visible"},children:[e.jsx("line",{x1:f,y1:0,x2:f,y2:t.height,stroke:p,strokeWidth:1.5}),t.branches.map((r,i)=>{const x=r.y;return e.jsxs("g",{transform:`translate(0, ${x})`,children:[e.jsx("rect",{x:f-5,y:-5,width:10,height:10,fill:"#fff",stroke:p,strokeWidth:1.5,transform:`rotate(45, ${f}, 0)`}),e.jsx("text",{x:f+14,y:4,fontSize:12,fontWeight:500,fill:"var(--ff-text, #212121)",style:{fontFamily:"sans-serif"},children:r.label})]},i)})]})},te=({id:t,data:o})=>{const{onEditNode:f,onDeleteNode:p}=w(),{conditions:r=[],infoText:i="Filter conditions applied to workflow data",_branchRail:x}=o;return e.jsxs("div",{style:{width:350,position:"relative"},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #ffe082",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-mb-2 ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center",children:[e.jsx("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded",style:{width:25,height:25,background:"rgba(255,160,0,0.1)"},children:e.jsx(ae.FiFilter,{className:"ff-text-warning",size:16})}),e.jsx("span",{className:"ff-ms-2 ff-fw-medium ff-text-dark",style:{fontSize:14},children:"Filter"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:s=>{s.stopPropagation(),f(t)},onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),f(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:s=>{s.stopPropagation(),p(t)},onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})}),e.jsx(T.Tooltip,{title:i,placement:"right",arrow:!0,children:e.jsx("div",{className:"ff-ms-2",children:e.jsx(y.MdInfoOutline,{color:"gray",size:16})})})]})]}),e.jsx("div",{className:"ff-p-2 ff-mx-2 ff-mb-2 ff-rounded",style:{background:"#fafafa",fontSize:12},children:r.length===0?e.jsx("span",{className:"ff-text-muted",children:"No conditions configured"}):r.map((s,n)=>e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-mb-1",children:[e.jsx("p",{className:"ff-m-0 ff-fw-bold ff-me-1 ff-text-truncate",style:{maxWidth:100},title:s.field,children:s.field}),e.jsx("span",{className:"ff-text-muted",children:s.operator}),e.jsx("p",{className:"ff-text-dark ff-text-truncate ff-mx-1 ff-m-0",title:s.value,children:s.value}),n<r.length-1&&e.jsx("p",{className:"ff-bg-primary ff-text-white ff-fw-bold ff-ms-1 ff-px-1 ff-rounded-1 ff-m-0",children:s.logicalOperator})]},n))})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}}),x&&e.jsx(ee,{rail:x,cardWidth:350})]})},se=({id:t,data:o})=>{const{onEditNode:f,onDeleteNode:p,nodeRegistry:r,nodeBody:i="full"}=w(),{title:x="Task",descriptorType:s,groupBlocks:n,groups:d,roles:g,groupId:h,roleId:j,infoText:a=""}=o,c=s?r==null?void 0:r.forType(s):void 0,N=c==null?void 0:c.icon,m=u=>u==null?"":typeof u=="string"?u:typeof u=="object"&&"label"in u?String(u.label):String(u),k=u=>Array.isArray(u)?u.map(m).filter(Boolean):u!=null&&u!==""?[m(u)]:[],b=(n==null?void 0:n.flatMap(u=>u.groups??[]))??[...k(d),...k(g),...k(h),...k(j)],P=b.length>0;return e.jsxs("div",{style:{width:350},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b0bec5",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[N&&e.jsx("div",{style:{display:"flex",alignItems:"center"},children:N}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:x})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:u=>{u.stopPropagation(),f(t)},onKeyDown:u=>{u.key==="Enter"&&(u.stopPropagation(),f(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:u=>{u.stopPropagation(),p(t)},onKeyDown:u=>{u.key==="Enter"&&(u.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})}),a&&e.jsx(T.Tooltip,{title:a,placement:"right",arrow:!0,children:e.jsx("div",{className:"ff-ms-2",children:e.jsx(y.MdInfoOutline,{color:"gray",size:16})})})]})]}),i!=="title-only"&&e.jsx("div",{className:"ff-mx-2 ff-mb-2 ff-p-2 ff-rounded",style:{background:"#fafafa",fontSize:12},children:c!=null&&c.renderNode?c.renderNode(o):P?e.jsx("div",{className:"ff-d-flex ff-flex-wrap ff-gap-1",children:b.map((u,E)=>e.jsx("span",{className:"ff-badge ff-bg-dark ff-text-white ff-py-1 ff-px-2 ff-rounded",style:{fontSize:11},title:u,children:u},E))}):e.jsx("span",{className:"ff-text-muted",children:"Not configured"})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},W=5,ne=({id:t,data:o})=>{const{onEditNode:f,onDeleteNode:p}=w(),{approvalData:r,isPreview:i=!1,_branchRail:x}=o,s=(r==null?void 0:r.policy)??{},n=s.stages??[],d=n.length,g=n.slice(0,W),h=d-W,j=s.name??s.policyName??"Untitled Policy";return e.jsxs("div",{style:{width:350,position:"relative"},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #ffe082",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-mb-2 ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded",style:{width:25,height:25,background:"rgba(251,192,45,0.2)"},children:e.jsx(y.MdCheckCircle,{style:{color:"#FBC02D"},size:16})}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:"Approval Policy"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[!i&&e.jsx("div",{role:"button",tabIndex:0,style:{cursor:"pointer"},onClick:a=>{a.stopPropagation(),f(t)},onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),f(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16,className:"ff-text-secondary"})}),!i&&e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,style:{cursor:"pointer"},onClick:a=>{a.stopPropagation(),p(t)},onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})}),e.jsx(T.Tooltip,{title:"This approval policy determines who must approve a request before the workflow continues.",arrow:!0,placement:"right",children:e.jsx("span",{className:"ff-ms-2 ff-d-inline-flex",children:e.jsx(y.MdInfoOutline,{color:"gray",size:16})})})]})]}),e.jsxs("div",{className:"ff-p-2 ff-rounded ff-mx-2 ff-mb-2",style:{background:"#FCFCFC"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-start ff-align-items-center ff-mb-2",children:[e.jsx("h6",{className:"ff-text-dark ff-mb-0 ff-text-truncate ff-flex-grow-1 ff-me-2",style:{fontSize:13,fontWeight:700},title:j,children:j}),e.jsxs("span",{className:"ff-badge ff-rounded-pill ff-px-2 ff-py-1 ff-flex-shrink-0",style:{background:"#FFF9C4",color:"#616161",fontSize:11,fontWeight:600},children:[d," Stage",d!==1?"s":""]})]}),n.length>0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[g.map((a,c)=>{var E,I,S;const N=((E=a.stageName)==null?void 0:E.trim())||`Stage ${c+1}`,m=Array.isArray(a.userIds)?a.userIds.length:0,k=((I=a.groupName)==null?void 0:I.trim())??"",b=((S=a.roleName)==null?void 0:S.trim())??"",P=m>0||k||b;let u="Not configured";return k?u=`Group: ${k}`:b?u=`Role: ${b}`:m>0&&(u=`${m} approver${m!==1?"s":""}`),e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{className:"ff-rounded-circle ff-d-flex ff-align-items-center ff-justify-content-center ff-flex-shrink-0",style:{width:28,height:28,background:"#FFF9C4",color:"#5D4037",fontSize:12,fontWeight:700},children:c+1}),e.jsxs("div",{className:"ff-flex-grow-1 ff-rounded ff-p-2 ff-d-flex ff-justify-content-between ff-align-items-center ff-border",style:{background:"#FFFDE7",borderColor:"#FEE79A"},children:[e.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#212121"},children:N}),e.jsxs("span",{className:`ff-d-flex ff-align-items-center ff-gap-1 ${P?"ff-text-dark":"ff-text-muted"}`,style:{fontSize:12},children:[e.jsx(y.MdPeople,{size:16,className:"ff-flex-shrink-0",style:{color:P?"#5D4037":"#9E9E9E"}}),u]})]})]},c)}),h>0&&e.jsxs("div",{className:"ff-text-center ff-fw-bold ff-py-2 ff-border ff-rounded",style:{fontSize:11,color:"#1976d2",borderColor:"#FEE79A",background:"#FFFDE7",borderStyle:"dashed",cursor:i?"default":"pointer"},role:i?void 0:"button",tabIndex:i?void 0:0,onClick:a=>{i||(a.stopPropagation(),f(t))},onKeyDown:a=>{i||a.key!=="Enter"||(a.stopPropagation(),f(t))},children:["+ ",h," More Stage",h>1?"s":""]})]}):e.jsx("div",{className:"ff-text-center ff-py-3 ff-rounded ff-border",style:{fontSize:12,color:"#9e9e9e",background:"#FFFDE7",borderColor:"#FEE79A",borderStyle:"dashed"},children:"No stages configured"})]})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}}),x&&e.jsx(ee,{rail:x,cardWidth:350})]})},oe=({id:t,data:o})=>{const{onEditNode:f,onDeleteNode:p}=w(),{duration:r,unit:i}=o,x=r!=null&&i,s=x?`Wait ${r} ${i}`:"Not configured";return e.jsxs("div",{style:{width:350},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b0bec5",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded",style:{width:25,height:25,background:"rgba(33,150,243,0.1)"},children:e.jsx(y.MdSchedule,{size:16,color:"#1976d2"})}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:"Delay"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:n=>{n.stopPropagation(),f(t)},onKeyDown:n=>{n.key==="Enter"&&(n.stopPropagation(),f(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:n=>{n.stopPropagation(),p(t)},onKeyDown:n=>{n.key==="Enter"&&(n.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{className:"ff-mx-2 ff-mb-2 ff-p-2 ff-rounded",style:{background:"#fafafa",fontSize:12},children:e.jsx("span",{className:x?"ff-text-dark ff-fw-medium":"ff-text-muted",children:s})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},F={email:{label:"Email",bg:"#e3f2fd",color:"#1565c0",iconType:y.MdEmail},slack:{label:"Slack",bg:"#e8f5e9",color:"#2e7d32",iconType:y.MdNotifications},teams:{label:"MS Teams",bg:"#ede7f6",color:"#4527a0",iconType:y.MdNotifications},sms:{label:"SMS",bg:"#fce4ec",color:"#880e4f",iconType:y.MdSms},"in-app":{label:"In-App",bg:"#fff3e0",color:"#e65100",iconType:y.MdNotifications},webhook:{label:"Webhook",bg:"#f3e5f5",color:"#6a1b9a",iconType:y.MdWebhook}},ge={label:"Notification",bg:"rgba(156,39,176,0.1)",color:"#7b1fa2",iconType:y.MdNotifications};function ue(t){var o;switch(t.channel){case"email":return((o=t.emailTo)==null?void 0:o.join(", "))??t.recipient??null;case"slack":return t.slackChannel??null;case"teams":return t.teamsMessage?"Message configured":null;case"sms":return t.smsTo??null;case"in-app":return t.inAppRecipient??null;case"webhook":return t.webhookUrl??null;default:return t.recipient??null}}function ye(t){switch(t.channel){case"email":return t.emailSubject??t.subject??null;case"slack":{const o=t.slackMessage;return o?o.length>60?`${o.slice(0,60)}…`:o:null}case"in-app":return t.inAppTitle??null;default:return t.subject??null}}const ie=({id:t,data:o})=>{const{onEditNode:f,onDeleteNode:p}=w(),r=o,i=r.channel&&F[r.channel]?F[r.channel]:ge,x=ue(r),s=ye(r),n=!!(r.channel&&x),d=i.iconType;return e.jsxs("div",{style:{width:C.NODE_WIDTH},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b0bec5",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded",style:{width:25,height:25,background:i.bg},children:e.jsx(d,{size:16,color:i.color})}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:r.channel?`${i.label} Notification`:"Notification"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),f(t)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.stopPropagation(),f(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),p(t)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{className:"ff-mx-2 ff-mb-2 ff-p-2 ff-rounded",style:{background:"#fafafa",fontSize:12},children:n?e.jsxs("div",{className:"ff-d-flex ff-flex-column ff-gap-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("span",{className:"ff-px-2 ff-py-1 ff-rounded",style:{fontSize:10,background:i.bg,color:i.color,fontWeight:600,flexShrink:0},children:i.label}),e.jsx("span",{className:"ff-text-dark ff-text-truncate",style:{maxWidth:220},children:x})]}),s&&e.jsx("span",{className:"ff-text-muted ff-text-truncate",style:{maxWidth:280},children:s})]}):e.jsx("span",{className:"ff-text-muted",children:"Not configured"})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},R={"api-key":"API Key",hmac:"HMAC"},le=({data:t})=>{const{onClickAddTrigger:o}=w(),{label:f="Webhook Trigger",endpointUrl:p,authMethod:r,source:i}=t,x=n=>{n.stopPropagation(),o()},s=n=>{n.stopPropagation(),p&&navigator.clipboard.writeText(p).catch(()=>{})};return e.jsxs("div",{style:{width:C.NODE_WIDTH},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #90caf9",borderRadius:8,background:"#fff",overflow:"hidden"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-2",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"rgba(33,150,243,0.1)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(y.MdWebhook,{size:16,color:"#1565c0"})}),e.jsx("span",{style:{fontSize:13,fontWeight:600,color:"#212121"},children:"Webhook Trigger"})]}),e.jsx("div",{role:"button",tabIndex:0,onClick:x,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&x(n)},className:"ff-d-flex ff-align-items-center",style:{paddingRight:4,cursor:"pointer"},children:e.jsx(y.MdOutlineModeEdit,{size:16,color:"#555"})})]}),e.jsxs("div",{className:"ff-mx-2 ff-mb-2 ff-p-2 ff-rounded",style:{background:"#e3f2fd",border:"1px solid #90caf9"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-flex-wrap ff-gap-2 ff-mb-1",children:[e.jsx("span",{style:{fontSize:12,color:"#1565c0",fontWeight:600},children:f}),i&&e.jsx("span",{className:"ff-px-2 ff-py-1 ff-rounded",style:{fontSize:11,background:"#fff",border:"1px solid #90caf9",color:"#1565c0"},children:i}),r&&r!=="none"&&R[r]&&e.jsx("span",{className:"ff-px-2 ff-py-1 ff-rounded",style:{fontSize:10,background:"#1565c0",color:"#fff",fontWeight:600},children:R[r]})]}),p&&e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-1",style:{marginTop:4},children:[e.jsx("span",{style:{fontSize:10,color:"#1565c0",fontFamily:"monospace",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}),e.jsx(T.Tooltip,{title:"Copy URL",placement:"top",arrow:!0,children:e.jsx("div",{role:"button",tabIndex:0,onClick:s,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&s(n)},style:{cursor:"pointer",flexShrink:0},children:e.jsx(y.MdContentCopy,{size:12,color:"#1565c0"})})})]})]})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},re=({id:t,data:o})=>{var j;const{onEditNode:f,onDeleteNode:p,nodeRegistry:r}=w(),{method:i,url:x,descriptorType:s}=o,n=s?(j=r==null?void 0:r.forType(s))==null?void 0:j.icon:e.jsx(y.MdHttp,{size:16,color:"#546e7a"}),d=!!(i&&x),g=(i==null?void 0:i.toUpperCase())??"",h=C.HTTP_METHOD_STYLE[g]??null;return e.jsxs("div",{style:{width:C.NODE_WIDTH},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b0bec5",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:25,height:25,display:"flex",alignItems:"center",justifyContent:"center"},children:n}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:"REST API Call"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),f(t)},onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.stopPropagation(),f(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),p(t)},onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{className:"ff-mx-2 ff-mb-2 ff-p-2 ff-rounded",style:{background:"#fafafa",fontSize:12},children:d?e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[h&&e.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:4,background:h.bg,color:h.color,flexShrink:0},children:g}),e.jsx("span",{className:"ff-text-dark ff-text-truncate",style:{fontFamily:"monospace",fontSize:11},title:x,children:x})]}):e.jsx("span",{className:"ff-text-muted",children:"Not configured"})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},me={eq:"=",neq:"≠",gt:">",gte:"≥",lt:"<",lte:"≤",contains:"contains",startsWith:"starts with",endsWith:"ends with",isEmpty:"is empty",isNotEmpty:"is not empty"},je=({id:t,data:o})=>{const{onEditNode:f,onDeleteNode:p}=w(),{title:r="Condition Branch",branchConfigs:i=[],defaultBranch:x}=o,s=i.length>0;return e.jsxs("div",{style:{width:C.NODE_WIDTH},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b39ddb",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:25,height:25,borderRadius:6,background:"rgba(103,58,183,0.1)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(y.MdCallSplit,{size:16,color:"#512da8"})}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:r})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:n=>{n.stopPropagation(),f(t)},onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.stopPropagation(),f(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:n=>{n.stopPropagation(),p(t)},onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{className:"ff-mx-2 ff-mb-2 ff-p-2 ff-rounded",style:{background:"#fafafa",fontSize:12},children:s?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[i.map((n,d)=>{var a,c;const g=C.BRANCH_PALETTE[d%C.BRANCH_PALETTE.length],h=(a=n.conditions)==null?void 0:a[0],j=(((c=n.conditions)==null?void 0:c.length)??0)-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:10,background:g.bg,color:g.color,flexShrink:0},children:n.label||n.key}),h?e.jsxs("span",{style:{fontSize:11,color:"#616161",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[h.field," ",me[h.operator]??h.operator,h.value?` ${h.value}`:"",j>0?` +${j} more`:""]}):e.jsx("span",{style:{fontSize:11,color:"#9e9e9e"},children:"No conditions yet"})]},n.key)}),x&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:2},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:10,background:"#f5f5f5",color:"#757575",flexShrink:0},children:"Default"}),e.jsx("span",{style:{fontSize:11,color:"#9e9e9e"},children:"fallback path"})]})]}):e.jsx("span",{className:"ff-text-muted",children:"Not configured — click edit to add branches"})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},be=({id:t,data:o})=>{var a;const{onEditNode:f,onDeleteNode:p,nodeRegistry:r}=w(),{title:i="Sub-Workflow",workflowId:x,workflowLabel:s,descriptorType:n,onPreview:d}=o,g=n?(a=r==null?void 0:r.forType(n))==null?void 0:a.icon:e.jsx(y.MdAccountTree,{size:16,color:"#00695c"}),h=!!x,j=c=>{c.stopPropagation(),x&&d&&d(x)};return e.jsxs("div",{style:{width:C.NODE_WIDTH},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #80cbc4",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:25,height:25,borderRadius:6,background:"rgba(0,137,123,0.1)",display:"flex",alignItems:"center",justifyContent:"center"},children:g}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:i})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:c=>{c.stopPropagation(),f(t)},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.stopPropagation(),f(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:c=>{c.stopPropagation(),p(t)},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{className:"ff-mx-2 ff-mb-2 ff-p-2 ff-rounded",style:{background:h?"#e0f2f1":"#fafafa",fontSize:12,border:h?"1px solid #b2dfdb":"none"},children:h?e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-between",children:[e.jsxs("div",{className:"ff-d-flex ff-flex-column ff-gap-1",children:[e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#00695c"},children:s||x}),e.jsxs("span",{style:{fontSize:10,color:"#80cbc4",fontFamily:"monospace"},children:["ID: ",x]})]}),d&&e.jsxs("div",{role:"button",tabIndex:0,onClick:j,onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&j(c)},style:{cursor:"pointer",display:"flex",alignItems:"center",gap:3,fontSize:11,color:"#00897b"},children:[e.jsx(y.MdOpenInNew,{size:13}),"Preview"]})]}):e.jsx("span",{className:"ff-text-muted",children:"Not configured — select a workflow"})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},Ne={startNode:Y,endNode:J,addTriggerNode:Q,addStepNode:pe,triggerNode:X,filterNode:te,actionNode:se,approvalNode:ne,delayNode:oe,notificationNode:ie,webhookTriggerNode:le,restApiNode:re,conditionBranchNode:je,subWorkflowNode:be},ke=11.5,H=2,D=6,$=40,B=20,O=4,ve=({id:t,sourceX:o,sourceY:f,targetX:p,targetY:r,sourcePosition:i,targetPosition:x,source:s,target:n,data:d})=>{const[g,h,j]=l.getStraightPath({sourceX:o,sourceY:f,targetX:p,targetY:r}),a=d==null?void 0:d.label,c=a==="Pass",N=c||a==="Fail",m=o+(p-o)/3,k=f+(r-f)/3,b=o+2*(p-o)/3,P=f+2*(r-f)/3,u=d==null?void 0:d.onAddStepClick,E=z=>{if(z.stopPropagation(),typeof u!="function")return;const fe={edgeId:t,nodeId:s,sourceNodeId:s,targetNodeId:n,position:"between",referenceNodeId:s,referenceNodeType:d==null?void 0:d.referenceNodeType,stepVisibility:d==null?void 0:d.stepVisibility};u(s,fe)},I=z=>{(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),E(z))},S=()=>e.jsxs(e.Fragment,{children:[e.jsxs("g",{className:"plus-icon-container",children:[e.jsx("circle",{r:ke,className:"edge-plus-circle"}),e.jsx("line",{x1:0,y1:-D,x2:0,y2:D,strokeWidth:H,strokeLinecap:"round",className:"plus-line"}),e.jsx("line",{x1:-D,y1:0,x2:D,y2:0,strokeWidth:H,strokeLinecap:"round",className:"plus-line"})]}),e.jsxs("g",{className:"edge-plus-tooltip",transform:"translate(18, 0)",children:[e.jsx("rect",{x:0,y:-10,width:65,height:20,rx:4,className:"tooltip-bg"}),e.jsx("path",{d:"M0 -4 L-4 0 L0 4 Z",className:"tooltip-bg"}),e.jsx("text",{x:32,y:0,textAnchor:"middle",dominantBaseline:"central",fill:"white",style:{fontSize:10,fontWeight:600,pointerEvents:"none"},children:"Add Step"})]})]}),v=u?{onClick:E,onKeyDown:I,role:"button",tabIndex:0,style:{cursor:"pointer",pointerEvents:"all"}}:{style:{cursor:"default",pointerEvents:"all"}};return e.jsxs("g",{className:"edge-with-plus-wrapper",children:[e.jsx(l.BaseEdge,{id:t,path:g}),N?e.jsxs(e.Fragment,{children:[e.jsxs("g",{transform:`translate(${m}, ${k})`,children:[e.jsx("rect",{x:-$/2,y:-B/2,width:$,height:B,rx:O,ry:O,fill:c?"#ADE6C5":"#FDBFBF"}),e.jsx("text",{textAnchor:"middle",dominantBaseline:"central",fill:c?"#1DBF60":"#C50000",style:{fontSize:12,fontWeight:500},children:a})]}),e.jsx("g",{className:"nodrag nopan edge-plus-svg",transform:`translate(${b}, ${P})`,"data-testid":"plus-node-icon",...v,children:e.jsx(S,{})})]}):e.jsx("g",{className:"nodrag nopan edge-plus-svg",transform:`translate(${h}, ${j})`,"data-testid":"plus-node-icon",...v,children:e.jsx(S,{})})]})},we=11.5,_=2,A=6,Se=({id:t,sourceX:o,sourceY:f,targetX:p,targetY:r,source:i,target:x,data:s})=>{const[n,d,g]=l.getStraightPath({sourceX:o,sourceY:f,targetX:p,targetY:r}),h=s==null?void 0:s.onAddStepClick,j=c=>{c.stopPropagation(),typeof h=="function"&&h(i,{edgeId:t,nodeId:i,sourceNodeId:i,targetNodeId:x,position:"between",referenceNodeId:i,referenceNodeType:s==null?void 0:s.referenceNodeType,stepVisibility:s==null?void 0:s.stepVisibility,filterId:s==null?void 0:s.filterId,branch:s==null?void 0:s.branch})},a=c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),j(c))};return e.jsxs("g",{className:"edge-with-plus-wrapper",children:[e.jsx(l.BaseEdge,{id:t,path:n,style:{stroke:"#b0bec5"}}),e.jsxs("g",{className:"nodrag nopan edge-plus-svg",transform:`translate(${d}, ${g})`,style:{cursor:h?"pointer":"default",pointerEvents:"all",outline:"none"},onClick:h?j:void 0,onKeyDown:h?a:void 0,role:h?"button":void 0,tabIndex:h?0:void 0,"data-testid":"plus-node-icon",children:[e.jsx("circle",{r:we,className:"edge-plus-circle"}),e.jsx("line",{x1:0,y1:-A,x2:0,y2:A,strokeWidth:_,strokeLinecap:"round",className:"plus-line"}),e.jsx("line",{x1:-A,y1:0,x2:A,y2:0,strokeWidth:_,strokeLinecap:"round",className:"plus-line"}),e.jsxs("g",{className:"edge-plus-tooltip",transform:"translate(18, 0)",children:[e.jsx("rect",{x:0,y:-10,width:65,height:20,rx:4,className:"tooltip-bg"}),e.jsx("path",{d:"M0 -4 L-4 0 L0 4 Z",className:"tooltip-bg"}),e.jsx("text",{x:32,y:0,textAnchor:"middle",dominantBaseline:"central",fill:"white",style:{fontSize:10,fontWeight:600,pointerEvents:"none"},children:"Add Step"})]})]})]})},Ee=({id:t,sourceX:o,sourceY:f,targetX:p,targetY:r})=>{const[i]=l.getStraightPath({sourceX:o,sourceY:f,targetX:p,targetY:r});return e.jsx(l.BaseEdge,{id:t,path:i,style:{stroke:"#b0bec5"}})},Pe=11.5,K=2,M=6,Te=-24,U=40,q=20,G=4,Ce=({id:t,sourceX:o,sourceY:f,targetX:p,targetY:r,source:i,target:x,data:s})=>{const[n,d,g]=l.getStraightPath({sourceX:o,sourceY:f,targetX:p,targetY:r}),h=s==null?void 0:s.label,j=h==="Pass",a=j||h==="Fail",c=s==null?void 0:s.onAddStepClick,N=(s==null?void 0:s.showPlus)!==!1&&!!c,m=b=>{b.stopPropagation(),typeof c=="function"&&c(i,{edgeId:t,nodeId:i,sourceNodeId:i,targetNodeId:x,position:"between",referenceNodeId:i,referenceNodeType:s==null?void 0:s.referenceNodeType,stepVisibility:s==null?void 0:s.stepVisibility})},k=b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),m(b))};return e.jsxs("g",{className:"edge-with-plus-wrapper",children:[e.jsx(l.BaseEdge,{id:t,path:n,style:{stroke:"#b0bec5"}}),e.jsxs("g",{className:"nodrag nopan edge-plus-svg",transform:`translate(${d}, ${g})`,style:{cursor:c?"pointer":"default",pointerEvents:"all",outline:"none"},onClick:c?m:void 0,onKeyDown:c?k:void 0,role:c?"button":void 0,tabIndex:c?0:void 0,children:[a&&e.jsxs("g",{transform:`translate(0, ${N?Te:0})`,children:[e.jsx("rect",{x:-U/2,y:-q/2,width:U,height:q,rx:G,ry:G,fill:j?"#ADE6C5":"#FDBFBF"}),e.jsx("text",{textAnchor:"middle",dominantBaseline:"central",fill:j?"#1DBF60":"#C50000",style:{fontSize:12,fontWeight:500},children:h})]}),N&&e.jsxs("g",{className:"plus-icon-container",children:[e.jsx("circle",{r:Pe,className:"edge-plus-circle"}),e.jsx("line",{x1:0,y1:-M,x2:0,y2:M,strokeWidth:K,strokeLinecap:"round",className:"plus-line"}),e.jsx("line",{x1:-M,y1:0,x2:M,y2:0,strokeWidth:K,strokeLinecap:"round",className:"plus-line"})]}),N&&e.jsxs("g",{className:"edge-plus-tooltip",transform:"translate(22, 0)",children:[e.jsx("rect",{x:0,y:-10,width:65,height:20,rx:4,className:"tooltip-bg"}),e.jsx("path",{d:"M0 -4 L-4 0 L0 4 Z",className:"tooltip-bg"}),e.jsx("text",{x:32,y:0,textAnchor:"middle",dominantBaseline:"central",fill:"white",style:{fontSize:10,fontWeight:600,pointerEvents:"none"},children:"Add Step"})]})]})]})},Ie=({id:t,source:o,target:f,sourceX:p,sourceY:r,targetX:i,targetY:x,style:s={},markerEnd:n,data:d})=>{const g=(d==null?void 0:d.verticalRouting)??!1,h=30,j=g?(()=>{const v=x-h;return`M ${p},${v} L ${i},${v} L ${i},${x}`})():(()=>{const v=r+30;return`M ${p},${r} L ${p},${v} L ${i},${v} L ${i},${x}`})(),a=s.stroke||"#d1d5db",c=d==null?void 0:d.label,N=(d==null?void 0:d.isFirst)??!1,m=d==null?void 0:d.onAddStepClick,k=g?x-h:r+30,b=p+(i-p)*(g?.25:.35),P=p+(i-p)*(g?.65:.7),u=k,E=v=>{v.stopPropagation(),m&&m(o,{edgeId:t,nodeId:o,sourceNodeId:o,targetNodeId:f,position:"between",referenceNodeId:o,filterId:d==null?void 0:d.filterId,branch:d==null?void 0:d.branch})},I=11.5,S=6;return e.jsxs("g",{children:[e.jsx("path",{id:t,d:j,fill:"none",stroke:a,strokeWidth:1.5,markerEnd:n}),c&&!g&&e.jsx("g",{transform:`translate(${b}, ${u})`,children:(()=>{const v=Math.max(44,c.length*7+20);return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:-v/2,y:-11,width:v,height:22,rx:11,fill:N?"#e8f5e9":"#ffebee",stroke:N?"#81c784":"#e57373",strokeWidth:1}),e.jsx("text",{x:0,y:4,textAnchor:"middle",fontSize:10,fontWeight:600,fill:N?"#2e7d32":"#c62828",style:{fontFamily:"sans-serif",pointerEvents:"none"},children:c})]})})()}),m&&e.jsxs("g",{transform:`translate(${P}, ${u})`,onClick:E,style:{cursor:"pointer",pointerEvents:"all"},className:"nodrag nopan edge-plus-svg",children:[e.jsx("circle",{r:I,className:"edge-plus-circle"}),e.jsx("line",{x1:0,y1:-S,x2:0,y2:S,strokeWidth:2,strokeLinecap:"round",className:"plus-line"}),e.jsx("line",{x1:-S,y1:0,x2:S,y2:0,strokeWidth:2,strokeLinecap:"round",className:"plus-line"})]})]})};exports.ActionNode=se;exports.AddTriggerNode=Q;exports.ApprovalNode=ne;exports.DelayNode=oe;exports.EdgeWithPlusLabel=ve;exports.EndNode=J;exports.FilterNode=te;exports.GatewayBranchEdge=Ie;exports.LabelPlusEdge=Ce;exports.NotificationNode=ie;exports.PlainEdge=Ee;exports.PlusEdge=Se;exports.RestApiNode=re;exports.StartNode=Y;exports.TriggerNode=X;exports.WebhookTriggerNode=le;exports.WorkflowCanvasContext=Z;exports.builtInNodeTypes=Ne;
|