@squeed/flow-sdk 2.0.34 → 2.0.35
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 +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -280,5 +280,5 @@
|
|
|
280
280
|
`;function su({nodeAddress:e,active:r,label:t,open:n=!1,onClose:o,children:i,filter:s,height:a,width:c}){const{background:l,border:d,colorText:u}=st(),{colorMode:h}=He(),p=j.useRef(null),m=j.useId(),{data:y,schema:g,bindings:b}=j.useContext(Mt),v=i!==void 0||!!(y&&g&&(b?$n(b,e,g):Xr(y,e,g)));j.useEffect(()=>{var w,C,S,_,k;!r||!v||!n?(w=p.current)==null||w.close():(C=p.current)!=null&&C.open||((S=p.current)==null||S.showModal(),(k=(_=p.current)==null?void 0:_.querySelector("[data-form-filter] input"))==null||k.focus())},[r,v,n]);const x=Pe(l);return v?f.jsx(f.Fragment,{children:typeof document<"u"&&Vr.createPortal(f.jsx(Dj,{ref:p,id:m,$surface:x,$border:Pe(d),"aria-label":`Configure ${t}`,onClose:o,onPointerDown:w=>w.stopPropagation(),onWheel:w=>w.stopPropagation(),onKeyDown:w=>w.stopPropagation(),onClick:w=>{var C;w.stopPropagation(),w.target===w.currentTarget&&((C=p.current)==null||C.close())},style:{position:"fixed",inset:"94px 20px auto auto",margin:0,padding:20,width:c??"var(--top-toolbar-width, 360px)",boxSizing:"border-box",maxWidth:"calc(100vw - 40px)",maxHeight:"calc(100dvh - 114px)",height:a,overflow:"hidden",borderRadius:30,background:x,color:Pe(u),fontSize:16,textTransform:"none"},children:n&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexShrink:0},children:[f.jsx("strong",{style:{overflowWrap:"anywhere",minWidth:0},children:t}),f.jsx(Yr,{"aria-label":"Close node configuration",onClick:()=>{var w;return(w=p.current)==null?void 0:w.close()}})]}),s&&f.jsx("div",{"data-form-filter":"",style:{flexShrink:0},children:s}),f.jsx(Vj,{$divider:`var(--chakra-colors-gray-${h==="dark"?"700":"200"})`,"data-form-scroll":"",style:a?{flex:1}:void 0,children:i??f.jsx(Od,{nodeAddress:e})})]})}),document.body)}):null}const vd=({icon:e,label:r,onClick:t,color:n,boxSize:o=6,...i})=>{const{background:s,border:a,colorText:c}=st();return f.jsx(Ue,{label:r,children:f.jsx(V.Flex,{asChild:!0,p:0,border:0,bg:"transparent",children:f.jsx("button",{type:"button","aria-label":r,onClick:t,children:f.jsx(V.Icon,{as:e,boxSize:o,color:n,cursor:t?"pointer":void 0})})})})},Wj=({data:e,children:r,isInverted:t,isParent:n,onOpenView:o,editOnMount:i=!1,hoverLeaveDelay:s=0})=>{var je,pe,fe,Y,H,we,J,ve;const{selectedNodeIds:a,setSelectedNodeIds:c,selectedEdgeId:l,setSelectedEdgeId:d,isMultiSelectMode:u,nodeGridOptions:h,isPerformanceMode:p,engineRef:m,callbacks:y,config:g,themeColor:b,direction:v,nodeViewModes:x}=He(),{background:w,border:C,colorText:S}=st(),_=j.useRef(null),k=j.useRef(null);j.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]);const[E,O]=j.useState(!1),[P,A]=j.useState(i&&!!g.editable&&!g.readOnly),[M,T]=j.useState(!1),N=e==null?void 0:e.id,$=mb(N),I=a.includes(N),W=(je=g.nodeOverlayActions)==null?void 0:je.filter(Q=>!Q.nodeTypes||Q.nodeTypes.includes(e==null?void 0:e.type)),ie=g.renderNodeOverlay,ae=(e==null?void 0:e.type)==="grid"?(pe=g.customViews)==null?void 0:pe.gridHoverControls:void 0,re=(e==null?void 0:e.type)==="grid"?"20px":"-100px",ye=(e==null?void 0:e.type)==="grid"?"top center":void 0,be=(e==null?void 0:e.type)==="grid"?"translateX(-50%) scale3d(1.8, 1.8, 1)":"translateX(-50%) scale3d(3, 3, 1)",L=(()=>{var Q;try{const Ee=(Q=m.current)==null?void 0:Q.zoom();return Ee!==void 0&&Ee<.08}catch{return!1}})(),z=j.useCallback((Q,Ee=!1)=>{var qe,Je,Fe,ct;if(P||g.readOnly||h!=null&&h.fill&&!Q.shiftKey)return;const Ae={shiftKey:Q.shiftKey,ctrlKey:Q.ctrlKey,metaKey:Q.metaKey,altKey:Q.altKey,...Ee?{viewToggle:!0}:{}};if(l&&(d(null),(qe=y.onEdgeDeselect)==null||qe.call(y)),u||Q.shiftKey&&(h!=null&&h.fill)){const De=a.includes(N),rt=De?a.filter(ft=>ft!==N):[...a,N];c(rt),De?(Je=y.onNodeDeselect)==null||Je.call(y):(Fe=y.onNodeSelect)==null||Fe.call(y,N,e,Ae)}else c([N]),(ct=y.onNodeSelect)==null||ct.call(y,N,e,Ae)},[N,e,a,l,u,h,P,c,d,y,g]),G=j.useCallback(()=>{var Q;P||g.readOnly||(Q=y.onNodeDoubleClick)==null||Q.call(y,N,e)},[N,e,P,y,g]),D=j.useCallback(()=>{k.current&&clearTimeout(k.current),k.current=setTimeout(()=>O(!0),100)},[]),se=j.useCallback(Q=>{var Ee;Q.relatedTarget instanceof Node&&((Ee=_.current)!=null&&Ee.contains(Q.relatedTarget))||(k.current&&clearTimeout(k.current),s?k.current=setTimeout(()=>O(!1),s):O(!1))},[s]),X=!!((fe=e==null?void 0:e.config)!=null&&fe.form),le={tabIndex:X?0:void 0,"aria-haspopup":X?"dialog":void 0,"aria-expanded":X?M:void 0,onDoubleClickCapture:Q=>{var Ee;!X&&!o||g.readOnly||P||!Q.currentTarget.contains(Q.target)||Q.target instanceof Element&&Q.target.closest("button, input, textarea, select, a, [contenteditable=true], [data-flow-content]")||(Q.preventDefault(),Q.stopPropagation(),c([N]),o?o():T(!0),(Ee=y.onNodeDoubleClick)==null||Ee.call(y,N,e))},onKeyDown:Q=>{!X&&!o||g.readOnly||Q.target!==Q.currentTarget||Q.key!=="Enter"||(Q.preventDefault(),Q.stopPropagation(),c([N]),o?o():T(!0))}},ue=X&&f.jsx(su,{nodeAddress:N,active:I,label:e.label||e.headerTitle||"Node",open:M,onClose:()=>{var Q;T(!1),I&&((Q=_.current)==null||Q.focus({preventScroll:!0}))}}),Ce=Array.isArray((Y=e==null?void 0:e.config)==null?void 0:Y.ports)?e.config.ports.map(Q=>f.jsx(Yv,{...Q},`${Q.id}:${Q.role}`)):null;return n?f.jsxs(V.Box,{ref:_,...le,onClick:z,onDoubleClick:G,onMouseEnter:D,onMouseLeave:se,cursor:"pointer",position:"relative",children:[ue,!p&&(ie||W&&W.length>0)&&E&&!L&&f.jsxs(f.Fragment,{children:[f.jsx(V.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>O(!0),onMouseLeave:se}),ie?f.jsx(V.Box,{position:"absolute",zIndex:1e3,top:re,transformOrigin:ye,left:"50%",pointerEvents:"auto",transform:be,onMouseEnter:()=>O(!0),onMouseLeave:se,willChange:"transform",children:ie({nodeId:N,nodeData:e,isRoot:N==="root",isParent:!0,isHovered:E,setIsHovered:O})}):f.jsx(V.Box,{position:"absolute",zIndex:1e3,top:re,transformOrigin:ye,left:"50%",bg:w,p:3,borderColor:C,borderWidth:1,borderRadius:"30px",pointerEvents:"auto",transform:be,boxShadow:"lg",onMouseEnter:()=>O(!0),onMouseLeave:se,willChange:"transform",children:f.jsxs(V.HStack,{px:2,gap:2,children:[W.map((Q,Ee)=>f.jsxs(V.Box,{display:"contents",children:[Ee>0&&f.jsx(V.Box,{borderColor:C,height:5,borderRightWidth:1}),f.jsx(vd,{icon:Q.icon,label:Q.label,color:S,bgColor:w,borderColor:C,textColor:S,boxSize:5,onClick:Ae=>{var qe;Ae.stopPropagation(),(qe=y.onNodeHoverAction)==null||qe.call(y,Q.id,N,e)}})]},Q.id)),ae&&f.jsx(ae,{data:e})]})})]}),r({id:N,data:e,isActive:I,isHovered:E,isLowZoom:L,isEditing:P,onSelect:z,onEditStart:()=>A(!0),onEditEnd:()=>A(!1)}),$&&!((H=e==null?void 0:e.config)!=null&&H.parentContainer)&&((we=e==null?void 0:e.config)==null?void 0:we.collapsed)!==void 0&&(()=>{var Ae;const Q=v==="TB"||v==="BT",Ee=t||v==="RL";return f.jsx(V.IconButton,{position:"absolute",...Q?{[v==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:Ee?void 0:"-75px",left:Ee?"-75px":void 0,top:"50%",transform:"translateY(-50%)"},"data-flow-collapse-control":"","aria-label":e.config.collapsed?"Expand":"Collapse",disabled:g.readOnly,onClick:qe=>{var Je;qe.stopPropagation(),(Je=y.onNodeCollapse)==null||Je.call(y,N,!e.config.collapsed)},bgColor:Pe(((Ae=e==null?void 0:e.viewProps)==null?void 0:Ae.bgColor)||b),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(Z.PiPlusBold,{size:30,color:Pe("gray.800")}):f.jsx(Z.PiMinusBold,{size:30,color:Pe("gray.800")})})})()]}):f.jsxs(V.Box,{ref:_,...le,onClick:z,onDoubleClick:G,onMouseEnter:D,onMouseLeave:se,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[ue,Ce,!p&&(ie||W&&W.length>0)&&E&&!L&&f.jsxs(f.Fragment,{children:[f.jsx(V.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>O(!0),onMouseLeave:se}),ie?f.jsx(V.Box,{position:"absolute",zIndex:1e3,top:re,transformOrigin:ye,left:"50%",pointerEvents:"auto",transform:be,onMouseEnter:()=>O(!0),onMouseLeave:se,willChange:"transform",children:ie({nodeId:N,nodeData:e,isRoot:N==="root",isParent:!!n,isHovered:E,setIsHovered:O})}):f.jsx(V.Box,{position:"absolute",zIndex:1e3,top:re,transformOrigin:ye,left:"50%",bg:w,p:3,borderColor:C,borderWidth:1,borderRadius:"30px",pointerEvents:"auto",transform:be,boxShadow:"lg",onMouseEnter:()=>O(!0),onMouseLeave:se,willChange:"transform",children:f.jsxs(V.HStack,{px:2,gap:2,children:[W.map((Q,Ee)=>f.jsxs(V.Box,{display:"contents",children:[Ee>0&&f.jsx(V.Box,{borderColor:C,height:5,borderRightWidth:1}),f.jsx(vd,{icon:Q.icon,label:Q.label,color:S,bgColor:w,borderColor:C,textColor:S,boxSize:5,onClick:Ae=>{var qe;Ae.stopPropagation(),(qe=y.onNodeHoverAction)==null||qe.call(y,Q.id,N,e)}})]},Q.id)),ae&&f.jsx(ae,{data:e})]})})]}),f.jsxs(V.Box,{position:"relative",display:"flex",h:"100%",w:"100%",children:[$&&!((J=e==null?void 0:e.config)!=null&&J.parentContainer)&&((ve=e==null?void 0:e.config)==null?void 0:ve.collapsed)!==void 0&&!n&&(()=>{var qe,Je,Fe;const Q=v==="TB"||v==="BT",Ee=t||v==="RL",Ae=(qe=e==null?void 0:e.config)!=null&&qe.labelBelow&&x[N]!=="properties"?((((Je=e==null?void 0:e.viewProps)==null?void 0:Je.fontSize)||1)*100+100)/2:void 0;return f.jsx(V.IconButton,{position:"absolute",...Q?{[v==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:Ee?void 0:Ae===void 0?"-75px":`calc(50% - ${Ae+75}px)`,left:Ee?Ae===void 0?"-75px":`calc(50% - ${Ae+75}px)`:void 0,alignSelf:Ae===void 0?"center":void 0,top:Ae===void 0?void 0:`${Ae}px`,transform:Ae===void 0?void 0:"translateY(-50%)",zIndex:Ae===void 0?void 0:1},"data-flow-collapse-control":"","aria-label":e.config.collapsed?"Expand":"Collapse",disabled:g.readOnly,onClick:ct=>{var De;ct.stopPropagation(),(De=y.onNodeCollapse)==null||De.call(y,N,!e.config.collapsed)},bgColor:Pe(((Fe=e==null?void 0:e.viewProps)==null?void 0:Fe.bgColor)||b),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(Z.PiPlusBold,{size:30,color:Pe("gray.800")}):f.jsx(Z.PiMinusBold,{size:30,color:Pe("gray.800")})})})(),r({id:N,data:e,isActive:I,isHovered:E,isLowZoom:L,isEditing:P,onSelect:z,onEditStart:()=>A(!0),onEditEnd:()=>A(!1)})]})]})},Vn=j.memo(Wj),Gj=({id:e,data:r,isActive:t,isEditing:n,onEditStart:o,onEditEnd:i})=>{var y,g,b,v,x,w,C,S;const{themeColor:s}=He(),{colorText:a}=st(),c=((y=r==null?void 0:r.viewProps)==null?void 0:y.bgColor)==="transparent",l=((g=r==null?void 0:r.viewProps)==null?void 0:g.outline)===!0,{highlightColor:d,borderColor:u,textColor:h}=Nn(((b=r==null?void 0:r.viewProps)==null?void 0:b.bgColor)||s),p=Pe(((v=r==null?void 0:r.viewProps)==null?void 0:v.textColor)||(c||l?a:h)),m=((x=r==null?void 0:r.viewProps)==null?void 0:x.borderColor)||(l?!c&&((w=r==null?void 0:r.viewProps)==null?void 0:w.bgColor)||s:u);return f.jsx(V.Box,{"data-flow-node-surface":"",borderRadius:(C=r==null?void 0:r.viewProps)==null?void 0:C.borderRadius,bgColor:l?"transparent":d,...Tn(r==null?void 0:r.viewProps,m,t,2),py:14,px:20,whiteSpace:"nowrap",w:"fit-content",children:f.jsxs(V.Flex,{justifyContent:"start",alignItems:"center",gap:8,w:"fit-content",maxW:900,minW:0,fontSize:"5xl",lineHeight:"normal",children:[((S=r==null?void 0:r.config)==null?void 0:S.icon)&&f.jsx(V.Box,{flexShrink:0,children:f.jsx(Qt,{name:r.config.icon,size:80,color:p})}),f.jsx(Jr,{nodeId:e,label:(r==null?void 0:r.label)||(r==null?void 0:r.text)||"",color:p,isEditing:n,onEditStart:o,onEditEnd:i})]})})};function Wn(){const{nodeViewModes:e,setNodeViewMode:r,allNodesIconLabel:t,setAllNodesIconLabel:n}=He();return{allNodesIconLabel:t,setAllNodesIconLabel:n,getNodeViewMode:o=>e[o]??"default",showNodeProperties:o=>r(o,"properties"),restoreNodeView:o=>r(o,"default"),toggleNodeView:o=>r(o,e[o]==="properties"?"default":"properties"),setNodeViewMode:r}}function cu(e,r,t){const{readOnly:n,selectedNodeIds:o}=He(),i=o.includes(e),s=j.useRef(i),a=j.useRef(t);a.current=t,j.useEffect(()=>{s.current&&!i&&r&&!n&&a.current(),s.current=i},[i,r,n])}const Uj=({id:e,isActive:r,data:t,isEditing:n,onEditStart:o,onEditEnd:i})=>{var x,w,C,S,_,k,E,O,P,A,M,T,N,$,I;const{themeColor:s}=He(),{colorText:a}=st(),c=((x=t==null?void 0:t.viewProps)==null?void 0:x.bgColor)==="transparent",l=((w=t==null?void 0:t.viewProps)==null?void 0:w.outline)===!0,d=!c&&((C=t==null?void 0:t.viewProps)==null?void 0:C.bgColor)||s,{borderColor:u,highlightColor:h,textColor:p}=Nn(d),m=Pe(((S=t==null?void 0:t.viewProps)==null?void 0:S.textColor)||(c||l?a:p)),y=c&&!l&&!((_=t==null?void 0:t.viewProps)!=null&&_.borderColor)?"transparent":Pe(((k=t==null?void 0:t.viewProps)==null?void 0:k.borderColor)||(l?d:u)),g=c||l?"transparent":d!=null&&d.startsWith("#")?d:Pe(h),b=(E=t==null?void 0:t.config)==null?void 0:E.icon,v=(t==null?void 0:t.label)??(t==null?void 0:t.text)??"";if((O=t==null?void 0:t.config)!=null&&O.labelBelow){const W=(((P=t==null?void 0:t.viewProps)==null?void 0:P.fontSize)||1)*100;return f.jsxs(V.Flex,{"data-flow-icon-label":"",css:{"--flow-grid-on-surface-color":m},direction:"column",align:"center",gap:"24px",width:`${Math.max(W+200,360)}px`,position:"relative",children:[f.jsx(V.Flex,{"data-flow-node-surface":"",align:"center",justify:"center",width:`${W+100}px`,height:`${W+100}px`,flexShrink:0,borderRadius:(A=t==null?void 0:t.viewProps)==null?void 0:A.borderRadius,backgroundColor:g,...Tn(t==null?void 0:t.viewProps,y,r,2),children:!!b&&f.jsx(Qt,{name:b,size:W,color:m})}),f.jsxs(V.Flex,{"data-flow-icon-caption":"",direction:"column",align:"center",gap:"8px",justify:"center",width:"100%",minW:0,textAlign:"center",children:[f.jsx(Jr,{nodeId:e,label:v,color:`var(--flow-grid-caption-color, ${Pe(((M=t==null?void 0:t.viewProps)==null?void 0:M.textColor)||a)})`,isEditing:n,onEditStart:o,onEditEnd:i,wrap:!0}),typeof((T=t.config)==null?void 0:T.subtitle)=="string"&&t.config.subtitle!==""&&f.jsx(V.Text,{"data-flow-node-subtitle":"",color:Pe(((N=t==null?void 0:t.viewProps)==null?void 0:N.textColor)||a),opacity:.65,fontSize:"32px",fontWeight:"normal",lineHeight:1.3,width:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",title:t.config.subtitle,children:t.config.subtitle})]})]})}return f.jsxs(V.Flex,{"data-flow-node-surface":"",align:"center",borderRadius:($=t==null?void 0:t.viewProps)==null?void 0:$.borderRadius,bgColor:g,style:{backgroundColor:g},textTransform:"capitalize",...Tn(t==null?void 0:t.viewProps,y,r,2),px:50,w:"fit-content",whiteSpace:"nowrap",children:[!!b&&f.jsx(V.Flex,{align:"center",py:14,mr:v?8:0,flexShrink:0,children:f.jsx(Qt,{name:b,size:(((I=t==null?void 0:t.viewProps)==null?void 0:I.fontSize)||1)*100,color:m},m)}),(v||!b)&&f.jsx(V.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:"fit-content",maxW:900,minW:0,children:f.jsx(Jr,{nodeId:e,label:v,color:m,isEditing:n,onEditStart:o,onEditEnd:i})})]})};function lu({onExpand:e,toggleLabel:r="Show properties",toggleDisabled:t=!1,renderCompact:n=Uj,...o}){const{colorMode:i,callbacks:s}=He();return f.jsx(Vn,{...o,hoverLeaveDelay:e?350:0,children:a=>f.jsxs(V.Box,{position:"relative",children:[f.jsx(n,{...a}),e&&(a.isHovered||a.isActive)&&f.jsx(V.Box,{position:"absolute",top:"-24px",right:"-48px","data-flow-content-toggle":"",children:f.jsx(Ue,{label:r,children:f.jsx(Ne,{"aria-label":r,icon:f.jsx(V.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:i==="dark"?"gray.100":"gray.800",disabled:t,onClick:c=>{var l;c.stopPropagation(),a.isActive||a.onSelect(c,!0),(l=s.onNodeViewToggle)==null||l.call(s,o.data.id),e()}})})})]})})}const Hj=`${$b}
|
|
281
281
|
[data-flow-loading-border][data-flow-loading-border] .flow-sdk-node-border-animation{animation:flow-sdk-node-border 2.4s linear infinite!important}
|
|
282
282
|
[data-flow-loading-border][data-flow-loading-border][data-motion-disabled] .flow-sdk-node-border-animation{animation:none!important}
|
|
283
|
-
@media(prefers-reduced-motion:reduce){[data-flow-loading-border][data-flow-loading-border] .flow-sdk-node-border-animation{animation:none!important}}`;function Xv({active:e=!0,label:r="Loading content",radius:t}){const{config:n,themeColor:o}=He(),{colorText:i}=st(),s=j.useRef(null),[a,c]=j.useState({width:0,height:0,radius:0});if(j.useLayoutEffect(()=>{const u=s.current;if(!e||!u)return;const h=()=>{const m=u.parentElement,y={width:u.clientWidth,height:u.clientHeight,radius:t??(m&&parseFloat(getComputedStyle(m).borderTopLeftRadius)||0)};c(g=>g.width===y.width&&g.height===y.height&&g.radius===y.radius?g:y)},p=new ResizeObserver(h);return p.observe(u),h(),()=>p.disconnect()},[e,t]),!e)return null;const l=Pe(o||i),d={x:4,y:4,width:a.width-8,height:a.height-8,radius:Math.max(0,a.radius-4),color:l,strokeWidth:2};return f.jsxs("div",{ref:s,role:"status","aria-label":r,"data-flow-loading-border":"","data-motion-disabled":n.disableAnimations||void 0,style:{position:"absolute",inset:0,pointerEvents:"none",borderRadius:"inherit",overflow:"hidden",zIndex:2},children:[f.jsx("style",{children:Hj}),f.jsxs("svg",{width:"100%",height:"100%","aria-hidden":"true",style:{display:"block",pointerEvents:"none"},children:[f.jsx("g",{opacity:.5,style:{filter:"blur(3px)"},children:f.jsx(oo,{...d,strokeWidth:6})}),f.jsx(oo,{...d})]})]})}function Kj({content:e,format:r,onEdit:t}){var N;const{config:n,colorMode:o}=He(),{background:i,border:s,colorInactive:a}=st(),c=(N=n.customViews)==null?void 0:N.jsxContent,l=typeof e=="string"?e:JSON.stringify(e,null,2);let d,u;if(r==="jsx")try{const $=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray($)||$.some(I=>!I||typeof I!="object"||Array.isArray(I)||typeof I.type!="string"))throw new Error("JSX content must be an array of components with a type.");d=$}catch($){u=$ instanceof Error?$.message:"Invalid components array."}const h=j.useRef(null),p=j.useRef(null),m=j.useRef(null),y=j.useRef(!1),[g,b]=j.useState(!1),[v,x]=j.useState(""),w=!!t;j.useEffect(()=>{const $=()=>{var W;const I=document.fullscreenElement===p.current;b(I),y.current&&!I&&!document.fullscreenElement&&((W=m.current)==null||W.focus({preventScroll:!0})),y.current=I};return document.addEventListener("fullscreenchange",$),()=>document.removeEventListener("fullscreenchange",$)},[]);const C=async()=>{var $;x("");try{if(document.fullscreenElement===p.current)await document.exitFullscreen();else if(($=p.current)!=null&&$.requestFullscreen)await p.current.requestFullscreen();else throw new Error("Fullscreen is not supported in this browser.")}catch(I){x(I instanceof Error?I.message:"Unable to change fullscreen.")}},[S,_]=j.useState(),[k,E]=j.useState(),[O,P]=j.useState();j.useEffect(()=>{if(r==="jsx")return;let $=!1;return Promise.resolve().then(()=>require("./contentPreviewDocument-BsKd0dD4.cjs")).then(({contentPreviewDocument:I})=>I(l,r,w)).then(I=>{$||_({content:l,format:r,editable:w,document:I})},I=>{$||_({content:l,format:r,editable:w,error:I instanceof Error?I.message:String(I)})}),()=>{$=!0}},[l,r,w]),j.useEffect(()=>{if(!t)return;const $=async I=>{var W,ie;if(!(!((W=h.current)!=null&&W.contentWindow)||I.source!==h.current.contentWindow||((ie=I.data)==null?void 0:ie.type)!=="squeed:content-edit"))try{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()}catch(ae){x(ae instanceof Error?ae.message:"Unable to close fullscreen.")}};return window.addEventListener("message",$),()=>window.removeEventListener("message",$)},[t]);const A=(S==null?void 0:S.content)===l&&S.format===r&&S.editable===w?S:void 0,M=!!A&&A===O,T=r!=="jsx"&&!(A!=null&&A.error)&&!M&&(!A||k!==A);return f.jsxs("div",{"data-flow-content-preview":"",style:{width:"100%",height:360,fontSize:16,overflow:"auto"},children:[f.jsx("pre",{"data-flow-preview-source":"",style:{display:"none",whiteSpace:"pre-wrap"},children:l}),f.jsxs(V.Box,{ref:p,position:"relative",w:"100%",h:"100%","aria-busy":r!=="jsx"?T:void 0,bg:r==="jsx"&&o==="dark"?"gray.900":"white",onDoubleClick:$=>{r!=="jsx"||!t||$.defaultPrevented||$.target.closest('button, a, input, textarea, select, [contenteditable], [role="button"], [role="textbox"]')||($.stopPropagation(),(async()=>{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()})().catch(I=>x(String(I))))},onKeyDownCapture:$=>{$.key!=="Escape"||document.fullscreenElement!==p.current||($.preventDefault(),$.stopPropagation(),C())},css:{"&:fullscreen":{width:"100vw",height:"100dvh",maxWidth:"none",maxHeight:"none",padding:0},"&:hover > [data-flow-content-toolbar], &:focus-within > [data-flow-content-toolbar]":{opacity:1,pointerEvents:"auto"},"@media (hover: none)":{"& > [data-flow-content-toolbar]":{opacity:1,pointerEvents:"auto"}}},children:[f.jsx(V.Box,{role:"toolbar","aria-label":"Content controls","data-flow-content-toolbar":"",position:"absolute",top:"8px",right:"8px",zIndex:1,w:"max-content",maxW:"calc(100% - 16px)",opacity:g?1:0,pointerEvents:g?"auto":"none",children:f.jsx($d,{background:i,border:o==="dark"?s:"gray.300",children:f.jsxs(V.HStack,{px:"8px",gap:"8px",h:"100%",w:"max-content",css:{"& button > svg":{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",flexShrink:0}},children:[t&&f.jsx(Ne,{"data-flow-content-edit":"","aria-label":"Edit content source",title:"Edit content source",icon:f.jsx(Z.PiCode,{size:20}),size:"sm",variant:"plain",bg:"transparent",color:a,borderRadius:"30px",w:"32px",h:"32px",minW:"32px",p:0,onClick:$=>{$.stopPropagation(),(async()=>{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()})().catch(I=>x(String(I)))}}),f.jsx(Ne,{ref:m,"data-flow-fullscreen":"","aria-label":g?"Exit fullscreen":"Expand preview",title:g?"Exit fullscreen":"Expand preview","aria-expanded":g,icon:g?f.jsx(Z.PiArrowsIn,{size:20}):f.jsx(Z.PiArrowsOut,{size:20}),size:"sm",variant:"plain",bg:"transparent",color:a,borderRadius:"30px",w:"32px",h:"32px",minW:"32px",p:0,onClick:$=>{$.stopPropagation(),C()}})]})})}),v&&f.jsx(V.Box,{role:"alert",position:"absolute",bottom:0,insetInline:0,bg:"white",color:"red.700",fontSize:"14px",children:v}),r==="jsx"?u?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:u}):c&&d?f.jsx(c,{components:d,colorMode:o,fillHeight:!0}):f.jsx(V.Box,{role:"status",fontSize:"14px",children:"JSX content renderer is not available."}):A!=null&&A.error||M?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:(A==null?void 0:A.error)||"Content preview could not be loaded."}):A!=null&&A.document?f.jsx("iframe",{ref:h,title:`${r.toUpperCase()} content preview`,sandbox:w?"allow-scripts":"",allowFullScreen:!0,referrerPolicy:"no-referrer",srcDoc:A.document,onLoad:()=>E(A),onError:()=>P(A),style:{width:"100%",height:"100%",border:0,display:"block",background:"white",visibility:T?"hidden":"visible"}},A.document):null,f.jsx(Xv,{active:T,label:"Loading HTML content"})]})]})}const Cm=1.55;function Jj({nodeId:e,content:r,color:t,format:n="markdown"}){const{callbacks:o,config:i,readOnly:s,nodeGridOptions:a}=He(),c=!!i.editable&&!s,l=c&&!a,d=typeof r=="string"?r:JSON.stringify(r,null,2),[u,h]=j.useState(!1),[p,m]=j.useState(d),[y,g]=j.useState(""),[b,v]=j.useState(),x=j.useRef(null),w=j.useRef(!1),C=au(u);j.useLayoutEffect(()=>{const k=x.current;!u||!k||(k.style.height="auto",k.style.height=`${Math.max((b==null?void 0:b.height)??0,k.scrollHeight)}px`)},[p,u,b]),j.useEffect(()=>{var k,E;c?u&&(w.current=!1,(k=x.current)==null||k.focus({preventScroll:!0}),(E=x.current)==null||E.select()):h(!1)},[u,c]);const S=(k,E=!1)=>{!c||a&&!E||(v({width:k.offsetWidth,height:k.offsetHeight}),m(d),g(""),h(!0))},_=()=>{var E;if(w.current||!c)return;let k=p;if(n==="jsx")try{if(k=JSON.parse(p),!Array.isArray(k)||k.some(O=>!O||typeof O!="object"||Array.isArray(O)||typeof O.type!="string"))throw new Error("JSX content must be an array of components with a type.")}catch(O){g(O instanceof Error?O.message:"Invalid components array.");return}w.current=!0,p!==d&&((E=o.onNodeContentChange)==null||E.call(o,e,k)),h(!1)};return(!u||!c)&&n!=="markdown"?f.jsx(V.Box,{ref:C,w:"100%",position:"relative","data-flow-content":"",children:f.jsx(Kj,{content:r,format:n,onEdit:l?()=>{C.current&&S(C.current)}:void 0})}):!u||!c?f.jsx(V.Box,{"data-flow-content":"",color:t,opacity:r?void 0:.6,w:"100%",minH:"1.2em",whiteSpace:"normal",lineHeight:Cm,overflowWrap:"anywhere",css:{"& > :first-of-type":{marginTop:0},"& > :last-of-type":{marginBottom:0},"& h1, & h2, & h3, & h4, & h5, & h6":{fontWeight:700,lineHeight:1.2,margin:"1em 0 0.45em"},"& h1":{fontSize:"1.5em"},"& h2":{fontSize:"1.3em"},"& h3":{fontSize:"1.1em"},"& p":{margin:"0.65em 0",whiteSpace:"pre-wrap"},"& ul, & ol":{margin:"0.65em 0",paddingInlineStart:"1.6em"},"& ul":{listStyleType:"disc"},"& ol":{listStyleType:"decimal"},"& li":{display:"list-item",margin:"0.3em 0",paddingInlineStart:"0.15em"},"& li > ul, & li > ol":{margin:"0.25em 0"},"& li > p":{margin:0},"& a":{color:"inherit",textDecoration:"underline"},"& code":{fontFamily:"monospace",fontSize:"0.85em"},"& :not(pre) > code":{background:"color-mix(in srgb, currentColor 10%, transparent)",padding:"0.1em 0.25em",borderRadius:"0.2em"},"& pre":{margin:"0.75em 0",padding:"0.75em",background:"color-mix(in srgb, currentColor 8%, transparent)",border:0,borderRadius:"6px",maxWidth:"100%",overflowX:"auto",whiteSpace:"pre",overflowWrap:"normal",lineHeight:1.5},"& pre code":{background:"transparent",padding:0,whiteSpace:"inherit"},"& strong":{fontWeight:700},"& em":{fontStyle:"italic"},"& blockquote":{margin:"0.4em 0",borderInlineStart:"0.1em solid currentColor",paddingInlineStart:"0.6em"},"& table":{width:"100%",tableLayout:"fixed",borderCollapse:"collapse",margin:"0.4em 0"},"& th, & td":{border:"1px solid currentColor",padding:"0.2em 0.3em",textAlign:"left"},"& th":{fontWeight:700},"& img":{maxWidth:"100%",height:"auto"}},cursor:l?"text":void 0,tabIndex:l?0:void 0,outline:"none",_focusVisible:{outline:"none",boxShadow:"none"},onClick:k=>{!c||a&&!k.shiftKey||k.target instanceof Element&&k.target.closest("a, button, input")||(k.stopPropagation(),S(k.currentTarget,k.shiftKey))},onDoubleClick:k=>{k.stopPropagation(),S(k.currentTarget,k.shiftKey)},onKeyDown:k=>{c&&(!a||k.shiftKey)&&k.key==="Enter"&&k.target===k.currentTarget&&(k.preventDefault(),k.stopPropagation(),S(k.currentTarget,k.shiftKey))},children:f.jsx(Cx.default,{options:{forceBlock:!0,wrapper:j.Fragment,disableParsingRawHTML:!0,overrides:{a:{props:{target:"_blank",rel:"noopener noreferrer"}},img:{props:{loading:"lazy",referrerPolicy:"no-referrer"}}}},children:d||(i.editable&&!s?"Write your content here":"")})}):f.jsxs("div",{ref:C,style:{width:b==null?void 0:b.width,minHeight:b==null?void 0:b.height,maxWidth:"100%"},children:[f.jsx(V.Textarea,{ref:x,"aria-label":"Node content",placeholder:"Write your content here",value:p,"aria-invalid":!!y,onChange:k=>m(k.target.value),onBlur:_,onKeyDown:k=>{k.stopPropagation(),!k.nativeEvent.isComposing&&(k.key==="Enter"&&(k.ctrlKey||k.metaKey)&&(k.preventDefault(),_()),k.key==="Escape"&&(w.current=!0,h(!1)))},color:t,fontFamily:"inherit",fontSize:"inherit",lineHeight:Cm,overflowWrap:"anywhere",whiteSpace:"pre-wrap",rows:1,bg:"transparent",display:"block",style:{border:0,outline:"none",boxShadow:"none"},_focus:{border:0,outline:"none",boxShadow:"none"},_focusVisible:{border:0,outline:"none",boxShadow:"none"},p:0,w:"100%",h:"100%",minW:0,minH:0,resize:"none"}),y&&f.jsx(V.Box,{role:"alert",fontSize:"14px",color:"red.500",children:y})]})}const Zj=(e,r,t)=>{var h,p,m,y;const n=((h=e==null?void 0:e.viewProps)==null?void 0:h.bgColor)||r,[o]=n.split("."),i=Nn(n),s=((p=e==null?void 0:e.viewProps)==null?void 0:p.outline)===!0,a=n==="transparent"||s,c=t==="dark"?"gray.200":"gray.900",l=a?"transparent":n!=null&&n.startsWith("#")?Pe(n):Pe(i.bgColor),d=Pe(((m=e==null?void 0:e.viewProps)==null?void 0:m.textColor)||(a?c:i.textColor)),u=Pe(((y=e==null?void 0:e.viewProps)==null?void 0:y.borderColor)||(s?n==="transparent"?r:n:i.borderColor));return{...i,bgColor:a?"transparent":i.bgColor,highlightColor:a?"transparent":i.highlightColor,isTransparent:a,propertyColor:a?c:i.propertyColor,bg:n,wordBeforeDot:o,hexbgColor:l,hextextColor:d,hexborderColor:u}},Yj=(e,r=350)=>`${String(e).substring(0,r)}${String(e).length>r?"...":""}`,Xj=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,Qv=600,Qj=3,e_=e=>{const r=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(r*28+30,200)};function t_({headerTitle:e,hasContent:r,data:t,icon:n,colors:o,hasConfig:i,id:s,isActive:a,isHovered:c,isEditing:l,onSelect:d,onEditStart:u,onEditEnd:h,props:p,objVisible:m,setObjVisible:y,onShowNativeIcon:g}){var w,C;const{callbacks:b}=He(),v=p.onShowIcon??g,x=v?"Show icon":m?"Show content":"Show properties";return f.jsx(f.Fragment,{children:(e||r||((w=t.config)==null?void 0:w.form)||(a||c)&&g)&&f.jsxs(V.Flex,{justify:"flex-start",direction:"row",p:r||Object.entries(t.description||{}).length?8:20,borderBottomWidth:1,minWidth:"max-content !important",width:"100%",textTransform:"capitalize",align:"center",textOverflow:"ellipsis",alignItems:"center",fontWeight:"bold",color:o.propertyColor,bgColor:o.highlightColor,borderBottomColor:!i&&!r?"transparent":o.hexborderColor,children:[!!n&&f.jsx(V.Flex,{mr:6,alignItems:"center",flexShrink:0,children:f.jsx(Qt,{name:n,size:64,color:o.hextextColor},o.hextextColor)}),f.jsx(Jr,{nodeId:s,label:Xj(e),color:((C=t==null?void 0:t.viewProps)==null?void 0:C.textColor)||o.propertyColor,isEditing:l,onEditStart:u,onEditEnd:h}),(a||c)&&(r||v)&&f.jsx(V.Box,{ml:"auto",pl:6,flexShrink:0,"data-flow-content-toggle":"",children:f.jsx(Ue,{label:x,children:f.jsx(Ne,{"aria-label":x,icon:f.jsx(V.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:o.hextextColor,onClick:S=>{var _;S.stopPropagation(),a||d(S),v?v():y(!m),(_=b.onNodeViewToggle)==null||_.call(b,s)}})})})]})})}function r_({data:e,resourcePorts:r,inspecting:t,form:n,inspectionPorts:o,extraPorts:i,colors:s,direction:a,uniformKeyWidth:c}){const{edgeById:l}=vr(),d=new Set;for(const{data:u}of l.values())u.source===e.id&&u.sourceProperty!==void 0&&d.add(`source:${u.sourceProperty}`),u.target===e.id&&u.targetProperty!==void 0&&d.add(`target:${u.targetProperty}`);return f.jsx(V.Box,{children:Object.entries(e.description||{}).map(([u,h],p)=>{var M,T,N;const m=r&&Object.keys(r).find($=>$.slice($.indexOf(":")+1)===u),y=t&&((M=n==null?void 0:n.type.ports)==null?void 0:M[u]),g=m??(y?`${y.kind}:${u}`:u),b=o.find($=>$.id===g),v=m?"source":b==null?void 0:b.role,x=d.has(`source:${g}`),w=d.has(`target:${g}`),C=i.some($=>$.id===u),S=h===""&&(C||(v?d.has(`${v}:${g}`):x||w)),_=v??(x!==w?x?"source":"target":void 0),k=(b==null?void 0:b.side)??(_?_==="source"!=(a==="RL")?"right":"left":void 0),E=S&&k==="right"?"right":"left",O=(b==null?void 0:b.label)??(y==null?void 0:y.label)??(C?u.replace(/^(template|input|output|config|error):/,""):u),P=Xt(s.wordBeforeDot)[typeof h],A=Xt(s.wordBeforeDot).property;return f.jsxs(V.Box,{"data-flow-property":m&&(a==="TB"||a==="BT")?void 0:g,"data-flow-port-role":v,"data-flow-inspection-row":t?"":void 0,children:[f.jsxs(V.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[f.jsx(V.Flex,{justifyContent:"start",align:"center",background:s.highlightColor,width:S?"100%":`${c}px`,minWidth:`${c}px`,borderRightColor:s.hexborderColor,borderRightWidth:S?0:1,children:f.jsx(V.Text,{py:5,px:10,w:"100%",textAlign:E,whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((T=e==null?void 0:e.viewProps)==null?void 0:T.textColor)||(s.isTransparent?s.hextextColor:A),children:O})}),!S&&f.jsx(V.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:s.hexbgColor,w:Qv,maxH:200,children:f.jsx(V.Text,{overflow:"hidden",py:3,px:4,whiteSpace:"normal",textOverflow:"ellipsis",fontSize:"4xl",color:((N=e==null?void 0:e.viewProps)==null?void 0:N.textColor)||(s.isTransparent?s.hextextColor:P),fontWeight:400,children:Yj(h)})})]}),p!==Object.entries(e.description||{}).length-1&&f.jsx(V.Box,{borderTopWidth:1,my:0,borderColor:s.hexborderColor})]},u)})})}function n_(e){var x,w,C,S,_;const{themeColor:r,colorMode:t,direction:n}=He(),o=Wn(),i=o.getNodeViewMode(e.data.id)==="properties",s=k=>o.setNodeViewMode(e.data.id,k?"properties":"default"),a=!!e.onShowIcon||i||typeof((x=e.data.config)==null?void 0:x.content)!="string"&&!(((w=e.data.config)==null?void 0:w.contentFormat)==="jsx"&&Array.isArray((C=e.data.config)==null?void 0:C.content)),{bindings:c,data:l,schema:d}=j.useContext(Mt),u=(S=c==null?void 0:c[e.data.id])==null?void 0:S.portResources,h=c?$n(c,e.data.id,d):l&&d?Xr(l,e.data.id,d):void 0,p=h&&Le(l,"address"in h?h.address:e.data.id),m=p&&typeof p=="object"&&h?Object.fromEntries(Object.keys(h.type.properties).filter(k=>{var E;return Object.prototype.hasOwnProperty.call(p,k)&&ho((E=h.fields[k])==null?void 0:E.$visibleWhen,l)}).map(k=>[k,p[k]!==null&&typeof p[k]=="object"?JSON.stringify(p[k],null,2):p[k]===null?"null":p[k]])):{},y=u?Object.fromEntries(Object.entries(u).map(([k,E])=>{var O;return[k.slice(k.indexOf(":")+1),((O=Le(l,E))==null?void 0:O.name)??E.split(".").at(-1)]})):Object.keys(e.data.description??{}).length?e.data.description:m,g=a&&!u?((_=e.data.config)==null?void 0:_.ports)??[]:[],b=g.filter(k=>!Object.prototype.hasOwnProperty.call(y,k.id)&&!Object.entries((h==null?void 0:h.type.ports)??{}).some(([E,O])=>`${O.kind}:${E}`===k.id&&Object.prototype.hasOwnProperty.call(y,E))),v={...y,...Object.fromEntries(b.map(k=>[k.id,""]))};return{themeColor:r,colorMode:t,direction:n,objVisible:i,setObjVisible:s,inspecting:a,resourcePorts:u,form:h,description:v,inspectionPorts:g,extraPorts:b}}const du=e=>{var v,x,w,C,S,_;const{themeColor:r,colorMode:t,direction:n,objVisible:o,setObjVisible:i,inspecting:s,resourcePorts:a,form:c,description:l,inspectionPorts:d,extraPorts:u}=n_(e),h=Wn(),p=h.getNodeViewMode(e.data.id)==="icon-label",m=!e.onShowIcon&&(typeof((v=e.data.config)==null?void 0:v.content)=="string"||((x=e.data.config)==null?void 0:x.contentFormat)==="jsx"&&Array.isArray((w=e.data.config)==null?void 0:w.content)),y=j.useRef(p);p&&(y.current=!0),cu(e.data.id,m&&!((C=e.data.config)!=null&&C.parentContainer)&&h.allNodesIconLabel&&!p&&y.current,()=>h.setNodeViewMode(e.data.id,"icon-label"));const b=!e.onShowIcon&&!((S=e.data.config)!=null&&S.parentContainer)&&!m?()=>h.setNodeViewMode(e.data.id,"icon-label"):void 0;return!e.onShowIcon&&p?f.jsx(lu,{...e,data:{...e.data,label:e.data.label??e.data.headerTitle,config:{...e.data.config,labelBelow:!0,icon:((_=e.data.config)==null?void 0:_.icon)||"PiBracketsCurly"}},onExpand:()=>h.restoreNodeView(e.data.id)}):f.jsx(Vn,{...e,data:{...e.data,description:l},hoverLeaveDelay:m||e.onShowIcon||b?350:0,children:({id:k,data:E,isActive:O,isHovered:P,isEditing:A,onSelect:M,onEditStart:T,onEditEnd:N})=>{var L,z,G,D,se,X,le,ue,Ce,je;const $=Zj(E,r,t),I=E.label??E.headerTitle,W=Object.entries(E.description||{}).length>0,ie=e_(E.description),ae=(z=(L=e.data)==null?void 0:L.config)==null?void 0:z.icon,re=(D=(G=e.data)==null?void 0:G.config)==null?void 0:D.content,ye=((se=E==null?void 0:E.viewProps)==null?void 0:se.borderRadius)??"53px",be=Tn(E==null?void 0:E.viewProps,$.hexborderColor,O,Qj);return f.jsx(V.Flex,{justifyContent:"space-between",...E==null?void 0:E.viewProps,"data-flow-node-surface":"",direction:"column",p:0,borderRadius:ye,overflow:"hidden",alignItems:"center",style:{backgroundColor:$.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:"100%",minW:m||e.onShowIcon?ie+Qv+be.borderWidth*2:void 0,...be,children:f.jsxs(V.Flex,{width:"100%",direction:"column",borderRadius:ye,borderColor:$.hexborderColor,borderWidth:0,overflow:"hidden",children:[f.jsx(t_,{headerTitle:I,hasContent:m,data:E,icon:ae,colors:$,hasConfig:W,id:k,isActive:O,isHovered:P,isEditing:A,onSelect:M,onEditStart:T,onEditEnd:N,props:e,objVisible:o,setObjVisible:i,onShowNativeIcon:b}),m&&!o?f.jsx(V.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:$.highlightColor,p:["html","jsx"].includes((le=(X=e.data)==null?void 0:X.config)==null?void 0:le.contentFormat)?0:12,fontSize:"5xl",lineHeight:"normal",children:f.jsx(Jj,{nodeId:k,content:re,format:(Ce=(ue=e.data)==null?void 0:ue.config)==null?void 0:Ce.contentFormat,color:((je=E==null?void 0:E.viewProps)==null?void 0:je.textColor)||$.hextextColor})}):f.jsx(r_,{data:E,resourcePorts:a,inspecting:s,form:c,inspectionPorts:d,extraPorts:u,colors:$,direction:n,uniformKeyWidth:ie})]})})}})};du.displayName="NodeJsonObjectView";const ex=e=>{var h,p,m,y,g,b,v,x,w,C,S;const r=Wn(),[t,n]=j.useState(!1),o=r.getNodeViewMode(e.data.id)==="properties",i=_=>{n(_),r.setNodeViewMode(e.data.id,_?"properties":"default")},{callbacks:s,readOnly:a}=He(),c=(p=(h=e.data)==null?void 0:h.config)==null?void 0:p.parentContainer;cu(e.data.id,o&&((y=(m=e.data)==null?void 0:m.config)==null?void 0:y.labelBelow)&&!c,()=>i(!1));const l=c?"Show parent":"Show properties",d=c||((b=(g=e.data)==null?void 0:g.config)==null?void 0:b.form)||((w=(x=(v=e.data)==null?void 0:v.config)==null?void 0:x.ports)==null?void 0:w.length),u=d?()=>{var _;c?(_=s.onNodeCollapse)==null||_.call(s,e.data.id,!1):i(!0)}:void 0;return!c&&d&&o?f.jsx(du,{...e,editOnMount:t,onShowIcon:()=>i(!1)}):f.jsx(lu,{...e,onOpenView:u&&(c||(S=(C=e.data)==null?void 0:C.config)!=null&&S.labelBelow)?()=>{var _;u(),(_=s.onNodeViewToggle)==null||_.call(s,e.data.id)}:void 0,toggleLabel:l,toggleDisabled:c&&a,onExpand:u})};function o_(e){var b,v,x,w,C,S;const{config:r,callbacks:t,readOnly:n,selectedNodeIds:o,nodeRadiusPreviews:i,nodeViewModes:s,allNodesIconLabel:a}=He(),c=i[e.data.id]??((b=e.data.viewProps)==null?void 0:b.borderRadius),[l,d]=j.useState(!1),u=Wn(),{border:h,colorText:p}=st(),m=(v=r.customViews)==null?void 0:v.gridContent,y=(s[e.data.id]??(a?"icon-label":"default"))==="icon-label",g=j.useRef(y);return y&&(g.current=!0),cu(e.data.id,a&&!y&&g.current,()=>u.setNodeViewMode(e.data.id,"icon-label")),y?f.jsx(V.Box,{"data-grid-document":((x=e.data.config)==null?void 0:x.documentId)??"",children:f.jsx(lu,{...e,data:{...e.data,viewProps:{...e.data.viewProps,borderRadius:c},config:{...e.data.config,labelBelow:!0,icon:((w=e.data.config)==null?void 0:w.icon)||"PiGridFour"}},toggleLabel:"Show grid",onExpand:()=>u.restoreNodeView(e.data.id)})}):f.jsxs(f.Fragment,{children:[f.jsx(Vn,{...e,onOpenView:()=>d(!0),children:({data:_,isActive:k})=>{var E,O,P,A,M,T,N,$;return f.jsx(V.Box,{"data-flow-node-surface":"","data-grid-document":((E=_.config)==null?void 0:E.documentId)??"",width:`${((P=(O=_.config)==null?void 0:O.gridSize)==null?void 0:P.width)??600}px`,height:`${((M=(A=_.config)==null?void 0:A.gridSize)==null?void 0:M.height)??440}px`,overflow:"hidden",position:"relative",bg:((T=_.viewProps)==null?void 0:T.bgColor)??"transparent",color:((N=_.viewProps)==null?void 0:N.textColor)??p,borderRadius:`${c??0}px`,...Tn(_.viewProps,Pe((($=_.viewProps)==null?void 0:$.borderColor)??h),k,0),children:m?f.jsx(m,{...e}):f.jsx(V.Box,{p:4,children:_.label??"Grid"})})}}),f.jsx(su,{nodeAddress:e.data.id,active:o.includes(e.data.id),label:e.data.label??"Grid",open:l&&!n,onClose:()=>d(!1),children:f.jsx(Mt.Provider,{value:{data:{metadata:{label:e.data.label??"",subtitle:((C=e.data.config)==null?void 0:C.subtitle)??"",icon:((S=e.data.config)==null?void 0:S.icon)??"PiGridFour"}},bindings:{[e.data.id]:{address:"root.metadata",type:"GridMetadata"}},schema:{GridMetadata:{kind:"object",properties:{label:{optional:!0,type:{kind:"string"}},subtitle:{optional:!0,type:{kind:"string"}},icon:{optional:!0,type:{kind:"string"}}}}},editable:!!r.editable&&!n,callbacks:{onFormChange:_=>{var E,O,P;if(n||!r.editable)return;const k=String(_.value??"");_.address==="root.metadata.label"?(E=t.onNodeLabelChange)==null||E.call(t,e.data.id,k):_.address==="root.metadata.subtitle"?(O=t.onNodeSubtitleChange)==null||O.call(t,e.data.id,k):_.address==="root.metadata.icon"&&((P=t.onNodeIconChange)==null||P.call(t,e.data.id,k))}}},children:f.jsx(Od,{nodeAddress:e.data.id})})})]})}const tx=e=>f.jsx(ex,{...e,renderCompact:Gj}),rx=e=>f.jsx(ex,{...e}),nx=({containerStyle:e,...r})=>{const{selectedNodeIds:t}=He();return f.jsx(Vn,{...r,editOnMount:t.includes(r.data.id),children:n=>f.jsx(V.Box,{bg:e.textColor==="transparent"?"transparent":e.labelBg,p:`${e.fontSize/5}px`,fontFamily:hr,lineHeight:1,w:"fit-content",children:f.jsx(Jr,{nodeId:n.id,label:n.data.label??n.data.headerTitle??"Container",color:e.textColor,fontSize:`${e.fontSize}px`,isEditing:n.isEditing,onEditStart:n.onEditStart,onEditEnd:n.onEditEnd})})})};tx.displayName="text";rx.displayName="arrayView";nx.displayName="ParentContainerView";const i_={grid:o_,objectView:du,arrayView:rx,text:tx,parentContainer:nx},a_=({children:e,pattern:r="dot",backgroundColor:t})=>{const{colorMode:n}=He(),o=n==="dark",i=o?"--chakra-colors-gray-700":"--chakra-colors-gray-500",s=o?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return r==="none"?f.jsx(V.Box,{"data-flow-background":"none",width:"100%",height:"100%",padding:0,bg:t,children:e}):f.jsxs(V.Box,{"data-flow-background":r,position:"relative",width:"100%",height:"100%",padding:0,bg:t,children:[f.jsx(V.Box,{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:0,pointerEvents:"none",style:{backgroundImage:r==="dot"?`radial-gradient(var(${i}) 8%, transparent 8%)`:r==="steel"?`repeating-linear-gradient(45deg, var(${s}) 0, var(${s}) 1px, transparent 1px, transparent 20px)`:`linear-gradient(var(${s}) 1px, transparent 1px), linear-gradient(90deg, var(${s}) 1px, transparent 1px)`,backgroundSize:"20px 20px",opacity:.3}}),f.jsx(V.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:e})]})},s_=.4,_r={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},c_=({nodes:e,edges:r})=>{var ze;const{themeColor:t,spacing:n,edgeRadius:o,backgroundVariant:i,backgroundSelected:s,setBackgroundSelected:a,edgeColor:c,direction:l,nodeAlignment:d,edgeMode:u,compactPropertyLayout:h,workflowContract:p,parentNodeStyle:m,engineRef:y,callbacks:g,config:b,selectedNodeIds:v,setSelectedNodeIds:x,selectedEdgeId:w,setSelectedEdgeId:C,setIsPerformanceMode:S,setNodeGridOptions:_,fillRadiusEditedIds:k,isZoomMode:E,setIsZoomMode:O,isMultiSelectMode:P,setIsMultiSelectMode:A,isDragMode:M,setIsDragMode:T,isEdgeHandlesEnabled:N,setIsEdgeHandlesEnabled:$,isArrayNodeMode:I}=He(),W=j.useRef(null),[ie,ae]=j.useState(null),re=j.useRef(null),ye=e.length>200;j.useEffect(()=>{S(ye)},[ye,S]);const{edgeSep:be,rankSep:L,spacingFactor:z}=j.useMemo(()=>{const ce=zw(e.length),B=b.nodeGridSpacing==="layout"&&n<.5?n*1.3:n<1?.3+.7*n:.5+.5*n;return{edgeSep:ce.edgeSep*B,rankSep:ce.rankSep*B,spacingFactor:1.3+(n-1)*(n<1?.4:.3)}},[e.length,n,b.nodeGridSpacing]),{bgColor:G}=Nn(t),{canvas:D,borderSecondary:se,colorText:X}=st(),le=i==="transparent"?"transparent":b.backgroundColor||D,ue=j.useCallback(ce=>{if(!ce)return Pe(t);switch(ce){case"dark":return Pe(le);case"light":return Pe(se);default:return Pe(ce)}},[t,le,se]),Ce=b.colorMode==="dark",je=Ce?Pe("gray.500"):Zr,pe=Ce?G!=null&&G.includes("gray")?"whitesmoke":ue(G):je,fe=c?ue(c):je,Y=j.useMemo(()=>{var ce;return b.initialViewport||{pan:{x:0,y:0},zoom:(ce=b.nodeGrid)!=null&&ce.enabled&&b.nodeGrid.options.fill?1:.01}},[]),H=l==="C"?"LR":l,we=j.useCallback(ce=>{const B={...m,...ce};return{...B,bgColor:B.bgColor||t,bgOpacity:B.outline?0:B.bgOpacity??s_}},[m,t]),J=j.useMemo(()=>{var B;const ce=new Map;for(const oe of e)(B=oe.data)!=null&&B.id&&ce.set(oe.data.id,oe);return ce},[e]),ve=j.useMemo(()=>{var B;const ce=new Map;for(const oe of r)(B=oe.data)!=null&&B.id&&ce.set(oe.data.id,oe);return ce},[r]),Q=j.useCallback(ce=>{var U;const B=(U=J.get(ce))==null?void 0:U.data,oe=we(B==null?void 0:B.viewProps),$e=Pe(oe.bgColor);return{animated:!!(B!=null&&B.isNodeAnimated)&&!ye,animationVariant:B==null?void 0:B.nodeAnimationVariant,animationColor:Pe(oe.borderColor||t),bgColor:oe.outline?"transparent":$e,bgOpacity:oe.bgOpacity,borderColor:oe.borderColor?Pe(oe.borderColor):oe.outline&&oe.bgColor==="transparent"?Pe(t):$e,borderWidth:In(oe.borderWidth,_r.borderWidth),borderStyle:oe.borderStyle??_r.borderStyle,borderRadius:oe.borderRadius??_r.borderRadius,textColor:oe.textColor?Pe(oe.textColor):oe.outline||oe.bgColor==="transparent"?Pe(X):$e,fontSize:oe.fontSize??_r.fontSize,labelPosition:oe.labelPosition??_r.labelPosition,labelMargin:_r.labelMargin,labelBg:wu(ue("dark"),$e,oe.bgOpacity)??ue("dark"),padding:oe.padding??_r.padding}},[we,J,X,t,ye,ue]),Ee=j.useMemo(()=>{var oe,$e;const ce=new Map;for(const U of r){const ge=(oe=U.data)==null?void 0:oe.source,Ie=($e=U.data)==null?void 0:$e.target;if(!ge||!Ie||ge===Ie)continue;const xe=ge<Ie?`${ge}|${Ie}`:`${Ie}|${ge}`,Ze=ce.get(xe);Ze?Ze.push({id:U.data.id,source:ge}):ce.set(xe,[{id:U.data.id,source:ge}])}const B=new Map;for(const[U,ge]of ce){if(ge.length<2)continue;const Ie=U.split("|")[0],xe=Math.min(20,70/ge.length);ge.forEach(({id:Ze,source:Qe},Ke)=>{const vt=50+(Ke-(ge.length-1)/2)*xe;B.set(Ze,(Qe===Ie?vt:100-vt)/100)})}return B},[r]),Ae=j.useMemo(()=>{const ce=ue("dark");return r.filter(B=>{var oe;return((oe=B.data)==null?void 0:oe.id)&&B.data.source&&B.data.target}).map(({data:B})=>{var ge,Ie,xe,Ze,Qe,Ke;let oe=ce;const $e=(Ie=(ge=J.get(B.source))==null?void 0:ge.data)==null?void 0:Ie.parent,U=(Ze=(xe=J.get(B.target))==null?void 0:xe.data)==null?void 0:Ze.parent;if($e&&$e===U){const vt=we((Ke=(Qe=J.get($e))==null?void 0:Qe.data)==null?void 0:Ke.viewProps),It=wu(ce,Pe(vt.bgColor),vt.bgOpacity);It&&(oe=It)}return{id:B.id,data:B,type:B.type??b.edgeType??"rounded-orthogonal",source:B.source,target:B.target,sourceProperty:B.sourceProperty,targetProperty:B.targetProperty,label:B.label,validationIssue:(u==="auto"||u==="properties")&&(B.sourceProperty!==void 0||B.targetProperty!==void 0)&&p?Id(p,B):void 0,color:c?fe:B.color?Pe(B.color):fe,connectorColor:c?fe:B.color?Pe(B.color):pe,labelBg:oe,dashed:!!B.isEdgeDashed,animated:!!B.isEdgeAnimated,inverted:!!B.isInverted,turn:Ee.get(B.id)??.5}})},[r,fe,pe,c,Ee,b.edgeType,u,p,J,we,ue]),qe=j.useMemo(()=>{var B;const ce=new Set;for(const oe of e)(B=oe.data)!=null&&B.parent&&ce.add(oe.data.parent);return ce},[e]),Je=j.useMemo(()=>{const ce=new Map;for(const B of r){const oe=B.data.isInverted?B.data.target:B.data.source;oe&&!ce.has(oe)&&ce.set(oe,B.data)}for(const B of r){if(B.data.connection)continue;const oe=B.data.isInverted?B.data.target:B.data.source,$e=B.data.isInverted?B.data.source:B.data.target;$e.startsWith(`${oe}.`)&&(ce.set(oe,B.data),ce.set($e,B.data))}return ce},[r]),Fe=j.useMemo(()=>{const ce={...i_,...b.customViews};return e.filter(B=>{var oe;return(oe=B.data)==null?void 0:oe.id}).map(B=>{var xe,Ze,Qe,Ke,vt,It;const oe=qe.has(B.data.id)&&!B.data.parent,$e=oe?B.data.label??B.data.headerTitle??"Container":void 0,U=oe?ce.parentContainer:ce[B.data.type]||ce.text,ge=Je.get(B.data.id),Ie={...B,isInverted:((xe=B.data.config)==null?void 0:xe.isInverted)??(ge==null?void 0:ge.isInverted),isParent:oe,containerStyle:oe?Q(B.data.id):void 0};return{id:B.data.id,collapsed:(Ze=B.data.config)==null?void 0:Ze.collapsed,parent:B.data.parent,acceptsChildren:!!((Qe=B.data.config)!=null&&Qe.parentContainer)||qe.has(B.data.id),label:$e,animated:!!B.data.isNodeAnimated,animationVariant:B.data.nodeAnimationVariant,hasCollapseControl:((Ke=B.data.config)==null?void 0:Ke.collapsed)!==void 0,animationColor:Pe(((vt=B.data.viewProps)==null?void 0:vt.borderColor)||t),animationWidth:In((It=B.data.viewProps)==null?void 0:It.borderWidth,8),element:j.createElement(U,{...Ie,key:`${B.data.id}-${t}`}),fillElement:k.has(B.data.id)?void 0:j.createElement(U,{...Ie,data:{...B.data,viewProps:{...B.data.viewProps,borderRadius:0}},containerStyle:Ie.containerStyle?{...Ie.containerStyle,borderRadius:0}:void 0,key:`${B.data.id}-${t}`})}})},[e,qe,Je,t,b.customViews,Q,k]),ct=j.useMemo(()=>ye?300:e.length>50?150:e.length>20?100:50,[e.length,ye]),De=j.useRef(b);De.current=b;const rt=j.useRef(E);rt.current=E;const ft=j.useRef(I);ft.current=I;const Oe=j.useRef(v);Oe.current=v;const Xe=j.useRef(w);Xe.current=w;const nt=j.useRef(P);nt.current=P;const lt=j.useRef(J);lt.current=J;const zt=j.useRef(ve);zt.current=ve;const kt=j.useRef(new Map);j.useEffect(()=>{var oe,$e;const ce=new Map([...ve].filter(([,U])=>J.has(U.data.source)&&J.has(U.data.target))),B=kt.current;kt.current=ce;for(const[U,ge]of B)ce.has(U)||(Xe.current===U&&(C(null),(oe=g.onEdgeDeselect)==null||oe.call(g)),($e=g.onEdgeRemove)==null||$e.call(g,U,ge.data))},[ve,J,g,C]),j.useEffect(()=>{const ce=W.current;if(!ie||!ce)return;let B=null,oe=null,$e=0,U=0,ge=0,Ie=0,xe=0;const Ze=Qe=>{var It;if(De.current.readOnly||De.current.minZoom===De.current.maxZoom&&De.current.minZoom!==void 0&&((It=ce.parentElement)!=null&&It.closest(".flow-sdk-canvas")))return;const Ke=ce.ownerDocument.fullscreenElement;if(Ke&&Ke!==ce&&ce.contains(Ke)&&Qe.target instanceof Node&&Ke.contains(Qe.target))return;Qe.preventDefault(),Qe.stopPropagation(),rt.current||Qe.metaKey||Qe.ctrlKey?(ge+=Qe.deltaY,Ie=Qe.clientX,xe=Qe.clientY,oe===null&&(oe=requestAnimationFrame(()=>{oe=null;const Jt=De.current,mt=ie.zoom(),pt=ge;ge=0;let xt=mt-pt*.05/100;xt=Math.max(Jt.minZoom??.01,Math.min(Jt.maxZoom??1.5,xt));const Tt=ce.getBoundingClientRect();ie.zoomAt(xt,{x:Ie-Tt.left,y:xe-Tt.top})}))):($e+=Qe.deltaX,U+=Qe.deltaY,B===null&&(B=requestAnimationFrame(()=>{B=null;const Jt=ie.pan(),mt=ie.zoom(),pt=.35,xt=$e,Tt=U;$e=0,U=0,ie.pan({x:Jt.x+-xt*pt/mt,y:Jt.y+-Tt*pt/mt})})))};return ce.addEventListener("wheel",Ze,{passive:!1}),()=>{ce.removeEventListener("wheel",Ze),B!==null&&cancelAnimationFrame(B),oe!==null&&cancelAnimationFrame(oe)}},[ie]),j.useEffect(()=>{if(b.disableKeyboardShortcuts)return;const ce=B=>{var $e,U,ge,Ie;if(De.current.readOnly)return;const oe=B.target;if(!(oe.tagName==="INPUT"||oe.tagName==="TEXTAREA"||oe.isContentEditable)){if((B.key==="z"||B.key==="Z")&&O(!rt.current),(B.key==="m"||B.key==="M")&&A(!P),(B.key==="d"||B.key==="D")&&T(!M),(B.key==="v"||B.key==="V")&&!B.repeat&&!B.metaKey&&!B.ctrlKey&&!B.altKey&&oe.tagName!=="SELECT"&&$(!N),(B.key==="Delete"||B.key==="Backspace")&&Xe.current){B.preventDefault();const xe=Xe.current;(U=g.onEdgeDelete)==null||U.call(g,xe,(($e=zt.current.get(xe))==null?void 0:$e.data)??{id:xe}),C(null);return}if((B.key==="Delete"||B.key==="Backspace")&&Oe.current.length>0){B.preventDefault();const xe=Oe.current.filter(Ze=>Ze!=="root");if(xe.length===0)return;for(const Ze of xe){const Qe=(ge=lt.current.get(Ze))==null?void 0:ge.data;(Ie=g.onNodeDelete)==null||Ie.call(g,Ze,Qe||{})}x([])}}};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[P,M,N,$,O,A,T,b.disableKeyboardShortcuts,g,x,C]);const et=j.useCallback(ce=>{var B;y.current=ce,ae(ce),(B=g.onInit)==null||B.call(g,ce)},[y,g]),We=j.useCallback(ce=>{var B;return(B=g.onViewportChange)==null?void 0:B.call(g,ce)},[g]),Ht=j.useCallback(ce=>{var oe,$e,U;const B=((oe=zt.current.get(ce))==null?void 0:oe.data)??{id:ce};if(Xe.current===ce&&nt.current){C(null),($e=g.onEdgeDeselect)==null||$e.call(g);return}Oe.current.length&&x([]),C(ce),(U=g.onEdgeSelect)==null||U.call(g,ce,B)},[g,C,x]),dt=j.useCallback(()=>{var ce,B,oe,$e,U;if(a(b.bottomBarCollapsed??(Oe.current.length>0||!!Xe.current||!s)),(ce=g.onBackgroundClick)==null||ce.call(g),!De.current.readOnly){const ge=new Set;for(const Ie of Oe.current){let xe=lt.current.get(Ie);for(;xe&&!ge.has(xe.data.id);)ge.add(xe.data.id),qe.has(xe.data.id)&&((B=xe.data.config)==null?void 0:B.collapsed)!==!0&&((oe=g.onNodeCollapse)==null||oe.call(g,xe.data.id,!0)),xe=xe.data.parent?lt.current.get(xe.data.parent):void 0}}Oe.current.length&&(x([]),($e=g.onNodeDeselect)==null||$e.call(g)),Xe.current&&(C(null),(U=g.onEdgeDeselect)==null||U.call(g))},[g,x,C,a,s,b.bottomBarCollapsed,qe]),tr=j.useCallback(ce=>{var $e,U;const B=Oe.current,oe=ce.filter(ge=>!B.includes(ge));if(oe.length){x([...B,...oe]);for(const ge of oe)(U=g.onNodeSelect)==null||U.call(g,ge,(($e=lt.current.get(ge))==null?void 0:$e.data)??{id:ge})}},[g,x]),ar=j.useCallback((ce,B)=>{var oe,$e;x([ce]),($e=g.onNodeSelect)==null||$e.call(g,ce,((oe=lt.current.get(ce))==null?void 0:oe.data)??{id:ce},B)},[g,x]),Bt=j.useRef(null),Dt=j.useCallback((ce,B,oe)=>{var $e;Bt.current={source:ce,target:B,edgeIds:new Set(zt.current.keys())};try{($e=g.onEdgeCreate)==null||$e.call(g,ce,B,oe)}catch(U){throw Bt.current=null,U}},[g]),Kt=j.useCallback((ce,B,oe,$e=!1)=>{var U,ge;if(re.current={sourceId:ce,nodeIds:new Set(lt.current.keys()),reverse:$e},!(u==="properties"&&((U=g.onNodeCreateRequest)==null?void 0:U.call(g,{sourceNodeId:ce,position:B,sourceProperty:oe,reverse:$e}))===!0)){if(oe!==void 0||$e){re.current=null;return}(ge=g.onNodeCreate)==null||ge.call(g,{type:"text",sourceNodeId:ce,position:B,isArrayMode:ft.current})}},[g,u]),rr=!b.readOnly&&N&&b.edgeHandles!==!1,$r=i==="transparent"?"none":i;return f.jsx(a_,{pattern:$r,backgroundColor:le,children:f.jsx(V.Box,{ref:W,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:f.jsx(Bj,{nodes:Fe,edges:Ae,direction:H,nodeAlignment:d,onContainerCollapse:ce=>{var B,oe;(B=g.onNodeCollapse)==null||B.call(g,ce,!0),(oe=g.onNodeViewToggle)==null||oe.call(g,ce)},selectedNodeIds:v,edgeMode:u,compactPropertyLayout:h,edgeType:b.edgeType,edgeRadius:o,customEdgeTypes:b.customEdgeTypes,edgeReveal:b.disableAnimations?void 0:b.edgeReveal,rankSep:L,edgeSep:be,nodeGridSpacing:b.nodeGridSpacing,nodeGridConnections:b.nodeGridConnections,initialNodeGrid:b.nodeGrid,spacingFactor:z,compactSpacingScale:n,layoutDebounce:ct,isPerformanceMode:ye,minZoom:b.minZoom??.01,maxZoom:b.maxZoom??1.5,initialViewport:Y,fitOnInit:!b.initialViewport&&!((ze=b.nodeGrid)!=null&&ze.enabled&&b.nodeGrid.options.fill),readOnly:!!b.readOnly,containerStyle:Q,lineColor:c?fe:pe,drawMode:rr,drawHandles:!b.readOnly&&b.edgeHandles!==!1,dragMode:M,multiSelect:!!P,onInit:et,onLayoutComplete:ce=>{var ge;(ge=g.onLayoutComplete)==null||ge.call(g,ce);const B=Bt.current;B&&(!lt.current.has(B.source)||!lt.current.has(B.target)?Bt.current=null:r.some(({data:Ie})=>Ie.source===B.source&&Ie.target===B.target&&!B.edgeIds.has(Ie.id))&&ce.getNodeBox(B.source)&&ce.getNodeBox(B.target)&&(Bt.current=null,ce.focusConnections(B.source)));const oe=re.current;if(!oe)return;if(!lt.current.has(oe.sourceId)){re.current=null;return}const U=e.filter(Ie=>!oe.nodeIds.has(Ie.data.id)).filter(Ie=>r.some(({data:xe})=>xe.source===oe.sourceId&&xe.target===Ie.data.id||xe.target===oe.sourceId&&xe.source===Ie.data.id));!U.length||U.some(Ie=>!ce.getNodeBox(Ie.data.id))||(re.current=null,ce.focusBranch(oe.reverse?U[0].data.id:oe.sourceId))},onNodeGridModeChange:_,onNodeGridZoomOut:g.onNodeGridZoomOut,onNodeGridDrop:g.onNodeGridDrop,onNodeParentChange:g.onNodeParentChange,animateViewport:b.animateViewport,disableAnimations:b.disableAnimations,onViewportChange:We,onBackgroundTap:dt,onBoxSelect:tr,onEdgeSelect:Ht,onContainerSelect:ar,onEdgeDraw:Dt,onDrawIntoSpace:Kt})})})},ox=j.memo(c_),l_=".flow-sdk-canvas{position:relative;width:100%;height:100%;overflow:clip;user-select:none;-webkit-user-select:none;touch-action:none}.flow-sdk-svg{position:absolute;top:0;left:0;width:100%;height:100%;overflow:visible;display:block}.flow-sdk-nodes{position:absolute;top:0;left:0;transform-origin:0 0;pointer-events:none;will-change:transform;backface-visibility:hidden;z-index:10}.flow-sdk-node{position:absolute;top:0;left:0;transform-origin:0 0;pointer-events:auto;will-change:transform;backface-visibility:hidden;z-index:10}.flow-sdk-node input,.flow-sdk-node textarea{pointer-events:auto;user-select:text;-webkit-user-select:text;cursor:text}.flow-sdk-edge-hit{fill:none;stroke:transparent;stroke-width:24px;vector-effect:non-scaling-stroke;pointer-events:stroke;cursor:pointer}.flow-sdk-container{cursor:pointer}.flow-sdk-edge-anim{animation:flow-sdk-dash .5s linear infinite}.flow-sdk-edge-anim-rev{animation-direction:reverse}@keyframes flow-sdk-dash{to{stroke-dashoffset:-50}}.flow-sdk-draw{cursor:crosshair}.flow-sdk-draw .flow-sdk-node,.flow-sdk-draw .flow-sdk-node input,.flow-sdk-draw .flow-sdk-node textarea,.flow-sdk-draw .flow-sdk-edge,.flow-sdk-draw .flow-sdk-container{pointer-events:none}.flow-sdk-perf.flow-sdk-busy .flow-sdk-edges{display:none}.flow-sdk-box{position:absolute;border:1px solid rgba(170,170,170,.9);background:rgba(221,221,221,.25);pointer-events:none;z-index:20}";let Sm=!1;function d_(){if(Sm||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=l_+".flow-sdk-canvas[data-node-grid] .flow-sdk-node,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *::before,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *::after{animation:none!important;transition:none!important}.flow-sdk-node[data-grid-fill] [data-flow-icon-label]{--flow-grid-caption-color:var(--flow-grid-on-surface-color)}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]{border:0;outline:none;box-shadow:none}.flow-sdk-node[data-grid-fill]{box-sizing:border-box}.flow-sdk-node[data-grid-fill] :not(svg):has([data-flow-node-surface]),.flow-sdk-node[data-grid-fill]>:not(svg):not(button){width:100%;height:100%;min-width:0;max-width:none}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]{width:100%;height:100%;min-width:0;max-width:none;box-sizing:border-box;overflow:hidden}.flow-sdk-node[data-grid-fill] [data-flow-icon-label]{gap:0}.flow-sdk-node[data-grid-fill] [data-flow-icon-caption]{position:absolute;bottom:12px;left:12px;width:calc(100% - 24px);max-height:40%;overflow:hidden}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]>svg{max-width:45%;max-height:55%}.flow-sdk-node[data-grid-fill] p{font-size:var(--flow-grid-font);white-space:normal;overflow-wrap:anywhere}.flow-sdk-canvas[data-node-grid]:not([data-grid-connections]) .flow-sdk-property-port,.flow-sdk-canvas[data-node-grid]:not([data-grid-connections]) .flow-sdk-handle,.flow-sdk-canvas[data-node-grid] [data-flow-collapse-control]{display:none}.flow-sdk-node[data-grid-draggable] :not(button):not(input):not(textarea):not(select):not(a){cursor:inherit}"+$b+Lw+$w+".flow-sdk-handle{position:absolute;left:-36px;top:50%;transform:translateY(-50%);width:36px;height:36px;display:grid;place-items:center;border:2px solid currentColor;border-radius:50%;background:white;cursor:crosshair;opacity:0;pointer-events:none}.flow-sdk-node:hover>.flow-sdk-handle,.flow-sdk-handle:focus-visible{opacity:1;pointer-events:auto}.flow-sdk-draw .flow-sdk-node *,.flow-sdk-draw .flow-sdk-edge *,.flow-sdk-draw .flow-sdk-container *,.flow-sdk-ghost *{pointer-events:none}",document.head.appendChild(e),e.textContent+=".flow-sdk-draw .flow-sdk-node{pointer-events:auto}.flow-sdk-draw .flow-sdk-node>.flow-sdk-handle{opacity:0;pointer-events:none}.flow-sdk-draw .flow-sdk-node:hover>.flow-sdk-handle,.flow-sdk-draw .flow-sdk-node>.flow-sdk-handle:focus-visible{opacity:1;pointer-events:auto}",e.textContent+='.flow-sdk-property-port{position:absolute;transform:translateY(-50%);width:32px;height:32px;margin:0;padding:0;border:3px solid currentColor;border-radius:50%;background:white;cursor:crosshair;pointer-events:auto;z-index:20}.flow-sdk-property-port[data-port-role="source"]{background:currentColor}.flow-sdk-property-port:hover{outline:3px solid currentColor;outline-offset:3px}.flow-sdk-draw .flow-sdk-node .flow-sdk-property-port{pointer-events:auto}',Sm=!0}function u_({loading:e=!1,loader:r,...t}){var c,l;const[n,o]=j.useState(null),i=j.useMemo(()=>!!(n!=null&&n.json)&&!!t.json&&Tw(n.json,t.json),[n==null?void 0:n.json,t.json]),s=n===null||n.json!==t.json&&!i,a=e||s;return j.useEffect(()=>{!e&&i&&(n==null?void 0:n.json)!==t.json&&o(t)},[e,i,n==null?void 0:n.json,t.json]),j.useEffect(()=>{if(e||!s)return;let d;const u=requestAnimationFrame(()=>{d=requestAnimationFrame(()=>o(t))});return()=>{cancelAnimationFrame(u),d!==void 0&&cancelAnimationFrame(d)}},[e,s,t.json]),f.jsxs(V.Box,{className:t.className,style:t.style,width:"100%",height:"100%",position:"relative","aria-busy":a,children:[f.jsx("div",{style:{width:"100%",height:"100%"},ref:d=>{var h;const u=(d==null?void 0:d.contains(document.activeElement))&&((h=document.activeElement)==null?void 0:h.matches("input, textarea, [contenteditable=true]"));a&&(e||!u)?d==null||d.setAttribute("inert",""):d==null||d.removeAttribute("inert")},children:n&&f.jsx(f_,{...s?n:t,children:t.children,config:t.config,className:void 0,style:void 0})}),a&&r!==null&&f.jsx(V.Box,{"data-flow-loader":"",role:"status","aria-label":"Loading diagram",position:"absolute",inset:0,zIndex:1e3,display:"grid",placeItems:"center",background:((c=t.config)==null?void 0:c.colorMode)==="dark"?"gray.800":"gray.100",color:((l=t.config)==null?void 0:l.colorMode)==="dark"?"whiteAlpha.800":"blackAlpha.800",children:r===void 0?f.jsx("span",{children:"Loading diagram..."}):r})]})}function f_({title:e="untitled",json:r,forms:t,nodes:n,edges:o,config:i={},callbacks:s={},className:a,style:c,showBottomBar:l=!0,children:d}){d_();const[u,h]=j.useState(),[p,m]=j.useState(!1),y=i.formSchema??u,g=j.useMemo(()=>r&&t?pb(r,t.state):r,[r,t==null?void 0:t.state]),b=i.direction==="C",v=j.useMemo(()=>{let P,A;return M=>(A=P&&A?Ow(P,M,A)??hd(M,{title:e,isCenter:b}):hd(M,{title:e,isCenter:b}),P=M,A)},[e,b]),x=j.useMemo(()=>g?v(g):null,[g,v]),w=j.useMemo(()=>t!=null&&t.structured&&!p&&y?gb(t.state,t.bindings,y,(x==null?void 0:x.nodes)??n??[]):void 0,[t==null?void 0:t.structured,p,t==null?void 0:t.state,t==null?void 0:t.bindings,y,x,n]),C=(w==null?void 0:w.schema)??y,S=(w==null?void 0:w.bindings)??(t==null?void 0:t.bindings),_=j.useMemo(()=>[...(x==null?void 0:x.nodes)??n??[],...(w==null?void 0:w.nodes)??[]].map(A=>{var ie,ae,re,ye;const M=r?(ie=Le(r,A.data.id))==null?void 0:ie.$view:(ae=A.data.config)==null?void 0:ae.typeView,T=M&&wd.includes(M)?M:void 0,N=T?T==="icon-label":(re=A.data.config)==null?void 0:re.labelBelow,$=T==="object"?"objectView":T==="text"?"text":N?"arrayView":A.data.type,I=C&&(t?$n(S,A.data.id,C):r&&Xr(r,A.data.id,C)),W=(((ye=A.data.config)==null?void 0:ye.ports)??[]).map(be=>({...be}));if(w&&I){const be=i.direction==="RL"?{input:"right",output:"left",config:"bottom",error:"top"}:i.direction==="TB"?{input:"top",output:"bottom",config:"right",error:"left"}:i.direction==="BT"?{input:"bottom",output:"top",config:"left",error:"right"}:{input:"left",output:"right",config:"top",error:"bottom"};for(const[L,z]of Object.entries(I.type.ports??{})){const G=`${z.kind}:${L}`,D=W.find(se=>se.id===G);D?D.label===void 0&&z.label!==void 0&&(D.label=z.label):W.push({id:G,...z.label!==void 0?{label:z.label}:{},role:z.kind==="input"||z.kind==="config"?"target":"source",side:be[z.kind],...z.kind==="config"?{placement:"config"}:{}})}for(const L of W){const z=W.filter(G=>G.side===L.side);L.position=(z.indexOf(L)+1)/(z.length+1)}}return I||N||T?{...A,data:{...A.data,type:$,...t?{description:Object.fromEntries(Object.entries(A.data.description??{}).filter(([be])=>!be.startsWith("$")&&!(w!=null&&w.slots.has(gn(A.data.id,be)))))}:{},config:{...A.data.config,...w&&I?{ports:W}:{},...I?{form:!0}:{},...T?{typeView:T,labelBelow:!!N}:N?{labelBelow:!0}:{}}}}:A}),[x,n,r,C,S,w,i.direction]),k=j.useMemo(()=>[...(x==null?void 0:x.edges)??o??[],...(w==null?void 0:w.edges)??[]],[x==null?void 0:x.edges,o,w==null?void 0:w.edges]),E=j.useMemo(()=>{const P=r&&x?Nb(r,x.edges,s,s.onJsonChange,y):{...s};if(w){const A=new Set([...w.nodes.map(M=>M.data.id),...w.edges.map(M=>M.data.id)]);for(const M of Object.keys(P)){if(!/^on(?:Node|Edge).*(?:Change|Collapse)$/.test(M))continue;const T=P[M];P[M]=(N,...$)=>{if(!A.has(N))return T==null?void 0:T(N,...$)}}}return{...P,onAllNodesIconLabelChange:A=>{var M;m(A),(M=P.onAllNodesIconLabelChange)==null||M.call(P,A)}}},[r,x,s,y,w]),O=j.useMemo(()=>{if(!t)return E;let P=t.state;const A=T=>{if(i.readOnly||i.editable===!1)return;const N=t.onStateChange??t.onChange;if(!N)return;const $=ww(P,T,s.onFormChange);$!==P&&(P=$,N($,{...T,data:$}))},M=(T,N,$)=>{var W;const I=r&&((W=Le(r,T))==null?void 0:W[N]);return!I||typeof I.$state!="string"?!1:(A({address:I.$state,nodeAddress:T,previousValue:Le(P,I.$state),value:$,data:P}),!0)};return{...E,onFormChange:A,onNodeCreateRequest:T=>{var I,W;const N=(I=T.sourceProperty)!=null&&I.startsWith("config:")?T.sourceProperty.slice(7):void 0,$=N!==void 0&&(w==null?void 0:w.slots.get(gn(T.sourceNodeId,N)));return $?($.present||A({data:P,nodeAddress:$.address.split(".").slice(0,-1).join("."),address:$.address,value:yn($.type),previousValue:void 0}),!0):((W=E.onNodeCreateRequest)==null?void 0:W.call(E,T))??!1},onNodeDelete:(T,N)=>{var re,ye;if(!(w!=null&&w.nodes.some(be=>be.data.id===T)))return(re=E.onNodeDelete)==null?void 0:re.call(E,T,N);const $=w&&[...w.slots.values()].find(be=>be.nodeId===T);if(!$)return(ye=E.onNodeDelete)==null?void 0:ye.call(E,T,N);const I=$.address.split("."),W=I.pop(),ie=I.join("."),ae=Le(P,ie);A(Array.isArray(ae)?{data:P,nodeAddress:ie,address:ie,previousValue:ae,value:ae.filter((be,L)=>String(L)!==W)}:{data:P,nodeAddress:ie,address:$.address,previousValue:Le(P,$.address),value:void 0})},onEdgeCreate:(T,N,$)=>{var ie,ae;const I=((ie=$==null?void 0:$.targetProperty)==null?void 0:ie.startsWith("config:"))&&(w==null?void 0:w.slots.get(gn(N,$.targetProperty.slice(7)))),W=w==null?void 0:w.containers.get(T);if(I&&W&&($==null?void 0:$.sourceProperty)==="output:resource"){const re=jw(P,W,I);re!==void 0&&A({data:P,nodeAddress:I.address.split(".").slice(0,-1).join("."),address:I.address,previousValue:Le(P,I.address),value:re});return}I||w!=null&&w.nodes.some(re=>re.data.id===T||re.data.id===N)||(ae=E.onEdgeCreate)==null||ae.call(E,T,N,$)},onEdgeDelete:(T,N)=>{var ye;const $=w==null?void 0:w.edges.find(be=>be.data.id===T);if(!$)return(ye=E.onEdgeDelete)==null?void 0:ye.call(E,T,N);const I=w.slots.get(gn($.data.target,$.data.targetProperty.slice(7))),W=I.address.split("."),ie=W.pop(),ae=W.join("."),re=Le(P,ae);A(Array.isArray(re)?{data:P,nodeAddress:ae,address:ae,previousValue:re,value:re.filter((be,L)=>String(L)!==ie)}:{data:P,nodeAddress:ae,address:I.address,previousValue:Le(P,I.address),value:void 0})},onNodeContentChange:(T,N)=>{var $,I;M(T,"$content",N)?($=s.onNodeContentChange)==null||$.call(s,T,N):(I=E.onNodeContentChange)==null||I.call(E,T,N)},onNodeLabelChange:(T,N)=>{var $,I;M(T,"$label",N)?($=s.onNodeLabelChange)==null||$.call(s,T,N):(I=E.onNodeLabelChange)==null||I.call(E,T,N)}}},[E,t,r,s,w,i.readOnly,i.editable]);return f.jsx(Mt.Provider,{value:{data:(t==null?void 0:t.state)??r,viewData:r,bindings:S,references:t==null?void 0:t.references,structured:w,renderForm:t==null?void 0:t.renderForm,editable:t?!!(t.onStateChange??t.onChange):!!s.onJsonChange,schema:C,setSchema:P=>{var A;h(P),(A=s.onFormSchemaChange)==null||A.call(s,P)},callbacks:O},children:f.jsx(Mm,{config:w?{...i,formSchema:C}:i,callbacks:O,nodes:_,edges:k,children:f.jsxs(V.Box,{className:a,"data-flow-diagram":"","data-animations-disabled":i.disableAnimations||void 0,style:c,width:"100%",height:"100%",position:"relative",overflow:"hidden",css:{"&[data-animations-disabled], &[data-animations-disabled] *, &[data-animations-disabled] *::before, &[data-animations-disabled] *::after":{animation:"none !important",transition:"none !important"},"& input, & textarea, & select":{outline:"none !important",boxShadow:"none !important"}},children:[f.jsx(ox,{nodes:_,edges:k}),l&&f.jsx(Ab,{}),d]})})})}function h_(e){return xd(JSON.parse(e))}function xd(e){if(!e||typeof e!="object")throw new Error("Expected a JSON object or array.");const r=new Set,t=n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(!n||typeof n!="object"||r.has(n)||!Array.isArray(n)&&![Object.prototype,null].includes(Object.getPrototypeOf(n)))throw new Error("Document must contain only finite, acyclic JSON values.");r.add(n);for(const[o,i]of Object.entries(n)){if(["__proto__","prototype","constructor"].includes(o))throw new Error(`Unsafe document key: ${o}`);t(i)}r.delete(n)}};return t(e),structuredClone(e)}function p_(e){return{replaceJson(r){if(e.readOnly||!e.onJsonChange)throw new Error("JSON document is read-only.");const t=xd(r);return e.onJsonChange(t,{type:"documentReplace",address:"root"}),t},replaceState(r){if(e.readOnly||!e.onStateChange)throw new Error("Form state is read-only.");const t=xd(r);return e.onStateChange(t,{address:"root",nodeAddress:"root",previousValue:e.state,value:t,data:t}),t}}}function g_(e,r){const t=(n,o)=>{if(n===null||typeof n!="object")return typeof n==typeof o?n:void 0;if(!(!o||typeof o!="object"))return Array.isArray(n)?Array.isArray(o)?n.map((i,s)=>t(i,o[s])).filter(i=>i!==void 0):void 0:Object.fromEntries(Object.entries(n).flatMap(([i,s])=>{if(!Object.prototype.hasOwnProperty.call(o,i))return[];if(i==="$content"&&n.$contentFormat==="jsx"&&o.$contentFormat==="jsx"&&Array.isArray(s)&&Array.isArray(o[i]))return[[i,s.filter((c,l)=>JSON.stringify(c)===JSON.stringify(o[i][l]))]];if(i.startsWith("$")&&i!=="$")return JSON.stringify(s)===JSON.stringify(o[i])?[[i,s]]:[];const a=t(s,o[i]);return a===void 0?[]:[[i,a]]}))};return t(e,r)??{}}function eo(e){let r="",t=!1,n="",o;const i=()=>{clearTimeout(o),o=void 0},s=()=>{if(i(),!(t||!r.trim()))try{const c=e.parse(e.repair(r)),l=JSON.stringify(c);if(l===n)return;e.preview(c),n=l}catch{}},a=c=>{if(!t){if(new TextEncoder().encode(c).byteLength>(e.maxBytes??1024*1024))throw t=!0,i(),new Error("JSON stream exceeds the size limit.");r=c,o||(o=setTimeout(s,e.intervalMs??150))}};return{snapshot:a,append(c){a(r+c)},flush:s,finish(){if(t)throw new Error("JSON stream is closed.");t=!0,i();const c=e.parse(r);return e.commit(c),c},cancel(){t=!0,i(),r=""}}}function y_(e){const{source:r}=e,t=e.tickMs??50,n=e.durationMs??8e3;if(!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0)throw new Error("Playback timing must be positive.");if(new TextEncoder().encode(r).byteLength>(e.maxBytes??1024*1024))throw new Error("JSON stream exceeds the size limit.");e.parse(r);let o=eo(e),i=0,s=!1,a=!1,c;const l=Math.max(1,Math.ceil(r.length*t/n)),d=()=>e.onChange({position:i,total:r.length,playing:s}),u=()=>{clearTimeout(c),c=void 0},h=(y=!1)=>{o.snapshot(r.slice(0,i)),i===r.length?(s=!1,u(),o.finish()):y&&o.flush()},p=y=>{s=!1,u(),o.cancel(),d(),e.onError(y)},m=()=>{if(c=void 0,!(!s||a)){i=Math.min(r.length,i+l);try{h()}catch(y){p(y);return}d(),s&&(c=setTimeout(m,t))}};return{play(){a||s||(i===r.length&&(o.cancel(),o=eo(e),i=0),s=!0,d(),c=setTimeout(m,t))},pause(){a||(s=!1,u(),o.flush(),d())},seek(y){if(!a){if(!Number.isFinite(y))throw new Error("Playback position must be finite.");u(),i=Math.max(0,Math.min(r.length,Math.round(y))),o.cancel(),o=eo(e);try{h(!0)}catch(g){p(g);return}d(),s&&(c=setTimeout(m,t))}},dispose(){a=!0,s=!1,u(),o.cancel()}}}function m_({nodeAddress:e,expanded:r=!1}){var l;const{data:t,schema:n,bindings:o}=j.useContext(Mt),{colorText:i,background:s}=st();if((l=o==null?void 0:o[e])!=null&&l.portResources)return null;const a=o&&$n(o,e,n);if(!t||!a)return null;const c=Le(t,a.address);return!c||typeof c!="object"?null:f.jsx("div",{"data-flow-config-summary":"",style:{width:"100%",minWidth:0,color:Pe(i),background:Pe(s),fontSize:24,lineHeight:1.4,textTransform:"none"},children:Object.keys(a.type.properties).map(d=>{const u=a.fields[d]??{};if(!ho(u.$visibleWhen,t))return null;const h=c[d],p=h==null?"":typeof h=="object"?JSON.stringify(h):String(h);return f.jsxs("div",{"data-flow-property":d,style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1fr)",gap:12,padding:"10px 16px",borderTop:"1px solid color-mix(in srgb, currentColor 12%, transparent)"},children:[f.jsx("span",{style:{overflowWrap:"anywhere"},children:$t(u.$label??d)}),f.jsx("span",{title:p,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:r?"pre-wrap":"nowrap",overflowWrap:r?"anywhere":void 0},children:p})]},d)})})}exports.BottomBar=Ab;exports.CollapseAllToggle=eb;exports.CompactPropertyLayoutToggle=tb;exports.ConnectionsOnlyToggle=Iw;exports.DEFAULT_PALETTE=no;exports.DiagramAppearanceControls=rb;exports.DynamicIcon=Qt;exports.EdgeTools=wb;exports.EditableLabel=Jr;exports.ErrorToast=kb;exports.FlowDiagram=u_;exports.FlowDiagramProvider=Mm;exports.FlowPort=Yv;exports.FlowView=ox;exports.FormDocumentContext=Mt;exports.GridAdjustmentToggle=nb;exports.LIGHT_BLACK=Zr;exports.LoadingBorder=Xv;exports.NODE_TYPE_VIEWS=wd;exports.NodeBorderRadiusControl=Cb;exports.NodeConfigSummary=m_;exports.NodeForm=Od;exports.NodeFormPopover=su;exports.NodeIconPicker=Nd;exports.NodeTools=Sb;exports.NodeView=Vn;exports.SvgExportButton=Eb;exports.Swatches=Mr;exports.TEXT_PALETTE=vb;exports.ToolbarCloseButton=Yr;exports.ToolbarCommitInput=Dr;exports.ToolbarDivider=xn;exports.ToolbarIconButton=Ne;exports.ToolbarRangeInput=Sd;exports.ToolbarScrollContainer=$d;exports.ToolbarSelect=At;exports.ToolbarTooltip=Ue;exports.TooltipIconButton=vd;exports.WorkflowControls=qd;exports.addChild=Rd;exports.addConnection=Ad;exports.addTargetEdge=db;exports.addressToPath=Vt;exports.applyCollapsed=bw;exports.applyFormChange=po;exports.applyStateEdits=xw;exports.bindSqueedCallbacks=Nb;exports.compileSqueed=hd;exports.connectionIssue=Id;exports.contentObjTheme=Xt;exports.copySelection=Ld;exports.createFlowDiagram=Pr;exports.createFlowDocumentActions=p_;exports.createFormNode=Mb;exports.createJsonPlayback=y_;exports.createJsonStream=eo;exports.createWorkflowExecution=Sx;exports.downloadSvg=_b;exports.duplicateSelection=Ob;exports.exportSvg=jb;exports.formValueError=Wt;exports.getChakraColorHex=Pe;exports.getColorVariant=km;exports.getDarkerHexColor=to;exports.getInteractionSurface=gr;exports.getNode=Le;exports.getSelectionRoots=Tb;exports.isNodeVisible=Yt;exports.parseFlowDocument=h_;exports.parseJsonContract=Pd;exports.parseTypeScriptContract=fb;exports.parseTypeScriptForm=Md;exports.projectJsonPlaybackPreview=g_;exports.readFormSchema=Td;exports.readWorkflowContract=hb;exports.removeEdge=ub;exports.removeNode=lb;exports.reparentNode=Ib;exports.resolveEdgeOwner=Rr;exports.resolveStateView=pb;exports.setCollapsed=kd;exports.setEdgeProp=ur;exports.setEdgeStyle=cb;exports.setNodeProp=St;exports.updateNode=_t;exports.useCustomColors=st;exports.useEdgeProximity=Em;exports.useFlowData=vr;exports.useFlowDiagramContext=He;exports.useNodeViewActions=Wn;exports.useStopPropagation=au;exports.useThemeContentColors=Nn;exports.validateGridAdjustment=Hv;
|
|
283
|
+
@media(prefers-reduced-motion:reduce){[data-flow-loading-border][data-flow-loading-border] .flow-sdk-node-border-animation{animation:none!important}}`;function Xv({active:e=!0,label:r="Loading content",radius:t}){const{config:n,themeColor:o}=He(),{colorText:i}=st(),s=j.useRef(null),[a,c]=j.useState({width:0,height:0,radius:0});if(j.useLayoutEffect(()=>{const u=s.current;if(!e||!u)return;const h=()=>{const m=u.parentElement,y={width:u.clientWidth,height:u.clientHeight,radius:t??(m&&parseFloat(getComputedStyle(m).borderTopLeftRadius)||0)};c(g=>g.width===y.width&&g.height===y.height&&g.radius===y.radius?g:y)},p=new ResizeObserver(h);return p.observe(u),h(),()=>p.disconnect()},[e,t]),!e)return null;const l=Pe(o||i),d={x:4,y:4,width:a.width-8,height:a.height-8,radius:Math.max(0,a.radius-4),color:l,strokeWidth:2};return f.jsxs("div",{ref:s,role:"status","aria-label":r,"data-flow-loading-border":"","data-motion-disabled":n.disableAnimations||void 0,style:{position:"absolute",inset:0,pointerEvents:"none",borderRadius:"inherit",overflow:"hidden",zIndex:2},children:[f.jsx("style",{children:Hj}),f.jsxs("svg",{width:"100%",height:"100%","aria-hidden":"true",style:{display:"block",pointerEvents:"none"},children:[f.jsx("g",{opacity:.5,style:{filter:"blur(3px)"},children:f.jsx(oo,{...d,strokeWidth:6})}),f.jsx(oo,{...d})]})]})}function Kj({content:e,format:r,onEdit:t}){var N;const{config:n,colorMode:o}=He(),{background:i,border:s,colorInactive:a}=st(),c=(N=n.customViews)==null?void 0:N.jsxContent,l=typeof e=="string"?e:JSON.stringify(e,null,2);let d,u;if(r==="jsx")try{const $=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray($)||$.some(I=>!I||typeof I!="object"||Array.isArray(I)||typeof I.type!="string"))throw new Error("JSX content must be an array of components with a type.");d=$}catch($){u=$ instanceof Error?$.message:"Invalid components array."}const h=j.useRef(null),p=j.useRef(null),m=j.useRef(null),y=j.useRef(!1),[g,b]=j.useState(!1),[v,x]=j.useState(""),w=!!t;j.useEffect(()=>{const $=()=>{var W;const I=document.fullscreenElement===p.current;b(I),y.current&&!I&&!document.fullscreenElement&&((W=m.current)==null||W.focus({preventScroll:!0})),y.current=I};return document.addEventListener("fullscreenchange",$),()=>document.removeEventListener("fullscreenchange",$)},[]);const C=async()=>{var $;x("");try{if(document.fullscreenElement===p.current)await document.exitFullscreen();else if(($=p.current)!=null&&$.requestFullscreen)await p.current.requestFullscreen();else throw new Error("Fullscreen is not supported in this browser.")}catch(I){x(I instanceof Error?I.message:"Unable to change fullscreen.")}},[S,_]=j.useState(),[k,E]=j.useState(),[O,P]=j.useState();j.useEffect(()=>{if(r==="jsx")return;let $=!1;return Promise.resolve().then(()=>require("./contentPreviewDocument-BsKd0dD4.cjs")).then(({contentPreviewDocument:I})=>I(l,r,w)).then(I=>{$||_({content:l,format:r,editable:w,document:I})},I=>{$||_({content:l,format:r,editable:w,error:I instanceof Error?I.message:String(I)})}),()=>{$=!0}},[l,r,w]),j.useEffect(()=>{if(!t)return;const $=async I=>{var W,ie;if(!(!((W=h.current)!=null&&W.contentWindow)||I.source!==h.current.contentWindow||((ie=I.data)==null?void 0:ie.type)!=="squeed:content-edit"))try{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()}catch(ae){x(ae instanceof Error?ae.message:"Unable to close fullscreen.")}};return window.addEventListener("message",$),()=>window.removeEventListener("message",$)},[t]);const A=(S==null?void 0:S.content)===l&&S.format===r&&S.editable===w?S:void 0,M=!!A&&A===O,T=r!=="jsx"&&!(A!=null&&A.error)&&!M&&(!A||k!==A);return f.jsxs("div",{"data-flow-content-preview":"",style:{width:"100%",height:360,fontSize:16,overflow:"auto"},children:[f.jsx("pre",{"data-flow-preview-source":"",style:{display:"none",whiteSpace:"pre-wrap"},children:l}),f.jsxs(V.Box,{ref:p,position:"relative",w:"100%",h:"100%","aria-busy":r!=="jsx"?T:void 0,bg:r==="jsx"&&o==="dark"?"gray.900":"white",onDoubleClick:$=>{r!=="jsx"||!t||$.defaultPrevented||$.target.closest('button, a, input, textarea, select, [contenteditable], [role="button"], [role="textbox"]')||($.stopPropagation(),(async()=>{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()})().catch(I=>x(String(I))))},onKeyDownCapture:$=>{$.key!=="Escape"||document.fullscreenElement!==p.current||($.preventDefault(),$.stopPropagation(),C())},css:{"&:fullscreen":{width:"100vw",height:"100dvh",maxWidth:"none",maxHeight:"none",padding:0},"&:hover > [data-flow-content-toolbar], &:focus-within > [data-flow-content-toolbar]":{opacity:1,pointerEvents:"auto"},"@media (hover: none)":{"& > [data-flow-content-toolbar]":{opacity:1,pointerEvents:"auto"}}},children:[f.jsx(V.Box,{role:"toolbar","aria-label":"Content controls","data-flow-content-toolbar":"",position:"absolute",top:"8px",right:"8px",zIndex:1,w:"max-content",maxW:"calc(100% - 16px)",opacity:g?1:0,pointerEvents:g?"auto":"none",children:f.jsx($d,{background:i,border:o==="dark"?s:"gray.300",children:f.jsxs(V.HStack,{px:"8px",gap:"8px",h:"100%",w:"max-content",css:{"& button > svg":{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",flexShrink:0}},children:[t&&f.jsx(Ne,{"data-flow-content-edit":"","aria-label":"Edit content source",title:"Edit content source",icon:f.jsx(Z.PiCode,{size:20}),size:"sm",variant:"plain",bg:"transparent",color:a,borderRadius:"30px",w:"32px",h:"32px",minW:"32px",p:0,onClick:$=>{$.stopPropagation(),(async()=>{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()})().catch(I=>x(String(I)))}}),f.jsx(Ne,{ref:m,"data-flow-fullscreen":"","aria-label":g?"Exit fullscreen":"Expand preview",title:g?"Exit fullscreen":"Expand preview","aria-expanded":g,icon:g?f.jsx(Z.PiArrowsIn,{size:20}):f.jsx(Z.PiArrowsOut,{size:20}),size:"sm",variant:"plain",bg:"transparent",color:a,borderRadius:"30px",w:"32px",h:"32px",minW:"32px",p:0,onClick:$=>{$.stopPropagation(),C()}})]})})}),v&&f.jsx(V.Box,{role:"alert",position:"absolute",bottom:0,insetInline:0,bg:"white",color:"red.700",fontSize:"14px",children:v}),r==="jsx"?u?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:u}):c&&d?f.jsx(c,{components:d,colorMode:o,fillHeight:!0}):f.jsx(V.Box,{role:"status",fontSize:"14px",children:"JSX content renderer is not available."}):A!=null&&A.error||M?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:(A==null?void 0:A.error)||"Content preview could not be loaded."}):A!=null&&A.document?f.jsx("iframe",{ref:h,title:`${r.toUpperCase()} content preview`,sandbox:w?"allow-scripts":"",allowFullScreen:!0,referrerPolicy:"no-referrer",srcDoc:A.document,onLoad:()=>E(A),onError:()=>P(A),style:{width:"100%",height:"100%",border:0,display:"block",background:"white",visibility:T?"hidden":"visible"}},A.document):null,f.jsx(Xv,{active:T,label:"Loading HTML content"})]})]})}const Cm=1.55;function Jj({nodeId:e,content:r,color:t,format:n="markdown"}){const{callbacks:o,config:i,readOnly:s,nodeGridOptions:a}=He(),c=!!i.editable&&!s,l=c&&!a,d=typeof r=="string"?r:JSON.stringify(r,null,2),[u,h]=j.useState(!1),[p,m]=j.useState(d),[y,g]=j.useState(""),[b,v]=j.useState(),x=j.useRef(null),w=j.useRef(!1),C=au(u);j.useLayoutEffect(()=>{const k=x.current;!u||!k||(k.style.height="auto",k.style.height=`${Math.max((b==null?void 0:b.height)??0,k.scrollHeight)}px`)},[p,u,b]),j.useEffect(()=>{var k,E;c?u&&(w.current=!1,(k=x.current)==null||k.focus({preventScroll:!0}),(E=x.current)==null||E.select()):h(!1)},[u,c]);const S=(k,E=!1)=>{!c||a&&!E||(v({width:k.offsetWidth,height:k.offsetHeight}),m(d),g(""),h(!0))},_=()=>{var E;if(w.current||!c)return;let k=p;if(n==="jsx")try{if(k=JSON.parse(p),!Array.isArray(k)||k.some(O=>!O||typeof O!="object"||Array.isArray(O)||typeof O.type!="string"))throw new Error("JSX content must be an array of components with a type.")}catch(O){g(O instanceof Error?O.message:"Invalid components array.");return}w.current=!0,p!==d&&((E=o.onNodeContentChange)==null||E.call(o,e,k)),h(!1)};return(!u||!c)&&n!=="markdown"?f.jsx(V.Box,{ref:C,w:"100%",position:"relative","data-flow-content":"",children:f.jsx(Kj,{content:r,format:n,onEdit:l?()=>{C.current&&S(C.current)}:void 0})}):!u||!c?f.jsx(V.Box,{"data-flow-content":"",color:t,opacity:r?void 0:.6,w:"100%",minH:"1.2em",whiteSpace:"normal",lineHeight:Cm,overflowWrap:"anywhere",css:{"& > :first-of-type":{marginTop:0},"& > :last-of-type":{marginBottom:0},"& h1, & h2, & h3, & h4, & h5, & h6":{fontWeight:700,lineHeight:1.2,margin:"1em 0 0.45em"},"& h1":{fontSize:"1.5em"},"& h2":{fontSize:"1.3em"},"& h3":{fontSize:"1.1em"},"& p":{margin:"0.65em 0",whiteSpace:"pre-wrap"},"& ul, & ol":{margin:"0.65em 0",paddingInlineStart:"1.6em"},"& ul":{listStyleType:"disc"},"& ol":{listStyleType:"decimal"},"& li":{display:"list-item",margin:"0.3em 0",paddingInlineStart:"0.15em"},"& li > ul, & li > ol":{margin:"0.25em 0"},"& li > p":{margin:0},"& a":{color:"inherit",textDecoration:"underline"},"& code":{fontFamily:"monospace",fontSize:"0.85em"},"& :not(pre) > code":{background:"color-mix(in srgb, currentColor 10%, transparent)",padding:"0.1em 0.25em",borderRadius:"0.2em"},"& pre":{margin:"0.75em 0",padding:"0.75em",background:"color-mix(in srgb, currentColor 8%, transparent)",border:0,borderRadius:"6px",maxWidth:"100%",overflowX:"auto",whiteSpace:"pre",overflowWrap:"normal",lineHeight:1.5},"& pre code":{background:"transparent",padding:0,whiteSpace:"inherit"},"& strong":{fontWeight:700},"& em":{fontStyle:"italic"},"& blockquote":{margin:"0.4em 0",borderInlineStart:"0.1em solid currentColor",paddingInlineStart:"0.6em"},"& table":{width:"100%",tableLayout:"fixed",borderCollapse:"collapse",margin:"0.4em 0"},"& th, & td":{border:"1px solid currentColor",padding:"0.2em 0.3em",textAlign:"left"},"& th":{fontWeight:700},"& img":{maxWidth:"100%",height:"auto"}},cursor:l?"text":void 0,tabIndex:l?0:void 0,outline:"none",_focusVisible:{outline:"none",boxShadow:"none"},onClick:k=>{!c||a&&!k.shiftKey||k.target instanceof Element&&k.target.closest("a, button, input")||(k.stopPropagation(),S(k.currentTarget,k.shiftKey))},onDoubleClick:k=>{k.stopPropagation(),S(k.currentTarget,k.shiftKey)},onKeyDown:k=>{c&&(!a||k.shiftKey)&&k.key==="Enter"&&k.target===k.currentTarget&&(k.preventDefault(),k.stopPropagation(),S(k.currentTarget,k.shiftKey))},children:f.jsx(Cx.default,{options:{forceBlock:!0,wrapper:j.Fragment,disableParsingRawHTML:!0,overrides:{a:{props:{target:"_blank",rel:"noopener noreferrer"}},img:{props:{loading:"lazy",referrerPolicy:"no-referrer"}}}},children:d||(i.editable&&!s?"Write your content here":"")})}):f.jsxs("div",{ref:C,style:{width:b==null?void 0:b.width,minHeight:b==null?void 0:b.height,maxWidth:"100%"},children:[f.jsx(V.Textarea,{ref:x,"aria-label":"Node content",placeholder:"Write your content here",value:p,"aria-invalid":!!y,onChange:k=>m(k.target.value),onBlur:_,onKeyDown:k=>{k.stopPropagation(),!k.nativeEvent.isComposing&&(k.key==="Enter"&&(k.ctrlKey||k.metaKey)&&(k.preventDefault(),_()),k.key==="Escape"&&(w.current=!0,h(!1)))},color:t,fontFamily:"inherit",fontSize:"inherit",lineHeight:Cm,overflowWrap:"anywhere",whiteSpace:"pre-wrap",rows:1,bg:"transparent",display:"block",style:{border:0,outline:"none",boxShadow:"none"},_focus:{border:0,outline:"none",boxShadow:"none"},_focusVisible:{border:0,outline:"none",boxShadow:"none"},p:0,w:"100%",h:"100%",minW:0,minH:0,resize:"none"}),y&&f.jsx(V.Box,{role:"alert",fontSize:"14px",color:"red.500",children:y})]})}const Zj=(e,r,t)=>{var h,p,m,y;const n=((h=e==null?void 0:e.viewProps)==null?void 0:h.bgColor)||r,[o]=n.split("."),i=Nn(n),s=((p=e==null?void 0:e.viewProps)==null?void 0:p.outline)===!0,a=n==="transparent"||s,c=t==="dark"?"gray.200":"gray.900",l=a?"transparent":n!=null&&n.startsWith("#")?Pe(n):Pe(i.bgColor),d=Pe(((m=e==null?void 0:e.viewProps)==null?void 0:m.textColor)||(a?c:i.textColor)),u=Pe(((y=e==null?void 0:e.viewProps)==null?void 0:y.borderColor)||(s?n==="transparent"?r:n:i.borderColor));return{...i,bgColor:a?"transparent":i.bgColor,highlightColor:a?"transparent":i.highlightColor,isTransparent:a,propertyColor:a?c:i.propertyColor,bg:n,wordBeforeDot:o,hexbgColor:l,hextextColor:d,hexborderColor:u}},Yj=(e,r=350)=>`${String(e).substring(0,r)}${String(e).length>r?"...":""}`,Xj=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,Qv=600,Qj=3,e_=e=>{const r=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(r*28+30,200)};function t_({headerTitle:e,hasContent:r,data:t,icon:n,colors:o,hasConfig:i,id:s,isActive:a,isHovered:c,isEditing:l,onSelect:d,onEditStart:u,onEditEnd:h,props:p,objVisible:m,setObjVisible:y,onShowNativeIcon:g}){var w,C;const{callbacks:b}=He(),v=p.onShowIcon??g,x=v?"Show icon":m?"Show content":"Show properties";return f.jsx(f.Fragment,{children:(e||r||((w=t.config)==null?void 0:w.form)||(a||c)&&g)&&f.jsxs(V.Flex,{justify:"flex-start",direction:"row",p:r||Object.entries(t.description||{}).length?8:20,borderBottomWidth:1,minWidth:"max-content !important",width:"100%",textTransform:"capitalize",align:"center",textOverflow:"ellipsis",alignItems:"center",fontWeight:"bold",color:o.propertyColor,bgColor:o.highlightColor,borderBottomColor:!i&&!r?"transparent":o.hexborderColor,children:[!!n&&f.jsx(V.Flex,{mr:6,alignItems:"center",flexShrink:0,children:f.jsx(Qt,{name:n,size:64,color:o.hextextColor},o.hextextColor)}),f.jsx(Jr,{nodeId:s,label:Xj(e),color:((C=t==null?void 0:t.viewProps)==null?void 0:C.textColor)||o.propertyColor,isEditing:l,onEditStart:u,onEditEnd:h}),(a||c)&&(r||v)&&f.jsx(V.Box,{ml:"auto",pl:6,flexShrink:0,"data-flow-content-toggle":"",children:f.jsx(Ue,{label:x,children:f.jsx(Ne,{"aria-label":x,icon:f.jsx(V.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:o.hextextColor,onClick:S=>{var _;S.stopPropagation(),a||d(S),v?v():y(!m),(_=b.onNodeViewToggle)==null||_.call(b,s)}})})})]})})}function r_({data:e,resourcePorts:r,inspecting:t,form:n,inspectionPorts:o,extraPorts:i,colors:s,direction:a,uniformKeyWidth:c}){const{edgeById:l}=vr(),d=new Set;for(const{data:u}of l.values())u.source===e.id&&u.sourceProperty!==void 0&&d.add(`source:${u.sourceProperty}`),u.target===e.id&&u.targetProperty!==void 0&&d.add(`target:${u.targetProperty}`);return f.jsx(V.Box,{children:Object.entries(e.description||{}).map(([u,h],p)=>{var M,T,N;const m=r&&Object.keys(r).find($=>$.slice($.indexOf(":")+1)===u),y=t&&((M=n==null?void 0:n.type.ports)==null?void 0:M[u]),g=m??(y?`${y.kind}:${u}`:u),b=o.find($=>$.id===g),v=m?"source":b==null?void 0:b.role,x=d.has(`source:${g}`),w=d.has(`target:${g}`),C=i.some($=>$.id===u),S=h===""&&(C||(v?d.has(`${v}:${g}`):x||w)),_=v??(x!==w?x?"source":"target":void 0),k=(b==null?void 0:b.side)??(_?_==="source"!=(a==="RL")?"right":"left":void 0),E=S&&k==="right"?"right":"left",O=(b==null?void 0:b.label)??(y==null?void 0:y.label)??(C?u.replace(/^(template|input|output|config|error):/,""):u),P=Xt(s.wordBeforeDot)[typeof h],A=Xt(s.wordBeforeDot).property;return f.jsxs(V.Box,{"data-flow-property":m&&(a==="TB"||a==="BT")?void 0:g,"data-flow-port-role":v,"data-flow-inspection-row":t?"":void 0,children:[f.jsxs(V.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[f.jsx(V.Flex,{justifyContent:"start",align:"center",background:s.highlightColor,width:S?"100%":`${c}px`,minWidth:`${c}px`,borderRightColor:s.hexborderColor,borderRightWidth:S?0:1,children:f.jsx(V.Text,{py:5,px:10,w:"100%",textAlign:E,whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((T=e==null?void 0:e.viewProps)==null?void 0:T.textColor)||(s.isTransparent?s.hextextColor:A),children:O})}),!S&&f.jsx(V.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:s.hexbgColor,w:Qv,maxH:200,children:f.jsx(V.Text,{overflow:"hidden",py:3,px:4,whiteSpace:"normal",textOverflow:"ellipsis",fontSize:"4xl",color:((N=e==null?void 0:e.viewProps)==null?void 0:N.textColor)||(s.isTransparent?s.hextextColor:P),fontWeight:400,children:Yj(h)})})]}),p!==Object.entries(e.description||{}).length-1&&f.jsx(V.Box,{borderTopWidth:1,my:0,borderColor:s.hexborderColor})]},u)})})}function n_(e){var x,w,C,S,_;const{themeColor:r,colorMode:t,direction:n}=He(),o=Wn(),i=o.getNodeViewMode(e.data.id)==="properties",s=k=>o.setNodeViewMode(e.data.id,k?"properties":"default"),a=!!e.onShowIcon||i||typeof((x=e.data.config)==null?void 0:x.content)!="string"&&!(((w=e.data.config)==null?void 0:w.contentFormat)==="jsx"&&Array.isArray((C=e.data.config)==null?void 0:C.content)),{bindings:c,data:l,schema:d}=j.useContext(Mt),u=(S=c==null?void 0:c[e.data.id])==null?void 0:S.portResources,h=c?$n(c,e.data.id,d):l&&d?Xr(l,e.data.id,d):void 0,p=h&&Le(l,"address"in h?h.address:e.data.id),m=p&&typeof p=="object"&&h?Object.fromEntries(Object.keys(h.type.properties).filter(k=>{var E;return Object.prototype.hasOwnProperty.call(p,k)&&ho((E=h.fields[k])==null?void 0:E.$visibleWhen,l)}).map(k=>[k,p[k]!==null&&typeof p[k]=="object"?JSON.stringify(p[k],null,2):p[k]===null?"null":p[k]])):{},y=u?Object.fromEntries(Object.entries(u).map(([k,E])=>{var O;return[k.slice(k.indexOf(":")+1),((O=Le(l,E))==null?void 0:O.name)??E.split(".").at(-1)]})):Object.keys(e.data.description??{}).length?e.data.description:m,g=a&&!u?((_=e.data.config)==null?void 0:_.ports)??[]:[],b=g.filter(k=>!Object.prototype.hasOwnProperty.call(y,k.id)&&!Object.entries((h==null?void 0:h.type.ports)??{}).some(([E,O])=>`${O.kind}:${E}`===k.id&&Object.prototype.hasOwnProperty.call(y,E))),v={...y,...Object.fromEntries(b.map(k=>[k.id,""]))};return{themeColor:r,colorMode:t,direction:n,objVisible:i,setObjVisible:s,inspecting:a,resourcePorts:u,form:h,description:v,inspectionPorts:g,extraPorts:b}}const du=e=>{var v,x,w,C,S,_;const{themeColor:r,colorMode:t,direction:n,objVisible:o,setObjVisible:i,inspecting:s,resourcePorts:a,form:c,description:l,inspectionPorts:d,extraPorts:u}=n_(e),h=Wn(),p=h.getNodeViewMode(e.data.id)==="icon-label",m=!e.onShowIcon&&(typeof((v=e.data.config)==null?void 0:v.content)=="string"||((x=e.data.config)==null?void 0:x.contentFormat)==="jsx"&&Array.isArray((w=e.data.config)==null?void 0:w.content)),y=j.useRef(p);p&&(y.current=!0),cu(e.data.id,m&&!((C=e.data.config)!=null&&C.parentContainer)&&h.allNodesIconLabel&&!p&&y.current,()=>h.setNodeViewMode(e.data.id,"icon-label"));const b=!e.onShowIcon&&!((S=e.data.config)!=null&&S.parentContainer)?()=>h.setNodeViewMode(e.data.id,"icon-label"):void 0;return!e.onShowIcon&&p?f.jsx(lu,{...e,data:{...e.data,label:e.data.label??e.data.headerTitle,config:{...e.data.config,labelBelow:!0,icon:((_=e.data.config)==null?void 0:_.icon)||"PiBracketsCurly"}},onExpand:()=>h.restoreNodeView(e.data.id)}):f.jsx(Vn,{...e,data:{...e.data,description:l},hoverLeaveDelay:m||e.onShowIcon||b?350:0,children:({id:k,data:E,isActive:O,isHovered:P,isEditing:A,onSelect:M,onEditStart:T,onEditEnd:N})=>{var L,z,G,D,se,X,le,ue,Ce,je;const $=Zj(E,r,t),I=E.label??E.headerTitle,W=Object.entries(E.description||{}).length>0,ie=e_(E.description),ae=(z=(L=e.data)==null?void 0:L.config)==null?void 0:z.icon,re=(D=(G=e.data)==null?void 0:G.config)==null?void 0:D.content,ye=((se=E==null?void 0:E.viewProps)==null?void 0:se.borderRadius)??"53px",be=Tn(E==null?void 0:E.viewProps,$.hexborderColor,O,Qj);return f.jsx(V.Flex,{justifyContent:"space-between",...E==null?void 0:E.viewProps,"data-flow-node-surface":"",direction:"column",p:0,borderRadius:ye,overflow:"hidden",alignItems:"center",style:{backgroundColor:$.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:"100%",minW:m||e.onShowIcon?ie+Qv+be.borderWidth*2:void 0,...be,children:f.jsxs(V.Flex,{width:"100%",direction:"column",borderRadius:ye,borderColor:$.hexborderColor,borderWidth:0,overflow:"hidden",children:[f.jsx(t_,{headerTitle:I,hasContent:m,data:E,icon:ae,colors:$,hasConfig:W,id:k,isActive:O,isHovered:P,isEditing:A,onSelect:M,onEditStart:T,onEditEnd:N,props:e,objVisible:o,setObjVisible:i,onShowNativeIcon:b}),m&&!o?f.jsx(V.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:$.highlightColor,p:["html","jsx"].includes((le=(X=e.data)==null?void 0:X.config)==null?void 0:le.contentFormat)?0:12,fontSize:"5xl",lineHeight:"normal",children:f.jsx(Jj,{nodeId:k,content:re,format:(Ce=(ue=e.data)==null?void 0:ue.config)==null?void 0:Ce.contentFormat,color:((je=E==null?void 0:E.viewProps)==null?void 0:je.textColor)||$.hextextColor})}):f.jsx(r_,{data:E,resourcePorts:a,inspecting:s,form:c,inspectionPorts:d,extraPorts:u,colors:$,direction:n,uniformKeyWidth:ie})]})})}})};du.displayName="NodeJsonObjectView";const ex=e=>{var h,p,m,y,g,b,v,x,w,C,S;const r=Wn(),[t,n]=j.useState(!1),o=r.getNodeViewMode(e.data.id)==="properties",i=_=>{n(_),r.setNodeViewMode(e.data.id,_?"properties":"default")},{callbacks:s,readOnly:a}=He(),c=(p=(h=e.data)==null?void 0:h.config)==null?void 0:p.parentContainer;cu(e.data.id,o&&((y=(m=e.data)==null?void 0:m.config)==null?void 0:y.labelBelow)&&!c,()=>i(!1));const l=c?"Show parent":"Show properties",d=c||((b=(g=e.data)==null?void 0:g.config)==null?void 0:b.form)||((w=(x=(v=e.data)==null?void 0:v.config)==null?void 0:x.ports)==null?void 0:w.length),u=d?()=>{var _;c?(_=s.onNodeCollapse)==null||_.call(s,e.data.id,!1):i(!0)}:void 0;return!c&&d&&o?f.jsx(du,{...e,editOnMount:t,onShowIcon:()=>i(!1)}):f.jsx(lu,{...e,onOpenView:u&&(c||(S=(C=e.data)==null?void 0:C.config)!=null&&S.labelBelow)?()=>{var _;u(),(_=s.onNodeViewToggle)==null||_.call(s,e.data.id)}:void 0,toggleLabel:l,toggleDisabled:c&&a,onExpand:u})};function o_(e){var b,v,x,w,C,S;const{config:r,callbacks:t,readOnly:n,selectedNodeIds:o,nodeRadiusPreviews:i,nodeViewModes:s,allNodesIconLabel:a}=He(),c=i[e.data.id]??((b=e.data.viewProps)==null?void 0:b.borderRadius),[l,d]=j.useState(!1),u=Wn(),{border:h,colorText:p}=st(),m=(v=r.customViews)==null?void 0:v.gridContent,y=(s[e.data.id]??(a?"icon-label":"default"))==="icon-label",g=j.useRef(y);return y&&(g.current=!0),cu(e.data.id,a&&!y&&g.current,()=>u.setNodeViewMode(e.data.id,"icon-label")),y?f.jsx(V.Box,{"data-grid-document":((x=e.data.config)==null?void 0:x.documentId)??"",children:f.jsx(lu,{...e,data:{...e.data,viewProps:{...e.data.viewProps,borderRadius:c},config:{...e.data.config,labelBelow:!0,icon:((w=e.data.config)==null?void 0:w.icon)||"PiGridFour"}},toggleLabel:"Show grid",onExpand:()=>u.restoreNodeView(e.data.id)})}):f.jsxs(f.Fragment,{children:[f.jsx(Vn,{...e,onOpenView:()=>d(!0),children:({data:_,isActive:k})=>{var E,O,P,A,M,T,N,$;return f.jsx(V.Box,{"data-flow-node-surface":"","data-grid-document":((E=_.config)==null?void 0:E.documentId)??"",width:`${((P=(O=_.config)==null?void 0:O.gridSize)==null?void 0:P.width)??600}px`,height:`${((M=(A=_.config)==null?void 0:A.gridSize)==null?void 0:M.height)??440}px`,overflow:"hidden",position:"relative",bg:((T=_.viewProps)==null?void 0:T.bgColor)??"transparent",color:((N=_.viewProps)==null?void 0:N.textColor)??p,borderRadius:`${c??0}px`,...Tn(_.viewProps,Pe((($=_.viewProps)==null?void 0:$.borderColor)??h),k,0),children:m?f.jsx(m,{...e}):f.jsx(V.Box,{p:4,children:_.label??"Grid"})})}}),f.jsx(su,{nodeAddress:e.data.id,active:o.includes(e.data.id),label:e.data.label??"Grid",open:l&&!n,onClose:()=>d(!1),children:f.jsx(Mt.Provider,{value:{data:{metadata:{label:e.data.label??"",subtitle:((C=e.data.config)==null?void 0:C.subtitle)??"",icon:((S=e.data.config)==null?void 0:S.icon)??"PiGridFour"}},bindings:{[e.data.id]:{address:"root.metadata",type:"GridMetadata"}},schema:{GridMetadata:{kind:"object",properties:{label:{optional:!0,type:{kind:"string"}},subtitle:{optional:!0,type:{kind:"string"}},icon:{optional:!0,type:{kind:"string"}}}}},editable:!!r.editable&&!n,callbacks:{onFormChange:_=>{var E,O,P;if(n||!r.editable)return;const k=String(_.value??"");_.address==="root.metadata.label"?(E=t.onNodeLabelChange)==null||E.call(t,e.data.id,k):_.address==="root.metadata.subtitle"?(O=t.onNodeSubtitleChange)==null||O.call(t,e.data.id,k):_.address==="root.metadata.icon"&&((P=t.onNodeIconChange)==null||P.call(t,e.data.id,k))}}},children:f.jsx(Od,{nodeAddress:e.data.id})})})]})}const tx=e=>f.jsx(ex,{...e,renderCompact:Gj}),rx=e=>f.jsx(ex,{...e}),nx=({containerStyle:e,...r})=>{const{selectedNodeIds:t}=He();return f.jsx(Vn,{...r,editOnMount:t.includes(r.data.id),children:n=>f.jsx(V.Box,{bg:e.textColor==="transparent"?"transparent":e.labelBg,p:`${e.fontSize/5}px`,fontFamily:hr,lineHeight:1,w:"fit-content",children:f.jsx(Jr,{nodeId:n.id,label:n.data.label??n.data.headerTitle??"Container",color:e.textColor,fontSize:`${e.fontSize}px`,isEditing:n.isEditing,onEditStart:n.onEditStart,onEditEnd:n.onEditEnd})})})};tx.displayName="text";rx.displayName="arrayView";nx.displayName="ParentContainerView";const i_={grid:o_,objectView:du,arrayView:rx,text:tx,parentContainer:nx},a_=({children:e,pattern:r="dot",backgroundColor:t})=>{const{colorMode:n}=He(),o=n==="dark",i=o?"--chakra-colors-gray-700":"--chakra-colors-gray-500",s=o?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return r==="none"?f.jsx(V.Box,{"data-flow-background":"none",width:"100%",height:"100%",padding:0,bg:t,children:e}):f.jsxs(V.Box,{"data-flow-background":r,position:"relative",width:"100%",height:"100%",padding:0,bg:t,children:[f.jsx(V.Box,{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:0,pointerEvents:"none",style:{backgroundImage:r==="dot"?`radial-gradient(var(${i}) 8%, transparent 8%)`:r==="steel"?`repeating-linear-gradient(45deg, var(${s}) 0, var(${s}) 1px, transparent 1px, transparent 20px)`:`linear-gradient(var(${s}) 1px, transparent 1px), linear-gradient(90deg, var(${s}) 1px, transparent 1px)`,backgroundSize:"20px 20px",opacity:.3}}),f.jsx(V.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:e})]})},s_=.4,_r={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},c_=({nodes:e,edges:r})=>{var ze;const{themeColor:t,spacing:n,edgeRadius:o,backgroundVariant:i,backgroundSelected:s,setBackgroundSelected:a,edgeColor:c,direction:l,nodeAlignment:d,edgeMode:u,compactPropertyLayout:h,workflowContract:p,parentNodeStyle:m,engineRef:y,callbacks:g,config:b,selectedNodeIds:v,setSelectedNodeIds:x,selectedEdgeId:w,setSelectedEdgeId:C,setIsPerformanceMode:S,setNodeGridOptions:_,fillRadiusEditedIds:k,isZoomMode:E,setIsZoomMode:O,isMultiSelectMode:P,setIsMultiSelectMode:A,isDragMode:M,setIsDragMode:T,isEdgeHandlesEnabled:N,setIsEdgeHandlesEnabled:$,isArrayNodeMode:I}=He(),W=j.useRef(null),[ie,ae]=j.useState(null),re=j.useRef(null),ye=e.length>200;j.useEffect(()=>{S(ye)},[ye,S]);const{edgeSep:be,rankSep:L,spacingFactor:z}=j.useMemo(()=>{const ce=zw(e.length),B=b.nodeGridSpacing==="layout"&&n<.5?n*1.3:n<1?.3+.7*n:.5+.5*n;return{edgeSep:ce.edgeSep*B,rankSep:ce.rankSep*B,spacingFactor:1.3+(n-1)*(n<1?.4:.3)}},[e.length,n,b.nodeGridSpacing]),{bgColor:G}=Nn(t),{canvas:D,borderSecondary:se,colorText:X}=st(),le=i==="transparent"?"transparent":b.backgroundColor||D,ue=j.useCallback(ce=>{if(!ce)return Pe(t);switch(ce){case"dark":return Pe(le);case"light":return Pe(se);default:return Pe(ce)}},[t,le,se]),Ce=b.colorMode==="dark",je=Ce?Pe("gray.500"):Zr,pe=Ce?G!=null&&G.includes("gray")?"whitesmoke":ue(G):je,fe=c?ue(c):je,Y=j.useMemo(()=>{var ce;return b.initialViewport||{pan:{x:0,y:0},zoom:(ce=b.nodeGrid)!=null&&ce.enabled&&b.nodeGrid.options.fill?1:.01}},[]),H=l==="C"?"LR":l,we=j.useCallback(ce=>{const B={...m,...ce};return{...B,bgColor:B.bgColor||t,bgOpacity:B.outline?0:B.bgOpacity??s_}},[m,t]),J=j.useMemo(()=>{var B;const ce=new Map;for(const oe of e)(B=oe.data)!=null&&B.id&&ce.set(oe.data.id,oe);return ce},[e]),ve=j.useMemo(()=>{var B;const ce=new Map;for(const oe of r)(B=oe.data)!=null&&B.id&&ce.set(oe.data.id,oe);return ce},[r]),Q=j.useCallback(ce=>{var U;const B=(U=J.get(ce))==null?void 0:U.data,oe=we(B==null?void 0:B.viewProps),$e=Pe(oe.bgColor);return{animated:!!(B!=null&&B.isNodeAnimated)&&!ye,animationVariant:B==null?void 0:B.nodeAnimationVariant,animationColor:Pe(oe.borderColor||t),bgColor:oe.outline?"transparent":$e,bgOpacity:oe.bgOpacity,borderColor:oe.borderColor?Pe(oe.borderColor):oe.outline&&oe.bgColor==="transparent"?Pe(t):$e,borderWidth:In(oe.borderWidth,_r.borderWidth),borderStyle:oe.borderStyle??_r.borderStyle,borderRadius:oe.borderRadius??_r.borderRadius,textColor:oe.textColor?Pe(oe.textColor):oe.outline||oe.bgColor==="transparent"?Pe(X):$e,fontSize:oe.fontSize??_r.fontSize,labelPosition:oe.labelPosition??_r.labelPosition,labelMargin:_r.labelMargin,labelBg:wu(ue("dark"),$e,oe.bgOpacity)??ue("dark"),padding:oe.padding??_r.padding}},[we,J,X,t,ye,ue]),Ee=j.useMemo(()=>{var oe,$e;const ce=new Map;for(const U of r){const ge=(oe=U.data)==null?void 0:oe.source,Ie=($e=U.data)==null?void 0:$e.target;if(!ge||!Ie||ge===Ie)continue;const xe=ge<Ie?`${ge}|${Ie}`:`${Ie}|${ge}`,Ze=ce.get(xe);Ze?Ze.push({id:U.data.id,source:ge}):ce.set(xe,[{id:U.data.id,source:ge}])}const B=new Map;for(const[U,ge]of ce){if(ge.length<2)continue;const Ie=U.split("|")[0],xe=Math.min(20,70/ge.length);ge.forEach(({id:Ze,source:Qe},Ke)=>{const vt=50+(Ke-(ge.length-1)/2)*xe;B.set(Ze,(Qe===Ie?vt:100-vt)/100)})}return B},[r]),Ae=j.useMemo(()=>{const ce=ue("dark");return r.filter(B=>{var oe;return((oe=B.data)==null?void 0:oe.id)&&B.data.source&&B.data.target}).map(({data:B})=>{var ge,Ie,xe,Ze,Qe,Ke;let oe=ce;const $e=(Ie=(ge=J.get(B.source))==null?void 0:ge.data)==null?void 0:Ie.parent,U=(Ze=(xe=J.get(B.target))==null?void 0:xe.data)==null?void 0:Ze.parent;if($e&&$e===U){const vt=we((Ke=(Qe=J.get($e))==null?void 0:Qe.data)==null?void 0:Ke.viewProps),It=wu(ce,Pe(vt.bgColor),vt.bgOpacity);It&&(oe=It)}return{id:B.id,data:B,type:B.type??b.edgeType??"rounded-orthogonal",source:B.source,target:B.target,sourceProperty:B.sourceProperty,targetProperty:B.targetProperty,label:B.label,validationIssue:(u==="auto"||u==="properties")&&(B.sourceProperty!==void 0||B.targetProperty!==void 0)&&p?Id(p,B):void 0,color:c?fe:B.color?Pe(B.color):fe,connectorColor:c?fe:B.color?Pe(B.color):pe,labelBg:oe,dashed:!!B.isEdgeDashed,animated:!!B.isEdgeAnimated,inverted:!!B.isInverted,turn:Ee.get(B.id)??.5}})},[r,fe,pe,c,Ee,b.edgeType,u,p,J,we,ue]),qe=j.useMemo(()=>{var B;const ce=new Set;for(const oe of e)(B=oe.data)!=null&&B.parent&&ce.add(oe.data.parent);return ce},[e]),Je=j.useMemo(()=>{const ce=new Map;for(const B of r){const oe=B.data.isInverted?B.data.target:B.data.source;oe&&!ce.has(oe)&&ce.set(oe,B.data)}for(const B of r){if(B.data.connection)continue;const oe=B.data.isInverted?B.data.target:B.data.source,$e=B.data.isInverted?B.data.source:B.data.target;$e.startsWith(`${oe}.`)&&(ce.set(oe,B.data),ce.set($e,B.data))}return ce},[r]),Fe=j.useMemo(()=>{const ce={...i_,...b.customViews};return e.filter(B=>{var oe;return(oe=B.data)==null?void 0:oe.id}).map(B=>{var xe,Ze,Qe,Ke,vt,It;const oe=qe.has(B.data.id)&&!B.data.parent,$e=oe?B.data.label??B.data.headerTitle??"Container":void 0,U=oe?ce.parentContainer:ce[B.data.type]||ce.text,ge=Je.get(B.data.id),Ie={...B,isInverted:((xe=B.data.config)==null?void 0:xe.isInverted)??(ge==null?void 0:ge.isInverted),isParent:oe,containerStyle:oe?Q(B.data.id):void 0};return{id:B.data.id,collapsed:(Ze=B.data.config)==null?void 0:Ze.collapsed,parent:B.data.parent,acceptsChildren:!!((Qe=B.data.config)!=null&&Qe.parentContainer)||qe.has(B.data.id),label:$e,animated:!!B.data.isNodeAnimated,animationVariant:B.data.nodeAnimationVariant,hasCollapseControl:((Ke=B.data.config)==null?void 0:Ke.collapsed)!==void 0,animationColor:Pe(((vt=B.data.viewProps)==null?void 0:vt.borderColor)||t),animationWidth:In((It=B.data.viewProps)==null?void 0:It.borderWidth,8),element:j.createElement(U,{...Ie,key:`${B.data.id}-${t}`}),fillElement:k.has(B.data.id)?void 0:j.createElement(U,{...Ie,data:{...B.data,viewProps:{...B.data.viewProps,borderRadius:0}},containerStyle:Ie.containerStyle?{...Ie.containerStyle,borderRadius:0}:void 0,key:`${B.data.id}-${t}`})}})},[e,qe,Je,t,b.customViews,Q,k]),ct=j.useMemo(()=>ye?300:e.length>50?150:e.length>20?100:50,[e.length,ye]),De=j.useRef(b);De.current=b;const rt=j.useRef(E);rt.current=E;const ft=j.useRef(I);ft.current=I;const Oe=j.useRef(v);Oe.current=v;const Xe=j.useRef(w);Xe.current=w;const nt=j.useRef(P);nt.current=P;const lt=j.useRef(J);lt.current=J;const zt=j.useRef(ve);zt.current=ve;const kt=j.useRef(new Map);j.useEffect(()=>{var oe,$e;const ce=new Map([...ve].filter(([,U])=>J.has(U.data.source)&&J.has(U.data.target))),B=kt.current;kt.current=ce;for(const[U,ge]of B)ce.has(U)||(Xe.current===U&&(C(null),(oe=g.onEdgeDeselect)==null||oe.call(g)),($e=g.onEdgeRemove)==null||$e.call(g,U,ge.data))},[ve,J,g,C]),j.useEffect(()=>{const ce=W.current;if(!ie||!ce)return;let B=null,oe=null,$e=0,U=0,ge=0,Ie=0,xe=0;const Ze=Qe=>{var It;if(De.current.readOnly||De.current.minZoom===De.current.maxZoom&&De.current.minZoom!==void 0&&((It=ce.parentElement)!=null&&It.closest(".flow-sdk-canvas")))return;const Ke=ce.ownerDocument.fullscreenElement;if(Ke&&Ke!==ce&&ce.contains(Ke)&&Qe.target instanceof Node&&Ke.contains(Qe.target))return;Qe.preventDefault(),Qe.stopPropagation(),rt.current||Qe.metaKey||Qe.ctrlKey?(ge+=Qe.deltaY,Ie=Qe.clientX,xe=Qe.clientY,oe===null&&(oe=requestAnimationFrame(()=>{oe=null;const Jt=De.current,mt=ie.zoom(),pt=ge;ge=0;let xt=mt-pt*.05/100;xt=Math.max(Jt.minZoom??.01,Math.min(Jt.maxZoom??1.5,xt));const Tt=ce.getBoundingClientRect();ie.zoomAt(xt,{x:Ie-Tt.left,y:xe-Tt.top})}))):($e+=Qe.deltaX,U+=Qe.deltaY,B===null&&(B=requestAnimationFrame(()=>{B=null;const Jt=ie.pan(),mt=ie.zoom(),pt=.35,xt=$e,Tt=U;$e=0,U=0,ie.pan({x:Jt.x+-xt*pt/mt,y:Jt.y+-Tt*pt/mt})})))};return ce.addEventListener("wheel",Ze,{passive:!1}),()=>{ce.removeEventListener("wheel",Ze),B!==null&&cancelAnimationFrame(B),oe!==null&&cancelAnimationFrame(oe)}},[ie]),j.useEffect(()=>{if(b.disableKeyboardShortcuts)return;const ce=B=>{var $e,U,ge,Ie;if(De.current.readOnly)return;const oe=B.target;if(!(oe.tagName==="INPUT"||oe.tagName==="TEXTAREA"||oe.isContentEditable)){if((B.key==="z"||B.key==="Z")&&O(!rt.current),(B.key==="m"||B.key==="M")&&A(!P),(B.key==="d"||B.key==="D")&&T(!M),(B.key==="v"||B.key==="V")&&!B.repeat&&!B.metaKey&&!B.ctrlKey&&!B.altKey&&oe.tagName!=="SELECT"&&$(!N),(B.key==="Delete"||B.key==="Backspace")&&Xe.current){B.preventDefault();const xe=Xe.current;(U=g.onEdgeDelete)==null||U.call(g,xe,(($e=zt.current.get(xe))==null?void 0:$e.data)??{id:xe}),C(null);return}if((B.key==="Delete"||B.key==="Backspace")&&Oe.current.length>0){B.preventDefault();const xe=Oe.current.filter(Ze=>Ze!=="root");if(xe.length===0)return;for(const Ze of xe){const Qe=(ge=lt.current.get(Ze))==null?void 0:ge.data;(Ie=g.onNodeDelete)==null||Ie.call(g,Ze,Qe||{})}x([])}}};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[P,M,N,$,O,A,T,b.disableKeyboardShortcuts,g,x,C]);const et=j.useCallback(ce=>{var B;y.current=ce,ae(ce),(B=g.onInit)==null||B.call(g,ce)},[y,g]),We=j.useCallback(ce=>{var B;return(B=g.onViewportChange)==null?void 0:B.call(g,ce)},[g]),Ht=j.useCallback(ce=>{var oe,$e,U;const B=((oe=zt.current.get(ce))==null?void 0:oe.data)??{id:ce};if(Xe.current===ce&&nt.current){C(null),($e=g.onEdgeDeselect)==null||$e.call(g);return}Oe.current.length&&x([]),C(ce),(U=g.onEdgeSelect)==null||U.call(g,ce,B)},[g,C,x]),dt=j.useCallback(()=>{var ce,B,oe,$e,U;if(a(b.bottomBarCollapsed??(Oe.current.length>0||!!Xe.current||!s)),(ce=g.onBackgroundClick)==null||ce.call(g),!De.current.readOnly){const ge=new Set;for(const Ie of Oe.current){let xe=lt.current.get(Ie);for(;xe&&!ge.has(xe.data.id);)ge.add(xe.data.id),qe.has(xe.data.id)&&((B=xe.data.config)==null?void 0:B.collapsed)!==!0&&((oe=g.onNodeCollapse)==null||oe.call(g,xe.data.id,!0)),xe=xe.data.parent?lt.current.get(xe.data.parent):void 0}}Oe.current.length&&(x([]),($e=g.onNodeDeselect)==null||$e.call(g)),Xe.current&&(C(null),(U=g.onEdgeDeselect)==null||U.call(g))},[g,x,C,a,s,b.bottomBarCollapsed,qe]),tr=j.useCallback(ce=>{var $e,U;const B=Oe.current,oe=ce.filter(ge=>!B.includes(ge));if(oe.length){x([...B,...oe]);for(const ge of oe)(U=g.onNodeSelect)==null||U.call(g,ge,(($e=lt.current.get(ge))==null?void 0:$e.data)??{id:ge})}},[g,x]),ar=j.useCallback((ce,B)=>{var oe,$e;x([ce]),($e=g.onNodeSelect)==null||$e.call(g,ce,((oe=lt.current.get(ce))==null?void 0:oe.data)??{id:ce},B)},[g,x]),Bt=j.useRef(null),Dt=j.useCallback((ce,B,oe)=>{var $e;Bt.current={source:ce,target:B,edgeIds:new Set(zt.current.keys())};try{($e=g.onEdgeCreate)==null||$e.call(g,ce,B,oe)}catch(U){throw Bt.current=null,U}},[g]),Kt=j.useCallback((ce,B,oe,$e=!1)=>{var U,ge;if(re.current={sourceId:ce,nodeIds:new Set(lt.current.keys()),reverse:$e},!(u==="properties"&&((U=g.onNodeCreateRequest)==null?void 0:U.call(g,{sourceNodeId:ce,position:B,sourceProperty:oe,reverse:$e}))===!0)){if(oe!==void 0||$e){re.current=null;return}(ge=g.onNodeCreate)==null||ge.call(g,{type:"text",sourceNodeId:ce,position:B,isArrayMode:ft.current})}},[g,u]),rr=!b.readOnly&&N&&b.edgeHandles!==!1,$r=i==="transparent"?"none":i;return f.jsx(a_,{pattern:$r,backgroundColor:le,children:f.jsx(V.Box,{ref:W,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:f.jsx(Bj,{nodes:Fe,edges:Ae,direction:H,nodeAlignment:d,onContainerCollapse:ce=>{var B,oe;(B=g.onNodeCollapse)==null||B.call(g,ce,!0),(oe=g.onNodeViewToggle)==null||oe.call(g,ce)},selectedNodeIds:v,edgeMode:u,compactPropertyLayout:h,edgeType:b.edgeType,edgeRadius:o,customEdgeTypes:b.customEdgeTypes,edgeReveal:b.disableAnimations?void 0:b.edgeReveal,rankSep:L,edgeSep:be,nodeGridSpacing:b.nodeGridSpacing,nodeGridConnections:b.nodeGridConnections,initialNodeGrid:b.nodeGrid,spacingFactor:z,compactSpacingScale:n,layoutDebounce:ct,isPerformanceMode:ye,minZoom:b.minZoom??.01,maxZoom:b.maxZoom??1.5,initialViewport:Y,fitOnInit:!b.initialViewport&&!((ze=b.nodeGrid)!=null&&ze.enabled&&b.nodeGrid.options.fill),readOnly:!!b.readOnly,containerStyle:Q,lineColor:c?fe:pe,drawMode:rr,drawHandles:!b.readOnly&&b.edgeHandles!==!1,dragMode:M,multiSelect:!!P,onInit:et,onLayoutComplete:ce=>{var ge;(ge=g.onLayoutComplete)==null||ge.call(g,ce);const B=Bt.current;B&&(!lt.current.has(B.source)||!lt.current.has(B.target)?Bt.current=null:r.some(({data:Ie})=>Ie.source===B.source&&Ie.target===B.target&&!B.edgeIds.has(Ie.id))&&ce.getNodeBox(B.source)&&ce.getNodeBox(B.target)&&(Bt.current=null,ce.focusConnections(B.source)));const oe=re.current;if(!oe)return;if(!lt.current.has(oe.sourceId)){re.current=null;return}const U=e.filter(Ie=>!oe.nodeIds.has(Ie.data.id)).filter(Ie=>r.some(({data:xe})=>xe.source===oe.sourceId&&xe.target===Ie.data.id||xe.target===oe.sourceId&&xe.source===Ie.data.id));!U.length||U.some(Ie=>!ce.getNodeBox(Ie.data.id))||(re.current=null,ce.focusBranch(oe.reverse?U[0].data.id:oe.sourceId))},onNodeGridModeChange:_,onNodeGridZoomOut:g.onNodeGridZoomOut,onNodeGridDrop:g.onNodeGridDrop,onNodeParentChange:g.onNodeParentChange,animateViewport:b.animateViewport,disableAnimations:b.disableAnimations,onViewportChange:We,onBackgroundTap:dt,onBoxSelect:tr,onEdgeSelect:Ht,onContainerSelect:ar,onEdgeDraw:Dt,onDrawIntoSpace:Kt})})})},ox=j.memo(c_),l_=".flow-sdk-canvas{position:relative;width:100%;height:100%;overflow:clip;user-select:none;-webkit-user-select:none;touch-action:none}.flow-sdk-svg{position:absolute;top:0;left:0;width:100%;height:100%;overflow:visible;display:block}.flow-sdk-nodes{position:absolute;top:0;left:0;transform-origin:0 0;pointer-events:none;will-change:transform;backface-visibility:hidden;z-index:10}.flow-sdk-node{position:absolute;top:0;left:0;transform-origin:0 0;pointer-events:auto;will-change:transform;backface-visibility:hidden;z-index:10}.flow-sdk-node input,.flow-sdk-node textarea{pointer-events:auto;user-select:text;-webkit-user-select:text;cursor:text}.flow-sdk-edge-hit{fill:none;stroke:transparent;stroke-width:24px;vector-effect:non-scaling-stroke;pointer-events:stroke;cursor:pointer}.flow-sdk-container{cursor:pointer}.flow-sdk-edge-anim{animation:flow-sdk-dash .5s linear infinite}.flow-sdk-edge-anim-rev{animation-direction:reverse}@keyframes flow-sdk-dash{to{stroke-dashoffset:-50}}.flow-sdk-draw{cursor:crosshair}.flow-sdk-draw .flow-sdk-node,.flow-sdk-draw .flow-sdk-node input,.flow-sdk-draw .flow-sdk-node textarea,.flow-sdk-draw .flow-sdk-edge,.flow-sdk-draw .flow-sdk-container{pointer-events:none}.flow-sdk-perf.flow-sdk-busy .flow-sdk-edges{display:none}.flow-sdk-box{position:absolute;border:1px solid rgba(170,170,170,.9);background:rgba(221,221,221,.25);pointer-events:none;z-index:20}";let Sm=!1;function d_(){if(Sm||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=l_+".flow-sdk-canvas[data-node-grid] .flow-sdk-node,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *::before,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *::after{animation:none!important;transition:none!important}.flow-sdk-node[data-grid-fill] [data-flow-icon-label]{--flow-grid-caption-color:var(--flow-grid-on-surface-color)}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]{border:0;outline:none;box-shadow:none}.flow-sdk-node[data-grid-fill]{box-sizing:border-box}.flow-sdk-node[data-grid-fill] :not(svg):has([data-flow-node-surface]),.flow-sdk-node[data-grid-fill]>:not(svg):not(button){width:100%;height:100%;min-width:0;max-width:none}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]{width:100%;height:100%;min-width:0;max-width:none;box-sizing:border-box;overflow:hidden}.flow-sdk-node[data-grid-fill] [data-flow-icon-label]{gap:0}.flow-sdk-node[data-grid-fill] [data-flow-icon-caption]{position:absolute;bottom:12px;left:12px;width:calc(100% - 24px);max-height:40%;overflow:hidden}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]>svg{max-width:45%;max-height:55%}.flow-sdk-node[data-grid-fill] p{font-size:var(--flow-grid-font);white-space:normal;overflow-wrap:anywhere}.flow-sdk-canvas[data-node-grid]:not([data-grid-connections]) .flow-sdk-property-port,.flow-sdk-canvas[data-node-grid]:not([data-grid-connections]) .flow-sdk-handle,.flow-sdk-canvas[data-node-grid] [data-flow-collapse-control]{display:none}.flow-sdk-node[data-grid-draggable] :not(button):not(input):not(textarea):not(select):not(a){cursor:inherit}"+$b+Lw+$w+".flow-sdk-handle{position:absolute;left:-36px;top:50%;transform:translateY(-50%);width:36px;height:36px;display:grid;place-items:center;border:2px solid currentColor;border-radius:50%;background:white;cursor:crosshair;opacity:0;pointer-events:none}.flow-sdk-node:hover>.flow-sdk-handle,.flow-sdk-handle:focus-visible{opacity:1;pointer-events:auto}.flow-sdk-draw .flow-sdk-node *,.flow-sdk-draw .flow-sdk-edge *,.flow-sdk-draw .flow-sdk-container *,.flow-sdk-ghost *{pointer-events:none}",document.head.appendChild(e),e.textContent+=".flow-sdk-draw .flow-sdk-node{pointer-events:auto}.flow-sdk-draw .flow-sdk-node>.flow-sdk-handle{opacity:0;pointer-events:none}.flow-sdk-draw .flow-sdk-node:hover>.flow-sdk-handle,.flow-sdk-draw .flow-sdk-node>.flow-sdk-handle:focus-visible{opacity:1;pointer-events:auto}",e.textContent+='.flow-sdk-property-port{position:absolute;transform:translateY(-50%);width:32px;height:32px;margin:0;padding:0;border:3px solid currentColor;border-radius:50%;background:white;cursor:crosshair;pointer-events:auto;z-index:20}.flow-sdk-property-port[data-port-role="source"]{background:currentColor}.flow-sdk-property-port:hover{outline:3px solid currentColor;outline-offset:3px}.flow-sdk-draw .flow-sdk-node .flow-sdk-property-port{pointer-events:auto}',Sm=!0}function u_({loading:e=!1,loader:r,...t}){var c,l;const[n,o]=j.useState(null),i=j.useMemo(()=>!!(n!=null&&n.json)&&!!t.json&&Tw(n.json,t.json),[n==null?void 0:n.json,t.json]),s=n===null||n.json!==t.json&&!i,a=e||s;return j.useEffect(()=>{!e&&i&&(n==null?void 0:n.json)!==t.json&&o(t)},[e,i,n==null?void 0:n.json,t.json]),j.useEffect(()=>{if(e||!s)return;let d;const u=requestAnimationFrame(()=>{d=requestAnimationFrame(()=>o(t))});return()=>{cancelAnimationFrame(u),d!==void 0&&cancelAnimationFrame(d)}},[e,s,t.json]),f.jsxs(V.Box,{className:t.className,style:t.style,width:"100%",height:"100%",position:"relative","aria-busy":a,children:[f.jsx("div",{style:{width:"100%",height:"100%"},ref:d=>{var h;const u=(d==null?void 0:d.contains(document.activeElement))&&((h=document.activeElement)==null?void 0:h.matches("input, textarea, [contenteditable=true]"));a&&(e||!u)?d==null||d.setAttribute("inert",""):d==null||d.removeAttribute("inert")},children:n&&f.jsx(f_,{...s?n:t,children:t.children,config:t.config,className:void 0,style:void 0})}),a&&r!==null&&f.jsx(V.Box,{"data-flow-loader":"",role:"status","aria-label":"Loading diagram",position:"absolute",inset:0,zIndex:1e3,display:"grid",placeItems:"center",background:((c=t.config)==null?void 0:c.colorMode)==="dark"?"gray.800":"gray.100",color:((l=t.config)==null?void 0:l.colorMode)==="dark"?"whiteAlpha.800":"blackAlpha.800",children:r===void 0?f.jsx("span",{children:"Loading diagram..."}):r})]})}function f_({title:e="untitled",json:r,forms:t,nodes:n,edges:o,config:i={},callbacks:s={},className:a,style:c,showBottomBar:l=!0,children:d}){d_();const[u,h]=j.useState(),[p,m]=j.useState(!1),y=i.formSchema??u,g=j.useMemo(()=>r&&t?pb(r,t.state):r,[r,t==null?void 0:t.state]),b=i.direction==="C",v=j.useMemo(()=>{let P,A;return M=>(A=P&&A?Ow(P,M,A)??hd(M,{title:e,isCenter:b}):hd(M,{title:e,isCenter:b}),P=M,A)},[e,b]),x=j.useMemo(()=>g?v(g):null,[g,v]),w=j.useMemo(()=>t!=null&&t.structured&&!p&&y?gb(t.state,t.bindings,y,(x==null?void 0:x.nodes)??n??[]):void 0,[t==null?void 0:t.structured,p,t==null?void 0:t.state,t==null?void 0:t.bindings,y,x,n]),C=(w==null?void 0:w.schema)??y,S=(w==null?void 0:w.bindings)??(t==null?void 0:t.bindings),_=j.useMemo(()=>[...(x==null?void 0:x.nodes)??n??[],...(w==null?void 0:w.nodes)??[]].map(A=>{var ie,ae,re,ye;const M=r?(ie=Le(r,A.data.id))==null?void 0:ie.$view:(ae=A.data.config)==null?void 0:ae.typeView,T=M&&wd.includes(M)?M:void 0,N=T?T==="icon-label":(re=A.data.config)==null?void 0:re.labelBelow,$=T==="object"?"objectView":T==="text"?"text":N?"arrayView":A.data.type,I=C&&(t?$n(S,A.data.id,C):r&&Xr(r,A.data.id,C)),W=(((ye=A.data.config)==null?void 0:ye.ports)??[]).map(be=>({...be}));if(w&&I){const be=i.direction==="RL"?{input:"right",output:"left",config:"bottom",error:"top"}:i.direction==="TB"?{input:"top",output:"bottom",config:"right",error:"left"}:i.direction==="BT"?{input:"bottom",output:"top",config:"left",error:"right"}:{input:"left",output:"right",config:"top",error:"bottom"};for(const[L,z]of Object.entries(I.type.ports??{})){const G=`${z.kind}:${L}`,D=W.find(se=>se.id===G);D?D.label===void 0&&z.label!==void 0&&(D.label=z.label):W.push({id:G,...z.label!==void 0?{label:z.label}:{},role:z.kind==="input"||z.kind==="config"?"target":"source",side:be[z.kind],...z.kind==="config"?{placement:"config"}:{}})}for(const L of W){const z=W.filter(G=>G.side===L.side);L.position=(z.indexOf(L)+1)/(z.length+1)}}return I||N||T?{...A,data:{...A.data,type:$,...t?{description:Object.fromEntries(Object.entries(A.data.description??{}).filter(([be])=>!be.startsWith("$")&&!(w!=null&&w.slots.has(gn(A.data.id,be)))))}:{},config:{...A.data.config,...w&&I?{ports:W}:{},...I?{form:!0}:{},...T?{typeView:T,labelBelow:!!N}:N?{labelBelow:!0}:{}}}}:A}),[x,n,r,C,S,w,i.direction]),k=j.useMemo(()=>[...(x==null?void 0:x.edges)??o??[],...(w==null?void 0:w.edges)??[]],[x==null?void 0:x.edges,o,w==null?void 0:w.edges]),E=j.useMemo(()=>{const P=r&&x?Nb(r,x.edges,s,s.onJsonChange,y):{...s};if(w){const A=new Set([...w.nodes.map(M=>M.data.id),...w.edges.map(M=>M.data.id)]);for(const M of Object.keys(P)){if(!/^on(?:Node|Edge).*(?:Change|Collapse)$/.test(M))continue;const T=P[M];P[M]=(N,...$)=>{if(!A.has(N))return T==null?void 0:T(N,...$)}}}return{...P,onAllNodesIconLabelChange:A=>{var M;m(A),(M=P.onAllNodesIconLabelChange)==null||M.call(P,A)}}},[r,x,s,y,w]),O=j.useMemo(()=>{if(!t)return E;let P=t.state;const A=T=>{if(i.readOnly||i.editable===!1)return;const N=t.onStateChange??t.onChange;if(!N)return;const $=ww(P,T,s.onFormChange);$!==P&&(P=$,N($,{...T,data:$}))},M=(T,N,$)=>{var W;const I=r&&((W=Le(r,T))==null?void 0:W[N]);return!I||typeof I.$state!="string"?!1:(A({address:I.$state,nodeAddress:T,previousValue:Le(P,I.$state),value:$,data:P}),!0)};return{...E,onFormChange:A,onNodeCreateRequest:T=>{var I,W;const N=(I=T.sourceProperty)!=null&&I.startsWith("config:")?T.sourceProperty.slice(7):void 0,$=N!==void 0&&(w==null?void 0:w.slots.get(gn(T.sourceNodeId,N)));return $?($.present||A({data:P,nodeAddress:$.address.split(".").slice(0,-1).join("."),address:$.address,value:yn($.type),previousValue:void 0}),!0):((W=E.onNodeCreateRequest)==null?void 0:W.call(E,T))??!1},onNodeDelete:(T,N)=>{var re,ye;if(!(w!=null&&w.nodes.some(be=>be.data.id===T)))return(re=E.onNodeDelete)==null?void 0:re.call(E,T,N);const $=w&&[...w.slots.values()].find(be=>be.nodeId===T);if(!$)return(ye=E.onNodeDelete)==null?void 0:ye.call(E,T,N);const I=$.address.split("."),W=I.pop(),ie=I.join("."),ae=Le(P,ie);A(Array.isArray(ae)?{data:P,nodeAddress:ie,address:ie,previousValue:ae,value:ae.filter((be,L)=>String(L)!==W)}:{data:P,nodeAddress:ie,address:$.address,previousValue:Le(P,$.address),value:void 0})},onEdgeCreate:(T,N,$)=>{var ie,ae;const I=((ie=$==null?void 0:$.targetProperty)==null?void 0:ie.startsWith("config:"))&&(w==null?void 0:w.slots.get(gn(N,$.targetProperty.slice(7)))),W=w==null?void 0:w.containers.get(T);if(I&&W&&($==null?void 0:$.sourceProperty)==="output:resource"){const re=jw(P,W,I);re!==void 0&&A({data:P,nodeAddress:I.address.split(".").slice(0,-1).join("."),address:I.address,previousValue:Le(P,I.address),value:re});return}I||w!=null&&w.nodes.some(re=>re.data.id===T||re.data.id===N)||(ae=E.onEdgeCreate)==null||ae.call(E,T,N,$)},onEdgeDelete:(T,N)=>{var ye;const $=w==null?void 0:w.edges.find(be=>be.data.id===T);if(!$)return(ye=E.onEdgeDelete)==null?void 0:ye.call(E,T,N);const I=w.slots.get(gn($.data.target,$.data.targetProperty.slice(7))),W=I.address.split("."),ie=W.pop(),ae=W.join("."),re=Le(P,ae);A(Array.isArray(re)?{data:P,nodeAddress:ae,address:ae,previousValue:re,value:re.filter((be,L)=>String(L)!==ie)}:{data:P,nodeAddress:ae,address:I.address,previousValue:Le(P,I.address),value:void 0})},onNodeContentChange:(T,N)=>{var $,I;M(T,"$content",N)?($=s.onNodeContentChange)==null||$.call(s,T,N):(I=E.onNodeContentChange)==null||I.call(E,T,N)},onNodeLabelChange:(T,N)=>{var $,I;M(T,"$label",N)?($=s.onNodeLabelChange)==null||$.call(s,T,N):(I=E.onNodeLabelChange)==null||I.call(E,T,N)}}},[E,t,r,s,w,i.readOnly,i.editable]);return f.jsx(Mt.Provider,{value:{data:(t==null?void 0:t.state)??r,viewData:r,bindings:S,references:t==null?void 0:t.references,structured:w,renderForm:t==null?void 0:t.renderForm,editable:t?!!(t.onStateChange??t.onChange):!!s.onJsonChange,schema:C,setSchema:P=>{var A;h(P),(A=s.onFormSchemaChange)==null||A.call(s,P)},callbacks:O},children:f.jsx(Mm,{config:w?{...i,formSchema:C}:i,callbacks:O,nodes:_,edges:k,children:f.jsxs(V.Box,{className:a,"data-flow-diagram":"","data-animations-disabled":i.disableAnimations||void 0,style:c,width:"100%",height:"100%",position:"relative",overflow:"hidden",css:{"&[data-animations-disabled], &[data-animations-disabled] *, &[data-animations-disabled] *::before, &[data-animations-disabled] *::after":{animation:"none !important",transition:"none !important"},"& input, & textarea, & select":{outline:"none !important",boxShadow:"none !important"}},children:[f.jsx(ox,{nodes:_,edges:k}),l&&f.jsx(Ab,{}),d]})})})}function h_(e){return xd(JSON.parse(e))}function xd(e){if(!e||typeof e!="object")throw new Error("Expected a JSON object or array.");const r=new Set,t=n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(!n||typeof n!="object"||r.has(n)||!Array.isArray(n)&&![Object.prototype,null].includes(Object.getPrototypeOf(n)))throw new Error("Document must contain only finite, acyclic JSON values.");r.add(n);for(const[o,i]of Object.entries(n)){if(["__proto__","prototype","constructor"].includes(o))throw new Error(`Unsafe document key: ${o}`);t(i)}r.delete(n)}};return t(e),structuredClone(e)}function p_(e){return{replaceJson(r){if(e.readOnly||!e.onJsonChange)throw new Error("JSON document is read-only.");const t=xd(r);return e.onJsonChange(t,{type:"documentReplace",address:"root"}),t},replaceState(r){if(e.readOnly||!e.onStateChange)throw new Error("Form state is read-only.");const t=xd(r);return e.onStateChange(t,{address:"root",nodeAddress:"root",previousValue:e.state,value:t,data:t}),t}}}function g_(e,r){const t=(n,o)=>{if(n===null||typeof n!="object")return typeof n==typeof o?n:void 0;if(!(!o||typeof o!="object"))return Array.isArray(n)?Array.isArray(o)?n.map((i,s)=>t(i,o[s])).filter(i=>i!==void 0):void 0:Object.fromEntries(Object.entries(n).flatMap(([i,s])=>{if(!Object.prototype.hasOwnProperty.call(o,i))return[];if(i==="$content"&&n.$contentFormat==="jsx"&&o.$contentFormat==="jsx"&&Array.isArray(s)&&Array.isArray(o[i]))return[[i,s.filter((c,l)=>JSON.stringify(c)===JSON.stringify(o[i][l]))]];if(i.startsWith("$")&&i!=="$")return JSON.stringify(s)===JSON.stringify(o[i])?[[i,s]]:[];const a=t(s,o[i]);return a===void 0?[]:[[i,a]]}))};return t(e,r)??{}}function eo(e){let r="",t=!1,n="",o;const i=()=>{clearTimeout(o),o=void 0},s=()=>{if(i(),!(t||!r.trim()))try{const c=e.parse(e.repair(r)),l=JSON.stringify(c);if(l===n)return;e.preview(c),n=l}catch{}},a=c=>{if(!t){if(new TextEncoder().encode(c).byteLength>(e.maxBytes??1024*1024))throw t=!0,i(),new Error("JSON stream exceeds the size limit.");r=c,o||(o=setTimeout(s,e.intervalMs??150))}};return{snapshot:a,append(c){a(r+c)},flush:s,finish(){if(t)throw new Error("JSON stream is closed.");t=!0,i();const c=e.parse(r);return e.commit(c),c},cancel(){t=!0,i(),r=""}}}function y_(e){const{source:r}=e,t=e.tickMs??50,n=e.durationMs??8e3;if(!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0)throw new Error("Playback timing must be positive.");if(new TextEncoder().encode(r).byteLength>(e.maxBytes??1024*1024))throw new Error("JSON stream exceeds the size limit.");e.parse(r);let o=eo(e),i=0,s=!1,a=!1,c;const l=Math.max(1,Math.ceil(r.length*t/n)),d=()=>e.onChange({position:i,total:r.length,playing:s}),u=()=>{clearTimeout(c),c=void 0},h=(y=!1)=>{o.snapshot(r.slice(0,i)),i===r.length?(s=!1,u(),o.finish()):y&&o.flush()},p=y=>{s=!1,u(),o.cancel(),d(),e.onError(y)},m=()=>{if(c=void 0,!(!s||a)){i=Math.min(r.length,i+l);try{h()}catch(y){p(y);return}d(),s&&(c=setTimeout(m,t))}};return{play(){a||s||(i===r.length&&(o.cancel(),o=eo(e),i=0),s=!0,d(),c=setTimeout(m,t))},pause(){a||(s=!1,u(),o.flush(),d())},seek(y){if(!a){if(!Number.isFinite(y))throw new Error("Playback position must be finite.");u(),i=Math.max(0,Math.min(r.length,Math.round(y))),o.cancel(),o=eo(e);try{h(!0)}catch(g){p(g);return}d(),s&&(c=setTimeout(m,t))}},dispose(){a=!0,s=!1,u(),o.cancel()}}}function m_({nodeAddress:e,expanded:r=!1}){var l;const{data:t,schema:n,bindings:o}=j.useContext(Mt),{colorText:i,background:s}=st();if((l=o==null?void 0:o[e])!=null&&l.portResources)return null;const a=o&&$n(o,e,n);if(!t||!a)return null;const c=Le(t,a.address);return!c||typeof c!="object"?null:f.jsx("div",{"data-flow-config-summary":"",style:{width:"100%",minWidth:0,color:Pe(i),background:Pe(s),fontSize:24,lineHeight:1.4,textTransform:"none"},children:Object.keys(a.type.properties).map(d=>{const u=a.fields[d]??{};if(!ho(u.$visibleWhen,t))return null;const h=c[d],p=h==null?"":typeof h=="object"?JSON.stringify(h):String(h);return f.jsxs("div",{"data-flow-property":d,style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1fr)",gap:12,padding:"10px 16px",borderTop:"1px solid color-mix(in srgb, currentColor 12%, transparent)"},children:[f.jsx("span",{style:{overflowWrap:"anywhere"},children:$t(u.$label??d)}),f.jsx("span",{title:p,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:r?"pre-wrap":"nowrap",overflowWrap:r?"anywhere":void 0},children:p})]},d)})})}exports.BottomBar=Ab;exports.CollapseAllToggle=eb;exports.CompactPropertyLayoutToggle=tb;exports.ConnectionsOnlyToggle=Iw;exports.DEFAULT_PALETTE=no;exports.DiagramAppearanceControls=rb;exports.DynamicIcon=Qt;exports.EdgeTools=wb;exports.EditableLabel=Jr;exports.ErrorToast=kb;exports.FlowDiagram=u_;exports.FlowDiagramProvider=Mm;exports.FlowPort=Yv;exports.FlowView=ox;exports.FormDocumentContext=Mt;exports.GridAdjustmentToggle=nb;exports.LIGHT_BLACK=Zr;exports.LoadingBorder=Xv;exports.NODE_TYPE_VIEWS=wd;exports.NodeBorderRadiusControl=Cb;exports.NodeConfigSummary=m_;exports.NodeForm=Od;exports.NodeFormPopover=su;exports.NodeIconPicker=Nd;exports.NodeTools=Sb;exports.NodeView=Vn;exports.SvgExportButton=Eb;exports.Swatches=Mr;exports.TEXT_PALETTE=vb;exports.ToolbarCloseButton=Yr;exports.ToolbarCommitInput=Dr;exports.ToolbarDivider=xn;exports.ToolbarIconButton=Ne;exports.ToolbarRangeInput=Sd;exports.ToolbarScrollContainer=$d;exports.ToolbarSelect=At;exports.ToolbarTooltip=Ue;exports.TooltipIconButton=vd;exports.WorkflowControls=qd;exports.addChild=Rd;exports.addConnection=Ad;exports.addTargetEdge=db;exports.addressToPath=Vt;exports.applyCollapsed=bw;exports.applyFormChange=po;exports.applyStateEdits=xw;exports.bindSqueedCallbacks=Nb;exports.compileSqueed=hd;exports.connectionIssue=Id;exports.contentObjTheme=Xt;exports.copySelection=Ld;exports.createFlowDiagram=Pr;exports.createFlowDocumentActions=p_;exports.createFormNode=Mb;exports.createJsonPlayback=y_;exports.createJsonStream=eo;exports.createWorkflowExecution=Sx;exports.downloadSvg=_b;exports.duplicateSelection=Ob;exports.exportSvg=jb;exports.formValueError=Wt;exports.getChakraColorHex=Pe;exports.getColorVariant=km;exports.getDarkerHexColor=to;exports.getInteractionSurface=gr;exports.getNode=Le;exports.getSelectionRoots=Tb;exports.isNodeVisible=Yt;exports.parseFlowDocument=h_;exports.parseJsonContract=Pd;exports.parseTypeScriptContract=fb;exports.parseTypeScriptForm=Md;exports.projectJsonPlaybackPreview=g_;exports.readFormSchema=Td;exports.readWorkflowContract=hb;exports.removeEdge=ub;exports.removeNode=lb;exports.reparentNode=Ib;exports.resolveEdgeOwner=Rr;exports.resolveStateView=pb;exports.setCollapsed=kd;exports.setEdgeProp=ur;exports.setEdgeStyle=cb;exports.setNodeProp=St;exports.updateNode=_t;exports.useCustomColors=st;exports.useEdgeProximity=Em;exports.useFlowData=vr;exports.useFlowDiagramContext=He;exports.useNodeViewActions=Wn;exports.useStopPropagation=au;exports.useThemeContentColors=Nn;exports.validateGridAdjustment=Hv;
|
|
284
284
|
//# sourceMappingURL=index.cjs.map
|