journey-flow-editor 0.0.15 → 0.0.16

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/index.cjs CHANGED
@@ -156,4 +156,4 @@ To suppress this warning, you need to explicitly provide the \`palette.${t}Chann
156
156
  `))}return null}),anchorOrigin:a.shape({horizontal:a.oneOfType([a.oneOf(["center","left","right"]),a.number]).isRequired,vertical:a.oneOfType([a.oneOf(["bottom","center","top"]),a.number]).isRequired}),anchorPosition:a.shape({left:a.number.isRequired,top:a.number.isRequired}),anchorReference:a.oneOf(["anchorEl","anchorPosition","none"]),BackdropComponent:a.elementType,BackdropProps:a.object,children:a.node,classes:a.object,className:a.string,container:a.oneOfType([io,a.func]),disableScrollLock:a.bool,elevation:vl,marginThreshold:a.number,onClose:a.func,open:a.bool.isRequired,PaperProps:a.shape({component:yl}),slotProps:a.shape({backdrop:a.oneOfType([a.func,a.object]),paper:a.oneOfType([a.func,a.object]),root:a.oneOfType([a.func,a.object]),transition:a.oneOfType([a.func,a.object])}),slots:a.shape({backdrop:a.elementType,paper:a.elementType,root:a.elementType,transition:a.elementType}),sx:a.oneOfType([a.arrayOf(a.oneOfType([a.func,a.object,a.bool])),a.func,a.object]),transformOrigin:a.shape({horizontal:a.oneOfType([a.oneOf(["center","left","right"]),a.number]).isRequired,vertical:a.oneOfType([a.oneOf(["bottom","center","top"]),a.number]).isRequired}),TransitionComponent:a.elementType,transitionDuration:a.oneOfType([a.oneOf(["auto"]),a.number,a.shape({appear:a.number,enter:a.number,exit:a.number})]),TransitionProps:a.object});function mO(e){return Pe("MuiMenu",e)}Me("MuiMenu",["root","paper","list"]);const gO={vertical:"top",horizontal:"right"},yO={vertical:"top",horizontal:"left"},bO=e=>{const{classes:t}=e;return $e({root:["root"],paper:["paper"],list:["list"]},mO,t)},vO=de(Lh,{shouldForwardProp:e=>gt(e)||e==="classes",name:"MuiMenu",slot:"Root"})({}),xO=de(jh,{name:"MuiMenu",slot:"Paper"})({maxHeight:"calc(100% - 96px)",WebkitOverflowScrolling:"touch"}),wO=de(Dh,{name:"MuiMenu",slot:"List"})({outline:0}),Cl=A.forwardRef(function(t,n){const o=Le({props:t,name:"MuiMenu"}),{autoFocus:r=!0,children:i,className:s,disableAutoFocusItem:l=!1,MenuListProps:c={},onClose:u,open:d,PaperProps:f={},PopoverClasses:p,transitionDuration:m="auto",TransitionProps:{onEntering:g,...h}={},variant:v="selectedMenu",slots:b={},slotProps:C={},...y}=o,x=Gp(),w={...o,autoFocus:r,disableAutoFocusItem:l,MenuListProps:c,onEntering:g,PaperProps:f,transitionDuration:m,TransitionProps:h,variant:v},S=bO(w),O=r&&!l&&d,k=A.useRef(null),_=(j,$)=>{k.current&&k.current.adjustStyleForScrollbar(j,{direction:x?"rtl":"ltr"}),g&&g(j,$)},V=j=>{j.key==="Tab"&&(j.preventDefault(),u&&u(j,"tabKeyDown"))};let I=-1;A.Children.map(i,(j,$)=>{A.isValidElement(j)&&(process.env.NODE_ENV!=="production"&&Nn.isFragment(j)&&console.error(["MUI: The Menu component doesn't accept a Fragment as a child.","Consider providing an array instead."].join(`
157
157
  `)),j.props.disabled||(v==="selectedMenu"&&j.props.selected||I===-1)&&(I=$))});const E={slots:b,slotProps:{list:c,transition:h,paper:f,...C}},D=$T({elementType:b.root,externalSlotProps:C.root,ownerState:w,className:[S.root,s]}),[T,R]=qe("paper",{className:S.paper,elementType:xO,externalForwardedProps:E,shouldForwardComponentProp:!0,ownerState:w}),[P,L]=qe("list",{className:me(S.list,c.className),elementType:wO,shouldForwardComponentProp:!0,externalForwardedProps:E,getSlotProps:j=>({...j,onKeyDown:$=>{V($),j.onKeyDown?.($)}}),ownerState:w}),M=typeof E.slotProps.transition=="function"?E.slotProps.transition(w):E.slotProps.transition;return N.jsx(vO,{onClose:u,anchorOrigin:{vertical:"bottom",horizontal:x?"right":"left"},transformOrigin:x?gO:yO,slots:{root:b.root,paper:T,backdrop:b.backdrop,...b.transition&&{transition:b.transition}},slotProps:{root:D,paper:R,backdrop:typeof C.backdrop=="function"?C.backdrop(w):C.backdrop,transition:{...M,onEntering:(...j)=>{_(...j),M?.onEntering?.(...j)}}},open:d,ref:n,transitionDuration:m,ownerState:w,...y,classes:p,children:N.jsx(P,{actions:k,autoFocus:r&&(I===-1||l),autoFocusItem:O,variant:v,...L,children:i})})});process.env.NODE_ENV!=="production"&&(Cl.propTypes={anchorEl:a.oneOfType([io,a.func]),autoFocus:a.bool,children:a.node,classes:a.object,className:a.string,disableAutoFocusItem:a.bool,MenuListProps:a.object,onClose:a.func,open:a.bool.isRequired,PaperProps:a.object,PopoverClasses:a.object,slotProps:a.shape({backdrop:a.oneOfType([a.func,a.object]),list:a.oneOfType([a.func,a.object]),paper:a.oneOfType([a.func,a.object]),root:a.oneOfType([a.func,a.object]),transition:a.oneOfType([a.func,a.object])}),slots:a.shape({backdrop:a.elementType,list:a.elementType,paper:a.elementType,root:a.elementType,transition:a.elementType}),sx:a.oneOfType([a.arrayOf(a.oneOfType([a.func,a.object,a.bool])),a.func,a.object]),transitionDuration:a.oneOfType([a.oneOf(["auto"]),a.number,a.shape({appear:a.number,enter:a.number,exit:a.number})]),TransitionProps:a.object,variant:a.oneOf(["menu","selectedMenu"])});function EO(e){return Pe("MuiMenuItem",e)}const To=Me("MuiMenuItem",["root","focusVisible","dense","disabled","divider","gutters","selected"]),SO=(e,t)=>{const{ownerState:n}=e;return[t.root,n.dense&&t.dense,n.divider&&t.divider,!n.disableGutters&&t.gutters]},CO=e=>{const{disabled:t,dense:n,divider:o,disableGutters:r,selected:i,classes:s}=e,c=$e({root:["root",n&&"dense",t&&"disabled",!r&&"gutters",o&&"divider",i&&"selected"]},EO,s);return{...s,...c}},TO=de(wl,{shouldForwardProp:e=>gt(e)||e==="classes",name:"MuiMenuItem",slot:"Root",overridesResolver:SO})(ze(({theme:e})=>({...e.typography.body1,display:"flex",justifyContent:"flex-start",alignItems:"center",position:"relative",textDecoration:"none",minHeight:48,paddingTop:6,paddingBottom:6,boxSizing:"border-box",whiteSpace:"nowrap","&:hover":{textDecoration:"none",backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${To.selected}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${To.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}},[`&.${To.selected}:hover`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity)}},[`&.${To.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${To.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},[`& + .${od.root}`]:{marginTop:e.spacing(1),marginBottom:e.spacing(1)},[`& + .${od.inset}`]:{marginLeft:52},[`& .${Wn.root}`]:{marginTop:0,marginBottom:0},[`& .${Wn.inset}`]:{paddingLeft:36},[`& .${sd.root}`]:{minWidth:36},variants:[{props:({ownerState:t})=>!t.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:t})=>t.divider,style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`,backgroundClip:"padding-box"}},{props:({ownerState:t})=>!t.dense,style:{[e.breakpoints.up("sm")]:{minHeight:"auto"}}},{props:({ownerState:t})=>t.dense,style:{minHeight:32,paddingTop:4,paddingBottom:4,...e.typography.body2,[`& .${sd.root} svg`]:{fontSize:"1.25rem"}}}]}))),St=A.forwardRef(function(t,n){const o=Le({props:t,name:"MuiMenuItem"}),{autoFocus:r=!1,component:i="li",dense:s=!1,divider:l=!1,disableGutters:c=!1,focusVisibleClassName:u,role:d="menuitem",tabIndex:f,className:p,...m}=o,g=A.useContext(ao),h=A.useMemo(()=>({dense:s||g.dense||!1,disableGutters:c}),[g.dense,s,c]),v=A.useRef(null);sn(()=>{r&&(v.current?v.current.focus():process.env.NODE_ENV!=="production"&&console.error("MUI: Unable to set focus to a MenuItem whose component has not been rendered."))},[r]);const b={...o,dense:h.dense,divider:l,disableGutters:c},C=CO(o),y=st(v,n);let x;return o.disabled||(x=f!==void 0?f:-1),N.jsx(ao.Provider,{value:h,children:N.jsx(TO,{ref:y,role:d,tabIndex:x,component:i,focusVisibleClassName:me(C.focusVisible,u),className:me(C.root,p),...m,ownerState:b,classes:C})})});process.env.NODE_ENV!=="production"&&(St.propTypes={autoFocus:a.bool,children:a.node,classes:a.object,className:a.string,component:a.elementType,dense:a.bool,disabled:a.bool,disableGutters:a.bool,divider:a.bool,focusVisibleClassName:a.string,role:a.string,selected:a.bool,sx:a.oneOfType([a.arrayOf(a.oneOfType([a.func,a.object,a.bool])),a.func,a.object]),tabIndex:a.number});function NO(e){return Pe("MuiNativeSelect",e)}const Tl=Me("MuiNativeSelect",["root","select","multiple","filled","outlined","standard","disabled","icon","iconOpen","iconFilled","iconOutlined","iconStandard","nativeInput","error"]),OO=e=>{const{classes:t,variant:n,disabled:o,multiple:r,open:i,error:s}=e,l={select:["select",n,o&&"disabled",r&&"multiple",s&&"error"],icon:["icon",`icon${ge(n)}`,i&&"iconOpen",o&&"disabled"]};return $e(l,NO,t)},Fh=de("select",{name:"MuiNativeSelect"})(({theme:e})=>({MozAppearance:"none",WebkitAppearance:"none",userSelect:"none",borderRadius:0,cursor:"pointer","&:focus":{borderRadius:0},[`&.${Tl.disabled}`]:{cursor:"default"},"&[multiple]":{height:"auto"},"&:not([multiple]) option, &:not([multiple]) optgroup":{backgroundColor:(e.vars||e).palette.background.paper},variants:[{props:({ownerState:t})=>t.variant!=="filled"&&t.variant!=="outlined",style:{"&&&":{paddingRight:24,minWidth:16}}},{props:{variant:"filled"},style:{"&&&":{paddingRight:32}}},{props:{variant:"outlined"},style:{borderRadius:(e.vars||e).shape.borderRadius,"&:focus":{borderRadius:(e.vars||e).shape.borderRadius},"&&&":{paddingRight:32}}}]})),PO=de(Fh,{name:"MuiNativeSelect",slot:"Select",shouldForwardProp:gt,overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.select,t[n.variant],n.error&&t.error,{[`&.${Tl.multiple}`]:t.multiple}]}})({}),Bh=de("svg",{name:"MuiNativeSelect"})(({theme:e})=>({position:"absolute",right:0,top:"calc(50% - .5em)",pointerEvents:"none",color:(e.vars||e).palette.action.active,[`&.${Tl.disabled}`]:{color:(e.vars||e).palette.action.disabled},variants:[{props:({ownerState:t})=>t.open,style:{transform:"rotate(180deg)"}},{props:{variant:"filled"},style:{right:7}},{props:{variant:"outlined"},style:{right:7}}]})),RO=de(Bh,{name:"MuiNativeSelect",slot:"Icon",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.icon,n.variant&&t[`icon${ge(n.variant)}`],n.open&&t.iconOpen]}})({}),zh=A.forwardRef(function(t,n){const{className:o,disabled:r,error:i,IconComponent:s,inputRef:l,variant:c="standard",...u}=t,d={...t,disabled:r,variant:c,error:i},f=OO(d);return N.jsxs(A.Fragment,{children:[N.jsx(PO,{ownerState:d,className:me(f.select,o),disabled:r,ref:l||n,...u}),t.multiple?null:N.jsx(RO,{as:s,ownerState:d,className:f.icon})]})});process.env.NODE_ENV!=="production"&&(zh.propTypes={children:a.node,classes:a.object,className:a.string,disabled:a.bool,error:a.bool,IconComponent:a.elementType.isRequired,inputRef:Zt,multiple:a.bool,name:a.string,onChange:a.func,value:a.any,variant:a.oneOf(["standard","outlined","filled"])});var dd;const kO=de("fieldset",{name:"MuiNotchedOutlined",shouldForwardProp:gt})({textAlign:"left",position:"absolute",bottom:0,right:0,top:-5,left:0,margin:0,padding:"0 8px",pointerEvents:"none",borderRadius:"inherit",borderStyle:"solid",borderWidth:1,overflow:"hidden",minWidth:"0%"}),_O=de("legend",{name:"MuiNotchedOutlined",shouldForwardProp:gt})(ze(({theme:e})=>({float:"unset",width:"auto",overflow:"hidden",variants:[{props:({ownerState:t})=>!t.withLabel,style:{padding:0,lineHeight:"11px",transition:e.transitions.create("width",{duration:150,easing:e.transitions.easing.easeOut})}},{props:({ownerState:t})=>t.withLabel,style:{display:"block",padding:0,height:11,fontSize:"0.75em",visibility:"hidden",maxWidth:.01,transition:e.transitions.create("max-width",{duration:50,easing:e.transitions.easing.easeOut}),whiteSpace:"nowrap","& > span":{paddingLeft:5,paddingRight:5,display:"inline-block",opacity:0,visibility:"visible"}}},{props:({ownerState:t})=>t.withLabel&&t.notched,style:{maxWidth:"100%",transition:e.transitions.create("max-width",{duration:100,easing:e.transitions.easing.easeOut,delay:50})}}]})));function Vh(e){const{children:t,classes:n,className:o,label:r,notched:i,...s}=e,l=r!=null&&r!=="",c={...e,notched:i,withLabel:l};return N.jsx(kO,{"aria-hidden":!0,className:o,ownerState:c,...s,children:N.jsx(_O,{ownerState:c,children:l?N.jsx("span",{children:r}):dd||(dd=N.jsx("span",{className:"notranslate","aria-hidden":!0,children:"​"}))})})}process.env.NODE_ENV!=="production"&&(Vh.propTypes={children:a.node,classes:a.object,className:a.string,label:a.node,notched:a.bool.isRequired,style:a.object});const IO=e=>{const{classes:t}=e,o=$e({root:["root"],notchedOutline:["notchedOutline"],input:["input"]},UT,t);return{...t,...o}},MO=de(cs,{shouldForwardProp:e=>gt(e)||e==="classes",name:"MuiOutlinedInput",slot:"Root",overridesResolver:as})(ze(({theme:e})=>{const t=e.palette.mode==="light"?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)";return{position:"relative",borderRadius:(e.vars||e).shape.borderRadius,[`&:hover .${Mt.notchedOutline}`]:{borderColor:(e.vars||e).palette.text.primary},"@media (hover: none)":{[`&:hover .${Mt.notchedOutline}`]:{borderColor:e.vars?e.alpha(e.vars.palette.common.onBackground,.23):t}},[`&.${Mt.focused} .${Mt.notchedOutline}`]:{borderWidth:2},variants:[...Object.entries(e.palette).filter(kn()).map(([n])=>({props:{color:n},style:{[`&.${Mt.focused} .${Mt.notchedOutline}`]:{borderColor:(e.vars||e).palette[n].main}}})),{props:{},style:{[`&.${Mt.error} .${Mt.notchedOutline}`]:{borderColor:(e.vars||e).palette.error.main},[`&.${Mt.disabled} .${Mt.notchedOutline}`]:{borderColor:(e.vars||e).palette.action.disabled}}},{props:({ownerState:n})=>n.startAdornment,style:{paddingLeft:14}},{props:({ownerState:n})=>n.endAdornment,style:{paddingRight:14}},{props:({ownerState:n})=>n.multiline,style:{padding:"16.5px 14px"}},{props:({ownerState:n,size:o})=>n.multiline&&o==="small",style:{padding:"8.5px 14px"}}]}})),$O=de(Vh,{name:"MuiOutlinedInput",slot:"NotchedOutline"})(ze(({theme:e})=>{const t=e.palette.mode==="light"?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)";return{borderColor:e.vars?e.alpha(e.vars.palette.common.onBackground,.23):t}})),AO=de(us,{name:"MuiOutlinedInput",slot:"Input",overridesResolver:ls})(ze(({theme:e})=>({padding:"16.5px 14px",...!e.vars&&{"&:-webkit-autofill":{WebkitBoxShadow:e.palette.mode==="light"?null:"0 0 0 100px #266798 inset",WebkitTextFillColor:e.palette.mode==="light"?null:"#fff",caretColor:e.palette.mode==="light"?null:"#fff",borderRadius:"inherit"}},...e.vars&&{"&:-webkit-autofill":{borderRadius:"inherit"},[e.getColorSchemeSelector("dark")]:{"&:-webkit-autofill":{WebkitBoxShadow:"0 0 0 100px #266798 inset",WebkitTextFillColor:"#fff",caretColor:"#fff"}}},variants:[{props:{size:"small"},style:{padding:"8.5px 14px"}},{props:({ownerState:t})=>t.multiline,style:{padding:0}},{props:({ownerState:t})=>t.startAdornment,style:{paddingLeft:0}},{props:({ownerState:t})=>t.endAdornment,style:{paddingRight:0}}]}))),hs=A.forwardRef(function(t,n){const o=Le({props:t,name:"MuiOutlinedInput"}),{components:r={},fullWidth:i=!1,inputComponent:s="input",label:l,multiline:c=!1,notched:u,slots:d={},slotProps:f={},type:p="text",...m}=o,g=IO(o),h=po(),v=fo({props:o,muiFormControl:h,states:["color","disabled","error","focused","hiddenLabel","size","required"]}),b={...o,color:v.color||"primary",disabled:v.disabled,error:v.error,focused:v.focused,formControl:h,fullWidth:i,hiddenLabel:v.hiddenLabel,multiline:c,size:v.size,type:p},C=d.root??r.Root??MO,y=d.input??r.Input??AO,[x,w]=qe("notchedOutline",{elementType:$O,className:g.notchedOutline,shouldForwardComponentProp:!0,ownerState:b,externalForwardedProps:{slots:d,slotProps:f},additionalProps:{label:l!=null&&l!==""&&v.required?N.jsxs(A.Fragment,{children:[l," ","*"]}):l}});return N.jsx(ds,{slots:{root:C,input:y},slotProps:f,renderSuffix:S=>N.jsx(x,{...w,notched:typeof u<"u"?u:!!(S.startAdornment||S.filled||S.focused)}),fullWidth:i,inputComponent:s,multiline:c,ref:n,type:p,...m,classes:{...g,notchedOutline:null}})});process.env.NODE_ENV!=="production"&&(hs.propTypes={autoComplete:a.string,autoFocus:a.bool,classes:a.object,color:a.oneOfType([a.oneOf(["primary","secondary"]),a.string]),components:a.shape({Input:a.elementType,Root:a.elementType}),defaultValue:a.any,disabled:a.bool,endAdornment:a.node,error:a.bool,fullWidth:a.bool,id:a.string,inputComponent:a.elementType,inputProps:a.object,inputRef:Zt,label:a.node,margin:a.oneOf(["dense","none"]),maxRows:a.oneOfType([a.number,a.string]),minRows:a.oneOfType([a.number,a.string]),multiline:a.bool,name:a.string,notched:a.bool,onChange:a.func,placeholder:a.string,readOnly:a.bool,required:a.bool,rows:a.oneOfType([a.number,a.string]),slotProps:a.shape({input:a.object,notchedOutline:a.oneOfType([a.func,a.object]),root:a.object}),slots:a.shape({input:a.elementType,notchedOutline:a.elementType,root:a.elementType}),startAdornment:a.node,sx:a.oneOfType([a.arrayOf(a.oneOfType([a.func,a.object,a.bool])),a.func,a.object]),type:a.string,value:a.any});hs.muiName="Input";function Hh(e){return Pe("MuiSelect",e)}const No=Me("MuiSelect",["root","select","multiple","filled","outlined","standard","disabled","focused","icon","iconOpen","iconFilled","iconOutlined","iconStandard","nativeInput","error"]);var fd;const DO=de(Fh,{name:"MuiSelect",slot:"Select",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[{[`&.${No.select}`]:t.select},{[`&.${No.select}`]:t[n.variant]},{[`&.${No.error}`]:t.error},{[`&.${No.multiple}`]:t.multiple}]}})({[`&.${No.select}`]:{height:"auto",minHeight:"1.4375em",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}}),jO=de(Bh,{name:"MuiSelect",slot:"Icon",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.icon,n.variant&&t[`icon${ge(n.variant)}`],n.open&&t.iconOpen]}})({}),LO=de("input",{shouldForwardProp:e=>nh(e)&&e!=="classes",name:"MuiSelect",slot:"NativeInput"})({bottom:0,left:0,position:"absolute",opacity:0,pointerEvents:"none",width:"100%",boxSizing:"border-box"});function pd(e,t){return typeof t=="object"&&t!==null?e===t:String(e)===String(t)}function FO(e){return e==null||typeof e=="string"&&!e.trim()}const BO=e=>{const{classes:t,variant:n,disabled:o,multiple:r,open:i,error:s}=e,l={select:["select",n,o&&"disabled",r&&"multiple",s&&"error"],icon:["icon",`icon${ge(n)}`,i&&"iconOpen",o&&"disabled"],nativeInput:["nativeInput"]};return $e(l,Hh,t)},Wh=A.forwardRef(function(t,n){const{"aria-describedby":o,"aria-label":r,autoFocus:i,autoWidth:s,children:l,className:c,defaultOpen:u,defaultValue:d,disabled:f,displayEmpty:p,error:m=!1,IconComponent:g,inputRef:h,labelId:v,MenuProps:b={},multiple:C,name:y,onBlur:x,onChange:w,onClose:S,onFocus:O,onKeyDown:k,onMouseDown:_,onOpen:V,open:I,readOnly:E,renderValue:D,required:T,SelectDisplayProps:R={},tabIndex:P,type:L,value:M,variant:j="standard",...$}=t,[z,H]=Vu({controlled:M,default:d,name:"Select"}),[U,W]=Vu({controlled:I,default:u,name:"Select"}),ee=A.useRef(null),te=A.useRef(null),[Q,Y]=A.useState(null),{current:X}=A.useRef(I!=null),[K,oe]=A.useState(),B=st(n,h),ie=A.useCallback(ae=>{te.current=ae,ae&&Y(ae)},[]),re=Q?.parentNode;A.useImperativeHandle(B,()=>({focus:()=>{te.current.focus()},node:ee.current,value:z}),[z]);const le=Q!==null&&U;A.useEffect(()=>{if(!le||!re||s||typeof ResizeObserver>"u")return;const ae=new ResizeObserver(()=>{oe(re.clientWidth)});return ae.observe(re),()=>{ae.disconnect()}},[le,re,s]),A.useEffect(()=>{u&&U&&Q&&!X&&(oe(s?null:re.clientWidth),te.current.focus())},[Q,s]),A.useEffect(()=>{i&&te.current.focus()},[i]),A.useEffect(()=>{if(!v)return;const ae=Pt(te.current).getElementById(v);if(ae){const ve=()=>{getSelection().isCollapsed&&te.current.focus()};return ae.addEventListener("click",ve),()=>{ae.removeEventListener("click",ve)}}},[v]);const be=(ae,ve)=>{ae?V&&V(ve):S&&S(ve),X||(oe(s?null:re.clientWidth),W(ae))},Se=ae=>{_?.(ae),ae.button===0&&(ae.preventDefault(),te.current.focus(),be(!0,ae))},Ae=ae=>{be(!1,ae)},G=A.Children.toArray(l),Z=ae=>{const ve=G.find(Ye=>Ye.props.value===ae.target.value);ve!==void 0&&(H(ve.props.value),w&&w(ae,ve))},ne=ae=>ve=>{let Ye;if(ve.currentTarget.hasAttribute("tabindex")){if(C){Ye=Array.isArray(z)?z.slice():[];const Qt=z.indexOf(ae.props.value);Qt===-1?Ye.push(ae.props.value):Ye.splice(Qt,1)}else Ye=ae.props.value;if(ae.props.onClick&&ae.props.onClick(ve),z!==Ye&&(H(Ye),w)){const Qt=ve.nativeEvent||ve,Cr=new Qt.constructor(Qt.type,Qt);Object.defineProperty(Cr,"target",{writable:!0,value:{value:Ye,name:y}}),w(Cr,ae)}C||be(!1,ve)}},J=ae=>{E||([" ","ArrowUp","ArrowDown","Enter"].includes(ae.key)&&(ae.preventDefault(),be(!0,ae)),k?.(ae))},pe=ae=>{!le&&x&&(Object.defineProperty(ae,"target",{writable:!0,value:{value:z,name:y}}),x(ae))};delete $["aria-invalid"];let se,ce;const fe=[];let he=!1,ye=!1;(Si({value:z})||p)&&(D?se=D(z):he=!0);const Te=G.map(ae=>{if(!A.isValidElement(ae))return null;process.env.NODE_ENV!=="production"&&Nn.isFragment(ae)&&console.error(["MUI: The Select component doesn't accept a Fragment as a child.","Consider providing an array instead."].join(`
158
158
  `));let ve;if(C){if(!Array.isArray(z))throw new Error(process.env.NODE_ENV!=="production"?"MUI: The `value` prop must be an array when using the `Select` component with `multiple`.":Kt(2));ve=z.some(Ye=>pd(Ye,ae.props.value)),ve&&he&&fe.push(ae.props.children)}else ve=pd(z,ae.props.value),ve&&he&&(ce=ae.props.children);return ve&&(ye=!0),A.cloneElement(ae,{"aria-selected":ve?"true":"false",onClick:ne(ae),onKeyUp:Ye=>{Ye.key===" "&&Ye.preventDefault(),ae.props.onKeyUp&&ae.props.onKeyUp(Ye)},role:"option",selected:ve,value:void 0,"data-value":ae.props.value})});process.env.NODE_ENV!=="production"&&A.useEffect(()=>{if(!ye&&!C&&z!==""){const ae=G.map(ve=>ve.props.value);console.warn([`MUI: You have provided an out-of-range value \`${z}\` for the select ${y?`(name="${y}") `:""}component.`,"Consider providing a value that matches one of the available options or ''.",`The available values are ${ae.filter(ve=>ve!=null).map(ve=>`\`${ve}\``).join(", ")||'""'}.`].join(`
159
- `))}},[ye,G,C,y,z]),he&&(C?fe.length===0?se=null:se=fe.reduce((ae,ve,Ye)=>(ae.push(ve),Ye<fe.length-1&&ae.push(", "),ae),[]):se=ce);let et=K;!s&&X&&Q&&(et=re.clientWidth);let xe;typeof P<"u"?xe=P:xe=f?null:0;const Ve=R.id||(y?`mui-component-select-${y}`:void 0),Ce={...t,variant:j,value:z,open:le,error:m},Ee=BO(Ce),tt={...b.PaperProps,...typeof b.slotProps?.paper=="function"?b.slotProps.paper(Ce):b.slotProps?.paper},Ht={...b.MenuListProps,...typeof b.slotProps?.list=="function"?b.slotProps.list(Ce):b.slotProps?.list},_n=ul();return N.jsxs(A.Fragment,{children:[N.jsx(DO,{as:"div",ref:ie,tabIndex:xe,role:"combobox","aria-controls":le?_n:void 0,"aria-disabled":f?"true":void 0,"aria-expanded":le?"true":"false","aria-haspopup":"listbox","aria-label":r,"aria-labelledby":[v,Ve].filter(Boolean).join(" ")||void 0,"aria-describedby":o,"aria-required":T?"true":void 0,"aria-invalid":m?"true":void 0,onKeyDown:J,onMouseDown:f||E?null:Se,onBlur:pe,onFocus:O,...R,ownerState:Ce,className:me(R.className,Ee.select,c),id:Ve,children:FO(se)?fd||(fd=N.jsx("span",{className:"notranslate","aria-hidden":!0,children:"​"})):se}),N.jsx(LO,{"aria-invalid":m,value:Array.isArray(z)?z.join(","):z,name:y,ref:ee,"aria-hidden":!0,onChange:Z,tabIndex:-1,disabled:f,className:Ee.nativeInput,autoFocus:i,required:T,...$,ownerState:Ce}),N.jsx(jO,{as:g,className:Ee.icon,ownerState:Ce}),N.jsx(Cl,{id:`menu-${y||""}`,anchorEl:re,open:le,onClose:Ae,anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},...b,slotProps:{...b.slotProps,list:{"aria-labelledby":v,role:"listbox","aria-multiselectable":C?"true":void 0,disableListWrap:!0,id:_n,...Ht},paper:{...tt,style:{minWidth:et,...tt!=null?tt.style:null}}},children:Te})]})});process.env.NODE_ENV!=="production"&&(Wh.propTypes={"aria-describedby":a.string,"aria-label":a.string,autoFocus:a.bool,autoWidth:a.bool,children:a.node,classes:a.object,className:a.string,defaultOpen:a.bool,defaultValue:a.any,disabled:a.bool,displayEmpty:a.bool,error:a.bool,IconComponent:a.elementType.isRequired,inputRef:Zt,labelId:a.string,MenuProps:a.object,multiple:a.bool,name:a.string,onBlur:a.func,onChange:a.func,onClose:a.func,onFocus:a.func,onOpen:a.func,open:a.bool,readOnly:a.bool,renderValue:a.func,required:a.bool,SelectDisplayProps:a.object,tabIndex:a.oneOfType([a.number,a.string]),type:a.any,value:a.any,variant:a.oneOf(["standard","outlined","filled"])});const zO=e=>{const{classes:t}=e,o=$e({root:["root"]},Hh,t);return{...t,...o}},Nl={name:"MuiSelect",slot:"Root",shouldForwardProp:e=>gt(e)&&e!=="variant"},VO=de(ps,Nl)(""),HO=de(hs,Nl)(""),WO=de(fs,Nl)(""),sr=A.forwardRef(function(t,n){const o=Le({name:"MuiSelect",props:t}),{autoWidth:r=!1,children:i,classes:s={},className:l,defaultOpen:c=!1,displayEmpty:u=!1,IconComponent:d=qT,id:f,input:p,inputProps:m,label:g,labelId:h,MenuProps:v,multiple:b=!1,native:C=!1,onClose:y,onOpen:x,open:w,renderValue:S,SelectDisplayProps:O,variant:k="outlined",..._}=o,V=C?zh:Wh,I=po(),E=fo({props:o,muiFormControl:I,states:["variant","error"]}),D=E.variant||k,T={...o,variant:D,classes:s},R=zO(T),{root:P,...L}=R,M=p||{standard:N.jsx(VO,{ownerState:T}),outlined:N.jsx(HO,{label:g,ownerState:T}),filled:N.jsx(WO,{ownerState:T})}[D],j=st(n,uo(M));return N.jsx(A.Fragment,{children:A.cloneElement(M,{inputComponent:V,inputProps:{children:i,error:E.error,IconComponent:d,variant:D,type:void 0,multiple:b,...C?{id:f}:{autoWidth:r,defaultOpen:c,displayEmpty:u,labelId:h,MenuProps:v,onClose:y,onOpen:x,open:w,renderValue:S,SelectDisplayProps:{id:f,...O}},...m,classes:m?nt(L,m.classes):L,...p?p.props.inputProps:{}},...(b&&C||u)&&D==="outlined"?{notched:!0}:{},ref:j,className:me(M.props.className,l,R.root),...!p&&{variant:D},..._})})});process.env.NODE_ENV!=="production"&&(sr.propTypes={autoWidth:a.bool,children:a.node,classes:a.object,className:a.string,defaultOpen:a.bool,defaultValue:a.any,displayEmpty:a.bool,IconComponent:a.elementType,id:a.string,input:a.element,inputProps:a.object,label:a.node,labelId:a.string,MenuProps:a.object,multiple:a.bool,native:a.bool,onChange:a.func,onClose:a.func,onOpen:a.func,open:a.bool,renderValue:a.func,SelectDisplayProps:a.object,sx:a.oneOfType([a.arrayOf(a.oneOfType([a.func,a.object,a.bool])),a.func,a.object]),value:a.oneOfType([a.oneOf([""]),a.any]),variant:a.oneOf(["filled","outlined","standard"])});sr.muiName="Select";const vt=iC({createStyledComponent:de("div",{name:"MuiStack",slot:"Root"}),useThemeProps:e=>Le({props:e,name:"MuiStack"})});process.env.NODE_ENV!=="production"&&(vt.propTypes={children:a.node,component:a.elementType,direction:a.oneOfType([a.oneOf(["column-reverse","column","row-reverse","row"]),a.arrayOf(a.oneOf(["column-reverse","column","row-reverse","row"])),a.object]),divider:a.node,spacing:a.oneOfType([a.arrayOf(a.oneOfType([a.number,a.string])),a.number,a.object,a.string]),sx:a.oneOfType([a.arrayOf(a.oneOfType([a.func,a.object,a.bool])),a.func,a.object]),useFlexGap:a.bool});function UO(e){return Pe("MuiTextField",e)}Me("MuiTextField",["root"]);const YO={standard:ps,filled:fs,outlined:hs},qO=e=>{const{classes:t}=e;return $e({root:["root"]},UO,t)},GO=de(Ti,{name:"MuiTextField",slot:"Root"})({}),Ft=A.forwardRef(function(t,n){const o=Le({props:t,name:"MuiTextField"}),{autoComplete:r,autoFocus:i=!1,children:s,className:l,color:c="primary",defaultValue:u,disabled:d=!1,error:f=!1,FormHelperTextProps:p,fullWidth:m=!1,helperText:g,id:h,InputLabelProps:v,inputProps:b,InputProps:C,inputRef:y,label:x,maxRows:w,minRows:S,multiline:O=!1,name:k,onBlur:_,onChange:V,onFocus:I,placeholder:E,required:D=!1,rows:T,select:R=!1,SelectProps:P,slots:L={},slotProps:M={},type:j,value:$,variant:z="outlined",...H}=o,U={...o,autoFocus:i,color:c,disabled:d,error:f,fullWidth:m,multiline:O,required:D,select:R,variant:z},W=qO(U);process.env.NODE_ENV!=="production"&&R&&!s&&console.error("MUI: `children` must be passed when using the `TextField` component with `select`.");const ee=ul(h),te=g&&ee?`${ee}-helper-text`:void 0,Q=x&&ee?`${ee}-label`:void 0,Y=YO[z],X={slots:L,slotProps:{input:C,inputLabel:v,htmlInput:b,formHelperText:p,select:P,...M}},K={},oe=X.slotProps.inputLabel;z==="outlined"&&(oe&&typeof oe.shrink<"u"&&(K.notched=oe.shrink),K.label=x),R&&((!P||!P.native)&&(K.id=void 0),K["aria-describedby"]=void 0);const[B,ie]=qe("root",{elementType:GO,shouldForwardComponentProp:!0,externalForwardedProps:{...X,...H},ownerState:U,className:me(W.root,l),ref:n,additionalProps:{disabled:d,error:f,fullWidth:m,required:D,color:c,variant:z}}),[re,le]=qe("input",{elementType:Y,externalForwardedProps:X,additionalProps:K,ownerState:U}),[be,Se]=qe("inputLabel",{elementType:Sl,externalForwardedProps:X,ownerState:U}),[Ae,G]=qe("htmlInput",{elementType:"input",externalForwardedProps:X,ownerState:U}),[Z,ne]=qe("formHelperText",{elementType:_h,externalForwardedProps:X,ownerState:U}),[J,pe]=qe("select",{elementType:sr,externalForwardedProps:X,ownerState:U}),se=N.jsx(re,{"aria-describedby":te,autoComplete:r,autoFocus:i,defaultValue:u,fullWidth:m,multiline:O,name:k,rows:T,maxRows:w,minRows:S,type:j,value:$,id:ee,inputRef:y,onBlur:_,onChange:V,onFocus:I,placeholder:E,inputProps:G,slots:{input:L.htmlInput?Ae:void 0},...le});return N.jsxs(B,{...ie,children:[x!=null&&x!==""&&N.jsx(be,{htmlFor:ee,id:Q,...Se,children:x}),R?N.jsx(J,{"aria-describedby":te,id:ee,labelId:Q,value:$,input:se,...pe,children:s}):se,g&&N.jsx(Z,{id:te,...ne,children:g})]})});process.env.NODE_ENV!=="production"&&(Ft.propTypes={autoComplete:a.string,autoFocus:a.bool,children:a.node,classes:a.object,className:a.string,color:a.oneOfType([a.oneOf(["primary","secondary","error","info","success","warning"]),a.string]),defaultValue:a.any,disabled:a.bool,error:a.bool,FormHelperTextProps:a.object,fullWidth:a.bool,helperText:a.node,id:a.string,InputLabelProps:a.object,inputProps:a.object,InputProps:a.object,inputRef:Zt,label:a.node,margin:a.oneOf(["dense","none","normal"]),maxRows:a.oneOfType([a.number,a.string]),minRows:a.oneOfType([a.number,a.string]),multiline:a.bool,name:a.string,onBlur:a.func,onChange:a.func,onFocus:a.func,placeholder:a.string,required:a.bool,rows:a.oneOfType([a.number,a.string]),select:a.bool,SelectProps:a.object,size:a.oneOfType([a.oneOf(["medium","small"]),a.string]),slotProps:a.shape({formHelperText:a.oneOfType([a.func,a.object]),htmlInput:a.oneOfType([a.func,a.object]),input:a.oneOfType([a.func,a.object]),inputLabel:a.oneOfType([a.func,a.object]),select:a.oneOfType([a.func,a.object])}),slots:a.shape({formHelperText:a.elementType,htmlInput:a.elementType,input:a.elementType,inputLabel:a.elementType,root:a.elementType,select:a.elementType}),sx:a.oneOfType([a.arrayOf(a.oneOfType([a.func,a.object,a.bool])),a.func,a.object]),type:a.string,value:a.any,variant:a.oneOf(["filled","outlined","standard"])});const Oo=2,Gs=5;function $t({node:e,nodeLabel:t,setNodeLabel:n,nodeMetaData:o,setNodeMetaData:r}){const i=e.type==="multiChoice",s=o&&typeof o=="object"&&!Array.isArray(o)?o:{},l=typeof s.field1=="string"?s.field1:"",c=typeof s.field2=="string"?s.field2:"",u=typeof s.field3=="string"?s.field3:"",d=Math.min(Gs,Math.max(Oo,Number(s.choiceCount)||Oo));return N.jsxs(vt,{spacing:2,children:[N.jsx(Ft,{label:"Node label",helperText:"Shown in the node body (under the divider)",value:t,onChange:f=>n(f.target.value),fullWidth:!0}),i&&N.jsx(Ft,{label:"Number of choices (2–5)",type:"number",inputProps:{min:Oo,max:Gs,step:1},value:d,onChange:f=>r(p=>({...p&&typeof p=="object"&&!Array.isArray(p)?p:{},choiceCount:Math.min(Gs,Math.max(Oo,Number(f.target.value)||Oo))})),fullWidth:!0,helperText:"Reducing prunes removed-branch subtrees (END preserved)."}),N.jsx(Ft,{label:"Text field 1",value:l,onChange:f=>r(p=>({...p&&typeof p=="object"&&!Array.isArray(p)?p:{},field1:f.target.value})),fullWidth:!0,multiline:!0,minRows:2}),N.jsx(Ft,{label:"Text field 2",value:c,onChange:f=>r(p=>({...p&&typeof p=="object"&&!Array.isArray(p)?p:{},field2:f.target.value})),fullWidth:!0,multiline:!0,minRows:2}),N.jsx(Ft,{label:"Text field 3",value:u,onChange:f=>r(p=>({...p&&typeof p=="object"&&!Array.isArray(p)?p:{},field3:f.target.value})),fullWidth:!0,multiline:!0,minRows:2})]})}function KO({nodeLabel:e,setNodeLabel:t,nodeMetaData:n,setNodeMetaData:o}){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{},i=typeof r.subject=="string"?r.subject:"",s=typeof r.body=="string"?r.body:"";return N.jsxs(vt,{spacing:2,children:[N.jsx(Ft,{label:"Node label",helperText:"Shown in the node body (under the divider)",value:e,onChange:l=>t(l.target.value),fullWidth:!0}),N.jsx(Ft,{label:"Email subject",value:i,onChange:l=>o(c=>({...c&&typeof c=="object"&&!Array.isArray(c)?c:{},subject:l.target.value})),fullWidth:!0}),N.jsx(Ft,{label:"Email body",value:s,onChange:l=>o(c=>({...c&&typeof c=="object"&&!Array.isArray(c)?c:{},body:l.target.value})),fullWidth:!0,multiline:!0,minRows:4})]})}function XO({node:e,setNodeLabel:t,nodeMetaData:n,setNodeMetaData:o}){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{},i=typeof r.trackedEvent=="string"?r.trackedEvent:"",s=l=>{const c=l.target.value;o(u=>({...u&&typeof u=="object"&&!Array.isArray(u)?u:{},trackedEvent:c})),t(c)};return N.jsx(vt,{spacing:2,children:N.jsxs(Ti,{fullWidth:!0,children:[N.jsxs(vt,{children:[N.jsx(Sl,{id:"demo-simple-select-label",children:"Tracked Event"}),N.jsxs(sr,{labelId:"demo-simple-select-label",id:"demo-simple-select",value:i,label:"Tracked Event",onChange:s,children:[N.jsx(St,{value:"Class Booked",children:"Class Booked"}),N.jsx(St,{value:"Class Cancelled",children:"Class Cancelled"}),N.jsx(St,{value:"Class Rescheduled",children:"Class Rescheduled"})]}),N.jsx(it,{variant:"caption",sx:{mt:.5,color:"text.secondary"},children:"Select the event to wait for before proceeding."})]}),N.jsxs(vt,{sx:{mt:2},spacing:1,children:[N.jsx(it,{variant:"subtitle2",children:'Wait time before "No / False" is triggered'}),N.jsxs(vt,{direction:"row",spacing:1,alignItems:"center",children:[N.jsx(Ft,{type:"number",value:r.waitTime??7,onChange:l=>{const c=parseInt(l.target.value,10);o(u=>({...u&&typeof u=="object"&&!Array.isArray(u)?u:{},waitTime:isNaN(c)?0:c}))},InputProps:{inputProps:{min:0}},sx:{width:100}}),N.jsx(Ti,{sx:{minWidth:120},children:N.jsxs(sr,{value:r.waitType??"days",onChange:l=>{const c=l.target.value;o(u=>({...u&&typeof u=="object"&&!Array.isArray(u)?u:{},waitType:c}))},children:[N.jsx(St,{value:"days",children:"Days"}),N.jsx(St,{value:"hours",children:"Hours"}),N.jsx(St,{value:"minutes",children:"Minutes"})]})})]}),N.jsx(it,{variant:"caption",sx:{mt:.5,color:"text.secondary"},children:'Specify how long to wait for the event before taking "No / False" action.'})]})]})})}const at="start",Je="end",mo="mingcute:entrance-fill",go="mingcute:exit-fill",yo=2,mn=()=>({field1:"",field2:"",field3:""}),ZO=()=>({trackedEvent:"",waitTime:7,waitType:"days"}),QO=()=>({subject:"",body:""}),JO=()=>({...mn(),choiceCount:yo}),hd=()=>({}),bo=[{kind:"start",title:"Start",icon:mo,drawerFormComponent:$t,createInitialNodeMetaData:hd},{kind:"end",title:"End",icon:go,drawerFormComponent:$t,createInitialNodeMetaData:hd},{kind:"email",title:"Email",category:"Send Message",nodeType:"action",icon:"streamline:send-email",drawerFormComponent:KO,createInitialNodeMetaData:QO},{kind:"sms",title:"SMS",category:"Send Message",nodeType:"action",icon:"fa-solid:sms",drawerFormComponent:$t,createInitialNodeMetaData:mn},{kind:"push",title:"Push Notification / Web Message",category:"Send Message",nodeType:"action",icon:"mdi:message-badge-outline",enabled:!1,drawerFormComponent:$t,createInitialNodeMetaData:mn},{kind:"tag",title:"Tag Client",category:"Update",nodeType:"action",icon:"ph:tag",drawerFormComponent:$t,createInitialNodeMetaData:mn},{kind:"note",title:"Add Client Note",category:"Update",nodeType:"action",icon:"material-symbols-light:add-notes-outline",drawerFormComponent:$t,createInitialNodeMetaData:mn},{kind:"delay",title:"Delay",category:"Action",nodeType:"action",icon:"mdi:timer-sand-empty",drawerFormComponent:$t,createInitialNodeMetaData:mn},{kind:"smartFilter",title:"Smart Filter",category:"Event",nodeType:"conditional",icon:"tabler:filter",drawerFormComponent:$t,createInitialNodeMetaData:mn},{kind:"waitForEvent",title:"Tracked Event",category:"Event",nodeType:"conditional",icon:"codicon:github-action",drawerFormComponent:XO,createInitialNodeMetaData:ZO},{kind:"multiChoice",title:"Multi Choice",category:"Event",nodeType:"multiChoice",icon:"tabler:list-numbers",drawerFormComponent:$t,createInitialNodeMetaData:JO}],eP=bo;function ms(e){return new Map(e.map(t=>[t.kind,t]))}function Uh(e){return!!e&&e.kind!=="start"&&e.kind!=="end"}function Yh(e,t){if(t.length===0)return e;const n=ms(e);for(const i of t)n.set(i.kind,i);const o=e.map(i=>n.get(i.kind)??i),r=new Set(e.map(i=>i.kind));for(const i of t)r.has(i.kind)||o.push(i);return o}const tP=["Send Message","Update","Action","Event"];function qh(e=bo){const t={"Send Message":[],Update:[],Action:[],Event:[]};for(const n of e)Uh(n)&&t[n.category].push(n);return t}function nP(e,t=bo){const n=ms(t).get(e);return Uh(n)?n.nodeType:"action"}const oP=[{id:at,type:"start",position:{x:260,y:60},data:{label:"Start",nodeLabel:"",kind:"start",icon:mo,nodeMetaData:{}}},{id:Je,type:"end",position:{x:260,y:520},data:{label:"End",nodeLabel:"",kind:"end",icon:go,nodeMetaData:{}}}],rP=[{id:"e-start-out-end",type:"plusEdge",source:at,sourceHandle:"out",target:Je,targetHandle:"in",data:{kind:"default",isRedirect:!1}}],Ol=150,iP=170,md=Ol,sP=24,aP=Ol+sP;function gd(e){return Math.min(5,Math.max(2,Number(e.data.nodeMetaData?.choiceCount)||yo))}function yd(e,t){const n=new Map(e.map(p=>[p.id,p])),o=n.get(at),r=n.get(Je),i=o?.position.x??260,s=o?.position.y??60,l=t.filter(p=>!p.data?.isRedirect),c=new Map;for(const p of l){const m=c.get(p.source)??[];m.push(p),c.set(p.source,m)}const u=new Map,d=new Map;u.set(at,0),d.set(at,i);const f=[at];for(;f.length;){const p=f.shift(),m=n.get(p);if(!m)continue;const g=u.get(p)??0,h=d.get(p)??i,v=c.get(p)??[];v.sort((b,C)=>{const y=b.sourceHandle??"",x=C.sourceHandle??"",w=S=>S==="yes"?0:S==="no"?1:S.startsWith("c")?2:3;return w(y)-w(x)});for(const b of v){const C=b.target,y=n.get(C);if(!y)continue;const x=u.get(C),w=g+1;if(x!=null&&x<=g||!(x==null||w<x))continue;u.set(C,w);let O=h;if(m.type==="conditional"){const k=b.sourceHandle??"",_=k==="yes"?h-md:k==="no"?h+md:h;if(y.type==="multiChoice"&&(k==="yes"||k==="no")){const V=gd(y),I=Math.max(0,V-2)*Ol;O=k==="yes"?_-I:_+I}else O=_}if(m.type==="multiChoice"){const _=(gd(m)-1)/2,V=/^c(\d)$/.exec(b.sourceHandle??""),E=(V?Number(V[1]):1)-1-_;O=h+E*aP}d.set(C,O),f.push(C)}}if(r){d.set(Je,i);let p=0;for(const[m,g]of u.entries())m!==Je&&(p=Math.max(p,g));u.set(Je,p+1)}return e.map(p=>{const m=u.get(p.id),g=d.get(p.id);if(m==null||g==null)return p;const h=s+m*iP;return p.id===Je?{...p,position:{x:i,y:h}}:{...p,position:{x:g,y:h}}})}function lP(e){const{nodeId:t,removedHandles:n,nodes:o,edges:r}=e,i=new Map(o.map(b=>[b.id,b])),s=new Map,l=new Map;for(const b of r){const C=s.get(b.source)??[];C.push(b),s.set(b.source,C);const y=l.get(b.target)??[];y.push(b),l.set(b.target,y)}const c=b=>!b.data?.isRedirect,d=r.filter(b=>b.source===t&&n.includes(b.sourceHandle??"")&&c(b)).map(b=>b.target).filter(b=>b&&b!==Je&&b!==at),f=new Set,p=[...d];for(;p.length;){const b=p.pop();if(b===Je||b===at||!i.has(b)||f.has(b))continue;f.add(b);const C=s.get(b)??[];for(const y of C)c(y)&&y.target!==Je&&p.push(y.target)}const m=new Set;let g=!0;for(;g;){g=!1;for(const b of f){if(b===Je||m.has(b))continue;(l.get(b)??[]).filter(c).filter(x=>!(x.source===t&&n.includes(x.sourceHandle??"")||m.has(x.source))).length===0&&(m.add(b),g=!0)}}if(m.size===0)return{nodes:o,edges:r};const h=o.filter(b=>!m.has(b.id)||b.id===Je),v=r.filter(b=>!(m.has(b.source)||m.has(b.target)));return{nodes:h,edges:v}}function cP(e,t){const n=e.icons,o=e.aliases||Object.create(null),r=Object.create(null);function i(s){if(n[s])return r[s]=[];if(!(s in r)){r[s]=null;const l=o[s]&&o[s].parent,c=l&&i(l);c&&(r[s]=[l].concat(c))}return r[s]}return Object.keys(n).concat(Object.keys(o)).forEach(i),r}const Gh=Object.freeze({left:0,top:0,width:16,height:16}),Oi=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Pl=Object.freeze({...Gh,...Oi}),Oa=Object.freeze({...Pl,body:"",hidden:!1});function uP(e,t){const n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);const o=((e.rotate||0)+(t.rotate||0))%4;return o&&(n.rotate=o),n}function bd(e,t){const n=uP(e,t);for(const o in Oa)o in Oi?o in e&&!(o in n)&&(n[o]=Oi[o]):o in t?n[o]=t[o]:o in e&&(n[o]=e[o]);return n}function dP(e,t,n){const o=e.icons,r=e.aliases||Object.create(null);let i={};function s(l){i=bd(o[l]||r[l],i)}return s(t),n.forEach(s),bd(e,i)}function Kh(e,t){const n=[];if(typeof e!="object"||typeof e.icons!="object")return n;e.not_found instanceof Array&&e.not_found.forEach(r=>{t(r,null),n.push(r)});const o=cP(e);for(const r in o){const i=o[r];i&&(t(r,dP(e,r,i)),n.push(r))}return n}const fP={provider:"",aliases:{},not_found:{},...Gh};function Ks(e,t){for(const n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function Xh(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.prefix!="string"||!e.icons||typeof e.icons!="object"||!Ks(e,fP))return null;const n=t.icons;for(const r in n){const i=n[r];if(!r||typeof i.body!="string"||!Ks(i,Oa))return null}const o=t.aliases||Object.create(null);for(const r in o){const i=o[r],s=i.parent;if(!r||typeof s!="string"||!n[s]&&!o[s]||!Ks(i,Oa))return null}return t}const vd=Object.create(null);function pP(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function lo(e,t){const n=vd[e]||(vd[e]=Object.create(null));return n[t]||(n[t]=pP(e,t))}function Zh(e,t){return Xh(t)?Kh(t,(n,o)=>{o?e.icons[n]=o:e.missing.add(n)}):[]}function hP(e,t,n){try{if(typeof n.body=="string")return e.icons[t]={...n},!0}catch{}return!1}const Qh=/^[a-z0-9]+(-[a-z0-9]+)*$/,gs=(e,t,n,o="")=>{const r=e.split(":");if(e.slice(0,1)==="@"){if(r.length<2||r.length>3)return null;o=r.shift().slice(1)}if(r.length>3||!r.length)return null;if(r.length>1){const l=r.pop(),c=r.pop(),u={provider:r.length>0?r[0]:o,prefix:c,name:l};return t&&!ei(u)?null:u}const i=r[0],s=i.split("-");if(s.length>1){const l={provider:o,prefix:s.shift(),name:s.join("-")};return t&&!ei(l)?null:l}if(n&&o===""){const l={provider:o,prefix:"",name:i};return t&&!ei(l,n)?null:l}return null},ei=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1;let ar=!1;function Jh(e){return typeof e=="boolean"&&(ar=e),ar}function xd(e){const t=typeof e=="string"?gs(e,!0,ar):e;if(t){const n=lo(t.provider,t.prefix),o=t.name;return n.icons[o]||(n.missing.has(o)?null:void 0)}}function mP(e,t){const n=gs(e,!0,ar);if(!n)return!1;const o=lo(n.provider,n.prefix);return t?hP(o,n.name,t):(o.missing.add(n.name),!0)}function gP(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),ar&&!t&&!e.prefix){let r=!1;return Xh(e)&&(e.prefix="",Kh(e,(i,s)=>{mP(i,s)&&(r=!0)})),r}const n=e.prefix;if(!ei({prefix:n,name:"a"}))return!1;const o=lo(t,n);return!!Zh(o,e)}const em=Object.freeze({width:null,height:null}),tm=Object.freeze({...em,...Oi}),yP=/(-?[0-9.]*[0-9]+[0-9.]*)/g,bP=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function wd(e,t,n){if(t===1)return e;if(n=n||100,typeof e=="number")return Math.ceil(e*t*n)/n;if(typeof e!="string")return e;const o=e.split(yP);if(o===null||!o.length)return e;const r=[];let i=o.shift(),s=bP.test(i);for(;;){if(s){const l=parseFloat(i);isNaN(l)?r.push(i):r.push(Math.ceil(l*t*n)/n)}else r.push(i);if(i=o.shift(),i===void 0)return r.join("");s=!s}}function vP(e,t="defs"){let n="";const o=e.indexOf("<"+t);for(;o>=0;){const r=e.indexOf(">",o),i=e.indexOf("</"+t);if(r===-1||i===-1)break;const s=e.indexOf(">",i);if(s===-1)break;n+=e.slice(r+1,i).trim(),e=e.slice(0,o).trim()+e.slice(s+1)}return{defs:n,content:e}}function xP(e,t){return e?"<defs>"+e+"</defs>"+t:t}function wP(e,t,n){const o=vP(e);return xP(o.defs,t+o.content+n)}const EP=e=>e==="unset"||e==="undefined"||e==="none";function SP(e,t){const n={...Pl,...e},o={...tm,...t},r={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,o].forEach(h=>{const v=[],b=h.hFlip,C=h.vFlip;let y=h.rotate;b?C?y+=2:(v.push("translate("+(r.width+r.left).toString()+" "+(0-r.top).toString()+")"),v.push("scale(-1 1)"),r.top=r.left=0):C&&(v.push("translate("+(0-r.left).toString()+" "+(r.height+r.top).toString()+")"),v.push("scale(1 -1)"),r.top=r.left=0);let x;switch(y<0&&(y-=Math.floor(y/4)*4),y=y%4,y){case 1:x=r.height/2+r.top,v.unshift("rotate(90 "+x.toString()+" "+x.toString()+")");break;case 2:v.unshift("rotate(180 "+(r.width/2+r.left).toString()+" "+(r.height/2+r.top).toString()+")");break;case 3:x=r.width/2+r.left,v.unshift("rotate(-90 "+x.toString()+" "+x.toString()+")");break}y%2===1&&(r.left!==r.top&&(x=r.left,r.left=r.top,r.top=x),r.width!==r.height&&(x=r.width,r.width=r.height,r.height=x)),v.length&&(i=wP(i,'<g transform="'+v.join(" ")+'">',"</g>"))});const s=o.width,l=o.height,c=r.width,u=r.height;let d,f;s===null?(f=l===null?"1em":l==="auto"?u:l,d=wd(f,c/u)):(d=s==="auto"?c:s,f=l===null?wd(d,u/c):l==="auto"?u:l);const p={},m=(h,v)=>{EP(v)||(p[h]=v.toString())};m("width",d),m("height",f);const g=[r.left,r.top,c,u];return p.viewBox=g.join(" "),{attributes:p,viewBox:g,body:i}}const CP=/\sid="(\S+)"/g,TP="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let NP=0;function OP(e,t=TP){const n=[];let o;for(;o=CP.exec(e);)n.push(o[1]);if(!n.length)return e;const r="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const s=typeof t=="function"?t(i):t+(NP++).toString(),l=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+l+')([")]|\\.[a-z])',"g"),"$1"+s+r+"$3")}),e=e.replace(new RegExp(r,"g"),""),e}const Pa=Object.create(null);function PP(e,t){Pa[e]=t}function Ra(e){return Pa[e]||Pa[""]}function Rl(e){let t;if(typeof e.resources=="string")t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const kl=Object.create(null),Po=["https://api.simplesvg.com","https://api.unisvg.com"],ti=[];for(;Po.length>0;)Po.length===1||Math.random()>.5?ti.push(Po.shift()):ti.push(Po.pop());kl[""]=Rl({resources:["https://api.iconify.design"].concat(ti)});function RP(e,t){const n=Rl(t);return n===null?!1:(kl[e]=n,!0)}function _l(e){return kl[e]}const kP=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let Ed=kP();function _P(e,t){const n=_l(e);if(!n)return 0;let o;if(!n.maxURL)o=0;else{let r=0;n.resources.forEach(s=>{r=Math.max(r,s.length)});const i=t+".json?icons=";o=n.maxURL-r-n.path.length-i.length}return o}function IP(e){return e===404}const MP=(e,t,n)=>{const o=[],r=_P(e,t),i="icons";let s={type:i,provider:e,prefix:t,icons:[]},l=0;return n.forEach((c,u)=>{l+=c.length+1,l>=r&&u>0&&(o.push(s),s={type:i,provider:e,prefix:t,icons:[]},l=c.length),s.icons.push(c)}),o.push(s),o};function $P(e){if(typeof e=="string"){const t=_l(e);if(t)return t.path}return"/"}const AP=(e,t,n)=>{if(!Ed){n("abort",424);return}let o=$P(t.provider);switch(t.type){case"icons":{const i=t.prefix,l=t.icons.join(","),c=new URLSearchParams({icons:l});o+=i+".json?"+c.toString();break}case"custom":{const i=t.uri;o+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let r=503;Ed(e+o).then(i=>{const s=i.status;if(s!==200){setTimeout(()=>{n(IP(s)?"abort":"next",s)});return}return r=501,i.json()}).then(i=>{if(typeof i!="object"||i===null){setTimeout(()=>{i===404?n("abort",i):n("next",r)});return}setTimeout(()=>{n("success",i)})}).catch(()=>{n("next",r)})},DP={prepare:MP,send:AP};function nm(e,t){e.forEach(n=>{const o=n.loaderCallbacks;o&&(n.loaderCallbacks=o.filter(r=>r.id!==t))})}function jP(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1;const o=e.provider,r=e.prefix;t.forEach(i=>{const s=i.icons,l=s.pending.length;s.pending=s.pending.filter(c=>{if(c.prefix!==r)return!0;const u=c.name;if(e.icons[u])s.loaded.push({provider:o,prefix:r,name:u});else if(e.missing.has(u))s.missing.push({provider:o,prefix:r,name:u});else return n=!0,!0;return!1}),s.pending.length!==l&&(n||nm([e],i.id),i.callback(s.loaded.slice(0),s.missing.slice(0),s.pending.slice(0),i.abort))})}))}let LP=0;function FP(e,t,n){const o=LP++,r=nm.bind(null,n,o);if(!t.pending.length)return r;const i={id:o,icons:t,callback:e,abort:r};return n.forEach(s=>{(s.loaderCallbacks||(s.loaderCallbacks=[])).push(i)}),r}function BP(e){const t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((r,i)=>r.provider!==i.provider?r.provider.localeCompare(i.provider):r.prefix!==i.prefix?r.prefix.localeCompare(i.prefix):r.name.localeCompare(i.name));let o={provider:"",prefix:"",name:""};return e.forEach(r=>{if(o.name===r.name&&o.prefix===r.prefix&&o.provider===r.provider)return;o=r;const i=r.provider,s=r.prefix,l=r.name,c=n[i]||(n[i]=Object.create(null)),u=c[s]||(c[s]=lo(i,s));let d;l in u.icons?d=t.loaded:s===""||u.missing.has(l)?d=t.missing:d=t.pending;const f={provider:i,prefix:s,name:l};d.push(f)}),t}function zP(e,t=!0,n=!1){const o=[];return e.forEach(r=>{const i=typeof r=="string"?gs(r,t,n):r;i&&o.push(i)}),o}const VP={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function HP(e,t,n,o){const r=e.resources.length,i=e.random?Math.floor(Math.random()*r):e.index;let s;if(e.random){let S=e.resources.slice(0);for(s=[];S.length>1;){const O=Math.floor(Math.random()*S.length);s.push(S[O]),S=S.slice(0,O).concat(S.slice(O+1))}s=s.concat(S)}else s=e.resources.slice(i).concat(e.resources.slice(0,i));const l=Date.now();let c="pending",u=0,d,f=null,p=[],m=[];typeof o=="function"&&m.push(o);function g(){f&&(clearTimeout(f),f=null)}function h(){c==="pending"&&(c="aborted"),g(),p.forEach(S=>{S.status==="pending"&&(S.status="aborted")}),p=[]}function v(S,O){O&&(m=[]),typeof S=="function"&&m.push(S)}function b(){return{startTime:l,payload:t,status:c,queriesSent:u,queriesPending:p.length,subscribe:v,abort:h}}function C(){c="failed",m.forEach(S=>{S(void 0,d)})}function y(){p.forEach(S=>{S.status==="pending"&&(S.status="aborted")}),p=[]}function x(S,O,k){const _=O!=="success";switch(p=p.filter(V=>V!==S),c){case"pending":break;case"failed":if(_||!e.dataAfterTimeout)return;break;default:return}if(O==="abort"){d=k,C();return}if(_){d=k,p.length||(s.length?w():C());return}if(g(),y(),!e.random){const V=e.resources.indexOf(S.resource);V!==-1&&V!==e.index&&(e.index=V)}c="completed",m.forEach(V=>{V(k)})}function w(){if(c!=="pending")return;g();const S=s.shift();if(S===void 0){if(p.length){f=setTimeout(()=>{g(),c==="pending"&&(y(),C())},e.timeout);return}C();return}const O={status:"pending",resource:S,callback:(k,_)=>{x(O,k,_)}};p.push(O),u++,f=setTimeout(w,e.rotate),n(S,t,O.callback)}return setTimeout(w),b}function om(e){const t={...VP,...e};let n=[];function o(){n=n.filter(l=>l().status==="pending")}function r(l,c,u){const d=HP(t,l,c,(f,p)=>{o(),u&&u(f,p)});return n.push(d),d}function i(l){return n.find(c=>l(c))||null}return{query:r,find:i,setIndex:l=>{t.index=l},getIndex:()=>t.index,cleanup:o}}function Sd(){}const Xs=Object.create(null);function WP(e){if(!Xs[e]){const t=_l(e);if(!t)return;const n=om(t),o={config:t,redundancy:n};Xs[e]=o}return Xs[e]}function UP(e,t,n){let o,r;if(typeof e=="string"){const i=Ra(e);if(!i)return n(void 0,424),Sd;r=i.send;const s=WP(e);s&&(o=s.redundancy)}else{const i=Rl(e);if(i){o=om(i);const s=e.resources?e.resources[0]:"",l=Ra(s);l&&(r=l.send)}}return!o||!r?(n(void 0,424),Sd):o.query(t,r,n)().abort}function Cd(){}function YP(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,jP(e)}))}function qP(e){const t=[],n=[];return e.forEach(o=>{(o.match(Qh)?t:n).push(o)}),{valid:t,invalid:n}}function Ro(e,t,n){function o(){const r=e.pendingIcons;t.forEach(i=>{r&&r.delete(i),e.icons[i]||e.missing.add(i)})}if(n&&typeof n=="object")try{if(!Zh(e,n).length){o();return}}catch(r){console.error(r)}o(),YP(e)}function Td(e,t){e instanceof Promise?e.then(n=>{t(n)}).catch(()=>{t(null)}):t(e)}function GP(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:n,prefix:o}=e,r=e.iconsToLoad;if(delete e.iconsToLoad,!r||!r.length)return;const i=e.loadIcon;if(e.loadIcons&&(r.length>1||!i)){Td(e.loadIcons(r,o,n),d=>{Ro(e,r,d)});return}if(i){r.forEach(d=>{const f=i(d,o,n);Td(f,p=>{const m=p?{prefix:o,icons:{[d]:p}}:null;Ro(e,[d],m)})});return}const{valid:s,invalid:l}=qP(r);if(l.length&&Ro(e,l,null),!s.length)return;const c=o.match(Qh)?Ra(n):null;if(!c){Ro(e,s,null);return}c.prepare(n,o,s).forEach(d=>{UP(n,d,f=>{Ro(e,d.icons,f)})})}))}const KP=(e,t)=>{const n=zP(e,!0,Jh()),o=BP(n);if(!o.pending.length){let c=!0;return t&&setTimeout(()=>{c&&t(o.loaded,o.missing,o.pending,Cd)}),()=>{c=!1}}const r=Object.create(null),i=[];let s,l;return o.pending.forEach(c=>{const{provider:u,prefix:d}=c;if(d===l&&u===s)return;s=u,l=d,i.push(lo(u,d));const f=r[u]||(r[u]=Object.create(null));f[d]||(f[d]=[])}),o.pending.forEach(c=>{const{provider:u,prefix:d,name:f}=c,p=lo(u,d),m=p.pendingIcons||(p.pendingIcons=new Set);m.has(f)||(m.add(f),r[u][d].push(f))}),i.forEach(c=>{const u=r[c.provider][c.prefix];u.length&&GP(c,u)}),t?FP(t,o,i):Cd};function XP(e,t){const n={...e};for(const o in t){const r=t[o],i=typeof r;o in em?(r===null||r&&(i==="string"||i==="number"))&&(n[o]=r):i===typeof n[o]&&(n[o]=o==="rotate"?r%4:r)}return n}const ZP=/[\s,]+/;function QP(e,t){t.split(ZP).forEach(n=>{switch(n.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function JP(e,t=0){const n=e.replace(/^-?[0-9.]*/,"");function o(r){for(;r<0;)r+=4;return r%4}if(n===""){const r=parseInt(e);return isNaN(r)?0:o(r)}else if(n!==e){let r=0;switch(n){case"%":r=25;break;case"deg":r=90}if(r){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i=i/r,i%1===0?o(i):0)}}return t}function eR(e,t){let n=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const o in t)n+=" "+o+'="'+t[o]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+e+"</svg>"}function tR(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function nR(e){return"data:image/svg+xml,"+tR(e)}function oR(e){return'url("'+nR(e)+'")'}let Wo;function rR(){try{Wo=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{Wo=null}}function iR(e){return Wo===void 0&&rR(),Wo?Wo.createHTML(e):e}const rm={...tm,inline:!1},sR={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},aR={display:"inline-block"},ka={backgroundColor:"currentColor"},im={backgroundColor:"transparent"},Nd={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},Od={WebkitMask:ka,mask:ka,background:im};for(const e in Od){const t=Od[e];for(const n in Nd)t[e+n]=Nd[n]}const lR={...rm,inline:!0};function Pd(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const cR=(e,t,n)=>{const o=t.inline?lR:rm,r=XP(o,t),i=t.mode||"svg",s={},l=t.style||{},c={...i==="svg"?sR:{}};if(n){const v=gs(n,!1,!0);if(v){const b=["iconify"],C=["provider","prefix"];for(const y of C)v[y]&&b.push("iconify--"+v[y]);c.className=b.join(" ")}}for(let v in t){const b=t[v];if(b!==void 0)switch(v){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":c.ref=b;break;case"className":c[v]=(c[v]?c[v]+" ":"")+b;break;case"inline":case"hFlip":case"vFlip":r[v]=b===!0||b==="true"||b===1;break;case"flip":typeof b=="string"&&QP(r,b);break;case"color":s.color=b;break;case"rotate":typeof b=="string"?r[v]=JP(b):typeof b=="number"&&(r[v]=b);break;case"ariaHidden":case"aria-hidden":b!==!0&&b!=="true"&&delete c["aria-hidden"];break;default:o[v]===void 0&&(c[v]=b)}}const u=SP(e,r),d=u.attributes;if(r.inline&&(s.verticalAlign="-0.125em"),i==="svg"){c.style={...s,...l},Object.assign(c,d);let v=0,b=t.id;return typeof b=="string"&&(b=b.replace(/-/g,"_")),c.dangerouslySetInnerHTML={__html:iR(OP(u.body,b?()=>b+"ID"+v++:"iconifyReact"))},F.createElement("svg",c)}const{body:f,width:p,height:m}=e,g=i==="mask"||(i==="bg"?!1:f.indexOf("currentColor")!==-1),h=eR(f,{...d,width:p+"",height:m+""});return c.style={...s,"--svg":oR(h),width:Pd(d.width),height:Pd(d.height),...aR,...g?ka:im,...l},F.createElement("span",c)};Jh(!0);PP("",DP);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof t=="object"&&t!==null&&(t instanceof Array?t:[t]).forEach(o=>{try{(typeof o!="object"||o===null||o instanceof Array||typeof o.icons!="object"||typeof o.prefix!="string"||!gP(o))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let n in t){const o="IconifyProviders["+n+"] is invalid.";try{const r=t[n];if(typeof r!="object"||!r||r.resources===void 0)continue;RP(n,r)||console.error(o)}catch{console.error(o)}}}}function sm(e){const[t,n]=F.useState(!!e.ssr),[o,r]=F.useState({});function i(m){if(m){const g=e.icon;if(typeof g=="object")return{name:"",data:g};const h=xd(g);if(h)return{name:g,data:h}}return{name:""}}const[s,l]=F.useState(i(!!e.ssr));function c(){const m=o.callback;m&&(m(),r({}))}function u(m){if(JSON.stringify(s)!==JSON.stringify(m))return c(),l(m),!0}function d(){var m;const g=e.icon;if(typeof g=="object"){u({name:"",data:g});return}const h=xd(g);if(u({name:g,data:h}))if(h===void 0){const v=KP([g],d);r({callback:v})}else h&&((m=e.onLoad)===null||m===void 0||m.call(e,g))}F.useEffect(()=>(n(!0),c),[]),F.useEffect(()=>{t&&d()},[e.icon,t]);const{name:f,data:p}=s;return p?cR({...Pl,...p},e,f):e.children?e.children:e.fallback?e.fallback:F.createElement("span",{})}const uR=F.forwardRef((e,t)=>sm({...e,_ref:t}));F.forwardRef((e,t)=>sm({inline:!0,...e,_ref:t}));const Il=F.forwardRef(({icon:e,width:t=20,sx:n,...o},r)=>N.jsx(wr,{ref:r,component:uR,className:"component-iconify",icon:e,sx:{width:t,height:t,...n},...o}));Il.displayName="Iconify";function Er({title:e,icon:t,children:n}){return N.jsx(wr,{width:"150px",sx:{borderRadius:"3px",backgroundColor:"white",border:"1px solid #646464",boxShadow:"0 0 6px 2px rgba(0, 0, 0, 0.08)"},children:N.jsxs(vt,{children:[N.jsxs(vt,{direction:"row",spacing:1,sx:{p:.5,alignItems:"center"},children:[N.jsx(Il,{icon:t,width:20,sx:{color:"rgba(0, 167, 111, 0.7)"}}),N.jsx(it,{variant:"caption",sx:{color:"#646464"},children:e})]}),n?N.jsxs(N.Fragment,{children:[N.jsx(rn,{}),n]}):null]})})}function dR(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function fR(e){if(!e||typeof e!="object"||Array.isArray(e))return[];const t=e,n=[],o=new Set;for(const i of["field1","field2","field3","subject","body"])i in t&&(n.push(i),o.add(i));for(const i of Object.keys(t))o.has(i)||n.push(i);const r=[];for(const i of n){const s=dR(t[i]);if(s&&(r.push(s),r.length===3))break}return r}function Sr({nodeLabel:e,nodeMetaData:t}){const n=e?.trim()??"",o=!!n,r=fR(t);return N.jsxs(wr,{children:[N.jsx(it,{variant:"caption",textAlign:"center",py:.5,sx:{color:o?"#646464":"#f36",fontSize:"8px",fontWeight:600},children:o?n:"Action required"}),r.map((i,s)=>N.jsx(it,{variant:"caption",textAlign:"center",sx:{color:"#646464",fontSize:"8px",opacity:.85,lineHeight:"10px"},children:i},s))]})}function pR({data:e}){return N.jsxs(N.Fragment,{children:[N.jsx(Er,{title:e.label,icon:e.icon??(e.kind==="start"?mo:go),children:N.jsx(Sr,{nodeLabel:e.nodeLabel,nodeMetaData:e.nodeMetaData})}),N.jsx(pt,{type:"source",position:ue.Bottom,id:"out"})]})}function hR({data:e}){return N.jsxs(N.Fragment,{children:[N.jsx(pt,{type:"target",position:ue.Top,id:"in"}),N.jsx(Er,{title:e.label,icon:e.icon??(e.kind==="start"?mo:go),children:N.jsx(Sr,{nodeLabel:e.nodeLabel,nodeMetaData:e.nodeMetaData})})]})}function mR({data:e}){return N.jsxs(N.Fragment,{children:[N.jsx(pt,{type:"target",position:ue.Top,id:"in"}),N.jsx(Er,{title:e.label,icon:e.icon??"ph:circle",children:N.jsx(Sr,{nodeLabel:e.nodeLabel,nodeMetaData:e.nodeMetaData})}),N.jsx(pt,{type:"source",position:ue.Bottom,id:"out"})]})}const gR={left:"30%"},yR={left:"70%"};function bR({data:e}){const t=e.kind==="abTest";return N.jsxs(N.Fragment,{children:[N.jsx(pt,{type:"target",position:ue.Top,id:"in"}),N.jsx(Er,{title:e.label,icon:e.icon??"tabler:arrow-fork",children:N.jsx(Sr,{nodeLabel:e.nodeLabel,nodeMetaData:e.nodeMetaData})}),N.jsx(pt,{type:"source",position:ue.Bottom,id:"yes",style:gR}),N.jsx(pt,{type:"source",position:ue.Bottom,id:"no",style:yR}),N.jsxs("div",{style:{position:"absolute",width:150,left:0,top:"100%",marginTop:2,display:"flex",justifyContent:"space-between",fontSize:9,color:"#4f4f4f",pointerEvents:"none"},children:[N.jsx("span",{style:{transform:"translateX(-6px)"},children:t?"A":"Yes"}),N.jsx("span",{style:{transform:"translateX(6px)"},children:t?"B":"No"})]})]})}function vR({data:e}){const t=Math.min(5,Math.max(2,Number(e.nodeMetaData?.choiceCount)||yo));return N.jsxs(N.Fragment,{children:[N.jsx(pt,{type:"target",position:ue.Top,id:"in"}),N.jsx(Er,{title:e.label,icon:e.icon??"tabler:list-numbers",children:N.jsx(Sr,{nodeLabel:e.nodeLabel,nodeMetaData:e.nodeMetaData})}),Array.from({length:t}).map((n,o)=>{const r=o+1,i=(o+1)/(t+1)*100;return N.jsx(pt,{type:"source",position:ue.Bottom,id:`c${r}`,style:{left:`${i}%`}},r)}),N.jsx("div",{style:{position:"absolute",width:150,left:0,top:"100%",marginTop:2,display:"flex",justifyContent:"space-between",fontSize:9,color:"#4f4f4f",pointerEvents:"none"},children:Array.from({length:t}).map((n,o)=>N.jsx("span",{style:{width:`${100/t}%`,textAlign:"center"},children:o+1},o))})]})}function xR(e){if(e.length<2)return"";const[t,...n]=e;return`M ${t.x} ${t.y} `+n.map(o=>`L ${o.x} ${o.y}`).join(" ")}function wR(e){let t=0;for(let n=1;n<e.length;n++){const o=e[n].x-e[n-1].x,r=e[n].y-e[n-1].y;t+=Math.hypot(o,r)}return t}function ER(e){if(e.length===0)return{x:0,y:0};if(e.length===1)return e[0];const n=wR(e)/2;let o=0;for(let r=1;r<e.length;r++){const i=e[r-1],s=e[r],l=Math.hypot(s.x-i.x,s.y-i.y);if(o+l>=n){const c=l===0?0:(n-o)/l;return{x:i.x+(s.x-i.x)*c,y:i.y+(s.y-i.y)*c}}o+=l}return e[e.length-1]}const SR={width:22,height:22,background:"rgba(0, 167, 111, 0.7)",border:"1px solid rgba(2, 107, 72, 0.7)",cursor:"pointer",borderRadius:"50%",fontSize:12,lineHeight:1,color:"white",fontWeight:600,boxShadow:"0 0 6px 2px rgba(0, 0, 0, 0.08)",padding:0,display:"flex",alignItems:"center",justifyContent:"center"},CR={position:"absolute",background:"transparent",padding:10,color:"#4f4f4f",fontSize:9,fontWeight:500};function TR(e){const{id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s,targetPosition:l,markerEnd:c,data:u}=e,d=e.sourceHandleId,f=Iw(),p=u?._onPlusClick,m=!!u?.isRedirect,g=i<o-5,[h,v,b]=Ha({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:l}),C=150,y=f.length===0?Math.min(n,r):Math.min(...f.map(j=>j.position.x)),x=f.length===0?Math.max(n,r):Math.max(...f.map(j=>j.position.x+C)),w=140,S=Math.min(y-w,n-w,r-w),O=Math.max(x+w,n+w,r+w),k=m&&d==="yes",_=m&&d==="no",V=k?S:O,I=30,E=[{x:n,y:o},{x:V,y:o},{x:V,y:i-I},{x:r,y:i-I},{x:r,y:i}],D=xR(E),T=ER(E),R=g?D:h,P=g?T.x:v,L=g?T.y:b,M=u?.kind==="yes"?"Yes":u?.kind==="no"?"No":u?.kind==="branch"&&u?.branch?String(u.branch):"";return N.jsxs(N.Fragment,{children:[N.jsx(hr,{id:t,path:R,markerEnd:c,style:{strokeWidth:2,stroke:"#646464",strokeDasharray:m?"6 4":void 0}}),N.jsxs(Rw,{children:[!!M&&N.jsx("div",{style:{...CR,transform:`translate(-50%, 0%) translate(${n}px,${o-10}px)`},className:"nodrag nopan",children:M}),!m&&N.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${P}px,${L}px)`,pointerEvents:"all"},className:"nodrag nopan",children:N.jsx("button",{type:"button",onClick:()=>p?.(t),style:SR,title:"Add step",children:"+"})})]})]})}function NR({menu:e,onClose:t,definitions:n,onChooseKind:o,redirectCandidates:r,onChooseRedirectTarget:i,onSwitchMode:s}){const l=F.useMemo(()=>qh(n),[n]),c=F.useCallback(()=>{const f=[],p=(m,g,h)=>{f.push(N.jsx(it,{variant:"body1",sx:{fontWeight:600,textAlign:"center",px:2,pt:f.length?2:1},children:m},`${h}-t`)),f.push(N.jsx(rn,{},`${h}-d`));for(const v of g){const b=v.enabled===!1;f.push(N.jsxs(St,{disabled:b,onClick:()=>o(e.edgeId,v.kind),sx:b?{opacity:.5}:void 0,children:[N.jsx($h,{children:N.jsx(Il,{icon:v.icon,width:28,sx:{color:"#646464"}})}),N.jsx(jo,{children:v.title})]},`${h}-${v.kind}`))}};return p("Send Message",l["Send Message"],"sm"),p("Update",l.Update,"up"),p("Action",l.Action,"ac"),p("Event",l.Event,"ev"),f.push(N.jsx(rn,{},"redir-d")),f.push(N.jsx(St,{onClick:()=>s("redirect",!1),children:N.jsx(jo,{primary:"Redirect to…"})},"redir")),f},[l,e,o,s]),u=F.useCallback(()=>[N.jsx(Ei,{disableSticky:!0,sx:{fontWeight:700,lineHeight:"32px"},children:e?.relinkSolid?"Relink solid edge to…":"Redirect to…"},"rs"),...r.map(f=>N.jsx(St,{onClick:()=>i(e.edgeId,f.id,!e?.relinkSolid),children:N.jsx(jo,{primary:f.label,secondary:f.nodeLabel?.trim()?f.nodeLabel:`id: ${f.id}`})},`rc-${f.id}`)),N.jsx(rn,{},"rd1"),N.jsx(St,{onClick:()=>s("choose",!1),children:N.jsx(jo,{primary:"Back"})},"back")],[e,r,i,s]),d=F.useMemo(()=>e?e.mode==="choose"?c():u():[],[e,c,u]);return N.jsx(Cl,{open:!!e,onClose:t,anchorReference:"anchorPosition",anchorPosition:e?.anchorPosition??{top:0,left:0},MenuListProps:{dense:!0},children:d})}function OR({open:e,onClose:t,selectedNode:n,selectedDefinition:o,nodeLabel:r,setNodeLabel:i,nodeMetaData:s,setNodeMetaData:l,onSave:c}){const u=o?.drawerFormComponent,d=typeof u=="function"?u:$t;return N.jsxs(kh,{anchor:"right",open:e,onClose:t,PaperProps:{sx:{width:550,p:2}},children:[N.jsx(it,{variant:"h6",sx:{mb:.5},children:"Node metadata"}),N.jsxs(it,{sx:{fontSize:12,opacity:.75,mb:2},children:["Type: ",N.jsx("b",{children:n?.data?.label??"—"}),n?` • id: ${n.id}`:""]}),N.jsxs(vt,{spacing:2,children:[n?N.jsx(d,{node:n,nodeLabel:r,setNodeLabel:i,nodeMetaData:s,setNodeMetaData:l}):N.jsx(it,{sx:{fontSize:13,opacity:.7},children:"No node selected."}),N.jsx(rn,{}),N.jsxs(vt,{direction:"row",spacing:1,children:[N.jsx(Kn,{variant:"outlined",onClick:t,fullWidth:!0,children:"Cancel"}),N.jsx(Kn,{variant:"contained",onClick:c,fullWidth:!0,children:"Save"})]})]})]})}const PR={start:pR,end:hR,conditional:bR,action:mR,multiChoice:vR},RR={plusEdge:TR};function Bn(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function ko(e){const t=Bn(e);return Math.min(5,Math.max(2,Number(t.choiceCount)||yo))}function kR(e){if(e==="yes"||e==="no")return e;const t=/^c(\d+)$/.exec(e??"");return t?t[1]:"child"}function _R(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,o]of Object.entries(e))typeof o!="string"||!o||(t[n]=o);return t}function IR(e,t){const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const r of n)if(e[r]!==t[r])return!1;return!0}function MR(e){if(!e||typeof e!="object"||Array.isArray(e))return;const{x:t,y:n,zoom:o}=e;if(!(typeof t!="number"||typeof n!="number"||typeof o!="number"))return{x:t,y:n,zoom:o}}function $R(e){return e.map(t=>{if(!t.data)return t;const{_onPlusClick:n,...o}=t.data;return{...t,data:o}})}function AR(e){const t=Array.isArray(e?.nodes),n=Array.isArray(e?.edges);return{nodes:t?e?.nodes:oP,edges:n?$R(e?.edges):rP,viewport:MR(e?.viewport)}}function DR({nodeDefinitions:e=bo,initialFlow:t,onExportJson:n,onCancel:o}){const r=F.useRef(AR(t)),i=!!r.current.viewport,s=Li(),l=kw(),c=Dw(),u=F.useMemo(()=>ms(e),[e]),[d,f]=Mw(r.current.nodes),[p,m,g]=$w(r.current.edges),h=F.useRef(p);F.useEffect(()=>{h.current=p},[p]);const[v,b]=F.useState(null),C=F.useRef(!1),y=F.useRef(!1),[x,w]=F.useState(!1),[S,O]=F.useState(null),[k,_]=F.useState(""),[V,I]=F.useState({}),E=F.useRef(null),D=F.useCallback(G=>d.find(Z=>Z.id===G),[d]),T=F.useCallback((G,Z)=>p.filter(ne=>ne.source===G&&(Z==null?!0:(ne.sourceHandle??null)===(Z??null))).length,[p]),R=F.useCallback(G=>p.filter(Z=>Z.target===G).length,[p]),P=F.useCallback(G=>{if(C.current){y.current=!0;return}const Z=s.getNodes(),ne=s.getEdges(),J=yd(Z,ne);f(J),G?.fit&&requestAnimationFrame(()=>s.fitView({duration:300,padding:.35}))},[s,f]);F.useEffect(()=>{if(!c)return;const G=setTimeout(()=>P({fit:!i}),30);return()=>clearTimeout(G)},[c,P,i]),F.useEffect(()=>{if(!c)return;const G=r.current.viewport;if(!G)return;const Z=setTimeout(()=>{s.setViewport(G)},60);return()=>clearTimeout(Z)},[c,s]),F.useEffect(()=>{f(G=>{const Z=new Set(G.map(ce=>ce.id)),ne=new Map,J=new Map;for(const ce of p){if(!Z.has(ce.source)||!Z.has(ce.target))continue;const fe=kR(ce.sourceHandle),he=J.get(ce.source)??{};he[fe]=ce.target,J.set(ce.source,he),ne.has(ce.target)||ne.set(ce.target,ce.source)}let pe=!1;const se=G.map(ce=>{const fe=ne.get(ce.id),he=J.get(ce.id)??{},ye=_R(ce.data.childNodeIds),Te=ce.data.parentNodeId===fe,et=IR(ye,he);return Te&&et?ce:(pe=!0,{...ce,data:{...ce.data,parentNodeId:fe,childNodeIds:Object.keys(he).length>0?he:void 0}})});return pe?se:G})},[p,f]),F.useEffect(()=>{f(G=>G.map(Z=>{const ne=Z.data.kind??(Z.id===at?"start":Z.id===Je?"end":void 0),J=ne?u.get(ne):void 0,pe=Bn(Z.data.nodeMetaData),se=Bn(J?.createInitialNodeMetaData?.()??{}),ce=J?{...se,...pe}:pe,fe={...Z.data,nodeMetaData:ce};if(Z.id===at||Z.id===Je)return{...Z,data:{...Z.data,nodeMetaData:ce,label:J?.title??Z.data.label??(Z.id===at?"Start":"End"),icon:J?.icon??Z.data.icon??(Z.id===at?mo:go)}};if(J&&!Z.data.icon)return{...Z,data:{...fe,icon:J.icon,label:Z.data.label??J.title}};if(Z.type==="multiChoice"){const he=ko(ce);return{...Z,data:{...fe,nodeMetaData:{...ce,choiceCount:he}}}}return{...Z,data:fe}}))},[u,f]),F.useEffect(()=>{const G=E.current;if(!G)return;const Z=d.find(pe=>pe.id===G.nodeId);if(!Z||Z.type!=="multiChoice"){E.current=null;return}const ne=ko(Z.data.nodeMetaData);if(ne!==G.nextCount)return;l(G.nodeId);const J=requestAnimationFrame(()=>{requestAnimationFrame(()=>{let pe=d,se=p;const ce=[];for(let fe=ne+1;fe<=5;fe++)ce.push(`c${fe}`);if(ce.length>0){const fe=lP({nodeId:G.nodeId,removedHandles:ce,nodes:pe,edges:se});pe=fe.nodes,se=fe.edges}se=se.filter(fe=>{if(fe.source!==G.nodeId)return!0;const he=fe.sourceHandle??"",ye=/^c(\d)$/.exec(he);return ye?Number(ye[1])<=ne:!0});for(let fe=1;fe<=ne;fe++){const he=`c${fe}`;se.some(Te=>Te.source===G.nodeId&&(Te.sourceHandle??"")===he)||(se=[...se,{id:`e-${G.nodeId}-${he}-${Je}`,type:"plusEdge",source:G.nodeId,sourceHandle:he,target:Je,targetHandle:"in",data:{kind:"branch",branch:fe,isRedirect:!1}}])}f(pe),m(se),E.current=null,setTimeout(()=>P(),0)})});return()=>cancelAnimationFrame(J)},[d,p,f,m,P,l]);const L=F.useCallback(()=>({version:2,nodes:d,edges:p.map(G=>{const{_onPlusClick:Z,...ne}=G.data??{};return{...G,data:ne}}),viewport:s.getViewport()}),[d,p,s]),M=F.useCallback(()=>{const G=L();if(n){n(G);return}const Z=JSON.stringify(G,null,2);console.log(Z),navigator.clipboard?.writeText(Z).catch(()=>{}),alert("Export copied to clipboard (and logged to console).")},[L,n]),j=F.useCallback(()=>{b(null),w(!1),o?.()},[o]),$=F.useCallback(G=>{if(!G.source||!G.target)return!1;const Z=D(G.source),ne=D(G.target);if(!Z||!ne||ne.type==="start"||Z.type==="end"||ne.type==="end"&&R(ne.id)>=1||Z.type==="start"&&T(Z.id)>=1)return!1;if(Z.type==="conditional"){const J=G.sourceHandle;if(J!=="yes"&&J!=="no"||T(Z.id,J)>=1)return!1}if(Z.type==="action"&&((G.sourceHandle??"out")!=="out"||T(Z.id,"out")>=1))return!1;if(Z.type==="multiChoice"){const J=G.sourceHandle??"";if(!/^c[1-5]$/.test(J)||T(Z.id,J)>=1)return!1}return!0},[D,R,T]),z=F.useCallback(G=>{const Z=p.find(ce=>ce.id===G);if(!Z||Z.data?.isRedirect)return;const ne=s.getNode(Z.source),J=s.getNode(Z.target);if(!ne||!J)return;const pe={x:(ne.position.x+J.position.x)/2,y:(ne.position.y+J.position.y)/2},se=s.flowToScreenPosition(pe);b({edgeId:G,mode:"choose",relinkSolid:!1,anchorPosition:{top:se.y,left:se.x}})},[p,s]),H=F.useCallback((G,Z)=>{const ne=p.find(Ve=>Ve.id===G);if(!ne||ne.data?.isRedirect)return;const J=s.getNode(ne.source),pe=s.getNode(ne.target);if(!J||!pe)return;const se=u.get(Z);if(!se||!("nodeType"in se))return;const ce=se.nodeType,fe=(J.position.x+pe.position.x)/2,he=(J.position.y+pe.position.y)/2,ye=crypto.randomUUID(),Te=Bn(se.createInitialNodeMetaData?.()??{}),et=ce==="multiChoice"?{...Te,choiceCount:ko(Te)}:Te,xe={id:ye,type:ce,position:{x:fe,y:he-40},data:{label:se.title,nodeLabel:"",kind:Z,icon:se.icon,nodeMetaData:et}};f(Ve=>[...Ve,xe]),m(Ve=>{const Ce=Ve.find(ae=>ae.id===G);if(!Ce)return Ve;const Ee=Ve.filter(ae=>ae.id!==G),tt={id:`e-${Ce.source}-${Ce.sourceHandle??"out"}-${ye}`,type:"plusEdge",source:Ce.source,sourceHandle:Ce.sourceHandle,target:ye,targetHandle:"in",data:{kind:Ce.data?.kind??"default",isRedirect:!1,branch:Ce.data?.branch}};if(ce==="action"){const ae={id:`e-${ye}-out-${Ce.target}`,type:"plusEdge",source:ye,sourceHandle:"out",target:Ce.target,targetHandle:Ce.targetHandle??"in",data:{kind:"default",isRedirect:!1}};return[...Ee,tt,ae]}if(ce==="conditional"){const ae={id:`e-${ye}-yes-${Ce.target}`,type:"plusEdge",source:ye,sourceHandle:"yes",target:Ce.target,targetHandle:Ce.targetHandle??"in",data:{kind:"yes",isRedirect:!1}},ve={id:`e-${ye}-no-${Ce.target}`,type:"plusEdge",source:ye,sourceHandle:"no",target:Ce.target,targetHandle:Ce.targetHandle??"in",data:{kind:"no",isRedirect:!1}};return[...Ee,tt,ae,ve]}const Ht=Math.min(5,Math.max(2,yo)),_n=Array.from({length:Ht}).map((ae,ve)=>{const Ye=ve+1;return{id:`e-${ye}-c${Ye}-${Ce.target}`,type:"plusEdge",source:ye,sourceHandle:`c${Ye}`,target:Ce.target,targetHandle:Ce.targetHandle??"in",data:{kind:"branch",branch:Ye,isRedirect:!1}}});return[...Ee,tt,..._n]}),b(null),queueMicrotask(()=>P())},[p,u,s,m,f,P]),U=F.useCallback((G,Z,ne)=>{const J=D(Z);J&&J.type!=="start"&&(m(pe=>pe.map(se=>{if(se.id!==G)return se;const ce=se.data??{kind:"default"},fe=ne.makeRedirect&&!ce.isRedirect?se.target:ce.baseTarget,he=ne.makeRedirect&&!ce.isRedirect?se.targetHandle??"in":ce.baseTargetHandle;return{...se,target:Z,targetHandle:"in",data:{...ce,isRedirect:!!ne.makeRedirect,baseTarget:ne.makeRedirect?fe:void 0,baseTargetHandle:ne.makeRedirect?he:void 0}}})),b(null),queueMicrotask(()=>P()))},[D,m,P]),W=F.useCallback(async G=>{const Z=G.nodes??[];if(Z.length===0||Z.length!==1)return!0;const ne=Z[0];if(ne.type==="start"||ne.type==="end")return!1;const J=s.getEdges(),pe=s.getNodes(),se=pe.find(Ee=>Ee.id===ne.id);if(!se)return!1;const ce=J.filter(Ee=>Ee.target===ne.id),fe=J.filter(Ee=>Ee.source===ne.id),he=ce.find(Ee=>!Ee.data?.isRedirect)??ce[0],ye=Ee=>Ee.find(tt=>!tt.data?.isRedirect)??Ee[0];let Te;if(se.type==="conditional"){const Ee=fe.filter(tt=>tt.sourceHandle==="yes");Te=ye(Ee)??ye(fe)}else if(se.type==="multiChoice"){const Ee=fe.filter(tt=>tt.sourceHandle==="c1");Te=ye(Ee)??ye(fe)}else{const Ee=fe.filter(tt=>(tt.sourceHandle??"out")==="out");Te=ye(Ee)??ye(fe)}const et=J.filter(Ee=>Ee.source!==ne.id&&Ee.target!==ne.id),xe=pe.filter(Ee=>Ee.id!==ne.id);let Ve=et;if(he&&Te&&Te.target!==at){const Ee={id:`e-${he.source}-${he.sourceHandle??"out"}-${Te.target}`,type:"plusEdge",source:he.source,sourceHandle:he.sourceHandle,target:Te.target,targetHandle:Te.targetHandle??"in",data:{kind:he.data?.kind??"default",isRedirect:!1,branch:he.data?.branch}};Ve.some(Ht=>Ht.source===Ee.source&&(Ht.sourceHandle??null)===(Ee.sourceHandle??null)&&Ht.target===Ee.target)||(Ve=[...Ve,Ee])}m(Ve);const Ce=yd(xe,Ve);return f(Ce),!1},[s,m,f]),ee=F.useCallback((G,Z)=>{const ne=G.data,J=ne?.kind??(Z.sourceHandle==="yes"?"yes":Z.sourceHandle==="no"?"no":/^c[1-5]$/.test(Z.sourceHandle??"")?"branch":"default"),pe=ne?.branch??(()=>{const he=/^c(\d)$/.exec(Z.sourceHandle??"");return he?Number(he[1]):void 0})(),se=!!ne?.isRedirect,ce=ne?.baseTarget,fe=ne?.baseTargetHandle;m(he=>Y0(G,Z,he).map(ye=>{if(ye.id!==G.id)return{...ye,data:ye.data??{kind:"default"}};const Te=ye.data??{kind:J};return{...ye,data:{kind:Te.kind??J,branch:Te.branch??pe,isRedirect:!0,baseTarget:se?ce:G.target,baseTargetHandle:se?fe:G.targetHandle??"in"}}})),queueMicrotask(()=>P())},[m,P]),te=F.useCallback(G=>{f(Z=>Ka(G,Z))},[f]),Q=F.useCallback(G=>{const Z=G.filter(J=>{if(J.type!=="remove")return!1;const pe=J.id;return pe?!!h.current.find(ce=>ce.id===pe)?.data?.isRedirect:!1}),ne=G.filter(J=>{if(J.type!=="remove")return!0;const pe=J.id;return pe?!h.current.find(ce=>ce.id===pe)?.data?.isRedirect:!0});ne.length&&(m(J=>Xa(ne,J)),g(ne));for(const J of Z){const pe=J.id,se=h.current.find(xe=>xe.id===pe);if(!se)continue;const ce=se.data?.baseTarget??Je,fe=se.data?.baseTargetHandle??"in";m(xe=>xe.map(Ve=>Ve.id===pe?{...Ve,target:ce,targetHandle:fe,data:{...Ve.data??{kind:"default"},isRedirect:!1,baseTarget:void 0,baseTargetHandle:void 0}}:Ve));const he=s.getNode(se.source),ye=s.getNode(ce),Te=he&&ye?{x:(he.position.x+ye.position.x)/2,y:(he.position.y+ye.position.y)/2}:{x:0,y:0},et=s.flowToScreenPosition(Te);b({edgeId:pe,mode:"redirect",relinkSolid:!0,anchorPosition:{top:et.y,left:et.x}}),queueMicrotask(()=>P())}},[m,g,s,P]),Y=F.useMemo(()=>p.map(G=>({...G,data:{...G.data??{kind:"default"},_onPlusClick:z}})),[p,z]),X=F.useMemo(()=>d.filter(G=>G.type!=="start").map(G=>({id:G.id,label:G.data?.label??G.id,nodeLabel:G.data?.nodeLabel??""})),[d]),K=F.useCallback((G,Z)=>{Z.data?.isRedirect&&(G.preventDefault(),G.stopPropagation(),b({edgeId:Z.id,mode:"redirect",relinkSolid:!1,anchorPosition:{top:G.clientY,left:G.clientX}}))},[]),oe=F.useCallback((G,Z)=>{O(Z.id),_(Z.data?.nodeLabel??"");const ne=Bn(Z.data.nodeMetaData);I(Z.type==="multiChoice"?{...ne,choiceCount:ko(ne)}:ne),w(!0)},[]),B=F.useMemo(()=>S?D(S):void 0,[D,S]),ie=F.useMemo(()=>{const G=B?.data?.kind??(B?.id===at?"start":B?.id===Je?"end":void 0);if(G)return u.get(G)},[u,B]),re=F.useCallback(()=>{if(!S)return;const Z=d.find(pe=>pe.id===S)?.type==="multiChoice",ne=Bn(V),J=ko(ne);f(pe=>pe.map(se=>se.id===S?{...se,data:{...se.data??{label:""},nodeLabel:k,nodeMetaData:se.type==="multiChoice"?{...ne,choiceCount:J}:ne}}:se)),Z&&(E.current={nodeId:S,nextCount:J}),w(!1),queueMicrotask(()=>P())},[S,k,V,d,f,P]),le=F.useCallback(()=>b(null),[]),be=F.useCallback(()=>{C.current=!0},[]),Se=F.useCallback(()=>{C.current=!1,y.current&&(y.current=!1,P())},[P]),Ae=F.useCallback((G,Z)=>{b(ne=>ne&&{...ne,mode:G,relinkSolid:Z??ne.relinkSolid})},[]);return N.jsxs(wr,{sx:{width:"100%",height:"88vh",border:"1px solid #ddd",borderRadius:2,position:"relative",overflow:"hidden",bgcolor:"white"},children:[N.jsxs(vt,{direction:"row",spacing:1,sx:{p:1.25,borderBottom:"1px solid #eee",alignItems:"center"},children:[N.jsx(Kn,{variant:"contained",size:"small",onClick:M,children:"Save"}),N.jsx(Kn,{variant:"outlined",size:"small",onClick:j,children:"Cancel / Close"}),N.jsx(Kn,{variant:"outlined",size:"small",onClick:()=>P({fit:!0}),children:"Auto layout"}),N.jsx(it,{sx:{ml:"auto",fontSize:12,opacity:.75},children:"Redirect edge delete ⇒ restores solid + asks relink"})]}),N.jsx(NR,{menu:v,onClose:le,definitions:e,onChooseKind:(G,Z)=>H(G,Z),redirectCandidates:X,onChooseRedirectTarget:(G,Z,ne)=>U(G,Z,{makeRedirect:ne}),onSwitchMode:Ae}),N.jsxs(Ow,{nodes:d,edges:Y,onNodesChange:te,onEdgesChange:Q,nodeTypes:PR,edgeTypes:RR,fitView:!i,isValidConnection:$,onBeforeDelete:W,onReconnect:ee,onEdgeClick:K,onNodeClick:oe,onNodeDragStart:be,onNodeDragStop:Se,defaultEdgeOptions:{markerEnd:{type:Zo.Arrow,width:12,height:12}},children:[N.jsx(Gw,{}),N.jsx(zw,{})]}),N.jsx(OR,{open:x,onClose:()=>w(!1),selectedNode:B,selectedDefinition:ie,nodeLabel:k,setNodeLabel:_,nodeMetaData:V,setNodeMetaData:I,onSave:re})]})}function jR({nodeDefinitions:e,extendNodeDefinitions:t=[],initialFlow:n,onExportJson:o,onCancel:r}){const i=F.useMemo(()=>e||Yh(bo,t),[e,t]);return N.jsx(pp,{children:N.jsx(DR,{nodeDefinitions:i,initialFlow:n,onExportJson:o,onCancel:r})})}exports.CATEGORIES=tP;exports.DEFAULT_MULTI_CHOICE_COUNT=yo;exports.DEFAULT_NODE_DEFINITIONS=bo;exports.END_ICON=go;exports.END_ID=Je;exports.FlowEditor=jR;exports.NODE_DEFINITIONS=eP;exports.START_ICON=mo;exports.START_ID=at;exports.createNodeDefinitionMap=ms;exports.groupDefinitions=qh;exports.kindToNodeType=nP;exports.mergeNodeDefinitions=Yh;
159
+ `))}},[ye,G,C,y,z]),he&&(C?fe.length===0?se=null:se=fe.reduce((ae,ve,Ye)=>(ae.push(ve),Ye<fe.length-1&&ae.push(", "),ae),[]):se=ce);let et=K;!s&&X&&Q&&(et=re.clientWidth);let xe;typeof P<"u"?xe=P:xe=f?null:0;const Ve=R.id||(y?`mui-component-select-${y}`:void 0),Ce={...t,variant:j,value:z,open:le,error:m},Ee=BO(Ce),tt={...b.PaperProps,...typeof b.slotProps?.paper=="function"?b.slotProps.paper(Ce):b.slotProps?.paper},Ht={...b.MenuListProps,...typeof b.slotProps?.list=="function"?b.slotProps.list(Ce):b.slotProps?.list},_n=ul();return N.jsxs(A.Fragment,{children:[N.jsx(DO,{as:"div",ref:ie,tabIndex:xe,role:"combobox","aria-controls":le?_n:void 0,"aria-disabled":f?"true":void 0,"aria-expanded":le?"true":"false","aria-haspopup":"listbox","aria-label":r,"aria-labelledby":[v,Ve].filter(Boolean).join(" ")||void 0,"aria-describedby":o,"aria-required":T?"true":void 0,"aria-invalid":m?"true":void 0,onKeyDown:J,onMouseDown:f||E?null:Se,onBlur:pe,onFocus:O,...R,ownerState:Ce,className:me(R.className,Ee.select,c),id:Ve,children:FO(se)?fd||(fd=N.jsx("span",{className:"notranslate","aria-hidden":!0,children:"​"})):se}),N.jsx(LO,{"aria-invalid":m,value:Array.isArray(z)?z.join(","):z,name:y,ref:ee,"aria-hidden":!0,onChange:Z,tabIndex:-1,disabled:f,className:Ee.nativeInput,autoFocus:i,required:T,...$,ownerState:Ce}),N.jsx(jO,{as:g,className:Ee.icon,ownerState:Ce}),N.jsx(Cl,{id:`menu-${y||""}`,anchorEl:re,open:le,onClose:Ae,anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},...b,slotProps:{...b.slotProps,list:{"aria-labelledby":v,role:"listbox","aria-multiselectable":C?"true":void 0,disableListWrap:!0,id:_n,...Ht},paper:{...tt,style:{minWidth:et,...tt!=null?tt.style:null}}},children:Te})]})});process.env.NODE_ENV!=="production"&&(Wh.propTypes={"aria-describedby":a.string,"aria-label":a.string,autoFocus:a.bool,autoWidth:a.bool,children:a.node,classes:a.object,className:a.string,defaultOpen:a.bool,defaultValue:a.any,disabled:a.bool,displayEmpty:a.bool,error:a.bool,IconComponent:a.elementType.isRequired,inputRef:Zt,labelId:a.string,MenuProps:a.object,multiple:a.bool,name:a.string,onBlur:a.func,onChange:a.func,onClose:a.func,onFocus:a.func,onOpen:a.func,open:a.bool,readOnly:a.bool,renderValue:a.func,required:a.bool,SelectDisplayProps:a.object,tabIndex:a.oneOfType([a.number,a.string]),type:a.any,value:a.any,variant:a.oneOf(["standard","outlined","filled"])});const zO=e=>{const{classes:t}=e,o=$e({root:["root"]},Hh,t);return{...t,...o}},Nl={name:"MuiSelect",slot:"Root",shouldForwardProp:e=>gt(e)&&e!=="variant"},VO=de(ps,Nl)(""),HO=de(hs,Nl)(""),WO=de(fs,Nl)(""),sr=A.forwardRef(function(t,n){const o=Le({name:"MuiSelect",props:t}),{autoWidth:r=!1,children:i,classes:s={},className:l,defaultOpen:c=!1,displayEmpty:u=!1,IconComponent:d=qT,id:f,input:p,inputProps:m,label:g,labelId:h,MenuProps:v,multiple:b=!1,native:C=!1,onClose:y,onOpen:x,open:w,renderValue:S,SelectDisplayProps:O,variant:k="outlined",..._}=o,V=C?zh:Wh,I=po(),E=fo({props:o,muiFormControl:I,states:["variant","error"]}),D=E.variant||k,T={...o,variant:D,classes:s},R=zO(T),{root:P,...L}=R,M=p||{standard:N.jsx(VO,{ownerState:T}),outlined:N.jsx(HO,{label:g,ownerState:T}),filled:N.jsx(WO,{ownerState:T})}[D],j=st(n,uo(M));return N.jsx(A.Fragment,{children:A.cloneElement(M,{inputComponent:V,inputProps:{children:i,error:E.error,IconComponent:d,variant:D,type:void 0,multiple:b,...C?{id:f}:{autoWidth:r,defaultOpen:c,displayEmpty:u,labelId:h,MenuProps:v,onClose:y,onOpen:x,open:w,renderValue:S,SelectDisplayProps:{id:f,...O}},...m,classes:m?nt(L,m.classes):L,...p?p.props.inputProps:{}},...(b&&C||u)&&D==="outlined"?{notched:!0}:{},ref:j,className:me(M.props.className,l,R.root),...!p&&{variant:D},..._})})});process.env.NODE_ENV!=="production"&&(sr.propTypes={autoWidth:a.bool,children:a.node,classes:a.object,className:a.string,defaultOpen:a.bool,defaultValue:a.any,displayEmpty:a.bool,IconComponent:a.elementType,id:a.string,input:a.element,inputProps:a.object,label:a.node,labelId:a.string,MenuProps:a.object,multiple:a.bool,native:a.bool,onChange:a.func,onClose:a.func,onOpen:a.func,open:a.bool,renderValue:a.func,SelectDisplayProps:a.object,sx:a.oneOfType([a.arrayOf(a.oneOfType([a.func,a.object,a.bool])),a.func,a.object]),value:a.oneOfType([a.oneOf([""]),a.any]),variant:a.oneOf(["filled","outlined","standard"])});sr.muiName="Select";const vt=iC({createStyledComponent:de("div",{name:"MuiStack",slot:"Root"}),useThemeProps:e=>Le({props:e,name:"MuiStack"})});process.env.NODE_ENV!=="production"&&(vt.propTypes={children:a.node,component:a.elementType,direction:a.oneOfType([a.oneOf(["column-reverse","column","row-reverse","row"]),a.arrayOf(a.oneOf(["column-reverse","column","row-reverse","row"])),a.object]),divider:a.node,spacing:a.oneOfType([a.arrayOf(a.oneOfType([a.number,a.string])),a.number,a.object,a.string]),sx:a.oneOfType([a.arrayOf(a.oneOfType([a.func,a.object,a.bool])),a.func,a.object]),useFlexGap:a.bool});function UO(e){return Pe("MuiTextField",e)}Me("MuiTextField",["root"]);const YO={standard:ps,filled:fs,outlined:hs},qO=e=>{const{classes:t}=e;return $e({root:["root"]},UO,t)},GO=de(Ti,{name:"MuiTextField",slot:"Root"})({}),Ft=A.forwardRef(function(t,n){const o=Le({props:t,name:"MuiTextField"}),{autoComplete:r,autoFocus:i=!1,children:s,className:l,color:c="primary",defaultValue:u,disabled:d=!1,error:f=!1,FormHelperTextProps:p,fullWidth:m=!1,helperText:g,id:h,InputLabelProps:v,inputProps:b,InputProps:C,inputRef:y,label:x,maxRows:w,minRows:S,multiline:O=!1,name:k,onBlur:_,onChange:V,onFocus:I,placeholder:E,required:D=!1,rows:T,select:R=!1,SelectProps:P,slots:L={},slotProps:M={},type:j,value:$,variant:z="outlined",...H}=o,U={...o,autoFocus:i,color:c,disabled:d,error:f,fullWidth:m,multiline:O,required:D,select:R,variant:z},W=qO(U);process.env.NODE_ENV!=="production"&&R&&!s&&console.error("MUI: `children` must be passed when using the `TextField` component with `select`.");const ee=ul(h),te=g&&ee?`${ee}-helper-text`:void 0,Q=x&&ee?`${ee}-label`:void 0,Y=YO[z],X={slots:L,slotProps:{input:C,inputLabel:v,htmlInput:b,formHelperText:p,select:P,...M}},K={},oe=X.slotProps.inputLabel;z==="outlined"&&(oe&&typeof oe.shrink<"u"&&(K.notched=oe.shrink),K.label=x),R&&((!P||!P.native)&&(K.id=void 0),K["aria-describedby"]=void 0);const[B,ie]=qe("root",{elementType:GO,shouldForwardComponentProp:!0,externalForwardedProps:{...X,...H},ownerState:U,className:me(W.root,l),ref:n,additionalProps:{disabled:d,error:f,fullWidth:m,required:D,color:c,variant:z}}),[re,le]=qe("input",{elementType:Y,externalForwardedProps:X,additionalProps:K,ownerState:U}),[be,Se]=qe("inputLabel",{elementType:Sl,externalForwardedProps:X,ownerState:U}),[Ae,G]=qe("htmlInput",{elementType:"input",externalForwardedProps:X,ownerState:U}),[Z,ne]=qe("formHelperText",{elementType:_h,externalForwardedProps:X,ownerState:U}),[J,pe]=qe("select",{elementType:sr,externalForwardedProps:X,ownerState:U}),se=N.jsx(re,{"aria-describedby":te,autoComplete:r,autoFocus:i,defaultValue:u,fullWidth:m,multiline:O,name:k,rows:T,maxRows:w,minRows:S,type:j,value:$,id:ee,inputRef:y,onBlur:_,onChange:V,onFocus:I,placeholder:E,inputProps:G,slots:{input:L.htmlInput?Ae:void 0},...le});return N.jsxs(B,{...ie,children:[x!=null&&x!==""&&N.jsx(be,{htmlFor:ee,id:Q,...Se,children:x}),R?N.jsx(J,{"aria-describedby":te,id:ee,labelId:Q,value:$,input:se,...pe,children:s}):se,g&&N.jsx(Z,{id:te,...ne,children:g})]})});process.env.NODE_ENV!=="production"&&(Ft.propTypes={autoComplete:a.string,autoFocus:a.bool,children:a.node,classes:a.object,className:a.string,color:a.oneOfType([a.oneOf(["primary","secondary","error","info","success","warning"]),a.string]),defaultValue:a.any,disabled:a.bool,error:a.bool,FormHelperTextProps:a.object,fullWidth:a.bool,helperText:a.node,id:a.string,InputLabelProps:a.object,inputProps:a.object,InputProps:a.object,inputRef:Zt,label:a.node,margin:a.oneOf(["dense","none","normal"]),maxRows:a.oneOfType([a.number,a.string]),minRows:a.oneOfType([a.number,a.string]),multiline:a.bool,name:a.string,onBlur:a.func,onChange:a.func,onFocus:a.func,placeholder:a.string,required:a.bool,rows:a.oneOfType([a.number,a.string]),select:a.bool,SelectProps:a.object,size:a.oneOfType([a.oneOf(["medium","small"]),a.string]),slotProps:a.shape({formHelperText:a.oneOfType([a.func,a.object]),htmlInput:a.oneOfType([a.func,a.object]),input:a.oneOfType([a.func,a.object]),inputLabel:a.oneOfType([a.func,a.object]),select:a.oneOfType([a.func,a.object])}),slots:a.shape({formHelperText:a.elementType,htmlInput:a.elementType,input:a.elementType,inputLabel:a.elementType,root:a.elementType,select:a.elementType}),sx:a.oneOfType([a.arrayOf(a.oneOfType([a.func,a.object,a.bool])),a.func,a.object]),type:a.string,value:a.any,variant:a.oneOf(["filled","outlined","standard"])});const Oo=2,Gs=5;function $t({node:e,nodeLabel:t,setNodeLabel:n,nodeMetaData:o,setNodeMetaData:r}){const i=e.type==="multiChoice",s=o&&typeof o=="object"&&!Array.isArray(o)?o:{},l=typeof s.field1=="string"?s.field1:"",c=typeof s.field2=="string"?s.field2:"",u=typeof s.field3=="string"?s.field3:"",d=Math.min(Gs,Math.max(Oo,Number(s.choiceCount)||Oo));return N.jsxs(vt,{spacing:2,children:[N.jsx(Ft,{label:"Node label",helperText:"Shown in the node body (under the divider)",value:t,onChange:f=>n(f.target.value),fullWidth:!0}),i&&N.jsx(Ft,{label:"Number of choices (2–5)",type:"number",inputProps:{min:Oo,max:Gs,step:1},value:d,onChange:f=>r(p=>({...p&&typeof p=="object"&&!Array.isArray(p)?p:{},choiceCount:Math.min(Gs,Math.max(Oo,Number(f.target.value)||Oo))})),fullWidth:!0,helperText:"Reducing prunes removed-branch subtrees (END preserved)."}),N.jsx(Ft,{label:"Text field 1",value:l,onChange:f=>r(p=>({...p&&typeof p=="object"&&!Array.isArray(p)?p:{},field1:f.target.value})),fullWidth:!0,multiline:!0,minRows:2}),N.jsx(Ft,{label:"Text field 2",value:c,onChange:f=>r(p=>({...p&&typeof p=="object"&&!Array.isArray(p)?p:{},field2:f.target.value})),fullWidth:!0,multiline:!0,minRows:2}),N.jsx(Ft,{label:"Text field 3",value:u,onChange:f=>r(p=>({...p&&typeof p=="object"&&!Array.isArray(p)?p:{},field3:f.target.value})),fullWidth:!0,multiline:!0,minRows:2})]})}function KO({nodeLabel:e,setNodeLabel:t,nodeMetaData:n,setNodeMetaData:o}){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{},i=typeof r.subject=="string"?r.subject:"",s=typeof r.body=="string"?r.body:"";return N.jsxs(vt,{spacing:2,children:[N.jsx(Ft,{label:"Node label",helperText:"Shown in the node body (under the divider)",value:e,onChange:l=>t(l.target.value),fullWidth:!0}),N.jsx(Ft,{label:"Email subject",value:i,onChange:l=>o(c=>({...c&&typeof c=="object"&&!Array.isArray(c)?c:{},subject:l.target.value})),fullWidth:!0}),N.jsx(Ft,{label:"Email body",value:s,onChange:l=>o(c=>({...c&&typeof c=="object"&&!Array.isArray(c)?c:{},body:l.target.value})),fullWidth:!0,multiline:!0,minRows:4})]})}function XO({node:e,setNodeLabel:t,nodeMetaData:n,setNodeMetaData:o}){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{},i=typeof r.trackedEvent=="string"?r.trackedEvent:"",s=l=>{const c=l.target.value;o(u=>({...u&&typeof u=="object"&&!Array.isArray(u)?u:{},trackedEvent:c})),t(c)};return N.jsx(vt,{spacing:2,children:N.jsxs(Ti,{fullWidth:!0,children:[N.jsxs(vt,{children:[N.jsx(Sl,{id:"demo-simple-select-label",children:"Tracked Event"}),N.jsxs(sr,{labelId:"demo-simple-select-label",id:"demo-simple-select",value:i,label:"Tracked Event",onChange:s,children:[N.jsx(St,{value:"Class Booked",children:"Class Booked"}),N.jsx(St,{value:"Class Cancelled",children:"Class Cancelled"}),N.jsx(St,{value:"Class Rescheduled",children:"Class Rescheduled"})]}),N.jsx(it,{variant:"caption",sx:{mt:.5,color:"text.secondary"},children:"Select the event to wait for before proceeding."})]}),N.jsxs(vt,{sx:{mt:2},spacing:1,children:[N.jsx(it,{variant:"subtitle2",children:'Wait time before "No / False" is triggered'}),N.jsxs(vt,{direction:"row",spacing:1,alignItems:"center",children:[N.jsx(Ft,{type:"number",value:r.waitTime??7,onChange:l=>{const c=parseInt(l.target.value,10);o(u=>({...u&&typeof u=="object"&&!Array.isArray(u)?u:{},waitTime:isNaN(c)?0:c}))},InputProps:{inputProps:{min:0}},sx:{width:100}}),N.jsx(Ti,{sx:{minWidth:120},children:N.jsxs(sr,{value:r.waitType??"days",onChange:l=>{const c=l.target.value;o(u=>({...u&&typeof u=="object"&&!Array.isArray(u)?u:{},waitType:c}))},children:[N.jsx(St,{value:"days",children:"Days"}),N.jsx(St,{value:"hours",children:"Hours"}),N.jsx(St,{value:"minutes",children:"Minutes"})]})})]}),N.jsx(it,{variant:"caption",sx:{mt:.5,color:"text.secondary"},children:'Specify how long to wait for the event before taking "No / False" action.'})]})]})})}const at="start",Je="end",mo="mingcute:entrance-fill",go="mingcute:exit-fill",yo=2,mn=()=>({field1:"",field2:"",field3:""}),ZO=()=>({trackedEvent:"",waitTime:7,waitType:"days"}),QO=()=>({subject:"",body:""}),JO=()=>({...mn(),choiceCount:yo}),hd=()=>({}),bo=[{kind:"start",title:"Start",icon:mo,drawerFormComponent:$t,createInitialNodeMetaData:hd},{kind:"end",title:"Exit",icon:go,drawerFormComponent:$t,createInitialNodeMetaData:hd},{kind:"email",title:"Email",category:"Send Message",nodeType:"action",icon:"streamline:send-email",drawerFormComponent:KO,createInitialNodeMetaData:QO},{kind:"sms",title:"SMS",category:"Send Message",nodeType:"action",icon:"fa-solid:sms",drawerFormComponent:$t,createInitialNodeMetaData:mn},{kind:"push",title:"Push Notification / Web Message",category:"Send Message",nodeType:"action",icon:"mdi:message-badge-outline",enabled:!1,drawerFormComponent:$t,createInitialNodeMetaData:mn},{kind:"tag",title:"Tag Client",category:"Update",nodeType:"action",icon:"ph:tag",drawerFormComponent:$t,createInitialNodeMetaData:mn},{kind:"note",title:"Add Client Note",category:"Update",nodeType:"action",icon:"material-symbols-light:add-notes-outline",drawerFormComponent:$t,createInitialNodeMetaData:mn},{kind:"delay",title:"Delay",category:"Action",nodeType:"action",icon:"mdi:timer-sand-empty",drawerFormComponent:$t,createInitialNodeMetaData:mn},{kind:"smartFilter",title:"Smart Filter",category:"Event",nodeType:"conditional",icon:"tabler:filter",drawerFormComponent:$t,createInitialNodeMetaData:mn},{kind:"waitForEvent",title:"Tracked Event",category:"Event",nodeType:"conditional",icon:"codicon:github-action",drawerFormComponent:XO,createInitialNodeMetaData:ZO},{kind:"multiChoice",title:"Multi Choice",category:"Event",nodeType:"multiChoice",icon:"tabler:list-numbers",drawerFormComponent:$t,createInitialNodeMetaData:JO}],eP=bo;function ms(e){return new Map(e.map(t=>[t.kind,t]))}function Uh(e){return!!e&&e.kind!=="start"&&e.kind!=="end"}function Yh(e,t){if(t.length===0)return e;const n=ms(e);for(const i of t)n.set(i.kind,i);const o=e.map(i=>n.get(i.kind)??i),r=new Set(e.map(i=>i.kind));for(const i of t)r.has(i.kind)||o.push(i);return o}const tP=["Send Message","Update","Action","Event"];function qh(e=bo){const t={"Send Message":[],Update:[],Action:[],Event:[]};for(const n of e)Uh(n)&&t[n.category].push(n);return t}function nP(e,t=bo){const n=ms(t).get(e);return Uh(n)?n.nodeType:"action"}const oP=[{id:at,type:"start",position:{x:260,y:60},data:{label:"Start",nodeLabel:"",kind:"start",icon:mo,nodeMetaData:{}}},{id:Je,type:"end",position:{x:260,y:520},data:{label:"Exit",nodeLabel:"",kind:"end",icon:go,nodeMetaData:{}}}],rP=[{id:"e-start-out-end",type:"plusEdge",source:at,sourceHandle:"out",target:Je,targetHandle:"in",data:{kind:"default",isRedirect:!1}}],Ol=150,iP=170,md=Ol,sP=24,aP=Ol+sP;function gd(e){return Math.min(5,Math.max(2,Number(e.data.nodeMetaData?.choiceCount)||yo))}function yd(e,t){const n=new Map(e.map(p=>[p.id,p])),o=n.get(at),r=n.get(Je),i=o?.position.x??260,s=o?.position.y??60,l=t.filter(p=>!p.data?.isRedirect),c=new Map;for(const p of l){const m=c.get(p.source)??[];m.push(p),c.set(p.source,m)}const u=new Map,d=new Map;u.set(at,0),d.set(at,i);const f=[at];for(;f.length;){const p=f.shift(),m=n.get(p);if(!m)continue;const g=u.get(p)??0,h=d.get(p)??i,v=c.get(p)??[];v.sort((b,C)=>{const y=b.sourceHandle??"",x=C.sourceHandle??"",w=S=>S==="yes"?0:S==="no"?1:S.startsWith("c")?2:3;return w(y)-w(x)});for(const b of v){const C=b.target,y=n.get(C);if(!y)continue;const x=u.get(C),w=g+1;if(x!=null&&x<=g||!(x==null||w<x))continue;u.set(C,w);let O=h;if(m.type==="conditional"){const k=b.sourceHandle??"",_=k==="yes"?h-md:k==="no"?h+md:h;if(y.type==="multiChoice"&&(k==="yes"||k==="no")){const V=gd(y),I=Math.max(0,V-2)*Ol;O=k==="yes"?_-I:_+I}else O=_}if(m.type==="multiChoice"){const _=(gd(m)-1)/2,V=/^c(\d)$/.exec(b.sourceHandle??""),E=(V?Number(V[1]):1)-1-_;O=h+E*aP}d.set(C,O),f.push(C)}}if(r){d.set(Je,i);let p=0;for(const[m,g]of u.entries())m!==Je&&(p=Math.max(p,g));u.set(Je,p+1)}return e.map(p=>{const m=u.get(p.id),g=d.get(p.id);if(m==null||g==null)return p;const h=s+m*iP;return p.id===Je?{...p,position:{x:i,y:h}}:{...p,position:{x:g,y:h}}})}function lP(e){const{nodeId:t,removedHandles:n,nodes:o,edges:r}=e,i=new Map(o.map(b=>[b.id,b])),s=new Map,l=new Map;for(const b of r){const C=s.get(b.source)??[];C.push(b),s.set(b.source,C);const y=l.get(b.target)??[];y.push(b),l.set(b.target,y)}const c=b=>!b.data?.isRedirect,d=r.filter(b=>b.source===t&&n.includes(b.sourceHandle??"")&&c(b)).map(b=>b.target).filter(b=>b&&b!==Je&&b!==at),f=new Set,p=[...d];for(;p.length;){const b=p.pop();if(b===Je||b===at||!i.has(b)||f.has(b))continue;f.add(b);const C=s.get(b)??[];for(const y of C)c(y)&&y.target!==Je&&p.push(y.target)}const m=new Set;let g=!0;for(;g;){g=!1;for(const b of f){if(b===Je||m.has(b))continue;(l.get(b)??[]).filter(c).filter(x=>!(x.source===t&&n.includes(x.sourceHandle??"")||m.has(x.source))).length===0&&(m.add(b),g=!0)}}if(m.size===0)return{nodes:o,edges:r};const h=o.filter(b=>!m.has(b.id)||b.id===Je),v=r.filter(b=>!(m.has(b.source)||m.has(b.target)));return{nodes:h,edges:v}}function cP(e,t){const n=e.icons,o=e.aliases||Object.create(null),r=Object.create(null);function i(s){if(n[s])return r[s]=[];if(!(s in r)){r[s]=null;const l=o[s]&&o[s].parent,c=l&&i(l);c&&(r[s]=[l].concat(c))}return r[s]}return Object.keys(n).concat(Object.keys(o)).forEach(i),r}const Gh=Object.freeze({left:0,top:0,width:16,height:16}),Oi=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Pl=Object.freeze({...Gh,...Oi}),Oa=Object.freeze({...Pl,body:"",hidden:!1});function uP(e,t){const n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);const o=((e.rotate||0)+(t.rotate||0))%4;return o&&(n.rotate=o),n}function bd(e,t){const n=uP(e,t);for(const o in Oa)o in Oi?o in e&&!(o in n)&&(n[o]=Oi[o]):o in t?n[o]=t[o]:o in e&&(n[o]=e[o]);return n}function dP(e,t,n){const o=e.icons,r=e.aliases||Object.create(null);let i={};function s(l){i=bd(o[l]||r[l],i)}return s(t),n.forEach(s),bd(e,i)}function Kh(e,t){const n=[];if(typeof e!="object"||typeof e.icons!="object")return n;e.not_found instanceof Array&&e.not_found.forEach(r=>{t(r,null),n.push(r)});const o=cP(e);for(const r in o){const i=o[r];i&&(t(r,dP(e,r,i)),n.push(r))}return n}const fP={provider:"",aliases:{},not_found:{},...Gh};function Ks(e,t){for(const n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function Xh(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.prefix!="string"||!e.icons||typeof e.icons!="object"||!Ks(e,fP))return null;const n=t.icons;for(const r in n){const i=n[r];if(!r||typeof i.body!="string"||!Ks(i,Oa))return null}const o=t.aliases||Object.create(null);for(const r in o){const i=o[r],s=i.parent;if(!r||typeof s!="string"||!n[s]&&!o[s]||!Ks(i,Oa))return null}return t}const vd=Object.create(null);function pP(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function lo(e,t){const n=vd[e]||(vd[e]=Object.create(null));return n[t]||(n[t]=pP(e,t))}function Zh(e,t){return Xh(t)?Kh(t,(n,o)=>{o?e.icons[n]=o:e.missing.add(n)}):[]}function hP(e,t,n){try{if(typeof n.body=="string")return e.icons[t]={...n},!0}catch{}return!1}const Qh=/^[a-z0-9]+(-[a-z0-9]+)*$/,gs=(e,t,n,o="")=>{const r=e.split(":");if(e.slice(0,1)==="@"){if(r.length<2||r.length>3)return null;o=r.shift().slice(1)}if(r.length>3||!r.length)return null;if(r.length>1){const l=r.pop(),c=r.pop(),u={provider:r.length>0?r[0]:o,prefix:c,name:l};return t&&!ei(u)?null:u}const i=r[0],s=i.split("-");if(s.length>1){const l={provider:o,prefix:s.shift(),name:s.join("-")};return t&&!ei(l)?null:l}if(n&&o===""){const l={provider:o,prefix:"",name:i};return t&&!ei(l,n)?null:l}return null},ei=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1;let ar=!1;function Jh(e){return typeof e=="boolean"&&(ar=e),ar}function xd(e){const t=typeof e=="string"?gs(e,!0,ar):e;if(t){const n=lo(t.provider,t.prefix),o=t.name;return n.icons[o]||(n.missing.has(o)?null:void 0)}}function mP(e,t){const n=gs(e,!0,ar);if(!n)return!1;const o=lo(n.provider,n.prefix);return t?hP(o,n.name,t):(o.missing.add(n.name),!0)}function gP(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),ar&&!t&&!e.prefix){let r=!1;return Xh(e)&&(e.prefix="",Kh(e,(i,s)=>{mP(i,s)&&(r=!0)})),r}const n=e.prefix;if(!ei({prefix:n,name:"a"}))return!1;const o=lo(t,n);return!!Zh(o,e)}const em=Object.freeze({width:null,height:null}),tm=Object.freeze({...em,...Oi}),yP=/(-?[0-9.]*[0-9]+[0-9.]*)/g,bP=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function wd(e,t,n){if(t===1)return e;if(n=n||100,typeof e=="number")return Math.ceil(e*t*n)/n;if(typeof e!="string")return e;const o=e.split(yP);if(o===null||!o.length)return e;const r=[];let i=o.shift(),s=bP.test(i);for(;;){if(s){const l=parseFloat(i);isNaN(l)?r.push(i):r.push(Math.ceil(l*t*n)/n)}else r.push(i);if(i=o.shift(),i===void 0)return r.join("");s=!s}}function vP(e,t="defs"){let n="";const o=e.indexOf("<"+t);for(;o>=0;){const r=e.indexOf(">",o),i=e.indexOf("</"+t);if(r===-1||i===-1)break;const s=e.indexOf(">",i);if(s===-1)break;n+=e.slice(r+1,i).trim(),e=e.slice(0,o).trim()+e.slice(s+1)}return{defs:n,content:e}}function xP(e,t){return e?"<defs>"+e+"</defs>"+t:t}function wP(e,t,n){const o=vP(e);return xP(o.defs,t+o.content+n)}const EP=e=>e==="unset"||e==="undefined"||e==="none";function SP(e,t){const n={...Pl,...e},o={...tm,...t},r={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,o].forEach(h=>{const v=[],b=h.hFlip,C=h.vFlip;let y=h.rotate;b?C?y+=2:(v.push("translate("+(r.width+r.left).toString()+" "+(0-r.top).toString()+")"),v.push("scale(-1 1)"),r.top=r.left=0):C&&(v.push("translate("+(0-r.left).toString()+" "+(r.height+r.top).toString()+")"),v.push("scale(1 -1)"),r.top=r.left=0);let x;switch(y<0&&(y-=Math.floor(y/4)*4),y=y%4,y){case 1:x=r.height/2+r.top,v.unshift("rotate(90 "+x.toString()+" "+x.toString()+")");break;case 2:v.unshift("rotate(180 "+(r.width/2+r.left).toString()+" "+(r.height/2+r.top).toString()+")");break;case 3:x=r.width/2+r.left,v.unshift("rotate(-90 "+x.toString()+" "+x.toString()+")");break}y%2===1&&(r.left!==r.top&&(x=r.left,r.left=r.top,r.top=x),r.width!==r.height&&(x=r.width,r.width=r.height,r.height=x)),v.length&&(i=wP(i,'<g transform="'+v.join(" ")+'">',"</g>"))});const s=o.width,l=o.height,c=r.width,u=r.height;let d,f;s===null?(f=l===null?"1em":l==="auto"?u:l,d=wd(f,c/u)):(d=s==="auto"?c:s,f=l===null?wd(d,u/c):l==="auto"?u:l);const p={},m=(h,v)=>{EP(v)||(p[h]=v.toString())};m("width",d),m("height",f);const g=[r.left,r.top,c,u];return p.viewBox=g.join(" "),{attributes:p,viewBox:g,body:i}}const CP=/\sid="(\S+)"/g,TP="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let NP=0;function OP(e,t=TP){const n=[];let o;for(;o=CP.exec(e);)n.push(o[1]);if(!n.length)return e;const r="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const s=typeof t=="function"?t(i):t+(NP++).toString(),l=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+l+')([")]|\\.[a-z])',"g"),"$1"+s+r+"$3")}),e=e.replace(new RegExp(r,"g"),""),e}const Pa=Object.create(null);function PP(e,t){Pa[e]=t}function Ra(e){return Pa[e]||Pa[""]}function Rl(e){let t;if(typeof e.resources=="string")t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const kl=Object.create(null),Po=["https://api.simplesvg.com","https://api.unisvg.com"],ti=[];for(;Po.length>0;)Po.length===1||Math.random()>.5?ti.push(Po.shift()):ti.push(Po.pop());kl[""]=Rl({resources:["https://api.iconify.design"].concat(ti)});function RP(e,t){const n=Rl(t);return n===null?!1:(kl[e]=n,!0)}function _l(e){return kl[e]}const kP=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let Ed=kP();function _P(e,t){const n=_l(e);if(!n)return 0;let o;if(!n.maxURL)o=0;else{let r=0;n.resources.forEach(s=>{r=Math.max(r,s.length)});const i=t+".json?icons=";o=n.maxURL-r-n.path.length-i.length}return o}function IP(e){return e===404}const MP=(e,t,n)=>{const o=[],r=_P(e,t),i="icons";let s={type:i,provider:e,prefix:t,icons:[]},l=0;return n.forEach((c,u)=>{l+=c.length+1,l>=r&&u>0&&(o.push(s),s={type:i,provider:e,prefix:t,icons:[]},l=c.length),s.icons.push(c)}),o.push(s),o};function $P(e){if(typeof e=="string"){const t=_l(e);if(t)return t.path}return"/"}const AP=(e,t,n)=>{if(!Ed){n("abort",424);return}let o=$P(t.provider);switch(t.type){case"icons":{const i=t.prefix,l=t.icons.join(","),c=new URLSearchParams({icons:l});o+=i+".json?"+c.toString();break}case"custom":{const i=t.uri;o+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let r=503;Ed(e+o).then(i=>{const s=i.status;if(s!==200){setTimeout(()=>{n(IP(s)?"abort":"next",s)});return}return r=501,i.json()}).then(i=>{if(typeof i!="object"||i===null){setTimeout(()=>{i===404?n("abort",i):n("next",r)});return}setTimeout(()=>{n("success",i)})}).catch(()=>{n("next",r)})},DP={prepare:MP,send:AP};function nm(e,t){e.forEach(n=>{const o=n.loaderCallbacks;o&&(n.loaderCallbacks=o.filter(r=>r.id!==t))})}function jP(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1;const o=e.provider,r=e.prefix;t.forEach(i=>{const s=i.icons,l=s.pending.length;s.pending=s.pending.filter(c=>{if(c.prefix!==r)return!0;const u=c.name;if(e.icons[u])s.loaded.push({provider:o,prefix:r,name:u});else if(e.missing.has(u))s.missing.push({provider:o,prefix:r,name:u});else return n=!0,!0;return!1}),s.pending.length!==l&&(n||nm([e],i.id),i.callback(s.loaded.slice(0),s.missing.slice(0),s.pending.slice(0),i.abort))})}))}let LP=0;function FP(e,t,n){const o=LP++,r=nm.bind(null,n,o);if(!t.pending.length)return r;const i={id:o,icons:t,callback:e,abort:r};return n.forEach(s=>{(s.loaderCallbacks||(s.loaderCallbacks=[])).push(i)}),r}function BP(e){const t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((r,i)=>r.provider!==i.provider?r.provider.localeCompare(i.provider):r.prefix!==i.prefix?r.prefix.localeCompare(i.prefix):r.name.localeCompare(i.name));let o={provider:"",prefix:"",name:""};return e.forEach(r=>{if(o.name===r.name&&o.prefix===r.prefix&&o.provider===r.provider)return;o=r;const i=r.provider,s=r.prefix,l=r.name,c=n[i]||(n[i]=Object.create(null)),u=c[s]||(c[s]=lo(i,s));let d;l in u.icons?d=t.loaded:s===""||u.missing.has(l)?d=t.missing:d=t.pending;const f={provider:i,prefix:s,name:l};d.push(f)}),t}function zP(e,t=!0,n=!1){const o=[];return e.forEach(r=>{const i=typeof r=="string"?gs(r,t,n):r;i&&o.push(i)}),o}const VP={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function HP(e,t,n,o){const r=e.resources.length,i=e.random?Math.floor(Math.random()*r):e.index;let s;if(e.random){let S=e.resources.slice(0);for(s=[];S.length>1;){const O=Math.floor(Math.random()*S.length);s.push(S[O]),S=S.slice(0,O).concat(S.slice(O+1))}s=s.concat(S)}else s=e.resources.slice(i).concat(e.resources.slice(0,i));const l=Date.now();let c="pending",u=0,d,f=null,p=[],m=[];typeof o=="function"&&m.push(o);function g(){f&&(clearTimeout(f),f=null)}function h(){c==="pending"&&(c="aborted"),g(),p.forEach(S=>{S.status==="pending"&&(S.status="aborted")}),p=[]}function v(S,O){O&&(m=[]),typeof S=="function"&&m.push(S)}function b(){return{startTime:l,payload:t,status:c,queriesSent:u,queriesPending:p.length,subscribe:v,abort:h}}function C(){c="failed",m.forEach(S=>{S(void 0,d)})}function y(){p.forEach(S=>{S.status==="pending"&&(S.status="aborted")}),p=[]}function x(S,O,k){const _=O!=="success";switch(p=p.filter(V=>V!==S),c){case"pending":break;case"failed":if(_||!e.dataAfterTimeout)return;break;default:return}if(O==="abort"){d=k,C();return}if(_){d=k,p.length||(s.length?w():C());return}if(g(),y(),!e.random){const V=e.resources.indexOf(S.resource);V!==-1&&V!==e.index&&(e.index=V)}c="completed",m.forEach(V=>{V(k)})}function w(){if(c!=="pending")return;g();const S=s.shift();if(S===void 0){if(p.length){f=setTimeout(()=>{g(),c==="pending"&&(y(),C())},e.timeout);return}C();return}const O={status:"pending",resource:S,callback:(k,_)=>{x(O,k,_)}};p.push(O),u++,f=setTimeout(w,e.rotate),n(S,t,O.callback)}return setTimeout(w),b}function om(e){const t={...VP,...e};let n=[];function o(){n=n.filter(l=>l().status==="pending")}function r(l,c,u){const d=HP(t,l,c,(f,p)=>{o(),u&&u(f,p)});return n.push(d),d}function i(l){return n.find(c=>l(c))||null}return{query:r,find:i,setIndex:l=>{t.index=l},getIndex:()=>t.index,cleanup:o}}function Sd(){}const Xs=Object.create(null);function WP(e){if(!Xs[e]){const t=_l(e);if(!t)return;const n=om(t),o={config:t,redundancy:n};Xs[e]=o}return Xs[e]}function UP(e,t,n){let o,r;if(typeof e=="string"){const i=Ra(e);if(!i)return n(void 0,424),Sd;r=i.send;const s=WP(e);s&&(o=s.redundancy)}else{const i=Rl(e);if(i){o=om(i);const s=e.resources?e.resources[0]:"",l=Ra(s);l&&(r=l.send)}}return!o||!r?(n(void 0,424),Sd):o.query(t,r,n)().abort}function Cd(){}function YP(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,jP(e)}))}function qP(e){const t=[],n=[];return e.forEach(o=>{(o.match(Qh)?t:n).push(o)}),{valid:t,invalid:n}}function Ro(e,t,n){function o(){const r=e.pendingIcons;t.forEach(i=>{r&&r.delete(i),e.icons[i]||e.missing.add(i)})}if(n&&typeof n=="object")try{if(!Zh(e,n).length){o();return}}catch(r){console.error(r)}o(),YP(e)}function Td(e,t){e instanceof Promise?e.then(n=>{t(n)}).catch(()=>{t(null)}):t(e)}function GP(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:n,prefix:o}=e,r=e.iconsToLoad;if(delete e.iconsToLoad,!r||!r.length)return;const i=e.loadIcon;if(e.loadIcons&&(r.length>1||!i)){Td(e.loadIcons(r,o,n),d=>{Ro(e,r,d)});return}if(i){r.forEach(d=>{const f=i(d,o,n);Td(f,p=>{const m=p?{prefix:o,icons:{[d]:p}}:null;Ro(e,[d],m)})});return}const{valid:s,invalid:l}=qP(r);if(l.length&&Ro(e,l,null),!s.length)return;const c=o.match(Qh)?Ra(n):null;if(!c){Ro(e,s,null);return}c.prepare(n,o,s).forEach(d=>{UP(n,d,f=>{Ro(e,d.icons,f)})})}))}const KP=(e,t)=>{const n=zP(e,!0,Jh()),o=BP(n);if(!o.pending.length){let c=!0;return t&&setTimeout(()=>{c&&t(o.loaded,o.missing,o.pending,Cd)}),()=>{c=!1}}const r=Object.create(null),i=[];let s,l;return o.pending.forEach(c=>{const{provider:u,prefix:d}=c;if(d===l&&u===s)return;s=u,l=d,i.push(lo(u,d));const f=r[u]||(r[u]=Object.create(null));f[d]||(f[d]=[])}),o.pending.forEach(c=>{const{provider:u,prefix:d,name:f}=c,p=lo(u,d),m=p.pendingIcons||(p.pendingIcons=new Set);m.has(f)||(m.add(f),r[u][d].push(f))}),i.forEach(c=>{const u=r[c.provider][c.prefix];u.length&&GP(c,u)}),t?FP(t,o,i):Cd};function XP(e,t){const n={...e};for(const o in t){const r=t[o],i=typeof r;o in em?(r===null||r&&(i==="string"||i==="number"))&&(n[o]=r):i===typeof n[o]&&(n[o]=o==="rotate"?r%4:r)}return n}const ZP=/[\s,]+/;function QP(e,t){t.split(ZP).forEach(n=>{switch(n.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function JP(e,t=0){const n=e.replace(/^-?[0-9.]*/,"");function o(r){for(;r<0;)r+=4;return r%4}if(n===""){const r=parseInt(e);return isNaN(r)?0:o(r)}else if(n!==e){let r=0;switch(n){case"%":r=25;break;case"deg":r=90}if(r){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i=i/r,i%1===0?o(i):0)}}return t}function eR(e,t){let n=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const o in t)n+=" "+o+'="'+t[o]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+e+"</svg>"}function tR(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function nR(e){return"data:image/svg+xml,"+tR(e)}function oR(e){return'url("'+nR(e)+'")'}let Wo;function rR(){try{Wo=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{Wo=null}}function iR(e){return Wo===void 0&&rR(),Wo?Wo.createHTML(e):e}const rm={...tm,inline:!1},sR={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},aR={display:"inline-block"},ka={backgroundColor:"currentColor"},im={backgroundColor:"transparent"},Nd={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},Od={WebkitMask:ka,mask:ka,background:im};for(const e in Od){const t=Od[e];for(const n in Nd)t[e+n]=Nd[n]}const lR={...rm,inline:!0};function Pd(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const cR=(e,t,n)=>{const o=t.inline?lR:rm,r=XP(o,t),i=t.mode||"svg",s={},l=t.style||{},c={...i==="svg"?sR:{}};if(n){const v=gs(n,!1,!0);if(v){const b=["iconify"],C=["provider","prefix"];for(const y of C)v[y]&&b.push("iconify--"+v[y]);c.className=b.join(" ")}}for(let v in t){const b=t[v];if(b!==void 0)switch(v){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":c.ref=b;break;case"className":c[v]=(c[v]?c[v]+" ":"")+b;break;case"inline":case"hFlip":case"vFlip":r[v]=b===!0||b==="true"||b===1;break;case"flip":typeof b=="string"&&QP(r,b);break;case"color":s.color=b;break;case"rotate":typeof b=="string"?r[v]=JP(b):typeof b=="number"&&(r[v]=b);break;case"ariaHidden":case"aria-hidden":b!==!0&&b!=="true"&&delete c["aria-hidden"];break;default:o[v]===void 0&&(c[v]=b)}}const u=SP(e,r),d=u.attributes;if(r.inline&&(s.verticalAlign="-0.125em"),i==="svg"){c.style={...s,...l},Object.assign(c,d);let v=0,b=t.id;return typeof b=="string"&&(b=b.replace(/-/g,"_")),c.dangerouslySetInnerHTML={__html:iR(OP(u.body,b?()=>b+"ID"+v++:"iconifyReact"))},F.createElement("svg",c)}const{body:f,width:p,height:m}=e,g=i==="mask"||(i==="bg"?!1:f.indexOf("currentColor")!==-1),h=eR(f,{...d,width:p+"",height:m+""});return c.style={...s,"--svg":oR(h),width:Pd(d.width),height:Pd(d.height),...aR,...g?ka:im,...l},F.createElement("span",c)};Jh(!0);PP("",DP);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof t=="object"&&t!==null&&(t instanceof Array?t:[t]).forEach(o=>{try{(typeof o!="object"||o===null||o instanceof Array||typeof o.icons!="object"||typeof o.prefix!="string"||!gP(o))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let n in t){const o="IconifyProviders["+n+"] is invalid.";try{const r=t[n];if(typeof r!="object"||!r||r.resources===void 0)continue;RP(n,r)||console.error(o)}catch{console.error(o)}}}}function sm(e){const[t,n]=F.useState(!!e.ssr),[o,r]=F.useState({});function i(m){if(m){const g=e.icon;if(typeof g=="object")return{name:"",data:g};const h=xd(g);if(h)return{name:g,data:h}}return{name:""}}const[s,l]=F.useState(i(!!e.ssr));function c(){const m=o.callback;m&&(m(),r({}))}function u(m){if(JSON.stringify(s)!==JSON.stringify(m))return c(),l(m),!0}function d(){var m;const g=e.icon;if(typeof g=="object"){u({name:"",data:g});return}const h=xd(g);if(u({name:g,data:h}))if(h===void 0){const v=KP([g],d);r({callback:v})}else h&&((m=e.onLoad)===null||m===void 0||m.call(e,g))}F.useEffect(()=>(n(!0),c),[]),F.useEffect(()=>{t&&d()},[e.icon,t]);const{name:f,data:p}=s;return p?cR({...Pl,...p},e,f):e.children?e.children:e.fallback?e.fallback:F.createElement("span",{})}const uR=F.forwardRef((e,t)=>sm({...e,_ref:t}));F.forwardRef((e,t)=>sm({inline:!0,...e,_ref:t}));const Il=F.forwardRef(({icon:e,width:t=20,sx:n,...o},r)=>N.jsx(wr,{ref:r,component:uR,className:"component-iconify",icon:e,sx:{width:t,height:t,...n},...o}));Il.displayName="Iconify";function Er({title:e,icon:t,children:n}){return N.jsx(wr,{width:"150px",sx:{borderRadius:"3px",backgroundColor:"white",border:"1px solid #646464",boxShadow:"0 0 6px 2px rgba(0, 0, 0, 0.08)"},children:N.jsxs(vt,{children:[N.jsxs(vt,{direction:"row",spacing:1,sx:{p:.5,alignItems:"center"},children:[N.jsx(Il,{icon:t,width:20,sx:{color:"rgba(0, 167, 111, 0.7)"}}),N.jsx(it,{variant:"caption",sx:{color:"#646464"},children:e})]}),n?N.jsxs(N.Fragment,{children:[N.jsx(rn,{}),n]}):null]})})}function dR(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function fR(e){if(!e||typeof e!="object"||Array.isArray(e))return[];const t=e,n=[],o=new Set;for(const i of["field1","field2","field3","subject","body"])i in t&&(n.push(i),o.add(i));for(const i of Object.keys(t))o.has(i)||n.push(i);const r=[];for(const i of n){const s=dR(t[i]);if(s&&(r.push(s),r.length===3))break}return r}function Sr({nodeLabel:e,nodeMetaData:t}){const n=e?.trim()??"",o=!!n,r=fR(t);return N.jsxs(wr,{children:[N.jsx(it,{variant:"caption",textAlign:"center",py:.5,sx:{color:o?"#646464":"#f36",fontSize:"8px",fontWeight:600},children:o?n:"Action required"}),r.map((i,s)=>N.jsx(it,{variant:"caption",textAlign:"center",sx:{color:"#646464",fontSize:"8px",opacity:.85,lineHeight:"10px"},children:i},s))]})}function pR({data:e}){return N.jsxs(N.Fragment,{children:[N.jsx(Er,{title:e.label,icon:e.icon??(e.kind==="start"?mo:go),children:N.jsx(Sr,{nodeLabel:e.nodeLabel,nodeMetaData:e.nodeMetaData})}),N.jsx(pt,{type:"source",position:ue.Bottom,id:"out"})]})}function hR({data:e}){return N.jsxs(N.Fragment,{children:[N.jsx(pt,{type:"target",position:ue.Top,id:"in"}),N.jsx(Er,{title:e.label,icon:e.icon??(e.kind==="start"?mo:go),children:N.jsx(Sr,{nodeLabel:e.nodeLabel,nodeMetaData:e.nodeMetaData})})]})}function mR({data:e}){return N.jsxs(N.Fragment,{children:[N.jsx(pt,{type:"target",position:ue.Top,id:"in"}),N.jsx(Er,{title:e.label,icon:e.icon??"ph:circle",children:N.jsx(Sr,{nodeLabel:e.nodeLabel,nodeMetaData:e.nodeMetaData})}),N.jsx(pt,{type:"source",position:ue.Bottom,id:"out"})]})}const gR={left:"30%"},yR={left:"70%"};function bR({data:e}){const t=e.kind==="abTest";return N.jsxs(N.Fragment,{children:[N.jsx(pt,{type:"target",position:ue.Top,id:"in"}),N.jsx(Er,{title:e.label,icon:e.icon??"tabler:arrow-fork",children:N.jsx(Sr,{nodeLabel:e.nodeLabel,nodeMetaData:e.nodeMetaData})}),N.jsx(pt,{type:"source",position:ue.Bottom,id:"yes",style:gR}),N.jsx(pt,{type:"source",position:ue.Bottom,id:"no",style:yR}),N.jsxs("div",{style:{position:"absolute",width:150,left:0,top:"100%",marginTop:2,display:"flex",justifyContent:"space-between",fontSize:9,color:"#4f4f4f",pointerEvents:"none"},children:[N.jsx("span",{style:{transform:"translateX(-6px)"},children:t?"A":"Yes"}),N.jsx("span",{style:{transform:"translateX(6px)"},children:t?"B":"No"})]})]})}function vR({data:e}){const t=Math.min(5,Math.max(2,Number(e.nodeMetaData?.choiceCount)||yo));return N.jsxs(N.Fragment,{children:[N.jsx(pt,{type:"target",position:ue.Top,id:"in"}),N.jsx(Er,{title:e.label,icon:e.icon??"tabler:list-numbers",children:N.jsx(Sr,{nodeLabel:e.nodeLabel,nodeMetaData:e.nodeMetaData})}),Array.from({length:t}).map((n,o)=>{const r=o+1,i=(o+1)/(t+1)*100;return N.jsx(pt,{type:"source",position:ue.Bottom,id:`c${r}`,style:{left:`${i}%`}},r)}),N.jsx("div",{style:{position:"absolute",width:150,left:0,top:"100%",marginTop:2,display:"flex",justifyContent:"space-between",fontSize:9,color:"#4f4f4f",pointerEvents:"none"},children:Array.from({length:t}).map((n,o)=>N.jsx("span",{style:{width:`${100/t}%`,textAlign:"center"},children:o+1},o))})]})}function xR(e){if(e.length<2)return"";const[t,...n]=e;return`M ${t.x} ${t.y} `+n.map(o=>`L ${o.x} ${o.y}`).join(" ")}function wR(e){let t=0;for(let n=1;n<e.length;n++){const o=e[n].x-e[n-1].x,r=e[n].y-e[n-1].y;t+=Math.hypot(o,r)}return t}function ER(e){if(e.length===0)return{x:0,y:0};if(e.length===1)return e[0];const n=wR(e)/2;let o=0;for(let r=1;r<e.length;r++){const i=e[r-1],s=e[r],l=Math.hypot(s.x-i.x,s.y-i.y);if(o+l>=n){const c=l===0?0:(n-o)/l;return{x:i.x+(s.x-i.x)*c,y:i.y+(s.y-i.y)*c}}o+=l}return e[e.length-1]}const SR={width:22,height:22,background:"rgba(0, 167, 111, 0.7)",border:"1px solid rgba(2, 107, 72, 0.7)",cursor:"pointer",borderRadius:"50%",fontSize:12,lineHeight:1,color:"white",fontWeight:600,boxShadow:"0 0 6px 2px rgba(0, 0, 0, 0.08)",padding:0,display:"flex",alignItems:"center",justifyContent:"center"},CR={position:"absolute",background:"transparent",padding:10,color:"#4f4f4f",fontSize:9,fontWeight:500};function TR(e){const{id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s,targetPosition:l,markerEnd:c,data:u}=e,d=e.sourceHandleId,f=Iw(),p=u?._onPlusClick,m=!!u?.isRedirect,g=i<o-5,[h,v,b]=Ha({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:l}),C=150,y=f.length===0?Math.min(n,r):Math.min(...f.map(j=>j.position.x)),x=f.length===0?Math.max(n,r):Math.max(...f.map(j=>j.position.x+C)),w=140,S=Math.min(y-w,n-w,r-w),O=Math.max(x+w,n+w,r+w),k=m&&d==="yes",_=m&&d==="no",V=k?S:O,I=30,E=[{x:n,y:o},{x:V,y:o},{x:V,y:i-I},{x:r,y:i-I},{x:r,y:i}],D=xR(E),T=ER(E),R=g?D:h,P=g?T.x:v,L=g?T.y:b,M=u?.kind==="yes"?"Yes":u?.kind==="no"?"No":u?.kind==="branch"&&u?.branch?String(u.branch):"";return N.jsxs(N.Fragment,{children:[N.jsx(hr,{id:t,path:R,markerEnd:c,style:{strokeWidth:2,stroke:"#646464",strokeDasharray:m?"6 4":void 0}}),N.jsxs(Rw,{children:[!!M&&N.jsx("div",{style:{...CR,transform:`translate(-50%, 0%) translate(${n}px,${o-10}px)`},className:"nodrag nopan",children:M}),!m&&N.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${P}px,${L}px)`,pointerEvents:"all"},className:"nodrag nopan",children:N.jsx("button",{type:"button",onClick:()=>p?.(t),style:SR,title:"Add step",children:"+"})})]})]})}function NR({menu:e,onClose:t,definitions:n,onChooseKind:o,redirectCandidates:r,onChooseRedirectTarget:i,onSwitchMode:s}){const l=F.useMemo(()=>qh(n),[n]),c=F.useCallback(()=>{const f=[],p=(m,g,h)=>{f.push(N.jsx(it,{variant:"body1",sx:{fontWeight:600,textAlign:"center",px:2,pt:f.length?2:1},children:m},`${h}-t`)),f.push(N.jsx(rn,{},`${h}-d`));for(const v of g){const b=v.enabled===!1;f.push(N.jsxs(St,{disabled:b,onClick:()=>o(e.edgeId,v.kind),sx:b?{opacity:.5}:void 0,children:[N.jsx($h,{children:N.jsx(Il,{icon:v.icon,width:28,sx:{color:"#646464"}})}),N.jsx(jo,{children:v.title})]},`${h}-${v.kind}`))}};return p("Send Message",l["Send Message"],"sm"),p("Update",l.Update,"up"),p("Action",l.Action,"ac"),p("Event",l.Event,"ev"),f.push(N.jsx(rn,{},"redir-d")),f.push(N.jsx(St,{onClick:()=>s("redirect",!1),children:N.jsx(jo,{primary:"Redirect to…"})},"redir")),f},[l,e,o,s]),u=F.useCallback(()=>[N.jsx(Ei,{disableSticky:!0,sx:{fontWeight:700,lineHeight:"32px"},children:e?.relinkSolid?"Relink solid edge to…":"Redirect to…"},"rs"),...r.map(f=>N.jsx(St,{onClick:()=>i(e.edgeId,f.id,!e?.relinkSolid),children:N.jsx(jo,{primary:f.label,secondary:f.nodeLabel?.trim()?f.nodeLabel:`id: ${f.id}`})},`rc-${f.id}`)),N.jsx(rn,{},"rd1"),N.jsx(St,{onClick:()=>s("choose",!1),children:N.jsx(jo,{primary:"Back"})},"back")],[e,r,i,s]),d=F.useMemo(()=>e?e.mode==="choose"?c():u():[],[e,c,u]);return N.jsx(Cl,{open:!!e,onClose:t,anchorReference:"anchorPosition",anchorPosition:e?.anchorPosition??{top:0,left:0},MenuListProps:{dense:!0},children:d})}function OR({open:e,onClose:t,selectedNode:n,selectedDefinition:o,nodeLabel:r,setNodeLabel:i,nodeMetaData:s,setNodeMetaData:l,onSave:c}){const u=o?.drawerFormComponent,d=typeof u=="function"?u:$t;return N.jsxs(kh,{anchor:"right",open:e,onClose:t,PaperProps:{sx:{width:550,p:2}},children:[N.jsx(it,{variant:"h6",sx:{mb:.5},children:"Node metadata"}),N.jsxs(it,{sx:{fontSize:12,opacity:.75,mb:2},children:["Type: ",N.jsx("b",{children:n?.data?.label??"—"}),n?` • id: ${n.id}`:""]}),N.jsxs(vt,{spacing:2,children:[n?N.jsx(d,{node:n,nodeLabel:r,setNodeLabel:i,nodeMetaData:s,setNodeMetaData:l}):N.jsx(it,{sx:{fontSize:13,opacity:.7},children:"No node selected."}),N.jsx(rn,{}),N.jsxs(vt,{direction:"row",spacing:1,children:[N.jsx(Kn,{variant:"outlined",onClick:t,fullWidth:!0,children:"Cancel"}),N.jsx(Kn,{variant:"contained",onClick:c,fullWidth:!0,children:"Save"})]})]})]})}const PR={start:pR,end:hR,conditional:bR,action:mR,multiChoice:vR},RR={plusEdge:TR};function Bn(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function ko(e){const t=Bn(e);return Math.min(5,Math.max(2,Number(t.choiceCount)||yo))}function kR(e){if(e==="yes"||e==="no")return e;const t=/^c(\d+)$/.exec(e??"");return t?t[1]:"child"}function _R(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,o]of Object.entries(e))typeof o!="string"||!o||(t[n]=o);return t}function IR(e,t){const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const r of n)if(e[r]!==t[r])return!1;return!0}function MR(e){if(!e||typeof e!="object"||Array.isArray(e))return;const{x:t,y:n,zoom:o}=e;if(!(typeof t!="number"||typeof n!="number"||typeof o!="number"))return{x:t,y:n,zoom:o}}function $R(e){return e.map(t=>{if(!t.data)return t;const{_onPlusClick:n,...o}=t.data;return{...t,data:o}})}function AR(e){const t=Array.isArray(e?.nodes),n=Array.isArray(e?.edges);return{nodes:t?e?.nodes:oP,edges:n?$R(e?.edges):rP,viewport:MR(e?.viewport)}}function DR({nodeDefinitions:e=bo,initialFlow:t,onExportJson:n,onCancel:o}){const r=F.useRef(AR(t)),i=!!r.current.viewport,s=Li(),l=kw(),c=Dw(),u=F.useMemo(()=>ms(e),[e]),[d,f]=Mw(r.current.nodes),[p,m,g]=$w(r.current.edges),h=F.useRef(p);F.useEffect(()=>{h.current=p},[p]);const[v,b]=F.useState(null),C=F.useRef(!1),y=F.useRef(!1),[x,w]=F.useState(!1),[S,O]=F.useState(null),[k,_]=F.useState(""),[V,I]=F.useState({}),E=F.useRef(null),D=F.useCallback(G=>d.find(Z=>Z.id===G),[d]),T=F.useCallback((G,Z)=>p.filter(ne=>ne.source===G&&(Z==null?!0:(ne.sourceHandle??null)===(Z??null))).length,[p]),R=F.useCallback(G=>p.filter(Z=>Z.target===G).length,[p]),P=F.useCallback(G=>{if(C.current){y.current=!0;return}const Z=s.getNodes(),ne=s.getEdges(),J=yd(Z,ne);f(J),G?.fit&&requestAnimationFrame(()=>s.fitView({duration:300,padding:.35}))},[s,f]);F.useEffect(()=>{if(!c)return;const G=setTimeout(()=>P({fit:!i}),30);return()=>clearTimeout(G)},[c,P,i]),F.useEffect(()=>{if(!c)return;const G=r.current.viewport;if(!G)return;const Z=setTimeout(()=>{s.setViewport(G)},60);return()=>clearTimeout(Z)},[c,s]),F.useEffect(()=>{f(G=>{const Z=new Set(G.map(ce=>ce.id)),ne=new Map,J=new Map;for(const ce of p){if(!Z.has(ce.source)||!Z.has(ce.target))continue;const fe=kR(ce.sourceHandle),he=J.get(ce.source)??{};he[fe]=ce.target,J.set(ce.source,he),ne.has(ce.target)||ne.set(ce.target,ce.source)}let pe=!1;const se=G.map(ce=>{const fe=ne.get(ce.id),he=J.get(ce.id)??{},ye=_R(ce.data.childNodeIds),Te=ce.data.parentNodeId===fe,et=IR(ye,he);return Te&&et?ce:(pe=!0,{...ce,data:{...ce.data,parentNodeId:fe,childNodeIds:Object.keys(he).length>0?he:void 0}})});return pe?se:G})},[p,f]),F.useEffect(()=>{f(G=>G.map(Z=>{const ne=Z.data.kind??(Z.id===at?"start":Z.id===Je?"end":void 0),J=ne?u.get(ne):void 0,pe=Bn(Z.data.nodeMetaData),se=Bn(J?.createInitialNodeMetaData?.()??{}),ce=J?{...se,...pe}:pe,fe={...Z.data,nodeMetaData:ce};if(Z.id===at||Z.id===Je)return{...Z,data:{...Z.data,nodeMetaData:ce,label:J?.title??Z.data.label??(Z.id===at?"Entry":"Exit"),icon:J?.icon??Z.data.icon??(Z.id===at?mo:go)}};if(J&&!Z.data.icon)return{...Z,data:{...fe,icon:J.icon,label:Z.data.label??J.title}};if(Z.type==="multiChoice"){const he=ko(ce);return{...Z,data:{...fe,nodeMetaData:{...ce,choiceCount:he}}}}return{...Z,data:fe}}))},[u,f]),F.useEffect(()=>{const G=E.current;if(!G)return;const Z=d.find(pe=>pe.id===G.nodeId);if(!Z||Z.type!=="multiChoice"){E.current=null;return}const ne=ko(Z.data.nodeMetaData);if(ne!==G.nextCount)return;l(G.nodeId);const J=requestAnimationFrame(()=>{requestAnimationFrame(()=>{let pe=d,se=p;const ce=[];for(let fe=ne+1;fe<=5;fe++)ce.push(`c${fe}`);if(ce.length>0){const fe=lP({nodeId:G.nodeId,removedHandles:ce,nodes:pe,edges:se});pe=fe.nodes,se=fe.edges}se=se.filter(fe=>{if(fe.source!==G.nodeId)return!0;const he=fe.sourceHandle??"",ye=/^c(\d)$/.exec(he);return ye?Number(ye[1])<=ne:!0});for(let fe=1;fe<=ne;fe++){const he=`c${fe}`;se.some(Te=>Te.source===G.nodeId&&(Te.sourceHandle??"")===he)||(se=[...se,{id:`e-${G.nodeId}-${he}-${Je}`,type:"plusEdge",source:G.nodeId,sourceHandle:he,target:Je,targetHandle:"in",data:{kind:"branch",branch:fe,isRedirect:!1}}])}f(pe),m(se),E.current=null,setTimeout(()=>P(),0)})});return()=>cancelAnimationFrame(J)},[d,p,f,m,P,l]);const L=F.useCallback(()=>({version:2,nodes:d,edges:p.map(G=>{const{_onPlusClick:Z,...ne}=G.data??{};return{...G,data:ne}}),viewport:s.getViewport()}),[d,p,s]),M=F.useCallback(()=>{const G=L();if(n){n(G);return}const Z=JSON.stringify(G,null,2);console.log(Z),navigator.clipboard?.writeText(Z).catch(()=>{}),alert("Export copied to clipboard (and logged to console).")},[L,n]),j=F.useCallback(()=>{b(null),w(!1),o?.()},[o]),$=F.useCallback(G=>{if(!G.source||!G.target)return!1;const Z=D(G.source),ne=D(G.target);if(!Z||!ne||ne.type==="start"||Z.type==="end"||ne.type==="end"&&R(ne.id)>=1||Z.type==="start"&&T(Z.id)>=1)return!1;if(Z.type==="conditional"){const J=G.sourceHandle;if(J!=="yes"&&J!=="no"||T(Z.id,J)>=1)return!1}if(Z.type==="action"&&((G.sourceHandle??"out")!=="out"||T(Z.id,"out")>=1))return!1;if(Z.type==="multiChoice"){const J=G.sourceHandle??"";if(!/^c[1-5]$/.test(J)||T(Z.id,J)>=1)return!1}return!0},[D,R,T]),z=F.useCallback(G=>{const Z=p.find(ce=>ce.id===G);if(!Z||Z.data?.isRedirect)return;const ne=s.getNode(Z.source),J=s.getNode(Z.target);if(!ne||!J)return;const pe={x:(ne.position.x+J.position.x)/2,y:(ne.position.y+J.position.y)/2},se=s.flowToScreenPosition(pe);b({edgeId:G,mode:"choose",relinkSolid:!1,anchorPosition:{top:se.y,left:se.x}})},[p,s]),H=F.useCallback((G,Z)=>{const ne=p.find(Ve=>Ve.id===G);if(!ne||ne.data?.isRedirect)return;const J=s.getNode(ne.source),pe=s.getNode(ne.target);if(!J||!pe)return;const se=u.get(Z);if(!se||!("nodeType"in se))return;const ce=se.nodeType,fe=(J.position.x+pe.position.x)/2,he=(J.position.y+pe.position.y)/2,ye=crypto.randomUUID(),Te=Bn(se.createInitialNodeMetaData?.()??{}),et=ce==="multiChoice"?{...Te,choiceCount:ko(Te)}:Te,xe={id:ye,type:ce,position:{x:fe,y:he-40},data:{label:se.title,nodeLabel:"",kind:Z,icon:se.icon,nodeMetaData:et}};f(Ve=>[...Ve,xe]),m(Ve=>{const Ce=Ve.find(ae=>ae.id===G);if(!Ce)return Ve;const Ee=Ve.filter(ae=>ae.id!==G),tt={id:`e-${Ce.source}-${Ce.sourceHandle??"out"}-${ye}`,type:"plusEdge",source:Ce.source,sourceHandle:Ce.sourceHandle,target:ye,targetHandle:"in",data:{kind:Ce.data?.kind??"default",isRedirect:!1,branch:Ce.data?.branch}};if(ce==="action"){const ae={id:`e-${ye}-out-${Ce.target}`,type:"plusEdge",source:ye,sourceHandle:"out",target:Ce.target,targetHandle:Ce.targetHandle??"in",data:{kind:"default",isRedirect:!1}};return[...Ee,tt,ae]}if(ce==="conditional"){const ae={id:`e-${ye}-yes-${Ce.target}`,type:"plusEdge",source:ye,sourceHandle:"yes",target:Ce.target,targetHandle:Ce.targetHandle??"in",data:{kind:"yes",isRedirect:!1}},ve={id:`e-${ye}-no-${Ce.target}`,type:"plusEdge",source:ye,sourceHandle:"no",target:Ce.target,targetHandle:Ce.targetHandle??"in",data:{kind:"no",isRedirect:!1}};return[...Ee,tt,ae,ve]}const Ht=Math.min(5,Math.max(2,yo)),_n=Array.from({length:Ht}).map((ae,ve)=>{const Ye=ve+1;return{id:`e-${ye}-c${Ye}-${Ce.target}`,type:"plusEdge",source:ye,sourceHandle:`c${Ye}`,target:Ce.target,targetHandle:Ce.targetHandle??"in",data:{kind:"branch",branch:Ye,isRedirect:!1}}});return[...Ee,tt,..._n]}),b(null),queueMicrotask(()=>P())},[p,u,s,m,f,P]),U=F.useCallback((G,Z,ne)=>{const J=D(Z);J&&J.type!=="start"&&(m(pe=>pe.map(se=>{if(se.id!==G)return se;const ce=se.data??{kind:"default"},fe=ne.makeRedirect&&!ce.isRedirect?se.target:ce.baseTarget,he=ne.makeRedirect&&!ce.isRedirect?se.targetHandle??"in":ce.baseTargetHandle;return{...se,target:Z,targetHandle:"in",data:{...ce,isRedirect:!!ne.makeRedirect,baseTarget:ne.makeRedirect?fe:void 0,baseTargetHandle:ne.makeRedirect?he:void 0}}})),b(null),queueMicrotask(()=>P()))},[D,m,P]),W=F.useCallback(async G=>{const Z=G.nodes??[];if(Z.length===0||Z.length!==1)return!0;const ne=Z[0];if(ne.type==="start"||ne.type==="end")return!1;const J=s.getEdges(),pe=s.getNodes(),se=pe.find(Ee=>Ee.id===ne.id);if(!se)return!1;const ce=J.filter(Ee=>Ee.target===ne.id),fe=J.filter(Ee=>Ee.source===ne.id),he=ce.find(Ee=>!Ee.data?.isRedirect)??ce[0],ye=Ee=>Ee.find(tt=>!tt.data?.isRedirect)??Ee[0];let Te;if(se.type==="conditional"){const Ee=fe.filter(tt=>tt.sourceHandle==="yes");Te=ye(Ee)??ye(fe)}else if(se.type==="multiChoice"){const Ee=fe.filter(tt=>tt.sourceHandle==="c1");Te=ye(Ee)??ye(fe)}else{const Ee=fe.filter(tt=>(tt.sourceHandle??"out")==="out");Te=ye(Ee)??ye(fe)}const et=J.filter(Ee=>Ee.source!==ne.id&&Ee.target!==ne.id),xe=pe.filter(Ee=>Ee.id!==ne.id);let Ve=et;if(he&&Te&&Te.target!==at){const Ee={id:`e-${he.source}-${he.sourceHandle??"out"}-${Te.target}`,type:"plusEdge",source:he.source,sourceHandle:he.sourceHandle,target:Te.target,targetHandle:Te.targetHandle??"in",data:{kind:he.data?.kind??"default",isRedirect:!1,branch:he.data?.branch}};Ve.some(Ht=>Ht.source===Ee.source&&(Ht.sourceHandle??null)===(Ee.sourceHandle??null)&&Ht.target===Ee.target)||(Ve=[...Ve,Ee])}m(Ve);const Ce=yd(xe,Ve);return f(Ce),!1},[s,m,f]),ee=F.useCallback((G,Z)=>{const ne=G.data,J=ne?.kind??(Z.sourceHandle==="yes"?"yes":Z.sourceHandle==="no"?"no":/^c[1-5]$/.test(Z.sourceHandle??"")?"branch":"default"),pe=ne?.branch??(()=>{const he=/^c(\d)$/.exec(Z.sourceHandle??"");return he?Number(he[1]):void 0})(),se=!!ne?.isRedirect,ce=ne?.baseTarget,fe=ne?.baseTargetHandle;m(he=>Y0(G,Z,he).map(ye=>{if(ye.id!==G.id)return{...ye,data:ye.data??{kind:"default"}};const Te=ye.data??{kind:J};return{...ye,data:{kind:Te.kind??J,branch:Te.branch??pe,isRedirect:!0,baseTarget:se?ce:G.target,baseTargetHandle:se?fe:G.targetHandle??"in"}}})),queueMicrotask(()=>P())},[m,P]),te=F.useCallback(G=>{f(Z=>Ka(G,Z))},[f]),Q=F.useCallback(G=>{const Z=G.filter(J=>{if(J.type!=="remove")return!1;const pe=J.id;return pe?!!h.current.find(ce=>ce.id===pe)?.data?.isRedirect:!1}),ne=G.filter(J=>{if(J.type!=="remove")return!0;const pe=J.id;return pe?!h.current.find(ce=>ce.id===pe)?.data?.isRedirect:!0});ne.length&&(m(J=>Xa(ne,J)),g(ne));for(const J of Z){const pe=J.id,se=h.current.find(xe=>xe.id===pe);if(!se)continue;const ce=se.data?.baseTarget??Je,fe=se.data?.baseTargetHandle??"in";m(xe=>xe.map(Ve=>Ve.id===pe?{...Ve,target:ce,targetHandle:fe,data:{...Ve.data??{kind:"default"},isRedirect:!1,baseTarget:void 0,baseTargetHandle:void 0}}:Ve));const he=s.getNode(se.source),ye=s.getNode(ce),Te=he&&ye?{x:(he.position.x+ye.position.x)/2,y:(he.position.y+ye.position.y)/2}:{x:0,y:0},et=s.flowToScreenPosition(Te);b({edgeId:pe,mode:"redirect",relinkSolid:!0,anchorPosition:{top:et.y,left:et.x}}),queueMicrotask(()=>P())}},[m,g,s,P]),Y=F.useMemo(()=>p.map(G=>({...G,data:{...G.data??{kind:"default"},_onPlusClick:z}})),[p,z]),X=F.useMemo(()=>d.filter(G=>G.type!=="start").map(G=>({id:G.id,label:G.data?.label??G.id,nodeLabel:G.data?.nodeLabel??""})),[d]),K=F.useCallback((G,Z)=>{Z.data?.isRedirect&&(G.preventDefault(),G.stopPropagation(),b({edgeId:Z.id,mode:"redirect",relinkSolid:!1,anchorPosition:{top:G.clientY,left:G.clientX}}))},[]),oe=F.useCallback((G,Z)=>{O(Z.id),_(Z.data?.nodeLabel??"");const ne=Bn(Z.data.nodeMetaData);I(Z.type==="multiChoice"?{...ne,choiceCount:ko(ne)}:ne),w(!0)},[]),B=F.useMemo(()=>S?D(S):void 0,[D,S]),ie=F.useMemo(()=>{const G=B?.data?.kind??(B?.id===at?"start":B?.id===Je?"end":void 0);if(G)return u.get(G)},[u,B]),re=F.useCallback(()=>{if(!S)return;const Z=d.find(pe=>pe.id===S)?.type==="multiChoice",ne=Bn(V),J=ko(ne);f(pe=>pe.map(se=>se.id===S?{...se,data:{...se.data??{label:""},nodeLabel:k,nodeMetaData:se.type==="multiChoice"?{...ne,choiceCount:J}:ne}}:se)),Z&&(E.current={nodeId:S,nextCount:J}),w(!1),queueMicrotask(()=>P())},[S,k,V,d,f,P]),le=F.useCallback(()=>b(null),[]),be=F.useCallback(()=>{C.current=!0},[]),Se=F.useCallback(()=>{C.current=!1,y.current&&(y.current=!1,P())},[P]),Ae=F.useCallback((G,Z)=>{b(ne=>ne&&{...ne,mode:G,relinkSolid:Z??ne.relinkSolid})},[]);return N.jsxs(wr,{sx:{width:"100%",height:"88vh",border:"1px solid #ddd",borderRadius:2,position:"relative",overflow:"hidden",bgcolor:"white"},children:[N.jsxs(vt,{direction:"row",spacing:1,sx:{p:1.25,borderBottom:"1px solid #eee",alignItems:"center"},children:[N.jsx(Kn,{variant:"contained",size:"small",onClick:M,children:"Save"}),N.jsx(Kn,{variant:"outlined",size:"small",onClick:j,children:"Cancel / Close"}),N.jsx(Kn,{variant:"outlined",size:"small",onClick:()=>P({fit:!0}),children:"Auto layout"}),N.jsx(it,{sx:{ml:"auto",fontSize:12,opacity:.75},children:"Redirect edge delete ⇒ restores solid + asks relink"})]}),N.jsx(NR,{menu:v,onClose:le,definitions:e,onChooseKind:(G,Z)=>H(G,Z),redirectCandidates:X,onChooseRedirectTarget:(G,Z,ne)=>U(G,Z,{makeRedirect:ne}),onSwitchMode:Ae}),N.jsxs(Ow,{nodes:d,edges:Y,onNodesChange:te,onEdgesChange:Q,nodeTypes:PR,edgeTypes:RR,fitView:!i,isValidConnection:$,onBeforeDelete:W,onReconnect:ee,onEdgeClick:K,onNodeClick:oe,onNodeDragStart:be,onNodeDragStop:Se,defaultEdgeOptions:{markerEnd:{type:Zo.Arrow,width:12,height:12}},children:[N.jsx(Gw,{}),N.jsx(zw,{})]}),N.jsx(OR,{open:x,onClose:()=>w(!1),selectedNode:B,selectedDefinition:ie,nodeLabel:k,setNodeLabel:_,nodeMetaData:V,setNodeMetaData:I,onSave:re})]})}function jR({nodeDefinitions:e,extendNodeDefinitions:t=[],initialFlow:n,onExportJson:o,onCancel:r}){const i=F.useMemo(()=>e||Yh(bo,t),[e,t]);return N.jsx(pp,{children:N.jsx(DR,{nodeDefinitions:i,initialFlow:n,onExportJson:o,onCancel:r})})}exports.CATEGORIES=tP;exports.DEFAULT_MULTI_CHOICE_COUNT=yo;exports.DEFAULT_NODE_DEFINITIONS=bo;exports.END_ICON=go;exports.END_ID=Je;exports.FlowEditor=jR;exports.NODE_DEFINITIONS=eP;exports.START_ICON=mo;exports.START_ID=at;exports.createNodeDefinitionMap=ms;exports.groupDefinitions=qh;exports.kindToNodeType=nP;exports.mergeNodeDefinitions=Yh;
package/dist/index.js CHANGED
@@ -23164,7 +23164,7 @@ const gt = "start", at = "end", Or = "mingcute:entrance-fill", Pr = "mingcute:ex
23164
23164
  },
23165
23165
  {
23166
23166
  kind: "end",
23167
- title: "End",
23167
+ title: "Exit",
23168
23168
  icon: Pr,
23169
23169
  drawerFormComponent: Ht,
23170
23170
  createInitialNodeMetaData: Pd
@@ -23307,7 +23307,7 @@ const mP = [
23307
23307
  type: "end",
23308
23308
  position: { x: 260, y: 520 },
23309
23309
  data: {
23310
- label: "End",
23310
+ label: "Exit",
23311
23311
  nodeLabel: "",
23312
23312
  kind: "end",
23313
23313
  icon: Pr,
@@ -25066,7 +25066,7 @@ function K_({
25066
25066
  data: {
25067
25067
  ...X.data,
25068
25068
  nodeMetaData: le,
25069
- label: Q?.title ?? X.data.label ?? (X.id === gt ? "Start" : "End"),
25069
+ label: Q?.title ?? X.data.label ?? (X.id === gt ? "Entry" : "Exit"),
25070
25070
  icon: Q?.icon ?? X.data.icon ?? (X.id === gt ? Or : Pr)
25071
25071
  }
25072
25072
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "journey-flow-editor",
3
3
  "private": false,
4
- "version": "0.0.15",
4
+ "version": "0.0.16",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",