@squeed/flow-sdk 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";var Kb=Object.create;var Kn=Object.defineProperty;var Jb=Object.getOwnPropertyDescriptor;var Zb=Object.getOwnPropertyNames;var Yb=Object.getPrototypeOf,Xb=Object.prototype.hasOwnProperty;var Qb=(e,t,r)=>t in e?Kn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ev=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Zb(t))!Xb.call(e,o)&&o!==r&&Kn(e,o,{get:()=>t[o],enumerable:!(n=Jb(t,o))||n.enumerable});return e};var qe=(e,t,r)=>(r=e!=null?Kb(Yb(e)):{},ev(t||!e||!e.__esModule?Kn(r,"default",{value:e,enumerable:!0}):r,e));var Tr=(e,t,r)=>Qb(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),D=require("@chakra-ui/react"),S=require("react"),J=require("react-icons/pi"),fy=require("@emotion/react"),rv=require("@emotion/styled"),tv=require("react-icons/tb"),Bt=require("react-dom"),nv=require("markdown-to-jsx/react"),hy=e=>e&&e.__esModule?e:{default:e},mn=hy(rv),ov=hy(nv);function py({edge:e,enabled:t,bounds:r,inside:n=[],threshold:o=80}){const[i,a]=S.useState(!1),[s,u]=S.useState(!1),c=S.useRef(n);return c.current=n,S.useEffect(()=>{if(!t)return;const l=()=>{const f=document.querySelectorAll(':popover-open, dialog[open], [role="dialog"], [role="menu"], [role="listbox"]');u(Array.from(f).some(p=>p.getClientRects().length>0&&!p.closest('[hidden], [aria-hidden="true"], [data-state="closed"]')&&getComputedStyle(p).visibility==="visible"))},d=new MutationObserver(l);return d.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["open","hidden","aria-hidden","data-state"]}),document.addEventListener("toggle",l,!0),l(),()=>{d.disconnect(),document.removeEventListener("toggle",l,!0)}},[t]),S.useEffect(()=>{const l=f=>{var y;const p=(y=r.current)==null?void 0:y.getBoundingClientRect();if(!p)return;const m=f.target instanceof Node?f.target:null,g=!!m&&c.current.some(x=>{var v;return(v=x.current)==null?void 0:v.contains(m)}),b=e==="bottom"?p.bottom-f.clientY:f.clientY-p.top,w=f.clientX>=p.left&&f.clientX<=p.right&&b>=0&&b<=o;a(g||w)},d=()=>a(!1);return document.addEventListener("pointermove",l,!0),document.addEventListener("pointerdown",l,!0),document.documentElement.addEventListener("pointerleave",d),()=>{document.removeEventListener("pointermove",l,!0),document.removeEventListener("pointerdown",l,!0),document.documentElement.removeEventListener("pointerleave",d)}},[e,r,o]),t&&(i||s)}const iv=fy.keyframes`
1
+ "use strict";var Km=Object.create;var Kn=Object.defineProperty;var Jm=Object.getOwnPropertyDescriptor;var Zm=Object.getOwnPropertyNames;var Ym=Object.getPrototypeOf,Xm=Object.prototype.hasOwnProperty;var Qm=(e,t,r)=>t in e?Kn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ev=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Zm(t))!Xm.call(e,o)&&o!==r&&Kn(e,o,{get:()=>t[o],enumerable:!(n=Jm(t,o))||n.enumerable});return e};var qe=(e,t,r)=>(r=e!=null?Km(Ym(e)):{},ev(t||!e||!e.__esModule?Kn(r,"default",{value:e,enumerable:!0}):r,e));var Tr=(e,t,r)=>Qm(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),D=require("@chakra-ui/react"),S=require("react"),J=require("react-icons/pi"),fy=require("@emotion/react"),rv=require("@emotion/styled"),tv=require("react-icons/tb"),Bt=require("react-dom"),nv=require("markdown-to-jsx/react"),hy=e=>e&&e.__esModule?e:{default:e},bn=hy(rv),ov=hy(nv);function py({edge:e,enabled:t,bounds:r,inside:n=[],threshold:o=80}){const[i,a]=S.useState(!1),[s,u]=S.useState(!1),c=S.useRef(n);return c.current=n,S.useEffect(()=>{if(!t)return;const l=()=>{const f=document.querySelectorAll(':popover-open, dialog[open], [role="dialog"], [role="menu"], [role="listbox"]');u(Array.from(f).some(p=>p.getClientRects().length>0&&!p.closest('[hidden], [aria-hidden="true"], [data-state="closed"]')&&getComputedStyle(p).visibility==="visible"))},d=new MutationObserver(l);return d.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["open","hidden","aria-hidden","data-state"]}),document.addEventListener("toggle",l,!0),l(),()=>{d.disconnect(),document.removeEventListener("toggle",l,!0)}},[t]),S.useEffect(()=>{const l=f=>{var y;const p=(y=r.current)==null?void 0:y.getBoundingClientRect();if(!p)return;const b=f.target instanceof Node?f.target:null,g=!!b&&c.current.some(x=>{var v;return(v=x.current)==null?void 0:v.contains(b)}),m=e==="bottom"?p.bottom-f.clientY:f.clientY-p.top,w=f.clientX>=p.left&&f.clientX<=p.right&&m>=0&&m<=o;a(g||w)},d=()=>a(!1);return document.addEventListener("pointermove",l,!0),document.addEventListener("pointerdown",l,!0),document.documentElement.addEventListener("pointerleave",d),()=>{document.removeEventListener("pointermove",l,!0),document.removeEventListener("pointerdown",l,!0),document.documentElement.removeEventListener("pointerleave",d)}},[e,r,o]),t&&(i||s)}const iv=fy.keyframes`
2
2
  0%, 100% { box-shadow: var(--flow-rest-shadow); }
3
3
  25%, 50% { box-shadow: var(--flow-hover-shadow); }
4
4
  `,av=fy.keyframes`
5
5
  from { box-shadow: var(--flow-start-shadow); }
6
6
  to { box-shadow: var(--flow-rest-shadow); }
7
- `;function gy(e,t=!0,r="&:hover",n=!0){const o=`color-mix(in srgb, ${e} 60%, transparent)`,a=`0 0 0 ${t?8:0}px ${o}`,s=`0 0 0 8px ${o}`;return{boxShadow:a,css:{"--flow-rest-shadow":s,"--flow-hover-shadow":`0 0 0 18px ${o}`,"@media (hover: hover)":{[r]:{boxShadow:s,"@media (prefers-reduced-motion: no-preference)":{animation:n?`${iv} 1200ms steps(10, end) 600ms`:"none"}}}}}}function zr(e,t){const{boxShadow:r,css:n}=gy(e,!1),o=n["@media (hover: hover)"]["&:hover"];return{borderWidth:"1px",borderStyle:"solid",borderColor:"transparent",boxShadow:r,...n,"--flow-start-shadow":r,"@media (hover: hover)":{"&:hover":{...o,borderColor:t,"@media (prefers-reduced-motion: no-preference)":{animation:`${av} 600ms steps(5, end)`}}}}}const yy=S.createContext(null),my=S.createContext({nodeById:new Map,edgeById:new Map,parentIds:new Set});function Ur(){return S.useContext(my)}function Oe(){const e=S.useContext(yy);if(!e)throw new Error("useFlowDiagramContext must be used within FlowDiagram");return e}function by({config:e,callbacks:t,nodes:r=[],edges:n=[],children:o}){const i=S.useMemo(()=>{var Fe,er,Be;const ne=new Map;for(const Q of r)(Fe=Q.data)!=null&&Fe.id&&ne.set(Q.data.id,Q);const ze=new Map;for(const Q of n)(er=Q.data)!=null&&er.id&&ze.set(Q.data.id,Q);const Qe=new Set;for(const Q of r)(Be=Q.data)!=null&&Be.parent&&Qe.add(Q.data.parent);return{nodeById:ne,edgeById:ze,parentIds:Qe}},[r,n]),a=S.useRef(null),[s,u]=S.useState([]),[c,l]=S.useState(null),[d,f]=S.useState(!0),[p,m]=S.useState(!1),[g,b]=S.useState(!0),[w,y]=S.useState(!1),[x,v]=S.useState(!1),[C,_]=S.useState(!0),[k,T]=S.useState(!1),[P,j]=S.useState("auto"),[R,E]=S.useState(!1),M=e.compactPropertyLayout??R,[I,N]=S.useState({}),O=e.nodeViewModes??I,W=[...i.nodeById.values()].filter(ne=>{var ze;return i.parentIds.has(ne.data.id)||((ze=ne.data.config)==null?void 0:ze.parentContainer)||ne.data.type==="objectView"||ne.data.type==="arrayView"}),z=!!W.length&&W.every(ne=>{var ze,Qe,Fe;return i.parentIds.has(ne.data.id)||(ze=ne.data.config)!=null&&ze.parentContainer?!!((Qe=ne.data.config)!=null&&Qe.collapsed):O[ne.data.id]==="icon-label"||((Fe=ne.data.config)==null?void 0:Fe.labelBelow)&&O[ne.data.id]!=="properties"}),[re,te]=S.useState("normal"),[he,me]=S.useState(),K=e.edgeRadius??he,q=K!==void 0&&Number.isFinite(K)?Math.min(500,Math.max(0,K)):void 0,[L,G]=S.useState(),B=e.spacing??re,Y=typeof B=="number"?Number.isFinite(B)?Math.min(2,Math.max(.5,B)):1:B==="compact"?.5:B==="spacious"?2:1,ce=e.backgroundVariant??L??(e.backgroundPattern==="none"&&e.backgroundColor==="transparent"?"transparent":e.backgroundPattern??"dot"),[X,U]=S.useState(),Z=Object.prototype.hasOwnProperty.call(e,"workflowContract")?e.workflowContract:X,[ae,ue]=S.useState("blue.500"),[de,Ee]=S.useState(!1),ge=S.useRef(t);ge.current=t;const He=S.useMemo(()=>{const ne=ze=>(...Qe)=>{var Fe,er;return(er=(Fe=ge.current)==null?void 0:Fe[ze])==null?void 0:er.call(Fe,...Qe)};return{onNodeSelect:ne("onNodeSelect"),onBackgroundClick:ne("onBackgroundClick"),onNodeDeselect:ne("onNodeDeselect"),onNodeDoubleClick:ne("onNodeDoubleClick"),onNodeViewToggle:ne("onNodeViewToggle"),onNodeTypeViewChange:ne("onNodeTypeViewChange"),onNodeCreate:ne("onNodeCreate"),onNodeCreateRequest:ne("onNodeCreateRequest"),onNodeDelete:ne("onNodeDelete"),onNodeLabelChange:ne("onNodeLabelChange"),onNodeContentChange:ne("onNodeContentChange"),onNodeCollapse:ne("onNodeCollapse"),onNodeColorChange:ne("onNodeColorChange"),onNodeBorderColorChange:ne("onNodeBorderColorChange"),onNodeBorderStyleChange:ne("onNodeBorderStyleChange"),onNodeBorderWidthChange:ne("onNodeBorderWidthChange"),onNodeBorderRadiusChange:ne("onNodeBorderRadiusChange"),onNodeIconChange:ne("onNodeIconChange"),onNodeOutlineChange:ne("onNodeOutlineChange"),onNodeAnimationChange:ne("onNodeAnimationChange"),onNodeAnimationVariantChange:ne("onNodeAnimationVariantChange"),onEdgeAnimationVariantChange:ne("onEdgeAnimationVariantChange"),onNodeHoverAction:ne("onNodeHoverAction"),onEdgeCreate:ne("onEdgeCreate"),onEdgeSelect:ne("onEdgeSelect"),onEdgeDeselect:ne("onEdgeDeselect"),onEdgeRemove:ne("onEdgeRemove"),onEdgeDelete:ne("onEdgeDelete"),onEdgeColorChange:ne("onEdgeColorChange"),onEdgeTypeChange:ne("onEdgeTypeChange"),onEdgeIconChange:ne("onEdgeIconChange"),onEdgeLabelChange:ne("onEdgeLabelChange"),onEdgeStyleChange:ne("onEdgeStyleChange"),onViewportChange:ne("onViewportChange"),onDirectionChange:ne("onDirectionChange"),onThemeColorChange:ne("onThemeColorChange"),onSpacingChange:ne("onSpacingChange"),onEdgeRadiusChange:ne("onEdgeRadiusChange"),onBackgroundVariantChange:ne("onBackgroundVariantChange"),onEdgeModeChange:ne("onEdgeModeChange"),onCompactPropertyLayoutChange:ne("onCompactPropertyLayoutChange"),onWorkflowContractChange:ne("onWorkflowContractChange"),onArrayModeChange:ne("onArrayModeChange"),onInit:ne("onInit"),onLayoutComplete:ne("onLayoutComplete"),onJsonChange:ne("onJsonChange")}},[]),Le=e.themeColor||ae,Xe=e.edgeColor||"",ur=e.colorMode||"light",Ge=e.direction||"LR",Ne=e.nodeAlignment??"center",xe=e.edgeMode==="workflow"?"nodes":e.edgeMode??P,Ie=e.readOnly??!1,$e=JSON.stringify(e.parentNodeStyle??null),tr=S.useMemo(()=>e.parentNodeStyle,[$e]),Je=e.isZoomMode!==void 0?e.isZoomMode:d,Ze=e.isMultiSelectMode!==void 0?e.isMultiSelectMode:p,fr=e.isEdgeHandlesEnabled!==void 0?e.isEdgeHandlesEnabled:w,wr=e.isDragMode!==void 0?e.isDragMode:g,Ce=S.useRef(e);Ce.current=e;const ir=S.useMemo(()=>({get direction(){return Ce.current.direction},get nodeAlignment(){return Ce.current.nodeAlignment},get edgeMode(){return Ce.current.edgeMode},get compactPropertyLayout(){return Ce.current.compactPropertyLayout},get edgeType(){return Ce.current.edgeType},get customEdgeTypes(){return Ce.current.customEdgeTypes},get themeColor(){return Ce.current.themeColor},get colorMode(){return Ce.current.colorMode},get readOnly(){return Ce.current.readOnly},get editable(){return Ce.current.editable},get minZoom(){return Ce.current.minZoom},get maxZoom(){return Ce.current.maxZoom},get backgroundPattern(){return Ce.current.backgroundPattern},get edgeColor(){return Ce.current.edgeColor},get parentNodeStyle(){return Ce.current.parentNodeStyle},get backgroundColor(){return Ce.current.backgroundColor},get edgeHandles(){return Ce.current.edgeHandles},get initialViewport(){return Ce.current.initialViewport},get nodeOverlayActions(){return Ce.current.nodeOverlayActions},get renderNodeOverlay(){return Ce.current.renderNodeOverlay},get renderSelectedNodeToolbar(){return Ce.current.renderSelectedNodeToolbar},get renderSelectedEdgeToolbar(){return Ce.current.renderSelectedEdgeToolbar},get renderBottomBar(){return Ce.current.renderBottomBar},get bottomBarExtra(){return Ce.current.bottomBarExtra},get selectionToolbar(){return Ce.current.selectionToolbar},get customViews(){return Ce.current.customViews},get disableKeyboardShortcuts(){return Ce.current.disableKeyboardShortcuts},get isZoomMode(){return Ce.current.isZoomMode},get isMultiSelectMode(){return Ce.current.isMultiSelectMode},get isEdgeHandlesEnabled(){return Ce.current.isEdgeHandlesEnabled},get isDragMode(){return Ce.current.isDragMode}}),[]),ar=S.useCallback((ne,ze)=>{var Qe;if(ze!=="default"&&ze!=="properties"&&ze!=="icon-label")throw new Error("Unknown node view mode.");N(Fe=>Fe[ne]===ze?Fe:{...Fe,[ne]:ze}),(Qe=t.onNodeViewModeChange)==null||Qe.call(t,ne,ze)},[t.onNodeViewModeChange]),Ct=S.useMemo(()=>({allNodesIconLabel:z,setAllNodesIconLabel:ne=>{var ze,Qe,Fe,er;if(!ne)for(const[Be,Q]of Object.entries(O))Q==="icon-label"&&!i.nodeById.has(Be)&&ar(Be,"default");for(const Be of W)i.parentIds.has(Be.data.id)||(ze=Be.data.config)!=null&&ze.parentContainer?!Ie&&!!((Qe=Be.data.config)!=null&&Qe.collapsed)!==ne&&((Fe=t.onNodeCollapse)==null||Fe.call(t,Be.data.id,ne)):ar(Be.data.id,ne?"icon-label":"default");(er=t.onAllNodesIconLabelChange)==null||er.call(t,ne)},nodeViewModes:O,setNodeViewMode:ar,spacing:Y,setSpacing:te,edgeRadius:q,setEdgeRadius:me,backgroundVariant:ce,setBackgroundVariant:G,themeColor:Le,setThemeColor:ue,backgroundSelected:de,setBackgroundSelected:Ee,edgeColor:Xe,colorMode:ur,direction:Ge,nodeAlignment:Ne,edgeMode:xe,setEdgeMode:j,compactPropertyLayout:M,setCompactPropertyLayout:E,workflowContract:Z,setWorkflowContract:U,parentNodeStyle:tr,selectedNodeIds:s,setSelectedNodeIds:u,selectedEdgeId:c,setSelectedEdgeId:l,isZoomMode:Je,setIsZoomMode:f,isMultiSelectMode:Ze,setIsMultiSelectMode:m,isDragMode:wr,setIsDragMode:b,isEdgeHandlesEnabled:fr,setIsEdgeHandlesEnabled:y,isArrayNodeMode:x,setIsArrayNodeMode:v,isPinned:C,setIsPinned:_,isPerformanceMode:k,setIsPerformanceMode:T,engineRef:a,callbacks:He,config:ir,readOnly:Ie}),[z,i,ar,t.onNodeCollapse,t.onAllNodesIconLabelChange,O,t.onNodeViewModeChange,Le,Y,ce,q,e.backgroundColor,de,Xe,ur,Ge,Ne,xe,Z,tr,s,c,Je,Ze,wr,fr,x,C,k,Ie,e.edgeHandles,e.edgeType,e.customEdgeTypes,e.selectionToolbar,e.bottomBarExtra,e.compactPropertyLayout,M,He,ir]);return h.jsx(yy.Provider,{value:Ct,children:h.jsx(my.Provider,{value:i,children:o})})}function ln(e,t=.2){const r=e.replace(/^#/,""),n=parseInt(r,16);let o=n>>16&255,i=n>>8&255,a=n&255;return o=Math.max(0,Math.floor(o*(1-t))),i=Math.max(0,Math.floor(i*(1-t))),a=Math.max(0,Math.floor(a*(1-t))),"#"+((1<<24)+(o<<16)+(i<<8)+a).toString(16).slice(1).toUpperCase()}function ul(e,t,r){const n=s=>{const u=/^#?([0-9a-f]{6})$/i.exec((s==null?void 0:s.trim())??"");return u?parseInt(u[1],16):null},o=n(e),i=n(t);if(o===null||i===null)return null;const a=s=>Math.round((o>>s&255)*(1-r)+(i>>s&255)*r);return"#"+((1<<24)+(a(16)<<16)+(a(8)<<8)+a(0)).toString(16).slice(1).toUpperCase()}const jr=e=>e==="transparent"?{background:"transparent",highlight:"transparent",border:"transparent",property:"gray.900",boolean:"green.800",string:"gray.900",number:"orange.800"}:e!=null&&e.startsWith("#")?{background:e,highlight:ln(e,.1),border:ln(e,.5),property:"gray.900",boolean:"green.200",string:"gray.900",number:"orange.800"}:e==="gray"?{background:"gray.950",highlight:"gray.800",border:"gray.700",property:"gray.200",boolean:"green.400",string:"gray.200",number:"orange.600"}:e==="white"?{background:"white",highlight:"gray.200",border:"gray.400",property:"gray.900",boolean:"green.400",string:"gray.900",number:"orange.600"}:{background:e+".100",highlight:e+".200",border:e+".700",property:"gray.900",boolean:"green.800",string:"gray.900",number:"orange.800"},vy=e=>{if(e==="transparent")return{primary:e,secondary:e,light:e};let t=e;if(t!=null&&t.startsWith("#"))return{secondary:ln(e)};let r=String(Number(e.slice(-3))+200);r=e.slice(0,-3).concat(r);let n=String(Number(e.slice(-3))-100);return n=e.slice(0,-3).concat(n),{primary:t,secondary:r,light:n}},ll={red:{50:"#FFF5F5",100:"#FED7D7",200:"#FEB2B2",300:"#FC8181",400:"#F56565",500:"#E53E3E",600:"#C53030",700:"#9B2C2C",800:"#822727",900:"#63171B"},orange:{50:"#FFFAF0",100:"#FEEBC8",200:"#FBD38D",300:"#F6AD55",400:"#ED8936",500:"#DD6B20",600:"#C05621",700:"#9C4221",800:"#7B341E",900:"#652B19"},yellow:{50:"#FFFFF0",100:"#FEFCBF",200:"#FAF089",300:"#F6E05E",400:"#ECC94B",500:"#D69E2E",600:"#B7791F",700:"#975A16",800:"#744210",900:"#5F370E"},green:{50:"#F0FFF4",100:"#C6F6D5",200:"#9AE6B4",300:"#68D391",400:"#48BB78",500:"#38A169",600:"#2F855A",700:"#276749",800:"#22543D",900:"#1C4532"},teal:{50:"#E6FFFA",100:"#B2F5EA",200:"#81E6D9",300:"#4FD1C5",400:"#38B2AC",500:"#319795",600:"#2C7A7B",700:"#285E61",800:"#234E52",900:"#1D4044"},blue:{50:"#EBF8FF",100:"#BEE3F8",200:"#90CDF4",300:"#63B3ED",400:"#4299E1",500:"#3182CE",600:"#2B6CB0",700:"#2C5282",800:"#2A4365",900:"#1A365D"},cyan:{50:"#EDFDFD",100:"#C4F1F9",200:"#9DECF9",300:"#76E4F7",400:"#0BC5EA",500:"#00B5D8",600:"#00A3C4",700:"#0987A0",800:"#086F83",900:"#065666"},purple:{50:"#FAF5FF",100:"#E9D8FD",200:"#D6BCFA",300:"#B794F4",400:"#9F7AEA",500:"#805AD5",600:"#6B46C1",700:"#553C9A",800:"#44337A",900:"#322659"},pink:{50:"#FFF5F7",100:"#FED7E2",200:"#FBB6CE",300:"#F687B3",400:"#ED64A6",500:"#D53F8C",600:"#B83280",700:"#97266D",800:"#702459",900:"#521B41"},gray:{50:"#F7FAFC",100:"#EDF2F7",200:"#E2E8F0",300:"#CBD5E0",400:"#A0AEC0",500:"#718096",600:"#4A5568",700:"#2D3748",800:"#1A202C",900:"#171923",950:"#0d1117"}},fe=(e,t)=>{var i;if(e==="transparent"||e!=null&&e.startsWith("#"))return e;if(!e)return"whitesmoke";const r=e.replace(/\./g,"-");try{const s=getComputedStyle(document.documentElement).getPropertyValue(`--chakra-colors-${r}`).trim();if(s&&s!=="")return s}catch{}const[n,o]=e.split(".");return n&&o&&((i=ll[n])!=null&&i[Number(o)])?ll[n][Number(o)]:`var(--chakra-colors-${r})`};function nr(e,t,r){return e?r:t}function Yt(e){const[t]=(e==null?void 0:e.split("."))||[],{secondary:r}=vy(e),n=jr(t).background,o=jr(t).highlight,i=jr(t).border,a=jr(t).property,s=jr(t).property;let u=jr(t).background,c=jr(t).highlight;return u=e==="transparent"?e:fe(u)+50,c=e==="transparent"?e:fe(c)+20,{bgColor:n,highlightColor:o,borderColor:i,textColor:a,propertyColor:s,secondary:r,bgColorFaint:u,highlightColorFaint:c}}function Ue(e=null){const{colorMode:t}=Oe(),r=e==null?void 0:e.includes("gray"),n=t==="dark",o=nr(n,"white","gray.900"),i=nr(n,"gray.100","gray.800"),a=nr(n,"gray.200","blackAlpha.400"),s=nr(n,"gray.200","blackAlpha.600"),u=nr(n,"gray.500","gray.700"),c=nr(n,"gray.700","gray.700"),l=nr(n,"gray.900","gray.900"),d=nr(n,"gray.400","gray.500"),f=nr(n,"gray.400","gray.500"),p=nr(n,"gray.900","gray.200"),m=nr(n,r?"gray.900":"gray.200",r?"gray.200":"gray.900"),g=nr(n,"gray.900","gray.200"),b=nr(n,e&&"#000000",e||"#ffffff"),w=nr(n,e||"#ffffff",e?"#000000":"#ffffff"),y=c,x=nr(n,"gray.300","gray.800"),v=nr(n,"white","blackAlpha.400"),C=nr(n,"green.100","green.700");return{canvas:o,background:i,backgroundSecondary:a,darkBackgroundSecondary:s,border:u,darkColor:l,backgroundWhiteColor:v,borderSecondary:c,colorActive:d,colorInactive:f,iconColor:g,moreIconColor:y,colorText:p,themedColorText:m,logoColor:b,logoColorSecondary:w,darkColorActive:x,greenColor:C}}var jt=(e=>(e.TOP_DOWN="TB",e.BOTTOM_UP="BT",e.LEFT_RIGHT="LR",e.RIGHT_LEFT="RL",e.CENTER="C",e))(jt||{});const Dt=["","icon-label","object","text"];var sv=typeof global=="object"&&global&&global.Object===Object&&global,cv=typeof self=="object"&&self&&self.Object===Object&&self,uv=sv||cv||Function("return this")(),ht=uv.Symbol,xy=Object.prototype,lv=xy.hasOwnProperty,dv=xy.toString,St=ht?ht.toStringTag:void 0;function fv(e){var t=lv.call(e,St),r=e[St];try{e[St]=void 0;var n=!0}catch{}var o=dv.call(e);return n&&(t?e[St]=r:delete e[St]),o}var hv=Object.prototype,pv=hv.toString;function gv(e){return pv.call(e)}var yv="[object Null]",mv="[object Undefined]",dl=ht?ht.toStringTag:void 0;function bv(e){return e==null?e===void 0?mv:yv:dl&&dl in Object(e)?fv(e):gv(e)}function vv(e){return e!=null&&typeof e=="object"}var xv="[object Symbol]";function wv(e){return typeof e=="symbol"||vv(e)&&bv(e)==xv}function Cv(e,t){for(var r=-1,n=e==null?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}var Ae=Array.isArray,fl=ht?ht.prototype:void 0,hl=fl?fl.toString:void 0;function wy(e){if(typeof e=="string")return e;if(Ae(e))return Cv(e,wy)+"";if(wv(e))return hl?hl.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function Eu(e){return e==null?"":wy(e)}function _v(e,t,r){var n=-1,o=e.length;t<0&&(t=-t>o?0:o+t),r=r>o?o:r,r<0&&(r+=o),o=t>r?0:r-t>>>0,t>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+t];return i}function Sv(e,t,r){var n=e.length;return r=r===void 0?n:r,!t&&r>=n?e:_v(e,t,r)}var Ev="\\ud800-\\udfff",jv="\\u0300-\\u036f",Rv="\\ufe20-\\ufe2f",kv="\\u20d0-\\u20ff",Pv=jv+Rv+kv,Av="\\ufe0e\\ufe0f",Tv="\\u200d",Ov=RegExp("["+Tv+Ev+Pv+Av+"]");function Cy(e){return Ov.test(e)}function Iv(e){return e.split("")}var _y="\\ud800-\\udfff",Mv="\\u0300-\\u036f",qv="\\ufe20-\\ufe2f",Nv="\\u20d0-\\u20ff",$v=Mv+qv+Nv,Lv="\\ufe0e\\ufe0f",Fv="["+_y+"]",mu="["+$v+"]",bu="\\ud83c[\\udffb-\\udfff]",Bv="(?:"+mu+"|"+bu+")",Sy="[^"+_y+"]",Ey="(?:\\ud83c[\\udde6-\\uddff]){2}",jy="[\\ud800-\\udbff][\\udc00-\\udfff]",Dv="\\u200d",Ry=Bv+"?",ky="["+Lv+"]?",zv="(?:"+Dv+"(?:"+[Sy,Ey,jy].join("|")+")"+ky+Ry+")*",Vv=ky+Ry+zv,Wv="(?:"+[Sy+mu+"?",mu,Ey,jy,Fv].join("|")+")",Gv=RegExp(bu+"(?="+bu+")|"+Wv+Vv,"g");function Uv(e){return e.match(Gv)||[]}function Hv(e){return Cy(e)?Uv(e):Iv(e)}function Kv(e){return function(t){t=Eu(t);var r=Cy(t)?Hv(t):void 0,n=r?r[0]:t.charAt(0),o=r?Sv(r,1).join(""):t.slice(1);return n[e]()+o}}var Jv=Kv("toUpperCase");function Zv(e,t,r,n){for(var o=-1,i=e==null?0:e.length;++o<i;)r=t(r,e[o],o,e);return r}function Yv(e){return function(t){return e==null?void 0:e[t]}}var Xv={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Qv=Yv(Xv),ex=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,rx="\\u0300-\\u036f",tx="\\ufe20-\\ufe2f",nx="\\u20d0-\\u20ff",ox=rx+tx+nx,ix="["+ox+"]",ax=RegExp(ix,"g");function sx(e){return e=Eu(e),e&&e.replace(ex,Qv).replace(ax,"")}var cx=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function ux(e){return e.match(cx)||[]}var lx=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function dx(e){return lx.test(e)}var Py="\\ud800-\\udfff",fx="\\u0300-\\u036f",hx="\\ufe20-\\ufe2f",px="\\u20d0-\\u20ff",gx=fx+hx+px,Ay="\\u2700-\\u27bf",Ty="a-z\\xdf-\\xf6\\xf8-\\xff",yx="\\xac\\xb1\\xd7\\xf7",mx="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",bx="\\u2000-\\u206f",vx=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Oy="A-Z\\xc0-\\xd6\\xd8-\\xde",xx="\\ufe0e\\ufe0f",Iy=yx+mx+bx+vx,My="['’]",pl="["+Iy+"]",wx="["+gx+"]",qy="\\d+",Cx="["+Ay+"]",Ny="["+Ty+"]",$y="[^"+Py+Iy+qy+Ay+Ty+Oy+"]",_x="\\ud83c[\\udffb-\\udfff]",Sx="(?:"+wx+"|"+_x+")",Ex="[^"+Py+"]",Ly="(?:\\ud83c[\\udde6-\\uddff]){2}",Fy="[\\ud800-\\udbff][\\udc00-\\udfff]",st="["+Oy+"]",jx="\\u200d",gl="(?:"+Ny+"|"+$y+")",Rx="(?:"+st+"|"+$y+")",yl="(?:"+My+"(?:d|ll|m|re|s|t|ve))?",ml="(?:"+My+"(?:D|LL|M|RE|S|T|VE))?",By=Sx+"?",Dy="["+xx+"]?",kx="(?:"+jx+"(?:"+[Ex,Ly,Fy].join("|")+")"+Dy+By+")*",Px="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ax="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Tx=Dy+By+kx,Ox="(?:"+[Cx,Ly,Fy].join("|")+")"+Tx,Ix=RegExp([st+"?"+Ny+"+"+yl+"(?="+[pl,st,"$"].join("|")+")",Rx+"+"+ml+"(?="+[pl,st+gl,"$"].join("|")+")",st+"?"+gl+"+"+yl,st+"+"+ml,Ax,Px,qy,Ox].join("|"),"g");function Mx(e){return e.match(Ix)||[]}function qx(e,t,r){return e=Eu(e),t=t,t===void 0?dx(e)?Mx(e):ux(e):e.match(t)||[]}var Nx="['’]",$x=RegExp(Nx,"g");function Lx(e){return function(t){return Zv(qx(sx(t).replace($x,"")),e,"")}}var Cr=Lx(function(e,t,r){return e+(r?" ":"")+Jv(t)});function je({label:e,children:t}){const r=S.cloneElement(t,{title:t.props.title??e});if(!D.Tooltip.Root){const n=D.Tooltip;return h.jsx(n,{label:e,placement:"top",fontSize:"xs",borderRadius:"15px",children:r})}return h.jsxs(D.Tooltip.Root,{positioning:{placement:"top"},children:[h.jsx(D.Tooltip.Trigger,{asChild:!0,children:r}),h.jsx(D.Portal,{children:h.jsx(D.Tooltip.Positioner,{children:h.jsx(D.Tooltip.Content,{fontSize:"xs",borderRadius:"15px",children:e})})})]})}function Mt(){const{border:e}=Ue();return h.jsx(D.chakra.span,{role:"separator","aria-orientation":"vertical",display:"block",flexShrink:0,w:"1px",h:"20px",mx:"4px",bg:e})}function Ir({children:e,value:t,onValueChange:r,disabled:n,style:o,title:i,icon:a,popupContent:s,labelCase:u="title","aria-label":c}){var R;const{colorMode:l}=Oe(),{background:d,border:f,colorText:p,colorActive:m,colorInactive:g}=Ue(),b=l==="dark",w=S.useId(),y=S.useRef(null),x=S.useRef(null),[v,C]=S.useState(!1);S.useEffect(()=>{const E=x.current;E.setAttribute("popover","auto");const M=I=>C(I.newState==="open");return E.addEventListener("toggle",M),()=>E.removeEventListener("toggle",M)},[]);const _=S.Children.toArray(e).filter(S.isValidElement).map(E=>{const M=E.props;return{value:String(M.value),label:typeof M.children=="string"&&u==="title"?Cr(M.children):M.children,disabled:M.disabled}}),k=()=>{var E;return(E=x.current)==null?void 0:E.hidePopover()},T=()=>{var W,z,re,te;const E=(W=y.current)==null?void 0:W.getBoundingClientRect(),M=x.current;if(!E||!M)return;const N=((te=(re=(z=y.current)==null?void 0:z.closest("[data-flow-toolbar-scroll]"))==null?void 0:re.parentElement)==null?void 0:te.getBoundingClientRect())??E;M.style.maxHeight=`${Math.max(60,Math.max(N.top-40,window.innerHeight-N.bottom-40))}px`;const O=M.getBoundingClientRect();M.style.left=`${Math.max(12,Math.min(E.right-O.width,window.innerWidth-O.width-12))}px`,M.style.top=`${Math.max(12,N.top>=O.height+36?N.top-O.height-24:Math.min(N.bottom+24,window.innerHeight-O.height-12))}px`},P=()=>{var I,N,O,W,z,re;if(n)return;if((I=x.current)==null||I.showPopover(),T(),s){(O=(N=x.current)==null?void 0:N.querySelector("input"))==null||O.focus({preventScroll:!0});return}const E=(W=x.current)==null?void 0:W.querySelectorAll('[role="option"]:not(:disabled)');(re=((z=x.current)==null?void 0:z.querySelector('[aria-selected="true"]:not(:disabled)'))??(E==null?void 0:E[0]))==null||re.focus()};S.useEffect(()=>{if(v){if(n){k();return}return window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0)}}},[v,n]);const j=`var(--chakra-colors-${d.replace(".","-")})`;return h.jsxs(h.Fragment,{children:[h.jsx(je,{label:i??c,children:h.jsx(D.chakra.button,{ref:y,type:"button",role:"combobox","data-flow-select-icon":a?"":void 0,"aria-label":c,title:i??c,"aria-haspopup":s?"dialog":"listbox","aria-expanded":v,"aria-controls":w,disabled:n,h:"30px",w:"160px",px:"6px",fontSize:"12px",border:"none",borderRadius:"4px",bg:"transparent",color:a?g:p,display:"flex",alignItems:"center",justifyContent:a?"center":"space-between",gap:2,style:o,onClick:()=>v?k():P(),onKeyDown:E=>{["ArrowDown","ArrowUp"].includes(E.key)&&(E.preventDefault(),P())},children:a??h.jsxs(h.Fragment,{children:[h.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((R=_.find(E=>E.value===t))==null?void 0:R.label)??t}),h.jsx(J.PiCaretUp,{size:16,style:{flexShrink:0}})]})})}),h.jsx(D.chakra.div,{ref:x,id:w,role:s?"dialog":"listbox","aria-label":c,position:"fixed",m:0,p:2,minW:"180px",maxW:"calc(100vw - 24px)",overflowY:"auto",bg:d,color:p,borderRadius:"30px",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"},...zr(j,`var(--chakra-colors-${(b?f:"gray.300").replace(".","-")})`)},onKeyDown:E=>{var N,O,W;if(s&&!["Escape","Tab"].includes(E.key))return;const M=[...E.currentTarget.querySelectorAll('[role="option"]:not(:disabled)')],I=M.indexOf(document.activeElement);if(["ArrowDown","ArrowUp","Home","End"].includes(E.key)){E.preventDefault();const z=E.key==="Home"?0:E.key==="End"?M.length-1:(I+(E.key==="ArrowDown"?1:-1)+M.length)%M.length;(N=M[z])==null||N.focus()}else E.key==="Escape"||E.key==="Tab"?(E.key==="Escape"&&(E.preventDefault(),E.stopPropagation()),k(),(O=y.current)==null||O.focus()):E.key.length===1&&E.key!==" "&&((W=M.find((z,re)=>{var te;return re>I&&((te=z.textContent)==null?void 0:te.toLowerCase().startsWith(E.key.toLowerCase()))}))==null||W.focus())},children:s??_.map(E=>h.jsxs(D.chakra.button,{type:"button",role:"option","aria-selected":E.value===t,disabled:E.disabled,tabIndex:-1,display:"flex",alignItems:"center",gap:3,px:3,py:2,w:"100%",borderRadius:"30px",fontSize:"sm",textAlign:"left",bg:"transparent",color:p,_hover:{bg:b?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:b?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var M;k(),(M=y.current)==null||M.focus(),r(E.value)},children:[h.jsx("span",{style:{flex:1},children:E.label}),h.jsx(J.PiCheck,{size:16,color:`var(--chakra-colors-${m.replace(".","-")})`,"aria-hidden":"true",style:{flexShrink:0,visibility:E.value===t?"visible":"hidden"}})]},E.value))})]})}const be=S.forwardRef(function({icon:t,...r},n){const{colorMode:o}=Oe();return h.jsx(D.IconButton,{ref:n,_hover:{bg:o==="dark"?"whiteAlpha.100":"blackAlpha.50"},title:r.title??r["aria-label"],...r,children:t})}),gt=S.forwardRef(function(t,r){const{themeColor:n}=Oe();return h.jsx(je,{label:"Close",children:h.jsx(be,{ref:r,size:"sm",variant:"ghost",color:n,focusRingColor:n,...t,"aria-label":t["aria-label"]??"Close selection tools",icon:h.jsx(J.PiXLight,{size:20,"aria-hidden":"true"})})})});function ju({label:e,icon:t,checked:r,onChange:n,disabled:o}){const{themeColor:i,readOnly:a}=Oe(),{colorInactive:s}=Ue();return h.jsx(je,{label:e,children:h.jsx(be,{"aria-label":e,"aria-pressed":r,icon:h.jsxs(h.Fragment,{children:[t,h.jsx(D.Text,{as:"span",fontSize:"xs",fontWeight:"normal",whiteSpace:"nowrap",children:e})]}),size:"sm",variant:"ghost",width:"auto",px:2,gap:2,color:r?i:s,disabled:o||a,onClick:()=>n(!r)})})}function zy({label:e="Compact layout"}={}){const{compactPropertyLayout:t,setCompactPropertyLayout:r,callbacks:n}=Oe();return h.jsx(ju,{label:e,checked:t,icon:h.jsx(D.Icon,{as:J.PiArrowsIn,boxSize:5}),onChange:o=>{var i;r(o),(i=n.onCompactPropertyLayoutChange)==null||i.call(n,o)}})}const Vy=mn.default.input`
7
+ `;function gy(e,t=!0,r="&:hover",n=!0){const o=`color-mix(in srgb, ${e} 60%, transparent)`,a=`0 0 0 ${t?8:0}px ${o}`,s=`0 0 0 8px ${o}`;return{boxShadow:a,css:{"--flow-rest-shadow":s,"--flow-hover-shadow":`0 0 0 18px ${o}`,"@media (hover: hover)":{[r]:{boxShadow:s,"@media (prefers-reduced-motion: no-preference)":{animation:n?`${iv} 1200ms steps(10, end) 600ms`:"none"}}}}}}function zr(e,t){const{boxShadow:r,css:n}=gy(e,!1),o=n["@media (hover: hover)"]["&:hover"];return{borderWidth:"1px",borderStyle:"solid",borderColor:"transparent",boxShadow:r,...n,"--flow-start-shadow":r,"@media (hover: hover)":{"&:hover":{...o,borderColor:t,"@media (prefers-reduced-motion: no-preference)":{animation:`${av} 600ms steps(5, end)`}}}}}const yy=S.createContext(null),by=S.createContext({nodeById:new Map,edgeById:new Map,parentIds:new Set});function Ur(){return S.useContext(by)}function Oe(){const e=S.useContext(yy);if(!e)throw new Error("useFlowDiagramContext must be used within FlowDiagram");return e}function my({config:e,callbacks:t,nodes:r=[],edges:n=[],children:o}){const i=S.useMemo(()=>{var Fe,er,Be;const ne=new Map;for(const Q of r)(Fe=Q.data)!=null&&Fe.id&&ne.set(Q.data.id,Q);const ze=new Map;for(const Q of n)(er=Q.data)!=null&&er.id&&ze.set(Q.data.id,Q);const Qe=new Set;for(const Q of r)(Be=Q.data)!=null&&Be.parent&&Qe.add(Q.data.parent);return{nodeById:ne,edgeById:ze,parentIds:Qe}},[r,n]),a=S.useRef(null),[s,u]=S.useState([]),[c,l]=S.useState(null),[d,f]=S.useState(!0),[p,b]=S.useState(!1),[g,m]=S.useState(!0),[w,y]=S.useState(!1),[x,v]=S.useState(!1),[C,_]=S.useState(!0),[k,T]=S.useState(!1),[P,j]=S.useState("auto"),[R,E]=S.useState(!1),M=e.compactPropertyLayout??R,[I,N]=S.useState({}),O=e.nodeViewModes??I,W=[...i.nodeById.values()].filter(ne=>{var ze;return i.parentIds.has(ne.data.id)||((ze=ne.data.config)==null?void 0:ze.parentContainer)||ne.data.type==="objectView"||ne.data.type==="arrayView"}),z=!!W.length&&W.every(ne=>{var ze,Qe,Fe;return i.parentIds.has(ne.data.id)||(ze=ne.data.config)!=null&&ze.parentContainer?!!((Qe=ne.data.config)!=null&&Qe.collapsed):O[ne.data.id]==="icon-label"||((Fe=ne.data.config)==null?void 0:Fe.labelBelow)&&O[ne.data.id]!=="properties"}),[re,te]=S.useState("normal"),[he,be]=S.useState(),K=e.edgeRadius??he,q=K!==void 0&&Number.isFinite(K)?Math.min(500,Math.max(0,K)):void 0,[L,G]=S.useState(),B=e.spacing??re,Y=typeof B=="number"?Number.isFinite(B)?Math.min(2,Math.max(.5,B)):1:B==="compact"?.5:B==="spacious"?2:1,ce=e.backgroundVariant??L??(e.backgroundPattern==="none"&&e.backgroundColor==="transparent"?"transparent":e.backgroundPattern??"dot"),[X,U]=S.useState(),Z=Object.prototype.hasOwnProperty.call(e,"workflowContract")?e.workflowContract:X,[ae,ue]=S.useState("blue.500"),[de,Ee]=S.useState(!1),ge=S.useRef(t);ge.current=t;const He=S.useMemo(()=>{const ne=ze=>(...Qe)=>{var Fe,er;return(er=(Fe=ge.current)==null?void 0:Fe[ze])==null?void 0:er.call(Fe,...Qe)};return{onNodeSelect:ne("onNodeSelect"),onBackgroundClick:ne("onBackgroundClick"),onNodeDeselect:ne("onNodeDeselect"),onNodeDoubleClick:ne("onNodeDoubleClick"),onNodeViewToggle:ne("onNodeViewToggle"),onNodeTypeViewChange:ne("onNodeTypeViewChange"),onNodeCreate:ne("onNodeCreate"),onNodeCreateRequest:ne("onNodeCreateRequest"),onNodeDelete:ne("onNodeDelete"),onNodeLabelChange:ne("onNodeLabelChange"),onNodeContentChange:ne("onNodeContentChange"),onNodeCollapse:ne("onNodeCollapse"),onNodeColorChange:ne("onNodeColorChange"),onNodeBorderColorChange:ne("onNodeBorderColorChange"),onNodeBorderStyleChange:ne("onNodeBorderStyleChange"),onNodeBorderWidthChange:ne("onNodeBorderWidthChange"),onNodeBorderRadiusChange:ne("onNodeBorderRadiusChange"),onNodeIconChange:ne("onNodeIconChange"),onNodeOutlineChange:ne("onNodeOutlineChange"),onNodeAnimationChange:ne("onNodeAnimationChange"),onNodeAnimationVariantChange:ne("onNodeAnimationVariantChange"),onEdgeAnimationVariantChange:ne("onEdgeAnimationVariantChange"),onNodeHoverAction:ne("onNodeHoverAction"),onEdgeCreate:ne("onEdgeCreate"),onEdgeSelect:ne("onEdgeSelect"),onEdgeDeselect:ne("onEdgeDeselect"),onEdgeRemove:ne("onEdgeRemove"),onEdgeDelete:ne("onEdgeDelete"),onEdgeColorChange:ne("onEdgeColorChange"),onEdgeTypeChange:ne("onEdgeTypeChange"),onEdgeIconChange:ne("onEdgeIconChange"),onEdgeLabelChange:ne("onEdgeLabelChange"),onEdgeStyleChange:ne("onEdgeStyleChange"),onViewportChange:ne("onViewportChange"),onDirectionChange:ne("onDirectionChange"),onThemeColorChange:ne("onThemeColorChange"),onSpacingChange:ne("onSpacingChange"),onEdgeRadiusChange:ne("onEdgeRadiusChange"),onBackgroundVariantChange:ne("onBackgroundVariantChange"),onEdgeModeChange:ne("onEdgeModeChange"),onCompactPropertyLayoutChange:ne("onCompactPropertyLayoutChange"),onWorkflowContractChange:ne("onWorkflowContractChange"),onArrayModeChange:ne("onArrayModeChange"),onInit:ne("onInit"),onLayoutComplete:ne("onLayoutComplete"),onJsonChange:ne("onJsonChange")}},[]),Le=e.themeColor||ae,Xe=e.edgeColor||"",ur=e.colorMode||"light",Ge=e.direction||"LR",Ne=e.nodeAlignment??"center",xe=e.edgeMode==="workflow"?"nodes":e.edgeMode??P,Ie=e.readOnly??!1,$e=JSON.stringify(e.parentNodeStyle??null),tr=S.useMemo(()=>e.parentNodeStyle,[$e]),Je=e.isZoomMode!==void 0?e.isZoomMode:d,Ze=e.isMultiSelectMode!==void 0?e.isMultiSelectMode:p,fr=e.isEdgeHandlesEnabled!==void 0?e.isEdgeHandlesEnabled:w,wr=e.isDragMode!==void 0?e.isDragMode:g,Ce=S.useRef(e);Ce.current=e;const ir=S.useMemo(()=>({get direction(){return Ce.current.direction},get nodeAlignment(){return Ce.current.nodeAlignment},get edgeMode(){return Ce.current.edgeMode},get compactPropertyLayout(){return Ce.current.compactPropertyLayout},get edgeType(){return Ce.current.edgeType},get customEdgeTypes(){return Ce.current.customEdgeTypes},get themeColor(){return Ce.current.themeColor},get colorMode(){return Ce.current.colorMode},get readOnly(){return Ce.current.readOnly},get editable(){return Ce.current.editable},get minZoom(){return Ce.current.minZoom},get maxZoom(){return Ce.current.maxZoom},get backgroundPattern(){return Ce.current.backgroundPattern},get edgeColor(){return Ce.current.edgeColor},get parentNodeStyle(){return Ce.current.parentNodeStyle},get backgroundColor(){return Ce.current.backgroundColor},get edgeHandles(){return Ce.current.edgeHandles},get initialViewport(){return Ce.current.initialViewport},get nodeOverlayActions(){return Ce.current.nodeOverlayActions},get renderNodeOverlay(){return Ce.current.renderNodeOverlay},get renderSelectedNodeToolbar(){return Ce.current.renderSelectedNodeToolbar},get renderSelectedEdgeToolbar(){return Ce.current.renderSelectedEdgeToolbar},get renderBottomBar(){return Ce.current.renderBottomBar},get bottomBarExtra(){return Ce.current.bottomBarExtra},get selectionToolbar(){return Ce.current.selectionToolbar},get customViews(){return Ce.current.customViews},get disableKeyboardShortcuts(){return Ce.current.disableKeyboardShortcuts},get isZoomMode(){return Ce.current.isZoomMode},get isMultiSelectMode(){return Ce.current.isMultiSelectMode},get isEdgeHandlesEnabled(){return Ce.current.isEdgeHandlesEnabled},get isDragMode(){return Ce.current.isDragMode}}),[]),ar=S.useCallback((ne,ze)=>{var Qe;if(ze!=="default"&&ze!=="properties"&&ze!=="icon-label")throw new Error("Unknown node view mode.");N(Fe=>Fe[ne]===ze?Fe:{...Fe,[ne]:ze}),(Qe=t.onNodeViewModeChange)==null||Qe.call(t,ne,ze)},[t.onNodeViewModeChange]),Ct=S.useMemo(()=>({allNodesIconLabel:z,setAllNodesIconLabel:ne=>{var ze,Qe,Fe,er;if(!ne)for(const[Be,Q]of Object.entries(O))Q==="icon-label"&&!i.nodeById.has(Be)&&ar(Be,"default");for(const Be of W)i.parentIds.has(Be.data.id)||(ze=Be.data.config)!=null&&ze.parentContainer?!Ie&&!!((Qe=Be.data.config)!=null&&Qe.collapsed)!==ne&&((Fe=t.onNodeCollapse)==null||Fe.call(t,Be.data.id,ne)):ar(Be.data.id,ne?"icon-label":"default");(er=t.onAllNodesIconLabelChange)==null||er.call(t,ne)},nodeViewModes:O,setNodeViewMode:ar,spacing:Y,setSpacing:te,edgeRadius:q,setEdgeRadius:be,backgroundVariant:ce,setBackgroundVariant:G,themeColor:Le,setThemeColor:ue,backgroundSelected:de,setBackgroundSelected:Ee,edgeColor:Xe,colorMode:ur,direction:Ge,nodeAlignment:Ne,edgeMode:xe,setEdgeMode:j,compactPropertyLayout:M,setCompactPropertyLayout:E,workflowContract:Z,setWorkflowContract:U,parentNodeStyle:tr,selectedNodeIds:s,setSelectedNodeIds:u,selectedEdgeId:c,setSelectedEdgeId:l,isZoomMode:Je,setIsZoomMode:f,isMultiSelectMode:Ze,setIsMultiSelectMode:b,isDragMode:wr,setIsDragMode:m,isEdgeHandlesEnabled:fr,setIsEdgeHandlesEnabled:y,isArrayNodeMode:x,setIsArrayNodeMode:v,isPinned:C,setIsPinned:_,isPerformanceMode:k,setIsPerformanceMode:T,engineRef:a,callbacks:He,config:ir,readOnly:Ie}),[z,i,ar,t.onNodeCollapse,t.onAllNodesIconLabelChange,O,t.onNodeViewModeChange,Le,Y,ce,q,e.backgroundColor,de,Xe,ur,Ge,Ne,xe,Z,tr,s,c,Je,Ze,wr,fr,x,C,k,Ie,e.edgeHandles,e.edgeType,e.customEdgeTypes,e.selectionToolbar,e.bottomBarExtra,e.compactPropertyLayout,M,He,ir]);return h.jsx(yy.Provider,{value:Ct,children:h.jsx(by.Provider,{value:i,children:o})})}function ln(e,t=.2){const r=e.replace(/^#/,""),n=parseInt(r,16);let o=n>>16&255,i=n>>8&255,a=n&255;return o=Math.max(0,Math.floor(o*(1-t))),i=Math.max(0,Math.floor(i*(1-t))),a=Math.max(0,Math.floor(a*(1-t))),"#"+((1<<24)+(o<<16)+(i<<8)+a).toString(16).slice(1).toUpperCase()}function ul(e,t,r){const n=s=>{const u=/^#?([0-9a-f]{6})$/i.exec((s==null?void 0:s.trim())??"");return u?parseInt(u[1],16):null},o=n(e),i=n(t);if(o===null||i===null)return null;const a=s=>Math.round((o>>s&255)*(1-r)+(i>>s&255)*r);return"#"+((1<<24)+(a(16)<<16)+(a(8)<<8)+a(0)).toString(16).slice(1).toUpperCase()}const jr=e=>e==="transparent"?{background:"transparent",highlight:"transparent",border:"transparent",property:"gray.900",boolean:"green.800",string:"gray.900",number:"orange.800"}:e!=null&&e.startsWith("#")?{background:e,highlight:ln(e,.1),border:ln(e,.5),property:"gray.900",boolean:"green.200",string:"gray.900",number:"orange.800"}:e==="gray"?{background:"gray.950",highlight:"gray.800",border:"gray.700",property:"gray.200",boolean:"green.400",string:"gray.200",number:"orange.600"}:e==="white"?{background:"white",highlight:"gray.200",border:"gray.400",property:"gray.900",boolean:"green.400",string:"gray.900",number:"orange.600"}:{background:e+".100",highlight:e+".200",border:e+".700",property:"gray.900",boolean:"green.800",string:"gray.900",number:"orange.800"},vy=e=>{if(e==="transparent")return{primary:e,secondary:e,light:e};let t=e;if(t!=null&&t.startsWith("#"))return{secondary:ln(e)};let r=String(Number(e.slice(-3))+200);r=e.slice(0,-3).concat(r);let n=String(Number(e.slice(-3))-100);return n=e.slice(0,-3).concat(n),{primary:t,secondary:r,light:n}},ll={red:{50:"#FFF5F5",100:"#FED7D7",200:"#FEB2B2",300:"#FC8181",400:"#F56565",500:"#E53E3E",600:"#C53030",700:"#9B2C2C",800:"#822727",900:"#63171B"},orange:{50:"#FFFAF0",100:"#FEEBC8",200:"#FBD38D",300:"#F6AD55",400:"#ED8936",500:"#DD6B20",600:"#C05621",700:"#9C4221",800:"#7B341E",900:"#652B19"},yellow:{50:"#FFFFF0",100:"#FEFCBF",200:"#FAF089",300:"#F6E05E",400:"#ECC94B",500:"#D69E2E",600:"#B7791F",700:"#975A16",800:"#744210",900:"#5F370E"},green:{50:"#F0FFF4",100:"#C6F6D5",200:"#9AE6B4",300:"#68D391",400:"#48BB78",500:"#38A169",600:"#2F855A",700:"#276749",800:"#22543D",900:"#1C4532"},teal:{50:"#E6FFFA",100:"#B2F5EA",200:"#81E6D9",300:"#4FD1C5",400:"#38B2AC",500:"#319795",600:"#2C7A7B",700:"#285E61",800:"#234E52",900:"#1D4044"},blue:{50:"#EBF8FF",100:"#BEE3F8",200:"#90CDF4",300:"#63B3ED",400:"#4299E1",500:"#3182CE",600:"#2B6CB0",700:"#2C5282",800:"#2A4365",900:"#1A365D"},cyan:{50:"#EDFDFD",100:"#C4F1F9",200:"#9DECF9",300:"#76E4F7",400:"#0BC5EA",500:"#00B5D8",600:"#00A3C4",700:"#0987A0",800:"#086F83",900:"#065666"},purple:{50:"#FAF5FF",100:"#E9D8FD",200:"#D6BCFA",300:"#B794F4",400:"#9F7AEA",500:"#805AD5",600:"#6B46C1",700:"#553C9A",800:"#44337A",900:"#322659"},pink:{50:"#FFF5F7",100:"#FED7E2",200:"#FBB6CE",300:"#F687B3",400:"#ED64A6",500:"#D53F8C",600:"#B83280",700:"#97266D",800:"#702459",900:"#521B41"},gray:{50:"#F7FAFC",100:"#EDF2F7",200:"#E2E8F0",300:"#CBD5E0",400:"#A0AEC0",500:"#718096",600:"#4A5568",700:"#2D3748",800:"#1A202C",900:"#171923",950:"#0d1117"}},fe=(e,t)=>{var i;if(e==="transparent"||e!=null&&e.startsWith("#"))return e;if(!e)return"whitesmoke";const r=e.replace(/\./g,"-");try{const s=getComputedStyle(document.documentElement).getPropertyValue(`--chakra-colors-${r}`).trim();if(s&&s!=="")return s}catch{}const[n,o]=e.split(".");return n&&o&&((i=ll[n])!=null&&i[Number(o)])?ll[n][Number(o)]:`var(--chakra-colors-${r})`};function nr(e,t,r){return e?r:t}function Yt(e){const[t]=(e==null?void 0:e.split("."))||[],{secondary:r}=vy(e),n=jr(t).background,o=jr(t).highlight,i=jr(t).border,a=jr(t).property,s=jr(t).property;let u=jr(t).background,c=jr(t).highlight;return u=e==="transparent"?e:fe(u)+50,c=e==="transparent"?e:fe(c)+20,{bgColor:n,highlightColor:o,borderColor:i,textColor:a,propertyColor:s,secondary:r,bgColorFaint:u,highlightColorFaint:c}}function Ue(e=null){const{colorMode:t}=Oe(),r=e==null?void 0:e.includes("gray"),n=t==="dark",o=nr(n,"white","gray.900"),i=nr(n,"gray.100","gray.800"),a=nr(n,"gray.200","blackAlpha.400"),s=nr(n,"gray.200","blackAlpha.600"),u=nr(n,"gray.500","gray.700"),c=nr(n,"gray.700","gray.700"),l=nr(n,"gray.900","gray.900"),d=nr(n,"gray.400","gray.500"),f=nr(n,"gray.400","gray.500"),p=nr(n,"gray.900","gray.200"),b=nr(n,r?"gray.900":"gray.200",r?"gray.200":"gray.900"),g=nr(n,"gray.900","gray.200"),m=nr(n,e&&"#000000",e||"#ffffff"),w=nr(n,e||"#ffffff",e?"#000000":"#ffffff"),y=c,x=nr(n,"gray.300","gray.800"),v=nr(n,"white","blackAlpha.400"),C=nr(n,"green.100","green.700");return{canvas:o,background:i,backgroundSecondary:a,darkBackgroundSecondary:s,border:u,darkColor:l,backgroundWhiteColor:v,borderSecondary:c,colorActive:d,colorInactive:f,iconColor:g,moreIconColor:y,colorText:p,themedColorText:b,logoColor:m,logoColorSecondary:w,darkColorActive:x,greenColor:C}}var jt=(e=>(e.TOP_DOWN="TB",e.BOTTOM_UP="BT",e.LEFT_RIGHT="LR",e.RIGHT_LEFT="RL",e.CENTER="C",e))(jt||{});const Dt=["","icon-label","object","text"];var sv=typeof global=="object"&&global&&global.Object===Object&&global,cv=typeof self=="object"&&self&&self.Object===Object&&self,uv=sv||cv||Function("return this")(),ht=uv.Symbol,xy=Object.prototype,lv=xy.hasOwnProperty,dv=xy.toString,St=ht?ht.toStringTag:void 0;function fv(e){var t=lv.call(e,St),r=e[St];try{e[St]=void 0;var n=!0}catch{}var o=dv.call(e);return n&&(t?e[St]=r:delete e[St]),o}var hv=Object.prototype,pv=hv.toString;function gv(e){return pv.call(e)}var yv="[object Null]",bv="[object Undefined]",dl=ht?ht.toStringTag:void 0;function mv(e){return e==null?e===void 0?bv:yv:dl&&dl in Object(e)?fv(e):gv(e)}function vv(e){return e!=null&&typeof e=="object"}var xv="[object Symbol]";function wv(e){return typeof e=="symbol"||vv(e)&&mv(e)==xv}function Cv(e,t){for(var r=-1,n=e==null?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}var Ae=Array.isArray,fl=ht?ht.prototype:void 0,hl=fl?fl.toString:void 0;function wy(e){if(typeof e=="string")return e;if(Ae(e))return Cv(e,wy)+"";if(wv(e))return hl?hl.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function Eu(e){return e==null?"":wy(e)}function _v(e,t,r){var n=-1,o=e.length;t<0&&(t=-t>o?0:o+t),r=r>o?o:r,r<0&&(r+=o),o=t>r?0:r-t>>>0,t>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+t];return i}function Sv(e,t,r){var n=e.length;return r=r===void 0?n:r,!t&&r>=n?e:_v(e,t,r)}var Ev="\\ud800-\\udfff",jv="\\u0300-\\u036f",Rv="\\ufe20-\\ufe2f",kv="\\u20d0-\\u20ff",Pv=jv+Rv+kv,Av="\\ufe0e\\ufe0f",Tv="\\u200d",Ov=RegExp("["+Tv+Ev+Pv+Av+"]");function Cy(e){return Ov.test(e)}function Iv(e){return e.split("")}var _y="\\ud800-\\udfff",Mv="\\u0300-\\u036f",qv="\\ufe20-\\ufe2f",Nv="\\u20d0-\\u20ff",$v=Mv+qv+Nv,Lv="\\ufe0e\\ufe0f",Fv="["+_y+"]",bu="["+$v+"]",mu="\\ud83c[\\udffb-\\udfff]",Bv="(?:"+bu+"|"+mu+")",Sy="[^"+_y+"]",Ey="(?:\\ud83c[\\udde6-\\uddff]){2}",jy="[\\ud800-\\udbff][\\udc00-\\udfff]",Dv="\\u200d",Ry=Bv+"?",ky="["+Lv+"]?",zv="(?:"+Dv+"(?:"+[Sy,Ey,jy].join("|")+")"+ky+Ry+")*",Vv=ky+Ry+zv,Wv="(?:"+[Sy+bu+"?",bu,Ey,jy,Fv].join("|")+")",Gv=RegExp(mu+"(?="+mu+")|"+Wv+Vv,"g");function Uv(e){return e.match(Gv)||[]}function Hv(e){return Cy(e)?Uv(e):Iv(e)}function Kv(e){return function(t){t=Eu(t);var r=Cy(t)?Hv(t):void 0,n=r?r[0]:t.charAt(0),o=r?Sv(r,1).join(""):t.slice(1);return n[e]()+o}}var Jv=Kv("toUpperCase");function Zv(e,t,r,n){for(var o=-1,i=e==null?0:e.length;++o<i;)r=t(r,e[o],o,e);return r}function Yv(e){return function(t){return e==null?void 0:e[t]}}var Xv={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Qv=Yv(Xv),ex=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,rx="\\u0300-\\u036f",tx="\\ufe20-\\ufe2f",nx="\\u20d0-\\u20ff",ox=rx+tx+nx,ix="["+ox+"]",ax=RegExp(ix,"g");function sx(e){return e=Eu(e),e&&e.replace(ex,Qv).replace(ax,"")}var cx=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function ux(e){return e.match(cx)||[]}var lx=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function dx(e){return lx.test(e)}var Py="\\ud800-\\udfff",fx="\\u0300-\\u036f",hx="\\ufe20-\\ufe2f",px="\\u20d0-\\u20ff",gx=fx+hx+px,Ay="\\u2700-\\u27bf",Ty="a-z\\xdf-\\xf6\\xf8-\\xff",yx="\\xac\\xb1\\xd7\\xf7",bx="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",mx="\\u2000-\\u206f",vx=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Oy="A-Z\\xc0-\\xd6\\xd8-\\xde",xx="\\ufe0e\\ufe0f",Iy=yx+bx+mx+vx,My="['’]",pl="["+Iy+"]",wx="["+gx+"]",qy="\\d+",Cx="["+Ay+"]",Ny="["+Ty+"]",$y="[^"+Py+Iy+qy+Ay+Ty+Oy+"]",_x="\\ud83c[\\udffb-\\udfff]",Sx="(?:"+wx+"|"+_x+")",Ex="[^"+Py+"]",Ly="(?:\\ud83c[\\udde6-\\uddff]){2}",Fy="[\\ud800-\\udbff][\\udc00-\\udfff]",st="["+Oy+"]",jx="\\u200d",gl="(?:"+Ny+"|"+$y+")",Rx="(?:"+st+"|"+$y+")",yl="(?:"+My+"(?:d|ll|m|re|s|t|ve))?",bl="(?:"+My+"(?:D|LL|M|RE|S|T|VE))?",By=Sx+"?",Dy="["+xx+"]?",kx="(?:"+jx+"(?:"+[Ex,Ly,Fy].join("|")+")"+Dy+By+")*",Px="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ax="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Tx=Dy+By+kx,Ox="(?:"+[Cx,Ly,Fy].join("|")+")"+Tx,Ix=RegExp([st+"?"+Ny+"+"+yl+"(?="+[pl,st,"$"].join("|")+")",Rx+"+"+bl+"(?="+[pl,st+gl,"$"].join("|")+")",st+"?"+gl+"+"+yl,st+"+"+bl,Ax,Px,qy,Ox].join("|"),"g");function Mx(e){return e.match(Ix)||[]}function qx(e,t,r){return e=Eu(e),t=t,t===void 0?dx(e)?Mx(e):ux(e):e.match(t)||[]}var Nx="['’]",$x=RegExp(Nx,"g");function Lx(e){return function(t){return Zv(qx(sx(t).replace($x,"")),e,"")}}var Cr=Lx(function(e,t,r){return e+(r?" ":"")+Jv(t)});function je({label:e,children:t}){const r=S.cloneElement(t,{title:t.props.title??e});if(!D.Tooltip.Root){const n=D.Tooltip;return h.jsx(n,{label:e,placement:"top",fontSize:"xs",borderRadius:"15px",children:r})}return h.jsxs(D.Tooltip.Root,{positioning:{placement:"top"},children:[h.jsx(D.Tooltip.Trigger,{asChild:!0,children:r}),h.jsx(D.Portal,{children:h.jsx(D.Tooltip.Positioner,{children:h.jsx(D.Tooltip.Content,{fontSize:"xs",borderRadius:"15px",children:e})})})]})}function Mt(){const{border:e}=Ue();return h.jsx(D.chakra.span,{role:"separator","aria-orientation":"vertical",display:"block",flexShrink:0,w:"1px",h:"20px",mx:"4px",bg:e})}function Ir({children:e,value:t,onValueChange:r,disabled:n,style:o,title:i,icon:a,popupContent:s,labelCase:u="title","aria-label":c}){var R;const{colorMode:l}=Oe(),{background:d,border:f,colorText:p,colorActive:b,colorInactive:g}=Ue(),m=l==="dark",w=S.useId(),y=S.useRef(null),x=S.useRef(null),[v,C]=S.useState(!1);S.useEffect(()=>{const E=x.current;E.setAttribute("popover","auto");const M=I=>C(I.newState==="open");return E.addEventListener("toggle",M),()=>E.removeEventListener("toggle",M)},[]);const _=S.Children.toArray(e).filter(S.isValidElement).map(E=>{const M=E.props;return{value:String(M.value),label:typeof M.children=="string"&&u==="title"?Cr(M.children):M.children,disabled:M.disabled}}),k=()=>{var E;return(E=x.current)==null?void 0:E.hidePopover()},T=()=>{var W,z,re,te;const E=(W=y.current)==null?void 0:W.getBoundingClientRect(),M=x.current;if(!E||!M)return;const N=((te=(re=(z=y.current)==null?void 0:z.closest("[data-flow-toolbar-scroll]"))==null?void 0:re.parentElement)==null?void 0:te.getBoundingClientRect())??E;M.style.maxHeight=`${Math.max(60,Math.max(N.top-40,window.innerHeight-N.bottom-40))}px`;const O=M.getBoundingClientRect();M.style.left=`${Math.max(12,Math.min(E.right-O.width,window.innerWidth-O.width-12))}px`,M.style.top=`${Math.max(12,N.top>=O.height+36?N.top-O.height-24:Math.min(N.bottom+24,window.innerHeight-O.height-12))}px`},P=()=>{var I,N,O,W,z,re;if(n)return;if((I=x.current)==null||I.showPopover(),T(),s){(O=(N=x.current)==null?void 0:N.querySelector("input"))==null||O.focus({preventScroll:!0});return}const E=(W=x.current)==null?void 0:W.querySelectorAll('[role="option"]:not(:disabled)');(re=((z=x.current)==null?void 0:z.querySelector('[aria-selected="true"]:not(:disabled)'))??(E==null?void 0:E[0]))==null||re.focus()};S.useEffect(()=>{if(v){if(n){k();return}return window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0)}}},[v,n]);const j=`var(--chakra-colors-${d.replace(".","-")})`;return h.jsxs(h.Fragment,{children:[h.jsx(je,{label:i??c,children:h.jsx(D.chakra.button,{ref:y,type:"button",role:"combobox","data-flow-select-icon":a?"":void 0,"aria-label":c,title:i??c,"aria-haspopup":s?"dialog":"listbox","aria-expanded":v,"aria-controls":w,disabled:n,h:"30px",w:"160px",px:"6px",fontSize:"12px",border:"none",borderRadius:"4px",bg:"transparent",color:a?g:p,display:"flex",alignItems:"center",justifyContent:a?"center":"space-between",gap:2,style:o,onClick:()=>v?k():P(),onKeyDown:E=>{["ArrowDown","ArrowUp"].includes(E.key)&&(E.preventDefault(),P())},children:a??h.jsxs(h.Fragment,{children:[h.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((R=_.find(E=>E.value===t))==null?void 0:R.label)??t}),h.jsx(J.PiCaretUp,{size:16,style:{flexShrink:0}})]})})}),h.jsx(D.chakra.div,{ref:x,id:w,role:s?"dialog":"listbox","aria-label":c,position:"fixed",m:0,p:2,minW:"180px",maxW:"calc(100vw - 24px)",overflowY:"auto",bg:d,color:p,borderRadius:"30px",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"},...zr(j,`var(--chakra-colors-${(m?f:"gray.300").replace(".","-")})`)},onKeyDown:E=>{var N,O,W;if(s&&!["Escape","Tab"].includes(E.key))return;const M=[...E.currentTarget.querySelectorAll('[role="option"]:not(:disabled)')],I=M.indexOf(document.activeElement);if(["ArrowDown","ArrowUp","Home","End"].includes(E.key)){E.preventDefault();const z=E.key==="Home"?0:E.key==="End"?M.length-1:(I+(E.key==="ArrowDown"?1:-1)+M.length)%M.length;(N=M[z])==null||N.focus()}else E.key==="Escape"||E.key==="Tab"?(E.key==="Escape"&&(E.preventDefault(),E.stopPropagation()),k(),(O=y.current)==null||O.focus()):E.key.length===1&&E.key!==" "&&((W=M.find((z,re)=>{var te;return re>I&&((te=z.textContent)==null?void 0:te.toLowerCase().startsWith(E.key.toLowerCase()))}))==null||W.focus())},children:s??_.map(E=>h.jsxs(D.chakra.button,{type:"button",role:"option","aria-selected":E.value===t,disabled:E.disabled,tabIndex:-1,display:"flex",alignItems:"center",gap:3,px:3,py:2,w:"100%",borderRadius:"30px",fontSize:"sm",textAlign:"left",bg:"transparent",color:p,_hover:{bg:m?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:m?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var M;k(),(M=y.current)==null||M.focus(),r(E.value)},children:[h.jsx("span",{style:{flex:1},children:E.label}),h.jsx(J.PiCheck,{size:16,color:`var(--chakra-colors-${b.replace(".","-")})`,"aria-hidden":"true",style:{flexShrink:0,visibility:E.value===t?"visible":"hidden"}})]},E.value))})]})}const me=S.forwardRef(function({icon:t,...r},n){const{colorMode:o}=Oe();return h.jsx(D.IconButton,{ref:n,_hover:{bg:o==="dark"?"whiteAlpha.100":"blackAlpha.50"},title:r.title??r["aria-label"],...r,children:t})}),gt=S.forwardRef(function(t,r){const{themeColor:n}=Oe();return h.jsx(je,{label:"Close",children:h.jsx(me,{ref:r,size:"sm",variant:"ghost",color:n,focusRingColor:n,...t,"aria-label":t["aria-label"]??"Close selection tools",icon:h.jsx(J.PiXLight,{size:20,"aria-hidden":"true"})})})});function ju({label:e,icon:t,checked:r,onChange:n,disabled:o}){const{themeColor:i,readOnly:a}=Oe(),{colorInactive:s}=Ue();return h.jsx(je,{label:e,children:h.jsx(me,{"aria-label":e,"aria-pressed":r,icon:h.jsxs(h.Fragment,{children:[t,h.jsx(D.Text,{as:"span",fontSize:"xs",fontWeight:"normal",whiteSpace:"nowrap",children:e})]}),size:"sm",variant:"ghost",width:"auto",px:2,gap:2,color:r?i:s,disabled:o||a,onClick:()=>n(!r)})})}function zy({label:e="Compact layout"}={}){const{compactPropertyLayout:t,setCompactPropertyLayout:r,callbacks:n}=Oe();return h.jsx(ju,{label:e,checked:t,icon:h.jsx(D.Icon,{as:J.PiArrowsIn,boxSize:5}),onChange:o=>{var i;r(o),(i=n.onCompactPropertyLayoutChange)==null||i.call(n,o)}})}const Fx=bn.default.input`
8
8
  appearance: none;
9
9
  width: 100%;
10
10
  height: 24px;
@@ -13,19 +13,23 @@
13
13
  border: 0;
14
14
  box-shadow: none;
15
15
  background-color: transparent;
16
- background-size: 100% 6px;
16
+ background-size: 0 0;
17
17
  background-position: center;
18
18
  background-repeat: no-repeat;
19
19
  cursor: pointer;
20
20
  &::-webkit-slider-runnable-track {
21
21
  height: 6px;
22
- background: transparent;
22
+ background: var(--flow-range-track, transparent);
23
+ background-size: 100% 100%;
24
+ border-radius: 999px;
23
25
  border: 0;
24
26
  box-shadow: none;
25
27
  }
26
28
  &::-moz-range-track {
27
29
  height: 6px;
28
- background: transparent;
30
+ background: var(--flow-range-track, transparent);
31
+ background-size: 100% 100%;
32
+ border-radius: 999px;
29
33
  border: 0;
30
34
  box-shadow: none;
31
35
  }
@@ -51,7 +55,7 @@
51
55
  cursor: default;
52
56
  opacity: 0.5;
53
57
  }
54
- `;function bl({label:e,inputLabel:t,value:r,displayValue:n,min:o,max:i,onChange:a}){const s=S.useId(),{readOnly:u,themeColor:c}=Oe(),{colorInactive:l}=Ue(),d=(r-o)/(i-o)*100,f=c.includes(".")?`var(--chakra-colors-${c.replace(".","-")})`:c;return h.jsxs("div",{style:{width:224,maxWidth:"calc(100vw - 64px)",padding:12},children:[h.jsxs("label",{htmlFor:s,style:{display:"flex",justifyContent:"space-between",fontSize:14,marginBottom:12},children:[e," ",h.jsx("span",{children:n})]}),h.jsx(Vy,{id:s,"aria-label":t,type:"range",min:o,max:i,step:5,value:r,disabled:u,style:{color:f,accentColor:f,backgroundImage:`linear-gradient(to right, currentColor ${d}%, var(--chakra-colors-${l.replace(".","-")}) ${d}%)`},onChange:p=>a(Number(p.target.value))})]})}const vl={dot:{label:"Dots",icon:J.PiDotsNine},grid:{label:"Grid",icon:J.PiGridFour},steel:{label:"Steel",icon:J.PiLineSegments},none:{label:"Solid",icon:J.PiSquareFill},transparent:{label:"Transparent",icon:J.PiSelection}};function Wy(){const{spacing:e,setSpacing:t,edgeRadius:r,setEdgeRadius:n,backgroundVariant:o,setBackgroundVariant:i,callbacks:a,readOnly:s}=Oe(),u=vl[o].icon;return h.jsxs(h.Fragment,{children:[h.jsx(Mt,{}),h.jsx(Ir,{"aria-label":"Node spacing",title:`Spacing: ${Math.round(e*100)}%`,icon:h.jsx(J.PiArrowsOutCardinal,{size:20}),style:{width:36},value:"spacing",disabled:s,onValueChange:()=>{},popupContent:h.jsx(bl,{label:"Spacing",inputLabel:"Node spacing percentage",min:50,max:200,value:Math.round(e*100),displayValue:`${Math.round(e*100)}%`,onChange:c=>{var l;t(c/100),(l=a.onSpacingChange)==null||l.call(a,c/100)}}),children:h.jsx("option",{value:"spacing",children:"Spacing"})}),h.jsx(Mt,{}),h.jsx(Ir,{"aria-label":"Edge radius",title:`Edge radius: ${r??"Default"}`,icon:h.jsx(J.PiBezierCurve,{size:20}),style:{width:36},value:"radius",disabled:s,onValueChange:()=>{},popupContent:h.jsx(bl,{label:"Edge radius",inputLabel:"Edge corner radius",min:0,max:500,value:r??500,displayValue:r??"Default",onChange:c=>{var l;n(c),(l=a.onEdgeRadiusChange)==null||l.call(a,c)}}),children:h.jsx("option",{value:"radius",children:"Edge radius"})}),h.jsx(Mt,{}),h.jsxs(Ir,{"aria-label":"Background variant",title:`Background: ${vl[o].label}`,icon:h.jsx(u,{size:20,"data-background-icon":o}),style:{width:36},value:o,disabled:s,onValueChange:c=>{var l;i(c),(l=a.onBackgroundVariantChange)==null||l.call(a,c)},children:[h.jsx("option",{value:"dot",children:"Dots"}),h.jsx("option",{value:"grid",children:"Grid"}),h.jsx("option",{value:"steel",children:"Steel"}),h.jsx("option",{value:"none",children:"Solid"}),h.jsx("option",{value:"transparent",children:"Transparent"})]})]})}const or=[];for(let e=0;e<256;++e)or.push((e+256).toString(16).slice(1));function Fx(e,t=0){return(or[e[t+0]]+or[e[t+1]]+or[e[t+2]]+or[e[t+3]]+"-"+or[e[t+4]]+or[e[t+5]]+"-"+or[e[t+6]]+or[e[t+7]]+"-"+or[e[t+8]]+or[e[t+9]]+"-"+or[e[t+10]]+or[e[t+11]]+or[e[t+12]]+or[e[t+13]]+or[e[t+14]]+or[e[t+15]]).toLowerCase()}let Jn;const Bx=new Uint8Array(16);function Dx(){if(!Jn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Jn=crypto.getRandomValues.bind(crypto)}return Jn(Bx)}const zx=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),xl={randomUUID:zx};function Ru(e,t,r){var o;if(xl.randomUUID&&!e)return xl.randomUUID();e=e||{};const n=e.random??((o=e.rng)==null?void 0:o.call(e))??Dx();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Fx(n)}const bn={label:"Untitled",description:"",isTask:!1,isLocked:!1},ku={id:null,type:"text",data:{...bn,viewProps:{width:"max-content !important",maxWidth:700,height:"100%",borderColor:"transparent",borderRadius:25,borderWidth:0,boxShadow:"none",textOverflow:"ellipsis",fontWeight:"bold",textColor:"gray.800",textAlign:"center"}}},wl={id:null,type:"objectView",data:{...bn,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:53,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},Vx={id:null,type:"arrayView",data:{...bn,viewProps:{width:"max-content !important",maxWidth:700,height:"100%",textAlign:"center",borderRadius:25,fontSize:"5xl",borderWidth:2,textOverflow:"ellipsis",wordBreak:"keep-all",fontWeight:"bold",textColor:"gray.900",placeholder:"Start Typing"}}},Cl={id:null,type:"workflowStep",data:{...bn,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}},yr=e=>typeof e=="object",Gy=e=>Array.isArray(e),Wx=["order","position","selected","locked","grabbed","grabbable","scratch"],Vr=e=>Object.entries(e).reduce((t,[r,n])=>(!yr(n)&&!r.startsWith("$")&&(t[r]=n),t),{}),Pu=(e,t)=>typeof e=="string"&&e.startsWith("$")?Zn(e,t):yr(e)&&!Gy(e)?Object.entries(e).reduce((r,[n,o])=>(typeof o=="string"&&o.startsWith("$")&&n==="..."?(delete r["..."],r[n]={...Zn(o,t),...e}):typeof o=="string"&&o.startsWith("$")?r[n]=Zn(o,t):r[n]=o,r),{}):e,Wr=e=>Object.entries(e).reduce((t,[r,n])=>(yr(n)&&r&&n&&!r.startsWith("$")&&(Wx.includes(r)&&(r=r+"#"),t[r]=n),t),{}),Yr=(e,t,{label:r,parent:n=void 0},o,i=null)=>(i!==null&&(yr(i)||Gy(i))&&(i=JSON.stringify(i,null,2)),{data:{parent:n,...e.data,id:t,text:r||"",label:r,code:i||null,type:e.type,description:o}}),Dr=(e,t,r=null,n=null,o=null,i=!1,a=null)=>({data:{id:Ru(),source:o?t:e,target:o?e:t,label:n||"",isInverted:o,isEdgeAnimated:i,parent:a}}),Gr=(e,t=[])=>{const r={},n={};let o=[];if(e)for(const[i,a]of Object.entries(e))i.startsWith("$")&&i!=="$"?r[i.slice(1)]=a:i!=="$"?n[i]=a:i==="$"&&(o=a);return{newConfig:r,updatedObject:n,arrayObject:o}},lt=(e,t)=>{let r=wl;const{view:n,borderColor:o,borderRadius:i,bgColor:a,textColor:s,fontSize:u,stepType:c}=t;e=n||e,c?r={...Cl}:e==="object"?r=wl:e==="text"?r=ku:e==="array"?r=Vx:e==="workflowStep"&&(r={...Cl});const l=r.data.viewProps;return r.data.viewProps={...l,borderRadius:i||(c?15:53),bgColor:a,borderColor:o,textColor:s,fontSize:u},r.data.config=t,{config:r}},zt=(e,t)=>(e=t.find(n=>n.data.id===e)?`${e}.#`:e,e),Zn=(e,{ids:t,jsnObjct:r})=>{if(typeof e=="string"&&(e!=null&&e.startsWith("$"))){const n=e.replace("$","").replace("*","");e==null||e.endsWith("*");const o=t.find(s=>s.split(".").slice(-1)[0]===n||n===s);if(!o)return e;const i=Gx(o,r);return JSON.stringify(i).includes(e)?e:i||e}return e},Gx=(e,t)=>{let r=e.split(".").splice(1);return r=r[r.length-1]==="#"||r[r.length-1].includes("{")?r.slice(0,-2):r,(i=>r.reduce((a,s)=>{s=s.replace("[","").replace("]","");const{arrayObject:u}=Gr(a);return a=u.length?u:a,a[s]},i))(t)};function ft(e,t="root",r=[]){try{const{arrayObject:n}=Gr(e);n.length&&(e=n);const o=Vr(e),i=Wr(e);return yr(e)?(Ae(e)||Ae(e)&&t==="root"||!Ae(e)&&Object.keys(o).length||t==="root")&&r.push(t):r.push(t),Object.keys(i).length&&!Ae(e)?qt({chldPth:null,itrblObjct:i,nodes:r,path:t}):Ae(e)&&e.forEach((a,s)=>{const u=Vr(a),c=Wr(a),{newConfig:l,arrayObject:d}=Gr(a);let f=`${t}.${s}`;yr(a)?Object.keys(u).length?(ft(u,f,r),Object.keys(c).length&&!Ae(a)&&qt({chldPth:f,itrblObjct:c,nodes:r,path:t})):Object.keys(c).length&&!Ae(a)?qt({chldPth:f,itrblObjct:c,nodes:r,path:t}):Ae(a)&&Uy({chldPth:f,item:a,nodes:r,path:t}):r.push(f)}),{nodes:r}}catch{return{nodes:r}}}const qt=({chldPth:e,itrblObjct:t,nodes:r,path:n})=>Object.entries(t).forEach(([o,i],a)=>{const s=Vr(i),u=Wr(i),{newConfig:c,arrayObject:l}=Gr(i);l.length&&(i=l),n.split(".").slice(0,2).join(".");let d=e?`${e}.${o}`:`${n}.${o}`;if(yr(i)&&!Ae(i)){const f=Object.keys(s).length===0;if(f&&(lt("array",c),r.push(d)),Object.keys(s).length){const p=Ae(i)?`${i.length||""}`:`{${Object.keys(i).length||""}}`;let m=d;f&&(m=`${d}.${p}`),ft(i,m,r)}else Object.keys(u).length&&!Ae(i)?qt({chldPth:d,itrblObjct:u,path:d,nodes:r}):ft(i,d,r)}else Ae(i)&&ft(i,d,r)}),Uy=({chldPth:e,item:t,nodes:r,path:n})=>t.forEach((o,i)=>{let a=`${e}.${i}`;const s=Wr(o),u=Vr(o);yr(o)?!Ae(o)&&Object.keys(u).length?ft(o,a,r):Object.keys(s).length&&!Ae(o)?qt({chldPth:a,itrblObjct:s,path:n,nodes:r}):Ae(o)&&Uy({chldPth:a,item:o,nodes:r,path:n}):r.push(a)}),dn=[];let Nt;function Qr(e,t="root",r=[],n=[],o="untitled",i={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},a={}){if(!e||typeof e!="object")return console.error("Invalid object passed",e),{nodes:r,edges:n};const s=e;if(!Nt){const{nodes:l}=ft(e);Nt={ids:l,jsnObjct:e}}let{hideDefaultObject:u,sprtObjctKy:c}=i;try{t=zt(t,r);const{newConfig:l,arrayObject:d}=Gr(e),f=Object.keys(a).length>0?a:l;d.length&&(e=d);const p=Vr(e),m=Wr(e),{label:g,collapsed:b,parent:w}=f;if(!yr(e))r.push(Yr(ku,t,{label:g||t,parent:w},e,s));else if(Ae(e)||Ae(e)&&t==="root"){const{config:y}=lt("array",f),x=Ae(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,v=t==="root"?o:`${o} ${x}`;r.push(Yr(y,t,{label:g||v,parent:w},e,Ae(s)?{[o]:s}:s))}else if(!Ae(e)&&Object.keys(p).length||t==="root"){const{config:y}=lt(null,f),x=Ae(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,v=t.split("."),C=v[v.length-1];let _=isNaN(Number(C))?null:Number(C)+1;const k=isNaN(Number(C))?C:v[v.length-2]+" "+_,T=t==="root"?o:k;let P=!1;Number.isNaN(Number(o))||(P=!0);const j=e;if(g){const{config:R}=lt("object",f);r.push(Yr(R,t,{label:g||`${g} ${x}`,parent:w},p,j))}else y.data.headerTitle=T,r.push(Yr(y,t,{label:g,parent:w},p,j))}return b||(Object.keys(m).length&&!Ae(e)?$t({flowConfig:i,chldPth:null,edges:n,isInverted:null,itrblObjct:m,nodes:r,path:t,newConfig:f}):Ae(e)&&e.forEach((y,x)=>{y=Pu(y,Nt);const v=y,C=Vr(y),_=Wr(y),{newConfig:k,arrayObject:T}=Gr(y);T.length&&(y=T);const{config:P}=lt(typeof y=="string"?"text":"array",k),{hideConfig:j,sourceLabel:R,label:E,isEdgeAnimated:M,parent:I}=k;u=u||j;const N=t==="root"&&i.isCntr,O=t.split(".").slice(0,2).join("."),W=dn.includes(O),z=i.isCntr&&W||x%2===0&&N;let re=`${t}.${x}`;re=zt(re,r),z&&dn.push(re),yr(y)?Object.keys(C).length&&!Ae(y)?(n.push(Dr(t,re,null,R,z,M)),Qr(y,re,r,n,E||x,i,k)):Object.keys(_).length&&!Ae(y)?$t({flowConfig:i,chldPth:re,isInverted:z,edges:n,itrblObjct:_,nodes:r,path:t,newConfig:k,forceIsInverted:!0}):Ae(y)?Hy({flowConfig:i,chldPth:re,edges:n,isInverted:z,item:y,nodes:r,path:t}):yr(y)&&$t({flowConfig:i,chldPth:re,isInverted:z,edges:n,itrblObjct:[y],nodes:r,path:t,newConfig:k}):(n.push(Dr(t,re,null,R,z,M)),r.push(Yr(P,re,{label:E||String(y),parent:I},y,v)))})),{nodes:r,edges:n}}catch{return{nodes:r,edges:n}}}const $t=({chldPth:e,flowConfig:t,edges:r,itrblObjct:n,nodes:o,isInverted:i,path:a,newConfig:s,forceIsInverted:u=!1})=>{let{hideDefaultObject:c,sprtObjctKy:l}=t;return Object.entries(n).forEach(([d,f],p)=>{f=Pu(f,Nt);const m=f,g=Vr(f),b=Wr(f),{newConfig:w,arrayObject:y}=Gr(f);y.length&&(f=y);const{hideConfig:x,sourceLabel:v,label:C,content:_,target:k,targetLabel:T,collapsed:P,isEdgeAnimated:j,parent:R}=w;c=c||x;const E=a==="root"&&t.isCntr,M=a.split(".").slice(0,2).join("."),I=dn.includes(M);u||(i=t.isCntr&&I||p%2===0&&E);let N=e?`${e}.${d}`:`${a}.${d}`;if(N=zt(N,o),i&&dn.push(N),k&&r.push(Dr(N,k,null,T,i,j)),yr(f)&&!Ae(f)){r.push(Dr(a,N,null,v,i,j));const O=l||Object.keys(g).length===0;if(O){const W=_?"object":"array",{config:z}=lt(W,w);z.data.headerTitle=_?C:null,o.push(Yr(z,N,{label:C||d,parent:R},f,m))}if(Object.keys(g).length&&!c){const W=Ae(f)?` ${f.length||""}`:`{${Object.keys(f).length||""}}`;let z=N;O&&(z=`${N}.${W}`,z=zt(z,o),r.push(Dr(N,z,null,v,i,j))),Qr(f,z,o,r,C||d,t,w)}else Object.keys(b).length&&!Ae(f)?$t({chldPth:N,flowConfig:t,itrblObjct:b,path:N,edges:r,nodes:o,newConfig:w,isInverted:i}):Qr(f,N,o,r,d,t,w)}else Ae(f)&&(r.push(Dr(a,N,null,v,i,j)),Qr(f,N,o,r,d,t,w))})},Hy=({flowConfig:e,chldPth:t,edges:r,isInverted:n,item:o,nodes:i,path:a})=>o.forEach((s,u)=>{let c=`${t}.${u}`;c=zt(c,i);const l=s;s=Pu(s,Nt);const d=Wr(s),f=Vr(s),{newConfig:p}=Gr(s),{collapsed:m,label:g,parent:b,sourceLabel:w,isEdgeAnimated:y,content:x}=p;yr(s)?!Ae(s)&&Object.keys(f).length?(r.push(Dr(a,c,null,w,n,y)),Qr(s,c,i,r,u,e,p)):Object.keys(d).length&&!Ae(s)&&!m?$t({chldPth:c,flowConfig:e,itrblObjct:d,path:a,edges:r,nodes:i,isInverted:n,newConfig:p}):Ae(s)&&Hy({flowConfig:e,chldPth:c,edges:r,isInverted:n,item:s,nodes:i,path:a}):(r.push(Dr(a,c,null,w,n,y)),i.push(Yr(ku,c,{label:g||String(s),parent:b},s,l)))});function Ux(e,t){const r=new Set,n=c=>{if(!(!c||typeof c!="object")){typeof c.$parent=="string"&&r.add(c.$parent);for(const[l,d]of Object.entries(c))(!l.startsWith("$")||l==="$")&&n(d)}};if(n(e),!r.size)return t;const o=new Map(t.nodes.map(c=>[c.data.id,c])),i=c=>{var p,m;let l=c.data.id;const d=new Set([c.data.id]);let f=c.data.parent;for(;f&&!d.has(f);)r.has(f)&&o.has(f)&&((p=ve(e,f))!=null&&p.$collapsed)&&(l=f),d.add(f),f=(m=o.get(f))==null?void 0:m.data.parent;return l},a=new Map(t.nodes.map(c=>[c.data.id,i(c)])),s=t.nodes.filter(c=>a.get(c.data.id)===c.data.id).map(c=>{if(!r.has(c.data.id))return c;const l=ve(e,c.data.id),d=!!(l!=null&&l.$collapsed);return{...c,data:{...c.data,...d?{type:"arrayView"}:{},config:{...c.data.config,parentContainer:!0,collapsed:d,...d?{labelBelow:!0,icon:(l==null?void 0:l.$icon)||"PiStack"}:{}}}}}),u=new Set(s.map(c=>c.data.id));return{nodes:s,edges:t.edges.flatMap(c=>{const l=a.get(c.data.source),d=a.get(c.data.target);return!l||!d||!u.has(l)||!u.has(d)?[]:l===c.data.source&&d===c.data.target?[c]:l===d?[]:[{...c,data:{...c.data,source:l,target:d,collapsedEndpoints:c.data.collapsedEndpoints??{source:c.data.source,target:c.data.target}}}]})}}function vn(e){if(!Array.isArray(e==null?void 0:e.$connections))return[];const t=new Map;return e.$connections.flatMap((r,n)=>{if(!r||typeof r!="object")return[];const o=r;if(typeof o.target!="string"||!/^root(?:\.|$)/.test(o.target))return[];if(o.sourceProperty!==void 0&&typeof o.sourceProperty!="string")return[];if(o.targetProperty!==void 0&&typeof o.targetProperty!="string")return[];const i=typeof o.id=="string"&&o.id?JSON.stringify(["id",o.id]):JSON.stringify(["ports",o.target,o.sourceProperty??null,o.targetProperty??null]),a=t.get(i)??0;return t.set(i,a+1),[{value:o,key:`${i}#${a}`,index:n}]})}function Ky(e,t,r){const n=vn(e).find(u=>u.key===t);if(!n)return e;const o=r(n.value),i=e.$connections.flatMap((u,c)=>c===n.index?o?[o]:[]:[u]);if(i.length)return{...e,$connections:i};const{$connections:a,...s}=e;return s}function Hx(e){const t=[],r=(n,o)=>{if(!n||typeof n!="object")return n;if(Array.isArray(n))return n.map((i,a)=>r(i,`${o}.${a}`));for(const i of vn(n)){const a=i.value;t.push({data:{id:`connection:${JSON.stringify([o,i.key])}`,source:o,target:a.target,type:typeof a.type=="string"?a.type:void 0,sourceProperty:a.sourceProperty,targetProperty:a.targetProperty,icon:typeof a.icon=="string"?a.icon:void 0,label:typeof a.label=="string"?a.label:void 0,color:typeof a.color=="string"?a.color:void 0,isEdgeDashed:a.style==="dashed",isEdgeAnimated:a.style==="animated",...["dashed","traveling"].includes(a.animationVariant)?{edgeAnimationVariant:a.animationVariant}:{},connection:{address:o,key:i.key}}})}return Object.fromEntries(Object.entries(n).filter(([i])=>i!=="$connections").map(([i,a])=>[i,i==="$"?r(a,o):i.startsWith("$")?a:r(a,`${o}.${i}`)]))};return{json:r(e,"root"),edges:t}}const Vt="root",_l=e=>e==="#"||e.startsWith("{")||/^\s\d*$/.test(e);function Mr(e){const t=e.split(".");for(t[0]===Vt&&t.shift();t.length&&_l(t[t.length-1]);)t.pop();return t.filter(r=>!_l(r))}function xn(e){return e==null||typeof e!="object"?e:Array.isArray(e.$)?e.$:e}function ve(e,t){return Mr(t).reduce((r,n)=>{var o;if(r!=null)return(o=xn(r))==null?void 0:o[n]},e)}function Kx(e){return Array.isArray(e)?[...e]:{...e}}function mr(e,t,r){const n=Mr(t),o=(i,a)=>{if(a===n.length)return r(i);const s=n[a],u=xn(i);if(u==null||typeof u!="object")return i;const c=o(u[s],a+1);if(Object.is(c,u[s]))return i;const l=Kx(u);return l[s]=c,u!==i?{...i,$:l}:l};return o(e,0)}function Or(e,t,r){const n=r===""&&t!=="$content"||r===void 0||r===null;if(Array.isArray(e))return n?e:{[t]:r,$:[...e]};const o=e!=null&&typeof e=="object"?{...e}:{};return e!=null&&typeof e!="object"&&(o.$label=String(e)),n?delete o[t]:o[t]=r,o}function cr(e,t,r,n){return mr(e,t,o=>r==="$label"&&typeof o=="string"&&typeof n=="string"&&n!==""?n:Or(o,r,n))}const Jy=(e,t,r)=>cr(e,t,"$collapsed",r);function Wt(e){if(e.connection)return{address:e.connection.address,kind:"connection"};const t=e.collapsedEndpoints??e,r=e.isInverted?t.target:t.source,n=e.isInverted?t.source:t.target,o=Mr(r).join("."),i=Mr(n).join(".");return i.startsWith(o?o+".":"")&&i!==o?{address:n,kind:"hierarchy"}:o.startsWith(i?i+".":"")&&o!==i?{address:r,kind:"hierarchy"}:{address:r,kind:"target"}}function Br(e,t,r,n){if(t.connection){const s=t.connection;return mr(e,s.address,u=>Ky(u,s.key,c=>{if(r==="$edgeIcon")return Or(c,"icon",n);if(r==="$edgeType")return Or(c,"type",n);if(r==="$edgeAnimationVariant")return Or(c,"animationVariant",n);if(r==="$sourceLabel"||r==="$edgeColor")return Or(c,r==="$sourceLabel"?"label":"color",n);const l=r==="$isEdgeAnimated"?"animated":"dashed";return n?{...c,style:l}:c.style===l?Or(c,"style",void 0):c}))}const{address:o,kind:i}=Wt(t),a=i==="target"&&r==="$sourceLabel"?"$targetLabel":i==="target"&&r==="$edgeType"?"$targetEdgeType":i==="target"&&r==="$edgeIcon"?"$targetIcon":i==="target"&&r==="$edgeAnimationVariant"?"$targetAnimationVariant":r;return mr(e,o,s=>Or(s,a,n))}const Zy=(e,t,r)=>Br(Br(e,t,"$isEdgeAnimated",r==="animated"||void 0),t,"$isEdgeDashed",r==="dashed"||void 0);function Au(e,t,r,n){let o=n||"";const i=mr(e,t,s=>{const u=xn(s);if(Array.isArray(u)){o=String(u.length);const l=[...u,r];return u===s?l:{...s,$:l}}const c=s!=null&&typeof s=="object"&&!Array.isArray(s)?{...s}:s!=null&&typeof s!="object"?{$label:String(s)}:{};if(!o){let l=1;for(;`node_${l}`in c;)l++;o=`node_${l}`}return c[o]=r,c}),a=Mr(t);return{json:i,address:[Vt,...a,o].join(".")}}function Yy(e,t){const r=Mr(t);if(!r.length)return e;const n=r[r.length-1],o=[Vt,...r.slice(0,-1)].join(".");return mr(e,o,i=>{const a=xn(i);if(a==null||typeof a!="object"||!Object.prototype.hasOwnProperty.call(a,n))return i;if(Array.isArray(a)){const c=a.filter((l,d)=>String(d)!==n);return a===i?c:{...i,$:c}}const{[n]:s,...u}=i;return u})}const Xy=(e,t,r,n)=>cr(n?mr(e,t,o=>Or(o,"$targetLabel",n)):e,t,"$target",r);function Tu(e,t,r){const n=ve(e,t);return vn(n).some(({value:i})=>i.target===r.target&&i.sourceProperty===r.sourceProperty&&i.targetProperty===r.targetProperty)?e:mr(e,t,i=>Or(i,"$connections",[...Array.isArray(i==null?void 0:i.$connections)?i.$connections:[],{...r,id:r.id||Ru()}]))}function Qy(e,t){if(t.connection){const i=t.connection;return vn(ve(e,i.address)).some(a=>a.key===i.key)?{json:mr(e,i.address,a=>Ky(a,i.key,()=>null)),removed:!0}:{json:e,removed:!1}}const{address:r,kind:n}=Wt(t);return n==="hierarchy"?ve(e,r)===void 0?{json:e,removed:!1}:{json:mr(e,r,i=>({...i,$hideParentEdge:!0})),removed:!0}:n!=="target"?{json:e,removed:!1}:{json:mr(e,r,i=>{const{$target:a,$targetLabel:s,...u}=i||{};return u}),removed:!0}}function vu(e,t={}){var w;const r=Hx(e),{nodes:n,edges:o}=Qr(r.json,Vt,[],[],t.title||"untitled",{hideDefaultObject:!!t.hideDefaultObject,sprtObjctKy:!!t.separateObjectKeys,isCntr:!!t.isCenter}),i=new Set(n.map(y=>y.data.id)),a=new Map;for(const y of n){const x=y.data.id;if(!x.endsWith(".0")||ve(e,x)!==void 0)continue;const v=x.slice(0,-2),C=ve(e,v);!i.has(v)&&C&&typeof C=="object"&&!Array.isArray(C)&&typeof C.$label=="string"&&Object.keys(C).every(_=>_.startsWith("$")&&_!=="$")&&a.set(x,v)}const s=y=>a.get(y)??y,u=new Set(n.flatMap(y=>y.data.parent?[s(y.data.parent)]:[])),c=n.map(y=>{var T;const x=s(y.data.id),v=ve(e,x),C={...y.data,id:x},_=v&&typeof v=="object"&&!Array.isArray(v)&&"$"in v?v.$:v;if((Array.isArray(_)?_.length>0:_&&typeof _=="object"&&Object.keys(_).some(P=>!P.startsWith("$")))&&(C.config={...C.config,collapsed:!!v.$collapsed}),u.has(x)||(C.viewProps={...C.viewProps},delete C.viewProps.borderWidth),!v||typeof v!="object"||Array.isArray(v))return{data:C};if(v.$form&&typeof v.$form=="object"&&(C.config={...C.config,form:v.$form},C.type="objectView"),Array.isArray(v.$ports)){const P=v.$ports.filter(j=>j&&typeof j.id=="string"&&["source","target"].includes(j.role)&&["top","right","bottom","left"].includes(j.side));C.config={...C.config,ports:P}}return C.parent&&(C.parent=s(C.parent)),typeof v.$label=="string"&&(C.label=v.$label,C.headerTitle=v.$label),typeof v.$subtitle=="string"&&(C.config={...C.config,subtitle:v.$subtitle}),typeof v.$outline=="boolean"&&(C.viewProps={...C.viewProps,outline:v.$outline}),["solid","dashed","dotted","double"].includes(v.$borderStyle)&&(C.viewProps={...C.viewProps,borderStyle:v.$borderStyle}),Number.isFinite(v.$borderWidth)&&v.$borderWidth>=0&&(C.viewProps={...C.viewProps,borderWidth:v.$borderWidth}),Number.isFinite(v.$borderRadius)&&v.$borderRadius>=0&&(C.viewProps={...C.viewProps,borderRadius:v.$borderRadius}),typeof v.$isNodeAnimated=="boolean"&&(C.isNodeAnimated=v.$isNodeAnimated),["traveling","pulse"].includes(v.$nodeAnimationVariant)&&(C.nodeAnimationVariant=v.$nodeAnimationVariant),typeof v.$content=="string"&&(C.config={...C.config,content:v.$content},v.$view||(C.type="objectView")),(((T=C.config)==null?void 0:T.collapsed)!==void 0||v.$collapsed!==void 0||v.$icon!==void 0)&&(C.config={...C.config||{}},(v.$collapsed!==void 0||C.config.collapsed!==void 0)&&(C.config.collapsed=!!v.$collapsed),v.$icon!==void 0&&(C.config.icon=v.$icon)),{data:C}}),l=new Map,d=o.map(y=>{const x=s(y.data.source),v=s(y.data.target),C=`${x}->${v}`,_=l.get(C)??0;l.set(C,_+1);const k={...y.data,id:_?`${C}#${_}`:C,source:x,target:v},T=Wt(k),P=ve(e,T.address);if(P&&typeof P=="object"){const j=P[T.kind==="target"?"$targetEdgeType":"$edgeType"];typeof j=="string"&&(k.type=j);const R=P[T.kind==="target"?"$targetIcon":"$edgeIcon"];typeof R=="string"&&(k.icon=R),P.$isEdgeAnimated!==void 0&&(k.isEdgeAnimated=!!P.$isEdgeAnimated);const E=P[T.kind==="target"?"$targetAnimationVariant":"$edgeAnimationVariant"];["dashed","traveling"].includes(E)&&(k.edgeAnimationVariant=E),P.$isEdgeDashed!==void 0&&(k.isEdgeDashed=!!P.$isEdgeDashed),P.$edgeColor&&(k.color=P.$edgeColor)}return{data:k}});if(!Array.isArray(e)&&(e==null?void 0:e.$hideRoot)===!0){const y=c.findIndex(x=>x.data.id===Vt);y!==-1&&c.splice(y,1)}const f=new Set(c.map(y=>y.data.id));for(let y=d.length-1;y>=0;y--){const x=d[y].data,v=Wt(x);(!f.has(x.source)||!f.has(x.target)||v.kind==="hierarchy"&&((w=ve(e,v.address))==null?void 0:w.$hideParentEdge)===!0)&&d.splice(y,1)}d.push(...r.edges.filter(y=>f.has(y.data.source)&&f.has(y.data.target)));const p=Ux(e,{nodes:c,edges:d}),m=p.nodes.filter(y=>{var x;return(x=y.data.config)==null?void 0:x.collapsed}).map(y=>Mr(y.data.id));if(!m.length)return p;const g=p.nodes.filter(y=>{const x=Mr(y.data.id);return!m.some(v=>v.length<x.length&&v.every((C,_)=>C===x[_]))}),b=new Set(g.map(y=>y.data.id));return{nodes:g,edges:p.edges.filter(y=>b.has(y.data.source)&&b.has(y.data.target))}}function Jx(e,t){const r=new Set(e.filter(u=>{var c,l;return(l=(c=u.data)==null?void 0:c.config)==null?void 0:l.collapsed}).map(u=>u.data.id));if(!r.size)return{nodes:e,edges:t};const n=new Map(e.map(u=>[u.data.id,u])),o=new Set(e.map(u=>u.data.parent).filter(Boolean)),i=new Map(e.map(u=>{var f;let c=u.data.id,l=u.data.parent;const d=new Set([c]);for(;l&&!d.has(l);)r.has(l)&&(c=l),d.add(l),l=(f=n.get(l))==null?void 0:f.data.parent;return[u.data.id,c]})),a=new Map;for(const u of t){const c=u.data.isInverted?u.data.target:u.data.source,l=u.data.isInverted?u.data.source:u.data.target;(a.get(c)??a.set(c,[]).get(c)).push(l)}const s=new Set(e.filter(u=>i.get(u.data.id)!==u.data.id).map(u=>u.data.id));for(const u of r){if(o.has(u))continue;const c=[...a.get(u)||[]];for(;c.length;){const l=c.pop();r.has(l)||s.has(l)||(s.add(l),c.push(...a.get(l)||[]))}}return{nodes:e.filter(u=>!s.has(u.data.id)).map(u=>{var c;return r.has(u.data.id)&&o.has(u.data.id)?{...u,data:{...u.data,type:"arrayView",label:u.data.label??u.data.headerTitle,config:{...u.data.config,parentContainer:!0,labelBelow:!0,icon:((c=u.data.config)==null?void 0:c.icon)||"PiStack"}}}:u}),edges:t.flatMap(u=>{const c=i.get(u.data.source)??u.data.source,l=i.get(u.data.target)??u.data.target;return s.has(c)||s.has(l)?[]:c===u.data.source&&l===u.data.target?[u]:c===l?[]:[{...u,data:{...u.data,source:c,target:l,collapsedEndpoints:u.data.collapsedEndpoints??{source:u.data.source,target:u.data.target}}}]})}}function Ou(e,t){const r=JSON.parse(e);let n=512;const o=(a,s=[])=>{if(--n<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(!a||typeof a!="object"||Array.isArray(a))throw new Error("Expected a JSON Schema object.");const u=new Set(["$schema","$id","$defs","definitions","$ref","title","description","default","examples","type","properties","required","items","enum","const","anyOf","additionalProperties"]);for(const l of Object.keys(a))if(!u.has(l))throw new Error(`Unsupported JSON Schema keyword: ${l}`);const c=["$schema","$id","$defs","definitions","title","description","default","examples"];if(a.$ref){if(Object.keys(a).some(d=>!["$ref","title","description"].includes(d)))throw new Error("Use $ref without sibling constraints.");if(typeof a.$ref!="string"||!a.$ref.startsWith("#/")||s.includes(a.$ref))throw new Error("Only nonrecursive local $ref references are supported.");let l=r;for(const d of a.$ref.slice(2).split("/")){const f=d.replace(/~1/g,"/").replace(/~0/g,"~");if(!l||!Object.prototype.hasOwnProperty.call(l,f))throw new Error(`Unresolved reference: ${a.$ref}`);l=l[f]}return o(l,[...s,a.$ref])}if(a.anyOf){if(!Array.isArray(a.anyOf)||!a.anyOf.length||Object.keys(a).some(l=>l!=="anyOf"&&!c.includes(l)))throw new Error("Use a nonempty anyOf without sibling type constraints.");return{kind:"union",types:a.anyOf.map(l=>o(l,s))}}if(Object.prototype.hasOwnProperty.call(a,"const")||a.enum){if(Object.keys(a).some(f=>![...c,"const","enum","type"].includes(f))||a.enum&&Object.prototype.hasOwnProperty.call(a,"const"))throw new Error("Use enum or const without sibling constraints other than type.");const l=Object.prototype.hasOwnProperty.call(a,"const")?[a.const]:a.enum;if(!Array.isArray(l)||!l.length)throw new Error("Expected a nonempty enum.");return{kind:"union",types:l.map(f=>{if(f!==null&&!["string","number","boolean"].includes(typeof f))throw new Error("Only primitive literals are supported.");const p=f===null?"null":typeof f;if(a.type&&!(Array.isArray(a.type)?a.type:[a.type]).some(m=>m===p||m==="integer"&&Number.isInteger(f)))throw new Error("Literal does not match its declared type.");return{kind:"literal",value:f}})}}if(Array.isArray(a.type)){if(!a.type.length||a.type.some(l=>typeof l!="string"))throw new Error("Expected a nonempty list of primitive types.");if(Object.keys(a).some(l=>l!=="type"&&!c.includes(l)))throw new Error("Use anyOf for unions with object or array constraints.");return{kind:"union",types:a.type.map(l=>o({type:l},s))}}if((a.properties||a.required||a.additionalProperties!==void 0)&&a.type!=="object"&&a.type!==void 0)throw new Error("Object constraints require an object type.");if(a.items&&a.type!=="array")throw new Error("items requires an array type.");if(a.type==="object"||a.properties){if(a.additionalProperties!==void 0&&a.additionalProperties!==!0)throw new Error("Closed objects and typed additionalProperties are not supported.");if(!a.properties||typeof a.properties!="object"||Array.isArray(a.properties))throw new Error("Object schemas must declare properties.");if(a.required!==void 0&&(!Array.isArray(a.required)||a.required.some(d=>typeof d!="string"||!Object.prototype.hasOwnProperty.call(a.properties,d))))throw new Error("required must list declared property names.");return{kind:"object",properties:Object.fromEntries(Object.entries(a.properties).map(([d,f])=>[d,{type:o(f,s),optional:!(a.required??[]).includes(d)}]))}}if(a.type==="array")return{kind:"array",items:o(a.items,s)};if(["string","number","integer","boolean","null"].includes(a.type))return{kind:a.type};throw new Error("Every property must declare a supported type.")},i=o(r);if(i.kind!=="object")throw new Error("The root schema must be an object keyed by node ID.");if(Object.values(i.properties).some(a=>a.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:t,nodes:i.properties}}async function Iu(e,t,r,n={}){var m;let o=512;const i=await import("typescript"),a=i.createSourceFile(t,e,i.ScriptTarget.Latest,!0,i.ScriptKind.TS),s=a.parseDiagnostics;if(s!=null&&s.length)throw new Error("Invalid TypeScript syntax.");const u=new Map;for(const g of a.statements){if(!i.isInterfaceDeclaration(g)&&!i.isTypeAliasDeclaration(g))throw new Error("Upload interfaces/type aliases only; imports and executable code are not supported.");if((m=g.typeParameters)!=null&&m.length||u.has(g.name.text))throw new Error("Generics and duplicate declarations are not supported.");u.set(g.name.text,g)}const c=(g,b)=>{var C;const w={},y=g.find(_=>i.isIndexSignatureDeclaration(_));let x;if(y&&n.allowJson&&i.isIndexSignatureDeclaration(y)){if(g.filter(_=>i.isIndexSignatureDeclaration(_)).length!==1||y.parameters.length!==1||((C=y.parameters[0].type)==null?void 0:C.kind)!==i.SyntaxKind.StringKeyword||!y.type)throw new Error("Only one string-keyed index signature is supported for forms.");x=d(y.type,b)}return{kind:"object",properties:Object.fromEntries(g.filter(_=>_!==y||!x).map(_=>{if(!i.isPropertySignature(_)||!_.type||!_.name||!i.isIdentifier(_.name)&&!i.isStringLiteral(_.name))throw new Error("Only explicitly typed named properties are supported.");const k=d(_.type,b),T=n.allowJson?i.getJSDocTags(_).filter(P=>P.tagName.text==="port"):[];if(T.length>1)throw new Error(`Duplicate port declaration: ${_.name.text}`);if(T.length){const[P,j,R]=String(T[0].comment??"").trim().split(/\s+/);if(P!=="config"||!j||R||!u.has(j))throw new Error(`Config port ${_.name.text} requires @port config ResourceType`);const E=k.kind==="array";if((k.kind==="array"?k.items.kind:k.kind)!=="string")throw new Error(`Config port ${_.name.text} must be a string or string array reference`);w[_.name.text]={kind:"config",resourceType:j,multiple:E}}return[_.name.text,{type:k,optional:!!_.questionToken}]})),...x?{additionalProperties:x}:{},...Object.keys(w).length?{ports:w}:{}}},l=(g,b)=>{var C;if(b.includes(g))throw new Error("Recursive types are not supported.");const w=u.get(g);if(!w)throw new Error(`Unknown type: ${g}`);let y;if(i.isInterfaceDeclaration(w)){if((C=w.heritageClauses)!=null&&C.length)throw new Error("Interface inheritance is not supported; declare properties explicitly.");y=c(w.members,[...b,g])}else y=d(w.type,[...b,g]);const x=n.allowJson?i.getJSDocTags(w).filter(_=>_.tagName.text==="port"):[];if(!x.length)return y;if(y.kind!=="object")throw new Error("Node ports require an object interface");const v={...y.ports};for(const _ of x){const[k,T,...P]=String(_.comment??"").trim().split(/\s+/);if(!["input","output","error"].includes(k)||!/^[A-Za-z][\w-]*$/.test(T??""))throw new Error("Node ports require @port input|output|error Name");const j=P.length?JSON.parse(P.join(" ")):void 0;if(j!==void 0&&typeof j!="string")throw new Error("Node port labels must be JSON strings");if(Object.prototype.hasOwnProperty.call(v,T))throw new Error(`Duplicate port declaration: ${T}`);v[T]={kind:k,...typeof j=="string"?{label:j}:{}}}return{...y,ports:v}},d=(g,b)=>{var w,y,x;if(--o<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(g.kind===i.SyntaxKind.StringKeyword)return{kind:"string"};if(g.kind===i.SyntaxKind.NumberKeyword)return{kind:"number"};if(g.kind===i.SyntaxKind.BooleanKeyword)return{kind:"boolean"};if(n.allowJson&&[i.SyntaxKind.AnyKeyword,i.SyntaxKind.UnknownKeyword].includes(g.kind))return{kind:"json"};if(i.isParenthesizedTypeNode(g))return d(g.type,b);if(i.isUnionTypeNode(g))return{kind:"union",types:g.types.map(v=>d(v,b))};if(i.isArrayTypeNode(g))return{kind:"array",items:d(g.elementType,b)};if(i.isTypeLiteralNode(g))return c(g.members,b);if(i.isLiteralTypeNode(g)){const v=g.literal;if(i.isStringLiteral(v))return{kind:"literal",value:v.text};if(i.isNumericLiteral(v))return{kind:"literal",value:Number(v.text)};if(v.kind===i.SyntaxKind.NullKeyword)return{kind:"null"};if(v.kind===i.SyntaxKind.TrueKeyword||v.kind===i.SyntaxKind.FalseKeyword)return{kind:"literal",value:v.kind===i.SyntaxKind.TrueKeyword}}if(i.isTypeReferenceNode(g)&&i.isIdentifier(g.typeName)){if(n.allowJson&&g.typeName.text==="Record"&&!u.has("Record")&&((w=g.typeArguments)==null?void 0:w.length)===2&&g.typeArguments[0].kind===i.SyntaxKind.StringKeyword)return{kind:"object",properties:{},additionalProperties:d(g.typeArguments[1],b)};if(g.typeName.text==="Array"&&((y=g.typeArguments)==null?void 0:y.length)===1)return{kind:"array",items:d(g.typeArguments[0],b)};if(!((x=g.typeArguments)!=null&&x.length))return l(g.typeName.text,b)}throw new Error(`Unsupported TypeScript type: ${g.getText(a)}`)},f=r??(u.has("Graph")?"Graph":u.size===1?[...u.keys()][0]:void 0);if(!f)throw new Error("Declare an interface Graph keyed by node ID.");const p=l(f,[]);if(p.kind!=="object")throw new Error("Graph must be an object keyed by node ID.");return p}async function em(e,t){const r=await Iu(e,t);if(Object.values(r.properties).some(n=>n.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:t,nodes:r.properties}}function Rt(e,t){if(e.kind==="json"||t.kind==="json"||e.kind==="object"&&e.additionalProperties||t.kind==="object"&&t.additionalProperties)return!1;if(e.kind==="union")return e.types.every(r=>Rt(r,t));if(t.kind==="union")return t.types.some(r=>Rt(e,r));if(e.kind==="literal"){if(t.kind==="literal")return e.value===t.value;const r=e.value===null?"null":typeof e.value;return t.kind===r||t.kind==="integer"&&typeof e.value=="number"&&Number.isInteger(e.value)}return e.kind==="integer"&&t.kind==="number"?!0:e.kind==="array"&&t.kind==="array"?Rt(e.items,t.items):e.kind==="object"&&t.kind==="object"?Object.entries(t.properties).every(([r,n])=>{const o=Object.prototype.hasOwnProperty.call(e.properties,r)?e.properties[r]:void 0;return o?(n.optional||!o.optional)&&Rt(o.type,n.type):n.optional}):e.kind===t.kind}function Mu(e,t){if(!t.sourceProperty&&!t.targetProperty)return;const r=(a,s)=>{var l;const u=Object.prototype.hasOwnProperty.call(e.nodes,a)?a:a.replace(/^root\./,""),c=Object.prototype.hasOwnProperty.call(e.nodes,u)?(l=e.nodes[u])==null?void 0:l.type:void 0;return s&&(c==null?void 0:c.kind)==="object"&&Object.prototype.hasOwnProperty.call(c.properties,s)?c.properties[s]:void 0},n=r(t.source,t.sourceProperty),o=r(t.target,t.targetProperty);if(!n||!o)return"Unverified: source or target property is missing from the interface.";const i=a=>a.kind==="json"||a.kind==="object"&&(!!a.additionalProperties||Object.values(a.properties).some(s=>i(s.type)))||a.kind==="array"&&i(a.items)||a.kind==="union"&&a.types.some(i);if(i(n.type)||i(o.type))return"Unverified: arbitrary JSON or dictionary fields require runtime validation.";if(n.optional&&!o.optional)return"Optional source cannot supply a required target property.";if(!Rt(n.type,o.type))return`Incompatible property types: ${t.sourceProperty} -> ${t.targetProperty}.`}async function rm(e){if(e.size>256*1024)throw new Error("Interface must be 256 KB or smaller.");const t=await e.text();if(/\.json$/i.test(e.name))return Ou(t,e.name);if(/\.ts$/i.test(e.name))return em(t,e.name);throw new Error("Choose a .ts interface or .json JSON Schema file.")}const Sl=new WeakMap;function Gt(e){if(!e||typeof e!="object")return e;const t=Sl.get(e);if(t)return t;const r=()=>{throw new Error("Form callback data is read-only. Return edits instead.")},n=new Proxy(Array.isArray(e)?[]:{},{get:(o,i)=>Gt(Reflect.get(e,i)),has:(o,i)=>Reflect.has(e,i),ownKeys:()=>Reflect.ownKeys(e),getOwnPropertyDescriptor:(o,i)=>{const a=Reflect.getOwnPropertyDescriptor(e,i);return a&&{...a,value:Gt(Reflect.get(e,i)),configurable:i!=="length"||!Array.isArray(e)}},set:r,deleteProperty:r,defineProperty:r,setPrototypeOf:r,preventExtensions:r});return Sl.set(e,n),n}function yt(e,t,r){var o;const n=t.split(".");for(let i=n.length;i>0;i--){const a=n.slice(0,i).join("."),s=(o=ve(e,a))==null?void 0:o.$form;if(!(s!=null&&s.$type))continue;let u=Object.prototype.hasOwnProperty.call(r,s.$type)?r[s.$type]:void 0;for(const d of n.slice(i))(u==null?void 0:u.kind)==="array"&&/^\d+$/.test(d)?u=u.items:(u==null?void 0:u.kind)==="object"?u=Object.prototype.hasOwnProperty.call(u.properties,d)?u.properties[d].type:void 0:u=void 0;if((u==null?void 0:u.kind)!=="object")return;const c=n.slice(i).join("."),l=Object.fromEntries(Object.entries(s.$fields??{}).filter(([d])=>!c||d.startsWith(`${c}.`)).map(([d,f])=>[c?d.slice(c.length+1):d,f]));return{type:u,fields:l,binding:s}}}async function qu(e,t){if(e.size>256*1024)throw new Error("Form schema exceeds 256 KB.");const r=await e.text();if(e.name.endsWith(".ts")){if(!t.length||t.length>32)throw new Error("Choose between 1 and 32 form interface names.");const o=[],i=new Set(t);for(const a of i){if(i.size>32)throw new Error("Choose between 1 and 32 form interface names.");const s=await Iu(r,e.name,a,{allowJson:!0});o.push([a,s]);for(const u of Object.values(s.ports??{}))u.resourceType&&i.add(u.resourceType)}return Object.fromEntries(o)}if(!e.name.endsWith(".json"))throw new Error("Choose a .ts interface or .json schema file.");const n=Ou(r,e.name);return Object.fromEntries(Object.entries(n.nodes).map(([o,i])=>[o,i.type]))}function wn(e,t){return!e||("$in"in e?e.$in.includes(ve(t,e.$address)):ve(t,e.$address)===e.$equals)}function Lt(e){const t=e.kind==="array"?e.items:e,r=t.kind==="union"?t.types:[t];if(r.every(n=>n.kind==="literal"))return r.map(n=>({label:String(n.value),value:n.value}))}function Rr(e,t,r){if(t===void 0||t==="")return r?"Required":void 0;if(e.kind==="json"){const n=new Set,o=i=>{if(i===null||typeof i=="string"||typeof i=="boolean")return!0;if(typeof i=="number")return Number.isFinite(i);if(!i||typeof i!="object"||n.has(i)||!Array.isArray(i)&&![Object.prototype,null].includes(Object.getPrototypeOf(i)))return!1;n.add(i);const a=Object.values(i).every(o);return n.delete(i),a};return o(t)?void 0:"Expected a JSON value"}if(e.kind==="union")return e.types.some(n=>!Rr(n,t,!0))?void 0:"Choose a valid value";if(e.kind==="literal")return t===e.value?void 0:"Choose a valid value";if(e.kind==="array")return Array.isArray(t)&&t.every(n=>!Rr(e.items,n,!0))?void 0:"Invalid list value";if(e.kind==="object")return!t||typeof t!="object"||Array.isArray(t)?"Expected an object":e.additionalProperties&&Object.entries(t).some(([n,o])=>!Object.prototype.hasOwnProperty.call(e.properties,n)&&Rr(e.additionalProperties,o,!0))?"Invalid dictionary value":Object.entries(e.properties).some(([n,o])=>Rr(o.type,t[n],!o.optional))?"Invalid object fields":void 0;if(e.kind==="null")return t===null?void 0:"Expected null";if(e.kind==="integer")return Number.isInteger(t)?void 0:"Expected a whole number";if(typeof t!==e.kind||typeof t=="number"&&!Number.isFinite(t))return`Expected ${e.kind}`}function El(e,t){const r=t.address.split(".");if(r.shift()!=="root"||!r.length||r.some(s=>!s||["__proto__","prototype","constructor","#"].includes(s)))throw new Error("Invalid form field address.");const n=r.pop(),o=n==="$bgColor"||n==="$textColor"||n==="$borderColor";if(r.some(s=>s.startsWith("$"))||n.startsWith("$")&&!o)throw new Error("Unsupported form metadata address.");const i=["root",...r].join("."),a=ve(e,i);if(!a||typeof a!="object")throw new Error(`Missing form parent: ${i}`);if(o){if(t.op==="set"&&typeof t.value!="string")throw new Error("Node colors must be strings.");return cr(e,i,n,t.op==="remove"?void 0:t.value)}return mr(e,i,s=>{const u=Array.isArray(s.$)?s.$:s;if(t.op==="remove"&&!Object.prototype.hasOwnProperty.call(u,n)||t.op==="set"&&Object.is(u[n],t.value))return s;const c=Array.isArray(u)?[...u]:{...u};if(Array.isArray(c)&&(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=c.length))throw new Error("Invalid array address.");return t.op==="remove"?Array.isArray(c)?c.splice(Number(n),1):delete c[n]:Object.defineProperty(c,n,{value:structuredClone(t.value),enumerable:!0,writable:!0,configurable:!0}),u===s?c:{...s,$:c}})}function Cn(e,t,r){let n=El(e,t.value===void 0?{op:"remove",address:t.address}:{op:"set",address:t.address,value:t.value});const o=r==null?void 0:r({...t,previousValue:Gt(ve(e,t.address)),data:Gt(n)});if(o&&!Array.isArray(o))throw new Error("Form change handlers must return edits synchronously.");for(const i of Array.isArray(o)?o:[]){if(i.op!=="set"&&i.op!=="remove")throw new Error("Unsupported form edit.");n=El(n,i)}return n}function Zx(e,t){let r=e;for(const n of t){if(n.op!=="set"&&n.op!=="remove")throw new Error("Unsupported state edit.");const o=n.address.split(".");if(o.some(a=>a.startsWith("$")||["__proto__","prototype","constructor"].includes(a)))throw new Error("State edits cannot target view metadata or unsafe keys.");const i=n.op==="remove"?void 0:n.value;Ut(i),r=Cn(r,{address:n.address,nodeAddress:o.slice(0,-1).join("."),value:i})}return Ut(r),r}function Xt(e,t,r){const n=Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;if(!(!n||!r||!Object.prototype.hasOwnProperty.call(r,n.type)))return{address:n.address,type:r[n.type],fields:n.fields??{}}}function Ut(e){if(!(!e||typeof e!="object"))for(const[t,r]of Object.entries(e)){if(t.startsWith("$")||["__proto__","prototype","constructor"].includes(t))throw new Error(`Form state cannot contain view metadata or unsafe keys: ${t}`);Ut(r)}}function Yx(e,t,r){Ut(t.value);const n=Cn(e,t,r);return Ut(n),n}function tm(e,t){const r=(n,o="")=>{if(!n||typeof n!="object")return n;if(["$label","$subtitle","$content","$icon","$bgColor","$textColor","$borderColor"].includes(o)&&typeof n.$state=="string"){const a=ve(t,n.$state);return a==null?"":typeof a=="object"?JSON.stringify(a,null,2):String(a)}let i=n;for(const[a,s]of Object.entries(n)){const u=r(s,a);u!==s&&(i===n&&(i=Array.isArray(n)?[...n]:{...n}),Object.defineProperty(i,a,{value:u,enumerable:!0,writable:!0,configurable:!0}))}return i};return r(e)}const Xr=(e="reference")=>({kind:e,text:"",paths:[""]}),nm=e=>/^[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*|\.\d+)+$/.test(e)&&!e.split(".").some(t=>["__proto__","constructor","prototype"].includes(t));function Xx(e,t){const r=new Set(t.map(a=>a.path)),n=a=>{if(!a.paths.length||a.paths.some(s=>!nm(s)||!r.has(s)))throw new Error("Choose an available reference.");return[...a.paths,...a.fallback===void 0?[]:[JSON.stringify(a.fallback)]].join(" || ")},o=a=>{if(a.includes("{{")||a.includes("}}"))throw new Error("Use a reference part for dynamic values.");return a},i=a=>a.map(s=>{if(s.kind==="text")return o(s.text);if(s.kind==="conditional"){if(s.paths.length!==1||s.fallback!==void 0)throw new Error("Choose one condition reference.");return`{{#if ${n(s)}}}${o(s.text)}{{/if}}`}return`{{${n(s)}}}`}).join("");if(e.mode==="reference"||e.mode==="condition"){if(e.parts.length!==1||e.parts[0].kind!=="reference")throw new Error("Choose one reference binding.");const a=i(e.parts);return e.mode==="condition"?`${a} == ${JSON.stringify(e.comparison)}`:a}if(e.mode==="json"){const a=e.fields.map(s=>s.key);if(!a.length||new Set(a).size!==a.length||a.some(s=>!s||["__proto__","constructor","prototype"].includes(s)))throw new Error("Output field names must be unique and nonempty.");return JSON.stringify(Object.fromEntries(e.fields.map(s=>[s.key,i(s.parts)])))}return i(e.parts)}async function Qx(e){const t=await import("typescript"),r=a=>{const s=t.createSourceFile("binding.ts",`(${a})`,t.ScriptTarget.Latest,!0,t.ScriptKind.TS);if(s.parseDiagnostics.length)throw new Error("Unsupported reference expression.");const u=s.statements[0];if(!u||!t.isExpressionStatement(u))throw new Error("Unsupported reference expression.");const c=Xr();c.paths=[];const l=d=>{if(t.isParenthesizedExpression(d))return l(d.expression);if(t.isBinaryExpression(d)&&d.operatorToken.kind===t.SyntaxKind.BarBarToken){l(d.left),l(d.right);return}if(t.isStringLiteral(d)){if(c.fallback!==void 0)throw new Error("Multiple fallback values.");c.fallback=d.text;return}const f=d.getText(s);if(!nm(f)||c.fallback!==void 0)throw new Error("Unsupported reference expression.");c.paths.push(f)};if(l(u.expression),!c.paths.length)throw new Error("A binding needs a reference.");return c},n=a=>{const s=[];let u=0;const c=/\{\{([\s\S]*?)\}\}/g;for(const l of a.matchAll(c)){const d=l.index;if(d<u)continue;d>u&&s.push({...Xr("text"),text:a.slice(u,d)});const f=l[1].trim();if(f.startsWith("#if ")){const p=a.indexOf("{{/if}}",d+l[0].length);if(p<0)throw new Error("Unclosed condition.");s.push({...r(f.slice(4)),kind:"conditional",text:a.slice(d+l[0].length,p)}),u=p+7}else s.push(r(f)),u=d+l[0].length}return u<a.length&&s.push({...Xr("text"),text:a.slice(u)}),s},o={mode:"reference",parts:[Xr()],comparison:"",fields:[]};if(!e)return o;if(e.trim().startsWith("{"))try{const a=JSON.parse(e);if(a&&typeof a=="object"&&!Array.isArray(a)&&Object.values(a).every(s=>typeof s=="string"))return{...o,mode:"json",fields:Object.entries(a).map(([s,u])=>({key:s,parts:n(u)}))}}catch{}const i=n(e);if(i.length===2&&i[0].kind==="reference"&&i[1].kind==="text"){const a=t.createSourceFile("condition.ts",`value ${i[1].text}`,t.ScriptTarget.Latest,!0,t.ScriptKind.TS),s=a.statements[0];if(a.statements.length===1&&t.isExpressionStatement(s)&&t.isBinaryExpression(s.expression)&&s.expression.operatorToken.kind===t.SyntaxKind.EqualsEqualsToken&&t.isStringLiteral(s.expression.right))return{...o,mode:"condition",parts:[i[0]],comparison:s.expression.right.text}}return{...o,mode:i.length===1&&i[0].kind==="reference"?"reference":"template",parts:i}}function jl({parts:e,references:t,onChange:r,disabled:n}){const o=(i,a)=>r(e.map((s,u)=>u===i?{...s,...a}:s));return h.jsxs("div",{style:{display:"grid",gap:12},children:[e.map((i,a)=>h.jsxs("fieldset",{"data-binding-part":a,style:{border:0,padding:0,margin:0,minWidth:0},children:[h.jsxs("legend",{children:["Part ",a+1]}),h.jsxs("div",{style:{display:"flex",gap:8},children:[h.jsxs("span",{"data-form-select":"",style:{flex:1},children:[h.jsxs("select",{"aria-label":"Part type",disabled:n,value:i.kind,onChange:s=>o(a,{kind:s.target.value}),children:[h.jsx("option",{value:"reference",children:"Reference"}),h.jsx("option",{value:"text",children:"Text"}),h.jsx("option",{value:"conditional",children:"Conditional text"})]}),h.jsx(J.PiCaretDown,{size:16,"aria-hidden":"true"})]}),h.jsx(be,{"aria-label":`Remove part ${a+1}`,title:"Remove part",icon:h.jsx(J.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>r(e.filter((s,u)=>u!==a))})]}),i.kind!=="text"&&h.jsxs(h.Fragment,{children:[i.paths.map((s,u)=>h.jsxs("label",{children:["Reference ",u+1,h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsxs("select",{"aria-label":`Reference ${u+1}`,disabled:n,value:s,onChange:c=>o(a,{paths:i.paths.map((l,d)=>d===u?c.target.value:l)}),children:[h.jsx("option",{value:"",children:"Select reference"}),t.map(c=>h.jsx("option",{value:c.path,children:c.label},c.path))]}),h.jsx(J.PiCaretDown,{size:16,"aria-hidden":"true"})]})]},u)),i.kind==="reference"&&h.jsxs(h.Fragment,{children:[h.jsx(be,{"aria-label":"Add fallback reference",title:"Add fallback reference",icon:h.jsx(J.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>o(a,{paths:[...i.paths,""]})}),h.jsxs("label",{style:{display:"flex",gap:8,alignItems:"center"},children:[h.jsx("input",{type:"checkbox","aria-label":"Default value enabled",disabled:n,checked:i.fallback!==void 0,onChange:s=>o(a,{fallback:s.target.checked?"":void 0})}),"Default value"]}),i.fallback!==void 0&&h.jsx("input",{"aria-label":"Default value",disabled:n,value:i.fallback,onChange:s=>o(a,{fallback:s.target.value})})]})]}),i.kind!=="reference"&&h.jsxs("label",{children:["Text",h.jsx("textarea",{"aria-label":"Part text",disabled:n,value:i.text,onChange:s=>o(a,{text:s.target.value})})]})]},a)),h.jsx(be,{"aria-label":"Add part",title:"Add part",icon:h.jsx(J.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>r([...e,Xr()])})]})}function e0({label:e,value:t,references:r,disabled:n,onChange:o}){const[i,a]=S.useState(),[s,u]=S.useState(""),[c,l]=S.useState(!1),d=async()=>{l(!0),u("");try{a(await Qx(typeof t=="string"?t:""))}catch(f){u(f instanceof Error?f.message:"Unable to read binding.")}finally{l(!1)}};return h.jsxs("div",{"data-runtime-binding":e,style:{marginBottom:8},children:[h.jsx(be,{"aria-label":`Bind ${e}`,title:`Bind ${e}`,icon:h.jsx(J.PiLink,{size:18}),size:"sm",variant:"ghost",disabled:n||c,onClick:d}),typeof t=="string"&&t.includes("{{")&&h.jsx("span",{children:"Bound value"}),i&&h.jsxs("fieldset",{disabled:n,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[h.jsxs("label",{children:["Binding mode",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsxs("select",{"aria-label":"Binding mode",value:i.mode,onChange:f=>a({...i,mode:f.target.value,parts:[Xr()]}),children:[h.jsx("option",{value:"reference",children:"Reference"}),h.jsx("option",{value:"condition",children:"Equals"}),h.jsx("option",{value:"template",children:"Text template"}),h.jsx("option",{value:"json",children:"JSON output"})]}),h.jsx(J.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),i.mode==="json"?h.jsxs(h.Fragment,{children:[i.fields.map((f,p)=>h.jsxs("fieldset",{"data-output-field":p,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[h.jsxs("label",{children:["Output field name",h.jsx("input",{"aria-label":"Output field name",value:f.key,onChange:m=>a({...i,fields:i.fields.map((g,b)=>b===p?{...g,key:m.target.value}:g)})})]}),h.jsx(jl,{parts:f.parts,references:r,disabled:n,onChange:m=>a({...i,fields:i.fields.map((g,b)=>b===p?{...g,parts:m}:g)})}),h.jsx(be,{"aria-label":"Remove output field",title:"Remove output field",icon:h.jsx(J.PiTrash,{size:18}),size:"sm",variant:"ghost",onClick:()=>a({...i,fields:i.fields.filter((m,g)=>g!==p)})})]},p)),h.jsx(be,{"aria-label":"Add output field",title:"Add output field",icon:h.jsx(J.PiPlus,{size:18}),size:"sm",variant:"ghost",onClick:()=>a({...i,fields:[...i.fields,{key:"",parts:[Xr()]}]})})]}):h.jsx(jl,{parts:i.parts,references:r,disabled:n,onChange:f=>a({...i,parts:f})}),i.mode==="condition"&&h.jsxs("label",{children:["Equals",h.jsx("input",{"aria-label":"Comparison value",value:i.comparison,onChange:f=>a({...i,comparison:f.target.value})})]}),h.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[h.jsx(be,{"aria-label":"Apply binding",title:"Apply binding",icon:h.jsx(J.PiCheck,{size:20}),size:"sm",variant:"ghost",onClick:()=>{try{o(Xx(i,r)),a(void 0),u("")}catch(f){u(f instanceof Error?f.message:"Unable to apply binding.")}}}),h.jsx(be,{"aria-label":"Cancel binding",title:"Cancel binding",icon:h.jsx(J.PiX,{size:20}),size:"sm",variant:"ghost",onClick:()=>{a(void 0),u("")}})]})]}),s&&h.jsx("p",{role:"alert",children:s})]})}const r0=e=>!!e&&!e.includes(".")&&!e.startsWith("$")&&!["__proto__","constructor","prototype"].includes(e),t0=e=>`root.__form_${encodeURIComponent(e).replace(/\./g,"%2E")}`,kt=(e,t)=>JSON.stringify([e,t]);function Ht(e,t){if(e.kind==="union"){const r=e.types.find(n=>n.kind===(Array.isArray(t)?"array":t===null?"null":typeof t)||n.kind==="literal"&&Object.is(n.value,t));return Ht(r??e.types.find(n=>n.kind!=="null")??e.types[0]??{kind:"json"},t)}return e.kind!=="json"?e:Array.isArray(t)?{kind:"array",items:{kind:"json"}}:t!==null&&typeof t=="object"||t===void 0?{kind:"object",properties:{},additionalProperties:{kind:"json"}}:{kind:t===null?"null":typeof t}}function Pt(e){const t=Ht(e,void 0);return t.kind==="object"?{}:t.kind==="array"?[]:t.kind==="literal"?t.value:t.kind==="number"||t.kind==="integer"?0:t.kind==="boolean"?!1:t.kind==="null"?null:""}function Rl(e){return e.kind==="json"?[{kind:"string"},{kind:"number"},{kind:"boolean"},{kind:"null"},{kind:"object",properties:{},additionalProperties:{kind:"json"}},{kind:"array",items:{kind:"json"}}]:e.kind==="union"&&!Lt(e)?e.types:[e]}function n0(e,t,r){if(t.address===r.address)return;const n=ve(e,t.address),o=(i,a)=>a===void 0?!1:i.kind==="union"?i.types.some(s=>o(s,a)):i.kind==="array"?Array.isArray(a)&&a.every(s=>o(i.items,s)):i.kind==="object"?!!a&&typeof a=="object"&&!Array.isArray(a)&&Object.entries(i.properties).every(([s,u])=>u.optional&&a[s]===void 0||o(u.type,a[s]))&&Object.entries(a).every(([s,u])=>Object.prototype.hasOwnProperty.call(i.properties,s)||!i.additionalProperties||o(i.additionalProperties,u)):a===""?i.kind==="string"||i.kind==="json"||i.kind==="literal"&&i.value==="":!Rr(i,a,!0);if(o(r.type,n))return structuredClone(n)}function o0(e,t,r,n){var u,c;const o={sourceSchema:r,sourceBindings:t,nodes:[],edges:[],schema:{...r},bindings:{...t},slots:new Map,containers:new Map},i=new Set(n.map(l=>l.data.id)),a=new Map(n.flatMap(l=>{const d=t[l.data.id];return d&&r[d.type]?[[d.address,l.data.id]]:[]})),s=(l,d,f,p,m,g=!1)=>{var k,T,P,j;if(m>24||o.containers.size>512)throw new Error("Structured form exceeds the flow node limit.");const b=ve(e,d),w=Ht(f,b),y=w.kind!=="object"&&w.kind!=="array";o.containers.set(l,{address:d,type:w,declared:f,scalar:y});const x=`__form:${l}`,v={...(k=o.bindings[l])==null?void 0:k.fields},C={kind:"object",properties:{},ports:{...w.kind==="object"?w.ports:{},...g?{resource:{label:"output",...w.kind==="object"?(T=w.ports)==null?void 0:T.resource:{},kind:"output"}}:{}}},_=w.kind==="object"?{...w.properties,...Object.fromEntries(Object.keys(b??{}).filter(R=>!Object.prototype.hasOwnProperty.call(w.properties,R)&&w.additionalProperties).map(R=>[R,{type:w.additionalProperties,optional:!0}]))}:w.kind==="array"?Object.fromEntries((Array.isArray(b)?b:[]).map((R,E)=>[String(E),{type:w.items,optional:!0}])):{value:{type:Lt(f)?f:w,optional:!1}};for(const[R,E]of Object.entries(_)){if(!r0(R))throw new Error(`Unsupported structured property key: ${R}`);const M=y?d:`${d}.${R}`,I=ve(e,M),N=Ht(E.type,I),O=N.kind==="object"||N.kind==="array",W=(P=C.ports)==null?void 0:P[R],z=(W==null?void 0:W.kind)==="config"&&(((j=v[R])==null?void 0:j.$options)||Lt(E.type)),re=E.type.kind==="json"||E.type.kind==="union"&&!Lt(E.type);if(!O&&w.kind!=="array"&&(!re||y)||z){C.properties[R]={...E,type:E.type.kind==="json"?N:E.type};continue}const te=a.get(M)??t0(M),he=w.kind==="array"?`Item ${Number(R)+1}`:R,me={address:M,owner:l,field:R,type:E.type,label:he,nodeId:te,present:I!==void 0};if(o.slots.set(kt(l,R),me),C.ports[R]={kind:"config",resourceType:`__form:${te}`},I===void 0||(o.edges.push({data:{id:`__form-edge:${l}:${R}`,source:te,target:l,sourceProperty:"output:resource",targetProperty:`config:${R}`,isEdgeDashed:!0}}),o.containers.has(te)||a.has(M)))continue;if(i.has(te))throw new Error(`Structured node identity conflict: ${te}`);i.add(te);const K={data:{id:te,type:"objectView",label:he,headerTitle:he,description:{},config:{form:!0,icon:N.kind==="array"?"PiListNumbers":O?"PiBracketsCurly":"PiTextT"},viewProps:{bgColor:p}}};o.nodes.push(K),s(te,M,E.type,p,m+1,!0);const q=o.schema[`__form:${te}`];K.data.description=Object.fromEntries(Object.keys(q.properties).map(L=>[L,ve(e,N.kind==="array"||N.kind==="object"?`${M}.${L}`:M)]).filter(([,L])=>L!==void 0))}o.schema[x]=C,o.bindings[l]={...o.bindings[l],address:d,type:x,fields:v}};for(const l of n){const d=t[l.data.id];if(d!=null&&d.portResources)continue;const f=d&&r[d.type];!d||!f||ve(e,d.address)===void 0||s(l.data.id,d.address,f,(u=l.data.viewProps)==null?void 0:u.bgColor,0,o.edges.some(p=>p.data.source===l.data.id))}for(const l of o.edges){const d=o.bindings[l.data.source],f=o.schema[d.type].ports;f.resource={...f.resource,kind:"output",label:((c=f.resource)==null?void 0:c.label)??"output"}}return o}function i0({nodeAddress:e}){const{structured:t,data:r,callbacks:n,editable:o}=S.useContext(kr),i=Oe(),[a,s]=S.useState(""),[u,c]=S.useState("0"),[l,d]=S.useState(""),f=t==null?void 0:t.containers.get(e);if(!f||!r||!t)return null;const p=i.readOnly||i.config.editable===!1||!o,m=ve(r,f.address),g=Rl(f.declared),b=f.type.kind==="array"?f.type.items:f.type.kind==="object"?f.type.additionalProperties:void 0,w=b?Rl(b):[],y=j=>j.kind==="literal"?String(j.value):j.kind==="string"?"Text":Cr(j.kind),x=[...t.slots.values()].filter(j=>j.owner===e),v=(j,R)=>{var E;return(E=n.onFormChange)==null?void 0:E.call(n,{data:r,nodeAddress:f.address,address:j,previousValue:ve(r,j),value:R})},C=j=>{var R;i.setSelectedNodeIds([j]),(R=i.engineRef.current)==null||R.focusNode(j,90,!1)},_=(j,R)=>{if(!Array.isArray(m))return;const E=[...m];[E[j],E[j+R]]=[E[j+R],E[j]],v(f.address,E)},k=()=>{const j=w[Number(u)]??w[0];if(j)if(f.type.kind==="array")v(f.address,[...Array.isArray(m)?m:[],Pt(j)]);else{if(!a||a.includes(".")||a.startsWith("$")||["__proto__","constructor","prototype"].includes(a)){d("Choose a property name without dots or reserved prefixes.");return}if(Object.prototype.hasOwnProperty.call(m,a)){d("Property already exists.");return}v(`${f.address}.${a}`,Pt(j)),s(""),d("")}},T=f.type.kind==="object"&&!!f.type.additionalProperties,P=f.type.kind==="array";return h.jsxs("div",{"data-structured-controls":"",style:{display:"grid",gap:8,minWidth:0},children:[g.length>1&&h.jsxs("label",{children:["Value type",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsx("select",{"aria-label":"Value type",disabled:p,value:g.findIndex(j=>Ht(j,m).kind===f.type.kind),onChange:j=>v(f.address,Pt(g[Number(j.target.value)])),children:g.map((j,R)=>h.jsx("option",{value:R,children:y(j)},R))}),h.jsx(J.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),x.map((j,R)=>h.jsxs("div",{"data-structured-slot":j.address,style:{display:"flex",gap:6,alignItems:"center",minWidth:0},children:[j.type.kind==="array"?h.jsx(J.PiListNumbers,{size:20}):h.jsx(J.PiBracketsCurly,{size:20}),h.jsx("span",{style:{flex:1,overflowWrap:"anywhere"},children:Cr(j.label)}),h.jsx(be,{"aria-label":`${j.present?"Focus":"Create"} ${Cr(j.label)}`,title:`${j.present?"Focus":"Create"} ${Cr(j.label)}`,icon:j.present?h.jsx(J.PiMagnifyingGlass,{size:18}):h.jsx(J.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:p&&!j.present,onClick:E=>{var M;j.present?((M=E.currentTarget.closest("dialog"))==null||M.close(),C(j.nodeId)):v(j.address,Pt(j.type))}}),P&&h.jsxs(h.Fragment,{children:[h.jsx(be,{"aria-label":`Move item ${R+1} up`,icon:h.jsx(J.PiArrowUp,{size:18}),size:"sm",variant:"ghost",disabled:p||R===0,onClick:()=>_(R,-1)}),h.jsx(be,{"aria-label":`Move item ${R+1} down`,icon:h.jsx(J.PiArrowDown,{size:18}),size:"sm",variant:"ghost",disabled:p||R===x.length-1,onClick:()=>_(R,1)})]}),j.present&&h.jsx(be,{"aria-label":`Remove ${Cr(j.label)}`,icon:h.jsx(J.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:p,onClick:()=>P?v(f.address,m.filter((E,M)=>M!==R)):v(j.address,void 0)})]},j.address)),(P||T)&&h.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"end"},children:[T&&h.jsxs("label",{style:{flex:"1 1 120px",minWidth:0},children:["Property name",h.jsx("input",{"aria-label":"Property name",value:a,disabled:p,onChange:j=>s(j.target.value)})]}),w.length>1&&h.jsxs("label",{style:{flex:"1 1 100px"},children:["New value type",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsx("select",{"aria-label":"New value type",value:u,disabled:p,onChange:j=>c(j.target.value),children:w.map((j,R)=>h.jsx("option",{value:R,children:y(j)},R))}),h.jsx(J.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),h.jsx("span",{style:{display:"flex",alignItems:"center",flexShrink:0,...T||w.length>1?{height:"calc(1.4em + 20px)",fontSize:15,marginBottom:6}:{}},children:h.jsx(be,{"aria-label":P?"Add item":"Add property",icon:h.jsx(J.PiPlus,{size:20}),size:"sm",variant:"ghost",disabled:p,onClick:k})})]}),l&&h.jsx("p",{role:"alert",children:l})]})}const kr=S.createContext({callbacks:{}}),on=mn.default.div`
58
+ `,Vy=S.forwardRef(function({style:t,...r},n){return h.jsx(Fx,{...r,ref:n,style:{...t,backgroundImage:"none","--flow-range-track":(t==null?void 0:t.backgroundImage)??"none"}})});function ml({label:e,inputLabel:t,value:r,displayValue:n,min:o,max:i,onChange:a}){const s=S.useId(),{readOnly:u,themeColor:c}=Oe(),{colorInactive:l}=Ue(),d=(r-o)/(i-o)*100,f=c.includes(".")?`var(--chakra-colors-${c.replace(".","-")})`:c;return h.jsxs("div",{style:{width:224,maxWidth:"calc(100vw - 64px)",padding:12},children:[h.jsxs("label",{htmlFor:s,style:{display:"flex",justifyContent:"space-between",fontSize:14,marginBottom:12},children:[e," ",h.jsx("span",{children:n})]}),h.jsx(Vy,{id:s,"aria-label":t,type:"range",min:o,max:i,step:5,value:r,disabled:u,style:{color:f,accentColor:f,backgroundImage:`linear-gradient(to right, currentColor ${d}%, var(--chakra-colors-${l.replace(".","-")}) ${d}%)`},onChange:p=>a(Number(p.target.value))})]})}const vl={dot:{label:"Dots",icon:J.PiDotsNine},grid:{label:"Grid",icon:J.PiGridFour},steel:{label:"Steel",icon:J.PiLineSegments},none:{label:"Solid",icon:J.PiSquareFill},transparent:{label:"Transparent",icon:J.PiSelection}};function Wy(){const{spacing:e,setSpacing:t,edgeRadius:r,setEdgeRadius:n,backgroundVariant:o,setBackgroundVariant:i,callbacks:a,readOnly:s}=Oe(),u=vl[o].icon;return h.jsxs(h.Fragment,{children:[h.jsx(Mt,{}),h.jsx(Ir,{"aria-label":"Node spacing",title:`Spacing: ${Math.round(e*100)}%`,icon:h.jsx(J.PiArrowsOutCardinal,{size:20}),style:{width:36},value:"spacing",disabled:s,onValueChange:()=>{},popupContent:h.jsx(ml,{label:"Spacing",inputLabel:"Node spacing percentage",min:50,max:200,value:Math.round(e*100),displayValue:`${Math.round(e*100)}%`,onChange:c=>{var l;t(c/100),(l=a.onSpacingChange)==null||l.call(a,c/100)}}),children:h.jsx("option",{value:"spacing",children:"Spacing"})}),h.jsx(Mt,{}),h.jsx(Ir,{"aria-label":"Edge radius",title:`Edge radius: ${r??"Default"}`,icon:h.jsx(J.PiBezierCurve,{size:20}),style:{width:36},value:"radius",disabled:s,onValueChange:()=>{},popupContent:h.jsx(ml,{label:"Edge radius",inputLabel:"Edge corner radius",min:0,max:500,value:r??500,displayValue:r??"Default",onChange:c=>{var l;n(c),(l=a.onEdgeRadiusChange)==null||l.call(a,c)}}),children:h.jsx("option",{value:"radius",children:"Edge radius"})}),h.jsx(Mt,{}),h.jsxs(Ir,{"aria-label":"Background variant",title:`Background: ${vl[o].label}`,icon:h.jsx(u,{size:20,"data-background-icon":o}),style:{width:36},value:o,disabled:s,onValueChange:c=>{var l;i(c),(l=a.onBackgroundVariantChange)==null||l.call(a,c)},children:[h.jsx("option",{value:"dot",children:"Dots"}),h.jsx("option",{value:"grid",children:"Grid"}),h.jsx("option",{value:"steel",children:"Steel"}),h.jsx("option",{value:"none",children:"Solid"}),h.jsx("option",{value:"transparent",children:"Transparent"})]})]})}const or=[];for(let e=0;e<256;++e)or.push((e+256).toString(16).slice(1));function Bx(e,t=0){return(or[e[t+0]]+or[e[t+1]]+or[e[t+2]]+or[e[t+3]]+"-"+or[e[t+4]]+or[e[t+5]]+"-"+or[e[t+6]]+or[e[t+7]]+"-"+or[e[t+8]]+or[e[t+9]]+"-"+or[e[t+10]]+or[e[t+11]]+or[e[t+12]]+or[e[t+13]]+or[e[t+14]]+or[e[t+15]]).toLowerCase()}let Jn;const Dx=new Uint8Array(16);function zx(){if(!Jn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Jn=crypto.getRandomValues.bind(crypto)}return Jn(Dx)}const Vx=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),xl={randomUUID:Vx};function Ru(e,t,r){var o;if(xl.randomUUID&&!e)return xl.randomUUID();e=e||{};const n=e.random??((o=e.rng)==null?void 0:o.call(e))??zx();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Bx(n)}const mn={label:"Untitled",description:"",isTask:!1,isLocked:!1},ku={id:null,type:"text",data:{...mn,viewProps:{width:"max-content !important",maxWidth:700,height:"100%",borderColor:"transparent",borderRadius:25,borderWidth:0,boxShadow:"none",textOverflow:"ellipsis",fontWeight:"bold",textColor:"gray.800",textAlign:"center"}}},wl={id:null,type:"objectView",data:{...mn,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:53,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},Wx={id:null,type:"arrayView",data:{...mn,viewProps:{width:"max-content !important",maxWidth:700,height:"100%",textAlign:"center",borderRadius:25,fontSize:"5xl",borderWidth:2,textOverflow:"ellipsis",wordBreak:"keep-all",fontWeight:"bold",textColor:"gray.900",placeholder:"Start Typing"}}},Cl={id:null,type:"workflowStep",data:{...mn,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}},yr=e=>typeof e=="object",Gy=e=>Array.isArray(e),Gx=["order","position","selected","locked","grabbed","grabbable","scratch"],Vr=e=>Object.entries(e).reduce((t,[r,n])=>(!yr(n)&&!r.startsWith("$")&&(t[r]=n),t),{}),Pu=(e,t)=>typeof e=="string"&&e.startsWith("$")?Zn(e,t):yr(e)&&!Gy(e)?Object.entries(e).reduce((r,[n,o])=>(typeof o=="string"&&o.startsWith("$")&&n==="..."?(delete r["..."],r[n]={...Zn(o,t),...e}):typeof o=="string"&&o.startsWith("$")?r[n]=Zn(o,t):r[n]=o,r),{}):e,Wr=e=>Object.entries(e).reduce((t,[r,n])=>(yr(n)&&r&&n&&!r.startsWith("$")&&(Gx.includes(r)&&(r=r+"#"),t[r]=n),t),{}),Yr=(e,t,{label:r,parent:n=void 0},o,i=null)=>(i!==null&&(yr(i)||Gy(i))&&(i=JSON.stringify(i,null,2)),{data:{parent:n,...e.data,id:t,text:r||"",label:r,code:i||null,type:e.type,description:o}}),Dr=(e,t,r=null,n=null,o=null,i=!1,a=null)=>({data:{id:Ru(),source:o?t:e,target:o?e:t,label:n||"",isInverted:o,isEdgeAnimated:i,parent:a}}),Gr=(e,t=[])=>{const r={},n={};let o=[];if(e)for(const[i,a]of Object.entries(e))i.startsWith("$")&&i!=="$"?r[i.slice(1)]=a:i!=="$"?n[i]=a:i==="$"&&(o=a);return{newConfig:r,updatedObject:n,arrayObject:o}},lt=(e,t)=>{let r=wl;const{view:n,borderColor:o,borderRadius:i,bgColor:a,textColor:s,fontSize:u,stepType:c}=t;e=n||e,c?r={...Cl}:e==="object"?r=wl:e==="text"?r=ku:e==="array"?r=Wx:e==="workflowStep"&&(r={...Cl});const l=r.data.viewProps;return r.data.viewProps={...l,borderRadius:i||(c?15:53),bgColor:a,borderColor:o,textColor:s,fontSize:u},r.data.config=t,{config:r}},zt=(e,t)=>(e=t.find(n=>n.data.id===e)?`${e}.#`:e,e),Zn=(e,{ids:t,jsnObjct:r})=>{if(typeof e=="string"&&(e!=null&&e.startsWith("$"))){const n=e.replace("$","").replace("*","");e==null||e.endsWith("*");const o=t.find(s=>s.split(".").slice(-1)[0]===n||n===s);if(!o)return e;const i=Ux(o,r);return JSON.stringify(i).includes(e)?e:i||e}return e},Ux=(e,t)=>{let r=e.split(".").splice(1);return r=r[r.length-1]==="#"||r[r.length-1].includes("{")?r.slice(0,-2):r,(i=>r.reduce((a,s)=>{s=s.replace("[","").replace("]","");const{arrayObject:u}=Gr(a);return a=u.length?u:a,a[s]},i))(t)};function ft(e,t="root",r=[]){try{const{arrayObject:n}=Gr(e);n.length&&(e=n);const o=Vr(e),i=Wr(e);return yr(e)?(Ae(e)||Ae(e)&&t==="root"||!Ae(e)&&Object.keys(o).length||t==="root")&&r.push(t):r.push(t),Object.keys(i).length&&!Ae(e)?qt({chldPth:null,itrblObjct:i,nodes:r,path:t}):Ae(e)&&e.forEach((a,s)=>{const u=Vr(a),c=Wr(a),{newConfig:l,arrayObject:d}=Gr(a);let f=`${t}.${s}`;yr(a)?Object.keys(u).length?(ft(u,f,r),Object.keys(c).length&&!Ae(a)&&qt({chldPth:f,itrblObjct:c,nodes:r,path:t})):Object.keys(c).length&&!Ae(a)?qt({chldPth:f,itrblObjct:c,nodes:r,path:t}):Ae(a)&&Uy({chldPth:f,item:a,nodes:r,path:t}):r.push(f)}),{nodes:r}}catch{return{nodes:r}}}const qt=({chldPth:e,itrblObjct:t,nodes:r,path:n})=>Object.entries(t).forEach(([o,i],a)=>{const s=Vr(i),u=Wr(i),{newConfig:c,arrayObject:l}=Gr(i);l.length&&(i=l),n.split(".").slice(0,2).join(".");let d=e?`${e}.${o}`:`${n}.${o}`;if(yr(i)&&!Ae(i)){const f=Object.keys(s).length===0;if(f&&(lt("array",c),r.push(d)),Object.keys(s).length){const p=Ae(i)?`${i.length||""}`:`{${Object.keys(i).length||""}}`;let b=d;f&&(b=`${d}.${p}`),ft(i,b,r)}else Object.keys(u).length&&!Ae(i)?qt({chldPth:d,itrblObjct:u,path:d,nodes:r}):ft(i,d,r)}else Ae(i)&&ft(i,d,r)}),Uy=({chldPth:e,item:t,nodes:r,path:n})=>t.forEach((o,i)=>{let a=`${e}.${i}`;const s=Wr(o),u=Vr(o);yr(o)?!Ae(o)&&Object.keys(u).length?ft(o,a,r):Object.keys(s).length&&!Ae(o)?qt({chldPth:a,itrblObjct:s,path:n,nodes:r}):Ae(o)&&Uy({chldPth:a,item:o,nodes:r,path:n}):r.push(a)}),dn=[];let Nt;function Qr(e,t="root",r=[],n=[],o="untitled",i={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},a={}){if(!e||typeof e!="object")return console.error("Invalid object passed",e),{nodes:r,edges:n};const s=e;if(!Nt){const{nodes:l}=ft(e);Nt={ids:l,jsnObjct:e}}let{hideDefaultObject:u,sprtObjctKy:c}=i;try{t=zt(t,r);const{newConfig:l,arrayObject:d}=Gr(e),f=Object.keys(a).length>0?a:l;d.length&&(e=d);const p=Vr(e),b=Wr(e),{label:g,collapsed:m,parent:w}=f;if(!yr(e))r.push(Yr(ku,t,{label:g||t,parent:w},e,s));else if(Ae(e)||Ae(e)&&t==="root"){const{config:y}=lt("array",f),x=Ae(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,v=t==="root"?o:`${o} ${x}`;r.push(Yr(y,t,{label:g||v,parent:w},e,Ae(s)?{[o]:s}:s))}else if(!Ae(e)&&Object.keys(p).length||t==="root"){const{config:y}=lt(null,f),x=Ae(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,v=t.split("."),C=v[v.length-1];let _=isNaN(Number(C))?null:Number(C)+1;const k=isNaN(Number(C))?C:v[v.length-2]+" "+_,T=t==="root"?o:k;let P=!1;Number.isNaN(Number(o))||(P=!0);const j=e;if(g){const{config:R}=lt("object",f);r.push(Yr(R,t,{label:g||`${g} ${x}`,parent:w},p,j))}else y.data.headerTitle=T,r.push(Yr(y,t,{label:g,parent:w},p,j))}return m||(Object.keys(b).length&&!Ae(e)?$t({flowConfig:i,chldPth:null,edges:n,isInverted:null,itrblObjct:b,nodes:r,path:t,newConfig:f}):Ae(e)&&e.forEach((y,x)=>{y=Pu(y,Nt);const v=y,C=Vr(y),_=Wr(y),{newConfig:k,arrayObject:T}=Gr(y);T.length&&(y=T);const{config:P}=lt(typeof y=="string"?"text":"array",k),{hideConfig:j,sourceLabel:R,label:E,isEdgeAnimated:M,parent:I}=k;u=u||j;const N=t==="root"&&i.isCntr,O=t.split(".").slice(0,2).join("."),W=dn.includes(O),z=i.isCntr&&W||x%2===0&&N;let re=`${t}.${x}`;re=zt(re,r),z&&dn.push(re),yr(y)?Object.keys(C).length&&!Ae(y)?(n.push(Dr(t,re,null,R,z,M)),Qr(y,re,r,n,E||x,i,k)):Object.keys(_).length&&!Ae(y)?$t({flowConfig:i,chldPth:re,isInverted:z,edges:n,itrblObjct:_,nodes:r,path:t,newConfig:k,forceIsInverted:!0}):Ae(y)?Hy({flowConfig:i,chldPth:re,edges:n,isInverted:z,item:y,nodes:r,path:t}):yr(y)&&$t({flowConfig:i,chldPth:re,isInverted:z,edges:n,itrblObjct:[y],nodes:r,path:t,newConfig:k}):(n.push(Dr(t,re,null,R,z,M)),r.push(Yr(P,re,{label:E||String(y),parent:I},y,v)))})),{nodes:r,edges:n}}catch{return{nodes:r,edges:n}}}const $t=({chldPth:e,flowConfig:t,edges:r,itrblObjct:n,nodes:o,isInverted:i,path:a,newConfig:s,forceIsInverted:u=!1})=>{let{hideDefaultObject:c,sprtObjctKy:l}=t;return Object.entries(n).forEach(([d,f],p)=>{f=Pu(f,Nt);const b=f,g=Vr(f),m=Wr(f),{newConfig:w,arrayObject:y}=Gr(f);y.length&&(f=y);const{hideConfig:x,sourceLabel:v,label:C,content:_,target:k,targetLabel:T,collapsed:P,isEdgeAnimated:j,parent:R}=w;c=c||x;const E=a==="root"&&t.isCntr,M=a.split(".").slice(0,2).join("."),I=dn.includes(M);u||(i=t.isCntr&&I||p%2===0&&E);let N=e?`${e}.${d}`:`${a}.${d}`;if(N=zt(N,o),i&&dn.push(N),k&&r.push(Dr(N,k,null,T,i,j)),yr(f)&&!Ae(f)){r.push(Dr(a,N,null,v,i,j));const O=l||Object.keys(g).length===0;if(O){const W=_?"object":"array",{config:z}=lt(W,w);z.data.headerTitle=_?C:null,o.push(Yr(z,N,{label:C||d,parent:R},f,b))}if(Object.keys(g).length&&!c){const W=Ae(f)?` ${f.length||""}`:`{${Object.keys(f).length||""}}`;let z=N;O&&(z=`${N}.${W}`,z=zt(z,o),r.push(Dr(N,z,null,v,i,j))),Qr(f,z,o,r,C||d,t,w)}else Object.keys(m).length&&!Ae(f)?$t({chldPth:N,flowConfig:t,itrblObjct:m,path:N,edges:r,nodes:o,newConfig:w,isInverted:i}):Qr(f,N,o,r,d,t,w)}else Ae(f)&&(r.push(Dr(a,N,null,v,i,j)),Qr(f,N,o,r,d,t,w))})},Hy=({flowConfig:e,chldPth:t,edges:r,isInverted:n,item:o,nodes:i,path:a})=>o.forEach((s,u)=>{let c=`${t}.${u}`;c=zt(c,i);const l=s;s=Pu(s,Nt);const d=Wr(s),f=Vr(s),{newConfig:p}=Gr(s),{collapsed:b,label:g,parent:m,sourceLabel:w,isEdgeAnimated:y,content:x}=p;yr(s)?!Ae(s)&&Object.keys(f).length?(r.push(Dr(a,c,null,w,n,y)),Qr(s,c,i,r,u,e,p)):Object.keys(d).length&&!Ae(s)&&!b?$t({chldPth:c,flowConfig:e,itrblObjct:d,path:a,edges:r,nodes:i,isInverted:n,newConfig:p}):Ae(s)&&Hy({flowConfig:e,chldPth:c,edges:r,isInverted:n,item:s,nodes:i,path:a}):(r.push(Dr(a,c,null,w,n,y)),i.push(Yr(ku,c,{label:g||String(s),parent:m},s,l)))});function Hx(e,t){const r=new Set,n=c=>{if(!(!c||typeof c!="object")){typeof c.$parent=="string"&&r.add(c.$parent);for(const[l,d]of Object.entries(c))(!l.startsWith("$")||l==="$")&&n(d)}};if(n(e),!r.size)return t;const o=new Map(t.nodes.map(c=>[c.data.id,c])),i=c=>{var p,b;let l=c.data.id;const d=new Set([c.data.id]);let f=c.data.parent;for(;f&&!d.has(f);)r.has(f)&&o.has(f)&&((p=ve(e,f))!=null&&p.$collapsed)&&(l=f),d.add(f),f=(b=o.get(f))==null?void 0:b.data.parent;return l},a=new Map(t.nodes.map(c=>[c.data.id,i(c)])),s=t.nodes.filter(c=>a.get(c.data.id)===c.data.id).map(c=>{if(!r.has(c.data.id))return c;const l=ve(e,c.data.id),d=!!(l!=null&&l.$collapsed);return{...c,data:{...c.data,...d?{type:"arrayView"}:{},config:{...c.data.config,parentContainer:!0,collapsed:d,...d?{labelBelow:!0,icon:(l==null?void 0:l.$icon)||"PiStack"}:{}}}}}),u=new Set(s.map(c=>c.data.id));return{nodes:s,edges:t.edges.flatMap(c=>{const l=a.get(c.data.source),d=a.get(c.data.target);return!l||!d||!u.has(l)||!u.has(d)?[]:l===c.data.source&&d===c.data.target?[c]:l===d?[]:[{...c,data:{...c.data,source:l,target:d,collapsedEndpoints:c.data.collapsedEndpoints??{source:c.data.source,target:c.data.target}}}]})}}function vn(e){if(!Array.isArray(e==null?void 0:e.$connections))return[];const t=new Map;return e.$connections.flatMap((r,n)=>{if(!r||typeof r!="object")return[];const o=r;if(typeof o.target!="string"||!/^root(?:\.|$)/.test(o.target))return[];if(o.sourceProperty!==void 0&&typeof o.sourceProperty!="string")return[];if(o.targetProperty!==void 0&&typeof o.targetProperty!="string")return[];const i=typeof o.id=="string"&&o.id?JSON.stringify(["id",o.id]):JSON.stringify(["ports",o.target,o.sourceProperty??null,o.targetProperty??null]),a=t.get(i)??0;return t.set(i,a+1),[{value:o,key:`${i}#${a}`,index:n}]})}function Ky(e,t,r){const n=vn(e).find(u=>u.key===t);if(!n)return e;const o=r(n.value),i=e.$connections.flatMap((u,c)=>c===n.index?o?[o]:[]:[u]);if(i.length)return{...e,$connections:i};const{$connections:a,...s}=e;return s}function Kx(e){const t=[],r=(n,o)=>{if(!n||typeof n!="object")return n;if(Array.isArray(n))return n.map((i,a)=>r(i,`${o}.${a}`));for(const i of vn(n)){const a=i.value;t.push({data:{id:`connection:${JSON.stringify([o,i.key])}`,source:o,target:a.target,type:typeof a.type=="string"?a.type:void 0,sourceProperty:a.sourceProperty,targetProperty:a.targetProperty,icon:typeof a.icon=="string"?a.icon:void 0,label:typeof a.label=="string"?a.label:void 0,color:typeof a.color=="string"?a.color:void 0,isEdgeDashed:a.style==="dashed",isEdgeAnimated:a.style==="animated",...["dashed","traveling"].includes(a.animationVariant)?{edgeAnimationVariant:a.animationVariant}:{},connection:{address:o,key:i.key}}})}return Object.fromEntries(Object.entries(n).filter(([i])=>i!=="$connections").map(([i,a])=>[i,i==="$"?r(a,o):i.startsWith("$")?a:r(a,`${o}.${i}`)]))};return{json:r(e,"root"),edges:t}}const Vt="root",_l=e=>e==="#"||e.startsWith("{")||/^\s\d*$/.test(e);function Mr(e){const t=e.split(".");for(t[0]===Vt&&t.shift();t.length&&_l(t[t.length-1]);)t.pop();return t.filter(r=>!_l(r))}function xn(e){return e==null||typeof e!="object"?e:Array.isArray(e.$)?e.$:e}function ve(e,t){return Mr(t).reduce((r,n)=>{var o;if(r!=null)return(o=xn(r))==null?void 0:o[n]},e)}function Jx(e){return Array.isArray(e)?[...e]:{...e}}function br(e,t,r){const n=Mr(t),o=(i,a)=>{if(a===n.length)return r(i);const s=n[a],u=xn(i);if(u==null||typeof u!="object")return i;const c=o(u[s],a+1);if(Object.is(c,u[s]))return i;const l=Jx(u);return l[s]=c,u!==i?{...i,$:l}:l};return o(e,0)}function Or(e,t,r){const n=r===""&&t!=="$content"||r===void 0||r===null;if(Array.isArray(e))return n?e:{[t]:r,$:[...e]};const o=e!=null&&typeof e=="object"?{...e}:{};return e!=null&&typeof e!="object"&&(o.$label=String(e)),n?delete o[t]:o[t]=r,o}function cr(e,t,r,n){return br(e,t,o=>r==="$label"&&typeof o=="string"&&typeof n=="string"&&n!==""?n:Or(o,r,n))}const Jy=(e,t,r)=>cr(e,t,"$collapsed",r);function Wt(e){if(e.connection)return{address:e.connection.address,kind:"connection"};const t=e.collapsedEndpoints??e,r=e.isInverted?t.target:t.source,n=e.isInverted?t.source:t.target,o=Mr(r).join("."),i=Mr(n).join(".");return i.startsWith(o?o+".":"")&&i!==o?{address:n,kind:"hierarchy"}:o.startsWith(i?i+".":"")&&o!==i?{address:r,kind:"hierarchy"}:{address:r,kind:"target"}}function Br(e,t,r,n){if(t.connection){const s=t.connection;return br(e,s.address,u=>Ky(u,s.key,c=>{if(r==="$edgeIcon")return Or(c,"icon",n);if(r==="$edgeType")return Or(c,"type",n);if(r==="$edgeAnimationVariant")return Or(c,"animationVariant",n);if(r==="$sourceLabel"||r==="$edgeColor")return Or(c,r==="$sourceLabel"?"label":"color",n);const l=r==="$isEdgeAnimated"?"animated":"dashed";return n?{...c,style:l}:c.style===l?Or(c,"style",void 0):c}))}const{address:o,kind:i}=Wt(t),a=i==="target"&&r==="$sourceLabel"?"$targetLabel":i==="target"&&r==="$edgeType"?"$targetEdgeType":i==="target"&&r==="$edgeIcon"?"$targetIcon":i==="target"&&r==="$edgeAnimationVariant"?"$targetAnimationVariant":r;return br(e,o,s=>Or(s,a,n))}const Zy=(e,t,r)=>Br(Br(e,t,"$isEdgeAnimated",r==="animated"||void 0),t,"$isEdgeDashed",r==="dashed"||void 0);function Au(e,t,r,n){let o=n||"";const i=br(e,t,s=>{const u=xn(s);if(Array.isArray(u)){o=String(u.length);const l=[...u,r];return u===s?l:{...s,$:l}}const c=s!=null&&typeof s=="object"&&!Array.isArray(s)?{...s}:s!=null&&typeof s!="object"?{$label:String(s)}:{};if(!o){let l=1;for(;`node_${l}`in c;)l++;o=`node_${l}`}return c[o]=r,c}),a=Mr(t);return{json:i,address:[Vt,...a,o].join(".")}}function Yy(e,t){const r=Mr(t);if(!r.length)return e;const n=r[r.length-1],o=[Vt,...r.slice(0,-1)].join(".");return br(e,o,i=>{const a=xn(i);if(a==null||typeof a!="object"||!Object.prototype.hasOwnProperty.call(a,n))return i;if(Array.isArray(a)){const c=a.filter((l,d)=>String(d)!==n);return a===i?c:{...i,$:c}}const{[n]:s,...u}=i;return u})}const Xy=(e,t,r,n)=>cr(n?br(e,t,o=>Or(o,"$targetLabel",n)):e,t,"$target",r);function Tu(e,t,r){const n=ve(e,t);return vn(n).some(({value:i})=>i.target===r.target&&i.sourceProperty===r.sourceProperty&&i.targetProperty===r.targetProperty)?e:br(e,t,i=>Or(i,"$connections",[...Array.isArray(i==null?void 0:i.$connections)?i.$connections:[],{...r,id:r.id||Ru()}]))}function Qy(e,t){if(t.connection){const i=t.connection;return vn(ve(e,i.address)).some(a=>a.key===i.key)?{json:br(e,i.address,a=>Ky(a,i.key,()=>null)),removed:!0}:{json:e,removed:!1}}const{address:r,kind:n}=Wt(t);return n==="hierarchy"?ve(e,r)===void 0?{json:e,removed:!1}:{json:br(e,r,i=>({...i,$hideParentEdge:!0})),removed:!0}:n!=="target"?{json:e,removed:!1}:{json:br(e,r,i=>{const{$target:a,$targetLabel:s,...u}=i||{};return u}),removed:!0}}function vu(e,t={}){var w;const r=Kx(e),{nodes:n,edges:o}=Qr(r.json,Vt,[],[],t.title||"untitled",{hideDefaultObject:!!t.hideDefaultObject,sprtObjctKy:!!t.separateObjectKeys,isCntr:!!t.isCenter}),i=new Set(n.map(y=>y.data.id)),a=new Map;for(const y of n){const x=y.data.id;if(!x.endsWith(".0")||ve(e,x)!==void 0)continue;const v=x.slice(0,-2),C=ve(e,v);!i.has(v)&&C&&typeof C=="object"&&!Array.isArray(C)&&typeof C.$label=="string"&&Object.keys(C).every(_=>_.startsWith("$")&&_!=="$")&&a.set(x,v)}const s=y=>a.get(y)??y,u=new Set(n.flatMap(y=>y.data.parent?[s(y.data.parent)]:[])),c=n.map(y=>{var T;const x=s(y.data.id),v=ve(e,x),C={...y.data,id:x},_=v&&typeof v=="object"&&!Array.isArray(v)&&"$"in v?v.$:v;if((Array.isArray(_)?_.length>0:_&&typeof _=="object"&&Object.keys(_).some(P=>!P.startsWith("$")))&&(C.config={...C.config,collapsed:!!v.$collapsed}),u.has(x)||(C.viewProps={...C.viewProps},delete C.viewProps.borderWidth),!v||typeof v!="object"||Array.isArray(v))return{data:C};if(v.$form&&typeof v.$form=="object"&&(C.config={...C.config,form:v.$form},C.type="objectView"),Array.isArray(v.$ports)){const P=v.$ports.filter(j=>j&&typeof j.id=="string"&&["source","target"].includes(j.role)&&["top","right","bottom","left"].includes(j.side));C.config={...C.config,ports:P}}return C.parent&&(C.parent=s(C.parent)),typeof v.$label=="string"&&(C.label=v.$label,C.headerTitle=v.$label),typeof v.$subtitle=="string"&&(C.config={...C.config,subtitle:v.$subtitle}),typeof v.$outline=="boolean"&&(C.viewProps={...C.viewProps,outline:v.$outline}),["solid","dashed","dotted","double"].includes(v.$borderStyle)&&(C.viewProps={...C.viewProps,borderStyle:v.$borderStyle}),Number.isFinite(v.$borderWidth)&&v.$borderWidth>=0&&(C.viewProps={...C.viewProps,borderWidth:v.$borderWidth}),Number.isFinite(v.$borderRadius)&&v.$borderRadius>=0&&(C.viewProps={...C.viewProps,borderRadius:v.$borderRadius}),typeof v.$isNodeAnimated=="boolean"&&(C.isNodeAnimated=v.$isNodeAnimated),["traveling","pulse"].includes(v.$nodeAnimationVariant)&&(C.nodeAnimationVariant=v.$nodeAnimationVariant),typeof v.$content=="string"&&(C.config={...C.config,content:v.$content},v.$view||(C.type="objectView")),(((T=C.config)==null?void 0:T.collapsed)!==void 0||v.$collapsed!==void 0||v.$icon!==void 0)&&(C.config={...C.config||{}},(v.$collapsed!==void 0||C.config.collapsed!==void 0)&&(C.config.collapsed=!!v.$collapsed),v.$icon!==void 0&&(C.config.icon=v.$icon)),{data:C}}),l=new Map,d=o.map(y=>{const x=s(y.data.source),v=s(y.data.target),C=`${x}->${v}`,_=l.get(C)??0;l.set(C,_+1);const k={...y.data,id:_?`${C}#${_}`:C,source:x,target:v},T=Wt(k),P=ve(e,T.address);if(P&&typeof P=="object"){const j=P[T.kind==="target"?"$targetEdgeType":"$edgeType"];typeof j=="string"&&(k.type=j);const R=P[T.kind==="target"?"$targetIcon":"$edgeIcon"];typeof R=="string"&&(k.icon=R),P.$isEdgeAnimated!==void 0&&(k.isEdgeAnimated=!!P.$isEdgeAnimated);const E=P[T.kind==="target"?"$targetAnimationVariant":"$edgeAnimationVariant"];["dashed","traveling"].includes(E)&&(k.edgeAnimationVariant=E),P.$isEdgeDashed!==void 0&&(k.isEdgeDashed=!!P.$isEdgeDashed),P.$edgeColor&&(k.color=P.$edgeColor)}return{data:k}});if(!Array.isArray(e)&&(e==null?void 0:e.$hideRoot)===!0){const y=c.findIndex(x=>x.data.id===Vt);y!==-1&&c.splice(y,1)}const f=new Set(c.map(y=>y.data.id));for(let y=d.length-1;y>=0;y--){const x=d[y].data,v=Wt(x);(!f.has(x.source)||!f.has(x.target)||v.kind==="hierarchy"&&((w=ve(e,v.address))==null?void 0:w.$hideParentEdge)===!0)&&d.splice(y,1)}d.push(...r.edges.filter(y=>f.has(y.data.source)&&f.has(y.data.target)));const p=Hx(e,{nodes:c,edges:d}),b=p.nodes.filter(y=>{var x;return(x=y.data.config)==null?void 0:x.collapsed}).map(y=>Mr(y.data.id));if(!b.length)return p;const g=p.nodes.filter(y=>{const x=Mr(y.data.id);return!b.some(v=>v.length<x.length&&v.every((C,_)=>C===x[_]))}),m=new Set(g.map(y=>y.data.id));return{nodes:g,edges:p.edges.filter(y=>m.has(y.data.source)&&m.has(y.data.target))}}function Zx(e,t){const r=new Set(e.filter(u=>{var c,l;return(l=(c=u.data)==null?void 0:c.config)==null?void 0:l.collapsed}).map(u=>u.data.id));if(!r.size)return{nodes:e,edges:t};const n=new Map(e.map(u=>[u.data.id,u])),o=new Set(e.map(u=>u.data.parent).filter(Boolean)),i=new Map(e.map(u=>{var f;let c=u.data.id,l=u.data.parent;const d=new Set([c]);for(;l&&!d.has(l);)r.has(l)&&(c=l),d.add(l),l=(f=n.get(l))==null?void 0:f.data.parent;return[u.data.id,c]})),a=new Map;for(const u of t){const c=u.data.isInverted?u.data.target:u.data.source,l=u.data.isInverted?u.data.source:u.data.target;(a.get(c)??a.set(c,[]).get(c)).push(l)}const s=new Set(e.filter(u=>i.get(u.data.id)!==u.data.id).map(u=>u.data.id));for(const u of r){if(o.has(u))continue;const c=[...a.get(u)||[]];for(;c.length;){const l=c.pop();r.has(l)||s.has(l)||(s.add(l),c.push(...a.get(l)||[]))}}return{nodes:e.filter(u=>!s.has(u.data.id)).map(u=>{var c;return r.has(u.data.id)&&o.has(u.data.id)?{...u,data:{...u.data,type:"arrayView",label:u.data.label??u.data.headerTitle,config:{...u.data.config,parentContainer:!0,labelBelow:!0,icon:((c=u.data.config)==null?void 0:c.icon)||"PiStack"}}}:u}),edges:t.flatMap(u=>{const c=i.get(u.data.source)??u.data.source,l=i.get(u.data.target)??u.data.target;return s.has(c)||s.has(l)?[]:c===u.data.source&&l===u.data.target?[u]:c===l?[]:[{...u,data:{...u.data,source:c,target:l,collapsedEndpoints:u.data.collapsedEndpoints??{source:u.data.source,target:u.data.target}}}]})}}function Ou(e,t){const r=JSON.parse(e);let n=512;const o=(a,s=[])=>{if(--n<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(!a||typeof a!="object"||Array.isArray(a))throw new Error("Expected a JSON Schema object.");const u=new Set(["$schema","$id","$defs","definitions","$ref","title","description","default","examples","type","properties","required","items","enum","const","anyOf","additionalProperties"]);for(const l of Object.keys(a))if(!u.has(l))throw new Error(`Unsupported JSON Schema keyword: ${l}`);const c=["$schema","$id","$defs","definitions","title","description","default","examples"];if(a.$ref){if(Object.keys(a).some(d=>!["$ref","title","description"].includes(d)))throw new Error("Use $ref without sibling constraints.");if(typeof a.$ref!="string"||!a.$ref.startsWith("#/")||s.includes(a.$ref))throw new Error("Only nonrecursive local $ref references are supported.");let l=r;for(const d of a.$ref.slice(2).split("/")){const f=d.replace(/~1/g,"/").replace(/~0/g,"~");if(!l||!Object.prototype.hasOwnProperty.call(l,f))throw new Error(`Unresolved reference: ${a.$ref}`);l=l[f]}return o(l,[...s,a.$ref])}if(a.anyOf){if(!Array.isArray(a.anyOf)||!a.anyOf.length||Object.keys(a).some(l=>l!=="anyOf"&&!c.includes(l)))throw new Error("Use a nonempty anyOf without sibling type constraints.");return{kind:"union",types:a.anyOf.map(l=>o(l,s))}}if(Object.prototype.hasOwnProperty.call(a,"const")||a.enum){if(Object.keys(a).some(f=>![...c,"const","enum","type"].includes(f))||a.enum&&Object.prototype.hasOwnProperty.call(a,"const"))throw new Error("Use enum or const without sibling constraints other than type.");const l=Object.prototype.hasOwnProperty.call(a,"const")?[a.const]:a.enum;if(!Array.isArray(l)||!l.length)throw new Error("Expected a nonempty enum.");return{kind:"union",types:l.map(f=>{if(f!==null&&!["string","number","boolean"].includes(typeof f))throw new Error("Only primitive literals are supported.");const p=f===null?"null":typeof f;if(a.type&&!(Array.isArray(a.type)?a.type:[a.type]).some(b=>b===p||b==="integer"&&Number.isInteger(f)))throw new Error("Literal does not match its declared type.");return{kind:"literal",value:f}})}}if(Array.isArray(a.type)){if(!a.type.length||a.type.some(l=>typeof l!="string"))throw new Error("Expected a nonempty list of primitive types.");if(Object.keys(a).some(l=>l!=="type"&&!c.includes(l)))throw new Error("Use anyOf for unions with object or array constraints.");return{kind:"union",types:a.type.map(l=>o({type:l},s))}}if((a.properties||a.required||a.additionalProperties!==void 0)&&a.type!=="object"&&a.type!==void 0)throw new Error("Object constraints require an object type.");if(a.items&&a.type!=="array")throw new Error("items requires an array type.");if(a.type==="object"||a.properties){if(a.additionalProperties!==void 0&&a.additionalProperties!==!0)throw new Error("Closed objects and typed additionalProperties are not supported.");if(!a.properties||typeof a.properties!="object"||Array.isArray(a.properties))throw new Error("Object schemas must declare properties.");if(a.required!==void 0&&(!Array.isArray(a.required)||a.required.some(d=>typeof d!="string"||!Object.prototype.hasOwnProperty.call(a.properties,d))))throw new Error("required must list declared property names.");return{kind:"object",properties:Object.fromEntries(Object.entries(a.properties).map(([d,f])=>[d,{type:o(f,s),optional:!(a.required??[]).includes(d)}]))}}if(a.type==="array")return{kind:"array",items:o(a.items,s)};if(["string","number","integer","boolean","null"].includes(a.type))return{kind:a.type};throw new Error("Every property must declare a supported type.")},i=o(r);if(i.kind!=="object")throw new Error("The root schema must be an object keyed by node ID.");if(Object.values(i.properties).some(a=>a.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:t,nodes:i.properties}}async function Iu(e,t,r,n={}){var b;let o=512;const i=await import("typescript"),a=i.createSourceFile(t,e,i.ScriptTarget.Latest,!0,i.ScriptKind.TS),s=a.parseDiagnostics;if(s!=null&&s.length)throw new Error("Invalid TypeScript syntax.");const u=new Map;for(const g of a.statements){if(!i.isInterfaceDeclaration(g)&&!i.isTypeAliasDeclaration(g))throw new Error("Upload interfaces/type aliases only; imports and executable code are not supported.");if((b=g.typeParameters)!=null&&b.length||u.has(g.name.text))throw new Error("Generics and duplicate declarations are not supported.");u.set(g.name.text,g)}const c=(g,m)=>{var C;const w={},y=g.find(_=>i.isIndexSignatureDeclaration(_));let x;if(y&&n.allowJson&&i.isIndexSignatureDeclaration(y)){if(g.filter(_=>i.isIndexSignatureDeclaration(_)).length!==1||y.parameters.length!==1||((C=y.parameters[0].type)==null?void 0:C.kind)!==i.SyntaxKind.StringKeyword||!y.type)throw new Error("Only one string-keyed index signature is supported for forms.");x=d(y.type,m)}return{kind:"object",properties:Object.fromEntries(g.filter(_=>_!==y||!x).map(_=>{if(!i.isPropertySignature(_)||!_.type||!_.name||!i.isIdentifier(_.name)&&!i.isStringLiteral(_.name))throw new Error("Only explicitly typed named properties are supported.");const k=d(_.type,m),T=n.allowJson?i.getJSDocTags(_).filter(P=>P.tagName.text==="port"):[];if(T.length>1)throw new Error(`Duplicate port declaration: ${_.name.text}`);if(T.length){const[P,j,R]=String(T[0].comment??"").trim().split(/\s+/);if(P!=="config"||!j||R||!u.has(j))throw new Error(`Config port ${_.name.text} requires @port config ResourceType`);const E=k.kind==="array";if((k.kind==="array"?k.items.kind:k.kind)!=="string")throw new Error(`Config port ${_.name.text} must be a string or string array reference`);w[_.name.text]={kind:"config",resourceType:j,multiple:E}}return[_.name.text,{type:k,optional:!!_.questionToken}]})),...x?{additionalProperties:x}:{},...Object.keys(w).length?{ports:w}:{}}},l=(g,m)=>{var C;if(m.includes(g))throw new Error("Recursive types are not supported.");const w=u.get(g);if(!w)throw new Error(`Unknown type: ${g}`);let y;if(i.isInterfaceDeclaration(w)){if((C=w.heritageClauses)!=null&&C.length)throw new Error("Interface inheritance is not supported; declare properties explicitly.");y=c(w.members,[...m,g])}else y=d(w.type,[...m,g]);const x=n.allowJson?i.getJSDocTags(w).filter(_=>_.tagName.text==="port"):[];if(!x.length)return y;if(y.kind!=="object")throw new Error("Node ports require an object interface");const v={...y.ports};for(const _ of x){const[k,T,...P]=String(_.comment??"").trim().split(/\s+/);if(!["input","output","error"].includes(k)||!/^[A-Za-z][\w-]*$/.test(T??""))throw new Error("Node ports require @port input|output|error Name");const j=P.length?JSON.parse(P.join(" ")):void 0;if(j!==void 0&&typeof j!="string")throw new Error("Node port labels must be JSON strings");if(Object.prototype.hasOwnProperty.call(v,T))throw new Error(`Duplicate port declaration: ${T}`);v[T]={kind:k,...typeof j=="string"?{label:j}:{}}}return{...y,ports:v}},d=(g,m)=>{var w,y,x;if(--o<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(g.kind===i.SyntaxKind.StringKeyword)return{kind:"string"};if(g.kind===i.SyntaxKind.NumberKeyword)return{kind:"number"};if(g.kind===i.SyntaxKind.BooleanKeyword)return{kind:"boolean"};if(n.allowJson&&[i.SyntaxKind.AnyKeyword,i.SyntaxKind.UnknownKeyword].includes(g.kind))return{kind:"json"};if(i.isParenthesizedTypeNode(g))return d(g.type,m);if(i.isUnionTypeNode(g))return{kind:"union",types:g.types.map(v=>d(v,m))};if(i.isArrayTypeNode(g))return{kind:"array",items:d(g.elementType,m)};if(i.isTypeLiteralNode(g))return c(g.members,m);if(i.isLiteralTypeNode(g)){const v=g.literal;if(i.isStringLiteral(v))return{kind:"literal",value:v.text};if(i.isNumericLiteral(v))return{kind:"literal",value:Number(v.text)};if(v.kind===i.SyntaxKind.NullKeyword)return{kind:"null"};if(v.kind===i.SyntaxKind.TrueKeyword||v.kind===i.SyntaxKind.FalseKeyword)return{kind:"literal",value:v.kind===i.SyntaxKind.TrueKeyword}}if(i.isTypeReferenceNode(g)&&i.isIdentifier(g.typeName)){if(n.allowJson&&g.typeName.text==="Record"&&!u.has("Record")&&((w=g.typeArguments)==null?void 0:w.length)===2&&g.typeArguments[0].kind===i.SyntaxKind.StringKeyword)return{kind:"object",properties:{},additionalProperties:d(g.typeArguments[1],m)};if(g.typeName.text==="Array"&&((y=g.typeArguments)==null?void 0:y.length)===1)return{kind:"array",items:d(g.typeArguments[0],m)};if(!((x=g.typeArguments)!=null&&x.length))return l(g.typeName.text,m)}throw new Error(`Unsupported TypeScript type: ${g.getText(a)}`)},f=r??(u.has("Graph")?"Graph":u.size===1?[...u.keys()][0]:void 0);if(!f)throw new Error("Declare an interface Graph keyed by node ID.");const p=l(f,[]);if(p.kind!=="object")throw new Error("Graph must be an object keyed by node ID.");return p}async function eb(e,t){const r=await Iu(e,t);if(Object.values(r.properties).some(n=>n.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:t,nodes:r.properties}}function Rt(e,t){if(e.kind==="json"||t.kind==="json"||e.kind==="object"&&e.additionalProperties||t.kind==="object"&&t.additionalProperties)return!1;if(e.kind==="union")return e.types.every(r=>Rt(r,t));if(t.kind==="union")return t.types.some(r=>Rt(e,r));if(e.kind==="literal"){if(t.kind==="literal")return e.value===t.value;const r=e.value===null?"null":typeof e.value;return t.kind===r||t.kind==="integer"&&typeof e.value=="number"&&Number.isInteger(e.value)}return e.kind==="integer"&&t.kind==="number"?!0:e.kind==="array"&&t.kind==="array"?Rt(e.items,t.items):e.kind==="object"&&t.kind==="object"?Object.entries(t.properties).every(([r,n])=>{const o=Object.prototype.hasOwnProperty.call(e.properties,r)?e.properties[r]:void 0;return o?(n.optional||!o.optional)&&Rt(o.type,n.type):n.optional}):e.kind===t.kind}function Mu(e,t){if(!t.sourceProperty&&!t.targetProperty)return;const r=(a,s)=>{var l;const u=Object.prototype.hasOwnProperty.call(e.nodes,a)?a:a.replace(/^root\./,""),c=Object.prototype.hasOwnProperty.call(e.nodes,u)?(l=e.nodes[u])==null?void 0:l.type:void 0;return s&&(c==null?void 0:c.kind)==="object"&&Object.prototype.hasOwnProperty.call(c.properties,s)?c.properties[s]:void 0},n=r(t.source,t.sourceProperty),o=r(t.target,t.targetProperty);if(!n||!o)return"Unverified: source or target property is missing from the interface.";const i=a=>a.kind==="json"||a.kind==="object"&&(!!a.additionalProperties||Object.values(a.properties).some(s=>i(s.type)))||a.kind==="array"&&i(a.items)||a.kind==="union"&&a.types.some(i);if(i(n.type)||i(o.type))return"Unverified: arbitrary JSON or dictionary fields require runtime validation.";if(n.optional&&!o.optional)return"Optional source cannot supply a required target property.";if(!Rt(n.type,o.type))return`Incompatible property types: ${t.sourceProperty} -> ${t.targetProperty}.`}async function rb(e){if(e.size>256*1024)throw new Error("Interface must be 256 KB or smaller.");const t=await e.text();if(/\.json$/i.test(e.name))return Ou(t,e.name);if(/\.ts$/i.test(e.name))return eb(t,e.name);throw new Error("Choose a .ts interface or .json JSON Schema file.")}const Sl=new WeakMap;function Gt(e){if(!e||typeof e!="object")return e;const t=Sl.get(e);if(t)return t;const r=()=>{throw new Error("Form callback data is read-only. Return edits instead.")},n=new Proxy(Array.isArray(e)?[]:{},{get:(o,i)=>Gt(Reflect.get(e,i)),has:(o,i)=>Reflect.has(e,i),ownKeys:()=>Reflect.ownKeys(e),getOwnPropertyDescriptor:(o,i)=>{const a=Reflect.getOwnPropertyDescriptor(e,i);return a&&{...a,value:Gt(Reflect.get(e,i)),configurable:i!=="length"||!Array.isArray(e)}},set:r,deleteProperty:r,defineProperty:r,setPrototypeOf:r,preventExtensions:r});return Sl.set(e,n),n}function yt(e,t,r){var o;const n=t.split(".");for(let i=n.length;i>0;i--){const a=n.slice(0,i).join("."),s=(o=ve(e,a))==null?void 0:o.$form;if(!(s!=null&&s.$type))continue;let u=Object.prototype.hasOwnProperty.call(r,s.$type)?r[s.$type]:void 0;for(const d of n.slice(i))(u==null?void 0:u.kind)==="array"&&/^\d+$/.test(d)?u=u.items:(u==null?void 0:u.kind)==="object"?u=Object.prototype.hasOwnProperty.call(u.properties,d)?u.properties[d].type:void 0:u=void 0;if((u==null?void 0:u.kind)!=="object")return;const c=n.slice(i).join("."),l=Object.fromEntries(Object.entries(s.$fields??{}).filter(([d])=>!c||d.startsWith(`${c}.`)).map(([d,f])=>[c?d.slice(c.length+1):d,f]));return{type:u,fields:l,binding:s}}}async function qu(e,t){if(e.size>256*1024)throw new Error("Form schema exceeds 256 KB.");const r=await e.text();if(e.name.endsWith(".ts")){if(!t.length||t.length>32)throw new Error("Choose between 1 and 32 form interface names.");const o=[],i=new Set(t);for(const a of i){if(i.size>32)throw new Error("Choose between 1 and 32 form interface names.");const s=await Iu(r,e.name,a,{allowJson:!0});o.push([a,s]);for(const u of Object.values(s.ports??{}))u.resourceType&&i.add(u.resourceType)}return Object.fromEntries(o)}if(!e.name.endsWith(".json"))throw new Error("Choose a .ts interface or .json schema file.");const n=Ou(r,e.name);return Object.fromEntries(Object.entries(n.nodes).map(([o,i])=>[o,i.type]))}function wn(e,t){return!e||("$in"in e?e.$in.includes(ve(t,e.$address)):ve(t,e.$address)===e.$equals)}function Lt(e){const t=e.kind==="array"?e.items:e,r=t.kind==="union"?t.types:[t];if(r.every(n=>n.kind==="literal"))return r.map(n=>({label:String(n.value),value:n.value}))}function Rr(e,t,r){if(t===void 0||t==="")return r?"Required":void 0;if(e.kind==="json"){const n=new Set,o=i=>{if(i===null||typeof i=="string"||typeof i=="boolean")return!0;if(typeof i=="number")return Number.isFinite(i);if(!i||typeof i!="object"||n.has(i)||!Array.isArray(i)&&![Object.prototype,null].includes(Object.getPrototypeOf(i)))return!1;n.add(i);const a=Object.values(i).every(o);return n.delete(i),a};return o(t)?void 0:"Expected a JSON value"}if(e.kind==="union")return e.types.some(n=>!Rr(n,t,!0))?void 0:"Choose a valid value";if(e.kind==="literal")return t===e.value?void 0:"Choose a valid value";if(e.kind==="array")return Array.isArray(t)&&t.every(n=>!Rr(e.items,n,!0))?void 0:"Invalid list value";if(e.kind==="object")return!t||typeof t!="object"||Array.isArray(t)?"Expected an object":e.additionalProperties&&Object.entries(t).some(([n,o])=>!Object.prototype.hasOwnProperty.call(e.properties,n)&&Rr(e.additionalProperties,o,!0))?"Invalid dictionary value":Object.entries(e.properties).some(([n,o])=>Rr(o.type,t[n],!o.optional))?"Invalid object fields":void 0;if(e.kind==="null")return t===null?void 0:"Expected null";if(e.kind==="integer")return Number.isInteger(t)?void 0:"Expected a whole number";if(typeof t!==e.kind||typeof t=="number"&&!Number.isFinite(t))return`Expected ${e.kind}`}function El(e,t){const r=t.address.split(".");if(r.shift()!=="root"||!r.length||r.some(s=>!s||["__proto__","prototype","constructor","#"].includes(s)))throw new Error("Invalid form field address.");const n=r.pop(),o=n==="$bgColor"||n==="$textColor"||n==="$borderColor";if(r.some(s=>s.startsWith("$"))||n.startsWith("$")&&!o)throw new Error("Unsupported form metadata address.");const i=["root",...r].join("."),a=ve(e,i);if(!a||typeof a!="object")throw new Error(`Missing form parent: ${i}`);if(o){if(t.op==="set"&&typeof t.value!="string")throw new Error("Node colors must be strings.");return cr(e,i,n,t.op==="remove"?void 0:t.value)}return br(e,i,s=>{const u=Array.isArray(s.$)?s.$:s;if(t.op==="remove"&&!Object.prototype.hasOwnProperty.call(u,n)||t.op==="set"&&Object.is(u[n],t.value))return s;const c=Array.isArray(u)?[...u]:{...u};if(Array.isArray(c)&&(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=c.length))throw new Error("Invalid array address.");return t.op==="remove"?Array.isArray(c)?c.splice(Number(n),1):delete c[n]:Object.defineProperty(c,n,{value:structuredClone(t.value),enumerable:!0,writable:!0,configurable:!0}),u===s?c:{...s,$:c}})}function Cn(e,t,r){let n=El(e,t.value===void 0?{op:"remove",address:t.address}:{op:"set",address:t.address,value:t.value});const o=r==null?void 0:r({...t,previousValue:Gt(ve(e,t.address)),data:Gt(n)});if(o&&!Array.isArray(o))throw new Error("Form change handlers must return edits synchronously.");for(const i of Array.isArray(o)?o:[]){if(i.op!=="set"&&i.op!=="remove")throw new Error("Unsupported form edit.");n=El(n,i)}return n}function Yx(e,t){let r=e;for(const n of t){if(n.op!=="set"&&n.op!=="remove")throw new Error("Unsupported state edit.");const o=n.address.split(".");if(o.some(a=>a.startsWith("$")||["__proto__","prototype","constructor"].includes(a)))throw new Error("State edits cannot target view metadata or unsafe keys.");const i=n.op==="remove"?void 0:n.value;Ut(i),r=Cn(r,{address:n.address,nodeAddress:o.slice(0,-1).join("."),value:i})}return Ut(r),r}function Xt(e,t,r){const n=Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;if(!(!n||!r||!Object.prototype.hasOwnProperty.call(r,n.type)))return{address:n.address,type:r[n.type],fields:n.fields??{}}}function Ut(e){if(!(!e||typeof e!="object"))for(const[t,r]of Object.entries(e)){if(t.startsWith("$")||["__proto__","prototype","constructor"].includes(t))throw new Error(`Form state cannot contain view metadata or unsafe keys: ${t}`);Ut(r)}}function Xx(e,t,r){Ut(t.value);const n=Cn(e,t,r);return Ut(n),n}function tb(e,t){const r=(n,o="")=>{if(!n||typeof n!="object")return n;if(["$label","$subtitle","$content","$icon","$bgColor","$textColor","$borderColor"].includes(o)&&typeof n.$state=="string"){const a=ve(t,n.$state);return a==null?"":typeof a=="object"?JSON.stringify(a,null,2):String(a)}let i=n;for(const[a,s]of Object.entries(n)){const u=r(s,a);u!==s&&(i===n&&(i=Array.isArray(n)?[...n]:{...n}),Object.defineProperty(i,a,{value:u,enumerable:!0,writable:!0,configurable:!0}))}return i};return r(e)}const Xr=(e="reference")=>({kind:e,text:"",paths:[""]}),nb=e=>/^[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*|\.\d+)+$/.test(e)&&!e.split(".").some(t=>["__proto__","constructor","prototype"].includes(t));function Qx(e,t){const r=new Set(t.map(a=>a.path)),n=a=>{if(!a.paths.length||a.paths.some(s=>!nb(s)||!r.has(s)))throw new Error("Choose an available reference.");return[...a.paths,...a.fallback===void 0?[]:[JSON.stringify(a.fallback)]].join(" || ")},o=a=>{if(a.includes("{{")||a.includes("}}"))throw new Error("Use a reference part for dynamic values.");return a},i=a=>a.map(s=>{if(s.kind==="text")return o(s.text);if(s.kind==="conditional"){if(s.paths.length!==1||s.fallback!==void 0)throw new Error("Choose one condition reference.");return`{{#if ${n(s)}}}${o(s.text)}{{/if}}`}return`{{${n(s)}}}`}).join("");if(e.mode==="reference"||e.mode==="condition"){if(e.parts.length!==1||e.parts[0].kind!=="reference")throw new Error("Choose one reference binding.");const a=i(e.parts);return e.mode==="condition"?`${a} == ${JSON.stringify(e.comparison)}`:a}if(e.mode==="json"){const a=e.fields.map(s=>s.key);if(!a.length||new Set(a).size!==a.length||a.some(s=>!s||["__proto__","constructor","prototype"].includes(s)))throw new Error("Output field names must be unique and nonempty.");return JSON.stringify(Object.fromEntries(e.fields.map(s=>[s.key,i(s.parts)])))}return i(e.parts)}async function e0(e){const t=await import("typescript"),r=a=>{const s=t.createSourceFile("binding.ts",`(${a})`,t.ScriptTarget.Latest,!0,t.ScriptKind.TS);if(s.parseDiagnostics.length)throw new Error("Unsupported reference expression.");const u=s.statements[0];if(!u||!t.isExpressionStatement(u))throw new Error("Unsupported reference expression.");const c=Xr();c.paths=[];const l=d=>{if(t.isParenthesizedExpression(d))return l(d.expression);if(t.isBinaryExpression(d)&&d.operatorToken.kind===t.SyntaxKind.BarBarToken){l(d.left),l(d.right);return}if(t.isStringLiteral(d)){if(c.fallback!==void 0)throw new Error("Multiple fallback values.");c.fallback=d.text;return}const f=d.getText(s);if(!nb(f)||c.fallback!==void 0)throw new Error("Unsupported reference expression.");c.paths.push(f)};if(l(u.expression),!c.paths.length)throw new Error("A binding needs a reference.");return c},n=a=>{const s=[];let u=0;const c=/\{\{([\s\S]*?)\}\}/g;for(const l of a.matchAll(c)){const d=l.index;if(d<u)continue;d>u&&s.push({...Xr("text"),text:a.slice(u,d)});const f=l[1].trim();if(f.startsWith("#if ")){const p=a.indexOf("{{/if}}",d+l[0].length);if(p<0)throw new Error("Unclosed condition.");s.push({...r(f.slice(4)),kind:"conditional",text:a.slice(d+l[0].length,p)}),u=p+7}else s.push(r(f)),u=d+l[0].length}return u<a.length&&s.push({...Xr("text"),text:a.slice(u)}),s},o={mode:"reference",parts:[Xr()],comparison:"",fields:[]};if(!e)return o;if(e.trim().startsWith("{"))try{const a=JSON.parse(e);if(a&&typeof a=="object"&&!Array.isArray(a)&&Object.values(a).every(s=>typeof s=="string"))return{...o,mode:"json",fields:Object.entries(a).map(([s,u])=>({key:s,parts:n(u)}))}}catch{}const i=n(e);if(i.length===2&&i[0].kind==="reference"&&i[1].kind==="text"){const a=t.createSourceFile("condition.ts",`value ${i[1].text}`,t.ScriptTarget.Latest,!0,t.ScriptKind.TS),s=a.statements[0];if(a.statements.length===1&&t.isExpressionStatement(s)&&t.isBinaryExpression(s.expression)&&s.expression.operatorToken.kind===t.SyntaxKind.EqualsEqualsToken&&t.isStringLiteral(s.expression.right))return{...o,mode:"condition",parts:[i[0]],comparison:s.expression.right.text}}return{...o,mode:i.length===1&&i[0].kind==="reference"?"reference":"template",parts:i}}function jl({parts:e,references:t,onChange:r,disabled:n}){const o=(i,a)=>r(e.map((s,u)=>u===i?{...s,...a}:s));return h.jsxs("div",{style:{display:"grid",gap:12},children:[e.map((i,a)=>h.jsxs("fieldset",{"data-binding-part":a,style:{border:0,padding:0,margin:0,minWidth:0},children:[h.jsxs("legend",{children:["Part ",a+1]}),h.jsxs("div",{style:{display:"flex",gap:8},children:[h.jsxs("span",{"data-form-select":"",style:{flex:1},children:[h.jsxs("select",{"aria-label":"Part type",disabled:n,value:i.kind,onChange:s=>o(a,{kind:s.target.value}),children:[h.jsx("option",{value:"reference",children:"Reference"}),h.jsx("option",{value:"text",children:"Text"}),h.jsx("option",{value:"conditional",children:"Conditional text"})]}),h.jsx(J.PiCaretDown,{size:16,"aria-hidden":"true"})]}),h.jsx(me,{"aria-label":`Remove part ${a+1}`,title:"Remove part",icon:h.jsx(J.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>r(e.filter((s,u)=>u!==a))})]}),i.kind!=="text"&&h.jsxs(h.Fragment,{children:[i.paths.map((s,u)=>h.jsxs("label",{children:["Reference ",u+1,h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsxs("select",{"aria-label":`Reference ${u+1}`,disabled:n,value:s,onChange:c=>o(a,{paths:i.paths.map((l,d)=>d===u?c.target.value:l)}),children:[h.jsx("option",{value:"",children:"Select reference"}),t.map(c=>h.jsx("option",{value:c.path,children:c.label},c.path))]}),h.jsx(J.PiCaretDown,{size:16,"aria-hidden":"true"})]})]},u)),i.kind==="reference"&&h.jsxs(h.Fragment,{children:[h.jsx(me,{"aria-label":"Add fallback reference",title:"Add fallback reference",icon:h.jsx(J.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>o(a,{paths:[...i.paths,""]})}),h.jsxs("label",{style:{display:"flex",gap:8,alignItems:"center"},children:[h.jsx("input",{type:"checkbox","aria-label":"Default value enabled",disabled:n,checked:i.fallback!==void 0,onChange:s=>o(a,{fallback:s.target.checked?"":void 0})}),"Default value"]}),i.fallback!==void 0&&h.jsx("input",{"aria-label":"Default value",disabled:n,value:i.fallback,onChange:s=>o(a,{fallback:s.target.value})})]})]}),i.kind!=="reference"&&h.jsxs("label",{children:["Text",h.jsx("textarea",{"aria-label":"Part text",disabled:n,value:i.text,onChange:s=>o(a,{text:s.target.value})})]})]},a)),h.jsx(me,{"aria-label":"Add part",title:"Add part",icon:h.jsx(J.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>r([...e,Xr()])})]})}function r0({label:e,value:t,references:r,disabled:n,onChange:o}){const[i,a]=S.useState(),[s,u]=S.useState(""),[c,l]=S.useState(!1),d=async()=>{l(!0),u("");try{a(await e0(typeof t=="string"?t:""))}catch(f){u(f instanceof Error?f.message:"Unable to read binding.")}finally{l(!1)}};return h.jsxs("div",{"data-runtime-binding":e,style:{marginBottom:8},children:[h.jsx(me,{"aria-label":`Bind ${e}`,title:`Bind ${e}`,icon:h.jsx(J.PiLink,{size:18}),size:"sm",variant:"ghost",disabled:n||c,onClick:d}),typeof t=="string"&&t.includes("{{")&&h.jsx("span",{children:"Bound value"}),i&&h.jsxs("fieldset",{disabled:n,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[h.jsxs("label",{children:["Binding mode",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsxs("select",{"aria-label":"Binding mode",value:i.mode,onChange:f=>a({...i,mode:f.target.value,parts:[Xr()]}),children:[h.jsx("option",{value:"reference",children:"Reference"}),h.jsx("option",{value:"condition",children:"Equals"}),h.jsx("option",{value:"template",children:"Text template"}),h.jsx("option",{value:"json",children:"JSON output"})]}),h.jsx(J.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),i.mode==="json"?h.jsxs(h.Fragment,{children:[i.fields.map((f,p)=>h.jsxs("fieldset",{"data-output-field":p,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[h.jsxs("label",{children:["Output field name",h.jsx("input",{"aria-label":"Output field name",value:f.key,onChange:b=>a({...i,fields:i.fields.map((g,m)=>m===p?{...g,key:b.target.value}:g)})})]}),h.jsx(jl,{parts:f.parts,references:r,disabled:n,onChange:b=>a({...i,fields:i.fields.map((g,m)=>m===p?{...g,parts:b}:g)})}),h.jsx(me,{"aria-label":"Remove output field",title:"Remove output field",icon:h.jsx(J.PiTrash,{size:18}),size:"sm",variant:"ghost",onClick:()=>a({...i,fields:i.fields.filter((b,g)=>g!==p)})})]},p)),h.jsx(me,{"aria-label":"Add output field",title:"Add output field",icon:h.jsx(J.PiPlus,{size:18}),size:"sm",variant:"ghost",onClick:()=>a({...i,fields:[...i.fields,{key:"",parts:[Xr()]}]})})]}):h.jsx(jl,{parts:i.parts,references:r,disabled:n,onChange:f=>a({...i,parts:f})}),i.mode==="condition"&&h.jsxs("label",{children:["Equals",h.jsx("input",{"aria-label":"Comparison value",value:i.comparison,onChange:f=>a({...i,comparison:f.target.value})})]}),h.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[h.jsx(me,{"aria-label":"Apply binding",title:"Apply binding",icon:h.jsx(J.PiCheck,{size:20}),size:"sm",variant:"ghost",onClick:()=>{try{o(Qx(i,r)),a(void 0),u("")}catch(f){u(f instanceof Error?f.message:"Unable to apply binding.")}}}),h.jsx(me,{"aria-label":"Cancel binding",title:"Cancel binding",icon:h.jsx(J.PiX,{size:20}),size:"sm",variant:"ghost",onClick:()=>{a(void 0),u("")}})]})]}),s&&h.jsx("p",{role:"alert",children:s})]})}const t0=e=>!!e&&!e.includes(".")&&!e.startsWith("$")&&!["__proto__","constructor","prototype"].includes(e),n0=e=>`root.__form_${encodeURIComponent(e).replace(/\./g,"%2E")}`,kt=(e,t)=>JSON.stringify([e,t]);function Ht(e,t){if(e.kind==="union"){const r=e.types.find(n=>n.kind===(Array.isArray(t)?"array":t===null?"null":typeof t)||n.kind==="literal"&&Object.is(n.value,t));return Ht(r??e.types.find(n=>n.kind!=="null")??e.types[0]??{kind:"json"},t)}return e.kind!=="json"?e:Array.isArray(t)?{kind:"array",items:{kind:"json"}}:t!==null&&typeof t=="object"||t===void 0?{kind:"object",properties:{},additionalProperties:{kind:"json"}}:{kind:t===null?"null":typeof t}}function Pt(e){const t=Ht(e,void 0);return t.kind==="object"?{}:t.kind==="array"?[]:t.kind==="literal"?t.value:t.kind==="number"||t.kind==="integer"?0:t.kind==="boolean"?!1:t.kind==="null"?null:""}function Rl(e){return e.kind==="json"?[{kind:"string"},{kind:"number"},{kind:"boolean"},{kind:"null"},{kind:"object",properties:{},additionalProperties:{kind:"json"}},{kind:"array",items:{kind:"json"}}]:e.kind==="union"&&!Lt(e)?e.types:[e]}function o0(e,t,r){if(t.address===r.address)return;const n=ve(e,t.address),o=(i,a)=>a===void 0?!1:i.kind==="union"?i.types.some(s=>o(s,a)):i.kind==="array"?Array.isArray(a)&&a.every(s=>o(i.items,s)):i.kind==="object"?!!a&&typeof a=="object"&&!Array.isArray(a)&&Object.entries(i.properties).every(([s,u])=>u.optional&&a[s]===void 0||o(u.type,a[s]))&&Object.entries(a).every(([s,u])=>Object.prototype.hasOwnProperty.call(i.properties,s)||!i.additionalProperties||o(i.additionalProperties,u)):a===""?i.kind==="string"||i.kind==="json"||i.kind==="literal"&&i.value==="":!Rr(i,a,!0);if(o(r.type,n))return structuredClone(n)}function i0(e,t,r,n){var u,c;const o={sourceSchema:r,sourceBindings:t,nodes:[],edges:[],schema:{...r},bindings:{...t},slots:new Map,containers:new Map},i=new Set(n.map(l=>l.data.id)),a=new Map(n.flatMap(l=>{const d=t[l.data.id];return d&&r[d.type]?[[d.address,l.data.id]]:[]})),s=(l,d,f,p,b,g=!1)=>{var k,T,P,j;if(b>24||o.containers.size>512)throw new Error("Structured form exceeds the flow node limit.");const m=ve(e,d),w=Ht(f,m),y=w.kind!=="object"&&w.kind!=="array";o.containers.set(l,{address:d,type:w,declared:f,scalar:y});const x=`__form:${l}`,v={...(k=o.bindings[l])==null?void 0:k.fields},C={kind:"object",properties:{},ports:{...w.kind==="object"?w.ports:{},...g?{resource:{label:"output",...w.kind==="object"?(T=w.ports)==null?void 0:T.resource:{},kind:"output"}}:{}}},_=w.kind==="object"?{...w.properties,...Object.fromEntries(Object.keys(m??{}).filter(R=>!Object.prototype.hasOwnProperty.call(w.properties,R)&&w.additionalProperties).map(R=>[R,{type:w.additionalProperties,optional:!0}]))}:w.kind==="array"?Object.fromEntries((Array.isArray(m)?m:[]).map((R,E)=>[String(E),{type:w.items,optional:!0}])):{value:{type:Lt(f)?f:w,optional:!1}};for(const[R,E]of Object.entries(_)){if(!t0(R))throw new Error(`Unsupported structured property key: ${R}`);const M=y?d:`${d}.${R}`,I=ve(e,M),N=Ht(E.type,I),O=N.kind==="object"||N.kind==="array",W=(P=C.ports)==null?void 0:P[R],z=(W==null?void 0:W.kind)==="config"&&(((j=v[R])==null?void 0:j.$options)||Lt(E.type)),re=E.type.kind==="json"||E.type.kind==="union"&&!Lt(E.type);if(!O&&w.kind!=="array"&&(!re||y)||z){C.properties[R]={...E,type:E.type.kind==="json"?N:E.type};continue}const te=a.get(M)??n0(M),he=w.kind==="array"?`Item ${Number(R)+1}`:R,be={address:M,owner:l,field:R,type:E.type,label:he,nodeId:te,present:I!==void 0};if(o.slots.set(kt(l,R),be),C.ports[R]={kind:"config",resourceType:`__form:${te}`},I===void 0||(o.edges.push({data:{id:`__form-edge:${l}:${R}`,source:te,target:l,sourceProperty:"output:resource",targetProperty:`config:${R}`,isEdgeDashed:!0}}),o.containers.has(te)||a.has(M)))continue;if(i.has(te))throw new Error(`Structured node identity conflict: ${te}`);i.add(te);const K={data:{id:te,type:"objectView",label:he,headerTitle:he,description:{},config:{form:!0,icon:N.kind==="array"?"PiListNumbers":O?"PiBracketsCurly":"PiTextT"},viewProps:{bgColor:p}}};o.nodes.push(K),s(te,M,E.type,p,b+1,!0);const q=o.schema[`__form:${te}`];K.data.description=Object.fromEntries(Object.keys(q.properties).map(L=>[L,ve(e,N.kind==="array"||N.kind==="object"?`${M}.${L}`:M)]).filter(([,L])=>L!==void 0))}o.schema[x]=C,o.bindings[l]={...o.bindings[l],address:d,type:x,fields:v}};for(const l of n){const d=t[l.data.id];if(d!=null&&d.portResources)continue;const f=d&&r[d.type];!d||!f||ve(e,d.address)===void 0||s(l.data.id,d.address,f,(u=l.data.viewProps)==null?void 0:u.bgColor,0,o.edges.some(p=>p.data.source===l.data.id))}for(const l of o.edges){const d=o.bindings[l.data.source],f=o.schema[d.type].ports;f.resource={...f.resource,kind:"output",label:((c=f.resource)==null?void 0:c.label)??"output"}}return o}function a0({nodeAddress:e}){const{structured:t,data:r,callbacks:n,editable:o}=S.useContext(kr),i=Oe(),[a,s]=S.useState(""),[u,c]=S.useState("0"),[l,d]=S.useState(""),f=t==null?void 0:t.containers.get(e);if(!f||!r||!t)return null;const p=i.readOnly||i.config.editable===!1||!o,b=ve(r,f.address),g=Rl(f.declared),m=f.type.kind==="array"?f.type.items:f.type.kind==="object"?f.type.additionalProperties:void 0,w=m?Rl(m):[],y=j=>j.kind==="literal"?String(j.value):j.kind==="string"?"Text":Cr(j.kind),x=[...t.slots.values()].filter(j=>j.owner===e),v=(j,R)=>{var E;return(E=n.onFormChange)==null?void 0:E.call(n,{data:r,nodeAddress:f.address,address:j,previousValue:ve(r,j),value:R})},C=j=>{var R;i.setSelectedNodeIds([j]),(R=i.engineRef.current)==null||R.focusNode(j,90,!1)},_=(j,R)=>{if(!Array.isArray(b))return;const E=[...b];[E[j],E[j+R]]=[E[j+R],E[j]],v(f.address,E)},k=()=>{const j=w[Number(u)]??w[0];if(j)if(f.type.kind==="array")v(f.address,[...Array.isArray(b)?b:[],Pt(j)]);else{if(!a||a.includes(".")||a.startsWith("$")||["__proto__","constructor","prototype"].includes(a)){d("Choose a property name without dots or reserved prefixes.");return}if(Object.prototype.hasOwnProperty.call(b,a)){d("Property already exists.");return}v(`${f.address}.${a}`,Pt(j)),s(""),d("")}},T=f.type.kind==="object"&&!!f.type.additionalProperties,P=f.type.kind==="array";return h.jsxs("div",{"data-structured-controls":"",style:{display:"grid",gap:8,minWidth:0},children:[g.length>1&&h.jsxs("label",{children:["Value type",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsx("select",{"aria-label":"Value type",disabled:p,value:g.findIndex(j=>Ht(j,b).kind===f.type.kind),onChange:j=>v(f.address,Pt(g[Number(j.target.value)])),children:g.map((j,R)=>h.jsx("option",{value:R,children:y(j)},R))}),h.jsx(J.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),x.map((j,R)=>h.jsxs("div",{"data-structured-slot":j.address,style:{display:"flex",gap:6,alignItems:"center",minWidth:0},children:[j.type.kind==="array"?h.jsx(J.PiListNumbers,{size:20}):h.jsx(J.PiBracketsCurly,{size:20}),h.jsx("span",{style:{flex:1,overflowWrap:"anywhere"},children:Cr(j.label)}),h.jsx(me,{"aria-label":`${j.present?"Focus":"Create"} ${Cr(j.label)}`,title:`${j.present?"Focus":"Create"} ${Cr(j.label)}`,icon:j.present?h.jsx(J.PiMagnifyingGlass,{size:18}):h.jsx(J.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:p&&!j.present,onClick:E=>{var M;j.present?((M=E.currentTarget.closest("dialog"))==null||M.close(),C(j.nodeId)):v(j.address,Pt(j.type))}}),P&&h.jsxs(h.Fragment,{children:[h.jsx(me,{"aria-label":`Move item ${R+1} up`,icon:h.jsx(J.PiArrowUp,{size:18}),size:"sm",variant:"ghost",disabled:p||R===0,onClick:()=>_(R,-1)}),h.jsx(me,{"aria-label":`Move item ${R+1} down`,icon:h.jsx(J.PiArrowDown,{size:18}),size:"sm",variant:"ghost",disabled:p||R===x.length-1,onClick:()=>_(R,1)})]}),j.present&&h.jsx(me,{"aria-label":`Remove ${Cr(j.label)}`,icon:h.jsx(J.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:p,onClick:()=>P?v(f.address,b.filter((E,M)=>M!==R)):v(j.address,void 0)})]},j.address)),(P||T)&&h.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"end"},children:[T&&h.jsxs("label",{style:{flex:"1 1 120px",minWidth:0},children:["Property name",h.jsx("input",{"aria-label":"Property name",value:a,disabled:p,onChange:j=>s(j.target.value)})]}),w.length>1&&h.jsxs("label",{style:{flex:"1 1 100px"},children:["New value type",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsx("select",{"aria-label":"New value type",value:u,disabled:p,onChange:j=>c(j.target.value),children:w.map((j,R)=>h.jsx("option",{value:R,children:y(j)},R))}),h.jsx(J.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),h.jsx("span",{style:{display:"flex",alignItems:"center",flexShrink:0,...T||w.length>1?{height:"calc(1.4em + 20px)",fontSize:15,marginBottom:6}:{}},children:h.jsx(me,{"aria-label":P?"Add item":"Add property",icon:h.jsx(J.PiPlus,{size:20}),size:"sm",variant:"ghost",disabled:p,onClick:k})})]}),l&&h.jsx("p",{role:"alert",children:l})]})}const kr=S.createContext({callbacks:{}}),on=bn.default.div`
55
59
  padding: 0;
56
60
  font-size: 16px;
57
61
  line-height: 1.4;
@@ -149,8 +153,8 @@
149
153
  font-size: 14px;
150
154
  margin-top: 8px;
151
155
  }
152
- `;function kl({request:e,property:t,config:r,value:n,disabled:o}){var L,G;const{callbacks:i,structured:a,references:s}=S.useContext(kr),{themeColor:u}=Oe(),{background:c}=Ue(),l=S.useId(),d=t.type.kind==="object"||t.type.kind==="array"||t.type.kind==="json",f=n===void 0?"":d?JSON.stringify(n,null,2):String(n),[p,m]=S.useState(f),[g,b]=S.useState(""),[w,y]=S.useState(0),[x,v]=S.useState(),C=((L=r.$options)==null?void 0:L.$source)==="callback",_=i.resolveFormOptions,{data:k,address:T,nodeAddress:P,nodeId:j}=e,R=S.useRef(k);R.current=k;const E=JSON.stringify([T,j,(G=r.$options)!=null&&G.$dependsOn?r.$options.$dependsOn.map(B=>ve(k,B)):ve(k,P)]);S.useEffect(()=>{m(f),b("")},[f,T,j]),S.useEffect(()=>{if(!C)return;const B=new AbortController;return Promise.resolve().then(()=>{if(!_)throw new Error("No options resolver configured");return _({address:T,nodeAddress:P,nodeId:j,data:Gt(R.current),signal:B.signal})}).then(Y=>{if(!Array.isArray(Y)||Y.some(ce=>!ce||typeof ce.label!="string"||!["string","number","boolean"].includes(typeof ce.value)&&ce.value!==null))throw new Error("Invalid options response");B.signal.aborted||v({key:E,options:Y})}).catch(Y=>{B.signal.aborted||v({key:E,options:[],error:Y instanceof Error?Y.message:"Options unavailable"})}),()=>B.abort()},[C,_,E,T,P,j,w]);const M=C&&(x==null?void 0:x.key)!==E,I=C?(x==null?void 0:x.key)===E?x.options:[]:t.type.kind==="null"?[{label:"Null",value:null}]:t.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:Lt(t.type),N=t.type.kind==="array",O=(a&&d||r.$control==="checkbox"?"pills":r.$control)??(I?N||t.type.kind==="boolean"?"pills":"select":t.type.kind==="boolean"?"checkbox":d?"textarea":"input"),W=!t.optional||!!r.$requiredWhen&&wn(r.$requiredWhen,k),z=!!(s!=null&&s.length)&&typeof n=="string"&&n.includes("{{"),re=g||C&&(x==null?void 0:x.key)===E&&x.error||!z&&Rr(t.type,n,W),te=Cr(r.$label??T.split(".").pop()),he=B=>{var Y;if(!(o||Object.is(B,n)))try{(Y=i.onFormChange)==null||Y.call(i,{...e,previousValue:n,value:B}),b("")}catch(ce){b(ce instanceof Error?ce.message:"Unable to update field")}},me=()=>{if(d){try{const X=p===""&&t.optional?void 0:JSON.parse(p),U=Rr(t.type,X,W);if(U){b(U);return}he(X)}catch{b("Enter valid JSON")}return}const B=t.type.kind==="number"||t.type.kind==="integer",Y=p===""&&t.optional?void 0:B&&p!==""?Number(p):p,ce=Rr(t.type,Y,W);if(B&&ce&&p!==""){b(ce);return}he(Y)},K={id:l,disabled:o,"aria-label":te,"aria-required":W,"aria-invalid":!!re,"aria-describedby":re?`${l}-error`:void 0},q=fe(u);return h.jsxs("div",{"data-form-field":T,"data-flow-property":T.slice(P.length+1),children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[h.jsxs("label",{htmlFor:l,children:[te,W?" *":""]}),t.optional&&n!==void 0&&h.jsx("button",{type:"button","aria-label":`Reset ${te}`,title:`Reset ${te}`,disabled:o,style:{width:24,height:24,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:0,background:"transparent",color:"inherit"},onClick:()=>he(void 0),children:h.jsx(J.PiArrowCounterClockwise,{size:14})})]}),!!(s!=null&&s.length)&&!d&&h.jsx(e0,{label:te,value:n,references:s,disabled:o,onChange:he}),z?null:O==="select"?h.jsxs("div",{"data-form-select":"",children:[h.jsxs("select",{...K,disabled:o||M||!!(x!=null&&x.error),value:(I==null?void 0:I.findIndex(B=>Object.is(B.value,n)))??-1,onChange:B=>{const Y=I==null?void 0:I[Number(B.target.value)];Y&&he(Y.value)},children:[h.jsx("option",{value:-1,disabled:!0,children:n!==void 0?String(n):""}),I==null?void 0:I.map((B,Y)=>h.jsx("option",{value:Y,style:{background:fe(c)},children:Cr(B.label)||B.label},Y))]}),h.jsx(J.PiCaretDown,{size:16,"aria-hidden":"true"})]}):O==="pills"?h.jsxs("div",{id:l,role:"group","aria-label":te,"aria-describedby":K["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[I==null?void 0:I.map((B,Y)=>{const ce=N?Array.isArray(n)&&n.includes(B.value):Object.is(n,B.value);return h.jsx("button",{type:"button",disabled:o||M,"aria-pressed":ce,style:{padding:"8px 16px",borderRadius:24,border:0,color:ce?q:"inherit",background:ce?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>he(N?ce?n.filter(X=>X!==B.value):[...Array.isArray(n)?n:[],B.value]:B.value),children:Cr(B.label)||B.label},Y)}),M&&h.jsx("span",{role:"status",children:"Loading..."})]}):O==="textarea"?h.jsx("textarea",{...K,value:p,onChange:B=>m(B.target.value),onBlur:me}):h.jsx("input",{...K,type:t.type.kind==="number"||t.type.kind==="integer"?"number":"text",step:t.type.kind==="integer"?1:"any",value:p,onChange:B=>m(B.target.value),onBlur:me,onKeyDown:B=>{B.key==="Enter"&&me(),B.key==="Escape"&&m(n===void 0?"":String(n))}}),re&&h.jsx("div",{role:"alert",id:`${l}-error`,children:re}),C&&(x==null?void 0:x.error)&&h.jsx("button",{type:"button",disabled:o,onClick:()=>{v(void 0),y(w+1)},children:"Retry"})]})}function om({nodeAddress:e}){var v,C;const{data:t,schema:r,callbacks:n,bindings:o,editable:i,renderForm:a,structured:s}=S.useContext(kr),{readOnly:u,config:c}=Oe(),l=a==null?void 0:a(e);if(l!==void 0)return h.jsx("fieldset",{"data-flow-form":e,disabled:u||c.editable===!1||!i,style:{border:0,margin:0,padding:0,minWidth:0},children:l});if(!t)return h.jsx(on,{role:"alert",children:"Forms require a JSON document."});const d=o?Xt(o,e,r):void 0,f=o?d:r&&yt(t,e,r);if(!f)return h.jsx(on,{role:"status",children:"Form schema unavailable."});const p=(d==null?void 0:d.address)??e,m=ve(t,p),g=(v=s==null?void 0:s.containers.get(e))==null?void 0:v.scalar;if(m===void 0||typeof m!="object"&&!g)return h.jsx(on,{role:"alert",children:"Bound form state is unavailable."});const b=Object.entries(f.type.properties).filter(([_])=>{var k;return wn((k=f.fields[_])==null?void 0:k.$visibleWhen,t)}),w=b.length>8||b.some(([_])=>{var k;return(k=f.fields[_])==null?void 0:k.$section}),y=new Map;for(const _ of b){const[k,T]=_,P=w?Cr(((C=f.fields[k])==null?void 0:C.$section)??(T.type.kind==="object"||T.type.kind==="array"?k:T.optional?"Options":"General")):"";y.has(P)||y.set(P,[]),y.get(P).push(_)}const x=([_,k])=>h.jsx(kl,{request:{data:t,address:g?p:`${p}.${_}`,nodeAddress:p,nodeId:typeof(m==null?void 0:m.id)=="string"?m.id:void 0},property:k,config:f.fields[_]??{},value:g?m:m==null?void 0:m[_],disabled:u||c.editable===!1||!(i??!!n.onJsonChange)},`${(m==null?void 0:m.id)??e}:${_}`);return h.jsxs(on,{"data-flow-form":e,onClick:_=>_.stopPropagation(),onDoubleClick:_=>_.stopPropagation(),children:[s&&h.jsx(i0,{nodeAddress:e}),d&&f.type.additionalProperties&&b.length===0&&h.jsx(kl,{request:{data:t,address:p,nodeAddress:p},property:{type:f.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:m,disabled:u||c.editable===!1||!i}),[...y].map(([_,k])=>w&&k.length>1?h.jsxs("details",{open:!0,children:[h.jsxs("summary",{children:[h.jsx("span",{children:_}),h.jsx(J.PiCaretDown,{size:16,"aria-hidden":"true"})]}),k.map(x)]},_):k.map(x))]})}function im(e){const{viewData:t}=S.useContext(kr),{nodeById:r,edgeById:n,parentIds:o}=Ur();if(t){const i=ve(t,e),a=i&&typeof i=="object"&&!Array.isArray(i)&&"$"in i?i.$:i;return Array.isArray(a)?a.length>0:!!a&&typeof a=="object"&&Object.entries(a).some(([s,u])=>!s.startsWith("$")&&u!==null&&typeof u=="object")}return o.has(e)?!0:[...n.values()].some(({data:i})=>{const a=i.isInverted?i.target:i.source,s=i.isInverted?i.source:i.target;return a===e&&s!==e&&r.has(s)})}function Kt(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:t}function fn(e,t,r,n){return{borderColor:t,borderWidth:Kt(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...gy(t==="transparent"?"currentColor":t,r,".flow-sdk-node:hover &",!r)}}function am({label:e,value:t,options:r,onChange:n,disabled:o}){var i;return h.jsxs(Ir,{"aria-label":e,title:`Animation: ${((i=r.find(a=>a.value===t))==null?void 0:i.label)??"Mixed"}`,value:t,style:{width:104},disabled:o,onValueChange:a=>{const s=r.find(u=>u.value===a);s&&n(s.value)},children:[t===""&&h.jsx("option",{value:"",disabled:!0,children:"Mixed"}),r.map(a=>h.jsx("option",{value:a.value,children:a.label},a.value))]})}const hn="data:image/svg+xml;base64,";function At(e){if(e.startsWith(hn))return!0;try{const t=new URL(e);return(t.protocol==="https:"||t.protocol==="http:")&&!t.username&&!t.password}catch{return!1}}async function a0(e){if(e.size>256*1024)throw new Error("SVG must be 256 KB or smaller.");const t=await e.text(),r=new DOMParser().parseFromString(t,"image/svg+xml");if(r.doctype||r.querySelector("parsererror")||r.documentElement.localName!=="svg"||r.documentElement.namespaceURI!=="http://www.w3.org/2000/svg")throw new Error("Choose a valid SVG file.");if(r.querySelector("script, foreignObject")||[...r.querySelectorAll("*")].some(i=>[...i.attributes].some(a=>/^on/i.test(a.name))))throw new Error("SVG scripts and event handlers are not allowed.");const n=new TextEncoder().encode(t);let o="";for(const i of n)o+=String.fromCharCode(i);return hn+btoa(o)}const qr=({name:e,svg:t=!1,...r})=>{const[n,o]=S.useState(null),[i,a]=S.useState(!0),[s,u]=S.useState(!1),c=typeof e=="string"&&At(e);if(S.useEffect(()=>{if(c||!e||e.length<2){o(null),a(!1);return}a(!0),u(!1),(async()=>{try{let d;if(e.startsWith("Md"))d="md";else if(e.startsWith("Fa"))d="fa6";else if(e.startsWith("Io5"))d="io5";else if(e.startsWith("Io"))d="io";else if(e.startsWith("Ti"))d="ti";else if(e.startsWith("Go"))d="go";else if(e.startsWith("Fi"))d="fi";else if(e.startsWith("Di"))d="di";else if(e.startsWith("Ai"))d="ai";else if(e.startsWith("Bs"))d="bs";else if(e.startsWith("Ri"))d="ri";else if(e.startsWith("Fc"))d="fc";else if(e.startsWith("Gi"))d="gi";else if(e.startsWith("Hi2"))d="hi2";else if(e.startsWith("Hi"))d="hi";else if(e.startsWith("Si"))d="si";else if(e.startsWith("Sl"))d="sl";else if(e.startsWith("Im"))d="im";else if(e.startsWith("Bi"))d="bi";else if(e.startsWith("Pi"))d="pi";else if(e.startsWith("Vsc"))d="vsc";else if(e.startsWith("Tb"))d="tb";else if(e.startsWith("Tfi"))d="tfi";else if(e.startsWith("Cg"))d="cg";else if(e.startsWith("Lia"))d="lia";else if(e.startsWith("Lu"))d="lu";else throw new Error(`Unknown library prefix for icon: ${e}`);let f;switch(d){case"md":f=await import("react-icons/md");break;case"fa6":f=await import("react-icons/fa6");break;case"io5":f=await import("react-icons/io5");break;case"io":f=await import("react-icons/io");break;case"ti":f=await import("react-icons/ti");break;case"go":f=await import("react-icons/go");break;case"fi":f=await import("react-icons/fi");break;case"di":f=await import("react-icons/di");break;case"ai":f=await import("react-icons/ai");break;case"bs":f=await import("react-icons/bs");break;case"ri":f=await import("react-icons/ri");break;case"fc":f=await import("react-icons/fc");break;case"gi":f=await import("react-icons/gi");break;case"hi2":f=await import("react-icons/hi2");break;case"hi":f=await import("react-icons/hi");break;case"si":f=await import("react-icons/si");break;case"sl":f=await import("react-icons/sl");break;case"im":f=await import("react-icons/im");break;case"bi":f=await import("react-icons/bi");break;case"pi":f=await import("react-icons/pi");break;case"vsc":f=await import("react-icons/vsc");break;case"tb":f=await import("react-icons/tb");break;case"tfi":f=await import("react-icons/tfi");break;case"cg":f=await import("react-icons/cg");break;case"lia":f=await import("react-icons/lia");break;case"lu":f=await import("react-icons/lu");break;default:throw new Error(`Unsupported library: ${d}`)}const p=f[e];if(!p)throw new Error(`Icon ${e} not found in library ${d}`);o(()=>p)}catch(d){console.warn(`Failed to load icon ${e}:`,d.message),u(!0),o(null)}finally{a(!1)}})()},[e,c]),c){const{size:l=80,style:d,...f}=r;return t?h.jsx("image",{...f,href:e,width:l,height:l,preserveAspectRatio:"xMidYMid meet",style:d}):h.jsx("img",{...f,src:e,alt:"",width:l,height:l,referrerPolicy:"no-referrer",style:{objectFit:"contain",...d}})}return i||!n?null:h.jsx(n,{...r})};function Nu({nodeId:e,edgeId:t,value:r}){const{callbacks:n,readOnly:o,themeColor:i}=Oe(),{background:a,backgroundSecondary:s,border:u,colorText:c}=Ue(),l=S.useRef(null),d=S.useId(),f=S.useRef(null),p=S.useRef(0),[m,g]=S.useState(!1),[b,w]=S.useState("icons"),[y,x]=S.useState([]),[v,C]=S.useState("loading"),[_,k]=S.useState(""),[T,P]=S.useState(0),[j,R]=S.useState(""),[E,M]=S.useState(""),[I,N]=S.useState(!1);S.useEffect(()=>()=>{p.current++},[]),S.useEffect(()=>{if(!m)return;let K=!0;return import("react-icons/pi").then(q=>{K&&(x(Object.keys(q).filter(L=>L.startsWith("Pi")).sort()),C("ready"))}).catch(()=>{K&&C("unavailable")}),()=>{K=!1}},[m]),S.useEffect(()=>{var K;o&&((K=l.current)==null||K.close())},[o]);const O=K=>{var q,L,G;o||(t?(q=n.onEdgeIconChange)==null||q.call(n,t,K):e&&((L=n.onNodeIconChange)==null||L.call(n,e,K)),(G=l.current)==null||G.close())},W=y.filter(K=>K.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(_.trim().toLowerCase())),z=36,re=Math.max(1,Math.ceil(W.length/z)),te=Math.min(T,re-1),he=W.slice(te*z,(te+1)*z),me={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${fe(u)}`,borderRadius:30};return h.jsxs(h.Fragment,{children:[h.jsx(je,{label:t?"Choose edge icon":"Choose node icon",children:h.jsx(be,{"aria-label":t?"Choose edge icon":"Choose node icon",icon:h.jsx(J.PiShapes,{size:20}),size:"sm",variant:"ghost",color:fe(i),disabled:o,onClick:()=>{var K;M(""),w(r&&At(r)?"custom":"icons"),R(r&&!r.startsWith(hn)&&At(r)?r:""),g(!0),(K=l.current)==null||K.showModal()}})}),h.jsx(D.chakra.dialog,{ref:l,"aria-label":t?"Choose edge icon":"Choose node icon",css:zr(fe(a),fe(u)),onClose:()=>{g(!1),p.current++,N(!1)},onClick:K=>{K.stopPropagation(),K.target===K.currentTarget&&K.currentTarget.close()},onKeyDown:K=>K.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",borderRadius:30,background:fe(a),color:fe(c)},children:m&&h.jsxs("div",{style:{display:"grid",gap:8},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[h.jsx("strong",{children:t?"Edge icon":"Node icon"}),h.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[r&&h.jsx(je,{label:"Remove icon",children:h.jsx(be,{"aria-label":t?"Remove edge icon":"Remove node icon",icon:h.jsx(J.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:o||I,onClick:()=>O("")})}),h.jsx(gt,{"aria-label":"Close icon picker",onClick:()=>{var K;return(K=l.current)==null?void 0:K.close()}})]})]}),h.jsx("div",{role:"tablist","aria-label":"Icon source",style:{display:"flex",borderBottom:`1px solid ${fe(u)}`},children:["icons","custom"].map(K=>h.jsx("button",{id:`${d}-${K}`,type:"button",role:"tab","aria-selected":b===K,"aria-controls":`${d}-panel`,tabIndex:b===K?0:-1,onClick:()=>{w(K),M("")},onKeyDown:q=>{var G;if(!["ArrowLeft","ArrowRight","Home","End"].includes(q.key))return;q.preventDefault();const L=q.key==="Home"?"icons":q.key==="End"||K==="icons"?"custom":"icons";w(L),M(""),(G=document.getElementById(`${d}-${L}`))==null||G.focus()},style:{flex:1,padding:"8px 12px",background:"transparent",border:0,borderBottom:`2px solid ${b===K?fe(i):"transparent"}`,color:b===K?fe(i):"inherit",cursor:"pointer",fontSize:13},children:K==="icons"?"React icons":"Custom SVG"},K))}),h.jsx("input",{ref:f,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:I||o,onChange:async K=>{var G;const q=(G=K.target.files)==null?void 0:G[0];if(K.target.value="",!q)return;const L=++p.current;N(!0),M("");try{const B=await a0(q);L===p.current&&O(B)}catch(B){L===p.current&&M(B instanceof Error?B.message:"Unable to read SVG.")}finally{L===p.current&&N(!1)}}}),h.jsx("div",{id:`${d}-panel`,role:"tabpanel","aria-labelledby":`${d}-${b}`,style:{display:"grid",gap:8},children:b==="icons"?h.jsxs(h.Fragment,{children:[h.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:_,onChange:K=>{k(K.target.value),P(0)},style:me}),h.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[he.map(K=>h.jsx("button",{type:"button","aria-label":`Choose ${K}`,"aria-pressed":r===K,title:K,onClick:()=>O(K),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${r===K?2:1}px solid ${fe(r===K?i:u)}`,background:fe(r===K?a:s),color:"inherit",cursor:"pointer"},children:h.jsx(qr,{name:K,size:24})},K)),he.length===0&&h.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:v==="loading"?"Loading icons...":v==="unavailable"?"React icons unavailable":"No icons found"})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[h.jsxs("span",{role:"status",style:{fontSize:12},children:[W.length," icons · ",te+1," / ",re]}),h.jsxs("div",{style:{display:"flex",gap:4},children:[h.jsx(je,{label:"Previous icons",children:h.jsx(be,{"aria-label":"Previous icons",icon:h.jsx(J.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:te===0,onClick:()=>P(te-1)})}),h.jsx(je,{label:"Next icons",children:h.jsx(be,{"aria-label":"Next icons",icon:h.jsx(J.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:te+1>=re,onClick:()=>P(te+1)})})]})]})]}):h.jsxs(h.Fragment,{children:[r&&At(r)&&h.jsx(qr,{name:r,size:64}),h.jsxs("button",{type:"button",disabled:I||o,onClick:()=>{var K;return(K=f.current)==null?void 0:K.click()},style:{...me,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[h.jsx(J.PiUploadSimple,{}),I?"Uploading...":"Upload SVG"]}),h.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:K=>{K.preventDefault(),!(I||o)&&(!At(j.trim())||j.trim().startsWith(hn)?M("Enter an HTTP or HTTPS image URL."):O(j.trim()))},children:[h.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:j,disabled:I||o,onChange:K=>R(K.target.value),style:{...me,flex:1,minWidth:0}}),h.jsx(je,{label:"Apply URL",children:h.jsx(be,{type:"submit","aria-label":"Apply URL",icon:h.jsx(J.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:I||o||!j.trim(),style:{flexShrink:0}})})]})]})}),E&&h.jsx("div",{role:"alert",style:{fontSize:13},children:E})]})})]})}const $u=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500"],sm=["gray.900","gray.600","gray.200","white"];function cm(){const{config:e}=Oe(),t=e.selectionToolbar||{},r=new Set(t.hide||[]);return{palette:t.palette||$u,show:n=>!r.has(n)}}function dr(){const{border:e}=Ue();return h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:e})}function et({value:e,placeholder:t,ariaLabel:r,width:n="140px",type:o="text",min:i,onCommit:a}){const{colorText:s}=Ue(),[u,c]=S.useState(e),l=S.useRef(!1);S.useEffect(()=>c(e),[e]);const d=()=>{if(l.current)return;l.current=!0;const f=u.trim();if(o==="number"&&f!==""&&(!Number.isFinite(Number(f))||Number(f)<(i??0))){c(e);return}f!==e&&a(f)};return h.jsx(D.Input,{"aria-label":r,type:o,min:i,size:"xs",w:n,value:u,placeholder:t,color:s,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{l.current=!1},onChange:f=>c(f.target.value),onBlur:d,onKeyDown:f=>{f.key==="Enter"&&(d(),f.target.blur()),f.key==="Escape"&&(l.current=!0,c(e),f.target.blur())}})}function Jt({colors:e,value:t,label:r,onPick:n,onReset:o,includeTransparent:i=!0}){const{colorInactive:a,colorText:s}=Ue(),[u,c]=S.useState(!1),l=S.useId(),d=S.useRef(null),f=t??e[0]??"transparent";return h.jsxs(D.HStack,{gap:1,"aria-label":r,role:"group",onKeyDown:p=>{var m;p.key==="Escape"&&(c(!1),(m=d.current)==null||m.focus())},children:[h.jsx(je,{label:`${r}: ${f}`,children:h.jsx(D.chakra.button,{ref:d,type:"button","aria-label":`${r} colors`,"aria-expanded":u,"aria-controls":l,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:fe(f),...f==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${fe(s)}`,outlineOffset:"1px",onClick:()=>c(p=>!p)})}),u&&h.jsxs(D.HStack,{id:l,gap:1,children:[[...new Set([...e,...i?["transparent"]:[]])].map(p=>{const m=t===p;return h.jsx(je,{label:`${r}: ${p}`,children:h.jsx(D.Box,{as:"button","aria-label":`${r} ${p}`,"aria-pressed":m,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:fe(p),...p==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:m?`2px solid ${fe(s)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(p),onDoubleClick:g=>{var b;g.stopPropagation(),c(!1),(b=d.current)==null||b.focus()}})},p)}),o&&h.jsx(je,{label:`Reset ${r.toLowerCase()}`,children:h.jsx(be,{"aria-label":`Reset ${r}`,icon:h.jsx(D.Icon,{as:J.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:a,onClick:()=>{var p;o(),c(!1),(p=d.current)==null||p.focus()}})})]})]})}function um({edgeId:e,onClose:t}){var p;const{callbacks:r,themeColor:n,config:o}=Oe(),{colorInactive:i}=Ue(),{edgeById:a}=Ur(),{palette:s,show:u}=cm(),c=(p=a.get(e))==null?void 0:p.data,l=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(o.customEdgeTypes??{}),...c!=null&&c.type?[c.type]:[]])],d=c!=null&&c.isEdgeAnimated?"animated":c!=null&&c.isEdgeDashed?"dashed":"solid",f=[{key:"solid",icon:J.PiLineSegment,label:"Solid"},{key:"dashed",icon:J.PiLineSegments,label:"Dashed"},{key:"animated",icon:J.PiFastForward,label:"Animated"}];return h.jsxs(h.Fragment,{children:[h.jsx(gt,{onClick:t}),u("label")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(et,{ariaLabel:"Edge label",placeholder:"Edge label",value:(c==null?void 0:c.label)||"",onCommit:m=>{var g;return(g=r.onEdgeLabelChange)==null?void 0:g.call(r,e,m)}})]}),u("style")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),f.map(m=>h.jsx(je,{label:m.label,children:h.jsx(be,{"aria-label":`Edge style ${m.key}`,"aria-pressed":d===m.key,icon:h.jsx(D.Icon,{as:m.icon,boxSize:5}),size:"sm",variant:"ghost",color:d===m.key?n:i,onClick:()=>{var g;return(g=r.onEdgeStyleChange)==null?void 0:g.call(r,e,m.key)}})},m.key)),d==="animated"&&h.jsx(am,{label:"Edge animation",value:(c==null?void 0:c.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:o.readOnly,onChange:m=>{var g;return(g=r.onEdgeAnimationVariantChange)==null?void 0:g.call(r,e,m)}}),h.jsxs(Ir,{"aria-label":"Edge shape",title:`Edge shape: ${(c==null?void 0:c.type)??"Default"}`,icon:h.jsx(J.PiBezierCurve,{size:20}),style:{width:36},value:(c==null?void 0:c.type)??"",disabled:o.readOnly,onValueChange:m=>{var g;return(g=r.onEdgeTypeChange)==null?void 0:g.call(r,e,m||void 0)},children:[h.jsx("option",{value:"",children:"Default"}),l.map(m=>h.jsx("option",{value:m,children:m},m))]})]}),u("icon")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Nu,{edgeId:e,value:c==null?void 0:c.icon},e),h.jsx(et,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(c==null?void 0:c.icon)??"",onCommit:m=>{var g;return(g=r.onEdgeIconChange)==null?void 0:g.call(r,e,m)}})]}),u("color")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Jt,{label:"Edge color",colors:s,value:c==null?void 0:c.color,onPick:m=>{var g;return(g=r.onEdgeColorChange)==null?void 0:g.call(r,e,m)},onReset:()=>{var m;return(m=r.onEdgeColorChange)==null?void 0:m.call(r,e,"")}})]}),u("delete")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(je,{label:"Delete edge",children:h.jsx(be,{"aria-label":"Delete edge",icon:h.jsx(D.Icon,{as:J.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var m;(m=r.onEdgeDelete)==null||m.call(r,e,c),t()}})})]})]})}function lm({ids:e,showDivider:t=!0}){const{callbacks:r,config:n}=Oe(),{colorInactive:o}=Ue(),{nodeById:i}=Ur(),[a,s]=S.useState(!1),u=e.map(m=>{var g,b;return(b=(g=i.get(m))==null?void 0:g.data.viewProps)==null?void 0:b.borderRadius}),c=!u.every(m=>m===u[0]),l=c?"mixed":String(u[0]??""),d=["0","8","16","30","53","100"],f=a||!c&&l!==""&&!d.includes(l),p=m=>e.forEach(g=>{var b;return(b=r.onNodeBorderRadiusChange)==null?void 0:b.call(r,g,m)});return h.jsxs(h.Fragment,{children:[t&&h.jsx(dr,{}),h.jsx(D.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:h.jsxs(Ir,{icon:h.jsx(D.Icon,{as:tv.TbBorderRadius,boxSize:5,color:o,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${c?"Mixed":u[0]===void 0?"Default":`${u[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:f?"custom":l,disabled:n.readOnly,onValueChange:m=>{s(m==="custom"),m!=="custom"&&p(m===""?void 0:Number(m))},children:[h.jsx("option",{value:"",children:"Default radius"}),c&&h.jsx("option",{value:"mixed",disabled:!0,children:"Mixed radii"}),d.map(m=>h.jsxs("option",{value:m,children:[m,"px radius"]},m)),h.jsx("option",{value:"custom",children:"Custom radius"})]})}),f&&h.jsx(et,{ariaLabel:"Custom border radius",placeholder:c?"Mixed":"Auto",type:"number",min:0,width:"72px",value:c?"":l,onCommit:m=>p(m===""?void 0:Number(m))})]})}function dm({ids:e,onClose:t}){var K,q,L,G,B,Y,ce,X;const{callbacks:r,colorMode:n,themeColor:o,config:i,setNodeViewMode:a}=Oe(),{colorText:s,colorInactive:u}=Ue(),{nodeById:c,parentIds:l}=Ur(),{palette:d,show:f}=cm(),p=e.length===1,m=p?(K=c.get(e[0]))==null?void 0:K.data:void 0,g=e.map(U=>{var Z,ae;return((ae=(Z=c.get(U))==null?void 0:Z.data.config)==null?void 0:ae.typeView)??""}),b=g.some(U=>U!==g[0]),w=b?"mixed":g[0]??"",y=e.some(U=>{var ae,ue;const Z=(ae=c.get(U))==null?void 0:ae.data;return Z&&(l.has(U)||((ue=Z.config)==null?void 0:ue.parentContainer)||Object.prototype.hasOwnProperty.call(i.customViews??{},Z.type))}),x=(q=m==null?void 0:m.config)==null?void 0:q.collapsed,v=im(e[0]),C=U=>{var Z,ae,ue;return(((ae=(Z=c.get(U))==null?void 0:Z.data.viewProps)==null?void 0:ae.outline)??(l.has(U)?(ue=i.parentNodeStyle)==null?void 0:ue.outline:!1))===!0},_=e.every(C),k=!_&&e.some(C),T=U=>{var Z;return((Z=c.get(U))==null?void 0:Z.data.isNodeAnimated)===!0},P=e.every(T),j=!P&&e.some(T),R=e.map(U=>{var Z;return((Z=c.get(U))==null?void 0:Z.data.nodeAnimationVariant)??"traveling"}),E=R.every(U=>U===R[0])?R[0]:"",M=U=>e.forEach(U),[I,N]=S.useState(!1),O=I&&f("color")&&f("borderColor"),W=U=>{var Z,ae,ue;return(((ae=(Z=c.get(U))==null?void 0:Z.data.viewProps)==null?void 0:ae.borderStyle)??(l.has(U)?(ue=i.parentNodeStyle)==null?void 0:ue.borderStyle:"solid"))==="dashed"},z=e.every(W),re=!z&&e.some(W),te=e.map(U=>{var ue,de,Ee;const Z=(ue=c.get(U))==null?void 0:ue.data,ae=l.has(U)?Kt((de=i.parentNodeStyle)==null?void 0:de.borderWidth,6):(Z==null?void 0:Z.type)==="objectView"?3:2;return Kt((Ee=Z==null?void 0:Z.viewProps)==null?void 0:Ee.borderWidth,ae)}),he=te.every(U=>U===te[0])?String(te[0]??""):"",me=U=>M(Z=>{var ae,ue;O?(ae=r.onNodeBorderColorChange)==null||ae.call(r,Z,U):(ue=r.onNodeColorChange)==null||ue.call(r,Z,"bg",U)});return h.jsxs(h.Fragment,{children:[h.jsx(gt,{onClick:t}),h.jsx(dr,{}),p&&f("label")?h.jsx(et,{ariaLabel:"Node label",placeholder:"Node label",value:(m==null?void 0:m.label)??(m==null?void 0:m.headerTitle)??"",onCommit:U=>{var Z;return(Z=r.onNodeLabelChange)==null?void 0:Z.call(r,e[0],U)}}):h.jsxs(D.Text,{fontSize:"xs",color:s,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),f("typeView")&&h.jsxs(Ir,{"aria-label":"Type view",title:y?"Type view is managed by the custom renderer or container":`Type view: ${w||"None (default)"}`,icon:h.jsx(J.PiImage,{size:20}),style:{width:36},value:w,disabled:i.readOnly||i.editable===!1||y,onValueChange:U=>{Dt.includes(U)&&M(Z=>{var ae,ue;(ae=r.onNodeTypeViewChange)==null||ae.call(r,Z,U||void 0),a(Z,"default"),(ue=r.onNodeViewToggle)==null||ue.call(r,Z)})},children:[b&&h.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),Dt.map(U=>h.jsx("option",{value:U,children:U||"None"},U))]}),f("style")&&h.jsx(lm,{ids:e},e.join("\0")),f("outline")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(je,{label:_?"Restore node fill":"Remove node fill",children:h.jsx(be,{"aria-label":"Toggle node outline","aria-pressed":k?"mixed":_,icon:h.jsx(D.Icon,{as:_?J.PiSquare:J.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:_?o:u,onClick:()=>M(U=>{var Z;return(Z=r.onNodeOutlineChange)==null?void 0:Z.call(r,U,!_)})})})]}),f("color")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),f("borderColor")&&h.jsx(je,{label:O?"Edit node colors":"Edit node border",children:h.jsx(be,{"aria-label":"Edit node border","aria-pressed":O,icon:h.jsx(D.Icon,{as:J.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:O?o:u,bg:O?n==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>N(U=>!U)})}),h.jsx(Jt,{label:O?"Border color":"Background",colors:d,value:O?((L=m==null?void 0:m.viewProps)==null?void 0:L.borderColor)??(p&&l.has(e[0])?(G=i.parentNodeStyle)==null?void 0:G.borderColor:void 0):(B=m==null?void 0:m.viewProps)==null?void 0:B.bgColor,onPick:me,onReset:()=>me("")}),O&&f("style")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(je,{label:z?"Solid border":"Dashed border",children:h.jsx(be,{"aria-label":"Toggle dashed border","aria-pressed":re?"mixed":z,icon:h.jsx(D.Icon,{as:z?J.PiLineSegments:J.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:z?o:u,onClick:()=>M(U=>{var Z;return(Z=r.onNodeBorderStyleChange)==null?void 0:Z.call(r,U,z?"solid":"dashed")})})}),h.jsx(et,{ariaLabel:"Border thickness",placeholder:p?"Auto":"Mixed",width:"64px",type:"number",min:0,value:he,onCommit:U=>M(Z=>{var ae;return(ae=r.onNodeBorderWidthChange)==null?void 0:ae.call(r,Z,U===""?void 0:Number(U))})})]})]}),f("animation")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(je,{label:P?"Stop border animation":"Animate node border",children:h.jsx(be,{"aria-label":"Toggle node animation","aria-pressed":j?"mixed":P,icon:h.jsx(D.Icon,{as:J.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:P?o:u,onClick:()=>M(U=>{var Z;return(Z=r.onNodeAnimationChange)==null?void 0:Z.call(r,U,!P)})})}),(P||j)&&h.jsx(am,{label:"Node animation",value:E,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:i.readOnly,onChange:U=>M(Z=>{var ae;return(ae=r.onNodeAnimationVariantChange)==null?void 0:ae.call(r,Z,U)})})]}),!O&&f("textColor")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Jt,{label:"Text color",colors:sm,value:(Y=m==null?void 0:m.viewProps)==null?void 0:Y.textColor,onPick:U=>M(Z=>{var ae;return(ae=r.onNodeColorChange)==null?void 0:ae.call(r,Z,"text",U)}),onReset:()=>M(U=>{var Z;return(Z=r.onNodeColorChange)==null?void 0:Z.call(r,U,"text","")})})]}),p&&f("icon")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Nu,{nodeId:e[0],value:(ce=m==null?void 0:m.config)==null?void 0:ce.icon},e[0]),h.jsx(et,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((X=m==null?void 0:m.config)==null?void 0:X.icon)||"",onCommit:U=>{var Z;return(Z=r.onNodeIconChange)==null?void 0:Z.call(r,e[0],U)}})]}),p&&v&&f("collapse")&&x!==void 0&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(je,{label:x?"Expand":"Collapse",children:h.jsx(be,{"aria-label":x?"Expand node":"Collapse node",icon:h.jsx(D.Icon,{as:x?J.PiArrowsOutLineVertical:J.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:u,onClick:()=>{var U;return(U=r.onNodeCollapse)==null?void 0:U.call(r,e[0],!x)}})})]}),f("delete")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(je,{label:p?"Delete node":`Delete ${e.length} nodes`,children:h.jsx(be,{"aria-label":"Delete selected nodes",icon:h.jsx(D.Icon,{as:J.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:n==="dark"?"red.300":"red.500",onClick:()=>{M(U=>{var Z,ae;return(ae=r.onNodeDelete)==null?void 0:ae.call(r,U,((Z=c.get(U))==null?void 0:Z.data)||{id:U})}),t()}})})]})]})}async function fm(e){const{toSvg:t}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const r=await t(e,{filter:o=>!(o instanceof Element)||!o.matches("button, [role=tooltip], .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-edge-hit, .flow-sdk-ghost, .flow-sdk-node-animation")}),n=new DOMParser().parseFromString(decodeURIComponent(r.slice(r.indexOf(",")+1)),"image/svg+xml");return n.querySelectorAll(".flow-sdk-edge-hit, .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-ghost").forEach(o=>o.remove()),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}async function hm(e,t="squeed.svg"){const r=document.createElement("a");r.href=await fm(e),r.download=t.endsWith(".svg")?t:`${t}.svg`,r.click()}function pm(){const{themeColor:e}=Oe(),[t,r]=S.useState(!1),[n,o]=S.useState("");return h.jsxs(h.Fragment,{children:[h.jsx(je,{label:"Download SVG (current view)",children:h.jsx(be,{"aria-label":"Download SVG",icon:h.jsx(J.PiDownloadSimpleFill,{size:20}),disabled:t,borderRadius:"30%",color:e,variant:"ghost",onClick:async i=>{var s;const a=(s=i.currentTarget.closest("[data-flow-diagram]"))==null?void 0:s.querySelector("[data-flow-background]");if(!a){o("Diagram not available for export.");return}r(!0),o("");try{await hm(a)}catch(u){o(u instanceof Error?u.message:"Unable to export SVG.")}finally{r(!1)}}})}),n&&h.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function gm({children:e,background:t,border:r}){const n=S.useRef(null),[o,i]=S.useState({left:!1,right:!1});S.useLayoutEffect(()=>{const s=n.current,u=()=>{const l=s.scrollLeft>1,d=s.scrollWidth-s.clientWidth-s.scrollLeft>1;i(f=>f.left===l&&f.right===d?f:{left:l,right:d})},c=new ResizeObserver(u);return c.observe(s),s.firstElementChild&&c.observe(s.firstElementChild),s.addEventListener("scroll",u,{passive:!0}),u(),()=>{c.disconnect(),s.removeEventListener("scroll",u)}},[]);const a=`var(--chakra-colors-${t.replace(".","-")})`;return h.jsxs(D.Box,{position:"relative",bg:t,minW:0,maxW:"100%",flex:"0 1 auto",borderRadius:"30px",css:zr(a,`var(--chakra-colors-${r.replace(".","-")})`),children:[h.jsx(D.Box,{ref:n,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(s=>h.jsx(D.Box,{"data-flow-toolbar-fade":s,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",borderRadius:s==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[s]:0,opacity:o[s]?1:0,background:`linear-gradient(to ${s==="left"?"right":"left"}, ${a}, transparent)`}},s))]})}async function s0(e,t){const r=new Set,n=[],o=(s,u)=>{var l,d,f;if(!s||typeof s!="object")return;const c=s;n.push(u),typeof((l=c.$form)==null?void 0:l.$type)=="string"&&r.add(c.$form.$type),typeof((f=(d=c.$form)==null?void 0:d.$create)==null?void 0:f.$type)=="string"&&r.add(c.$form.$create.$type);for(const[p,m]of Object.entries(c))p==="$"?o(m,u):p.startsWith("$")||o(m,`${u}.${p}`)};if(o(t,"root"),!r.size)return{contract:await rm(e)};const i=await qu(e,[...r]);for(const s of r)if(!Object.prototype.hasOwnProperty.call(i,s))throw new Error(`Missing form type: ${s}`);const a={};for(const s of n){const u=yt(t,s,i);u&&(a[s]={type:u.type,optional:!1})}return{schema:i,contract:{name:e.name,nodes:a}}}function ym({message:e,onDismiss:t}){const{background:r,colorText:n,border:o}=Ue();return!e||typeof document>"u"?null:Bt.createPortal(h.jsxs(D.chakra.div,{role:"alert","aria-atomic":"true",css:zr(fe(r),fe(o)),onPointerDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),style:{position:"fixed",top:20,right:20,zIndex:1e4,width:360,maxWidth:"calc(100vw - 40px)",boxSizing:"border-box",display:"flex",alignItems:"flex-start",gap:10,padding:16,borderRadius:8,background:fe(r),color:fe(n),fontSize:14,lineHeight:1.5},children:[h.jsx(J.PiWarningCircle,{size:20,"aria-hidden":"true",style:{flexShrink:0,color:"#ef4444"}}),h.jsxs("div",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:[h.jsx("strong",{children:"Interface upload failed"}),h.jsx("div",{children:e})]}),h.jsx(gt,{type:"button","aria-label":"Dismiss upload error",title:"Dismiss upload error",onClick:t,flexShrink:0,width:"24px",height:"24px",minWidth:"24px",padding:0})]}),document.body)}function mm({showDivider:e=!0,compact:t=!1}={}){const{edgeMode:r,setEdgeMode:n,workflowContract:o,setWorkflowContract:i,callbacks:a,readOnly:s,themeColor:u}=Oe(),{edgeById:c}=Ur(),{data:l,schema:d,setSchema:f,bindings:p,structured:m}=S.useContext(kr),g=(m==null?void 0:m.sourceBindings)??p,b=(m==null?void 0:m.sourceSchema)??d,{colorText:w}=Ue(),y=S.useRef(null),x=S.useRef(0),[v,C]=S.useState(!1),[_,k]=S.useState("");S.useEffect(()=>()=>{x.current++},[]),S.useEffect(()=>{x.current++,C(!1)},[s,l,g]);const T=o?[...c.values()].filter(j=>Mu(o,j.data)).length:0,P=o?`${o.name}: ${b?`${Object.keys(b).length} form types loaded; `:""}${T} invalid or unverified connections`:"";return h.jsxs(h.Fragment,{children:[h.jsx(ym,{message:_,onDismiss:()=>k("")}),e&&h.jsx(Mt,{}),h.jsxs(Ir,{"aria-label":"Edge mode",title:r==="auto"?"Connections: Auto":r==="properties"?"Connections: Properties":"Connections: Nodes",icon:r==="auto"?h.jsx(J.PiGraph,{size:20}):r==="properties"?h.jsx(J.PiTable,{size:20}):h.jsx(J.PiTreeStructure,{size:20}),style:{width:36},value:r,disabled:s,onValueChange:j=>{var E;const R=j==="auto"?"auto":j==="properties"?"properties":"nodes";n(R),(E=a.onEdgeModeChange)==null||E.call(a,R)},children:[h.jsx("option",{value:"auto",children:"Auto"}),h.jsx("option",{value:"nodes",children:"Nodes"}),h.jsx("option",{value:"properties",children:"Properties"})]}),h.jsxs("span",{style:{display:r==="auto"||r==="properties"?"contents":"none"},children:[h.jsx(je,{label:o?`Replace ${o.name}`:"Upload workflow interface",children:h.jsx(be,{"aria-label":"Upload workflow interface",icon:h.jsx(J.PiUploadSimple,{size:20}),color:fe(u),size:"sm",variant:"ghost",disabled:v||s,onClick:()=>{var j;return(j=y.current)==null?void 0:j.click()}})}),h.jsx("input",{ref:y,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:s||v,onChange:async j=>{var M,I;const R=(M=j.target.files)==null?void 0:M[0];if(j.target.value="",!R)return;const E=++x.current;C(!0),k("");try{const N=g?await qu(R,[...new Set(Object.values(g).map(z=>z.schemaType??z.type))]):void 0;if(g&&N){for(const z of Object.values(g))if(!Object.prototype.hasOwnProperty.call(N,z.schemaType??z.type))throw new Error(`Missing form type: ${z.schemaType??z.type}`)}const{contract:O,schema:W}=g&&N?{schema:N,contract:{name:R.name,nodes:Object.fromEntries(Object.entries(g).map(([z,re])=>[z,{type:N[re.schemaType??re.type],optional:!1}]))}}:await s0(R,l);if(E!==x.current)return;f==null||f(W),i(O),(I=a.onWorkflowContractChange)==null||I.call(a,O)}catch(N){E===x.current&&k(`${R.name}: ${N instanceof Error?N.message:"Unable to load interface."}`)}finally{E===x.current&&C(!1)}}}),!t&&(P||v)&&h.jsx("span",{role:"status",title:P,style:{color:fe(w),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v?"Loading interface...":P}),!t&&o&&h.jsx(je,{label:"Remove workflow interface",children:h.jsx(be,{"aria-label":"Remove workflow interface",icon:h.jsx(J.PiX,{size:16}),size:"sm",variant:"ghost",disabled:s||v,onClick:()=>{var j;f==null||f(void 0),i(void 0),(j=a.onWorkflowContractChange)==null||j.call(a,void 0),k("")}})})]})]})}const c0=[{value:"BT",label:"Bottom to Up",icon:J.PiArrowUp,flowType:jt.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:J.PiArrowDown,flowType:jt.TOP_DOWN},{value:"LR",label:"Left to Right",icon:J.PiArrowRight,flowType:jt.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:J.PiArrowLeft,flowType:jt.RIGHT_LEFT}],bm=()=>{const{engineRef:e,themeColor:t,setThemeColor:r,backgroundSelected:n,setBackgroundSelected:o,direction:i,edgeMode:a,allNodesIconLabel:s,setAllNodesIconLabel:u,selectedNodeIds:c,setSelectedNodeIds:l,selectedEdgeId:d,setSelectedEdgeId:f,isZoomMode:p,setIsZoomMode:m,isMultiSelectMode:g,setIsMultiSelectMode:b,isDragMode:w,setIsDragMode:y,isEdgeHandlesEnabled:x,setIsEdgeHandlesEnabled:v,isArrayNodeMode:C,setIsArrayNodeMode:_,isPinned:k,setIsPinned:T,callbacks:P,config:j,readOnly:R}=Oe(),{nodeById:E,edgeById:M,parentIds:I}=Ur(),N=j.colorMode==="dark",{background:O,border:W,colorInactive:z,colorText:re,colorActive:te}=Ue(),he=`var(--chakra-colors-${O.replace(".","-")})`,me=`var(--chakra-colors-${(N?W:"gray.300").replace(".","-")})`,[K,q]=S.useState(!1),[L,G]=S.useState(!0),B=S.useRef(null),Y=py({edge:"bottom",enabled:!k,bounds:B,inside:[B]}),ce=S.useCallback(xe=>{const Ie=e.current;if(!Ie)return;const $e=j.minZoom??.01,tr=j.maxZoom??1.5,Je=.02;let Ze=Ie.zoom();switch(xe){case"increase":Ze=Math.min(tr,Ze+Je),Ie.zoom(Ze),Ie.center();break;case"decrease":Ze=Math.max($e,Ze-Je),Ie.zoom(Ze),Ie.center();break;case"reset":Ie.fit(50);break}},[e,j.minZoom,j.maxZoom]),X=j.renderSelectedNodeToolbar,U=c.length>0&&!!X,Z=S.useMemo(()=>U?c.map(xe=>{var $e;return{...(($e=E.get(xe))==null?void 0:$e.data)??{id:xe},isParent:I.has(xe)}}):[],[U,c,E,I]),ae=S.useCallback(()=>{var xe;l([]),(xe=P.onNodeDeselect)==null||xe.call(P)},[l,P]),ue=j.renderSelectedEdgeToolbar,de=!!d&&!!ue,Ee=S.useMemo(()=>{var xe;return!de||!d?null:((xe=M.get(d))==null?void 0:xe.data)??{id:d}},[de,d,M]),ge=S.useCallback(()=>{var xe;f(null),(xe=P.onEdgeDeselect)==null||xe.call(P)},[f,P]),He=j.selectionToolbar!==!1&&!R,Le=He&&!!d&&!ue,Xe=He&&!Le&&c.length>0&&!X,ur=Le||Xe,Ge=k||Y||K||ur;S.useEffect(()=>{c.length||d?o(!1):n&&!R&&(T(!0),G(!1))},[n,c.length,d,R,o,T]);const Ne=j.renderBottomBar;return Ne?h.jsxs(h.Fragment,{children:[U&&h.jsx(D.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:X({selectedNodeIds:c,selectedNodeData:Z,onDeselect:ae})}),de&&Ee&&h.jsx(D.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:ue({edgeId:d,edgeData:Ee,onDeselect:ge})}),h.jsx(D.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:Ne({zoomIn:()=>ce("increase"),zoomOut:()=>ce("decrease"),resetZoom:()=>ce("reset"),direction:i,isZoomMode:p,setIsZoomMode:m,isMultiSelectMode:g,setIsMultiSelectMode:b,isDragMode:w,setIsDragMode:y,isEdgeHandlesEnabled:x,setIsEdgeHandlesEnabled:v,isArrayNodeMode:C,setIsArrayNodeMode:_,selectedNodeIds:c,selectedNodeData:Z,selectedEdgeId:d,selectedEdgeData:Ee,onNodeDeselect:ae,onEdgeDeselect:ge,callbacks:P})})]}):h.jsxs(h.Fragment,{children:[U&&h.jsx(D.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:X({selectedNodeIds:c,selectedNodeData:Z,onDeselect:ae})}),de&&Ee&&h.jsx(D.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:ue({edgeId:d,edgeData:Ee,onDeselect:ge})}),h.jsx(D.Box,{ref:B,role:"toolbar","aria-label":"Diagram controls",position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",transition:"opacity 0.3s ease-in, transform 0.3s ease",transform:Ge?"translateY(0)":"translateY(100%)",pointerEvents:Ge?"auto":"none",visibility:Ge?"visible":"hidden",opacity:Ge?1:0,children:h.jsxs(D.Flex,{w:"100%",px:5,position:"absolute",bottom:5,flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:"24px",children:[h.jsx(gm,{background:O,border:N?W:"gray.300",children:h.jsxs(D.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[Le?h.jsx(um,{edgeId:d,onClose:ge}):Xe?h.jsx(dm,{ids:c,onClose:ae}):null,h.jsxs("div",{style:{display:Le||Xe?"none":"contents"},children:[h.jsx(je,{label:k?"Unpin":"Pin",children:h.jsx(be,{"aria-label":"Pin",icon:h.jsx(D.Icon,{as:k?J.PiPushPinFill:J.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:k?t:z,onClick:()=>{T(!k),q(!1)}})}),h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W}),h.jsx(je,{label:"Zoom Out",children:h.jsx(be,{"aria-label":"Zoom out",icon:h.jsx(D.Icon,{as:J.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:re,onClick:()=>ce("decrease")})}),h.jsx(je,{label:"Zoom In",children:h.jsx(be,{"aria-label":"Zoom in",icon:h.jsx(D.Icon,{as:J.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:re,onClick:()=>ce("increase")})}),h.jsx(je,{label:"Reset Zoom",children:h.jsx(be,{"aria-label":"Reset zoom",icon:h.jsx(D.Icon,{as:J.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:re,onClick:()=>ce("reset")})}),!L&&h.jsxs(h.Fragment,{children:[h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W}),h.jsx(je,{label:p?"Zoom Mode (z)":"Pan Mode (z)",children:h.jsx(be,{"aria-label":"Toggle zoom mode",icon:h.jsx(D.Icon,{as:p?J.PiMagnifyingGlassPlus:J.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:p?t:z,onClick:()=>m(!p)})}),h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W}),h.jsx(je,{label:g?"Multi-Select On (m)":"Multi-Select Off (m)",children:h.jsx(be,{"aria-label":"Toggle multi-select",icon:h.jsx(D.Icon,{as:J.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:g?t:z,onClick:()=>b(!g)})}),h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W}),h.jsx(je,{label:w?"Drag Mode On (d)":"Drag Mode Off (d)",children:h.jsx(be,{"aria-label":"Toggle drag mode",icon:h.jsx(D.Icon,{as:J.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:w?t:z,onClick:()=>y(!w)})}),j.edgeHandles!==!1&&h.jsxs(h.Fragment,{children:[h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W}),h.jsx(je,{label:x?"Draw Mode On":"Draw Mode Off",children:h.jsx(be,{"aria-label":"Toggle draw mode",icon:h.jsx(D.Icon,{as:J.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:x?t:z,onClick:()=>v(!x)})})]}),j.bottomBarExtra&&h.jsxs(h.Fragment,{children:[h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W,role:"separator","aria-orientation":"vertical"}),j.bottomBarExtra]}),h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W,role:"separator","aria-orientation":"vertical"}),h.jsx(zy,{}),h.jsx(ju,{label:"All icon labels",checked:s,icon:h.jsx(D.Icon,{as:J.PiImage,boxSize:5}),onChange:u}),a!=="properties"&&h.jsxs(h.Fragment,{children:[h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W}),h.jsx(je,{label:C?"Array Mode [ ]":"Set Mode { }",children:h.jsx(be,{"aria-label":"Toggle array mode",icon:h.jsx(D.Icon,{as:C?J.PiBracketsSquare:J.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:C?t:z,onClick:()=>{var Ie;const xe=!C;_(xe),(Ie=P.onArrayModeChange)==null||Ie.call(P,xe)}})})]}),n&&!R&&h.jsxs(h.Fragment,{children:[h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W}),h.jsx(Jt,{label:"Graph theme",colors:$u,value:t,includeTransparent:!1,onPick:xe=>{var Ie;r(xe),(Ie=P.onThemeColorChange)==null||Ie.call(P,xe)}})]}),h.jsx(mm,{}),h.jsx(Wy,{})]}),h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W}),h.jsx(je,{label:L?"Expand toolbar":"Collapse toolbar",children:h.jsx(be,{"aria-label":"Toggle toolbar collapse",icon:h.jsx(D.Icon,{as:L?J.PiCaretRight:J.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:z,onClick:()=>G(!L)})}),!L&&h.jsx(pm,{})]})]})}),!ur&&h.jsxs(D.Box,{position:"relative",ml:"auto",flexShrink:0,children:[h.jsx(D.Box,{"data-flow-direction-control":"",bg:O,borderRadius:"30px",h:50,css:zr(he,me),px:3,cursor:"pointer",onClick:()=>q(!K),children:h.jsxs(D.Flex,{align:"center",h:"100%",children:[h.jsx(je,{label:"Flow Direction",children:h.jsx(be,{"aria-label":"Direction",icon:h.jsx(D.Icon,{as:J.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:z})}),h.jsx(D.Text,{fontSize:"xs",color:N?"whiteAlpha.600":"blackAlpha.500",ml:1,children:i})]})}),K&&h.jsx(D.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:h.jsxs(D.Box,{bg:O,borderRadius:"30px",p:2,minW:"180px",css:zr(he,me),children:[c0.map(xe=>h.jsxs(D.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"30px",cursor:"pointer",_hover:{bg:N?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Ie;(Ie=P.onDirectionChange)==null||Ie.call(P,xe.value),q(!1)},children:[h.jsx(D.Icon,{as:xe.icon,boxSize:5,color:re}),h.jsx(D.Text,{fontSize:"sm",color:re,flex:1,whiteSpace:"nowrap",children:xe.label}),i===xe.value&&h.jsx(D.Icon,{as:J.PiCheck,boxSize:4,color:te})]},xe.value)),h.jsxs(D.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"10px",cursor:"pointer",_hover:{bg:N?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var xe;(xe=P.onDirectionChange)==null||xe.call(P,"C"),q(!1)},children:[h.jsx(D.Icon,{as:J.PiAlignCenterHorizontal,boxSize:5,color:re}),h.jsx(D.Text,{fontSize:"sm",color:re,flex:1,whiteSpace:"nowrap",children:"Center"}),i==="C"&&h.jsx(D.Icon,{as:J.PiCheck,boxSize:4,color:te})]})]})})]})]})})]})};bm.displayName="BottomBar";const vm=S.memo(bm);function u0({checked:e,onChange:t,disabled:r,label:n="Connected nodes"}){return h.jsx(ju,{label:n,checked:e,onChange:t,disabled:r,icon:h.jsx(D.Icon,{as:J.PiGraph,boxSize:5})})}const Pl={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function xm(e,t){const r=new Map,n=(i,a)=>{if(Object.is(i,a))return!0;if(!i||!a||typeof i!="object"||typeof a!="object"||Array.isArray(i)!==Array.isArray(a))return!1;const s=Object.keys(i);return s.length===Object.keys(a).length&&s.every(u=>Object.prototype.hasOwnProperty.call(a,u)&&n(i[u],a[u]))},o=(i,a,s)=>{if(i===a)return!0;if(!i||!a||typeof i!="object"||typeof a!="object"||Array.isArray(i)!==Array.isArray(a))return!1;const u=new Set([...Object.keys(i),...Object.keys(a)]);for(const c of u)if(!n(i[c],a[c])){if(Object.prototype.hasOwnProperty.call(Pl,c)){if(typeof a[c]!="string"||!a[c])return!1;r.set(s,{...r.get(s),[Pl[c]]:a[c]})}else if(c.startsWith("$")&&c!=="$"||!o(i[c],a[c],c==="$"?s:`${s}.${c}`))return!1}return!0};if(o(e,t,"root"))return r}function l0(e,t){return xm(e,t)!==void 0}function d0(e,t,r){if(e===t)return r;const n=xm(e,t);if(!n)return;const o=new Set(r.nodes.map(i=>i.data.id));for(const i of n.keys())if(!o.has(i)||!ve(t,i))return;return{edges:r.edges,nodes:r.nodes.map(i=>{const a=n.get(i.data.id),s=ve(e,i.data.id),u=ve(t,i.data.id);return!a&&s===u?i:{...i,data:{...i.data,...typeof i.data.code=="string"?{code:JSON.stringify(u,null,2)}:{},...a?{viewProps:{...i.data.viewProps,...a},config:{...i.data.config,...a}}:{}}}})}}function xu(e){return e.kind==="literal"?e.value:e.kind==="union"?xu(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,t])=>!t.optional).map(([t,r])=>[t,xu(r.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function wm(e,t,r){var b,w,y;const n=(b=ve(e,t))==null?void 0:b.$form,o=n==null?void 0:n.$create;if(!o)return;const i=o.$address.split(".");if(i.shift()!=="root"||!i.length||i.some(x=>!/^[A-Za-z0-9_-]+$/.test(x)||["__proto__","constructor","prototype"].includes(x)))throw new Error("Invalid form creation address.");if(!r||!Object.prototype.hasOwnProperty.call(r,o.$type))throw new Error(`Load form type: ${o.$type}`);const a=i.pop(),s=["root",...i].join("."),u=yt(e,s,r),c=(w=u==null?void 0:u.type.properties[a])==null?void 0:w.type;if((c==null?void 0:c.kind)!=="array"||c.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const l=r[o.$type],d=o.$defaults??{};for(const[x,v]of Object.entries(d))if(!Object.prototype.hasOwnProperty.call(l.properties,x)||Rr(l.properties[x].type,v,!l.properties[x].optional))throw new Error(`Invalid creation default: ${x}`);const f={...xu(l),...structuredClone(d)};((y=l.properties.id)==null?void 0:y.type.kind)==="string"&&(f.id=Ru());let p=e;const m=ve(e,o.$address);if(m===void 0)p=mr(e,s,x=>({...x,[a]:[]}));else if(!Array.isArray(m)&&!Array.isArray(m==null?void 0:m.$))throw new Error("Form creation destination is not an array.");const g=Au(p,o.$address,{...f,$label:o.$label??o.$type,...o.$icon?{$icon:o.$icon}:{},$form:{$type:o.$type,$create:o}});return{address:g.address,json:Tu(g.json,t,{target:g.address,label:o.$edgeLabel})}}function f0(e,t){const r=o=>e&&typeof e=="object"&&o in e;let n=1;for(;r(`${t}_${n}`);)n++;return`${t}_${n}`}function Cm(e,t,r,n,o){const i=(s,u)=>{s!==e&&(e=s,n==null||n(s,u))},a=s=>{var c;const u=(c=t.find(l=>l.data.id===s))==null?void 0:c.data;return u&&{source:u.source,target:u.target,isInverted:u.isInverted,sourceProperty:u.sourceProperty,targetProperty:u.targetProperty,connection:u.connection}};return{...r,onFormChange:s=>{const u=ve(e,s.nodeAddress);if(!u||s.nodeId!==void 0&&u.id!==s.nodeId)throw new Error("This form node has moved. Retry the edit.");i(Cn(e,s,r.onFormChange),{type:"form",address:s.address,value:s.value})},onNodeLabelChange:(s,u)=>{var c;(c=r.onNodeLabelChange)==null||c.call(r,s,u),i(cr(e,s,"$label",u),{type:"nodeLabel",address:s,key:"$label",value:u})},onNodeContentChange:(s,u)=>{var c;(c=r.onNodeContentChange)==null||c.call(r,s,u),i(cr(e,s,"$content",u),{type:"nodeContent",address:s,key:"$content",value:u})},onNodeTypeViewChange:(s,u)=>{var c;u!==void 0&&!Dt.includes(u)||((c=r.onNodeTypeViewChange)==null||c.call(r,s,u),i(cr(e,s,"$view",u),{type:"nodeStyle",address:s,key:"$view",value:u}))},onNodeColorChange:(s,u,c)=>{var d;(d=r.onNodeColorChange)==null||d.call(r,s,u,c);const l=u==="bg"?"$bgColor":"$textColor";i(cr(e,s,l,c),{type:"nodeColor",address:s,key:l,value:c})},onNodeBorderColorChange:(s,u)=>{var c;(c=r.onNodeBorderColorChange)==null||c.call(r,s,u),i(cr(e,s,"$borderColor",u),{type:"nodeColor",address:s,key:"$borderColor",value:u})},onNodeBorderStyleChange:(s,u)=>{var c;(c=r.onNodeBorderStyleChange)==null||c.call(r,s,u),i(cr(e,s,"$borderStyle",u),{type:"nodeStyle",address:s,key:"$borderStyle",value:u})},onNodeBorderWidthChange:(s,u)=>{var c;u!==void 0&&(!Number.isFinite(u)||u<0)||((c=r.onNodeBorderWidthChange)==null||c.call(r,s,u),i(cr(e,s,"$borderWidth",u),{type:"nodeStyle",address:s,key:"$borderWidth",value:u}))},onNodeBorderRadiusChange:(s,u)=>{var c;u!==void 0&&(!Number.isFinite(u)||u<0)||((c=r.onNodeBorderRadiusChange)==null||c.call(r,s,u),i(cr(e,s,"$borderRadius",u),{type:"nodeStyle",address:s,key:"$borderRadius",value:u}))},onNodeIconChange:(s,u)=>{var c;(c=r.onNodeIconChange)==null||c.call(r,s,u),i(cr(e,s,"$icon",u),{type:"nodeIcon",address:s,key:"$icon",value:u})},onNodeOutlineChange:(s,u)=>{var c;(c=r.onNodeOutlineChange)==null||c.call(r,s,u),i(cr(e,s,"$outline",u),{type:"nodeOutline",address:s,key:"$outline",value:u})},onNodeAnimationChange:(s,u)=>{var c;(c=r.onNodeAnimationChange)==null||c.call(r,s,u),i(cr(e,s,"$isNodeAnimated",u),{type:"nodeAnimation",address:s,key:"$isNodeAnimated",value:u})},onNodeAnimationVariantChange:(s,u)=>{var c;u!=="traveling"&&u!=="pulse"||((c=r.onNodeAnimationVariantChange)==null||c.call(r,s,u),i(cr(e,s,"$nodeAnimationVariant",u),{type:"nodeAnimation",address:s,key:"$nodeAnimationVariant",value:u}))},onNodeCollapse:(s,u)=>{var c;(c=r.onNodeCollapse)==null||c.call(r,s,u),i(Jy(e,s,u),{type:"nodeCollapse",address:s,key:"$collapsed",value:u})},onNodeCreate:s=>{var p,m;const u=s.sourceNodeId&&wm(e,s.sourceNodeId,o);if(u){(p=r.onNodeCreate)==null||p.call(r,s),i(u.json,{type:"nodeCreate",address:u.address,value:"form"});return}(m=r.onNodeCreate)==null||m.call(r,s);const c=s.sourceNodeId||"root",l=ve(e,c),d=f0(l,s.isArrayMode?"list":"node"),f=Au(e,c,s.isArrayMode?[]:{},d);i(f.json,{type:"nodeCreate",address:f.address,value:s.isArrayMode?"array":"set"})},onNodeDelete:(s,u)=>{var c;(c=r.onNodeDelete)==null||c.call(r,s,u),i(Yy(e,s),{type:"nodeDelete",address:s})},onEdgeCreate:(s,u,c)=>{var d;(d=r.onEdgeCreate)==null||d.call(r,s,u,c);const l=c&&(c.sourceProperty!==void 0||c.targetProperty!==void 0)?{...c,target:u}:void 0;i(l?Tu(e,s,l):Xy(e,s,u),{type:"edgeCreate",address:s,key:l?"$connections":"$target",value:l??u})},onEdgeLabelChange:(s,u)=>{var l;(l=r.onEdgeLabelChange)==null||l.call(r,s,u);const c=a(s);c&&i(Br(e,c,"$sourceLabel",u),{type:"edgeLabel",edge:c,key:c.connection?"$connections":"$sourceLabel",value:u})},onEdgeStyleChange:(s,u)=>{var l;(l=r.onEdgeStyleChange)==null||l.call(r,s,u);const c=a(s);c&&i(Zy(e,c,u),{type:"edgeStyle",edge:c,value:u})},onEdgeAnimationVariantChange:(s,u)=>{var l;if(u!=="dashed"&&u!=="traveling")return;(l=r.onEdgeAnimationVariantChange)==null||l.call(r,s,u);const c=a(s);c&&i(Br(e,c,"$edgeAnimationVariant",u),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeAnimationVariant",value:u})},onEdgeTypeChange:(s,u)=>{var l;(l=r.onEdgeTypeChange)==null||l.call(r,s,u);const c=a(s);c&&i(Br(e,c,"$edgeType",u),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeType",value:u})},onEdgeIconChange:(s,u)=>{var l;(l=r.onEdgeIconChange)==null||l.call(r,s,u);const c=a(s);c&&i(Br(e,c,"$edgeIcon",u||void 0),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeIcon",value:u})},onEdgeColorChange:(s,u)=>{var l;(l=r.onEdgeColorChange)==null||l.call(r,s,u);const c=a(s);c&&i(Br(e,c,"$edgeColor",u),{type:"edgeColor",edge:c,key:c.connection?"$connections":"$edgeColor",value:u})},onEdgeDelete:(s,u)=>{var d;(d=r.onEdgeDelete)==null||d.call(r,s,u);const c=a(s);if(!c)return;const l=Qy(e,c);l.removed&&i(l.json,{type:"edgeDelete",edge:c,key:c.connection?"$connections":"$target"})}}}const h0=".flow-sdk-edge-trace{pointer-events:none;animation:flow-sdk-edge-trace 2.4s linear infinite}.flow-sdk-edge-trace-reverse{animation-direction:reverse}@keyframes flow-sdk-edge-trace{from{stroke-dashoffset:18}to{stroke-dashoffset:-100}}@media(prefers-reduced-motion:reduce){.flow-sdk-edge-trace,.flow-sdk-edge-anim{animation:none}}";function p0({path:e,color:t,width:r,reversed:n}){return h.jsx("path",{className:`flow-sdk-edge-trace${n?" flow-sdk-edge-trace-reverse":""}`,"data-animation-variant":"traveling","aria-hidden":"true",pointerEvents:"none",d:e,fill:"none",stroke:t,strokeWidth:r,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 100"})}const g0=".flow-sdk-node-animation{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;z-index:1}.flow-sdk-node-border-animation{pointer-events:none;animation:flow-sdk-node-border 2.4s linear infinite}.flow-sdk-node-border-pulse{stroke-width:var(--flow-pulse-rest-width);animation:flow-sdk-node-pulse 1.8s ease-in-out infinite}@keyframes flow-sdk-node-border{from{stroke-dashoffset:0}to{stroke-dashoffset:-100}}@keyframes flow-sdk-node-pulse{0%,100%{stroke-width:var(--flow-pulse-rest-width)}50%{stroke-width:var(--flow-pulse-expanded-width)}}@media(prefers-reduced-motion:reduce){.flow-sdk-node-border-animation{animation:none}}";function _m({x:e=0,y:t=0,width:r,height:n,radius:o,color:i,strokeWidth:a=8,path:s,variant:u="traveling"}){const c=S.useId(),l=`flow-sdk-node-border-animation${u==="pulse"?" flow-sdk-node-border-pulse":""}`;if(u==="pulse"){const d=s?"path":"rect",f=s?{d:s}:{x:e,y:t,width:Math.max(0,r),height:Math.max(0,n),rx:Math.max(0,Math.min(o,r/2,n/2))},p=a+36,m={x:e-p,y:t-p,width:r+2*p,height:n+2*p};return h.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[h.jsx("defs",{children:h.jsxs("mask",{id:c,maskUnits:"userSpaceOnUse",...m,style:{maskType:"luminance"},children:[h.jsx("rect",{...m,fill:"white"}),h.jsx(d,{...f,fill:"black",stroke:"black",strokeWidth:a,strokeLinejoin:"round"})]})}),h.jsx(d,{...f,className:l,"data-animation-variant":u,fill:"none",stroke:`color-mix(in srgb, ${i} 60%, transparent)`,strokeLinejoin:"round",mask:`url(#${c})`,style:{"--flow-pulse-rest-width":`${a+16}px`,"--flow-pulse-expanded-width":`${a+36}px`}})]})}return s?h.jsx("path",{className:l,"data-animation-variant":u,"aria-hidden":"true",pointerEvents:"none",d:s,fill:"none",stroke:i,strokeWidth:a,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"}):h.jsx("rect",{className:l,"data-animation-variant":u,"aria-hidden":"true",pointerEvents:"none",x:e,y:t,width:Math.max(0,r),height:Math.max(0,n),rx:Math.max(0,Math.min(o,r/2,n/2)),fill:"none",stroke:i,strokeWidth:a,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const y0=e=>{const n=1/(Math.cbrt(e)*.8);let o=Math.round(650*n),i=Math.round(350*n);return o=Math.max(40,Math.min(450,o)),i=Math.max(30,Math.min(300,i)),{edgeSep:o,rankSep:i}};function Al(e,t,r){const n=new Set([e]),o=[e];for(;o.length;){const i=o.pop();for(const a of t)(a.parent===i||a.id.startsWith(`${i}.`)||r.some(u=>(u.inverted?u.target:u.source)===i&&(u.inverted?u.source:u.target)===a.id))&&!n.has(a.id)&&(n.add(a.id),o.push(a.id))}return n}function m0(e,t,r){const n=r==="downward"||r==="upward",o=new Map;for(const a of e){if(a.source===a.target||a.sourceProperty||a.targetProperty)continue;const s=t(a.source),u=t(a.target);if(!s||!u)continue;const c=n?u.y-s.y:u.x-s.x,l=Math.abs(c)-(n?s.h+u.h:s.w+u.w)/2;if(l<=320)continue;const d=JSON.stringify([a.source,Math.sign(c)]),f=o.get(d)??[];f.push({edge:a,gap:l,cross:n?u.x-s.x:u.y-s.y}),o.set(d,f)}const i=new Map;for(const a of o.values()){if(new Set(a.map(({edge:u})=>u.target)).size<2)continue;const s=new Map;for(const{edge:u}of a)s.set(u.target,(s.get(u.target)??0)+1);for(const u of[-1,0,1]){const c=a.filter(({cross:d})=>Math.sign(d)===u);c.sort((d,f)=>Math.abs(f.cross)-Math.abs(d.cross)||d.edge.id.localeCompare(f.edge.id));const l=Math.min(...c.map(({gap:d})=>d));c.forEach(({edge:d,gap:f,cross:p},m)=>{const g=c.length===1?l/2:120+(l-280)*m/(c.length-1),b=c.find(w=>Math.abs(w.cross)<Math.abs(p));i.set(d.id,{turn:g/f,labelAtTarget:s.get(d.target)===1,labelFraction:p?(p+((b==null?void 0:b.cross)??0))/(2*p):.5})})}}return i}const ct=e=>({x1:e.x-e.w/2,y1:e.y-e.h/2,x2:e.x+e.w/2,y2:e.y+e.h/2}),b0=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function Yn(e){if(!e.length)return null;const t={...e[0]};for(let r=1;r<e.length;r++)t.x1=Math.min(t.x1,e[r].x1),t.y1=Math.min(t.y1,e[r].y1),t.x2=Math.max(t.x2,e[r].x2),t.y2=Math.max(t.y2,e[r].y2);return t}const v0=(e,t)=>e.x1<=t.x2&&e.x2>=t.x1&&e.y1<=t.y2&&e.y2>=t.y1,Tl=(e,t)=>e.x>=t.x1&&e.x<=t.x2&&e.y>=t.y1&&e.y<=t.y2,hr=e=>(Math.round(e*10)/10).toString(),Ke=e=>`${hr(e.x)} ${hr(e.y)}`,x0=e=>e>0?1:e<0?-1:0,Ol=(e,t)=>e>0?Math.max(e-t,0):Math.min(e+t,0);function w0(e,t,r,n,o=10){const i=t.x-e.x,a=t.y-e.y,s=Ol(i,(e.w+t.w)/2),u=Ol(a,(e.h+t.h)/2),c=r==="downward"||r==="upward",l=c?u:s,d=c?a:i,f=x0(d),p=n*l,m=y=>Math.abs(y)<o||Math.abs(y)>=Math.abs(l),g=m(p)||m(Math.abs(l)-Math.abs(p));let b;if(g)if(c)if(Math.abs(d)<=e.h/2){const y=(e.x+t.x)/2;b=[y,e.y,y,t.y]}else if(Math.abs(i)<=t.w/2){const y=(e.y+t.y)/2;b=[e.x,y,t.x,y]}else b=[e.x,t.y];else if(Math.abs(d)<=e.w/2){const y=(e.y+t.y)/2;b=[e.x,y,t.x,y]}else if(Math.abs(a)<=t.h/2){const y=(e.x+t.x)/2;b=[y,e.y,y,t.y]}else b=[t.x,e.y];else if(c){const y=e.y+p+e.h/2*f;b=[e.x,y,t.x,y]}else{const y=e.x+p+e.w/2*f;b=[y,e.y,y,t.y]}const w=[{x:e.x,y:e.y}];for(let y=0;y<b.length;y+=2)w.push({x:b[y],y:b[y+1]});return w.push({x:t.x,y:t.y}),w}function C0(e,t,r){const n=t.x-e.x,o=t.y-e.y,i=n>0?(r.x2-e.x)/n:n<0?(r.x1-e.x)/n:1/0,a=o>0?(r.y2-e.y)/o:o<0?(r.y1-e.y)/o:1/0,s=Math.min(i,a);return!Number.isFinite(s)||s>=1||s<0?null:{x:e.x+n*s,y:e.y+o*s}}function pt(e,t,r){var a;if(!((a=r.outline)!=null&&a.length))return C0(e,t,ct(r));const n=t.x-e.x,o=t.y-e.y;let i=1/0;return r.outline.forEach((s,u,c)=>{const l=c[(u+1)%c.length],d=l.x-s.x,f=l.y-s.y,p=n*f-o*d;if(Math.abs(p)<1e-9)return;const m=s.x-e.x,g=s.y-e.y,b=(m*f-g*d)/p,w=(m*o-g*n)/p;b>=0&&b<1&&w>=-1e-9&&w<=1+1e-9&&(i=Math.min(i,b))}),Number.isFinite(i)?{x:e.x+n*i,y:e.y+o*i}:null}function Sm(e,t,r=.5){const n=Number.isFinite(r)?Math.max(0,Math.min(1,r)):.5,o=t==="top"||t==="bottom",i=t==="top"||t==="left"?-1:1,a={x:o?e.x-e.w/2+e.w*n:e.x,y:o?e.y:e.y-e.h/2+e.h*n},s=Math.max(e.w,e.h)*2+1;return{...pt(a,{x:a.x+(o?0:i*s),y:a.y+(o?i*s:0)},e)??{x:o?a.x:e.x+i*e.w/2,y:o?e.y+i*e.h/2:a.y},side:t}}function dt(e,t){return{x:e.x+(e.side==="right"?t:e.side==="left"?-t:0),y:e.y+(e.side==="bottom"?t:e.side==="top"?-t:0)}}function _0(e,t,r,n){const o=dt(e,r.srcDist),i=dt(t,r.tgtDist);if(n==="straight")return jm(o,i,r);const a=Math.max(80,Math.min(300,Math.hypot(i.x-o.x,i.y-o.y)/3)),s=e.side==="bottom"&&t.side==="top"?i.y-o.y:e.side==="top"&&t.side==="bottom"?o.y-i.y:e.side==="right"&&t.side==="left"?i.x-o.x:e.side==="left"&&t.side==="right"?o.x-i.x:void 0,u=s!==void 0&&s>0?Math.min(a,s/2):a,c=dt({...o,side:e.side},u),l=dt({...i,side:t.side},u),d=r.arrowAt==="source"?rr(o,c,r.arrowGap):o,f=r.arrowAt==="target"?rr(i,l,r.arrowGap):i,p=r.arrowAt==="source"?br(o,c,r.arrowSize,r.headShape):r.arrowAt==="target"?br(i,l,r.arrowSize,r.headShape):void 0;if(n==="bezier")return{d:`M${Ke(d)} C${Ke(c)} ${Ke(l)} ${Ke(f)}`,arrow:p,label:{x:(d.x+3*c.x+3*l.x+f.x)/8,y:(d.y+3*c.y+3*l.y+f.y)/8,angle:0}};const m=e.side==="left"||e.side==="right",g=t.side==="left"||t.side==="right";let b;if(m!==g){const y=m?{x:l.x,y:c.y}:{x:c.x,y:l.y},x=(y.x-c.x)*(c.x-o.x)+(y.y-c.y)*(c.y-o.y)>=0,v=(y.x-l.x)*(l.x-i.x)+(y.y-l.y)*(l.y-i.y)>=0;b=[x&&v?y:m?{x:c.x,y:l.y}:{x:l.x,y:c.y}]}else if(s!==void 0&&s<=0)if(m){const y=(c.y+l.y)/2;b=[{x:c.x,y},{x:l.x,y}]}else{const y=(c.x+l.x)/2;b=[{x:y,y:c.y},{x:y,y:l.y}]}else if(m){const y=e.side===t.side?e.side==="right"?Math.max(c.x,l.x):Math.min(c.x,l.x):(c.x+l.x)/2;b=[{x:y,y:c.y},{x:y,y:l.y}]}else{const y=e.side===t.side?e.side==="bottom"?Math.max(c.y,l.y):Math.min(c.y,l.y):(c.y+l.y)/2;b=[{x:c.x,y},{x:l.x,y}]}const w=[c,...b,l].filter((y,x,v)=>x===0||y.x!==v[x-1].x||y.y!==v[x-1].y);return _n(d,w,f,p,n==="orthogonal"?0:r.radius)}function rr(e,t,r){const n=e.x-t.x,o=e.y-t.y,i=Math.hypot(n,o);if(!i)return e;let a=(i-r)/i;return a<0&&(a=1e-5),{x:t.x+a*n,y:t.y+a*o}}function br(e,t,r,n="triangle"){const o=e.x-t.x,i=e.y-t.y,a=Math.hypot(o,i)||1,s=o/a,u=i/a,c=(n==="square"?.15:.3)*r,l=.15*r,d=e.x-s*c,f=e.y-u*c;return n==="square"?`M${Ke(e)} L${hr(e.x-u*l)} ${hr(e.y+s*l)} L${hr(d-u*l)} ${hr(f+s*l)} L${hr(d+u*l)} ${hr(f-s*l)} L${hr(e.x+u*l)} ${hr(e.y-s*l)} Z`:`M${Ke(e)} L${hr(d-u*l)} ${hr(f+s*l)} L${hr(d+u*l)} ${hr(f-s*l)} Z`}function Fr(e,t){let r=Math.atan(t/e);return e===0&&r<0&&(r=-r),Number.isFinite(r)||(r=0),r*180/Math.PI}function S0(e,t,r,n){const o={x:t.x-e.x,y:t.y-e.y},i={x:r.x-t.x,y:r.y-t.y},a=Math.hypot(o.x,o.y),s=Math.hypot(i.x,i.y),u=o.x*i.y-o.y*i.x;if(a<1e-6||s<1e-6||Math.abs(u)<1e-6)return{p1:t,b:t,p2:t,r:0};const c=Math.min(n,a/2,s/2);return{p1:{x:t.x-o.x/a*c,y:t.y-o.y/a*c},b:t,p2:{x:t.x+i.x/s*c,y:t.y+i.y/s*c},r:c}}function Em(e,t,r,n){let o=-1,i=null;for(let m=0;m<e.length-1;m++){const g=pt(e[m],e[m+1],t);if(g){o=m,i=g;break}}let a=-1,s=null;for(let m=e.length-1;m>0;m--){const g=pt(e[m],e[m-1],r);if(g){a=m,s=g;break}}if(!i||!s||o>=a)return null;const u=e.slice(o+1,a),c=u[0]??s,l=u[u.length-1]??i;let d,f,p;if(n.arrowAt==="source"){const m=rr(i,c,n.srcDist);d=rr(i,c,n.srcDist+n.arrowGap),p=br(m,c,n.arrowSize,n.headShape)}else d=rr(i,c,n.srcDist);if(n.arrowAt==="target"){const m=rr(s,l,n.tgtDist);f=rr(s,l,n.tgtDist+n.arrowGap),p=br(m,l,n.arrowSize,n.headShape)}else f=rr(s,l,n.tgtDist);return _n(d,u,f,p,n.radius,n.labelTargetLength,n.labelFraction)}function _n(e,t,r,n,o,i,a){var f;const s=[e,...t,r],u=[];let c=`M${Ke(e)}`;for(let p=1;p<s.length-1;p++){const m=S0(s[p-1],s[p],s[p+1],o);u.push(m),m.r===0?c+=` L${Ke(m.b)}`:c+=` L${Ke(m.p1)} Q${Ke(m.b)} ${Ke(m.p2)}`}c+=` L${Ke(r)}`;let l;const d=t.length;if(d===0)l={x:(e.x+r.x)/2,y:(e.y+r.y)/2,angle:Fr(r.x-e.x,r.y-e.y)};else if(d%2===0){const p=t[d/2-1],m=t[d/2];l={x:(p.x+m.x)/2,y:(p.y+m.y)/2,angle:Fr(m.x-p.x,m.y-p.y)}}else{const p=u[(d-1)/2];if(p.r===0){const m=s[(d-1)/2+2];l={x:p.b.x,y:p.b.y,angle:Fr(m.x-p.b.x,m.y-p.b.y)}}else l={x:.25*p.p1.x+.5*p.b.x+.25*p.p2.x,y:.25*p.p1.y+.5*p.b.y+.25*p.p2.y,angle:Fr(p.p2.x-p.p1.x,p.p2.y-p.p1.y)}}if(i!==void 0){if(a!==void 0&&u.length===2){const b=u[0].p2,w=u[1].p1,y=Math.hypot(w.x-b.x,w.y-b.y),x=Math.min(.5,i/(2*y)),v=Math.max(x,Math.min(1-x,a));l={x:b.x+(w.x-b.x)*v,y:b.y+(w.y-b.y)*v,angle:Fr(w.x-b.x,w.y-b.y)}}const p=((f=u[u.length-1])==null?void 0:f.p2)??e,m=r.x-p.x,g=r.y-p.y;Math.hypot(m,g)>=i&&(l={x:(p.x+r.x)/2,y:(p.y+r.y)/2,angle:Fr(m,g)})}return{d:c,arrow:n,label:l}}function Il(e,t,r,n,o,i,a){const s=r==="leftward"?-1:1,u={x:e.x+s*(e.w/2+a.srcDist),y:n??e.y},c={x:t.x-s*(t.w/2+a.tgtDist),y:o??t.y},l=Math.max(80,a.arrowGap+a.arrowSize*.3),d=u.x+s*l,f=c.x-s*l;let p;if(s*(f-d)>=0){const w=u.x+(c.x-u.x)*i,y=Math.max(Math.min(d,f),Math.min(Math.max(d,f),w));p=[{x:y,y:u.y},{x:y,y:c.y}]}else{const w=Math.min(e.y-e.h/2,t.y-t.h/2)-l*(1+i);p=[{x:d,y:u.y},{x:d,y:w},{x:f,y:w},{x:f,y:c.y}]}const m=a.arrowAt==="source"?rr(u,p[0],a.arrowGap):u,g=a.arrowAt==="target"?rr(c,p[p.length-1],a.arrowGap):c,b=a.arrowAt==="source"?br(u,p[0],a.arrowSize,a.headShape):a.arrowAt==="target"?br(c,p[p.length-1],a.arrowSize,a.headShape):void 0;return _n(m,p,g,b,a.radius)}function Ml(e,t,r,n,o){return Em(w0(e,t,r,n),e,t,o)}function ql(e,t,r,n,o,i){const a=n===void 0&&o===void 0&&(r==="downward"||r==="upward"),s=r==="leftward"||a&&r==="upward"?-1:1,u=(c,l,d)=>{const f={x:c.x,y:l??c.y},p=Math.max(c.w,c.h)*2+1,m=pt(f,{x:f.x+(a?0:d*p),y:f.y+(a?d*p:0)},c);return m?{x:m.x+(a?0:d*i),y:m.y+(a?d*i:0)}:a?{x:c.x,y:c.y+d*(c.h/2+i)}:{x:c.x+d*(c.w/2+i),y:l??c.y}};return{sourcePoint:u(e,n,s),targetPoint:u(t,o,-s)}}function E0(e,t,r,n){const o=r==="downward"||r==="upward",i=r==="leftward"||r==="upward"?-1:1,a=Math.max(100,Math.abs(o?t.y-e.y:t.x-e.x)/2),s={x:e.x+(o?0:i*a),y:e.y+(o?i*a:0)},u={x:t.x-(o?0:i*a),y:t.y-(o?i*a:0)},c=n.arrowAt==="source"?rr(e,s,n.arrowGap):e,l=n.arrowAt==="target"?rr(t,u,n.arrowGap):t;return{d:`M${Ke(c)} C${Ke(s)} ${Ke(u)} ${Ke(l)}`,arrow:n.arrowAt==="source"?br(e,s,n.arrowSize,n.headShape):n.arrowAt==="target"?br(t,u,n.arrowSize,n.headShape):void 0,label:{x:(c.x+3*s.x+3*u.x+l.x)/8,y:(c.y+3*s.y+3*u.y+l.y)/8,angle:Fr(l.x+u.x-s.x-c.x,l.y+u.y-s.y-c.y)}}}function jm(e,t,r){const n=r.arrowAt==="source"?rr(e,t,r.arrowGap):e,o=r.arrowAt==="target"?rr(t,e,r.arrowGap):t,i=r.arrowAt==="source"?br(e,t,r.arrowSize,r.headShape):r.arrowAt==="target"?br(t,e,r.arrowSize,r.headShape):void 0;return _n(n,[],o,i,0)}function j0(e,t,r,n=-90,o=-60,i=350){const a=n*Math.PI/180,s=o*Math.PI/180,u=a-Math.PI/2,c=u-s/2,l=u+s/2,d=1.4*i*(t/3+1),f={x:e.x+Math.cos(c)*d,y:e.y+Math.sin(c)*d},p={x:e.x+Math.cos(l)*d,y:e.y+Math.sin(l)*d},m={x:e.x,y:e.y},g=pt(m,f,e),b=pt(m,p,e);if(!g||!b)return null;const w={x:(f.x+p.x)/2,y:(f.y+p.y)/2};let y=rr(g,f,r.srcDist),x=rr(b,p,r.tgtDist),v;if(r.arrowAt==="target"){const _=x;x=rr(b,p,r.tgtDist+r.arrowGap),v=br(_,p,r.arrowSize,r.headShape)}else if(r.arrowAt==="source"){const _=y;y=rr(g,f,r.srcDist+r.arrowGap),v=br(_,f,r.arrowSize,r.headShape)}return{d:`M${Ke(y)} Q${Ke(f)} ${Ke(w)} Q${Ke(p)} ${Ke(x)}`,arrow:v,label:{x:w.x,y:w.y,angle:Fr(p.x-f.x,p.y-f.y)}}}const at=e=>Math.round(e*1e3)/1e3;function Rm(e){const t=e.querySelector("[data-flow-node-surface]");if(!t)return;const r=e.getBoundingClientRect(),n=r.width/e.offsetWidth;if(!Number.isFinite(n)||n<=0)return;const o=t.getBoundingClientRect();if(!o.width||!o.height)return;const i=t,a=typeof i.getScreenCTM=="function"?i.getScreenCTM():null,s=typeof i.getTotalLength=="function"?i.getTotalLength():0,u=i.points,c=(u==null?void 0:u.numberOfItems)||128,l=a&&s>0?Array.from({length:c},(d,f)=>{const p=u!=null&&u.numberOfItems?u.getItem(f):i.getPointAtLength(s*f/c);return{x:at((a.a*p.x+a.c*p.y+a.e-r.left)/n),y:at((a.b*p.x+a.d*p.y+a.f-r.top)/n)}}):void 0;return{left:at((o.left-r.left)/n),top:at((o.top-r.top)/n),width:t instanceof HTMLElement?t.offsetWidth:at(o.width/n),height:t instanceof HTMLElement?t.offsetHeight:at(o.height/n),radius:parseFloat(getComputedStyle(t).borderTopLeftRadius)||0,...l?{outline:l}:{}}}function Ft(e,t){const r=e.x-e.w/2,n=e.y-e.h/2;return{x:r+t.left+t.width/2,y:n+t.top+t.height/2,w:t.width,h:t.height,...t.outline?{outline:t.outline.map(o=>({x:r+o.x,y:n+o.y}))}:{}}}function R0(e,t,r,n,o){var l;const i=o!=="TB"&&o!=="BT",a=i?"top":"left",s=i?"bottom":"right",u=new Map;for(const d of n)for(const[f,p,m]of[[d.source,d.sourceProperty,d.target],[d.target,d.targetProperty,d.source]]){const g=t.get(m);if(p===void 0||!g||m===f)continue;const b=r.get(m),w=JSON.stringify([f,p]),y=u.get(w)??[];y.push(b?Ft(g,b):g),u.set(w,y)}const c=new Map(e);for(const[d,f]of e){const p=t.get(d);if(!p||!f.some(x=>x.placement==="config"))continue;const m=r.get(d),g=m?Ft(p,m):p,b={x:p.w/2,y:p.h/2,w:p.w,h:p.h},w=m?Ft(b,m):b,y=new Map;for(const x of f){if(x.placement!=="config")continue;const C=(u.get(JSON.stringify([d,x.property]))??[]).reduce((k,T)=>k+(i?T.y-g.y:T.x-g.x),0),_=((l=x.anchor)==null?void 0:l.side)===s?s:a;y.set(x,C<-.001?a:C>.001?s:_)}c.set(d,f.map(x=>{const v=y.get(x);if(!v)return x;const C=f.filter(T=>y.get(T)===v),_=(C.indexOf(x)+1)/(C.length+1),k=Sm(w,v,_);return{...x,anchor:k,top:k.y,height:0}}))}return c}function Nl(e,t,r){const n=new Set(t.map(s=>s.id));if(!n.has(e))return new Set;const o=new Set([e]);let i=!0;for(;i;){i=!1;for(const s of t)!o.has(s.id)&&(o.has(s.parent??"")||s.id.startsWith(`${e}.`))&&(o.add(s.id),i=!0)}const a=new Set(o);for(const s of r)o.has(s.source)&&n.has(s.target)&&a.add(s.target),o.has(s.target)&&n.has(s.source)&&a.add(s.source);return a}const rt='"Helvetica Neue", Helvetica, sans-serif';let Et;const an=new Map;function Sn(e,t){const r=`${t}|${e}`,n=an.get(r);if(n!==void 0)return n;Et===void 0&&(Et=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let o;return Et?(Et.font=t,o=Et.measureText(e).width):o=e.length*(parseFloat(t)||16)*.55,an.size>5e3&&an.clear(),an.set(r,o),o}function k0(e,t,r){const n=[];for(const o of String(e).split(`
153
- `)){const i=o.split(/\s+/).filter(Boolean);if(!i.length){n.push("");continue}let a="";for(const s of i){const u=a?`${a} ${s}`:s;!a||Sn(u,t)<=r?a=u:(n.push(a),a=s)}n.push(a)}return n}const P0=e=>e.stopPropagation();function A0({id:e,rect:t,label:r,labelLayer:n,style:o,onSelect:i,onCollapse:a,selected:s=!1}){const u=t.x2-t.x1,c=t.y2-t.y1,l=o.borderWidth,d=o.borderStyle==="dashed"?`${l*4} ${l*2}`:o.borderStyle==="dotted"?`${l} ${l}`:void 0,f=t.x1+u/2,p=o.labelPosition==="top"?t.y1+o.labelMargin-o.fontSize/2:o.labelPosition==="bottom"?t.y2-o.labelMargin+o.fontSize/2:t.y1+c/2,m=r?Sn(r,`bold ${o.fontSize}px ${rt}`):0,g=o.fontSize/5,b=r||s&&a?h.jsxs("g",{className:"flow-sdk-container-label","data-node-id":e,children:[s&&a&&h.jsx("foreignObject",{x:f+m/2+g+8,y:p-24,width:48,height:48,"data-flow-content-toggle":"",style:{pointerEvents:"auto"},children:h.jsx(je,{label:"Show icon",children:h.jsx(be,{"aria-label":"Show icon",icon:h.jsx(J.PiCircleFill,{}),variant:"ghost",style:{width:48,height:48,color:o.textColor},onClick:w=>{w.stopPropagation(),a(e)}})})}),r&&h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:f-m/2-g,y:p-o.fontSize/2-g,width:m+2*g,height:o.fontSize+2*g,fill:o.textColor==="transparent"?"transparent":o.labelBg}),h.jsx("text",{x:f,y:p,fill:o.textColor,fontSize:o.fontSize,fontWeight:"bold",fontFamily:rt,style:{fontSize:o.fontSize,fontWeight:"bold",fontFamily:rt},textAnchor:"middle",dominantBaseline:"central",children:r})]})]}):null;return h.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:P0,onClick:w=>{w.stopPropagation(),i==null||i(e,{shiftKey:w.shiftKey,ctrlKey:w.ctrlKey,metaKey:w.metaKey,altKey:w.altKey})},children:[h.jsx("rect",{x:t.x1,y:t.y1,width:u,height:c,rx:o.borderRadius,ry:o.borderRadius,fill:o.bgColor,fillOpacity:o.bgOpacity,stroke:o.borderColor,strokeWidth:o.borderStyle==="double"?l/3:l,strokeDasharray:d}),o.borderStyle==="double"&&h.jsx("rect",{x:t.x1+l*2/3,y:t.y1+l*2/3,width:Math.max(0,u-l*4/3),height:Math.max(0,c-l*4/3),rx:Math.max(0,o.borderRadius-l*2/3),ry:Math.max(0,o.borderRadius-l*2/3),fill:"none",stroke:o.borderColor,strokeWidth:l/3}),o.animated&&l>0&&h.jsx(_m,{variant:o.animationVariant,x:t.x1,y:t.y1,width:u,height:c,radius:o.borderRadius,color:o.animationColor||o.borderColor,strokeWidth:Math.max(8,l*1.6)}),n&&b?Bt.createPortal(b,n):b]})}const T0=S.memo(A0),pn=45,km=70,Zr=15,Pm=50;function Am(e,t,r=pn){const n=`${r}px ${rt}`,o=e?k0(e,n,200*r/pn):[],i=t?48+(o.length?12:0):0,a=i+Math.max(0,...o.map(c=>Sn(c,n))),s=Math.max(o.length*r,t?48:0),u=o.length||t?2*Zr:0;return{lines:o,iconWidth:i,contentWidth:a,contentHeight:s,width:a+u,height:s+u}}const gn=6,Tm=3,Lu=Math.max(Math.pow(gn*13.37,.9),29)*Tm,Om=gn*Tm*2,cn=80,O0=2*cn+Lu*.3+100,I0=36+2*Math.max(80,Om+Lu*.3);function wu(e){return e.sourceProperty!==void 0||e.targetProperty!==void 0}function Cu(e,t){return t==="auto"||(t==="properties"?wu(e):!wu(e))}function ut(e,t,r){return r!=="properties"||e!=="root"||t.some(n=>(n.source===e||n.target===e)&&wu(n))}function M0(e,t,r,n=!1,o){if(!n)return{nodes:e,edges:t};const i=e.filter(s=>ut(s.id,t,r)&&(!o||o.has(s.id))),a=new Set(i.map(s=>s.id));return{nodes:i,edges:t.filter(s=>Cu(s,r)&&a.has(s.source)&&a.has(s.target))}}const q0=500,N0="32 18",$0=e=>e.stopPropagation();function L0({id:e,edgeData:t,validationIssue:r,edgeType:n="rounded-orthogonal",edgeRadius:o,customEdgeTypes:i,source:a,target:s,sourceProperty:u,targetProperty:c,sourceY:l,targetY:d,sourcePort:f,targetPort:p,propertyMode:m=!1,dir:g,turn:b,labelAtTarget:w,labelFraction:y,color:x,labelBg:v,labelLayer:C,label:_,dashed:k,animated:T,inverted:P,loopIndex:j=0,onSelect:R}){const E=t==null?void 0:t.icon,M=m?pn:km,{lines:I,iconWidth:N,contentWidth:O,contentHeight:W}=S.useMemo(()=>Am(_,E,M),[_,E,M]),z=S.useMemo(()=>{const Y={srcDist:cn,tgtDist:cn,arrowGap:Om,arrowSize:Lu,headShape:m&&(P?l!==void 0||f:d!==void 0||p)?"square":"triangle",radius:o??(w?40:q0),arrowAt:P?"source":"target",labelTargetLength:w?O+2*Zr:void 0,labelFraction:w?y:void 0},ce=l!==void 0||d!==void 0||!!f||!!p,X=ql(a,s,g,l,d,0),U=l===void 0&&d===void 0&&(g==="downward"||g==="upward"),Z=f??{...X.sourcePoint,side:U?g==="upward"?"top":"bottom":g==="leftward"?"left":"right"},ae=p??{...X.targetPoint,side:U?g==="upward"?"bottom":"top":g==="leftward"?"right":"left"},ue=a.x===s.x&&a.y===s.y,de=f||p?_0(Z,ae,{...Y,srcDist:18,tgtDist:18},n):ce?Il(a,s,g,l,d,b,{...Y,srcDist:18,tgtDist:18,radius:o??Math.min(Y.radius,40)}):ue?j0(a,j,{...Y,srcDist:0,tgtDist:0}):Ml(a,s,g,b,Y);if(!de)return null;const Ee=ql(a,s,g,l,d,ce?18:cn);f&&(Ee.sourcePoint=dt(f,18)),p&&(Ee.targetPoint=dt(p,18));const ge=Object.prototype.hasOwnProperty.call(i??{},n)?i==null?void 0:i[n]:void 0;if(ge){const He={rightward:"LR",leftward:"RL",downward:"TB",upward:"BT"};return ge({edge:t??{id:e,source:"",target:""},source:{...a},target:{...s},...Ee,direction:He[g],sourceY:l,targetY:d,inverted:!!P,defaultGeometry:de})??de}return ue||f||p?de:n==="straight"?ce?jm(Ee.sourcePoint,Ee.targetPoint,Y):Em([a,s],a,s,Y):n==="bezier"?E0(Ee.sourcePoint,Ee.targetPoint,ce?g==="leftward"?"leftward":"rightward":g,Y):n==="orthogonal"?ce?Il(a,s,g,l,d,b,{...Y,srcDist:18,tgtDist:18,radius:0}):Ml(a,s,g,b,{...Y,radius:0}):de},[a,e,t,n,o,i,s,m,l,d,f,p,g,b,P,j,w,y,O]);if(!z)return null;const re=(g==="rightward"||g==="leftward")&&!Object.prototype.hasOwnProperty.call(i??{},n)&&!(m&&(l!==void 0||d!==void 0||f||p)),te=re?`translate(${z.label.x} ${z.label.y-W/2-2*Zr})`:`translate(${z.label.x} ${z.label.y}) rotate(${z.label.angle}) translate(${w||Object.prototype.hasOwnProperty.call(i??{},n)?0:Pm} 0)`,he=r!=null&&r.startsWith("Unverified:")?"#b45309":"#dc2626",me=r?he:x,K=r?h.jsxs("g",{className:"flow-sdk-edge-validation",role:"img","aria-label":r,transform:`translate(${z.label.x} ${z.label.y-I.length*M/2-55})`,children:[h.jsx("title",{children:r}),h.jsx(qr,{name:"PiWarningCircleFill",svg:!0,size:48,x:-24,y:-24,color:he})]}):null,q=T&&(t==null?void 0:t.edgeAnimationVariant)==="traveling",L=!q&&(k||T)?N0:void 0,G=T&&!q?`flow-sdk-edge-anim${P?" flow-sdk-edge-anim-rev":""}`:void 0;let B=null;if(I.length||E){const Y=O,ce=W;B=h.jsxs("g",{className:"flow-sdk-edge-label","data-label-transform":te,"data-label-horizontal":re||void 0,"data-edge-id":e,"data-source-property":u,"data-target-property":c,transform:te,children:[h.jsx("rect",{x:-Y/2-Zr,y:-ce/2-Zr,width:Y+2*Zr,height:ce+2*Zr,fill:x==="transparent"?"transparent":v}),h.jsx("text",{fill:x,fontSize:M,style:{fontSize:M,fontFamily:rt},fontFamily:rt,textAnchor:"middle",dominantBaseline:"central",children:I.map((X,U)=>h.jsx("tspan",{x:N/2,y:(U-(I.length-1)/2)*M,children:X},U))}),E&&h.jsxs("g",{className:"flow-sdk-edge-icon",opacity:x==="transparent"?0:1,children:[h.jsx("title",{children:_?`Edge icon: ${_}`:"Edge icon"}),h.jsx("rect",{x:-Y/2,y:-24,width:48,height:48,fill:"transparent"}),h.jsx(qr,{name:E,svg:!0,size:48,x:-Y/2,y:-24,color:x})]})]})}return h.jsxs("g",{className:"flow-sdk-edge","data-edge-id":e,"data-source-property":u,"data-target-property":c,"data-validation":r?r.startsWith("Unverified:")?"unverified":"invalid":void 0,"aria-label":r,onPointerDown:$0,onClick:Y=>{Y.stopPropagation(),R==null||R(e)},children:[h.jsx("path",{d:z.d,fill:"none",stroke:me,strokeWidth:gn,strokeOpacity:q?.35:void 0,strokeDasharray:L,className:G}),q&&h.jsx(p0,{path:z.d,color:me,width:gn*1.6,reversed:P}),z.arrow&&h.jsx("path",{d:z.arrow,fill:me}),C&&B?Bt.createPortal(B,C):B,C&&K?Bt.createPortal(K,C):K,h.jsx("path",{className:"flow-sdk-edge-hit",d:z.d,fill:"none",stroke:"transparent"})]})}const $l=S.memo(L0),Ll=(e,t)=>e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top;function F0(e){const t=e.querySelector(".flow-sdk-labels"),r=t==null?void 0:t.getScreenCTM();if(!t||!r)return;const n=r.inverse(),o=(c,l=0)=>{const d=c.getBoundingClientRect(),f=new DOMPoint(d.left,d.top).matrixTransform(n),p=new DOMPoint(d.right,d.bottom).matrixTransform(n);return{left:f.x-l,right:p.x+l,top:f.y-l,bottom:p.y+l}},i=[...e.querySelectorAll(".flow-sdk-node, .flow-sdk-node button")].filter(c=>{const l=c.getBoundingClientRect(),d=getComputedStyle(c);return l.width>0&&l.height>0&&d.visibility!=="hidden"&&d.opacity!=="0"}).map(c=>o(c,24));for(const c of t.querySelectorAll(".flow-sdk-container-label"))i.push(o(c,12));const a=[...t.querySelectorAll(".flow-sdk-edge-label")];for(const c of a)c.setAttribute("transform",c.dataset.labelTransform??"");const s=new Map(a.map(c=>[c,o(c,8)])),u=new Map([...e.querySelectorAll(".flow-sdk-edge")].map(c=>[c.dataset.edgeId,c.querySelector("path")]));for(const c of a){const l=c.dataset.labelHorizontal==="true",d=s.get(c);s.delete(c);const f=k=>i.some(T=>Ll(k,T))||[...s.values()].some(T=>Ll(k,T));if(!l&&!f(d)){s.set(c,d);continue}const p=u.get(c.dataset.edgeId),m=c.querySelector("rect");if(!p||!m)continue;const g=m.getBBox(),b=p.getTotalLength();if(!Number.isFinite(b)||b<=0)continue;const w=(d.left+d.right)/2,y=(d.top+d.bottom)/2,x=Math.min(256,Math.max(16,Math.ceil(b/24))),v=Array.from({length:x+1},(k,T)=>p.getPointAtLength(b*T/x)),_=Array.from({length:x+1},(k,T)=>{const P=b*T/x,j=v[T],R=l?{x:j.x,y:j.y-g.height/2-15}:j,E=p.getPointAtLength(Math.max(0,P-2)),M=p.getPointAtLength(Math.min(b,P+2));let I=Math.atan2(M.y-E.y,M.x-E.x)*180/Math.PI;I>90&&(I-=180),I<-90&&(I+=180);const N=Math.abs(I)<1;l&&(I=0);const O=I*Math.PI/180,W=Math.abs(Math.cos(O))*g.width+Math.abs(Math.sin(O))*g.height,z=Math.abs(Math.sin(O))*g.width+Math.abs(Math.cos(O))*g.height;return{point:R,angle:I,straight:N,score:Math.hypot(R.x-w,R.y-y),bounds:{left:R.x-W/2-8,right:R.x+W/2+8,top:R.y-z/2-8,bottom:R.y+z/2+8}}}).sort((k,T)=>k.score-T.score).find(k=>!f(k.bounds)&&(!l||k.straight&&!v.some(T=>T.x>k.bounds.left&&T.x<k.bounds.right&&T.y>k.bounds.top&&T.y<k.bounds.bottom)));_?(c.setAttribute("transform",`translate(${_.point.x} ${_.point.y}) rotate(${_.angle})`),s.set(c,_.bounds)):s.set(c,d)}}var sn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function B0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Fu(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Xn,Fl;function D0(){if(Fl)return Xn;Fl=1;function e(){this.__data__=[],this.size=0}return Xn=e,Xn}var Qn,Bl;function mt(){if(Bl)return Qn;Bl=1;function e(t,r){return t===r||t!==t&&r!==r}return Qn=e,Qn}var eo,Dl;function En(){if(Dl)return eo;Dl=1;var e=mt();function t(r,n){for(var o=r.length;o--;)if(e(r[o][0],n))return o;return-1}return eo=t,eo}var ro,zl;function z0(){if(zl)return ro;zl=1;var e=En(),t=Array.prototype,r=t.splice;function n(o){var i=this.__data__,a=e(i,o);if(a<0)return!1;var s=i.length-1;return a==s?i.pop():r.call(i,a,1),--this.size,!0}return ro=n,ro}var to,Vl;function V0(){if(Vl)return to;Vl=1;var e=En();function t(r){var n=this.__data__,o=e(n,r);return o<0?void 0:n[o][1]}return to=t,to}var no,Wl;function W0(){if(Wl)return no;Wl=1;var e=En();function t(r){return e(this.__data__,r)>-1}return no=t,no}var oo,Gl;function G0(){if(Gl)return oo;Gl=1;var e=En();function t(r,n){var o=this.__data__,i=e(o,r);return i<0?(++this.size,o.push([r,n])):o[i][1]=n,this}return oo=t,oo}var io,Ul;function jn(){if(Ul)return io;Ul=1;var e=D0(),t=z0(),r=V0(),n=W0(),o=G0();function i(a){var s=-1,u=a==null?0:a.length;for(this.clear();++s<u;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,io=i,io}var ao,Hl;function U0(){if(Hl)return ao;Hl=1;var e=jn();function t(){this.__data__=new e,this.size=0}return ao=t,ao}var so,Kl;function H0(){if(Kl)return so;Kl=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return so=e,so}var co,Jl;function K0(){if(Jl)return co;Jl=1;function e(t){return this.__data__.get(t)}return co=e,co}var uo,Zl;function J0(){if(Zl)return uo;Zl=1;function e(t){return this.__data__.has(t)}return uo=e,uo}var lo,Yl;function Im(){if(Yl)return lo;Yl=1;var e=typeof sn=="object"&&sn&&sn.Object===Object&&sn;return lo=e,lo}var fo,Xl;function Sr(){if(Xl)return fo;Xl=1;var e=Im(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return fo=r,fo}var ho,Ql;function bt(){if(Ql)return ho;Ql=1;var e=Sr(),t=e.Symbol;return ho=t,ho}var po,ed;function Z0(){if(ed)return po;ed=1;var e=bt(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,o=e?e.toStringTag:void 0;function i(a){var s=r.call(a,o),u=a[o];try{a[o]=void 0;var c=!0}catch{}var l=n.call(a);return c&&(s?a[o]=u:delete a[o]),l}return po=i,po}var go,rd;function Y0(){if(rd)return go;rd=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return go=r,go}var yo,td;function tt(){if(td)return yo;td=1;var e=bt(),t=Z0(),r=Y0(),n="[object Null]",o="[object Undefined]",i=e?e.toStringTag:void 0;function a(s){return s==null?s===void 0?o:n:i&&i in Object(s)?t(s):r(s)}return yo=a,yo}var mo,nd;function vr(){if(nd)return mo;nd=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return mo=e,mo}var bo,od;function Qt(){if(od)return bo;od=1;var e=tt(),t=vr(),r="[object AsyncFunction]",n="[object Function]",o="[object GeneratorFunction]",i="[object Proxy]";function a(s){if(!t(s))return!1;var u=e(s);return u==n||u==o||u==r||u==i}return bo=a,bo}var vo,id;function X0(){if(id)return vo;id=1;var e=Sr(),t=e["__core-js_shared__"];return vo=t,vo}var xo,ad;function Q0(){if(ad)return xo;ad=1;var e=X0(),t=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!t&&t in n}return xo=r,xo}var wo,sd;function Mm(){if(sd)return wo;sd=1;var e=Function.prototype,t=e.toString;function r(n){if(n!=null){try{return t.call(n)}catch{}try{return n+""}catch{}}return""}return wo=r,wo}var Co,cd;function ew(){if(cd)return Co;cd=1;var e=Qt(),t=Q0(),r=vr(),n=Mm(),o=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,a=Function.prototype,s=Object.prototype,u=a.toString,c=s.hasOwnProperty,l=RegExp("^"+u.call(c).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(f){if(!r(f)||t(f))return!1;var p=e(f)?l:i;return p.test(n(f))}return Co=d,Co}var _o,ud;function rw(){if(ud)return _o;ud=1;function e(t,r){return t==null?void 0:t[r]}return _o=e,_o}var So,ld;function nt(){if(ld)return So;ld=1;var e=ew(),t=rw();function r(n,o){var i=t(n,o);return e(i)?i:void 0}return So=r,So}var Eo,dd;function Bu(){if(dd)return Eo;dd=1;var e=nt(),t=Sr(),r=e(t,"Map");return Eo=r,Eo}var jo,fd;function Rn(){if(fd)return jo;fd=1;var e=nt(),t=e(Object,"create");return jo=t,jo}var Ro,hd;function tw(){if(hd)return Ro;hd=1;var e=Rn();function t(){this.__data__=e?e(null):{},this.size=0}return Ro=t,Ro}var ko,pd;function nw(){if(pd)return ko;pd=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return ko=e,ko}var Po,gd;function ow(){if(gd)return Po;gd=1;var e=Rn(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function o(i){var a=this.__data__;if(e){var s=a[i];return s===t?void 0:s}return n.call(a,i)?a[i]:void 0}return Po=o,Po}var Ao,yd;function iw(){if(yd)return Ao;yd=1;var e=Rn(),t=Object.prototype,r=t.hasOwnProperty;function n(o){var i=this.__data__;return e?i[o]!==void 0:r.call(i,o)}return Ao=n,Ao}var To,md;function aw(){if(md)return To;md=1;var e=Rn(),t="__lodash_hash_undefined__";function r(n,o){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=e&&o===void 0?t:o,this}return To=r,To}var Oo,bd;function sw(){if(bd)return Oo;bd=1;var e=tw(),t=nw(),r=ow(),n=iw(),o=aw();function i(a){var s=-1,u=a==null?0:a.length;for(this.clear();++s<u;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Oo=i,Oo}var Io,vd;function cw(){if(vd)return Io;vd=1;var e=sw(),t=jn(),r=Bu();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return Io=n,Io}var Mo,xd;function uw(){if(xd)return Mo;xd=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return Mo=e,Mo}var qo,wd;function kn(){if(wd)return qo;wd=1;var e=uw();function t(r,n){var o=r.__data__;return e(n)?o[typeof n=="string"?"string":"hash"]:o.map}return qo=t,qo}var No,Cd;function lw(){if(Cd)return No;Cd=1;var e=kn();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return No=t,No}var $o,_d;function dw(){if(_d)return $o;_d=1;var e=kn();function t(r){return e(this,r).get(r)}return $o=t,$o}var Lo,Sd;function fw(){if(Sd)return Lo;Sd=1;var e=kn();function t(r){return e(this,r).has(r)}return Lo=t,Lo}var Fo,Ed;function hw(){if(Ed)return Fo;Ed=1;var e=kn();function t(r,n){var o=e(this,r),i=o.size;return o.set(r,n),this.size+=o.size==i?0:1,this}return Fo=t,Fo}var Bo,jd;function Du(){if(jd)return Bo;jd=1;var e=cw(),t=lw(),r=dw(),n=fw(),o=hw();function i(a){var s=-1,u=a==null?0:a.length;for(this.clear();++s<u;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Bo=i,Bo}var Do,Rd;function pw(){if(Rd)return Do;Rd=1;var e=jn(),t=Bu(),r=Du(),n=200;function o(i,a){var s=this.__data__;if(s instanceof e){var u=s.__data__;if(!t||u.length<n-1)return u.push([i,a]),this.size=++s.size,this;s=this.__data__=new r(u)}return s.set(i,a),this.size=s.size,this}return Do=o,Do}var zo,kd;function Pn(){if(kd)return zo;kd=1;var e=jn(),t=U0(),r=H0(),n=K0(),o=J0(),i=pw();function a(s){var u=this.__data__=new e(s);this.size=u.size}return a.prototype.clear=t,a.prototype.delete=r,a.prototype.get=n,a.prototype.has=o,a.prototype.set=i,zo=a,zo}var Vo,Pd;function zu(){if(Pd)return Vo;Pd=1;function e(t,r){for(var n=-1,o=t==null?0:t.length;++n<o&&r(t[n],n,t)!==!1;);return t}return Vo=e,Vo}var Wo,Ad;function qm(){if(Ad)return Wo;Ad=1;var e=nt(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return Wo=t,Wo}var Go,Td;function An(){if(Td)return Go;Td=1;var e=qm();function t(r,n,o){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[n]=o}return Go=t,Go}var Uo,Od;function Tn(){if(Od)return Uo;Od=1;var e=An(),t=mt(),r=Object.prototype,n=r.hasOwnProperty;function o(i,a,s){var u=i[a];(!(n.call(i,a)&&t(u,s))||s===void 0&&!(a in i))&&e(i,a,s)}return Uo=o,Uo}var Ho,Id;function en(){if(Id)return Ho;Id=1;var e=Tn(),t=An();function r(n,o,i,a){var s=!i;i||(i={});for(var u=-1,c=o.length;++u<c;){var l=o[u],d=a?a(i[l],n[l],l,i,n):void 0;d===void 0&&(d=n[l]),s?t(i,l,d):e(i,l,d)}return i}return Ho=r,Ho}var Ko,Md;function gw(){if(Md)return Ko;Md=1;function e(t,r){for(var n=-1,o=Array(t);++n<t;)o[n]=r(n);return o}return Ko=e,Ko}var Jo,qd;function Pr(){if(qd)return Jo;qd=1;function e(t){return t!=null&&typeof t=="object"}return Jo=e,Jo}var Zo,Nd;function yw(){if(Nd)return Zo;Nd=1;var e=tt(),t=Pr(),r="[object Arguments]";function n(o){return t(o)&&e(o)==r}return Zo=n,Zo}var Yo,$d;function rn(){if($d)return Yo;$d=1;var e=yw(),t=Pr(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=e((function(){return arguments})())?e:function(a){return t(a)&&n.call(a,"callee")&&!o.call(a,"callee")};return Yo=i,Yo}var Xo,Ld;function Ye(){if(Ld)return Xo;Ld=1;var e=Array.isArray;return Xo=e,Xo}var Tt={exports:{}},Qo,Fd;function mw(){if(Fd)return Qo;Fd=1;function e(){return!1}return Qo=e,Qo}Tt.exports;var Bd;function vt(){return Bd||(Bd=1,(function(e,t){var r=Sr(),n=mw(),o=t&&!t.nodeType&&t,i=o&&!0&&e&&!e.nodeType&&e,a=i&&i.exports===o,s=a?r.Buffer:void 0,u=s?s.isBuffer:void 0,c=u||n;e.exports=c})(Tt,Tt.exports)),Tt.exports}var ei,Dd;function On(){if(Dd)return ei;Dd=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,o){var i=typeof n;return o=o??e,!!o&&(i=="number"||i!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<o}return ei=r,ei}var ri,zd;function Vu(){if(zd)return ri;zd=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return ri=t,ri}var ti,Vd;function bw(){if(Vd)return ti;Vd=1;var e=tt(),t=Vu(),r=Pr(),n="[object Arguments]",o="[object Array]",i="[object Boolean]",a="[object Date]",s="[object Error]",u="[object Function]",c="[object Map]",l="[object Number]",d="[object Object]",f="[object RegExp]",p="[object Set]",m="[object String]",g="[object WeakMap]",b="[object ArrayBuffer]",w="[object DataView]",y="[object Float32Array]",x="[object Float64Array]",v="[object Int8Array]",C="[object Int16Array]",_="[object Int32Array]",k="[object Uint8Array]",T="[object Uint8ClampedArray]",P="[object Uint16Array]",j="[object Uint32Array]",R={};R[y]=R[x]=R[v]=R[C]=R[_]=R[k]=R[T]=R[P]=R[j]=!0,R[n]=R[o]=R[b]=R[i]=R[w]=R[a]=R[s]=R[u]=R[c]=R[l]=R[d]=R[f]=R[p]=R[m]=R[g]=!1;function E(M){return r(M)&&t(M.length)&&!!R[e(M)]}return ti=E,ti}var ni,Wd;function In(){if(Wd)return ni;Wd=1;function e(t){return function(r){return t(r)}}return ni=e,ni}var Ot={exports:{}};Ot.exports;var Gd;function Wu(){return Gd||(Gd=1,(function(e,t){var r=Im(),n=t&&!t.nodeType&&t,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,a=i&&r.process,s=(function(){try{var u=o&&o.require&&o.require("util").types;return u||a&&a.binding&&a.binding("util")}catch{}})();e.exports=s})(Ot,Ot.exports)),Ot.exports}var oi,Ud;function tn(){if(Ud)return oi;Ud=1;var e=bw(),t=In(),r=Wu(),n=r&&r.isTypedArray,o=n?t(n):e;return oi=o,oi}var ii,Hd;function Nm(){if(Hd)return ii;Hd=1;var e=gw(),t=rn(),r=Ye(),n=vt(),o=On(),i=tn(),a=Object.prototype,s=a.hasOwnProperty;function u(c,l){var d=r(c),f=!d&&t(c),p=!d&&!f&&n(c),m=!d&&!f&&!p&&i(c),g=d||f||p||m,b=g?e(c.length,String):[],w=b.length;for(var y in c)(l||s.call(c,y))&&!(g&&(y=="length"||p&&(y=="offset"||y=="parent")||m&&(y=="buffer"||y=="byteLength"||y=="byteOffset")||o(y,w)))&&b.push(y);return b}return ii=u,ii}var ai,Kd;function Mn(){if(Kd)return ai;Kd=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,o=typeof n=="function"&&n.prototype||e;return r===o}return ai=t,ai}var si,Jd;function $m(){if(Jd)return si;Jd=1;function e(t,r){return function(n){return t(r(n))}}return si=e,si}var ci,Zd;function vw(){if(Zd)return ci;Zd=1;var e=$m(),t=e(Object.keys,Object);return ci=t,ci}var ui,Yd;function Gu(){if(Yd)return ui;Yd=1;var e=Mn(),t=vw(),r=Object.prototype,n=r.hasOwnProperty;function o(i){if(!e(i))return t(i);var a=[];for(var s in Object(i))n.call(i,s)&&s!="constructor"&&a.push(s);return a}return ui=o,ui}var li,Xd;function Nr(){if(Xd)return li;Xd=1;var e=Qt(),t=Vu();function r(n){return n!=null&&t(n.length)&&!e(n)}return li=r,li}var di,Qd;function Hr(){if(Qd)return di;Qd=1;var e=Nm(),t=Gu(),r=Nr();function n(o){return r(o)?e(o):t(o)}return di=n,di}var fi,ef;function xw(){if(ef)return fi;ef=1;var e=en(),t=Hr();function r(n,o){return n&&e(o,t(o),n)}return fi=r,fi}var hi,rf;function ww(){if(rf)return hi;rf=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return hi=e,hi}var pi,tf;function Cw(){if(tf)return pi;tf=1;var e=vr(),t=Mn(),r=ww(),n=Object.prototype,o=n.hasOwnProperty;function i(a){if(!e(a))return r(a);var s=t(a),u=[];for(var c in a)c=="constructor"&&(s||!o.call(a,c))||u.push(c);return u}return pi=i,pi}var gi,nf;function ot(){if(nf)return gi;nf=1;var e=Nm(),t=Cw(),r=Nr();function n(o){return r(o)?e(o,!0):t(o)}return gi=n,gi}var yi,of;function _w(){if(of)return yi;of=1;var e=en(),t=ot();function r(n,o){return n&&e(o,t(o),n)}return yi=r,yi}var It={exports:{}};It.exports;var af;function Lm(){return af||(af=1,(function(e,t){var r=Sr(),n=t&&!t.nodeType&&t,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,a=i?r.Buffer:void 0,s=a?a.allocUnsafe:void 0;function u(c,l){if(l)return c.slice();var d=c.length,f=s?s(d):new c.constructor(d);return c.copy(f),f}e.exports=u})(It,It.exports)),It.exports}var mi,sf;function Fm(){if(sf)return mi;sf=1;function e(t,r){var n=-1,o=t.length;for(r||(r=Array(o));++n<o;)r[n]=t[n];return r}return mi=e,mi}var bi,cf;function Bm(){if(cf)return bi;cf=1;function e(t,r){for(var n=-1,o=t==null?0:t.length,i=0,a=[];++n<o;){var s=t[n];r(s,n,t)&&(a[i++]=s)}return a}return bi=e,bi}var vi,uf;function Dm(){if(uf)return vi;uf=1;function e(){return[]}return vi=e,vi}var xi,lf;function Uu(){if(lf)return xi;lf=1;var e=Bm(),t=Dm(),r=Object.prototype,n=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,i=o?function(a){return a==null?[]:(a=Object(a),e(o(a),function(s){return n.call(a,s)}))}:t;return xi=i,xi}var wi,df;function Sw(){if(df)return wi;df=1;var e=en(),t=Uu();function r(n,o){return e(n,t(n),o)}return wi=r,wi}var Ci,ff;function Hu(){if(ff)return Ci;ff=1;function e(t,r){for(var n=-1,o=r.length,i=t.length;++n<o;)t[i+n]=r[n];return t}return Ci=e,Ci}var _i,hf;function qn(){if(hf)return _i;hf=1;var e=$m(),t=e(Object.getPrototypeOf,Object);return _i=t,_i}var Si,pf;function zm(){if(pf)return Si;pf=1;var e=Hu(),t=qn(),r=Uu(),n=Dm(),o=Object.getOwnPropertySymbols,i=o?function(a){for(var s=[];a;)e(s,r(a)),a=t(a);return s}:n;return Si=i,Si}var Ei,gf;function Ew(){if(gf)return Ei;gf=1;var e=en(),t=zm();function r(n,o){return e(n,t(n),o)}return Ei=r,Ei}var ji,yf;function Vm(){if(yf)return ji;yf=1;var e=Hu(),t=Ye();function r(n,o,i){var a=o(n);return t(n)?a:e(a,i(n))}return ji=r,ji}var Ri,mf;function Wm(){if(mf)return Ri;mf=1;var e=Vm(),t=Uu(),r=Hr();function n(o){return e(o,r,t)}return Ri=n,Ri}var ki,bf;function jw(){if(bf)return ki;bf=1;var e=Vm(),t=zm(),r=ot();function n(o){return e(o,r,t)}return ki=n,ki}var Pi,vf;function Rw(){if(vf)return Pi;vf=1;var e=nt(),t=Sr(),r=e(t,"DataView");return Pi=r,Pi}var Ai,xf;function kw(){if(xf)return Ai;xf=1;var e=nt(),t=Sr(),r=e(t,"Promise");return Ai=r,Ai}var Ti,wf;function Gm(){if(wf)return Ti;wf=1;var e=nt(),t=Sr(),r=e(t,"Set");return Ti=r,Ti}var Oi,Cf;function Pw(){if(Cf)return Oi;Cf=1;var e=nt(),t=Sr(),r=e(t,"WeakMap");return Oi=r,Oi}var Ii,_f;function xt(){if(_f)return Ii;_f=1;var e=Rw(),t=Bu(),r=kw(),n=Gm(),o=Pw(),i=tt(),a=Mm(),s="[object Map]",u="[object Object]",c="[object Promise]",l="[object Set]",d="[object WeakMap]",f="[object DataView]",p=a(e),m=a(t),g=a(r),b=a(n),w=a(o),y=i;return(e&&y(new e(new ArrayBuffer(1)))!=f||t&&y(new t)!=s||r&&y(r.resolve())!=c||n&&y(new n)!=l||o&&y(new o)!=d)&&(y=function(x){var v=i(x),C=v==u?x.constructor:void 0,_=C?a(C):"";if(_)switch(_){case p:return f;case m:return s;case g:return c;case b:return l;case w:return d}return v}),Ii=y,Ii}var Mi,Sf;function Aw(){if(Sf)return Mi;Sf=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var o=n.length,i=new n.constructor(o);return o&&typeof n[0]=="string"&&t.call(n,"index")&&(i.index=n.index,i.input=n.input),i}return Mi=r,Mi}var qi,Ef;function Um(){if(Ef)return qi;Ef=1;var e=Sr(),t=e.Uint8Array;return qi=t,qi}var Ni,jf;function Ku(){if(jf)return Ni;jf=1;var e=Um();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return Ni=t,Ni}var $i,Rf;function Tw(){if(Rf)return $i;Rf=1;var e=Ku();function t(r,n){var o=n?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return $i=t,$i}var Li,kf;function Ow(){if(kf)return Li;kf=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return Li=t,Li}var Fi,Pf;function Iw(){if(Pf)return Fi;Pf=1;var e=bt(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(o){return r?Object(r.call(o)):{}}return Fi=n,Fi}var Bi,Af;function Hm(){if(Af)return Bi;Af=1;var e=Ku();function t(r,n){var o=n?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return Bi=t,Bi}var Di,Tf;function Mw(){if(Tf)return Di;Tf=1;var e=Ku(),t=Tw(),r=Ow(),n=Iw(),o=Hm(),i="[object Boolean]",a="[object Date]",s="[object Map]",u="[object Number]",c="[object RegExp]",l="[object Set]",d="[object String]",f="[object Symbol]",p="[object ArrayBuffer]",m="[object DataView]",g="[object Float32Array]",b="[object Float64Array]",w="[object Int8Array]",y="[object Int16Array]",x="[object Int32Array]",v="[object Uint8Array]",C="[object Uint8ClampedArray]",_="[object Uint16Array]",k="[object Uint32Array]";function T(P,j,R){var E=P.constructor;switch(j){case p:return e(P);case i:case a:return new E(+P);case m:return t(P,R);case g:case b:case w:case y:case x:case v:case C:case _:case k:return o(P,R);case s:return new E;case u:case d:return new E(P);case c:return r(P);case l:return new E;case f:return n(P)}}return Di=T,Di}var zi,Of;function Km(){if(Of)return zi;Of=1;var e=vr(),t=Object.create,r=(function(){function n(){}return function(o){if(!e(o))return{};if(t)return t(o);n.prototype=o;var i=new n;return n.prototype=void 0,i}})();return zi=r,zi}var Vi,If;function Jm(){if(If)return Vi;If=1;var e=Km(),t=qn(),r=Mn();function n(o){return typeof o.constructor=="function"&&!r(o)?e(t(o)):{}}return Vi=n,Vi}var Wi,Mf;function qw(){if(Mf)return Wi;Mf=1;var e=xt(),t=Pr(),r="[object Map]";function n(o){return t(o)&&e(o)==r}return Wi=n,Wi}var Gi,qf;function Nw(){if(qf)return Gi;qf=1;var e=qw(),t=In(),r=Wu(),n=r&&r.isMap,o=n?t(n):e;return Gi=o,Gi}var Ui,Nf;function $w(){if(Nf)return Ui;Nf=1;var e=xt(),t=Pr(),r="[object Set]";function n(o){return t(o)&&e(o)==r}return Ui=n,Ui}var Hi,$f;function Lw(){if($f)return Hi;$f=1;var e=$w(),t=In(),r=Wu(),n=r&&r.isSet,o=n?t(n):e;return Hi=o,Hi}var Ki,Lf;function Zm(){if(Lf)return Ki;Lf=1;var e=Pn(),t=zu(),r=Tn(),n=xw(),o=_w(),i=Lm(),a=Fm(),s=Sw(),u=Ew(),c=Wm(),l=jw(),d=xt(),f=Aw(),p=Mw(),m=Jm(),g=Ye(),b=vt(),w=Nw(),y=vr(),x=Lw(),v=Hr(),C=ot(),_=1,k=2,T=4,P="[object Arguments]",j="[object Array]",R="[object Boolean]",E="[object Date]",M="[object Error]",I="[object Function]",N="[object GeneratorFunction]",O="[object Map]",W="[object Number]",z="[object Object]",re="[object RegExp]",te="[object Set]",he="[object String]",me="[object Symbol]",K="[object WeakMap]",q="[object ArrayBuffer]",L="[object DataView]",G="[object Float32Array]",B="[object Float64Array]",Y="[object Int8Array]",ce="[object Int16Array]",X="[object Int32Array]",U="[object Uint8Array]",Z="[object Uint8ClampedArray]",ae="[object Uint16Array]",ue="[object Uint32Array]",de={};de[P]=de[j]=de[q]=de[L]=de[R]=de[E]=de[G]=de[B]=de[Y]=de[ce]=de[X]=de[O]=de[W]=de[z]=de[re]=de[te]=de[he]=de[me]=de[U]=de[Z]=de[ae]=de[ue]=!0,de[M]=de[I]=de[K]=!1;function Ee(ge,He,Le,Xe,ur,Ge){var Ne,xe=He&_,Ie=He&k,$e=He&T;if(Le&&(Ne=ur?Le(ge,Xe,ur,Ge):Le(ge)),Ne!==void 0)return Ne;if(!y(ge))return ge;var tr=g(ge);if(tr){if(Ne=f(ge),!xe)return a(ge,Ne)}else{var Je=d(ge),Ze=Je==I||Je==N;if(b(ge))return i(ge,xe);if(Je==z||Je==P||Ze&&!ur){if(Ne=Ie||Ze?{}:m(ge),!xe)return Ie?u(ge,o(Ne,ge)):s(ge,n(Ne,ge))}else{if(!de[Je])return ur?ge:{};Ne=p(ge,Je,xe)}}Ge||(Ge=new e);var fr=Ge.get(ge);if(fr)return fr;Ge.set(ge,Ne),x(ge)?ge.forEach(function(ir){Ne.add(Ee(ir,He,Le,ir,ge,Ge))}):w(ge)&&ge.forEach(function(ir,ar){Ne.set(ar,Ee(ir,He,Le,ar,ge,Ge))});var wr=$e?Ie?l:c:Ie?C:v,Ce=tr?void 0:wr(ge);return t(Ce||ge,function(ir,ar){Ce&&(ar=ir,ir=ge[ar]),r(Ne,ar,Ee(ir,He,Le,ar,ge,Ge))}),Ne}return Ki=Ee,Ki}var Ji,Ff;function Fw(){if(Ff)return Ji;Ff=1;var e=Zm(),t=4;function r(n){return e(n,t)}return Ji=r,Ji}var Zi,Bf;function Ju(){if(Bf)return Zi;Bf=1;function e(t){return function(){return t}}return Zi=e,Zi}var Yi,Df;function Bw(){if(Df)return Yi;Df=1;function e(t){return function(r,n,o){for(var i=-1,a=Object(r),s=o(r),u=s.length;u--;){var c=s[t?u:++i];if(n(a[c],c,a)===!1)break}return r}}return Yi=e,Yi}var Xi,zf;function Zu(){if(zf)return Xi;zf=1;var e=Bw(),t=e();return Xi=t,Xi}var Qi,Vf;function Yu(){if(Vf)return Qi;Vf=1;var e=Zu(),t=Hr();function r(n,o){return n&&e(n,o,t)}return Qi=r,Qi}var ea,Wf;function Dw(){if(Wf)return ea;Wf=1;var e=Nr();function t(r,n){return function(o,i){if(o==null)return o;if(!e(o))return r(o,i);for(var a=o.length,s=n?a:-1,u=Object(o);(n?s--:++s<a)&&i(u[s],s,u)!==!1;);return o}}return ea=t,ea}var ra,Gf;function Nn(){if(Gf)return ra;Gf=1;var e=Yu(),t=Dw(),r=t(e);return ra=r,ra}var ta,Uf;function it(){if(Uf)return ta;Uf=1;function e(t){return t}return ta=e,ta}var na,Hf;function Ym(){if(Hf)return na;Hf=1;var e=it();function t(r){return typeof r=="function"?r:e}return na=t,na}var oa,Kf;function Xm(){if(Kf)return oa;Kf=1;var e=zu(),t=Nn(),r=Ym(),n=Ye();function o(i,a){var s=n(i)?e:t;return s(i,r(a))}return oa=o,oa}var ia,Jf;function Qm(){return Jf||(Jf=1,ia=Xm()),ia}var aa,Zf;function zw(){if(Zf)return aa;Zf=1;var e=Nn();function t(r,n){var o=[];return e(r,function(i,a,s){n(i,a,s)&&o.push(i)}),o}return aa=t,aa}var sa,Yf;function Vw(){if(Yf)return sa;Yf=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return sa=t,sa}var ca,Xf;function Ww(){if(Xf)return ca;Xf=1;function e(t){return this.__data__.has(t)}return ca=e,ca}var ua,Qf;function eb(){if(Qf)return ua;Qf=1;var e=Du(),t=Vw(),r=Ww();function n(o){var i=-1,a=o==null?0:o.length;for(this.__data__=new e;++i<a;)this.add(o[i])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,ua=n,ua}var la,eh;function Gw(){if(eh)return la;eh=1;function e(t,r){for(var n=-1,o=t==null?0:t.length;++n<o;)if(r(t[n],n,t))return!0;return!1}return la=e,la}var da,rh;function rb(){if(rh)return da;rh=1;function e(t,r){return t.has(r)}return da=e,da}var fa,th;function tb(){if(th)return fa;th=1;var e=eb(),t=Gw(),r=rb(),n=1,o=2;function i(a,s,u,c,l,d){var f=u&n,p=a.length,m=s.length;if(p!=m&&!(f&&m>p))return!1;var g=d.get(a),b=d.get(s);if(g&&b)return g==s&&b==a;var w=-1,y=!0,x=u&o?new e:void 0;for(d.set(a,s),d.set(s,a);++w<p;){var v=a[w],C=s[w];if(c)var _=f?c(C,v,w,s,a,d):c(v,C,w,a,s,d);if(_!==void 0){if(_)continue;y=!1;break}if(x){if(!t(s,function(k,T){if(!r(x,T)&&(v===k||l(v,k,u,c,d)))return x.push(T)})){y=!1;break}}else if(!(v===C||l(v,C,u,c,d))){y=!1;break}}return d.delete(a),d.delete(s),y}return fa=i,fa}var ha,nh;function Uw(){if(nh)return ha;nh=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(o,i){n[++r]=[i,o]}),n}return ha=e,ha}var pa,oh;function Xu(){if(oh)return pa;oh=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(o){n[++r]=o}),n}return pa=e,pa}var ga,ih;function Hw(){if(ih)return ga;ih=1;var e=bt(),t=Um(),r=mt(),n=tb(),o=Uw(),i=Xu(),a=1,s=2,u="[object Boolean]",c="[object Date]",l="[object Error]",d="[object Map]",f="[object Number]",p="[object RegExp]",m="[object Set]",g="[object String]",b="[object Symbol]",w="[object ArrayBuffer]",y="[object DataView]",x=e?e.prototype:void 0,v=x?x.valueOf:void 0;function C(_,k,T,P,j,R,E){switch(T){case y:if(_.byteLength!=k.byteLength||_.byteOffset!=k.byteOffset)return!1;_=_.buffer,k=k.buffer;case w:return!(_.byteLength!=k.byteLength||!R(new t(_),new t(k)));case u:case c:case f:return r(+_,+k);case l:return _.name==k.name&&_.message==k.message;case p:case g:return _==k+"";case d:var M=o;case m:var I=P&a;if(M||(M=i),_.size!=k.size&&!I)return!1;var N=E.get(_);if(N)return N==k;P|=s,E.set(_,k);var O=n(M(_),M(k),P,j,R,E);return E.delete(_),O;case b:if(v)return v.call(_)==v.call(k)}return!1}return ga=C,ga}var ya,ah;function Kw(){if(ah)return ya;ah=1;var e=Wm(),t=1,r=Object.prototype,n=r.hasOwnProperty;function o(i,a,s,u,c,l){var d=s&t,f=e(i),p=f.length,m=e(a),g=m.length;if(p!=g&&!d)return!1;for(var b=p;b--;){var w=f[b];if(!(d?w in a:n.call(a,w)))return!1}var y=l.get(i),x=l.get(a);if(y&&x)return y==a&&x==i;var v=!0;l.set(i,a),l.set(a,i);for(var C=d;++b<p;){w=f[b];var _=i[w],k=a[w];if(u)var T=d?u(k,_,w,a,i,l):u(_,k,w,i,a,l);if(!(T===void 0?_===k||c(_,k,s,u,l):T)){v=!1;break}C||(C=w=="constructor")}if(v&&!C){var P=i.constructor,j=a.constructor;P!=j&&"constructor"in i&&"constructor"in a&&!(typeof P=="function"&&P instanceof P&&typeof j=="function"&&j instanceof j)&&(v=!1)}return l.delete(i),l.delete(a),v}return ya=o,ya}var ma,sh;function Jw(){if(sh)return ma;sh=1;var e=Pn(),t=tb(),r=Hw(),n=Kw(),o=xt(),i=Ye(),a=vt(),s=tn(),u=1,c="[object Arguments]",l="[object Array]",d="[object Object]",f=Object.prototype,p=f.hasOwnProperty;function m(g,b,w,y,x,v){var C=i(g),_=i(b),k=C?l:o(g),T=_?l:o(b);k=k==c?d:k,T=T==c?d:T;var P=k==d,j=T==d,R=k==T;if(R&&a(g)){if(!a(b))return!1;C=!0,P=!1}if(R&&!P)return v||(v=new e),C||s(g)?t(g,b,w,y,x,v):r(g,b,k,w,y,x,v);if(!(w&u)){var E=P&&p.call(g,"__wrapped__"),M=j&&p.call(b,"__wrapped__");if(E||M){var I=E?g.value():g,N=M?b.value():b;return v||(v=new e),x(I,N,w,y,v)}}return R?(v||(v=new e),n(g,b,w,y,x,v)):!1}return ma=m,ma}var ba,ch;function nb(){if(ch)return ba;ch=1;var e=Jw(),t=Pr();function r(n,o,i,a,s){return n===o?!0:n==null||o==null||!t(n)&&!t(o)?n!==n&&o!==o:e(n,o,i,a,r,s)}return ba=r,ba}var va,uh;function Zw(){if(uh)return va;uh=1;var e=Pn(),t=nb(),r=1,n=2;function o(i,a,s,u){var c=s.length,l=c,d=!u;if(i==null)return!l;for(i=Object(i);c--;){var f=s[c];if(d&&f[2]?f[1]!==i[f[0]]:!(f[0]in i))return!1}for(;++c<l;){f=s[c];var p=f[0],m=i[p],g=f[1];if(d&&f[2]){if(m===void 0&&!(p in i))return!1}else{var b=new e;if(u)var w=u(m,g,p,i,a,b);if(!(w===void 0?t(g,m,r|n,u,b):w))return!1}}return!0}return va=o,va}var xa,lh;function ob(){if(lh)return xa;lh=1;var e=vr();function t(r){return r===r&&!e(r)}return xa=t,xa}var wa,dh;function Yw(){if(dh)return wa;dh=1;var e=ob(),t=Hr();function r(n){for(var o=t(n),i=o.length;i--;){var a=o[i],s=n[a];o[i]=[a,s,e(s)]}return o}return wa=r,wa}var Ca,fh;function ib(){if(fh)return Ca;fh=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return Ca=e,Ca}var _a,hh;function Xw(){if(hh)return _a;hh=1;var e=Zw(),t=Yw(),r=ib();function n(o){var i=t(o);return i.length==1&&i[0][2]?r(i[0][0],i[0][1]):function(a){return a===o||e(a,o,i)}}return _a=n,_a}var Sa,ph;function wt(){if(ph)return Sa;ph=1;var e=tt(),t=Pr(),r="[object Symbol]";function n(o){return typeof o=="symbol"||t(o)&&e(o)==r}return Sa=n,Sa}var Ea,gh;function Qu(){if(gh)return Ea;gh=1;var e=Ye(),t=wt(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function o(i,a){if(e(i))return!1;var s=typeof i;return s=="number"||s=="symbol"||s=="boolean"||i==null||t(i)?!0:n.test(i)||!r.test(i)||a!=null&&i in Object(a)}return Ea=o,Ea}var ja,yh;function Qw(){if(yh)return ja;yh=1;var e=Du(),t="Expected a function";function r(n,o){if(typeof n!="function"||o!=null&&typeof o!="function")throw new TypeError(t);var i=function(){var a=arguments,s=o?o.apply(this,a):a[0],u=i.cache;if(u.has(s))return u.get(s);var c=n.apply(this,a);return i.cache=u.set(s,c)||u,c};return i.cache=new(r.Cache||e),i}return r.Cache=e,ja=r,ja}var Ra,mh;function e1(){if(mh)return Ra;mh=1;var e=Qw(),t=500;function r(n){var o=e(n,function(a){return i.size===t&&i.clear(),a}),i=o.cache;return o}return Ra=r,Ra}var ka,bh;function r1(){if(bh)return ka;bh=1;var e=e1(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(o){var i=[];return o.charCodeAt(0)===46&&i.push(""),o.replace(t,function(a,s,u,c){i.push(u?c.replace(r,"$1"):s||a)}),i});return ka=n,ka}var Pa,vh;function $n(){if(vh)return Pa;vh=1;function e(t,r){for(var n=-1,o=t==null?0:t.length,i=Array(o);++n<o;)i[n]=r(t[n],n,t);return i}return Pa=e,Pa}var Aa,xh;function t1(){if(xh)return Aa;xh=1;var e=bt(),t=$n(),r=Ye(),n=wt(),o=e?e.prototype:void 0,i=o?o.toString:void 0;function a(s){if(typeof s=="string")return s;if(r(s))return t(s,a)+"";if(n(s))return i?i.call(s):"";var u=s+"";return u=="0"&&1/s==-1/0?"-0":u}return Aa=a,Aa}var Ta,wh;function ab(){if(wh)return Ta;wh=1;var e=t1();function t(r){return r==null?"":e(r)}return Ta=t,Ta}var Oa,Ch;function Ln(){if(Ch)return Oa;Ch=1;var e=Ye(),t=Qu(),r=r1(),n=ab();function o(i,a){return e(i)?i:t(i,a)?[i]:r(n(i))}return Oa=o,Oa}var Ia,_h;function nn(){if(_h)return Ia;_h=1;var e=wt();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return Ia=t,Ia}var Ma,Sh;function Fn(){if(Sh)return Ma;Sh=1;var e=Ln(),t=nn();function r(n,o){o=e(o,n);for(var i=0,a=o.length;n!=null&&i<a;)n=n[t(o[i++])];return i&&i==a?n:void 0}return Ma=r,Ma}var qa,Eh;function n1(){if(Eh)return qa;Eh=1;var e=Fn();function t(r,n,o){var i=r==null?void 0:e(r,n);return i===void 0?o:i}return qa=t,qa}var Na,jh;function o1(){if(jh)return Na;jh=1;function e(t,r){return t!=null&&r in Object(t)}return Na=e,Na}var $a,Rh;function sb(){if(Rh)return $a;Rh=1;var e=Ln(),t=rn(),r=Ye(),n=On(),o=Vu(),i=nn();function a(s,u,c){u=e(u,s);for(var l=-1,d=u.length,f=!1;++l<d;){var p=i(u[l]);if(!(f=s!=null&&c(s,p)))break;s=s[p]}return f||++l!=d?f:(d=s==null?0:s.length,!!d&&o(d)&&n(p,d)&&(r(s)||t(s)))}return $a=a,$a}var La,kh;function cb(){if(kh)return La;kh=1;var e=o1(),t=sb();function r(n,o){return n!=null&&t(n,o,e)}return La=r,La}var Fa,Ph;function i1(){if(Ph)return Fa;Ph=1;var e=nb(),t=n1(),r=cb(),n=Qu(),o=ob(),i=ib(),a=nn(),s=1,u=2;function c(l,d){return n(l)&&o(d)?i(a(l),d):function(f){var p=t(f,l);return p===void 0&&p===d?r(f,l):e(d,p,s|u)}}return Fa=c,Fa}var Ba,Ah;function ub(){if(Ah)return Ba;Ah=1;function e(t){return function(r){return r==null?void 0:r[t]}}return Ba=e,Ba}var Da,Th;function a1(){if(Th)return Da;Th=1;var e=Fn();function t(r){return function(n){return e(n,r)}}return Da=t,Da}var za,Oh;function s1(){if(Oh)return za;Oh=1;var e=ub(),t=a1(),r=Qu(),n=nn();function o(i){return r(i)?e(n(i)):t(i)}return za=o,za}var Va,Ih;function $r(){if(Ih)return Va;Ih=1;var e=Xw(),t=i1(),r=it(),n=Ye(),o=s1();function i(a){return typeof a=="function"?a:a==null?r:typeof a=="object"?n(a)?t(a[0],a[1]):e(a):o(a)}return Va=i,Va}var Wa,Mh;function lb(){if(Mh)return Wa;Mh=1;var e=Bm(),t=zw(),r=$r(),n=Ye();function o(i,a){var s=n(i)?e:t;return s(i,r(a,3))}return Wa=o,Wa}var Ga,qh;function c1(){if(qh)return Ga;qh=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,o){return n!=null&&t.call(n,o)}return Ga=r,Ga}var Ua,Nh;function db(){if(Nh)return Ua;Nh=1;var e=c1(),t=sb();function r(n,o){return n!=null&&t(n,o,e)}return Ua=r,Ua}var Ha,$h;function u1(){if($h)return Ha;$h=1;var e=Gu(),t=xt(),r=rn(),n=Ye(),o=Nr(),i=vt(),a=Mn(),s=tn(),u="[object Map]",c="[object Set]",l=Object.prototype,d=l.hasOwnProperty;function f(p){if(p==null)return!0;if(o(p)&&(n(p)||typeof p=="string"||typeof p.splice=="function"||i(p)||s(p)||r(p)))return!p.length;var m=t(p);if(m==u||m==c)return!p.size;if(a(p))return!e(p).length;for(var g in p)if(d.call(p,g))return!1;return!0}return Ha=f,Ha}var Ka,Lh;function fb(){if(Lh)return Ka;Lh=1;function e(t){return t===void 0}return Ka=e,Ka}var Ja,Fh;function hb(){if(Fh)return Ja;Fh=1;var e=Nn(),t=Nr();function r(n,o){var i=-1,a=t(n)?Array(n.length):[];return e(n,function(s,u,c){a[++i]=o(s,u,c)}),a}return Ja=r,Ja}var Za,Bh;function pb(){if(Bh)return Za;Bh=1;var e=$n(),t=$r(),r=hb(),n=Ye();function o(i,a){var s=n(i)?e:r;return s(i,t(a,3))}return Za=o,Za}var Ya,Dh;function l1(){if(Dh)return Ya;Dh=1;function e(t,r,n,o){var i=-1,a=t==null?0:t.length;for(o&&a&&(n=t[++i]);++i<a;)n=r(n,t[i],i,t);return n}return Ya=e,Ya}var Xa,zh;function d1(){if(zh)return Xa;zh=1;function e(t,r,n,o,i){return i(t,function(a,s,u){n=o?(o=!1,a):r(n,a,s,u)}),n}return Xa=e,Xa}var Qa,Vh;function gb(){if(Vh)return Qa;Vh=1;var e=l1(),t=Nn(),r=$r(),n=d1(),o=Ye();function i(a,s,u){var c=o(a)?e:n,l=arguments.length<3;return c(a,r(s,4),u,l,t)}return Qa=i,Qa}var es,Wh;function f1(){if(Wh)return es;Wh=1;var e=tt(),t=Ye(),r=Pr(),n="[object String]";function o(i){return typeof i=="string"||!t(i)&&r(i)&&e(i)==n}return es=o,es}var rs,Gh;function h1(){if(Gh)return rs;Gh=1;var e=ub(),t=e("length");return rs=t,rs}var ts,Uh;function p1(){if(Uh)return ts;Uh=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=t+r+n,i="\\ufe0e\\ufe0f",a="\\u200d",s=RegExp("["+a+e+o+i+"]");function u(c){return s.test(c)}return ts=u,ts}var ns,Hh;function g1(){if(Hh)return ns;Hh=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=t+r+n,i="\\ufe0e\\ufe0f",a="["+e+"]",s="["+o+"]",u="\\ud83c[\\udffb-\\udfff]",c="(?:"+s+"|"+u+")",l="[^"+e+"]",d="(?:\\ud83c[\\udde6-\\uddff]){2}",f="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",m=c+"?",g="["+i+"]?",b="(?:"+p+"(?:"+[l,d,f].join("|")+")"+g+m+")*",w=g+m+b,y="(?:"+[l+s+"?",s,d,f,a].join("|")+")",x=RegExp(u+"(?="+u+")|"+y+w,"g");function v(C){for(var _=x.lastIndex=0;x.test(C);)++_;return _}return ns=v,ns}var os,Kh;function y1(){if(Kh)return os;Kh=1;var e=h1(),t=p1(),r=g1();function n(o){return t(o)?r(o):e(o)}return os=n,os}var is,Jh;function m1(){if(Jh)return is;Jh=1;var e=Gu(),t=xt(),r=Nr(),n=f1(),o=y1(),i="[object Map]",a="[object Set]";function s(u){if(u==null)return 0;if(r(u))return n(u)?o(u):u.length;var c=t(u);return c==i||c==a?u.size:e(u).length}return is=s,is}var as,Zh;function b1(){if(Zh)return as;Zh=1;var e=zu(),t=Km(),r=Yu(),n=$r(),o=qn(),i=Ye(),a=vt(),s=Qt(),u=vr(),c=tn();function l(d,f,p){var m=i(d),g=m||a(d)||c(d);if(f=n(f,4),p==null){var b=d&&d.constructor;g?p=m?new b:[]:u(d)?p=s(b)?t(o(d)):{}:p={}}return(g?e:r)(d,function(w,y,x){return f(p,w,y,x)}),p}return as=l,as}var ss,Yh;function v1(){if(Yh)return ss;Yh=1;var e=bt(),t=rn(),r=Ye(),n=e?e.isConcatSpreadable:void 0;function o(i){return r(i)||t(i)||!!(n&&i&&i[n])}return ss=o,ss}var cs,Xh;function el(){if(Xh)return cs;Xh=1;var e=Hu(),t=v1();function r(n,o,i,a,s){var u=-1,c=n.length;for(i||(i=t),s||(s=[]);++u<c;){var l=n[u];o>0&&i(l)?o>1?r(l,o-1,i,a,s):e(s,l):a||(s[s.length]=l)}return s}return cs=r,cs}var us,Qh;function x1(){if(Qh)return us;Qh=1;function e(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}return us=e,us}var ls,ep;function yb(){if(ep)return ls;ep=1;var e=x1(),t=Math.max;function r(n,o,i){return o=t(o===void 0?n.length-1:o,0),function(){for(var a=arguments,s=-1,u=t(a.length-o,0),c=Array(u);++s<u;)c[s]=a[o+s];s=-1;for(var l=Array(o+1);++s<o;)l[s]=a[s];return l[o]=i(c),e(n,this,l)}}return ls=r,ls}var ds,rp;function w1(){if(rp)return ds;rp=1;var e=Ju(),t=qm(),r=it(),n=t?function(o,i){return t(o,"toString",{configurable:!0,enumerable:!1,value:e(i),writable:!0})}:r;return ds=n,ds}var fs,tp;function C1(){if(tp)return fs;tp=1;var e=800,t=16,r=Date.now;function n(o){var i=0,a=0;return function(){var s=r(),u=t-(s-a);if(a=s,u>0){if(++i>=e)return arguments[0]}else i=0;return o.apply(void 0,arguments)}}return fs=n,fs}var hs,np;function mb(){if(np)return hs;np=1;var e=w1(),t=C1(),r=t(e);return hs=r,hs}var ps,op;function Bn(){if(op)return ps;op=1;var e=it(),t=yb(),r=mb();function n(o,i){return r(t(o,i,e),o+"")}return ps=n,ps}var gs,ip;function bb(){if(ip)return gs;ip=1;function e(t,r,n,o){for(var i=t.length,a=n+(o?1:-1);o?a--:++a<i;)if(r(t[a],a,t))return a;return-1}return gs=e,gs}var ys,ap;function _1(){if(ap)return ys;ap=1;function e(t){return t!==t}return ys=e,ys}var ms,sp;function S1(){if(sp)return ms;sp=1;function e(t,r,n){for(var o=n-1,i=t.length;++o<i;)if(t[o]===r)return o;return-1}return ms=e,ms}var bs,cp;function E1(){if(cp)return bs;cp=1;var e=bb(),t=_1(),r=S1();function n(o,i,a){return i===i?r(o,i,a):e(o,t,a)}return bs=n,bs}var vs,up;function j1(){if(up)return vs;up=1;var e=E1();function t(r,n){var o=r==null?0:r.length;return!!o&&e(r,n,0)>-1}return vs=t,vs}var xs,lp;function R1(){if(lp)return xs;lp=1;function e(t,r,n){for(var o=-1,i=t==null?0:t.length;++o<i;)if(n(r,t[o]))return!0;return!1}return xs=e,xs}var ws,dp;function k1(){if(dp)return ws;dp=1;function e(){}return ws=e,ws}var Cs,fp;function P1(){if(fp)return Cs;fp=1;var e=Gm(),t=k1(),r=Xu(),n=1/0,o=e&&1/r(new e([,-0]))[1]==n?function(i){return new e(i)}:t;return Cs=o,Cs}var _s,hp;function A1(){if(hp)return _s;hp=1;var e=eb(),t=j1(),r=R1(),n=rb(),o=P1(),i=Xu(),a=200;function s(u,c,l){var d=-1,f=t,p=u.length,m=!0,g=[],b=g;if(l)m=!1,f=r;else if(p>=a){var w=c?null:o(u);if(w)return i(w);m=!1,f=n,b=new e}else b=c?[]:g;e:for(;++d<p;){var y=u[d],x=c?c(y):y;if(y=l||y!==0?y:0,m&&x===x){for(var v=b.length;v--;)if(b[v]===x)continue e;c&&b.push(x),g.push(y)}else f(b,x,l)||(b!==g&&b.push(x),g.push(y))}return g}return _s=s,_s}var Ss,pp;function vb(){if(pp)return Ss;pp=1;var e=Nr(),t=Pr();function r(n){return t(n)&&e(n)}return Ss=r,Ss}var Es,gp;function T1(){if(gp)return Es;gp=1;var e=el(),t=Bn(),r=A1(),n=vb(),o=t(function(i){return r(e(i,1,n,!0))});return Es=o,Es}var js,yp;function O1(){if(yp)return js;yp=1;var e=$n();function t(r,n){return e(n,function(o){return r[o]})}return js=t,js}var Rs,mp;function xb(){if(mp)return Rs;mp=1;var e=O1(),t=Hr();function r(n){return n==null?[]:e(n,t(n))}return Rs=r,Rs}var ks,bp;function xr(){if(bp)return ks;bp=1;var e;if(typeof Fu=="function")try{e={clone:Fw(),constant:Ju(),each:Qm(),filter:lb(),has:db(),isArray:Ye(),isEmpty:u1(),isFunction:Qt(),isUndefined:fb(),keys:Hr(),map:pb(),reduce:gb(),size:m1(),transform:b1(),union:T1(),values:xb()}}catch{}return e||(e=window._),ks=e,ks}var Ps,vp;function rl(){if(vp)return Ps;vp=1;var e=xr();Ps=o;var t="\0",r="\0",n="";function o(l){this._isDirected=e.has(l,"directed")?l.directed:!0,this._isMultigraph=e.has(l,"multigraph")?l.multigraph:!1,this._isCompound=e.has(l,"compound")?l.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(l){return this._label=l,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultNodeLabelFn=l,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._in[d])})},o.prototype.sinks=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._out[d])})},o.prototype.setNodes=function(l,d){var f=arguments,p=this;return e.each(l,function(m){f.length>1?p.setNode(m,d):p.setNode(m)}),this},o.prototype.setNode=function(l,d){return e.has(this._nodes,l)?(arguments.length>1&&(this._nodes[l]=d),this):(this._nodes[l]=arguments.length>1?d:this._defaultNodeLabelFn(l),this._isCompound&&(this._parent[l]=r,this._children[l]={},this._children[r][l]=!0),this._in[l]={},this._preds[l]={},this._out[l]={},this._sucs[l]={},++this._nodeCount,this)},o.prototype.node=function(l){return this._nodes[l]},o.prototype.hasNode=function(l){return e.has(this._nodes,l)},o.prototype.removeNode=function(l){var d=this;if(e.has(this._nodes,l)){var f=function(p){d.removeEdge(d._edgeObjs[p])};delete this._nodes[l],this._isCompound&&(this._removeFromParentsChildList(l),delete this._parent[l],e.each(this.children(l),function(p){d.setParent(p)}),delete this._children[l]),e.each(e.keys(this._in[l]),f),delete this._in[l],delete this._preds[l],e.each(e.keys(this._out[l]),f),delete this._out[l],delete this._sucs[l],--this._nodeCount}return this},o.prototype.setParent=function(l,d){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(d))d=r;else{d+="";for(var f=d;!e.isUndefined(f);f=this.parent(f))if(f===l)throw new Error("Setting "+d+" as parent of "+l+" would create a cycle");this.setNode(d)}return this.setNode(l),this._removeFromParentsChildList(l),this._parent[l]=d,this._children[d][l]=!0,this},o.prototype._removeFromParentsChildList=function(l){delete this._children[this._parent[l]][l]},o.prototype.parent=function(l){if(this._isCompound){var d=this._parent[l];if(d!==r)return d}},o.prototype.children=function(l){if(e.isUndefined(l)&&(l=r),this._isCompound){var d=this._children[l];if(d)return e.keys(d)}else{if(l===r)return this.nodes();if(this.hasNode(l))return[]}},o.prototype.predecessors=function(l){var d=this._preds[l];if(d)return e.keys(d)},o.prototype.successors=function(l){var d=this._sucs[l];if(d)return e.keys(d)},o.prototype.neighbors=function(l){var d=this.predecessors(l);if(d)return e.union(d,this.successors(l))},o.prototype.isLeaf=function(l){var d;return this.isDirected()?d=this.successors(l):d=this.neighbors(l),d.length===0},o.prototype.filterNodes=function(l){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var f=this;e.each(this._nodes,function(g,b){l(b)&&d.setNode(b,g)}),e.each(this._edgeObjs,function(g){d.hasNode(g.v)&&d.hasNode(g.w)&&d.setEdge(g,f.edge(g))});var p={};function m(g){var b=f.parent(g);return b===void 0||d.hasNode(b)?(p[g]=b,b):b in p?p[b]:m(b)}return this._isCompound&&e.each(d.nodes(),function(g){d.setParent(g,m(g))}),d},o.prototype.setDefaultEdgeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultEdgeLabelFn=l,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(l,d){var f=this,p=arguments;return e.reduce(l,function(m,g){return p.length>1?f.setEdge(m,g,d):f.setEdge(m,g),g}),this},o.prototype.setEdge=function(){var l,d,f,p,m=!1,g=arguments[0];typeof g=="object"&&g!==null&&"v"in g?(l=g.v,d=g.w,f=g.name,arguments.length===2&&(p=arguments[1],m=!0)):(l=g,d=arguments[1],f=arguments[3],arguments.length>2&&(p=arguments[2],m=!0)),l=""+l,d=""+d,e.isUndefined(f)||(f=""+f);var b=s(this._isDirected,l,d,f);if(e.has(this._edgeLabels,b))return m&&(this._edgeLabels[b]=p),this;if(!e.isUndefined(f)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(l),this.setNode(d),this._edgeLabels[b]=m?p:this._defaultEdgeLabelFn(l,d,f);var w=u(this._isDirected,l,d,f);return l=w.v,d=w.w,Object.freeze(w),this._edgeObjs[b]=w,i(this._preds[d],l),i(this._sucs[l],d),this._in[d][b]=w,this._out[l][b]=w,this._edgeCount++,this},o.prototype.edge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):s(this._isDirected,l,d,f);return this._edgeLabels[p]},o.prototype.hasEdge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):s(this._isDirected,l,d,f);return e.has(this._edgeLabels,p)},o.prototype.removeEdge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):s(this._isDirected,l,d,f),m=this._edgeObjs[p];return m&&(l=m.v,d=m.w,delete this._edgeLabels[p],delete this._edgeObjs[p],a(this._preds[d],l),a(this._sucs[l],d),delete this._in[d][p],delete this._out[l][p],this._edgeCount--),this},o.prototype.inEdges=function(l,d){var f=this._in[l];if(f){var p=e.values(f);return d?e.filter(p,function(m){return m.v===d}):p}},o.prototype.outEdges=function(l,d){var f=this._out[l];if(f){var p=e.values(f);return d?e.filter(p,function(m){return m.w===d}):p}},o.prototype.nodeEdges=function(l,d){var f=this.inEdges(l,d);if(f)return f.concat(this.outEdges(l,d))};function i(l,d){l[d]?l[d]++:l[d]=1}function a(l,d){--l[d]||delete l[d]}function s(l,d,f,p){var m=""+d,g=""+f;if(!l&&m>g){var b=m;m=g,g=b}return m+n+g+n+(e.isUndefined(p)?t:p)}function u(l,d,f,p){var m=""+d,g=""+f;if(!l&&m>g){var b=m;m=g,g=b}var w={v:m,w:g};return p&&(w.name=p),w}function c(l,d){return s(l,d.v,d.w,d.name)}return Ps}var As,xp;function I1(){return xp||(xp=1,As="2.1.8"),As}var Ts,wp;function M1(){return wp||(wp=1,Ts={Graph:rl(),version:I1()}),Ts}var Os,Cp;function q1(){if(Cp)return Os;Cp=1;var e=xr(),t=rl();Os={write:r,read:i};function r(a){var s={options:{directed:a.isDirected(),multigraph:a.isMultigraph(),compound:a.isCompound()},nodes:n(a),edges:o(a)};return e.isUndefined(a.graph())||(s.value=e.clone(a.graph())),s}function n(a){return e.map(a.nodes(),function(s){var u=a.node(s),c=a.parent(s),l={v:s};return e.isUndefined(u)||(l.value=u),e.isUndefined(c)||(l.parent=c),l})}function o(a){return e.map(a.edges(),function(s){var u=a.edge(s),c={v:s.v,w:s.w};return e.isUndefined(s.name)||(c.name=s.name),e.isUndefined(u)||(c.value=u),c})}function i(a){var s=new t(a.options).setGraph(a.value);return e.each(a.nodes,function(u){s.setNode(u.v,u.value),u.parent&&s.setParent(u.v,u.parent)}),e.each(a.edges,function(u){s.setEdge({v:u.v,w:u.w,name:u.name},u.value)}),s}return Os}var Is,_p;function N1(){if(_p)return Is;_p=1;var e=xr();Is=t;function t(r){var n={},o=[],i;function a(s){e.has(n,s)||(n[s]=!0,i.push(s),e.each(r.successors(s),a),e.each(r.predecessors(s),a))}return e.each(r.nodes(),function(s){i=[],a(s),i.length&&o.push(i)}),o}return Is}var Ms,Sp;function wb(){if(Sp)return Ms;Sp=1;var e=xr();Ms=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(r){return r.key})},t.prototype.has=function(r){return e.has(this._keyIndices,r)},t.prototype.priority=function(r){var n=this._keyIndices[r];if(n!==void 0)return this._arr[n].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(r,n){var o=this._keyIndices;if(r=String(r),!e.has(o,r)){var i=this._arr,a=i.length;return o[r]=a,i.push({key:r,priority:n}),this._decrease(a),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},t.prototype.decrease=function(r,n){var o=this._keyIndices[r];if(n>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+n);this._arr[o].priority=n,this._decrease(o)},t.prototype._heapify=function(r){var n=this._arr,o=2*r,i=o+1,a=r;o<n.length&&(a=n[o].priority<n[a].priority?o:a,i<n.length&&(a=n[i].priority<n[a].priority?i:a),a!==r&&(this._swap(r,a),this._heapify(a)))},t.prototype._decrease=function(r){for(var n=this._arr,o=n[r].priority,i;r!==0&&(i=r>>1,!(n[i].priority<o));)this._swap(r,i),r=i},t.prototype._swap=function(r,n){var o=this._arr,i=this._keyIndices,a=o[r],s=o[n];o[r]=s,o[n]=a,i[s.key]=r,i[a.key]=n},Ms}var qs,Ep;function Cb(){if(Ep)return qs;Ep=1;var e=xr(),t=wb();qs=n;var r=e.constant(1);function n(i,a,s,u){return o(i,String(a),s||r,u||function(c){return i.outEdges(c)})}function o(i,a,s,u){var c={},l=new t,d,f,p=function(m){var g=m.v!==d?m.v:m.w,b=c[g],w=s(m),y=f.distance+w;if(w<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+w);y<b.distance&&(b.distance=y,b.predecessor=d,l.decrease(g,y))};for(i.nodes().forEach(function(m){var g=m===a?0:Number.POSITIVE_INFINITY;c[m]={distance:g},l.add(m,g)});l.size()>0&&(d=l.removeMin(),f=c[d],f.distance!==Number.POSITIVE_INFINITY);)u(d).forEach(p);return c}return qs}var Ns,jp;function $1(){if(jp)return Ns;jp=1;var e=Cb(),t=xr();Ns=r;function r(n,o,i){return t.transform(n.nodes(),function(a,s){a[s]=e(n,s,o,i)},{})}return Ns}var $s,Rp;function _b(){if(Rp)return $s;Rp=1;var e=xr();$s=t;function t(r){var n=0,o=[],i={},a=[];function s(u){var c=i[u]={onStack:!0,lowlink:n,index:n++};if(o.push(u),r.successors(u).forEach(function(f){e.has(i,f)?i[f].onStack&&(c.lowlink=Math.min(c.lowlink,i[f].index)):(s(f),c.lowlink=Math.min(c.lowlink,i[f].lowlink))}),c.lowlink===c.index){var l=[],d;do d=o.pop(),i[d].onStack=!1,l.push(d);while(u!==d);a.push(l)}}return r.nodes().forEach(function(u){e.has(i,u)||s(u)}),a}return $s}var Ls,kp;function L1(){if(kp)return Ls;kp=1;var e=xr(),t=_b();Ls=r;function r(n){return e.filter(t(n),function(o){return o.length>1||o.length===1&&n.hasEdge(o[0],o[0])})}return Ls}var Fs,Pp;function F1(){if(Pp)return Fs;Pp=1;var e=xr();Fs=r;var t=e.constant(1);function r(o,i,a){return n(o,i||t,a||function(s){return o.outEdges(s)})}function n(o,i,a){var s={},u=o.nodes();return u.forEach(function(c){s[c]={},s[c][c]={distance:0},u.forEach(function(l){c!==l&&(s[c][l]={distance:Number.POSITIVE_INFINITY})}),a(c).forEach(function(l){var d=l.v===c?l.w:l.v,f=i(l);s[c][d]={distance:f,predecessor:c}})}),u.forEach(function(c){var l=s[c];u.forEach(function(d){var f=s[d];u.forEach(function(p){var m=f[c],g=l[p],b=f[p],w=m.distance+g.distance;w<b.distance&&(b.distance=w,b.predecessor=g.predecessor)})})}),s}return Fs}var Bs,Ap;function Sb(){if(Ap)return Bs;Ap=1;var e=xr();Bs=t,t.CycleException=r;function t(n){var o={},i={},a=[];function s(u){if(e.has(i,u))throw new r;e.has(o,u)||(i[u]=!0,o[u]=!0,e.each(n.predecessors(u),s),delete i[u],a.push(u))}if(e.each(n.sinks(),s),e.size(o)!==n.nodeCount())throw new r;return a}function r(){}return r.prototype=new Error,Bs}var Ds,Tp;function B1(){if(Tp)return Ds;Tp=1;var e=Sb();Ds=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return Ds}var zs,Op;function Eb(){if(Op)return zs;Op=1;var e=xr();zs=t;function t(n,o,i){e.isArray(o)||(o=[o]);var a=(n.isDirected()?n.successors:n.neighbors).bind(n),s=[],u={};return e.each(o,function(c){if(!n.hasNode(c))throw new Error("Graph does not have node: "+c);r(n,c,i==="post",u,a,s)}),s}function r(n,o,i,a,s,u){e.has(a,o)||(a[o]=!0,i||u.push(o),e.each(s(o),function(c){r(n,c,i,a,s,u)}),i&&u.push(o))}return zs}var Vs,Ip;function D1(){if(Ip)return Vs;Ip=1;var e=Eb();Vs=t;function t(r,n){return e(r,n,"post")}return Vs}var Ws,Mp;function z1(){if(Mp)return Ws;Mp=1;var e=Eb();Ws=t;function t(r,n){return e(r,n,"pre")}return Ws}var Gs,qp;function V1(){if(qp)return Gs;qp=1;var e=xr(),t=rl(),r=wb();Gs=n;function n(o,i){var a=new t,s={},u=new r,c;function l(f){var p=f.v===c?f.w:f.v,m=u.priority(p);if(m!==void 0){var g=i(f);g<m&&(s[p]=c,u.decrease(p,g))}}if(o.nodeCount()===0)return a;e.each(o.nodes(),function(f){u.add(f,Number.POSITIVE_INFINITY),a.setNode(f)}),u.decrease(o.nodes()[0],0);for(var d=!1;u.size()>0;){if(c=u.removeMin(),e.has(s,c))a.setEdge(c,s[c]);else{if(d)throw new Error("Input graph is not connected: "+o);d=!0}o.nodeEdges(c).forEach(l)}return a}return Gs}var Us,Np;function W1(){return Np||(Np=1,Us={components:N1(),dijkstra:Cb(),dijkstraAll:$1(),findCycles:L1(),floydWarshall:F1(),isAcyclic:B1(),postorder:D1(),preorder:z1(),prim:V1(),tarjan:_b(),topsort:Sb()}),Us}var Hs,$p;function G1(){if($p)return Hs;$p=1;var e=M1();return Hs={Graph:e.Graph,json:q1(),alg:W1(),version:e.version},Hs}var Ks,Lp;function _r(){if(Lp)return Ks;Lp=1;var e;if(typeof Fu=="function")try{e=G1()}catch{}return e||(e=window.graphlib),Ks=e,Ks}var Js,Fp;function U1(){if(Fp)return Js;Fp=1;var e=Zm(),t=1,r=4;function n(o){return e(o,t|r)}return Js=n,Js}var Zs,Bp;function Dn(){if(Bp)return Zs;Bp=1;var e=mt(),t=Nr(),r=On(),n=vr();function o(i,a,s){if(!n(s))return!1;var u=typeof a;return(u=="number"?t(s)&&r(a,s.length):u=="string"&&a in s)?e(s[a],i):!1}return Zs=o,Zs}var Ys,Dp;function H1(){if(Dp)return Ys;Dp=1;var e=Bn(),t=mt(),r=Dn(),n=ot(),o=Object.prototype,i=o.hasOwnProperty,a=e(function(s,u){s=Object(s);var c=-1,l=u.length,d=l>2?u[2]:void 0;for(d&&r(u[0],u[1],d)&&(l=1);++c<l;)for(var f=u[c],p=n(f),m=-1,g=p.length;++m<g;){var b=p[m],w=s[b];(w===void 0||t(w,o[b])&&!i.call(s,b))&&(s[b]=f[b])}return s});return Ys=a,Ys}var Xs,zp;function K1(){if(zp)return Xs;zp=1;var e=$r(),t=Nr(),r=Hr();function n(o){return function(i,a,s){var u=Object(i);if(!t(i)){var c=e(a,3);i=r(i),a=function(d){return c(u[d],d,u)}}var l=o(i,a,s);return l>-1?u[c?i[l]:l]:void 0}}return Xs=n,Xs}var Qs,Vp;function J1(){if(Vp)return Qs;Vp=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return Qs=t,Qs}var ec,Wp;function Z1(){if(Wp)return ec;Wp=1;var e=J1(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return ec=r,ec}var rc,Gp;function Y1(){if(Gp)return rc;Gp=1;var e=Z1(),t=vr(),r=wt(),n=NaN,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,a=/^0o[0-7]+$/i,s=parseInt;function u(c){if(typeof c=="number")return c;if(r(c))return n;if(t(c)){var l=typeof c.valueOf=="function"?c.valueOf():c;c=t(l)?l+"":l}if(typeof c!="string")return c===0?c:+c;c=e(c);var d=i.test(c);return d||a.test(c)?s(c.slice(2),d?2:8):o.test(c)?n:+c}return rc=u,rc}var tc,Up;function jb(){if(Up)return tc;Up=1;var e=Y1(),t=1/0,r=17976931348623157e292;function n(o){if(!o)return o===0?o:0;if(o=e(o),o===t||o===-t){var i=o<0?-1:1;return i*r}return o===o?o:0}return tc=n,tc}var nc,Hp;function X1(){if(Hp)return nc;Hp=1;var e=jb();function t(r){var n=e(r),o=n%1;return n===n?o?n-o:n:0}return nc=t,nc}var oc,Kp;function Q1(){if(Kp)return oc;Kp=1;var e=bb(),t=$r(),r=X1(),n=Math.max;function o(i,a,s){var u=i==null?0:i.length;if(!u)return-1;var c=s==null?0:r(s);return c<0&&(c=n(u+c,0)),e(i,t(a,3),c)}return oc=o,oc}var ic,Jp;function eC(){if(Jp)return ic;Jp=1;var e=K1(),t=Q1(),r=e(t);return ic=r,ic}var ac,Zp;function Rb(){if(Zp)return ac;Zp=1;var e=el();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return ac=t,ac}var sc,Yp;function rC(){if(Yp)return sc;Yp=1;var e=Zu(),t=Ym(),r=ot();function n(o,i){return o==null?o:e(o,t(i),r)}return sc=n,sc}var cc,Xp;function tC(){if(Xp)return cc;Xp=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return cc=e,cc}var uc,Qp;function nC(){if(Qp)return uc;Qp=1;var e=An(),t=Yu(),r=$r();function n(o,i){var a={};return i=r(i,3),t(o,function(s,u,c){e(a,u,i(s,u,c))}),a}return uc=n,uc}var lc,eg;function tl(){if(eg)return lc;eg=1;var e=wt();function t(r,n,o){for(var i=-1,a=r.length;++i<a;){var s=r[i],u=n(s);if(u!=null&&(c===void 0?u===u&&!e(u):o(u,c)))var c=u,l=s}return l}return lc=t,lc}var dc,rg;function oC(){if(rg)return dc;rg=1;function e(t,r){return t>r}return dc=e,dc}var fc,tg;function iC(){if(tg)return fc;tg=1;var e=tl(),t=oC(),r=it();function n(o){return o&&o.length?e(o,r,t):void 0}return fc=n,fc}var hc,ng;function kb(){if(ng)return hc;ng=1;var e=An(),t=mt();function r(n,o,i){(i!==void 0&&!t(n[o],i)||i===void 0&&!(o in n))&&e(n,o,i)}return hc=r,hc}var pc,og;function aC(){if(og)return pc;og=1;var e=tt(),t=qn(),r=Pr(),n="[object Object]",o=Function.prototype,i=Object.prototype,a=o.toString,s=i.hasOwnProperty,u=a.call(Object);function c(l){if(!r(l)||e(l)!=n)return!1;var d=t(l);if(d===null)return!0;var f=s.call(d,"constructor")&&d.constructor;return typeof f=="function"&&f instanceof f&&a.call(f)==u}return pc=c,pc}var gc,ig;function Pb(){if(ig)return gc;ig=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return gc=e,gc}var yc,ag;function sC(){if(ag)return yc;ag=1;var e=en(),t=ot();function r(n){return e(n,t(n))}return yc=r,yc}var mc,sg;function cC(){if(sg)return mc;sg=1;var e=kb(),t=Lm(),r=Hm(),n=Fm(),o=Jm(),i=rn(),a=Ye(),s=vb(),u=vt(),c=Qt(),l=vr(),d=aC(),f=tn(),p=Pb(),m=sC();function g(b,w,y,x,v,C,_){var k=p(b,y),T=p(w,y),P=_.get(T);if(P){e(b,y,P);return}var j=C?C(k,T,y+"",b,w,_):void 0,R=j===void 0;if(R){var E=a(T),M=!E&&u(T),I=!E&&!M&&f(T);j=T,E||M||I?a(k)?j=k:s(k)?j=n(k):M?(R=!1,j=t(T,!0)):I?(R=!1,j=r(T,!0)):j=[]:d(T)||i(T)?(j=k,i(k)?j=m(k):(!l(k)||c(k))&&(j=o(T))):R=!1}R&&(_.set(T,j),v(j,T,x,C,_),_.delete(T)),e(b,y,j)}return mc=g,mc}var bc,cg;function uC(){if(cg)return bc;cg=1;var e=Pn(),t=kb(),r=Zu(),n=cC(),o=vr(),i=ot(),a=Pb();function s(u,c,l,d,f){u!==c&&r(c,function(p,m){if(f||(f=new e),o(p))n(u,c,m,l,s,d,f);else{var g=d?d(a(u,m),p,m+"",u,c,f):void 0;g===void 0&&(g=p),t(u,m,g)}},i)}return bc=s,bc}var vc,ug;function lC(){if(ug)return vc;ug=1;var e=Bn(),t=Dn();function r(n){return e(function(o,i){var a=-1,s=i.length,u=s>1?i[s-1]:void 0,c=s>2?i[2]:void 0;for(u=n.length>3&&typeof u=="function"?(s--,u):void 0,c&&t(i[0],i[1],c)&&(u=s<3?void 0:u,s=1),o=Object(o);++a<s;){var l=i[a];l&&n(o,l,a,u)}return o})}return vc=r,vc}var xc,lg;function dC(){if(lg)return xc;lg=1;var e=uC(),t=lC(),r=t(function(n,o,i){e(n,o,i)});return xc=r,xc}var wc,dg;function Ab(){if(dg)return wc;dg=1;function e(t,r){return t<r}return wc=e,wc}var Cc,fg;function fC(){if(fg)return Cc;fg=1;var e=tl(),t=Ab(),r=it();function n(o){return o&&o.length?e(o,r,t):void 0}return Cc=n,Cc}var _c,hg;function hC(){if(hg)return _c;hg=1;var e=tl(),t=$r(),r=Ab();function n(o,i){return o&&o.length?e(o,t(i,2),r):void 0}return _c=n,_c}var Sc,pg;function pC(){if(pg)return Sc;pg=1;var e=Sr(),t=function(){return e.Date.now()};return Sc=t,Sc}var Ec,gg;function gC(){if(gg)return Ec;gg=1;var e=Tn(),t=Ln(),r=On(),n=vr(),o=nn();function i(a,s,u,c){if(!n(a))return a;s=t(s,a);for(var l=-1,d=s.length,f=d-1,p=a;p!=null&&++l<d;){var m=o(s[l]),g=u;if(m==="__proto__"||m==="constructor"||m==="prototype")return a;if(l!=f){var b=p[m];g=c?c(b,m,p):void 0,g===void 0&&(g=n(b)?b:r(s[l+1])?[]:{})}e(p,m,g),p=p[m]}return a}return Ec=i,Ec}var jc,yg;function yC(){if(yg)return jc;yg=1;var e=Fn(),t=gC(),r=Ln();function n(o,i,a){for(var s=-1,u=i.length,c={};++s<u;){var l=i[s],d=e(o,l);a(d,l)&&t(c,r(l,o),d)}return c}return jc=n,jc}var Rc,mg;function mC(){if(mg)return Rc;mg=1;var e=yC(),t=cb();function r(n,o){return e(n,o,function(i,a){return t(n,a)})}return Rc=r,Rc}var kc,bg;function bC(){if(bg)return kc;bg=1;var e=Rb(),t=yb(),r=mb();function n(o){return r(t(o,void 0,e),o+"")}return kc=n,kc}var Pc,vg;function vC(){if(vg)return Pc;vg=1;var e=mC(),t=bC(),r=t(function(n,o){return n==null?{}:e(n,o)});return Pc=r,Pc}var Ac,xg;function xC(){if(xg)return Ac;xg=1;var e=Math.ceil,t=Math.max;function r(n,o,i,a){for(var s=-1,u=t(e((o-n)/(i||1)),0),c=Array(u);u--;)c[a?u:++s]=n,n+=i;return c}return Ac=r,Ac}var Tc,wg;function wC(){if(wg)return Tc;wg=1;var e=xC(),t=Dn(),r=jb();function n(o){return function(i,a,s){return s&&typeof s!="number"&&t(i,a,s)&&(a=s=void 0),i=r(i),a===void 0?(a=i,i=0):a=r(a),s=s===void 0?i<a?1:-1:r(s),e(i,a,s,o)}}return Tc=n,Tc}var Oc,Cg;function CC(){if(Cg)return Oc;Cg=1;var e=wC(),t=e();return Oc=t,Oc}var Ic,_g;function _C(){if(_g)return Ic;_g=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return Ic=e,Ic}var Mc,Sg;function SC(){if(Sg)return Mc;Sg=1;var e=wt();function t(r,n){if(r!==n){var o=r!==void 0,i=r===null,a=r===r,s=e(r),u=n!==void 0,c=n===null,l=n===n,d=e(n);if(!c&&!d&&!s&&r>n||s&&u&&l&&!c&&!d||i&&u&&l||!o&&l||!a)return 1;if(!i&&!s&&!d&&r<n||d&&o&&a&&!i&&!s||c&&o&&a||!u&&a||!l)return-1}return 0}return Mc=t,Mc}var qc,Eg;function EC(){if(Eg)return qc;Eg=1;var e=SC();function t(r,n,o){for(var i=-1,a=r.criteria,s=n.criteria,u=a.length,c=o.length;++i<u;){var l=e(a[i],s[i]);if(l){if(i>=c)return l;var d=o[i];return l*(d=="desc"?-1:1)}}return r.index-n.index}return qc=t,qc}var Nc,jg;function jC(){if(jg)return Nc;jg=1;var e=$n(),t=Fn(),r=$r(),n=hb(),o=_C(),i=In(),a=EC(),s=it(),u=Ye();function c(l,d,f){d.length?d=e(d,function(g){return u(g)?function(b){return t(b,g.length===1?g[0]:g)}:g}):d=[s];var p=-1;d=e(d,i(r));var m=n(l,function(g,b,w){var y=e(d,function(x){return x(g)});return{criteria:y,index:++p,value:g}});return o(m,function(g,b){return a(g,b,f)})}return Nc=c,Nc}var $c,Rg;function RC(){if(Rg)return $c;Rg=1;var e=el(),t=jC(),r=Bn(),n=Dn(),o=r(function(i,a){if(i==null)return[];var s=a.length;return s>1&&n(i,a[0],a[1])?a=[]:s>2&&n(a[0],a[1],a[2])&&(a=[a[0]]),t(i,e(a,1),[])});return $c=o,$c}var Lc,kg;function kC(){if(kg)return Lc;kg=1;var e=ab(),t=0;function r(n){var o=++t;return e(n)+o}return Lc=r,Lc}var Fc,Pg;function PC(){if(Pg)return Fc;Pg=1;function e(t,r,n){for(var o=-1,i=t.length,a=r.length,s={};++o<i;){var u=o<a?r[o]:void 0;n(s,t[o],u)}return s}return Fc=e,Fc}var Bc,Ag;function AC(){if(Ag)return Bc;Ag=1;var e=Tn(),t=PC();function r(n,o){return t(n||[],o||[],e)}return Bc=r,Bc}var Dc,Tg;function We(){if(Tg)return Dc;Tg=1;var e;if(typeof Fu=="function")try{e={cloneDeep:U1(),constant:Ju(),defaults:H1(),each:Qm(),filter:lb(),find:eC(),flatten:Rb(),forEach:Xm(),forIn:rC(),has:db(),isUndefined:fb(),last:tC(),map:pb(),mapValues:nC(),max:iC(),merge:dC(),min:fC(),minBy:hC(),now:pC(),pick:vC(),range:CC(),reduce:gb(),sortBy:RC(),uniqueId:kC(),values:xb(),zipObject:AC()}}catch{}return e||(e=window._),Dc=e,Dc}var zc,Og;function TC(){if(Og)return zc;Og=1,zc=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,o=n._prev;if(o!==n)return t(o),o},e.prototype.enqueue=function(n){var o=this._sentinel;n._prev&&n._next&&t(n),n._next=o._next,o._next._prev=n,o._next=n,n._prev=o},e.prototype.toString=function(){for(var n=[],o=this._sentinel,i=o._prev;i!==o;)n.push(JSON.stringify(i,r)),i=i._prev;return"["+n.join(", ")+"]"};function t(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function r(n,o){if(n!=="_next"&&n!=="_prev")return o}return zc}var Vc,Ig;function OC(){if(Ig)return Vc;Ig=1;var e=We(),t=_r().Graph,r=TC();Vc=o;var n=e.constant(1);function o(c,l){if(c.nodeCount()<=1)return[];var d=s(c,l||n),f=i(d.graph,d.buckets,d.zeroIdx);return e.flatten(e.map(f,function(p){return c.outEdges(p.v,p.w)}),!0)}function i(c,l,d){for(var f=[],p=l[l.length-1],m=l[0],g;c.nodeCount();){for(;g=m.dequeue();)a(c,l,d,g);for(;g=p.dequeue();)a(c,l,d,g);if(c.nodeCount()){for(var b=l.length-2;b>0;--b)if(g=l[b].dequeue(),g){f=f.concat(a(c,l,d,g,!0));break}}}return f}function a(c,l,d,f,p){var m=p?[]:void 0;return e.forEach(c.inEdges(f.v),function(g){var b=c.edge(g),w=c.node(g.v);p&&m.push({v:g.v,w:g.w}),w.out-=b,u(l,d,w)}),e.forEach(c.outEdges(f.v),function(g){var b=c.edge(g),w=g.w,y=c.node(w);y.in-=b,u(l,d,y)}),c.removeNode(f.v),m}function s(c,l){var d=new t,f=0,p=0;e.forEach(c.nodes(),function(b){d.setNode(b,{v:b,in:0,out:0})}),e.forEach(c.edges(),function(b){var w=d.edge(b.v,b.w)||0,y=l(b),x=w+y;d.setEdge(b.v,b.w,x),p=Math.max(p,d.node(b.v).out+=y),f=Math.max(f,d.node(b.w).in+=y)});var m=e.range(p+f+3).map(function(){return new r}),g=f+1;return e.forEach(d.nodes(),function(b){u(m,g,d.node(b))}),{graph:d,buckets:m,zeroIdx:g}}function u(c,l,d){d.out?d.in?c[d.out-d.in+l].enqueue(d):c[c.length-1].enqueue(d):c[0].enqueue(d)}return Vc}var Wc,Mg;function IC(){if(Mg)return Wc;Mg=1;var e=We(),t=OC();Wc={run:r,undo:o};function r(i){var a=i.graph().acyclicer==="greedy"?t(i,s(i)):n(i);e.forEach(a,function(u){var c=i.edge(u);i.removeEdge(u),c.forwardName=u.name,c.reversed=!0,i.setEdge(u.w,u.v,c,e.uniqueId("rev"))});function s(u){return function(c){return u.edge(c).weight}}}function n(i){var a=[],s={},u={};function c(l){e.has(u,l)||(u[l]=!0,s[l]=!0,e.forEach(i.outEdges(l),function(d){e.has(s,d.w)?a.push(d):c(d.w)}),delete s[l])}return e.forEach(i.nodes(),c),a}function o(i){e.forEach(i.edges(),function(a){var s=i.edge(a);if(s.reversed){i.removeEdge(a);var u=s.forwardName;delete s.reversed,delete s.forwardName,i.setEdge(a.w,a.v,s,u)}})}return Wc}var Gc,qg;function pr(){if(qg)return Gc;qg=1;var e=We(),t=_r().Graph;Gc={addDummyNode:r,simplify:n,asNonCompoundGraph:o,successorWeights:i,predecessorWeights:a,intersectRect:s,buildLayerMatrix:u,normalizeRanks:c,removeEmptyRanks:l,addBorderNode:d,maxRank:f,partition:p,time:m,notime:g};function r(b,w,y,x){var v;do v=e.uniqueId(x);while(b.hasNode(v));return y.dummy=w,b.setNode(v,y),v}function n(b){var w=new t().setGraph(b.graph());return e.forEach(b.nodes(),function(y){w.setNode(y,b.node(y))}),e.forEach(b.edges(),function(y){var x=w.edge(y.v,y.w)||{weight:0,minlen:1},v=b.edge(y);w.setEdge(y.v,y.w,{weight:x.weight+v.weight,minlen:Math.max(x.minlen,v.minlen)})}),w}function o(b){var w=new t({multigraph:b.isMultigraph()}).setGraph(b.graph());return e.forEach(b.nodes(),function(y){b.children(y).length||w.setNode(y,b.node(y))}),e.forEach(b.edges(),function(y){w.setEdge(y,b.edge(y))}),w}function i(b){var w=e.map(b.nodes(),function(y){var x={};return e.forEach(b.outEdges(y),function(v){x[v.w]=(x[v.w]||0)+b.edge(v).weight}),x});return e.zipObject(b.nodes(),w)}function a(b){var w=e.map(b.nodes(),function(y){var x={};return e.forEach(b.inEdges(y),function(v){x[v.v]=(x[v.v]||0)+b.edge(v).weight}),x});return e.zipObject(b.nodes(),w)}function s(b,w){var y=b.x,x=b.y,v=w.x-y,C=w.y-x,_=b.width/2,k=b.height/2;if(!v&&!C)throw new Error("Not possible to find intersection inside of the rectangle");var T,P;return Math.abs(C)*_>Math.abs(v)*k?(C<0&&(k=-k),T=k*v/C,P=k):(v<0&&(_=-_),T=_,P=_*C/v),{x:y+T,y:x+P}}function u(b){var w=e.map(e.range(f(b)+1),function(){return[]});return e.forEach(b.nodes(),function(y){var x=b.node(y),v=x.rank;e.isUndefined(v)||(w[v][x.order]=y)}),w}function c(b){var w=e.min(e.map(b.nodes(),function(y){return b.node(y).rank}));e.forEach(b.nodes(),function(y){var x=b.node(y);e.has(x,"rank")&&(x.rank-=w)})}function l(b){var w=e.min(e.map(b.nodes(),function(C){return b.node(C).rank})),y=[];e.forEach(b.nodes(),function(C){var _=b.node(C).rank-w;y[_]||(y[_]=[]),y[_].push(C)});var x=0,v=b.graph().nodeRankFactor;e.forEach(y,function(C,_){e.isUndefined(C)&&_%v!==0?--x:x&&e.forEach(C,function(k){b.node(k).rank+=x})})}function d(b,w,y,x){var v={width:0,height:0};return arguments.length>=4&&(v.rank=y,v.order=x),r(b,"border",v,w)}function f(b){return e.max(e.map(b.nodes(),function(w){var y=b.node(w).rank;if(!e.isUndefined(y))return y}))}function p(b,w){var y={lhs:[],rhs:[]};return e.forEach(b,function(x){w(x)?y.lhs.push(x):y.rhs.push(x)}),y}function m(b,w){var y=e.now();try{return w()}finally{console.log(b+" time: "+(e.now()-y)+"ms")}}function g(b,w){return w()}return Gc}var Uc,Ng;function MC(){if(Ng)return Uc;Ng=1;var e=We(),t=pr();Uc={run:r,undo:o};function r(i){i.graph().dummyChains=[],e.forEach(i.edges(),function(a){n(i,a)})}function n(i,a){var s=a.v,u=i.node(s).rank,c=a.w,l=i.node(c).rank,d=a.name,f=i.edge(a),p=f.labelRank;if(l!==u+1){i.removeEdge(a);var m,g,b;for(b=0,++u;u<l;++b,++u)f.points=[],g={width:0,height:0,edgeLabel:f,edgeObj:a,rank:u},m=t.addDummyNode(i,"edge",g,"_d"),u===p&&(g.width=f.width,g.height=f.height,g.dummy="edge-label",g.labelpos=f.labelpos),i.setEdge(s,m,{weight:f.weight},d),b===0&&i.graph().dummyChains.push(m),s=m;i.setEdge(s,c,{weight:f.weight},d)}}function o(i){e.forEach(i.graph().dummyChains,function(a){var s=i.node(a),u=s.edgeLabel,c;for(i.setEdge(s.edgeObj,u);s.dummy;)c=i.successors(a)[0],i.removeNode(a),u.points.push({x:s.x,y:s.y}),s.dummy==="edge-label"&&(u.x=s.x,u.y=s.y,u.width=s.width,u.height=s.height),a=c,s=i.node(a)})}return Uc}var Hc,$g;function yn(){if($g)return Hc;$g=1;var e=We();Hc={longestPath:t,slack:r};function t(n){var o={};function i(a){var s=n.node(a);if(e.has(o,a))return s.rank;o[a]=!0;var u=e.min(e.map(n.outEdges(a),function(c){return i(c.w)-n.edge(c).minlen}));return(u===Number.POSITIVE_INFINITY||u===void 0||u===null)&&(u=0),s.rank=u}e.forEach(n.sources(),i)}function r(n,o){return n.node(o.w).rank-n.node(o.v).rank-n.edge(o).minlen}return Hc}var Kc,Lg;function Tb(){if(Lg)return Kc;Lg=1;var e=We(),t=_r().Graph,r=yn().slack;Kc=n;function n(s){var u=new t({directed:!1}),c=s.nodes()[0],l=s.nodeCount();u.setNode(c,{});for(var d,f;o(u,s)<l;)d=i(u,s),f=u.hasNode(d.v)?r(s,d):-r(s,d),a(u,s,f);return u}function o(s,u){function c(l){e.forEach(u.nodeEdges(l),function(d){var f=d.v,p=l===f?d.w:f;!s.hasNode(p)&&!r(u,d)&&(s.setNode(p,{}),s.setEdge(l,p,{}),c(p))})}return e.forEach(s.nodes(),c),s.nodeCount()}function i(s,u){return e.minBy(u.edges(),function(c){if(s.hasNode(c.v)!==s.hasNode(c.w))return r(u,c)})}function a(s,u,c){e.forEach(s.nodes(),function(l){u.node(l).rank+=c})}return Kc}var Jc,Fg;function qC(){if(Fg)return Jc;Fg=1;var e=We(),t=Tb(),r=yn().slack,n=yn().longestPath,o=_r().alg.preorder,i=_r().alg.postorder,a=pr().simplify;Jc=s,s.initLowLimValues=d,s.initCutValues=u,s.calcCutValue=l,s.leaveEdge=p,s.enterEdge=m,s.exchangeEdges=g;function s(x){x=a(x),n(x);var v=t(x);d(v),u(v,x);for(var C,_;C=p(v);)_=m(v,x,C),g(v,x,C,_)}function u(x,v){var C=i(x,x.nodes());C=C.slice(0,C.length-1),e.forEach(C,function(_){c(x,v,_)})}function c(x,v,C){var _=x.node(C),k=_.parent;x.edge(C,k).cutvalue=l(x,v,C)}function l(x,v,C){var _=x.node(C),k=_.parent,T=!0,P=v.edge(C,k),j=0;return P||(T=!1,P=v.edge(k,C)),j=P.weight,e.forEach(v.nodeEdges(C),function(R){var E=R.v===C,M=E?R.w:R.v;if(M!==k){var I=E===T,N=v.edge(R).weight;if(j+=I?N:-N,w(x,C,M)){var O=x.edge(C,M).cutvalue;j+=I?-O:O}}}),j}function d(x,v){arguments.length<2&&(v=x.nodes()[0]),f(x,{},1,v)}function f(x,v,C,_,k){var T=C,P=x.node(_);return v[_]=!0,e.forEach(x.neighbors(_),function(j){e.has(v,j)||(C=f(x,v,C,j,_))}),P.low=T,P.lim=C++,k?P.parent=k:delete P.parent,C}function p(x){return e.find(x.edges(),function(v){return x.edge(v).cutvalue<0})}function m(x,v,C){var _=C.v,k=C.w;v.hasEdge(_,k)||(_=C.w,k=C.v);var T=x.node(_),P=x.node(k),j=T,R=!1;T.lim>P.lim&&(j=P,R=!0);var E=e.filter(v.edges(),function(M){return R===y(x,x.node(M.v),j)&&R!==y(x,x.node(M.w),j)});return e.minBy(E,function(M){return r(v,M)})}function g(x,v,C,_){var k=C.v,T=C.w;x.removeEdge(k,T),x.setEdge(_.v,_.w,{}),d(x),u(x,v),b(x,v)}function b(x,v){var C=e.find(x.nodes(),function(k){return!v.node(k).parent}),_=o(x,C);_=_.slice(1),e.forEach(_,function(k){var T=x.node(k).parent,P=v.edge(k,T),j=!1;P||(P=v.edge(T,k),j=!0),v.node(k).rank=v.node(T).rank+(j?P.minlen:-P.minlen)})}function w(x,v,C){return x.hasEdge(v,C)}function y(x,v,C){return C.low<=v.lim&&v.lim<=C.lim}return Jc}var Zc,Bg;function NC(){if(Bg)return Zc;Bg=1;var e=yn(),t=e.longestPath,r=Tb(),n=qC();Zc=o;function o(u){switch(u.graph().ranker){case"network-simplex":s(u);break;case"tight-tree":a(u);break;case"longest-path":i(u);break;default:s(u)}}var i=t;function a(u){t(u),r(u)}function s(u){n(u)}return Zc}var Yc,Dg;function $C(){if(Dg)return Yc;Dg=1;var e=We();Yc=t;function t(o){var i=n(o);e.forEach(o.graph().dummyChains,function(a){for(var s=o.node(a),u=s.edgeObj,c=r(o,i,u.v,u.w),l=c.path,d=c.lca,f=0,p=l[f],m=!0;a!==u.w;){if(s=o.node(a),m){for(;(p=l[f])!==d&&o.node(p).maxRank<s.rank;)f++;p===d&&(m=!1)}if(!m){for(;f<l.length-1&&o.node(p=l[f+1]).minRank<=s.rank;)f++;p=l[f]}o.setParent(a,p),a=o.successors(a)[0]}})}function r(o,i,a,s){var u=[],c=[],l=Math.min(i[a].low,i[s].low),d=Math.max(i[a].lim,i[s].lim),f,p;f=a;do f=o.parent(f),u.push(f);while(f&&(i[f].low>l||d>i[f].lim));for(p=f,f=s;(f=o.parent(f))!==p;)c.push(f);return{path:u.concat(c.reverse()),lca:p}}function n(o){var i={},a=0;function s(u){var c=a;e.forEach(o.children(u),s),i[u]={low:c,lim:a++}}return e.forEach(o.children(),s),i}return Yc}var Xc,zg;function LC(){if(zg)return Xc;zg=1;var e=We(),t=pr();Xc={run:r,cleanup:a};function r(s){var u=t.addDummyNode(s,"root",{},"_root"),c=o(s),l=e.max(e.values(c))-1,d=2*l+1;s.graph().nestingRoot=u,e.forEach(s.edges(),function(p){s.edge(p).minlen*=d});var f=i(s)+1;e.forEach(s.children(),function(p){n(s,u,d,f,l,c,p)}),s.graph().nodeRankFactor=d}function n(s,u,c,l,d,f,p){var m=s.children(p);if(!m.length){p!==u&&s.setEdge(u,p,{weight:0,minlen:c});return}var g=t.addBorderNode(s,"_bt"),b=t.addBorderNode(s,"_bb"),w=s.node(p);s.setParent(g,p),w.borderTop=g,s.setParent(b,p),w.borderBottom=b,e.forEach(m,function(y){n(s,u,c,l,d,f,y);var x=s.node(y),v=x.borderTop?x.borderTop:y,C=x.borderBottom?x.borderBottom:y,_=x.borderTop?l:2*l,k=v!==C?1:d-f[p]+1;s.setEdge(g,v,{weight:_,minlen:k,nestingEdge:!0}),s.setEdge(C,b,{weight:_,minlen:k,nestingEdge:!0})}),s.parent(p)||s.setEdge(u,g,{weight:0,minlen:d+f[p]})}function o(s){var u={};function c(l,d){var f=s.children(l);f&&f.length&&e.forEach(f,function(p){c(p,d+1)}),u[l]=d}return e.forEach(s.children(),function(l){c(l,1)}),u}function i(s){return e.reduce(s.edges(),function(u,c){return u+s.edge(c).weight},0)}function a(s){var u=s.graph();s.removeNode(u.nestingRoot),delete u.nestingRoot,e.forEach(s.edges(),function(c){var l=s.edge(c);l.nestingEdge&&s.removeEdge(c)})}return Xc}var Qc,Vg;function FC(){if(Vg)return Qc;Vg=1;var e=We(),t=pr();Qc=r;function r(o){function i(a){var s=o.children(a),u=o.node(a);if(s.length&&e.forEach(s,i),e.has(u,"minRank")){u.borderLeft=[],u.borderRight=[];for(var c=u.minRank,l=u.maxRank+1;c<l;++c)n(o,"borderLeft","_bl",a,u,c),n(o,"borderRight","_br",a,u,c)}}e.forEach(o.children(),i)}function n(o,i,a,s,u,c){var l={width:0,height:0,rank:c,borderType:i},d=u[i][c-1],f=t.addDummyNode(o,"border",l,a);u[i][c]=f,o.setParent(f,s),d&&o.setEdge(d,f,{weight:1})}return Qc}var eu,Wg;function BC(){if(Wg)return eu;Wg=1;var e=We();eu={adjust:t,undo:r};function t(c){var l=c.graph().rankdir.toLowerCase();(l==="lr"||l==="rl")&&n(c)}function r(c){var l=c.graph().rankdir.toLowerCase();(l==="bt"||l==="rl")&&i(c),(l==="lr"||l==="rl")&&(s(c),n(c))}function n(c){e.forEach(c.nodes(),function(l){o(c.node(l))}),e.forEach(c.edges(),function(l){o(c.edge(l))})}function o(c){var l=c.width;c.width=c.height,c.height=l}function i(c){e.forEach(c.nodes(),function(l){a(c.node(l))}),e.forEach(c.edges(),function(l){var d=c.edge(l);e.forEach(d.points,a),e.has(d,"y")&&a(d)})}function a(c){c.y=-c.y}function s(c){e.forEach(c.nodes(),function(l){u(c.node(l))}),e.forEach(c.edges(),function(l){var d=c.edge(l);e.forEach(d.points,u),e.has(d,"x")&&u(d)})}function u(c){var l=c.x;c.x=c.y,c.y=l}return eu}var ru,Gg;function DC(){if(Gg)return ru;Gg=1;var e=We();ru=t;function t(r){var n={},o=e.filter(r.nodes(),function(c){return!r.children(c).length}),i=e.max(e.map(o,function(c){return r.node(c).rank})),a=e.map(e.range(i+1),function(){return[]});function s(c){if(!e.has(n,c)){n[c]=!0;var l=r.node(c);a[l.rank].push(c),e.forEach(r.successors(c),s)}}var u=e.sortBy(o,function(c){return r.node(c).rank});return e.forEach(u,s),a}return ru}var tu,Ug;function zC(){if(Ug)return tu;Ug=1;var e=We();tu=t;function t(n,o){for(var i=0,a=1;a<o.length;++a)i+=r(n,o[a-1],o[a]);return i}function r(n,o,i){for(var a=e.zipObject(i,e.map(i,function(f,p){return p})),s=e.flatten(e.map(o,function(f){return e.sortBy(e.map(n.outEdges(f),function(p){return{pos:a[p.w],weight:n.edge(p).weight}}),"pos")}),!0),u=1;u<i.length;)u<<=1;var c=2*u-1;u-=1;var l=e.map(new Array(c),function(){return 0}),d=0;return e.forEach(s.forEach(function(f){var p=f.pos+u;l[p]+=f.weight;for(var m=0;p>0;)p%2&&(m+=l[p+1]),p=p-1>>1,l[p]+=f.weight;d+=f.weight*m})),d}return tu}var nu,Hg;function VC(){if(Hg)return nu;Hg=1;var e=We();nu=t;function t(r,n){return e.map(n,function(o){var i=r.inEdges(o);if(i.length){var a=e.reduce(i,function(s,u){var c=r.edge(u),l=r.node(u.v);return{sum:s.sum+c.weight*l.order,weight:s.weight+c.weight}},{sum:0,weight:0});return{v:o,barycenter:a.sum/a.weight,weight:a.weight}}else return{v:o}})}return nu}var ou,Kg;function WC(){if(Kg)return ou;Kg=1;var e=We();ou=t;function t(o,i){var a={};e.forEach(o,function(u,c){var l=a[u.v]={indegree:0,in:[],out:[],vs:[u.v],i:c};e.isUndefined(u.barycenter)||(l.barycenter=u.barycenter,l.weight=u.weight)}),e.forEach(i.edges(),function(u){var c=a[u.v],l=a[u.w];!e.isUndefined(c)&&!e.isUndefined(l)&&(l.indegree++,c.out.push(a[u.w]))});var s=e.filter(a,function(u){return!u.indegree});return r(s)}function r(o){var i=[];function a(c){return function(l){l.merged||(e.isUndefined(l.barycenter)||e.isUndefined(c.barycenter)||l.barycenter>=c.barycenter)&&n(c,l)}}function s(c){return function(l){l.in.push(c),--l.indegree===0&&o.push(l)}}for(;o.length;){var u=o.pop();i.push(u),e.forEach(u.in.reverse(),a(u)),e.forEach(u.out,s(u))}return e.map(e.filter(i,function(c){return!c.merged}),function(c){return e.pick(c,["vs","i","barycenter","weight"])})}function n(o,i){var a=0,s=0;o.weight&&(a+=o.barycenter*o.weight,s+=o.weight),i.weight&&(a+=i.barycenter*i.weight,s+=i.weight),o.vs=i.vs.concat(o.vs),o.barycenter=a/s,o.weight=s,o.i=Math.min(i.i,o.i),i.merged=!0}return ou}var iu,Jg;function GC(){if(Jg)return iu;Jg=1;var e=We(),t=pr();iu=r;function r(i,a){var s=t.partition(i,function(g){return e.has(g,"barycenter")}),u=s.lhs,c=e.sortBy(s.rhs,function(g){return-g.i}),l=[],d=0,f=0,p=0;u.sort(o(!!a)),p=n(l,c,p),e.forEach(u,function(g){p+=g.vs.length,l.push(g.vs),d+=g.barycenter*g.weight,f+=g.weight,p=n(l,c,p)});var m={vs:e.flatten(l,!0)};return f&&(m.barycenter=d/f,m.weight=f),m}function n(i,a,s){for(var u;a.length&&(u=e.last(a)).i<=s;)a.pop(),i.push(u.vs),s++;return s}function o(i){return function(a,s){return a.barycenter<s.barycenter?-1:a.barycenter>s.barycenter?1:i?s.i-a.i:a.i-s.i}}return iu}var au,Zg;function UC(){if(Zg)return au;Zg=1;var e=We(),t=VC(),r=WC(),n=GC();au=o;function o(s,u,c,l){var d=s.children(u),f=s.node(u),p=f?f.borderLeft:void 0,m=f?f.borderRight:void 0,g={};p&&(d=e.filter(d,function(C){return C!==p&&C!==m}));var b=t(s,d);e.forEach(b,function(C){if(s.children(C.v).length){var _=o(s,C.v,c,l);g[C.v]=_,e.has(_,"barycenter")&&a(C,_)}});var w=r(b,c);i(w,g);var y=n(w,l);if(p&&(y.vs=e.flatten([p,y.vs,m],!0),s.predecessors(p).length)){var x=s.node(s.predecessors(p)[0]),v=s.node(s.predecessors(m)[0]);e.has(y,"barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+x.order+v.order)/(y.weight+2),y.weight+=2}return y}function i(s,u){e.forEach(s,function(c){c.vs=e.flatten(c.vs.map(function(l){return u[l]?u[l].vs:l}),!0)})}function a(s,u){e.isUndefined(s.barycenter)?(s.barycenter=u.barycenter,s.weight=u.weight):(s.barycenter=(s.barycenter*s.weight+u.barycenter*u.weight)/(s.weight+u.weight),s.weight+=u.weight)}return au}var su,Yg;function HC(){if(Yg)return su;Yg=1;var e=We(),t=_r().Graph;su=r;function r(o,i,a){var s=n(o),u=new t({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(function(c){return o.node(c)});return e.forEach(o.nodes(),function(c){var l=o.node(c),d=o.parent(c);(l.rank===i||l.minRank<=i&&i<=l.maxRank)&&(u.setNode(c),u.setParent(c,d||s),e.forEach(o[a](c),function(f){var p=f.v===c?f.w:f.v,m=u.edge(p,c),g=e.isUndefined(m)?0:m.weight;u.setEdge(p,c,{weight:o.edge(f).weight+g})}),e.has(l,"minRank")&&u.setNode(c,{borderLeft:l.borderLeft[i],borderRight:l.borderRight[i]}))}),u}function n(o){for(var i;o.hasNode(i=e.uniqueId("_root")););return i}return su}var cu,Xg;function KC(){if(Xg)return cu;Xg=1;var e=We();cu=t;function t(r,n,o){var i={},a;e.forEach(o,function(s){for(var u=r.parent(s),c,l;u;){if(c=r.parent(u),c?(l=i[c],i[c]=u):(l=a,a=u),l&&l!==u){n.setEdge(l,u);return}u=c}})}return cu}var uu,Qg;function JC(){if(Qg)return uu;Qg=1;var e=We(),t=DC(),r=zC(),n=UC(),o=HC(),i=KC(),a=_r().Graph,s=pr();uu=u;function u(f){var p=s.maxRank(f),m=c(f,e.range(1,p+1),"inEdges"),g=c(f,e.range(p-1,-1,-1),"outEdges"),b=t(f);d(f,b);for(var w=Number.POSITIVE_INFINITY,y,x=0,v=0;v<4;++x,++v){l(x%2?m:g,x%4>=2),b=s.buildLayerMatrix(f);var C=r(f,b);C<w&&(v=0,y=e.cloneDeep(b),w=C)}d(f,y)}function c(f,p,m){return e.map(p,function(g){return o(f,g,m)})}function l(f,p){var m=new a;e.forEach(f,function(g){var b=g.graph().root,w=n(g,b,m,p);e.forEach(w.vs,function(y,x){g.node(y).order=x}),i(g,m,w.vs)})}function d(f,p){e.forEach(p,function(m){e.forEach(m,function(g,b){f.node(g).order=b})})}return uu}var lu,ey;function ZC(){if(ey)return lu;ey=1;var e=We(),t=_r().Graph,r=pr();lu={positionX:m,findType1Conflicts:n,findType2Conflicts:o,addConflict:a,hasConflict:s,verticalAlignment:u,horizontalCompaction:c,alignCoordinates:f,findSmallestWidthAlignment:d,balance:p};function n(w,y){var x={};function v(C,_){var k=0,T=0,P=C.length,j=e.last(_);return e.forEach(_,function(R,E){var M=i(w,R),I=M?w.node(M).order:P;(M||R===j)&&(e.forEach(_.slice(T,E+1),function(N){e.forEach(w.predecessors(N),function(O){var W=w.node(O),z=W.order;(z<k||I<z)&&!(W.dummy&&w.node(N).dummy)&&a(x,O,N)})}),T=E+1,k=I)}),_}return e.reduce(y,v),x}function o(w,y){var x={};function v(_,k,T,P,j){var R;e.forEach(e.range(k,T),function(E){R=_[E],w.node(R).dummy&&e.forEach(w.predecessors(R),function(M){var I=w.node(M);I.dummy&&(I.order<P||I.order>j)&&a(x,M,R)})})}function C(_,k){var T=-1,P,j=0;return e.forEach(k,function(R,E){if(w.node(R).dummy==="border"){var M=w.predecessors(R);M.length&&(P=w.node(M[0]).order,v(k,j,E,T,P),j=E,T=P)}v(k,j,k.length,P,_.length)}),k}return e.reduce(y,C),x}function i(w,y){if(w.node(y).dummy)return e.find(w.predecessors(y),function(x){return w.node(x).dummy})}function a(w,y,x){if(y>x){var v=y;y=x,x=v}var C=w[y];C||(w[y]=C={}),C[x]=!0}function s(w,y,x){if(y>x){var v=y;y=x,x=v}return e.has(w[y],x)}function u(w,y,x,v){var C={},_={},k={};return e.forEach(y,function(T){e.forEach(T,function(P,j){C[P]=P,_[P]=P,k[P]=j})}),e.forEach(y,function(T){var P=-1;e.forEach(T,function(j){var R=v(j);if(R.length){R=e.sortBy(R,function(O){return k[O]});for(var E=(R.length-1)/2,M=Math.floor(E),I=Math.ceil(E);M<=I;++M){var N=R[M];_[j]===j&&P<k[N]&&!s(x,j,N)&&(_[N]=j,_[j]=C[j]=C[N],P=k[N])}}})}),{root:C,align:_}}function c(w,y,x,v,C){var _={},k=l(w,y,x,C),T=C?"borderLeft":"borderRight";function P(E,M){for(var I=k.nodes(),N=I.pop(),O={};N;)O[N]?E(N):(O[N]=!0,I.push(N),I=I.concat(M(N))),N=I.pop()}function j(E){_[E]=k.inEdges(E).reduce(function(M,I){return Math.max(M,_[I.v]+k.edge(I))},0)}function R(E){var M=k.outEdges(E).reduce(function(N,O){return Math.min(N,_[O.w]-k.edge(O))},Number.POSITIVE_INFINITY),I=w.node(E);M!==Number.POSITIVE_INFINITY&&I.borderType!==T&&(_[E]=Math.max(_[E],M))}return P(j,k.predecessors.bind(k)),P(R,k.successors.bind(k)),e.forEach(v,function(E){_[E]=_[x[E]]}),_}function l(w,y,x,v){var C=new t,_=w.graph(),k=g(_.nodesep,_.edgesep,v);return e.forEach(y,function(T){var P;e.forEach(T,function(j){var R=x[j];if(C.setNode(R),P){var E=x[P],M=C.edge(E,R);C.setEdge(E,R,Math.max(k(w,j,P),M||0))}P=j})}),C}function d(w,y){return e.minBy(e.values(y),function(x){var v=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;return e.forIn(x,function(_,k){var T=b(w,k)/2;v=Math.max(_+T,v),C=Math.min(_-T,C)}),v-C})}function f(w,y){var x=e.values(y),v=e.min(x),C=e.max(x);e.forEach(["u","d"],function(_){e.forEach(["l","r"],function(k){var T=_+k,P=w[T],j;if(P!==y){var R=e.values(P);j=k==="l"?v-e.min(R):C-e.max(R),j&&(w[T]=e.mapValues(P,function(E){return E+j}))}})})}function p(w,y){return e.mapValues(w.ul,function(x,v){if(y)return w[y.toLowerCase()][v];var C=e.sortBy(e.map(w,v));return(C[1]+C[2])/2})}function m(w){var y=r.buildLayerMatrix(w),x=e.merge(n(w,y),o(w,y)),v={},C;e.forEach(["u","d"],function(k){C=k==="u"?y:e.values(y).reverse(),e.forEach(["l","r"],function(T){T==="r"&&(C=e.map(C,function(E){return e.values(E).reverse()}));var P=(k==="u"?w.predecessors:w.successors).bind(w),j=u(w,C,x,P),R=c(w,C,j.root,j.align,T==="r");T==="r"&&(R=e.mapValues(R,function(E){return-E})),v[k+T]=R})});var _=d(w,v);return f(v,_),p(v,w.graph().align)}function g(w,y,x){return function(v,C,_){var k=v.node(C),T=v.node(_),P=0,j;if(P+=k.width/2,e.has(k,"labelpos"))switch(k.labelpos.toLowerCase()){case"l":j=-k.width/2;break;case"r":j=k.width/2;break}if(j&&(P+=x?j:-j),j=0,P+=(k.dummy?y:w)/2,P+=(T.dummy?y:w)/2,P+=T.width/2,e.has(T,"labelpos"))switch(T.labelpos.toLowerCase()){case"l":j=T.width/2;break;case"r":j=-T.width/2;break}return j&&(P+=x?j:-j),j=0,P}}function b(w,y){return w.node(y).width}return lu}var du,ry;function YC(){if(ry)return du;ry=1;var e=We(),t=pr(),r=ZC().positionX;du=n;function n(i){i=t.asNonCompoundGraph(i),o(i),e.forEach(r(i),function(a,s){i.node(s).x=a})}function o(i){var a=t.buildLayerMatrix(i),s=i.graph().ranksep,u=0;e.forEach(a,function(c){var l=e.max(e.map(c,function(d){return i.node(d).height}));e.forEach(c,function(d){i.node(d).y=u+l/2}),u+=l+s})}return du}var fu,ty;function XC(){if(ty)return fu;ty=1;var e=We(),t=IC(),r=MC(),n=NC(),o=pr().normalizeRanks,i=$C(),a=pr().removeEmptyRanks,s=LC(),u=FC(),c=BC(),l=JC(),d=YC(),f=pr(),p=_r().Graph;fu=m;function m(q,L){var G=L&&L.debugTiming?f.time:f.notime;G("layout",function(){var B=G(" buildLayoutGraph",function(){return P(q)});G(" runLayout",function(){g(B,G)}),G(" updateInputGraph",function(){b(q,B)})})}function g(q,L){L(" makeSpaceForEdgeLabels",function(){j(q)}),L(" removeSelfEdges",function(){re(q)}),L(" acyclic",function(){t.run(q)}),L(" nestingGraph.run",function(){s.run(q)}),L(" rank",function(){n(f.asNonCompoundGraph(q))}),L(" injectEdgeLabelProxies",function(){R(q)}),L(" removeEmptyRanks",function(){a(q)}),L(" nestingGraph.cleanup",function(){s.cleanup(q)}),L(" normalizeRanks",function(){o(q)}),L(" assignRankMinMax",function(){E(q)}),L(" removeEdgeLabelProxies",function(){M(q)}),L(" normalize.run",function(){r.run(q)}),L(" parentDummyChains",function(){i(q)}),L(" addBorderSegments",function(){u(q)}),L(" order",function(){l(q)}),L(" insertSelfEdges",function(){te(q)}),L(" adjustCoordinateSystem",function(){c.adjust(q)}),L(" position",function(){d(q)}),L(" positionSelfEdges",function(){he(q)}),L(" removeBorderNodes",function(){z(q)}),L(" normalize.undo",function(){r.undo(q)}),L(" fixupEdgeLabelCoords",function(){O(q)}),L(" undoCoordinateSystem",function(){c.undo(q)}),L(" translateGraph",function(){I(q)}),L(" assignNodeIntersects",function(){N(q)}),L(" reversePoints",function(){W(q)}),L(" acyclic.undo",function(){t.undo(q)})}function b(q,L){e.forEach(q.nodes(),function(G){var B=q.node(G),Y=L.node(G);B&&(B.x=Y.x,B.y=Y.y,L.children(G).length&&(B.width=Y.width,B.height=Y.height))}),e.forEach(q.edges(),function(G){var B=q.edge(G),Y=L.edge(G);B.points=Y.points,e.has(Y,"x")&&(B.x=Y.x,B.y=Y.y)}),q.graph().width=L.graph().width,q.graph().height=L.graph().height}var w=["nodesep","edgesep","ranksep","marginx","marginy"],y={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},x=["acyclicer","ranker","rankdir","align"],v=["width","height"],C={width:0,height:0},_=["minlen","weight","width","height","labeloffset"],k={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},T=["labelpos"];function P(q){var L=new p({multigraph:!0,compound:!0}),G=K(q.graph());return L.setGraph(e.merge({},y,me(G,w),e.pick(G,x))),e.forEach(q.nodes(),function(B){var Y=K(q.node(B));L.setNode(B,e.defaults(me(Y,v),C)),L.setParent(B,q.parent(B))}),e.forEach(q.edges(),function(B){var Y=K(q.edge(B));L.setEdge(B,e.merge({},k,me(Y,_),e.pick(Y,T)))}),L}function j(q){var L=q.graph();L.ranksep/=2,e.forEach(q.edges(),function(G){var B=q.edge(G);B.minlen*=2,B.labelpos.toLowerCase()!=="c"&&(L.rankdir==="TB"||L.rankdir==="BT"?B.width+=B.labeloffset:B.height+=B.labeloffset)})}function R(q){e.forEach(q.edges(),function(L){var G=q.edge(L);if(G.width&&G.height){var B=q.node(L.v),Y=q.node(L.w),ce={rank:(Y.rank-B.rank)/2+B.rank,e:L};f.addDummyNode(q,"edge-proxy",ce,"_ep")}})}function E(q){var L=0;e.forEach(q.nodes(),function(G){var B=q.node(G);B.borderTop&&(B.minRank=q.node(B.borderTop).rank,B.maxRank=q.node(B.borderBottom).rank,L=e.max(L,B.maxRank))}),q.graph().maxRank=L}function M(q){e.forEach(q.nodes(),function(L){var G=q.node(L);G.dummy==="edge-proxy"&&(q.edge(G.e).labelRank=G.rank,q.removeNode(L))})}function I(q){var L=Number.POSITIVE_INFINITY,G=0,B=Number.POSITIVE_INFINITY,Y=0,ce=q.graph(),X=ce.marginx||0,U=ce.marginy||0;function Z(ae){var ue=ae.x,de=ae.y,Ee=ae.width,ge=ae.height;L=Math.min(L,ue-Ee/2),G=Math.max(G,ue+Ee/2),B=Math.min(B,de-ge/2),Y=Math.max(Y,de+ge/2)}e.forEach(q.nodes(),function(ae){Z(q.node(ae))}),e.forEach(q.edges(),function(ae){var ue=q.edge(ae);e.has(ue,"x")&&Z(ue)}),L-=X,B-=U,e.forEach(q.nodes(),function(ae){var ue=q.node(ae);ue.x-=L,ue.y-=B}),e.forEach(q.edges(),function(ae){var ue=q.edge(ae);e.forEach(ue.points,function(de){de.x-=L,de.y-=B}),e.has(ue,"x")&&(ue.x-=L),e.has(ue,"y")&&(ue.y-=B)}),ce.width=G-L+X,ce.height=Y-B+U}function N(q){e.forEach(q.edges(),function(L){var G=q.edge(L),B=q.node(L.v),Y=q.node(L.w),ce,X;G.points?(ce=G.points[0],X=G.points[G.points.length-1]):(G.points=[],ce=Y,X=B),G.points.unshift(f.intersectRect(B,ce)),G.points.push(f.intersectRect(Y,X))})}function O(q){e.forEach(q.edges(),function(L){var G=q.edge(L);if(e.has(G,"x"))switch((G.labelpos==="l"||G.labelpos==="r")&&(G.width-=G.labeloffset),G.labelpos){case"l":G.x-=G.width/2+G.labeloffset;break;case"r":G.x+=G.width/2+G.labeloffset;break}})}function W(q){e.forEach(q.edges(),function(L){var G=q.edge(L);G.reversed&&G.points.reverse()})}function z(q){e.forEach(q.nodes(),function(L){if(q.children(L).length){var G=q.node(L),B=q.node(G.borderTop),Y=q.node(G.borderBottom),ce=q.node(e.last(G.borderLeft)),X=q.node(e.last(G.borderRight));G.width=Math.abs(X.x-ce.x),G.height=Math.abs(Y.y-B.y),G.x=ce.x+G.width/2,G.y=B.y+G.height/2}}),e.forEach(q.nodes(),function(L){q.node(L).dummy==="border"&&q.removeNode(L)})}function re(q){e.forEach(q.edges(),function(L){if(L.v===L.w){var G=q.node(L.v);G.selfEdges||(G.selfEdges=[]),G.selfEdges.push({e:L,label:q.edge(L)}),q.removeEdge(L)}})}function te(q){var L=f.buildLayerMatrix(q);e.forEach(L,function(G){var B=0;e.forEach(G,function(Y,ce){var X=q.node(Y);X.order=ce+B,e.forEach(X.selfEdges,function(U){f.addDummyNode(q,"selfedge",{width:U.label.width,height:U.label.height,rank:X.rank,order:ce+ ++B,e:U.e,label:U.label},"_se")}),delete X.selfEdges})})}function he(q){e.forEach(q.nodes(),function(L){var G=q.node(L);if(G.dummy==="selfedge"){var B=q.node(G.e.v),Y=B.x+B.width/2,ce=B.y,X=G.x-Y,U=B.height/2;q.setEdge(G.e,G.label),q.removeNode(L),G.label.points=[{x:Y+2*X/3,y:ce-U},{x:Y+5*X/6,y:ce-U},{x:Y+X,y:ce},{x:Y+5*X/6,y:ce+U},{x:Y+2*X/3,y:ce+U}],G.label.x=G.x,G.label.y=G.y}})}function me(q,L){return e.mapValues(e.pick(q,L),Number)}function K(q){var L={};return e.forEach(q,function(G,B){L[B.toLowerCase()]=G}),L}return fu}var hu,ny;function QC(){if(ny)return hu;ny=1;var e=We(),t=pr(),r=_r().Graph;hu={debugOrdering:n};function n(o){var i=t.buildLayerMatrix(o),a=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(s){a.setNode(s,{label:s}),a.setParent(s,"layer"+o.node(s).rank)}),e.forEach(o.edges(),function(s){a.setEdge(s.v,s.w,{},s.name)}),e.forEach(i,function(s,u){var c="layer"+u;a.setNode(c,{rank:"same"}),e.reduce(s,function(l,d){return a.setEdge(l,d,{style:"invis"}),d})}),a}return hu}var pu,oy;function e_(){return oy||(oy=1,pu="0.8.5"),pu}var gu,iy;function r_(){return iy||(iy=1,gu={graphlib:_r(),layout:XC(),debug:QC(),util:{time:pr().time,notime:pr().notime},version:e_()}),gu}var t_=r_();const ay=B0(t_);function n_(e,t,r){var l;const n=new Set(e.map(d=>d.id)),o=new Set;for(const d of e)d.parent&&n.has(d.parent)&&o.add(d.parent);const i=new ay.graphlib.Graph({multigraph:!0,compound:!0}),a=r.compactSpacingScale??(r.spacingFactor>0?r.spacingFactor/1.3:1);i.setGraph({rankdir:r.rankDir,nodesep:r.compact?Math.max(r.nodeSep,24*a):r.nodeSep,edgesep:r.compact?Math.min(r.edgeSep,24*a):r.edgeSep,ranksep:r.compact?Math.min(r.rankSep,80*a):r.rankSep,ranker:"network-simplex"}),i.setDefaultEdgeLabel(()=>({})),i.setDefaultNodeLabel(()=>({}));for(const d of e)i.setNode(d.id,{width:d.width+2,height:d.height+2});for(const d of e)d.parent&&n.has(d.parent)&&i.setParent(d.id,d.parent);for(const d of t){if(!n.has(d.source)||!n.has(d.target)||o.has(d.source)||o.has(d.target))continue;const f=Am(d.label,d.icon??((l=d.data)==null?void 0:l.icon),r.edgeLabelFontSize),p=r.rankDir==="LR"||r.rankDir==="RL",m=(f.width?f.width+2*Pm:0)+(d.connectorClearance??0);i.setEdge(d.source,d.target,{minlen:1,weight:1,...m?{width:p?m:Math.max(1,f.height),height:p?Math.max(1,f.height):m,labelpos:"c"}:{}},d.id)}ay.layout(i);const s=new Map;for(const d of e){if(o.has(d.id))continue;const f=i.node(d.id);f&&Number.isFinite(f.x)&&Number.isFinite(f.y)&&s.set(d.id,{x:f.x,y:f.y})}const u=r.compact?1:r.spacingFactor;if(u&&u!==1&&s.size){let d=1/0,f=1/0,p=-1/0,m=-1/0;s.forEach(w=>{d=Math.min(d,w.x),f=Math.min(f,w.y),p=Math.max(p,w.x),m=Math.max(m,w.y)});const g=(d+p)/2,b=(f+m)/2;s.forEach((w,y)=>s.set(y,{x:g+(w.x-g)*u,y:b+(w.y-b)*u}))}const c=r.nodeAlignment??"center";if(c!=="center"){const d=r.rankDir==="LR"||r.rankDir==="RL",f=d?"x":"y",p=d?"width":"height",m=r.rankDir==="RL"||r.rankDir==="BT"?-1:1,g=c==="leading"?-m:m,b=new Map;for(const w of e){const y=s.get(w.id);if(!y)continue;const x=y[f];b.set(x,Math.max(b.get(x)??0,w[p]))}for(const w of e){const y=s.get(w.id);if(!y)continue;const x=y[f],v=(b.get(x)-w[p])/2;s.set(w.id,{...y,[f]:x+g*v})}}return s}function o_(e,t,r,n,o){const i=new Map,a=new Map(e.map(l=>[l.id,l]));for(const l of e){if(!l.parent||!a.has(l.parent))continue;const d=i.get(l.parent);d?d.push(l.id):i.set(l.parent,[l.id])}const s=(l,d=new Set)=>{var p;const f=(p=a.get(l))==null?void 0:p.parent;return!f||!a.has(f)||d.has(l)?0:(d.add(l),1+s(f,d))},u=[...i.keys()].sort((l,d)=>s(d)-s(l)),c=new Map;for(const l of u){let d=null;for(const m of i.get(l)||[]){let g=c.get(m);if(!g){const b=t.get(m);if(!b)continue;const w=r.get(m)||{w:60,h:60};g={x1:b.x-w.w/2,y1:b.y-w.h/2,x2:b.x+w.w/2,y2:b.y+w.h/2}}d=d?{x1:Math.min(d.x1,g.x1),y1:Math.min(d.y1,g.y1),x2:Math.max(d.x2,g.x2),y2:Math.max(d.y2,g.y2)}:{...g}}if(!d)continue;const f=n(l);d={x1:d.x1-f,y1:d.y1-f,x2:d.x2+f,y2:d.y2+f};const p=o(l);if(p){const m=d.x2-d.x1,g=d.y2-d.y1;if(p.w>m){const b=(p.w-m)/2;d.x1-=b,d.x2+=b}if(p.h>g){const b=(p.h-g)/2;d.y1-=b,d.y2+=b}}c.set(l,d)}return c}function i_(e){const t=e.getBoundingClientRect(),r=t.height/e.offsetHeight;if(!Number.isFinite(r)||r<=0)return[];const n=Rm(e),o={x:e.offsetWidth/2,y:e.offsetHeight/2,w:e.offsetWidth,h:e.offsetHeight},i=[...e.querySelectorAll("[data-flow-property]")],a=new Set(i.filter(s=>s.hasAttribute("data-flow-inspection-row")&&s.getBoundingClientRect().height>0).map(s=>s.dataset.flowProperty));return i.flatMap(s=>{if(s.closest(".flow-sdk-node")!==e)return[];if(a.has(s.dataset.flowProperty)&&!s.hasAttribute("data-flow-inspection-row"))return[];const u=s.dataset.flowPortSide;if(u&&["top","right","bottom","left"].includes(u)){const l=Sm(n?Ft(o,n):o,u,Number(s.dataset.flowPortPosition??.5));return[{property:s.getAttribute("data-flow-property"),top:l.y,height:0,anchor:l,...s.dataset.flowPortPlacement==="config"?{placement:"config"}:{},...s.dataset.flowPortRole==="source"||s.dataset.flowPortRole==="target"?{role:s.dataset.flowPortRole}:{}}]}const c=s.getBoundingClientRect();return!c.width||!c.height?[]:[{property:s.getAttribute("data-flow-property"),top:Math.round((c.top-t.top)/r*1e3)/1e3,height:Math.round(c.height/r*1e3)/1e3,...s.dataset.flowPortRole==="source"||s.dataset.flowPortRole==="target"?{role:s.dataset.flowPortRole}:{}}]})}function a_({id:e,x:t,y:r,placed:n,hidden:o,onMount:i,drawHandles:a,drawMode:s,connectedPorts:u,resolvedRows:c,hasCollapseControl:l,handleColor:d,animated:f,animationColor:p,animationWidth:m=8,animationVariant:g,width:b=0,height:w=0,propertyMode:y,reversePorts:x,direction:v="LR",onPropertyRows:C,onSurface:_,children:k}){const T=S.useRef(null),[P,j]=S.useState([]),R=c??P,[E,M]=S.useState();return S.useLayoutEffect(()=>{const I=T.current;if(!I)return;const N=()=>{const z=Rm(I);M(re=>JSON.stringify(re)===JSON.stringify(z)?re:z),_==null||_(e,z)};N();const O=new ResizeObserver(N);O.observe(I);const W=I.querySelector("[data-flow-node-surface]");return W&&O.observe(W),()=>O.disconnect()},[e,k,_]),S.useLayoutEffect(()=>(i(e,T.current),()=>{i(e,null),_==null||_(e,void 0)}),[e,i,_]),S.useLayoutEffect(()=>{const I=T.current;if(!I)return;let N="";const O=()=>{const te=i_(I),he=y?te:te.filter(K=>K.anchor),me=JSON.stringify(he);me!==N&&(N=me,j(he),C==null||C(e,he))};if(O(),!y&&!I.querySelector("[data-flow-port-side]"))return;const W=new ResizeObserver(O),z=()=>{W.disconnect(),W.observe(I),I.querySelectorAll("[data-flow-property]").forEach(te=>W.observe(te)),O()};z();const re=new MutationObserver(z);return re.observe(I,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["data-flow-property","data-flow-port-role","data-flow-port-side","data-flow-port-position","data-flow-port-placement"]}),I.addEventListener("scroll",O,!0),()=>{W.disconnect(),re.disconnect(),I.removeEventListener("scroll",O,!0)}},[e,y,C,k]),h.jsxs("div",{ref:T,className:"flow-sdk-node","data-node-id":e,style:{transform:`translate(-50%, -50%) translate3d(${t.toFixed(2)}px, ${r.toFixed(2)}px, 0)`,visibility:n&&!o?void 0:"hidden"},children:[k,f&&m>0&&b>0&&w>0&&h.jsx("svg",{className:"flow-sdk-node-animation","aria-hidden":"true",pointerEvents:"none",children:h.jsx(_m,{variant:g,x:((E==null?void 0:E.left)??0)+m/2,y:((E==null?void 0:E.top)??0)+m/2,width:((E==null?void 0:E.width)??b)-m,height:((E==null?void 0:E.height)??w)-m,radius:((E==null?void 0:E.radius)??0)-m/2,path:E!=null&&E.outline?`M${E.outline.map(I=>`${I.x} ${I.y}`).join(" L")} Z`:void 0,color:p||d||"currentColor",strokeWidth:m})}),a&&y&&R.map(I=>["source","target"].filter(N=>!I.role||I.role===N).filter(N=>s||(u==null?void 0:u.has(`${N}:${I.property}`))).map(N=>{var O;return h.jsx("button",{type:"button",className:"flow-sdk-property-port","data-property":I.property,"data-port-role":N,"data-port-side":(O=I.anchor)==null?void 0:O.side,"aria-label":`${N==="source"?"Connect":"Input"} ${I.property}`,title:`${N==="source"?"Connect":"Input"} ${I.property}`,style:{color:d,...I.anchor?{top:I.anchor.y,left:I.anchor.x-16}:{top:I.top+I.height/2,[N==="source"!=!!x?"right":"left"]:-16}},onClick:W=>W.stopPropagation()},`${I.property}:${N}`)})),a&&!l&&(!y||!R.length)&&(!y||!R.some(I=>I.anchor))&&h.jsx("button",{type:"button",className:"flow-sdk-handle","aria-label":"Draw edge",title:"Draw edge",style:{color:d,left:((E==null?void 0:E.left)??0)+(v==="RL"?-36:v==="LR"?(E==null?void 0:E.width)??b:((E==null?void 0:E.width)??b)/2),top:((E==null?void 0:E.top)??0)+(v==="BT"?-36:v==="TB"?(E==null?void 0:E.height)??w:((E==null?void 0:E.height)??w)/2),transform:v==="BT"||v==="TB"?"translateX(-50%)":"translateY(-50%)"},onClick:I=>I.stopPropagation(),children:h.jsx(J.PiPlusBold,{size:24})})]})}const s_=S.memo(a_);class c_{constructor(t,r,n){Tr(this,"_pan");Tr(this,"_zoom");Tr(this,"minZoom");Tr(this,"maxZoom");Tr(this,"size",{w:0,h:0});Tr(this,"listeners",new Set);Tr(this,"animationFrame");Tr(this,"animationTimer");this.minZoom=r,this.maxZoom=n,this._pan={...t.pan},this._zoom=this.clamp(t.zoom)}cancelAnimation(){this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame),clearTimeout(this.animationTimer),this.animationFrame=void 0,this.animationTimer=void 0}transition(t,r=!1){if(this.cancelAnimation(),!r||typeof requestAnimationFrame>"u"||typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches){this.set(t.pan,t.zoom);return}const n=this.state,o={pan:{...t.pan},zoom:this.clamp(t.zoom)},i=performance.now(),a=()=>{this.cancelAnimation(),this.set(o.pan,o.zoom)},s=u=>{const c=Math.min(1,(u-i)/300);if(c>=1){a();return}const l=c*c*(3-2*c);this.apply({x:n.pan.x+(o.pan.x-n.pan.x)*l,y:n.pan.y+(o.pan.y-n.pan.y)*l},n.zoom+(o.zoom-n.zoom)*l),this.animationFrame=requestAnimationFrame(s)};this.animationFrame=requestAnimationFrame(s),this.animationTimer=setTimeout(a,400)}get pan(){return{...this._pan}}get zoom(){return this._zoom}get state(){return{pan:this.pan,zoom:this._zoom}}clamp(t){return Number.isFinite(t)?Math.max(this.minZoom,Math.min(this.maxZoom,t)):this.minZoom}set(t,r){this.cancelAnimation(),this.apply(t,r)}apply(t,r){let n=!1;if(t&&(t.x!==this._pan.x||t.y!==this._pan.y)&&(this._pan={x:t.x,y:t.y},n=!0),r!==void 0){const o=this.clamp(r);o!==this._zoom&&(this._zoom=o,n=!0)}n&&this.emit()}zoomAt(t,r){const n=this.clamp(t),o=this._zoom;if(n===o)return;const i=n/o;this.set({x:r.x-(r.x-this._pan.x)*i,y:r.y-(r.y-this._pan.y)*i},n)}fit(t,r=0,n=!1){const o=t.x2-t.x1,i=t.y2-t.y1;if(!(o>0)||!(i>0)||!this.size.w||!this.size.h)return;const a=this.clamp(Math.min((this.size.w-2*r)/o,(this.size.h-2*r)/i));this.transition({pan:{x:(this.size.w-a*(t.x1+t.x2))/2,y:(this.size.h-a*(t.y1+t.y2))/2},zoom:a},n)}center(t,r=!1){if(!this.size.w||!this.size.h)return;const n=this._zoom;this.transition({pan:{x:(this.size.w-n*(t.x1+t.x2))/2,y:(this.size.h-n*(t.y1+t.y2))/2},zoom:n},r)}renderedToModel(t){return{x:(t.x-this._pan.x)/this._zoom,y:(t.y-this._pan.y)/this._zoom}}modelToRendered(t){return{x:t.x*this._zoom+this._pan.x,y:t.y*this._zoom+this._pan.y}}onChange(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}emit(){const t=this.state;this.listeners.forEach(r=>r(t))}}const u_={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},yu={w:60,h:60},sy=4,l_=30,cy=300,d_=500,f_=45,h_=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2;function uy(e){const[t,r]=[...e.values()];return!t||!r?null:{center:{x:(t.x+r.x)/2,y:(t.y+r.y)/2},distance:Math.max(1,Math.hypot(r.x-t.x,r.y-t.y))}}function p_(e){const{nodes:t,edges:r,direction:n,nodeAlignment:o="center",edgeMode:i="auto",compactPropertyLayout:a=!1,rankSep:s,edgeSep:u,spacingFactor:c=1.3,compactSpacingScale:l,minZoom:d,maxZoom:f,initialViewport:p,containerStyle:m,lineColor:g,drawMode:b,dragMode:w,multiSelect:y,isPerformanceMode:x}=e,[v,C]=S.useState(null),_=S.useMemo(()=>v?(v.mode==="connections"?Nl:Al)(v.id,t,r):null,[v,t,r]),k=i==="auto"||i==="properties",T=S.useMemo(()=>r.filter(A=>Cu(A,i)&&(!_||_.has(A.source)&&_.has(A.target))),[r,i,_]),P=S.useMemo(()=>M0(t,r,i,a,_),[t,r,i,a,_]),j=S.useRef(P);j.current=P;const R=S.useRef(e);R.current=e;const E=S.useRef(null),M=S.useRef(null),I=S.useRef(null),N=S.useRef(null),O=S.useMemo(()=>new c_(p,d,f),[]);S.useEffect(()=>{O.minZoom=d,O.maxZoom=f},[O,d,f]);const W=S.useRef(new Map),z=S.useRef(new Map),re=S.useRef(new Map),te=S.useRef(null),[he,me]=S.useState(new Map),K=S.useCallback((A,$)=>{me(F=>{if(JSON.stringify(F.get(A))===JSON.stringify($))return F;const H=new Map(F);return $?H.set(A,$):H.delete(A),H})},[]),[q,L]=S.useState(new Map),G=S.useRef(q),B=S.useCallback((A,$)=>{L(F=>{if(JSON.stringify(F.get(A)??[])===JSON.stringify($))return F;const H=new Map(F);return $.length?H.set(A,$):H.delete(A),H})},[]),[Y,ce]=S.useState(()=>new Map),X=S.useRef(Y);X.current=Y;const U=S.useRef(new Map),Z=S.useRef(!1),[ae,ue]=S.useState(0),de=S.useRef(),Ee=S.useRef(),ge=S.useRef(null),He=S.useRef(),Le=S.useRef(!1),Xe=S.useRef(null),ur=S.useRef(c),Ge=a,Ne=S.useRef(Ge),[xe,Ie]=S.useState(!0),$e=S.useRef(null);$e.current=_;const tr=S.useRef(1);tr.current=(v==null?void 0:v.mode)==="connections"?1.25:1;const Je=S.useRef(null),Ze=S.useRef(t),fr=S.useRef([]),wr=S.useRef(!1),Ce=()=>{ge.current!==null&&cancelAnimationFrame(ge.current),ge.current=null,clearTimeout(He.current)},ir=()=>{fr.current.length&&(wr.current=!0),!Z.current&&R.current.fitOnInit!==!1&&(Le.current=!0),clearTimeout(Ee.current),Ee.current=setTimeout(()=>{Z.current=!0,ue(A=>A+1)},d_)},ar=A=>{Ce();const $=new Map(X.current),F=performance.now(),H=()=>{Ce(),ce(A),ir()},oe=pe=>{const Re=Math.min(1,(pe-F)/cy);if(Re>=1)return H();const Te=h_(Re),ie=new Map;A.forEach((se,le)=>{const ye=$.get(le);ie.set(le,ye?{x:ye.x+(se.x-ye.x)*Te,y:ye.y+(se.y-ye.y)*Te}:se)}),ce(ie),ge.current=requestAnimationFrame(oe)};ge.current=requestAnimationFrame(oe),He.current=setTimeout(H,cy+100)},Ct=()=>{const A=R.current,$=tr.current,F=j.current,H=F.nodes.map(pe=>{const Re=W.current.get(pe.id)||yu;return{id:pe.id,parent:pe.parent,width:Re.w,height:Re.h}});let oe;try{const pe=A.compactPropertyLayout,Re=A.edgeMode!=="nodes"&&A.edgeMode!=="workflow",Te=F.edges.map(ie=>({...ie,connectorClearance:pe?Re&&(ie.sourceProperty!==void 0||ie.targetProperty!==void 0)?I0:O0:0}));oe=n_(H,Te,{edgeLabelFontSize:A.edgeMode==="nodes"||A.edgeMode==="workflow"?km:pn,rankDir:A.direction,compact:pe,nodeAlignment:A.nodeAlignment,rankSep:A.rankSep*$,edgeSep:A.edgeSep*$,nodeSep:5*$,spacingFactor:A.spacingFactor??1.3,compactSpacingScale:(A.compactSpacingScale??(A.spacingFactor??1.3)/1.3)*$})}catch(pe){console.warn("[flow-sdk] layout failed",pe);return}for(const[pe,Re]of U.current)oe.has(pe)?oe.set(pe,Re):A.nodes.some(Te=>Te.id===pe)||U.current.delete(pe);Z.current&&!A.isPerformanceMode?ar(oe):(Ce(),ce(oe),ir())},ne=S.useCallback(()=>{clearTimeout(Ee.current),clearTimeout(de.current),de.current=setTimeout(Ct,R.current.layoutDebounce)},[]);S.useEffect(()=>{const A=new Map(Ze.current.map($=>[$.id,$]));t.some($=>{var F;return((F=A.get($.id))==null?void 0:F.collapsed)===!0&&!$.collapsed})&&(fr.current=t.filter($=>!A.has($.id)).map($=>$.id)),Ze.current=t,ur.current!==c&&X.current.size>0&&(Z.current=!0,Le.current=!1,clearTimeout(Ee.current)),ur.current=c,Ne.current!==Ge&&(Le.current=!Xe.current),Ne.current=Ge,ne()},[t,r,P.nodes,P.edges,Ge,n,o,s,u,ne,c,l]),S.useEffect(()=>()=>{clearTimeout(de.current),clearTimeout(Ee.current),Ce()},[]);const ze=S.useCallback((A,$)=>{var F,H;if(!te.current&&typeof ResizeObserver<"u"&&(te.current=new ResizeObserver(oe=>{let pe=!1;for(const Re of oe){const Te=re.current.get(Re.target);if(!Te)continue;const ie=Re.target,se=ie.offsetWidth,le=ie.offsetHeight;if(!se&&!le)continue;const ye=W.current.get(Te);ye&&ye.w===se&&ye.h===le||(W.current.set(Te,{w:se,h:le}),pe=!0)}pe&&ne()})),$){z.current.set(A,$),re.current.set($,A),(F=te.current)==null||F.observe($);const oe=$.offsetWidth,pe=$.offsetHeight;(oe||pe)&&W.current.set(A,{w:oe,h:pe})}else{const oe=z.current.get(A);oe&&((H=te.current)==null||H.unobserve(oe),re.current.delete(oe)),z.current.delete(A),W.current.delete(A),G.current.has(A)&&B(A,[])}ne()},[ne,B]);S.useEffect(()=>()=>{var A;return(A=te.current)==null?void 0:A.disconnect()},[]);const Qe=S.useMemo(()=>{const A=new Map;for(const $ of t)$.label&&A.set($.id,$.label);return A},[t]),Fe=S.useMemo(()=>o_(P.nodes,Y,W.current,A=>m(A).padding,A=>{const $=Qe.get(A);if(!$)return;const F=m(A);return{w:Sn($,`bold ${F.fontSize}px ${rt}`)+2*f_,h:0}}),[P.nodes,Y,m,Qe]),er=S.useRef(Fe);er.current=Fe;const Be=S.useCallback(A=>{const $=er.current.get(A);if($)return b0($);const F=X.current.get(A);if(!F)return;const H=W.current.get(A)||yu;return{x:F.x,y:F.y,w:H.w,h:H.h}},[]),Q=S.useMemo(()=>{const A=new Map;for(const $ of t){const F=Be($.id);F&&A.set($.id,F)}return R0(q,A,he,r,n)},[q,t,Y,Fe,he,r,n,Be]);G.current=Q;const V=(A,$)=>{var oe;if(!k||$===void 0)return;const F=(oe=Q.get(A))==null?void 0:oe.find(pe=>pe.property===$),H=Be(A);return F&&!F.anchor&&H?H.y-H.h/2+F.top+F.height/2:void 0},ee=(A,$)=>{var oe,pe;if($===void 0)return;const F=(pe=(oe=Q.get(A))==null?void 0:oe.find(Re=>Re.property===$))==null?void 0:pe.anchor,H=Be(A);return F&&H?{x:H.x-H.w/2+F.x,y:H.y-H.h/2+F.y,side:F.side}:void 0},we=(A,$)=>{const F=Be(A),H=he.get(A);return F&&H&&!Fe.has(A)&&V(A,$)===void 0?Ft(F,H):F},_e=()=>{const A=[];X.current.forEach(($,F)=>{if(er.current.has(F))return;const H=W.current.get(F)||yu;A.push(ct({x:$.x,y:$.y,w:H.w,h:H.h}))}),er.current.forEach($=>A.push($));try{for(const $ of[M.current,I.current]){const F=$==null?void 0:$.getBBox();F&&F.width>0&&F.height>0&&A.push({x1:F.x,y1:F.y,x2:F.x+F.width,y2:F.y+F.height})}}catch{}return Yn(A)},Se=()=>{var F,H;const{pan:A,zoom:$}=O;N.current&&(N.current.style.transform=`translate3d(${A.x}px, ${A.y}px, 0) scale(${$})`),(F=M.current)==null||F.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${$})`),(H=I.current)==null||H.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${$})`)};S.useEffect(()=>{Se();let A=null,$;const F=O.onChange(()=>{Se();const H=E.current;H&&(H.classList.add("flow-sdk-busy"),clearTimeout($),$=setTimeout(()=>H.classList.remove("flow-sdk-busy"),150)),A===null&&(A=requestAnimationFrame(()=>{var oe,pe;A=null,(pe=(oe=R.current).onViewportChange)==null||pe.call(oe,O.state)}))});return()=>{F(),clearTimeout($),A!==null&&cancelAnimationFrame(A)}},[]),S.useLayoutEffect(()=>{const A=E.current;if(!A)return;const $=()=>{let H=A.clientWidth,oe=A.clientHeight;oe||(oe=Math.max(0,window.innerHeight-A.getBoundingClientRect().top-100),oe&&(A.style.height=`${oe}px`)),H||(H=window.innerWidth,H&&(A.style.width=`${H}px`)),O.size={w:H,h:oe}};if($(),typeof ResizeObserver>"u")return;const F=new ResizeObserver($);return F.observe(A),()=>F.disconnect()},[O]),S.useEffect(()=>{if(wr.current){wr.current=!1;const $=fr.current.flatMap(H=>{const oe=Be(H);return oe?[ct(oe)]:[]});fr.current=[];const F=Yn($);if(F){Le.current=!1,O.center(F,R.current.animateViewport);return}}if(!Le.current)return;Le.current=!1;const A=_e();A&&O.fit(A,50,R.current.animateViewport)},[Y]);const Ve=S.useMemo(()=>{const A=ie=>Al(ie,R.current.nodes,R.current.edges),$=(ie,se=50,le=R.current.animateViewport)=>{const ye=Yn([...ie].flatMap(lr=>{const _t=Be(lr);return _t?[ct(_t)]:[]}));ye&&(Le.current=!1,O.fit(ye,Number.isFinite(se)?Math.max(0,se):50,le))},F=(ie,se,le,ye)=>{if(!Be(ie))return;const lr=se==="connections"?oe(ie):A(ie);Je.current||(Je.current={pan:{...O.pan},zoom:O.zoom}),$e.current=lr,R.current.compactPropertyLayout&&(Le.current=!1,Xe.current=()=>$($e.current??lr,le,ye)),C({id:ie,mode:se}),R.current.compactPropertyLayout||$(lr,le,ye)},H=ie=>{Xe.current?Xe.current=ie:ie()},oe=ie=>Nl(ie,R.current.nodes,R.current.edges),pe=(ie=>{if(ie===void 0)return O.zoom;O.set(void 0,ie)}),Re=(ie=>{if(ie===void 0)return O.pan;O.set(ie)}),Te=(ie,se)=>{var ye;const le=(ye=E.current)==null?void 0:ye.getBoundingClientRect();return{x:ie-((le==null?void 0:le.left)??0),y:se-((le==null?void 0:le.top)??0)}};return{zoom:pe,pan:Re,setEdgesVisible:Ie,focusNode:(ie,se,le)=>H(()=>$(new Set([ie]),se,le)),focusBranch:(ie,se,le)=>H(()=>$(A(ie),se,le)),focusConnections:(ie,se,le)=>H(()=>$(oe(ie),se,le)),isolateConnections:(ie,se,le)=>F(ie,"connections",se,le),isolateBranch:(ie,se,le)=>F(ie,"branch",se,le),restoreView:(ie=R.current.animateViewport)=>{const se=R.current.compactPropertyLayout&&!!$e.current;$e.current=null,C(null);const le=Je.current;Je.current=null,se?Xe.current=()=>{le&&O.transition(le,ie)}:le&&H(()=>O.transition(le,ie))},zoomAt:(ie,se)=>O.zoomAt(ie,se),fit:(ie=0,se=R.current.animateViewport)=>{H(()=>{const le=_e();le&&O.fit(le,ie,se)})},centerAndFit:(ie=0,se=R.current.animateViewport)=>{H(()=>{const le=_e();le&&O.fit(le,ie,se)})},center:(ie=R.current.animateViewport)=>{const se=_e();se&&O.center(se,ie)},clientToModel:(ie,se)=>O.renderedToModel(Te(ie,se)),modelToClient:ie=>{var ye;const se=(ye=E.current)==null?void 0:ye.getBoundingClientRect(),le=O.modelToRendered(ie);return{x:le.x+((se==null?void 0:se.left)??0),y:le.y+((se==null?void 0:se.top)??0)}},getNodeBox:ie=>Be(ie),setNodePosition:(ie,se,le)=>{if(!X.current.has(ie)||se&&(!Number.isFinite(se.x)||!Number.isFinite(se.y)))return!1;if(Ce(),!se)return U.current.delete(ie),ne(),!0;const ye=new Map(X.current);return ye.set(ie,{...se}),(le==null?void 0:le.persist)===!1?U.current.delete(ie):U.current.set(ie,{...se}),X.current=ye,ce(ye),(le==null?void 0:le.persist)===!1&&ne(),!0},onViewportChange:ie=>O.onChange(ie)}},[]);S.useEffect(()=>{var A,$;return($=(A=R.current).onInit)==null||$.call(A,Ve),()=>O.cancelAnimation()},[Ve]),S.useEffect(()=>{var A,$;if(ae>0){const F=Xe.current;Xe.current=null,F==null||F(),($=(A=R.current).onLayoutComplete)==null||$.call(A,Ve)}},[Ve,ae]);const ke=S.useRef(null),Me=S.useRef(new Map),De=S.useRef(!1),[gr,sr]=S.useState(null),[Pe,Er]=S.useState(null),Ar=A=>{const $=E.current.getBoundingClientRect();return{x:A.clientX-$.left,y:A.clientY-$.top}},Lr=(A,$)=>{const F=R.current.nodes;for(let H=F.length-1;H>=0;H--){const oe=F[H].id;if(!ut(oe,R.current.edges,R.current.edgeMode)||$e.current&&!$e.current.has(oe)||oe===$||er.current.has(oe))continue;const pe=Be(oe);if(pe&&Tl(A,ct(pe)))return oe}for(const[H,oe]of er.current)if(ut(H,R.current.edges,R.current.edgeMode)&&!($e.current&&!$e.current.has(H))&&H!==$&&Tl(A,oe))return H;return null},Wn=(A,$)=>{if(R.current.edgeMode==="nodes"||R.current.edgeMode==="workflow")return null;const F=R.current.direction==="RL",H=Math.max(16,6/O.zoom);let oe=null;for(const pe of[...R.current.nodes].reverse()){if(!ut(pe.id,R.current.edges,R.current.edgeMode)||$e.current&&!$e.current.has(pe.id))continue;const Re=Be(pe.id),Te=G.current.get(pe.id);if(!Re||!Te||er.current.has(pe.id))continue;const ie=Re.x+($==="source"!==F?1:-1)*Re.w/2;for(const se of Te){if(se.role&&se.role!==$)continue;const le=Re.y-Re.h/2+se.top,ye=Math.hypot(A.x-(se.anchor?Re.x-Re.w/2+se.anchor.x:ie),A.y-le-se.height/2);if(!se.anchor&&A.x>=Re.x-Re.w/2&&A.x<=Re.x+Re.w/2&&A.y>=le&&A.y<=le+se.height)return{nodeId:pe.id,property:se.property};ye<=H&&(!oe||ye<oe.distance)&&(oe={nodeId:pe.id,property:se.property,distance:ye})}}return oe},Db=A=>{var Re;if(!A.currentTarget.contains(A.target)||A.button!==0||R.current.readOnly)return;ke.current||(De.current=!1);const $=A.target;if($.closest('input, textarea, select, [contenteditable="true"], [data-flow-content-toggle]'))return;const F=R.current,H=Ar(A);if(A.pointerType==="touch"){Me.current.set(A.pointerId,H);const Te=uy(Me.current);if(Te){ke.current={kind:"pinch",distance:Te.distance,zoom:O.zoom,anchor:O.renderedToModel(Te.center)},Er(null),sr(null),De.current=!0;for(const ie of Me.current.keys())A.currentTarget.setPointerCapture(ie);return}}if(ke.current)return;const oe=F.drawHandles&&$.closest(".flow-sdk-handle"),pe=F.drawHandles&&$.closest(".flow-sdk-property-port");if(F.drawMode||oe||pe){const Te=O.renderedToModel(H),ie=F.drawMode?Wn(Te,"source"):null,se=pe||oe,le=se?(Re=se.closest("[data-node-id]"))==null?void 0:Re.dataset.nodeId:(ie==null?void 0:ie.nodeId)??Lr(Te),ye=pe?pe.dataset.property:ie==null?void 0:ie.property;if(le){ke.current={kind:"draw",pointerId:A.pointerId,source:le,sourceProperty:ye,reverse:(pe==null?void 0:pe.dataset.portRole)==="target",startClient:{x:A.clientX,y:A.clientY}},De.current=!0,Er({source:le,sourceProperty:ye,point:Te,target:null}),A.currentTarget.setPointerCapture(A.pointerId);return}}$.closest(".flow-sdk-node, .flow-sdk-container, .flow-sdk-edge, .flow-sdk-edge-label, .flow-sdk-container-label")||(F.multiSelect?ke.current={kind:"box",pointerId:A.pointerId,start:H,current:H}:F.dragMode?ke.current={kind:"pan",pointerId:A.pointerId,start:H,pan0:O.pan,moved:!1}:ke.current={kind:"tap",pointerId:A.pointerId,start:H,moved:!1},A.currentTarget.setPointerCapture(A.pointerId))},zb=A=>{const $=ke.current;if(!$||R.current.readOnly)return;const F=Ar(A);if(Me.current.has(A.pointerId)&&Me.current.set(A.pointerId,F),$.kind==="pinch"){const H=uy(Me.current);if(!H)return;const oe=Math.max(O.minZoom,Math.min(O.maxZoom,$.zoom*H.distance/$.distance));O.set({x:H.center.x-$.anchor.x*oe,y:H.center.y-$.anchor.y*oe},oe);return}if($.pointerId===A.pointerId)switch($.kind){case"pan":{const H=F.x-$.start.x,oe=F.y-$.start.y;if(!$.moved&&Math.hypot(H,oe)<=sy)return;$.moved=!0,De.current=!0,O.set({x:$.pan0.x+H,y:$.pan0.y+oe});break}case"tap":{Math.hypot(F.x-$.start.x,F.y-$.start.y)>sy&&($.moved=!0);break}case"box":{De.current=!0,$.current=F,sr({x1:Math.min($.start.x,F.x),y1:Math.min($.start.y,F.y),x2:Math.max($.start.x,F.x),y2:Math.max($.start.y,F.y)});break}case"draw":{const H=O.renderedToModel(F),oe=Wn(H,$.reverse?"source":"target");Er($.reverse&&oe?{source:oe.nodeId,sourceProperty:oe.property,point:H,target:$.source,targetProperty:$.sourceProperty}:{source:$.source,sourceProperty:$.sourceProperty,point:H,target:(oe==null?void 0:oe.nodeId)??Lr(H,$.source),targetProperty:oe==null?void 0:oe.property});break}}},il=(A,$)=>{var oe,pe,Re,Te,ie;Me.current.delete(A.pointerId);const F=ke.current;if(!F)return;if(F.kind==="pinch"){const se=[...Me.current][0];ke.current=se&&R.current.dragMode&&!$?{kind:"pan",pointerId:se[0],start:se[1],pan0:O.pan,moved:!0}:null;return}if(F.pointerId!==A.pointerId)return;ke.current=null;try{A.currentTarget.releasePointerCapture(A.pointerId)}catch{}const H=R.current;switch($=$||!!H.readOnly,F.kind){case"pan":case"tap":!$&&!F.moved&&((oe=H.onBackgroundTap)==null||oe.call(H));break;case"box":{if(sr(null),$)break;const se=O.renderedToModel(F.start),le=O.renderedToModel(F.current),ye={x1:Math.min(se.x,le.x),y1:Math.min(se.y,le.y),x2:Math.max(se.x,le.x),y2:Math.max(se.y,le.y)};if(ye.x2-ye.x1<1&&ye.y2-ye.y1<1){(pe=H.onBackgroundTap)==null||pe.call(H);break}const lr=[];for(const _t of H.nodes){const cl=Be(_t.id);cl&&v0(ct(cl),ye)&&lr.push(_t.id)}lr.length&&((Re=H.onBoxSelect)==null||Re.call(H,lr));break}case"draw":{if(Er(null),$)break;const se=Ar(A),le=O.renderedToModel(se),ye=Wn(le,F.reverse?"source":"target"),lr=(ye==null?void 0:ye.nodeId)??Lr(le);if(lr===F.source&&(F.sourceProperty===void 0||(ye==null?void 0:ye.property)===void 0||ye.property===F.sourceProperty))break;lr?(Te=H.onEdgeDraw)==null||Te.call(H,F.reverse?lr:F.source,F.reverse?F.source:lr,F.sourceProperty!==void 0||(ye==null?void 0:ye.property)!==void 0?{sourceProperty:F.reverse?ye==null?void 0:ye.property:F.sourceProperty,targetProperty:F.reverse?F.sourceProperty:ye==null?void 0:ye.property}:void 0):Math.max(Math.abs(A.clientX-F.startClient.x),Math.abs(A.clientY-F.startClient.y))>l_&&((ie=H.onDrawIntoSpace)==null||ie.call(H,F.source,le,F.sourceProperty,F.reverse));break}}},Kr=S.useCallback(()=>{var F;const A=ke.current,$=[...Me.current.keys()];A&&A.kind!=="pinch"&&$.push(A.pointerId),ke.current=null,Me.current.clear(),Er(null),sr(null);for(const H of $)(F=E.current)!=null&&F.hasPointerCapture(H)&&E.current.releasePointerCapture(H)},[]);S.useEffect(()=>{const A=$=>{$.key==="Escape"&&Kr()};return window.addEventListener("keydown",A),window.addEventListener("blur",Kr),()=>{window.removeEventListener("keydown",A),window.removeEventListener("blur",Kr),ke.current=null,Me.current.clear()}},[Kr]),S.useEffect(()=>{Kr()},[b,w,y,i,n,e.drawHandles,e.readOnly,Kr]);const Vb=S.useMemo(()=>{const A=new Map,$=new Map;for(const F of T){if(F.source!==F.target)continue;const H=A.get(F.source)??0;A.set(F.source,H+1),$.set(F.id,H)}return $},[T]),Gn=u_[n],[Un,Wb]=S.useState(null);S.useLayoutEffect(()=>{E.current&&Un&&F0(E.current)});const Hn=m0(T,we,Gn),Gb=e.onEdgeSelect,Ub=e.onContainerSelect,al=Pe?Pe.target&&we(Pe.target,Pe.targetProperty)||{x:Pe.point.x,y:Pe.point.y,w:1,h:1}:null,sl=Pe?we(Pe.source,Pe.sourceProperty):null,Hb=["flow-sdk-canvas",b?"flow-sdk-draw":"",x?"flow-sdk-perf":""].filter(Boolean).join(" ");return h.jsxs("div",{ref:E,className:Hb,"data-edge-mode":i,onPointerDownCapture:Db,onPointerMove:zb,onPointerUp:A=>il(A,!1),onPointerCancel:A=>il(A,!0),onLostPointerCapture:A=>{const $=ke.current;$&&($.kind==="pinch"||$.pointerId===A.pointerId)&&Kr()},onClickCapture:A=>{A.currentTarget.contains(A.target)&&(De.current||e.readOnly)&&(A.preventDefault(),A.stopPropagation())},children:[h.jsx("svg",{className:"flow-sdk-svg",children:h.jsxs("g",{ref:M,children:[h.jsx("g",{className:"flow-sdk-containers",children:[...Fe].filter(([A])=>ut(A,r,i)).filter(([A])=>!_||_.has(A)).map(([A,$])=>{var F;return h.jsx(T0,{id:A,rect:$,label:Qe.get(A),labelLayer:Un,style:m(A),onSelect:Ub,onCollapse:e.readOnly?void 0:e.onContainerCollapse,selected:(F=e.selectedNodeIds)==null?void 0:F.includes(A)},A)})}),h.jsx("g",{className:"flow-sdk-edges",children:xe&&T.map(A=>{var H,oe,pe;if(_&&(!_.has(A.source)||!_.has(A.target)))return null;const $=we(A.source,A.sourceProperty),F=we(A.target,A.targetProperty);return!$||!F?null:h.jsx($l,{id:A.id,edgeData:A.data,validationIssue:A.validationIssue,edgeType:A.type,edgeRadius:e.edgeRadius,propertyMode:k,customEdgeTypes:e.customEdgeTypes,source:$,target:F,sourceProperty:A.sourceProperty,targetProperty:A.targetProperty,sourceY:V(A.source,A.sourceProperty),targetY:V(A.target,A.targetProperty),sourcePort:ee(A.source,A.sourceProperty),targetPort:ee(A.target,A.targetProperty),dir:Gn,turn:((H=Hn.get(A.id))==null?void 0:H.turn)??A.turn,labelAtTarget:(oe=Hn.get(A.id))==null?void 0:oe.labelAtTarget,labelFraction:(pe=Hn.get(A.id))==null?void 0:pe.labelFraction,color:A.color,labelBg:A.labelBg,label:A.label,labelLayer:Un,dashed:A.dashed,animated:A.animated&&!x,inverted:A.inverted,loopIndex:Vb.get(A.id)??0,onSelect:Gb},A.id)})}),xe&&Pe&&Cu(Pe,i)&&sl&&al&&h.jsx("g",{className:"flow-sdk-ghost",pointerEvents:"none",children:h.jsx($l,{id:"__flow-sdk-ghost",edgeData:{id:"__flow-sdk-ghost",source:Pe.source,target:Pe.target??"",sourceProperty:Pe.sourceProperty,targetProperty:Pe.targetProperty},edgeType:e.edgeType,edgeRadius:e.edgeRadius,propertyMode:k,customEdgeTypes:e.customEdgeTypes,source:sl,target:al,sourceProperty:Pe.sourceProperty,targetProperty:Pe.targetProperty,sourceY:V(Pe.source,Pe.sourceProperty),sourcePort:ee(Pe.source,Pe.sourceProperty),targetPort:Pe.target?ee(Pe.target,Pe.targetProperty):void 0,targetY:Pe.target?V(Pe.target,Pe.targetProperty):void 0,dir:Gn,turn:.5,color:g,labelBg:g})})]})}),h.jsx("div",{ref:N,className:"flow-sdk-nodes",children:t.map(A=>{var pe,Re;const $=Y.get(A.id),F=Fe.get(A.id),H=($==null?void 0:$.x)??(F?(F.x1+F.x2)/2:0),oe=($==null?void 0:$.y)??(F?(F.y1+F.y2)/2:0);return h.jsx(s_,{id:A.id,x:H,y:oe,placed:!!$||!!F,hidden:!ut(A.id,r,i)||!!_&&!_.has(A.id),onMount:ze,drawHandles:e.drawHandles&&!e.readOnly,drawMode:b,connectedPorts:new Set(T.flatMap(Te=>[...Te.source===A.id&&Te.sourceProperty!==void 0?[`source:${Te.sourceProperty}`]:[],...Te.target===A.id&&Te.targetProperty!==void 0?[`target:${Te.targetProperty}`]:[]])),hasCollapseControl:A.hasCollapseControl,handleColor:g,animated:A.animated&&!F&&!x,animationColor:A.animationColor,animationWidth:A.animationWidth,animationVariant:A.animationVariant,width:(pe=W.current.get(A.id))==null?void 0:pe.w,height:(Re=W.current.get(A.id))==null?void 0:Re.h,propertyMode:k,resolvedRows:Q.get(A.id),reversePorts:n==="RL",direction:n,onPropertyRows:B,onSurface:K,children:A.element},A.id)})}),gr&&h.jsx("div",{className:"flow-sdk-box",style:{left:gr.x1,top:gr.y1,width:gr.x2-gr.x1,height:gr.y2-gr.y1}}),h.jsx("svg",{className:"flow-sdk-svg flow-sdk-label-overlay",style:{zIndex:11,pointerEvents:"none"},children:h.jsx("g",{ref:I,transform:`translate(${O.pan.x} ${O.pan.y}) scale(${O.zoom})`,children:h.jsx("g",{ref:Wb,className:"flow-sdk-labels",style:{pointerEvents:b?"none":"visiblePainted",outline:"none"}})})})]})}const g_=S.memo(p_);function Ob({id:e,label:t,role:r,side:n,position:o=.5,placement:i,children:a,style:s}){return h.jsx("div",{"data-flow-property":e,"data-flow-port-role":r,"data-flow-port-side":n,"data-flow-port-position":n?o:void 0,"data-flow-port-placement":i,style:{minHeight:32,display:"flex",alignItems:"center",justifyContent:r==="source"?"flex-end":"flex-start",...s,...n?{display:"none"}:{}},children:a??t??e})}const y_=mn.default.dialog`
156
+ `;function kl({request:e,property:t,config:r,value:n,disabled:o}){var L,G;const{callbacks:i,structured:a,references:s}=S.useContext(kr),{themeColor:u}=Oe(),{background:c}=Ue(),l=S.useId(),d=t.type.kind==="object"||t.type.kind==="array"||t.type.kind==="json",f=n===void 0?"":d?JSON.stringify(n,null,2):String(n),[p,b]=S.useState(f),[g,m]=S.useState(""),[w,y]=S.useState(0),[x,v]=S.useState(),C=((L=r.$options)==null?void 0:L.$source)==="callback",_=i.resolveFormOptions,{data:k,address:T,nodeAddress:P,nodeId:j}=e,R=S.useRef(k);R.current=k;const E=JSON.stringify([T,j,(G=r.$options)!=null&&G.$dependsOn?r.$options.$dependsOn.map(B=>ve(k,B)):ve(k,P)]);S.useEffect(()=>{b(f),m("")},[f,T,j]),S.useEffect(()=>{if(!C)return;const B=new AbortController;return Promise.resolve().then(()=>{if(!_)throw new Error("No options resolver configured");return _({address:T,nodeAddress:P,nodeId:j,data:Gt(R.current),signal:B.signal})}).then(Y=>{if(!Array.isArray(Y)||Y.some(ce=>!ce||typeof ce.label!="string"||!["string","number","boolean"].includes(typeof ce.value)&&ce.value!==null))throw new Error("Invalid options response");B.signal.aborted||v({key:E,options:Y})}).catch(Y=>{B.signal.aborted||v({key:E,options:[],error:Y instanceof Error?Y.message:"Options unavailable"})}),()=>B.abort()},[C,_,E,T,P,j,w]);const M=C&&(x==null?void 0:x.key)!==E,I=C?(x==null?void 0:x.key)===E?x.options:[]:t.type.kind==="null"?[{label:"Null",value:null}]:t.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:Lt(t.type),N=t.type.kind==="array",O=(a&&d||r.$control==="checkbox"?"pills":r.$control)??(I?N||t.type.kind==="boolean"?"pills":"select":t.type.kind==="boolean"?"checkbox":d?"textarea":"input"),W=!t.optional||!!r.$requiredWhen&&wn(r.$requiredWhen,k),z=!!(s!=null&&s.length)&&typeof n=="string"&&n.includes("{{"),re=g||C&&(x==null?void 0:x.key)===E&&x.error||!z&&Rr(t.type,n,W),te=Cr(r.$label??T.split(".").pop()),he=B=>{var Y;if(!(o||Object.is(B,n)))try{(Y=i.onFormChange)==null||Y.call(i,{...e,previousValue:n,value:B}),m("")}catch(ce){m(ce instanceof Error?ce.message:"Unable to update field")}},be=()=>{if(d){try{const X=p===""&&t.optional?void 0:JSON.parse(p),U=Rr(t.type,X,W);if(U){m(U);return}he(X)}catch{m("Enter valid JSON")}return}const B=t.type.kind==="number"||t.type.kind==="integer",Y=p===""&&t.optional?void 0:B&&p!==""?Number(p):p,ce=Rr(t.type,Y,W);if(B&&ce&&p!==""){m(ce);return}he(Y)},K={id:l,disabled:o,"aria-label":te,"aria-required":W,"aria-invalid":!!re,"aria-describedby":re?`${l}-error`:void 0},q=fe(u);return h.jsxs("div",{"data-form-field":T,"data-flow-property":T.slice(P.length+1),children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[h.jsxs("label",{htmlFor:l,children:[te,W?" *":""]}),t.optional&&n!==void 0&&h.jsx("button",{type:"button","aria-label":`Reset ${te}`,title:`Reset ${te}`,disabled:o,style:{width:24,height:24,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:0,background:"transparent",color:"inherit"},onClick:()=>he(void 0),children:h.jsx(J.PiArrowCounterClockwise,{size:14})})]}),!!(s!=null&&s.length)&&!d&&h.jsx(r0,{label:te,value:n,references:s,disabled:o,onChange:he}),z?null:O==="select"?h.jsxs("div",{"data-form-select":"",children:[h.jsxs("select",{...K,disabled:o||M||!!(x!=null&&x.error),value:(I==null?void 0:I.findIndex(B=>Object.is(B.value,n)))??-1,onChange:B=>{const Y=I==null?void 0:I[Number(B.target.value)];Y&&he(Y.value)},children:[h.jsx("option",{value:-1,disabled:!0,children:n!==void 0?String(n):""}),I==null?void 0:I.map((B,Y)=>h.jsx("option",{value:Y,style:{background:fe(c)},children:Cr(B.label)||B.label},Y))]}),h.jsx(J.PiCaretDown,{size:16,"aria-hidden":"true"})]}):O==="pills"?h.jsxs("div",{id:l,role:"group","aria-label":te,"aria-describedby":K["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[I==null?void 0:I.map((B,Y)=>{const ce=N?Array.isArray(n)&&n.includes(B.value):Object.is(n,B.value);return h.jsx("button",{type:"button",disabled:o||M,"aria-pressed":ce,style:{padding:"8px 16px",borderRadius:24,border:0,color:ce?q:"inherit",background:ce?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>he(N?ce?n.filter(X=>X!==B.value):[...Array.isArray(n)?n:[],B.value]:B.value),children:Cr(B.label)||B.label},Y)}),M&&h.jsx("span",{role:"status",children:"Loading..."})]}):O==="textarea"?h.jsx("textarea",{...K,value:p,onChange:B=>b(B.target.value),onBlur:be}):h.jsx("input",{...K,type:t.type.kind==="number"||t.type.kind==="integer"?"number":"text",step:t.type.kind==="integer"?1:"any",value:p,onChange:B=>b(B.target.value),onBlur:be,onKeyDown:B=>{B.key==="Enter"&&be(),B.key==="Escape"&&b(n===void 0?"":String(n))}}),re&&h.jsx("div",{role:"alert",id:`${l}-error`,children:re}),C&&(x==null?void 0:x.error)&&h.jsx("button",{type:"button",disabled:o,onClick:()=>{v(void 0),y(w+1)},children:"Retry"})]})}function ob({nodeAddress:e}){var v,C;const{data:t,schema:r,callbacks:n,bindings:o,editable:i,renderForm:a,structured:s}=S.useContext(kr),{readOnly:u,config:c}=Oe(),l=a==null?void 0:a(e);if(l!==void 0)return h.jsx("fieldset",{"data-flow-form":e,disabled:u||c.editable===!1||!i,style:{border:0,margin:0,padding:0,minWidth:0},children:l});if(!t)return h.jsx(on,{role:"alert",children:"Forms require a JSON document."});const d=o?Xt(o,e,r):void 0,f=o?d:r&&yt(t,e,r);if(!f)return h.jsx(on,{role:"status",children:"Form schema unavailable."});const p=(d==null?void 0:d.address)??e,b=ve(t,p),g=(v=s==null?void 0:s.containers.get(e))==null?void 0:v.scalar;if(b===void 0||typeof b!="object"&&!g)return h.jsx(on,{role:"alert",children:"Bound form state is unavailable."});const m=Object.entries(f.type.properties).filter(([_])=>{var k;return wn((k=f.fields[_])==null?void 0:k.$visibleWhen,t)}),w=m.length>8||m.some(([_])=>{var k;return(k=f.fields[_])==null?void 0:k.$section}),y=new Map;for(const _ of m){const[k,T]=_,P=w?Cr(((C=f.fields[k])==null?void 0:C.$section)??(T.type.kind==="object"||T.type.kind==="array"?k:T.optional?"Options":"General")):"";y.has(P)||y.set(P,[]),y.get(P).push(_)}const x=([_,k])=>h.jsx(kl,{request:{data:t,address:g?p:`${p}.${_}`,nodeAddress:p,nodeId:typeof(b==null?void 0:b.id)=="string"?b.id:void 0},property:k,config:f.fields[_]??{},value:g?b:b==null?void 0:b[_],disabled:u||c.editable===!1||!(i??!!n.onJsonChange)},`${(b==null?void 0:b.id)??e}:${_}`);return h.jsxs(on,{"data-flow-form":e,onClick:_=>_.stopPropagation(),onDoubleClick:_=>_.stopPropagation(),children:[s&&h.jsx(a0,{nodeAddress:e}),d&&f.type.additionalProperties&&m.length===0&&h.jsx(kl,{request:{data:t,address:p,nodeAddress:p},property:{type:f.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:b,disabled:u||c.editable===!1||!i}),[...y].map(([_,k])=>w&&k.length>1?h.jsxs("details",{open:!0,children:[h.jsxs("summary",{children:[h.jsx("span",{children:_}),h.jsx(J.PiCaretDown,{size:16,"aria-hidden":"true"})]}),k.map(x)]},_):k.map(x))]})}function ib(e){const{viewData:t}=S.useContext(kr),{nodeById:r,edgeById:n,parentIds:o}=Ur();if(t){const i=ve(t,e),a=i&&typeof i=="object"&&!Array.isArray(i)&&"$"in i?i.$:i;return Array.isArray(a)?a.length>0:!!a&&typeof a=="object"&&Object.entries(a).some(([s,u])=>!s.startsWith("$")&&u!==null&&typeof u=="object")}return o.has(e)?!0:[...n.values()].some(({data:i})=>{const a=i.isInverted?i.target:i.source,s=i.isInverted?i.source:i.target;return a===e&&s!==e&&r.has(s)})}function Kt(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:t}function fn(e,t,r,n){return{borderColor:t,borderWidth:Kt(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...gy(t==="transparent"?"currentColor":t,r,".flow-sdk-node:hover &",!r)}}function ab({label:e,value:t,options:r,onChange:n,disabled:o}){var i;return h.jsxs(Ir,{"aria-label":e,title:`Animation: ${((i=r.find(a=>a.value===t))==null?void 0:i.label)??"Mixed"}`,value:t,style:{width:104},disabled:o,onValueChange:a=>{const s=r.find(u=>u.value===a);s&&n(s.value)},children:[t===""&&h.jsx("option",{value:"",disabled:!0,children:"Mixed"}),r.map(a=>h.jsx("option",{value:a.value,children:a.label},a.value))]})}const hn="data:image/svg+xml;base64,";function At(e){if(e.startsWith(hn))return!0;try{const t=new URL(e);return(t.protocol==="https:"||t.protocol==="http:")&&!t.username&&!t.password}catch{return!1}}async function s0(e){if(e.size>256*1024)throw new Error("SVG must be 256 KB or smaller.");const t=await e.text(),r=new DOMParser().parseFromString(t,"image/svg+xml");if(r.doctype||r.querySelector("parsererror")||r.documentElement.localName!=="svg"||r.documentElement.namespaceURI!=="http://www.w3.org/2000/svg")throw new Error("Choose a valid SVG file.");if(r.querySelector("script, foreignObject")||[...r.querySelectorAll("*")].some(i=>[...i.attributes].some(a=>/^on/i.test(a.name))))throw new Error("SVG scripts and event handlers are not allowed.");const n=new TextEncoder().encode(t);let o="";for(const i of n)o+=String.fromCharCode(i);return hn+btoa(o)}const qr=({name:e,svg:t=!1,...r})=>{const[n,o]=S.useState(null),[i,a]=S.useState(!0),[s,u]=S.useState(!1),c=typeof e=="string"&&At(e);if(S.useEffect(()=>{if(c||!e||e.length<2){o(null),a(!1);return}a(!0),u(!1),(async()=>{try{let d;if(e.startsWith("Md"))d="md";else if(e.startsWith("Fa"))d="fa6";else if(e.startsWith("Io5"))d="io5";else if(e.startsWith("Io"))d="io";else if(e.startsWith("Ti"))d="ti";else if(e.startsWith("Go"))d="go";else if(e.startsWith("Fi"))d="fi";else if(e.startsWith("Di"))d="di";else if(e.startsWith("Ai"))d="ai";else if(e.startsWith("Bs"))d="bs";else if(e.startsWith("Ri"))d="ri";else if(e.startsWith("Fc"))d="fc";else if(e.startsWith("Gi"))d="gi";else if(e.startsWith("Hi2"))d="hi2";else if(e.startsWith("Hi"))d="hi";else if(e.startsWith("Si"))d="si";else if(e.startsWith("Sl"))d="sl";else if(e.startsWith("Im"))d="im";else if(e.startsWith("Bi"))d="bi";else if(e.startsWith("Pi"))d="pi";else if(e.startsWith("Vsc"))d="vsc";else if(e.startsWith("Tb"))d="tb";else if(e.startsWith("Tfi"))d="tfi";else if(e.startsWith("Cg"))d="cg";else if(e.startsWith("Lia"))d="lia";else if(e.startsWith("Lu"))d="lu";else throw new Error(`Unknown library prefix for icon: ${e}`);let f;switch(d){case"md":f=await import("react-icons/md");break;case"fa6":f=await import("react-icons/fa6");break;case"io5":f=await import("react-icons/io5");break;case"io":f=await import("react-icons/io");break;case"ti":f=await import("react-icons/ti");break;case"go":f=await import("react-icons/go");break;case"fi":f=await import("react-icons/fi");break;case"di":f=await import("react-icons/di");break;case"ai":f=await import("react-icons/ai");break;case"bs":f=await import("react-icons/bs");break;case"ri":f=await import("react-icons/ri");break;case"fc":f=await import("react-icons/fc");break;case"gi":f=await import("react-icons/gi");break;case"hi2":f=await import("react-icons/hi2");break;case"hi":f=await import("react-icons/hi");break;case"si":f=await import("react-icons/si");break;case"sl":f=await import("react-icons/sl");break;case"im":f=await import("react-icons/im");break;case"bi":f=await import("react-icons/bi");break;case"pi":f=await import("react-icons/pi");break;case"vsc":f=await import("react-icons/vsc");break;case"tb":f=await import("react-icons/tb");break;case"tfi":f=await import("react-icons/tfi");break;case"cg":f=await import("react-icons/cg");break;case"lia":f=await import("react-icons/lia");break;case"lu":f=await import("react-icons/lu");break;default:throw new Error(`Unsupported library: ${d}`)}const p=f[e];if(!p)throw new Error(`Icon ${e} not found in library ${d}`);o(()=>p)}catch(d){console.warn(`Failed to load icon ${e}:`,d.message),u(!0),o(null)}finally{a(!1)}})()},[e,c]),c){const{size:l=80,style:d,...f}=r;return t?h.jsx("image",{...f,href:e,width:l,height:l,preserveAspectRatio:"xMidYMid meet",style:d}):h.jsx("img",{...f,src:e,alt:"",width:l,height:l,referrerPolicy:"no-referrer",style:{objectFit:"contain",...d}})}return i||!n?null:h.jsx(n,{...r})};function Nu({nodeId:e,edgeId:t,value:r}){const{callbacks:n,readOnly:o,themeColor:i}=Oe(),{background:a,backgroundSecondary:s,border:u,colorText:c}=Ue(),l=S.useRef(null),d=S.useId(),f=S.useRef(null),p=S.useRef(0),[b,g]=S.useState(!1),[m,w]=S.useState("icons"),[y,x]=S.useState([]),[v,C]=S.useState("loading"),[_,k]=S.useState(""),[T,P]=S.useState(0),[j,R]=S.useState(""),[E,M]=S.useState(""),[I,N]=S.useState(!1);S.useEffect(()=>()=>{p.current++},[]),S.useEffect(()=>{if(!b)return;let K=!0;return import("react-icons/pi").then(q=>{K&&(x(Object.keys(q).filter(L=>L.startsWith("Pi")).sort()),C("ready"))}).catch(()=>{K&&C("unavailable")}),()=>{K=!1}},[b]),S.useEffect(()=>{var K;o&&((K=l.current)==null||K.close())},[o]);const O=K=>{var q,L,G;o||(t?(q=n.onEdgeIconChange)==null||q.call(n,t,K):e&&((L=n.onNodeIconChange)==null||L.call(n,e,K)),(G=l.current)==null||G.close())},W=y.filter(K=>K.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(_.trim().toLowerCase())),z=36,re=Math.max(1,Math.ceil(W.length/z)),te=Math.min(T,re-1),he=W.slice(te*z,(te+1)*z),be={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${fe(u)}`,borderRadius:30};return h.jsxs(h.Fragment,{children:[h.jsx(je,{label:t?"Choose edge icon":"Choose node icon",children:h.jsx(me,{"aria-label":t?"Choose edge icon":"Choose node icon",icon:h.jsx(J.PiShapes,{size:20}),size:"sm",variant:"ghost",color:fe(i),disabled:o,onClick:()=>{var K;M(""),w(r&&At(r)?"custom":"icons"),R(r&&!r.startsWith(hn)&&At(r)?r:""),g(!0),(K=l.current)==null||K.showModal()}})}),h.jsx(D.chakra.dialog,{ref:l,"aria-label":t?"Choose edge icon":"Choose node icon",css:zr(fe(a),fe(u)),onClose:()=>{g(!1),p.current++,N(!1)},onClick:K=>{K.stopPropagation(),K.target===K.currentTarget&&K.currentTarget.close()},onKeyDown:K=>K.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",borderRadius:30,background:fe(a),color:fe(c)},children:b&&h.jsxs("div",{style:{display:"grid",gap:8},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[h.jsx("strong",{children:t?"Edge icon":"Node icon"}),h.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[r&&h.jsx(je,{label:"Remove icon",children:h.jsx(me,{"aria-label":t?"Remove edge icon":"Remove node icon",icon:h.jsx(J.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:o||I,onClick:()=>O("")})}),h.jsx(gt,{"aria-label":"Close icon picker",onClick:()=>{var K;return(K=l.current)==null?void 0:K.close()}})]})]}),h.jsx("div",{role:"tablist","aria-label":"Icon source",style:{display:"flex",borderBottom:`1px solid ${fe(u)}`},children:["icons","custom"].map(K=>h.jsx("button",{id:`${d}-${K}`,type:"button",role:"tab","aria-selected":m===K,"aria-controls":`${d}-panel`,tabIndex:m===K?0:-1,onClick:()=>{w(K),M("")},onKeyDown:q=>{var G;if(!["ArrowLeft","ArrowRight","Home","End"].includes(q.key))return;q.preventDefault();const L=q.key==="Home"?"icons":q.key==="End"||K==="icons"?"custom":"icons";w(L),M(""),(G=document.getElementById(`${d}-${L}`))==null||G.focus()},style:{flex:1,padding:"8px 12px",background:"transparent",border:0,borderBottom:`2px solid ${m===K?fe(i):"transparent"}`,color:m===K?fe(i):"inherit",cursor:"pointer",fontSize:13},children:K==="icons"?"React icons":"Custom SVG"},K))}),h.jsx("input",{ref:f,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:I||o,onChange:async K=>{var G;const q=(G=K.target.files)==null?void 0:G[0];if(K.target.value="",!q)return;const L=++p.current;N(!0),M("");try{const B=await s0(q);L===p.current&&O(B)}catch(B){L===p.current&&M(B instanceof Error?B.message:"Unable to read SVG.")}finally{L===p.current&&N(!1)}}}),h.jsx("div",{id:`${d}-panel`,role:"tabpanel","aria-labelledby":`${d}-${m}`,style:{display:"grid",gap:8},children:m==="icons"?h.jsxs(h.Fragment,{children:[h.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:_,onChange:K=>{k(K.target.value),P(0)},style:be}),h.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[he.map(K=>h.jsx("button",{type:"button","aria-label":`Choose ${K}`,"aria-pressed":r===K,title:K,onClick:()=>O(K),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${r===K?2:1}px solid ${fe(r===K?i:u)}`,background:fe(r===K?a:s),color:"inherit",cursor:"pointer"},children:h.jsx(qr,{name:K,size:24})},K)),he.length===0&&h.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:v==="loading"?"Loading icons...":v==="unavailable"?"React icons unavailable":"No icons found"})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[h.jsxs("span",{role:"status",style:{fontSize:12},children:[W.length," icons · ",te+1," / ",re]}),h.jsxs("div",{style:{display:"flex",gap:4},children:[h.jsx(je,{label:"Previous icons",children:h.jsx(me,{"aria-label":"Previous icons",icon:h.jsx(J.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:te===0,onClick:()=>P(te-1)})}),h.jsx(je,{label:"Next icons",children:h.jsx(me,{"aria-label":"Next icons",icon:h.jsx(J.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:te+1>=re,onClick:()=>P(te+1)})})]})]})]}):h.jsxs(h.Fragment,{children:[r&&At(r)&&h.jsx(qr,{name:r,size:64}),h.jsxs("button",{type:"button",disabled:I||o,onClick:()=>{var K;return(K=f.current)==null?void 0:K.click()},style:{...be,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[h.jsx(J.PiUploadSimple,{}),I?"Uploading...":"Upload SVG"]}),h.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:K=>{K.preventDefault(),!(I||o)&&(!At(j.trim())||j.trim().startsWith(hn)?M("Enter an HTTP or HTTPS image URL."):O(j.trim()))},children:[h.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:j,disabled:I||o,onChange:K=>R(K.target.value),style:{...be,flex:1,minWidth:0}}),h.jsx(je,{label:"Apply URL",children:h.jsx(me,{type:"submit","aria-label":"Apply URL",icon:h.jsx(J.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:I||o||!j.trim(),style:{flexShrink:0}})})]})]})}),E&&h.jsx("div",{role:"alert",style:{fontSize:13},children:E})]})})]})}const $u=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500"],sb=["gray.900","gray.600","gray.200","white"];function cb(){const{config:e}=Oe(),t=e.selectionToolbar||{},r=new Set(t.hide||[]);return{palette:t.palette||$u,show:n=>!r.has(n)}}function dr(){const{border:e}=Ue();return h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:e})}function et({value:e,placeholder:t,ariaLabel:r,width:n="140px",type:o="text",min:i,onCommit:a}){const{colorText:s}=Ue(),[u,c]=S.useState(e),l=S.useRef(!1);S.useEffect(()=>c(e),[e]);const d=()=>{if(l.current)return;l.current=!0;const f=u.trim();if(o==="number"&&f!==""&&(!Number.isFinite(Number(f))||Number(f)<(i??0))){c(e);return}f!==e&&a(f)};return h.jsx(D.Input,{"aria-label":r,type:o,min:i,size:"xs",w:n,value:u,placeholder:t,color:s,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{l.current=!1},onChange:f=>c(f.target.value),onBlur:d,onKeyDown:f=>{f.key==="Enter"&&(d(),f.target.blur()),f.key==="Escape"&&(l.current=!0,c(e),f.target.blur())}})}function Jt({colors:e,value:t,label:r,onPick:n,onReset:o,includeTransparent:i=!0}){const{colorInactive:a,colorText:s}=Ue(),[u,c]=S.useState(!1),l=S.useId(),d=S.useRef(null),f=t??e[0]??"transparent";return h.jsxs(D.HStack,{gap:1,"aria-label":r,role:"group",onKeyDown:p=>{var b;p.key==="Escape"&&(c(!1),(b=d.current)==null||b.focus())},children:[h.jsx(je,{label:`${r}: ${f}`,children:h.jsx(D.chakra.button,{ref:d,type:"button","aria-label":`${r} colors`,"aria-expanded":u,"aria-controls":l,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:fe(f),...f==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${fe(s)}`,outlineOffset:"1px",onClick:()=>c(p=>!p)})}),u&&h.jsxs(D.HStack,{id:l,gap:1,children:[[...new Set([...e,...i?["transparent"]:[]])].map(p=>{const b=t===p;return h.jsx(je,{label:`${r}: ${p}`,children:h.jsx(D.Box,{as:"button","aria-label":`${r} ${p}`,"aria-pressed":b,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:fe(p),...p==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:b?`2px solid ${fe(s)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(p),onDoubleClick:g=>{var m;g.stopPropagation(),c(!1),(m=d.current)==null||m.focus()}})},p)}),o&&h.jsx(je,{label:`Reset ${r.toLowerCase()}`,children:h.jsx(me,{"aria-label":`Reset ${r}`,icon:h.jsx(D.Icon,{as:J.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:a,onClick:()=>{var p;o(),c(!1),(p=d.current)==null||p.focus()}})})]})]})}function ub({edgeId:e,onClose:t}){var p;const{callbacks:r,themeColor:n,config:o}=Oe(),{colorInactive:i}=Ue(),{edgeById:a}=Ur(),{palette:s,show:u}=cb(),c=(p=a.get(e))==null?void 0:p.data,l=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(o.customEdgeTypes??{}),...c!=null&&c.type?[c.type]:[]])],d=c!=null&&c.isEdgeAnimated?"animated":c!=null&&c.isEdgeDashed?"dashed":"solid",f=[{key:"solid",icon:J.PiLineSegment,label:"Solid"},{key:"dashed",icon:J.PiLineSegments,label:"Dashed"},{key:"animated",icon:J.PiFastForward,label:"Animated"}];return h.jsxs(h.Fragment,{children:[h.jsx(gt,{onClick:t}),u("label")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(et,{ariaLabel:"Edge label",placeholder:"Edge label",value:(c==null?void 0:c.label)||"",onCommit:b=>{var g;return(g=r.onEdgeLabelChange)==null?void 0:g.call(r,e,b)}})]}),u("style")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),f.map(b=>h.jsx(je,{label:b.label,children:h.jsx(me,{"aria-label":`Edge style ${b.key}`,"aria-pressed":d===b.key,icon:h.jsx(D.Icon,{as:b.icon,boxSize:5}),size:"sm",variant:"ghost",color:d===b.key?n:i,onClick:()=>{var g;return(g=r.onEdgeStyleChange)==null?void 0:g.call(r,e,b.key)}})},b.key)),d==="animated"&&h.jsx(ab,{label:"Edge animation",value:(c==null?void 0:c.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:o.readOnly,onChange:b=>{var g;return(g=r.onEdgeAnimationVariantChange)==null?void 0:g.call(r,e,b)}}),h.jsxs(Ir,{"aria-label":"Edge shape",title:`Edge shape: ${(c==null?void 0:c.type)??"Default"}`,icon:h.jsx(J.PiBezierCurve,{size:20}),style:{width:36},value:(c==null?void 0:c.type)??"",disabled:o.readOnly,onValueChange:b=>{var g;return(g=r.onEdgeTypeChange)==null?void 0:g.call(r,e,b||void 0)},children:[h.jsx("option",{value:"",children:"Default"}),l.map(b=>h.jsx("option",{value:b,children:b},b))]})]}),u("icon")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Nu,{edgeId:e,value:c==null?void 0:c.icon},e),h.jsx(et,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(c==null?void 0:c.icon)??"",onCommit:b=>{var g;return(g=r.onEdgeIconChange)==null?void 0:g.call(r,e,b)}})]}),u("color")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Jt,{label:"Edge color",colors:s,value:c==null?void 0:c.color,onPick:b=>{var g;return(g=r.onEdgeColorChange)==null?void 0:g.call(r,e,b)},onReset:()=>{var b;return(b=r.onEdgeColorChange)==null?void 0:b.call(r,e,"")}})]}),u("delete")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(je,{label:"Delete edge",children:h.jsx(me,{"aria-label":"Delete edge",icon:h.jsx(D.Icon,{as:J.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var b;(b=r.onEdgeDelete)==null||b.call(r,e,c),t()}})})]})]})}function lb({ids:e,showDivider:t=!0}){const{callbacks:r,config:n}=Oe(),{colorInactive:o}=Ue(),{nodeById:i}=Ur(),[a,s]=S.useState(!1),u=e.map(b=>{var g,m;return(m=(g=i.get(b))==null?void 0:g.data.viewProps)==null?void 0:m.borderRadius}),c=!u.every(b=>b===u[0]),l=c?"mixed":String(u[0]??""),d=["0","8","16","30","53","100"],f=a||!c&&l!==""&&!d.includes(l),p=b=>e.forEach(g=>{var m;return(m=r.onNodeBorderRadiusChange)==null?void 0:m.call(r,g,b)});return h.jsxs(h.Fragment,{children:[t&&h.jsx(dr,{}),h.jsx(D.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:h.jsxs(Ir,{icon:h.jsx(D.Icon,{as:tv.TbBorderRadius,boxSize:5,color:o,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${c?"Mixed":u[0]===void 0?"Default":`${u[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:f?"custom":l,disabled:n.readOnly,onValueChange:b=>{s(b==="custom"),b!=="custom"&&p(b===""?void 0:Number(b))},children:[h.jsx("option",{value:"",children:"Default radius"}),c&&h.jsx("option",{value:"mixed",disabled:!0,children:"Mixed radii"}),d.map(b=>h.jsxs("option",{value:b,children:[b,"px radius"]},b)),h.jsx("option",{value:"custom",children:"Custom radius"})]})}),f&&h.jsx(et,{ariaLabel:"Custom border radius",placeholder:c?"Mixed":"Auto",type:"number",min:0,width:"72px",value:c?"":l,onCommit:b=>p(b===""?void 0:Number(b))})]})}function db({ids:e,onClose:t}){var K,q,L,G,B,Y,ce,X;const{callbacks:r,colorMode:n,themeColor:o,config:i,setNodeViewMode:a}=Oe(),{colorText:s,colorInactive:u}=Ue(),{nodeById:c,parentIds:l}=Ur(),{palette:d,show:f}=cb(),p=e.length===1,b=p?(K=c.get(e[0]))==null?void 0:K.data:void 0,g=e.map(U=>{var Z,ae;return((ae=(Z=c.get(U))==null?void 0:Z.data.config)==null?void 0:ae.typeView)??""}),m=g.some(U=>U!==g[0]),w=m?"mixed":g[0]??"",y=e.some(U=>{var ae,ue;const Z=(ae=c.get(U))==null?void 0:ae.data;return Z&&(l.has(U)||((ue=Z.config)==null?void 0:ue.parentContainer)||Object.prototype.hasOwnProperty.call(i.customViews??{},Z.type))}),x=(q=b==null?void 0:b.config)==null?void 0:q.collapsed,v=ib(e[0]),C=U=>{var Z,ae,ue;return(((ae=(Z=c.get(U))==null?void 0:Z.data.viewProps)==null?void 0:ae.outline)??(l.has(U)?(ue=i.parentNodeStyle)==null?void 0:ue.outline:!1))===!0},_=e.every(C),k=!_&&e.some(C),T=U=>{var Z;return((Z=c.get(U))==null?void 0:Z.data.isNodeAnimated)===!0},P=e.every(T),j=!P&&e.some(T),R=e.map(U=>{var Z;return((Z=c.get(U))==null?void 0:Z.data.nodeAnimationVariant)??"traveling"}),E=R.every(U=>U===R[0])?R[0]:"",M=U=>e.forEach(U),[I,N]=S.useState(!1),O=I&&f("color")&&f("borderColor"),W=U=>{var Z,ae,ue;return(((ae=(Z=c.get(U))==null?void 0:Z.data.viewProps)==null?void 0:ae.borderStyle)??(l.has(U)?(ue=i.parentNodeStyle)==null?void 0:ue.borderStyle:"solid"))==="dashed"},z=e.every(W),re=!z&&e.some(W),te=e.map(U=>{var ue,de,Ee;const Z=(ue=c.get(U))==null?void 0:ue.data,ae=l.has(U)?Kt((de=i.parentNodeStyle)==null?void 0:de.borderWidth,6):(Z==null?void 0:Z.type)==="objectView"?3:2;return Kt((Ee=Z==null?void 0:Z.viewProps)==null?void 0:Ee.borderWidth,ae)}),he=te.every(U=>U===te[0])?String(te[0]??""):"",be=U=>M(Z=>{var ae,ue;O?(ae=r.onNodeBorderColorChange)==null||ae.call(r,Z,U):(ue=r.onNodeColorChange)==null||ue.call(r,Z,"bg",U)});return h.jsxs(h.Fragment,{children:[h.jsx(gt,{onClick:t}),h.jsx(dr,{}),p&&f("label")?h.jsx(et,{ariaLabel:"Node label",placeholder:"Node label",value:(b==null?void 0:b.label)??(b==null?void 0:b.headerTitle)??"",onCommit:U=>{var Z;return(Z=r.onNodeLabelChange)==null?void 0:Z.call(r,e[0],U)}}):h.jsxs(D.Text,{fontSize:"xs",color:s,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),f("typeView")&&h.jsxs(Ir,{"aria-label":"Type view",title:y?"Type view is managed by the custom renderer or container":`Type view: ${w||"None (default)"}`,icon:h.jsx(J.PiImage,{size:20}),style:{width:36},value:w,disabled:i.readOnly||i.editable===!1||y,onValueChange:U=>{Dt.includes(U)&&M(Z=>{var ae,ue;(ae=r.onNodeTypeViewChange)==null||ae.call(r,Z,U||void 0),a(Z,"default"),(ue=r.onNodeViewToggle)==null||ue.call(r,Z)})},children:[m&&h.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),Dt.map(U=>h.jsx("option",{value:U,children:U||"None"},U))]}),f("style")&&h.jsx(lb,{ids:e},e.join("\0")),f("outline")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(je,{label:_?"Restore node fill":"Remove node fill",children:h.jsx(me,{"aria-label":"Toggle node outline","aria-pressed":k?"mixed":_,icon:h.jsx(D.Icon,{as:_?J.PiSquare:J.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:_?o:u,onClick:()=>M(U=>{var Z;return(Z=r.onNodeOutlineChange)==null?void 0:Z.call(r,U,!_)})})})]}),f("color")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),f("borderColor")&&h.jsx(je,{label:O?"Edit node colors":"Edit node border",children:h.jsx(me,{"aria-label":"Edit node border","aria-pressed":O,icon:h.jsx(D.Icon,{as:J.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:O?o:u,bg:O?n==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>N(U=>!U)})}),h.jsx(Jt,{label:O?"Border color":"Background",colors:d,value:O?((L=b==null?void 0:b.viewProps)==null?void 0:L.borderColor)??(p&&l.has(e[0])?(G=i.parentNodeStyle)==null?void 0:G.borderColor:void 0):(B=b==null?void 0:b.viewProps)==null?void 0:B.bgColor,onPick:be,onReset:()=>be("")}),O&&f("style")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(je,{label:z?"Solid border":"Dashed border",children:h.jsx(me,{"aria-label":"Toggle dashed border","aria-pressed":re?"mixed":z,icon:h.jsx(D.Icon,{as:z?J.PiLineSegments:J.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:z?o:u,onClick:()=>M(U=>{var Z;return(Z=r.onNodeBorderStyleChange)==null?void 0:Z.call(r,U,z?"solid":"dashed")})})}),h.jsx(et,{ariaLabel:"Border thickness",placeholder:p?"Auto":"Mixed",width:"64px",type:"number",min:0,value:he,onCommit:U=>M(Z=>{var ae;return(ae=r.onNodeBorderWidthChange)==null?void 0:ae.call(r,Z,U===""?void 0:Number(U))})})]})]}),f("animation")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(je,{label:P?"Stop border animation":"Animate node border",children:h.jsx(me,{"aria-label":"Toggle node animation","aria-pressed":j?"mixed":P,icon:h.jsx(D.Icon,{as:J.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:P?o:u,onClick:()=>M(U=>{var Z;return(Z=r.onNodeAnimationChange)==null?void 0:Z.call(r,U,!P)})})}),(P||j)&&h.jsx(ab,{label:"Node animation",value:E,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:i.readOnly,onChange:U=>M(Z=>{var ae;return(ae=r.onNodeAnimationVariantChange)==null?void 0:ae.call(r,Z,U)})})]}),!O&&f("textColor")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Jt,{label:"Text color",colors:sb,value:(Y=b==null?void 0:b.viewProps)==null?void 0:Y.textColor,onPick:U=>M(Z=>{var ae;return(ae=r.onNodeColorChange)==null?void 0:ae.call(r,Z,"text",U)}),onReset:()=>M(U=>{var Z;return(Z=r.onNodeColorChange)==null?void 0:Z.call(r,U,"text","")})})]}),p&&f("icon")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(Nu,{nodeId:e[0],value:(ce=b==null?void 0:b.config)==null?void 0:ce.icon},e[0]),h.jsx(et,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((X=b==null?void 0:b.config)==null?void 0:X.icon)||"",onCommit:U=>{var Z;return(Z=r.onNodeIconChange)==null?void 0:Z.call(r,e[0],U)}})]}),p&&v&&f("collapse")&&x!==void 0&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(je,{label:x?"Expand":"Collapse",children:h.jsx(me,{"aria-label":x?"Expand node":"Collapse node",icon:h.jsx(D.Icon,{as:x?J.PiArrowsOutLineVertical:J.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:u,onClick:()=>{var U;return(U=r.onNodeCollapse)==null?void 0:U.call(r,e[0],!x)}})})]}),f("delete")&&h.jsxs(h.Fragment,{children:[h.jsx(dr,{}),h.jsx(je,{label:p?"Delete node":`Delete ${e.length} nodes`,children:h.jsx(me,{"aria-label":"Delete selected nodes",icon:h.jsx(D.Icon,{as:J.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:n==="dark"?"red.300":"red.500",onClick:()=>{M(U=>{var Z,ae;return(ae=r.onNodeDelete)==null?void 0:ae.call(r,U,((Z=c.get(U))==null?void 0:Z.data)||{id:U})}),t()}})})]})]})}async function fb(e){const{toSvg:t}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const r=await t(e,{filter:o=>!(o instanceof Element)||!o.matches("button, [role=tooltip], .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-edge-hit, .flow-sdk-ghost, .flow-sdk-node-animation")}),n=new DOMParser().parseFromString(decodeURIComponent(r.slice(r.indexOf(",")+1)),"image/svg+xml");return n.querySelectorAll(".flow-sdk-edge-hit, .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-ghost").forEach(o=>o.remove()),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}async function hb(e,t="squeed.svg"){const r=document.createElement("a");r.href=await fb(e),r.download=t.endsWith(".svg")?t:`${t}.svg`,r.click()}function pb(){const{themeColor:e}=Oe(),[t,r]=S.useState(!1),[n,o]=S.useState("");return h.jsxs(h.Fragment,{children:[h.jsx(je,{label:"Download SVG (current view)",children:h.jsx(me,{"aria-label":"Download SVG",icon:h.jsx(J.PiDownloadSimpleFill,{size:20}),disabled:t,borderRadius:"30%",color:e,variant:"ghost",onClick:async i=>{var s;const a=(s=i.currentTarget.closest("[data-flow-diagram]"))==null?void 0:s.querySelector("[data-flow-background]");if(!a){o("Diagram not available for export.");return}r(!0),o("");try{await hb(a)}catch(u){o(u instanceof Error?u.message:"Unable to export SVG.")}finally{r(!1)}}})}),n&&h.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function gb({children:e,background:t,border:r}){const n=S.useRef(null),[o,i]=S.useState({left:!1,right:!1});S.useLayoutEffect(()=>{const s=n.current,u=()=>{const l=s.scrollLeft>1,d=s.scrollWidth-s.clientWidth-s.scrollLeft>1;i(f=>f.left===l&&f.right===d?f:{left:l,right:d})},c=new ResizeObserver(u);return c.observe(s),s.firstElementChild&&c.observe(s.firstElementChild),s.addEventListener("scroll",u,{passive:!0}),u(),()=>{c.disconnect(),s.removeEventListener("scroll",u)}},[]);const a=`var(--chakra-colors-${t.replace(".","-")})`;return h.jsxs(D.Box,{position:"relative",bg:t,minW:0,maxW:"100%",flex:"0 1 auto",borderRadius:"30px",css:zr(a,`var(--chakra-colors-${r.replace(".","-")})`),children:[h.jsx(D.Box,{ref:n,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(s=>h.jsx(D.Box,{"data-flow-toolbar-fade":s,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",borderRadius:s==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[s]:0,opacity:o[s]?1:0,background:`linear-gradient(to ${s==="left"?"right":"left"}, ${a}, transparent)`}},s))]})}async function c0(e,t){const r=new Set,n=[],o=(s,u)=>{var l,d,f;if(!s||typeof s!="object")return;const c=s;n.push(u),typeof((l=c.$form)==null?void 0:l.$type)=="string"&&r.add(c.$form.$type),typeof((f=(d=c.$form)==null?void 0:d.$create)==null?void 0:f.$type)=="string"&&r.add(c.$form.$create.$type);for(const[p,b]of Object.entries(c))p==="$"?o(b,u):p.startsWith("$")||o(b,`${u}.${p}`)};if(o(t,"root"),!r.size)return{contract:await rb(e)};const i=await qu(e,[...r]);for(const s of r)if(!Object.prototype.hasOwnProperty.call(i,s))throw new Error(`Missing form type: ${s}`);const a={};for(const s of n){const u=yt(t,s,i);u&&(a[s]={type:u.type,optional:!1})}return{schema:i,contract:{name:e.name,nodes:a}}}function yb({message:e,onDismiss:t}){const{background:r,colorText:n,border:o}=Ue();return!e||typeof document>"u"?null:Bt.createPortal(h.jsxs(D.chakra.div,{role:"alert","aria-atomic":"true",css:zr(fe(r),fe(o)),onPointerDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),style:{position:"fixed",top:20,right:20,zIndex:1e4,width:360,maxWidth:"calc(100vw - 40px)",boxSizing:"border-box",display:"flex",alignItems:"flex-start",gap:10,padding:16,borderRadius:8,background:fe(r),color:fe(n),fontSize:14,lineHeight:1.5},children:[h.jsx(J.PiWarningCircle,{size:20,"aria-hidden":"true",style:{flexShrink:0,color:"#ef4444"}}),h.jsxs("div",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:[h.jsx("strong",{children:"Interface upload failed"}),h.jsx("div",{children:e})]}),h.jsx(gt,{type:"button","aria-label":"Dismiss upload error",title:"Dismiss upload error",onClick:t,flexShrink:0,width:"24px",height:"24px",minWidth:"24px",padding:0})]}),document.body)}function bb({showDivider:e=!0,compact:t=!1}={}){const{edgeMode:r,setEdgeMode:n,workflowContract:o,setWorkflowContract:i,callbacks:a,readOnly:s,themeColor:u}=Oe(),{edgeById:c}=Ur(),{data:l,schema:d,setSchema:f,bindings:p,structured:b}=S.useContext(kr),g=(b==null?void 0:b.sourceBindings)??p,m=(b==null?void 0:b.sourceSchema)??d,{colorText:w}=Ue(),y=S.useRef(null),x=S.useRef(0),[v,C]=S.useState(!1),[_,k]=S.useState("");S.useEffect(()=>()=>{x.current++},[]),S.useEffect(()=>{x.current++,C(!1)},[s,l,g]);const T=o?[...c.values()].filter(j=>Mu(o,j.data)).length:0,P=o?`${o.name}: ${m?`${Object.keys(m).length} form types loaded; `:""}${T} invalid or unverified connections`:"";return h.jsxs(h.Fragment,{children:[h.jsx(yb,{message:_,onDismiss:()=>k("")}),e&&h.jsx(Mt,{}),h.jsxs(Ir,{"aria-label":"Edge mode",title:r==="auto"?"Connections: Auto":r==="properties"?"Connections: Properties":"Connections: Nodes",icon:r==="auto"?h.jsx(J.PiGraph,{size:20}):r==="properties"?h.jsx(J.PiTable,{size:20}):h.jsx(J.PiTreeStructure,{size:20}),style:{width:36},value:r,disabled:s,onValueChange:j=>{var E;const R=j==="auto"?"auto":j==="properties"?"properties":"nodes";n(R),(E=a.onEdgeModeChange)==null||E.call(a,R)},children:[h.jsx("option",{value:"auto",children:"Auto"}),h.jsx("option",{value:"nodes",children:"Nodes"}),h.jsx("option",{value:"properties",children:"Properties"})]}),h.jsxs("span",{style:{display:r==="auto"||r==="properties"?"contents":"none"},children:[h.jsx(je,{label:o?`Replace ${o.name}`:"Upload workflow interface",children:h.jsx(me,{"aria-label":"Upload workflow interface",icon:h.jsx(J.PiUploadSimple,{size:20}),color:fe(u),size:"sm",variant:"ghost",disabled:v||s,onClick:()=>{var j;return(j=y.current)==null?void 0:j.click()}})}),h.jsx("input",{ref:y,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:s||v,onChange:async j=>{var M,I;const R=(M=j.target.files)==null?void 0:M[0];if(j.target.value="",!R)return;const E=++x.current;C(!0),k("");try{const N=g?await qu(R,[...new Set(Object.values(g).map(z=>z.schemaType??z.type))]):void 0;if(g&&N){for(const z of Object.values(g))if(!Object.prototype.hasOwnProperty.call(N,z.schemaType??z.type))throw new Error(`Missing form type: ${z.schemaType??z.type}`)}const{contract:O,schema:W}=g&&N?{schema:N,contract:{name:R.name,nodes:Object.fromEntries(Object.entries(g).map(([z,re])=>[z,{type:N[re.schemaType??re.type],optional:!1}]))}}:await c0(R,l);if(E!==x.current)return;f==null||f(W),i(O),(I=a.onWorkflowContractChange)==null||I.call(a,O)}catch(N){E===x.current&&k(`${R.name}: ${N instanceof Error?N.message:"Unable to load interface."}`)}finally{E===x.current&&C(!1)}}}),!t&&(P||v)&&h.jsx("span",{role:"status",title:P,style:{color:fe(w),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v?"Loading interface...":P}),!t&&o&&h.jsx(je,{label:"Remove workflow interface",children:h.jsx(me,{"aria-label":"Remove workflow interface",icon:h.jsx(J.PiX,{size:16}),size:"sm",variant:"ghost",disabled:s||v,onClick:()=>{var j;f==null||f(void 0),i(void 0),(j=a.onWorkflowContractChange)==null||j.call(a,void 0),k("")}})})]})]})}const u0=[{value:"BT",label:"Bottom to Up",icon:J.PiArrowUp,flowType:jt.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:J.PiArrowDown,flowType:jt.TOP_DOWN},{value:"LR",label:"Left to Right",icon:J.PiArrowRight,flowType:jt.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:J.PiArrowLeft,flowType:jt.RIGHT_LEFT}],mb=()=>{const{engineRef:e,themeColor:t,setThemeColor:r,backgroundSelected:n,setBackgroundSelected:o,direction:i,edgeMode:a,allNodesIconLabel:s,setAllNodesIconLabel:u,selectedNodeIds:c,setSelectedNodeIds:l,selectedEdgeId:d,setSelectedEdgeId:f,isZoomMode:p,setIsZoomMode:b,isMultiSelectMode:g,setIsMultiSelectMode:m,isDragMode:w,setIsDragMode:y,isEdgeHandlesEnabled:x,setIsEdgeHandlesEnabled:v,isArrayNodeMode:C,setIsArrayNodeMode:_,isPinned:k,setIsPinned:T,callbacks:P,config:j,readOnly:R}=Oe(),{nodeById:E,edgeById:M,parentIds:I}=Ur(),N=j.colorMode==="dark",{background:O,border:W,colorInactive:z,colorText:re,colorActive:te}=Ue(),he=`var(--chakra-colors-${O.replace(".","-")})`,be=`var(--chakra-colors-${(N?W:"gray.300").replace(".","-")})`,[K,q]=S.useState(!1),[L,G]=S.useState(!0),B=S.useRef(null),Y=py({edge:"bottom",enabled:!k,bounds:B,inside:[B]}),ce=S.useCallback(xe=>{const Ie=e.current;if(!Ie)return;const $e=j.minZoom??.01,tr=j.maxZoom??1.5,Je=.02;let Ze=Ie.zoom();switch(xe){case"increase":Ze=Math.min(tr,Ze+Je),Ie.zoom(Ze),Ie.center();break;case"decrease":Ze=Math.max($e,Ze-Je),Ie.zoom(Ze),Ie.center();break;case"reset":Ie.fit(50);break}},[e,j.minZoom,j.maxZoom]),X=j.renderSelectedNodeToolbar,U=c.length>0&&!!X,Z=S.useMemo(()=>U?c.map(xe=>{var $e;return{...(($e=E.get(xe))==null?void 0:$e.data)??{id:xe},isParent:I.has(xe)}}):[],[U,c,E,I]),ae=S.useCallback(()=>{var xe;l([]),(xe=P.onNodeDeselect)==null||xe.call(P)},[l,P]),ue=j.renderSelectedEdgeToolbar,de=!!d&&!!ue,Ee=S.useMemo(()=>{var xe;return!de||!d?null:((xe=M.get(d))==null?void 0:xe.data)??{id:d}},[de,d,M]),ge=S.useCallback(()=>{var xe;f(null),(xe=P.onEdgeDeselect)==null||xe.call(P)},[f,P]),He=j.selectionToolbar!==!1&&!R,Le=He&&!!d&&!ue,Xe=He&&!Le&&c.length>0&&!X,ur=Le||Xe,Ge=k||Y||K||ur;S.useEffect(()=>{c.length||d?o(!1):n&&!R&&(T(!0),G(!1))},[n,c.length,d,R,o,T]);const Ne=j.renderBottomBar;return Ne?h.jsxs(h.Fragment,{children:[U&&h.jsx(D.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:X({selectedNodeIds:c,selectedNodeData:Z,onDeselect:ae})}),de&&Ee&&h.jsx(D.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:ue({edgeId:d,edgeData:Ee,onDeselect:ge})}),h.jsx(D.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:Ne({zoomIn:()=>ce("increase"),zoomOut:()=>ce("decrease"),resetZoom:()=>ce("reset"),direction:i,isZoomMode:p,setIsZoomMode:b,isMultiSelectMode:g,setIsMultiSelectMode:m,isDragMode:w,setIsDragMode:y,isEdgeHandlesEnabled:x,setIsEdgeHandlesEnabled:v,isArrayNodeMode:C,setIsArrayNodeMode:_,selectedNodeIds:c,selectedNodeData:Z,selectedEdgeId:d,selectedEdgeData:Ee,onNodeDeselect:ae,onEdgeDeselect:ge,callbacks:P})})]}):h.jsxs(h.Fragment,{children:[U&&h.jsx(D.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:X({selectedNodeIds:c,selectedNodeData:Z,onDeselect:ae})}),de&&Ee&&h.jsx(D.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:ue({edgeId:d,edgeData:Ee,onDeselect:ge})}),h.jsx(D.Box,{ref:B,role:"toolbar","aria-label":"Diagram controls",position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",transition:"opacity 0.3s ease-in, transform 0.3s ease",transform:Ge?"translateY(0)":"translateY(100%)",pointerEvents:Ge?"auto":"none",visibility:Ge?"visible":"hidden",opacity:Ge?1:0,children:h.jsxs(D.Flex,{w:"100%",px:5,position:"absolute",bottom:5,flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:"24px",children:[h.jsx(gb,{background:O,border:N?W:"gray.300",children:h.jsxs(D.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[Le?h.jsx(ub,{edgeId:d,onClose:ge}):Xe?h.jsx(db,{ids:c,onClose:ae}):null,h.jsxs("div",{style:{display:Le||Xe?"none":"contents"},children:[h.jsx(je,{label:k?"Unpin":"Pin",children:h.jsx(me,{"aria-label":"Pin",icon:h.jsx(D.Icon,{as:k?J.PiPushPinFill:J.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:k?t:z,onClick:()=>{T(!k),q(!1)}})}),h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W}),h.jsx(je,{label:"Zoom Out",children:h.jsx(me,{"aria-label":"Zoom out",icon:h.jsx(D.Icon,{as:J.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:re,onClick:()=>ce("decrease")})}),h.jsx(je,{label:"Zoom In",children:h.jsx(me,{"aria-label":"Zoom in",icon:h.jsx(D.Icon,{as:J.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:re,onClick:()=>ce("increase")})}),h.jsx(je,{label:"Reset Zoom",children:h.jsx(me,{"aria-label":"Reset zoom",icon:h.jsx(D.Icon,{as:J.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:re,onClick:()=>ce("reset")})}),!L&&h.jsxs(h.Fragment,{children:[h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W}),h.jsx(je,{label:p?"Zoom Mode (z)":"Pan Mode (z)",children:h.jsx(me,{"aria-label":"Toggle zoom mode",icon:h.jsx(D.Icon,{as:p?J.PiMagnifyingGlassPlus:J.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:p?t:z,onClick:()=>b(!p)})}),h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W}),h.jsx(je,{label:g?"Multi-Select On (m)":"Multi-Select Off (m)",children:h.jsx(me,{"aria-label":"Toggle multi-select",icon:h.jsx(D.Icon,{as:J.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:g?t:z,onClick:()=>m(!g)})}),h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W}),h.jsx(je,{label:w?"Drag Mode On (d)":"Drag Mode Off (d)",children:h.jsx(me,{"aria-label":"Toggle drag mode",icon:h.jsx(D.Icon,{as:J.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:w?t:z,onClick:()=>y(!w)})}),j.edgeHandles!==!1&&h.jsxs(h.Fragment,{children:[h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W}),h.jsx(je,{label:x?"Draw Mode On":"Draw Mode Off",children:h.jsx(me,{"aria-label":"Toggle draw mode",icon:h.jsx(D.Icon,{as:J.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:x?t:z,onClick:()=>v(!x)})})]}),j.bottomBarExtra&&h.jsxs(h.Fragment,{children:[h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W,role:"separator","aria-orientation":"vertical"}),j.bottomBarExtra]}),h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W,role:"separator","aria-orientation":"vertical"}),h.jsx(zy,{}),h.jsx(ju,{label:"Collapse all",checked:s,icon:h.jsx(D.Icon,{as:J.PiArrowsInLineVertical,boxSize:5}),onChange:u}),a!=="properties"&&h.jsxs(h.Fragment,{children:[h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W}),h.jsx(je,{label:C?"Array Mode [ ]":"Set Mode { }",children:h.jsx(me,{"aria-label":"Toggle array mode",icon:h.jsx(D.Icon,{as:C?J.PiBracketsSquare:J.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:C?t:z,onClick:()=>{var Ie;const xe=!C;_(xe),(Ie=P.onArrayModeChange)==null||Ie.call(P,xe)}})})]}),n&&!R&&h.jsxs(h.Fragment,{children:[h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W}),h.jsx(Jt,{label:"Graph theme",colors:$u,value:t,includeTransparent:!1,onPick:xe=>{var Ie;r(xe),(Ie=P.onThemeColorChange)==null||Ie.call(P,xe)}})]}),h.jsx(bb,{}),h.jsx(Wy,{})]}),h.jsx(D.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:W}),h.jsx(je,{label:L?"Expand toolbar":"Collapse toolbar",children:h.jsx(me,{"aria-label":"Toggle toolbar collapse",icon:h.jsx(D.Icon,{as:L?J.PiCaretRight:J.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:z,onClick:()=>G(!L)})}),!L&&h.jsx(pb,{})]})]})}),!ur&&h.jsxs(D.Box,{position:"relative",ml:"auto",flexShrink:0,children:[h.jsx(D.Box,{"data-flow-direction-control":"",bg:O,borderRadius:"30px",h:50,css:zr(he,be),px:3,cursor:"pointer",onClick:()=>q(!K),children:h.jsxs(D.Flex,{align:"center",h:"100%",children:[h.jsx(je,{label:"Flow Direction",children:h.jsx(me,{"aria-label":"Direction",icon:h.jsx(D.Icon,{as:J.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:z})}),h.jsx(D.Text,{fontSize:"xs",color:N?"whiteAlpha.600":"blackAlpha.500",ml:1,children:i})]})}),K&&h.jsx(D.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:h.jsxs(D.Box,{bg:O,borderRadius:"30px",p:2,minW:"180px",css:zr(he,be),children:[u0.map(xe=>h.jsxs(D.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"30px",cursor:"pointer",_hover:{bg:N?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Ie;(Ie=P.onDirectionChange)==null||Ie.call(P,xe.value),q(!1)},children:[h.jsx(D.Icon,{as:xe.icon,boxSize:5,color:re}),h.jsx(D.Text,{fontSize:"sm",color:re,flex:1,whiteSpace:"nowrap",children:xe.label}),i===xe.value&&h.jsx(D.Icon,{as:J.PiCheck,boxSize:4,color:te})]},xe.value)),h.jsxs(D.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"10px",cursor:"pointer",_hover:{bg:N?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var xe;(xe=P.onDirectionChange)==null||xe.call(P,"C"),q(!1)},children:[h.jsx(D.Icon,{as:J.PiAlignCenterHorizontal,boxSize:5,color:re}),h.jsx(D.Text,{fontSize:"sm",color:re,flex:1,whiteSpace:"nowrap",children:"Center"}),i==="C"&&h.jsx(D.Icon,{as:J.PiCheck,boxSize:4,color:te})]})]})})]})]})})]})};mb.displayName="BottomBar";const vb=S.memo(mb);function l0({checked:e,onChange:t,disabled:r,label:n="Connected nodes"}){return h.jsx(ju,{label:n,checked:e,onChange:t,disabled:r,icon:h.jsx(D.Icon,{as:J.PiGraph,boxSize:5})})}const Pl={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function xb(e,t){const r=new Map,n=(i,a)=>{if(Object.is(i,a))return!0;if(!i||!a||typeof i!="object"||typeof a!="object"||Array.isArray(i)!==Array.isArray(a))return!1;const s=Object.keys(i);return s.length===Object.keys(a).length&&s.every(u=>Object.prototype.hasOwnProperty.call(a,u)&&n(i[u],a[u]))},o=(i,a,s)=>{if(i===a)return!0;if(!i||!a||typeof i!="object"||typeof a!="object"||Array.isArray(i)!==Array.isArray(a))return!1;const u=new Set([...Object.keys(i),...Object.keys(a)]);for(const c of u)if(!n(i[c],a[c])){if(Object.prototype.hasOwnProperty.call(Pl,c)){if(typeof a[c]!="string"||!a[c])return!1;r.set(s,{...r.get(s),[Pl[c]]:a[c]})}else if(c.startsWith("$")&&c!=="$"||!o(i[c],a[c],c==="$"?s:`${s}.${c}`))return!1}return!0};if(o(e,t,"root"))return r}function d0(e,t){return xb(e,t)!==void 0}function f0(e,t,r){if(e===t)return r;const n=xb(e,t);if(!n)return;const o=new Set(r.nodes.map(i=>i.data.id));for(const i of n.keys())if(!o.has(i)||!ve(t,i))return;return{edges:r.edges,nodes:r.nodes.map(i=>{const a=n.get(i.data.id),s=ve(e,i.data.id),u=ve(t,i.data.id);return!a&&s===u?i:{...i,data:{...i.data,...typeof i.data.code=="string"?{code:JSON.stringify(u,null,2)}:{},...a?{viewProps:{...i.data.viewProps,...a},config:{...i.data.config,...a}}:{}}}})}}function xu(e){return e.kind==="literal"?e.value:e.kind==="union"?xu(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,t])=>!t.optional).map(([t,r])=>[t,xu(r.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function wb(e,t,r){var m,w,y;const n=(m=ve(e,t))==null?void 0:m.$form,o=n==null?void 0:n.$create;if(!o)return;const i=o.$address.split(".");if(i.shift()!=="root"||!i.length||i.some(x=>!/^[A-Za-z0-9_-]+$/.test(x)||["__proto__","constructor","prototype"].includes(x)))throw new Error("Invalid form creation address.");if(!r||!Object.prototype.hasOwnProperty.call(r,o.$type))throw new Error(`Load form type: ${o.$type}`);const a=i.pop(),s=["root",...i].join("."),u=yt(e,s,r),c=(w=u==null?void 0:u.type.properties[a])==null?void 0:w.type;if((c==null?void 0:c.kind)!=="array"||c.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const l=r[o.$type],d=o.$defaults??{};for(const[x,v]of Object.entries(d))if(!Object.prototype.hasOwnProperty.call(l.properties,x)||Rr(l.properties[x].type,v,!l.properties[x].optional))throw new Error(`Invalid creation default: ${x}`);const f={...xu(l),...structuredClone(d)};((y=l.properties.id)==null?void 0:y.type.kind)==="string"&&(f.id=Ru());let p=e;const b=ve(e,o.$address);if(b===void 0)p=br(e,s,x=>({...x,[a]:[]}));else if(!Array.isArray(b)&&!Array.isArray(b==null?void 0:b.$))throw new Error("Form creation destination is not an array.");const g=Au(p,o.$address,{...f,$label:o.$label??o.$type,...o.$icon?{$icon:o.$icon}:{},$form:{$type:o.$type,$create:o}});return{address:g.address,json:Tu(g.json,t,{target:g.address,label:o.$edgeLabel})}}function h0(e,t){const r=o=>e&&typeof e=="object"&&o in e;let n=1;for(;r(`${t}_${n}`);)n++;return`${t}_${n}`}function Cb(e,t,r,n,o){const i=(s,u)=>{s!==e&&(e=s,n==null||n(s,u))},a=s=>{var c;const u=(c=t.find(l=>l.data.id===s))==null?void 0:c.data;return u&&{source:u.source,target:u.target,isInverted:u.isInverted,sourceProperty:u.sourceProperty,targetProperty:u.targetProperty,connection:u.connection}};return{...r,onFormChange:s=>{const u=ve(e,s.nodeAddress);if(!u||s.nodeId!==void 0&&u.id!==s.nodeId)throw new Error("This form node has moved. Retry the edit.");i(Cn(e,s,r.onFormChange),{type:"form",address:s.address,value:s.value})},onNodeLabelChange:(s,u)=>{var c;(c=r.onNodeLabelChange)==null||c.call(r,s,u),i(cr(e,s,"$label",u),{type:"nodeLabel",address:s,key:"$label",value:u})},onNodeContentChange:(s,u)=>{var c;(c=r.onNodeContentChange)==null||c.call(r,s,u),i(cr(e,s,"$content",u),{type:"nodeContent",address:s,key:"$content",value:u})},onNodeTypeViewChange:(s,u)=>{var c;u!==void 0&&!Dt.includes(u)||((c=r.onNodeTypeViewChange)==null||c.call(r,s,u),i(cr(e,s,"$view",u),{type:"nodeStyle",address:s,key:"$view",value:u}))},onNodeColorChange:(s,u,c)=>{var d;(d=r.onNodeColorChange)==null||d.call(r,s,u,c);const l=u==="bg"?"$bgColor":"$textColor";i(cr(e,s,l,c),{type:"nodeColor",address:s,key:l,value:c})},onNodeBorderColorChange:(s,u)=>{var c;(c=r.onNodeBorderColorChange)==null||c.call(r,s,u),i(cr(e,s,"$borderColor",u),{type:"nodeColor",address:s,key:"$borderColor",value:u})},onNodeBorderStyleChange:(s,u)=>{var c;(c=r.onNodeBorderStyleChange)==null||c.call(r,s,u),i(cr(e,s,"$borderStyle",u),{type:"nodeStyle",address:s,key:"$borderStyle",value:u})},onNodeBorderWidthChange:(s,u)=>{var c;u!==void 0&&(!Number.isFinite(u)||u<0)||((c=r.onNodeBorderWidthChange)==null||c.call(r,s,u),i(cr(e,s,"$borderWidth",u),{type:"nodeStyle",address:s,key:"$borderWidth",value:u}))},onNodeBorderRadiusChange:(s,u)=>{var c;u!==void 0&&(!Number.isFinite(u)||u<0)||((c=r.onNodeBorderRadiusChange)==null||c.call(r,s,u),i(cr(e,s,"$borderRadius",u),{type:"nodeStyle",address:s,key:"$borderRadius",value:u}))},onNodeIconChange:(s,u)=>{var c;(c=r.onNodeIconChange)==null||c.call(r,s,u),i(cr(e,s,"$icon",u),{type:"nodeIcon",address:s,key:"$icon",value:u})},onNodeOutlineChange:(s,u)=>{var c;(c=r.onNodeOutlineChange)==null||c.call(r,s,u),i(cr(e,s,"$outline",u),{type:"nodeOutline",address:s,key:"$outline",value:u})},onNodeAnimationChange:(s,u)=>{var c;(c=r.onNodeAnimationChange)==null||c.call(r,s,u),i(cr(e,s,"$isNodeAnimated",u),{type:"nodeAnimation",address:s,key:"$isNodeAnimated",value:u})},onNodeAnimationVariantChange:(s,u)=>{var c;u!=="traveling"&&u!=="pulse"||((c=r.onNodeAnimationVariantChange)==null||c.call(r,s,u),i(cr(e,s,"$nodeAnimationVariant",u),{type:"nodeAnimation",address:s,key:"$nodeAnimationVariant",value:u}))},onNodeCollapse:(s,u)=>{var c;(c=r.onNodeCollapse)==null||c.call(r,s,u),i(Jy(e,s,u),{type:"nodeCollapse",address:s,key:"$collapsed",value:u})},onNodeCreate:s=>{var p,b;const u=s.sourceNodeId&&wb(e,s.sourceNodeId,o);if(u){(p=r.onNodeCreate)==null||p.call(r,s),i(u.json,{type:"nodeCreate",address:u.address,value:"form"});return}(b=r.onNodeCreate)==null||b.call(r,s);const c=s.sourceNodeId||"root",l=ve(e,c),d=h0(l,s.isArrayMode?"list":"node"),f=Au(e,c,s.isArrayMode?[]:{},d);i(f.json,{type:"nodeCreate",address:f.address,value:s.isArrayMode?"array":"set"})},onNodeDelete:(s,u)=>{var c;(c=r.onNodeDelete)==null||c.call(r,s,u),i(Yy(e,s),{type:"nodeDelete",address:s})},onEdgeCreate:(s,u,c)=>{var d;(d=r.onEdgeCreate)==null||d.call(r,s,u,c);const l=c&&(c.sourceProperty!==void 0||c.targetProperty!==void 0)?{...c,target:u}:void 0;i(l?Tu(e,s,l):Xy(e,s,u),{type:"edgeCreate",address:s,key:l?"$connections":"$target",value:l??u})},onEdgeLabelChange:(s,u)=>{var l;(l=r.onEdgeLabelChange)==null||l.call(r,s,u);const c=a(s);c&&i(Br(e,c,"$sourceLabel",u),{type:"edgeLabel",edge:c,key:c.connection?"$connections":"$sourceLabel",value:u})},onEdgeStyleChange:(s,u)=>{var l;(l=r.onEdgeStyleChange)==null||l.call(r,s,u);const c=a(s);c&&i(Zy(e,c,u),{type:"edgeStyle",edge:c,value:u})},onEdgeAnimationVariantChange:(s,u)=>{var l;if(u!=="dashed"&&u!=="traveling")return;(l=r.onEdgeAnimationVariantChange)==null||l.call(r,s,u);const c=a(s);c&&i(Br(e,c,"$edgeAnimationVariant",u),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeAnimationVariant",value:u})},onEdgeTypeChange:(s,u)=>{var l;(l=r.onEdgeTypeChange)==null||l.call(r,s,u);const c=a(s);c&&i(Br(e,c,"$edgeType",u),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeType",value:u})},onEdgeIconChange:(s,u)=>{var l;(l=r.onEdgeIconChange)==null||l.call(r,s,u);const c=a(s);c&&i(Br(e,c,"$edgeIcon",u||void 0),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeIcon",value:u})},onEdgeColorChange:(s,u)=>{var l;(l=r.onEdgeColorChange)==null||l.call(r,s,u);const c=a(s);c&&i(Br(e,c,"$edgeColor",u),{type:"edgeColor",edge:c,key:c.connection?"$connections":"$edgeColor",value:u})},onEdgeDelete:(s,u)=>{var d;(d=r.onEdgeDelete)==null||d.call(r,s,u);const c=a(s);if(!c)return;const l=Qy(e,c);l.removed&&i(l.json,{type:"edgeDelete",edge:c,key:c.connection?"$connections":"$target"})}}}const p0=".flow-sdk-edge-trace{pointer-events:none;animation:flow-sdk-edge-trace 2.4s linear infinite}.flow-sdk-edge-trace-reverse{animation-direction:reverse}@keyframes flow-sdk-edge-trace{from{stroke-dashoffset:18}to{stroke-dashoffset:-100}}@media(prefers-reduced-motion:reduce){.flow-sdk-edge-trace,.flow-sdk-edge-anim{animation:none}}";function g0({path:e,color:t,width:r,reversed:n}){return h.jsx("path",{className:`flow-sdk-edge-trace${n?" flow-sdk-edge-trace-reverse":""}`,"data-animation-variant":"traveling","aria-hidden":"true",pointerEvents:"none",d:e,fill:"none",stroke:t,strokeWidth:r,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 100"})}const y0=".flow-sdk-node-animation{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;z-index:1}.flow-sdk-node-border-animation{pointer-events:none;animation:flow-sdk-node-border 2.4s linear infinite}.flow-sdk-node-border-pulse{stroke-width:var(--flow-pulse-rest-width);animation:flow-sdk-node-pulse 1.8s ease-in-out infinite}@keyframes flow-sdk-node-border{from{stroke-dashoffset:0}to{stroke-dashoffset:-100}}@keyframes flow-sdk-node-pulse{0%,100%{stroke-width:var(--flow-pulse-rest-width)}50%{stroke-width:var(--flow-pulse-expanded-width)}}@media(prefers-reduced-motion:reduce){.flow-sdk-node-border-animation{animation:none}}";function _b({x:e=0,y:t=0,width:r,height:n,radius:o,color:i,strokeWidth:a=8,path:s,variant:u="traveling"}){const c=S.useId(),l=`flow-sdk-node-border-animation${u==="pulse"?" flow-sdk-node-border-pulse":""}`;if(u==="pulse"){const d=s?"path":"rect",f=s?{d:s}:{x:e,y:t,width:Math.max(0,r),height:Math.max(0,n),rx:Math.max(0,Math.min(o,r/2,n/2))},p=a+36,b={x:e-p,y:t-p,width:r+2*p,height:n+2*p};return h.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[h.jsx("defs",{children:h.jsxs("mask",{id:c,maskUnits:"userSpaceOnUse",...b,style:{maskType:"luminance"},children:[h.jsx("rect",{...b,fill:"white"}),h.jsx(d,{...f,fill:"black",stroke:"black",strokeWidth:a,strokeLinejoin:"round"})]})}),h.jsx(d,{...f,className:l,"data-animation-variant":u,fill:"none",stroke:`color-mix(in srgb, ${i} 60%, transparent)`,strokeLinejoin:"round",mask:`url(#${c})`,style:{"--flow-pulse-rest-width":`${a+16}px`,"--flow-pulse-expanded-width":`${a+36}px`}})]})}return s?h.jsx("path",{className:l,"data-animation-variant":u,"aria-hidden":"true",pointerEvents:"none",d:s,fill:"none",stroke:i,strokeWidth:a,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"}):h.jsx("rect",{className:l,"data-animation-variant":u,"aria-hidden":"true",pointerEvents:"none",x:e,y:t,width:Math.max(0,r),height:Math.max(0,n),rx:Math.max(0,Math.min(o,r/2,n/2)),fill:"none",stroke:i,strokeWidth:a,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const b0=e=>{const n=1/(Math.cbrt(e)*.8);let o=Math.round(650*n),i=Math.round(350*n);return o=Math.max(40,Math.min(450,o)),i=Math.max(30,Math.min(300,i)),{edgeSep:o,rankSep:i}};function Al(e,t,r){const n=new Set([e]),o=[e];for(;o.length;){const i=o.pop();for(const a of t)(a.parent===i||a.id.startsWith(`${i}.`)||r.some(u=>(u.inverted?u.target:u.source)===i&&(u.inverted?u.source:u.target)===a.id))&&!n.has(a.id)&&(n.add(a.id),o.push(a.id))}return n}function m0(e,t,r){const n=r==="downward"||r==="upward",o=new Map;for(const a of e){if(a.source===a.target||a.sourceProperty||a.targetProperty)continue;const s=t(a.source),u=t(a.target);if(!s||!u)continue;const c=n?u.y-s.y:u.x-s.x,l=Math.abs(c)-(n?s.h+u.h:s.w+u.w)/2;if(l<=320)continue;const d=JSON.stringify([a.source,Math.sign(c)]),f=o.get(d)??[];f.push({edge:a,gap:l,cross:n?u.x-s.x:u.y-s.y}),o.set(d,f)}const i=new Map;for(const a of o.values()){if(new Set(a.map(({edge:u})=>u.target)).size<2)continue;const s=new Map;for(const{edge:u}of a)s.set(u.target,(s.get(u.target)??0)+1);for(const u of[-1,0,1]){const c=a.filter(({cross:d})=>Math.sign(d)===u);c.sort((d,f)=>Math.abs(f.cross)-Math.abs(d.cross)||d.edge.id.localeCompare(f.edge.id));const l=Math.min(...c.map(({gap:d})=>d));c.forEach(({edge:d,gap:f,cross:p},b)=>{const g=c.length===1?l/2:120+(l-280)*b/(c.length-1),m=c.find(w=>Math.abs(w.cross)<Math.abs(p));i.set(d.id,{turn:g/f,labelAtTarget:s.get(d.target)===1,labelFraction:p?(p+((m==null?void 0:m.cross)??0))/(2*p):.5})})}}return i}const ct=e=>({x1:e.x-e.w/2,y1:e.y-e.h/2,x2:e.x+e.w/2,y2:e.y+e.h/2}),v0=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function Yn(e){if(!e.length)return null;const t={...e[0]};for(let r=1;r<e.length;r++)t.x1=Math.min(t.x1,e[r].x1),t.y1=Math.min(t.y1,e[r].y1),t.x2=Math.max(t.x2,e[r].x2),t.y2=Math.max(t.y2,e[r].y2);return t}const x0=(e,t)=>e.x1<=t.x2&&e.x2>=t.x1&&e.y1<=t.y2&&e.y2>=t.y1,Tl=(e,t)=>e.x>=t.x1&&e.x<=t.x2&&e.y>=t.y1&&e.y<=t.y2,hr=e=>(Math.round(e*10)/10).toString(),Ke=e=>`${hr(e.x)} ${hr(e.y)}`,w0=e=>e>0?1:e<0?-1:0,Ol=(e,t)=>e>0?Math.max(e-t,0):Math.min(e+t,0);function C0(e,t,r,n,o=10){const i=t.x-e.x,a=t.y-e.y,s=Ol(i,(e.w+t.w)/2),u=Ol(a,(e.h+t.h)/2),c=r==="downward"||r==="upward",l=c?u:s,d=c?a:i,f=w0(d),p=n*l,b=y=>Math.abs(y)<o||Math.abs(y)>=Math.abs(l),g=b(p)||b(Math.abs(l)-Math.abs(p));let m;if(g)if(c)if(Math.abs(d)<=e.h/2){const y=(e.x+t.x)/2;m=[y,e.y,y,t.y]}else if(Math.abs(i)<=t.w/2){const y=(e.y+t.y)/2;m=[e.x,y,t.x,y]}else m=[e.x,t.y];else if(Math.abs(d)<=e.w/2){const y=(e.y+t.y)/2;m=[e.x,y,t.x,y]}else if(Math.abs(a)<=t.h/2){const y=(e.x+t.x)/2;m=[y,e.y,y,t.y]}else m=[t.x,e.y];else if(c){const y=e.y+p+e.h/2*f;m=[e.x,y,t.x,y]}else{const y=e.x+p+e.w/2*f;m=[y,e.y,y,t.y]}const w=[{x:e.x,y:e.y}];for(let y=0;y<m.length;y+=2)w.push({x:m[y],y:m[y+1]});return w.push({x:t.x,y:t.y}),w}function _0(e,t,r){const n=t.x-e.x,o=t.y-e.y,i=n>0?(r.x2-e.x)/n:n<0?(r.x1-e.x)/n:1/0,a=o>0?(r.y2-e.y)/o:o<0?(r.y1-e.y)/o:1/0,s=Math.min(i,a);return!Number.isFinite(s)||s>=1||s<0?null:{x:e.x+n*s,y:e.y+o*s}}function pt(e,t,r){var a;if(!((a=r.outline)!=null&&a.length))return _0(e,t,ct(r));const n=t.x-e.x,o=t.y-e.y;let i=1/0;return r.outline.forEach((s,u,c)=>{const l=c[(u+1)%c.length],d=l.x-s.x,f=l.y-s.y,p=n*f-o*d;if(Math.abs(p)<1e-9)return;const b=s.x-e.x,g=s.y-e.y,m=(b*f-g*d)/p,w=(b*o-g*n)/p;m>=0&&m<1&&w>=-1e-9&&w<=1+1e-9&&(i=Math.min(i,m))}),Number.isFinite(i)?{x:e.x+n*i,y:e.y+o*i}:null}function Sb(e,t,r=.5){const n=Number.isFinite(r)?Math.max(0,Math.min(1,r)):.5,o=t==="top"||t==="bottom",i=t==="top"||t==="left"?-1:1,a={x:o?e.x-e.w/2+e.w*n:e.x,y:o?e.y:e.y-e.h/2+e.h*n},s=Math.max(e.w,e.h)*2+1;return{...pt(a,{x:a.x+(o?0:i*s),y:a.y+(o?i*s:0)},e)??{x:o?a.x:e.x+i*e.w/2,y:o?e.y+i*e.h/2:a.y},side:t}}function dt(e,t){return{x:e.x+(e.side==="right"?t:e.side==="left"?-t:0),y:e.y+(e.side==="bottom"?t:e.side==="top"?-t:0)}}function S0(e,t,r,n){const o=dt(e,r.srcDist),i=dt(t,r.tgtDist);if(n==="straight")return jb(o,i,r);const a=Math.max(80,Math.min(300,Math.hypot(i.x-o.x,i.y-o.y)/3)),s=e.side==="bottom"&&t.side==="top"?i.y-o.y:e.side==="top"&&t.side==="bottom"?o.y-i.y:e.side==="right"&&t.side==="left"?i.x-o.x:e.side==="left"&&t.side==="right"?o.x-i.x:void 0,u=s!==void 0&&s>0?Math.min(a,s/2):a,c=dt({...o,side:e.side},u),l=dt({...i,side:t.side},u),d=r.arrowAt==="source"?rr(o,c,r.arrowGap):o,f=r.arrowAt==="target"?rr(i,l,r.arrowGap):i,p=r.arrowAt==="source"?mr(o,c,r.arrowSize,r.headShape):r.arrowAt==="target"?mr(i,l,r.arrowSize,r.headShape):void 0;if(n==="bezier")return{d:`M${Ke(d)} C${Ke(c)} ${Ke(l)} ${Ke(f)}`,arrow:p,label:{x:(d.x+3*c.x+3*l.x+f.x)/8,y:(d.y+3*c.y+3*l.y+f.y)/8,angle:0}};const b=e.side==="left"||e.side==="right",g=t.side==="left"||t.side==="right";let m;if(b!==g){const y=b?{x:l.x,y:c.y}:{x:c.x,y:l.y},x=(y.x-c.x)*(c.x-o.x)+(y.y-c.y)*(c.y-o.y)>=0,v=(y.x-l.x)*(l.x-i.x)+(y.y-l.y)*(l.y-i.y)>=0;m=[x&&v?y:b?{x:c.x,y:l.y}:{x:l.x,y:c.y}]}else if(s!==void 0&&s<=0)if(b){const y=(c.y+l.y)/2;m=[{x:c.x,y},{x:l.x,y}]}else{const y=(c.x+l.x)/2;m=[{x:y,y:c.y},{x:y,y:l.y}]}else if(b){const y=e.side===t.side?e.side==="right"?Math.max(c.x,l.x):Math.min(c.x,l.x):(c.x+l.x)/2;m=[{x:y,y:c.y},{x:y,y:l.y}]}else{const y=e.side===t.side?e.side==="bottom"?Math.max(c.y,l.y):Math.min(c.y,l.y):(c.y+l.y)/2;m=[{x:c.x,y},{x:l.x,y}]}const w=[c,...m,l].filter((y,x,v)=>x===0||y.x!==v[x-1].x||y.y!==v[x-1].y);return _n(d,w,f,p,n==="orthogonal"?0:r.radius)}function rr(e,t,r){const n=e.x-t.x,o=e.y-t.y,i=Math.hypot(n,o);if(!i)return e;let a=(i-r)/i;return a<0&&(a=1e-5),{x:t.x+a*n,y:t.y+a*o}}function mr(e,t,r,n="triangle"){const o=e.x-t.x,i=e.y-t.y,a=Math.hypot(o,i)||1,s=o/a,u=i/a,c=(n==="square"?.15:.3)*r,l=.15*r,d=e.x-s*c,f=e.y-u*c;return n==="square"?`M${Ke(e)} L${hr(e.x-u*l)} ${hr(e.y+s*l)} L${hr(d-u*l)} ${hr(f+s*l)} L${hr(d+u*l)} ${hr(f-s*l)} L${hr(e.x+u*l)} ${hr(e.y-s*l)} Z`:`M${Ke(e)} L${hr(d-u*l)} ${hr(f+s*l)} L${hr(d+u*l)} ${hr(f-s*l)} Z`}function Fr(e,t){let r=Math.atan(t/e);return e===0&&r<0&&(r=-r),Number.isFinite(r)||(r=0),r*180/Math.PI}function E0(e,t,r,n){const o={x:t.x-e.x,y:t.y-e.y},i={x:r.x-t.x,y:r.y-t.y},a=Math.hypot(o.x,o.y),s=Math.hypot(i.x,i.y),u=o.x*i.y-o.y*i.x;if(a<1e-6||s<1e-6||Math.abs(u)<1e-6)return{p1:t,b:t,p2:t,r:0};const c=Math.min(n,a/2,s/2);return{p1:{x:t.x-o.x/a*c,y:t.y-o.y/a*c},b:t,p2:{x:t.x+i.x/s*c,y:t.y+i.y/s*c},r:c}}function Eb(e,t,r,n){let o=-1,i=null;for(let b=0;b<e.length-1;b++){const g=pt(e[b],e[b+1],t);if(g){o=b,i=g;break}}let a=-1,s=null;for(let b=e.length-1;b>0;b--){const g=pt(e[b],e[b-1],r);if(g){a=b,s=g;break}}if(!i||!s||o>=a)return null;const u=e.slice(o+1,a),c=u[0]??s,l=u[u.length-1]??i;let d,f,p;if(n.arrowAt==="source"){const b=rr(i,c,n.srcDist);d=rr(i,c,n.srcDist+n.arrowGap),p=mr(b,c,n.arrowSize,n.headShape)}else d=rr(i,c,n.srcDist);if(n.arrowAt==="target"){const b=rr(s,l,n.tgtDist);f=rr(s,l,n.tgtDist+n.arrowGap),p=mr(b,l,n.arrowSize,n.headShape)}else f=rr(s,l,n.tgtDist);return _n(d,u,f,p,n.radius,n.labelTargetLength,n.labelFraction)}function _n(e,t,r,n,o,i,a){var f;const s=[e,...t,r],u=[];let c=`M${Ke(e)}`;for(let p=1;p<s.length-1;p++){const b=E0(s[p-1],s[p],s[p+1],o);u.push(b),b.r===0?c+=` L${Ke(b.b)}`:c+=` L${Ke(b.p1)} Q${Ke(b.b)} ${Ke(b.p2)}`}c+=` L${Ke(r)}`;let l;const d=t.length;if(d===0)l={x:(e.x+r.x)/2,y:(e.y+r.y)/2,angle:Fr(r.x-e.x,r.y-e.y)};else if(d%2===0){const p=t[d/2-1],b=t[d/2];l={x:(p.x+b.x)/2,y:(p.y+b.y)/2,angle:Fr(b.x-p.x,b.y-p.y)}}else{const p=u[(d-1)/2];if(p.r===0){const b=s[(d-1)/2+2];l={x:p.b.x,y:p.b.y,angle:Fr(b.x-p.b.x,b.y-p.b.y)}}else l={x:.25*p.p1.x+.5*p.b.x+.25*p.p2.x,y:.25*p.p1.y+.5*p.b.y+.25*p.p2.y,angle:Fr(p.p2.x-p.p1.x,p.p2.y-p.p1.y)}}if(i!==void 0){if(a!==void 0&&u.length===2){const m=u[0].p2,w=u[1].p1,y=Math.hypot(w.x-m.x,w.y-m.y),x=Math.min(.5,i/(2*y)),v=Math.max(x,Math.min(1-x,a));l={x:m.x+(w.x-m.x)*v,y:m.y+(w.y-m.y)*v,angle:Fr(w.x-m.x,w.y-m.y)}}const p=((f=u[u.length-1])==null?void 0:f.p2)??e,b=r.x-p.x,g=r.y-p.y;Math.hypot(b,g)>=i&&(l={x:(p.x+r.x)/2,y:(p.y+r.y)/2,angle:Fr(b,g)})}return{d:c,arrow:n,label:l}}function Il(e,t,r,n,o,i,a){const s=r==="leftward"?-1:1,u={x:e.x+s*(e.w/2+a.srcDist),y:n??e.y},c={x:t.x-s*(t.w/2+a.tgtDist),y:o??t.y},l=Math.max(80,a.arrowGap+a.arrowSize*.3),d=u.x+s*l,f=c.x-s*l;let p;if(s*(f-d)>=0){const w=u.x+(c.x-u.x)*i,y=Math.max(Math.min(d,f),Math.min(Math.max(d,f),w));p=[{x:y,y:u.y},{x:y,y:c.y}]}else{const w=Math.min(e.y-e.h/2,t.y-t.h/2)-l*(1+i);p=[{x:d,y:u.y},{x:d,y:w},{x:f,y:w},{x:f,y:c.y}]}const b=a.arrowAt==="source"?rr(u,p[0],a.arrowGap):u,g=a.arrowAt==="target"?rr(c,p[p.length-1],a.arrowGap):c,m=a.arrowAt==="source"?mr(u,p[0],a.arrowSize,a.headShape):a.arrowAt==="target"?mr(c,p[p.length-1],a.arrowSize,a.headShape):void 0;return _n(b,p,g,m,a.radius)}function Ml(e,t,r,n,o){return Eb(C0(e,t,r,n),e,t,o)}function ql(e,t,r,n,o,i){const a=n===void 0&&o===void 0&&(r==="downward"||r==="upward"),s=r==="leftward"||a&&r==="upward"?-1:1,u=(c,l,d)=>{const f={x:c.x,y:l??c.y},p=Math.max(c.w,c.h)*2+1,b=pt(f,{x:f.x+(a?0:d*p),y:f.y+(a?d*p:0)},c);return b?{x:b.x+(a?0:d*i),y:b.y+(a?d*i:0)}:a?{x:c.x,y:c.y+d*(c.h/2+i)}:{x:c.x+d*(c.w/2+i),y:l??c.y}};return{sourcePoint:u(e,n,s),targetPoint:u(t,o,-s)}}function j0(e,t,r,n){const o=r==="downward"||r==="upward",i=r==="leftward"||r==="upward"?-1:1,a=Math.max(100,Math.abs(o?t.y-e.y:t.x-e.x)/2),s={x:e.x+(o?0:i*a),y:e.y+(o?i*a:0)},u={x:t.x-(o?0:i*a),y:t.y-(o?i*a:0)},c=n.arrowAt==="source"?rr(e,s,n.arrowGap):e,l=n.arrowAt==="target"?rr(t,u,n.arrowGap):t;return{d:`M${Ke(c)} C${Ke(s)} ${Ke(u)} ${Ke(l)}`,arrow:n.arrowAt==="source"?mr(e,s,n.arrowSize,n.headShape):n.arrowAt==="target"?mr(t,u,n.arrowSize,n.headShape):void 0,label:{x:(c.x+3*s.x+3*u.x+l.x)/8,y:(c.y+3*s.y+3*u.y+l.y)/8,angle:Fr(l.x+u.x-s.x-c.x,l.y+u.y-s.y-c.y)}}}function jb(e,t,r){const n=r.arrowAt==="source"?rr(e,t,r.arrowGap):e,o=r.arrowAt==="target"?rr(t,e,r.arrowGap):t,i=r.arrowAt==="source"?mr(e,t,r.arrowSize,r.headShape):r.arrowAt==="target"?mr(t,e,r.arrowSize,r.headShape):void 0;return _n(n,[],o,i,0)}function R0(e,t,r,n=-90,o=-60,i=350){const a=n*Math.PI/180,s=o*Math.PI/180,u=a-Math.PI/2,c=u-s/2,l=u+s/2,d=1.4*i*(t/3+1),f={x:e.x+Math.cos(c)*d,y:e.y+Math.sin(c)*d},p={x:e.x+Math.cos(l)*d,y:e.y+Math.sin(l)*d},b={x:e.x,y:e.y},g=pt(b,f,e),m=pt(b,p,e);if(!g||!m)return null;const w={x:(f.x+p.x)/2,y:(f.y+p.y)/2};let y=rr(g,f,r.srcDist),x=rr(m,p,r.tgtDist),v;if(r.arrowAt==="target"){const _=x;x=rr(m,p,r.tgtDist+r.arrowGap),v=mr(_,p,r.arrowSize,r.headShape)}else if(r.arrowAt==="source"){const _=y;y=rr(g,f,r.srcDist+r.arrowGap),v=mr(_,f,r.arrowSize,r.headShape)}return{d:`M${Ke(y)} Q${Ke(f)} ${Ke(w)} Q${Ke(p)} ${Ke(x)}`,arrow:v,label:{x:w.x,y:w.y,angle:Fr(p.x-f.x,p.y-f.y)}}}const at=e=>Math.round(e*1e3)/1e3;function Rb(e){const t=e.querySelector("[data-flow-node-surface]");if(!t)return;const r=e.getBoundingClientRect(),n=r.width/e.offsetWidth;if(!Number.isFinite(n)||n<=0)return;const o=t.getBoundingClientRect();if(!o.width||!o.height)return;const i=t,a=typeof i.getScreenCTM=="function"?i.getScreenCTM():null,s=typeof i.getTotalLength=="function"?i.getTotalLength():0,u=i.points,c=(u==null?void 0:u.numberOfItems)||128,l=a&&s>0?Array.from({length:c},(d,f)=>{const p=u!=null&&u.numberOfItems?u.getItem(f):i.getPointAtLength(s*f/c);return{x:at((a.a*p.x+a.c*p.y+a.e-r.left)/n),y:at((a.b*p.x+a.d*p.y+a.f-r.top)/n)}}):void 0;return{left:at((o.left-r.left)/n),top:at((o.top-r.top)/n),width:t instanceof HTMLElement?t.offsetWidth:at(o.width/n),height:t instanceof HTMLElement?t.offsetHeight:at(o.height/n),radius:parseFloat(getComputedStyle(t).borderTopLeftRadius)||0,...l?{outline:l}:{}}}function Ft(e,t){const r=e.x-e.w/2,n=e.y-e.h/2;return{x:r+t.left+t.width/2,y:n+t.top+t.height/2,w:t.width,h:t.height,...t.outline?{outline:t.outline.map(o=>({x:r+o.x,y:n+o.y}))}:{}}}function k0(e,t,r,n,o){var l;const i=o!=="TB"&&o!=="BT",a=i?"top":"left",s=i?"bottom":"right",u=new Map;for(const d of n)for(const[f,p,b]of[[d.source,d.sourceProperty,d.target],[d.target,d.targetProperty,d.source]]){const g=t.get(b);if(p===void 0||!g||b===f)continue;const m=r.get(b),w=JSON.stringify([f,p]),y=u.get(w)??[];y.push(m?Ft(g,m):g),u.set(w,y)}const c=new Map(e);for(const[d,f]of e){const p=t.get(d);if(!p||!f.some(x=>x.placement==="config"))continue;const b=r.get(d),g=b?Ft(p,b):p,m={x:p.w/2,y:p.h/2,w:p.w,h:p.h},w=b?Ft(m,b):m,y=new Map;for(const x of f){if(x.placement!=="config")continue;const C=(u.get(JSON.stringify([d,x.property]))??[]).reduce((k,T)=>k+(i?T.y-g.y:T.x-g.x),0),_=((l=x.anchor)==null?void 0:l.side)===s?s:a;y.set(x,C<-.001?a:C>.001?s:_)}c.set(d,f.map(x=>{const v=y.get(x);if(!v)return x;const C=f.filter(T=>y.get(T)===v),_=(C.indexOf(x)+1)/(C.length+1),k=Sb(w,v,_);return{...x,anchor:k,top:k.y,height:0}}))}return c}function Nl(e,t,r){const n=new Set(t.map(s=>s.id));if(!n.has(e))return new Set;const o=new Set([e]);let i=!0;for(;i;){i=!1;for(const s of t)!o.has(s.id)&&(o.has(s.parent??"")||s.id.startsWith(`${e}.`))&&(o.add(s.id),i=!0)}const a=new Set(o);for(const s of r)o.has(s.source)&&n.has(s.target)&&a.add(s.target),o.has(s.target)&&n.has(s.source)&&a.add(s.source);return a}const rt='"Helvetica Neue", Helvetica, sans-serif';let Et;const an=new Map;function Sn(e,t){const r=`${t}|${e}`,n=an.get(r);if(n!==void 0)return n;Et===void 0&&(Et=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let o;return Et?(Et.font=t,o=Et.measureText(e).width):o=e.length*(parseFloat(t)||16)*.55,an.size>5e3&&an.clear(),an.set(r,o),o}function P0(e,t,r){const n=[];for(const o of String(e).split(`
157
+ `)){const i=o.split(/\s+/).filter(Boolean);if(!i.length){n.push("");continue}let a="";for(const s of i){const u=a?`${a} ${s}`:s;!a||Sn(u,t)<=r?a=u:(n.push(a),a=s)}n.push(a)}return n}const A0=e=>e.stopPropagation();function T0({id:e,rect:t,label:r,labelLayer:n,style:o,onSelect:i,onCollapse:a,selected:s=!1}){const u=t.x2-t.x1,c=t.y2-t.y1,l=o.borderWidth,d=o.borderStyle==="dashed"?`${l*4} ${l*2}`:o.borderStyle==="dotted"?`${l} ${l}`:void 0,f=t.x1+u/2,p=o.labelPosition==="top"?t.y1+o.labelMargin-o.fontSize/2:o.labelPosition==="bottom"?t.y2-o.labelMargin+o.fontSize/2:t.y1+c/2,b=r?Sn(r,`bold ${o.fontSize}px ${rt}`):0,g=o.fontSize/5,m=r||s&&a?h.jsxs("g",{className:"flow-sdk-container-label","data-node-id":e,children:[s&&a&&h.jsx("foreignObject",{x:f+b/2+g+8,y:p-24,width:48,height:48,"data-flow-content-toggle":"",style:{pointerEvents:"auto"},children:h.jsx(je,{label:"Show icon",children:h.jsx(me,{"aria-label":"Show icon",icon:h.jsx(J.PiCircleFill,{}),variant:"ghost",style:{width:48,height:48,color:o.textColor},onClick:w=>{w.stopPropagation(),a(e)}})})}),r&&h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:f-b/2-g,y:p-o.fontSize/2-g,width:b+2*g,height:o.fontSize+2*g,fill:o.textColor==="transparent"?"transparent":o.labelBg}),h.jsx("text",{x:f,y:p,fill:o.textColor,fontSize:o.fontSize,fontWeight:"bold",fontFamily:rt,style:{fontSize:o.fontSize,fontWeight:"bold",fontFamily:rt},textAnchor:"middle",dominantBaseline:"central",children:r})]})]}):null;return h.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:A0,onClick:w=>{w.stopPropagation(),i==null||i(e,{shiftKey:w.shiftKey,ctrlKey:w.ctrlKey,metaKey:w.metaKey,altKey:w.altKey})},children:[h.jsx("rect",{x:t.x1,y:t.y1,width:u,height:c,rx:o.borderRadius,ry:o.borderRadius,fill:o.bgColor,fillOpacity:o.bgOpacity,stroke:o.borderColor,strokeWidth:o.borderStyle==="double"?l/3:l,strokeDasharray:d}),o.borderStyle==="double"&&h.jsx("rect",{x:t.x1+l*2/3,y:t.y1+l*2/3,width:Math.max(0,u-l*4/3),height:Math.max(0,c-l*4/3),rx:Math.max(0,o.borderRadius-l*2/3),ry:Math.max(0,o.borderRadius-l*2/3),fill:"none",stroke:o.borderColor,strokeWidth:l/3}),o.animated&&l>0&&h.jsx(_b,{variant:o.animationVariant,x:t.x1,y:t.y1,width:u,height:c,radius:o.borderRadius,color:o.animationColor||o.borderColor,strokeWidth:Math.max(8,l*1.6)}),n&&m?Bt.createPortal(m,n):m]})}const O0=S.memo(T0),pn=45,kb=70,Zr=15,Pb=50;function Ab(e,t,r=pn){const n=`${r}px ${rt}`,o=e?P0(e,n,200*r/pn):[],i=t?48+(o.length?12:0):0,a=i+Math.max(0,...o.map(c=>Sn(c,n))),s=Math.max(o.length*r,t?48:0),u=o.length||t?2*Zr:0;return{lines:o,iconWidth:i,contentWidth:a,contentHeight:s,width:a+u,height:s+u}}const gn=6,Tb=3,Lu=Math.max(Math.pow(gn*13.37,.9),29)*Tb,Ob=gn*Tb*2,cn=80,I0=2*cn+Lu*.3+100,M0=36+2*Math.max(80,Ob+Lu*.3);function wu(e){return e.sourceProperty!==void 0||e.targetProperty!==void 0}function Cu(e,t){return t==="auto"||(t==="properties"?wu(e):!wu(e))}function ut(e,t,r){return r!=="properties"||e!=="root"||t.some(n=>(n.source===e||n.target===e)&&wu(n))}function q0(e,t,r,n=!1,o){if(!n)return{nodes:e,edges:t};const i=e.filter(s=>ut(s.id,t,r)&&(!o||o.has(s.id))),a=new Set(i.map(s=>s.id));return{nodes:i,edges:t.filter(s=>Cu(s,r)&&a.has(s.source)&&a.has(s.target))}}const N0=500,$0="32 18",L0=e=>e.stopPropagation();function F0({id:e,edgeData:t,validationIssue:r,edgeType:n="rounded-orthogonal",edgeRadius:o,customEdgeTypes:i,source:a,target:s,sourceProperty:u,targetProperty:c,sourceY:l,targetY:d,sourcePort:f,targetPort:p,propertyMode:b=!1,dir:g,turn:m,labelAtTarget:w,labelFraction:y,color:x,labelBg:v,labelLayer:C,label:_,dashed:k,animated:T,inverted:P,loopIndex:j=0,onSelect:R}){const E=t==null?void 0:t.icon,M=b?pn:kb,{lines:I,iconWidth:N,contentWidth:O,contentHeight:W}=S.useMemo(()=>Ab(_,E,M),[_,E,M]),z=S.useMemo(()=>{const Y={srcDist:cn,tgtDist:cn,arrowGap:Ob,arrowSize:Lu,headShape:b&&(P?l!==void 0||f:d!==void 0||p)?"square":"triangle",radius:o??(w?40:N0),arrowAt:P?"source":"target",labelTargetLength:w?O+2*Zr:void 0,labelFraction:w?y:void 0},ce=l!==void 0||d!==void 0||!!f||!!p,X=ql(a,s,g,l,d,0),U=l===void 0&&d===void 0&&(g==="downward"||g==="upward"),Z=f??{...X.sourcePoint,side:U?g==="upward"?"top":"bottom":g==="leftward"?"left":"right"},ae=p??{...X.targetPoint,side:U?g==="upward"?"bottom":"top":g==="leftward"?"right":"left"},ue=a.x===s.x&&a.y===s.y,de=f||p?S0(Z,ae,{...Y,srcDist:18,tgtDist:18},n):ce?Il(a,s,g,l,d,m,{...Y,srcDist:18,tgtDist:18,radius:o??Math.min(Y.radius,40)}):ue?R0(a,j,{...Y,srcDist:0,tgtDist:0}):Ml(a,s,g,m,Y);if(!de)return null;const Ee=ql(a,s,g,l,d,ce?18:cn);f&&(Ee.sourcePoint=dt(f,18)),p&&(Ee.targetPoint=dt(p,18));const ge=Object.prototype.hasOwnProperty.call(i??{},n)?i==null?void 0:i[n]:void 0;if(ge){const He={rightward:"LR",leftward:"RL",downward:"TB",upward:"BT"};return ge({edge:t??{id:e,source:"",target:""},source:{...a},target:{...s},...Ee,direction:He[g],sourceY:l,targetY:d,inverted:!!P,defaultGeometry:de})??de}return ue||f||p?de:n==="straight"?ce?jb(Ee.sourcePoint,Ee.targetPoint,Y):Eb([a,s],a,s,Y):n==="bezier"?j0(Ee.sourcePoint,Ee.targetPoint,ce?g==="leftward"?"leftward":"rightward":g,Y):n==="orthogonal"?ce?Il(a,s,g,l,d,m,{...Y,srcDist:18,tgtDist:18,radius:0}):Ml(a,s,g,m,{...Y,radius:0}):de},[a,e,t,n,o,i,s,b,l,d,f,p,g,m,P,j,w,y,O]);if(!z)return null;const re=(g==="rightward"||g==="leftward")&&!Object.prototype.hasOwnProperty.call(i??{},n)&&!(b&&(l!==void 0||d!==void 0||f||p)),te=re?`translate(${z.label.x} ${z.label.y-W/2-2*Zr})`:`translate(${z.label.x} ${z.label.y}) rotate(${z.label.angle}) translate(${w||Object.prototype.hasOwnProperty.call(i??{},n)?0:Pb} 0)`,he=r!=null&&r.startsWith("Unverified:")?"#b45309":"#dc2626",be=r?he:x,K=r?h.jsxs("g",{className:"flow-sdk-edge-validation",role:"img","aria-label":r,transform:`translate(${z.label.x} ${z.label.y-I.length*M/2-55})`,children:[h.jsx("title",{children:r}),h.jsx(qr,{name:"PiWarningCircleFill",svg:!0,size:48,x:-24,y:-24,color:he})]}):null,q=T&&(t==null?void 0:t.edgeAnimationVariant)==="traveling",L=!q&&(k||T)?$0:void 0,G=T&&!q?`flow-sdk-edge-anim${P?" flow-sdk-edge-anim-rev":""}`:void 0;let B=null;if(I.length||E){const Y=O,ce=W;B=h.jsxs("g",{className:"flow-sdk-edge-label","data-label-transform":te,"data-label-horizontal":re||void 0,"data-edge-id":e,"data-source-property":u,"data-target-property":c,transform:te,children:[h.jsx("rect",{x:-Y/2-Zr,y:-ce/2-Zr,width:Y+2*Zr,height:ce+2*Zr,fill:x==="transparent"?"transparent":v}),h.jsx("text",{fill:x,fontSize:M,style:{fontSize:M,fontFamily:rt},fontFamily:rt,textAnchor:"middle",dominantBaseline:"central",children:I.map((X,U)=>h.jsx("tspan",{x:N/2,y:(U-(I.length-1)/2)*M,children:X},U))}),E&&h.jsxs("g",{className:"flow-sdk-edge-icon",opacity:x==="transparent"?0:1,children:[h.jsx("title",{children:_?`Edge icon: ${_}`:"Edge icon"}),h.jsx("rect",{x:-Y/2,y:-24,width:48,height:48,fill:"transparent"}),h.jsx(qr,{name:E,svg:!0,size:48,x:-Y/2,y:-24,color:x})]})]})}return h.jsxs("g",{className:"flow-sdk-edge","data-edge-id":e,"data-source-property":u,"data-target-property":c,"data-validation":r?r.startsWith("Unverified:")?"unverified":"invalid":void 0,"aria-label":r,onPointerDown:L0,onClick:Y=>{Y.stopPropagation(),R==null||R(e)},children:[h.jsx("path",{d:z.d,fill:"none",stroke:be,strokeWidth:gn,strokeOpacity:q?.35:void 0,strokeDasharray:L,className:G}),q&&h.jsx(g0,{path:z.d,color:be,width:gn*1.6,reversed:P}),z.arrow&&h.jsx("path",{d:z.arrow,fill:be}),C&&B?Bt.createPortal(B,C):B,C&&K?Bt.createPortal(K,C):K,h.jsx("path",{className:"flow-sdk-edge-hit",d:z.d,fill:"none",stroke:"transparent"})]})}const $l=S.memo(F0),Ll=(e,t)=>e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top;function B0(e){const t=e.querySelector(".flow-sdk-labels"),r=t==null?void 0:t.getScreenCTM();if(!t||!r)return;const n=r.inverse(),o=(c,l=0)=>{const d=c.getBoundingClientRect(),f=new DOMPoint(d.left,d.top).matrixTransform(n),p=new DOMPoint(d.right,d.bottom).matrixTransform(n);return{left:f.x-l,right:p.x+l,top:f.y-l,bottom:p.y+l}},i=[...e.querySelectorAll(".flow-sdk-node, .flow-sdk-node button")].filter(c=>{const l=c.getBoundingClientRect(),d=getComputedStyle(c);return l.width>0&&l.height>0&&d.visibility!=="hidden"&&d.opacity!=="0"}).map(c=>o(c,24));for(const c of t.querySelectorAll(".flow-sdk-container-label"))i.push(o(c,12));const a=[...t.querySelectorAll(".flow-sdk-edge-label")];for(const c of a)c.setAttribute("transform",c.dataset.labelTransform??"");const s=new Map(a.map(c=>[c,o(c,8)])),u=new Map([...e.querySelectorAll(".flow-sdk-edge")].map(c=>[c.dataset.edgeId,c.querySelector("path")]));for(const c of a){const l=c.dataset.labelHorizontal==="true",d=s.get(c);s.delete(c);const f=k=>i.some(T=>Ll(k,T))||[...s.values()].some(T=>Ll(k,T));if(!l&&!f(d)){s.set(c,d);continue}const p=u.get(c.dataset.edgeId),b=c.querySelector("rect");if(!p||!b)continue;const g=b.getBBox(),m=p.getTotalLength();if(!Number.isFinite(m)||m<=0)continue;const w=(d.left+d.right)/2,y=(d.top+d.bottom)/2,x=Math.min(256,Math.max(16,Math.ceil(m/24))),v=Array.from({length:x+1},(k,T)=>p.getPointAtLength(m*T/x)),_=Array.from({length:x+1},(k,T)=>{const P=m*T/x,j=v[T],R=l?{x:j.x,y:j.y-g.height/2-15}:j,E=p.getPointAtLength(Math.max(0,P-2)),M=p.getPointAtLength(Math.min(m,P+2));let I=Math.atan2(M.y-E.y,M.x-E.x)*180/Math.PI;I>90&&(I-=180),I<-90&&(I+=180);const N=Math.abs(I)<1;l&&(I=0);const O=I*Math.PI/180,W=Math.abs(Math.cos(O))*g.width+Math.abs(Math.sin(O))*g.height,z=Math.abs(Math.sin(O))*g.width+Math.abs(Math.cos(O))*g.height;return{point:R,angle:I,straight:N,score:Math.hypot(R.x-w,R.y-y),bounds:{left:R.x-W/2-8,right:R.x+W/2+8,top:R.y-z/2-8,bottom:R.y+z/2+8}}}).sort((k,T)=>k.score-T.score).find(k=>!f(k.bounds)&&(!l||k.straight&&!v.some(T=>T.x>k.bounds.left&&T.x<k.bounds.right&&T.y>k.bounds.top&&T.y<k.bounds.bottom)));_?(c.setAttribute("transform",`translate(${_.point.x} ${_.point.y}) rotate(${_.angle})`),s.set(c,_.bounds)):s.set(c,d)}}var sn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function D0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Fu(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Xn,Fl;function z0(){if(Fl)return Xn;Fl=1;function e(){this.__data__=[],this.size=0}return Xn=e,Xn}var Qn,Bl;function bt(){if(Bl)return Qn;Bl=1;function e(t,r){return t===r||t!==t&&r!==r}return Qn=e,Qn}var eo,Dl;function En(){if(Dl)return eo;Dl=1;var e=bt();function t(r,n){for(var o=r.length;o--;)if(e(r[o][0],n))return o;return-1}return eo=t,eo}var ro,zl;function V0(){if(zl)return ro;zl=1;var e=En(),t=Array.prototype,r=t.splice;function n(o){var i=this.__data__,a=e(i,o);if(a<0)return!1;var s=i.length-1;return a==s?i.pop():r.call(i,a,1),--this.size,!0}return ro=n,ro}var to,Vl;function W0(){if(Vl)return to;Vl=1;var e=En();function t(r){var n=this.__data__,o=e(n,r);return o<0?void 0:n[o][1]}return to=t,to}var no,Wl;function G0(){if(Wl)return no;Wl=1;var e=En();function t(r){return e(this.__data__,r)>-1}return no=t,no}var oo,Gl;function U0(){if(Gl)return oo;Gl=1;var e=En();function t(r,n){var o=this.__data__,i=e(o,r);return i<0?(++this.size,o.push([r,n])):o[i][1]=n,this}return oo=t,oo}var io,Ul;function jn(){if(Ul)return io;Ul=1;var e=z0(),t=V0(),r=W0(),n=G0(),o=U0();function i(a){var s=-1,u=a==null?0:a.length;for(this.clear();++s<u;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,io=i,io}var ao,Hl;function H0(){if(Hl)return ao;Hl=1;var e=jn();function t(){this.__data__=new e,this.size=0}return ao=t,ao}var so,Kl;function K0(){if(Kl)return so;Kl=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return so=e,so}var co,Jl;function J0(){if(Jl)return co;Jl=1;function e(t){return this.__data__.get(t)}return co=e,co}var uo,Zl;function Z0(){if(Zl)return uo;Zl=1;function e(t){return this.__data__.has(t)}return uo=e,uo}var lo,Yl;function Ib(){if(Yl)return lo;Yl=1;var e=typeof sn=="object"&&sn&&sn.Object===Object&&sn;return lo=e,lo}var fo,Xl;function Sr(){if(Xl)return fo;Xl=1;var e=Ib(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return fo=r,fo}var ho,Ql;function mt(){if(Ql)return ho;Ql=1;var e=Sr(),t=e.Symbol;return ho=t,ho}var po,ed;function Y0(){if(ed)return po;ed=1;var e=mt(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,o=e?e.toStringTag:void 0;function i(a){var s=r.call(a,o),u=a[o];try{a[o]=void 0;var c=!0}catch{}var l=n.call(a);return c&&(s?a[o]=u:delete a[o]),l}return po=i,po}var go,rd;function X0(){if(rd)return go;rd=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return go=r,go}var yo,td;function tt(){if(td)return yo;td=1;var e=mt(),t=Y0(),r=X0(),n="[object Null]",o="[object Undefined]",i=e?e.toStringTag:void 0;function a(s){return s==null?s===void 0?o:n:i&&i in Object(s)?t(s):r(s)}return yo=a,yo}var bo,nd;function vr(){if(nd)return bo;nd=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return bo=e,bo}var mo,od;function Qt(){if(od)return mo;od=1;var e=tt(),t=vr(),r="[object AsyncFunction]",n="[object Function]",o="[object GeneratorFunction]",i="[object Proxy]";function a(s){if(!t(s))return!1;var u=e(s);return u==n||u==o||u==r||u==i}return mo=a,mo}var vo,id;function Q0(){if(id)return vo;id=1;var e=Sr(),t=e["__core-js_shared__"];return vo=t,vo}var xo,ad;function ew(){if(ad)return xo;ad=1;var e=Q0(),t=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!t&&t in n}return xo=r,xo}var wo,sd;function Mb(){if(sd)return wo;sd=1;var e=Function.prototype,t=e.toString;function r(n){if(n!=null){try{return t.call(n)}catch{}try{return n+""}catch{}}return""}return wo=r,wo}var Co,cd;function rw(){if(cd)return Co;cd=1;var e=Qt(),t=ew(),r=vr(),n=Mb(),o=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,a=Function.prototype,s=Object.prototype,u=a.toString,c=s.hasOwnProperty,l=RegExp("^"+u.call(c).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(f){if(!r(f)||t(f))return!1;var p=e(f)?l:i;return p.test(n(f))}return Co=d,Co}var _o,ud;function tw(){if(ud)return _o;ud=1;function e(t,r){return t==null?void 0:t[r]}return _o=e,_o}var So,ld;function nt(){if(ld)return So;ld=1;var e=rw(),t=tw();function r(n,o){var i=t(n,o);return e(i)?i:void 0}return So=r,So}var Eo,dd;function Bu(){if(dd)return Eo;dd=1;var e=nt(),t=Sr(),r=e(t,"Map");return Eo=r,Eo}var jo,fd;function Rn(){if(fd)return jo;fd=1;var e=nt(),t=e(Object,"create");return jo=t,jo}var Ro,hd;function nw(){if(hd)return Ro;hd=1;var e=Rn();function t(){this.__data__=e?e(null):{},this.size=0}return Ro=t,Ro}var ko,pd;function ow(){if(pd)return ko;pd=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return ko=e,ko}var Po,gd;function iw(){if(gd)return Po;gd=1;var e=Rn(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function o(i){var a=this.__data__;if(e){var s=a[i];return s===t?void 0:s}return n.call(a,i)?a[i]:void 0}return Po=o,Po}var Ao,yd;function aw(){if(yd)return Ao;yd=1;var e=Rn(),t=Object.prototype,r=t.hasOwnProperty;function n(o){var i=this.__data__;return e?i[o]!==void 0:r.call(i,o)}return Ao=n,Ao}var To,bd;function sw(){if(bd)return To;bd=1;var e=Rn(),t="__lodash_hash_undefined__";function r(n,o){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=e&&o===void 0?t:o,this}return To=r,To}var Oo,md;function cw(){if(md)return Oo;md=1;var e=nw(),t=ow(),r=iw(),n=aw(),o=sw();function i(a){var s=-1,u=a==null?0:a.length;for(this.clear();++s<u;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Oo=i,Oo}var Io,vd;function uw(){if(vd)return Io;vd=1;var e=cw(),t=jn(),r=Bu();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return Io=n,Io}var Mo,xd;function lw(){if(xd)return Mo;xd=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return Mo=e,Mo}var qo,wd;function kn(){if(wd)return qo;wd=1;var e=lw();function t(r,n){var o=r.__data__;return e(n)?o[typeof n=="string"?"string":"hash"]:o.map}return qo=t,qo}var No,Cd;function dw(){if(Cd)return No;Cd=1;var e=kn();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return No=t,No}var $o,_d;function fw(){if(_d)return $o;_d=1;var e=kn();function t(r){return e(this,r).get(r)}return $o=t,$o}var Lo,Sd;function hw(){if(Sd)return Lo;Sd=1;var e=kn();function t(r){return e(this,r).has(r)}return Lo=t,Lo}var Fo,Ed;function pw(){if(Ed)return Fo;Ed=1;var e=kn();function t(r,n){var o=e(this,r),i=o.size;return o.set(r,n),this.size+=o.size==i?0:1,this}return Fo=t,Fo}var Bo,jd;function Du(){if(jd)return Bo;jd=1;var e=uw(),t=dw(),r=fw(),n=hw(),o=pw();function i(a){var s=-1,u=a==null?0:a.length;for(this.clear();++s<u;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Bo=i,Bo}var Do,Rd;function gw(){if(Rd)return Do;Rd=1;var e=jn(),t=Bu(),r=Du(),n=200;function o(i,a){var s=this.__data__;if(s instanceof e){var u=s.__data__;if(!t||u.length<n-1)return u.push([i,a]),this.size=++s.size,this;s=this.__data__=new r(u)}return s.set(i,a),this.size=s.size,this}return Do=o,Do}var zo,kd;function Pn(){if(kd)return zo;kd=1;var e=jn(),t=H0(),r=K0(),n=J0(),o=Z0(),i=gw();function a(s){var u=this.__data__=new e(s);this.size=u.size}return a.prototype.clear=t,a.prototype.delete=r,a.prototype.get=n,a.prototype.has=o,a.prototype.set=i,zo=a,zo}var Vo,Pd;function zu(){if(Pd)return Vo;Pd=1;function e(t,r){for(var n=-1,o=t==null?0:t.length;++n<o&&r(t[n],n,t)!==!1;);return t}return Vo=e,Vo}var Wo,Ad;function qb(){if(Ad)return Wo;Ad=1;var e=nt(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return Wo=t,Wo}var Go,Td;function An(){if(Td)return Go;Td=1;var e=qb();function t(r,n,o){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[n]=o}return Go=t,Go}var Uo,Od;function Tn(){if(Od)return Uo;Od=1;var e=An(),t=bt(),r=Object.prototype,n=r.hasOwnProperty;function o(i,a,s){var u=i[a];(!(n.call(i,a)&&t(u,s))||s===void 0&&!(a in i))&&e(i,a,s)}return Uo=o,Uo}var Ho,Id;function en(){if(Id)return Ho;Id=1;var e=Tn(),t=An();function r(n,o,i,a){var s=!i;i||(i={});for(var u=-1,c=o.length;++u<c;){var l=o[u],d=a?a(i[l],n[l],l,i,n):void 0;d===void 0&&(d=n[l]),s?t(i,l,d):e(i,l,d)}return i}return Ho=r,Ho}var Ko,Md;function yw(){if(Md)return Ko;Md=1;function e(t,r){for(var n=-1,o=Array(t);++n<t;)o[n]=r(n);return o}return Ko=e,Ko}var Jo,qd;function Pr(){if(qd)return Jo;qd=1;function e(t){return t!=null&&typeof t=="object"}return Jo=e,Jo}var Zo,Nd;function bw(){if(Nd)return Zo;Nd=1;var e=tt(),t=Pr(),r="[object Arguments]";function n(o){return t(o)&&e(o)==r}return Zo=n,Zo}var Yo,$d;function rn(){if($d)return Yo;$d=1;var e=bw(),t=Pr(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=e((function(){return arguments})())?e:function(a){return t(a)&&n.call(a,"callee")&&!o.call(a,"callee")};return Yo=i,Yo}var Xo,Ld;function Ye(){if(Ld)return Xo;Ld=1;var e=Array.isArray;return Xo=e,Xo}var Tt={exports:{}},Qo,Fd;function mw(){if(Fd)return Qo;Fd=1;function e(){return!1}return Qo=e,Qo}Tt.exports;var Bd;function vt(){return Bd||(Bd=1,(function(e,t){var r=Sr(),n=mw(),o=t&&!t.nodeType&&t,i=o&&!0&&e&&!e.nodeType&&e,a=i&&i.exports===o,s=a?r.Buffer:void 0,u=s?s.isBuffer:void 0,c=u||n;e.exports=c})(Tt,Tt.exports)),Tt.exports}var ei,Dd;function On(){if(Dd)return ei;Dd=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,o){var i=typeof n;return o=o??e,!!o&&(i=="number"||i!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<o}return ei=r,ei}var ri,zd;function Vu(){if(zd)return ri;zd=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return ri=t,ri}var ti,Vd;function vw(){if(Vd)return ti;Vd=1;var e=tt(),t=Vu(),r=Pr(),n="[object Arguments]",o="[object Array]",i="[object Boolean]",a="[object Date]",s="[object Error]",u="[object Function]",c="[object Map]",l="[object Number]",d="[object Object]",f="[object RegExp]",p="[object Set]",b="[object String]",g="[object WeakMap]",m="[object ArrayBuffer]",w="[object DataView]",y="[object Float32Array]",x="[object Float64Array]",v="[object Int8Array]",C="[object Int16Array]",_="[object Int32Array]",k="[object Uint8Array]",T="[object Uint8ClampedArray]",P="[object Uint16Array]",j="[object Uint32Array]",R={};R[y]=R[x]=R[v]=R[C]=R[_]=R[k]=R[T]=R[P]=R[j]=!0,R[n]=R[o]=R[m]=R[i]=R[w]=R[a]=R[s]=R[u]=R[c]=R[l]=R[d]=R[f]=R[p]=R[b]=R[g]=!1;function E(M){return r(M)&&t(M.length)&&!!R[e(M)]}return ti=E,ti}var ni,Wd;function In(){if(Wd)return ni;Wd=1;function e(t){return function(r){return t(r)}}return ni=e,ni}var Ot={exports:{}};Ot.exports;var Gd;function Wu(){return Gd||(Gd=1,(function(e,t){var r=Ib(),n=t&&!t.nodeType&&t,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,a=i&&r.process,s=(function(){try{var u=o&&o.require&&o.require("util").types;return u||a&&a.binding&&a.binding("util")}catch{}})();e.exports=s})(Ot,Ot.exports)),Ot.exports}var oi,Ud;function tn(){if(Ud)return oi;Ud=1;var e=vw(),t=In(),r=Wu(),n=r&&r.isTypedArray,o=n?t(n):e;return oi=o,oi}var ii,Hd;function Nb(){if(Hd)return ii;Hd=1;var e=yw(),t=rn(),r=Ye(),n=vt(),o=On(),i=tn(),a=Object.prototype,s=a.hasOwnProperty;function u(c,l){var d=r(c),f=!d&&t(c),p=!d&&!f&&n(c),b=!d&&!f&&!p&&i(c),g=d||f||p||b,m=g?e(c.length,String):[],w=m.length;for(var y in c)(l||s.call(c,y))&&!(g&&(y=="length"||p&&(y=="offset"||y=="parent")||b&&(y=="buffer"||y=="byteLength"||y=="byteOffset")||o(y,w)))&&m.push(y);return m}return ii=u,ii}var ai,Kd;function Mn(){if(Kd)return ai;Kd=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,o=typeof n=="function"&&n.prototype||e;return r===o}return ai=t,ai}var si,Jd;function $b(){if(Jd)return si;Jd=1;function e(t,r){return function(n){return t(r(n))}}return si=e,si}var ci,Zd;function xw(){if(Zd)return ci;Zd=1;var e=$b(),t=e(Object.keys,Object);return ci=t,ci}var ui,Yd;function Gu(){if(Yd)return ui;Yd=1;var e=Mn(),t=xw(),r=Object.prototype,n=r.hasOwnProperty;function o(i){if(!e(i))return t(i);var a=[];for(var s in Object(i))n.call(i,s)&&s!="constructor"&&a.push(s);return a}return ui=o,ui}var li,Xd;function Nr(){if(Xd)return li;Xd=1;var e=Qt(),t=Vu();function r(n){return n!=null&&t(n.length)&&!e(n)}return li=r,li}var di,Qd;function Hr(){if(Qd)return di;Qd=1;var e=Nb(),t=Gu(),r=Nr();function n(o){return r(o)?e(o):t(o)}return di=n,di}var fi,ef;function ww(){if(ef)return fi;ef=1;var e=en(),t=Hr();function r(n,o){return n&&e(o,t(o),n)}return fi=r,fi}var hi,rf;function Cw(){if(rf)return hi;rf=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return hi=e,hi}var pi,tf;function _w(){if(tf)return pi;tf=1;var e=vr(),t=Mn(),r=Cw(),n=Object.prototype,o=n.hasOwnProperty;function i(a){if(!e(a))return r(a);var s=t(a),u=[];for(var c in a)c=="constructor"&&(s||!o.call(a,c))||u.push(c);return u}return pi=i,pi}var gi,nf;function ot(){if(nf)return gi;nf=1;var e=Nb(),t=_w(),r=Nr();function n(o){return r(o)?e(o,!0):t(o)}return gi=n,gi}var yi,of;function Sw(){if(of)return yi;of=1;var e=en(),t=ot();function r(n,o){return n&&e(o,t(o),n)}return yi=r,yi}var It={exports:{}};It.exports;var af;function Lb(){return af||(af=1,(function(e,t){var r=Sr(),n=t&&!t.nodeType&&t,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,a=i?r.Buffer:void 0,s=a?a.allocUnsafe:void 0;function u(c,l){if(l)return c.slice();var d=c.length,f=s?s(d):new c.constructor(d);return c.copy(f),f}e.exports=u})(It,It.exports)),It.exports}var bi,sf;function Fb(){if(sf)return bi;sf=1;function e(t,r){var n=-1,o=t.length;for(r||(r=Array(o));++n<o;)r[n]=t[n];return r}return bi=e,bi}var mi,cf;function Bb(){if(cf)return mi;cf=1;function e(t,r){for(var n=-1,o=t==null?0:t.length,i=0,a=[];++n<o;){var s=t[n];r(s,n,t)&&(a[i++]=s)}return a}return mi=e,mi}var vi,uf;function Db(){if(uf)return vi;uf=1;function e(){return[]}return vi=e,vi}var xi,lf;function Uu(){if(lf)return xi;lf=1;var e=Bb(),t=Db(),r=Object.prototype,n=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,i=o?function(a){return a==null?[]:(a=Object(a),e(o(a),function(s){return n.call(a,s)}))}:t;return xi=i,xi}var wi,df;function Ew(){if(df)return wi;df=1;var e=en(),t=Uu();function r(n,o){return e(n,t(n),o)}return wi=r,wi}var Ci,ff;function Hu(){if(ff)return Ci;ff=1;function e(t,r){for(var n=-1,o=r.length,i=t.length;++n<o;)t[i+n]=r[n];return t}return Ci=e,Ci}var _i,hf;function qn(){if(hf)return _i;hf=1;var e=$b(),t=e(Object.getPrototypeOf,Object);return _i=t,_i}var Si,pf;function zb(){if(pf)return Si;pf=1;var e=Hu(),t=qn(),r=Uu(),n=Db(),o=Object.getOwnPropertySymbols,i=o?function(a){for(var s=[];a;)e(s,r(a)),a=t(a);return s}:n;return Si=i,Si}var Ei,gf;function jw(){if(gf)return Ei;gf=1;var e=en(),t=zb();function r(n,o){return e(n,t(n),o)}return Ei=r,Ei}var ji,yf;function Vb(){if(yf)return ji;yf=1;var e=Hu(),t=Ye();function r(n,o,i){var a=o(n);return t(n)?a:e(a,i(n))}return ji=r,ji}var Ri,bf;function Wb(){if(bf)return Ri;bf=1;var e=Vb(),t=Uu(),r=Hr();function n(o){return e(o,r,t)}return Ri=n,Ri}var ki,mf;function Rw(){if(mf)return ki;mf=1;var e=Vb(),t=zb(),r=ot();function n(o){return e(o,r,t)}return ki=n,ki}var Pi,vf;function kw(){if(vf)return Pi;vf=1;var e=nt(),t=Sr(),r=e(t,"DataView");return Pi=r,Pi}var Ai,xf;function Pw(){if(xf)return Ai;xf=1;var e=nt(),t=Sr(),r=e(t,"Promise");return Ai=r,Ai}var Ti,wf;function Gb(){if(wf)return Ti;wf=1;var e=nt(),t=Sr(),r=e(t,"Set");return Ti=r,Ti}var Oi,Cf;function Aw(){if(Cf)return Oi;Cf=1;var e=nt(),t=Sr(),r=e(t,"WeakMap");return Oi=r,Oi}var Ii,_f;function xt(){if(_f)return Ii;_f=1;var e=kw(),t=Bu(),r=Pw(),n=Gb(),o=Aw(),i=tt(),a=Mb(),s="[object Map]",u="[object Object]",c="[object Promise]",l="[object Set]",d="[object WeakMap]",f="[object DataView]",p=a(e),b=a(t),g=a(r),m=a(n),w=a(o),y=i;return(e&&y(new e(new ArrayBuffer(1)))!=f||t&&y(new t)!=s||r&&y(r.resolve())!=c||n&&y(new n)!=l||o&&y(new o)!=d)&&(y=function(x){var v=i(x),C=v==u?x.constructor:void 0,_=C?a(C):"";if(_)switch(_){case p:return f;case b:return s;case g:return c;case m:return l;case w:return d}return v}),Ii=y,Ii}var Mi,Sf;function Tw(){if(Sf)return Mi;Sf=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var o=n.length,i=new n.constructor(o);return o&&typeof n[0]=="string"&&t.call(n,"index")&&(i.index=n.index,i.input=n.input),i}return Mi=r,Mi}var qi,Ef;function Ub(){if(Ef)return qi;Ef=1;var e=Sr(),t=e.Uint8Array;return qi=t,qi}var Ni,jf;function Ku(){if(jf)return Ni;jf=1;var e=Ub();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return Ni=t,Ni}var $i,Rf;function Ow(){if(Rf)return $i;Rf=1;var e=Ku();function t(r,n){var o=n?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return $i=t,$i}var Li,kf;function Iw(){if(kf)return Li;kf=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return Li=t,Li}var Fi,Pf;function Mw(){if(Pf)return Fi;Pf=1;var e=mt(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(o){return r?Object(r.call(o)):{}}return Fi=n,Fi}var Bi,Af;function Hb(){if(Af)return Bi;Af=1;var e=Ku();function t(r,n){var o=n?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return Bi=t,Bi}var Di,Tf;function qw(){if(Tf)return Di;Tf=1;var e=Ku(),t=Ow(),r=Iw(),n=Mw(),o=Hb(),i="[object Boolean]",a="[object Date]",s="[object Map]",u="[object Number]",c="[object RegExp]",l="[object Set]",d="[object String]",f="[object Symbol]",p="[object ArrayBuffer]",b="[object DataView]",g="[object Float32Array]",m="[object Float64Array]",w="[object Int8Array]",y="[object Int16Array]",x="[object Int32Array]",v="[object Uint8Array]",C="[object Uint8ClampedArray]",_="[object Uint16Array]",k="[object Uint32Array]";function T(P,j,R){var E=P.constructor;switch(j){case p:return e(P);case i:case a:return new E(+P);case b:return t(P,R);case g:case m:case w:case y:case x:case v:case C:case _:case k:return o(P,R);case s:return new E;case u:case d:return new E(P);case c:return r(P);case l:return new E;case f:return n(P)}}return Di=T,Di}var zi,Of;function Kb(){if(Of)return zi;Of=1;var e=vr(),t=Object.create,r=(function(){function n(){}return function(o){if(!e(o))return{};if(t)return t(o);n.prototype=o;var i=new n;return n.prototype=void 0,i}})();return zi=r,zi}var Vi,If;function Jb(){if(If)return Vi;If=1;var e=Kb(),t=qn(),r=Mn();function n(o){return typeof o.constructor=="function"&&!r(o)?e(t(o)):{}}return Vi=n,Vi}var Wi,Mf;function Nw(){if(Mf)return Wi;Mf=1;var e=xt(),t=Pr(),r="[object Map]";function n(o){return t(o)&&e(o)==r}return Wi=n,Wi}var Gi,qf;function $w(){if(qf)return Gi;qf=1;var e=Nw(),t=In(),r=Wu(),n=r&&r.isMap,o=n?t(n):e;return Gi=o,Gi}var Ui,Nf;function Lw(){if(Nf)return Ui;Nf=1;var e=xt(),t=Pr(),r="[object Set]";function n(o){return t(o)&&e(o)==r}return Ui=n,Ui}var Hi,$f;function Fw(){if($f)return Hi;$f=1;var e=Lw(),t=In(),r=Wu(),n=r&&r.isSet,o=n?t(n):e;return Hi=o,Hi}var Ki,Lf;function Zb(){if(Lf)return Ki;Lf=1;var e=Pn(),t=zu(),r=Tn(),n=ww(),o=Sw(),i=Lb(),a=Fb(),s=Ew(),u=jw(),c=Wb(),l=Rw(),d=xt(),f=Tw(),p=qw(),b=Jb(),g=Ye(),m=vt(),w=$w(),y=vr(),x=Fw(),v=Hr(),C=ot(),_=1,k=2,T=4,P="[object Arguments]",j="[object Array]",R="[object Boolean]",E="[object Date]",M="[object Error]",I="[object Function]",N="[object GeneratorFunction]",O="[object Map]",W="[object Number]",z="[object Object]",re="[object RegExp]",te="[object Set]",he="[object String]",be="[object Symbol]",K="[object WeakMap]",q="[object ArrayBuffer]",L="[object DataView]",G="[object Float32Array]",B="[object Float64Array]",Y="[object Int8Array]",ce="[object Int16Array]",X="[object Int32Array]",U="[object Uint8Array]",Z="[object Uint8ClampedArray]",ae="[object Uint16Array]",ue="[object Uint32Array]",de={};de[P]=de[j]=de[q]=de[L]=de[R]=de[E]=de[G]=de[B]=de[Y]=de[ce]=de[X]=de[O]=de[W]=de[z]=de[re]=de[te]=de[he]=de[be]=de[U]=de[Z]=de[ae]=de[ue]=!0,de[M]=de[I]=de[K]=!1;function Ee(ge,He,Le,Xe,ur,Ge){var Ne,xe=He&_,Ie=He&k,$e=He&T;if(Le&&(Ne=ur?Le(ge,Xe,ur,Ge):Le(ge)),Ne!==void 0)return Ne;if(!y(ge))return ge;var tr=g(ge);if(tr){if(Ne=f(ge),!xe)return a(ge,Ne)}else{var Je=d(ge),Ze=Je==I||Je==N;if(m(ge))return i(ge,xe);if(Je==z||Je==P||Ze&&!ur){if(Ne=Ie||Ze?{}:b(ge),!xe)return Ie?u(ge,o(Ne,ge)):s(ge,n(Ne,ge))}else{if(!de[Je])return ur?ge:{};Ne=p(ge,Je,xe)}}Ge||(Ge=new e);var fr=Ge.get(ge);if(fr)return fr;Ge.set(ge,Ne),x(ge)?ge.forEach(function(ir){Ne.add(Ee(ir,He,Le,ir,ge,Ge))}):w(ge)&&ge.forEach(function(ir,ar){Ne.set(ar,Ee(ir,He,Le,ar,ge,Ge))});var wr=$e?Ie?l:c:Ie?C:v,Ce=tr?void 0:wr(ge);return t(Ce||ge,function(ir,ar){Ce&&(ar=ir,ir=ge[ar]),r(Ne,ar,Ee(ir,He,Le,ar,ge,Ge))}),Ne}return Ki=Ee,Ki}var Ji,Ff;function Bw(){if(Ff)return Ji;Ff=1;var e=Zb(),t=4;function r(n){return e(n,t)}return Ji=r,Ji}var Zi,Bf;function Ju(){if(Bf)return Zi;Bf=1;function e(t){return function(){return t}}return Zi=e,Zi}var Yi,Df;function Dw(){if(Df)return Yi;Df=1;function e(t){return function(r,n,o){for(var i=-1,a=Object(r),s=o(r),u=s.length;u--;){var c=s[t?u:++i];if(n(a[c],c,a)===!1)break}return r}}return Yi=e,Yi}var Xi,zf;function Zu(){if(zf)return Xi;zf=1;var e=Dw(),t=e();return Xi=t,Xi}var Qi,Vf;function Yu(){if(Vf)return Qi;Vf=1;var e=Zu(),t=Hr();function r(n,o){return n&&e(n,o,t)}return Qi=r,Qi}var ea,Wf;function zw(){if(Wf)return ea;Wf=1;var e=Nr();function t(r,n){return function(o,i){if(o==null)return o;if(!e(o))return r(o,i);for(var a=o.length,s=n?a:-1,u=Object(o);(n?s--:++s<a)&&i(u[s],s,u)!==!1;);return o}}return ea=t,ea}var ra,Gf;function Nn(){if(Gf)return ra;Gf=1;var e=Yu(),t=zw(),r=t(e);return ra=r,ra}var ta,Uf;function it(){if(Uf)return ta;Uf=1;function e(t){return t}return ta=e,ta}var na,Hf;function Yb(){if(Hf)return na;Hf=1;var e=it();function t(r){return typeof r=="function"?r:e}return na=t,na}var oa,Kf;function Xb(){if(Kf)return oa;Kf=1;var e=zu(),t=Nn(),r=Yb(),n=Ye();function o(i,a){var s=n(i)?e:t;return s(i,r(a))}return oa=o,oa}var ia,Jf;function Qb(){return Jf||(Jf=1,ia=Xb()),ia}var aa,Zf;function Vw(){if(Zf)return aa;Zf=1;var e=Nn();function t(r,n){var o=[];return e(r,function(i,a,s){n(i,a,s)&&o.push(i)}),o}return aa=t,aa}var sa,Yf;function Ww(){if(Yf)return sa;Yf=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return sa=t,sa}var ca,Xf;function Gw(){if(Xf)return ca;Xf=1;function e(t){return this.__data__.has(t)}return ca=e,ca}var ua,Qf;function em(){if(Qf)return ua;Qf=1;var e=Du(),t=Ww(),r=Gw();function n(o){var i=-1,a=o==null?0:o.length;for(this.__data__=new e;++i<a;)this.add(o[i])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,ua=n,ua}var la,eh;function Uw(){if(eh)return la;eh=1;function e(t,r){for(var n=-1,o=t==null?0:t.length;++n<o;)if(r(t[n],n,t))return!0;return!1}return la=e,la}var da,rh;function rm(){if(rh)return da;rh=1;function e(t,r){return t.has(r)}return da=e,da}var fa,th;function tm(){if(th)return fa;th=1;var e=em(),t=Uw(),r=rm(),n=1,o=2;function i(a,s,u,c,l,d){var f=u&n,p=a.length,b=s.length;if(p!=b&&!(f&&b>p))return!1;var g=d.get(a),m=d.get(s);if(g&&m)return g==s&&m==a;var w=-1,y=!0,x=u&o?new e:void 0;for(d.set(a,s),d.set(s,a);++w<p;){var v=a[w],C=s[w];if(c)var _=f?c(C,v,w,s,a,d):c(v,C,w,a,s,d);if(_!==void 0){if(_)continue;y=!1;break}if(x){if(!t(s,function(k,T){if(!r(x,T)&&(v===k||l(v,k,u,c,d)))return x.push(T)})){y=!1;break}}else if(!(v===C||l(v,C,u,c,d))){y=!1;break}}return d.delete(a),d.delete(s),y}return fa=i,fa}var ha,nh;function Hw(){if(nh)return ha;nh=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(o,i){n[++r]=[i,o]}),n}return ha=e,ha}var pa,oh;function Xu(){if(oh)return pa;oh=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(o){n[++r]=o}),n}return pa=e,pa}var ga,ih;function Kw(){if(ih)return ga;ih=1;var e=mt(),t=Ub(),r=bt(),n=tm(),o=Hw(),i=Xu(),a=1,s=2,u="[object Boolean]",c="[object Date]",l="[object Error]",d="[object Map]",f="[object Number]",p="[object RegExp]",b="[object Set]",g="[object String]",m="[object Symbol]",w="[object ArrayBuffer]",y="[object DataView]",x=e?e.prototype:void 0,v=x?x.valueOf:void 0;function C(_,k,T,P,j,R,E){switch(T){case y:if(_.byteLength!=k.byteLength||_.byteOffset!=k.byteOffset)return!1;_=_.buffer,k=k.buffer;case w:return!(_.byteLength!=k.byteLength||!R(new t(_),new t(k)));case u:case c:case f:return r(+_,+k);case l:return _.name==k.name&&_.message==k.message;case p:case g:return _==k+"";case d:var M=o;case b:var I=P&a;if(M||(M=i),_.size!=k.size&&!I)return!1;var N=E.get(_);if(N)return N==k;P|=s,E.set(_,k);var O=n(M(_),M(k),P,j,R,E);return E.delete(_),O;case m:if(v)return v.call(_)==v.call(k)}return!1}return ga=C,ga}var ya,ah;function Jw(){if(ah)return ya;ah=1;var e=Wb(),t=1,r=Object.prototype,n=r.hasOwnProperty;function o(i,a,s,u,c,l){var d=s&t,f=e(i),p=f.length,b=e(a),g=b.length;if(p!=g&&!d)return!1;for(var m=p;m--;){var w=f[m];if(!(d?w in a:n.call(a,w)))return!1}var y=l.get(i),x=l.get(a);if(y&&x)return y==a&&x==i;var v=!0;l.set(i,a),l.set(a,i);for(var C=d;++m<p;){w=f[m];var _=i[w],k=a[w];if(u)var T=d?u(k,_,w,a,i,l):u(_,k,w,i,a,l);if(!(T===void 0?_===k||c(_,k,s,u,l):T)){v=!1;break}C||(C=w=="constructor")}if(v&&!C){var P=i.constructor,j=a.constructor;P!=j&&"constructor"in i&&"constructor"in a&&!(typeof P=="function"&&P instanceof P&&typeof j=="function"&&j instanceof j)&&(v=!1)}return l.delete(i),l.delete(a),v}return ya=o,ya}var ba,sh;function Zw(){if(sh)return ba;sh=1;var e=Pn(),t=tm(),r=Kw(),n=Jw(),o=xt(),i=Ye(),a=vt(),s=tn(),u=1,c="[object Arguments]",l="[object Array]",d="[object Object]",f=Object.prototype,p=f.hasOwnProperty;function b(g,m,w,y,x,v){var C=i(g),_=i(m),k=C?l:o(g),T=_?l:o(m);k=k==c?d:k,T=T==c?d:T;var P=k==d,j=T==d,R=k==T;if(R&&a(g)){if(!a(m))return!1;C=!0,P=!1}if(R&&!P)return v||(v=new e),C||s(g)?t(g,m,w,y,x,v):r(g,m,k,w,y,x,v);if(!(w&u)){var E=P&&p.call(g,"__wrapped__"),M=j&&p.call(m,"__wrapped__");if(E||M){var I=E?g.value():g,N=M?m.value():m;return v||(v=new e),x(I,N,w,y,v)}}return R?(v||(v=new e),n(g,m,w,y,x,v)):!1}return ba=b,ba}var ma,ch;function nm(){if(ch)return ma;ch=1;var e=Zw(),t=Pr();function r(n,o,i,a,s){return n===o?!0:n==null||o==null||!t(n)&&!t(o)?n!==n&&o!==o:e(n,o,i,a,r,s)}return ma=r,ma}var va,uh;function Yw(){if(uh)return va;uh=1;var e=Pn(),t=nm(),r=1,n=2;function o(i,a,s,u){var c=s.length,l=c,d=!u;if(i==null)return!l;for(i=Object(i);c--;){var f=s[c];if(d&&f[2]?f[1]!==i[f[0]]:!(f[0]in i))return!1}for(;++c<l;){f=s[c];var p=f[0],b=i[p],g=f[1];if(d&&f[2]){if(b===void 0&&!(p in i))return!1}else{var m=new e;if(u)var w=u(b,g,p,i,a,m);if(!(w===void 0?t(g,b,r|n,u,m):w))return!1}}return!0}return va=o,va}var xa,lh;function om(){if(lh)return xa;lh=1;var e=vr();function t(r){return r===r&&!e(r)}return xa=t,xa}var wa,dh;function Xw(){if(dh)return wa;dh=1;var e=om(),t=Hr();function r(n){for(var o=t(n),i=o.length;i--;){var a=o[i],s=n[a];o[i]=[a,s,e(s)]}return o}return wa=r,wa}var Ca,fh;function im(){if(fh)return Ca;fh=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return Ca=e,Ca}var _a,hh;function Qw(){if(hh)return _a;hh=1;var e=Yw(),t=Xw(),r=im();function n(o){var i=t(o);return i.length==1&&i[0][2]?r(i[0][0],i[0][1]):function(a){return a===o||e(a,o,i)}}return _a=n,_a}var Sa,ph;function wt(){if(ph)return Sa;ph=1;var e=tt(),t=Pr(),r="[object Symbol]";function n(o){return typeof o=="symbol"||t(o)&&e(o)==r}return Sa=n,Sa}var Ea,gh;function Qu(){if(gh)return Ea;gh=1;var e=Ye(),t=wt(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function o(i,a){if(e(i))return!1;var s=typeof i;return s=="number"||s=="symbol"||s=="boolean"||i==null||t(i)?!0:n.test(i)||!r.test(i)||a!=null&&i in Object(a)}return Ea=o,Ea}var ja,yh;function e1(){if(yh)return ja;yh=1;var e=Du(),t="Expected a function";function r(n,o){if(typeof n!="function"||o!=null&&typeof o!="function")throw new TypeError(t);var i=function(){var a=arguments,s=o?o.apply(this,a):a[0],u=i.cache;if(u.has(s))return u.get(s);var c=n.apply(this,a);return i.cache=u.set(s,c)||u,c};return i.cache=new(r.Cache||e),i}return r.Cache=e,ja=r,ja}var Ra,bh;function r1(){if(bh)return Ra;bh=1;var e=e1(),t=500;function r(n){var o=e(n,function(a){return i.size===t&&i.clear(),a}),i=o.cache;return o}return Ra=r,Ra}var ka,mh;function t1(){if(mh)return ka;mh=1;var e=r1(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(o){var i=[];return o.charCodeAt(0)===46&&i.push(""),o.replace(t,function(a,s,u,c){i.push(u?c.replace(r,"$1"):s||a)}),i});return ka=n,ka}var Pa,vh;function $n(){if(vh)return Pa;vh=1;function e(t,r){for(var n=-1,o=t==null?0:t.length,i=Array(o);++n<o;)i[n]=r(t[n],n,t);return i}return Pa=e,Pa}var Aa,xh;function n1(){if(xh)return Aa;xh=1;var e=mt(),t=$n(),r=Ye(),n=wt(),o=e?e.prototype:void 0,i=o?o.toString:void 0;function a(s){if(typeof s=="string")return s;if(r(s))return t(s,a)+"";if(n(s))return i?i.call(s):"";var u=s+"";return u=="0"&&1/s==-1/0?"-0":u}return Aa=a,Aa}var Ta,wh;function am(){if(wh)return Ta;wh=1;var e=n1();function t(r){return r==null?"":e(r)}return Ta=t,Ta}var Oa,Ch;function Ln(){if(Ch)return Oa;Ch=1;var e=Ye(),t=Qu(),r=t1(),n=am();function o(i,a){return e(i)?i:t(i,a)?[i]:r(n(i))}return Oa=o,Oa}var Ia,_h;function nn(){if(_h)return Ia;_h=1;var e=wt();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return Ia=t,Ia}var Ma,Sh;function Fn(){if(Sh)return Ma;Sh=1;var e=Ln(),t=nn();function r(n,o){o=e(o,n);for(var i=0,a=o.length;n!=null&&i<a;)n=n[t(o[i++])];return i&&i==a?n:void 0}return Ma=r,Ma}var qa,Eh;function o1(){if(Eh)return qa;Eh=1;var e=Fn();function t(r,n,o){var i=r==null?void 0:e(r,n);return i===void 0?o:i}return qa=t,qa}var Na,jh;function i1(){if(jh)return Na;jh=1;function e(t,r){return t!=null&&r in Object(t)}return Na=e,Na}var $a,Rh;function sm(){if(Rh)return $a;Rh=1;var e=Ln(),t=rn(),r=Ye(),n=On(),o=Vu(),i=nn();function a(s,u,c){u=e(u,s);for(var l=-1,d=u.length,f=!1;++l<d;){var p=i(u[l]);if(!(f=s!=null&&c(s,p)))break;s=s[p]}return f||++l!=d?f:(d=s==null?0:s.length,!!d&&o(d)&&n(p,d)&&(r(s)||t(s)))}return $a=a,$a}var La,kh;function cm(){if(kh)return La;kh=1;var e=i1(),t=sm();function r(n,o){return n!=null&&t(n,o,e)}return La=r,La}var Fa,Ph;function a1(){if(Ph)return Fa;Ph=1;var e=nm(),t=o1(),r=cm(),n=Qu(),o=om(),i=im(),a=nn(),s=1,u=2;function c(l,d){return n(l)&&o(d)?i(a(l),d):function(f){var p=t(f,l);return p===void 0&&p===d?r(f,l):e(d,p,s|u)}}return Fa=c,Fa}var Ba,Ah;function um(){if(Ah)return Ba;Ah=1;function e(t){return function(r){return r==null?void 0:r[t]}}return Ba=e,Ba}var Da,Th;function s1(){if(Th)return Da;Th=1;var e=Fn();function t(r){return function(n){return e(n,r)}}return Da=t,Da}var za,Oh;function c1(){if(Oh)return za;Oh=1;var e=um(),t=s1(),r=Qu(),n=nn();function o(i){return r(i)?e(n(i)):t(i)}return za=o,za}var Va,Ih;function $r(){if(Ih)return Va;Ih=1;var e=Qw(),t=a1(),r=it(),n=Ye(),o=c1();function i(a){return typeof a=="function"?a:a==null?r:typeof a=="object"?n(a)?t(a[0],a[1]):e(a):o(a)}return Va=i,Va}var Wa,Mh;function lm(){if(Mh)return Wa;Mh=1;var e=Bb(),t=Vw(),r=$r(),n=Ye();function o(i,a){var s=n(i)?e:t;return s(i,r(a,3))}return Wa=o,Wa}var Ga,qh;function u1(){if(qh)return Ga;qh=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,o){return n!=null&&t.call(n,o)}return Ga=r,Ga}var Ua,Nh;function dm(){if(Nh)return Ua;Nh=1;var e=u1(),t=sm();function r(n,o){return n!=null&&t(n,o,e)}return Ua=r,Ua}var Ha,$h;function l1(){if($h)return Ha;$h=1;var e=Gu(),t=xt(),r=rn(),n=Ye(),o=Nr(),i=vt(),a=Mn(),s=tn(),u="[object Map]",c="[object Set]",l=Object.prototype,d=l.hasOwnProperty;function f(p){if(p==null)return!0;if(o(p)&&(n(p)||typeof p=="string"||typeof p.splice=="function"||i(p)||s(p)||r(p)))return!p.length;var b=t(p);if(b==u||b==c)return!p.size;if(a(p))return!e(p).length;for(var g in p)if(d.call(p,g))return!1;return!0}return Ha=f,Ha}var Ka,Lh;function fm(){if(Lh)return Ka;Lh=1;function e(t){return t===void 0}return Ka=e,Ka}var Ja,Fh;function hm(){if(Fh)return Ja;Fh=1;var e=Nn(),t=Nr();function r(n,o){var i=-1,a=t(n)?Array(n.length):[];return e(n,function(s,u,c){a[++i]=o(s,u,c)}),a}return Ja=r,Ja}var Za,Bh;function pm(){if(Bh)return Za;Bh=1;var e=$n(),t=$r(),r=hm(),n=Ye();function o(i,a){var s=n(i)?e:r;return s(i,t(a,3))}return Za=o,Za}var Ya,Dh;function d1(){if(Dh)return Ya;Dh=1;function e(t,r,n,o){var i=-1,a=t==null?0:t.length;for(o&&a&&(n=t[++i]);++i<a;)n=r(n,t[i],i,t);return n}return Ya=e,Ya}var Xa,zh;function f1(){if(zh)return Xa;zh=1;function e(t,r,n,o,i){return i(t,function(a,s,u){n=o?(o=!1,a):r(n,a,s,u)}),n}return Xa=e,Xa}var Qa,Vh;function gm(){if(Vh)return Qa;Vh=1;var e=d1(),t=Nn(),r=$r(),n=f1(),o=Ye();function i(a,s,u){var c=o(a)?e:n,l=arguments.length<3;return c(a,r(s,4),u,l,t)}return Qa=i,Qa}var es,Wh;function h1(){if(Wh)return es;Wh=1;var e=tt(),t=Ye(),r=Pr(),n="[object String]";function o(i){return typeof i=="string"||!t(i)&&r(i)&&e(i)==n}return es=o,es}var rs,Gh;function p1(){if(Gh)return rs;Gh=1;var e=um(),t=e("length");return rs=t,rs}var ts,Uh;function g1(){if(Uh)return ts;Uh=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=t+r+n,i="\\ufe0e\\ufe0f",a="\\u200d",s=RegExp("["+a+e+o+i+"]");function u(c){return s.test(c)}return ts=u,ts}var ns,Hh;function y1(){if(Hh)return ns;Hh=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=t+r+n,i="\\ufe0e\\ufe0f",a="["+e+"]",s="["+o+"]",u="\\ud83c[\\udffb-\\udfff]",c="(?:"+s+"|"+u+")",l="[^"+e+"]",d="(?:\\ud83c[\\udde6-\\uddff]){2}",f="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",b=c+"?",g="["+i+"]?",m="(?:"+p+"(?:"+[l,d,f].join("|")+")"+g+b+")*",w=g+b+m,y="(?:"+[l+s+"?",s,d,f,a].join("|")+")",x=RegExp(u+"(?="+u+")|"+y+w,"g");function v(C){for(var _=x.lastIndex=0;x.test(C);)++_;return _}return ns=v,ns}var os,Kh;function b1(){if(Kh)return os;Kh=1;var e=p1(),t=g1(),r=y1();function n(o){return t(o)?r(o):e(o)}return os=n,os}var is,Jh;function m1(){if(Jh)return is;Jh=1;var e=Gu(),t=xt(),r=Nr(),n=h1(),o=b1(),i="[object Map]",a="[object Set]";function s(u){if(u==null)return 0;if(r(u))return n(u)?o(u):u.length;var c=t(u);return c==i||c==a?u.size:e(u).length}return is=s,is}var as,Zh;function v1(){if(Zh)return as;Zh=1;var e=zu(),t=Kb(),r=Yu(),n=$r(),o=qn(),i=Ye(),a=vt(),s=Qt(),u=vr(),c=tn();function l(d,f,p){var b=i(d),g=b||a(d)||c(d);if(f=n(f,4),p==null){var m=d&&d.constructor;g?p=b?new m:[]:u(d)?p=s(m)?t(o(d)):{}:p={}}return(g?e:r)(d,function(w,y,x){return f(p,w,y,x)}),p}return as=l,as}var ss,Yh;function x1(){if(Yh)return ss;Yh=1;var e=mt(),t=rn(),r=Ye(),n=e?e.isConcatSpreadable:void 0;function o(i){return r(i)||t(i)||!!(n&&i&&i[n])}return ss=o,ss}var cs,Xh;function el(){if(Xh)return cs;Xh=1;var e=Hu(),t=x1();function r(n,o,i,a,s){var u=-1,c=n.length;for(i||(i=t),s||(s=[]);++u<c;){var l=n[u];o>0&&i(l)?o>1?r(l,o-1,i,a,s):e(s,l):a||(s[s.length]=l)}return s}return cs=r,cs}var us,Qh;function w1(){if(Qh)return us;Qh=1;function e(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}return us=e,us}var ls,ep;function ym(){if(ep)return ls;ep=1;var e=w1(),t=Math.max;function r(n,o,i){return o=t(o===void 0?n.length-1:o,0),function(){for(var a=arguments,s=-1,u=t(a.length-o,0),c=Array(u);++s<u;)c[s]=a[o+s];s=-1;for(var l=Array(o+1);++s<o;)l[s]=a[s];return l[o]=i(c),e(n,this,l)}}return ls=r,ls}var ds,rp;function C1(){if(rp)return ds;rp=1;var e=Ju(),t=qb(),r=it(),n=t?function(o,i){return t(o,"toString",{configurable:!0,enumerable:!1,value:e(i),writable:!0})}:r;return ds=n,ds}var fs,tp;function _1(){if(tp)return fs;tp=1;var e=800,t=16,r=Date.now;function n(o){var i=0,a=0;return function(){var s=r(),u=t-(s-a);if(a=s,u>0){if(++i>=e)return arguments[0]}else i=0;return o.apply(void 0,arguments)}}return fs=n,fs}var hs,np;function bm(){if(np)return hs;np=1;var e=C1(),t=_1(),r=t(e);return hs=r,hs}var ps,op;function Bn(){if(op)return ps;op=1;var e=it(),t=ym(),r=bm();function n(o,i){return r(t(o,i,e),o+"")}return ps=n,ps}var gs,ip;function mm(){if(ip)return gs;ip=1;function e(t,r,n,o){for(var i=t.length,a=n+(o?1:-1);o?a--:++a<i;)if(r(t[a],a,t))return a;return-1}return gs=e,gs}var ys,ap;function S1(){if(ap)return ys;ap=1;function e(t){return t!==t}return ys=e,ys}var bs,sp;function E1(){if(sp)return bs;sp=1;function e(t,r,n){for(var o=n-1,i=t.length;++o<i;)if(t[o]===r)return o;return-1}return bs=e,bs}var ms,cp;function j1(){if(cp)return ms;cp=1;var e=mm(),t=S1(),r=E1();function n(o,i,a){return i===i?r(o,i,a):e(o,t,a)}return ms=n,ms}var vs,up;function R1(){if(up)return vs;up=1;var e=j1();function t(r,n){var o=r==null?0:r.length;return!!o&&e(r,n,0)>-1}return vs=t,vs}var xs,lp;function k1(){if(lp)return xs;lp=1;function e(t,r,n){for(var o=-1,i=t==null?0:t.length;++o<i;)if(n(r,t[o]))return!0;return!1}return xs=e,xs}var ws,dp;function P1(){if(dp)return ws;dp=1;function e(){}return ws=e,ws}var Cs,fp;function A1(){if(fp)return Cs;fp=1;var e=Gb(),t=P1(),r=Xu(),n=1/0,o=e&&1/r(new e([,-0]))[1]==n?function(i){return new e(i)}:t;return Cs=o,Cs}var _s,hp;function T1(){if(hp)return _s;hp=1;var e=em(),t=R1(),r=k1(),n=rm(),o=A1(),i=Xu(),a=200;function s(u,c,l){var d=-1,f=t,p=u.length,b=!0,g=[],m=g;if(l)b=!1,f=r;else if(p>=a){var w=c?null:o(u);if(w)return i(w);b=!1,f=n,m=new e}else m=c?[]:g;e:for(;++d<p;){var y=u[d],x=c?c(y):y;if(y=l||y!==0?y:0,b&&x===x){for(var v=m.length;v--;)if(m[v]===x)continue e;c&&m.push(x),g.push(y)}else f(m,x,l)||(m!==g&&m.push(x),g.push(y))}return g}return _s=s,_s}var Ss,pp;function vm(){if(pp)return Ss;pp=1;var e=Nr(),t=Pr();function r(n){return t(n)&&e(n)}return Ss=r,Ss}var Es,gp;function O1(){if(gp)return Es;gp=1;var e=el(),t=Bn(),r=T1(),n=vm(),o=t(function(i){return r(e(i,1,n,!0))});return Es=o,Es}var js,yp;function I1(){if(yp)return js;yp=1;var e=$n();function t(r,n){return e(n,function(o){return r[o]})}return js=t,js}var Rs,bp;function xm(){if(bp)return Rs;bp=1;var e=I1(),t=Hr();function r(n){return n==null?[]:e(n,t(n))}return Rs=r,Rs}var ks,mp;function xr(){if(mp)return ks;mp=1;var e;if(typeof Fu=="function")try{e={clone:Bw(),constant:Ju(),each:Qb(),filter:lm(),has:dm(),isArray:Ye(),isEmpty:l1(),isFunction:Qt(),isUndefined:fm(),keys:Hr(),map:pm(),reduce:gm(),size:m1(),transform:v1(),union:O1(),values:xm()}}catch{}return e||(e=window._),ks=e,ks}var Ps,vp;function rl(){if(vp)return Ps;vp=1;var e=xr();Ps=o;var t="\0",r="\0",n="";function o(l){this._isDirected=e.has(l,"directed")?l.directed:!0,this._isMultigraph=e.has(l,"multigraph")?l.multigraph:!1,this._isCompound=e.has(l,"compound")?l.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(l){return this._label=l,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultNodeLabelFn=l,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._in[d])})},o.prototype.sinks=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._out[d])})},o.prototype.setNodes=function(l,d){var f=arguments,p=this;return e.each(l,function(b){f.length>1?p.setNode(b,d):p.setNode(b)}),this},o.prototype.setNode=function(l,d){return e.has(this._nodes,l)?(arguments.length>1&&(this._nodes[l]=d),this):(this._nodes[l]=arguments.length>1?d:this._defaultNodeLabelFn(l),this._isCompound&&(this._parent[l]=r,this._children[l]={},this._children[r][l]=!0),this._in[l]={},this._preds[l]={},this._out[l]={},this._sucs[l]={},++this._nodeCount,this)},o.prototype.node=function(l){return this._nodes[l]},o.prototype.hasNode=function(l){return e.has(this._nodes,l)},o.prototype.removeNode=function(l){var d=this;if(e.has(this._nodes,l)){var f=function(p){d.removeEdge(d._edgeObjs[p])};delete this._nodes[l],this._isCompound&&(this._removeFromParentsChildList(l),delete this._parent[l],e.each(this.children(l),function(p){d.setParent(p)}),delete this._children[l]),e.each(e.keys(this._in[l]),f),delete this._in[l],delete this._preds[l],e.each(e.keys(this._out[l]),f),delete this._out[l],delete this._sucs[l],--this._nodeCount}return this},o.prototype.setParent=function(l,d){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(d))d=r;else{d+="";for(var f=d;!e.isUndefined(f);f=this.parent(f))if(f===l)throw new Error("Setting "+d+" as parent of "+l+" would create a cycle");this.setNode(d)}return this.setNode(l),this._removeFromParentsChildList(l),this._parent[l]=d,this._children[d][l]=!0,this},o.prototype._removeFromParentsChildList=function(l){delete this._children[this._parent[l]][l]},o.prototype.parent=function(l){if(this._isCompound){var d=this._parent[l];if(d!==r)return d}},o.prototype.children=function(l){if(e.isUndefined(l)&&(l=r),this._isCompound){var d=this._children[l];if(d)return e.keys(d)}else{if(l===r)return this.nodes();if(this.hasNode(l))return[]}},o.prototype.predecessors=function(l){var d=this._preds[l];if(d)return e.keys(d)},o.prototype.successors=function(l){var d=this._sucs[l];if(d)return e.keys(d)},o.prototype.neighbors=function(l){var d=this.predecessors(l);if(d)return e.union(d,this.successors(l))},o.prototype.isLeaf=function(l){var d;return this.isDirected()?d=this.successors(l):d=this.neighbors(l),d.length===0},o.prototype.filterNodes=function(l){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var f=this;e.each(this._nodes,function(g,m){l(m)&&d.setNode(m,g)}),e.each(this._edgeObjs,function(g){d.hasNode(g.v)&&d.hasNode(g.w)&&d.setEdge(g,f.edge(g))});var p={};function b(g){var m=f.parent(g);return m===void 0||d.hasNode(m)?(p[g]=m,m):m in p?p[m]:b(m)}return this._isCompound&&e.each(d.nodes(),function(g){d.setParent(g,b(g))}),d},o.prototype.setDefaultEdgeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultEdgeLabelFn=l,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(l,d){var f=this,p=arguments;return e.reduce(l,function(b,g){return p.length>1?f.setEdge(b,g,d):f.setEdge(b,g),g}),this},o.prototype.setEdge=function(){var l,d,f,p,b=!1,g=arguments[0];typeof g=="object"&&g!==null&&"v"in g?(l=g.v,d=g.w,f=g.name,arguments.length===2&&(p=arguments[1],b=!0)):(l=g,d=arguments[1],f=arguments[3],arguments.length>2&&(p=arguments[2],b=!0)),l=""+l,d=""+d,e.isUndefined(f)||(f=""+f);var m=s(this._isDirected,l,d,f);if(e.has(this._edgeLabels,m))return b&&(this._edgeLabels[m]=p),this;if(!e.isUndefined(f)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(l),this.setNode(d),this._edgeLabels[m]=b?p:this._defaultEdgeLabelFn(l,d,f);var w=u(this._isDirected,l,d,f);return l=w.v,d=w.w,Object.freeze(w),this._edgeObjs[m]=w,i(this._preds[d],l),i(this._sucs[l],d),this._in[d][m]=w,this._out[l][m]=w,this._edgeCount++,this},o.prototype.edge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):s(this._isDirected,l,d,f);return this._edgeLabels[p]},o.prototype.hasEdge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):s(this._isDirected,l,d,f);return e.has(this._edgeLabels,p)},o.prototype.removeEdge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):s(this._isDirected,l,d,f),b=this._edgeObjs[p];return b&&(l=b.v,d=b.w,delete this._edgeLabels[p],delete this._edgeObjs[p],a(this._preds[d],l),a(this._sucs[l],d),delete this._in[d][p],delete this._out[l][p],this._edgeCount--),this},o.prototype.inEdges=function(l,d){var f=this._in[l];if(f){var p=e.values(f);return d?e.filter(p,function(b){return b.v===d}):p}},o.prototype.outEdges=function(l,d){var f=this._out[l];if(f){var p=e.values(f);return d?e.filter(p,function(b){return b.w===d}):p}},o.prototype.nodeEdges=function(l,d){var f=this.inEdges(l,d);if(f)return f.concat(this.outEdges(l,d))};function i(l,d){l[d]?l[d]++:l[d]=1}function a(l,d){--l[d]||delete l[d]}function s(l,d,f,p){var b=""+d,g=""+f;if(!l&&b>g){var m=b;b=g,g=m}return b+n+g+n+(e.isUndefined(p)?t:p)}function u(l,d,f,p){var b=""+d,g=""+f;if(!l&&b>g){var m=b;b=g,g=m}var w={v:b,w:g};return p&&(w.name=p),w}function c(l,d){return s(l,d.v,d.w,d.name)}return Ps}var As,xp;function M1(){return xp||(xp=1,As="2.1.8"),As}var Ts,wp;function q1(){return wp||(wp=1,Ts={Graph:rl(),version:M1()}),Ts}var Os,Cp;function N1(){if(Cp)return Os;Cp=1;var e=xr(),t=rl();Os={write:r,read:i};function r(a){var s={options:{directed:a.isDirected(),multigraph:a.isMultigraph(),compound:a.isCompound()},nodes:n(a),edges:o(a)};return e.isUndefined(a.graph())||(s.value=e.clone(a.graph())),s}function n(a){return e.map(a.nodes(),function(s){var u=a.node(s),c=a.parent(s),l={v:s};return e.isUndefined(u)||(l.value=u),e.isUndefined(c)||(l.parent=c),l})}function o(a){return e.map(a.edges(),function(s){var u=a.edge(s),c={v:s.v,w:s.w};return e.isUndefined(s.name)||(c.name=s.name),e.isUndefined(u)||(c.value=u),c})}function i(a){var s=new t(a.options).setGraph(a.value);return e.each(a.nodes,function(u){s.setNode(u.v,u.value),u.parent&&s.setParent(u.v,u.parent)}),e.each(a.edges,function(u){s.setEdge({v:u.v,w:u.w,name:u.name},u.value)}),s}return Os}var Is,_p;function $1(){if(_p)return Is;_p=1;var e=xr();Is=t;function t(r){var n={},o=[],i;function a(s){e.has(n,s)||(n[s]=!0,i.push(s),e.each(r.successors(s),a),e.each(r.predecessors(s),a))}return e.each(r.nodes(),function(s){i=[],a(s),i.length&&o.push(i)}),o}return Is}var Ms,Sp;function wm(){if(Sp)return Ms;Sp=1;var e=xr();Ms=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(r){return r.key})},t.prototype.has=function(r){return e.has(this._keyIndices,r)},t.prototype.priority=function(r){var n=this._keyIndices[r];if(n!==void 0)return this._arr[n].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(r,n){var o=this._keyIndices;if(r=String(r),!e.has(o,r)){var i=this._arr,a=i.length;return o[r]=a,i.push({key:r,priority:n}),this._decrease(a),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},t.prototype.decrease=function(r,n){var o=this._keyIndices[r];if(n>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+n);this._arr[o].priority=n,this._decrease(o)},t.prototype._heapify=function(r){var n=this._arr,o=2*r,i=o+1,a=r;o<n.length&&(a=n[o].priority<n[a].priority?o:a,i<n.length&&(a=n[i].priority<n[a].priority?i:a),a!==r&&(this._swap(r,a),this._heapify(a)))},t.prototype._decrease=function(r){for(var n=this._arr,o=n[r].priority,i;r!==0&&(i=r>>1,!(n[i].priority<o));)this._swap(r,i),r=i},t.prototype._swap=function(r,n){var o=this._arr,i=this._keyIndices,a=o[r],s=o[n];o[r]=s,o[n]=a,i[s.key]=r,i[a.key]=n},Ms}var qs,Ep;function Cm(){if(Ep)return qs;Ep=1;var e=xr(),t=wm();qs=n;var r=e.constant(1);function n(i,a,s,u){return o(i,String(a),s||r,u||function(c){return i.outEdges(c)})}function o(i,a,s,u){var c={},l=new t,d,f,p=function(b){var g=b.v!==d?b.v:b.w,m=c[g],w=s(b),y=f.distance+w;if(w<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+b+" Weight: "+w);y<m.distance&&(m.distance=y,m.predecessor=d,l.decrease(g,y))};for(i.nodes().forEach(function(b){var g=b===a?0:Number.POSITIVE_INFINITY;c[b]={distance:g},l.add(b,g)});l.size()>0&&(d=l.removeMin(),f=c[d],f.distance!==Number.POSITIVE_INFINITY);)u(d).forEach(p);return c}return qs}var Ns,jp;function L1(){if(jp)return Ns;jp=1;var e=Cm(),t=xr();Ns=r;function r(n,o,i){return t.transform(n.nodes(),function(a,s){a[s]=e(n,s,o,i)},{})}return Ns}var $s,Rp;function _m(){if(Rp)return $s;Rp=1;var e=xr();$s=t;function t(r){var n=0,o=[],i={},a=[];function s(u){var c=i[u]={onStack:!0,lowlink:n,index:n++};if(o.push(u),r.successors(u).forEach(function(f){e.has(i,f)?i[f].onStack&&(c.lowlink=Math.min(c.lowlink,i[f].index)):(s(f),c.lowlink=Math.min(c.lowlink,i[f].lowlink))}),c.lowlink===c.index){var l=[],d;do d=o.pop(),i[d].onStack=!1,l.push(d);while(u!==d);a.push(l)}}return r.nodes().forEach(function(u){e.has(i,u)||s(u)}),a}return $s}var Ls,kp;function F1(){if(kp)return Ls;kp=1;var e=xr(),t=_m();Ls=r;function r(n){return e.filter(t(n),function(o){return o.length>1||o.length===1&&n.hasEdge(o[0],o[0])})}return Ls}var Fs,Pp;function B1(){if(Pp)return Fs;Pp=1;var e=xr();Fs=r;var t=e.constant(1);function r(o,i,a){return n(o,i||t,a||function(s){return o.outEdges(s)})}function n(o,i,a){var s={},u=o.nodes();return u.forEach(function(c){s[c]={},s[c][c]={distance:0},u.forEach(function(l){c!==l&&(s[c][l]={distance:Number.POSITIVE_INFINITY})}),a(c).forEach(function(l){var d=l.v===c?l.w:l.v,f=i(l);s[c][d]={distance:f,predecessor:c}})}),u.forEach(function(c){var l=s[c];u.forEach(function(d){var f=s[d];u.forEach(function(p){var b=f[c],g=l[p],m=f[p],w=b.distance+g.distance;w<m.distance&&(m.distance=w,m.predecessor=g.predecessor)})})}),s}return Fs}var Bs,Ap;function Sm(){if(Ap)return Bs;Ap=1;var e=xr();Bs=t,t.CycleException=r;function t(n){var o={},i={},a=[];function s(u){if(e.has(i,u))throw new r;e.has(o,u)||(i[u]=!0,o[u]=!0,e.each(n.predecessors(u),s),delete i[u],a.push(u))}if(e.each(n.sinks(),s),e.size(o)!==n.nodeCount())throw new r;return a}function r(){}return r.prototype=new Error,Bs}var Ds,Tp;function D1(){if(Tp)return Ds;Tp=1;var e=Sm();Ds=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return Ds}var zs,Op;function Em(){if(Op)return zs;Op=1;var e=xr();zs=t;function t(n,o,i){e.isArray(o)||(o=[o]);var a=(n.isDirected()?n.successors:n.neighbors).bind(n),s=[],u={};return e.each(o,function(c){if(!n.hasNode(c))throw new Error("Graph does not have node: "+c);r(n,c,i==="post",u,a,s)}),s}function r(n,o,i,a,s,u){e.has(a,o)||(a[o]=!0,i||u.push(o),e.each(s(o),function(c){r(n,c,i,a,s,u)}),i&&u.push(o))}return zs}var Vs,Ip;function z1(){if(Ip)return Vs;Ip=1;var e=Em();Vs=t;function t(r,n){return e(r,n,"post")}return Vs}var Ws,Mp;function V1(){if(Mp)return Ws;Mp=1;var e=Em();Ws=t;function t(r,n){return e(r,n,"pre")}return Ws}var Gs,qp;function W1(){if(qp)return Gs;qp=1;var e=xr(),t=rl(),r=wm();Gs=n;function n(o,i){var a=new t,s={},u=new r,c;function l(f){var p=f.v===c?f.w:f.v,b=u.priority(p);if(b!==void 0){var g=i(f);g<b&&(s[p]=c,u.decrease(p,g))}}if(o.nodeCount()===0)return a;e.each(o.nodes(),function(f){u.add(f,Number.POSITIVE_INFINITY),a.setNode(f)}),u.decrease(o.nodes()[0],0);for(var d=!1;u.size()>0;){if(c=u.removeMin(),e.has(s,c))a.setEdge(c,s[c]);else{if(d)throw new Error("Input graph is not connected: "+o);d=!0}o.nodeEdges(c).forEach(l)}return a}return Gs}var Us,Np;function G1(){return Np||(Np=1,Us={components:$1(),dijkstra:Cm(),dijkstraAll:L1(),findCycles:F1(),floydWarshall:B1(),isAcyclic:D1(),postorder:z1(),preorder:V1(),prim:W1(),tarjan:_m(),topsort:Sm()}),Us}var Hs,$p;function U1(){if($p)return Hs;$p=1;var e=q1();return Hs={Graph:e.Graph,json:N1(),alg:G1(),version:e.version},Hs}var Ks,Lp;function _r(){if(Lp)return Ks;Lp=1;var e;if(typeof Fu=="function")try{e=U1()}catch{}return e||(e=window.graphlib),Ks=e,Ks}var Js,Fp;function H1(){if(Fp)return Js;Fp=1;var e=Zb(),t=1,r=4;function n(o){return e(o,t|r)}return Js=n,Js}var Zs,Bp;function Dn(){if(Bp)return Zs;Bp=1;var e=bt(),t=Nr(),r=On(),n=vr();function o(i,a,s){if(!n(s))return!1;var u=typeof a;return(u=="number"?t(s)&&r(a,s.length):u=="string"&&a in s)?e(s[a],i):!1}return Zs=o,Zs}var Ys,Dp;function K1(){if(Dp)return Ys;Dp=1;var e=Bn(),t=bt(),r=Dn(),n=ot(),o=Object.prototype,i=o.hasOwnProperty,a=e(function(s,u){s=Object(s);var c=-1,l=u.length,d=l>2?u[2]:void 0;for(d&&r(u[0],u[1],d)&&(l=1);++c<l;)for(var f=u[c],p=n(f),b=-1,g=p.length;++b<g;){var m=p[b],w=s[m];(w===void 0||t(w,o[m])&&!i.call(s,m))&&(s[m]=f[m])}return s});return Ys=a,Ys}var Xs,zp;function J1(){if(zp)return Xs;zp=1;var e=$r(),t=Nr(),r=Hr();function n(o){return function(i,a,s){var u=Object(i);if(!t(i)){var c=e(a,3);i=r(i),a=function(d){return c(u[d],d,u)}}var l=o(i,a,s);return l>-1?u[c?i[l]:l]:void 0}}return Xs=n,Xs}var Qs,Vp;function Z1(){if(Vp)return Qs;Vp=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return Qs=t,Qs}var ec,Wp;function Y1(){if(Wp)return ec;Wp=1;var e=Z1(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return ec=r,ec}var rc,Gp;function X1(){if(Gp)return rc;Gp=1;var e=Y1(),t=vr(),r=wt(),n=NaN,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,a=/^0o[0-7]+$/i,s=parseInt;function u(c){if(typeof c=="number")return c;if(r(c))return n;if(t(c)){var l=typeof c.valueOf=="function"?c.valueOf():c;c=t(l)?l+"":l}if(typeof c!="string")return c===0?c:+c;c=e(c);var d=i.test(c);return d||a.test(c)?s(c.slice(2),d?2:8):o.test(c)?n:+c}return rc=u,rc}var tc,Up;function jm(){if(Up)return tc;Up=1;var e=X1(),t=1/0,r=17976931348623157e292;function n(o){if(!o)return o===0?o:0;if(o=e(o),o===t||o===-t){var i=o<0?-1:1;return i*r}return o===o?o:0}return tc=n,tc}var nc,Hp;function Q1(){if(Hp)return nc;Hp=1;var e=jm();function t(r){var n=e(r),o=n%1;return n===n?o?n-o:n:0}return nc=t,nc}var oc,Kp;function eC(){if(Kp)return oc;Kp=1;var e=mm(),t=$r(),r=Q1(),n=Math.max;function o(i,a,s){var u=i==null?0:i.length;if(!u)return-1;var c=s==null?0:r(s);return c<0&&(c=n(u+c,0)),e(i,t(a,3),c)}return oc=o,oc}var ic,Jp;function rC(){if(Jp)return ic;Jp=1;var e=J1(),t=eC(),r=e(t);return ic=r,ic}var ac,Zp;function Rm(){if(Zp)return ac;Zp=1;var e=el();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return ac=t,ac}var sc,Yp;function tC(){if(Yp)return sc;Yp=1;var e=Zu(),t=Yb(),r=ot();function n(o,i){return o==null?o:e(o,t(i),r)}return sc=n,sc}var cc,Xp;function nC(){if(Xp)return cc;Xp=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return cc=e,cc}var uc,Qp;function oC(){if(Qp)return uc;Qp=1;var e=An(),t=Yu(),r=$r();function n(o,i){var a={};return i=r(i,3),t(o,function(s,u,c){e(a,u,i(s,u,c))}),a}return uc=n,uc}var lc,eg;function tl(){if(eg)return lc;eg=1;var e=wt();function t(r,n,o){for(var i=-1,a=r.length;++i<a;){var s=r[i],u=n(s);if(u!=null&&(c===void 0?u===u&&!e(u):o(u,c)))var c=u,l=s}return l}return lc=t,lc}var dc,rg;function iC(){if(rg)return dc;rg=1;function e(t,r){return t>r}return dc=e,dc}var fc,tg;function aC(){if(tg)return fc;tg=1;var e=tl(),t=iC(),r=it();function n(o){return o&&o.length?e(o,r,t):void 0}return fc=n,fc}var hc,ng;function km(){if(ng)return hc;ng=1;var e=An(),t=bt();function r(n,o,i){(i!==void 0&&!t(n[o],i)||i===void 0&&!(o in n))&&e(n,o,i)}return hc=r,hc}var pc,og;function sC(){if(og)return pc;og=1;var e=tt(),t=qn(),r=Pr(),n="[object Object]",o=Function.prototype,i=Object.prototype,a=o.toString,s=i.hasOwnProperty,u=a.call(Object);function c(l){if(!r(l)||e(l)!=n)return!1;var d=t(l);if(d===null)return!0;var f=s.call(d,"constructor")&&d.constructor;return typeof f=="function"&&f instanceof f&&a.call(f)==u}return pc=c,pc}var gc,ig;function Pm(){if(ig)return gc;ig=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return gc=e,gc}var yc,ag;function cC(){if(ag)return yc;ag=1;var e=en(),t=ot();function r(n){return e(n,t(n))}return yc=r,yc}var bc,sg;function uC(){if(sg)return bc;sg=1;var e=km(),t=Lb(),r=Hb(),n=Fb(),o=Jb(),i=rn(),a=Ye(),s=vm(),u=vt(),c=Qt(),l=vr(),d=sC(),f=tn(),p=Pm(),b=cC();function g(m,w,y,x,v,C,_){var k=p(m,y),T=p(w,y),P=_.get(T);if(P){e(m,y,P);return}var j=C?C(k,T,y+"",m,w,_):void 0,R=j===void 0;if(R){var E=a(T),M=!E&&u(T),I=!E&&!M&&f(T);j=T,E||M||I?a(k)?j=k:s(k)?j=n(k):M?(R=!1,j=t(T,!0)):I?(R=!1,j=r(T,!0)):j=[]:d(T)||i(T)?(j=k,i(k)?j=b(k):(!l(k)||c(k))&&(j=o(T))):R=!1}R&&(_.set(T,j),v(j,T,x,C,_),_.delete(T)),e(m,y,j)}return bc=g,bc}var mc,cg;function lC(){if(cg)return mc;cg=1;var e=Pn(),t=km(),r=Zu(),n=uC(),o=vr(),i=ot(),a=Pm();function s(u,c,l,d,f){u!==c&&r(c,function(p,b){if(f||(f=new e),o(p))n(u,c,b,l,s,d,f);else{var g=d?d(a(u,b),p,b+"",u,c,f):void 0;g===void 0&&(g=p),t(u,b,g)}},i)}return mc=s,mc}var vc,ug;function dC(){if(ug)return vc;ug=1;var e=Bn(),t=Dn();function r(n){return e(function(o,i){var a=-1,s=i.length,u=s>1?i[s-1]:void 0,c=s>2?i[2]:void 0;for(u=n.length>3&&typeof u=="function"?(s--,u):void 0,c&&t(i[0],i[1],c)&&(u=s<3?void 0:u,s=1),o=Object(o);++a<s;){var l=i[a];l&&n(o,l,a,u)}return o})}return vc=r,vc}var xc,lg;function fC(){if(lg)return xc;lg=1;var e=lC(),t=dC(),r=t(function(n,o,i){e(n,o,i)});return xc=r,xc}var wc,dg;function Am(){if(dg)return wc;dg=1;function e(t,r){return t<r}return wc=e,wc}var Cc,fg;function hC(){if(fg)return Cc;fg=1;var e=tl(),t=Am(),r=it();function n(o){return o&&o.length?e(o,r,t):void 0}return Cc=n,Cc}var _c,hg;function pC(){if(hg)return _c;hg=1;var e=tl(),t=$r(),r=Am();function n(o,i){return o&&o.length?e(o,t(i,2),r):void 0}return _c=n,_c}var Sc,pg;function gC(){if(pg)return Sc;pg=1;var e=Sr(),t=function(){return e.Date.now()};return Sc=t,Sc}var Ec,gg;function yC(){if(gg)return Ec;gg=1;var e=Tn(),t=Ln(),r=On(),n=vr(),o=nn();function i(a,s,u,c){if(!n(a))return a;s=t(s,a);for(var l=-1,d=s.length,f=d-1,p=a;p!=null&&++l<d;){var b=o(s[l]),g=u;if(b==="__proto__"||b==="constructor"||b==="prototype")return a;if(l!=f){var m=p[b];g=c?c(m,b,p):void 0,g===void 0&&(g=n(m)?m:r(s[l+1])?[]:{})}e(p,b,g),p=p[b]}return a}return Ec=i,Ec}var jc,yg;function bC(){if(yg)return jc;yg=1;var e=Fn(),t=yC(),r=Ln();function n(o,i,a){for(var s=-1,u=i.length,c={};++s<u;){var l=i[s],d=e(o,l);a(d,l)&&t(c,r(l,o),d)}return c}return jc=n,jc}var Rc,bg;function mC(){if(bg)return Rc;bg=1;var e=bC(),t=cm();function r(n,o){return e(n,o,function(i,a){return t(n,a)})}return Rc=r,Rc}var kc,mg;function vC(){if(mg)return kc;mg=1;var e=Rm(),t=ym(),r=bm();function n(o){return r(t(o,void 0,e),o+"")}return kc=n,kc}var Pc,vg;function xC(){if(vg)return Pc;vg=1;var e=mC(),t=vC(),r=t(function(n,o){return n==null?{}:e(n,o)});return Pc=r,Pc}var Ac,xg;function wC(){if(xg)return Ac;xg=1;var e=Math.ceil,t=Math.max;function r(n,o,i,a){for(var s=-1,u=t(e((o-n)/(i||1)),0),c=Array(u);u--;)c[a?u:++s]=n,n+=i;return c}return Ac=r,Ac}var Tc,wg;function CC(){if(wg)return Tc;wg=1;var e=wC(),t=Dn(),r=jm();function n(o){return function(i,a,s){return s&&typeof s!="number"&&t(i,a,s)&&(a=s=void 0),i=r(i),a===void 0?(a=i,i=0):a=r(a),s=s===void 0?i<a?1:-1:r(s),e(i,a,s,o)}}return Tc=n,Tc}var Oc,Cg;function _C(){if(Cg)return Oc;Cg=1;var e=CC(),t=e();return Oc=t,Oc}var Ic,_g;function SC(){if(_g)return Ic;_g=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return Ic=e,Ic}var Mc,Sg;function EC(){if(Sg)return Mc;Sg=1;var e=wt();function t(r,n){if(r!==n){var o=r!==void 0,i=r===null,a=r===r,s=e(r),u=n!==void 0,c=n===null,l=n===n,d=e(n);if(!c&&!d&&!s&&r>n||s&&u&&l&&!c&&!d||i&&u&&l||!o&&l||!a)return 1;if(!i&&!s&&!d&&r<n||d&&o&&a&&!i&&!s||c&&o&&a||!u&&a||!l)return-1}return 0}return Mc=t,Mc}var qc,Eg;function jC(){if(Eg)return qc;Eg=1;var e=EC();function t(r,n,o){for(var i=-1,a=r.criteria,s=n.criteria,u=a.length,c=o.length;++i<u;){var l=e(a[i],s[i]);if(l){if(i>=c)return l;var d=o[i];return l*(d=="desc"?-1:1)}}return r.index-n.index}return qc=t,qc}var Nc,jg;function RC(){if(jg)return Nc;jg=1;var e=$n(),t=Fn(),r=$r(),n=hm(),o=SC(),i=In(),a=jC(),s=it(),u=Ye();function c(l,d,f){d.length?d=e(d,function(g){return u(g)?function(m){return t(m,g.length===1?g[0]:g)}:g}):d=[s];var p=-1;d=e(d,i(r));var b=n(l,function(g,m,w){var y=e(d,function(x){return x(g)});return{criteria:y,index:++p,value:g}});return o(b,function(g,m){return a(g,m,f)})}return Nc=c,Nc}var $c,Rg;function kC(){if(Rg)return $c;Rg=1;var e=el(),t=RC(),r=Bn(),n=Dn(),o=r(function(i,a){if(i==null)return[];var s=a.length;return s>1&&n(i,a[0],a[1])?a=[]:s>2&&n(a[0],a[1],a[2])&&(a=[a[0]]),t(i,e(a,1),[])});return $c=o,$c}var Lc,kg;function PC(){if(kg)return Lc;kg=1;var e=am(),t=0;function r(n){var o=++t;return e(n)+o}return Lc=r,Lc}var Fc,Pg;function AC(){if(Pg)return Fc;Pg=1;function e(t,r,n){for(var o=-1,i=t.length,a=r.length,s={};++o<i;){var u=o<a?r[o]:void 0;n(s,t[o],u)}return s}return Fc=e,Fc}var Bc,Ag;function TC(){if(Ag)return Bc;Ag=1;var e=Tn(),t=AC();function r(n,o){return t(n||[],o||[],e)}return Bc=r,Bc}var Dc,Tg;function We(){if(Tg)return Dc;Tg=1;var e;if(typeof Fu=="function")try{e={cloneDeep:H1(),constant:Ju(),defaults:K1(),each:Qb(),filter:lm(),find:rC(),flatten:Rm(),forEach:Xb(),forIn:tC(),has:dm(),isUndefined:fm(),last:nC(),map:pm(),mapValues:oC(),max:aC(),merge:fC(),min:hC(),minBy:pC(),now:gC(),pick:xC(),range:_C(),reduce:gm(),sortBy:kC(),uniqueId:PC(),values:xm(),zipObject:TC()}}catch{}return e||(e=window._),Dc=e,Dc}var zc,Og;function OC(){if(Og)return zc;Og=1,zc=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,o=n._prev;if(o!==n)return t(o),o},e.prototype.enqueue=function(n){var o=this._sentinel;n._prev&&n._next&&t(n),n._next=o._next,o._next._prev=n,o._next=n,n._prev=o},e.prototype.toString=function(){for(var n=[],o=this._sentinel,i=o._prev;i!==o;)n.push(JSON.stringify(i,r)),i=i._prev;return"["+n.join(", ")+"]"};function t(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function r(n,o){if(n!=="_next"&&n!=="_prev")return o}return zc}var Vc,Ig;function IC(){if(Ig)return Vc;Ig=1;var e=We(),t=_r().Graph,r=OC();Vc=o;var n=e.constant(1);function o(c,l){if(c.nodeCount()<=1)return[];var d=s(c,l||n),f=i(d.graph,d.buckets,d.zeroIdx);return e.flatten(e.map(f,function(p){return c.outEdges(p.v,p.w)}),!0)}function i(c,l,d){for(var f=[],p=l[l.length-1],b=l[0],g;c.nodeCount();){for(;g=b.dequeue();)a(c,l,d,g);for(;g=p.dequeue();)a(c,l,d,g);if(c.nodeCount()){for(var m=l.length-2;m>0;--m)if(g=l[m].dequeue(),g){f=f.concat(a(c,l,d,g,!0));break}}}return f}function a(c,l,d,f,p){var b=p?[]:void 0;return e.forEach(c.inEdges(f.v),function(g){var m=c.edge(g),w=c.node(g.v);p&&b.push({v:g.v,w:g.w}),w.out-=m,u(l,d,w)}),e.forEach(c.outEdges(f.v),function(g){var m=c.edge(g),w=g.w,y=c.node(w);y.in-=m,u(l,d,y)}),c.removeNode(f.v),b}function s(c,l){var d=new t,f=0,p=0;e.forEach(c.nodes(),function(m){d.setNode(m,{v:m,in:0,out:0})}),e.forEach(c.edges(),function(m){var w=d.edge(m.v,m.w)||0,y=l(m),x=w+y;d.setEdge(m.v,m.w,x),p=Math.max(p,d.node(m.v).out+=y),f=Math.max(f,d.node(m.w).in+=y)});var b=e.range(p+f+3).map(function(){return new r}),g=f+1;return e.forEach(d.nodes(),function(m){u(b,g,d.node(m))}),{graph:d,buckets:b,zeroIdx:g}}function u(c,l,d){d.out?d.in?c[d.out-d.in+l].enqueue(d):c[c.length-1].enqueue(d):c[0].enqueue(d)}return Vc}var Wc,Mg;function MC(){if(Mg)return Wc;Mg=1;var e=We(),t=IC();Wc={run:r,undo:o};function r(i){var a=i.graph().acyclicer==="greedy"?t(i,s(i)):n(i);e.forEach(a,function(u){var c=i.edge(u);i.removeEdge(u),c.forwardName=u.name,c.reversed=!0,i.setEdge(u.w,u.v,c,e.uniqueId("rev"))});function s(u){return function(c){return u.edge(c).weight}}}function n(i){var a=[],s={},u={};function c(l){e.has(u,l)||(u[l]=!0,s[l]=!0,e.forEach(i.outEdges(l),function(d){e.has(s,d.w)?a.push(d):c(d.w)}),delete s[l])}return e.forEach(i.nodes(),c),a}function o(i){e.forEach(i.edges(),function(a){var s=i.edge(a);if(s.reversed){i.removeEdge(a);var u=s.forwardName;delete s.reversed,delete s.forwardName,i.setEdge(a.w,a.v,s,u)}})}return Wc}var Gc,qg;function pr(){if(qg)return Gc;qg=1;var e=We(),t=_r().Graph;Gc={addDummyNode:r,simplify:n,asNonCompoundGraph:o,successorWeights:i,predecessorWeights:a,intersectRect:s,buildLayerMatrix:u,normalizeRanks:c,removeEmptyRanks:l,addBorderNode:d,maxRank:f,partition:p,time:b,notime:g};function r(m,w,y,x){var v;do v=e.uniqueId(x);while(m.hasNode(v));return y.dummy=w,m.setNode(v,y),v}function n(m){var w=new t().setGraph(m.graph());return e.forEach(m.nodes(),function(y){w.setNode(y,m.node(y))}),e.forEach(m.edges(),function(y){var x=w.edge(y.v,y.w)||{weight:0,minlen:1},v=m.edge(y);w.setEdge(y.v,y.w,{weight:x.weight+v.weight,minlen:Math.max(x.minlen,v.minlen)})}),w}function o(m){var w=new t({multigraph:m.isMultigraph()}).setGraph(m.graph());return e.forEach(m.nodes(),function(y){m.children(y).length||w.setNode(y,m.node(y))}),e.forEach(m.edges(),function(y){w.setEdge(y,m.edge(y))}),w}function i(m){var w=e.map(m.nodes(),function(y){var x={};return e.forEach(m.outEdges(y),function(v){x[v.w]=(x[v.w]||0)+m.edge(v).weight}),x});return e.zipObject(m.nodes(),w)}function a(m){var w=e.map(m.nodes(),function(y){var x={};return e.forEach(m.inEdges(y),function(v){x[v.v]=(x[v.v]||0)+m.edge(v).weight}),x});return e.zipObject(m.nodes(),w)}function s(m,w){var y=m.x,x=m.y,v=w.x-y,C=w.y-x,_=m.width/2,k=m.height/2;if(!v&&!C)throw new Error("Not possible to find intersection inside of the rectangle");var T,P;return Math.abs(C)*_>Math.abs(v)*k?(C<0&&(k=-k),T=k*v/C,P=k):(v<0&&(_=-_),T=_,P=_*C/v),{x:y+T,y:x+P}}function u(m){var w=e.map(e.range(f(m)+1),function(){return[]});return e.forEach(m.nodes(),function(y){var x=m.node(y),v=x.rank;e.isUndefined(v)||(w[v][x.order]=y)}),w}function c(m){var w=e.min(e.map(m.nodes(),function(y){return m.node(y).rank}));e.forEach(m.nodes(),function(y){var x=m.node(y);e.has(x,"rank")&&(x.rank-=w)})}function l(m){var w=e.min(e.map(m.nodes(),function(C){return m.node(C).rank})),y=[];e.forEach(m.nodes(),function(C){var _=m.node(C).rank-w;y[_]||(y[_]=[]),y[_].push(C)});var x=0,v=m.graph().nodeRankFactor;e.forEach(y,function(C,_){e.isUndefined(C)&&_%v!==0?--x:x&&e.forEach(C,function(k){m.node(k).rank+=x})})}function d(m,w,y,x){var v={width:0,height:0};return arguments.length>=4&&(v.rank=y,v.order=x),r(m,"border",v,w)}function f(m){return e.max(e.map(m.nodes(),function(w){var y=m.node(w).rank;if(!e.isUndefined(y))return y}))}function p(m,w){var y={lhs:[],rhs:[]};return e.forEach(m,function(x){w(x)?y.lhs.push(x):y.rhs.push(x)}),y}function b(m,w){var y=e.now();try{return w()}finally{console.log(m+" time: "+(e.now()-y)+"ms")}}function g(m,w){return w()}return Gc}var Uc,Ng;function qC(){if(Ng)return Uc;Ng=1;var e=We(),t=pr();Uc={run:r,undo:o};function r(i){i.graph().dummyChains=[],e.forEach(i.edges(),function(a){n(i,a)})}function n(i,a){var s=a.v,u=i.node(s).rank,c=a.w,l=i.node(c).rank,d=a.name,f=i.edge(a),p=f.labelRank;if(l!==u+1){i.removeEdge(a);var b,g,m;for(m=0,++u;u<l;++m,++u)f.points=[],g={width:0,height:0,edgeLabel:f,edgeObj:a,rank:u},b=t.addDummyNode(i,"edge",g,"_d"),u===p&&(g.width=f.width,g.height=f.height,g.dummy="edge-label",g.labelpos=f.labelpos),i.setEdge(s,b,{weight:f.weight},d),m===0&&i.graph().dummyChains.push(b),s=b;i.setEdge(s,c,{weight:f.weight},d)}}function o(i){e.forEach(i.graph().dummyChains,function(a){var s=i.node(a),u=s.edgeLabel,c;for(i.setEdge(s.edgeObj,u);s.dummy;)c=i.successors(a)[0],i.removeNode(a),u.points.push({x:s.x,y:s.y}),s.dummy==="edge-label"&&(u.x=s.x,u.y=s.y,u.width=s.width,u.height=s.height),a=c,s=i.node(a)})}return Uc}var Hc,$g;function yn(){if($g)return Hc;$g=1;var e=We();Hc={longestPath:t,slack:r};function t(n){var o={};function i(a){var s=n.node(a);if(e.has(o,a))return s.rank;o[a]=!0;var u=e.min(e.map(n.outEdges(a),function(c){return i(c.w)-n.edge(c).minlen}));return(u===Number.POSITIVE_INFINITY||u===void 0||u===null)&&(u=0),s.rank=u}e.forEach(n.sources(),i)}function r(n,o){return n.node(o.w).rank-n.node(o.v).rank-n.edge(o).minlen}return Hc}var Kc,Lg;function Tm(){if(Lg)return Kc;Lg=1;var e=We(),t=_r().Graph,r=yn().slack;Kc=n;function n(s){var u=new t({directed:!1}),c=s.nodes()[0],l=s.nodeCount();u.setNode(c,{});for(var d,f;o(u,s)<l;)d=i(u,s),f=u.hasNode(d.v)?r(s,d):-r(s,d),a(u,s,f);return u}function o(s,u){function c(l){e.forEach(u.nodeEdges(l),function(d){var f=d.v,p=l===f?d.w:f;!s.hasNode(p)&&!r(u,d)&&(s.setNode(p,{}),s.setEdge(l,p,{}),c(p))})}return e.forEach(s.nodes(),c),s.nodeCount()}function i(s,u){return e.minBy(u.edges(),function(c){if(s.hasNode(c.v)!==s.hasNode(c.w))return r(u,c)})}function a(s,u,c){e.forEach(s.nodes(),function(l){u.node(l).rank+=c})}return Kc}var Jc,Fg;function NC(){if(Fg)return Jc;Fg=1;var e=We(),t=Tm(),r=yn().slack,n=yn().longestPath,o=_r().alg.preorder,i=_r().alg.postorder,a=pr().simplify;Jc=s,s.initLowLimValues=d,s.initCutValues=u,s.calcCutValue=l,s.leaveEdge=p,s.enterEdge=b,s.exchangeEdges=g;function s(x){x=a(x),n(x);var v=t(x);d(v),u(v,x);for(var C,_;C=p(v);)_=b(v,x,C),g(v,x,C,_)}function u(x,v){var C=i(x,x.nodes());C=C.slice(0,C.length-1),e.forEach(C,function(_){c(x,v,_)})}function c(x,v,C){var _=x.node(C),k=_.parent;x.edge(C,k).cutvalue=l(x,v,C)}function l(x,v,C){var _=x.node(C),k=_.parent,T=!0,P=v.edge(C,k),j=0;return P||(T=!1,P=v.edge(k,C)),j=P.weight,e.forEach(v.nodeEdges(C),function(R){var E=R.v===C,M=E?R.w:R.v;if(M!==k){var I=E===T,N=v.edge(R).weight;if(j+=I?N:-N,w(x,C,M)){var O=x.edge(C,M).cutvalue;j+=I?-O:O}}}),j}function d(x,v){arguments.length<2&&(v=x.nodes()[0]),f(x,{},1,v)}function f(x,v,C,_,k){var T=C,P=x.node(_);return v[_]=!0,e.forEach(x.neighbors(_),function(j){e.has(v,j)||(C=f(x,v,C,j,_))}),P.low=T,P.lim=C++,k?P.parent=k:delete P.parent,C}function p(x){return e.find(x.edges(),function(v){return x.edge(v).cutvalue<0})}function b(x,v,C){var _=C.v,k=C.w;v.hasEdge(_,k)||(_=C.w,k=C.v);var T=x.node(_),P=x.node(k),j=T,R=!1;T.lim>P.lim&&(j=P,R=!0);var E=e.filter(v.edges(),function(M){return R===y(x,x.node(M.v),j)&&R!==y(x,x.node(M.w),j)});return e.minBy(E,function(M){return r(v,M)})}function g(x,v,C,_){var k=C.v,T=C.w;x.removeEdge(k,T),x.setEdge(_.v,_.w,{}),d(x),u(x,v),m(x,v)}function m(x,v){var C=e.find(x.nodes(),function(k){return!v.node(k).parent}),_=o(x,C);_=_.slice(1),e.forEach(_,function(k){var T=x.node(k).parent,P=v.edge(k,T),j=!1;P||(P=v.edge(T,k),j=!0),v.node(k).rank=v.node(T).rank+(j?P.minlen:-P.minlen)})}function w(x,v,C){return x.hasEdge(v,C)}function y(x,v,C){return C.low<=v.lim&&v.lim<=C.lim}return Jc}var Zc,Bg;function $C(){if(Bg)return Zc;Bg=1;var e=yn(),t=e.longestPath,r=Tm(),n=NC();Zc=o;function o(u){switch(u.graph().ranker){case"network-simplex":s(u);break;case"tight-tree":a(u);break;case"longest-path":i(u);break;default:s(u)}}var i=t;function a(u){t(u),r(u)}function s(u){n(u)}return Zc}var Yc,Dg;function LC(){if(Dg)return Yc;Dg=1;var e=We();Yc=t;function t(o){var i=n(o);e.forEach(o.graph().dummyChains,function(a){for(var s=o.node(a),u=s.edgeObj,c=r(o,i,u.v,u.w),l=c.path,d=c.lca,f=0,p=l[f],b=!0;a!==u.w;){if(s=o.node(a),b){for(;(p=l[f])!==d&&o.node(p).maxRank<s.rank;)f++;p===d&&(b=!1)}if(!b){for(;f<l.length-1&&o.node(p=l[f+1]).minRank<=s.rank;)f++;p=l[f]}o.setParent(a,p),a=o.successors(a)[0]}})}function r(o,i,a,s){var u=[],c=[],l=Math.min(i[a].low,i[s].low),d=Math.max(i[a].lim,i[s].lim),f,p;f=a;do f=o.parent(f),u.push(f);while(f&&(i[f].low>l||d>i[f].lim));for(p=f,f=s;(f=o.parent(f))!==p;)c.push(f);return{path:u.concat(c.reverse()),lca:p}}function n(o){var i={},a=0;function s(u){var c=a;e.forEach(o.children(u),s),i[u]={low:c,lim:a++}}return e.forEach(o.children(),s),i}return Yc}var Xc,zg;function FC(){if(zg)return Xc;zg=1;var e=We(),t=pr();Xc={run:r,cleanup:a};function r(s){var u=t.addDummyNode(s,"root",{},"_root"),c=o(s),l=e.max(e.values(c))-1,d=2*l+1;s.graph().nestingRoot=u,e.forEach(s.edges(),function(p){s.edge(p).minlen*=d});var f=i(s)+1;e.forEach(s.children(),function(p){n(s,u,d,f,l,c,p)}),s.graph().nodeRankFactor=d}function n(s,u,c,l,d,f,p){var b=s.children(p);if(!b.length){p!==u&&s.setEdge(u,p,{weight:0,minlen:c});return}var g=t.addBorderNode(s,"_bt"),m=t.addBorderNode(s,"_bb"),w=s.node(p);s.setParent(g,p),w.borderTop=g,s.setParent(m,p),w.borderBottom=m,e.forEach(b,function(y){n(s,u,c,l,d,f,y);var x=s.node(y),v=x.borderTop?x.borderTop:y,C=x.borderBottom?x.borderBottom:y,_=x.borderTop?l:2*l,k=v!==C?1:d-f[p]+1;s.setEdge(g,v,{weight:_,minlen:k,nestingEdge:!0}),s.setEdge(C,m,{weight:_,minlen:k,nestingEdge:!0})}),s.parent(p)||s.setEdge(u,g,{weight:0,minlen:d+f[p]})}function o(s){var u={};function c(l,d){var f=s.children(l);f&&f.length&&e.forEach(f,function(p){c(p,d+1)}),u[l]=d}return e.forEach(s.children(),function(l){c(l,1)}),u}function i(s){return e.reduce(s.edges(),function(u,c){return u+s.edge(c).weight},0)}function a(s){var u=s.graph();s.removeNode(u.nestingRoot),delete u.nestingRoot,e.forEach(s.edges(),function(c){var l=s.edge(c);l.nestingEdge&&s.removeEdge(c)})}return Xc}var Qc,Vg;function BC(){if(Vg)return Qc;Vg=1;var e=We(),t=pr();Qc=r;function r(o){function i(a){var s=o.children(a),u=o.node(a);if(s.length&&e.forEach(s,i),e.has(u,"minRank")){u.borderLeft=[],u.borderRight=[];for(var c=u.minRank,l=u.maxRank+1;c<l;++c)n(o,"borderLeft","_bl",a,u,c),n(o,"borderRight","_br",a,u,c)}}e.forEach(o.children(),i)}function n(o,i,a,s,u,c){var l={width:0,height:0,rank:c,borderType:i},d=u[i][c-1],f=t.addDummyNode(o,"border",l,a);u[i][c]=f,o.setParent(f,s),d&&o.setEdge(d,f,{weight:1})}return Qc}var eu,Wg;function DC(){if(Wg)return eu;Wg=1;var e=We();eu={adjust:t,undo:r};function t(c){var l=c.graph().rankdir.toLowerCase();(l==="lr"||l==="rl")&&n(c)}function r(c){var l=c.graph().rankdir.toLowerCase();(l==="bt"||l==="rl")&&i(c),(l==="lr"||l==="rl")&&(s(c),n(c))}function n(c){e.forEach(c.nodes(),function(l){o(c.node(l))}),e.forEach(c.edges(),function(l){o(c.edge(l))})}function o(c){var l=c.width;c.width=c.height,c.height=l}function i(c){e.forEach(c.nodes(),function(l){a(c.node(l))}),e.forEach(c.edges(),function(l){var d=c.edge(l);e.forEach(d.points,a),e.has(d,"y")&&a(d)})}function a(c){c.y=-c.y}function s(c){e.forEach(c.nodes(),function(l){u(c.node(l))}),e.forEach(c.edges(),function(l){var d=c.edge(l);e.forEach(d.points,u),e.has(d,"x")&&u(d)})}function u(c){var l=c.x;c.x=c.y,c.y=l}return eu}var ru,Gg;function zC(){if(Gg)return ru;Gg=1;var e=We();ru=t;function t(r){var n={},o=e.filter(r.nodes(),function(c){return!r.children(c).length}),i=e.max(e.map(o,function(c){return r.node(c).rank})),a=e.map(e.range(i+1),function(){return[]});function s(c){if(!e.has(n,c)){n[c]=!0;var l=r.node(c);a[l.rank].push(c),e.forEach(r.successors(c),s)}}var u=e.sortBy(o,function(c){return r.node(c).rank});return e.forEach(u,s),a}return ru}var tu,Ug;function VC(){if(Ug)return tu;Ug=1;var e=We();tu=t;function t(n,o){for(var i=0,a=1;a<o.length;++a)i+=r(n,o[a-1],o[a]);return i}function r(n,o,i){for(var a=e.zipObject(i,e.map(i,function(f,p){return p})),s=e.flatten(e.map(o,function(f){return e.sortBy(e.map(n.outEdges(f),function(p){return{pos:a[p.w],weight:n.edge(p).weight}}),"pos")}),!0),u=1;u<i.length;)u<<=1;var c=2*u-1;u-=1;var l=e.map(new Array(c),function(){return 0}),d=0;return e.forEach(s.forEach(function(f){var p=f.pos+u;l[p]+=f.weight;for(var b=0;p>0;)p%2&&(b+=l[p+1]),p=p-1>>1,l[p]+=f.weight;d+=f.weight*b})),d}return tu}var nu,Hg;function WC(){if(Hg)return nu;Hg=1;var e=We();nu=t;function t(r,n){return e.map(n,function(o){var i=r.inEdges(o);if(i.length){var a=e.reduce(i,function(s,u){var c=r.edge(u),l=r.node(u.v);return{sum:s.sum+c.weight*l.order,weight:s.weight+c.weight}},{sum:0,weight:0});return{v:o,barycenter:a.sum/a.weight,weight:a.weight}}else return{v:o}})}return nu}var ou,Kg;function GC(){if(Kg)return ou;Kg=1;var e=We();ou=t;function t(o,i){var a={};e.forEach(o,function(u,c){var l=a[u.v]={indegree:0,in:[],out:[],vs:[u.v],i:c};e.isUndefined(u.barycenter)||(l.barycenter=u.barycenter,l.weight=u.weight)}),e.forEach(i.edges(),function(u){var c=a[u.v],l=a[u.w];!e.isUndefined(c)&&!e.isUndefined(l)&&(l.indegree++,c.out.push(a[u.w]))});var s=e.filter(a,function(u){return!u.indegree});return r(s)}function r(o){var i=[];function a(c){return function(l){l.merged||(e.isUndefined(l.barycenter)||e.isUndefined(c.barycenter)||l.barycenter>=c.barycenter)&&n(c,l)}}function s(c){return function(l){l.in.push(c),--l.indegree===0&&o.push(l)}}for(;o.length;){var u=o.pop();i.push(u),e.forEach(u.in.reverse(),a(u)),e.forEach(u.out,s(u))}return e.map(e.filter(i,function(c){return!c.merged}),function(c){return e.pick(c,["vs","i","barycenter","weight"])})}function n(o,i){var a=0,s=0;o.weight&&(a+=o.barycenter*o.weight,s+=o.weight),i.weight&&(a+=i.barycenter*i.weight,s+=i.weight),o.vs=i.vs.concat(o.vs),o.barycenter=a/s,o.weight=s,o.i=Math.min(i.i,o.i),i.merged=!0}return ou}var iu,Jg;function UC(){if(Jg)return iu;Jg=1;var e=We(),t=pr();iu=r;function r(i,a){var s=t.partition(i,function(g){return e.has(g,"barycenter")}),u=s.lhs,c=e.sortBy(s.rhs,function(g){return-g.i}),l=[],d=0,f=0,p=0;u.sort(o(!!a)),p=n(l,c,p),e.forEach(u,function(g){p+=g.vs.length,l.push(g.vs),d+=g.barycenter*g.weight,f+=g.weight,p=n(l,c,p)});var b={vs:e.flatten(l,!0)};return f&&(b.barycenter=d/f,b.weight=f),b}function n(i,a,s){for(var u;a.length&&(u=e.last(a)).i<=s;)a.pop(),i.push(u.vs),s++;return s}function o(i){return function(a,s){return a.barycenter<s.barycenter?-1:a.barycenter>s.barycenter?1:i?s.i-a.i:a.i-s.i}}return iu}var au,Zg;function HC(){if(Zg)return au;Zg=1;var e=We(),t=WC(),r=GC(),n=UC();au=o;function o(s,u,c,l){var d=s.children(u),f=s.node(u),p=f?f.borderLeft:void 0,b=f?f.borderRight:void 0,g={};p&&(d=e.filter(d,function(C){return C!==p&&C!==b}));var m=t(s,d);e.forEach(m,function(C){if(s.children(C.v).length){var _=o(s,C.v,c,l);g[C.v]=_,e.has(_,"barycenter")&&a(C,_)}});var w=r(m,c);i(w,g);var y=n(w,l);if(p&&(y.vs=e.flatten([p,y.vs,b],!0),s.predecessors(p).length)){var x=s.node(s.predecessors(p)[0]),v=s.node(s.predecessors(b)[0]);e.has(y,"barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+x.order+v.order)/(y.weight+2),y.weight+=2}return y}function i(s,u){e.forEach(s,function(c){c.vs=e.flatten(c.vs.map(function(l){return u[l]?u[l].vs:l}),!0)})}function a(s,u){e.isUndefined(s.barycenter)?(s.barycenter=u.barycenter,s.weight=u.weight):(s.barycenter=(s.barycenter*s.weight+u.barycenter*u.weight)/(s.weight+u.weight),s.weight+=u.weight)}return au}var su,Yg;function KC(){if(Yg)return su;Yg=1;var e=We(),t=_r().Graph;su=r;function r(o,i,a){var s=n(o),u=new t({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(function(c){return o.node(c)});return e.forEach(o.nodes(),function(c){var l=o.node(c),d=o.parent(c);(l.rank===i||l.minRank<=i&&i<=l.maxRank)&&(u.setNode(c),u.setParent(c,d||s),e.forEach(o[a](c),function(f){var p=f.v===c?f.w:f.v,b=u.edge(p,c),g=e.isUndefined(b)?0:b.weight;u.setEdge(p,c,{weight:o.edge(f).weight+g})}),e.has(l,"minRank")&&u.setNode(c,{borderLeft:l.borderLeft[i],borderRight:l.borderRight[i]}))}),u}function n(o){for(var i;o.hasNode(i=e.uniqueId("_root")););return i}return su}var cu,Xg;function JC(){if(Xg)return cu;Xg=1;var e=We();cu=t;function t(r,n,o){var i={},a;e.forEach(o,function(s){for(var u=r.parent(s),c,l;u;){if(c=r.parent(u),c?(l=i[c],i[c]=u):(l=a,a=u),l&&l!==u){n.setEdge(l,u);return}u=c}})}return cu}var uu,Qg;function ZC(){if(Qg)return uu;Qg=1;var e=We(),t=zC(),r=VC(),n=HC(),o=KC(),i=JC(),a=_r().Graph,s=pr();uu=u;function u(f){var p=s.maxRank(f),b=c(f,e.range(1,p+1),"inEdges"),g=c(f,e.range(p-1,-1,-1),"outEdges"),m=t(f);d(f,m);for(var w=Number.POSITIVE_INFINITY,y,x=0,v=0;v<4;++x,++v){l(x%2?b:g,x%4>=2),m=s.buildLayerMatrix(f);var C=r(f,m);C<w&&(v=0,y=e.cloneDeep(m),w=C)}d(f,y)}function c(f,p,b){return e.map(p,function(g){return o(f,g,b)})}function l(f,p){var b=new a;e.forEach(f,function(g){var m=g.graph().root,w=n(g,m,b,p);e.forEach(w.vs,function(y,x){g.node(y).order=x}),i(g,b,w.vs)})}function d(f,p){e.forEach(p,function(b){e.forEach(b,function(g,m){f.node(g).order=m})})}return uu}var lu,ey;function YC(){if(ey)return lu;ey=1;var e=We(),t=_r().Graph,r=pr();lu={positionX:b,findType1Conflicts:n,findType2Conflicts:o,addConflict:a,hasConflict:s,verticalAlignment:u,horizontalCompaction:c,alignCoordinates:f,findSmallestWidthAlignment:d,balance:p};function n(w,y){var x={};function v(C,_){var k=0,T=0,P=C.length,j=e.last(_);return e.forEach(_,function(R,E){var M=i(w,R),I=M?w.node(M).order:P;(M||R===j)&&(e.forEach(_.slice(T,E+1),function(N){e.forEach(w.predecessors(N),function(O){var W=w.node(O),z=W.order;(z<k||I<z)&&!(W.dummy&&w.node(N).dummy)&&a(x,O,N)})}),T=E+1,k=I)}),_}return e.reduce(y,v),x}function o(w,y){var x={};function v(_,k,T,P,j){var R;e.forEach(e.range(k,T),function(E){R=_[E],w.node(R).dummy&&e.forEach(w.predecessors(R),function(M){var I=w.node(M);I.dummy&&(I.order<P||I.order>j)&&a(x,M,R)})})}function C(_,k){var T=-1,P,j=0;return e.forEach(k,function(R,E){if(w.node(R).dummy==="border"){var M=w.predecessors(R);M.length&&(P=w.node(M[0]).order,v(k,j,E,T,P),j=E,T=P)}v(k,j,k.length,P,_.length)}),k}return e.reduce(y,C),x}function i(w,y){if(w.node(y).dummy)return e.find(w.predecessors(y),function(x){return w.node(x).dummy})}function a(w,y,x){if(y>x){var v=y;y=x,x=v}var C=w[y];C||(w[y]=C={}),C[x]=!0}function s(w,y,x){if(y>x){var v=y;y=x,x=v}return e.has(w[y],x)}function u(w,y,x,v){var C={},_={},k={};return e.forEach(y,function(T){e.forEach(T,function(P,j){C[P]=P,_[P]=P,k[P]=j})}),e.forEach(y,function(T){var P=-1;e.forEach(T,function(j){var R=v(j);if(R.length){R=e.sortBy(R,function(O){return k[O]});for(var E=(R.length-1)/2,M=Math.floor(E),I=Math.ceil(E);M<=I;++M){var N=R[M];_[j]===j&&P<k[N]&&!s(x,j,N)&&(_[N]=j,_[j]=C[j]=C[N],P=k[N])}}})}),{root:C,align:_}}function c(w,y,x,v,C){var _={},k=l(w,y,x,C),T=C?"borderLeft":"borderRight";function P(E,M){for(var I=k.nodes(),N=I.pop(),O={};N;)O[N]?E(N):(O[N]=!0,I.push(N),I=I.concat(M(N))),N=I.pop()}function j(E){_[E]=k.inEdges(E).reduce(function(M,I){return Math.max(M,_[I.v]+k.edge(I))},0)}function R(E){var M=k.outEdges(E).reduce(function(N,O){return Math.min(N,_[O.w]-k.edge(O))},Number.POSITIVE_INFINITY),I=w.node(E);M!==Number.POSITIVE_INFINITY&&I.borderType!==T&&(_[E]=Math.max(_[E],M))}return P(j,k.predecessors.bind(k)),P(R,k.successors.bind(k)),e.forEach(v,function(E){_[E]=_[x[E]]}),_}function l(w,y,x,v){var C=new t,_=w.graph(),k=g(_.nodesep,_.edgesep,v);return e.forEach(y,function(T){var P;e.forEach(T,function(j){var R=x[j];if(C.setNode(R),P){var E=x[P],M=C.edge(E,R);C.setEdge(E,R,Math.max(k(w,j,P),M||0))}P=j})}),C}function d(w,y){return e.minBy(e.values(y),function(x){var v=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;return e.forIn(x,function(_,k){var T=m(w,k)/2;v=Math.max(_+T,v),C=Math.min(_-T,C)}),v-C})}function f(w,y){var x=e.values(y),v=e.min(x),C=e.max(x);e.forEach(["u","d"],function(_){e.forEach(["l","r"],function(k){var T=_+k,P=w[T],j;if(P!==y){var R=e.values(P);j=k==="l"?v-e.min(R):C-e.max(R),j&&(w[T]=e.mapValues(P,function(E){return E+j}))}})})}function p(w,y){return e.mapValues(w.ul,function(x,v){if(y)return w[y.toLowerCase()][v];var C=e.sortBy(e.map(w,v));return(C[1]+C[2])/2})}function b(w){var y=r.buildLayerMatrix(w),x=e.merge(n(w,y),o(w,y)),v={},C;e.forEach(["u","d"],function(k){C=k==="u"?y:e.values(y).reverse(),e.forEach(["l","r"],function(T){T==="r"&&(C=e.map(C,function(E){return e.values(E).reverse()}));var P=(k==="u"?w.predecessors:w.successors).bind(w),j=u(w,C,x,P),R=c(w,C,j.root,j.align,T==="r");T==="r"&&(R=e.mapValues(R,function(E){return-E})),v[k+T]=R})});var _=d(w,v);return f(v,_),p(v,w.graph().align)}function g(w,y,x){return function(v,C,_){var k=v.node(C),T=v.node(_),P=0,j;if(P+=k.width/2,e.has(k,"labelpos"))switch(k.labelpos.toLowerCase()){case"l":j=-k.width/2;break;case"r":j=k.width/2;break}if(j&&(P+=x?j:-j),j=0,P+=(k.dummy?y:w)/2,P+=(T.dummy?y:w)/2,P+=T.width/2,e.has(T,"labelpos"))switch(T.labelpos.toLowerCase()){case"l":j=T.width/2;break;case"r":j=-T.width/2;break}return j&&(P+=x?j:-j),j=0,P}}function m(w,y){return w.node(y).width}return lu}var du,ry;function XC(){if(ry)return du;ry=1;var e=We(),t=pr(),r=YC().positionX;du=n;function n(i){i=t.asNonCompoundGraph(i),o(i),e.forEach(r(i),function(a,s){i.node(s).x=a})}function o(i){var a=t.buildLayerMatrix(i),s=i.graph().ranksep,u=0;e.forEach(a,function(c){var l=e.max(e.map(c,function(d){return i.node(d).height}));e.forEach(c,function(d){i.node(d).y=u+l/2}),u+=l+s})}return du}var fu,ty;function QC(){if(ty)return fu;ty=1;var e=We(),t=MC(),r=qC(),n=$C(),o=pr().normalizeRanks,i=LC(),a=pr().removeEmptyRanks,s=FC(),u=BC(),c=DC(),l=ZC(),d=XC(),f=pr(),p=_r().Graph;fu=b;function b(q,L){var G=L&&L.debugTiming?f.time:f.notime;G("layout",function(){var B=G(" buildLayoutGraph",function(){return P(q)});G(" runLayout",function(){g(B,G)}),G(" updateInputGraph",function(){m(q,B)})})}function g(q,L){L(" makeSpaceForEdgeLabels",function(){j(q)}),L(" removeSelfEdges",function(){re(q)}),L(" acyclic",function(){t.run(q)}),L(" nestingGraph.run",function(){s.run(q)}),L(" rank",function(){n(f.asNonCompoundGraph(q))}),L(" injectEdgeLabelProxies",function(){R(q)}),L(" removeEmptyRanks",function(){a(q)}),L(" nestingGraph.cleanup",function(){s.cleanup(q)}),L(" normalizeRanks",function(){o(q)}),L(" assignRankMinMax",function(){E(q)}),L(" removeEdgeLabelProxies",function(){M(q)}),L(" normalize.run",function(){r.run(q)}),L(" parentDummyChains",function(){i(q)}),L(" addBorderSegments",function(){u(q)}),L(" order",function(){l(q)}),L(" insertSelfEdges",function(){te(q)}),L(" adjustCoordinateSystem",function(){c.adjust(q)}),L(" position",function(){d(q)}),L(" positionSelfEdges",function(){he(q)}),L(" removeBorderNodes",function(){z(q)}),L(" normalize.undo",function(){r.undo(q)}),L(" fixupEdgeLabelCoords",function(){O(q)}),L(" undoCoordinateSystem",function(){c.undo(q)}),L(" translateGraph",function(){I(q)}),L(" assignNodeIntersects",function(){N(q)}),L(" reversePoints",function(){W(q)}),L(" acyclic.undo",function(){t.undo(q)})}function m(q,L){e.forEach(q.nodes(),function(G){var B=q.node(G),Y=L.node(G);B&&(B.x=Y.x,B.y=Y.y,L.children(G).length&&(B.width=Y.width,B.height=Y.height))}),e.forEach(q.edges(),function(G){var B=q.edge(G),Y=L.edge(G);B.points=Y.points,e.has(Y,"x")&&(B.x=Y.x,B.y=Y.y)}),q.graph().width=L.graph().width,q.graph().height=L.graph().height}var w=["nodesep","edgesep","ranksep","marginx","marginy"],y={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},x=["acyclicer","ranker","rankdir","align"],v=["width","height"],C={width:0,height:0},_=["minlen","weight","width","height","labeloffset"],k={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},T=["labelpos"];function P(q){var L=new p({multigraph:!0,compound:!0}),G=K(q.graph());return L.setGraph(e.merge({},y,be(G,w),e.pick(G,x))),e.forEach(q.nodes(),function(B){var Y=K(q.node(B));L.setNode(B,e.defaults(be(Y,v),C)),L.setParent(B,q.parent(B))}),e.forEach(q.edges(),function(B){var Y=K(q.edge(B));L.setEdge(B,e.merge({},k,be(Y,_),e.pick(Y,T)))}),L}function j(q){var L=q.graph();L.ranksep/=2,e.forEach(q.edges(),function(G){var B=q.edge(G);B.minlen*=2,B.labelpos.toLowerCase()!=="c"&&(L.rankdir==="TB"||L.rankdir==="BT"?B.width+=B.labeloffset:B.height+=B.labeloffset)})}function R(q){e.forEach(q.edges(),function(L){var G=q.edge(L);if(G.width&&G.height){var B=q.node(L.v),Y=q.node(L.w),ce={rank:(Y.rank-B.rank)/2+B.rank,e:L};f.addDummyNode(q,"edge-proxy",ce,"_ep")}})}function E(q){var L=0;e.forEach(q.nodes(),function(G){var B=q.node(G);B.borderTop&&(B.minRank=q.node(B.borderTop).rank,B.maxRank=q.node(B.borderBottom).rank,L=e.max(L,B.maxRank))}),q.graph().maxRank=L}function M(q){e.forEach(q.nodes(),function(L){var G=q.node(L);G.dummy==="edge-proxy"&&(q.edge(G.e).labelRank=G.rank,q.removeNode(L))})}function I(q){var L=Number.POSITIVE_INFINITY,G=0,B=Number.POSITIVE_INFINITY,Y=0,ce=q.graph(),X=ce.marginx||0,U=ce.marginy||0;function Z(ae){var ue=ae.x,de=ae.y,Ee=ae.width,ge=ae.height;L=Math.min(L,ue-Ee/2),G=Math.max(G,ue+Ee/2),B=Math.min(B,de-ge/2),Y=Math.max(Y,de+ge/2)}e.forEach(q.nodes(),function(ae){Z(q.node(ae))}),e.forEach(q.edges(),function(ae){var ue=q.edge(ae);e.has(ue,"x")&&Z(ue)}),L-=X,B-=U,e.forEach(q.nodes(),function(ae){var ue=q.node(ae);ue.x-=L,ue.y-=B}),e.forEach(q.edges(),function(ae){var ue=q.edge(ae);e.forEach(ue.points,function(de){de.x-=L,de.y-=B}),e.has(ue,"x")&&(ue.x-=L),e.has(ue,"y")&&(ue.y-=B)}),ce.width=G-L+X,ce.height=Y-B+U}function N(q){e.forEach(q.edges(),function(L){var G=q.edge(L),B=q.node(L.v),Y=q.node(L.w),ce,X;G.points?(ce=G.points[0],X=G.points[G.points.length-1]):(G.points=[],ce=Y,X=B),G.points.unshift(f.intersectRect(B,ce)),G.points.push(f.intersectRect(Y,X))})}function O(q){e.forEach(q.edges(),function(L){var G=q.edge(L);if(e.has(G,"x"))switch((G.labelpos==="l"||G.labelpos==="r")&&(G.width-=G.labeloffset),G.labelpos){case"l":G.x-=G.width/2+G.labeloffset;break;case"r":G.x+=G.width/2+G.labeloffset;break}})}function W(q){e.forEach(q.edges(),function(L){var G=q.edge(L);G.reversed&&G.points.reverse()})}function z(q){e.forEach(q.nodes(),function(L){if(q.children(L).length){var G=q.node(L),B=q.node(G.borderTop),Y=q.node(G.borderBottom),ce=q.node(e.last(G.borderLeft)),X=q.node(e.last(G.borderRight));G.width=Math.abs(X.x-ce.x),G.height=Math.abs(Y.y-B.y),G.x=ce.x+G.width/2,G.y=B.y+G.height/2}}),e.forEach(q.nodes(),function(L){q.node(L).dummy==="border"&&q.removeNode(L)})}function re(q){e.forEach(q.edges(),function(L){if(L.v===L.w){var G=q.node(L.v);G.selfEdges||(G.selfEdges=[]),G.selfEdges.push({e:L,label:q.edge(L)}),q.removeEdge(L)}})}function te(q){var L=f.buildLayerMatrix(q);e.forEach(L,function(G){var B=0;e.forEach(G,function(Y,ce){var X=q.node(Y);X.order=ce+B,e.forEach(X.selfEdges,function(U){f.addDummyNode(q,"selfedge",{width:U.label.width,height:U.label.height,rank:X.rank,order:ce+ ++B,e:U.e,label:U.label},"_se")}),delete X.selfEdges})})}function he(q){e.forEach(q.nodes(),function(L){var G=q.node(L);if(G.dummy==="selfedge"){var B=q.node(G.e.v),Y=B.x+B.width/2,ce=B.y,X=G.x-Y,U=B.height/2;q.setEdge(G.e,G.label),q.removeNode(L),G.label.points=[{x:Y+2*X/3,y:ce-U},{x:Y+5*X/6,y:ce-U},{x:Y+X,y:ce},{x:Y+5*X/6,y:ce+U},{x:Y+2*X/3,y:ce+U}],G.label.x=G.x,G.label.y=G.y}})}function be(q,L){return e.mapValues(e.pick(q,L),Number)}function K(q){var L={};return e.forEach(q,function(G,B){L[B.toLowerCase()]=G}),L}return fu}var hu,ny;function e_(){if(ny)return hu;ny=1;var e=We(),t=pr(),r=_r().Graph;hu={debugOrdering:n};function n(o){var i=t.buildLayerMatrix(o),a=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(s){a.setNode(s,{label:s}),a.setParent(s,"layer"+o.node(s).rank)}),e.forEach(o.edges(),function(s){a.setEdge(s.v,s.w,{},s.name)}),e.forEach(i,function(s,u){var c="layer"+u;a.setNode(c,{rank:"same"}),e.reduce(s,function(l,d){return a.setEdge(l,d,{style:"invis"}),d})}),a}return hu}var pu,oy;function r_(){return oy||(oy=1,pu="0.8.5"),pu}var gu,iy;function t_(){return iy||(iy=1,gu={graphlib:_r(),layout:QC(),debug:e_(),util:{time:pr().time,notime:pr().notime},version:r_()}),gu}var n_=t_();const ay=D0(n_);function o_(e,t,r){var l;const n=new Set(e.map(d=>d.id)),o=new Set;for(const d of e)d.parent&&n.has(d.parent)&&o.add(d.parent);const i=new ay.graphlib.Graph({multigraph:!0,compound:!0}),a=r.compactSpacingScale??(r.spacingFactor>0?r.spacingFactor/1.3:1);i.setGraph({rankdir:r.rankDir,nodesep:r.compact?Math.max(r.nodeSep,24*a):r.nodeSep,edgesep:r.compact?Math.min(r.edgeSep,24*a):r.edgeSep,ranksep:r.compact?Math.min(r.rankSep,80*a):r.rankSep,ranker:"network-simplex"}),i.setDefaultEdgeLabel(()=>({})),i.setDefaultNodeLabel(()=>({}));for(const d of e)i.setNode(d.id,{width:d.width+2,height:d.height+2});for(const d of e)d.parent&&n.has(d.parent)&&i.setParent(d.id,d.parent);for(const d of t){if(!n.has(d.source)||!n.has(d.target)||o.has(d.source)||o.has(d.target))continue;const f=Ab(d.label,d.icon??((l=d.data)==null?void 0:l.icon),r.edgeLabelFontSize),p=r.rankDir==="LR"||r.rankDir==="RL",b=(f.width?f.width+2*Pb:0)+(d.connectorClearance??0);i.setEdge(d.source,d.target,{minlen:1,weight:1,...b?{width:p?b:Math.max(1,f.height),height:p?Math.max(1,f.height):b,labelpos:"c"}:{}},d.id)}ay.layout(i);const s=new Map;for(const d of e){if(o.has(d.id))continue;const f=i.node(d.id);f&&Number.isFinite(f.x)&&Number.isFinite(f.y)&&s.set(d.id,{x:f.x,y:f.y})}const u=r.compact?1:r.spacingFactor;if(u&&u!==1&&s.size){let d=1/0,f=1/0,p=-1/0,b=-1/0;s.forEach(w=>{d=Math.min(d,w.x),f=Math.min(f,w.y),p=Math.max(p,w.x),b=Math.max(b,w.y)});const g=(d+p)/2,m=(f+b)/2;s.forEach((w,y)=>s.set(y,{x:g+(w.x-g)*u,y:m+(w.y-m)*u}))}const c=r.nodeAlignment??"center";if(c!=="center"){const d=r.rankDir==="LR"||r.rankDir==="RL",f=d?"x":"y",p=d?"width":"height",b=r.rankDir==="RL"||r.rankDir==="BT"?-1:1,g=c==="leading"?-b:b,m=new Map;for(const w of e){const y=s.get(w.id);if(!y)continue;const x=y[f];m.set(x,Math.max(m.get(x)??0,w[p]))}for(const w of e){const y=s.get(w.id);if(!y)continue;const x=y[f],v=(m.get(x)-w[p])/2;s.set(w.id,{...y,[f]:x+g*v})}}return s}function i_(e,t,r,n,o){const i=new Map,a=new Map(e.map(l=>[l.id,l]));for(const l of e){if(!l.parent||!a.has(l.parent))continue;const d=i.get(l.parent);d?d.push(l.id):i.set(l.parent,[l.id])}const s=(l,d=new Set)=>{var p;const f=(p=a.get(l))==null?void 0:p.parent;return!f||!a.has(f)||d.has(l)?0:(d.add(l),1+s(f,d))},u=[...i.keys()].sort((l,d)=>s(d)-s(l)),c=new Map;for(const l of u){let d=null;for(const b of i.get(l)||[]){let g=c.get(b);if(!g){const m=t.get(b);if(!m)continue;const w=r.get(b)||{w:60,h:60};g={x1:m.x-w.w/2,y1:m.y-w.h/2,x2:m.x+w.w/2,y2:m.y+w.h/2}}d=d?{x1:Math.min(d.x1,g.x1),y1:Math.min(d.y1,g.y1),x2:Math.max(d.x2,g.x2),y2:Math.max(d.y2,g.y2)}:{...g}}if(!d)continue;const f=n(l);d={x1:d.x1-f,y1:d.y1-f,x2:d.x2+f,y2:d.y2+f};const p=o(l);if(p){const b=d.x2-d.x1,g=d.y2-d.y1;if(p.w>b){const m=(p.w-b)/2;d.x1-=m,d.x2+=m}if(p.h>g){const m=(p.h-g)/2;d.y1-=m,d.y2+=m}}c.set(l,d)}return c}function a_(e){const t=e.getBoundingClientRect(),r=t.height/e.offsetHeight;if(!Number.isFinite(r)||r<=0)return[];const n=Rb(e),o={x:e.offsetWidth/2,y:e.offsetHeight/2,w:e.offsetWidth,h:e.offsetHeight},i=[...e.querySelectorAll("[data-flow-property]")],a=new Set(i.filter(s=>s.hasAttribute("data-flow-inspection-row")&&s.getBoundingClientRect().height>0).map(s=>s.dataset.flowProperty));return i.flatMap(s=>{if(s.closest(".flow-sdk-node")!==e)return[];if(a.has(s.dataset.flowProperty)&&!s.hasAttribute("data-flow-inspection-row"))return[];const u=s.dataset.flowPortSide;if(u&&["top","right","bottom","left"].includes(u)){const l=Sb(n?Ft(o,n):o,u,Number(s.dataset.flowPortPosition??.5));return[{property:s.getAttribute("data-flow-property"),top:l.y,height:0,anchor:l,...s.dataset.flowPortPlacement==="config"?{placement:"config"}:{},...s.dataset.flowPortRole==="source"||s.dataset.flowPortRole==="target"?{role:s.dataset.flowPortRole}:{}}]}const c=s.getBoundingClientRect();return!c.width||!c.height?[]:[{property:s.getAttribute("data-flow-property"),top:Math.round((c.top-t.top)/r*1e3)/1e3,height:Math.round(c.height/r*1e3)/1e3,...s.dataset.flowPortRole==="source"||s.dataset.flowPortRole==="target"?{role:s.dataset.flowPortRole}:{}}]})}function s_({id:e,x:t,y:r,placed:n,hidden:o,onMount:i,drawHandles:a,drawMode:s,connectedPorts:u,resolvedRows:c,hasCollapseControl:l,handleColor:d,animated:f,animationColor:p,animationWidth:b=8,animationVariant:g,width:m=0,height:w=0,propertyMode:y,reversePorts:x,direction:v="LR",onPropertyRows:C,onSurface:_,children:k}){const T=S.useRef(null),[P,j]=S.useState([]),R=c??P,[E,M]=S.useState();return S.useLayoutEffect(()=>{const I=T.current;if(!I)return;const N=()=>{const z=Rb(I);M(re=>JSON.stringify(re)===JSON.stringify(z)?re:z),_==null||_(e,z)};N();const O=new ResizeObserver(N);O.observe(I);const W=I.querySelector("[data-flow-node-surface]");return W&&O.observe(W),()=>O.disconnect()},[e,k,_]),S.useLayoutEffect(()=>(i(e,T.current),()=>{i(e,null),_==null||_(e,void 0)}),[e,i,_]),S.useLayoutEffect(()=>{const I=T.current;if(!I)return;let N="";const O=()=>{const te=a_(I),he=y?te:te.filter(K=>K.anchor),be=JSON.stringify(he);be!==N&&(N=be,j(he),C==null||C(e,he))};if(O(),!y&&!I.querySelector("[data-flow-port-side]"))return;const W=new ResizeObserver(O),z=()=>{W.disconnect(),W.observe(I),I.querySelectorAll("[data-flow-property]").forEach(te=>W.observe(te)),O()};z();const re=new MutationObserver(z);return re.observe(I,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["data-flow-property","data-flow-port-role","data-flow-port-side","data-flow-port-position","data-flow-port-placement"]}),I.addEventListener("scroll",O,!0),()=>{W.disconnect(),re.disconnect(),I.removeEventListener("scroll",O,!0)}},[e,y,C,k]),h.jsxs("div",{ref:T,className:"flow-sdk-node","data-node-id":e,style:{transform:`translate(-50%, -50%) translate3d(${t.toFixed(2)}px, ${r.toFixed(2)}px, 0)`,visibility:n&&!o?void 0:"hidden"},children:[k,f&&b>0&&m>0&&w>0&&h.jsx("svg",{className:"flow-sdk-node-animation","aria-hidden":"true",pointerEvents:"none",children:h.jsx(_b,{variant:g,x:((E==null?void 0:E.left)??0)+b/2,y:((E==null?void 0:E.top)??0)+b/2,width:((E==null?void 0:E.width)??m)-b,height:((E==null?void 0:E.height)??w)-b,radius:((E==null?void 0:E.radius)??0)-b/2,path:E!=null&&E.outline?`M${E.outline.map(I=>`${I.x} ${I.y}`).join(" L")} Z`:void 0,color:p||d||"currentColor",strokeWidth:b})}),a&&y&&R.map(I=>["source","target"].filter(N=>!I.role||I.role===N).filter(N=>s||(u==null?void 0:u.has(`${N}:${I.property}`))).map(N=>{var O;return h.jsx("button",{type:"button",className:"flow-sdk-property-port","data-property":I.property,"data-port-role":N,"data-port-side":(O=I.anchor)==null?void 0:O.side,"aria-label":`${N==="source"?"Connect":"Input"} ${I.property}`,title:`${N==="source"?"Connect":"Input"} ${I.property}`,style:{color:d,...I.anchor?{top:I.anchor.y,left:I.anchor.x-16}:{top:I.top+I.height/2,[N==="source"!=!!x?"right":"left"]:-16}},onClick:W=>W.stopPropagation()},`${I.property}:${N}`)})),a&&!l&&(!y||!R.length)&&(!y||!R.some(I=>I.anchor))&&h.jsx("button",{type:"button",className:"flow-sdk-handle","aria-label":"Draw edge",title:"Draw edge",style:{color:d,left:((E==null?void 0:E.left)??0)+(v==="RL"?-36:v==="LR"?(E==null?void 0:E.width)??m:((E==null?void 0:E.width)??m)/2),top:((E==null?void 0:E.top)??0)+(v==="BT"?-36:v==="TB"?(E==null?void 0:E.height)??w:((E==null?void 0:E.height)??w)/2),transform:v==="BT"||v==="TB"?"translateX(-50%)":"translateY(-50%)"},onClick:I=>I.stopPropagation(),children:h.jsx(J.PiPlusBold,{size:24})})]})}const c_=S.memo(s_);class u_{constructor(t,r,n){Tr(this,"_pan");Tr(this,"_zoom");Tr(this,"minZoom");Tr(this,"maxZoom");Tr(this,"size",{w:0,h:0});Tr(this,"listeners",new Set);Tr(this,"animationFrame");Tr(this,"animationTimer");this.minZoom=r,this.maxZoom=n,this._pan={...t.pan},this._zoom=this.clamp(t.zoom)}cancelAnimation(){this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame),clearTimeout(this.animationTimer),this.animationFrame=void 0,this.animationTimer=void 0}transition(t,r=!1){if(this.cancelAnimation(),!r||typeof requestAnimationFrame>"u"||typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches){this.set(t.pan,t.zoom);return}const n=this.state,o={pan:{...t.pan},zoom:this.clamp(t.zoom)},i=performance.now(),a=()=>{this.cancelAnimation(),this.set(o.pan,o.zoom)},s=u=>{const c=Math.min(1,(u-i)/300);if(c>=1){a();return}const l=c*c*(3-2*c);this.apply({x:n.pan.x+(o.pan.x-n.pan.x)*l,y:n.pan.y+(o.pan.y-n.pan.y)*l},n.zoom+(o.zoom-n.zoom)*l),this.animationFrame=requestAnimationFrame(s)};this.animationFrame=requestAnimationFrame(s),this.animationTimer=setTimeout(a,400)}get pan(){return{...this._pan}}get zoom(){return this._zoom}get state(){return{pan:this.pan,zoom:this._zoom}}clamp(t){return Number.isFinite(t)?Math.max(this.minZoom,Math.min(this.maxZoom,t)):this.minZoom}set(t,r){this.cancelAnimation(),this.apply(t,r)}apply(t,r){let n=!1;if(t&&(t.x!==this._pan.x||t.y!==this._pan.y)&&(this._pan={x:t.x,y:t.y},n=!0),r!==void 0){const o=this.clamp(r);o!==this._zoom&&(this._zoom=o,n=!0)}n&&this.emit()}zoomAt(t,r){const n=this.clamp(t),o=this._zoom;if(n===o)return;const i=n/o;this.set({x:r.x-(r.x-this._pan.x)*i,y:r.y-(r.y-this._pan.y)*i},n)}fit(t,r=0,n=!1){const o=t.x2-t.x1,i=t.y2-t.y1;if(!(o>0)||!(i>0)||!this.size.w||!this.size.h)return;const a=this.clamp(Math.min((this.size.w-2*r)/o,(this.size.h-2*r)/i));this.transition({pan:{x:(this.size.w-a*(t.x1+t.x2))/2,y:(this.size.h-a*(t.y1+t.y2))/2},zoom:a},n)}center(t,r=!1){if(!this.size.w||!this.size.h)return;const n=this._zoom;this.transition({pan:{x:(this.size.w-n*(t.x1+t.x2))/2,y:(this.size.h-n*(t.y1+t.y2))/2},zoom:n},r)}renderedToModel(t){return{x:(t.x-this._pan.x)/this._zoom,y:(t.y-this._pan.y)/this._zoom}}modelToRendered(t){return{x:t.x*this._zoom+this._pan.x,y:t.y*this._zoom+this._pan.y}}onChange(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}emit(){const t=this.state;this.listeners.forEach(r=>r(t))}}const l_={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},yu={w:60,h:60},sy=4,d_=30,cy=300,f_=500,h_=45,p_=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2;function uy(e){const[t,r]=[...e.values()];return!t||!r?null:{center:{x:(t.x+r.x)/2,y:(t.y+r.y)/2},distance:Math.max(1,Math.hypot(r.x-t.x,r.y-t.y))}}function g_(e){const{nodes:t,edges:r,direction:n,nodeAlignment:o="center",edgeMode:i="auto",compactPropertyLayout:a=!1,rankSep:s,edgeSep:u,spacingFactor:c=1.3,compactSpacingScale:l,minZoom:d,maxZoom:f,initialViewport:p,containerStyle:b,lineColor:g,drawMode:m,dragMode:w,multiSelect:y,isPerformanceMode:x}=e,[v,C]=S.useState(null),_=S.useMemo(()=>v?(v.mode==="connections"?Nl:Al)(v.id,t,r):null,[v,t,r]),k=i==="auto"||i==="properties",T=S.useMemo(()=>r.filter(A=>Cu(A,i)&&(!_||_.has(A.source)&&_.has(A.target))),[r,i,_]),P=S.useMemo(()=>q0(t,r,i,a,_),[t,r,i,a,_]),j=S.useRef(P);j.current=P;const R=S.useRef(e);R.current=e;const E=S.useRef(null),M=S.useRef(null),I=S.useRef(null),N=S.useRef(null),O=S.useMemo(()=>new u_(p,d,f),[]);S.useEffect(()=>{O.minZoom=d,O.maxZoom=f},[O,d,f]);const W=S.useRef(new Map),z=S.useRef(new Map),re=S.useRef(new Map),te=S.useRef(null),[he,be]=S.useState(new Map),K=S.useCallback((A,$)=>{be(F=>{if(JSON.stringify(F.get(A))===JSON.stringify($))return F;const H=new Map(F);return $?H.set(A,$):H.delete(A),H})},[]),[q,L]=S.useState(new Map),G=S.useRef(q),B=S.useCallback((A,$)=>{L(F=>{if(JSON.stringify(F.get(A)??[])===JSON.stringify($))return F;const H=new Map(F);return $.length?H.set(A,$):H.delete(A),H})},[]),[Y,ce]=S.useState(()=>new Map),X=S.useRef(Y);X.current=Y;const U=S.useRef(new Map),Z=S.useRef(!1),[ae,ue]=S.useState(0),de=S.useRef(),Ee=S.useRef(),ge=S.useRef(null),He=S.useRef(),Le=S.useRef(!1),Xe=S.useRef(null),ur=S.useRef(c),Ge=a,Ne=S.useRef(Ge),[xe,Ie]=S.useState(!0),$e=S.useRef(null);$e.current=_;const tr=S.useRef(1);tr.current=(v==null?void 0:v.mode)==="connections"?1.25:1;const Je=S.useRef(null),Ze=S.useRef(t),fr=S.useRef([]),wr=S.useRef(!1),Ce=()=>{ge.current!==null&&cancelAnimationFrame(ge.current),ge.current=null,clearTimeout(He.current)},ir=()=>{fr.current.length&&(wr.current=!0),!Z.current&&R.current.fitOnInit!==!1&&(Le.current=!0),clearTimeout(Ee.current),Ee.current=setTimeout(()=>{Z.current=!0,ue(A=>A+1)},f_)},ar=A=>{Ce();const $=new Map(X.current),F=performance.now(),H=()=>{Ce(),ce(A),ir()},oe=pe=>{const Re=Math.min(1,(pe-F)/cy);if(Re>=1)return H();const Te=p_(Re),ie=new Map;A.forEach((se,le)=>{const ye=$.get(le);ie.set(le,ye?{x:ye.x+(se.x-ye.x)*Te,y:ye.y+(se.y-ye.y)*Te}:se)}),ce(ie),ge.current=requestAnimationFrame(oe)};ge.current=requestAnimationFrame(oe),He.current=setTimeout(H,cy+100)},Ct=()=>{const A=R.current,$=tr.current,F=j.current,H=F.nodes.map(pe=>{const Re=W.current.get(pe.id)||yu;return{id:pe.id,parent:pe.parent,width:Re.w,height:Re.h}});let oe;try{const pe=A.compactPropertyLayout,Re=A.edgeMode!=="nodes"&&A.edgeMode!=="workflow",Te=F.edges.map(ie=>({...ie,connectorClearance:pe?Re&&(ie.sourceProperty!==void 0||ie.targetProperty!==void 0)?M0:I0:0}));oe=o_(H,Te,{edgeLabelFontSize:A.edgeMode==="nodes"||A.edgeMode==="workflow"?kb:pn,rankDir:A.direction,compact:pe,nodeAlignment:A.nodeAlignment,rankSep:A.rankSep*$,edgeSep:A.edgeSep*$,nodeSep:5*$,spacingFactor:A.spacingFactor??1.3,compactSpacingScale:(A.compactSpacingScale??(A.spacingFactor??1.3)/1.3)*$})}catch(pe){console.warn("[flow-sdk] layout failed",pe);return}for(const[pe,Re]of U.current)oe.has(pe)?oe.set(pe,Re):A.nodes.some(Te=>Te.id===pe)||U.current.delete(pe);Z.current&&!A.isPerformanceMode?ar(oe):(Ce(),ce(oe),ir())},ne=S.useCallback(()=>{clearTimeout(Ee.current),clearTimeout(de.current),de.current=setTimeout(Ct,R.current.layoutDebounce)},[]);S.useEffect(()=>{const A=new Map(Ze.current.map($=>[$.id,$]));t.some($=>{var F;return((F=A.get($.id))==null?void 0:F.collapsed)===!0&&!$.collapsed})&&(fr.current=t.filter($=>!A.has($.id)).map($=>$.id)),Ze.current=t,ur.current!==c&&X.current.size>0&&(Z.current=!0,Le.current=!1,clearTimeout(Ee.current)),ur.current=c,Ne.current!==Ge&&(Le.current=!Xe.current),Ne.current=Ge,ne()},[t,r,P.nodes,P.edges,Ge,n,o,s,u,ne,c,l]),S.useEffect(()=>()=>{clearTimeout(de.current),clearTimeout(Ee.current),Ce()},[]);const ze=S.useCallback((A,$)=>{var F,H;if(!te.current&&typeof ResizeObserver<"u"&&(te.current=new ResizeObserver(oe=>{let pe=!1;for(const Re of oe){const Te=re.current.get(Re.target);if(!Te)continue;const ie=Re.target,se=ie.offsetWidth,le=ie.offsetHeight;if(!se&&!le)continue;const ye=W.current.get(Te);ye&&ye.w===se&&ye.h===le||(W.current.set(Te,{w:se,h:le}),pe=!0)}pe&&ne()})),$){z.current.set(A,$),re.current.set($,A),(F=te.current)==null||F.observe($);const oe=$.offsetWidth,pe=$.offsetHeight;(oe||pe)&&W.current.set(A,{w:oe,h:pe})}else{const oe=z.current.get(A);oe&&((H=te.current)==null||H.unobserve(oe),re.current.delete(oe)),z.current.delete(A),W.current.delete(A),G.current.has(A)&&B(A,[])}ne()},[ne,B]);S.useEffect(()=>()=>{var A;return(A=te.current)==null?void 0:A.disconnect()},[]);const Qe=S.useMemo(()=>{const A=new Map;for(const $ of t)$.label&&A.set($.id,$.label);return A},[t]),Fe=S.useMemo(()=>i_(P.nodes,Y,W.current,A=>b(A).padding,A=>{const $=Qe.get(A);if(!$)return;const F=b(A);return{w:Sn($,`bold ${F.fontSize}px ${rt}`)+2*h_,h:0}}),[P.nodes,Y,b,Qe]),er=S.useRef(Fe);er.current=Fe;const Be=S.useCallback(A=>{const $=er.current.get(A);if($)return v0($);const F=X.current.get(A);if(!F)return;const H=W.current.get(A)||yu;return{x:F.x,y:F.y,w:H.w,h:H.h}},[]),Q=S.useMemo(()=>{const A=new Map;for(const $ of t){const F=Be($.id);F&&A.set($.id,F)}return k0(q,A,he,r,n)},[q,t,Y,Fe,he,r,n,Be]);G.current=Q;const V=(A,$)=>{var oe;if(!k||$===void 0)return;const F=(oe=Q.get(A))==null?void 0:oe.find(pe=>pe.property===$),H=Be(A);return F&&!F.anchor&&H?H.y-H.h/2+F.top+F.height/2:void 0},ee=(A,$)=>{var oe,pe;if($===void 0)return;const F=(pe=(oe=Q.get(A))==null?void 0:oe.find(Re=>Re.property===$))==null?void 0:pe.anchor,H=Be(A);return F&&H?{x:H.x-H.w/2+F.x,y:H.y-H.h/2+F.y,side:F.side}:void 0},we=(A,$)=>{const F=Be(A),H=he.get(A);return F&&H&&!Fe.has(A)&&V(A,$)===void 0?Ft(F,H):F},_e=()=>{const A=[];X.current.forEach(($,F)=>{if(er.current.has(F))return;const H=W.current.get(F)||yu;A.push(ct({x:$.x,y:$.y,w:H.w,h:H.h}))}),er.current.forEach($=>A.push($));try{for(const $ of[M.current,I.current]){const F=$==null?void 0:$.getBBox();F&&F.width>0&&F.height>0&&A.push({x1:F.x,y1:F.y,x2:F.x+F.width,y2:F.y+F.height})}}catch{}return Yn(A)},Se=()=>{var F,H;const{pan:A,zoom:$}=O;N.current&&(N.current.style.transform=`translate3d(${A.x}px, ${A.y}px, 0) scale(${$})`),(F=M.current)==null||F.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${$})`),(H=I.current)==null||H.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${$})`)};S.useEffect(()=>{Se();let A=null,$;const F=O.onChange(()=>{Se();const H=E.current;H&&(H.classList.add("flow-sdk-busy"),clearTimeout($),$=setTimeout(()=>H.classList.remove("flow-sdk-busy"),150)),A===null&&(A=requestAnimationFrame(()=>{var oe,pe;A=null,(pe=(oe=R.current).onViewportChange)==null||pe.call(oe,O.state)}))});return()=>{F(),clearTimeout($),A!==null&&cancelAnimationFrame(A)}},[]),S.useLayoutEffect(()=>{const A=E.current;if(!A)return;const $=()=>{let H=A.clientWidth,oe=A.clientHeight;oe||(oe=Math.max(0,window.innerHeight-A.getBoundingClientRect().top-100),oe&&(A.style.height=`${oe}px`)),H||(H=window.innerWidth,H&&(A.style.width=`${H}px`)),O.size={w:H,h:oe}};if($(),typeof ResizeObserver>"u")return;const F=new ResizeObserver($);return F.observe(A),()=>F.disconnect()},[O]),S.useEffect(()=>{if(wr.current){wr.current=!1;const $=fr.current.flatMap(H=>{const oe=Be(H);return oe?[ct(oe)]:[]});fr.current=[];const F=Yn($);if(F){Le.current=!1,O.center(F,R.current.animateViewport);return}}if(!Le.current)return;Le.current=!1;const A=_e();A&&O.fit(A,50,R.current.animateViewport)},[Y]);const Ve=S.useMemo(()=>{const A=ie=>Al(ie,R.current.nodes,R.current.edges),$=(ie,se=50,le=R.current.animateViewport)=>{const ye=Yn([...ie].flatMap(lr=>{const _t=Be(lr);return _t?[ct(_t)]:[]}));ye&&(Le.current=!1,O.fit(ye,Number.isFinite(se)?Math.max(0,se):50,le))},F=(ie,se,le,ye)=>{if(!Be(ie))return;const lr=se==="connections"?oe(ie):A(ie);Je.current||(Je.current={pan:{...O.pan},zoom:O.zoom}),$e.current=lr,R.current.compactPropertyLayout&&(Le.current=!1,Xe.current=()=>$($e.current??lr,le,ye)),C({id:ie,mode:se}),R.current.compactPropertyLayout||$(lr,le,ye)},H=ie=>{Xe.current?Xe.current=ie:ie()},oe=ie=>Nl(ie,R.current.nodes,R.current.edges),pe=(ie=>{if(ie===void 0)return O.zoom;O.set(void 0,ie)}),Re=(ie=>{if(ie===void 0)return O.pan;O.set(ie)}),Te=(ie,se)=>{var ye;const le=(ye=E.current)==null?void 0:ye.getBoundingClientRect();return{x:ie-((le==null?void 0:le.left)??0),y:se-((le==null?void 0:le.top)??0)}};return{zoom:pe,pan:Re,setEdgesVisible:Ie,focusNode:(ie,se,le)=>H(()=>$(new Set([ie]),se,le)),focusBranch:(ie,se,le)=>H(()=>$(A(ie),se,le)),focusConnections:(ie,se,le)=>H(()=>$(oe(ie),se,le)),isolateConnections:(ie,se,le)=>F(ie,"connections",se,le),isolateBranch:(ie,se,le)=>F(ie,"branch",se,le),restoreView:(ie=R.current.animateViewport)=>{const se=R.current.compactPropertyLayout&&!!$e.current;$e.current=null,C(null);const le=Je.current;Je.current=null,se?Xe.current=()=>{le&&O.transition(le,ie)}:le&&H(()=>O.transition(le,ie))},zoomAt:(ie,se)=>O.zoomAt(ie,se),fit:(ie=0,se=R.current.animateViewport)=>{H(()=>{const le=_e();le&&O.fit(le,ie,se)})},centerAndFit:(ie=0,se=R.current.animateViewport)=>{H(()=>{const le=_e();le&&O.fit(le,ie,se)})},center:(ie=R.current.animateViewport)=>{const se=_e();se&&O.center(se,ie)},clientToModel:(ie,se)=>O.renderedToModel(Te(ie,se)),modelToClient:ie=>{var ye;const se=(ye=E.current)==null?void 0:ye.getBoundingClientRect(),le=O.modelToRendered(ie);return{x:le.x+((se==null?void 0:se.left)??0),y:le.y+((se==null?void 0:se.top)??0)}},getNodeBox:ie=>Be(ie),setNodePosition:(ie,se,le)=>{if(!X.current.has(ie)||se&&(!Number.isFinite(se.x)||!Number.isFinite(se.y)))return!1;if(Ce(),!se)return U.current.delete(ie),ne(),!0;const ye=new Map(X.current);return ye.set(ie,{...se}),(le==null?void 0:le.persist)===!1?U.current.delete(ie):U.current.set(ie,{...se}),X.current=ye,ce(ye),(le==null?void 0:le.persist)===!1&&ne(),!0},onViewportChange:ie=>O.onChange(ie)}},[]);S.useEffect(()=>{var A,$;return($=(A=R.current).onInit)==null||$.call(A,Ve),()=>O.cancelAnimation()},[Ve]),S.useEffect(()=>{var A,$;if(ae>0){const F=Xe.current;Xe.current=null,F==null||F(),($=(A=R.current).onLayoutComplete)==null||$.call(A,Ve)}},[Ve,ae]);const ke=S.useRef(null),Me=S.useRef(new Map),De=S.useRef(!1),[gr,sr]=S.useState(null),[Pe,Er]=S.useState(null),Ar=A=>{const $=E.current.getBoundingClientRect();return{x:A.clientX-$.left,y:A.clientY-$.top}},Lr=(A,$)=>{const F=R.current.nodes;for(let H=F.length-1;H>=0;H--){const oe=F[H].id;if(!ut(oe,R.current.edges,R.current.edgeMode)||$e.current&&!$e.current.has(oe)||oe===$||er.current.has(oe))continue;const pe=Be(oe);if(pe&&Tl(A,ct(pe)))return oe}for(const[H,oe]of er.current)if(ut(H,R.current.edges,R.current.edgeMode)&&!($e.current&&!$e.current.has(H))&&H!==$&&Tl(A,oe))return H;return null},Wn=(A,$)=>{if(R.current.edgeMode==="nodes"||R.current.edgeMode==="workflow")return null;const F=R.current.direction==="RL",H=Math.max(16,6/O.zoom);let oe=null;for(const pe of[...R.current.nodes].reverse()){if(!ut(pe.id,R.current.edges,R.current.edgeMode)||$e.current&&!$e.current.has(pe.id))continue;const Re=Be(pe.id),Te=G.current.get(pe.id);if(!Re||!Te||er.current.has(pe.id))continue;const ie=Re.x+($==="source"!==F?1:-1)*Re.w/2;for(const se of Te){if(se.role&&se.role!==$)continue;const le=Re.y-Re.h/2+se.top,ye=Math.hypot(A.x-(se.anchor?Re.x-Re.w/2+se.anchor.x:ie),A.y-le-se.height/2);if(!se.anchor&&A.x>=Re.x-Re.w/2&&A.x<=Re.x+Re.w/2&&A.y>=le&&A.y<=le+se.height)return{nodeId:pe.id,property:se.property};ye<=H&&(!oe||ye<oe.distance)&&(oe={nodeId:pe.id,property:se.property,distance:ye})}}return oe},Dm=A=>{var Re;if(!A.currentTarget.contains(A.target)||A.button!==0||R.current.readOnly)return;ke.current||(De.current=!1);const $=A.target;if($.closest('input, textarea, select, [contenteditable="true"], [data-flow-content-toggle]'))return;const F=R.current,H=Ar(A);if(A.pointerType==="touch"){Me.current.set(A.pointerId,H);const Te=uy(Me.current);if(Te){ke.current={kind:"pinch",distance:Te.distance,zoom:O.zoom,anchor:O.renderedToModel(Te.center)},Er(null),sr(null),De.current=!0;for(const ie of Me.current.keys())A.currentTarget.setPointerCapture(ie);return}}if(ke.current)return;const oe=F.drawHandles&&$.closest(".flow-sdk-handle"),pe=F.drawHandles&&$.closest(".flow-sdk-property-port");if(F.drawMode||oe||pe){const Te=O.renderedToModel(H),ie=F.drawMode?Wn(Te,"source"):null,se=pe||oe,le=se?(Re=se.closest("[data-node-id]"))==null?void 0:Re.dataset.nodeId:(ie==null?void 0:ie.nodeId)??Lr(Te),ye=pe?pe.dataset.property:ie==null?void 0:ie.property;if(le){ke.current={kind:"draw",pointerId:A.pointerId,source:le,sourceProperty:ye,reverse:(pe==null?void 0:pe.dataset.portRole)==="target",startClient:{x:A.clientX,y:A.clientY}},De.current=!0,Er({source:le,sourceProperty:ye,point:Te,target:null}),A.currentTarget.setPointerCapture(A.pointerId);return}}$.closest(".flow-sdk-node, .flow-sdk-container, .flow-sdk-edge, .flow-sdk-edge-label, .flow-sdk-container-label")||(F.multiSelect?ke.current={kind:"box",pointerId:A.pointerId,start:H,current:H}:F.dragMode?ke.current={kind:"pan",pointerId:A.pointerId,start:H,pan0:O.pan,moved:!1}:ke.current={kind:"tap",pointerId:A.pointerId,start:H,moved:!1},A.currentTarget.setPointerCapture(A.pointerId))},zm=A=>{const $=ke.current;if(!$||R.current.readOnly)return;const F=Ar(A);if(Me.current.has(A.pointerId)&&Me.current.set(A.pointerId,F),$.kind==="pinch"){const H=uy(Me.current);if(!H)return;const oe=Math.max(O.minZoom,Math.min(O.maxZoom,$.zoom*H.distance/$.distance));O.set({x:H.center.x-$.anchor.x*oe,y:H.center.y-$.anchor.y*oe},oe);return}if($.pointerId===A.pointerId)switch($.kind){case"pan":{const H=F.x-$.start.x,oe=F.y-$.start.y;if(!$.moved&&Math.hypot(H,oe)<=sy)return;$.moved=!0,De.current=!0,O.set({x:$.pan0.x+H,y:$.pan0.y+oe});break}case"tap":{Math.hypot(F.x-$.start.x,F.y-$.start.y)>sy&&($.moved=!0);break}case"box":{De.current=!0,$.current=F,sr({x1:Math.min($.start.x,F.x),y1:Math.min($.start.y,F.y),x2:Math.max($.start.x,F.x),y2:Math.max($.start.y,F.y)});break}case"draw":{const H=O.renderedToModel(F),oe=Wn(H,$.reverse?"source":"target");Er($.reverse&&oe?{source:oe.nodeId,sourceProperty:oe.property,point:H,target:$.source,targetProperty:$.sourceProperty}:{source:$.source,sourceProperty:$.sourceProperty,point:H,target:(oe==null?void 0:oe.nodeId)??Lr(H,$.source),targetProperty:oe==null?void 0:oe.property});break}}},il=(A,$)=>{var oe,pe,Re,Te,ie;Me.current.delete(A.pointerId);const F=ke.current;if(!F)return;if(F.kind==="pinch"){const se=[...Me.current][0];ke.current=se&&R.current.dragMode&&!$?{kind:"pan",pointerId:se[0],start:se[1],pan0:O.pan,moved:!0}:null;return}if(F.pointerId!==A.pointerId)return;ke.current=null;try{A.currentTarget.releasePointerCapture(A.pointerId)}catch{}const H=R.current;switch($=$||!!H.readOnly,F.kind){case"pan":case"tap":!$&&!F.moved&&((oe=H.onBackgroundTap)==null||oe.call(H));break;case"box":{if(sr(null),$)break;const se=O.renderedToModel(F.start),le=O.renderedToModel(F.current),ye={x1:Math.min(se.x,le.x),y1:Math.min(se.y,le.y),x2:Math.max(se.x,le.x),y2:Math.max(se.y,le.y)};if(ye.x2-ye.x1<1&&ye.y2-ye.y1<1){(pe=H.onBackgroundTap)==null||pe.call(H);break}const lr=[];for(const _t of H.nodes){const cl=Be(_t.id);cl&&x0(ct(cl),ye)&&lr.push(_t.id)}lr.length&&((Re=H.onBoxSelect)==null||Re.call(H,lr));break}case"draw":{if(Er(null),$)break;const se=Ar(A),le=O.renderedToModel(se),ye=Wn(le,F.reverse?"source":"target"),lr=(ye==null?void 0:ye.nodeId)??Lr(le);if(lr===F.source&&(F.sourceProperty===void 0||(ye==null?void 0:ye.property)===void 0||ye.property===F.sourceProperty))break;lr?(Te=H.onEdgeDraw)==null||Te.call(H,F.reverse?lr:F.source,F.reverse?F.source:lr,F.sourceProperty!==void 0||(ye==null?void 0:ye.property)!==void 0?{sourceProperty:F.reverse?ye==null?void 0:ye.property:F.sourceProperty,targetProperty:F.reverse?F.sourceProperty:ye==null?void 0:ye.property}:void 0):Math.max(Math.abs(A.clientX-F.startClient.x),Math.abs(A.clientY-F.startClient.y))>d_&&((ie=H.onDrawIntoSpace)==null||ie.call(H,F.source,le,F.sourceProperty,F.reverse));break}}},Kr=S.useCallback(()=>{var F;const A=ke.current,$=[...Me.current.keys()];A&&A.kind!=="pinch"&&$.push(A.pointerId),ke.current=null,Me.current.clear(),Er(null),sr(null);for(const H of $)(F=E.current)!=null&&F.hasPointerCapture(H)&&E.current.releasePointerCapture(H)},[]);S.useEffect(()=>{const A=$=>{$.key==="Escape"&&Kr()};return window.addEventListener("keydown",A),window.addEventListener("blur",Kr),()=>{window.removeEventListener("keydown",A),window.removeEventListener("blur",Kr),ke.current=null,Me.current.clear()}},[Kr]),S.useEffect(()=>{Kr()},[m,w,y,i,n,e.drawHandles,e.readOnly,Kr]);const Vm=S.useMemo(()=>{const A=new Map,$=new Map;for(const F of T){if(F.source!==F.target)continue;const H=A.get(F.source)??0;A.set(F.source,H+1),$.set(F.id,H)}return $},[T]),Gn=l_[n],[Un,Wm]=S.useState(null);S.useLayoutEffect(()=>{E.current&&Un&&B0(E.current)});const Hn=m0(T,we,Gn),Gm=e.onEdgeSelect,Um=e.onContainerSelect,al=Pe?Pe.target&&we(Pe.target,Pe.targetProperty)||{x:Pe.point.x,y:Pe.point.y,w:1,h:1}:null,sl=Pe?we(Pe.source,Pe.sourceProperty):null,Hm=["flow-sdk-canvas",m?"flow-sdk-draw":"",x?"flow-sdk-perf":""].filter(Boolean).join(" ");return h.jsxs("div",{ref:E,className:Hm,"data-edge-mode":i,onPointerDownCapture:Dm,onPointerMove:zm,onPointerUp:A=>il(A,!1),onPointerCancel:A=>il(A,!0),onLostPointerCapture:A=>{const $=ke.current;$&&($.kind==="pinch"||$.pointerId===A.pointerId)&&Kr()},onClickCapture:A=>{A.currentTarget.contains(A.target)&&(De.current||e.readOnly)&&(A.preventDefault(),A.stopPropagation())},children:[h.jsx("svg",{className:"flow-sdk-svg",children:h.jsxs("g",{ref:M,children:[h.jsx("g",{className:"flow-sdk-containers",children:[...Fe].filter(([A])=>ut(A,r,i)).filter(([A])=>!_||_.has(A)).map(([A,$])=>{var F;return h.jsx(O0,{id:A,rect:$,label:Qe.get(A),labelLayer:Un,style:b(A),onSelect:Um,onCollapse:e.readOnly?void 0:e.onContainerCollapse,selected:(F=e.selectedNodeIds)==null?void 0:F.includes(A)},A)})}),h.jsx("g",{className:"flow-sdk-edges",children:xe&&T.map(A=>{var H,oe,pe;if(_&&(!_.has(A.source)||!_.has(A.target)))return null;const $=we(A.source,A.sourceProperty),F=we(A.target,A.targetProperty);return!$||!F?null:h.jsx($l,{id:A.id,edgeData:A.data,validationIssue:A.validationIssue,edgeType:A.type,edgeRadius:e.edgeRadius,propertyMode:k,customEdgeTypes:e.customEdgeTypes,source:$,target:F,sourceProperty:A.sourceProperty,targetProperty:A.targetProperty,sourceY:V(A.source,A.sourceProperty),targetY:V(A.target,A.targetProperty),sourcePort:ee(A.source,A.sourceProperty),targetPort:ee(A.target,A.targetProperty),dir:Gn,turn:((H=Hn.get(A.id))==null?void 0:H.turn)??A.turn,labelAtTarget:(oe=Hn.get(A.id))==null?void 0:oe.labelAtTarget,labelFraction:(pe=Hn.get(A.id))==null?void 0:pe.labelFraction,color:A.color,labelBg:A.labelBg,label:A.label,labelLayer:Un,dashed:A.dashed,animated:A.animated&&!x,inverted:A.inverted,loopIndex:Vm.get(A.id)??0,onSelect:Gm},A.id)})}),xe&&Pe&&Cu(Pe,i)&&sl&&al&&h.jsx("g",{className:"flow-sdk-ghost",pointerEvents:"none",children:h.jsx($l,{id:"__flow-sdk-ghost",edgeData:{id:"__flow-sdk-ghost",source:Pe.source,target:Pe.target??"",sourceProperty:Pe.sourceProperty,targetProperty:Pe.targetProperty},edgeType:e.edgeType,edgeRadius:e.edgeRadius,propertyMode:k,customEdgeTypes:e.customEdgeTypes,source:sl,target:al,sourceProperty:Pe.sourceProperty,targetProperty:Pe.targetProperty,sourceY:V(Pe.source,Pe.sourceProperty),sourcePort:ee(Pe.source,Pe.sourceProperty),targetPort:Pe.target?ee(Pe.target,Pe.targetProperty):void 0,targetY:Pe.target?V(Pe.target,Pe.targetProperty):void 0,dir:Gn,turn:.5,color:g,labelBg:g})})]})}),h.jsx("div",{ref:N,className:"flow-sdk-nodes",children:t.map(A=>{var pe,Re;const $=Y.get(A.id),F=Fe.get(A.id),H=($==null?void 0:$.x)??(F?(F.x1+F.x2)/2:0),oe=($==null?void 0:$.y)??(F?(F.y1+F.y2)/2:0);return h.jsx(c_,{id:A.id,x:H,y:oe,placed:!!$||!!F,hidden:!ut(A.id,r,i)||!!_&&!_.has(A.id),onMount:ze,drawHandles:e.drawHandles&&!e.readOnly,drawMode:m,connectedPorts:new Set(T.flatMap(Te=>[...Te.source===A.id&&Te.sourceProperty!==void 0?[`source:${Te.sourceProperty}`]:[],...Te.target===A.id&&Te.targetProperty!==void 0?[`target:${Te.targetProperty}`]:[]])),hasCollapseControl:A.hasCollapseControl,handleColor:g,animated:A.animated&&!F&&!x,animationColor:A.animationColor,animationWidth:A.animationWidth,animationVariant:A.animationVariant,width:(pe=W.current.get(A.id))==null?void 0:pe.w,height:(Re=W.current.get(A.id))==null?void 0:Re.h,propertyMode:k,resolvedRows:Q.get(A.id),reversePorts:n==="RL",direction:n,onPropertyRows:B,onSurface:K,children:A.element},A.id)})}),gr&&h.jsx("div",{className:"flow-sdk-box",style:{left:gr.x1,top:gr.y1,width:gr.x2-gr.x1,height:gr.y2-gr.y1}}),h.jsx("svg",{className:"flow-sdk-svg flow-sdk-label-overlay",style:{zIndex:11,pointerEvents:"none"},children:h.jsx("g",{ref:I,transform:`translate(${O.pan.x} ${O.pan.y}) scale(${O.zoom})`,children:h.jsx("g",{ref:Wm,className:"flow-sdk-labels",style:{pointerEvents:m?"none":"visiblePainted",outline:"none"}})})})]})}const y_=S.memo(g_);function Om({id:e,label:t,role:r,side:n,position:o=.5,placement:i,children:a,style:s}){return h.jsx("div",{"data-flow-property":e,"data-flow-port-role":r,"data-flow-port-side":n,"data-flow-port-position":n?o:void 0,"data-flow-port-placement":i,style:{minHeight:32,display:"flex",alignItems:"center",justifyContent:r==="source"?"flex-end":"flex-start",...s,...n?{display:"none"}:{}},children:a??t??e})}const b_=bn.default.dialog`
154
158
  ${e=>zr(e.$surface,e.$border)}
155
159
  &[open] {
156
160
  display: flex;
@@ -164,7 +168,7 @@
164
168
  & *::-webkit-scrollbar {
165
169
  display: none;
166
170
  }
167
- `,m_=mn.default.div`
171
+ `,m_=bn.default.div`
168
172
  min-height: 0;
169
173
  overflow: auto;
170
174
  padding: 32px 0;
@@ -182,5 +186,5 @@
182
186
  black calc(100% - 32px),
183
187
  transparent
184
188
  );
185
- `;function Ib({nodeAddress:e,active:t,label:r,open:n=!1,onClose:o,children:i,filter:a,height:s}){const{background:u,border:c,colorText:l}=Ue(),d=S.useRef(null),f=S.useId(),{data:p,schema:m,bindings:g}=S.useContext(kr),b=i!==void 0||!!(p&&m&&(g?Xt(g,e,m):yt(p,e,m)));S.useEffect(()=>{var y,x,v,C,_;!t||!b||!n?(y=d.current)==null||y.close():(x=d.current)!=null&&x.open||((v=d.current)==null||v.showModal(),(_=(C=d.current)==null?void 0:C.querySelector("[data-form-filter] input"))==null||_.focus())},[t,b,n]);const w=fe(u);return b?h.jsx(h.Fragment,{children:typeof document<"u"&&Bt.createPortal(h.jsx(y_,{ref:d,id:f,$surface:w,$border:fe(c),"aria-label":`Configure ${r}`,onClose:o,onPointerDown:y=>y.stopPropagation(),onWheel:y=>y.stopPropagation(),onKeyDown:y=>y.stopPropagation(),onClick:y=>{var x;y.stopPropagation(),y.target===y.currentTarget&&((x=d.current)==null||x.close())},style:{margin:"auto",padding:20,width:380,boxSizing:"border-box",maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100dvh - 32px)",height:s,overflow:"hidden",borderRadius:30,background:w,color:fe(l),fontSize:16,textTransform:"none"},children:n&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexShrink:0},children:[h.jsx("strong",{style:{overflowWrap:"anywhere",minWidth:0},children:r}),h.jsx("form",{method:"dialog",style:{margin:0},onSubmit:y=>y.stopPropagation(),children:h.jsx(gt,{type:"submit","aria-label":"Close node configuration"})})]}),a&&h.jsx("div",{"data-form-filter":"",style:{flexShrink:0},children:a}),h.jsx(m_,{"data-form-scroll":"",style:s?{flex:1}:void 0,children:i??h.jsx(om,{nodeAddress:e})})]})}),document.body)}):null}const _u=({icon:e,label:t,onClick:r,color:n,boxSize:o=6,...i})=>{const{background:a,border:s,colorText:u}=Ue();return h.jsx(je,{label:t,children:h.jsx(D.Flex,{children:h.jsx(D.Icon,{as:e,boxSize:o,color:n,cursor:r?"pointer":void 0,onClick:r})})})},b_=({data:e,children:t,isInverted:r,isParent:n})=>{var q,L,G,B,Y,ce;const{selectedNodeIds:o,setSelectedNodeIds:i,selectedEdgeId:a,setSelectedEdgeId:s,isMultiSelectMode:u,isPerformanceMode:c,engineRef:l,callbacks:d,config:f,themeColor:p,direction:m}=Oe(),{background:g,border:b,colorText:w}=Ue(),y=S.useRef(null),x=S.useRef(null),[v,C]=S.useState(!1),[_,k]=S.useState(!1),[T,P]=S.useState(!1),j=e==null?void 0:e.id,R=im(j),E=o.includes(j),M=f.nodeOverlayActions,I=f.renderNodeOverlay,N=(()=>{var X;try{const U=(X=l.current)==null?void 0:X.zoom();return U!==void 0&&U<.08}catch{return!1}})(),O=S.useCallback(X=>{var Z,ae,ue,de;if(_||f.readOnly)return;const U={shiftKey:X.shiftKey,ctrlKey:X.ctrlKey,metaKey:X.metaKey,altKey:X.altKey};if(a&&(s(null),(Z=d.onEdgeDeselect)==null||Z.call(d)),u){const Ee=o.includes(j),ge=Ee?o.filter(He=>He!==j):[...o,j];i(ge),Ee?(ae=d.onNodeDeselect)==null||ae.call(d):(ue=d.onNodeSelect)==null||ue.call(d,j,e,U)}else i([j]),(de=d.onNodeSelect)==null||de.call(d,j,e,U)},[j,e,o,a,u,_,i,s,d,f]),W=S.useCallback(()=>{var X;_||f.readOnly||(X=d.onNodeDoubleClick)==null||X.call(d,j,e)},[j,e,_,d,f]),z=S.useCallback(()=>{x.current&&clearTimeout(x.current),x.current=setTimeout(()=>C(!0),100)},[]),re=S.useCallback(()=>{x.current&&clearTimeout(x.current),C(!1)},[]),te=!!((q=e==null?void 0:e.config)!=null&&q.form),he={tabIndex:te?0:void 0,"aria-haspopup":te?"dialog":void 0,"aria-expanded":te?T:void 0,onDoubleClickCapture:X=>{var U;!te||f.readOnly||_||!X.currentTarget.contains(X.target)||X.target instanceof Element&&X.target.closest("button, input, textarea, select, a, [contenteditable=true]")||(X.preventDefault(),X.stopPropagation(),i([j]),P(!0),(U=d.onNodeDoubleClick)==null||U.call(d,j,e))},onKeyDown:X=>{!te||f.readOnly||X.target!==X.currentTarget||X.key!=="Enter"||(X.preventDefault(),X.stopPropagation(),i([j]),P(!0))}},me=te&&h.jsx(Ib,{nodeAddress:j,active:E,label:e.label||e.headerTitle||"Node",open:T,onClose:()=>{var X;P(!1),E&&((X=y.current)==null||X.focus({preventScroll:!0}))}}),K=Array.isArray((L=e==null?void 0:e.config)==null?void 0:L.ports)?e.config.ports.map(X=>h.jsx(Ob,{...X},`${X.id}:${X.role}`)):null;return n?h.jsxs(D.Box,{ref:y,...he,onClick:O,onDoubleClick:W,onMouseEnter:z,onMouseLeave:re,cursor:"pointer",position:"relative",children:[me,!c&&(I||M&&M.length>0)&&v&&!N&&h.jsxs(h.Fragment,{children:[h.jsx(D.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>C(!0),onMouseLeave:re}),I?h.jsx(D.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>C(!0),onMouseLeave:re,willChange:"transform",children:I({nodeId:j,nodeData:e,isRoot:j==="root",isParent:!0,isHovered:v,setIsHovered:C})}):h.jsx(D.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:g,p:3,borderColor:b,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>C(!0),onMouseLeave:re,willChange:"transform",children:h.jsx(D.HStack,{px:2,gap:2,children:M.map((X,U)=>h.jsxs(D.Box,{display:"contents",children:[U>0&&h.jsx(D.Box,{borderColor:b,height:5,borderRightWidth:1}),h.jsx(_u,{icon:X.icon,label:X.label,color:w,bgColor:g,borderColor:b,textColor:w,boxSize:5,onClick:Z=>{var ae;Z.stopPropagation(),(ae=d.onNodeHoverAction)==null||ae.call(d,X.id,j,e)}})]},X.id))})})]}),t({id:j,data:e,isActive:E,isLowZoom:N,isEditing:_,onEditStart:()=>k(!0),onEditEnd:()=>k(!1)}),R&&!((G=e==null?void 0:e.config)!=null&&G.parentContainer)&&((B=e==null?void 0:e.config)==null?void 0:B.collapsed)!==void 0&&(()=>{var Z;const X=m==="TB"||m==="BT",U=r||m==="RL";return h.jsx(D.IconButton,{position:"absolute",...X?{[m==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:U?void 0:"-75px",left:U?"-75px":void 0,top:"50%",transform:"translateY(-50%)"},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:f.readOnly,onClick:ae=>{var ue;ae.stopPropagation(),(ue=d.onNodeCollapse)==null||ue.call(d,j,!e.config.collapsed)},bgColor:fe(((Z=e==null?void 0:e.viewProps)==null?void 0:Z.bgColor)||p),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?h.jsx(J.PiPlusBold,{size:30,color:fe("gray.800")}):h.jsx(J.PiMinusBold,{size:30,color:fe("gray.800")})})})()]}):h.jsxs(D.Box,{ref:y,...he,onClick:O,onDoubleClick:W,onMouseEnter:z,onMouseLeave:re,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[me,K,!c&&(I||M&&M.length>0)&&v&&!N&&h.jsxs(h.Fragment,{children:[h.jsx(D.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>C(!0),onMouseLeave:re}),I?h.jsx(D.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>C(!0),onMouseLeave:re,willChange:"transform",children:I({nodeId:j,nodeData:e,isRoot:j==="root",isParent:!!n,isHovered:v,setIsHovered:C})}):h.jsx(D.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:g,p:3,borderColor:b,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>C(!0),onMouseLeave:re,willChange:"transform",children:h.jsx(D.HStack,{px:2,gap:2,children:M.map((X,U)=>h.jsxs(D.Box,{display:"contents",children:[U>0&&h.jsx(D.Box,{borderColor:b,height:5,borderRightWidth:1}),h.jsx(_u,{icon:X.icon,label:X.label,color:w,bgColor:g,borderColor:b,textColor:w,boxSize:5,onClick:Z=>{var ae;Z.stopPropagation(),(ae=d.onNodeHoverAction)==null||ae.call(d,X.id,j,e)}})]},X.id))})})]}),h.jsxs(D.Box,{position:"relative",display:"flex",h:"100%",w:"100%",children:[R&&!((Y=e==null?void 0:e.config)!=null&&Y.parentContainer)&&((ce=e==null?void 0:e.config)==null?void 0:ce.collapsed)!==void 0&&!n&&(()=>{var ae,ue,de;const X=m==="TB"||m==="BT",U=r||m==="RL",Z=(ae=e==null?void 0:e.config)!=null&&ae.labelBelow?((((ue=e==null?void 0:e.viewProps)==null?void 0:ue.fontSize)||1)*100+100)/2:void 0;return h.jsx(D.IconButton,{position:"absolute",...X?{[m==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:U?void 0:Z===void 0?"-75px":`calc(50% - ${Z+75}px)`,left:U?Z===void 0?"-75px":`calc(50% - ${Z+75}px)`:void 0,alignSelf:Z===void 0?"center":void 0,top:Z===void 0?void 0:`${Z}px`,transform:Z===void 0?void 0:"translateY(-50%)",zIndex:Z===void 0?void 0:1},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:f.readOnly,onClick:Ee=>{var ge;Ee.stopPropagation(),(ge=d.onNodeCollapse)==null||ge.call(d,j,!e.config.collapsed)},bgColor:fe(((de=e==null?void 0:e.viewProps)==null?void 0:de.bgColor)||p),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?h.jsx(J.PiPlusBold,{size:30,color:fe("gray.800")}):h.jsx(J.PiMinusBold,{size:30,color:fe("gray.800")})})})(),t({id:j,data:e,isActive:E,isLowZoom:N,isEditing:_,onEditStart:()=>k(!0),onEditEnd:()=>k(!1)})]})]})},zn=S.memo(b_);function nl(e=!0){const t=S.useRef(null);return S.useEffect(()=>{if(!e||!t.current)return;const r=i=>{i.stopPropagation()},n=t.current,o=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return o.forEach(i=>n.addEventListener(i,r)),()=>{o.forEach(i=>n.removeEventListener(i,r))}},[e]),t}const Zt=({nodeId:e,label:t,color:r,fontWeight:n="bold",fontSize:o="5xl",wrap:i=!1,isEditing:a,onEditStart:s,onEditEnd:u})=>{const{callbacks:c,config:l,readOnly:d}=Oe(),f=l.editable&&!d,[p,m]=S.useState(t),[g,b]=S.useState(),w=S.useRef(null),y=S.useRef(!1),x=nl(a);S.useEffect(()=>{a&&(y.current=!1,w.current&&(w.current.focus(),w.current.select()))},[a]);const v=()=>{var _;if(y.current)return;y.current=!0;const C=p.trim();C&&C!==t&&((_=c.onNodeLabelChange)==null||_.call(c,e,C)),u()};return!f||!a?h.jsx(D.Text,{color:r,fontWeight:n,fontSize:o,minW:0,maxW:"100%",whiteSpace:i?"normal":"nowrap",overflowWrap:i?"anywhere":void 0,overflow:"hidden",textOverflow:"ellipsis",title:t,onDoubleClick:f?C=>{C.stopPropagation(),b({width:C.currentTarget.offsetWidth,height:C.currentTarget.offsetHeight}),m(t),s()}:void 0,cursor:f?"text":void 0,children:t}):h.jsxs("div",{ref:x,style:{position:"relative",width:"max-content",minWidth:g==null?void 0:g.width,maxWidth:900,height:g==null?void 0:g.height},children:[h.jsx(D.Text,{as:"span","aria-hidden":"true",display:"block",visibility:"hidden",fontWeight:n,fontSize:o,lineHeight:"normal",whiteSpace:"pre",overflow:"hidden",children:p||" "}),h.jsx(D.Input,{ref:w,value:p,onChange:C=>m(C.target.value),onBlur:v,onKeyDown:C=>{C.key==="Enter"&&v(),C.key==="Escape"&&(y.current=!0,u())},color:r,fontWeight:n,fontSize:o,bg:"transparent",borderWidth:0,_focus:{outline:"none",boxShadow:"none"},_focusVisible:{outline:"none",boxShadow:"none"},p:0,display:"block",position:"absolute",top:0,left:0,w:"100%",h:"100%",minW:0,minH:0,lineHeight:"normal"})]})},v_=({id:e,data:t,isActive:r,isEditing:n,onEditStart:o,onEditEnd:i})=>{var g,b,w,y,x,v,C,_;const{themeColor:a}=Oe(),{colorText:s}=Ue(),u=((g=t==null?void 0:t.viewProps)==null?void 0:g.bgColor)==="transparent",c=((b=t==null?void 0:t.viewProps)==null?void 0:b.outline)===!0,{bgColor:l,borderColor:d,textColor:f}=Yt(((w=t==null?void 0:t.viewProps)==null?void 0:w.bgColor)||a),p=fe(((y=t==null?void 0:t.viewProps)==null?void 0:y.textColor)||(u||c?s:f)),m=((x=t==null?void 0:t.viewProps)==null?void 0:x.borderColor)||(c?!u&&((v=t==null?void 0:t.viewProps)==null?void 0:v.bgColor)||a:d);return h.jsx(D.Box,{"data-flow-node-surface":"",borderRadius:(C=t==null?void 0:t.viewProps)==null?void 0:C.borderRadius,bgColor:c?"transparent":l,...fn(t==null?void 0:t.viewProps,m,r,2),py:14,px:20,whiteSpace:"nowrap",w:"fit-content",children:h.jsxs(D.Flex,{justifyContent:"start",alignItems:"center",gap:8,w:"fit-content",maxW:900,minW:0,fontSize:"5xl",lineHeight:"normal",children:[((_=t==null?void 0:t.config)==null?void 0:_.icon)&&h.jsx(D.Box,{flexShrink:0,children:h.jsx(qr,{name:t.config.icon,size:80,color:p})}),h.jsx(Zt,{nodeId:e,label:(t==null?void 0:t.label)||(t==null?void 0:t.text)||"",color:p,isEditing:n,onEditStart:o,onEditEnd:i})]})})};function Vn(){const{nodeViewModes:e,setNodeViewMode:t,allNodesIconLabel:r,setAllNodesIconLabel:n}=Oe();return{allNodesIconLabel:r,setAllNodesIconLabel:n,getNodeViewMode:o=>e[o]??"default",showNodeProperties:o=>t(o,"properties"),restoreNodeView:o=>t(o,"default"),toggleNodeView:o=>t(o,e[o]==="properties"?"default":"properties"),setNodeViewMode:t}}const x_=({id:e,isActive:t,data:r,isEditing:n,onEditStart:o,onEditEnd:i})=>{var x,v,C,_,k,T,P,j,R,E,M,I,N,O,W;const{themeColor:a}=Oe(),{colorText:s}=Ue(),u=((x=r==null?void 0:r.viewProps)==null?void 0:x.bgColor)==="transparent",c=((v=r==null?void 0:r.viewProps)==null?void 0:v.outline)===!0,l=!u&&((C=r==null?void 0:r.viewProps)==null?void 0:C.bgColor)||a,{borderColor:d,highlightColor:f,textColor:p}=Yt(l),m=fe(((_=r==null?void 0:r.viewProps)==null?void 0:_.textColor)||(u||c?s:p)),g=u&&!c&&!((k=r==null?void 0:r.viewProps)!=null&&k.borderColor)?"transparent":fe(((T=r==null?void 0:r.viewProps)==null?void 0:T.borderColor)||(c?l:d)),b=u||c?"transparent":l!=null&&l.startsWith("#")?l:fe(f),w=(P=r==null?void 0:r.config)==null?void 0:P.icon,y=(r==null?void 0:r.label)??(r==null?void 0:r.text)??"";if((j=r==null?void 0:r.config)!=null&&j.labelBelow){const z=(((R=r==null?void 0:r.viewProps)==null?void 0:R.fontSize)||1)*100;return h.jsxs(D.Flex,{"data-flow-icon-label":"",direction:"column",align:"center",gap:"24px",width:`${Math.max(z+200,360)}px`,position:"relative",children:[h.jsx(D.Flex,{"data-flow-node-surface":"",align:"center",justify:"center",width:`${z+100}px`,height:`${z+100}px`,flexShrink:0,borderRadius:(E=r==null?void 0:r.viewProps)==null?void 0:E.borderRadius,backgroundColor:b,...fn(r==null?void 0:r.viewProps,g,t,2),children:!!w&&h.jsx(qr,{name:w,size:z,color:m})}),h.jsxs(D.Flex,{"data-flow-icon-caption":"",direction:"column",align:"center",gap:"8px",justify:"center",width:"100%",minW:0,textAlign:"center",children:[h.jsx(Zt,{nodeId:e,label:y,color:fe(((M=r==null?void 0:r.viewProps)==null?void 0:M.textColor)||s),isEditing:n,onEditStart:o,onEditEnd:i,wrap:!0}),typeof((I=r.config)==null?void 0:I.subtitle)=="string"&&r.config.subtitle!==""&&h.jsx(D.Text,{"data-flow-node-subtitle":"",color:fe(((N=r==null?void 0:r.viewProps)==null?void 0:N.textColor)||s),opacity:.65,fontSize:"32px",fontWeight:"normal",lineHeight:1.3,width:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",title:r.config.subtitle,children:r.config.subtitle})]})]})}return h.jsxs(D.Flex,{"data-flow-node-surface":"",align:"center",borderRadius:(O=r==null?void 0:r.viewProps)==null?void 0:O.borderRadius,bgColor:b,style:{backgroundColor:b},textTransform:"capitalize",...fn(r==null?void 0:r.viewProps,g,t,2),px:50,w:"fit-content",whiteSpace:"nowrap",children:[!!w&&h.jsx(D.Flex,{align:"center",py:14,mr:y?8:0,flexShrink:0,children:h.jsx(qr,{name:w,size:(((W=r==null?void 0:r.viewProps)==null?void 0:W.fontSize)||1)*100,color:m},m)}),(y||!w)&&h.jsx(D.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:"fit-content",maxW:900,minW:0,children:h.jsx(Zt,{nodeId:e,label:y,color:m,isEditing:n,onEditStart:o,onEditEnd:i})})]})};function Mb({onExpand:e,toggleLabel:t="Show properties",toggleDisabled:r=!1,renderCompact:n=x_,...o}){const{colorMode:i,callbacks:a}=Oe();return h.jsx(zn,{...o,children:s=>h.jsxs(D.Box,{position:"relative",children:[h.jsx(n,{...s}),e&&s.isActive&&h.jsx(D.Box,{position:"absolute",top:"-24px",right:"-48px","data-flow-content-toggle":"",children:h.jsx(je,{label:t,children:h.jsx(be,{"aria-label":t,icon:h.jsx(D.Icon,{as:J.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:i==="dark"?"gray.100":"gray.800",disabled:r,onClick:u=>{var c;u.stopPropagation(),e(),(c=a.onNodeViewToggle)==null||c.call(a,o.data.id)}})})})]})})}const ly=1.55;function w_({nodeId:e,content:t,color:r}){const{callbacks:n,config:o,readOnly:i}=Oe(),a=!!o.editable&&!i,[s,u]=S.useState(!1),[c,l]=S.useState(t),[d,f]=S.useState(),p=S.useRef(null),m=S.useRef(!1),g=nl(s);S.useLayoutEffect(()=>{const y=p.current;!s||!y||(y.style.height="auto",y.style.height=`${Math.max((d==null?void 0:d.height)??0,y.scrollHeight)}px`)},[c,s,d]),S.useEffect(()=>{var y;a?s&&(m.current=!1,(y=p.current)==null||y.focus()):u(!1)},[s,a]);const b=y=>{a&&(f({width:y.offsetWidth,height:y.offsetHeight}),l(t),u(!0))},w=()=>{var y;m.current||!a||(m.current=!0,c!==t&&((y=n.onNodeContentChange)==null||y.call(n,e,c)),u(!1))};return!s||!a?h.jsx(D.Box,{"data-flow-content":"",color:r,w:"100%",minH:"1.2em",whiteSpace:"normal",lineHeight:ly,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:a?"text":void 0,tabIndex:a?0:void 0,onDoubleClick:y=>{y.stopPropagation(),b(y.currentTarget)},onKeyDown:y=>{a&&y.key==="Enter"&&y.target===y.currentTarget&&(y.preventDefault(),y.stopPropagation(),b(y.currentTarget))},children:h.jsx(ov.default,{options:{forceBlock:!0,wrapper:S.Fragment,disableParsingRawHTML:!0,overrides:{a:{props:{target:"_blank",rel:"noopener noreferrer"}},img:{props:{loading:"lazy",referrerPolicy:"no-referrer"}}}},children:t})}):h.jsx("div",{ref:g,style:{width:d==null?void 0:d.width,minHeight:d==null?void 0:d.height,maxWidth:"100%"},children:h.jsx(D.Textarea,{ref:p,"aria-label":"Node content",value:c,onChange:y=>l(y.target.value),onBlur:w,onKeyDown:y=>{y.stopPropagation(),!y.nativeEvent.isComposing&&(y.key==="Enter"&&(y.ctrlKey||y.metaKey)&&(y.preventDefault(),w()),y.key==="Escape"&&(m.current=!0,u(!1)))},color:r,fontFamily:"inherit",fontSize:"inherit",lineHeight:ly,overflowWrap:"anywhere",whiteSpace:"pre-wrap",rows:1,bg:"transparent",display:"block",style:{border:0,outline:"none",boxShadow:"none"},p:0,w:"100%",h:"100%",minW:0,minH:0,resize:"none"})})}const C_=(e,t,r)=>{var f,p,m,g;const n=((f=e==null?void 0:e.viewProps)==null?void 0:f.bgColor)||t,[o]=n.split("."),i=Yt(n),a=((p=e==null?void 0:e.viewProps)==null?void 0:p.outline)===!0,s=n==="transparent"||a,u=r==="dark"?"gray.200":"gray.900",c=s?"transparent":n!=null&&n.startsWith("#")?fe(n):fe(i.bgColor),l=fe(((m=e==null?void 0:e.viewProps)==null?void 0:m.textColor)||(s?u:i.textColor)),d=fe(((g=e==null?void 0:e.viewProps)==null?void 0:g.borderColor)||(a?n==="transparent"?t:n:i.borderColor));return{...i,bgColor:s?"transparent":i.bgColor,highlightColor:s?"transparent":i.highlightColor,isTransparent:s,propertyColor:s?u:i.propertyColor,bg:n,wordBeforeDot:o,hexbgColor:c,hextextColor:l,hexborderColor:d}},__=(e,t=350)=>`${String(e).substring(0,t)}${String(e).length>t?"...":""}`,S_=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,qb=600,E_=3,j_=e=>{const t=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(t*28+30,200)};function R_({headerTitle:e,hasContent:t,data:r,icon:n,colors:o,hasConfig:i,id:a,isActive:s,isEditing:u,onEditStart:c,onEditEnd:l,props:d,objVisible:f,setObjVisible:p,onShowNativeIcon:m}){var y,x;const{callbacks:g}=Oe(),b=d.onShowIcon??m,w=b?"Show icon":f?"Show content":"Show properties";return h.jsx(h.Fragment,{children:(e||t||((y=r.config)==null?void 0:y.form)||s&&m)&&h.jsxs(D.Flex,{justify:"flex-start",direction:"row",p:Object.entries(r.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&&!t?"transparent":o.hexborderColor,children:[!!n&&h.jsx(D.Flex,{mr:6,alignItems:"center",flexShrink:0,children:h.jsx(qr,{name:n,size:64,color:o.hextextColor},o.hextextColor)}),h.jsx(Zt,{nodeId:a,label:S_(e),color:((x=r==null?void 0:r.viewProps)==null?void 0:x.textColor)||o.propertyColor,isEditing:u,onEditStart:c,onEditEnd:l}),s&&(t||b)&&h.jsx(D.Box,{ml:"auto",pl:6,flexShrink:0,"data-flow-content-toggle":"",children:h.jsx(je,{label:w,children:h.jsx(be,{"aria-label":w,icon:h.jsx(D.Icon,{as:J.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:o.hextextColor,onClick:v=>{var C;v.stopPropagation(),b?b():p(!f),(C=g.onNodeViewToggle)==null||C.call(g,a)}})})})]})})}function k_({data:e,resourcePorts:t,inspecting:r,form:n,inspectionPorts:o,extraPorts:i,colors:a,direction:s,uniformKeyWidth:u}){const{edgeById:c}=Ur(),l=new Set;for(const{data:d}of c.values())d.source===e.id&&d.sourceProperty!==void 0&&l.add(`source:${d.sourceProperty}`),d.target===e.id&&d.targetProperty!==void 0&&l.add(`target:${d.targetProperty}`);return h.jsx(D.Box,{children:Object.entries(e.description||{}).map(([d,f],p)=>{var M,I,N;const m=t&&Object.keys(t).find(O=>O.slice(O.indexOf(":")+1)===d),g=r&&((M=n==null?void 0:n.type.ports)==null?void 0:M[d]),b=m??(g?`${g.kind}:${d}`:d),w=o.find(O=>O.id===b),y=m?"source":w==null?void 0:w.role,x=l.has(`source:${b}`),v=l.has(`target:${b}`),C=i.some(O=>O.id===d),_=f===""&&(C||(y?l.has(`${y}:${b}`):x||v)),k=y??(x!==v?x?"source":"target":void 0),T=(w==null?void 0:w.side)??(k?k==="source"!=(s==="RL")?"right":"left":void 0),P=_&&T==="right"?"right":"left",j=(w==null?void 0:w.label)??(g==null?void 0:g.label)??(C?d.replace(/^(template|input|output|config|error):/,""):d),R=jr(a.wordBeforeDot)[typeof f],E=jr(a.wordBeforeDot).property;return h.jsxs(D.Box,{"data-flow-property":m&&(s==="TB"||s==="BT")?void 0:b,"data-flow-port-role":y,"data-flow-inspection-row":r?"":void 0,children:[h.jsxs(D.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[h.jsx(D.Flex,{justifyContent:"start",align:"center",background:a.highlightColor,width:_?"100%":`${u}px`,minWidth:`${u}px`,borderRightColor:a.hexborderColor,borderRightWidth:_?0:1,children:h.jsx(D.Text,{py:5,px:10,w:"100%",textAlign:P,whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((I=e==null?void 0:e.viewProps)==null?void 0:I.textColor)||(a.isTransparent?a.hextextColor:E),children:j})}),!_&&h.jsx(D.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:a.hexbgColor,w:qb,maxH:200,children:h.jsx(D.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)||(a.isTransparent?a.hextextColor:R),fontWeight:400,children:__(f)})})]}),p!==Object.entries(e.description||{}).length-1&&h.jsx(D.Box,{borderTopWidth:1,my:0,borderColor:a.hexborderColor})]},d)})})}function P_(e){var x,v,C;const{themeColor:t,colorMode:r,direction:n}=Oe(),o=Vn(),i=o.getNodeViewMode(e.data.id)==="properties",a=_=>o.setNodeViewMode(e.data.id,_?"properties":"default"),s=!!e.onShowIcon||i||typeof((x=e.data.config)==null?void 0:x.content)!="string",{bindings:u,data:c,schema:l}=S.useContext(kr),d=(v=u==null?void 0:u[e.data.id])==null?void 0:v.portResources,f=u?Xt(u,e.data.id,l):c&&l?yt(c,e.data.id,l):void 0,p=f&&ve(c,"address"in f?f.address:e.data.id),m=p&&typeof p=="object"&&f?Object.fromEntries(Object.keys(f.type.properties).filter(_=>{var k;return Object.prototype.hasOwnProperty.call(p,_)&&wn((k=f.fields[_])==null?void 0:k.$visibleWhen,c)}).map(_=>[_,p[_]!==null&&typeof p[_]=="object"?JSON.stringify(p[_],null,2):p[_]===null?"null":p[_]])):{},g=d?Object.fromEntries(Object.entries(d).map(([_,k])=>{var T;return[_.slice(_.indexOf(":")+1),((T=ve(c,k))==null?void 0:T.name)??k.split(".").at(-1)]})):Object.keys(e.data.description??{}).length?e.data.description:m,b=s&&!d?((C=e.data.config)==null?void 0:C.ports)??[]:[],w=b.filter(_=>!Object.prototype.hasOwnProperty.call(g,_.id)&&!Object.entries((f==null?void 0:f.type.ports)??{}).some(([k,T])=>`${T.kind}:${k}`===_.id&&Object.prototype.hasOwnProperty.call(g,k))),y={...g,...Object.fromEntries(w.map(_=>[_.id,""]))};return{themeColor:t,colorMode:r,direction:n,objVisible:i,setObjVisible:a,inspecting:s,resourcePorts:d,form:f,description:y,inspectionPorts:b,extraPorts:w}}const ol=e=>{var b,w,y;const{themeColor:t,colorMode:r,direction:n,objVisible:o,setObjVisible:i,inspecting:a,resourcePorts:s,form:u,description:c,inspectionPorts:l,extraPorts:d}=P_(e),f=Vn(),p=f.getNodeViewMode(e.data.id)==="icon-label",g=!e.onShowIcon&&!((b=e.data.config)!=null&&b.parentContainer)&&typeof((w=e.data.config)==null?void 0:w.content)!="string"?()=>f.setNodeViewMode(e.data.id,"icon-label"):void 0;return!e.onShowIcon&&p?h.jsx(Mb,{...e,data:{...e.data,label:e.data.label??e.data.headerTitle,config:{...e.data.config,labelBelow:!0,icon:((y=e.data.config)==null?void 0:y.icon)||"PiBracketsCurly"}},onExpand:()=>f.restoreNodeView(e.data.id)}):h.jsx(zn,{...e,data:{...e.data,description:c},children:({id:x,data:v,isActive:C,isEditing:_,onEditStart:k,onEditEnd:T})=>{var z,re,te,he,me,K;const P=C_(v,t,r),j=v.label??v.headerTitle,R=Object.entries(v.description||{}).length>0,E=j_(v.description),M=(re=(z=e.data)==null?void 0:z.config)==null?void 0:re.icon,I=(he=(te=e.data)==null?void 0:te.config)==null?void 0:he.content,N=typeof I=="string"&&!e.onShowIcon,O=((me=v==null?void 0:v.viewProps)==null?void 0:me.borderRadius)??"53px",W=fn(v==null?void 0:v.viewProps,P.hexborderColor,C,E_);return h.jsx(D.Flex,{justifyContent:"space-between",...v==null?void 0:v.viewProps,"data-flow-node-surface":"",direction:"column",p:0,borderRadius:O,overflow:"hidden",alignItems:"center",style:{backgroundColor:P.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:"100%",minW:N||e.onShowIcon?E+qb+W.borderWidth*2:void 0,...W,children:h.jsxs(D.Flex,{width:"100%",direction:"column",borderRadius:O,borderColor:P.hexborderColor,borderWidth:0,overflow:"hidden",children:[h.jsx(R_,{headerTitle:j,hasContent:N,data:v,icon:M,colors:P,hasConfig:R,id:x,isActive:C,isEditing:_,onEditStart:k,onEditEnd:T,props:e,objVisible:o,setObjVisible:i,onShowNativeIcon:g}),N&&!o?h.jsx(D.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:P.highlightColor,p:12,fontSize:"5xl",lineHeight:"normal",children:h.jsx(w_,{nodeId:x,content:I,color:((K=v==null?void 0:v.viewProps)==null?void 0:K.textColor)||P.hextextColor})}):h.jsx(k_,{data:v,resourcePorts:s,inspecting:a,form:u,inspectionPorts:l,extraPorts:d,colors:P,direction:n,uniformKeyWidth:E})]})})}})};ol.displayName="NodeJsonObjectView";const Nb=e=>{var c,l,d,f,p,m,g;const t=Vn(),r=t.getNodeViewMode(e.data.id)==="properties",n=b=>t.setNodeViewMode(e.data.id,b?"properties":"default"),{callbacks:o,readOnly:i}=Oe(),a=(l=(c=e.data)==null?void 0:c.config)==null?void 0:l.parentContainer,s=a?"Show parent":"Show properties",u=a||((f=(d=e.data)==null?void 0:d.config)==null?void 0:f.form)||((g=(m=(p=e.data)==null?void 0:p.config)==null?void 0:m.ports)==null?void 0:g.length);return!a&&u&&r?h.jsx(ol,{...e,onShowIcon:()=>n(!1)}):h.jsx(Mb,{...e,toggleLabel:s,toggleDisabled:a&&i,onExpand:u?()=>{var b;a?(b=o.onNodeCollapse)==null||b.call(o,e.data.id,!1):n(!0)}:void 0})},$b=e=>h.jsx(Nb,{...e,renderCompact:v_}),Lb=e=>h.jsx(Nb,{...e}),Fb=e=>h.jsx(zn,{...e,children:()=>null});$b.displayName="text";Lb.displayName="arrayView";Fb.displayName="ParentContainerView";const A_={objectView:ol,arrayView:Lb,text:$b,parentContainer:Fb},T_=({children:e,pattern:t="dot",backgroundColor:r})=>{const{colorMode:n}=Oe(),o=n==="dark",i=o?"--chakra-colors-gray-700":"--chakra-colors-gray-500",a=o?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return t==="none"?h.jsx(D.Box,{"data-flow-background":"none",width:"100%",height:"100%",padding:0,bg:r,children:e}):h.jsxs(D.Box,{"data-flow-background":t,position:"relative",width:"100%",height:"100%",padding:0,bg:r,children:[h.jsx(D.Box,{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:0,pointerEvents:"none",style:{backgroundImage:t==="dot"?`radial-gradient(var(${i}) 8%, transparent 8%)`:t==="steel"?`repeating-linear-gradient(45deg, var(${a}) 0, var(${a}) 1px, transparent 1px, transparent 20px)`:`linear-gradient(var(${a}) 1px, transparent 1px), linear-gradient(90deg, var(${a}) 1px, transparent 1px)`,backgroundSize:"20px 20px",opacity:.3}}),h.jsx(D.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:e})]})},O_=.4,Jr={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},I_=({nodes:e,edges:t})=>{const{themeColor:r,spacing:n,edgeRadius:o,backgroundVariant:i,setBackgroundSelected:a,edgeColor:s,direction:u,nodeAlignment:c,edgeMode:l,compactPropertyLayout:d,workflowContract:f,parentNodeStyle:p,engineRef:m,callbacks:g,config:b,selectedNodeIds:w,setSelectedNodeIds:y,selectedEdgeId:x,setSelectedEdgeId:v,setIsPerformanceMode:C,isZoomMode:_,setIsZoomMode:k,isMultiSelectMode:T,setIsMultiSelectMode:P,isDragMode:j,setIsDragMode:R,isEdgeHandlesEnabled:E,setIsEdgeHandlesEnabled:M,isArrayNodeMode:I}=Oe(),N=S.useRef(null),[O,W]=S.useState(null),z=e.length>200;S.useEffect(()=>{C(z)},[z,C]);const{edgeSep:re,rankSep:te,spacingFactor:he}=S.useMemo(()=>{const Q=y0(e.length),V=n<1?.3+.7*n:.5+.5*n;return{edgeSep:Q.edgeSep*V,rankSep:Q.rankSep*V,spacingFactor:1.3+(n-1)*(n<1?.4:.3)}},[e.length,n]),{bgColor:me}=Yt(r),{canvas:K,borderSecondary:q,colorText:L}=Ue(),G=i==="transparent"?"transparent":b.backgroundColor||K,B=S.useCallback(Q=>{if(Q!=null&&Q.includes("gray"))return"whitesmoke";if(!Q)return fe(r);switch(Q){case"dark":return fe(G);case"light":return fe(q);default:return fe(Q)}},[r,G,q]),Y=b.colorMode==="dark",ce=S.useMemo(()=>B(Y?me:"light"),[Y,me,B]),X=s?B(s):ce,U=S.useMemo(()=>b.initialViewport||{pan:{x:0,y:0},zoom:.01},[]),Z=u==="C"?"LR":u,ae=S.useCallback(Q=>{const V={...p,...Q};return{...V,bgColor:V.bgColor||r,bgOpacity:V.outline?0:V.bgOpacity??O_}},[p,r]),ue=S.useMemo(()=>{var V;const Q=new Map;for(const ee of e)(V=ee.data)!=null&&V.id&&Q.set(ee.data.id,ee);return Q},[e]),de=S.useMemo(()=>{var V;const Q=new Map;for(const ee of t)(V=ee.data)!=null&&V.id&&Q.set(ee.data.id,ee);return Q},[t]),Ee=S.useCallback(Q=>{var _e;const V=(_e=ue.get(Q))==null?void 0:_e.data,ee=ae(V==null?void 0:V.viewProps),we=fe(ee.bgColor);return{animated:!!(V!=null&&V.isNodeAnimated)&&!z,animationVariant:V==null?void 0:V.nodeAnimationVariant,animationColor:fe(ee.borderColor||r),bgColor:ee.outline?"transparent":we,bgOpacity:ee.bgOpacity,borderColor:ee.borderColor?fe(ee.borderColor):ee.outline&&ee.bgColor==="transparent"?fe(r):we,borderWidth:Kt(ee.borderWidth,Jr.borderWidth),borderStyle:ee.borderStyle??Jr.borderStyle,borderRadius:ee.borderRadius??Jr.borderRadius,textColor:ee.textColor?fe(ee.textColor):ee.outline||ee.bgColor==="transparent"?fe(L):we,fontSize:ee.fontSize??Jr.fontSize,labelPosition:ee.labelPosition??Jr.labelPosition,labelMargin:Jr.labelMargin,labelBg:ul(B("dark"),we,ee.bgOpacity)??B("dark"),padding:ee.padding??Jr.padding}},[ae,ue,L,r,z,B]),ge=S.useMemo(()=>{var ee,we;const Q=new Map;for(const _e of t){const Se=(ee=_e.data)==null?void 0:ee.source,Ve=(we=_e.data)==null?void 0:we.target;if(!Se||!Ve||Se===Ve)continue;const ke=Se<Ve?`${Se}|${Ve}`:`${Ve}|${Se}`,Me=Q.get(ke);Me?Me.push({id:_e.data.id,source:Se}):Q.set(ke,[{id:_e.data.id,source:Se}])}const V=new Map;for(const[_e,Se]of Q){if(Se.length<2)continue;const Ve=_e.split("|")[0],ke=Math.min(20,70/Se.length);Se.forEach(({id:Me,source:De},gr)=>{const sr=50+(gr-(Se.length-1)/2)*ke;V.set(Me,(De===Ve?sr:100-sr)/100)})}return V},[t]),He=S.useMemo(()=>{const Q=B("dark");return t.filter(V=>{var ee;return((ee=V.data)==null?void 0:ee.id)&&V.data.source&&V.data.target}).map(({data:V})=>{var Se,Ve,ke,Me,De,gr;let ee=Q;const we=(Ve=(Se=ue.get(V.source))==null?void 0:Se.data)==null?void 0:Ve.parent,_e=(Me=(ke=ue.get(V.target))==null?void 0:ke.data)==null?void 0:Me.parent;if(we&&we===_e){const sr=ae((gr=(De=ue.get(we))==null?void 0:De.data)==null?void 0:gr.viewProps),Pe=ul(Q,fe(sr.bgColor),sr.bgOpacity);Pe&&(ee=Pe)}return{id:V.id,data:V,type:V.type??b.edgeType??"rounded-orthogonal",source:V.source,target:V.target,sourceProperty:V.sourceProperty,targetProperty:V.targetProperty,label:V.label,validationIssue:(l==="auto"||l==="properties")&&(V.sourceProperty!==void 0||V.targetProperty!==void 0)&&f?Mu(f,V):void 0,color:V.color?fe(V.color):X,labelBg:ee,dashed:!!V.isEdgeDashed,animated:!!V.isEdgeAnimated,inverted:!!V.isInverted,turn:ge.get(V.id)??.5}})},[t,X,ge,b.edgeType,l,f,ue,ae,B]),Le=S.useMemo(()=>{var V;const Q=new Set;for(const ee of e)(V=ee.data)!=null&&V.parent&&Q.add(ee.data.parent);return Q},[e]),Xe=S.useMemo(()=>{var V;const Q=new Map;for(const ee of t)(V=ee.data)!=null&&V.source&&!Q.has(ee.data.source)&&Q.set(ee.data.source,ee.data);return Q},[t]),ur=S.useMemo(()=>{const Q={...A_,...b.customViews};return e.filter(V=>{var ee;return(ee=V.data)==null?void 0:ee.id}).map(V=>{var Ve,ke,Me,De;const ee=Le.has(V.data.id)&&!V.data.parent,we=ee?V.data.label??V.data.headerTitle??"Container":void 0,_e=ee?Q.parentContainer:Q[V.data.type]||Q.text,Se=Xe.get(V.data.id);return{id:V.data.id,collapsed:(Ve=V.data.config)==null?void 0:Ve.collapsed,parent:V.data.parent,label:we,animated:!!V.data.isNodeAnimated,animationVariant:V.data.nodeAnimationVariant,hasCollapseControl:((ke=V.data.config)==null?void 0:ke.collapsed)!==void 0,animationColor:fe(((Me=V.data.viewProps)==null?void 0:Me.borderColor)||r),animationWidth:Kt((De=V.data.viewProps)==null?void 0:De.borderWidth,8),element:S.createElement(_e,{...V,isInverted:Se==null?void 0:Se.isInverted,isParent:ee,key:`${V.data.id}-${r}`})}})},[e,Le,Xe,r,b.customViews]),Ge=S.useMemo(()=>z?300:e.length>50?150:e.length>20?100:50,[e.length,z]),Ne=S.useRef(b);Ne.current=b;const xe=S.useRef(_);xe.current=_;const Ie=S.useRef(I);Ie.current=I;const $e=S.useRef(w);$e.current=w;const tr=S.useRef(x);tr.current=x;const Je=S.useRef(T);Je.current=T;const Ze=S.useRef(ue);Ze.current=ue;const fr=S.useRef(de);fr.current=de;const wr=S.useRef(new Map);S.useEffect(()=>{var ee,we;const Q=new Map([...de].filter(([,_e])=>ue.has(_e.data.source)&&ue.has(_e.data.target))),V=wr.current;wr.current=Q;for(const[_e,Se]of V)Q.has(_e)||(tr.current===_e&&(v(null),(ee=g.onEdgeDeselect)==null||ee.call(g)),(we=g.onEdgeRemove)==null||we.call(g,_e,Se.data))},[de,ue,g,v]),S.useEffect(()=>{const Q=N.current;if(!O||!Q)return;let V=null,ee=null,we=0,_e=0,Se=0,Ve=0,ke=0;const Me=De=>{if(Ne.current.readOnly)return;De.preventDefault(),De.stopPropagation(),xe.current||De.metaKey||De.ctrlKey?(Se+=De.deltaY,Ve=De.clientX,ke=De.clientY,ee===null&&(ee=requestAnimationFrame(()=>{ee=null;const sr=Ne.current,Pe=O.zoom(),Er=Se;Se=0;let Ar=Pe-Er*.05/100;Ar=Math.max(sr.minZoom??.01,Math.min(sr.maxZoom??1.5,Ar));const Lr=Q.getBoundingClientRect();O.zoomAt(Ar,{x:Ve-Lr.left,y:ke-Lr.top})}))):(we+=De.deltaX,_e+=De.deltaY,V===null&&(V=requestAnimationFrame(()=>{V=null;const sr=O.pan(),Pe=O.zoom(),Er=.35,Ar=we,Lr=_e;we=0,_e=0,O.pan({x:sr.x+-Ar*Er/Pe,y:sr.y+-Lr*Er/Pe})})))};return Q.addEventListener("wheel",Me,{passive:!1}),()=>{Q.removeEventListener("wheel",Me),V!==null&&cancelAnimationFrame(V),ee!==null&&cancelAnimationFrame(ee)}},[O]),S.useEffect(()=>{if(b.disableKeyboardShortcuts)return;const Q=V=>{var we,_e,Se,Ve;if(Ne.current.readOnly)return;const ee=V.target;if(!(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.isContentEditable)){if((V.key==="z"||V.key==="Z")&&k(!xe.current),(V.key==="m"||V.key==="M")&&P(!T),(V.key==="d"||V.key==="D")&&R(!j),(V.key==="v"||V.key==="V")&&!V.repeat&&!V.metaKey&&!V.ctrlKey&&!V.altKey&&ee.tagName!=="SELECT"&&M(!E),(V.key==="Delete"||V.key==="Backspace")&&tr.current){V.preventDefault();const ke=tr.current;(_e=g.onEdgeDelete)==null||_e.call(g,ke,((we=fr.current.get(ke))==null?void 0:we.data)??{id:ke}),v(null);return}if((V.key==="Delete"||V.key==="Backspace")&&$e.current.length>0){V.preventDefault();const ke=$e.current.filter(Me=>Me!=="root");if(ke.length===0)return;for(const Me of ke){const De=(Se=Ze.current.get(Me))==null?void 0:Se.data;(Ve=g.onNodeDelete)==null||Ve.call(g,Me,De||{})}y([])}}};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[T,j,E,M,k,P,R,b.disableKeyboardShortcuts,g,y,v]);const Ce=S.useCallback(Q=>{var V;m.current=Q,W(Q),(V=g.onInit)==null||V.call(g,Q)},[m,g]),ir=S.useCallback(Q=>{var V;return(V=g.onViewportChange)==null?void 0:V.call(g,Q)},[g]),ar=S.useCallback(Q=>{var ee,we,_e;const V=((ee=fr.current.get(Q))==null?void 0:ee.data)??{id:Q};if(tr.current===Q&&Je.current){v(null),(we=g.onEdgeDeselect)==null||we.call(g);return}$e.current.length&&y([]),v(Q),(_e=g.onEdgeSelect)==null||_e.call(g,Q,V)},[g,v,y]),Ct=S.useCallback(()=>{var Q,V,ee;a(!0),(Q=g.onBackgroundClick)==null||Q.call(g),$e.current.length&&(y([]),(V=g.onNodeDeselect)==null||V.call(g)),tr.current&&(v(null),(ee=g.onEdgeDeselect)==null||ee.call(g))},[g,y,v,a]),ne=S.useCallback(Q=>{var we,_e;const V=$e.current,ee=Q.filter(Se=>!V.includes(Se));if(ee.length){y([...V,...ee]);for(const Se of ee)(_e=g.onNodeSelect)==null||_e.call(g,Se,((we=Ze.current.get(Se))==null?void 0:we.data)??{id:Se})}},[g,y]),ze=S.useCallback((Q,V)=>{var ee,we;y([Q]),(we=g.onNodeSelect)==null||we.call(g,Q,((ee=Ze.current.get(Q))==null?void 0:ee.data)??{id:Q},V)},[g,y]),Qe=S.useCallback((Q,V,ee)=>{var we;return(we=g.onEdgeCreate)==null?void 0:we.call(g,Q,V,ee)},[g]),Fe=S.useCallback((Q,V,ee,we=!1)=>{var _e,Se;l==="properties"&&((_e=g.onNodeCreateRequest)==null?void 0:_e.call(g,{sourceNodeId:Q,position:V,sourceProperty:ee,reverse:we}))===!0||ee!==void 0||we||(Se=g.onNodeCreate)==null||Se.call(g,{type:"text",sourceNodeId:Q,position:V,isArrayMode:Ie.current})},[g,l]),er=!b.readOnly&&E&&b.edgeHandles!==!1,Be=i==="transparent"?"none":i;return h.jsx(T_,{pattern:Be,backgroundColor:G,children:h.jsx(D.Box,{ref:N,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:h.jsx(g_,{nodes:ur,edges:He,direction:Z,nodeAlignment:c,onContainerCollapse:Q=>{var V,ee;(V=g.onNodeCollapse)==null||V.call(g,Q,!0),(ee=g.onNodeViewToggle)==null||ee.call(g,Q)},selectedNodeIds:w,edgeMode:l,compactPropertyLayout:d,edgeType:b.edgeType,edgeRadius:o,customEdgeTypes:b.customEdgeTypes,rankSep:te,edgeSep:re,spacingFactor:he,compactSpacingScale:n,layoutDebounce:Ge,isPerformanceMode:z,minZoom:b.minZoom??.01,maxZoom:b.maxZoom??1.5,initialViewport:U,fitOnInit:!b.initialViewport,readOnly:!!b.readOnly,containerStyle:Ee,lineColor:X,drawMode:er,drawHandles:!b.readOnly&&b.edgeHandles!==!1,dragMode:j,multiSelect:!!T,onInit:Ce,onLayoutComplete:g.onLayoutComplete,animateViewport:b.animateViewport,onViewportChange:ir,onBackgroundTap:Ct,onBoxSelect:ne,onEdgeSelect:ar,onContainerSelect:ze,onEdgeDraw:Qe,onDrawIntoSpace:Fe})})})},Bb=S.memo(I_),M_=".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 dy=!1;function q_(){if(dy||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=M_+g0+h0+".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}',dy=!0}function N_({loading:e=!1,loader:t,...r}){var u,c;const[n,o]=S.useState(null),i=S.useMemo(()=>!!(n!=null&&n.json)&&!!r.json&&l0(n.json,r.json),[n==null?void 0:n.json,r.json]),a=n===null||n.json!==r.json&&!i,s=e||a;return S.useEffect(()=>{!e&&i&&(n==null?void 0:n.json)!==r.json&&o(r)},[e,i,n==null?void 0:n.json,r.json]),S.useEffect(()=>{if(e||!a)return;let l;const d=requestAnimationFrame(()=>{l=requestAnimationFrame(()=>o(r))});return()=>{cancelAnimationFrame(d),l!==void 0&&cancelAnimationFrame(l)}},[e,a,r.json]),h.jsxs(D.Box,{className:r.className,style:r.style,width:"100%",height:"100%",position:"relative","aria-busy":s,children:[h.jsx("div",{style:{width:"100%",height:"100%"},ref:l=>{s?l==null||l.setAttribute("inert",""):l==null||l.removeAttribute("inert")},children:n&&h.jsx($_,{...a?n:r,className:void 0,style:void 0})}),s&&t!==null&&h.jsx(D.Box,{"data-flow-loader":"",role:"status","aria-label":"Loading diagram",position:"absolute",inset:0,zIndex:1e3,display:"grid",placeItems:"center",background:((u=r.config)==null?void 0:u.colorMode)==="dark"?"gray.800":"gray.100",color:((c=r.config)==null?void 0:c.colorMode)==="dark"?"whiteAlpha.800":"blackAlpha.800",children:t===void 0?h.jsx("span",{children:"Loading diagram..."}):t})]})}function $_({title:e="untitled",json:t,forms:r,nodes:n,edges:o,config:i={},callbacks:a={},className:s,style:u,showBottomBar:c=!0,children:l}){q_();const[d,f]=S.useState(),[p,m]=S.useState(!1),g=i.formSchema??d,b=S.useMemo(()=>t&&r?tm(t,r.state):t,[t,r==null?void 0:r.state]),w=i.direction==="C",y=S.useMemo(()=>{let R,E;return M=>(E=R&&E?d0(R,M,E)??vu(M,{title:e,isCenter:w}):vu(M,{title:e,isCenter:w}),R=M,E)},[e,w]),x=S.useMemo(()=>b?y(b):null,[b,y]),v=S.useMemo(()=>r!=null&&r.structured&&!p&&g?o0(r.state,r.bindings,g,(x==null?void 0:x.nodes)??n??[]):void 0,[r==null?void 0:r.structured,p,r==null?void 0:r.state,r==null?void 0:r.bindings,g,x,n]),C=(v==null?void 0:v.schema)??g,_=(v==null?void 0:v.bindings)??(r==null?void 0:r.bindings),k=S.useMemo(()=>[...(x==null?void 0:x.nodes)??n??[],...(v==null?void 0:v.nodes)??[]].map(E=>{var re,te,he,me;const M=t?(re=ve(t,E.data.id))==null?void 0:re.$view:(te=E.data.config)==null?void 0:te.typeView,I=M&&Dt.includes(M)?M:void 0,N=I?I==="icon-label":(he=E.data.config)==null?void 0:he.labelBelow,O=I==="object"?"objectView":I==="text"?"text":N?"arrayView":E.data.type,W=C&&(r?Xt(_,E.data.id,C):t&&yt(t,E.data.id,C)),z=(((me=E.data.config)==null?void 0:me.ports)??[]).map(K=>({...K}));if(v&&W){const K=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[q,L]of Object.entries(W.type.ports??{})){const G=`${L.kind}:${q}`,B=z.find(Y=>Y.id===G);B?B.label===void 0&&L.label!==void 0&&(B.label=L.label):z.push({id:G,...L.label!==void 0?{label:L.label}:{},role:L.kind==="input"||L.kind==="config"?"target":"source",side:K[L.kind],...L.kind==="config"?{placement:"config"}:{}})}for(const q of z){const L=z.filter(G=>G.side===q.side);q.position=(L.indexOf(q)+1)/(L.length+1)}}return W||N||I?{...E,data:{...E.data,type:O,...r?{description:Object.fromEntries(Object.entries(E.data.description??{}).filter(([K])=>!K.startsWith("$")&&!(v!=null&&v.slots.has(kt(E.data.id,K)))))}:{},config:{...E.data.config,...v&&W?{ports:z}:{},...W?{form:!0}:{},...I?{typeView:I,labelBelow:!!N}:N?{labelBelow:!0}:{}}}}:E}),[x,n,t,C,_,v,i.direction]),T=[...(x==null?void 0:x.edges)??o??[],...(v==null?void 0:v.edges)??[]],P=S.useMemo(()=>{const R=t&&x?Cm(t,x.edges,a,a.onJsonChange,g):{...a};if(v){const E=new Set([...v.nodes.map(M=>M.data.id),...v.edges.map(M=>M.data.id)]);for(const M of Object.keys(R)){if(!/^on(?:Node|Edge).*(?:Change|Collapse)$/.test(M))continue;const I=R[M];R[M]=(N,...O)=>{if(!E.has(N))return I==null?void 0:I(N,...O)}}}return{...R,onAllNodesIconLabelChange:E=>{var M;m(E),(M=R.onAllNodesIconLabelChange)==null||M.call(R,E)}}},[t,x,a,g,v]),j=S.useMemo(()=>{if(!r)return P;let R=r.state;const E=I=>{if(i.readOnly||i.editable===!1)return;const N=r.onStateChange??r.onChange;if(!N)return;const O=Yx(R,I,a.onFormChange);O!==R&&(R=O,N(O,{...I,data:O}))},M=(I,N,O)=>{var z;const W=t&&((z=ve(t,I))==null?void 0:z[N]);return!W||typeof W.$state!="string"?!1:(E({address:W.$state,nodeAddress:I,previousValue:ve(R,W.$state),value:O,data:R}),!0)};return{...P,onFormChange:E,onNodeCreateRequest:I=>{var W,z;const N=(W=I.sourceProperty)!=null&&W.startsWith("config:")?I.sourceProperty.slice(7):void 0,O=N!==void 0&&(v==null?void 0:v.slots.get(kt(I.sourceNodeId,N)));return O?(O.present||E({data:R,nodeAddress:O.address.split(".").slice(0,-1).join("."),address:O.address,value:Pt(O.type),previousValue:void 0}),!0):((z=P.onNodeCreateRequest)==null?void 0:z.call(P,I))??!1},onNodeDelete:(I,N)=>{var he,me;if(!(v!=null&&v.nodes.some(K=>K.data.id===I)))return(he=P.onNodeDelete)==null?void 0:he.call(P,I,N);const O=v&&[...v.slots.values()].find(K=>K.nodeId===I);if(!O)return(me=P.onNodeDelete)==null?void 0:me.call(P,I,N);const W=O.address.split("."),z=W.pop(),re=W.join("."),te=ve(R,re);E(Array.isArray(te)?{data:R,nodeAddress:re,address:re,previousValue:te,value:te.filter((K,q)=>String(q)!==z)}:{data:R,nodeAddress:re,address:O.address,previousValue:ve(R,O.address),value:void 0})},onEdgeCreate:(I,N,O)=>{var re,te;const W=((re=O==null?void 0:O.targetProperty)==null?void 0:re.startsWith("config:"))&&(v==null?void 0:v.slots.get(kt(N,O.targetProperty.slice(7)))),z=v==null?void 0:v.containers.get(I);if(W&&z&&(O==null?void 0:O.sourceProperty)==="output:resource"){const he=n0(R,z,W);he!==void 0&&E({data:R,nodeAddress:W.address.split(".").slice(0,-1).join("."),address:W.address,previousValue:ve(R,W.address),value:he});return}W||v!=null&&v.nodes.some(he=>he.data.id===I||he.data.id===N)||(te=P.onEdgeCreate)==null||te.call(P,I,N,O)},onEdgeDelete:(I,N)=>{var me;const O=v==null?void 0:v.edges.find(K=>K.data.id===I);if(!O)return(me=P.onEdgeDelete)==null?void 0:me.call(P,I,N);const W=v.slots.get(kt(O.data.target,O.data.targetProperty.slice(7))),z=W.address.split("."),re=z.pop(),te=z.join("."),he=ve(R,te);E(Array.isArray(he)?{data:R,nodeAddress:te,address:te,previousValue:he,value:he.filter((K,q)=>String(q)!==re)}:{data:R,nodeAddress:te,address:W.address,previousValue:ve(R,W.address),value:void 0})},onNodeContentChange:(I,N)=>{var O,W;M(I,"$content",N)?(O=a.onNodeContentChange)==null||O.call(a,I,N):(W=P.onNodeContentChange)==null||W.call(P,I,N)},onNodeLabelChange:(I,N)=>{var O,W;M(I,"$label",N)?(O=a.onNodeLabelChange)==null||O.call(a,I,N):(W=P.onNodeLabelChange)==null||W.call(P,I,N)}}},[P,r,t,a,v,i.readOnly,i.editable]);return h.jsx(kr.Provider,{value:{data:(r==null?void 0:r.state)??t,viewData:t,bindings:_,references:r==null?void 0:r.references,structured:v,renderForm:r==null?void 0:r.renderForm,editable:r?!!(r.onStateChange??r.onChange):!!a.onJsonChange,schema:C,setSchema:R=>{var E;f(R),(E=a.onFormSchemaChange)==null||E.call(a,R)},callbacks:j},children:h.jsx(by,{config:v?{...i,formSchema:C}:i,callbacks:j,nodes:k,edges:T,children:h.jsxs(D.Box,{className:s,"data-flow-diagram":"",style:u,width:"100%",height:"100%",position:"relative",overflow:"hidden",css:{"& input, & textarea, & select":{outline:"none !important",boxShadow:"none !important"}},children:[h.jsx(Bb,{nodes:k,edges:T}),c&&h.jsx(vm,{}),l]})})})}function L_(e){return Su(JSON.parse(e))}function Su(e){if(!e||typeof e!="object")throw new Error("Expected a JSON object or array.");const t=new Set,r=n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(!n||typeof n!="object"||t.has(n)||!Array.isArray(n)&&![Object.prototype,null].includes(Object.getPrototypeOf(n)))throw new Error("Document must contain only finite, acyclic JSON values.");t.add(n);for(const[o,i]of Object.entries(n)){if(["__proto__","prototype","constructor"].includes(o))throw new Error(`Unsafe document key: ${o}`);r(i)}t.delete(n)}};return r(e),structuredClone(e)}function F_(e){return{replaceJson(t){if(e.readOnly||!e.onJsonChange)throw new Error("JSON document is read-only.");const r=Su(t);return e.onJsonChange(r,{type:"documentReplace",address:"root"}),r},replaceState(t){if(e.readOnly||!e.onStateChange)throw new Error("Form state is read-only.");const r=Su(t);return e.onStateChange(r,{address:"root",nodeAddress:"root",previousValue:e.state,value:r,data:r}),r}}}function B_(e,t){const r=(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,a)=>r(i,o[a])).filter(i=>i!==void 0):void 0:Object.fromEntries(Object.entries(n).flatMap(([i,a])=>{if(!Object.prototype.hasOwnProperty.call(o,i))return[];if(i.startsWith("$")&&i!=="$")return JSON.stringify(a)===JSON.stringify(o[i])?[[i,a]]:[];const s=r(a,o[i]);return s===void 0?[]:[[i,s]]}))};return r(e,t)??{}}function un(e){let t="",r=!1,n="",o;const i=()=>{clearTimeout(o),o=void 0},a=()=>{if(i(),!(r||!t.trim()))try{const u=e.parse(e.repair(t)),c=JSON.stringify(u);if(c===n)return;e.preview(u),n=c}catch{}},s=u=>{if(!r){if(new TextEncoder().encode(u).byteLength>(e.maxBytes??1024*1024))throw r=!0,i(),new Error("JSON stream exceeds the size limit.");t=u,o||(o=setTimeout(a,e.intervalMs??150))}};return{snapshot:s,append(u){s(t+u)},flush:a,finish(){if(r)throw new Error("JSON stream is closed.");r=!0,i();const u=e.parse(t);return e.commit(u),u},cancel(){r=!0,i(),t=""}}}function D_(e){const{source:t}=e,r=e.tickMs??50,n=e.durationMs??8e3;if(!Number.isFinite(r)||r<=0||!Number.isFinite(n)||n<=0)throw new Error("Playback timing must be positive.");if(new TextEncoder().encode(t).byteLength>(e.maxBytes??1024*1024))throw new Error("JSON stream exceeds the size limit.");e.parse(t);let o=un(e),i=0,a=!1,s=!1,u;const c=Math.max(1,Math.ceil(t.length*r/n)),l=()=>e.onChange({position:i,total:t.length,playing:a}),d=()=>{clearTimeout(u),u=void 0},f=(g=!1)=>{o.snapshot(t.slice(0,i)),i===t.length?(a=!1,d(),o.finish()):g&&o.flush()},p=g=>{a=!1,d(),o.cancel(),l(),e.onError(g)},m=()=>{if(u=void 0,!(!a||s)){i=Math.min(t.length,i+c);try{f()}catch(g){p(g);return}l(),a&&(u=setTimeout(m,r))}};return{play(){s||a||(i===t.length&&(o.cancel(),o=un(e),i=0),a=!0,l(),u=setTimeout(m,r))},pause(){s||(a=!1,d(),o.flush(),l())},seek(g){if(!s){if(!Number.isFinite(g))throw new Error("Playback position must be finite.");d(),i=Math.max(0,Math.min(t.length,Math.round(g))),o.cancel(),o=un(e);try{f(!0)}catch(b){p(b);return}l(),a&&(u=setTimeout(m,r))}},dispose(){s=!0,a=!1,d(),o.cancel()}}}function z_({nodeAddress:e,expanded:t=!1}){var c;const{data:r,schema:n,bindings:o}=S.useContext(kr),{colorText:i,background:a}=Ue();if((c=o==null?void 0:o[e])!=null&&c.portResources)return null;const s=o&&Xt(o,e,n);if(!r||!s)return null;const u=ve(r,s.address);return!u||typeof u!="object"?null:h.jsx("div",{"data-flow-config-summary":"",style:{width:"100%",minWidth:0,color:fe(i),background:fe(a),fontSize:24,lineHeight:1.4,textTransform:"none"},children:Object.keys(s.type.properties).map(l=>{const d=s.fields[l]??{};if(!wn(d.$visibleWhen,r))return null;const f=u[l],p=f==null?"":typeof f=="object"?JSON.stringify(f):String(f);return h.jsxs("div",{"data-flow-property":l,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:[h.jsx("span",{style:{overflowWrap:"anywhere"},children:Cr(d.$label??l)}),h.jsx("span",{title:p,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:t?"pre-wrap":"nowrap",overflowWrap:t?"anywhere":void 0},children:p})]},l)})})}exports.BottomBar=vm;exports.CompactPropertyLayoutToggle=zy;exports.ConnectionsOnlyToggle=u0;exports.DEFAULT_PALETTE=$u;exports.DiagramAppearanceControls=Wy;exports.DynamicIcon=qr;exports.EdgeTools=um;exports.EditableLabel=Zt;exports.ErrorToast=ym;exports.FlowDiagram=N_;exports.FlowDiagramProvider=by;exports.FlowPort=Ob;exports.FlowView=Bb;exports.FormDocumentContext=kr;exports.NODE_TYPE_VIEWS=Dt;exports.NodeBorderRadiusControl=lm;exports.NodeConfigSummary=z_;exports.NodeForm=om;exports.NodeFormPopover=Ib;exports.NodeIconPicker=Nu;exports.NodeTools=dm;exports.NodeView=zn;exports.SvgExportButton=pm;exports.Swatches=Jt;exports.TEXT_PALETTE=sm;exports.ToolbarCloseButton=gt;exports.ToolbarCommitInput=et;exports.ToolbarDivider=Mt;exports.ToolbarIconButton=be;exports.ToolbarRangeInput=Vy;exports.ToolbarScrollContainer=gm;exports.ToolbarSelect=Ir;exports.ToolbarTooltip=je;exports.TooltipIconButton=_u;exports.WorkflowControls=mm;exports.addChild=Au;exports.addConnection=Tu;exports.addTargetEdge=Xy;exports.addressToPath=Mr;exports.applyCollapsed=Jx;exports.applyFormChange=Cn;exports.applyStateEdits=Zx;exports.bindSqueedCallbacks=Cm;exports.compileSqueed=vu;exports.connectionIssue=Mu;exports.contentObjTheme=jr;exports.createFlowDiagram=Qr;exports.createFlowDocumentActions=F_;exports.createFormNode=wm;exports.createJsonPlayback=D_;exports.createJsonStream=un;exports.downloadSvg=hm;exports.exportSvg=fm;exports.formValueError=Rr;exports.getChakraColorHex=fe;exports.getColorVariant=vy;exports.getDarkerHexColor=ln;exports.getInteractionSurface=zr;exports.getNode=ve;exports.parseFlowDocument=L_;exports.parseJsonContract=Ou;exports.parseTypeScriptContract=em;exports.parseTypeScriptForm=Iu;exports.projectJsonPlaybackPreview=B_;exports.readFormSchema=qu;exports.readWorkflowContract=rm;exports.removeEdge=Qy;exports.removeNode=Yy;exports.resolveEdgeOwner=Wt;exports.resolveStateView=tm;exports.setCollapsed=Jy;exports.setEdgeProp=Br;exports.setEdgeStyle=Zy;exports.setNodeProp=cr;exports.updateNode=mr;exports.useCustomColors=Ue;exports.useEdgeProximity=py;exports.useFlowData=Ur;exports.useFlowDiagramContext=Oe;exports.useNodeViewActions=Vn;exports.useStopPropagation=nl;exports.useThemeContentColors=Yt;
189
+ `;function Im({nodeAddress:e,active:t,label:r,open:n=!1,onClose:o,children:i,filter:a,height:s}){const{background:u,border:c,colorText:l}=Ue(),d=S.useRef(null),f=S.useId(),{data:p,schema:b,bindings:g}=S.useContext(kr),m=i!==void 0||!!(p&&b&&(g?Xt(g,e,b):yt(p,e,b)));S.useEffect(()=>{var y,x,v,C,_;!t||!m||!n?(y=d.current)==null||y.close():(x=d.current)!=null&&x.open||((v=d.current)==null||v.showModal(),(_=(C=d.current)==null?void 0:C.querySelector("[data-form-filter] input"))==null||_.focus())},[t,m,n]);const w=fe(u);return m?h.jsx(h.Fragment,{children:typeof document<"u"&&Bt.createPortal(h.jsx(b_,{ref:d,id:f,$surface:w,$border:fe(c),"aria-label":`Configure ${r}`,onClose:o,onPointerDown:y=>y.stopPropagation(),onWheel:y=>y.stopPropagation(),onKeyDown:y=>y.stopPropagation(),onClick:y=>{var x;y.stopPropagation(),y.target===y.currentTarget&&((x=d.current)==null||x.close())},style:{margin:"auto",padding:20,width:380,boxSizing:"border-box",maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100dvh - 32px)",height:s,overflow:"hidden",borderRadius:30,background:w,color:fe(l),fontSize:16,textTransform:"none"},children:n&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexShrink:0},children:[h.jsx("strong",{style:{overflowWrap:"anywhere",minWidth:0},children:r}),h.jsx("form",{method:"dialog",style:{margin:0},onSubmit:y=>y.stopPropagation(),children:h.jsx(gt,{type:"submit","aria-label":"Close node configuration"})})]}),a&&h.jsx("div",{"data-form-filter":"",style:{flexShrink:0},children:a}),h.jsx(m_,{"data-form-scroll":"",style:s?{flex:1}:void 0,children:i??h.jsx(ob,{nodeAddress:e})})]})}),document.body)}):null}const _u=({icon:e,label:t,onClick:r,color:n,boxSize:o=6,...i})=>{const{background:a,border:s,colorText:u}=Ue();return h.jsx(je,{label:t,children:h.jsx(D.Flex,{children:h.jsx(D.Icon,{as:e,boxSize:o,color:n,cursor:r?"pointer":void 0,onClick:r})})})},v_=({data:e,children:t,isInverted:r,isParent:n})=>{var q,L,G,B,Y,ce;const{selectedNodeIds:o,setSelectedNodeIds:i,selectedEdgeId:a,setSelectedEdgeId:s,isMultiSelectMode:u,isPerformanceMode:c,engineRef:l,callbacks:d,config:f,themeColor:p,direction:b}=Oe(),{background:g,border:m,colorText:w}=Ue(),y=S.useRef(null),x=S.useRef(null),[v,C]=S.useState(!1),[_,k]=S.useState(!1),[T,P]=S.useState(!1),j=e==null?void 0:e.id,R=ib(j),E=o.includes(j),M=f.nodeOverlayActions,I=f.renderNodeOverlay,N=(()=>{var X;try{const U=(X=l.current)==null?void 0:X.zoom();return U!==void 0&&U<.08}catch{return!1}})(),O=S.useCallback(X=>{var Z,ae,ue,de;if(_||f.readOnly)return;const U={shiftKey:X.shiftKey,ctrlKey:X.ctrlKey,metaKey:X.metaKey,altKey:X.altKey};if(a&&(s(null),(Z=d.onEdgeDeselect)==null||Z.call(d)),u){const Ee=o.includes(j),ge=Ee?o.filter(He=>He!==j):[...o,j];i(ge),Ee?(ae=d.onNodeDeselect)==null||ae.call(d):(ue=d.onNodeSelect)==null||ue.call(d,j,e,U)}else i([j]),(de=d.onNodeSelect)==null||de.call(d,j,e,U)},[j,e,o,a,u,_,i,s,d,f]),W=S.useCallback(()=>{var X;_||f.readOnly||(X=d.onNodeDoubleClick)==null||X.call(d,j,e)},[j,e,_,d,f]),z=S.useCallback(()=>{x.current&&clearTimeout(x.current),x.current=setTimeout(()=>C(!0),100)},[]),re=S.useCallback(()=>{x.current&&clearTimeout(x.current),C(!1)},[]),te=!!((q=e==null?void 0:e.config)!=null&&q.form),he={tabIndex:te?0:void 0,"aria-haspopup":te?"dialog":void 0,"aria-expanded":te?T:void 0,onDoubleClickCapture:X=>{var U;!te||f.readOnly||_||!X.currentTarget.contains(X.target)||X.target instanceof Element&&X.target.closest("button, input, textarea, select, a, [contenteditable=true]")||(X.preventDefault(),X.stopPropagation(),i([j]),P(!0),(U=d.onNodeDoubleClick)==null||U.call(d,j,e))},onKeyDown:X=>{!te||f.readOnly||X.target!==X.currentTarget||X.key!=="Enter"||(X.preventDefault(),X.stopPropagation(),i([j]),P(!0))}},be=te&&h.jsx(Im,{nodeAddress:j,active:E,label:e.label||e.headerTitle||"Node",open:T,onClose:()=>{var X;P(!1),E&&((X=y.current)==null||X.focus({preventScroll:!0}))}}),K=Array.isArray((L=e==null?void 0:e.config)==null?void 0:L.ports)?e.config.ports.map(X=>h.jsx(Om,{...X},`${X.id}:${X.role}`)):null;return n?h.jsxs(D.Box,{ref:y,...he,onClick:O,onDoubleClick:W,onMouseEnter:z,onMouseLeave:re,cursor:"pointer",position:"relative",children:[be,!c&&(I||M&&M.length>0)&&v&&!N&&h.jsxs(h.Fragment,{children:[h.jsx(D.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>C(!0),onMouseLeave:re}),I?h.jsx(D.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>C(!0),onMouseLeave:re,willChange:"transform",children:I({nodeId:j,nodeData:e,isRoot:j==="root",isParent:!0,isHovered:v,setIsHovered:C})}):h.jsx(D.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:g,p:3,borderColor:m,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>C(!0),onMouseLeave:re,willChange:"transform",children:h.jsx(D.HStack,{px:2,gap:2,children:M.map((X,U)=>h.jsxs(D.Box,{display:"contents",children:[U>0&&h.jsx(D.Box,{borderColor:m,height:5,borderRightWidth:1}),h.jsx(_u,{icon:X.icon,label:X.label,color:w,bgColor:g,borderColor:m,textColor:w,boxSize:5,onClick:Z=>{var ae;Z.stopPropagation(),(ae=d.onNodeHoverAction)==null||ae.call(d,X.id,j,e)}})]},X.id))})})]}),t({id:j,data:e,isActive:E,isLowZoom:N,isEditing:_,onEditStart:()=>k(!0),onEditEnd:()=>k(!1)}),R&&!((G=e==null?void 0:e.config)!=null&&G.parentContainer)&&((B=e==null?void 0:e.config)==null?void 0:B.collapsed)!==void 0&&(()=>{var Z;const X=b==="TB"||b==="BT",U=r||b==="RL";return h.jsx(D.IconButton,{position:"absolute",...X?{[b==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:U?void 0:"-75px",left:U?"-75px":void 0,top:"50%",transform:"translateY(-50%)"},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:f.readOnly,onClick:ae=>{var ue;ae.stopPropagation(),(ue=d.onNodeCollapse)==null||ue.call(d,j,!e.config.collapsed)},bgColor:fe(((Z=e==null?void 0:e.viewProps)==null?void 0:Z.bgColor)||p),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?h.jsx(J.PiPlusBold,{size:30,color:fe("gray.800")}):h.jsx(J.PiMinusBold,{size:30,color:fe("gray.800")})})})()]}):h.jsxs(D.Box,{ref:y,...he,onClick:O,onDoubleClick:W,onMouseEnter:z,onMouseLeave:re,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[be,K,!c&&(I||M&&M.length>0)&&v&&!N&&h.jsxs(h.Fragment,{children:[h.jsx(D.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>C(!0),onMouseLeave:re}),I?h.jsx(D.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>C(!0),onMouseLeave:re,willChange:"transform",children:I({nodeId:j,nodeData:e,isRoot:j==="root",isParent:!!n,isHovered:v,setIsHovered:C})}):h.jsx(D.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:g,p:3,borderColor:m,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>C(!0),onMouseLeave:re,willChange:"transform",children:h.jsx(D.HStack,{px:2,gap:2,children:M.map((X,U)=>h.jsxs(D.Box,{display:"contents",children:[U>0&&h.jsx(D.Box,{borderColor:m,height:5,borderRightWidth:1}),h.jsx(_u,{icon:X.icon,label:X.label,color:w,bgColor:g,borderColor:m,textColor:w,boxSize:5,onClick:Z=>{var ae;Z.stopPropagation(),(ae=d.onNodeHoverAction)==null||ae.call(d,X.id,j,e)}})]},X.id))})})]}),h.jsxs(D.Box,{position:"relative",display:"flex",h:"100%",w:"100%",children:[R&&!((Y=e==null?void 0:e.config)!=null&&Y.parentContainer)&&((ce=e==null?void 0:e.config)==null?void 0:ce.collapsed)!==void 0&&!n&&(()=>{var ae,ue,de;const X=b==="TB"||b==="BT",U=r||b==="RL",Z=(ae=e==null?void 0:e.config)!=null&&ae.labelBelow?((((ue=e==null?void 0:e.viewProps)==null?void 0:ue.fontSize)||1)*100+100)/2:void 0;return h.jsx(D.IconButton,{position:"absolute",...X?{[b==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:U?void 0:Z===void 0?"-75px":`calc(50% - ${Z+75}px)`,left:U?Z===void 0?"-75px":`calc(50% - ${Z+75}px)`:void 0,alignSelf:Z===void 0?"center":void 0,top:Z===void 0?void 0:`${Z}px`,transform:Z===void 0?void 0:"translateY(-50%)",zIndex:Z===void 0?void 0:1},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:f.readOnly,onClick:Ee=>{var ge;Ee.stopPropagation(),(ge=d.onNodeCollapse)==null||ge.call(d,j,!e.config.collapsed)},bgColor:fe(((de=e==null?void 0:e.viewProps)==null?void 0:de.bgColor)||p),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?h.jsx(J.PiPlusBold,{size:30,color:fe("gray.800")}):h.jsx(J.PiMinusBold,{size:30,color:fe("gray.800")})})})(),t({id:j,data:e,isActive:E,isLowZoom:N,isEditing:_,onEditStart:()=>k(!0),onEditEnd:()=>k(!1)})]})]})},zn=S.memo(v_);function nl(e=!0){const t=S.useRef(null);return S.useEffect(()=>{if(!e||!t.current)return;const r=i=>{i.stopPropagation()},n=t.current,o=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return o.forEach(i=>n.addEventListener(i,r)),()=>{o.forEach(i=>n.removeEventListener(i,r))}},[e]),t}const Zt=({nodeId:e,label:t,color:r,fontWeight:n="bold",fontSize:o="5xl",wrap:i=!1,isEditing:a,onEditStart:s,onEditEnd:u})=>{const{callbacks:c,config:l,readOnly:d}=Oe(),f=l.editable&&!d,[p,b]=S.useState(t),[g,m]=S.useState(),w=S.useRef(null),y=S.useRef(!1),x=nl(a);S.useEffect(()=>{a&&(y.current=!1,w.current&&(w.current.focus(),w.current.select()))},[a]);const v=()=>{var _;if(y.current)return;y.current=!0;const C=p.trim();C&&C!==t&&((_=c.onNodeLabelChange)==null||_.call(c,e,C)),u()};return!f||!a?h.jsx(D.Text,{color:r,fontWeight:n,fontSize:o,minW:0,maxW:"100%",whiteSpace:i?"normal":"nowrap",overflowWrap:i?"anywhere":void 0,overflow:"hidden",textOverflow:"ellipsis",title:t,onDoubleClick:f?C=>{C.stopPropagation(),m({width:C.currentTarget.offsetWidth,height:C.currentTarget.offsetHeight}),b(t),s()}:void 0,cursor:f?"text":void 0,children:t}):h.jsxs("div",{ref:x,style:{position:"relative",width:"max-content",minWidth:g==null?void 0:g.width,maxWidth:900,height:g==null?void 0:g.height},children:[h.jsx(D.Text,{as:"span","aria-hidden":"true",display:"block",visibility:"hidden",fontWeight:n,fontSize:o,lineHeight:"normal",whiteSpace:"pre",overflow:"hidden",children:p||" "}),h.jsx(D.Input,{ref:w,value:p,onChange:C=>b(C.target.value),onBlur:v,onKeyDown:C=>{C.key==="Enter"&&v(),C.key==="Escape"&&(y.current=!0,u())},color:r,fontWeight:n,fontSize:o,bg:"transparent",borderWidth:0,_focus:{outline:"none",boxShadow:"none"},_focusVisible:{outline:"none",boxShadow:"none"},p:0,display:"block",position:"absolute",top:0,left:0,w:"100%",h:"100%",minW:0,minH:0,lineHeight:"normal"})]})},x_=({id:e,data:t,isActive:r,isEditing:n,onEditStart:o,onEditEnd:i})=>{var g,m,w,y,x,v,C,_;const{themeColor:a}=Oe(),{colorText:s}=Ue(),u=((g=t==null?void 0:t.viewProps)==null?void 0:g.bgColor)==="transparent",c=((m=t==null?void 0:t.viewProps)==null?void 0:m.outline)===!0,{bgColor:l,borderColor:d,textColor:f}=Yt(((w=t==null?void 0:t.viewProps)==null?void 0:w.bgColor)||a),p=fe(((y=t==null?void 0:t.viewProps)==null?void 0:y.textColor)||(u||c?s:f)),b=((x=t==null?void 0:t.viewProps)==null?void 0:x.borderColor)||(c?!u&&((v=t==null?void 0:t.viewProps)==null?void 0:v.bgColor)||a:d);return h.jsx(D.Box,{"data-flow-node-surface":"",borderRadius:(C=t==null?void 0:t.viewProps)==null?void 0:C.borderRadius,bgColor:c?"transparent":l,...fn(t==null?void 0:t.viewProps,b,r,2),py:14,px:20,whiteSpace:"nowrap",w:"fit-content",children:h.jsxs(D.Flex,{justifyContent:"start",alignItems:"center",gap:8,w:"fit-content",maxW:900,minW:0,fontSize:"5xl",lineHeight:"normal",children:[((_=t==null?void 0:t.config)==null?void 0:_.icon)&&h.jsx(D.Box,{flexShrink:0,children:h.jsx(qr,{name:t.config.icon,size:80,color:p})}),h.jsx(Zt,{nodeId:e,label:(t==null?void 0:t.label)||(t==null?void 0:t.text)||"",color:p,isEditing:n,onEditStart:o,onEditEnd:i})]})})};function Vn(){const{nodeViewModes:e,setNodeViewMode:t,allNodesIconLabel:r,setAllNodesIconLabel:n}=Oe();return{allNodesIconLabel:r,setAllNodesIconLabel:n,getNodeViewMode:o=>e[o]??"default",showNodeProperties:o=>t(o,"properties"),restoreNodeView:o=>t(o,"default"),toggleNodeView:o=>t(o,e[o]==="properties"?"default":"properties"),setNodeViewMode:t}}const w_=({id:e,isActive:t,data:r,isEditing:n,onEditStart:o,onEditEnd:i})=>{var x,v,C,_,k,T,P,j,R,E,M,I,N,O,W;const{themeColor:a}=Oe(),{colorText:s}=Ue(),u=((x=r==null?void 0:r.viewProps)==null?void 0:x.bgColor)==="transparent",c=((v=r==null?void 0:r.viewProps)==null?void 0:v.outline)===!0,l=!u&&((C=r==null?void 0:r.viewProps)==null?void 0:C.bgColor)||a,{borderColor:d,highlightColor:f,textColor:p}=Yt(l),b=fe(((_=r==null?void 0:r.viewProps)==null?void 0:_.textColor)||(u||c?s:p)),g=u&&!c&&!((k=r==null?void 0:r.viewProps)!=null&&k.borderColor)?"transparent":fe(((T=r==null?void 0:r.viewProps)==null?void 0:T.borderColor)||(c?l:d)),m=u||c?"transparent":l!=null&&l.startsWith("#")?l:fe(f),w=(P=r==null?void 0:r.config)==null?void 0:P.icon,y=(r==null?void 0:r.label)??(r==null?void 0:r.text)??"";if((j=r==null?void 0:r.config)!=null&&j.labelBelow){const z=(((R=r==null?void 0:r.viewProps)==null?void 0:R.fontSize)||1)*100;return h.jsxs(D.Flex,{"data-flow-icon-label":"",direction:"column",align:"center",gap:"24px",width:`${Math.max(z+200,360)}px`,position:"relative",children:[h.jsx(D.Flex,{"data-flow-node-surface":"",align:"center",justify:"center",width:`${z+100}px`,height:`${z+100}px`,flexShrink:0,borderRadius:(E=r==null?void 0:r.viewProps)==null?void 0:E.borderRadius,backgroundColor:m,...fn(r==null?void 0:r.viewProps,g,t,2),children:!!w&&h.jsx(qr,{name:w,size:z,color:b})}),h.jsxs(D.Flex,{"data-flow-icon-caption":"",direction:"column",align:"center",gap:"8px",justify:"center",width:"100%",minW:0,textAlign:"center",children:[h.jsx(Zt,{nodeId:e,label:y,color:fe(((M=r==null?void 0:r.viewProps)==null?void 0:M.textColor)||s),isEditing:n,onEditStart:o,onEditEnd:i,wrap:!0}),typeof((I=r.config)==null?void 0:I.subtitle)=="string"&&r.config.subtitle!==""&&h.jsx(D.Text,{"data-flow-node-subtitle":"",color:fe(((N=r==null?void 0:r.viewProps)==null?void 0:N.textColor)||s),opacity:.65,fontSize:"32px",fontWeight:"normal",lineHeight:1.3,width:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",title:r.config.subtitle,children:r.config.subtitle})]})]})}return h.jsxs(D.Flex,{"data-flow-node-surface":"",align:"center",borderRadius:(O=r==null?void 0:r.viewProps)==null?void 0:O.borderRadius,bgColor:m,style:{backgroundColor:m},textTransform:"capitalize",...fn(r==null?void 0:r.viewProps,g,t,2),px:50,w:"fit-content",whiteSpace:"nowrap",children:[!!w&&h.jsx(D.Flex,{align:"center",py:14,mr:y?8:0,flexShrink:0,children:h.jsx(qr,{name:w,size:(((W=r==null?void 0:r.viewProps)==null?void 0:W.fontSize)||1)*100,color:b},b)}),(y||!w)&&h.jsx(D.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:"fit-content",maxW:900,minW:0,children:h.jsx(Zt,{nodeId:e,label:y,color:b,isEditing:n,onEditStart:o,onEditEnd:i})})]})};function Mm({onExpand:e,toggleLabel:t="Show properties",toggleDisabled:r=!1,renderCompact:n=w_,...o}){const{colorMode:i,callbacks:a}=Oe();return h.jsx(zn,{...o,children:s=>h.jsxs(D.Box,{position:"relative",children:[h.jsx(n,{...s}),e&&s.isActive&&h.jsx(D.Box,{position:"absolute",top:"-24px",right:"-48px","data-flow-content-toggle":"",children:h.jsx(je,{label:t,children:h.jsx(me,{"aria-label":t,icon:h.jsx(D.Icon,{as:J.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:i==="dark"?"gray.100":"gray.800",disabled:r,onClick:u=>{var c;u.stopPropagation(),e(),(c=a.onNodeViewToggle)==null||c.call(a,o.data.id)}})})})]})})}const ly=1.55;function C_({nodeId:e,content:t,color:r}){const{callbacks:n,config:o,readOnly:i}=Oe(),a=!!o.editable&&!i,[s,u]=S.useState(!1),[c,l]=S.useState(t),[d,f]=S.useState(),p=S.useRef(null),b=S.useRef(!1),g=nl(s);S.useLayoutEffect(()=>{const y=p.current;!s||!y||(y.style.height="auto",y.style.height=`${Math.max((d==null?void 0:d.height)??0,y.scrollHeight)}px`)},[c,s,d]),S.useEffect(()=>{var y;a?s&&(b.current=!1,(y=p.current)==null||y.focus()):u(!1)},[s,a]);const m=y=>{a&&(f({width:y.offsetWidth,height:y.offsetHeight}),l(t),u(!0))},w=()=>{var y;b.current||!a||(b.current=!0,c!==t&&((y=n.onNodeContentChange)==null||y.call(n,e,c)),u(!1))};return!s||!a?h.jsx(D.Box,{"data-flow-content":"",color:r,w:"100%",minH:"1.2em",whiteSpace:"normal",lineHeight:ly,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:a?"text":void 0,tabIndex:a?0:void 0,onDoubleClick:y=>{y.stopPropagation(),m(y.currentTarget)},onKeyDown:y=>{a&&y.key==="Enter"&&y.target===y.currentTarget&&(y.preventDefault(),y.stopPropagation(),m(y.currentTarget))},children:h.jsx(ov.default,{options:{forceBlock:!0,wrapper:S.Fragment,disableParsingRawHTML:!0,overrides:{a:{props:{target:"_blank",rel:"noopener noreferrer"}},img:{props:{loading:"lazy",referrerPolicy:"no-referrer"}}}},children:t})}):h.jsx("div",{ref:g,style:{width:d==null?void 0:d.width,minHeight:d==null?void 0:d.height,maxWidth:"100%"},children:h.jsx(D.Textarea,{ref:p,"aria-label":"Node content",value:c,onChange:y=>l(y.target.value),onBlur:w,onKeyDown:y=>{y.stopPropagation(),!y.nativeEvent.isComposing&&(y.key==="Enter"&&(y.ctrlKey||y.metaKey)&&(y.preventDefault(),w()),y.key==="Escape"&&(b.current=!0,u(!1)))},color:r,fontFamily:"inherit",fontSize:"inherit",lineHeight:ly,overflowWrap:"anywhere",whiteSpace:"pre-wrap",rows:1,bg:"transparent",display:"block",style:{border:0,outline:"none",boxShadow:"none"},p:0,w:"100%",h:"100%",minW:0,minH:0,resize:"none"})})}const __=(e,t,r)=>{var f,p,b,g;const n=((f=e==null?void 0:e.viewProps)==null?void 0:f.bgColor)||t,[o]=n.split("."),i=Yt(n),a=((p=e==null?void 0:e.viewProps)==null?void 0:p.outline)===!0,s=n==="transparent"||a,u=r==="dark"?"gray.200":"gray.900",c=s?"transparent":n!=null&&n.startsWith("#")?fe(n):fe(i.bgColor),l=fe(((b=e==null?void 0:e.viewProps)==null?void 0:b.textColor)||(s?u:i.textColor)),d=fe(((g=e==null?void 0:e.viewProps)==null?void 0:g.borderColor)||(a?n==="transparent"?t:n:i.borderColor));return{...i,bgColor:s?"transparent":i.bgColor,highlightColor:s?"transparent":i.highlightColor,isTransparent:s,propertyColor:s?u:i.propertyColor,bg:n,wordBeforeDot:o,hexbgColor:c,hextextColor:l,hexborderColor:d}},S_=(e,t=350)=>`${String(e).substring(0,t)}${String(e).length>t?"...":""}`,E_=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,qm=600,j_=3,R_=e=>{const t=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(t*28+30,200)};function k_({headerTitle:e,hasContent:t,data:r,icon:n,colors:o,hasConfig:i,id:a,isActive:s,isEditing:u,onEditStart:c,onEditEnd:l,props:d,objVisible:f,setObjVisible:p,onShowNativeIcon:b}){var y,x;const{callbacks:g}=Oe(),m=d.onShowIcon??b,w=m?"Show icon":f?"Show content":"Show properties";return h.jsx(h.Fragment,{children:(e||t||((y=r.config)==null?void 0:y.form)||s&&b)&&h.jsxs(D.Flex,{justify:"flex-start",direction:"row",p:Object.entries(r.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&&!t?"transparent":o.hexborderColor,children:[!!n&&h.jsx(D.Flex,{mr:6,alignItems:"center",flexShrink:0,children:h.jsx(qr,{name:n,size:64,color:o.hextextColor},o.hextextColor)}),h.jsx(Zt,{nodeId:a,label:E_(e),color:((x=r==null?void 0:r.viewProps)==null?void 0:x.textColor)||o.propertyColor,isEditing:u,onEditStart:c,onEditEnd:l}),s&&(t||m)&&h.jsx(D.Box,{ml:"auto",pl:6,flexShrink:0,"data-flow-content-toggle":"",children:h.jsx(je,{label:w,children:h.jsx(me,{"aria-label":w,icon:h.jsx(D.Icon,{as:J.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:o.hextextColor,onClick:v=>{var C;v.stopPropagation(),m?m():p(!f),(C=g.onNodeViewToggle)==null||C.call(g,a)}})})})]})})}function P_({data:e,resourcePorts:t,inspecting:r,form:n,inspectionPorts:o,extraPorts:i,colors:a,direction:s,uniformKeyWidth:u}){const{edgeById:c}=Ur(),l=new Set;for(const{data:d}of c.values())d.source===e.id&&d.sourceProperty!==void 0&&l.add(`source:${d.sourceProperty}`),d.target===e.id&&d.targetProperty!==void 0&&l.add(`target:${d.targetProperty}`);return h.jsx(D.Box,{children:Object.entries(e.description||{}).map(([d,f],p)=>{var M,I,N;const b=t&&Object.keys(t).find(O=>O.slice(O.indexOf(":")+1)===d),g=r&&((M=n==null?void 0:n.type.ports)==null?void 0:M[d]),m=b??(g?`${g.kind}:${d}`:d),w=o.find(O=>O.id===m),y=b?"source":w==null?void 0:w.role,x=l.has(`source:${m}`),v=l.has(`target:${m}`),C=i.some(O=>O.id===d),_=f===""&&(C||(y?l.has(`${y}:${m}`):x||v)),k=y??(x!==v?x?"source":"target":void 0),T=(w==null?void 0:w.side)??(k?k==="source"!=(s==="RL")?"right":"left":void 0),P=_&&T==="right"?"right":"left",j=(w==null?void 0:w.label)??(g==null?void 0:g.label)??(C?d.replace(/^(template|input|output|config|error):/,""):d),R=jr(a.wordBeforeDot)[typeof f],E=jr(a.wordBeforeDot).property;return h.jsxs(D.Box,{"data-flow-property":b&&(s==="TB"||s==="BT")?void 0:m,"data-flow-port-role":y,"data-flow-inspection-row":r?"":void 0,children:[h.jsxs(D.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[h.jsx(D.Flex,{justifyContent:"start",align:"center",background:a.highlightColor,width:_?"100%":`${u}px`,minWidth:`${u}px`,borderRightColor:a.hexborderColor,borderRightWidth:_?0:1,children:h.jsx(D.Text,{py:5,px:10,w:"100%",textAlign:P,whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((I=e==null?void 0:e.viewProps)==null?void 0:I.textColor)||(a.isTransparent?a.hextextColor:E),children:j})}),!_&&h.jsx(D.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:a.hexbgColor,w:qm,maxH:200,children:h.jsx(D.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)||(a.isTransparent?a.hextextColor:R),fontWeight:400,children:S_(f)})})]}),p!==Object.entries(e.description||{}).length-1&&h.jsx(D.Box,{borderTopWidth:1,my:0,borderColor:a.hexborderColor})]},d)})})}function A_(e){var x,v,C;const{themeColor:t,colorMode:r,direction:n}=Oe(),o=Vn(),i=o.getNodeViewMode(e.data.id)==="properties",a=_=>o.setNodeViewMode(e.data.id,_?"properties":"default"),s=!!e.onShowIcon||i||typeof((x=e.data.config)==null?void 0:x.content)!="string",{bindings:u,data:c,schema:l}=S.useContext(kr),d=(v=u==null?void 0:u[e.data.id])==null?void 0:v.portResources,f=u?Xt(u,e.data.id,l):c&&l?yt(c,e.data.id,l):void 0,p=f&&ve(c,"address"in f?f.address:e.data.id),b=p&&typeof p=="object"&&f?Object.fromEntries(Object.keys(f.type.properties).filter(_=>{var k;return Object.prototype.hasOwnProperty.call(p,_)&&wn((k=f.fields[_])==null?void 0:k.$visibleWhen,c)}).map(_=>[_,p[_]!==null&&typeof p[_]=="object"?JSON.stringify(p[_],null,2):p[_]===null?"null":p[_]])):{},g=d?Object.fromEntries(Object.entries(d).map(([_,k])=>{var T;return[_.slice(_.indexOf(":")+1),((T=ve(c,k))==null?void 0:T.name)??k.split(".").at(-1)]})):Object.keys(e.data.description??{}).length?e.data.description:b,m=s&&!d?((C=e.data.config)==null?void 0:C.ports)??[]:[],w=m.filter(_=>!Object.prototype.hasOwnProperty.call(g,_.id)&&!Object.entries((f==null?void 0:f.type.ports)??{}).some(([k,T])=>`${T.kind}:${k}`===_.id&&Object.prototype.hasOwnProperty.call(g,k))),y={...g,...Object.fromEntries(w.map(_=>[_.id,""]))};return{themeColor:t,colorMode:r,direction:n,objVisible:i,setObjVisible:a,inspecting:s,resourcePorts:d,form:f,description:y,inspectionPorts:m,extraPorts:w}}const ol=e=>{var m,w,y;const{themeColor:t,colorMode:r,direction:n,objVisible:o,setObjVisible:i,inspecting:a,resourcePorts:s,form:u,description:c,inspectionPorts:l,extraPorts:d}=A_(e),f=Vn(),p=f.getNodeViewMode(e.data.id)==="icon-label",g=!e.onShowIcon&&!((m=e.data.config)!=null&&m.parentContainer)&&typeof((w=e.data.config)==null?void 0:w.content)!="string"?()=>f.setNodeViewMode(e.data.id,"icon-label"):void 0;return!e.onShowIcon&&p?h.jsx(Mm,{...e,data:{...e.data,label:e.data.label??e.data.headerTitle,config:{...e.data.config,labelBelow:!0,icon:((y=e.data.config)==null?void 0:y.icon)||"PiBracketsCurly"}},onExpand:()=>f.restoreNodeView(e.data.id)}):h.jsx(zn,{...e,data:{...e.data,description:c},children:({id:x,data:v,isActive:C,isEditing:_,onEditStart:k,onEditEnd:T})=>{var z,re,te,he,be,K;const P=__(v,t,r),j=v.label??v.headerTitle,R=Object.entries(v.description||{}).length>0,E=R_(v.description),M=(re=(z=e.data)==null?void 0:z.config)==null?void 0:re.icon,I=(he=(te=e.data)==null?void 0:te.config)==null?void 0:he.content,N=typeof I=="string"&&!e.onShowIcon,O=((be=v==null?void 0:v.viewProps)==null?void 0:be.borderRadius)??"53px",W=fn(v==null?void 0:v.viewProps,P.hexborderColor,C,j_);return h.jsx(D.Flex,{justifyContent:"space-between",...v==null?void 0:v.viewProps,"data-flow-node-surface":"",direction:"column",p:0,borderRadius:O,overflow:"hidden",alignItems:"center",style:{backgroundColor:P.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:"100%",minW:N||e.onShowIcon?E+qm+W.borderWidth*2:void 0,...W,children:h.jsxs(D.Flex,{width:"100%",direction:"column",borderRadius:O,borderColor:P.hexborderColor,borderWidth:0,overflow:"hidden",children:[h.jsx(k_,{headerTitle:j,hasContent:N,data:v,icon:M,colors:P,hasConfig:R,id:x,isActive:C,isEditing:_,onEditStart:k,onEditEnd:T,props:e,objVisible:o,setObjVisible:i,onShowNativeIcon:g}),N&&!o?h.jsx(D.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:P.highlightColor,p:12,fontSize:"5xl",lineHeight:"normal",children:h.jsx(C_,{nodeId:x,content:I,color:((K=v==null?void 0:v.viewProps)==null?void 0:K.textColor)||P.hextextColor})}):h.jsx(P_,{data:v,resourcePorts:s,inspecting:a,form:u,inspectionPorts:l,extraPorts:d,colors:P,direction:n,uniformKeyWidth:E})]})})}})};ol.displayName="NodeJsonObjectView";const Nm=e=>{var c,l,d,f,p,b,g;const t=Vn(),r=t.getNodeViewMode(e.data.id)==="properties",n=m=>t.setNodeViewMode(e.data.id,m?"properties":"default"),{callbacks:o,readOnly:i}=Oe(),a=(l=(c=e.data)==null?void 0:c.config)==null?void 0:l.parentContainer,s=a?"Show parent":"Show properties",u=a||((f=(d=e.data)==null?void 0:d.config)==null?void 0:f.form)||((g=(b=(p=e.data)==null?void 0:p.config)==null?void 0:b.ports)==null?void 0:g.length);return!a&&u&&r?h.jsx(ol,{...e,onShowIcon:()=>n(!1)}):h.jsx(Mm,{...e,toggleLabel:s,toggleDisabled:a&&i,onExpand:u?()=>{var m;a?(m=o.onNodeCollapse)==null||m.call(o,e.data.id,!1):n(!0)}:void 0})},$m=e=>h.jsx(Nm,{...e,renderCompact:x_}),Lm=e=>h.jsx(Nm,{...e}),Fm=e=>h.jsx(zn,{...e,children:()=>null});$m.displayName="text";Lm.displayName="arrayView";Fm.displayName="ParentContainerView";const T_={objectView:ol,arrayView:Lm,text:$m,parentContainer:Fm},O_=({children:e,pattern:t="dot",backgroundColor:r})=>{const{colorMode:n}=Oe(),o=n==="dark",i=o?"--chakra-colors-gray-700":"--chakra-colors-gray-500",a=o?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return t==="none"?h.jsx(D.Box,{"data-flow-background":"none",width:"100%",height:"100%",padding:0,bg:r,children:e}):h.jsxs(D.Box,{"data-flow-background":t,position:"relative",width:"100%",height:"100%",padding:0,bg:r,children:[h.jsx(D.Box,{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:0,pointerEvents:"none",style:{backgroundImage:t==="dot"?`radial-gradient(var(${i}) 8%, transparent 8%)`:t==="steel"?`repeating-linear-gradient(45deg, var(${a}) 0, var(${a}) 1px, transparent 1px, transparent 20px)`:`linear-gradient(var(${a}) 1px, transparent 1px), linear-gradient(90deg, var(${a}) 1px, transparent 1px)`,backgroundSize:"20px 20px",opacity:.3}}),h.jsx(D.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:e})]})},I_=.4,Jr={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},M_=({nodes:e,edges:t})=>{const{themeColor:r,spacing:n,edgeRadius:o,backgroundVariant:i,setBackgroundSelected:a,edgeColor:s,direction:u,nodeAlignment:c,edgeMode:l,compactPropertyLayout:d,workflowContract:f,parentNodeStyle:p,engineRef:b,callbacks:g,config:m,selectedNodeIds:w,setSelectedNodeIds:y,selectedEdgeId:x,setSelectedEdgeId:v,setIsPerformanceMode:C,isZoomMode:_,setIsZoomMode:k,isMultiSelectMode:T,setIsMultiSelectMode:P,isDragMode:j,setIsDragMode:R,isEdgeHandlesEnabled:E,setIsEdgeHandlesEnabled:M,isArrayNodeMode:I}=Oe(),N=S.useRef(null),[O,W]=S.useState(null),z=e.length>200;S.useEffect(()=>{C(z)},[z,C]);const{edgeSep:re,rankSep:te,spacingFactor:he}=S.useMemo(()=>{const Q=b0(e.length),V=n<1?.3+.7*n:.5+.5*n;return{edgeSep:Q.edgeSep*V,rankSep:Q.rankSep*V,spacingFactor:1.3+(n-1)*(n<1?.4:.3)}},[e.length,n]),{bgColor:be}=Yt(r),{canvas:K,borderSecondary:q,colorText:L}=Ue(),G=i==="transparent"?"transparent":m.backgroundColor||K,B=S.useCallback(Q=>{if(Q!=null&&Q.includes("gray"))return"whitesmoke";if(!Q)return fe(r);switch(Q){case"dark":return fe(G);case"light":return fe(q);default:return fe(Q)}},[r,G,q]),Y=m.colorMode==="dark",ce=S.useMemo(()=>B(Y?be:"light"),[Y,be,B]),X=s?B(s):ce,U=S.useMemo(()=>m.initialViewport||{pan:{x:0,y:0},zoom:.01},[]),Z=u==="C"?"LR":u,ae=S.useCallback(Q=>{const V={...p,...Q};return{...V,bgColor:V.bgColor||r,bgOpacity:V.outline?0:V.bgOpacity??I_}},[p,r]),ue=S.useMemo(()=>{var V;const Q=new Map;for(const ee of e)(V=ee.data)!=null&&V.id&&Q.set(ee.data.id,ee);return Q},[e]),de=S.useMemo(()=>{var V;const Q=new Map;for(const ee of t)(V=ee.data)!=null&&V.id&&Q.set(ee.data.id,ee);return Q},[t]),Ee=S.useCallback(Q=>{var _e;const V=(_e=ue.get(Q))==null?void 0:_e.data,ee=ae(V==null?void 0:V.viewProps),we=fe(ee.bgColor);return{animated:!!(V!=null&&V.isNodeAnimated)&&!z,animationVariant:V==null?void 0:V.nodeAnimationVariant,animationColor:fe(ee.borderColor||r),bgColor:ee.outline?"transparent":we,bgOpacity:ee.bgOpacity,borderColor:ee.borderColor?fe(ee.borderColor):ee.outline&&ee.bgColor==="transparent"?fe(r):we,borderWidth:Kt(ee.borderWidth,Jr.borderWidth),borderStyle:ee.borderStyle??Jr.borderStyle,borderRadius:ee.borderRadius??Jr.borderRadius,textColor:ee.textColor?fe(ee.textColor):ee.outline||ee.bgColor==="transparent"?fe(L):we,fontSize:ee.fontSize??Jr.fontSize,labelPosition:ee.labelPosition??Jr.labelPosition,labelMargin:Jr.labelMargin,labelBg:ul(B("dark"),we,ee.bgOpacity)??B("dark"),padding:ee.padding??Jr.padding}},[ae,ue,L,r,z,B]),ge=S.useMemo(()=>{var ee,we;const Q=new Map;for(const _e of t){const Se=(ee=_e.data)==null?void 0:ee.source,Ve=(we=_e.data)==null?void 0:we.target;if(!Se||!Ve||Se===Ve)continue;const ke=Se<Ve?`${Se}|${Ve}`:`${Ve}|${Se}`,Me=Q.get(ke);Me?Me.push({id:_e.data.id,source:Se}):Q.set(ke,[{id:_e.data.id,source:Se}])}const V=new Map;for(const[_e,Se]of Q){if(Se.length<2)continue;const Ve=_e.split("|")[0],ke=Math.min(20,70/Se.length);Se.forEach(({id:Me,source:De},gr)=>{const sr=50+(gr-(Se.length-1)/2)*ke;V.set(Me,(De===Ve?sr:100-sr)/100)})}return V},[t]),He=S.useMemo(()=>{const Q=B("dark");return t.filter(V=>{var ee;return((ee=V.data)==null?void 0:ee.id)&&V.data.source&&V.data.target}).map(({data:V})=>{var Se,Ve,ke,Me,De,gr;let ee=Q;const we=(Ve=(Se=ue.get(V.source))==null?void 0:Se.data)==null?void 0:Ve.parent,_e=(Me=(ke=ue.get(V.target))==null?void 0:ke.data)==null?void 0:Me.parent;if(we&&we===_e){const sr=ae((gr=(De=ue.get(we))==null?void 0:De.data)==null?void 0:gr.viewProps),Pe=ul(Q,fe(sr.bgColor),sr.bgOpacity);Pe&&(ee=Pe)}return{id:V.id,data:V,type:V.type??m.edgeType??"rounded-orthogonal",source:V.source,target:V.target,sourceProperty:V.sourceProperty,targetProperty:V.targetProperty,label:V.label,validationIssue:(l==="auto"||l==="properties")&&(V.sourceProperty!==void 0||V.targetProperty!==void 0)&&f?Mu(f,V):void 0,color:V.color?fe(V.color):X,labelBg:ee,dashed:!!V.isEdgeDashed,animated:!!V.isEdgeAnimated,inverted:!!V.isInverted,turn:ge.get(V.id)??.5}})},[t,X,ge,m.edgeType,l,f,ue,ae,B]),Le=S.useMemo(()=>{var V;const Q=new Set;for(const ee of e)(V=ee.data)!=null&&V.parent&&Q.add(ee.data.parent);return Q},[e]),Xe=S.useMemo(()=>{var V;const Q=new Map;for(const ee of t)(V=ee.data)!=null&&V.source&&!Q.has(ee.data.source)&&Q.set(ee.data.source,ee.data);return Q},[t]),ur=S.useMemo(()=>{const Q={...T_,...m.customViews};return e.filter(V=>{var ee;return(ee=V.data)==null?void 0:ee.id}).map(V=>{var Ve,ke,Me,De;const ee=Le.has(V.data.id)&&!V.data.parent,we=ee?V.data.label??V.data.headerTitle??"Container":void 0,_e=ee?Q.parentContainer:Q[V.data.type]||Q.text,Se=Xe.get(V.data.id);return{id:V.data.id,collapsed:(Ve=V.data.config)==null?void 0:Ve.collapsed,parent:V.data.parent,label:we,animated:!!V.data.isNodeAnimated,animationVariant:V.data.nodeAnimationVariant,hasCollapseControl:((ke=V.data.config)==null?void 0:ke.collapsed)!==void 0,animationColor:fe(((Me=V.data.viewProps)==null?void 0:Me.borderColor)||r),animationWidth:Kt((De=V.data.viewProps)==null?void 0:De.borderWidth,8),element:S.createElement(_e,{...V,isInverted:Se==null?void 0:Se.isInverted,isParent:ee,key:`${V.data.id}-${r}`})}})},[e,Le,Xe,r,m.customViews]),Ge=S.useMemo(()=>z?300:e.length>50?150:e.length>20?100:50,[e.length,z]),Ne=S.useRef(m);Ne.current=m;const xe=S.useRef(_);xe.current=_;const Ie=S.useRef(I);Ie.current=I;const $e=S.useRef(w);$e.current=w;const tr=S.useRef(x);tr.current=x;const Je=S.useRef(T);Je.current=T;const Ze=S.useRef(ue);Ze.current=ue;const fr=S.useRef(de);fr.current=de;const wr=S.useRef(new Map);S.useEffect(()=>{var ee,we;const Q=new Map([...de].filter(([,_e])=>ue.has(_e.data.source)&&ue.has(_e.data.target))),V=wr.current;wr.current=Q;for(const[_e,Se]of V)Q.has(_e)||(tr.current===_e&&(v(null),(ee=g.onEdgeDeselect)==null||ee.call(g)),(we=g.onEdgeRemove)==null||we.call(g,_e,Se.data))},[de,ue,g,v]),S.useEffect(()=>{const Q=N.current;if(!O||!Q)return;let V=null,ee=null,we=0,_e=0,Se=0,Ve=0,ke=0;const Me=De=>{if(Ne.current.readOnly)return;De.preventDefault(),De.stopPropagation(),xe.current||De.metaKey||De.ctrlKey?(Se+=De.deltaY,Ve=De.clientX,ke=De.clientY,ee===null&&(ee=requestAnimationFrame(()=>{ee=null;const sr=Ne.current,Pe=O.zoom(),Er=Se;Se=0;let Ar=Pe-Er*.05/100;Ar=Math.max(sr.minZoom??.01,Math.min(sr.maxZoom??1.5,Ar));const Lr=Q.getBoundingClientRect();O.zoomAt(Ar,{x:Ve-Lr.left,y:ke-Lr.top})}))):(we+=De.deltaX,_e+=De.deltaY,V===null&&(V=requestAnimationFrame(()=>{V=null;const sr=O.pan(),Pe=O.zoom(),Er=.35,Ar=we,Lr=_e;we=0,_e=0,O.pan({x:sr.x+-Ar*Er/Pe,y:sr.y+-Lr*Er/Pe})})))};return Q.addEventListener("wheel",Me,{passive:!1}),()=>{Q.removeEventListener("wheel",Me),V!==null&&cancelAnimationFrame(V),ee!==null&&cancelAnimationFrame(ee)}},[O]),S.useEffect(()=>{if(m.disableKeyboardShortcuts)return;const Q=V=>{var we,_e,Se,Ve;if(Ne.current.readOnly)return;const ee=V.target;if(!(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.isContentEditable)){if((V.key==="z"||V.key==="Z")&&k(!xe.current),(V.key==="m"||V.key==="M")&&P(!T),(V.key==="d"||V.key==="D")&&R(!j),(V.key==="v"||V.key==="V")&&!V.repeat&&!V.metaKey&&!V.ctrlKey&&!V.altKey&&ee.tagName!=="SELECT"&&M(!E),(V.key==="Delete"||V.key==="Backspace")&&tr.current){V.preventDefault();const ke=tr.current;(_e=g.onEdgeDelete)==null||_e.call(g,ke,((we=fr.current.get(ke))==null?void 0:we.data)??{id:ke}),v(null);return}if((V.key==="Delete"||V.key==="Backspace")&&$e.current.length>0){V.preventDefault();const ke=$e.current.filter(Me=>Me!=="root");if(ke.length===0)return;for(const Me of ke){const De=(Se=Ze.current.get(Me))==null?void 0:Se.data;(Ve=g.onNodeDelete)==null||Ve.call(g,Me,De||{})}y([])}}};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[T,j,E,M,k,P,R,m.disableKeyboardShortcuts,g,y,v]);const Ce=S.useCallback(Q=>{var V;b.current=Q,W(Q),(V=g.onInit)==null||V.call(g,Q)},[b,g]),ir=S.useCallback(Q=>{var V;return(V=g.onViewportChange)==null?void 0:V.call(g,Q)},[g]),ar=S.useCallback(Q=>{var ee,we,_e;const V=((ee=fr.current.get(Q))==null?void 0:ee.data)??{id:Q};if(tr.current===Q&&Je.current){v(null),(we=g.onEdgeDeselect)==null||we.call(g);return}$e.current.length&&y([]),v(Q),(_e=g.onEdgeSelect)==null||_e.call(g,Q,V)},[g,v,y]),Ct=S.useCallback(()=>{var Q,V,ee;a(!0),(Q=g.onBackgroundClick)==null||Q.call(g),$e.current.length&&(y([]),(V=g.onNodeDeselect)==null||V.call(g)),tr.current&&(v(null),(ee=g.onEdgeDeselect)==null||ee.call(g))},[g,y,v,a]),ne=S.useCallback(Q=>{var we,_e;const V=$e.current,ee=Q.filter(Se=>!V.includes(Se));if(ee.length){y([...V,...ee]);for(const Se of ee)(_e=g.onNodeSelect)==null||_e.call(g,Se,((we=Ze.current.get(Se))==null?void 0:we.data)??{id:Se})}},[g,y]),ze=S.useCallback((Q,V)=>{var ee,we;y([Q]),(we=g.onNodeSelect)==null||we.call(g,Q,((ee=Ze.current.get(Q))==null?void 0:ee.data)??{id:Q},V)},[g,y]),Qe=S.useCallback((Q,V,ee)=>{var we;return(we=g.onEdgeCreate)==null?void 0:we.call(g,Q,V,ee)},[g]),Fe=S.useCallback((Q,V,ee,we=!1)=>{var _e,Se;l==="properties"&&((_e=g.onNodeCreateRequest)==null?void 0:_e.call(g,{sourceNodeId:Q,position:V,sourceProperty:ee,reverse:we}))===!0||ee!==void 0||we||(Se=g.onNodeCreate)==null||Se.call(g,{type:"text",sourceNodeId:Q,position:V,isArrayMode:Ie.current})},[g,l]),er=!m.readOnly&&E&&m.edgeHandles!==!1,Be=i==="transparent"?"none":i;return h.jsx(O_,{pattern:Be,backgroundColor:G,children:h.jsx(D.Box,{ref:N,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:h.jsx(y_,{nodes:ur,edges:He,direction:Z,nodeAlignment:c,onContainerCollapse:Q=>{var V,ee;(V=g.onNodeCollapse)==null||V.call(g,Q,!0),(ee=g.onNodeViewToggle)==null||ee.call(g,Q)},selectedNodeIds:w,edgeMode:l,compactPropertyLayout:d,edgeType:m.edgeType,edgeRadius:o,customEdgeTypes:m.customEdgeTypes,rankSep:te,edgeSep:re,spacingFactor:he,compactSpacingScale:n,layoutDebounce:Ge,isPerformanceMode:z,minZoom:m.minZoom??.01,maxZoom:m.maxZoom??1.5,initialViewport:U,fitOnInit:!m.initialViewport,readOnly:!!m.readOnly,containerStyle:Ee,lineColor:X,drawMode:er,drawHandles:!m.readOnly&&m.edgeHandles!==!1,dragMode:j,multiSelect:!!T,onInit:Ce,onLayoutComplete:g.onLayoutComplete,animateViewport:m.animateViewport,onViewportChange:ir,onBackgroundTap:Ct,onBoxSelect:ne,onEdgeSelect:ar,onContainerSelect:ze,onEdgeDraw:Qe,onDrawIntoSpace:Fe})})})},Bm=S.memo(M_),q_=".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 dy=!1;function N_(){if(dy||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=q_+y0+p0+".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}',dy=!0}function $_({loading:e=!1,loader:t,...r}){var u,c;const[n,o]=S.useState(null),i=S.useMemo(()=>!!(n!=null&&n.json)&&!!r.json&&d0(n.json,r.json),[n==null?void 0:n.json,r.json]),a=n===null||n.json!==r.json&&!i,s=e||a;return S.useEffect(()=>{!e&&i&&(n==null?void 0:n.json)!==r.json&&o(r)},[e,i,n==null?void 0:n.json,r.json]),S.useEffect(()=>{if(e||!a)return;let l;const d=requestAnimationFrame(()=>{l=requestAnimationFrame(()=>o(r))});return()=>{cancelAnimationFrame(d),l!==void 0&&cancelAnimationFrame(l)}},[e,a,r.json]),h.jsxs(D.Box,{className:r.className,style:r.style,width:"100%",height:"100%",position:"relative","aria-busy":s,children:[h.jsx("div",{style:{width:"100%",height:"100%"},ref:l=>{s?l==null||l.setAttribute("inert",""):l==null||l.removeAttribute("inert")},children:n&&h.jsx(L_,{...a?n:r,className:void 0,style:void 0})}),s&&t!==null&&h.jsx(D.Box,{"data-flow-loader":"",role:"status","aria-label":"Loading diagram",position:"absolute",inset:0,zIndex:1e3,display:"grid",placeItems:"center",background:((u=r.config)==null?void 0:u.colorMode)==="dark"?"gray.800":"gray.100",color:((c=r.config)==null?void 0:c.colorMode)==="dark"?"whiteAlpha.800":"blackAlpha.800",children:t===void 0?h.jsx("span",{children:"Loading diagram..."}):t})]})}function L_({title:e="untitled",json:t,forms:r,nodes:n,edges:o,config:i={},callbacks:a={},className:s,style:u,showBottomBar:c=!0,children:l}){N_();const[d,f]=S.useState(),[p,b]=S.useState(!1),g=i.formSchema??d,m=S.useMemo(()=>t&&r?tb(t,r.state):t,[t,r==null?void 0:r.state]),w=i.direction==="C",y=S.useMemo(()=>{let R,E;return M=>(E=R&&E?f0(R,M,E)??vu(M,{title:e,isCenter:w}):vu(M,{title:e,isCenter:w}),R=M,E)},[e,w]),x=S.useMemo(()=>m?y(m):null,[m,y]),v=S.useMemo(()=>r!=null&&r.structured&&!p&&g?i0(r.state,r.bindings,g,(x==null?void 0:x.nodes)??n??[]):void 0,[r==null?void 0:r.structured,p,r==null?void 0:r.state,r==null?void 0:r.bindings,g,x,n]),C=(v==null?void 0:v.schema)??g,_=(v==null?void 0:v.bindings)??(r==null?void 0:r.bindings),k=S.useMemo(()=>[...(x==null?void 0:x.nodes)??n??[],...(v==null?void 0:v.nodes)??[]].map(E=>{var re,te,he,be;const M=t?(re=ve(t,E.data.id))==null?void 0:re.$view:(te=E.data.config)==null?void 0:te.typeView,I=M&&Dt.includes(M)?M:void 0,N=I?I==="icon-label":(he=E.data.config)==null?void 0:he.labelBelow,O=I==="object"?"objectView":I==="text"?"text":N?"arrayView":E.data.type,W=C&&(r?Xt(_,E.data.id,C):t&&yt(t,E.data.id,C)),z=(((be=E.data.config)==null?void 0:be.ports)??[]).map(K=>({...K}));if(v&&W){const K=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[q,L]of Object.entries(W.type.ports??{})){const G=`${L.kind}:${q}`,B=z.find(Y=>Y.id===G);B?B.label===void 0&&L.label!==void 0&&(B.label=L.label):z.push({id:G,...L.label!==void 0?{label:L.label}:{},role:L.kind==="input"||L.kind==="config"?"target":"source",side:K[L.kind],...L.kind==="config"?{placement:"config"}:{}})}for(const q of z){const L=z.filter(G=>G.side===q.side);q.position=(L.indexOf(q)+1)/(L.length+1)}}return W||N||I?{...E,data:{...E.data,type:O,...r?{description:Object.fromEntries(Object.entries(E.data.description??{}).filter(([K])=>!K.startsWith("$")&&!(v!=null&&v.slots.has(kt(E.data.id,K)))))}:{},config:{...E.data.config,...v&&W?{ports:z}:{},...W?{form:!0}:{},...I?{typeView:I,labelBelow:!!N}:N?{labelBelow:!0}:{}}}}:E}),[x,n,t,C,_,v,i.direction]),T=[...(x==null?void 0:x.edges)??o??[],...(v==null?void 0:v.edges)??[]],P=S.useMemo(()=>{const R=t&&x?Cb(t,x.edges,a,a.onJsonChange,g):{...a};if(v){const E=new Set([...v.nodes.map(M=>M.data.id),...v.edges.map(M=>M.data.id)]);for(const M of Object.keys(R)){if(!/^on(?:Node|Edge).*(?:Change|Collapse)$/.test(M))continue;const I=R[M];R[M]=(N,...O)=>{if(!E.has(N))return I==null?void 0:I(N,...O)}}}return{...R,onAllNodesIconLabelChange:E=>{var M;b(E),(M=R.onAllNodesIconLabelChange)==null||M.call(R,E)}}},[t,x,a,g,v]),j=S.useMemo(()=>{if(!r)return P;let R=r.state;const E=I=>{if(i.readOnly||i.editable===!1)return;const N=r.onStateChange??r.onChange;if(!N)return;const O=Xx(R,I,a.onFormChange);O!==R&&(R=O,N(O,{...I,data:O}))},M=(I,N,O)=>{var z;const W=t&&((z=ve(t,I))==null?void 0:z[N]);return!W||typeof W.$state!="string"?!1:(E({address:W.$state,nodeAddress:I,previousValue:ve(R,W.$state),value:O,data:R}),!0)};return{...P,onFormChange:E,onNodeCreateRequest:I=>{var W,z;const N=(W=I.sourceProperty)!=null&&W.startsWith("config:")?I.sourceProperty.slice(7):void 0,O=N!==void 0&&(v==null?void 0:v.slots.get(kt(I.sourceNodeId,N)));return O?(O.present||E({data:R,nodeAddress:O.address.split(".").slice(0,-1).join("."),address:O.address,value:Pt(O.type),previousValue:void 0}),!0):((z=P.onNodeCreateRequest)==null?void 0:z.call(P,I))??!1},onNodeDelete:(I,N)=>{var he,be;if(!(v!=null&&v.nodes.some(K=>K.data.id===I)))return(he=P.onNodeDelete)==null?void 0:he.call(P,I,N);const O=v&&[...v.slots.values()].find(K=>K.nodeId===I);if(!O)return(be=P.onNodeDelete)==null?void 0:be.call(P,I,N);const W=O.address.split("."),z=W.pop(),re=W.join("."),te=ve(R,re);E(Array.isArray(te)?{data:R,nodeAddress:re,address:re,previousValue:te,value:te.filter((K,q)=>String(q)!==z)}:{data:R,nodeAddress:re,address:O.address,previousValue:ve(R,O.address),value:void 0})},onEdgeCreate:(I,N,O)=>{var re,te;const W=((re=O==null?void 0:O.targetProperty)==null?void 0:re.startsWith("config:"))&&(v==null?void 0:v.slots.get(kt(N,O.targetProperty.slice(7)))),z=v==null?void 0:v.containers.get(I);if(W&&z&&(O==null?void 0:O.sourceProperty)==="output:resource"){const he=o0(R,z,W);he!==void 0&&E({data:R,nodeAddress:W.address.split(".").slice(0,-1).join("."),address:W.address,previousValue:ve(R,W.address),value:he});return}W||v!=null&&v.nodes.some(he=>he.data.id===I||he.data.id===N)||(te=P.onEdgeCreate)==null||te.call(P,I,N,O)},onEdgeDelete:(I,N)=>{var be;const O=v==null?void 0:v.edges.find(K=>K.data.id===I);if(!O)return(be=P.onEdgeDelete)==null?void 0:be.call(P,I,N);const W=v.slots.get(kt(O.data.target,O.data.targetProperty.slice(7))),z=W.address.split("."),re=z.pop(),te=z.join("."),he=ve(R,te);E(Array.isArray(he)?{data:R,nodeAddress:te,address:te,previousValue:he,value:he.filter((K,q)=>String(q)!==re)}:{data:R,nodeAddress:te,address:W.address,previousValue:ve(R,W.address),value:void 0})},onNodeContentChange:(I,N)=>{var O,W;M(I,"$content",N)?(O=a.onNodeContentChange)==null||O.call(a,I,N):(W=P.onNodeContentChange)==null||W.call(P,I,N)},onNodeLabelChange:(I,N)=>{var O,W;M(I,"$label",N)?(O=a.onNodeLabelChange)==null||O.call(a,I,N):(W=P.onNodeLabelChange)==null||W.call(P,I,N)}}},[P,r,t,a,v,i.readOnly,i.editable]);return h.jsx(kr.Provider,{value:{data:(r==null?void 0:r.state)??t,viewData:t,bindings:_,references:r==null?void 0:r.references,structured:v,renderForm:r==null?void 0:r.renderForm,editable:r?!!(r.onStateChange??r.onChange):!!a.onJsonChange,schema:C,setSchema:R=>{var E;f(R),(E=a.onFormSchemaChange)==null||E.call(a,R)},callbacks:j},children:h.jsx(my,{config:v?{...i,formSchema:C}:i,callbacks:j,nodes:k,edges:T,children:h.jsxs(D.Box,{className:s,"data-flow-diagram":"",style:u,width:"100%",height:"100%",position:"relative",overflow:"hidden",css:{"& input, & textarea, & select":{outline:"none !important",boxShadow:"none !important"}},children:[h.jsx(Bm,{nodes:k,edges:T}),c&&h.jsx(vb,{}),l]})})})}function F_(e){return Su(JSON.parse(e))}function Su(e){if(!e||typeof e!="object")throw new Error("Expected a JSON object or array.");const t=new Set,r=n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(!n||typeof n!="object"||t.has(n)||!Array.isArray(n)&&![Object.prototype,null].includes(Object.getPrototypeOf(n)))throw new Error("Document must contain only finite, acyclic JSON values.");t.add(n);for(const[o,i]of Object.entries(n)){if(["__proto__","prototype","constructor"].includes(o))throw new Error(`Unsafe document key: ${o}`);r(i)}t.delete(n)}};return r(e),structuredClone(e)}function B_(e){return{replaceJson(t){if(e.readOnly||!e.onJsonChange)throw new Error("JSON document is read-only.");const r=Su(t);return e.onJsonChange(r,{type:"documentReplace",address:"root"}),r},replaceState(t){if(e.readOnly||!e.onStateChange)throw new Error("Form state is read-only.");const r=Su(t);return e.onStateChange(r,{address:"root",nodeAddress:"root",previousValue:e.state,value:r,data:r}),r}}}function D_(e,t){const r=(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,a)=>r(i,o[a])).filter(i=>i!==void 0):void 0:Object.fromEntries(Object.entries(n).flatMap(([i,a])=>{if(!Object.prototype.hasOwnProperty.call(o,i))return[];if(i.startsWith("$")&&i!=="$")return JSON.stringify(a)===JSON.stringify(o[i])?[[i,a]]:[];const s=r(a,o[i]);return s===void 0?[]:[[i,s]]}))};return r(e,t)??{}}function un(e){let t="",r=!1,n="",o;const i=()=>{clearTimeout(o),o=void 0},a=()=>{if(i(),!(r||!t.trim()))try{const u=e.parse(e.repair(t)),c=JSON.stringify(u);if(c===n)return;e.preview(u),n=c}catch{}},s=u=>{if(!r){if(new TextEncoder().encode(u).byteLength>(e.maxBytes??1024*1024))throw r=!0,i(),new Error("JSON stream exceeds the size limit.");t=u,o||(o=setTimeout(a,e.intervalMs??150))}};return{snapshot:s,append(u){s(t+u)},flush:a,finish(){if(r)throw new Error("JSON stream is closed.");r=!0,i();const u=e.parse(t);return e.commit(u),u},cancel(){r=!0,i(),t=""}}}function z_(e){const{source:t}=e,r=e.tickMs??50,n=e.durationMs??8e3;if(!Number.isFinite(r)||r<=0||!Number.isFinite(n)||n<=0)throw new Error("Playback timing must be positive.");if(new TextEncoder().encode(t).byteLength>(e.maxBytes??1024*1024))throw new Error("JSON stream exceeds the size limit.");e.parse(t);let o=un(e),i=0,a=!1,s=!1,u;const c=Math.max(1,Math.ceil(t.length*r/n)),l=()=>e.onChange({position:i,total:t.length,playing:a}),d=()=>{clearTimeout(u),u=void 0},f=(g=!1)=>{o.snapshot(t.slice(0,i)),i===t.length?(a=!1,d(),o.finish()):g&&o.flush()},p=g=>{a=!1,d(),o.cancel(),l(),e.onError(g)},b=()=>{if(u=void 0,!(!a||s)){i=Math.min(t.length,i+c);try{f()}catch(g){p(g);return}l(),a&&(u=setTimeout(b,r))}};return{play(){s||a||(i===t.length&&(o.cancel(),o=un(e),i=0),a=!0,l(),u=setTimeout(b,r))},pause(){s||(a=!1,d(),o.flush(),l())},seek(g){if(!s){if(!Number.isFinite(g))throw new Error("Playback position must be finite.");d(),i=Math.max(0,Math.min(t.length,Math.round(g))),o.cancel(),o=un(e);try{f(!0)}catch(m){p(m);return}l(),a&&(u=setTimeout(b,r))}},dispose(){s=!0,a=!1,d(),o.cancel()}}}function V_({nodeAddress:e,expanded:t=!1}){var c;const{data:r,schema:n,bindings:o}=S.useContext(kr),{colorText:i,background:a}=Ue();if((c=o==null?void 0:o[e])!=null&&c.portResources)return null;const s=o&&Xt(o,e,n);if(!r||!s)return null;const u=ve(r,s.address);return!u||typeof u!="object"?null:h.jsx("div",{"data-flow-config-summary":"",style:{width:"100%",minWidth:0,color:fe(i),background:fe(a),fontSize:24,lineHeight:1.4,textTransform:"none"},children:Object.keys(s.type.properties).map(l=>{const d=s.fields[l]??{};if(!wn(d.$visibleWhen,r))return null;const f=u[l],p=f==null?"":typeof f=="object"?JSON.stringify(f):String(f);return h.jsxs("div",{"data-flow-property":l,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:[h.jsx("span",{style:{overflowWrap:"anywhere"},children:Cr(d.$label??l)}),h.jsx("span",{title:p,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:t?"pre-wrap":"nowrap",overflowWrap:t?"anywhere":void 0},children:p})]},l)})})}exports.BottomBar=vb;exports.CompactPropertyLayoutToggle=zy;exports.ConnectionsOnlyToggle=l0;exports.DEFAULT_PALETTE=$u;exports.DiagramAppearanceControls=Wy;exports.DynamicIcon=qr;exports.EdgeTools=ub;exports.EditableLabel=Zt;exports.ErrorToast=yb;exports.FlowDiagram=$_;exports.FlowDiagramProvider=my;exports.FlowPort=Om;exports.FlowView=Bm;exports.FormDocumentContext=kr;exports.NODE_TYPE_VIEWS=Dt;exports.NodeBorderRadiusControl=lb;exports.NodeConfigSummary=V_;exports.NodeForm=ob;exports.NodeFormPopover=Im;exports.NodeIconPicker=Nu;exports.NodeTools=db;exports.NodeView=zn;exports.SvgExportButton=pb;exports.Swatches=Jt;exports.TEXT_PALETTE=sb;exports.ToolbarCloseButton=gt;exports.ToolbarCommitInput=et;exports.ToolbarDivider=Mt;exports.ToolbarIconButton=me;exports.ToolbarRangeInput=Vy;exports.ToolbarScrollContainer=gb;exports.ToolbarSelect=Ir;exports.ToolbarTooltip=je;exports.TooltipIconButton=_u;exports.WorkflowControls=bb;exports.addChild=Au;exports.addConnection=Tu;exports.addTargetEdge=Xy;exports.addressToPath=Mr;exports.applyCollapsed=Zx;exports.applyFormChange=Cn;exports.applyStateEdits=Yx;exports.bindSqueedCallbacks=Cb;exports.compileSqueed=vu;exports.connectionIssue=Mu;exports.contentObjTheme=jr;exports.createFlowDiagram=Qr;exports.createFlowDocumentActions=B_;exports.createFormNode=wb;exports.createJsonPlayback=z_;exports.createJsonStream=un;exports.downloadSvg=hb;exports.exportSvg=fb;exports.formValueError=Rr;exports.getChakraColorHex=fe;exports.getColorVariant=vy;exports.getDarkerHexColor=ln;exports.getInteractionSurface=zr;exports.getNode=ve;exports.parseFlowDocument=F_;exports.parseJsonContract=Ou;exports.parseTypeScriptContract=eb;exports.parseTypeScriptForm=Iu;exports.projectJsonPlaybackPreview=D_;exports.readFormSchema=qu;exports.readWorkflowContract=rb;exports.removeEdge=Qy;exports.removeNode=Yy;exports.resolveEdgeOwner=Wt;exports.resolveStateView=tb;exports.setCollapsed=Jy;exports.setEdgeProp=Br;exports.setEdgeStyle=Zy;exports.setNodeProp=cr;exports.updateNode=br;exports.useCustomColors=Ue;exports.useEdgeProximity=py;exports.useFlowData=Ur;exports.useFlowDiagramContext=Oe;exports.useNodeViewActions=Vn;exports.useStopPropagation=nl;exports.useThemeContentColors=Yt;
186
190
  //# sourceMappingURL=index.cjs.map