@squeed/flow-sdk 2.0.18 → 2.0.19
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 +11 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4648 -4645
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var xv=Object.create;var go=Object.defineProperty;var wv=Object.getOwnPropertyDescriptor;var Cv=Object.getOwnPropertyNames;var Sv=Object.getPrototypeOf,_v=Object.prototype.hasOwnProperty;var Ev=(e,t,r)=>t in e?go(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var jv=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Cv(t))!_v.call(e,i)&&i!==r&&go(e,i,{get:()=>t[i],enumerable:!(n=wv(t,i))||n.enumerable});return e};var Ve=(e,t,r)=>(r=e!=null?xv(Sv(e)):{},jv(t||!e||!e.__esModule?go(r,"default",{value:e,enumerable:!0}):r,e));var $r=(e,t,r)=>Ev(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),F=require("@chakra-ui/react"),_=require("react"),K=require("react-icons/pi"),$y=require("@emotion/react"),kv=require("@emotion/styled"),Rv=require("react-icons/tb"),tn=require("react-dom"),Pv=require("markdown-to-jsx/react"),Ny=e=>e&&e.__esModule?e:{default:e},Mn=Ny(kv),Av=Ny(Pv);function Tv(e,t){let r,n,i,o;const s=(u=r)=>!!u&&["completed","failed","cancelled"].includes(u.status),a=()=>{const u=o;o=void 0,u==null||u()},c=u=>{if(!n||n.signal.aborted||!r||u.executionId!==r.executionId||s())return;const{step:l,...d}=u;r={...r,...d,steps:l?{...r.steps,[l.id]:{...r.steps[l.id],...l}}:r.steps},n.state=r,s()&&a(),t(r)};return{getState:()=>r,async run(u,l=crypto.randomUUID()){if(n&&!n.signal.aborted&&!s())throw new Error("An execution is already active.");i==null||i.abort(),a(),i=new AbortController;const d={executionId:l,input:u,signal:i.signal,state:{executionId:l,status:"subscribing",steps:{}}};n=d,r=d.state,t(r);try{const h=await e.subscribe(d,y=>{n===d&&c(y)});if(n!==d||d.signal.aborted||s())return h(),d.state;if(o=h,c({executionId:l,status:"running"}),n!==d||d.signal.aborted||s(d.state))return d.state;const p=await e.execute(d);n===d&&p&&c(p)}catch(h){if(s(d.state))return d.state;throw n===d&&!d.signal.aborted&&c({executionId:l,status:"failed",error:h instanceof Error?h.message:String(h)}),h}return d.state},async cancel(){const u=n;if(!(!u||u.signal.aborted||s())){if(!e.cancel)throw new Error("This adapter does not support cancellation.");await e.cancel(u),n===u&&c({executionId:u.executionId,status:"cancelled"})}},dispose(){i==null||i.abort(),n=void 0,a()}}}function Ly({edge:e,enabled:t,bounds:r,inside:n=[],threshold:i=80}){const[o,s]=_.useState(!1),[a,c]=_.useState(!1),u=_.useRef(n);return u.current=n,_.useEffect(()=>{if(!t)return;const l=()=>{const h=document.querySelectorAll(':popover-open, dialog[open], [role="dialog"], [role="menu"], [role="listbox"]');c(Array.from(h).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]),_.useEffect(()=>{const l=h=>{var w;const p=(w=r.current)==null?void 0:w.getBoundingClientRect();if(!p)return;const y=h.target instanceof Node?h.target:null,m=!!y&&u.current.some(v=>{var x;return(x=v.current)==null?void 0:x.contains(y)}),g=e==="bottom"?p.bottom-h.clientY:h.clientY-p.top,b=h.clientX>=p.left&&h.clientX<=p.right&&g>=0&&g<=i;s(m||b)},d=()=>s(!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,i]),t&&(o||a)}const Pt="#c6c6c6";function Rn(e,t=.2){const r=e.replace(/^#/,""),n=parseInt(r,16);let i=n>>16&255,o=n>>8&255,s=n&255;return i=Math.max(0,Math.floor(i*(1-t))),o=Math.max(0,Math.floor(o*(1-t))),s=Math.max(0,Math.floor(s*(1-t))),"#"+((1<<24)+(i<<16)+(o<<8)+s).toString(16).slice(1).toUpperCase()}function Al(e,t,r){const n=a=>{const c=/^#?([0-9a-f]{6})$/i.exec((a==null?void 0:a.trim())??"");return c?parseInt(c[1],16):null},i=n(e),o=n(t);if(i===null||o===null)return null;const s=a=>Math.round((i>>a&255)*(1-r)+(o>>a&255)*r);return"#"+((1<<24)+(s(16)<<16)+(s(8)<<8)+s(0)).toString(16).slice(1).toUpperCase()}const Ir=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:Rn(e,.1),border:Rn(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"},Fy=e=>{if(e==="transparent")return{primary:e,secondary:e,light:e};let t=e;if(t!=null&&t.startsWith("#"))return{secondary:Rn(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}},Tl={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"}},ve=(e,t)=>{var o;if(e==="transparent"||e!=null&&e.startsWith("#")||e!=null&&e.startsWith("var(--"))return e;if(!e)return"whitesmoke";const r=e.replace(/\./g,"-");try{const a=getComputedStyle(document.documentElement).getPropertyValue(`--chakra-colors-${r}`).trim();if(a&&a!=="")return a}catch{}const[n,i]=e.split(".");return n&&i&&((o=Tl[n])!=null&&o[Number(i)])?Tl[n][Number(i)]:`var(--chakra-colors-${r})`},Iv=$y.keyframes`
|
|
2
2
|
0%, 100% { box-shadow: var(--flow-rest-shadow); }
|
|
3
3
|
25%, 50% { box-shadow: var(--flow-hover-shadow); }
|
|
4
|
-
`,
|
|
4
|
+
`,Ov=$y.keyframes`
|
|
5
5
|
from { box-shadow: var(--flow-start-shadow); }
|
|
6
6
|
to { box-shadow: var(--flow-rest-shadow); }
|
|
7
|
-
`;function Fy(e,t=!0,r="&:hover",n=!0){const i=`color-mix(in srgb, ${e} 60%, transparent)`,s=`0 0 0 ${t?8:0}px ${i}`,a=`0 0 0 8px ${i}`;return{boxShadow:s,css:{"--flow-rest-shadow":a,"--flow-hover-shadow":`0 0 0 18px ${i}`,"@media (hover: hover)":{[r]:{boxShadow:a,"@media (prefers-reduced-motion: no-preference)":{animation:n?`${Av} 1200ms steps(10, end) 600ms`:"none"}}}}}}function Hr(e,t){const{boxShadow:r,css:n}=Fy(e,!1),i=n["@media (hover: hover)"]["&:hover"];return{borderWidth:"1px",borderStyle:"solid",borderColor:"transparent",boxShadow:r,...n,"--flow-start-shadow":r,"@media (hover: hover)":{"&:hover":{...i,borderColor:t,"@media (prefers-reduced-motion: no-preference)":{animation:`${Tv} 600ms steps(5, end)`}}}}}const By=_.createContext(null),zy=_.createContext({nodeById:new Map,edgeById:new Map,parentIds:new Set});function Yr(){return _.useContext(zy)}function Ne(){const e=_.useContext(By);if(!e)throw new Error("useFlowDiagramContext must be used within FlowDiagram");return e}function Dy({config:e,callbacks:t,nodes:r=[],edges:n=[],children:i}){const o=_.useMemo(()=>{var Ge,ir,er;const ae=new Map;for(const Z of r)(Ge=Z.data)!=null&&Ge.id&&ae.set(Z.data.id,Z);const Ve=new Map;for(const Z of n)(ir=Z.data)!=null&&ir.id&&Ve.set(Z.data.id,Z);const or=new Set;for(const Z of r)(er=Z.data)!=null&&er.parent&&or.add(Z.data.parent);return{nodeById:ae,edgeById:Ve,parentIds:or}},[r,n]),s=_.useRef(null),[a,c]=_.useState([]),[u,l]=_.useState(null),[d,h]=_.useState(!0),[p,y]=_.useState(!1),[m,g]=_.useState(!0),[b,w]=_.useState(!1),[v,x]=_.useState(!1),[C,S]=_.useState(!0),[E,I]=_.useState(!1),[A,M]=_.useState("auto"),[j,R]=_.useState(!1),P=e.compactPropertyLayout??j,[k,q]=_.useState({}),O=e.nodeViewModes??k,z=[...o.nodeById.values()].filter(ae=>{var Ve;return o.parentIds.has(ae.data.id)||((Ve=ae.data.config)==null?void 0:Ve.parentContainer)||ae.data.type==="objectView"||ae.data.type==="arrayView"}),U=!!z.length&&z.every(ae=>{var Ve,or,Ge;return o.parentIds.has(ae.data.id)||(Ve=ae.data.config)!=null&&Ve.parentContainer?!!((or=ae.data.config)!=null&&or.collapsed):O[ae.data.id]==="icon-label"||((Ge=ae.data.config)==null?void 0:Ge.labelBelow)&&O[ae.data.id]!=="properties"}),[se,Q]=_.useState("normal"),[Y,ge]=_.useState(),ce=e.edgeRadius??Y,$=ce!==void 0&&Number.isFinite(ce)?Math.min(500,Math.max(0,ce)):void 0,[V,W]=_.useState(),N=e.spacing??se,ne=typeof N=="number"?Number.isFinite(N)?Math.min(2,Math.max(.5,N)):1:N==="compact"?.5:N==="spacious"?2:1,be=e.backgroundVariant??V??(e.backgroundPattern==="none"&&e.backgroundColor==="transparent"?"transparent":e.backgroundPattern??"dot"),[fe,J]=_.useState(),te=Object.prototype.hasOwnProperty.call(e,"workflowContract")?e.workflowContract:fe,[G,le]=_.useState("blue.500"),[ue,Ce]=_.useState(!1),ye=_.useRef(t);ye.current=t;const Me=_.useMemo(()=>{const ae=Ve=>(...or)=>{var Ge,ir;return(ir=(Ge=ye.current)==null?void 0:Ge[Ve])==null?void 0:ir.call(Ge,...or)};return{onNodeSelect:ae("onNodeSelect"),onBackgroundClick:ae("onBackgroundClick"),onBottomBarCollapsedChange:ae("onBottomBarCollapsedChange"),onNodeDeselect:ae("onNodeDeselect"),onNodeDoubleClick:ae("onNodeDoubleClick"),onNodeViewToggle:ae("onNodeViewToggle"),onNodeTypeViewChange:ae("onNodeTypeViewChange"),onNodeCreate:ae("onNodeCreate"),onNodeCreateRequest:ae("onNodeCreateRequest"),onNodeDelete:ae("onNodeDelete"),onNodeLabelChange:ae("onNodeLabelChange"),onNodeContentChange:ae("onNodeContentChange"),onNodeCollapse:ae("onNodeCollapse"),onNodeColorChange:ae("onNodeColorChange"),onNodeBorderColorChange:ae("onNodeBorderColorChange"),onNodeBorderStyleChange:ae("onNodeBorderStyleChange"),onNodeBorderWidthChange:ae("onNodeBorderWidthChange"),onNodeBorderRadiusChange:ae("onNodeBorderRadiusChange"),onNodeIconChange:ae("onNodeIconChange"),onNodeOutlineChange:ae("onNodeOutlineChange"),onNodeAnimationChange:ae("onNodeAnimationChange"),onNodeAnimationVariantChange:ae("onNodeAnimationVariantChange"),onEdgeAnimationVariantChange:ae("onEdgeAnimationVariantChange"),onNodeHoverAction:ae("onNodeHoverAction"),onEdgeCreate:ae("onEdgeCreate"),onEdgeSelect:ae("onEdgeSelect"),onEdgeDeselect:ae("onEdgeDeselect"),onEdgeRemove:ae("onEdgeRemove"),onEdgeDelete:ae("onEdgeDelete"),onEdgeColorChange:ae("onEdgeColorChange"),onEdgeTypeChange:ae("onEdgeTypeChange"),onEdgeIconChange:ae("onEdgeIconChange"),onEdgeLabelChange:ae("onEdgeLabelChange"),onEdgeStyleChange:ae("onEdgeStyleChange"),onViewportChange:ae("onViewportChange"),onDirectionChange:ae("onDirectionChange"),onThemeColorChange:ae("onThemeColorChange"),onSpacingChange:ae("onSpacingChange"),onEdgeRadiusChange:ae("onEdgeRadiusChange"),onBackgroundVariantChange:ae("onBackgroundVariantChange"),onEdgeModeChange:ae("onEdgeModeChange"),onCompactPropertyLayoutChange:ae("onCompactPropertyLayoutChange"),onWorkflowContractChange:ae("onWorkflowContractChange"),onWorkflowConfigurationOpen:t.onWorkflowConfigurationOpen?ae("onWorkflowConfigurationOpen"):void 0,onArrayModeChange:ae("onArrayModeChange"),onInit:ae("onInit"),onLayoutComplete:ae("onLayoutComplete"),onJsonChange:ae("onJsonChange")}},[]),ee=e.themeColor||G,[he,ve]=_.useState(""),je=e.edgeColor??he,qe=e.colorMode||"light",We=e.direction||"LR",Ye=e.nodeAlignment??"center",tr=e.edgeMode==="workflow"?"nodes":e.edgeMode??A,sr=e.readOnly??!1,Ae=JSON.stringify(e.parentNodeStyle??null),me=_.useMemo(()=>e.parentNodeStyle,[Ae]),Oe=e.isZoomMode!==void 0?e.isZoomMode:d,nr=e.isMultiSelectMode!==void 0?e.isMultiSelectMode:p,cr=e.isEdgeHandlesEnabled!==void 0?e.isEdgeHandlesEnabled:b,Xe=e.isDragMode!==void 0?e.isDragMode:m,we=_.useRef(e);we.current=e;const Qr=_.useMemo(()=>({get direction(){return we.current.direction},get nodeAlignment(){return we.current.nodeAlignment},get edgeMode(){return we.current.edgeMode},get compactPropertyLayout(){return we.current.compactPropertyLayout},get bottomBarCollapsed(){return we.current.bottomBarCollapsed},get edgeType(){return we.current.edgeType},get edgeReveal(){return we.current.edgeReveal},get customEdgeTypes(){return we.current.customEdgeTypes},get themeColor(){return we.current.themeColor},get colorMode(){return we.current.colorMode},get readOnly(){return we.current.readOnly},get editable(){return we.current.editable},get minZoom(){return we.current.minZoom},get maxZoom(){return we.current.maxZoom},get backgroundPattern(){return we.current.backgroundPattern},get edgeColor(){return we.current.edgeColor},get parentNodeStyle(){return we.current.parentNodeStyle},get backgroundColor(){return we.current.backgroundColor},get edgeHandles(){return we.current.edgeHandles},get initialViewport(){return we.current.initialViewport},get animateViewport(){return we.current.animateViewport},get nodeOverlayActions(){return we.current.nodeOverlayActions},get renderNodeOverlay(){return we.current.renderNodeOverlay},get renderSelectedNodeToolbar(){return we.current.renderSelectedNodeToolbar},get renderSelectedEdgeToolbar(){return we.current.renderSelectedEdgeToolbar},get renderBottomBar(){return we.current.renderBottomBar},get bottomBarExtra(){return we.current.bottomBarExtra},get selectionToolbar(){return we.current.selectionToolbar},get customViews(){return we.current.customViews},get disableKeyboardShortcuts(){return we.current.disableKeyboardShortcuts},get isZoomMode(){return we.current.isZoomMode},get isMultiSelectMode(){return we.current.isMultiSelectMode},get isEdgeHandlesEnabled(){return we.current.isEdgeHandlesEnabled},get isDragMode(){return we.current.isDragMode}}),[]),zr=_.useCallback((ae,Ve)=>{var or;if(Ve!=="default"&&Ve!=="properties"&&Ve!=="icon-label")throw new Error("Unknown node view mode.");q(Ge=>Ge[ae]===Ve?Ge:{...Ge,[ae]:Ve}),(or=t.onNodeViewModeChange)==null||or.call(t,ae,Ve)},[t.onNodeViewModeChange]),pt=_.useMemo(()=>({allNodesIconLabel:U,setAllNodesIconLabel:ae=>{var Ve,or,Ge,ir,er;if(!ae)for(const[Z,B]of Object.entries(O))B==="icon-label"&&!o.nodeById.has(Z)&&zr(Z,"default");for(const Z of z)o.parentIds.has(Z.data.id)||(Ve=Z.data.config)!=null&&Ve.parentContainer?!sr&&!!((or=Z.data.config)!=null&&or.collapsed)!==ae&&((Ge=t.onNodeCollapse)==null||Ge.call(t,Z.data.id,ae)):zr(Z.data.id,ae?"icon-label":(ir=Z.data.config)!=null&&ir.labelBelow?"properties":"default");(er=t.onAllNodesIconLabelChange)==null||er.call(t,ae)},nodeViewModes:O,setNodeViewMode:zr,spacing:ne,setSpacing:Q,edgeRadius:$,setEdgeRadius:ge,backgroundVariant:be,setBackgroundVariant:W,themeColor:ee,setThemeColor:le,backgroundSelected:ue,setBackgroundSelected:Ce,edgeColor:je,setEdgeColor:ae=>{var Ve;ve(ae),(Ve=t.onGraphEdgeColorChange)==null||Ve.call(t,ae)},colorMode:qe,direction:We,nodeAlignment:Ye,edgeMode:tr,setEdgeMode:M,compactPropertyLayout:P,setCompactPropertyLayout:R,workflowContract:te,setWorkflowContract:J,parentNodeStyle:me,selectedNodeIds:a,setSelectedNodeIds:c,selectedEdgeId:u,setSelectedEdgeId:l,isZoomMode:Oe,setIsZoomMode:h,isMultiSelectMode:nr,setIsMultiSelectMode:y,isDragMode:Xe,setIsDragMode:g,isEdgeHandlesEnabled:cr,setIsEdgeHandlesEnabled:w,isArrayNodeMode:v,setIsArrayNodeMode:x,isPinned:C,setIsPinned:S,isPerformanceMode:E,setIsPerformanceMode:I,engineRef:s,callbacks:Me,config:Qr,readOnly:sr}),[U,o,zr,t.onNodeCollapse,t.onAllNodesIconLabelChange,t.onGraphEdgeColorChange,O,t.onNodeViewModeChange,ee,ne,be,$,e.backgroundColor,ue,je,qe,We,Ye,tr,te,me,a,u,Oe,nr,Xe,cr,v,C,E,sr,e.edgeHandles,e.edgeType,e.edgeReveal,e.animateViewport,e.customEdgeTypes,e.selectionToolbar,e.bottomBarExtra,e.bottomBarCollapsed,e.compactPropertyLayout,P,Me,Qr]);return f.jsx(By.Provider,{value:pt,children:f.jsx(zy.Provider,{value:o,children:i})})}function ur(e,t,r){return e?r:t}function ln(e){const[t]=(e==null?void 0:e.split("."))||[],{secondary:r}=Ly(e),n=Ir(t).background,i=Ir(t).highlight,o=Ir(t).border,s=Ir(t).property,a=Ir(t).property;let c=Ir(t).background,u=Ir(t).highlight;return c=e==="transparent"?e:xe(c)+50,u=e==="transparent"?e:xe(u)+20,{bgColor:n,highlightColor:i,borderColor:o,textColor:s,propertyColor:a,secondary:r,bgColorFaint:c,highlightColorFaint:u}}function Ze(e=null){const{colorMode:t}=Ne(),r=e==null?void 0:e.includes("gray"),n=t==="dark",i=ur(n,"white","gray.900"),o=ur(n,"gray.100","gray.800"),s=ur(n,"gray.200","blackAlpha.400"),a=ur(n,"gray.200","blackAlpha.600"),c=ur(n,"gray.500","gray.700"),u=ur(n,"gray.700","gray.700"),l=ur(n,"gray.900","gray.900"),d=ur(n,"gray.400","gray.500"),h=ur(n,"gray.400","gray.500"),p=ur(n,"gray.900","gray.200"),y=ur(n,r?"gray.900":"gray.200",r?"gray.200":"gray.900"),m=ur(n,"gray.900","gray.200"),g=ur(n,e&&"#000000",e||"#ffffff"),b=ur(n,e||"#ffffff",e?"#000000":"#ffffff"),w=u,v=ur(n,"gray.300","gray.800"),x=ur(n,"white","blackAlpha.400"),C=ur(n,"green.100","green.700");return{canvas:i,background:o,backgroundSecondary:s,darkBackgroundSecondary:a,border:c,darkColor:l,backgroundWhiteColor:x,borderSecondary:u,colorActive:d,colorInactive:h,iconColor:m,moreIconColor:w,colorText:p,themedColorText:y,logoColor:g,logoColorSecondary:b,darkColorActive:v,greenColor:C}}var Bt=(e=>(e.TOP_DOWN="TB",e.BOTTOM_UP="BT",e.LEFT_RIGHT="LR",e.RIGHT_LEFT="RL",e.CENTER="C",e))(Bt||{});const nn=["","icon-label","object","text"];var Iv=typeof global=="object"&&global&&global.Object===Object&&global,Ov=typeof self=="object"&&self&&self.Object===Object&&self,Mv=Iv||Ov||Function("return this")(),_t=Mv.Symbol,Vy=Object.prototype,qv=Vy.hasOwnProperty,$v=Vy.toString,Lt=_t?_t.toStringTag:void 0;function Nv(e){var t=qv.call(e,Lt),r=e[Lt];try{e[Lt]=void 0;var n=!0}catch{}var i=$v.call(e);return n&&(t?e[Lt]=r:delete e[Lt]),i}var Lv=Object.prototype,Fv=Lv.toString;function Bv(e){return Fv.call(e)}var zv="[object Null]",Dv="[object Undefined]",Tl=_t?_t.toStringTag:void 0;function Vv(e){return e==null?e===void 0?Dv:zv:Tl&&Tl in Object(e)?Nv(e):Bv(e)}function Wv(e){return e!=null&&typeof e=="object"}var Gv="[object Symbol]";function Uv(e){return typeof e=="symbol"||Wv(e)&&Vv(e)==Gv}function Hv(e,t){for(var r=-1,n=e==null?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}var Fe=Array.isArray,Il=_t?_t.prototype:void 0,Ol=Il?Il.toString:void 0;function Wy(e){if(typeof e=="string")return e;if(Fe(e))return Hv(e,Wy)+"";if(Uv(e))return Ol?Ol.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function Vu(e){return e==null?"":Wy(e)}function Kv(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),r=r>i?i:r,r<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n<i;)o[n]=e[n+t];return o}function Jv(e,t,r){var n=e.length;return r=r===void 0?n:r,!t&&r>=n?e:Kv(e,t,r)}var Zv="\\ud800-\\udfff",Yv="\\u0300-\\u036f",Xv="\\ufe20-\\ufe2f",Qv="\\u20d0-\\u20ff",ex=Yv+Xv+Qv,rx="\\ufe0e\\ufe0f",tx="\\u200d",nx=RegExp("["+tx+Zv+ex+rx+"]");function Gy(e){return nx.test(e)}function ox(e){return e.split("")}var Uy="\\ud800-\\udfff",ix="\\u0300-\\u036f",ax="\\ufe20-\\ufe2f",sx="\\u20d0-\\u20ff",cx=ix+ax+sx,ux="\\ufe0e\\ufe0f",lx="["+Uy+"]",Mu="["+cx+"]",qu="\\ud83c[\\udffb-\\udfff]",dx="(?:"+Mu+"|"+qu+")",Hy="[^"+Uy+"]",Ky="(?:\\ud83c[\\udde6-\\uddff]){2}",Jy="[\\ud800-\\udbff][\\udc00-\\udfff]",fx="\\u200d",Zy=dx+"?",Yy="["+ux+"]?",hx="(?:"+fx+"(?:"+[Hy,Ky,Jy].join("|")+")"+Yy+Zy+")*",px=Yy+Zy+hx,gx="(?:"+[Hy+Mu+"?",Mu,Ky,Jy,lx].join("|")+")",yx=RegExp(qu+"(?="+qu+")|"+gx+px,"g");function mx(e){return e.match(yx)||[]}function bx(e){return Gy(e)?mx(e):ox(e)}function vx(e){return function(t){t=Vu(t);var r=Gy(t)?bx(t):void 0,n=r?r[0]:t.charAt(0),i=r?Jv(r,1).join(""):t.slice(1);return n[e]()+i}}var xx=vx("toUpperCase");function wx(e,t,r,n){for(var i=-1,o=e==null?0:e.length;++i<o;)r=t(r,e[i],i,e);return r}function Cx(e){return function(t){return e==null?void 0:e[t]}}var Sx={À:"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"},_x=Cx(Sx),Ex=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,jx="\\u0300-\\u036f",kx="\\ufe20-\\ufe2f",Rx="\\u20d0-\\u20ff",Px=jx+kx+Rx,Ax="["+Px+"]",Tx=RegExp(Ax,"g");function Ix(e){return e=Vu(e),e&&e.replace(Ex,_x).replace(Tx,"")}var Ox=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Mx(e){return e.match(Ox)||[]}var qx=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function $x(e){return qx.test(e)}var Xy="\\ud800-\\udfff",Nx="\\u0300-\\u036f",Lx="\\ufe20-\\ufe2f",Fx="\\u20d0-\\u20ff",Bx=Nx+Lx+Fx,Qy="\\u2700-\\u27bf",em="a-z\\xdf-\\xf6\\xf8-\\xff",zx="\\xac\\xb1\\xd7\\xf7",Dx="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Vx="\\u2000-\\u206f",Wx=" \\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",rm="A-Z\\xc0-\\xd6\\xd8-\\xde",Gx="\\ufe0e\\ufe0f",tm=zx+Dx+Vx+Wx,nm="['’]",Ml="["+tm+"]",Ux="["+Bx+"]",om="\\d+",Hx="["+Qy+"]",im="["+em+"]",am="[^"+Xy+tm+om+Qy+em+rm+"]",Kx="\\ud83c[\\udffb-\\udfff]",Jx="(?:"+Ux+"|"+Kx+")",Zx="[^"+Xy+"]",sm="(?:\\ud83c[\\udde6-\\uddff]){2}",cm="[\\ud800-\\udbff][\\udc00-\\udfff]",mt="["+rm+"]",Yx="\\u200d",ql="(?:"+im+"|"+am+")",Xx="(?:"+mt+"|"+am+")",$l="(?:"+nm+"(?:d|ll|m|re|s|t|ve))?",Nl="(?:"+nm+"(?:D|LL|M|RE|S|T|VE))?",um=Jx+"?",lm="["+Gx+"]?",Qx="(?:"+Yx+"(?:"+[Zx,sm,cm].join("|")+")"+lm+um+")*",e0="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",r0="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",t0=lm+um+Qx,n0="(?:"+[Hx,sm,cm].join("|")+")"+t0,o0=RegExp([mt+"?"+im+"+"+$l+"(?="+[Ml,mt,"$"].join("|")+")",Xx+"+"+Nl+"(?="+[Ml,mt+ql,"$"].join("|")+")",mt+"?"+ql+"+"+$l,mt+"+"+Nl,r0,e0,om,n0].join("|"),"g");function i0(e){return e.match(o0)||[]}function a0(e,t,r){return e=Vu(e),t=t,t===void 0?$x(e)?i0(e):Mx(e):e.match(t)||[]}var s0="['’]",c0=RegExp(s0,"g");function u0(e){return function(t){return wx(a0(Ix(t).replace(c0,"")),e,"")}}var wr=u0(function(e,t,r){return e+(r?" ":"")+xx(t)});function l0(){let e,t=null;const r=new Set,n=i=>{t=i,r.forEach(o=>o())};return{subscribe:i=>(r.add(i),()=>{r.delete(i)}),getSnapshot:()=>t,select(i,o){e=i,n(o)},update(i,o){e===i&&n(o)},remove(i){e===i&&(e=void 0,n(null))}}}const Et=_.createContext(null),d0=()=>_.useState(l0)[0];function Mn(e,t=!0){const r=_.useContext(Et),n=_.useId();return _.useEffect(()=>{t?r==null||r.update(n,e):r==null||r.remove(n)}),_.useEffect(()=>()=>r==null?void 0:r.remove(n),[r,n]),()=>{t&&(r==null||r.select(n,e))}}function f0({divider:e}){const t=_.useContext(Et),r=_.useSyncExternalStore(t.subscribe,t.getSnapshot,()=>null);return f.jsx(Et.Provider,{value:null,children:f.jsxs("span",{"data-recent-toolbar-action":"",style:{display:r?"contents":"none"},children:[r&&e,r]})})}function Ie({label:e,children:t}){const r=_.cloneElement(t,{title:t.props.title??e});if(!F.Tooltip.Root){const n=F.Tooltip;return f.jsx(n,{label:e,placement:"top",fontSize:"xs",borderRadius:"15px",children:r})}return f.jsxs(F.Tooltip.Root,{positioning:{placement:"top"},children:[f.jsx(F.Tooltip.Trigger,{asChild:!0,children:r}),f.jsx(F.Portal,{children:f.jsx(F.Tooltip.Positioner,{children:f.jsx(F.Tooltip.Content,{fontSize:"xs",borderRadius:"15px",children:e})})})]})}function Ht(){const{border:e}=Ze(),{colorMode:t}=Ne();return f.jsx(F.chakra.span,{role:"separator","aria-orientation":"vertical",display:"block",flexShrink:0,w:"1px",h:"20px",mx:"4px",bg:t==="dark"?e:"gray.300"})}function mr({children:e,value:t,onValueChange:r,disabled:n,style:i,title:o,icon:s,popupContent:a,footer:c,labelCase:u="title","aria-label":l,...d}){var P;const{colorMode:h}=Ne(),{background:p,border:y,colorText:m,colorInactive:g}=Ze(),b=h==="dark",w=_.useId(),v=_.useRef(null),x=_.useRef(null),[C,S]=_.useState(!1),E=Mn(f.jsx(mr,{value:t,onValueChange:r,disabled:n,style:i,title:o,icon:s,popupContent:a,footer:c,labelCase:u,"aria-label":l,children:e}),!!s);_.useEffect(()=>{const k=x.current;k.setAttribute("popover","auto");const q=O=>S(O.newState==="open");return k.addEventListener("toggle",q),()=>k.removeEventListener("toggle",q)},[]);const I=_.Children.toArray(e).filter(_.isValidElement).map(k=>{const q=k.props;return{value:String(q.value),label:typeof q.children=="string"&&u==="title"?wr(q.children):q.children,disabled:q.disabled}}),A=()=>{var k;return(k=x.current)==null?void 0:k.hidePopover()},M=()=>{var se,Q,Y,ge,ce;const k=(se=v.current)==null?void 0:se.getBoundingClientRect(),q=x.current;if(!k||!q)return;if((Q=v.current)!=null&&Q.closest("[popover]")){const $=window.innerHeight-k.bottom-16,V=k.top-16;q.style.maxHeight=`${Math.max(60,$,V)}px`;const W=q.getBoundingClientRect();q.style.left=`${Math.max(12,Math.min(k.right-W.width,window.innerWidth-W.width-12))}px`,q.style.top=`${Math.max(12,W.height<=$?k.bottom+4:k.top-W.height-4)}px`;return}const O=(ce=(ge=(Y=v.current)==null?void 0:Y.closest("[data-flow-toolbar-scroll]"))==null?void 0:ge.parentElement)==null?void 0:ce.getBoundingClientRect(),z=O??k;q.style.maxHeight=`${Math.max(60,Math.max(z.top-40,window.innerHeight-z.bottom-40))}px`;const U=q.getBoundingClientRect();q.style.left=`${Math.max(12,Math.min(Math.max((O==null?void 0:O.left)??12,k.right-U.width),((O==null?void 0:O.right)??window.innerWidth-12)-U.width,window.innerWidth-U.width-12))}px`,q.style.top=`${Math.max(12,z.top>=U.height+36?z.top-U.height-24:Math.min(z.bottom+24,window.innerHeight-U.height-12))}px`},j=()=>{var O,z,U,se,Q,Y;if(n)return;if((O=x.current)==null||O.showPopover(),M(),a){(U=(z=x.current)==null?void 0:z.querySelector("input"))==null||U.focus({preventScroll:!0});return}const k=(se=x.current)==null?void 0:se.querySelectorAll('[role="option"]:not(:disabled)');(Y=((Q=x.current)==null?void 0:Q.querySelector('[aria-selected="true"]:not(:disabled)'))??(k==null?void 0:k[0]))==null||Y.focus()};_.useEffect(()=>{if(C){if(n){A();return}return window.addEventListener("resize",M),window.addEventListener("scroll",M,!0),()=>{window.removeEventListener("resize",M),window.removeEventListener("scroll",M,!0)}}},[C,n]);const R=`var(--chakra-colors-${p.replace(".","-")})`;return f.jsxs(f.Fragment,{children:[f.jsx(Ie,{label:o??l,children:f.jsx(F.chakra.button,{...d,ref:v,type:"button",role:"combobox","data-flow-select-icon":s?"":void 0,"aria-label":l,title:o??l,"aria-haspopup":a?"dialog":"listbox","aria-expanded":C,"aria-controls":w,disabled:n,h:"30px",w:"160px",px:"6px",fontSize:"12px",border:"none",borderRadius:"4px",bg:"transparent",color:s?g:m,display:"flex",alignItems:"center",justifyContent:s?"center":"space-between",gap:2,style:i,onClick:()=>{E(),C?A():j()},onKeyDown:k=>{["ArrowDown","ArrowUp"].includes(k.key)&&(k.preventDefault(),j())},children:s??f.jsxs(f.Fragment,{children:[f.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((P=I.find(k=>k.value===t))==null?void 0:P.label)??t}),f.jsx(K.PiCaretUp,{size:16,style:{flexShrink:0}})]})})}),f.jsxs(F.chakra.div,{ref:x,id:w,role:a?"dialog":"listbox","aria-label":l,position:"fixed",m:0,p:2,minW:"180px",maxW:"calc(100vw - 24px)",overflowY:"auto",bg:p,color:m,borderRadius:"30px",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"},'& [role="option"]':Rn,'& details [role="option"]:first-child':{borderTopLeftRadius:"4px",borderTopRightRadius:"4px"},...Hr(R,`var(--chakra-colors-${(b?y:"gray.300").replace(".","-")})`)},onKeyDown:k=>{var z,U,se;if(a&&!["Escape","Tab"].includes(k.key))return;const q=[...k.currentTarget.querySelectorAll('[role="option"]:not(:disabled), [data-flow-menu-action]:not(:disabled)')],O=q.indexOf(document.activeElement);if(["ArrowDown","ArrowUp","Home","End"].includes(k.key)){k.preventDefault();const Q=k.key==="Home"?0:k.key==="End"?q.length-1:(O+(k.key==="ArrowDown"?1:-1)+q.length)%q.length;(z=q[Q])==null||z.focus()}else k.key==="Escape"||k.key==="Tab"?(k.key==="Escape"&&(k.preventDefault(),k.stopPropagation()),A(),(U=v.current)==null||U.focus()):k.key.length===1&&k.key!==" "&&((se=q.find((Q,Y)=>{var ge;return Y>O&&((ge=Q.textContent)==null?void 0:ge.toLowerCase().startsWith(k.key.toLowerCase()))}))==null||se.focus())},children:[a??I.map(k=>f.jsxs(F.chakra.button,{type:"button",role:"option","aria-selected":k.value===t,disabled:k.disabled,tabIndex:-1,display:"flex",alignItems:"center",gap:3,px:3,py:2,w:"100%",fontSize:"sm",textAlign:"left",bg:"transparent",color:m,_hover:{bg:b?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:b?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var q;A(),(q=v.current)==null||q.focus(),r(k.value)},children:[f.jsx("span",{style:{flex:1},children:k.label}),f.jsx(K.PiCheck,{size:16,color:`var(--chakra-colors-${m.replace(".","-")})`,"aria-hidden":"true",style:{flexShrink:0,visibility:k.value===t?"visible":"hidden"}})]},k.value)),c]})]})}const Rn={borderRadius:"4px","&:first-child":{borderTopLeftRadius:"22px",borderTopRightRadius:"22px"},"&:last-child":{borderBottomLeftRadius:"22px",borderBottomRightRadius:"22px"}},Se=_.forwardRef(function({icon:t,rememberAction:r=!0,...n},i){const{colorMode:o}=Ne(),s=Object.fromEntries(Object.entries(n).filter(([c])=>c!=="id"&&c!=="aria-describedby"&&!c.startsWith("data-")&&!/^on(Pointer|Mouse|Focus|Blur)/.test(c))),a=Mn(f.jsx(Ie,{label:n.title??n["aria-label"]??"Last used action",children:f.jsx(Se,{...s,icon:t})}),r&&!!n.onClick);return f.jsx(F.IconButton,{ref:i,_hover:{bg:o==="dark"?"whiteAlpha.100":"blackAlpha.50"},title:n.title??n["aria-label"],...n,onClick:c=>{var u;a(),(u=n.onClick)==null||u.call(n,c)},children:t})}),At=_.forwardRef(function(t,r){const{themeColor:n}=Ne();return f.jsx(Ie,{label:"Close",children:f.jsx(Se,{ref:r,size:"sm",variant:"plain",bg:"transparent",_hover:{bg:"transparent",color:n},color:n,focusRingColor:n,...t,"aria-label":t["aria-label"]??"Close selection tools",icon:f.jsx(K.PiXLight,{size:20,"aria-hidden":"true"})})})});function Wu({label:e,icon:t,checked:r,onChange:n,disabled:i,hideLabel:o=!1,helper:s=e}){const{themeColor:a,readOnly:c}=Ne(),{colorInactive:u}=Ze();return f.jsx(Ie,{label:s,children:f.jsx(Se,{"aria-label":e,"aria-pressed":r,icon:f.jsxs(f.Fragment,{children:[t,!o&&f.jsx(F.Text,{as:"span",fontSize:"16px",fontWeight:r?"bold":"normal",whiteSpace:"nowrap",children:e})]}),size:"sm",variant:"ghost",width:"auto",px:2,gap:2,color:r?a:u,disabled:i||c,onClick:()=>n(!r)})})}function dm({label:e="Compact layout"}={}){const{compactPropertyLayout:t,setCompactPropertyLayout:r,callbacks:n}=Ne();return f.jsx(Wu,{hideLabel:!0,label:e,checked:t,icon:f.jsx(F.Icon,{as:K.PiArrowsIn,boxSize:5}),onChange:i=>{var o;r(i),(o=n.onCompactPropertyLayoutChange)==null||o.call(n,i)}})}const h0=On.default.input`
|
|
7
|
+
`;function By(e,t=!0,r="&:hover",n=!0){const i=`color-mix(in srgb, ${e} 60%, transparent)`,s=`0 0 0 ${t?8:0}px ${i}`,a=`0 0 0 8px ${i}`;return{boxShadow:s,css:{"--flow-rest-shadow":a,"--flow-hover-shadow":`0 0 0 18px ${i}`,"@media (hover: hover)":{[r]:{boxShadow:a,"@media (prefers-reduced-motion: no-preference)":{animation:n?`${Iv} 1200ms steps(10, end) 600ms`:"none"}}}}}}function Kr(e,t){const{boxShadow:r,css:n}=By(e,!1),i=n["@media (hover: hover)"]["&:hover"];return{borderWidth:"1px",borderStyle:"solid",borderColor:"transparent",boxShadow:r,...n,"--flow-start-shadow":r,"@media (hover: hover)":{"&:hover":{...i,borderColor:t,"@media (prefers-reduced-motion: no-preference)":{animation:`${Ov} 600ms steps(5, end)`}}}}}const zy=_.createContext(null),Dy=_.createContext({nodeById:new Map,edgeById:new Map,parentIds:new Set});function Xr(){return _.useContext(Dy)}function Le(){const e=_.useContext(zy);if(!e)throw new Error("useFlowDiagramContext must be used within FlowDiagram");return e}function Vy({config:e,callbacks:t,nodes:r=[],edges:n=[],children:i}){const o=_.useMemo(()=>{var Ue,ir,er;const ie=new Map;for(const Z of r)(Ue=Z.data)!=null&&Ue.id&&ie.set(Z.data.id,Z);const We=new Map;for(const Z of n)(ir=Z.data)!=null&&ir.id&&We.set(Z.data.id,Z);const or=new Set;for(const Z of r)(er=Z.data)!=null&&er.parent&&or.add(Z.data.parent);return{nodeById:ie,edgeById:We,parentIds:or}},[r,n]),s=_.useRef(null),[a,c]=_.useState([]),[u,l]=_.useState(null),[d,h]=_.useState(!0),[p,y]=_.useState(!1),[m,g]=_.useState(!0),[b,w]=_.useState(!1),[v,x]=_.useState(!1),[C,S]=_.useState(!0),[k,I]=_.useState(!1),[R,M]=_.useState("auto"),[E,P]=_.useState(!1),A=e.compactPropertyLayout??E,[j,q]=_.useState({}),O=e.nodeViewModes??j,z=[...o.nodeById.values()].filter(ie=>{var We;return o.parentIds.has(ie.data.id)||((We=ie.data.config)==null?void 0:We.parentContainer)||ie.data.type==="objectView"||ie.data.type==="arrayView"}),U=!!z.length&&z.every(ie=>{var We,or,Ue;return o.parentIds.has(ie.data.id)||(We=ie.data.config)!=null&&We.parentContainer?!!((or=ie.data.config)!=null&&or.collapsed):O[ie.data.id]==="icon-label"||((Ue=ie.data.config)==null?void 0:Ue.labelBelow)&&O[ie.data.id]!=="properties"}),[ae,Q]=_.useState("normal"),[Y,pe]=_.useState(),se=e.edgeRadius??Y,$=se!==void 0&&Number.isFinite(se)?Math.min(500,Math.max(0,se)):void 0,[V,W]=_.useState(),N=e.spacing??ae,ne=typeof N=="number"?Number.isFinite(N)?Math.min(2,Math.max(.5,N)):1:N==="compact"?.5:N==="spacious"?2:1,me=e.backgroundVariant??V??(e.backgroundPattern==="none"&&e.backgroundColor==="transparent"?"transparent":e.backgroundPattern??"dot"),[fe,J]=_.useState(),te=Object.prototype.hasOwnProperty.call(e,"workflowContract")?e.workflowContract:fe,[G,le]=_.useState("blue.500"),[ue,we]=_.useState(!1),ge=_.useRef(t);ge.current=t;const qe=_.useMemo(()=>{const ie=We=>(...or)=>{var Ue,ir;return(ir=(Ue=ge.current)==null?void 0:Ue[We])==null?void 0:ir.call(Ue,...or)};return{onNodeSelect:ie("onNodeSelect"),onBackgroundClick:ie("onBackgroundClick"),onBottomBarCollapsedChange:ie("onBottomBarCollapsedChange"),onNodeDeselect:ie("onNodeDeselect"),onNodeDoubleClick:ie("onNodeDoubleClick"),onNodeViewToggle:ie("onNodeViewToggle"),onNodeTypeViewChange:ie("onNodeTypeViewChange"),onNodeCreate:ie("onNodeCreate"),onNodeCreateRequest:ie("onNodeCreateRequest"),onNodeDelete:ie("onNodeDelete"),onNodeLabelChange:ie("onNodeLabelChange"),onNodeContentChange:ie("onNodeContentChange"),onNodeCollapse:ie("onNodeCollapse"),onNodeColorChange:ie("onNodeColorChange"),onNodeBorderColorChange:ie("onNodeBorderColorChange"),onNodeBorderStyleChange:ie("onNodeBorderStyleChange"),onNodeBorderWidthChange:ie("onNodeBorderWidthChange"),onNodeBorderRadiusChange:ie("onNodeBorderRadiusChange"),onNodeIconChange:ie("onNodeIconChange"),onNodeOutlineChange:ie("onNodeOutlineChange"),onNodeAnimationChange:ie("onNodeAnimationChange"),onNodeAnimationVariantChange:ie("onNodeAnimationVariantChange"),onEdgeAnimationVariantChange:ie("onEdgeAnimationVariantChange"),onNodeHoverAction:ie("onNodeHoverAction"),onEdgeCreate:ie("onEdgeCreate"),onEdgeSelect:ie("onEdgeSelect"),onEdgeDeselect:ie("onEdgeDeselect"),onEdgeRemove:ie("onEdgeRemove"),onEdgeDelete:ie("onEdgeDelete"),onEdgeColorChange:ie("onEdgeColorChange"),onEdgeTypeChange:ie("onEdgeTypeChange"),onEdgeIconChange:ie("onEdgeIconChange"),onEdgeLabelChange:ie("onEdgeLabelChange"),onEdgeStyleChange:ie("onEdgeStyleChange"),onViewportChange:ie("onViewportChange"),onDirectionChange:ie("onDirectionChange"),onThemeColorChange:ie("onThemeColorChange"),onSpacingChange:ie("onSpacingChange"),onEdgeRadiusChange:ie("onEdgeRadiusChange"),onBackgroundVariantChange:ie("onBackgroundVariantChange"),onEdgeModeChange:ie("onEdgeModeChange"),onCompactPropertyLayoutChange:ie("onCompactPropertyLayoutChange"),onWorkflowContractChange:ie("onWorkflowContractChange"),onWorkflowConfigurationOpen:t.onWorkflowConfigurationOpen?ie("onWorkflowConfigurationOpen"):void 0,onArrayModeChange:ie("onArrayModeChange"),onInit:ie("onInit"),onLayoutComplete:ie("onLayoutComplete"),onJsonChange:ie("onJsonChange")}},[]),ee=e.themeColor||G,[he,be]=_.useState(""),Ee=e.edgeColor??he,$e=e.colorMode||"light",Ge=e.direction||"LR",Ye=e.nodeAlignment??"center",tr=e.edgeMode==="workflow"?"nodes":e.edgeMode??R,sr=e.readOnly??!1,Pe=JSON.stringify(e.parentNodeStyle??null),ye=_.useMemo(()=>e.parentNodeStyle,[Pe]),Me=e.isZoomMode!==void 0?e.isZoomMode:d,nr=e.isMultiSelectMode!==void 0?e.isMultiSelectMode:p,cr=e.isEdgeHandlesEnabled!==void 0?e.isEdgeHandlesEnabled:b,Xe=e.isDragMode!==void 0?e.isDragMode:m,xe=_.useRef(e);xe.current=e;const et=_.useMemo(()=>({get direction(){return xe.current.direction},get nodeAlignment(){return xe.current.nodeAlignment},get edgeMode(){return xe.current.edgeMode},get compactPropertyLayout(){return xe.current.compactPropertyLayout},get bottomBarCollapsed(){return xe.current.bottomBarCollapsed},get edgeType(){return xe.current.edgeType},get edgeReveal(){return xe.current.edgeReveal},get customEdgeTypes(){return xe.current.customEdgeTypes},get themeColor(){return xe.current.themeColor},get colorMode(){return xe.current.colorMode},get readOnly(){return xe.current.readOnly},get editable(){return xe.current.editable},get minZoom(){return xe.current.minZoom},get maxZoom(){return xe.current.maxZoom},get backgroundPattern(){return xe.current.backgroundPattern},get edgeColor(){return xe.current.edgeColor},get parentNodeStyle(){return xe.current.parentNodeStyle},get backgroundColor(){return xe.current.backgroundColor},get edgeHandles(){return xe.current.edgeHandles},get initialViewport(){return xe.current.initialViewport},get animateViewport(){return xe.current.animateViewport},get nodeOverlayActions(){return xe.current.nodeOverlayActions},get renderNodeOverlay(){return xe.current.renderNodeOverlay},get renderSelectedNodeToolbar(){return xe.current.renderSelectedNodeToolbar},get renderSelectedEdgeToolbar(){return xe.current.renderSelectedEdgeToolbar},get renderBottomBar(){return xe.current.renderBottomBar},get bottomBarExtra(){return xe.current.bottomBarExtra},get selectionToolbar(){return xe.current.selectionToolbar},get customViews(){return xe.current.customViews},get disableKeyboardShortcuts(){return xe.current.disableKeyboardShortcuts},get isZoomMode(){return xe.current.isZoomMode},get isMultiSelectMode(){return xe.current.isMultiSelectMode},get isEdgeHandlesEnabled(){return xe.current.isEdgeHandlesEnabled},get isDragMode(){return xe.current.isDragMode}}),[]),zr=_.useCallback((ie,We)=>{var or;if(We!=="default"&&We!=="properties"&&We!=="icon-label")throw new Error("Unknown node view mode.");q(Ue=>Ue[ie]===We?Ue:{...Ue,[ie]:We}),(or=t.onNodeViewModeChange)==null||or.call(t,ie,We)},[t.onNodeViewModeChange]),pt=_.useMemo(()=>({allNodesIconLabel:U,setAllNodesIconLabel:ie=>{var We,or,Ue,ir,er;if(!ie)for(const[Z,B]of Object.entries(O))B==="icon-label"&&!o.nodeById.has(Z)&&zr(Z,"default");for(const Z of z)o.parentIds.has(Z.data.id)||(We=Z.data.config)!=null&&We.parentContainer?!sr&&!!((or=Z.data.config)!=null&&or.collapsed)!==ie&&((Ue=t.onNodeCollapse)==null||Ue.call(t,Z.data.id,ie)):zr(Z.data.id,ie?"icon-label":(ir=Z.data.config)!=null&&ir.labelBelow?"properties":"default");(er=t.onAllNodesIconLabelChange)==null||er.call(t,ie)},nodeViewModes:O,setNodeViewMode:zr,spacing:ne,setSpacing:Q,edgeRadius:$,setEdgeRadius:pe,backgroundVariant:me,setBackgroundVariant:W,themeColor:ee,setThemeColor:le,backgroundSelected:ue,setBackgroundSelected:we,edgeColor:Ee,setEdgeColor:ie=>{var We;be(ie),(We=t.onGraphEdgeColorChange)==null||We.call(t,ie)},colorMode:$e,direction:Ge,nodeAlignment:Ye,edgeMode:tr,setEdgeMode:M,compactPropertyLayout:A,setCompactPropertyLayout:P,workflowContract:te,setWorkflowContract:J,parentNodeStyle:ye,selectedNodeIds:a,setSelectedNodeIds:c,selectedEdgeId:u,setSelectedEdgeId:l,isZoomMode:Me,setIsZoomMode:h,isMultiSelectMode:nr,setIsMultiSelectMode:y,isDragMode:Xe,setIsDragMode:g,isEdgeHandlesEnabled:cr,setIsEdgeHandlesEnabled:w,isArrayNodeMode:v,setIsArrayNodeMode:x,isPinned:C,setIsPinned:S,isPerformanceMode:k,setIsPerformanceMode:I,engineRef:s,callbacks:qe,config:et,readOnly:sr}),[U,o,zr,t.onNodeCollapse,t.onAllNodesIconLabelChange,t.onGraphEdgeColorChange,O,t.onNodeViewModeChange,ee,ne,me,$,e.backgroundColor,ue,Ee,$e,Ge,Ye,tr,te,ye,a,u,Me,nr,Xe,cr,v,C,k,sr,e.edgeHandles,e.edgeType,e.edgeReveal,e.animateViewport,e.customEdgeTypes,e.selectionToolbar,e.bottomBarExtra,e.bottomBarCollapsed,e.compactPropertyLayout,A,qe,et]);return f.jsx(zy.Provider,{value:pt,children:f.jsx(Dy.Provider,{value:o,children:i})})}function ur(e,t,r){return e?r:t}function ln(e){const[t]=(e==null?void 0:e.split("."))||[],{secondary:r}=Fy(e),n=Ir(t).background,i=Ir(t).highlight,o=Ir(t).border,s=Ir(t).property,a=Ir(t).property;let c=Ir(t).background,u=Ir(t).highlight;return c=e==="transparent"?e:ve(c)+50,u=e==="transparent"?e:ve(u)+20,{bgColor:n,highlightColor:i,borderColor:o,textColor:s,propertyColor:a,secondary:r,bgColorFaint:c,highlightColorFaint:u}}function Ze(e=null){const{colorMode:t}=Le(),r=e==null?void 0:e.includes("gray"),n=t==="dark",i=ur(n,"white","gray.900"),o=ur(n,"gray.100","gray.800"),s=ur(n,"gray.200","blackAlpha.400"),a=ur(n,"gray.200","blackAlpha.600"),c=ur(n,"gray.500","gray.700"),u=ur(n,"gray.700","gray.700"),l=ur(n,"gray.900","gray.900"),d=ur(n,"gray.400","gray.500"),h=ur(n,"gray.400","gray.500"),p=ur(n,"gray.900","gray.200"),y=ur(n,r?"gray.900":"gray.200",r?"gray.200":"gray.900"),m=ur(n,"gray.900","gray.200"),g=ur(n,e&&"#000000",e||"#ffffff"),b=ur(n,e||"#ffffff",e?"#000000":"#ffffff"),w=u,v=ur(n,"gray.300","gray.800"),x=ur(n,"white","blackAlpha.400"),C=ur(n,"green.100","green.700");return{canvas:i,background:o,backgroundSecondary:s,darkBackgroundSecondary:a,border:c,darkColor:l,backgroundWhiteColor:x,borderSecondary:u,colorActive:d,colorInactive:h,iconColor:m,moreIconColor:w,colorText:p,themedColorText:y,logoColor:g,logoColorSecondary:b,darkColorActive:v,greenColor:C}}var Bt=(e=>(e.TOP_DOWN="TB",e.BOTTOM_UP="BT",e.LEFT_RIGHT="LR",e.RIGHT_LEFT="RL",e.CENTER="C",e))(Bt||{});const nn=["","icon-label","object","text"];var Mv=typeof global=="object"&&global&&global.Object===Object&&global,qv=typeof self=="object"&&self&&self.Object===Object&&self,$v=Mv||qv||Function("return this")(),_t=$v.Symbol,Wy=Object.prototype,Nv=Wy.hasOwnProperty,Lv=Wy.toString,Lt=_t?_t.toStringTag:void 0;function Fv(e){var t=Nv.call(e,Lt),r=e[Lt];try{e[Lt]=void 0;var n=!0}catch{}var i=Lv.call(e);return n&&(t?e[Lt]=r:delete e[Lt]),i}var Bv=Object.prototype,zv=Bv.toString;function Dv(e){return zv.call(e)}var Vv="[object Null]",Wv="[object Undefined]",Il=_t?_t.toStringTag:void 0;function Gv(e){return e==null?e===void 0?Wv:Vv:Il&&Il in Object(e)?Fv(e):Dv(e)}function Uv(e){return e!=null&&typeof e=="object"}var Hv="[object Symbol]";function Kv(e){return typeof e=="symbol"||Uv(e)&&Gv(e)==Hv}function Jv(e,t){for(var r=-1,n=e==null?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}var Be=Array.isArray,Ol=_t?_t.prototype:void 0,Ml=Ol?Ol.toString:void 0;function Gy(e){if(typeof e=="string")return e;if(Be(e))return Jv(e,Gy)+"";if(Kv(e))return Ml?Ml.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function Gu(e){return e==null?"":Gy(e)}function Zv(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),r=r>i?i:r,r<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n<i;)o[n]=e[n+t];return o}function Yv(e,t,r){var n=e.length;return r=r===void 0?n:r,!t&&r>=n?e:Zv(e,t,r)}var Xv="\\ud800-\\udfff",Qv="\\u0300-\\u036f",ex="\\ufe20-\\ufe2f",rx="\\u20d0-\\u20ff",tx=Qv+ex+rx,nx="\\ufe0e\\ufe0f",ox="\\u200d",ix=RegExp("["+ox+Xv+tx+nx+"]");function Uy(e){return ix.test(e)}function ax(e){return e.split("")}var Hy="\\ud800-\\udfff",sx="\\u0300-\\u036f",cx="\\ufe20-\\ufe2f",ux="\\u20d0-\\u20ff",lx=sx+cx+ux,dx="\\ufe0e\\ufe0f",fx="["+Hy+"]",$u="["+lx+"]",Nu="\\ud83c[\\udffb-\\udfff]",hx="(?:"+$u+"|"+Nu+")",Ky="[^"+Hy+"]",Jy="(?:\\ud83c[\\udde6-\\uddff]){2}",Zy="[\\ud800-\\udbff][\\udc00-\\udfff]",px="\\u200d",Yy=hx+"?",Xy="["+dx+"]?",gx="(?:"+px+"(?:"+[Ky,Jy,Zy].join("|")+")"+Xy+Yy+")*",yx=Xy+Yy+gx,mx="(?:"+[Ky+$u+"?",$u,Jy,Zy,fx].join("|")+")",bx=RegExp(Nu+"(?="+Nu+")|"+mx+yx,"g");function vx(e){return e.match(bx)||[]}function xx(e){return Uy(e)?vx(e):ax(e)}function wx(e){return function(t){t=Gu(t);var r=Uy(t)?xx(t):void 0,n=r?r[0]:t.charAt(0),i=r?Yv(r,1).join(""):t.slice(1);return n[e]()+i}}var Cx=wx("toUpperCase");function Sx(e,t,r,n){for(var i=-1,o=e==null?0:e.length;++i<o;)r=t(r,e[i],i,e);return r}function _x(e){return function(t){return e==null?void 0:e[t]}}var Ex={À:"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"},jx=_x(Ex),kx=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Rx="\\u0300-\\u036f",Px="\\ufe20-\\ufe2f",Ax="\\u20d0-\\u20ff",Tx=Rx+Px+Ax,Ix="["+Tx+"]",Ox=RegExp(Ix,"g");function Mx(e){return e=Gu(e),e&&e.replace(kx,jx).replace(Ox,"")}var qx=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function $x(e){return e.match(qx)||[]}var Nx=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function Lx(e){return Nx.test(e)}var Qy="\\ud800-\\udfff",Fx="\\u0300-\\u036f",Bx="\\ufe20-\\ufe2f",zx="\\u20d0-\\u20ff",Dx=Fx+Bx+zx,em="\\u2700-\\u27bf",rm="a-z\\xdf-\\xf6\\xf8-\\xff",Vx="\\xac\\xb1\\xd7\\xf7",Wx="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Gx="\\u2000-\\u206f",Ux=" \\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",tm="A-Z\\xc0-\\xd6\\xd8-\\xde",Hx="\\ufe0e\\ufe0f",nm=Vx+Wx+Gx+Ux,om="['’]",ql="["+nm+"]",Kx="["+Dx+"]",im="\\d+",Jx="["+em+"]",am="["+rm+"]",sm="[^"+Qy+nm+im+em+rm+tm+"]",Zx="\\ud83c[\\udffb-\\udfff]",Yx="(?:"+Kx+"|"+Zx+")",Xx="[^"+Qy+"]",cm="(?:\\ud83c[\\udde6-\\uddff]){2}",um="[\\ud800-\\udbff][\\udc00-\\udfff]",mt="["+tm+"]",Qx="\\u200d",$l="(?:"+am+"|"+sm+")",e0="(?:"+mt+"|"+sm+")",Nl="(?:"+om+"(?:d|ll|m|re|s|t|ve))?",Ll="(?:"+om+"(?:D|LL|M|RE|S|T|VE))?",lm=Yx+"?",dm="["+Hx+"]?",r0="(?:"+Qx+"(?:"+[Xx,cm,um].join("|")+")"+dm+lm+")*",t0="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",n0="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",o0=dm+lm+r0,i0="(?:"+[Jx,cm,um].join("|")+")"+o0,a0=RegExp([mt+"?"+am+"+"+Nl+"(?="+[ql,mt,"$"].join("|")+")",e0+"+"+Ll+"(?="+[ql,mt+$l,"$"].join("|")+")",mt+"?"+$l+"+"+Nl,mt+"+"+Ll,n0,t0,im,i0].join("|"),"g");function s0(e){return e.match(a0)||[]}function c0(e,t,r){return e=Gu(e),t=t,t===void 0?Lx(e)?s0(e):$x(e):e.match(t)||[]}var u0="['’]",l0=RegExp(u0,"g");function d0(e){return function(t){return Sx(c0(Mx(t).replace(l0,"")),e,"")}}var Cr=d0(function(e,t,r){return e+(r?" ":"")+Cx(t)});function f0(){let e,t=null;const r=new Set,n=i=>{t=i,r.forEach(o=>o())};return{subscribe:i=>(r.add(i),()=>{r.delete(i)}),getSnapshot:()=>t,select(i,o){e=i,n(o)},update(i,o){e===i&&n(o)},remove(i){e===i&&(e=void 0,n(null))}}}const Et=_.createContext(null),h0=()=>_.useState(f0)[0];function qn(e,t=!0){const r=_.useContext(Et),n=_.useId();return _.useEffect(()=>{t?r==null||r.update(n,e):r==null||r.remove(n)}),_.useEffect(()=>()=>r==null?void 0:r.remove(n),[r,n]),()=>{t&&(r==null||r.select(n,e))}}function p0({divider:e}){const t=_.useContext(Et),r=_.useSyncExternalStore(t.subscribe,t.getSnapshot,()=>null);return f.jsx(Et.Provider,{value:null,children:f.jsxs("span",{"data-recent-toolbar-action":"",style:{display:r?"contents":"none"},children:[r&&e,r]})})}function Oe({label:e,children:t}){const r=_.cloneElement(t,{title:t.props.title??e});if(!F.Tooltip.Root){const n=F.Tooltip;return f.jsx(n,{label:e,placement:"top",fontSize:"xs",borderRadius:"15px",children:r})}return f.jsxs(F.Tooltip.Root,{positioning:{placement:"top"},children:[f.jsx(F.Tooltip.Trigger,{asChild:!0,children:r}),f.jsx(F.Portal,{children:f.jsx(F.Tooltip.Positioner,{children:f.jsx(F.Tooltip.Content,{fontSize:"xs",borderRadius:"15px",children:e})})})]})}function Ht(){const{border:e}=Ze(),{colorMode:t}=Le();return f.jsx(F.chakra.span,{role:"separator","aria-orientation":"vertical",display:"block",flexShrink:0,w:"1px",h:"20px",mx:"4px",bg:t==="dark"?e:"gray.300"})}function br({children:e,value:t,onValueChange:r,disabled:n,style:i,title:o,icon:s,popupContent:a,footer:c,labelCase:u="title","aria-label":l,...d}){var A;const{colorMode:h}=Le(),{background:p,border:y,colorText:m,colorInactive:g}=Ze(),b=h==="dark",w=_.useId(),v=_.useRef(null),x=_.useRef(null),[C,S]=_.useState(!1),k=qn(f.jsx(br,{value:t,onValueChange:r,disabled:n,style:i,title:o,icon:s,popupContent:a,footer:c,labelCase:u,"aria-label":l,children:e}),!!s);_.useEffect(()=>{const j=x.current;j.setAttribute("popover","auto");const q=O=>S(O.newState==="open");return j.addEventListener("toggle",q),()=>j.removeEventListener("toggle",q)},[]);const I=_.Children.toArray(e).filter(_.isValidElement).map(j=>{const q=j.props;return{value:String(q.value),label:typeof q.children=="string"&&u==="title"?Cr(q.children):q.children,disabled:q.disabled}}),R=()=>{var j;return(j=x.current)==null?void 0:j.hidePopover()},M=()=>{var ae,Q,Y,pe,se;const j=(ae=v.current)==null?void 0:ae.getBoundingClientRect(),q=x.current;if(!j||!q)return;if((Q=v.current)!=null&&Q.closest("[popover]")){const $=window.innerHeight-j.bottom-16,V=j.top-16;q.style.maxHeight=`${Math.max(60,$,V)}px`;const W=q.getBoundingClientRect();q.style.left=`${Math.max(12,Math.min(j.right-W.width,window.innerWidth-W.width-12))}px`,q.style.top=`${Math.max(12,W.height<=$?j.bottom+4:j.top-W.height-4)}px`;return}const O=(se=(pe=(Y=v.current)==null?void 0:Y.closest("[data-flow-toolbar-scroll]"))==null?void 0:pe.parentElement)==null?void 0:se.getBoundingClientRect(),z=O??j;q.style.maxHeight=`${Math.max(60,Math.max(z.top-40,window.innerHeight-z.bottom-40))}px`;const U=q.getBoundingClientRect();q.style.left=`${Math.max(12,Math.min(Math.max((O==null?void 0:O.left)??12,j.right-U.width),((O==null?void 0:O.right)??window.innerWidth-12)-U.width,window.innerWidth-U.width-12))}px`,q.style.top=`${Math.max(12,z.top>=U.height+36?z.top-U.height-24:Math.min(z.bottom+24,window.innerHeight-U.height-12))}px`},E=()=>{var O,z,U,ae,Q,Y;if(n)return;if((O=x.current)==null||O.showPopover(),M(),a){(U=(z=x.current)==null?void 0:z.querySelector("input"))==null||U.focus({preventScroll:!0});return}const j=(ae=x.current)==null?void 0:ae.querySelectorAll('[role="option"]:not(:disabled)');(Y=((Q=x.current)==null?void 0:Q.querySelector('[aria-selected="true"]:not(:disabled)'))??(j==null?void 0:j[0]))==null||Y.focus()};_.useEffect(()=>{if(C){if(n){R();return}return window.addEventListener("resize",M),window.addEventListener("scroll",M,!0),()=>{window.removeEventListener("resize",M),window.removeEventListener("scroll",M,!0)}}},[C,n]);const P=`var(--chakra-colors-${p.replace(".","-")})`;return f.jsxs(f.Fragment,{children:[f.jsx(Oe,{label:o??l,children:f.jsx(F.chakra.button,{...d,ref:v,type:"button",role:"combobox","data-flow-select-icon":s?"":void 0,"aria-label":l,title:o??l,"aria-haspopup":a?"dialog":"listbox","aria-expanded":C,"aria-controls":w,disabled:n,h:"30px",w:"160px",px:"6px",fontSize:"12px",border:"none",borderRadius:"4px",bg:"transparent",color:s?g:m,display:"flex",alignItems:"center",justifyContent:s?"center":"space-between",gap:2,style:i,onClick:()=>{k(),C?R():E()},onKeyDown:j=>{["ArrowDown","ArrowUp"].includes(j.key)&&(j.preventDefault(),E())},children:s??f.jsxs(f.Fragment,{children:[f.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((A=I.find(j=>j.value===t))==null?void 0:A.label)??t}),f.jsx(K.PiCaretUp,{size:16,style:{flexShrink:0}})]})})}),f.jsxs(F.chakra.div,{ref:x,id:w,role:a?"dialog":"listbox","aria-label":l,position:"fixed",m:0,p:2,minW:"180px",maxW:"calc(100vw - 24px)",overflowY:"auto",bg:p,color:m,borderRadius:"30px",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"},'& [role="option"]':Pn,'& details [role="option"]:first-child':{borderTopLeftRadius:"4px",borderTopRightRadius:"4px"},...Kr(P,`var(--chakra-colors-${(b?y:"gray.300").replace(".","-")})`)},onKeyDown:j=>{var z,U,ae;if(a&&!["Escape","Tab"].includes(j.key))return;const q=[...j.currentTarget.querySelectorAll('[role="option"]:not(:disabled), [data-flow-menu-action]:not(:disabled)')],O=q.indexOf(document.activeElement);if(["ArrowDown","ArrowUp","Home","End"].includes(j.key)){j.preventDefault();const Q=j.key==="Home"?0:j.key==="End"?q.length-1:(O+(j.key==="ArrowDown"?1:-1)+q.length)%q.length;(z=q[Q])==null||z.focus()}else j.key==="Escape"||j.key==="Tab"?(j.key==="Escape"&&(j.preventDefault(),j.stopPropagation()),R(),(U=v.current)==null||U.focus()):j.key.length===1&&j.key!==" "&&((ae=q.find((Q,Y)=>{var pe;return Y>O&&((pe=Q.textContent)==null?void 0:pe.toLowerCase().startsWith(j.key.toLowerCase()))}))==null||ae.focus())},children:[a??I.map(j=>f.jsxs(F.chakra.button,{type:"button",role:"option","aria-selected":j.value===t,disabled:j.disabled,tabIndex:-1,display:"flex",alignItems:"center",gap:3,px:3,py:2,w:"100%",fontSize:"sm",textAlign:"left",bg:"transparent",color:m,_hover:{bg:b?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:b?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var q;R(),(q=v.current)==null||q.focus(),r(j.value)},children:[f.jsx("span",{style:{flex:1},children:j.label}),f.jsx(K.PiCheck,{size:16,color:`var(--chakra-colors-${m.replace(".","-")})`,"aria-hidden":"true",style:{flexShrink:0,visibility:j.value===t?"visible":"hidden"}})]},j.value)),c]})]})}const Pn={borderRadius:"4px","&:first-child":{borderTopLeftRadius:"22px",borderTopRightRadius:"22px"},"&:last-child":{borderBottomLeftRadius:"22px",borderBottomRightRadius:"22px"}},Ce=_.forwardRef(function({icon:t,rememberAction:r=!0,...n},i){const{colorMode:o}=Le(),s=Object.fromEntries(Object.entries(n).filter(([c])=>c!=="id"&&c!=="aria-describedby"&&!c.startsWith("data-")&&!/^on(Pointer|Mouse|Focus|Blur)/.test(c))),a=qn(f.jsx(Oe,{label:n.title??n["aria-label"]??"Last used action",children:f.jsx(Ce,{...s,icon:t})}),r&&!!n.onClick);return f.jsx(F.IconButton,{ref:i,_hover:{bg:o==="dark"?"whiteAlpha.100":"blackAlpha.50"},title:n.title??n["aria-label"],...n,onClick:c=>{var u;a(),(u=n.onClick)==null||u.call(n,c)},children:t})}),At=_.forwardRef(function(t,r){const{themeColor:n}=Le();return f.jsx(Oe,{label:"Close",children:f.jsx(Ce,{ref:r,size:"sm",variant:"plain",bg:"transparent",_hover:{bg:"transparent",color:n},color:n,focusRingColor:n,...t,"aria-label":t["aria-label"]??"Close selection tools",icon:f.jsx(K.PiXLight,{size:20,"aria-hidden":"true"})})})});function Uu({label:e,icon:t,checked:r,onChange:n,disabled:i,hideLabel:o=!1,helper:s=e}){const{themeColor:a,readOnly:c}=Le(),{colorInactive:u}=Ze();return f.jsx(Oe,{label:s,children:f.jsx(Ce,{"aria-label":e,"aria-pressed":r,icon:f.jsxs(f.Fragment,{children:[t,!o&&f.jsx(F.Text,{as:"span",fontSize:"16px",fontWeight:r?"bold":"normal",whiteSpace:"nowrap",children:e})]}),size:"sm",variant:"ghost",width:"auto",px:2,gap:2,color:r?a:u,disabled:i||c,onClick:()=>n(!r)})})}function fm({label:e="Compact layout"}={}){const{compactPropertyLayout:t,setCompactPropertyLayout:r,callbacks:n}=Le();return f.jsx(Uu,{hideLabel:!0,label:e,checked:t,icon:f.jsx(F.Icon,{as:K.PiArrowsIn,boxSize:5}),onChange:i=>{var o;r(i),(o=n.onCompactPropertyLayoutChange)==null||o.call(n,i)}})}const g0=Mn.default.input`
|
|
8
8
|
appearance: none;
|
|
9
9
|
width: 100%;
|
|
10
10
|
height: 24px;
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
cursor: default;
|
|
56
56
|
opacity: 0.5;
|
|
57
57
|
}
|
|
58
|
-
`,fm=_.forwardRef(function({style:t,...r},n){return f.jsx(h0,{...r,ref:n,style:{...t,backgroundImage:"none","--flow-range-track":(t==null?void 0:t.backgroundImage)??"none"}})});function Ll({label:e,inputLabel:t,value:r,displayValue:n,min:i,max:o,onChange:s}){const a=_.useId(),{readOnly:c,themeColor:u}=Ne(),{colorInactive:l}=Ze(),d=(r-i)/(o-i)*100,h=u.includes(".")?`var(--chakra-colors-${u.replace(".","-")})`:u;return f.jsxs("div",{style:{width:224,maxWidth:"calc(100vw - 64px)",padding:12},children:[f.jsxs("label",{htmlFor:a,style:{display:"flex",justifyContent:"space-between",fontSize:14,marginBottom:12},children:[e," ",f.jsx("span",{children:n})]}),f.jsx(fm,{id:a,"aria-label":t,type:"range",min:i,max:o,step:5,value:r,disabled:c,style:{color:h,accentColor:h,backgroundImage:`linear-gradient(to right, currentColor ${d}%, var(--chakra-colors-${l.replace(".","-")}) ${d}%)`},onChange:p=>s(Number(p.target.value))})]})}const Fl={dot:{label:"Dots",icon:K.PiDotsNine},grid:{label:"Grid",icon:K.PiGridFour},steel:{label:"Steel",icon:K.PiLineSegments},none:{label:"Solid",icon:K.PiSquareFill},transparent:{label:"Transparent",icon:K.PiSelection}};function hm(){const{spacing:e,setSpacing:t,edgeRadius:r,setEdgeRadius:n,backgroundVariant:i,setBackgroundVariant:o,callbacks:s,readOnly:a}=Ne(),c=Fl[i].icon;return f.jsxs(f.Fragment,{children:[f.jsx(Ht,{}),f.jsx(mr,{"aria-label":"Node spacing",title:`Spacing: ${Math.round(e*100)}%`,icon:f.jsx(K.PiArrowsOutCardinal,{size:20}),style:{width:36},value:"spacing",disabled:a,onValueChange:()=>{},popupContent:f.jsx(Ll,{label:"Spacing",inputLabel:"Node spacing percentage",min:50,max:200,value:Math.round(e*100),displayValue:`${Math.round(e*100)}%`,onChange:u=>{var l;t(u/100),(l=s.onSpacingChange)==null||l.call(s,u/100)}}),children:f.jsx("option",{value:"spacing",children:"Spacing"})}),f.jsx(Ht,{}),f.jsx(mr,{"aria-label":"Edge radius",title:`Edge radius: ${r??"Default"}`,icon:f.jsx(K.PiBezierCurve,{size:20}),style:{width:36},value:"radius",disabled:a,onValueChange:()=>{},popupContent:f.jsx(Ll,{label:"Edge radius",inputLabel:"Edge corner radius",min:0,max:500,value:r??500,displayValue:r??"Default",onChange:u=>{var l;n(u),(l=s.onEdgeRadiusChange)==null||l.call(s,u)}}),children:f.jsx("option",{value:"radius",children:"Edge radius"})}),f.jsx(Ht,{}),f.jsxs(mr,{"aria-label":"Background variant",title:`Background: ${Fl[i].label}`,icon:f.jsx(c,{size:20,"data-background-icon":i}),style:{width:36},value:i,disabled:a,onValueChange:u=>{var l;o(u),(l=s.onBackgroundVariantChange)==null||l.call(s,u)},children:[f.jsx("option",{value:"dot",children:"Dots"}),f.jsx("option",{value:"grid",children:"Grid"}),f.jsx("option",{value:"steel",children:"Steel"}),f.jsx("option",{value:"none",children:"Solid"}),f.jsx("option",{value:"transparent",children:"Transparent"})]})]})}const lr=[];for(let e=0;e<256;++e)lr.push((e+256).toString(16).slice(1));function p0(e,t=0){return(lr[e[t+0]]+lr[e[t+1]]+lr[e[t+2]]+lr[e[t+3]]+"-"+lr[e[t+4]]+lr[e[t+5]]+"-"+lr[e[t+6]]+lr[e[t+7]]+"-"+lr[e[t+8]]+lr[e[t+9]]+"-"+lr[e[t+10]]+lr[e[t+11]]+lr[e[t+12]]+lr[e[t+13]]+lr[e[t+14]]+lr[e[t+15]]).toLowerCase()}let po;const g0=new Uint8Array(16);function y0(){if(!po){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");po=crypto.getRandomValues.bind(crypto)}return po(g0)}const m0=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Bl={randomUUID:m0};function Gu(e,t,r){var i;if(Bl.randomUUID&&!e)return Bl.randomUUID();e=e||{};const n=e.random??((i=e.rng)==null?void 0:i.call(e))??y0();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,p0(n)}const qn={label:"Untitled",description:"",isTask:!1,isLocked:!1},Uu={id:null,type:"text",data:{...qn,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"}}},zl={id:null,type:"objectView",data:{...qn,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:53,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},b0={id:null,type:"arrayView",data:{...qn,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"}}},Dl={id:null,type:"workflowStep",data:{...qn,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}},br=e=>typeof e=="object",pm=e=>Array.isArray(e),v0=["order","position","selected","locked","grabbed","grabbable","scratch"],Kr=e=>Object.entries(e).reduce((t,[r,n])=>(!br(n)&&!r.startsWith("$")&&(t[r]=n),t),{}),Hu=(e,t)=>typeof e=="string"&&e.startsWith("$")?go(e,t):br(e)&&!pm(e)?Object.entries(e).reduce((r,[n,i])=>(typeof i=="string"&&i.startsWith("$")&&n==="..."?(delete r["..."],r[n]={...go(i,t),...e}):typeof i=="string"&&i.startsWith("$")?r[n]=go(i,t):r[n]=i,r),{}):e,Jr=e=>Object.entries(e).reduce((t,[r,n])=>(br(n)&&r&&n&&!r.startsWith("$")&&(v0.includes(r)&&(r=r+"#"),t[r]=n),t),{}),ot=(e,t,{label:r,parent:n=void 0},i,o=null)=>(o!==null&&(br(o)||pm(o))&&(o=JSON.stringify(o,null,2)),{data:{parent:n,...e.data,id:t,text:r||"",label:r,code:o||null,type:e.type,description:i}}),Ur=(e,t,r=null,n=null,i=null,o=!1,s=null)=>({data:{id:Gu(),source:i?t:e,target:i?e:t,label:n||"",isInverted:i,isEdgeAnimated:o,parent:s}}),Zr=(e,t=[])=>{const r={},n={};let i=[];if(e)for(const[o,s]of Object.entries(e))o.startsWith("$")&&o!=="$"?r[o.slice(1)]=s:o!=="$"?n[o]=s:o==="$"&&(i=s);return{newConfig:r,updatedObject:n,arrayObject:i}},xt=(e,t)=>{let r=zl;const{view:n,borderColor:i,borderRadius:o,bgColor:s,textColor:a,fontSize:c,stepType:u}=t;e=n||e,u?r={...Dl}:e==="object"?r=zl:e==="text"?r=Uu:e==="array"?r=b0:e==="workflowStep"&&(r={...Dl});const l=r.data.viewProps;return r.data.viewProps={...l,borderRadius:o||(u?15:53),bgColor:s,borderColor:i,textColor:a,fontSize:c},r.data.config=t,{config:r}},on=(e,t)=>(e=t.find(n=>n.data.id===e)?`${e}.#`:e,e),go=(e,{ids:t,jsnObjct:r})=>{if(typeof e=="string"&&(e!=null&&e.startsWith("$"))){const n=e.replace("$","").replace("*","");e==null||e.endsWith("*");const i=t.find(a=>a.split(".").slice(-1)[0]===n||n===a);if(!i)return e;const o=x0(i,r);return JSON.stringify(o).includes(e)?e:o||e}return e},x0=(e,t)=>{let r=e.split(".").splice(1);return r=r[r.length-1]==="#"||r[r.length-1].includes("{")?r.slice(0,-2):r,(o=>r.reduce((s,a)=>{a=a.replace("[","").replace("]","");const{arrayObject:c}=Zr(s);return s=c.length?c:s,s[a]},o))(t)};function Ct(e,t="root",r=[]){try{const{arrayObject:n}=Zr(e);n.length&&(e=n);const i=Kr(e),o=Jr(e);return br(e)?(Fe(e)||Fe(e)&&t==="root"||!Fe(e)&&Object.keys(i).length||t==="root")&&r.push(t):r.push(t),Object.keys(o).length&&!Fe(e)?Kt({chldPth:null,itrblObjct:o,nodes:r,path:t}):Fe(e)&&e.forEach((s,a)=>{const c=Kr(s),u=Jr(s),{newConfig:l,arrayObject:d}=Zr(s);let h=`${t}.${a}`;br(s)?Object.keys(c).length?(Ct(c,h,r),Object.keys(u).length&&!Fe(s)&&Kt({chldPth:h,itrblObjct:u,nodes:r,path:t})):Object.keys(u).length&&!Fe(s)?Kt({chldPth:h,itrblObjct:u,nodes:r,path:t}):Fe(s)&&gm({chldPth:h,item:s,nodes:r,path:t}):r.push(h)}),{nodes:r}}catch{return{nodes:r}}}const Kt=({chldPth:e,itrblObjct:t,nodes:r,path:n})=>Object.entries(t).forEach(([i,o],s)=>{const a=Kr(o),c=Jr(o),{newConfig:u,arrayObject:l}=Zr(o);l.length&&(o=l),n.split(".").slice(0,2).join(".");let d=e?`${e}.${i}`:`${n}.${i}`;if(br(o)&&!Fe(o)){const h=Object.keys(a).length===0;if(h&&(xt("array",u),r.push(d)),Object.keys(a).length){const p=Fe(o)?`${o.length||""}`:`{${Object.keys(o).length||""}}`;let y=d;h&&(y=`${d}.${p}`),Ct(o,y,r)}else Object.keys(c).length&&!Fe(o)?Kt({chldPth:d,itrblObjct:c,path:d,nodes:r}):Ct(o,d,r)}else Fe(o)&&Ct(o,d,r)}),gm=({chldPth:e,item:t,nodes:r,path:n})=>t.forEach((i,o)=>{let s=`${e}.${o}`;const a=Jr(i),c=Kr(i);br(i)?!Fe(i)&&Object.keys(c).length?Ct(i,s,r):Object.keys(a).length&&!Fe(i)?Kt({chldPth:s,itrblObjct:a,path:n,nodes:r}):Fe(i)&&gm({chldPth:s,item:i,nodes:r,path:n}):r.push(s)}),Jt=[];let Zt;function st(e,t="root",r=[],n=[],i="untitled",o={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},s={}){if(!e||typeof e!="object")return console.error("Invalid object passed",e),{nodes:r,edges:n};const a=e;if(t==="root"&&(Jt.length=0),!Zt){const{nodes:l}=Ct(e);Zt={ids:l,jsnObjct:e}}let{hideDefaultObject:c,sprtObjctKy:u}=o;try{t=on(t,r);const{newConfig:l,arrayObject:d}=Zr(e),h=Object.keys(s).length>0?s:l;d.length&&(e=d);const p=Kr(e),y=Jr(e),{label:m,collapsed:g,parent:b}=h;if(!br(e))r.push(ot(Uu,t,{label:m||t,parent:b},e,a));else if(Fe(e)||Fe(e)&&t==="root"){const{config:w}=xt("array",h),v=Fe(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,x=t==="root"?i:`${i} ${v}`;r.push(ot(w,t,{label:m||x,parent:b},e,Fe(a)?{[i]:a}:a))}else if(!Fe(e)&&Object.keys(p).length||t==="root"){const{config:w}=xt(null,h),v=Fe(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,x=t.split("."),C=x[x.length-1];let S=isNaN(Number(C))?null:Number(C)+1;const E=isNaN(Number(C))?C:x[x.length-2]+" "+S,I=t==="root"?i:E;let A=!1;Number.isNaN(Number(i))||(A=!0);const M=e;if(m){const{config:j}=xt("object",h);r.push(ot(j,t,{label:m||`${m} ${v}`,parent:b},p,M))}else w.data.headerTitle=I,r.push(ot(w,t,{label:m,parent:b},p,M))}return g||(Object.keys(y).length&&!Fe(e)?Yt({flowConfig:o,chldPth:null,edges:n,isInverted:null,itrblObjct:y,nodes:r,path:t,newConfig:h}):Fe(e)&&e.forEach((w,v)=>{w=Hu(w,Zt);const x=w,C=Kr(w),S=Jr(w),{newConfig:E,arrayObject:I}=Zr(w);I.length&&(w=I);const{config:A}=xt(typeof w=="string"?"text":"array",E),{hideConfig:M,sourceLabel:j,label:R,isEdgeAnimated:P,parent:k}=E;c=c||M;const q=t==="root"&&o.isCntr,O=t.split(".").slice(0,2).join("."),z=Jt.includes(O),U=o.isCntr&&z||v%2===0&&q;let se=`${t}.${v}`;se=on(se,r),U&&Jt.push(se),br(w)?Object.keys(C).length&&!Fe(w)?(n.push(Ur(t,se,null,j,U,P)),st(w,se,r,n,R||v,o,E)):Object.keys(S).length&&!Fe(w)?Yt({flowConfig:o,chldPth:se,isInverted:U,edges:n,itrblObjct:S,nodes:r,path:t,newConfig:E,forceIsInverted:!0}):Fe(w)?ym({flowConfig:o,chldPth:se,edges:n,isInverted:U,item:w,nodes:r,path:t}):br(w)&&Yt({flowConfig:o,chldPth:se,isInverted:U,edges:n,itrblObjct:[w],nodes:r,path:t,newConfig:E}):(n.push(Ur(t,se,null,j,U,P)),r.push(ot(A,se,{label:R||String(w),parent:k},w,x)))})),{nodes:r,edges:n}}catch{return{nodes:r,edges:n}}}const Yt=({chldPth:e,flowConfig:t,edges:r,itrblObjct:n,nodes:i,isInverted:o,path:s,newConfig:a,forceIsInverted:c=!1})=>{let{hideDefaultObject:u,sprtObjctKy:l}=t;return Object.entries(n).forEach(([d,h],p)=>{h=Hu(h,Zt);const y=h,m=Kr(h),g=Jr(h),{newConfig:b,arrayObject:w}=Zr(h);w.length&&(h=w);const{hideConfig:v,sourceLabel:x,label:C,content:S,target:E,targetLabel:I,collapsed:A,isEdgeAnimated:M,parent:j}=b;u=u||v;const R=s==="root"&&t.isCntr,P=s.split(".").slice(0,2).join("."),k=Jt.includes(P);c||(o=t.isCntr&&k||p%2===0&&R);let q=e?`${e}.${d}`:`${s}.${d}`;if(q=on(q,i),o&&Jt.push(q),E&&r.push(Ur(q,E,null,I,o,M)),br(h)&&!Fe(h)){r.push(Ur(s,q,null,x,o,M));const O=l||Object.keys(m).length===0;if(O){const z=S?"object":"array",{config:U}=xt(z,b);U.data.headerTitle=S?C:null,i.push(ot(U,q,{label:C||d,parent:j},h,y))}if(Object.keys(m).length&&!u){const z=Fe(h)?` ${h.length||""}`:`{${Object.keys(h).length||""}}`;let U=q;O&&(U=`${q}.${z}`,U=on(U,i),r.push(Ur(q,U,null,x,o,M))),st(h,U,i,r,C||d,t,b)}else Object.keys(g).length&&!Fe(h)?Yt({chldPth:q,flowConfig:t,itrblObjct:g,path:q,edges:r,nodes:i,newConfig:b,isInverted:o}):st(h,q,i,r,d,t,b)}else Fe(h)&&(r.push(Ur(s,q,null,x,o,M)),st(h,q,i,r,d,t,b))})},ym=({flowConfig:e,chldPth:t,edges:r,isInverted:n,item:i,nodes:o,path:s})=>i.forEach((a,c)=>{let u=`${t}.${c}`;u=on(u,o);const l=a;a=Hu(a,Zt);const d=Jr(a),h=Kr(a),{newConfig:p}=Zr(a),{collapsed:y,label:m,parent:g,sourceLabel:b,isEdgeAnimated:w,content:v}=p;br(a)?!Fe(a)&&Object.keys(h).length?(r.push(Ur(s,u,null,b,n,w)),st(a,u,o,r,c,e,p)):Object.keys(d).length&&!Fe(a)&&!y?Yt({chldPth:u,flowConfig:e,itrblObjct:d,path:s,edges:r,nodes:o,isInverted:n,newConfig:p}):Fe(a)&&ym({flowConfig:e,chldPth:u,edges:r,isInverted:n,item:a,nodes:o,path:s}):(r.push(Ur(s,u,null,b,n,w)),o.push(ot(Uu,u,{label:m||String(a),parent:g},a,l)))});function w0(e,t){const r=new Set,n=u=>{if(!(!u||typeof u!="object")){typeof u.$parent=="string"&&r.add(u.$parent);for(const[l,d]of Object.entries(u))(!l.startsWith("$")||l==="$")&&n(d)}};if(n(e),!r.size)return t;const i=new Map(t.nodes.map(u=>[u.data.id,u])),o=u=>{var p,y;let l=u.data.id;const d=new Set([u.data.id]);let h=u.data.parent;for(;h&&!d.has(h);)r.has(h)&&i.has(h)&&((p=Re(e,h))!=null&&p.$collapsed)&&(l=h),d.add(h),h=(y=i.get(h))==null?void 0:y.data.parent;return l},s=new Map(t.nodes.map(u=>[u.data.id,o(u)])),a=t.nodes.filter(u=>s.get(u.data.id)===u.data.id).map(u=>{if(!r.has(u.data.id))return u;const l=Re(e,u.data.id),d=!!(l!=null&&l.$collapsed);return{...u,data:{...u.data,...d?{type:"arrayView"}:{},config:{...u.data.config,parentContainer:!0,collapsed:d,...d?{labelBelow:!0,icon:(l==null?void 0:l.$icon)||"PiStack"}:{}}}}}),c=new Set(a.map(u=>u.data.id));return{nodes:a,edges:t.edges.flatMap(u=>{const l=s.get(u.data.source),d=s.get(u.data.target);return!l||!d||!c.has(l)||!c.has(d)?[]:l===u.data.source&&d===u.data.target?[u]:l===d?[]:[{...u,data:{...u.data,source:l,target:d,collapsedEndpoints:u.data.collapsedEndpoints??{source:u.data.source,target:u.data.target}}}]})}}function $n(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 i=r;if(typeof i.target!="string"||!/^root(?:\.|$)/.test(i.target))return[];if(i.sourceProperty!==void 0&&typeof i.sourceProperty!="string")return[];if(i.targetProperty!==void 0&&typeof i.targetProperty!="string")return[];const o=typeof i.id=="string"&&i.id?JSON.stringify(["id",i.id]):JSON.stringify(["ports",i.target,i.sourceProperty??null,i.targetProperty??null]),s=t.get(o)??0;return t.set(o,s+1),[{value:i,key:`${o}#${s}`,index:n}]})}function mm(e,t,r){const n=$n(e).find(c=>c.key===t);if(!n)return e;const i=r(n.value),o=e.$connections.flatMap((c,u)=>u===n.index?i?[i]:[]:[c]);if(o.length)return{...e,$connections:o};const{$connections:s,...a}=e;return a}function C0(e){const t=[],r=(n,i)=>{if(!n||typeof n!="object")return n;if(Array.isArray(n))return n.map((o,s)=>r(o,`${i}.${s}`));for(const o of $n(n)){const s=o.value;t.push({data:{id:`connection:${JSON.stringify([i,o.key])}`,source:i,target:s.target,type:typeof s.type=="string"?s.type:void 0,sourceProperty:s.sourceProperty,targetProperty:s.targetProperty,icon:typeof s.icon=="string"?s.icon:void 0,label:typeof s.label=="string"?s.label:void 0,color:typeof s.color=="string"?s.color:void 0,isEdgeDashed:s.style==="dashed",isEdgeAnimated:s.style==="animated",...["dashed","traveling"].includes(s.animationVariant)?{edgeAnimationVariant:s.animationVariant}:{},connection:{address:i,key:o.key}}})}return Object.fromEntries(Object.entries(n).filter(([o])=>o!=="$connections").map(([o,s])=>[o,o==="$"?r(s,i):o.startsWith("$")?s:r(s,`${i}.${o}`)]))};return{json:r(e,"root"),edges:t}}const St="root",Vl=e=>e==="#"||e.startsWith("{")||/^\s\d*$/.test(e);function kr(e){const t=e.split(".");for(t[0]===St&&t.shift();t.length&&Vl(t[t.length-1]);)t.pop();return t.filter(r=>!Vl(r))}function Nn(e){return e==null||typeof e!="object"?e:Array.isArray(e.$)?e.$:e}function Re(e,t){return kr(t).reduce((r,n)=>{var i;if(r!=null)return(i=Nn(r))==null?void 0:i[n]},e)}function S0(e){return Array.isArray(e)?[...e]:{...e}}function vr(e,t,r){const n=kr(t),i=(o,s)=>{if(s===n.length)return r(o);const a=n[s],c=Nn(o);if(c==null||typeof c!="object")return o;const u=i(c[a],s+1);if(Object.is(u,c[a]))return o;const l=S0(c);return l[a]=u,c!==o?{...o,$:l}:l};return i(e,0)}function Nr(e,t,r){const n=r===""&&t!=="$content"||r===void 0||r===null;if(Array.isArray(e))return n?e:{[t]:r,$:[...e]};const i=e!=null&&typeof e=="object"?{...e}:{};return e!=null&&typeof e!="object"&&(i.$label=String(e)),n?delete i[t]:i[t]=r,i}function hr(e,t,r,n){return vr(e,t,i=>r==="$label"&&typeof i=="string"&&typeof n=="string"&&n!==""?n:Nr(i,r,n))}const bm=(e,t,r)=>hr(e,t,"$collapsed",r);function it(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,i=kr(r).join("."),o=kr(n).join(".");return o.startsWith(i?i+".":"")&&o!==i?{address:n,kind:"hierarchy"}:i.startsWith(o?o+".":"")&&i!==o?{address:r,kind:"hierarchy"}:{address:r,kind:"target"}}function Gr(e,t,r,n){if(t.connection){const a=t.connection;return vr(e,a.address,c=>mm(c,a.key,u=>{if(r==="$edgeIcon")return Nr(u,"icon",n);if(r==="$edgeType")return Nr(u,"type",n);if(r==="$edgeAnimationVariant")return Nr(u,"animationVariant",n);if(r==="$sourceLabel"||r==="$edgeColor")return Nr(u,r==="$sourceLabel"?"label":"color",n);const l=r==="$isEdgeAnimated"?"animated":"dashed";return n?{...u,style:l}:u.style===l?Nr(u,"style",void 0):u}))}const{address:i,kind:o}=it(t),s=o==="target"&&r==="$sourceLabel"?"$targetLabel":o==="target"&&r==="$edgeType"?"$targetEdgeType":o==="target"&&r==="$edgeIcon"?"$targetIcon":o==="target"&&r==="$edgeAnimationVariant"?"$targetAnimationVariant":r;return vr(e,i,a=>Nr(a,s,n))}const vm=(e,t,r)=>Gr(Gr(e,t,"$isEdgeAnimated",r==="animated"||void 0),t,"$isEdgeDashed",r==="dashed"||void 0);function Ku(e,t,r,n){let i=n||"";const o=vr(e,t,a=>{const c=Nn(a);if(Array.isArray(c)){i=String(c.length);const l=[...c,r];return c===a?l:{...a,$:l}}const u=a!=null&&typeof a=="object"&&!Array.isArray(a)?{...a}:a!=null&&typeof a!="object"?{$label:String(a)}:{};if(!i){let l=1;for(;`node_${l}`in u;)l++;i=`node_${l}`}return u[i]=r,u}),s=kr(t);return{json:o,address:[St,...s,i].join(".")}}function xm(e,t){const r=kr(t);if(!r.length)return e;const n=r[r.length-1],i=[St,...r.slice(0,-1)].join(".");return vr(e,i,o=>{const s=Nn(o);if(s==null||typeof s!="object"||!Object.prototype.hasOwnProperty.call(s,n))return o;if(Array.isArray(s)){const u=s.filter((l,d)=>String(d)!==n);return s===o?u:{...o,$:u}}const{[n]:a,...c}=o;return c})}const wm=(e,t,r,n)=>hr(n?vr(e,t,i=>Nr(i,"$targetLabel",n)):e,t,"$target",r);function Ju(e,t,r){const n=Re(e,t);return $n(n).some(({value:o})=>o.target===r.target&&o.sourceProperty===r.sourceProperty&&o.targetProperty===r.targetProperty)?e:vr(e,t,o=>Nr(o,"$connections",[...Array.isArray(o==null?void 0:o.$connections)?o.$connections:[],{...r,id:r.id||Gu()}]))}function Cm(e,t){if(t.connection){const o=t.connection;return $n(Re(e,o.address)).some(s=>s.key===o.key)?{json:vr(e,o.address,s=>mm(s,o.key,()=>null)),removed:!0}:{json:e,removed:!1}}const{address:r,kind:n}=it(t);return n==="hierarchy"?Re(e,r)===void 0?{json:e,removed:!1}:{json:vr(e,r,o=>({...o,$hideParentEdge:!0})),removed:!0}:n!=="target"?{json:e,removed:!1}:{json:vr(e,r,o=>{const{$target:s,$targetLabel:a,...c}=o||{};return c}),removed:!0}}function $u(e,t={}){var w;const r=C0(e),{nodes:n,edges:i}=st(r.json,St,[],[],t.title||"untitled",{hideDefaultObject:!!t.hideDefaultObject,sprtObjctKy:!!t.separateObjectKeys,isCntr:!!t.isCenter}),o=new Set(n.map(v=>v.data.id)),s=new Map;for(const v of n){const x=v.data.id;if(!x.endsWith(".0")||Re(e,x)!==void 0)continue;const C=x.slice(0,-2),S=Re(e,C);!o.has(C)&&S&&typeof S=="object"&&!Array.isArray(S)&&typeof S.$label=="string"&&Object.keys(S).every(E=>E.startsWith("$")&&E!=="$")&&s.set(x,C)}const a=v=>s.get(v)??v,c=new Set(n.flatMap(v=>v.data.parent?[a(v.data.parent)]:[])),u=new Map;if(t.isCenter){const v=new Map;for(const{data:x}of i){const C=it(x);if(C.kind==="hierarchy")u.set(a(C.address),!!x.isInverted);else if(!Array.isArray(e)&&e.$hideRoot===!0){const S=a(x.isInverted?x.source:x.target);if(kr(S).length!==1)continue;const E=!!x.isInverted;v.set(S,v.has(S)&&v.get(S)!==E?null:E)}}for(const[x]of u){const C=`${St}.${kr(x)[0]}`,S=v.get(C);typeof S=="boolean"&&u.set(x,S)}}const l=n.map(v=>{var A;const x=a(v.data.id),C=Re(e,x),S={...v.data,id:x};u.has(x)&&(S.config={...S.config,isInverted:u.get(x)});const E=C&&typeof C=="object"&&!Array.isArray(C)&&"$"in C?C.$:C;if((Array.isArray(E)?E.length>0:E&&typeof E=="object"&&Object.keys(E).some(M=>!M.startsWith("$")))&&(S.config={...S.config,collapsed:!!C.$collapsed}),c.has(x)||(S.viewProps={...S.viewProps},delete S.viewProps.borderWidth),!C||typeof C!="object"||Array.isArray(C))return{data:S};if(C.$form&&typeof C.$form=="object"&&(S.config={...S.config,form:C.$form},S.type="objectView"),Array.isArray(C.$ports)){const M=C.$ports.filter(j=>j&&typeof j.id=="string"&&["source","target"].includes(j.role)&&["top","right","bottom","left"].includes(j.side));S.config={...S.config,ports:M}}if(S.parent&&(S.parent=a(S.parent)),typeof C.$label=="string"&&(S.label=C.$label,S.headerTitle=C.$label),typeof C.$subtitle=="string"&&(S.config={...S.config,subtitle:C.$subtitle}),typeof C.$outline=="boolean"&&(S.viewProps={...S.viewProps,outline:C.$outline}),["solid","dashed","dotted","double"].includes(C.$borderStyle)&&(S.viewProps={...S.viewProps,borderStyle:C.$borderStyle}),Number.isFinite(C.$borderWidth)&&C.$borderWidth>=0&&(S.viewProps={...S.viewProps,borderWidth:C.$borderWidth}),Number.isFinite(C.$borderRadius)&&C.$borderRadius>=0&&(S.viewProps={...S.viewProps,borderRadius:C.$borderRadius}),typeof C.$isNodeAnimated=="boolean"&&(S.isNodeAnimated=C.$isNodeAnimated),["traveling","pulse"].includes(C.$nodeAnimationVariant)&&(S.nodeAnimationVariant=C.$nodeAnimationVariant),typeof C.$content=="string"){S.config={...S.config,content:C.$content};const M=C.$contentFormat??"markdown";if(!["markdown","html","jsx"].includes(M))throw new Error("Invalid content format: expected markdown, html, or jsx.");S.config.contentFormat=M,C.$view||(S.type="objectView")}return(((A=S.config)==null?void 0:A.collapsed)!==void 0||C.$collapsed!==void 0||C.$icon!==void 0)&&(S.config={...S.config||{}},(C.$collapsed!==void 0||S.config.collapsed!==void 0)&&(S.config.collapsed=!!C.$collapsed),C.$icon!==void 0&&(S.config.icon=C.$icon)),{data:S}}),d=new Map,h=i.map(v=>{let x=a(v.data.source),C=a(v.data.target),S=v.data.isInverted;const E=it(v.data),I=u.get(a(E.address));E.kind==="hierarchy"&&I!==void 0&&I!==!!S&&([x,C]=[C,x],S=I);const A=`${x}->${C}`,M=d.get(A)??0;d.set(A,M+1);const j={...v.data,id:M?`${A}#${M}`:A,source:x,target:C,isInverted:S},R=it(j),P=Re(e,R.address);if(P&&typeof P=="object"){const k=P[R.kind==="target"?"$targetEdgeType":"$edgeType"];typeof k=="string"&&(j.type=k);const q=P[R.kind==="target"?"$targetIcon":"$edgeIcon"];typeof q=="string"&&(j.icon=q),P.$isEdgeAnimated!==void 0&&(j.isEdgeAnimated=!!P.$isEdgeAnimated);const O=P[R.kind==="target"?"$targetAnimationVariant":"$edgeAnimationVariant"];["dashed","traveling"].includes(O)&&(j.edgeAnimationVariant=O),P.$isEdgeDashed!==void 0&&(j.isEdgeDashed=!!P.$isEdgeDashed),P.$edgeColor&&(j.color=P.$edgeColor)}return{data:j}});if(!Array.isArray(e)&&(e==null?void 0:e.$hideRoot)===!0){const v=l.findIndex(x=>x.data.id===St);v!==-1&&l.splice(v,1)}const p=new Set(l.map(v=>v.data.id));for(let v=h.length-1;v>=0;v--){const x=h[v].data,C=it(x);(!p.has(x.source)||!p.has(x.target)||C.kind==="hierarchy"&&((w=Re(e,C.address))==null?void 0:w.$hideParentEdge)===!0)&&h.splice(v,1)}h.push(...r.edges.filter(v=>p.has(v.data.source)&&p.has(v.data.target)));const y=w0(e,{nodes:l,edges:h}),m=y.nodes.filter(v=>{var x;return(x=v.data.config)==null?void 0:x.collapsed}).map(v=>kr(v.data.id));if(!m.length)return y;const g=y.nodes.filter(v=>{const x=kr(v.data.id);return!m.some(C=>C.length<x.length&&C.every((S,E)=>S===x[E]))}),b=new Set(g.map(v=>v.data.id));return{nodes:g,edges:y.edges.filter(v=>b.has(v.data.source)&&b.has(v.data.target))}}function _0(e,t){const r=new Set(e.filter(c=>{var u,l;return(l=(u=c.data)==null?void 0:u.config)==null?void 0:l.collapsed}).map(c=>c.data.id));if(!r.size)return{nodes:e,edges:t};const n=new Map(e.map(c=>[c.data.id,c])),i=new Set(e.map(c=>c.data.parent).filter(Boolean)),o=new Map(e.map(c=>{var h;let u=c.data.id,l=c.data.parent;const d=new Set([u]);for(;l&&!d.has(l);)r.has(l)&&(u=l),d.add(l),l=(h=n.get(l))==null?void 0:h.data.parent;return[c.data.id,u]})),s=new Map;for(const c of t){const u=c.data.isInverted?c.data.target:c.data.source,l=c.data.isInverted?c.data.source:c.data.target;(s.get(u)??s.set(u,[]).get(u)).push(l)}const a=new Set(e.filter(c=>o.get(c.data.id)!==c.data.id).map(c=>c.data.id));for(const c of r){if(i.has(c))continue;const u=[...s.get(c)||[]];for(;u.length;){const l=u.pop();r.has(l)||a.has(l)||(a.add(l),u.push(...s.get(l)||[]))}}return{nodes:e.filter(c=>!a.has(c.data.id)).map(c=>{var u;return r.has(c.data.id)&&i.has(c.data.id)?{...c,data:{...c.data,type:"arrayView",label:c.data.label??c.data.headerTitle,config:{...c.data.config,parentContainer:!0,labelBelow:!0,icon:((u=c.data.config)==null?void 0:u.icon)||"PiStack"}}}:c}),edges:t.flatMap(c=>{const u=o.get(c.data.source)??c.data.source,l=o.get(c.data.target)??c.data.target;return a.has(u)||a.has(l)?[]:u===c.data.source&&l===c.data.target?[c]:u===l?[]:[{...c,data:{...c.data,source:u,target:l,collapsedEndpoints:c.data.collapsedEndpoints??{source:c.data.source,target:c.data.target}}}]})}}function Zu(e,t){const r=JSON.parse(e);let n=512;const i=(s,a=[])=>{if(--n<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(!s||typeof s!="object"||Array.isArray(s))throw new Error("Expected a JSON Schema object.");const c=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(s))if(!c.has(l))throw new Error(`Unsupported JSON Schema keyword: ${l}`);const u=["$schema","$id","$defs","definitions","title","description","default","examples"];if(s.$ref){if(Object.keys(s).some(d=>!["$ref","title","description"].includes(d)))throw new Error("Use $ref without sibling constraints.");if(typeof s.$ref!="string"||!s.$ref.startsWith("#/")||a.includes(s.$ref))throw new Error("Only nonrecursive local $ref references are supported.");let l=r;for(const d of s.$ref.slice(2).split("/")){const h=d.replace(/~1/g,"/").replace(/~0/g,"~");if(!l||!Object.prototype.hasOwnProperty.call(l,h))throw new Error(`Unresolved reference: ${s.$ref}`);l=l[h]}return i(l,[...a,s.$ref])}if(s.anyOf){if(!Array.isArray(s.anyOf)||!s.anyOf.length||Object.keys(s).some(l=>l!=="anyOf"&&!u.includes(l)))throw new Error("Use a nonempty anyOf without sibling type constraints.");return{kind:"union",types:s.anyOf.map(l=>i(l,a))}}if(Object.prototype.hasOwnProperty.call(s,"const")||s.enum){if(Object.keys(s).some(h=>![...u,"const","enum","type"].includes(h))||s.enum&&Object.prototype.hasOwnProperty.call(s,"const"))throw new Error("Use enum or const without sibling constraints other than type.");const l=Object.prototype.hasOwnProperty.call(s,"const")?[s.const]:s.enum;if(!Array.isArray(l)||!l.length)throw new Error("Expected a nonempty enum.");return{kind:"union",types:l.map(h=>{if(h!==null&&!["string","number","boolean"].includes(typeof h))throw new Error("Only primitive literals are supported.");const p=h===null?"null":typeof h;if(s.type&&!(Array.isArray(s.type)?s.type:[s.type]).some(y=>y===p||y==="integer"&&Number.isInteger(h)))throw new Error("Literal does not match its declared type.");return{kind:"literal",value:h}})}}if(Array.isArray(s.type)){if(!s.type.length||s.type.some(l=>typeof l!="string"))throw new Error("Expected a nonempty list of primitive types.");if(Object.keys(s).some(l=>l!=="type"&&!u.includes(l)))throw new Error("Use anyOf for unions with object or array constraints.");return{kind:"union",types:s.type.map(l=>i({type:l},a))}}if((s.properties||s.required||s.additionalProperties!==void 0)&&s.type!=="object"&&s.type!==void 0)throw new Error("Object constraints require an object type.");if(s.items&&s.type!=="array")throw new Error("items requires an array type.");if(s.type==="object"||s.properties){if(s.additionalProperties!==void 0&&s.additionalProperties!==!0)throw new Error("Closed objects and typed additionalProperties are not supported.");if(!s.properties||typeof s.properties!="object"||Array.isArray(s.properties))throw new Error("Object schemas must declare properties.");if(s.required!==void 0&&(!Array.isArray(s.required)||s.required.some(d=>typeof d!="string"||!Object.prototype.hasOwnProperty.call(s.properties,d))))throw new Error("required must list declared property names.");return{kind:"object",properties:Object.fromEntries(Object.entries(s.properties).map(([d,h])=>[d,{type:i(h,a),optional:!(s.required??[]).includes(d)}]))}}if(s.type==="array")return{kind:"array",items:i(s.items,a)};if(["string","number","integer","boolean","null"].includes(s.type))return{kind:s.type};throw new Error("Every property must declare a supported type.")},o=i(r);if(o.kind!=="object")throw new Error("The root schema must be an object keyed by node ID.");if(Object.values(o.properties).some(s=>s.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:t,nodes:o.properties}}async function Yu(e,t,r,n={}){var y;let i=512;const o=await import("typescript"),s=o.createSourceFile(t,e,o.ScriptTarget.Latest,!0,o.ScriptKind.TS),a=s.parseDiagnostics;if(a!=null&&a.length)throw new Error("Invalid TypeScript syntax.");const c=new Map;for(const m of s.statements){if(!o.isInterfaceDeclaration(m)&&!o.isTypeAliasDeclaration(m))throw new Error("Upload interfaces/type aliases only; imports and executable code are not supported.");if((y=m.typeParameters)!=null&&y.length||c.has(m.name.text))throw new Error("Generics and duplicate declarations are not supported.");c.set(m.name.text,m)}const u=(m,g)=>{var C;const b={},w=m.find(S=>o.isIndexSignatureDeclaration(S));let v;if(w&&n.allowJson&&o.isIndexSignatureDeclaration(w)){if(m.filter(S=>o.isIndexSignatureDeclaration(S)).length!==1||w.parameters.length!==1||((C=w.parameters[0].type)==null?void 0:C.kind)!==o.SyntaxKind.StringKeyword||!w.type)throw new Error("Only one string-keyed index signature is supported for forms.");v=d(w.type,g)}return{kind:"object",properties:Object.fromEntries(m.filter(S=>S!==w||!v).map(S=>{if(!o.isPropertySignature(S)||!S.type||!S.name||!o.isIdentifier(S.name)&&!o.isStringLiteral(S.name))throw new Error("Only explicitly typed named properties are supported.");const E=d(S.type,g),I=n.allowJson?o.getJSDocTags(S).filter(A=>A.tagName.text==="port"):[];if(I.length>1)throw new Error(`Duplicate port declaration: ${S.name.text}`);if(I.length){const[A,M,j]=String(I[0].comment??"").trim().split(/\s+/);if(A!=="config"||!M||j||!c.has(M))throw new Error(`Config port ${S.name.text} requires @port config ResourceType`);const R=E.kind==="array";if((E.kind==="array"?E.items.kind:E.kind)!=="string")throw new Error(`Config port ${S.name.text} must be a string or string array reference`);b[S.name.text]={kind:"config",resourceType:M,multiple:R}}return[S.name.text,{type:E,optional:!!S.questionToken}]})),...v?{additionalProperties:v}:{},...Object.keys(b).length?{ports:b}:{}}},l=(m,g)=>{var C;if(g.includes(m))throw new Error("Recursive types are not supported.");const b=c.get(m);if(!b)throw new Error(`Unknown type: ${m}`);let w;if(o.isInterfaceDeclaration(b)){if((C=b.heritageClauses)!=null&&C.length)throw new Error("Interface inheritance is not supported; declare properties explicitly.");w=u(b.members,[...g,m])}else w=d(b.type,[...g,m]);const v=n.allowJson?o.getJSDocTags(b).filter(S=>S.tagName.text==="port"):[];if(!v.length)return w;if(w.kind!=="object")throw new Error("Node ports require an object interface");const x={...w.ports};for(const S of v){const[E,I,...A]=String(S.comment??"").trim().split(/\s+/);if(!["input","output","error"].includes(E)||!/^[A-Za-z][\w-]*$/.test(I??""))throw new Error("Node ports require @port input|output|error Name");const M=A.length?JSON.parse(A.join(" ")):void 0;if(M!==void 0&&typeof M!="string")throw new Error("Node port labels must be JSON strings");if(Object.prototype.hasOwnProperty.call(x,I))throw new Error(`Duplicate port declaration: ${I}`);x[I]={kind:E,...typeof M=="string"?{label:M}:{}}}return{...w,ports:x}},d=(m,g)=>{var b,w,v;if(--i<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(m.kind===o.SyntaxKind.StringKeyword)return{kind:"string"};if(m.kind===o.SyntaxKind.NumberKeyword)return{kind:"number"};if(m.kind===o.SyntaxKind.BooleanKeyword)return{kind:"boolean"};if(n.allowJson&&[o.SyntaxKind.AnyKeyword,o.SyntaxKind.UnknownKeyword].includes(m.kind))return{kind:"json"};if(o.isParenthesizedTypeNode(m))return d(m.type,g);if(o.isUnionTypeNode(m))return{kind:"union",types:m.types.map(x=>d(x,g))};if(o.isArrayTypeNode(m))return{kind:"array",items:d(m.elementType,g)};if(o.isTypeLiteralNode(m))return u(m.members,g);if(o.isLiteralTypeNode(m)){const x=m.literal;if(o.isStringLiteral(x))return{kind:"literal",value:x.text};if(o.isNumericLiteral(x))return{kind:"literal",value:Number(x.text)};if(x.kind===o.SyntaxKind.NullKeyword)return{kind:"null"};if(x.kind===o.SyntaxKind.TrueKeyword||x.kind===o.SyntaxKind.FalseKeyword)return{kind:"literal",value:x.kind===o.SyntaxKind.TrueKeyword}}if(o.isTypeReferenceNode(m)&&o.isIdentifier(m.typeName)){if(n.allowJson&&m.typeName.text==="Record"&&!c.has("Record")&&((b=m.typeArguments)==null?void 0:b.length)===2&&m.typeArguments[0].kind===o.SyntaxKind.StringKeyword)return{kind:"object",properties:{},additionalProperties:d(m.typeArguments[1],g)};if(m.typeName.text==="Array"&&((w=m.typeArguments)==null?void 0:w.length)===1)return{kind:"array",items:d(m.typeArguments[0],g)};if(!((v=m.typeArguments)!=null&&v.length))return l(m.typeName.text,g)}throw new Error(`Unsupported TypeScript type: ${m.getText(s)}`)},h=r??(c.has("Graph")?"Graph":c.size===1?[...c.keys()][0]:void 0);if(!h)throw new Error("Declare an interface Graph keyed by node ID.");const p=l(h,[]);if(p.kind!=="object")throw new Error("Graph must be an object keyed by node ID.");return p}async function Sm(e,t){const r=await Yu(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 zt(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=>zt(r,t));if(t.kind==="union")return t.types.some(r=>zt(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"?zt(e.items,t.items):e.kind==="object"&&t.kind==="object"?Object.entries(t.properties).every(([r,n])=>{const i=Object.prototype.hasOwnProperty.call(e.properties,r)?e.properties[r]:void 0;return i?(n.optional||!i.optional)&&zt(i.type,n.type):n.optional}):e.kind===t.kind}function Xu(e,t){if(!t.sourceProperty&&!t.targetProperty)return;const r=(s,a)=>{var l;const c=Object.prototype.hasOwnProperty.call(e.nodes,s)?s:s.replace(/^root\./,""),u=Object.prototype.hasOwnProperty.call(e.nodes,c)?(l=e.nodes[c])==null?void 0:l.type:void 0;return a&&(u==null?void 0:u.kind)==="object"&&Object.prototype.hasOwnProperty.call(u.properties,a)?u.properties[a]:void 0},n=r(t.source,t.sourceProperty),i=r(t.target,t.targetProperty);if(!n||!i)return"Unverified: source or target property is missing from the interface.";const o=s=>s.kind==="json"||s.kind==="object"&&(!!s.additionalProperties||Object.values(s.properties).some(a=>o(a.type)))||s.kind==="array"&&o(s.items)||s.kind==="union"&&s.types.some(o);if(o(n.type)||o(i.type))return"Unverified: arbitrary JSON or dictionary fields require runtime validation.";if(n.optional&&!i.optional)return"Optional source cannot supply a required target property.";if(!zt(n.type,i.type))return`Incompatible property types: ${t.sourceProperty} -> ${t.targetProperty}.`}async function _m(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 Zu(t,e.name);if(/\.ts$/i.test(e.name))return Sm(t,e.name);throw new Error("Choose a .ts interface or .json JSON Schema file.")}const Wl=new WeakMap;function jt(e){if(!e||typeof e!="object")return e;const t=Wl.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:(i,o)=>jt(Reflect.get(e,o)),has:(i,o)=>Reflect.has(e,o),ownKeys:()=>Reflect.ownKeys(e),getOwnPropertyDescriptor:(i,o)=>{const s=Reflect.getOwnPropertyDescriptor(e,o);return s&&{...s,value:jt(Reflect.get(e,o)),configurable:o!=="length"||!Array.isArray(e)}},set:r,deleteProperty:r,defineProperty:r,setPrototypeOf:r,preventExtensions:r});return Wl.set(e,n),n}function Tt(e,t,r){var i;const n=t.split(".");for(let o=n.length;o>0;o--){const s=n.slice(0,o).join("."),a=(i=Re(e,s))==null?void 0:i.$form;if(!(a!=null&&a.$type))continue;let c=Object.prototype.hasOwnProperty.call(r,a.$type)?r[a.$type]:void 0;for(const d of n.slice(o))(c==null?void 0:c.kind)==="array"&&/^\d+$/.test(d)?c=c.items:(c==null?void 0:c.kind)==="object"?c=Object.prototype.hasOwnProperty.call(c.properties,d)?c.properties[d].type:void 0:c=void 0;if((c==null?void 0:c.kind)!=="object")return;const u=n.slice(o).join("."),l=Object.fromEntries(Object.entries(a.$fields??{}).filter(([d])=>!u||d.startsWith(`${u}.`)).map(([d,h])=>[u?d.slice(u.length+1):d,h]));return{type:c,fields:l,binding:a}}}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 i=[],o=new Set(t);for(const s of o){if(o.size>32)throw new Error("Choose between 1 and 32 form interface names.");const a=await Yu(r,e.name,s,{allowJson:!0});i.push([s,a]);for(const c of Object.values(a.ports??{}))c.resourceType&&o.add(c.resourceType)}return Object.fromEntries(i)}if(!e.name.endsWith(".json"))throw new Error("Choose a .ts interface or .json schema file.");const n=Zu(r,e.name);return Object.fromEntries(Object.entries(n.nodes).map(([i,o])=>[i,o.type]))}function Ln(e,t){return!e||("$in"in e?e.$in.includes(Re(t,e.$address)):Re(t,e.$address)===e.$equals)}function Xt(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,i=o=>{if(o===null||typeof o=="string"||typeof o=="boolean")return!0;if(typeof o=="number")return Number.isFinite(o);if(!o||typeof o!="object"||n.has(o)||!Array.isArray(o)&&![Object.prototype,null].includes(Object.getPrototypeOf(o)))return!1;n.add(o);const s=Object.values(o).every(i);return n.delete(o),s};return i(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,i])=>!Object.prototype.hasOwnProperty.call(e.properties,n)&&Rr(e.additionalProperties,i,!0))?"Invalid dictionary value":Object.entries(e.properties).some(([n,i])=>Rr(i.type,t[n],!i.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 Gl(e,t){const r=t.address.split(".");if(r.shift()!=="root"||!r.length||r.some(a=>!a||["__proto__","prototype","constructor","#"].includes(a)))throw new Error("Invalid form field address.");const n=r.pop(),i=n==="$bgColor"||n==="$textColor"||n==="$borderColor";if(r.some(a=>a.startsWith("$"))||n.startsWith("$")&&!i)throw new Error("Unsupported form metadata address.");const o=["root",...r].join("."),s=Re(e,o);if(!s||typeof s!="object")throw new Error(`Missing form parent: ${o}`);if(i){if(t.op==="set"&&typeof t.value!="string")throw new Error("Node colors must be strings.");return hr(e,o,n,t.op==="remove"?void 0:t.value)}return vr(e,o,a=>{const c=Array.isArray(a.$)?a.$:a;if(t.op==="remove"&&!Object.prototype.hasOwnProperty.call(c,n)||t.op==="set"&&Object.is(c[n],t.value))return a;const u=Array.isArray(c)?[...c]:{...c};if(Array.isArray(u)&&(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=u.length))throw new Error("Invalid array address.");return t.op==="remove"?Array.isArray(u)?u.splice(Number(n),1):delete u[n]:Object.defineProperty(u,n,{value:structuredClone(t.value),enumerable:!0,writable:!0,configurable:!0}),c===a?u:{...a,$:u}})}function Fn(e,t,r){let n=Gl(e,t.value===void 0?{op:"remove",address:t.address}:{op:"set",address:t.address,value:t.value});const i=r==null?void 0:r({...t,previousValue:jt(Re(e,t.address)),data:jt(n)});if(i&&!Array.isArray(i))throw new Error("Form change handlers must return edits synchronously.");for(const o of Array.isArray(i)?i:[]){if(o.op!=="set"&&o.op!=="remove")throw new Error("Unsupported form edit.");n=Gl(n,o)}return n}const Qt="data:image/svg+xml;base64,";function Vr(e){if(e.startsWith(Qt))return!0;try{const t=new URL(e);return(t.protocol==="https:"||t.protocol==="http:")&&!t.username&&!t.password}catch{return!1}}async function E0(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(o=>[...o.attributes].some(s=>/^on/i.test(s.name))))throw new Error("SVG scripts and event handlers are not allowed.");const n=new TextEncoder().encode(t);let i="";for(const o of n)i+=String.fromCharCode(o);return Qt+btoa(i)}const Or=({name:e,svg:t=!1,...r})=>{const[n,i]=_.useState(null),[o,s]=_.useState(!0),[a,c]=_.useState(!1),u=typeof e=="string"&&Vr(e);if(_.useEffect(()=>{if(u||!e||e.length<2){i(null),s(!1);return}s(!0),c(!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 h;switch(d){case"md":h=await import("react-icons/md");break;case"fa6":h=await import("react-icons/fa6");break;case"io5":h=await import("react-icons/io5");break;case"io":h=await import("react-icons/io");break;case"ti":h=await import("react-icons/ti");break;case"go":h=await import("react-icons/go");break;case"fi":h=await import("react-icons/fi");break;case"di":h=await import("react-icons/di");break;case"ai":h=await import("react-icons/ai");break;case"bs":h=await import("react-icons/bs");break;case"ri":h=await import("react-icons/ri");break;case"fc":h=await import("react-icons/fc");break;case"gi":h=await import("react-icons/gi");break;case"hi2":h=await import("react-icons/hi2");break;case"hi":h=await import("react-icons/hi");break;case"si":h=await import("react-icons/si");break;case"sl":h=await import("react-icons/sl");break;case"im":h=await import("react-icons/im");break;case"bi":h=await import("react-icons/bi");break;case"pi":h=await import("react-icons/pi");break;case"vsc":h=await import("react-icons/vsc");break;case"tb":h=await import("react-icons/tb");break;case"tfi":h=await import("react-icons/tfi");break;case"cg":h=await import("react-icons/cg");break;case"lia":h=await import("react-icons/lia");break;case"lu":h=await import("react-icons/lu");break;default:throw new Error(`Unsupported library: ${d}`)}const p=h[e];if(!p)throw new Error(`Icon ${e} not found in library ${d}`);i(()=>p)}catch(d){console.warn(`Failed to load icon ${e}:`,d.message),c(!0),i(null)}finally{s(!1)}})()},[e,u]),u){const{size:l=80,style:d,...h}=r;return t?f.jsx("image",{...h,href:e,width:l,height:l,preserveAspectRatio:"xMidYMid meet",style:d}):f.jsx("img",{...h,src:e,alt:"",width:l,height:l,referrerPolicy:"no-referrer",style:{objectFit:"contain",...d}})}return o||!n?null:f.jsx(n,{...r})};function j0(e,t){let r=e;for(const n of t){if(n.op!=="set"&&n.op!=="remove")throw new Error("Unsupported state edit.");const i=n.address.split(".");if(i.some(s=>s.startsWith("$")||["__proto__","prototype","constructor"].includes(s)))throw new Error("State edits cannot target view metadata or unsafe keys.");const o=n.op==="remove"?void 0:n.value;an(o),r=Fn(r,{address:n.address,nodeAddress:i.slice(0,-1).join("."),value:o})}return an(r),r}function dn(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 an(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}`);an(r)}}function k0(e,t,r){an(t.value);const n=Fn(e,t,r);return an(n),n}function Em(e,t){const r=(n,i="")=>{if(!n||typeof n!="object")return n;if(["$label","$subtitle","$content","$icon","$bgColor","$textColor","$borderColor"].includes(i)&&typeof n.$state=="string"){const s=Re(t,n.$state);return s==null?"":typeof s=="object"?JSON.stringify(s,null,2):String(s)}let o=n;for(const[s,a]of Object.entries(n)){const c=r(a,s);c!==a&&(o===n&&(o=Array.isArray(n)?[...n]:{...n}),Object.defineProperty(o,s,{value:c,enumerable:!0,writable:!0,configurable:!0}))}return o};return r(e)}const R0=e=>!!e&&!e.includes(".")&&!e.startsWith("$")&&!["__proto__","constructor","prototype"].includes(e),P0=e=>`root.__form_${encodeURIComponent(e).replace(/\./g,"%2E")}`,Dt=(e,t)=>JSON.stringify([e,t]);function sn(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 sn(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 Vt(e){const t=sn(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 Ul(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"&&!Xt(e)?e.types:[e]}function A0(e,t,r){if(t.address===r.address)return;const n=Re(e,t.address),i=(o,s)=>s===void 0?!1:o.kind==="union"?o.types.some(a=>i(a,s)):o.kind==="array"?Array.isArray(s)&&s.every(a=>i(o.items,a)):o.kind==="object"?!!s&&typeof s=="object"&&!Array.isArray(s)&&Object.entries(o.properties).every(([a,c])=>c.optional&&s[a]===void 0||i(c.type,s[a]))&&Object.entries(s).every(([a,c])=>Object.prototype.hasOwnProperty.call(o.properties,a)||!o.additionalProperties||i(o.additionalProperties,c)):s===""?o.kind==="string"||o.kind==="json"||o.kind==="literal"&&o.value==="":!Rr(o,s,!0);if(i(r.type,n))return structuredClone(n)}function jm(e,t,r,n){var c,u;const i={sourceSchema:r,sourceBindings:t,nodes:[],edges:[],schema:{...r},bindings:{...t},slots:new Map,containers:new Map},o=new Set(n.map(l=>l.data.id)),s=new Map(n.flatMap(l=>{const d=t[l.data.id];return d&&r[d.type]?[[d.address,l.data.id]]:[]})),a=(l,d,h,p,y,m=!1)=>{var E,I,A,M,j;if(y>24||i.containers.size>512)throw new Error("Structured form exceeds the flow node limit.");const g=Re(e,d),b=sn(h,g),w=b.kind!=="object"&&b.kind!=="array";i.containers.set(l,{address:d,type:b,declared:h,scalar:w});const v=`__form:${l}`,x={...(E=i.bindings[l])==null?void 0:E.fields},C={kind:"object",properties:{},ports:{...b.kind==="object"?b.ports:{},...m?{resource:{label:"output",...b.kind==="object"?(I=b.ports)==null?void 0:I.resource:{},kind:"output"}}:{}}},S=b.kind==="object"?{...b.properties,...Object.fromEntries(Object.keys(g??{}).filter(R=>!Object.prototype.hasOwnProperty.call(b.properties,R)&&b.additionalProperties).map(R=>[R,{type:b.additionalProperties,optional:!0}]))}:b.kind==="array"?Object.fromEntries((Array.isArray(g)?g:[]).map((R,P)=>[String(P),{type:b.items,optional:!0}])):{value:{type:Xt(h)?h:b,optional:!1}};for(const[R,P]of Object.entries(S)){if(!R0(R))throw new Error(`Unsupported structured property key: ${R}`);const k=w?d:`${d}.${R}`,q=Re(e,k),O=sn(P.type,q),z=O.kind==="object"||O.kind==="array",U=(A=C.ports)==null?void 0:A[R],se=(U==null?void 0:U.kind)==="config"&&(((M=x[R])==null?void 0:M.$options)||Xt(P.type)),Q=P.type.kind==="json"||P.type.kind==="union"&&!Xt(P.type);if(((j=x[R])==null?void 0:j.$control)==="upload"||!z&&b.kind!=="array"&&(!Q||w)||se){C.properties[R]={...P,type:P.type.kind==="json"?O:P.type};continue}const Y=s.get(k)??P0(k),ge=b.kind==="array"?`Item ${Number(R)+1}`:R,ce={address:k,owner:l,field:R,type:P.type,label:ge,nodeId:Y,present:q!==void 0};if(i.slots.set(Dt(l,R),ce),C.ports[R]={kind:"config",resourceType:`__form:${Y}`},q===void 0||(i.edges.push({data:{id:`__form-edge:${l}:${R}`,source:Y,target:l,sourceProperty:"output:resource",targetProperty:`config:${R}`,isEdgeDashed:!0}}),i.containers.has(Y)||s.has(k)))continue;if(o.has(Y))throw new Error(`Structured node identity conflict: ${Y}`);o.add(Y);const $={data:{id:Y,type:"objectView",label:ge,headerTitle:ge,description:{},config:{form:!0,icon:O.kind==="array"?"PiListNumbers":z?"PiBracketsCurly":"PiTextT"},viewProps:{bgColor:p}}};i.nodes.push($),a(Y,k,P.type,p,y+1,!0);const V=i.schema[`__form:${Y}`];$.data.description=Object.fromEntries(Object.keys(V.properties).map(W=>[W,Re(e,O.kind==="array"||O.kind==="object"?`${k}.${W}`:k)]).filter(([,W])=>W!==void 0))}i.schema[v]=C,i.bindings[l]={...i.bindings[l],address:d,type:v,fields:x}};for(const l of n){const d=t[l.data.id];if(d!=null&&d.portResources)continue;const h=d&&r[d.type];!d||!h||Re(e,d.address)===void 0||a(l.data.id,d.address,h,(c=l.data.viewProps)==null?void 0:c.bgColor,0,i.edges.some(p=>p.data.source===l.data.id))}for(const l of i.edges){const d=i.bindings[l.data.source],h=i.schema[d.type].ports;h.resource={...h.resource,kind:"output",label:((u=h.resource)==null?void 0:u.label)??"output"}}return i}const at=(e="reference")=>({kind:e,text:"",paths:[""]}),km=e=>/^[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*|\.\d+)+$/.test(e)&&!e.split(".").some(t=>["__proto__","constructor","prototype"].includes(t));function T0(e,t){const r=new Set(t.map(s=>s.path)),n=s=>{if(!s.paths.length||s.paths.some(a=>!km(a)||!r.has(a)))throw new Error("Choose an available reference.");return[...s.paths,...s.fallback===void 0?[]:[JSON.stringify(s.fallback)]].join(" || ")},i=s=>{if(s.includes("{{")||s.includes("}}"))throw new Error("Use a reference part for dynamic values.");return s},o=s=>s.map(a=>{if(a.kind==="text")return i(a.text);if(a.kind==="conditional"){if(a.paths.length!==1||a.fallback!==void 0)throw new Error("Choose one condition reference.");return`{{#if ${n(a)}}}${i(a.text)}{{/if}}`}return`{{${n(a)}}}`}).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 s=o(e.parts);return e.mode==="condition"?`${s} == ${JSON.stringify(e.comparison)}`:s}if(e.mode==="json"){const s=e.fields.map(a=>a.key);if(!s.length||new Set(s).size!==s.length||s.some(a=>!a||["__proto__","constructor","prototype"].includes(a)))throw new Error("Output field names must be unique and nonempty.");return JSON.stringify(Object.fromEntries(e.fields.map(a=>[a.key,o(a.parts)])))}return o(e.parts)}async function I0(e){const t=await import("typescript"),r=s=>{const a=t.createSourceFile("binding.ts",`(${s})`,t.ScriptTarget.Latest,!0,t.ScriptKind.TS);if(a.parseDiagnostics.length)throw new Error("Unsupported reference expression.");const c=a.statements[0];if(!c||!t.isExpressionStatement(c))throw new Error("Unsupported reference expression.");const u=at();u.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(u.fallback!==void 0)throw new Error("Multiple fallback values.");u.fallback=d.text;return}const h=d.getText(a);if(!km(h)||u.fallback!==void 0)throw new Error("Unsupported reference expression.");u.paths.push(h)};if(l(c.expression),!u.paths.length)throw new Error("A binding needs a reference.");return u},n=s=>{const a=[];let c=0;const u=/\{\{([\s\S]*?)\}\}/g;for(const l of s.matchAll(u)){const d=l.index;if(d<c)continue;d>c&&a.push({...at("text"),text:s.slice(c,d)});const h=l[1].trim();if(h.startsWith("#if ")){const p=s.indexOf("{{/if}}",d+l[0].length);if(p<0)throw new Error("Unclosed condition.");a.push({...r(h.slice(4)),kind:"conditional",text:s.slice(d+l[0].length,p)}),c=p+7}else a.push(r(h)),c=d+l[0].length}return c<s.length&&a.push({...at("text"),text:s.slice(c)}),a},i={mode:"reference",parts:[at()],comparison:"",fields:[]};if(!e)return i;if(e.trim().startsWith("{"))try{const s=JSON.parse(e);if(s&&typeof s=="object"&&!Array.isArray(s)&&Object.values(s).every(a=>typeof a=="string"))return{...i,mode:"json",fields:Object.entries(s).map(([a,c])=>({key:a,parts:n(c)}))}}catch{}const o=n(e);if(o.length===2&&o[0].kind==="reference"&&o[1].kind==="text"){const s=t.createSourceFile("condition.ts",`value ${o[1].text}`,t.ScriptTarget.Latest,!0,t.ScriptKind.TS),a=s.statements[0];if(s.statements.length===1&&t.isExpressionStatement(a)&&t.isBinaryExpression(a.expression)&&a.expression.operatorToken.kind===t.SyntaxKind.EqualsEqualsToken&&t.isStringLiteral(a.expression.right))return{...i,mode:"condition",parts:[o[0]],comparison:a.expression.right.text}}return{...i,mode:o.length===1&&o[0].kind==="reference"?"reference":"template",parts:o}}function Hl({parts:e,references:t,onChange:r,disabled:n}){const i=(o,s)=>r(e.map((a,c)=>c===o?{...a,...s}:a));return f.jsxs("div",{style:{display:"grid",gap:12},children:[e.map((o,s)=>f.jsxs("fieldset",{"data-binding-part":s,style:{border:0,padding:0,margin:0,minWidth:0},children:[f.jsxs("legend",{children:["Part ",s+1]}),f.jsxs("div",{style:{display:"flex",gap:8},children:[f.jsxs("span",{"data-form-select":"",style:{flex:1},children:[f.jsxs("select",{"aria-label":"Part type",disabled:n,value:o.kind,onChange:a=>i(s,{kind:a.target.value}),children:[f.jsx("option",{value:"reference",children:"Reference"}),f.jsx("option",{value:"text",children:"Text"}),f.jsx("option",{value:"conditional",children:"Conditional text"})]}),f.jsx(K.PiCaretDown,{size:16,"aria-hidden":"true"})]}),f.jsx(Se,{"aria-label":`Remove part ${s+1}`,title:"Remove part",icon:f.jsx(K.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>r(e.filter((a,c)=>c!==s))})]}),o.kind!=="text"&&f.jsxs(f.Fragment,{children:[o.paths.map((a,c)=>f.jsxs("label",{children:["Reference ",c+1,f.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[f.jsxs("select",{"aria-label":`Reference ${c+1}`,disabled:n,value:a,onChange:u=>i(s,{paths:o.paths.map((l,d)=>d===c?u.target.value:l)}),children:[f.jsx("option",{value:"",children:"Select reference"}),t.map(u=>f.jsx("option",{value:u.path,children:u.label},u.path))]}),f.jsx(K.PiCaretDown,{size:16,"aria-hidden":"true"})]})]},c)),o.kind==="reference"&&f.jsxs(f.Fragment,{children:[f.jsx(Se,{"aria-label":"Add fallback reference",title:"Add fallback reference",icon:f.jsx(K.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>i(s,{paths:[...o.paths,""]})}),f.jsxs("label",{style:{display:"flex",gap:8,alignItems:"center"},children:[f.jsx("input",{type:"checkbox","aria-label":"Default value enabled",disabled:n,checked:o.fallback!==void 0,onChange:a=>i(s,{fallback:a.target.checked?"":void 0})}),"Default value"]}),o.fallback!==void 0&&f.jsx("input",{"aria-label":"Default value",disabled:n,value:o.fallback,onChange:a=>i(s,{fallback:a.target.value})})]})]}),o.kind!=="reference"&&f.jsxs("label",{children:["Text",f.jsx("textarea",{"aria-label":"Part text",disabled:n,value:o.text,onChange:a=>i(s,{text:a.target.value})})]})]},s)),f.jsx(Se,{"aria-label":"Add part",title:"Add part",icon:f.jsx(K.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>r([...e,at()])})]})}function O0({label:e,value:t,references:r,disabled:n,onChange:i}){const[o,s]=_.useState(),[a,c]=_.useState(""),[u,l]=_.useState(!1),d=async()=>{l(!0),c("");try{s(await I0(typeof t=="string"?t:""))}catch(h){c(h instanceof Error?h.message:"Unable to read binding.")}finally{l(!1)}};return f.jsxs("div",{"data-runtime-binding":e,style:{marginBottom:8},children:[f.jsx(Se,{"aria-label":`Bind ${e}`,title:`Bind ${e}`,icon:f.jsx(K.PiLink,{size:18}),size:"sm",variant:"ghost",disabled:n||u,onClick:d}),typeof t=="string"&&t.includes("{{")&&f.jsx("span",{children:"Bound value"}),o&&f.jsxs("fieldset",{disabled:n,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[f.jsxs("label",{children:["Binding mode",f.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[f.jsxs("select",{"aria-label":"Binding mode",value:o.mode,onChange:h=>s({...o,mode:h.target.value,parts:[at()]}),children:[f.jsx("option",{value:"reference",children:"Reference"}),f.jsx("option",{value:"condition",children:"Equals"}),f.jsx("option",{value:"template",children:"Text template"}),f.jsx("option",{value:"json",children:"JSON output"})]}),f.jsx(K.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),o.mode==="json"?f.jsxs(f.Fragment,{children:[o.fields.map((h,p)=>f.jsxs("fieldset",{"data-output-field":p,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[f.jsxs("label",{children:["Output field name",f.jsx("input",{"aria-label":"Output field name",value:h.key,onChange:y=>s({...o,fields:o.fields.map((m,g)=>g===p?{...m,key:y.target.value}:m)})})]}),f.jsx(Hl,{parts:h.parts,references:r,disabled:n,onChange:y=>s({...o,fields:o.fields.map((m,g)=>g===p?{...m,parts:y}:m)})}),f.jsx(Se,{"aria-label":"Remove output field",title:"Remove output field",icon:f.jsx(K.PiTrash,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...o,fields:o.fields.filter((y,m)=>m!==p)})})]},p)),f.jsx(Se,{"aria-label":"Add output field",title:"Add output field",icon:f.jsx(K.PiPlus,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...o,fields:[...o.fields,{key:"",parts:[at()]}]})})]}):f.jsx(Hl,{parts:o.parts,references:r,disabled:n,onChange:h=>s({...o,parts:h})}),o.mode==="condition"&&f.jsxs("label",{children:["Equals",f.jsx("input",{"aria-label":"Comparison value",value:o.comparison,onChange:h=>s({...o,comparison:h.target.value})})]}),f.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[f.jsx(Se,{"aria-label":"Apply binding",title:"Apply binding",icon:f.jsx(K.PiCheck,{size:20}),size:"sm",variant:"ghost",onClick:()=>{try{i(T0(o,r)),s(void 0),c("")}catch(h){c(h instanceof Error?h.message:"Unable to apply binding.")}}}),f.jsx(Se,{"aria-label":"Cancel binding",title:"Cancel binding",icon:f.jsx(K.PiX,{size:20}),size:"sm",variant:"ghost",onClick:()=>{s(void 0),c("")}})]})]}),a&&f.jsx("p",{role:"alert",children:a})]})}function M0({nodeAddress:e,onOpen:t}){const{structured:r,data:n,callbacks:i,editable:o,onFieldCreate:s}=_.useContext(Cr),a=Ne(),[c,u]=_.useState(""),[l,d]=_.useState("0"),[h,p]=_.useState(""),y=r==null?void 0:r.containers.get(e);if(!y||!n||!r)return null;const m=a.readOnly||a.config.editable===!1||!o,g=Re(n,y.address),b=Ul(y.declared),w=y.type.kind==="array"?y.type.items:y.type.kind==="object"?y.type.additionalProperties:void 0,v=w?Ul(w):[],x=!!s&&y.type.kind==="object"&&(w==null?void 0:w.kind)==="json",C=P=>P.kind==="literal"?String(P.value):P.kind==="string"?"Text":wr(P.kind),S=[...r.slots.values()].filter(P=>P.owner===e),E=(P,k)=>{var q;return(q=i.onFormChange)==null?void 0:q.call(i,{data:n,nodeAddress:y.address,address:P,previousValue:Re(n,P),value:k})},I=P=>{var k;a.setSelectedNodeIds([P]),(k=a.engineRef.current)==null||k.focusNode(P,90,!1)},A=(P,k)=>{if(!Array.isArray(g))return;const q=[...g];[q[P],q[P+k]]=[q[P+k],q[P]],E(y.address,q)},M=()=>{const P=v[Number(l)]??v[0];if(P)if(y.type.kind==="array")E(y.address,[...Array.isArray(g)?g:[],Vt(P)]);else{if(!c||c.includes(".")||c.startsWith("$")||["__proto__","constructor","prototype"].includes(c)){p("Choose a property name without dots or reserved prefixes.");return}if(Object.prototype.hasOwnProperty.call(g,c)){p("Property already exists.");return}x&&(l==="file"||l==="files")?s==null||s({data:n,nodeAddress:y.address,address:`${y.address}.${c}`,previousValue:void 0,value:l==="files"?[]:""},{$control:"upload"}):E(`${y.address}.${c}`,Vt(P)),u(""),p("")}},j=y.type.kind==="object"&&!!y.type.additionalProperties,R=y.type.kind==="array";return f.jsxs("div",{"data-structured-controls":"",style:{display:"grid",gap:8,minWidth:0},children:[b.length>1&&f.jsxs("label",{children:["Value type",f.jsx("span",{"data-form-select":"",style:{display:"block"},children:f.jsx(mr,{"aria-label":"Value type",disabled:m,value:String(b.findIndex(P=>sn(P,g).kind===y.type.kind)),onValueChange:P=>E(y.address,Vt(b[Number(P)])),children:b.map((P,k)=>f.jsx("option",{value:k,children:C(P)},k))})})]}),S.map((P,k)=>f.jsxs("div",{"data-structured-slot":P.address,style:{display:"flex",gap:6,alignItems:"center",minWidth:0},children:[P.type.kind==="array"?f.jsx(K.PiListNumbers,{size:20}):f.jsx(K.PiBracketsCurly,{size:20}),f.jsx("span",{style:{flex:1,overflowWrap:"anywhere"},children:wr(P.label)}),f.jsx(Se,{"aria-label":`${P.present?t?"Edit":"Focus":"Create"} ${wr(P.label)}`,title:`${P.present?t?"Edit":"Focus":"Create"} ${wr(P.label)}`,icon:P.present?f.jsx(K.PiMagnifyingGlass,{size:18}):f.jsx(K.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:m&&!P.present,onClick:q=>{var O;P.present?t?t(P.nodeId):((O=q.currentTarget.closest("dialog"))==null||O.close(),I(P.nodeId)):E(P.address,Vt(P.type))}}),R&&f.jsxs(f.Fragment,{children:[f.jsx(Se,{"aria-label":`Move item ${k+1} up`,icon:f.jsx(K.PiArrowUp,{size:18}),size:"sm",variant:"ghost",disabled:m||k===0,onClick:()=>A(k,-1)}),f.jsx(Se,{"aria-label":`Move item ${k+1} down`,icon:f.jsx(K.PiArrowDown,{size:18}),size:"sm",variant:"ghost",disabled:m||k===S.length-1,onClick:()=>A(k,1)})]}),P.present&&f.jsx(Se,{"aria-label":`Remove ${wr(P.label)}`,icon:f.jsx(K.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:m,onClick:()=>R?E(y.address,g.filter((q,O)=>O!==k)):E(P.address,void 0)})]},P.address)),(R||j)&&f.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"end"},children:[j&&f.jsxs("label",{style:{flex:"1 1 120px",minWidth:0,display:"grid",gap:8},children:["Property name",f.jsx("input",{"aria-label":"Property name",placeholder:"Required",value:c,disabled:m,onChange:P=>u(P.target.value)})]}),v.length>1&&f.jsxs("label",{style:{flex:"1 1 100px",minWidth:0,display:"grid",gap:8},children:["New value type",f.jsx("span",{"data-form-select":"",style:{display:"block"},children:f.jsxs(mr,{"aria-label":"New value type",value:l,disabled:m,onValueChange:d,children:[v.map((P,k)=>f.jsx("option",{value:k,children:C(P)},k)),x&&f.jsx("option",{value:"file",children:"File"}),x&&f.jsx("option",{value:"files",children:"Files"})]})})]}),f.jsx("span",{style:{display:"flex",alignItems:"center",flexShrink:0,...j||v.length>1?{height:"calc(1.4em + 20px)",fontSize:15,marginBottom:6}:{}},children:f.jsx(Se,{"aria-label":R?"Add item":"Add property",icon:f.jsx(K.PiPlus,{size:20}),size:"sm",variant:"ghost",disabled:m,onClick:M})})]}),h&&f.jsx("p",{role:"alert",children:h})]})}const Cr=_.createContext({callbacks:{}}),wn=On.default.div`
|
|
58
|
+
`,hm=_.forwardRef(function({style:t,...r},n){return f.jsx(g0,{...r,ref:n,style:{...t,backgroundImage:"none","--flow-range-track":(t==null?void 0:t.backgroundImage)??"none"}})});function Fl({label:e,inputLabel:t,value:r,displayValue:n,min:i,max:o,onChange:s}){const a=_.useId(),{readOnly:c,themeColor:u}=Le(),{colorInactive:l}=Ze(),d=(r-i)/(o-i)*100,h=u.includes(".")?`var(--chakra-colors-${u.replace(".","-")})`:u;return f.jsxs("div",{style:{width:224,maxWidth:"calc(100vw - 64px)",padding:12},children:[f.jsxs("label",{htmlFor:a,style:{display:"flex",justifyContent:"space-between",fontSize:14,marginBottom:12},children:[e," ",f.jsx("span",{children:n})]}),f.jsx(hm,{id:a,"aria-label":t,type:"range",min:i,max:o,step:5,value:r,disabled:c,style:{color:h,accentColor:h,backgroundImage:`linear-gradient(to right, currentColor ${d}%, var(--chakra-colors-${l.replace(".","-")}) ${d}%)`},onChange:p=>s(Number(p.target.value))})]})}const Bl={dot:{label:"Dots",icon:K.PiDotsNine},grid:{label:"Grid",icon:K.PiGridFour},steel:{label:"Steel",icon:K.PiLineSegments},none:{label:"Solid",icon:K.PiSquareFill},transparent:{label:"Transparent",icon:K.PiSelection}};function pm(){const{spacing:e,setSpacing:t,edgeRadius:r,setEdgeRadius:n,backgroundVariant:i,setBackgroundVariant:o,callbacks:s,readOnly:a}=Le(),c=Bl[i].icon;return f.jsxs(f.Fragment,{children:[f.jsx(Ht,{}),f.jsx(br,{"aria-label":"Node spacing",title:`Spacing: ${Math.round(e*100)}%`,icon:f.jsx(K.PiArrowsOutCardinal,{size:20}),style:{width:36},value:"spacing",disabled:a,onValueChange:()=>{},popupContent:f.jsx(Fl,{label:"Spacing",inputLabel:"Node spacing percentage",min:50,max:200,value:Math.round(e*100),displayValue:`${Math.round(e*100)}%`,onChange:u=>{var l;t(u/100),(l=s.onSpacingChange)==null||l.call(s,u/100)}}),children:f.jsx("option",{value:"spacing",children:"Spacing"})}),f.jsx(Ht,{}),f.jsx(br,{"aria-label":"Edge radius",title:`Edge radius: ${r??"Default"}`,icon:f.jsx(K.PiBezierCurve,{size:20}),style:{width:36},value:"radius",disabled:a,onValueChange:()=>{},popupContent:f.jsx(Fl,{label:"Edge radius",inputLabel:"Edge corner radius",min:0,max:500,value:r??500,displayValue:r??"Default",onChange:u=>{var l;n(u),(l=s.onEdgeRadiusChange)==null||l.call(s,u)}}),children:f.jsx("option",{value:"radius",children:"Edge radius"})}),f.jsx(Ht,{}),f.jsxs(br,{"aria-label":"Background variant",title:`Background: ${Bl[i].label}`,icon:f.jsx(c,{size:20,"data-background-icon":i}),style:{width:36},value:i,disabled:a,onValueChange:u=>{var l;o(u),(l=s.onBackgroundVariantChange)==null||l.call(s,u)},children:[f.jsx("option",{value:"dot",children:"Dots"}),f.jsx("option",{value:"grid",children:"Grid"}),f.jsx("option",{value:"steel",children:"Steel"}),f.jsx("option",{value:"none",children:"Solid"}),f.jsx("option",{value:"transparent",children:"Transparent"})]})]})}const lr=[];for(let e=0;e<256;++e)lr.push((e+256).toString(16).slice(1));function y0(e,t=0){return(lr[e[t+0]]+lr[e[t+1]]+lr[e[t+2]]+lr[e[t+3]]+"-"+lr[e[t+4]]+lr[e[t+5]]+"-"+lr[e[t+6]]+lr[e[t+7]]+"-"+lr[e[t+8]]+lr[e[t+9]]+"-"+lr[e[t+10]]+lr[e[t+11]]+lr[e[t+12]]+lr[e[t+13]]+lr[e[t+14]]+lr[e[t+15]]).toLowerCase()}let yo;const m0=new Uint8Array(16);function b0(){if(!yo){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");yo=crypto.getRandomValues.bind(crypto)}return yo(m0)}const v0=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),zl={randomUUID:v0};function Hu(e,t,r){var i;if(zl.randomUUID&&!e)return zl.randomUUID();e=e||{};const n=e.random??((i=e.rng)==null?void 0:i.call(e))??b0();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,y0(n)}const $n={label:"Untitled",description:"",isTask:!1,isLocked:!1},Ku={id:null,type:"text",data:{...$n,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"}}},Dl={id:null,type:"objectView",data:{...$n,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:53,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},x0={id:null,type:"arrayView",data:{...$n,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"}}},Vl={id:null,type:"workflowStep",data:{...$n,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}},vr=e=>typeof e=="object",gm=e=>Array.isArray(e),w0=["order","position","selected","locked","grabbed","grabbable","scratch"],Jr=e=>Object.entries(e).reduce((t,[r,n])=>(!vr(n)&&!r.startsWith("$")&&(t[r]=n),t),{}),Ju=(e,t)=>typeof e=="string"&&e.startsWith("$")?mo(e,t):vr(e)&&!gm(e)?Object.entries(e).reduce((r,[n,i])=>(typeof i=="string"&&i.startsWith("$")&&n==="..."?(delete r["..."],r[n]={...mo(i,t),...e}):typeof i=="string"&&i.startsWith("$")?r[n]=mo(i,t):r[n]=i,r),{}):e,Zr=e=>Object.entries(e).reduce((t,[r,n])=>(vr(n)&&r&&n&&!r.startsWith("$")&&(w0.includes(r)&&(r=r+"#"),t[r]=n),t),{}),ot=(e,t,{label:r,parent:n=void 0},i,o=null)=>(o!==null&&(vr(o)||gm(o))&&(o=JSON.stringify(o,null,2)),{data:{parent:n,...e.data,id:t,text:r||"",label:r,code:o||null,type:e.type,description:i}}),Hr=(e,t,r=null,n=null,i=null,o=!1,s=null)=>({data:{id:Hu(),source:i?t:e,target:i?e:t,label:n||"",isInverted:i,isEdgeAnimated:o,parent:s}}),Yr=(e,t=[])=>{const r={},n={};let i=[];if(e)for(const[o,s]of Object.entries(e))o.startsWith("$")&&o!=="$"?r[o.slice(1)]=s:o!=="$"?n[o]=s:o==="$"&&(i=s);return{newConfig:r,updatedObject:n,arrayObject:i}},xt=(e,t)=>{let r=Dl;const{view:n,borderColor:i,borderRadius:o,bgColor:s,textColor:a,fontSize:c,stepType:u}=t;e=n||e,u?r={...Vl}:e==="object"?r=Dl:e==="text"?r=Ku:e==="array"?r=x0:e==="workflowStep"&&(r={...Vl});const l=r.data.viewProps;return r.data.viewProps={...l,borderRadius:o||(u?15:53),bgColor:s,borderColor:i,textColor:a,fontSize:c},r.data.config=t,{config:r}},on=(e,t)=>(e=t.find(n=>n.data.id===e)?`${e}.#`:e,e),mo=(e,{ids:t,jsnObjct:r})=>{if(typeof e=="string"&&(e!=null&&e.startsWith("$"))){const n=e.replace("$","").replace("*","");e==null||e.endsWith("*");const i=t.find(a=>a.split(".").slice(-1)[0]===n||n===a);if(!i)return e;const o=C0(i,r);return JSON.stringify(o).includes(e)?e:o||e}return e},C0=(e,t)=>{let r=e.split(".").splice(1);return r=r[r.length-1]==="#"||r[r.length-1].includes("{")?r.slice(0,-2):r,(o=>r.reduce((s,a)=>{a=a.replace("[","").replace("]","");const{arrayObject:c}=Yr(s);return s=c.length?c:s,s[a]},o))(t)};function Ct(e,t="root",r=[]){try{const{arrayObject:n}=Yr(e);n.length&&(e=n);const i=Jr(e),o=Zr(e);return vr(e)?(Be(e)||Be(e)&&t==="root"||!Be(e)&&Object.keys(i).length||t==="root")&&r.push(t):r.push(t),Object.keys(o).length&&!Be(e)?Kt({chldPth:null,itrblObjct:o,nodes:r,path:t}):Be(e)&&e.forEach((s,a)=>{const c=Jr(s),u=Zr(s),{newConfig:l,arrayObject:d}=Yr(s);let h=`${t}.${a}`;vr(s)?Object.keys(c).length?(Ct(c,h,r),Object.keys(u).length&&!Be(s)&&Kt({chldPth:h,itrblObjct:u,nodes:r,path:t})):Object.keys(u).length&&!Be(s)?Kt({chldPth:h,itrblObjct:u,nodes:r,path:t}):Be(s)&&ym({chldPth:h,item:s,nodes:r,path:t}):r.push(h)}),{nodes:r}}catch{return{nodes:r}}}const Kt=({chldPth:e,itrblObjct:t,nodes:r,path:n})=>Object.entries(t).forEach(([i,o],s)=>{const a=Jr(o),c=Zr(o),{newConfig:u,arrayObject:l}=Yr(o);l.length&&(o=l),n.split(".").slice(0,2).join(".");let d=e?`${e}.${i}`:`${n}.${i}`;if(vr(o)&&!Be(o)){const h=Object.keys(a).length===0;if(h&&(xt("array",u),r.push(d)),Object.keys(a).length){const p=Be(o)?`${o.length||""}`:`{${Object.keys(o).length||""}}`;let y=d;h&&(y=`${d}.${p}`),Ct(o,y,r)}else Object.keys(c).length&&!Be(o)?Kt({chldPth:d,itrblObjct:c,path:d,nodes:r}):Ct(o,d,r)}else Be(o)&&Ct(o,d,r)}),ym=({chldPth:e,item:t,nodes:r,path:n})=>t.forEach((i,o)=>{let s=`${e}.${o}`;const a=Zr(i),c=Jr(i);vr(i)?!Be(i)&&Object.keys(c).length?Ct(i,s,r):Object.keys(a).length&&!Be(i)?Kt({chldPth:s,itrblObjct:a,path:n,nodes:r}):Be(i)&&ym({chldPth:s,item:i,nodes:r,path:n}):r.push(s)}),Jt=[];let Zt;function st(e,t="root",r=[],n=[],i="untitled",o={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},s={}){if(!e||typeof e!="object")return console.error("Invalid object passed",e),{nodes:r,edges:n};const a=e;if(t==="root"&&(Jt.length=0),!Zt){const{nodes:l}=Ct(e);Zt={ids:l,jsnObjct:e}}let{hideDefaultObject:c,sprtObjctKy:u}=o;try{t=on(t,r);const{newConfig:l,arrayObject:d}=Yr(e),h=Object.keys(s).length>0?s:l;d.length&&(e=d);const p=Jr(e),y=Zr(e),{label:m,collapsed:g,parent:b}=h;if(!vr(e))r.push(ot(Ku,t,{label:m||t,parent:b},e,a));else if(Be(e)||Be(e)&&t==="root"){const{config:w}=xt("array",h),v=Be(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,x=t==="root"?i:`${i} ${v}`;r.push(ot(w,t,{label:m||x,parent:b},e,Be(a)?{[i]:a}:a))}else if(!Be(e)&&Object.keys(p).length||t==="root"){const{config:w}=xt(null,h),v=Be(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,x=t.split("."),C=x[x.length-1];let S=isNaN(Number(C))?null:Number(C)+1;const k=isNaN(Number(C))?C:x[x.length-2]+" "+S,I=t==="root"?i:k;let R=!1;Number.isNaN(Number(i))||(R=!0);const M=e;if(m){const{config:E}=xt("object",h);r.push(ot(E,t,{label:m||`${m} ${v}`,parent:b},p,M))}else w.data.headerTitle=I,r.push(ot(w,t,{label:m,parent:b},p,M))}return g||(Object.keys(y).length&&!Be(e)?Yt({flowConfig:o,chldPth:null,edges:n,isInverted:null,itrblObjct:y,nodes:r,path:t,newConfig:h}):Be(e)&&e.forEach((w,v)=>{w=Ju(w,Zt);const x=w,C=Jr(w),S=Zr(w),{newConfig:k,arrayObject:I}=Yr(w);I.length&&(w=I);const{config:R}=xt(typeof w=="string"?"text":"array",k),{hideConfig:M,sourceLabel:E,label:P,isEdgeAnimated:A,parent:j}=k;c=c||M;const q=t==="root"&&o.isCntr,O=t.split(".").slice(0,2).join("."),z=Jt.includes(O),U=o.isCntr&&z||v%2===0&&q;let ae=`${t}.${v}`;ae=on(ae,r),U&&Jt.push(ae),vr(w)?Object.keys(C).length&&!Be(w)?(n.push(Hr(t,ae,null,E,U,A)),st(w,ae,r,n,P||v,o,k)):Object.keys(S).length&&!Be(w)?Yt({flowConfig:o,chldPth:ae,isInverted:U,edges:n,itrblObjct:S,nodes:r,path:t,newConfig:k,forceIsInverted:!0}):Be(w)?mm({flowConfig:o,chldPth:ae,edges:n,isInverted:U,item:w,nodes:r,path:t}):vr(w)&&Yt({flowConfig:o,chldPth:ae,isInverted:U,edges:n,itrblObjct:[w],nodes:r,path:t,newConfig:k}):(n.push(Hr(t,ae,null,E,U,A)),r.push(ot(R,ae,{label:P||String(w),parent:j},w,x)))})),{nodes:r,edges:n}}catch{return{nodes:r,edges:n}}}const Yt=({chldPth:e,flowConfig:t,edges:r,itrblObjct:n,nodes:i,isInverted:o,path:s,newConfig:a,forceIsInverted:c=!1})=>{let{hideDefaultObject:u,sprtObjctKy:l}=t;return Object.entries(n).forEach(([d,h],p)=>{h=Ju(h,Zt);const y=h,m=Jr(h),g=Zr(h),{newConfig:b,arrayObject:w}=Yr(h);w.length&&(h=w);const{hideConfig:v,sourceLabel:x,label:C,content:S,target:k,targetLabel:I,collapsed:R,isEdgeAnimated:M,parent:E}=b;u=u||v;const P=s==="root"&&t.isCntr,A=s.split(".").slice(0,2).join("."),j=Jt.includes(A);c||(o=t.isCntr&&j||p%2===0&&P);let q=e?`${e}.${d}`:`${s}.${d}`;if(q=on(q,i),o&&Jt.push(q),k&&r.push(Hr(q,k,null,I,o,M)),vr(h)&&!Be(h)){r.push(Hr(s,q,null,x,o,M));const O=l||Object.keys(m).length===0;if(O){const z=S?"object":"array",{config:U}=xt(z,b);U.data.headerTitle=S?C:null,i.push(ot(U,q,{label:C||d,parent:E},h,y))}if(Object.keys(m).length&&!u){const z=Be(h)?` ${h.length||""}`:`{${Object.keys(h).length||""}}`;let U=q;O&&(U=`${q}.${z}`,U=on(U,i),r.push(Hr(q,U,null,x,o,M))),st(h,U,i,r,C||d,t,b)}else Object.keys(g).length&&!Be(h)?Yt({chldPth:q,flowConfig:t,itrblObjct:g,path:q,edges:r,nodes:i,newConfig:b,isInverted:o}):st(h,q,i,r,d,t,b)}else Be(h)&&(r.push(Hr(s,q,null,x,o,M)),st(h,q,i,r,d,t,b))})},mm=({flowConfig:e,chldPth:t,edges:r,isInverted:n,item:i,nodes:o,path:s})=>i.forEach((a,c)=>{let u=`${t}.${c}`;u=on(u,o);const l=a;a=Ju(a,Zt);const d=Zr(a),h=Jr(a),{newConfig:p}=Yr(a),{collapsed:y,label:m,parent:g,sourceLabel:b,isEdgeAnimated:w,content:v}=p;vr(a)?!Be(a)&&Object.keys(h).length?(r.push(Hr(s,u,null,b,n,w)),st(a,u,o,r,c,e,p)):Object.keys(d).length&&!Be(a)&&!y?Yt({chldPth:u,flowConfig:e,itrblObjct:d,path:s,edges:r,nodes:o,isInverted:n,newConfig:p}):Be(a)&&mm({flowConfig:e,chldPth:u,edges:r,isInverted:n,item:a,nodes:o,path:s}):(r.push(Hr(s,u,null,b,n,w)),o.push(ot(Ku,u,{label:m||String(a),parent:g},a,l)))});function S0(e,t){const r=new Set,n=u=>{if(!(!u||typeof u!="object")){typeof u.$parent=="string"&&r.add(u.$parent);for(const[l,d]of Object.entries(u))(!l.startsWith("$")||l==="$")&&n(d)}};if(n(e),!r.size)return t;const i=new Map(t.nodes.map(u=>[u.data.id,u])),o=u=>{var p,y;let l=u.data.id;const d=new Set([u.data.id]);let h=u.data.parent;for(;h&&!d.has(h);)r.has(h)&&i.has(h)&&((p=ke(e,h))!=null&&p.$collapsed)&&(l=h),d.add(h),h=(y=i.get(h))==null?void 0:y.data.parent;return l},s=new Map(t.nodes.map(u=>[u.data.id,o(u)])),a=t.nodes.filter(u=>s.get(u.data.id)===u.data.id).map(u=>{if(!r.has(u.data.id))return u;const l=ke(e,u.data.id),d=!!(l!=null&&l.$collapsed);return{...u,data:{...u.data,...d?{type:"arrayView"}:{},config:{...u.data.config,parentContainer:!0,collapsed:d,...d?{labelBelow:!0,icon:(l==null?void 0:l.$icon)||"PiStack"}:{}}}}}),c=new Set(a.map(u=>u.data.id));return{nodes:a,edges:t.edges.flatMap(u=>{const l=s.get(u.data.source),d=s.get(u.data.target);return!l||!d||!c.has(l)||!c.has(d)?[]:l===u.data.source&&d===u.data.target?[u]:l===d?[]:[{...u,data:{...u.data,source:l,target:d,collapsedEndpoints:u.data.collapsedEndpoints??{source:u.data.source,target:u.data.target}}}]})}}function Nn(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 i=r;if(typeof i.target!="string"||!/^root(?:\.|$)/.test(i.target))return[];if(i.sourceProperty!==void 0&&typeof i.sourceProperty!="string")return[];if(i.targetProperty!==void 0&&typeof i.targetProperty!="string")return[];const o=typeof i.id=="string"&&i.id?JSON.stringify(["id",i.id]):JSON.stringify(["ports",i.target,i.sourceProperty??null,i.targetProperty??null]),s=t.get(o)??0;return t.set(o,s+1),[{value:i,key:`${o}#${s}`,index:n}]})}function bm(e,t,r){const n=Nn(e).find(c=>c.key===t);if(!n)return e;const i=r(n.value),o=e.$connections.flatMap((c,u)=>u===n.index?i?[i]:[]:[c]);if(o.length)return{...e,$connections:o};const{$connections:s,...a}=e;return a}function _0(e){const t=[],r=(n,i)=>{if(!n||typeof n!="object")return n;if(Array.isArray(n))return n.map((o,s)=>r(o,`${i}.${s}`));for(const o of Nn(n)){const s=o.value;t.push({data:{id:`connection:${JSON.stringify([i,o.key])}`,source:i,target:s.target,type:typeof s.type=="string"?s.type:void 0,sourceProperty:s.sourceProperty,targetProperty:s.targetProperty,icon:typeof s.icon=="string"?s.icon:void 0,label:typeof s.label=="string"?s.label:void 0,color:typeof s.color=="string"?s.color:void 0,isEdgeDashed:s.style==="dashed",isEdgeAnimated:s.style==="animated",...["dashed","traveling"].includes(s.animationVariant)?{edgeAnimationVariant:s.animationVariant}:{},connection:{address:i,key:o.key}}})}return Object.fromEntries(Object.entries(n).filter(([o])=>o!=="$connections").map(([o,s])=>[o,o==="$"?r(s,i):o.startsWith("$")?s:r(s,`${i}.${o}`)]))};return{json:r(e,"root"),edges:t}}const St="root",Wl=e=>e==="#"||e.startsWith("{")||/^\s\d*$/.test(e);function kr(e){const t=e.split(".");for(t[0]===St&&t.shift();t.length&&Wl(t[t.length-1]);)t.pop();return t.filter(r=>!Wl(r))}function Ln(e){return e==null||typeof e!="object"?e:Array.isArray(e.$)?e.$:e}function ke(e,t){return kr(t).reduce((r,n)=>{var i;if(r!=null)return(i=Ln(r))==null?void 0:i[n]},e)}function E0(e){return Array.isArray(e)?[...e]:{...e}}function xr(e,t,r){const n=kr(t),i=(o,s)=>{if(s===n.length)return r(o);const a=n[s],c=Ln(o);if(c==null||typeof c!="object")return o;const u=i(c[a],s+1);if(Object.is(u,c[a]))return o;const l=E0(c);return l[a]=u,c!==o?{...o,$:l}:l};return i(e,0)}function Nr(e,t,r){const n=r===""&&t!=="$content"||r===void 0||r===null;if(Array.isArray(e))return n?e:{[t]:r,$:[...e]};const i=e!=null&&typeof e=="object"?{...e}:{};return e!=null&&typeof e!="object"&&(i.$label=String(e)),n?delete i[t]:i[t]=r,i}function hr(e,t,r,n){return xr(e,t,i=>r==="$label"&&typeof i=="string"&&typeof n=="string"&&n!==""?n:Nr(i,r,n))}const vm=(e,t,r)=>hr(e,t,"$collapsed",r);function it(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,i=kr(r).join("."),o=kr(n).join(".");return o.startsWith(i?i+".":"")&&o!==i?{address:n,kind:"hierarchy"}:i.startsWith(o?o+".":"")&&i!==o?{address:r,kind:"hierarchy"}:{address:r,kind:"target"}}function Ur(e,t,r,n){if(t.connection){const a=t.connection;return xr(e,a.address,c=>bm(c,a.key,u=>{if(r==="$edgeIcon")return Nr(u,"icon",n);if(r==="$edgeType")return Nr(u,"type",n);if(r==="$edgeAnimationVariant")return Nr(u,"animationVariant",n);if(r==="$sourceLabel"||r==="$edgeColor")return Nr(u,r==="$sourceLabel"?"label":"color",n);const l=r==="$isEdgeAnimated"?"animated":"dashed";return n?{...u,style:l}:u.style===l?Nr(u,"style",void 0):u}))}const{address:i,kind:o}=it(t),s=o==="target"&&r==="$sourceLabel"?"$targetLabel":o==="target"&&r==="$edgeType"?"$targetEdgeType":o==="target"&&r==="$edgeIcon"?"$targetIcon":o==="target"&&r==="$edgeAnimationVariant"?"$targetAnimationVariant":r;return xr(e,i,a=>Nr(a,s,n))}const xm=(e,t,r)=>Ur(Ur(e,t,"$isEdgeAnimated",r==="animated"||void 0),t,"$isEdgeDashed",r==="dashed"||void 0);function Zu(e,t,r,n){let i=n||"";const o=xr(e,t,a=>{const c=Ln(a);if(Array.isArray(c)){i=String(c.length);const l=[...c,r];return c===a?l:{...a,$:l}}const u=a!=null&&typeof a=="object"&&!Array.isArray(a)?{...a}:a!=null&&typeof a!="object"?{$label:String(a)}:{};if(!i){let l=1;for(;`node_${l}`in u;)l++;i=`node_${l}`}return u[i]=r,u}),s=kr(t);return{json:o,address:[St,...s,i].join(".")}}function wm(e,t){const r=kr(t);if(!r.length)return e;const n=r[r.length-1],i=[St,...r.slice(0,-1)].join(".");return xr(e,i,o=>{const s=Ln(o);if(s==null||typeof s!="object"||!Object.prototype.hasOwnProperty.call(s,n))return o;if(Array.isArray(s)){const u=s.filter((l,d)=>String(d)!==n);return s===o?u:{...o,$:u}}const{[n]:a,...c}=o;return c})}const Cm=(e,t,r,n)=>hr(n?xr(e,t,i=>Nr(i,"$targetLabel",n)):e,t,"$target",r);function Yu(e,t,r){const n=ke(e,t);return Nn(n).some(({value:o})=>o.target===r.target&&o.sourceProperty===r.sourceProperty&&o.targetProperty===r.targetProperty)?e:xr(e,t,o=>Nr(o,"$connections",[...Array.isArray(o==null?void 0:o.$connections)?o.$connections:[],{...r,id:r.id||Hu()}]))}function Sm(e,t){if(t.connection){const o=t.connection;return Nn(ke(e,o.address)).some(s=>s.key===o.key)?{json:xr(e,o.address,s=>bm(s,o.key,()=>null)),removed:!0}:{json:e,removed:!1}}const{address:r,kind:n}=it(t);return n==="hierarchy"?ke(e,r)===void 0?{json:e,removed:!1}:{json:xr(e,r,o=>({...o,$hideParentEdge:!0})),removed:!0}:n!=="target"?{json:e,removed:!1}:{json:xr(e,r,o=>{const{$target:s,$targetLabel:a,...c}=o||{};return c}),removed:!0}}function Lu(e,t={}){var w;const r=_0(e),{nodes:n,edges:i}=st(r.json,St,[],[],t.title||"untitled",{hideDefaultObject:!!t.hideDefaultObject,sprtObjctKy:!!t.separateObjectKeys,isCntr:!!t.isCenter}),o=new Set(n.map(v=>v.data.id)),s=new Map;for(const v of n){const x=v.data.id;if(!x.endsWith(".0")||ke(e,x)!==void 0)continue;const C=x.slice(0,-2),S=ke(e,C);!o.has(C)&&S&&typeof S=="object"&&!Array.isArray(S)&&typeof S.$label=="string"&&Object.keys(S).every(k=>k.startsWith("$")&&k!=="$")&&s.set(x,C)}const a=v=>s.get(v)??v,c=new Set(n.flatMap(v=>v.data.parent?[a(v.data.parent)]:[])),u=new Map;if(t.isCenter){const v=new Map;for(const{data:x}of i){const C=it(x);if(C.kind==="hierarchy")u.set(a(C.address),!!x.isInverted);else if(!Array.isArray(e)&&e.$hideRoot===!0){const S=a(x.isInverted?x.source:x.target);if(kr(S).length!==1)continue;const k=!!x.isInverted;v.set(S,v.has(S)&&v.get(S)!==k?null:k)}}for(const[x]of u){const C=`${St}.${kr(x)[0]}`,S=v.get(C);typeof S=="boolean"&&u.set(x,S)}}const l=n.map(v=>{var R;const x=a(v.data.id),C=ke(e,x),S={...v.data,id:x};u.has(x)&&(S.config={...S.config,isInverted:u.get(x)});const k=C&&typeof C=="object"&&!Array.isArray(C)&&"$"in C?C.$:C;if((Array.isArray(k)?k.length>0:k&&typeof k=="object"&&Object.keys(k).some(M=>!M.startsWith("$")))&&(S.config={...S.config,collapsed:!!C.$collapsed}),c.has(x)||(S.viewProps={...S.viewProps},delete S.viewProps.borderWidth),!C||typeof C!="object"||Array.isArray(C))return{data:S};if(C.$form&&typeof C.$form=="object"&&(S.config={...S.config,form:C.$form},S.type="objectView"),Array.isArray(C.$ports)){const M=C.$ports.filter(E=>E&&typeof E.id=="string"&&["source","target"].includes(E.role)&&["top","right","bottom","left"].includes(E.side));S.config={...S.config,ports:M}}if(S.parent&&(S.parent=a(S.parent)),typeof C.$label=="string"&&(S.label=C.$label,S.headerTitle=C.$label),typeof C.$subtitle=="string"&&(S.config={...S.config,subtitle:C.$subtitle}),typeof C.$outline=="boolean"&&(S.viewProps={...S.viewProps,outline:C.$outline}),["solid","dashed","dotted","double"].includes(C.$borderStyle)&&(S.viewProps={...S.viewProps,borderStyle:C.$borderStyle}),Number.isFinite(C.$borderWidth)&&C.$borderWidth>=0&&(S.viewProps={...S.viewProps,borderWidth:C.$borderWidth}),Number.isFinite(C.$borderRadius)&&C.$borderRadius>=0&&(S.viewProps={...S.viewProps,borderRadius:C.$borderRadius}),typeof C.$isNodeAnimated=="boolean"&&(S.isNodeAnimated=C.$isNodeAnimated),["traveling","pulse"].includes(C.$nodeAnimationVariant)&&(S.nodeAnimationVariant=C.$nodeAnimationVariant),typeof C.$content=="string"){S.config={...S.config,content:C.$content};const M=C.$contentFormat??"markdown";if(!["markdown","html","jsx"].includes(M))throw new Error("Invalid content format: expected markdown, html, or jsx.");S.config.contentFormat=M,C.$view||(S.type="objectView")}return(((R=S.config)==null?void 0:R.collapsed)!==void 0||C.$collapsed!==void 0||C.$icon!==void 0)&&(S.config={...S.config||{}},(C.$collapsed!==void 0||S.config.collapsed!==void 0)&&(S.config.collapsed=!!C.$collapsed),C.$icon!==void 0&&(S.config.icon=C.$icon)),{data:S}}),d=new Map,h=i.map(v=>{let x=a(v.data.source),C=a(v.data.target),S=v.data.isInverted;const k=it(v.data),I=u.get(a(k.address));k.kind==="hierarchy"&&I!==void 0&&I!==!!S&&([x,C]=[C,x],S=I);const R=`${x}->${C}`,M=d.get(R)??0;d.set(R,M+1);const E={...v.data,id:M?`${R}#${M}`:R,source:x,target:C,isInverted:S},P=it(E),A=ke(e,P.address);if(A&&typeof A=="object"){const j=A[P.kind==="target"?"$targetEdgeType":"$edgeType"];typeof j=="string"&&(E.type=j);const q=A[P.kind==="target"?"$targetIcon":"$edgeIcon"];typeof q=="string"&&(E.icon=q),A.$isEdgeAnimated!==void 0&&(E.isEdgeAnimated=!!A.$isEdgeAnimated);const O=A[P.kind==="target"?"$targetAnimationVariant":"$edgeAnimationVariant"];["dashed","traveling"].includes(O)&&(E.edgeAnimationVariant=O),A.$isEdgeDashed!==void 0&&(E.isEdgeDashed=!!A.$isEdgeDashed),A.$edgeColor&&(E.color=A.$edgeColor)}return{data:E}});if(!Array.isArray(e)&&(e==null?void 0:e.$hideRoot)===!0){const v=l.findIndex(x=>x.data.id===St);v!==-1&&l.splice(v,1)}const p=new Set(l.map(v=>v.data.id));for(let v=h.length-1;v>=0;v--){const x=h[v].data,C=it(x);(!p.has(x.source)||!p.has(x.target)||C.kind==="hierarchy"&&((w=ke(e,C.address))==null?void 0:w.$hideParentEdge)===!0)&&h.splice(v,1)}h.push(...r.edges.filter(v=>p.has(v.data.source)&&p.has(v.data.target)));const y=S0(e,{nodes:l,edges:h}),m=y.nodes.filter(v=>{var x;return(x=v.data.config)==null?void 0:x.collapsed}).map(v=>kr(v.data.id));if(!m.length)return y;const g=y.nodes.filter(v=>{const x=kr(v.data.id);return!m.some(C=>C.length<x.length&&C.every((S,k)=>S===x[k]))}),b=new Set(g.map(v=>v.data.id));return{nodes:g,edges:y.edges.filter(v=>b.has(v.data.source)&&b.has(v.data.target))}}function j0(e,t){const r=new Set(e.filter(c=>{var u,l;return(l=(u=c.data)==null?void 0:u.config)==null?void 0:l.collapsed}).map(c=>c.data.id));if(!r.size)return{nodes:e,edges:t};const n=new Map(e.map(c=>[c.data.id,c])),i=new Set(e.map(c=>c.data.parent).filter(Boolean)),o=new Map(e.map(c=>{var h;let u=c.data.id,l=c.data.parent;const d=new Set([u]);for(;l&&!d.has(l);)r.has(l)&&(u=l),d.add(l),l=(h=n.get(l))==null?void 0:h.data.parent;return[c.data.id,u]})),s=new Map;for(const c of t){const u=c.data.isInverted?c.data.target:c.data.source,l=c.data.isInverted?c.data.source:c.data.target;(s.get(u)??s.set(u,[]).get(u)).push(l)}const a=new Set(e.filter(c=>o.get(c.data.id)!==c.data.id).map(c=>c.data.id));for(const c of r){if(i.has(c))continue;const u=[...s.get(c)||[]];for(;u.length;){const l=u.pop();r.has(l)||a.has(l)||(a.add(l),u.push(...s.get(l)||[]))}}return{nodes:e.filter(c=>!a.has(c.data.id)).map(c=>{var u;return r.has(c.data.id)&&i.has(c.data.id)?{...c,data:{...c.data,type:"arrayView",label:c.data.label??c.data.headerTitle,config:{...c.data.config,parentContainer:!0,labelBelow:!0,icon:((u=c.data.config)==null?void 0:u.icon)||"PiStack"}}}:c}),edges:t.flatMap(c=>{const u=o.get(c.data.source)??c.data.source,l=o.get(c.data.target)??c.data.target;return a.has(u)||a.has(l)?[]:u===c.data.source&&l===c.data.target?[c]:u===l?[]:[{...c,data:{...c.data,source:u,target:l,collapsedEndpoints:c.data.collapsedEndpoints??{source:c.data.source,target:c.data.target}}}]})}}function Xu(e,t){const r=JSON.parse(e);let n=512;const i=(s,a=[])=>{if(--n<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(!s||typeof s!="object"||Array.isArray(s))throw new Error("Expected a JSON Schema object.");const c=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(s))if(!c.has(l))throw new Error(`Unsupported JSON Schema keyword: ${l}`);const u=["$schema","$id","$defs","definitions","title","description","default","examples"];if(s.$ref){if(Object.keys(s).some(d=>!["$ref","title","description"].includes(d)))throw new Error("Use $ref without sibling constraints.");if(typeof s.$ref!="string"||!s.$ref.startsWith("#/")||a.includes(s.$ref))throw new Error("Only nonrecursive local $ref references are supported.");let l=r;for(const d of s.$ref.slice(2).split("/")){const h=d.replace(/~1/g,"/").replace(/~0/g,"~");if(!l||!Object.prototype.hasOwnProperty.call(l,h))throw new Error(`Unresolved reference: ${s.$ref}`);l=l[h]}return i(l,[...a,s.$ref])}if(s.anyOf){if(!Array.isArray(s.anyOf)||!s.anyOf.length||Object.keys(s).some(l=>l!=="anyOf"&&!u.includes(l)))throw new Error("Use a nonempty anyOf without sibling type constraints.");return{kind:"union",types:s.anyOf.map(l=>i(l,a))}}if(Object.prototype.hasOwnProperty.call(s,"const")||s.enum){if(Object.keys(s).some(h=>![...u,"const","enum","type"].includes(h))||s.enum&&Object.prototype.hasOwnProperty.call(s,"const"))throw new Error("Use enum or const without sibling constraints other than type.");const l=Object.prototype.hasOwnProperty.call(s,"const")?[s.const]:s.enum;if(!Array.isArray(l)||!l.length)throw new Error("Expected a nonempty enum.");return{kind:"union",types:l.map(h=>{if(h!==null&&!["string","number","boolean"].includes(typeof h))throw new Error("Only primitive literals are supported.");const p=h===null?"null":typeof h;if(s.type&&!(Array.isArray(s.type)?s.type:[s.type]).some(y=>y===p||y==="integer"&&Number.isInteger(h)))throw new Error("Literal does not match its declared type.");return{kind:"literal",value:h}})}}if(Array.isArray(s.type)){if(!s.type.length||s.type.some(l=>typeof l!="string"))throw new Error("Expected a nonempty list of primitive types.");if(Object.keys(s).some(l=>l!=="type"&&!u.includes(l)))throw new Error("Use anyOf for unions with object or array constraints.");return{kind:"union",types:s.type.map(l=>i({type:l},a))}}if((s.properties||s.required||s.additionalProperties!==void 0)&&s.type!=="object"&&s.type!==void 0)throw new Error("Object constraints require an object type.");if(s.items&&s.type!=="array")throw new Error("items requires an array type.");if(s.type==="object"||s.properties){if(s.additionalProperties!==void 0&&s.additionalProperties!==!0)throw new Error("Closed objects and typed additionalProperties are not supported.");if(!s.properties||typeof s.properties!="object"||Array.isArray(s.properties))throw new Error("Object schemas must declare properties.");if(s.required!==void 0&&(!Array.isArray(s.required)||s.required.some(d=>typeof d!="string"||!Object.prototype.hasOwnProperty.call(s.properties,d))))throw new Error("required must list declared property names.");return{kind:"object",properties:Object.fromEntries(Object.entries(s.properties).map(([d,h])=>[d,{type:i(h,a),optional:!(s.required??[]).includes(d)}]))}}if(s.type==="array")return{kind:"array",items:i(s.items,a)};if(["string","number","integer","boolean","null"].includes(s.type))return{kind:s.type};throw new Error("Every property must declare a supported type.")},o=i(r);if(o.kind!=="object")throw new Error("The root schema must be an object keyed by node ID.");if(Object.values(o.properties).some(s=>s.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:t,nodes:o.properties}}async function Qu(e,t,r,n={}){var y;let i=512;const o=await import("typescript"),s=o.createSourceFile(t,e,o.ScriptTarget.Latest,!0,o.ScriptKind.TS),a=s.parseDiagnostics;if(a!=null&&a.length)throw new Error("Invalid TypeScript syntax.");const c=new Map;for(const m of s.statements){if(!o.isInterfaceDeclaration(m)&&!o.isTypeAliasDeclaration(m))throw new Error("Upload interfaces/type aliases only; imports and executable code are not supported.");if((y=m.typeParameters)!=null&&y.length||c.has(m.name.text))throw new Error("Generics and duplicate declarations are not supported.");c.set(m.name.text,m)}const u=(m,g)=>{var C;const b={},w=m.find(S=>o.isIndexSignatureDeclaration(S));let v;if(w&&n.allowJson&&o.isIndexSignatureDeclaration(w)){if(m.filter(S=>o.isIndexSignatureDeclaration(S)).length!==1||w.parameters.length!==1||((C=w.parameters[0].type)==null?void 0:C.kind)!==o.SyntaxKind.StringKeyword||!w.type)throw new Error("Only one string-keyed index signature is supported for forms.");v=d(w.type,g)}return{kind:"object",properties:Object.fromEntries(m.filter(S=>S!==w||!v).map(S=>{if(!o.isPropertySignature(S)||!S.type||!S.name||!o.isIdentifier(S.name)&&!o.isStringLiteral(S.name))throw new Error("Only explicitly typed named properties are supported.");const k=d(S.type,g),I=n.allowJson?o.getJSDocTags(S).filter(R=>R.tagName.text==="port"):[];if(I.length>1)throw new Error(`Duplicate port declaration: ${S.name.text}`);if(I.length){const[R,M,E]=String(I[0].comment??"").trim().split(/\s+/);if(R!=="config"||!M||E||!c.has(M))throw new Error(`Config port ${S.name.text} requires @port config ResourceType`);const P=k.kind==="array";if((k.kind==="array"?k.items.kind:k.kind)!=="string")throw new Error(`Config port ${S.name.text} must be a string or string array reference`);b[S.name.text]={kind:"config",resourceType:M,multiple:P}}return[S.name.text,{type:k,optional:!!S.questionToken}]})),...v?{additionalProperties:v}:{},...Object.keys(b).length?{ports:b}:{}}},l=(m,g)=>{var C;if(g.includes(m))throw new Error("Recursive types are not supported.");const b=c.get(m);if(!b)throw new Error(`Unknown type: ${m}`);let w;if(o.isInterfaceDeclaration(b)){if((C=b.heritageClauses)!=null&&C.length)throw new Error("Interface inheritance is not supported; declare properties explicitly.");w=u(b.members,[...g,m])}else w=d(b.type,[...g,m]);const v=n.allowJson?o.getJSDocTags(b).filter(S=>S.tagName.text==="port"):[];if(!v.length)return w;if(w.kind!=="object")throw new Error("Node ports require an object interface");const x={...w.ports};for(const S of v){const[k,I,...R]=String(S.comment??"").trim().split(/\s+/);if(!["input","output","error"].includes(k)||!/^[A-Za-z][\w-]*$/.test(I??""))throw new Error("Node ports require @port input|output|error Name");const M=R.length?JSON.parse(R.join(" ")):void 0;if(M!==void 0&&typeof M!="string")throw new Error("Node port labels must be JSON strings");if(Object.prototype.hasOwnProperty.call(x,I))throw new Error(`Duplicate port declaration: ${I}`);x[I]={kind:k,...typeof M=="string"?{label:M}:{}}}return{...w,ports:x}},d=(m,g)=>{var b,w,v;if(--i<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(m.kind===o.SyntaxKind.StringKeyword)return{kind:"string"};if(m.kind===o.SyntaxKind.NumberKeyword)return{kind:"number"};if(m.kind===o.SyntaxKind.BooleanKeyword)return{kind:"boolean"};if(n.allowJson&&[o.SyntaxKind.AnyKeyword,o.SyntaxKind.UnknownKeyword].includes(m.kind))return{kind:"json"};if(o.isParenthesizedTypeNode(m))return d(m.type,g);if(o.isUnionTypeNode(m))return{kind:"union",types:m.types.map(x=>d(x,g))};if(o.isArrayTypeNode(m))return{kind:"array",items:d(m.elementType,g)};if(o.isTypeLiteralNode(m))return u(m.members,g);if(o.isLiteralTypeNode(m)){const x=m.literal;if(o.isStringLiteral(x))return{kind:"literal",value:x.text};if(o.isNumericLiteral(x))return{kind:"literal",value:Number(x.text)};if(x.kind===o.SyntaxKind.NullKeyword)return{kind:"null"};if(x.kind===o.SyntaxKind.TrueKeyword||x.kind===o.SyntaxKind.FalseKeyword)return{kind:"literal",value:x.kind===o.SyntaxKind.TrueKeyword}}if(o.isTypeReferenceNode(m)&&o.isIdentifier(m.typeName)){if(n.allowJson&&m.typeName.text==="Record"&&!c.has("Record")&&((b=m.typeArguments)==null?void 0:b.length)===2&&m.typeArguments[0].kind===o.SyntaxKind.StringKeyword)return{kind:"object",properties:{},additionalProperties:d(m.typeArguments[1],g)};if(m.typeName.text==="Array"&&((w=m.typeArguments)==null?void 0:w.length)===1)return{kind:"array",items:d(m.typeArguments[0],g)};if(!((v=m.typeArguments)!=null&&v.length))return l(m.typeName.text,g)}throw new Error(`Unsupported TypeScript type: ${m.getText(s)}`)},h=r??(c.has("Graph")?"Graph":c.size===1?[...c.keys()][0]:void 0);if(!h)throw new Error("Declare an interface Graph keyed by node ID.");const p=l(h,[]);if(p.kind!=="object")throw new Error("Graph must be an object keyed by node ID.");return p}async function _m(e,t){const r=await Qu(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 zt(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=>zt(r,t));if(t.kind==="union")return t.types.some(r=>zt(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"?zt(e.items,t.items):e.kind==="object"&&t.kind==="object"?Object.entries(t.properties).every(([r,n])=>{const i=Object.prototype.hasOwnProperty.call(e.properties,r)?e.properties[r]:void 0;return i?(n.optional||!i.optional)&&zt(i.type,n.type):n.optional}):e.kind===t.kind}function el(e,t){if(!t.sourceProperty&&!t.targetProperty)return;const r=(s,a)=>{var l;const c=Object.prototype.hasOwnProperty.call(e.nodes,s)?s:s.replace(/^root\./,""),u=Object.prototype.hasOwnProperty.call(e.nodes,c)?(l=e.nodes[c])==null?void 0:l.type:void 0;return a&&(u==null?void 0:u.kind)==="object"&&Object.prototype.hasOwnProperty.call(u.properties,a)?u.properties[a]:void 0},n=r(t.source,t.sourceProperty),i=r(t.target,t.targetProperty);if(!n||!i)return"Unverified: source or target property is missing from the interface.";const o=s=>s.kind==="json"||s.kind==="object"&&(!!s.additionalProperties||Object.values(s.properties).some(a=>o(a.type)))||s.kind==="array"&&o(s.items)||s.kind==="union"&&s.types.some(o);if(o(n.type)||o(i.type))return"Unverified: arbitrary JSON or dictionary fields require runtime validation.";if(n.optional&&!i.optional)return"Optional source cannot supply a required target property.";if(!zt(n.type,i.type))return`Incompatible property types: ${t.sourceProperty} -> ${t.targetProperty}.`}async function Em(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 Xu(t,e.name);if(/\.ts$/i.test(e.name))return _m(t,e.name);throw new Error("Choose a .ts interface or .json JSON Schema file.")}const Gl=new WeakMap;function jt(e){if(!e||typeof e!="object")return e;const t=Gl.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:(i,o)=>jt(Reflect.get(e,o)),has:(i,o)=>Reflect.has(e,o),ownKeys:()=>Reflect.ownKeys(e),getOwnPropertyDescriptor:(i,o)=>{const s=Reflect.getOwnPropertyDescriptor(e,o);return s&&{...s,value:jt(Reflect.get(e,o)),configurable:o!=="length"||!Array.isArray(e)}},set:r,deleteProperty:r,defineProperty:r,setPrototypeOf:r,preventExtensions:r});return Gl.set(e,n),n}function Tt(e,t,r){var i;const n=t.split(".");for(let o=n.length;o>0;o--){const s=n.slice(0,o).join("."),a=(i=ke(e,s))==null?void 0:i.$form;if(!(a!=null&&a.$type))continue;let c=Object.prototype.hasOwnProperty.call(r,a.$type)?r[a.$type]:void 0;for(const d of n.slice(o))(c==null?void 0:c.kind)==="array"&&/^\d+$/.test(d)?c=c.items:(c==null?void 0:c.kind)==="object"?c=Object.prototype.hasOwnProperty.call(c.properties,d)?c.properties[d].type:void 0:c=void 0;if((c==null?void 0:c.kind)!=="object")return;const u=n.slice(o).join("."),l=Object.fromEntries(Object.entries(a.$fields??{}).filter(([d])=>!u||d.startsWith(`${u}.`)).map(([d,h])=>[u?d.slice(u.length+1):d,h]));return{type:c,fields:l,binding:a}}}async function rl(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 i=[],o=new Set(t);for(const s of o){if(o.size>32)throw new Error("Choose between 1 and 32 form interface names.");const a=await Qu(r,e.name,s,{allowJson:!0});i.push([s,a]);for(const c of Object.values(a.ports??{}))c.resourceType&&o.add(c.resourceType)}return Object.fromEntries(i)}if(!e.name.endsWith(".json"))throw new Error("Choose a .ts interface or .json schema file.");const n=Xu(r,e.name);return Object.fromEntries(Object.entries(n.nodes).map(([i,o])=>[i,o.type]))}function Fn(e,t){return!e||("$in"in e?e.$in.includes(ke(t,e.$address)):ke(t,e.$address)===e.$equals)}function Xt(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,i=o=>{if(o===null||typeof o=="string"||typeof o=="boolean")return!0;if(typeof o=="number")return Number.isFinite(o);if(!o||typeof o!="object"||n.has(o)||!Array.isArray(o)&&![Object.prototype,null].includes(Object.getPrototypeOf(o)))return!1;n.add(o);const s=Object.values(o).every(i);return n.delete(o),s};return i(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,i])=>!Object.prototype.hasOwnProperty.call(e.properties,n)&&Rr(e.additionalProperties,i,!0))?"Invalid dictionary value":Object.entries(e.properties).some(([n,i])=>Rr(i.type,t[n],!i.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 Ul(e,t){const r=t.address.split(".");if(r.shift()!=="root"||!r.length||r.some(a=>!a||["__proto__","prototype","constructor","#"].includes(a)))throw new Error("Invalid form field address.");const n=r.pop(),i=n==="$bgColor"||n==="$textColor"||n==="$borderColor";if(r.some(a=>a.startsWith("$"))||n.startsWith("$")&&!i)throw new Error("Unsupported form metadata address.");const o=["root",...r].join("."),s=ke(e,o);if(!s||typeof s!="object")throw new Error(`Missing form parent: ${o}`);if(i){if(t.op==="set"&&typeof t.value!="string")throw new Error("Node colors must be strings.");return hr(e,o,n,t.op==="remove"?void 0:t.value)}return xr(e,o,a=>{const c=Array.isArray(a.$)?a.$:a;if(t.op==="remove"&&!Object.prototype.hasOwnProperty.call(c,n)||t.op==="set"&&Object.is(c[n],t.value))return a;const u=Array.isArray(c)?[...c]:{...c};if(Array.isArray(u)&&(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=u.length))throw new Error("Invalid array address.");return t.op==="remove"?Array.isArray(u)?u.splice(Number(n),1):delete u[n]:Object.defineProperty(u,n,{value:structuredClone(t.value),enumerable:!0,writable:!0,configurable:!0}),c===a?u:{...a,$:u}})}function Bn(e,t,r){let n=Ul(e,t.value===void 0?{op:"remove",address:t.address}:{op:"set",address:t.address,value:t.value});const i=r==null?void 0:r({...t,previousValue:jt(ke(e,t.address)),data:jt(n)});if(i&&!Array.isArray(i))throw new Error("Form change handlers must return edits synchronously.");for(const o of Array.isArray(i)?i:[]){if(o.op!=="set"&&o.op!=="remove")throw new Error("Unsupported form edit.");n=Ul(n,o)}return n}const Qt="data:image/svg+xml;base64,";function Wr(e){if(e.startsWith(Qt))return!0;try{const t=new URL(e);return(t.protocol==="https:"||t.protocol==="http:")&&!t.username&&!t.password}catch{return!1}}async function k0(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(o=>[...o.attributes].some(s=>/^on/i.test(s.name))))throw new Error("SVG scripts and event handlers are not allowed.");const n=new TextEncoder().encode(t);let i="";for(const o of n)i+=String.fromCharCode(o);return Qt+btoa(i)}const Or=({name:e,svg:t=!1,...r})=>{const[n,i]=_.useState(null),[o,s]=_.useState(!0),[a,c]=_.useState(!1),u=typeof e=="string"&&Wr(e);if(_.useEffect(()=>{if(u||!e||e.length<2){i(null),s(!1);return}s(!0),c(!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 h;switch(d){case"md":h=await import("react-icons/md");break;case"fa6":h=await import("react-icons/fa6");break;case"io5":h=await import("react-icons/io5");break;case"io":h=await import("react-icons/io");break;case"ti":h=await import("react-icons/ti");break;case"go":h=await import("react-icons/go");break;case"fi":h=await import("react-icons/fi");break;case"di":h=await import("react-icons/di");break;case"ai":h=await import("react-icons/ai");break;case"bs":h=await import("react-icons/bs");break;case"ri":h=await import("react-icons/ri");break;case"fc":h=await import("react-icons/fc");break;case"gi":h=await import("react-icons/gi");break;case"hi2":h=await import("react-icons/hi2");break;case"hi":h=await import("react-icons/hi");break;case"si":h=await import("react-icons/si");break;case"sl":h=await import("react-icons/sl");break;case"im":h=await import("react-icons/im");break;case"bi":h=await import("react-icons/bi");break;case"pi":h=await import("react-icons/pi");break;case"vsc":h=await import("react-icons/vsc");break;case"tb":h=await import("react-icons/tb");break;case"tfi":h=await import("react-icons/tfi");break;case"cg":h=await import("react-icons/cg");break;case"lia":h=await import("react-icons/lia");break;case"lu":h=await import("react-icons/lu");break;default:throw new Error(`Unsupported library: ${d}`)}const p=h[e];if(!p)throw new Error(`Icon ${e} not found in library ${d}`);i(()=>p)}catch(d){console.warn(`Failed to load icon ${e}:`,d.message),c(!0),i(null)}finally{s(!1)}})()},[e,u]),u){const{size:l=80,style:d,...h}=r;return t?f.jsx("image",{...h,href:e,width:l,height:l,preserveAspectRatio:"xMidYMid meet",style:d}):f.jsx("img",{...h,src:e,alt:"",width:l,height:l,referrerPolicy:"no-referrer",style:{objectFit:"contain",...d}})}return o||!n?null:f.jsx(n,{...r})};function R0(e,t){let r=e;for(const n of t){if(n.op!=="set"&&n.op!=="remove")throw new Error("Unsupported state edit.");const i=n.address.split(".");if(i.some(s=>s.startsWith("$")||["__proto__","prototype","constructor"].includes(s)))throw new Error("State edits cannot target view metadata or unsafe keys.");const o=n.op==="remove"?void 0:n.value;an(o),r=Bn(r,{address:n.address,nodeAddress:i.slice(0,-1).join("."),value:o})}return an(r),r}function dn(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 an(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}`);an(r)}}function P0(e,t,r){an(t.value);const n=Bn(e,t,r);return an(n),n}function jm(e,t){const r=(n,i="")=>{if(!n||typeof n!="object")return n;if(["$label","$subtitle","$content","$icon","$bgColor","$textColor","$borderColor"].includes(i)&&typeof n.$state=="string"){const s=ke(t,n.$state);return s==null?"":typeof s=="object"?JSON.stringify(s,null,2):String(s)}let o=n;for(const[s,a]of Object.entries(n)){const c=r(a,s);c!==a&&(o===n&&(o=Array.isArray(n)?[...n]:{...n}),Object.defineProperty(o,s,{value:c,enumerable:!0,writable:!0,configurable:!0}))}return o};return r(e)}const A0=e=>!!e&&!e.includes(".")&&!e.startsWith("$")&&!["__proto__","constructor","prototype"].includes(e),T0=e=>`root.__form_${encodeURIComponent(e).replace(/\./g,"%2E")}`,Dt=(e,t)=>JSON.stringify([e,t]);function sn(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 sn(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 Vt(e){const t=sn(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 Hl(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"&&!Xt(e)?e.types:[e]}function I0(e,t,r){if(t.address===r.address)return;const n=ke(e,t.address),i=(o,s)=>s===void 0?!1:o.kind==="union"?o.types.some(a=>i(a,s)):o.kind==="array"?Array.isArray(s)&&s.every(a=>i(o.items,a)):o.kind==="object"?!!s&&typeof s=="object"&&!Array.isArray(s)&&Object.entries(o.properties).every(([a,c])=>c.optional&&s[a]===void 0||i(c.type,s[a]))&&Object.entries(s).every(([a,c])=>Object.prototype.hasOwnProperty.call(o.properties,a)||!o.additionalProperties||i(o.additionalProperties,c)):s===""?o.kind==="string"||o.kind==="json"||o.kind==="literal"&&o.value==="":!Rr(o,s,!0);if(i(r.type,n))return structuredClone(n)}function km(e,t,r,n){var c,u;const i={sourceSchema:r,sourceBindings:t,nodes:[],edges:[],schema:{...r},bindings:{...t},slots:new Map,containers:new Map},o=new Set(n.map(l=>l.data.id)),s=new Map(n.flatMap(l=>{const d=t[l.data.id];return d&&r[d.type]?[[d.address,l.data.id]]:[]})),a=(l,d,h,p,y,m=!1)=>{var k,I,R,M,E;if(y>24||i.containers.size>512)throw new Error("Structured form exceeds the flow node limit.");const g=ke(e,d),b=sn(h,g),w=b.kind!=="object"&&b.kind!=="array";i.containers.set(l,{address:d,type:b,declared:h,scalar:w});const v=`__form:${l}`,x={...(k=i.bindings[l])==null?void 0:k.fields},C={kind:"object",properties:{},ports:{...b.kind==="object"?b.ports:{},...m?{resource:{label:"output",...b.kind==="object"?(I=b.ports)==null?void 0:I.resource:{},kind:"output"}}:{}}},S=b.kind==="object"?{...b.properties,...Object.fromEntries(Object.keys(g??{}).filter(P=>!Object.prototype.hasOwnProperty.call(b.properties,P)&&b.additionalProperties).map(P=>[P,{type:b.additionalProperties,optional:!0}]))}:b.kind==="array"?Object.fromEntries((Array.isArray(g)?g:[]).map((P,A)=>[String(A),{type:b.items,optional:!0}])):{value:{type:Xt(h)?h:b,optional:!1}};for(const[P,A]of Object.entries(S)){if(!A0(P))throw new Error(`Unsupported structured property key: ${P}`);const j=w?d:`${d}.${P}`,q=ke(e,j),O=sn(A.type,q),z=O.kind==="object"||O.kind==="array",U=(R=C.ports)==null?void 0:R[P],ae=(U==null?void 0:U.kind)==="config"&&(((M=x[P])==null?void 0:M.$options)||Xt(A.type)),Q=A.type.kind==="json"||A.type.kind==="union"&&!Xt(A.type);if(((E=x[P])==null?void 0:E.$control)==="upload"||!z&&b.kind!=="array"&&(!Q||w)||ae){C.properties[P]={...A,type:A.type.kind==="json"?O:A.type};continue}const Y=s.get(j)??T0(j),pe=b.kind==="array"?`Item ${Number(P)+1}`:P,se={address:j,owner:l,field:P,type:A.type,label:pe,nodeId:Y,present:q!==void 0};if(i.slots.set(Dt(l,P),se),C.ports[P]={kind:"config",resourceType:`__form:${Y}`},q===void 0||(i.edges.push({data:{id:`__form-edge:${l}:${P}`,source:Y,target:l,sourceProperty:"output:resource",targetProperty:`config:${P}`,isEdgeDashed:!0}}),i.containers.has(Y)||s.has(j)))continue;if(o.has(Y))throw new Error(`Structured node identity conflict: ${Y}`);o.add(Y);const $={data:{id:Y,type:"objectView",label:pe,headerTitle:pe,description:{},config:{form:!0,icon:O.kind==="array"?"PiListNumbers":z?"PiBracketsCurly":"PiTextT"},viewProps:{bgColor:p}}};i.nodes.push($),a(Y,j,A.type,p,y+1,!0);const V=i.schema[`__form:${Y}`];$.data.description=Object.fromEntries(Object.keys(V.properties).map(W=>[W,ke(e,O.kind==="array"||O.kind==="object"?`${j}.${W}`:j)]).filter(([,W])=>W!==void 0))}i.schema[v]=C,i.bindings[l]={...i.bindings[l],address:d,type:v,fields:x}};for(const l of n){const d=t[l.data.id];if(d!=null&&d.portResources)continue;const h=d&&r[d.type];!d||!h||ke(e,d.address)===void 0||a(l.data.id,d.address,h,(c=l.data.viewProps)==null?void 0:c.bgColor,0,i.edges.some(p=>p.data.source===l.data.id))}for(const l of i.edges){const d=i.bindings[l.data.source],h=i.schema[d.type].ports;h.resource={...h.resource,kind:"output",label:((u=h.resource)==null?void 0:u.label)??"output"}}return i}const at=(e="reference")=>({kind:e,text:"",paths:[""]}),Rm=e=>/^[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*|\.\d+)+$/.test(e)&&!e.split(".").some(t=>["__proto__","constructor","prototype"].includes(t));function O0(e,t){const r=new Set(t.map(s=>s.path)),n=s=>{if(!s.paths.length||s.paths.some(a=>!Rm(a)||!r.has(a)))throw new Error("Choose an available reference.");return[...s.paths,...s.fallback===void 0?[]:[JSON.stringify(s.fallback)]].join(" || ")},i=s=>{if(s.includes("{{")||s.includes("}}"))throw new Error("Use a reference part for dynamic values.");return s},o=s=>s.map(a=>{if(a.kind==="text")return i(a.text);if(a.kind==="conditional"){if(a.paths.length!==1||a.fallback!==void 0)throw new Error("Choose one condition reference.");return`{{#if ${n(a)}}}${i(a.text)}{{/if}}`}return`{{${n(a)}}}`}).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 s=o(e.parts);return e.mode==="condition"?`${s} == ${JSON.stringify(e.comparison)}`:s}if(e.mode==="json"){const s=e.fields.map(a=>a.key);if(!s.length||new Set(s).size!==s.length||s.some(a=>!a||["__proto__","constructor","prototype"].includes(a)))throw new Error("Output field names must be unique and nonempty.");return JSON.stringify(Object.fromEntries(e.fields.map(a=>[a.key,o(a.parts)])))}return o(e.parts)}async function M0(e){const t=await import("typescript"),r=s=>{const a=t.createSourceFile("binding.ts",`(${s})`,t.ScriptTarget.Latest,!0,t.ScriptKind.TS);if(a.parseDiagnostics.length)throw new Error("Unsupported reference expression.");const c=a.statements[0];if(!c||!t.isExpressionStatement(c))throw new Error("Unsupported reference expression.");const u=at();u.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(u.fallback!==void 0)throw new Error("Multiple fallback values.");u.fallback=d.text;return}const h=d.getText(a);if(!Rm(h)||u.fallback!==void 0)throw new Error("Unsupported reference expression.");u.paths.push(h)};if(l(c.expression),!u.paths.length)throw new Error("A binding needs a reference.");return u},n=s=>{const a=[];let c=0;const u=/\{\{([\s\S]*?)\}\}/g;for(const l of s.matchAll(u)){const d=l.index;if(d<c)continue;d>c&&a.push({...at("text"),text:s.slice(c,d)});const h=l[1].trim();if(h.startsWith("#if ")){const p=s.indexOf("{{/if}}",d+l[0].length);if(p<0)throw new Error("Unclosed condition.");a.push({...r(h.slice(4)),kind:"conditional",text:s.slice(d+l[0].length,p)}),c=p+7}else a.push(r(h)),c=d+l[0].length}return c<s.length&&a.push({...at("text"),text:s.slice(c)}),a},i={mode:"reference",parts:[at()],comparison:"",fields:[]};if(!e)return i;if(e.trim().startsWith("{"))try{const s=JSON.parse(e);if(s&&typeof s=="object"&&!Array.isArray(s)&&Object.values(s).every(a=>typeof a=="string"))return{...i,mode:"json",fields:Object.entries(s).map(([a,c])=>({key:a,parts:n(c)}))}}catch{}const o=n(e);if(o.length===2&&o[0].kind==="reference"&&o[1].kind==="text"){const s=t.createSourceFile("condition.ts",`value ${o[1].text}`,t.ScriptTarget.Latest,!0,t.ScriptKind.TS),a=s.statements[0];if(s.statements.length===1&&t.isExpressionStatement(a)&&t.isBinaryExpression(a.expression)&&a.expression.operatorToken.kind===t.SyntaxKind.EqualsEqualsToken&&t.isStringLiteral(a.expression.right))return{...i,mode:"condition",parts:[o[0]],comparison:a.expression.right.text}}return{...i,mode:o.length===1&&o[0].kind==="reference"?"reference":"template",parts:o}}function Kl({parts:e,references:t,onChange:r,disabled:n}){const i=(o,s)=>r(e.map((a,c)=>c===o?{...a,...s}:a));return f.jsxs("div",{style:{display:"grid",gap:12},children:[e.map((o,s)=>f.jsxs("fieldset",{"data-binding-part":s,style:{border:0,padding:0,margin:0,minWidth:0},children:[f.jsxs("legend",{children:["Part ",s+1]}),f.jsxs("div",{style:{display:"flex",gap:8},children:[f.jsxs("span",{"data-form-select":"",style:{flex:1},children:[f.jsxs("select",{"aria-label":"Part type",disabled:n,value:o.kind,onChange:a=>i(s,{kind:a.target.value}),children:[f.jsx("option",{value:"reference",children:"Reference"}),f.jsx("option",{value:"text",children:"Text"}),f.jsx("option",{value:"conditional",children:"Conditional text"})]}),f.jsx(K.PiCaretDown,{size:16,"aria-hidden":"true"})]}),f.jsx(Ce,{"aria-label":`Remove part ${s+1}`,title:"Remove part",icon:f.jsx(K.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>r(e.filter((a,c)=>c!==s))})]}),o.kind!=="text"&&f.jsxs(f.Fragment,{children:[o.paths.map((a,c)=>f.jsxs("label",{children:["Reference ",c+1,f.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[f.jsxs("select",{"aria-label":`Reference ${c+1}`,disabled:n,value:a,onChange:u=>i(s,{paths:o.paths.map((l,d)=>d===c?u.target.value:l)}),children:[f.jsx("option",{value:"",children:"Select reference"}),t.map(u=>f.jsx("option",{value:u.path,children:u.label},u.path))]}),f.jsx(K.PiCaretDown,{size:16,"aria-hidden":"true"})]})]},c)),o.kind==="reference"&&f.jsxs(f.Fragment,{children:[f.jsx(Ce,{"aria-label":"Add fallback reference",title:"Add fallback reference",icon:f.jsx(K.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>i(s,{paths:[...o.paths,""]})}),f.jsxs("label",{style:{display:"flex",gap:8,alignItems:"center"},children:[f.jsx("input",{type:"checkbox","aria-label":"Default value enabled",disabled:n,checked:o.fallback!==void 0,onChange:a=>i(s,{fallback:a.target.checked?"":void 0})}),"Default value"]}),o.fallback!==void 0&&f.jsx("input",{"aria-label":"Default value",disabled:n,value:o.fallback,onChange:a=>i(s,{fallback:a.target.value})})]})]}),o.kind!=="reference"&&f.jsxs("label",{children:["Text",f.jsx("textarea",{"aria-label":"Part text",disabled:n,value:o.text,onChange:a=>i(s,{text:a.target.value})})]})]},s)),f.jsx(Ce,{"aria-label":"Add part",title:"Add part",icon:f.jsx(K.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>r([...e,at()])})]})}function q0({label:e,value:t,references:r,disabled:n,onChange:i}){const[o,s]=_.useState(),[a,c]=_.useState(""),[u,l]=_.useState(!1),d=async()=>{l(!0),c("");try{s(await M0(typeof t=="string"?t:""))}catch(h){c(h instanceof Error?h.message:"Unable to read binding.")}finally{l(!1)}};return f.jsxs("div",{"data-runtime-binding":e,style:{marginBottom:8},children:[f.jsx(Ce,{"aria-label":`Bind ${e}`,title:`Bind ${e}`,icon:f.jsx(K.PiLink,{size:18}),size:"sm",variant:"ghost",disabled:n||u,onClick:d}),typeof t=="string"&&t.includes("{{")&&f.jsx("span",{children:"Bound value"}),o&&f.jsxs("fieldset",{disabled:n,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[f.jsxs("label",{children:["Binding mode",f.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[f.jsxs("select",{"aria-label":"Binding mode",value:o.mode,onChange:h=>s({...o,mode:h.target.value,parts:[at()]}),children:[f.jsx("option",{value:"reference",children:"Reference"}),f.jsx("option",{value:"condition",children:"Equals"}),f.jsx("option",{value:"template",children:"Text template"}),f.jsx("option",{value:"json",children:"JSON output"})]}),f.jsx(K.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),o.mode==="json"?f.jsxs(f.Fragment,{children:[o.fields.map((h,p)=>f.jsxs("fieldset",{"data-output-field":p,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[f.jsxs("label",{children:["Output field name",f.jsx("input",{"aria-label":"Output field name",value:h.key,onChange:y=>s({...o,fields:o.fields.map((m,g)=>g===p?{...m,key:y.target.value}:m)})})]}),f.jsx(Kl,{parts:h.parts,references:r,disabled:n,onChange:y=>s({...o,fields:o.fields.map((m,g)=>g===p?{...m,parts:y}:m)})}),f.jsx(Ce,{"aria-label":"Remove output field",title:"Remove output field",icon:f.jsx(K.PiTrash,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...o,fields:o.fields.filter((y,m)=>m!==p)})})]},p)),f.jsx(Ce,{"aria-label":"Add output field",title:"Add output field",icon:f.jsx(K.PiPlus,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...o,fields:[...o.fields,{key:"",parts:[at()]}]})})]}):f.jsx(Kl,{parts:o.parts,references:r,disabled:n,onChange:h=>s({...o,parts:h})}),o.mode==="condition"&&f.jsxs("label",{children:["Equals",f.jsx("input",{"aria-label":"Comparison value",value:o.comparison,onChange:h=>s({...o,comparison:h.target.value})})]}),f.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[f.jsx(Ce,{"aria-label":"Apply binding",title:"Apply binding",icon:f.jsx(K.PiCheck,{size:20}),size:"sm",variant:"ghost",onClick:()=>{try{i(O0(o,r)),s(void 0),c("")}catch(h){c(h instanceof Error?h.message:"Unable to apply binding.")}}}),f.jsx(Ce,{"aria-label":"Cancel binding",title:"Cancel binding",icon:f.jsx(K.PiX,{size:20}),size:"sm",variant:"ghost",onClick:()=>{s(void 0),c("")}})]})]}),a&&f.jsx("p",{role:"alert",children:a})]})}function $0({nodeAddress:e,onOpen:t}){const{structured:r,data:n,callbacks:i,editable:o,onFieldCreate:s}=_.useContext(Sr),a=Le(),[c,u]=_.useState(""),[l,d]=_.useState("0"),[h,p]=_.useState(""),y=r==null?void 0:r.containers.get(e);if(!y||!n||!r)return null;const m=a.readOnly||a.config.editable===!1||!o,g=ke(n,y.address),b=Hl(y.declared),w=y.type.kind==="array"?y.type.items:y.type.kind==="object"?y.type.additionalProperties:void 0,v=w?Hl(w):[],x=!!s&&y.type.kind==="object"&&(w==null?void 0:w.kind)==="json",C=A=>A.kind==="literal"?String(A.value):A.kind==="string"?"Text":Cr(A.kind),S=[...r.slots.values()].filter(A=>A.owner===e),k=(A,j)=>{var q;return(q=i.onFormChange)==null?void 0:q.call(i,{data:n,nodeAddress:y.address,address:A,previousValue:ke(n,A),value:j})},I=A=>{var j;a.setSelectedNodeIds([A]),(j=a.engineRef.current)==null||j.focusNode(A,90,!1)},R=(A,j)=>{if(!Array.isArray(g))return;const q=[...g];[q[A],q[A+j]]=[q[A+j],q[A]],k(y.address,q)},M=()=>{const A=v[Number(l)]??v[0];if(A)if(y.type.kind==="array")k(y.address,[...Array.isArray(g)?g:[],Vt(A)]);else{if(!c||c.includes(".")||c.startsWith("$")||["__proto__","constructor","prototype"].includes(c)){p("Choose a property name without dots or reserved prefixes.");return}if(Object.prototype.hasOwnProperty.call(g,c)){p("Property already exists.");return}x&&(l==="file"||l==="files")?s==null||s({data:n,nodeAddress:y.address,address:`${y.address}.${c}`,previousValue:void 0,value:l==="files"?[]:""},{$control:"upload"}):k(`${y.address}.${c}`,Vt(A)),u(""),p("")}},E=y.type.kind==="object"&&!!y.type.additionalProperties,P=y.type.kind==="array";return f.jsxs("div",{"data-structured-controls":"",style:{display:"grid",gap:8,minWidth:0},children:[b.length>1&&f.jsxs("label",{children:["Value type",f.jsx("span",{"data-form-select":"",style:{display:"block"},children:f.jsx(br,{"aria-label":"Value type",disabled:m,value:String(b.findIndex(A=>sn(A,g).kind===y.type.kind)),onValueChange:A=>k(y.address,Vt(b[Number(A)])),children:b.map((A,j)=>f.jsx("option",{value:j,children:C(A)},j))})})]}),S.map((A,j)=>f.jsxs("div",{"data-structured-slot":A.address,style:{display:"flex",gap:6,alignItems:"center",minWidth:0},children:[A.type.kind==="array"?f.jsx(K.PiListNumbers,{size:20}):f.jsx(K.PiBracketsCurly,{size:20}),f.jsx("span",{style:{flex:1,overflowWrap:"anywhere"},children:Cr(A.label)}),f.jsx(Ce,{"aria-label":`${A.present?t?"Edit":"Focus":"Create"} ${Cr(A.label)}`,title:`${A.present?t?"Edit":"Focus":"Create"} ${Cr(A.label)}`,icon:A.present?f.jsx(K.PiMagnifyingGlass,{size:18}):f.jsx(K.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:m&&!A.present,onClick:q=>{var O;A.present?t?t(A.nodeId):((O=q.currentTarget.closest("dialog"))==null||O.close(),I(A.nodeId)):k(A.address,Vt(A.type))}}),P&&f.jsxs(f.Fragment,{children:[f.jsx(Ce,{"aria-label":`Move item ${j+1} up`,icon:f.jsx(K.PiArrowUp,{size:18}),size:"sm",variant:"ghost",disabled:m||j===0,onClick:()=>R(j,-1)}),f.jsx(Ce,{"aria-label":`Move item ${j+1} down`,icon:f.jsx(K.PiArrowDown,{size:18}),size:"sm",variant:"ghost",disabled:m||j===S.length-1,onClick:()=>R(j,1)})]}),A.present&&f.jsx(Ce,{"aria-label":`Remove ${Cr(A.label)}`,icon:f.jsx(K.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:m,onClick:()=>P?k(y.address,g.filter((q,O)=>O!==j)):k(A.address,void 0)})]},A.address)),(P||E)&&f.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"end"},children:[E&&f.jsxs("label",{style:{flex:"1 1 120px",minWidth:0,display:"grid",gap:8},children:["Property name",f.jsx("input",{"aria-label":"Property name",placeholder:"Required",value:c,disabled:m,onChange:A=>u(A.target.value)})]}),v.length>1&&f.jsxs("label",{style:{flex:"1 1 100px",minWidth:0,display:"grid",gap:8},children:["New value type",f.jsx("span",{"data-form-select":"",style:{display:"block"},children:f.jsxs(br,{"aria-label":"New value type",value:l,disabled:m,onValueChange:d,children:[v.map((A,j)=>f.jsx("option",{value:j,children:C(A)},j)),x&&f.jsx("option",{value:"file",children:"File"}),x&&f.jsx("option",{value:"files",children:"Files"})]})})]}),f.jsx("span",{style:{display:"flex",alignItems:"center",flexShrink:0,...E||v.length>1?{height:"calc(1.4em + 20px)",fontSize:15,marginBottom:6}:{}},children:f.jsx(Ce,{"aria-label":P?"Add item":"Add property",icon:f.jsx(K.PiPlus,{size:20}),size:"sm",variant:"ghost",disabled:m,onClick:M})})]}),h&&f.jsx("p",{role:"alert",children:h})]})}const Sr=_.createContext({callbacks:{}}),Cn=Mn.default.div`
|
|
59
59
|
--flow-form-input-radius: 16px;
|
|
60
60
|
--flow-form-input-background: color-mix(
|
|
61
61
|
in srgb,
|
|
@@ -200,14 +200,15 @@
|
|
|
200
200
|
cursor: default;
|
|
201
201
|
opacity: 0.55;
|
|
202
202
|
}
|
|
203
|
+
&[role="alert"],
|
|
203
204
|
& [role="alert"] {
|
|
204
|
-
color:
|
|
205
|
+
color: ${({$colorMode:e})=>`var(--chakra-colors-red-${e==="dark"?"300":"500"})`};
|
|
205
206
|
font-size: 14px;
|
|
206
207
|
margin-top: 8px;
|
|
207
208
|
}
|
|
208
|
-
`;function Kl({request:e,property:t,config:r,value:n,disabled:i}){var le,ue,Ce,ye,Me;const{callbacks:o,structured:s,references:a}=_.useContext(Cr),{themeColor:c}=Ne(),{background:u}=Ze(),l=_.useId(),d=t.type.kind==="object"||t.type.kind==="array"||t.type.kind==="json",h=n===void 0?"":d?JSON.stringify(n,null,2):String(n),[p,y]=_.useState(h),[m,g]=_.useState(""),[b,w]=_.useState(0),v=_.useRef(null),x=_.useRef(),[C,S]=_.useState(!1),[E,I]=_.useState(!1),[A,M]=_.useState(),j=((le=r.$options)==null?void 0:le.$source)==="callback",R=o.resolveFormOptions,{data:P,address:k,nodeAddress:q,nodeId:O}=e;_.useEffect(()=>(S(!1),I(!1),()=>{var ee;(ee=x.current)==null||ee.abort(),x.current=void 0}),[k,q,O,i,h,r.$control,(ue=r.$upload)==null?void 0:ue.accept,(Ce=r.$upload)==null?void 0:Ce.maxSizeBytes]);const z=_.useRef(P);z.current=P;const U=JSON.stringify([k,O,(ye=r.$options)!=null&&ye.$dependsOn?r.$options.$dependsOn.map(ee=>Re(P,ee)):Re(P,q)]);_.useEffect(()=>{y(h),g("")},[h,k,O]),_.useEffect(()=>{if(!j)return;const ee=new AbortController;return Promise.resolve().then(()=>{if(!R)throw new Error("No options resolver configured");return R({address:k,nodeAddress:q,nodeId:O,data:jt(z.current),signal:ee.signal})}).then(he=>{if(!Array.isArray(he)||he.some(ve=>!ve||typeof ve.label!="string"||!["string","number","boolean"].includes(typeof ve.value)&&ve.value!==null))throw new Error("Invalid options response");ee.signal.aborted||M({key:U,options:he})}).catch(he=>{ee.signal.aborted||M({key:U,options:[],error:he instanceof Error?he.message:"Options unavailable"})}),()=>ee.abort()},[j,R,U,k,q,O,b]);const se=j&&(A==null?void 0:A.key)!==U,Q=j?(A==null?void 0:A.key)===U?A.options:[]:t.type.kind==="null"?[{label:"Null",value:null}]:t.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:Xt(t.type),Y=t.type.kind==="array",ge=(r.$control==="upload"?"upload":s&&d||r.$control==="checkbox"?"pills":r.$control)??(Q?Y||t.type.kind==="boolean"?"pills":"select":t.type.kind==="boolean"?"checkbox":d?"textarea":"input"),ce=!t.optional||!!r.$requiredWhen&&Ln(r.$requiredWhen,P),$=ce?"Required":"Optional",V=ge!=="upload"&&!!(a!=null&&a.length)&&typeof n=="string"&&n.includes("{{"),W=m||j&&(A==null?void 0:A.key)===U&&A.error||!V&&Rr(t.type,n,ce),N=wr(r.$label??k.split(".").pop()),ne=ee=>{var he;if(!(i||Object.is(ee,n)))try{(he=o.onFormChange)==null||he.call(o,{...e,previousValue:n,value:ee}),g("")}catch(ve){g(ve instanceof Error?ve.message:"Unable to update field")}},be=_.useRef(ne);_.useLayoutEffect(()=>{be.current=ne});const fe=()=>{if(d){try{const je=p===""&&t.optional?void 0:JSON.parse(p),qe=Rr(t.type,je,ce);if(qe){g(qe);return}ne(je)}catch{g("Enter valid JSON")}return}const ee=t.type.kind==="number"||t.type.kind==="integer",he=p===""&&t.optional?void 0:ee&&p!==""?Number(p):p,ve=Rr(t.type,he,ce);if(ee&&ve&&p!==""){g(ve);return}ne(he)},J=async ee=>{var ve,je,qe;if(i||x.current||!ee.length)return;const he=new AbortController;x.current=he,g(""),S(!0);try{if(t.type.kind!=="string"&&!(t.type.kind==="array"&&t.type.items.kind==="string"))throw new Error("Uploads require a string or string-array field.");if(!Y&&ee.length!==1)throw new Error("Choose one file for this field.");if(!o.uploadFormFile)throw new Error("No file upload handler configured.");const We=(je=(ve=r.$upload)==null?void 0:ve.accept)==null?void 0:je.split(",").map(Ae=>Ae.trim().toLowerCase()).filter(Boolean);for(const Ae of ee){if(((qe=r.$upload)==null?void 0:qe.maxSizeBytes)!==void 0&&Ae.size>r.$upload.maxSizeBytes)throw new Error(`${Ae.name} exceeds the file size limit.`);if(We!=null&&We.length&&!We.some(me=>me.startsWith(".")?Ae.name.toLowerCase().endsWith(me):me.endsWith("/*")?Ae.type.toLowerCase().startsWith(me.slice(0,-1)):Ae.type.toLowerCase()===me))throw new Error(`${Ae.name} is not an accepted file type.`)}const Ye=await Promise.all(ee.map(async Ae=>{const me=await o.uploadFormFile({...e,data:jt(P),file:Ae,signal:he.signal});if(typeof me!="string")throw new Error("Upload handler must return an HTTP or HTTPS URL.");let Oe;try{Oe=new URL(me)}catch{throw new Error("Upload handler must return an HTTP or HTTPS URL.")}if(!["http:","https:"].includes(Oe.protocol)||Oe.username||Oe.password)throw new Error("Upload handler must return an HTTP or HTTPS URL.");return me}));if(he.signal.aborted||x.current!==he)return;const tr=Y?[...Array.isArray(n)?n:[],...Ye]:Ye[0],sr=Rr(t.type,tr,ce);if(sr)throw new Error(sr);be.current(tr)}catch(We){he.signal.aborted||g(We instanceof Error?We.message:"Unable to upload file."),he.abort()}finally{x.current===he&&(x.current=void 0,S(!1))}},te={id:l,disabled:i,"aria-label":N,"aria-required":ce,"aria-invalid":!!W,"aria-describedby":W?`${l}-error`:void 0},G=xe(c);return f.jsxs("div",{"data-form-field":k,"data-flow-property":k.slice(q.length+1),children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[f.jsxs("label",{htmlFor:l,children:[N,ce?" *":""]}),t.optional&&n!==void 0&&f.jsx("button",{type:"button","aria-label":`Reset ${N}`,title:`Reset ${N}`,disabled:i||C,style:{width:24,height:24,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:0,background:"transparent",color:"inherit"},onClick:()=>ne(void 0),children:f.jsx(K.PiArrowCounterClockwise,{size:14})})]}),!!(a!=null&&a.length)&&!d&&ge!=="upload"&&f.jsx(O0,{label:N,value:n,references:a,disabled:i,onChange:ne}),ge==="upload"?f.jsxs("div",{"data-form-upload":Y?"multiple":"single","aria-busy":C,style:{"--flow-upload-surface":xe(u),outline:E?"2px dashed var(--flow-form-input-background)":void 0,borderRadius:"var(--flow-form-input-radius)"},onDragOver:ee=>{ee.preventDefault(),ee.stopPropagation(),!i&&!C&&(ee.dataTransfer.dropEffect="copy",I(!0))},onDragLeave:ee=>{ee.currentTarget.contains(ee.relatedTarget)||I(!1)},onDrop:ee=>{ee.preventDefault(),ee.stopPropagation(),I(!1),J(Array.from(ee.dataTransfer.files))},children:[f.jsx("input",{ref:v,type:"file",hidden:!0,"aria-label":`Upload ${N}`,accept:(Me=r.$upload)==null?void 0:Me.accept,multiple:Y,disabled:i||C,onChange:ee=>{const he=Array.from(ee.target.files??[]);ee.target.value="",J(he)}}),f.jsxs("div",{"data-upload-items":"",children:[(Y?Array.isArray(n)?n:[]:n?[n]:[]).map((ee,he)=>f.jsxs("div",{"data-upload-preview":"",children:[typeof ee=="string"&&Vr(ee)&&f.jsxs("a",{href:ee,target:"_blank",rel:"noopener noreferrer","aria-label":`${N} file ${he+1}`,children:[f.jsx(K.PiFile,{size:32,"aria-hidden":"true"}),f.jsx(Or,{name:ee,size:120,onError:ve=>{ve.currentTarget.style.visibility="hidden"}})]}),f.jsxs("div",{"data-upload-actions":"",children:[!Y&&f.jsx(Se,{"aria-label":`Replace ${N}`,title:`Replace ${N}`,icon:f.jsx(K.PiUploadSimple,{}),size:"xs",variant:"ghost",disabled:i||C,onClick:()=>{var ve;return(ve=v.current)==null?void 0:ve.click()}}),f.jsx(Se,{"aria-label":`Remove ${N} file ${he+1}`,title:"Remove file",icon:f.jsx(K.PiTrash,{}),size:"xs",variant:"ghost",disabled:i||C,onClick:()=>ne(Y&&Array.isArray(n)?n.filter((ve,je)=>je!==he):"")})]})]},`${he}:${ee}`)),(Y||!n)&&f.jsx("button",{...te,type:"button","data-upload-drop":"",title:`Upload ${N}`,disabled:i||C,onClick:()=>{var ee;return(ee=v.current)==null?void 0:ee.click()},children:f.jsx(K.PiPlus,{size:28,"aria-hidden":"true"})})]}),C&&f.jsx("span",{role:"status",children:"Uploading..."})]}):V?null:ge==="select"?f.jsx("div",{"data-form-select":"",children:f.jsxs(mr,{...te,disabled:i||se||!!(A!=null&&A.error),labelCase:"preserve",value:String((Q==null?void 0:Q.findIndex(ee=>Object.is(ee.value,n)))??-1),onValueChange:ee=>{const he=Q==null?void 0:Q[Number(ee)];he&&ne(he.value)},children:[f.jsx("option",{value:-1,disabled:!0,children:n!==void 0&&n!==""?String(n):$}),Q==null?void 0:Q.map((ee,he)=>f.jsx("option",{value:he,children:wr(ee.label)||ee.label},he))]})}):ge==="pills"?f.jsxs("div",{id:l,role:"group","aria-label":N,"aria-describedby":te["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[Q==null?void 0:Q.map((ee,he)=>{const ve=Y?Array.isArray(n)&&n.includes(ee.value):Object.is(n,ee.value);return f.jsx("button",{type:"button",disabled:i||se,"aria-pressed":ve,style:{padding:"8px 16px",borderRadius:24,border:0,color:ve?G:"inherit",background:ve?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>ne(Y?ve?n.filter(je=>je!==ee.value):[...Array.isArray(n)?n:[],ee.value]:ee.value),children:wr(ee.label)||ee.label},he)}),se&&f.jsx("span",{role:"status",children:"Loading..."})]}):ge==="textarea"?f.jsx("textarea",{...te,placeholder:$,value:p,onChange:ee=>y(ee.target.value),onBlur:fe}):f.jsx("input",{...te,placeholder:$,type:t.type.kind==="number"||t.type.kind==="integer"?"number":"text",step:t.type.kind==="integer"?1:"any",value:p,onChange:ee=>y(ee.target.value),onBlur:fe,onKeyDown:ee=>{ee.key==="Enter"&&fe(),ee.key==="Escape"&&y(n===void 0?"":String(n))}}),W&&f.jsx("div",{role:"alert",id:`${l}-error`,children:W}),j&&(A==null?void 0:A.error)&&f.jsx("button",{type:"button",disabled:i,onClick:()=>{M(void 0),w(b+1)},children:"Retry"})]})}function Rm({nodeAddress:e,structured:t=!1}){return t?f.jsx(q0,{nodeAddress:e},e):f.jsx(Nu,{nodeAddress:e})}function q0({nodeAddress:e}){var d,h,p;const t=_.useContext(Cr),[r,n]=_.useState([]),i=((d=t.structured)==null?void 0:d.sourceSchema)??t.schema,o=((h=t.structured)==null?void 0:h.sourceBindings)??t.bindings,s=_.useMemo(()=>{if(!(!t.data||!i||!o))return jm(t.data,o,i,[{data:{id:e,type:"objectView"}}])},[t.data,o,i,e]);if(!s)return f.jsx(Nu,{nodeAddress:e});const a=r.findIndex(y=>!s.containers.has(y)),c=a<0?r:r.slice(0,a),u=c.at(-1)??e,l=(p=[...s.slots.values()].find(y=>y.nodeId===u))==null?void 0:p.label;return f.jsxs(Cr.Provider,{value:{...t,structured:s,schema:s.schema,bindings:s.bindings,renderForm:void 0,onFieldCreate:u===e?t.onFieldCreate:void 0},children:[!!c.length&&f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[f.jsx(Se,{"aria-label":"Back to parent fields",title:"Back to parent fields",icon:f.jsx(K.PiArrowLeft,{size:18}),size:"sm",variant:"ghost",onClick:()=>n(c.slice(0,-1))}),f.jsx("strong",{style:{minWidth:0,overflowWrap:"anywhere"},children:wr(l)})]}),f.jsx(Nu,{nodeAddress:u,onOpen:y=>n([...c,y])},u)]})}function Nu({nodeAddress:e,onOpen:t}){var C,S;const{data:r,schema:n,callbacks:i,bindings:o,editable:s,renderForm:a,structured:c}=_.useContext(Cr),{readOnly:u,config:l}=Ne(),d=a==null?void 0:a(e);if(d!==void 0)return f.jsx("fieldset",{"data-flow-form":e,disabled:u||l.editable===!1||!s,style:{border:0,margin:0,padding:0,minWidth:0},children:d});if(!r)return f.jsx(wn,{role:"alert",children:"Forms require a JSON document."});const h=o?dn(o,e,n):void 0,p=o?h:n&&Tt(r,e,n);if(!p)return f.jsx(wn,{role:"status",children:"Form schema unavailable."});const y=(h==null?void 0:h.address)??e,m=Re(r,y),g=(C=c==null?void 0:c.containers.get(e))==null?void 0:C.scalar;if(m===void 0||typeof m!="object"&&!g)return f.jsx(wn,{role:"alert",children:"Bound form state is unavailable."});const b=Object.entries(p.type.properties).filter(([E])=>{var I;return Ln((I=p.fields[E])==null?void 0:I.$visibleWhen,r)}),w=b.length>8||b.some(([E])=>{var I;return(I=p.fields[E])==null?void 0:I.$section}),v=new Map;for(const E of b){const[I,A]=E,M=w?wr(((S=p.fields[I])==null?void 0:S.$section)??(A.type.kind==="object"||A.type.kind==="array"?I:A.optional?"Options":"General")):"";v.has(M)||v.set(M,[]),v.get(M).push(E)}const x=([E,I])=>f.jsx(Kl,{request:{data:r,address:g?y:`${y}.${E}`,nodeAddress:y,nodeId:typeof(m==null?void 0:m.id)=="string"?m.id:void 0},property:I,config:p.fields[E]??{},value:g?m:m==null?void 0:m[E],disabled:u||l.editable===!1||!(s??!!i.onJsonChange)},`${(m==null?void 0:m.id)??e}:${E}`);return f.jsxs(wn,{"data-flow-form":e,onClick:E=>E.stopPropagation(),onDoubleClick:E=>E.stopPropagation(),children:[c&&f.jsx(M0,{nodeAddress:e,onOpen:t}),!c&&h&&p.type.additionalProperties&&b.length===0&&f.jsx(Kl,{request:{data:r,address:y,nodeAddress:y},property:{type:p.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:m,disabled:u||l.editable===!1||!s}),[...v].map(([E,I])=>w&&I.length>1?f.jsxs("details",{open:!0,children:[f.jsxs("summary",{children:[f.jsx("span",{children:E}),f.jsx(K.PiCaretDown,{size:16,"aria-hidden":"true"})]}),I.map(x)]},E):I.map(x))]})}function Pm(e){const{viewData:t}=_.useContext(Cr),{nodeById:r,edgeById:n,parentIds:i}=Yr();if(t){const o=Re(t,e),s=o&&typeof o=="object"&&!Array.isArray(o)&&"$"in o?o.$:o;return Array.isArray(s)?s.length>0:!!s&&typeof s=="object"&&Object.entries(s).some(([a,c])=>!a.startsWith("$")&&c!==null&&typeof c=="object")}return i.has(e)?!0:[...n.values()].some(({data:o})=>{const s=o.isInverted?o.target:o.source,a=o.isInverted?o.source:o.target;return s===e&&a!==e&&r.has(a)})}function cn(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:t}function Pn(e,t,r,n){return{borderColor:t,borderWidth:cn(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...Fy(t==="transparent"?"currentColor":t,r,".flow-sdk-node:hover &",!r)}}function Am({label:e,value:t,options:r,onChange:n,disabled:i}){var o;return f.jsxs(mr,{"aria-label":e,title:`Animation: ${((o=r.find(s=>s.value===t))==null?void 0:o.label)??"Mixed"}`,value:t,style:{width:104},disabled:i,onValueChange:s=>{const a=r.find(c=>c.value===s);a&&n(a.value)},children:[t===""&&f.jsx("option",{value:"",disabled:!0,children:"Mixed"}),r.map(s=>f.jsx("option",{value:s.value,children:s.label},s.value))]})}function el({nodeId:e,edgeId:t,value:r,open:n,onOpenChange:i}){const{callbacks:o,readOnly:s,themeColor:a,colorMode:c}=Ne(),{background:u,backgroundSecondary:l,border:d,colorText:h,colorInactive:p}=Ze(),y=c==="dark"?Pt:xe(p),m=_.useRef(null),g=_.useRef(null),b=_.useRef(0),[w,v]=_.useState(!1),[x,C]=_.useState("icons"),[S,E]=_.useState([]),[I,A]=_.useState("loading"),[M,j]=_.useState(""),[R,P]=_.useState(0),[k,q]=_.useState(""),[O,z]=_.useState(""),[U,se]=_.useState(!1);_.useEffect(()=>()=>{b.current++},[]),_.useEffect(()=>{if(!w)return;let N=!0;return import("react-icons/pi").then(ne=>{N&&(E(Object.keys(ne).filter(be=>be.startsWith("Pi")).sort()),A("ready"))}).catch(()=>{N&&A("unavailable")}),()=>{N=!1}},[w]),_.useEffect(()=>{var N;s&&((N=m.current)==null||N.close())},[s]),_.useEffect(()=>{var N,ne,be;if(n!==void 0){if(!n||s){(N=m.current)==null||N.close();return}(ne=m.current)!=null&&ne.open||(z(""),C(r==="PiFileSvg"||r&&Vr(r)?"custom":"icons"),q(r&&!r.startsWith(Qt)&&Vr(r)?r:""),v(!0),(be=m.current)==null||be.showModal())}},[n,s,r]);const Q=N=>{var ne,be,fe;s||(t?(ne=o.onEdgeIconChange)==null||ne.call(o,t,N):e&&((be=o.onNodeIconChange)==null||be.call(o,e,N)),i==null||i(!1),(fe=m.current)==null||fe.close())},Y=S.filter(N=>N.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(M.trim().toLowerCase())),ge=36,ce=Math.max(1,Math.ceil(Y.length/ge)),$=Math.min(R,ce-1),V=Y.slice($*ge,($+1)*ge),W={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${xe(d)}`,borderRadius:30};return f.jsxs(f.Fragment,{children:[n===void 0&&f.jsx(Ie,{label:t?"Choose edge icon":"Choose node icon",children:f.jsx(Se,{"aria-label":t?"Choose edge icon":"Choose node icon",icon:f.jsx(K.PiShapes,{size:20}),size:"sm",variant:"ghost",color:xe(a),disabled:s,onClick:()=>{var N;z(""),C(r&&Vr(r)?"custom":"icons"),q(r&&!r.startsWith(Qt)&&Vr(r)?r:""),v(!0),(N=m.current)==null||N.showModal()}})}),f.jsx(F.chakra.dialog,{ref:m,"aria-label":t?"Choose edge icon":"Choose node icon",css:Hr(xe(u),xe(d)),onClose:()=>{v(!1),i==null||i(!1),b.current++,se(!1)},onClick:N=>{N.stopPropagation(),N.target===N.currentTarget&&N.currentTarget.close()},onKeyDown:N=>N.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",borderRadius:30,background:xe(u),color:xe(h)},children:w&&f.jsxs("div",{style:{display:"grid",gap:8},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsx("strong",{children:t?"Edge icon":"Node icon"}),f.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[r&&f.jsx(Ie,{label:"Remove icon",children:f.jsx(Se,{"aria-label":t?"Remove edge icon":"Remove node icon",icon:f.jsx(K.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:s||U,onClick:()=>Q("")})}),f.jsx(At,{"aria-label":"Close icon picker",onClick:()=>{var N;return(N=m.current)==null?void 0:N.close()}})]})]}),f.jsxs(F.Tabs.Root,{value:x,onValueChange:({value:N})=>{C(N),z("")},display:"contents",css:{"--indicator-thickness":"1px"},children:[f.jsx(F.Tabs.List,{"aria-label":"Icon source",width:"100%",borderBottomWidth:0,children:["icons","custom"].map(N=>f.jsx(F.Tabs.Trigger,{value:N,flex:1,minW:0,justifyContent:"center",px:3,py:2,fontSize:"13px",_selected:{color:a,borderColor:y,"--indicator-color":y},children:N==="icons"?"React icons":"Custom SVG"},N))}),f.jsx("input",{ref:g,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:U||s,onChange:async N=>{var fe;const ne=(fe=N.target.files)==null?void 0:fe[0];if(N.target.value="",!ne)return;const be=++b.current;se(!0),z("");try{const J=await E0(ne);be===b.current&&Q(J)}catch(J){be===b.current&&z(J instanceof Error?J.message:"Unable to read SVG.")}finally{be===b.current&&se(!1)}}}),f.jsx(F.Tabs.Content,{value:x,p:0,style:{display:"grid",gap:8},children:x==="icons"?f.jsxs(f.Fragment,{children:[f.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:M,onChange:N=>{j(N.target.value),P(0)},style:W}),f.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[V.map(N=>f.jsx("button",{type:"button","aria-label":`Choose ${N}`,"aria-pressed":r===N,title:N,onClick:()=>Q(N),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${r===N?2:1}px solid ${xe(r===N?a:d)}`,background:xe(r===N?u:l),color:"inherit",cursor:"pointer"},children:f.jsx(Or,{name:N,size:24})},N)),V.length===0&&f.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:I==="loading"?"Loading icons...":I==="unavailable"?"React icons unavailable":"No icons found"})]}),f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsxs("span",{role:"status",style:{fontSize:12},children:[Y.length," icons · ",$+1," / ",ce]}),f.jsxs("div",{style:{display:"flex",gap:4},children:[f.jsx(Ie,{label:"Previous icons",children:f.jsx(Se,{"aria-label":"Previous icons",icon:f.jsx(K.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:$===0,onClick:()=>P($-1)})}),f.jsx(Ie,{label:"Next icons",children:f.jsx(Se,{"aria-label":"Next icons",icon:f.jsx(K.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:$+1>=ce,onClick:()=>P($+1)})})]})]})]}):f.jsxs(f.Fragment,{children:[r&&Vr(r)&&f.jsx(Or,{name:r,size:64}),f.jsxs("button",{type:"button",disabled:U||s,onClick:()=>{var N;return(N=g.current)==null?void 0:N.click()},style:{...W,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[f.jsx(K.PiUploadSimple,{}),U?"Uploading...":"Upload SVG"]}),f.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:N=>{N.preventDefault(),!(U||s)&&(!Vr(k.trim())||k.trim().startsWith(Qt)?z("Enter an HTTP or HTTPS image URL."):Q(k.trim()))},children:[f.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:k,disabled:U||s,onChange:N=>q(N.target.value),style:{...W,flex:1,minWidth:0}}),f.jsx(Ie,{label:"Apply URL",children:f.jsx(Se,{type:"submit","aria-label":"Apply URL",icon:f.jsx(K.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:U||s||!k.trim(),style:{flexShrink:0}})})]})]})})]}),O&&f.jsx("div",{role:"alert",style:{fontSize:13},children:O})]})})]})}const An=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500",Pt],Tm=["gray.900",Pt,"gray.600","gray.200","white"];function Im(){const{config:e}=Ne(),t=e.selectionToolbar||{},r=new Set(t.hide||[]);return{palette:t.palette||An,show:n=>!r.has(n)}}function pr(){const{border:e}=Ze();return f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:e})}function ct({value:e,placeholder:t,ariaLabel:r,width:n="140px",type:i="text",min:o,onCommit:s}){const{colorText:a}=Ze(),[c,u]=_.useState(e),l=_.useRef(!1);_.useEffect(()=>u(e),[e]);const d=()=>{if(l.current)return;l.current=!0;const h=c.trim();if(i==="number"&&h!==""&&(!Number.isFinite(Number(h))||Number(h)<(o??0))){u(e);return}h!==e&&s(h)};return f.jsx(F.Input,{"aria-label":r,type:i,min:o,size:"xs",fontSize:"16px",w:n,value:c,placeholder:t,color:a,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{l.current=!1},onChange:h=>u(h.target.value),onBlur:d,onKeyDown:h=>{h.key==="Enter"&&(d(),h.target.blur()),h.key==="Escape"&&(l.current=!0,u(e),h.target.blur())}})}function ut({colors:e,value:t,label:r,onPick:n,onReset:i,includeTransparent:o=!0}){const{colorInactive:s,colorText:a}=Ze(),[c,u]=_.useState(!1),l=_.useId(),d=_.useRef(null),h=t??e[0]??"transparent",p=Mn(f.jsx(ut,{colors:e,value:t,label:r,onPick:n,onReset:i,includeTransparent:o}));return f.jsx(Et.Provider,{value:null,children:f.jsxs(F.HStack,{gap:1,"aria-label":r,role:"group",onClickCapture:p,onKeyDown:y=>{var m;y.key==="Escape"&&(u(!1),(m=d.current)==null||m.focus())},children:[f.jsx(Ie,{label:`${r}: ${h}`,children:f.jsx(F.chakra.button,{ref:d,type:"button","aria-label":`${r} colors`,"aria-expanded":c,"aria-controls":l,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:xe(h),...h==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${xe(a)}`,outlineOffset:"1px",onClick:()=>u(y=>!y)})}),c&&f.jsxs(F.HStack,{id:l,gap:1,children:[[...new Set([...e,...o?["transparent"]:[]])].map(y=>{const m=t===y;return f.jsx(Ie,{label:`${r}: ${y}`,children:f.jsx(F.Box,{as:"button","aria-label":`${r} ${y}`,"aria-pressed":m,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:xe(y),...y==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:m?`2px solid ${xe(a)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(y),onDoubleClick:g=>{var b;g.stopPropagation(),u(!1),(b=d.current)==null||b.focus()}})},y)}),i&&f.jsx(Ie,{label:`Reset ${r.toLowerCase()}`,children:f.jsx(Se,{"aria-label":`Reset ${r}`,icon:f.jsx(F.Icon,{as:K.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:s,onClick:()=>{var y;i(),u(!1),(y=d.current)==null||y.focus()}})})]})]})})}function Om({edgeId:e,onClose:t}){var p;const{callbacks:r,themeColor:n,config:i}=Ne(),{colorInactive:o}=Ze(),{edgeById:s}=Yr(),{palette:a,show:c}=Im(),u=(p=s.get(e))==null?void 0:p.data,l=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(i.customEdgeTypes??{}),...u!=null&&u.type?[u.type]:[]])],d=u!=null&&u.isEdgeAnimated?"animated":u!=null&&u.isEdgeDashed?"dashed":"solid",h=[{key:"solid",icon:K.PiLineSegment,label:"Solid"},{key:"dashed",icon:K.PiLineSegments,label:"Dashed"},{key:"animated",icon:K.PiFastForward,label:"Animated"}];return f.jsxs(f.Fragment,{children:[f.jsx(At,{onClick:t}),c("label")&&f.jsxs(f.Fragment,{children:[f.jsx(pr,{}),f.jsx(ct,{ariaLabel:"Edge label",placeholder:"Edge label",value:(u==null?void 0:u.label)||"",onCommit:y=>{var m;return(m=r.onEdgeLabelChange)==null?void 0:m.call(r,e,y)}})]}),c("style")&&f.jsxs(f.Fragment,{children:[f.jsx(pr,{}),h.map(y=>f.jsx(Ie,{label:y.label,children:f.jsx(Se,{"aria-label":`Edge style ${y.key}`,"aria-pressed":d===y.key,icon:f.jsx(F.Icon,{as:y.icon,boxSize:5}),size:"sm",variant:"ghost",color:d===y.key?n:o,onClick:()=>{var m;return(m=r.onEdgeStyleChange)==null?void 0:m.call(r,e,y.key)}})},y.key)),d==="animated"&&f.jsx(Am,{label:"Edge animation",value:(u==null?void 0:u.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:i.readOnly,onChange:y=>{var m;return(m=r.onEdgeAnimationVariantChange)==null?void 0:m.call(r,e,y)}}),f.jsxs(mr,{"aria-label":"Edge shape",title:`Edge shape: ${(u==null?void 0:u.type)??"Default"}`,icon:f.jsx(K.PiBezierCurve,{size:20}),style:{width:36},value:(u==null?void 0:u.type)??"",disabled:i.readOnly,onValueChange:y=>{var m;return(m=r.onEdgeTypeChange)==null?void 0:m.call(r,e,y||void 0)},children:[f.jsx("option",{value:"",children:"Default"}),l.map(y=>f.jsx("option",{value:y,children:y},y))]})]}),c("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(pr,{}),f.jsx(el,{edgeId:e,value:u==null?void 0:u.icon},e),f.jsx(ct,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(u==null?void 0:u.icon)??"",onCommit:y=>{var m;return(m=r.onEdgeIconChange)==null?void 0:m.call(r,e,y)}})]}),c("color")&&f.jsxs(f.Fragment,{children:[f.jsx(pr,{}),f.jsx(ut,{label:"Edge color",colors:a,value:u==null?void 0:u.color,onPick:y=>{var m;return(m=r.onEdgeColorChange)==null?void 0:m.call(r,e,y)},onReset:()=>{var y;return(y=r.onEdgeColorChange)==null?void 0:y.call(r,e,"")}})]}),c("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(pr,{}),f.jsx(Ie,{label:"Delete edge",children:f.jsx(Se,{"aria-label":"Delete edge",icon:f.jsx(F.Icon,{as:K.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var y;(y=r.onEdgeDelete)==null||y.call(r,e,u),t()}})})]})]})}function Mm({ids:e,showDivider:t=!0}){const{callbacks:r,config:n}=Ne(),{colorInactive:i}=Ze(),{nodeById:o}=Yr(),[s,a]=_.useState(!1),c=e.map(y=>{var m,g;return(g=(m=o.get(y))==null?void 0:m.data.viewProps)==null?void 0:g.borderRadius}),u=!c.every(y=>y===c[0]),l=u?"mixed":String(c[0]??""),d=["0","8","16","30","53","100"],h=s||!u&&l!==""&&!d.includes(l),p=y=>e.forEach(m=>{var g;return(g=r.onNodeBorderRadiusChange)==null?void 0:g.call(r,m,y)});return f.jsxs(f.Fragment,{children:[t&&f.jsx(pr,{}),f.jsx(F.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:f.jsxs(mr,{icon:f.jsx(F.Icon,{as:jv.TbBorderRadius,boxSize:5,color:i,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${u?"Mixed":c[0]===void 0?"Default":`${c[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:h?"custom":l,disabled:n.readOnly,onValueChange:y=>{a(y==="custom"),y!=="custom"&&p(y===""?void 0:Number(y))},children:[f.jsx("option",{value:"",children:"Default radius"}),u&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed radii"}),d.map(y=>f.jsxs("option",{value:y,children:[y,"px radius"]},y)),f.jsx("option",{value:"custom",children:"Custom radius"})]})}),h&&f.jsx(ct,{ariaLabel:"Custom border radius",placeholder:u?"Mixed":"Auto",type:"number",min:0,width:"72px",value:u?"":l,onCommit:y=>p(y===""?void 0:Number(y))})]})}function qm({ids:e,onClose:t}){var ce,$,V,W,N,ne,be,fe;const{callbacks:r,colorMode:n,themeColor:i,config:o,setNodeViewMode:s}=Ne(),{colorText:a,colorInactive:c}=Ze(),{nodeById:u,parentIds:l}=Yr(),{palette:d,show:h}=Im(),p=e.length===1,y=p?(ce=u.get(e[0]))==null?void 0:ce.data:void 0,m=e.map(J=>{var te,G;return((G=(te=u.get(J))==null?void 0:te.data.config)==null?void 0:G.typeView)??""}),g=m.some(J=>J!==m[0]),b=g?"mixed":m[0]??"",w=e.some(J=>{var G,le;const te=(G=u.get(J))==null?void 0:G.data;return te&&(l.has(J)||((le=te.config)==null?void 0:le.parentContainer)||Object.prototype.hasOwnProperty.call(o.customViews??{},te.type))}),v=($=y==null?void 0:y.config)==null?void 0:$.collapsed,x=Pm(e[0]),C=J=>{var te,G,le;return(((G=(te=u.get(J))==null?void 0:te.data.viewProps)==null?void 0:G.outline)??(l.has(J)?(le=o.parentNodeStyle)==null?void 0:le.outline:!1))===!0},S=e.every(C),E=!S&&e.some(C),I=J=>{var te;return((te=u.get(J))==null?void 0:te.data.isNodeAnimated)===!0},A=e.every(I),M=!A&&e.some(I),j=e.map(J=>{var te;return((te=u.get(J))==null?void 0:te.data.nodeAnimationVariant)??"traveling"}),R=j.every(J=>J===j[0])?j[0]:"",P=J=>e.forEach(J),[k,q]=_.useState(!1),O=k&&h("color")&&h("borderColor"),z=J=>{var te,G,le;return(((G=(te=u.get(J))==null?void 0:te.data.viewProps)==null?void 0:G.borderStyle)??(l.has(J)?(le=o.parentNodeStyle)==null?void 0:le.borderStyle:"solid"))==="dashed"},U=e.every(z),se=!U&&e.some(z),Q=e.map(J=>{var le,ue,Ce;const te=(le=u.get(J))==null?void 0:le.data,G=l.has(J)?cn((ue=o.parentNodeStyle)==null?void 0:ue.borderWidth,6):(te==null?void 0:te.type)==="objectView"?3:2;return cn((Ce=te==null?void 0:te.viewProps)==null?void 0:Ce.borderWidth,G)}),Y=Q.every(J=>J===Q[0])?String(Q[0]??""):"",ge=J=>P(te=>{var G,le;O?(G=r.onNodeBorderColorChange)==null||G.call(r,te,J):(le=r.onNodeColorChange)==null||le.call(r,te,"bg",J)});return f.jsxs(f.Fragment,{children:[f.jsx(At,{onClick:t}),f.jsx(pr,{}),p&&h("label")?f.jsx(ct,{ariaLabel:"Node label",placeholder:"Node label",value:(y==null?void 0:y.label)??(y==null?void 0:y.headerTitle)??"",onCommit:J=>{var te;return(te=r.onNodeLabelChange)==null?void 0:te.call(r,e[0],J)}}):f.jsxs(F.Text,{fontSize:"xs",color:a,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),h("typeView")&&f.jsxs(mr,{"aria-label":"Type view",title:w?"Type view is managed by the custom renderer or container":`Type view: ${b||"None (default)"}`,icon:f.jsx(K.PiImage,{size:20}),style:{width:36},value:b,disabled:o.readOnly||o.editable===!1||w,onValueChange:J=>{nn.includes(J)&&P(te=>{var G,le;(G=r.onNodeTypeViewChange)==null||G.call(r,te,J||void 0),s(te,"default"),(le=r.onNodeViewToggle)==null||le.call(r,te)})},children:[g&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),nn.map(J=>f.jsx("option",{value:J,children:J||"None"},J))]}),h("style")&&f.jsx(Mm,{ids:e},e.join("\0")),h("outline")&&f.jsxs(f.Fragment,{children:[f.jsx(pr,{}),f.jsx(Ie,{label:S?"Restore node fill":"Remove node fill",children:f.jsx(Se,{"aria-label":"Toggle node outline","aria-pressed":E?"mixed":S,icon:f.jsx(F.Icon,{as:S?K.PiSquare:K.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:S?i:c,onClick:()=>P(J=>{var te;return(te=r.onNodeOutlineChange)==null?void 0:te.call(r,J,!S)})})})]}),h("color")&&f.jsxs(f.Fragment,{children:[f.jsx(pr,{}),h("borderColor")&&f.jsx(Ie,{label:O?"Edit node colors":"Edit node border",children:f.jsx(Se,{"aria-label":"Edit node border","aria-pressed":O,icon:f.jsx(F.Icon,{as:K.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:O?i:c,bg:O?n==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>q(J=>!J)})}),f.jsx(ut,{label:O?"Border color":"Background",colors:d,value:O?((V=y==null?void 0:y.viewProps)==null?void 0:V.borderColor)??(p&&l.has(e[0])?(W=o.parentNodeStyle)==null?void 0:W.borderColor:void 0):(N=y==null?void 0:y.viewProps)==null?void 0:N.bgColor,onPick:ge,onReset:()=>ge("")}),O&&h("style")&&f.jsxs(f.Fragment,{children:[f.jsx(pr,{}),f.jsx(Ie,{label:U?"Solid border":"Dashed border",children:f.jsx(Se,{"aria-label":"Toggle dashed border","aria-pressed":se?"mixed":U,icon:f.jsx(F.Icon,{as:U?K.PiLineSegments:K.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:U?i:c,onClick:()=>P(J=>{var te;return(te=r.onNodeBorderStyleChange)==null?void 0:te.call(r,J,U?"solid":"dashed")})})}),f.jsx(ct,{ariaLabel:"Border thickness",placeholder:p?"Auto":"Mixed",width:"64px",type:"number",min:0,value:Y,onCommit:J=>P(te=>{var G;return(G=r.onNodeBorderWidthChange)==null?void 0:G.call(r,te,J===""?void 0:Number(J))})})]})]}),h("animation")&&f.jsxs(f.Fragment,{children:[f.jsx(pr,{}),f.jsx(Ie,{label:A?"Stop border animation":"Animate node border",children:f.jsx(Se,{"aria-label":"Toggle node animation","aria-pressed":M?"mixed":A,icon:f.jsx(F.Icon,{as:K.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:A?i:c,onClick:()=>P(J=>{var te;return(te=r.onNodeAnimationChange)==null?void 0:te.call(r,J,!A)})})}),(A||M)&&f.jsx(Am,{label:"Node animation",value:R,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:o.readOnly,onChange:J=>P(te=>{var G;return(G=r.onNodeAnimationVariantChange)==null?void 0:G.call(r,te,J)})})]}),!O&&h("textColor")&&f.jsxs(f.Fragment,{children:[f.jsx(pr,{}),f.jsx(ut,{label:"Text color",colors:Tm,value:(ne=y==null?void 0:y.viewProps)==null?void 0:ne.textColor,onPick:J=>P(te=>{var G;return(G=r.onNodeColorChange)==null?void 0:G.call(r,te,"text",J)}),onReset:()=>P(J=>{var te;return(te=r.onNodeColorChange)==null?void 0:te.call(r,J,"text","")})})]}),p&&h("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(pr,{}),f.jsx(el,{nodeId:e[0],value:(be=y==null?void 0:y.config)==null?void 0:be.icon},e[0]),f.jsx(ct,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((fe=y==null?void 0:y.config)==null?void 0:fe.icon)||"",onCommit:J=>{var te;return(te=r.onNodeIconChange)==null?void 0:te.call(r,e[0],J)}})]}),p&&x&&h("collapse")&&v!==void 0&&f.jsxs(f.Fragment,{children:[f.jsx(pr,{}),f.jsx(Ie,{label:v?"Expand":"Collapse",children:f.jsx(Se,{"aria-label":v?"Expand node":"Collapse node",icon:f.jsx(F.Icon,{as:v?K.PiArrowsOutLineVertical:K.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:c,onClick:()=>{var J;return(J=r.onNodeCollapse)==null?void 0:J.call(r,e[0],!v)}})})]}),h("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(pr,{}),f.jsx(Ie,{label:p?"Delete node":`Delete ${e.length} nodes`,children:f.jsx(Se,{"aria-label":"Delete selected nodes",icon:f.jsx(F.Icon,{as:K.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:n==="dark"?"red.300":"red.500",onClick:()=>{P(J=>{var te,G;return(G=r.onNodeDelete)==null?void 0:G.call(r,J,((te=u.get(J))==null?void 0:te.data)||{id:J})}),t()}})})]})]})}async function $m(e){const{toSvg:t}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const r=await t(e,{filter:i=>!(i instanceof Element)||!i.matches("button, iframe, [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(i=>i.remove()),n.querySelectorAll("[data-flow-preview-source]").forEach(i=>{i.setAttribute("style","display:block;white-space:pre-wrap;font:16px/1.5 monospace;overflow-wrap:anywhere")}),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}async function Nm(e,t="squeed.svg"){const r=document.createElement("a");r.href=await $m(e),r.download=t.endsWith(".svg")?t:`${t}.svg`,r.click()}function Lm(){const{themeColor:e}=Ne(),[t,r]=_.useState(!1),[n,i]=_.useState("");return f.jsxs(f.Fragment,{children:[f.jsx(Ie,{label:"Download SVG (current view)",children:f.jsx(Se,{"aria-label":"Download SVG",icon:f.jsx(K.PiDownloadSimpleFill,{size:20}),disabled:t,borderRadius:"30%",color:e,variant:"ghost",onClick:async o=>{var a;const s=(a=o.currentTarget.closest("[data-flow-diagram]"))==null?void 0:a.querySelector("[data-flow-background]");if(!s){i("Diagram not available for export.");return}r(!0),i("");try{await Nm(s)}catch(c){i(c instanceof Error?c.message:"Unable to export SVG.")}finally{r(!1)}}})}),n&&f.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function Fm({children:e,background:t,border:r,endElement:n}){const i=_.useRef(null),[o,s]=_.useState({left:!1,right:!1});_.useLayoutEffect(()=>{const c=i.current;let u=c.parentElement.offsetWidth;const l=()=>{const p=c.parentElement.offsetWidth;if(p>0&&p!==u){const g=u/p;u=p,g>0&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&c.parentElement.animate({transform:[`scaleX(${g})`,"scaleX(1)"],transformOrigin:[n?"right center":"left center",n?"right center":"left center"]},{duration:180,easing:"ease-out",id:"flow-toolbar-grow"})}const y=c.scrollLeft>1,m=c.scrollWidth-c.clientWidth-c.scrollLeft>1;s(g=>g.left===y&&g.right===m?g:{left:y,right:m})},d=p=>{if(p.defaultPrevented||p.ctrlKey||p.deltaX!==0||!p.deltaY||c.scrollWidth<=c.clientWidth)return;p.preventDefault();const y=p.deltaMode===WheelEvent.DOM_DELTA_LINE?16:p.deltaMode===WheelEvent.DOM_DELTA_PAGE?c.clientWidth:1;c.scrollLeft+=p.deltaY*y},h=new ResizeObserver(l);return h.observe(c),c.firstElementChild&&h.observe(c.firstElementChild),c.addEventListener("scroll",l,{passive:!0}),c.addEventListener("wheel",d,{passive:!1}),l(),()=>{h.disconnect(),c.removeEventListener("scroll",l),c.removeEventListener("wheel",d)}},[]);const a=`var(--chakra-colors-${t.replace(".","-")})`;return f.jsxs(F.Box,{position:"relative",bg:t,minW:0,maxW:"100%",flex:"0 1 auto",borderRadius:"30px",css:Hr(a,`var(--chakra-colors-${r.replace(".","-")})`),children:[f.jsx(F.Box,{ref:i,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",mr:n?"44px":void 0,borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(c=>f.jsx(F.Box,{"data-flow-toolbar-fade":c,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",borderRadius:c==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[c]:c==="right"&&n?44:0,opacity:o[c]?1:0,background:`linear-gradient(to ${c==="left"?"right":"left"}, ${a}, transparent)`}},c)),n&&f.jsx(F.Box,{position:"absolute",right:"6px",top:0,h:"50px",w:"32px",display:"flex",alignItems:"center",justifyContent:"center",children:n})]})}async function $0(e,t){const r=new Set,n=[],i=(a,c)=>{var l,d,h;if(!a||typeof a!="object")return;const u=a;n.push(c),typeof((l=u.$form)==null?void 0:l.$type)=="string"&&r.add(u.$form.$type),typeof((h=(d=u.$form)==null?void 0:d.$create)==null?void 0:h.$type)=="string"&&r.add(u.$form.$create.$type);for(const[p,y]of Object.entries(u))p==="$"?i(y,c):p.startsWith("$")||i(y,`${c}.${p}`)};if(i(t,"root"),!r.size)return{contract:await _m(e)};const o=await Qu(e,[...r]);for(const a of r)if(!Object.prototype.hasOwnProperty.call(o,a))throw new Error(`Missing form type: ${a}`);const s={};for(const a of n){const c=Tt(t,a,o);c&&(s[a]={type:c.type,optional:!1})}return{schema:o,contract:{name:e.name,nodes:s}}}function Bm({message:e,onDismiss:t}){const{background:r,colorText:n,border:i}=Ze();return!e||typeof document>"u"?null:tn.createPortal(f.jsxs(F.chakra.div,{role:"alert","aria-atomic":"true",css:Hr(xe(r),xe(i)),onPointerDown:o=>o.stopPropagation(),onClick:o=>o.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:xe(r),color:xe(n),fontSize:14,lineHeight:1.5},children:[f.jsx(K.PiWarningCircle,{size:20,"aria-hidden":"true",style:{flexShrink:0,color:"#ef4444"}}),f.jsxs("div",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:[f.jsx("strong",{children:"Interface upload failed"}),f.jsx("div",{children:e})]}),f.jsx(At,{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 rl({showDivider:e=!0,compact:t=!1}={}){const{edgeMode:r,setEdgeMode:n,workflowContract:i,setWorkflowContract:o,callbacks:s,readOnly:a,themeColor:c,colorMode:u}=Ne(),{edgeById:l}=Yr(),{data:d,schema:h,setSchema:p,bindings:y,structured:m}=_.useContext(Cr),g=(m==null?void 0:m.sourceBindings)??y,b=(m==null?void 0:m.sourceSchema)??h,{colorText:w}=Ze(),v=_.useRef(null),x=_.useRef(0),[C,S]=_.useState(!1),[E,I]=_.useState("");_.useEffect(()=>()=>{x.current++},[]),_.useEffect(()=>{x.current++,S(!1)},[a,d,g]);const A=i?[...l.values()].filter(R=>Xu(i,R.data)).length:0,M=i?`${i.name}: ${b?`${Object.keys(b).length} form types loaded; `:""}${A} invalid or unverified connections`:"",j=Mn(f.jsx(rl,{showDivider:!1,compact:!0}));return f.jsx(Et.Provider,{value:null,children:f.jsxs("span",{style:{display:"contents"},onClickCapture:j,children:[f.jsx(Bm,{message:E,onDismiss:()=>I("")}),e&&f.jsx(Ht,{}),f.jsxs(mr,{"aria-label":"Edge mode",title:r==="auto"?"Connections: Auto":r==="properties"?"Connections: Properties":"Connections: Nodes",icon:r==="auto"?f.jsx(K.PiGraph,{size:20}):r==="properties"?f.jsx(K.PiTable,{size:20}):f.jsx(K.PiTreeStructure,{size:20}),style:{width:36},value:r,disabled:a,footer:s.onWorkflowConfigurationOpen&&f.jsxs(f.Fragment,{children:[f.jsx("hr",{style:{border:0,borderTop:"1px solid currentColor",opacity:.2,margin:"8px 0"}}),f.jsxs(F.Button,{"data-flow-menu-action":"",variant:"ghost",width:"100%",justifyContent:"flex-start",color:"inherit",bg:"transparent",css:Rn,_hover:{bg:u==="dark"?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:u==="dark"?"whiteAlpha.100":"blackAlpha.50"},onClick:R=>{var P,k;(P=R.currentTarget.closest("[popover]"))==null||P.hidePopover(),(k=s.onWorkflowConfigurationOpen)==null||k.call(s)},children:[f.jsx(K.PiGear,{}),"Configuration"]})]}),onValueChange:R=>{var k;const P=R==="auto"?"auto":R==="properties"?"properties":"nodes";n(P),(k=s.onEdgeModeChange)==null||k.call(s,P)},children:[f.jsx("option",{value:"auto",children:"Auto"}),f.jsx("option",{value:"nodes",children:"Nodes"}),f.jsx("option",{value:"properties",children:"Properties"})]}),f.jsxs("span",{style:{display:r==="auto"||r==="properties"?"contents":"none"},children:[f.jsx(Ie,{label:i?`Replace ${i.name}`:"Upload workflow interface",children:f.jsx(Se,{"aria-label":"Upload workflow interface",icon:f.jsx(K.PiUploadSimple,{size:20}),color:xe(c),size:"sm",variant:"ghost",disabled:C||a,onClick:()=>{var R;return(R=v.current)==null?void 0:R.click()}})}),f.jsx("input",{ref:v,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:a||C,onChange:async R=>{var q,O;const P=(q=R.target.files)==null?void 0:q[0];if(R.target.value="",!P)return;const k=++x.current;S(!0),I("");try{const z=g?await Qu(P,[...new Set(Object.values(g).map(Q=>Q.schemaType??Q.type))]):void 0;if(g&&z){for(const Q of Object.values(g))if(!Object.prototype.hasOwnProperty.call(z,Q.schemaType??Q.type))throw new Error(`Missing form type: ${Q.schemaType??Q.type}`)}const{contract:U,schema:se}=g&&z?{schema:z,contract:{name:P.name,nodes:Object.fromEntries(Object.entries(g).map(([Q,Y])=>[Q,{type:z[Y.schemaType??Y.type],optional:!1}]))}}:await $0(P,d);if(k!==x.current)return;p==null||p(se),o(U),(O=s.onWorkflowContractChange)==null||O.call(s,U)}catch(z){k===x.current&&I(`${P.name}: ${z instanceof Error?z.message:"Unable to load interface."}`)}finally{k===x.current&&S(!1)}}}),!t&&(M||C)&&f.jsx("span",{role:"status",title:M,style:{color:xe(w),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:C?"Loading interface...":M}),!t&&i&&f.jsx(Ie,{label:"Remove workflow interface",children:f.jsx(Se,{"aria-label":"Remove workflow interface",icon:f.jsx(K.PiX,{size:16}),size:"sm",variant:"ghost",disabled:a||C,onClick:()=>{var R;p==null||p(void 0),o(void 0),(R=s.onWorkflowContractChange)==null||R.call(s,void 0),I("")}})})]})]})})}const N0=[{value:"BT",label:"Bottom to Up",icon:K.PiArrowUp,flowType:Bt.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:K.PiArrowDown,flowType:Bt.TOP_DOWN},{value:"LR",label:"Left to Right",icon:K.PiArrowRight,flowType:Bt.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:K.PiArrowLeft,flowType:Bt.RIGHT_LEFT}],zm=()=>{const{engineRef:e,themeColor:t,setThemeColor:r,edgeColor:n,setEdgeColor:i,backgroundSelected:o,setBackgroundSelected:s,direction:a,edgeMode:c,allNodesIconLabel:u,setAllNodesIconLabel:l,selectedNodeIds:d,setSelectedNodeIds:h,selectedEdgeId:p,setSelectedEdgeId:y,isZoomMode:m,setIsZoomMode:g,isMultiSelectMode:b,setIsMultiSelectMode:w,isDragMode:v,setIsDragMode:x,isEdgeHandlesEnabled:C,setIsEdgeHandlesEnabled:S,isArrayNodeMode:E,setIsArrayNodeMode:I,isPinned:A,setIsPinned:M,callbacks:j,config:R,readOnly:P}=Ne(),{nodeById:k,edgeById:q,parentIds:O}=Yr(),z=R.colorMode==="dark",{background:U,border:se,colorInactive:Q,colorText:Y,colorActive:ge}=Ze(),ce=z?se:"gray.300",$=`var(--chakra-colors-${U.replace(".","-")})`,V=`var(--chakra-colors-${(z?se:"gray.300").replace(".","-")})`,[W,N]=_.useState(!1),[ne,be]=_.useState(!0),fe=R.bottomBarCollapsed??ne,J=_.useRef(null),te=Ny({edge:"bottom",enabled:!A,bounds:J,inside:[J]}),G=_.useCallback(me=>{const Oe=e.current;if(!Oe)return;const nr=R.minZoom??.01,cr=R.maxZoom??1.5,Xe=.02;let we=Oe.zoom();switch(me){case"increase":we=Math.min(cr,we+Xe),Oe.zoom(we),Oe.center();break;case"decrease":we=Math.max(nr,we-Xe),Oe.zoom(we),Oe.center();break;case"reset":Oe.fit(50);break}},[e,R.minZoom,R.maxZoom]),le=R.renderSelectedNodeToolbar,ue=d.length>0&&!!le,Ce=_.useMemo(()=>ue?d.map(me=>{var nr;return{...((nr=k.get(me))==null?void 0:nr.data)??{id:me},isParent:O.has(me)}}):[],[ue,d,k,O]),ye=_.useCallback(()=>{var me;h([]),(me=j.onNodeDeselect)==null||me.call(j)},[h,j]),Me=R.renderSelectedEdgeToolbar,ee=!!p&&!!Me,he=_.useMemo(()=>{var me;return!ee||!p?null:((me=q.get(p))==null?void 0:me.data)??{id:p}},[ee,p,q]),ve=_.useCallback(()=>{var me;y(null),(me=j.onEdgeDeselect)==null||me.call(j)},[y,j]),je=R.selectionToolbar!==!1&&!P,qe=je&&!!p&&!Me,We=je&&!qe&&d.length>0&&!le,Ye=qe||We,tr=A||te||W||Ye||R.bottomBarCollapsed===!1;_.useEffect(()=>{d.length||p?s(!1):P||(o&&M(!0),R.bottomBarCollapsed===void 0&&be(!o))},[o,d.length,p,P,s,M,R.bottomBarCollapsed]);const sr=R.renderBottomBar,Ae=d0();return sr?f.jsxs(f.Fragment,{children:[ue&&f.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:le({selectedNodeIds:d,selectedNodeData:Ce,onDeselect:ye})}),ee&&he&&f.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:Me({edgeId:p,edgeData:he,onDeselect:ve})}),f.jsx(F.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:sr({zoomIn:()=>G("increase"),zoomOut:()=>G("decrease"),resetZoom:()=>G("reset"),direction:a,isZoomMode:m,setIsZoomMode:g,isMultiSelectMode:b,setIsMultiSelectMode:w,isDragMode:v,setIsDragMode:x,isEdgeHandlesEnabled:C,setIsEdgeHandlesEnabled:S,isArrayNodeMode:E,setIsArrayNodeMode:I,selectedNodeIds:d,selectedNodeData:Ce,selectedEdgeId:p,selectedEdgeData:he,onNodeDeselect:ye,onEdgeDeselect:ve,callbacks:j})})]}):f.jsxs(Et.Provider,{value:Ae,children:[ue&&f.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:le({selectedNodeIds:d,selectedNodeData:Ce,onDeselect:ye})}),ee&&he&&f.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:Me({edgeId:p,edgeData:he,onDeselect:ve})}),f.jsx(F.Box,{ref:J,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:tr?"translateY(0)":"translateY(100%)",pointerEvents:tr?"auto":"none",visibility:tr?"visible":"hidden",opacity:tr?1:0,css:{"@media (hover: none)":{visibility:"visible",opacity:1,transform:"none",pointerEvents:"auto"}},children:f.jsxs(F.Flex,{w:"100%",px:5,position:"absolute",bottom:"calc(20px + env(safe-area-inset-bottom, 0px))",flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:"24px",css:{"@media (min-width: 1024px)":{"& > :first-of-type":{maxWidth:"50vw"}}},children:[f.jsx(Fm,{background:U,border:z?se:"gray.300",children:f.jsxs(F.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[qe?f.jsx(Om,{edgeId:p,onClose:ve}):We?f.jsx(qm,{ids:d,onClose:ye}):null,f.jsxs("div",{style:{display:qe||We?"none":"contents"},children:[f.jsx(Ie,{label:A?"Unpin":"Pin",children:f.jsx(Se,{"aria-label":"Pin",icon:f.jsx(F.Icon,{as:A?K.PiPushPinFill:K.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:A?t:Q,onClick:()=>{M(!A),N(!1)}})}),f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Ie,{label:"Zoom Out",children:f.jsx(Se,{"aria-label":"Zoom out",rememberAction:!1,icon:f.jsx(F.Icon,{as:K.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:Y,onClick:()=>G("decrease")})}),f.jsx(Ie,{label:"Zoom In",children:f.jsx(Se,{"aria-label":"Zoom in",rememberAction:!1,icon:f.jsx(F.Icon,{as:K.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:Y,onClick:()=>G("increase")})}),f.jsx(Ie,{label:"Reset Zoom",children:f.jsx(Se,{"aria-label":"Reset zoom",rememberAction:!1,icon:f.jsx(F.Icon,{as:K.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:Y,onClick:()=>G("reset")})}),fe&&f.jsx(f0,{divider:f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"})}),f.jsxs("span",{style:{display:fe?"none":"contents"},children:[R.edgeHandles!==!1&&f.jsx(Ie,{label:C?"Draw Mode On (V)":"Draw Mode Off (V)",children:f.jsx(Se,{"aria-label":"Toggle draw mode","aria-keyshortcuts":"V","aria-pressed":C,icon:f.jsx(F.Icon,{as:K.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:C?t:Q,onClick:()=>S(!C)})}),f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Ie,{label:m?"Zoom Mode (z)":"Pan Mode (z)",children:f.jsx(Se,{"aria-label":"Toggle zoom mode",icon:f.jsx(F.Icon,{as:m?K.PiMagnifyingGlassPlus:K.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:m?t:Q,onClick:()=>g(!m)})}),f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Ie,{label:b?"Multi-Select On (m)":"Multi-Select Off (m)",children:f.jsx(Se,{"aria-label":"Toggle multi-select",icon:f.jsx(F.Icon,{as:K.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:b?t:Q,onClick:()=>w(!b)})}),f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Ie,{label:v?"Drag Mode On (d)":"Drag Mode Off (d)",children:f.jsx(Se,{"aria-label":"Toggle drag mode",icon:f.jsx(F.Icon,{as:K.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:v?t:Q,onClick:()=>x(!v)})}),R.bottomBarExtra&&f.jsxs(f.Fragment,{children:[f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"}),R.bottomBarExtra]}),f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"}),f.jsx(dm,{}),f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"}),f.jsx(Wu,{label:"Collapse all",hideLabel:!0,checked:u,icon:f.jsx(F.Icon,{as:K.PiArrowsInLineVertical,boxSize:5}),onChange:l}),c!=="properties"&&f.jsxs(f.Fragment,{children:[f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Ie,{label:E?"Array Mode [ ]":"Set Mode { }",children:f.jsx(Se,{"aria-label":"Toggle array mode",icon:f.jsx(F.Icon,{as:E?K.PiBracketsSquare:K.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:E?t:Q,onClick:()=>{var Oe;const me=!E;I(me),(Oe=j.onArrayModeChange)==null||Oe.call(j,me)}})})]}),f.jsx(rl,{}),!P&&f.jsxs("span",{style:{display:o?"contents":"none"},children:[f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(ut,{label:"Graph theme",colors:An,value:t,includeTransparent:!1,onPick:me=>{var Oe;r(me),(Oe=j.onThemeColorChange)==null||Oe.call(j,me)}})]}),!P&&f.jsxs(f.Fragment,{children:[f.jsx(F.Icon,{as:K.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"}),f.jsx(ut,{label:"Graph edge color",colors:An,value:n||(z?"gray.500":Pt),onPick:i,onReset:()=>i("")}),f.jsx(F.Icon,{as:K.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"})]}),f.jsx(hm,{})]}),f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Ie,{label:fe?"Expand toolbar":"Collapse toolbar",children:f.jsx(Se,{"aria-label":"Toggle toolbar collapse",rememberAction:!1,icon:f.jsx(F.Icon,{as:fe?K.PiCaretRight:K.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:Q,onClick:()=>{var me;R.bottomBarCollapsed===void 0&&be(!fe),s(fe),(me=j.onBottomBarCollapsedChange)==null||me.call(j,!fe)}})}),!fe&&f.jsx(Lm,{})]})]})}),!Ye&&f.jsxs(F.Box,{position:"relative",ml:"auto",flexShrink:0,children:[f.jsx(F.Box,{"data-flow-direction-control":"",bg:U,borderRadius:"30px",h:50,css:Hr($,V),px:3,cursor:"pointer",onClick:()=>N(!W),children:f.jsxs(F.Flex,{align:"center",h:"100%",children:[f.jsx(Ie,{label:"Flow Direction",children:f.jsx(Se,{"aria-label":"Direction",onClick:me=>{me.stopPropagation(),N(!W)},icon:f.jsx(F.Icon,{as:K.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:Q})}),f.jsx(F.Text,{fontSize:"xs",textTransform:"uppercase !important",color:z?"whiteAlpha.600":"blackAlpha.500",ml:1,children:a.toUpperCase()})]})}),W&&f.jsx(F.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:f.jsxs(F.Box,{bg:U,borderRadius:"30px",p:2,minW:"180px",css:Hr($,V),children:[N0.map(me=>f.jsxs(F.Flex,{align:"center",gap:3,px:3,py:2,css:Rn,cursor:"pointer",_hover:{bg:z?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Oe;(Oe=j.onDirectionChange)==null||Oe.call(j,me.value),N(!1)},children:[f.jsx(F.Icon,{as:me.icon,boxSize:5,color:Y}),f.jsx(F.Text,{fontSize:"sm",color:Y,flex:1,whiteSpace:"nowrap",children:me.label}),a===me.value&&f.jsx(F.Icon,{as:K.PiCheck,boxSize:4,color:ge})]},me.value)),f.jsxs(F.Flex,{align:"center",gap:3,px:3,py:2,css:Rn,cursor:"pointer",_hover:{bg:z?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var me;(me=j.onDirectionChange)==null||me.call(j,"C"),N(!1)},children:[f.jsx(F.Icon,{as:K.PiAlignCenterHorizontal,boxSize:5,color:Y}),f.jsx(F.Text,{fontSize:"sm",color:Y,flex:1,whiteSpace:"nowrap",children:"Center"}),a==="C"&&f.jsx(F.Icon,{as:K.PiCheck,boxSize:4,color:ge})]})]})})]})]})})]})};zm.displayName="BottomBar";const Dm=_.memo(zm);function L0({checked:e,onChange:t,disabled:r,label:n="Connected nodes"}){return f.jsx(Wu,{hideLabel:!0,label:n,helper:`${n}: isolate node and its connections`,checked:e,onChange:t,disabled:r,icon:f.jsx(F.Icon,{as:K.PiGraph,boxSize:5})})}const Jl={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function Vm(e,t){const r=new Map,n=(o,s)=>{if(Object.is(o,s))return!0;if(!o||!s||typeof o!="object"||typeof s!="object"||Array.isArray(o)!==Array.isArray(s))return!1;const a=Object.keys(o);return a.length===Object.keys(s).length&&a.every(c=>Object.prototype.hasOwnProperty.call(s,c)&&n(o[c],s[c]))},i=(o,s,a)=>{if(o===s)return!0;if(!o||!s||typeof o!="object"||typeof s!="object"||Array.isArray(o)!==Array.isArray(s))return!1;const c=new Set([...Object.keys(o),...Object.keys(s)]);for(const u of c)if(!n(o[u],s[u])){if(Object.prototype.hasOwnProperty.call(Jl,u)){if(typeof s[u]!="string"||!s[u])return!1;r.set(a,{...r.get(a),[Jl[u]]:s[u]})}else if(u.startsWith("$")&&u!=="$"||!i(o[u],s[u],u==="$"?a:`${a}.${u}`))return!1}return!0};if(i(e,t,"root"))return r}function F0(e,t){return Vm(e,t)!==void 0}function B0(e,t,r){if(e===t)return r;const n=Vm(e,t);if(!n)return;const i=new Set(r.nodes.map(o=>o.data.id));for(const o of n.keys())if(!i.has(o)||!Re(t,o))return;return{edges:r.edges,nodes:r.nodes.map(o=>{const s=n.get(o.data.id),a=Re(e,o.data.id),c=Re(t,o.data.id);return!s&&a===c?o:{...o,data:{...o.data,...typeof o.data.code=="string"?{code:JSON.stringify(c,null,2)}:{},...s?{viewProps:{...o.data.viewProps,...s},config:{...o.data.config,...s}}:{}}}})}}function Lu(e){return e.kind==="literal"?e.value:e.kind==="union"?Lu(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,t])=>!t.optional).map(([t,r])=>[t,Lu(r.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function Wm(e,t,r){var g,b,w;const n=(g=Re(e,t))==null?void 0:g.$form,i=n==null?void 0:n.$create;if(!i)return;const o=i.$address.split(".");if(o.shift()!=="root"||!o.length||o.some(v=>!/^[A-Za-z0-9_-]+$/.test(v)||["__proto__","constructor","prototype"].includes(v)))throw new Error("Invalid form creation address.");if(!r||!Object.prototype.hasOwnProperty.call(r,i.$type))throw new Error(`Load form type: ${i.$type}`);const s=o.pop(),a=["root",...o].join("."),c=Tt(e,a,r),u=(b=c==null?void 0:c.type.properties[s])==null?void 0:b.type;if((u==null?void 0:u.kind)!=="array"||u.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const l=r[i.$type],d=i.$defaults??{};for(const[v,x]of Object.entries(d))if(!Object.prototype.hasOwnProperty.call(l.properties,v)||Rr(l.properties[v].type,x,!l.properties[v].optional))throw new Error(`Invalid creation default: ${v}`);const h={...Lu(l),...structuredClone(d)};((w=l.properties.id)==null?void 0:w.type.kind)==="string"&&(h.id=Gu());let p=e;const y=Re(e,i.$address);if(y===void 0)p=vr(e,a,v=>({...v,[s]:[]}));else if(!Array.isArray(y)&&!Array.isArray(y==null?void 0:y.$))throw new Error("Form creation destination is not an array.");const m=Ku(p,i.$address,{...h,$label:i.$label??i.$type,...i.$icon?{$icon:i.$icon}:{},$form:{$type:i.$type,$create:i}});return{address:m.address,json:Ju(m.json,t,{target:m.address,label:i.$edgeLabel})}}function z0(e,t){const r=i=>e&&typeof e=="object"&&i in e;let n=1;for(;r(`${t}_${n}`);)n++;return`${t}_${n}`}function Gm(e,t,r,n,i){const o=(a,c)=>{a!==e&&(e=a,n==null||n(a,c))},s=a=>{var u;const c=(u=t.find(l=>l.data.id===a))==null?void 0:u.data;return c&&{source:c.source,target:c.target,isInverted:c.isInverted,sourceProperty:c.sourceProperty,targetProperty:c.targetProperty,connection:c.connection}};return{...r,onFormChange:a=>{const c=Re(e,a.nodeAddress);if(!c||a.nodeId!==void 0&&c.id!==a.nodeId)throw new Error("This form node has moved. Retry the edit.");o(Fn(e,a,r.onFormChange),{type:"form",address:a.address,value:a.value})},onNodeLabelChange:(a,c)=>{var u;(u=r.onNodeLabelChange)==null||u.call(r,a,c),o(hr(e,a,"$label",c),{type:"nodeLabel",address:a,key:"$label",value:c})},onNodeContentChange:(a,c)=>{var u;(u=r.onNodeContentChange)==null||u.call(r,a,c),o(hr(e,a,"$content",c),{type:"nodeContent",address:a,key:"$content",value:c})},onNodeTypeViewChange:(a,c)=>{var u;c!==void 0&&!nn.includes(c)||((u=r.onNodeTypeViewChange)==null||u.call(r,a,c),o(hr(e,a,"$view",c),{type:"nodeStyle",address:a,key:"$view",value:c}))},onNodeColorChange:(a,c,u)=>{var d;(d=r.onNodeColorChange)==null||d.call(r,a,c,u);const l=c==="bg"?"$bgColor":"$textColor";o(hr(e,a,l,u),{type:"nodeColor",address:a,key:l,value:u})},onNodeBorderColorChange:(a,c)=>{var u;(u=r.onNodeBorderColorChange)==null||u.call(r,a,c),o(hr(e,a,"$borderColor",c),{type:"nodeColor",address:a,key:"$borderColor",value:c})},onNodeBorderStyleChange:(a,c)=>{var u;(u=r.onNodeBorderStyleChange)==null||u.call(r,a,c),o(hr(e,a,"$borderStyle",c),{type:"nodeStyle",address:a,key:"$borderStyle",value:c})},onNodeBorderWidthChange:(a,c)=>{var u;c!==void 0&&(!Number.isFinite(c)||c<0)||((u=r.onNodeBorderWidthChange)==null||u.call(r,a,c),o(hr(e,a,"$borderWidth",c),{type:"nodeStyle",address:a,key:"$borderWidth",value:c}))},onNodeBorderRadiusChange:(a,c)=>{var u;c!==void 0&&(!Number.isFinite(c)||c<0)||((u=r.onNodeBorderRadiusChange)==null||u.call(r,a,c),o(hr(e,a,"$borderRadius",c),{type:"nodeStyle",address:a,key:"$borderRadius",value:c}))},onNodeIconChange:(a,c)=>{var u;(u=r.onNodeIconChange)==null||u.call(r,a,c),o(hr(e,a,"$icon",c),{type:"nodeIcon",address:a,key:"$icon",value:c})},onNodeOutlineChange:(a,c)=>{var u;(u=r.onNodeOutlineChange)==null||u.call(r,a,c),o(hr(e,a,"$outline",c),{type:"nodeOutline",address:a,key:"$outline",value:c})},onNodeAnimationChange:(a,c)=>{var u;(u=r.onNodeAnimationChange)==null||u.call(r,a,c),o(hr(e,a,"$isNodeAnimated",c),{type:"nodeAnimation",address:a,key:"$isNodeAnimated",value:c})},onNodeAnimationVariantChange:(a,c)=>{var u;c!=="traveling"&&c!=="pulse"||((u=r.onNodeAnimationVariantChange)==null||u.call(r,a,c),o(hr(e,a,"$nodeAnimationVariant",c),{type:"nodeAnimation",address:a,key:"$nodeAnimationVariant",value:c}))},onNodeCollapse:(a,c)=>{var u;(u=r.onNodeCollapse)==null||u.call(r,a,c),o(bm(e,a,c),{type:"nodeCollapse",address:a,key:"$collapsed",value:c})},onNodeCreate:a=>{var y,m;const c=a.sourceNodeId&&Wm(e,a.sourceNodeId,i);if(c){(y=r.onNodeCreate)==null||y.call(r,a),o(c.json,{type:"nodeCreate",address:c.address,value:"form"});return}(m=r.onNodeCreate)==null||m.call(r,a);const u=a.sourceNodeId||"root",l=Re(e,u),d=z0(l,a.isArrayMode?"list":"node"),h=a.isArrayMode?{$bgColor:"gray.500",$:[]}:{$bgColor:"gray.500"},p=Ku(e,u,h,d);o(p.json,{type:"nodeCreate",address:p.address,value:a.isArrayMode?"array":"set"})},onNodeDelete:(a,c)=>{var u;(u=r.onNodeDelete)==null||u.call(r,a,c),o(xm(e,a),{type:"nodeDelete",address:a})},onEdgeCreate:(a,c,u)=>{var d;(d=r.onEdgeCreate)==null||d.call(r,a,c,u);const l=u&&(u.sourceProperty!==void 0||u.targetProperty!==void 0)?{...u,target:c}:void 0;o(l?Ju(e,a,l):wm(e,a,c),{type:"edgeCreate",address:a,key:l?"$connections":"$target",value:l??c})},onEdgeLabelChange:(a,c)=>{var l;(l=r.onEdgeLabelChange)==null||l.call(r,a,c);const u=s(a);u&&o(Gr(e,u,"$sourceLabel",c),{type:"edgeLabel",edge:u,key:u.connection?"$connections":"$sourceLabel",value:c})},onEdgeStyleChange:(a,c)=>{var l;(l=r.onEdgeStyleChange)==null||l.call(r,a,c);const u=s(a);u&&o(vm(e,u,c),{type:"edgeStyle",edge:u,value:c})},onEdgeAnimationVariantChange:(a,c)=>{var l;if(c!=="dashed"&&c!=="traveling")return;(l=r.onEdgeAnimationVariantChange)==null||l.call(r,a,c);const u=s(a);u&&o(Gr(e,u,"$edgeAnimationVariant",c),{type:"edgeStyle",edge:u,key:u.connection?"$connections":"$edgeAnimationVariant",value:c})},onEdgeTypeChange:(a,c)=>{var l;(l=r.onEdgeTypeChange)==null||l.call(r,a,c);const u=s(a);u&&o(Gr(e,u,"$edgeType",c),{type:"edgeStyle",edge:u,key:u.connection?"$connections":"$edgeType",value:c})},onEdgeIconChange:(a,c)=>{var l;(l=r.onEdgeIconChange)==null||l.call(r,a,c);const u=s(a);u&&o(Gr(e,u,"$edgeIcon",c||void 0),{type:"edgeStyle",edge:u,key:u.connection?"$connections":"$edgeIcon",value:c})},onEdgeColorChange:(a,c)=>{var l;(l=r.onEdgeColorChange)==null||l.call(r,a,c);const u=s(a);u&&o(Gr(e,u,"$edgeColor",c),{type:"edgeColor",edge:u,key:u.connection?"$connections":"$edgeColor",value:c})},onEdgeDelete:(a,c)=>{var d;(d=r.onEdgeDelete)==null||d.call(r,a,c);const u=s(a);if(!u)return;const l=Cm(e,u);l.removed&&o(l.json,{type:"edgeDelete",edge:u,key:u.connection?"$connections":"$target"})}}}const D0=".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 V0({path:e,color:t,width:r,reversed:n}){return f.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 W0=".flow-sdk-edge-reveal{animation:flow-sdk-edge-reveal var(--flow-edge-reveal-duration,600ms) linear both;animation-play-state:var(--flow-edge-reveal-state,running)}.flow-sdk-edge-reveal-end{animation:flow-sdk-edge-reveal-end var(--flow-edge-reveal-duration,600ms) steps(1,end) both;animation-play-state:var(--flow-edge-reveal-state,running)}@keyframes flow-sdk-edge-reveal{from{stroke-dashoffset:var(--flow-edge-reveal-from,100)}to{stroke-dashoffset:0}}@keyframes flow-sdk-edge-reveal-end{from{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.flow-sdk-edge-reveal{animation:none;stroke-dashoffset:0}.flow-sdk-edge-reveal-end{animation:none;opacity:1}}";function G0({path:e,width:t,reversed:r,children:n,onComplete:i}){const o=`flow-edge-reveal-${_.useId().replace(/:/g,"")}`,s=_.useRef(null),[a,c]=_.useState({x:0,y:0,width:1,height:1});return _.useEffect(()=>{const u=matchMedia("(prefers-reduced-motion: reduce)"),l=()=>{u.matches&&(i==null||i())};return l(),u.addEventListener("change",l),()=>u.removeEventListener("change",l)},[i]),_.useLayoutEffect(()=>{var l;const u=(l=s.current)==null?void 0:l.getBBox();u&&c({x:u.x-t,y:u.y-t,width:u.width+t*2,height:u.height+t*2})},[e,t]),f.jsxs(f.Fragment,{children:[f.jsx("defs",{children:f.jsx("mask",{id:o,maskUnits:"userSpaceOnUse",...a,children:f.jsx("path",{ref:s,className:"flow-sdk-edge-reveal",onAnimationEnd:u=>{u.animationName==="flow-sdk-edge-reveal"&&(i==null||i())},"data-reveal-direction":r?"reverse":"forward",style:{"--flow-edge-reveal-from":r?-100:100},d:e,fill:"none",stroke:"white",strokeWidth:t,strokeLinecap:"butt",strokeLinejoin:"round",pathLength:100,strokeDasharray:"100 100"})})}),f.jsx("g",{mask:`url(#${o})`,children:n})]})}const U0=".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 Um({x:e=0,y:t=0,width:r,height:n,radius:i,color:o,strokeWidth:s=8,path:a,variant:c="traveling"}){const u=_.useId(),l=`flow-sdk-node-border-animation${c==="pulse"?" flow-sdk-node-border-pulse":""}`;if(c==="pulse"){const d=a?"path":"rect",h=a?{d:a}:{x:e,y:t,width:Math.max(0,r),height:Math.max(0,n),rx:Math.max(0,Math.min(i,r/2,n/2))},p=s+36,y={x:e-p,y:t-p,width:r+2*p,height:n+2*p};return f.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[f.jsx("defs",{children:f.jsxs("mask",{id:u,maskUnits:"userSpaceOnUse",...y,style:{maskType:"luminance"},children:[f.jsx("rect",{...y,fill:"white"}),f.jsx(d,{...h,fill:"black",stroke:"black",strokeWidth:s,strokeLinejoin:"round"})]})}),f.jsx(d,{...h,className:l,"data-animation-variant":c,fill:"none",stroke:`color-mix(in srgb, ${o} 30%, transparent)`,strokeLinejoin:"round",mask:`url(#${u})`,style:{"--flow-pulse-rest-width":`${s+16}px`,"--flow-pulse-expanded-width":`${s+36}px`}})]})}return a?f.jsx("path",{className:l,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",d:a,fill:"none",stroke:o,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"}):f.jsx("rect",{className:l,"data-animation-variant":c,"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(i,r/2,n/2)),fill:"none",stroke:o,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const H0=e=>{const n=1/(Math.cbrt(e)*.8);let i=Math.round(650*n),o=Math.round(350*n);return i=Math.max(40,Math.min(450,i)),o=Math.max(30,Math.min(300,o)),{edgeSep:i,rankSep:o}};function Zl(e,t,r){const n=new Set([e]),i=[e];for(;i.length;){const o=i.pop();for(const s of t)(s.parent===o||s.id.startsWith(`${o}.`)||r.some(c=>(c.inverted?c.target:c.source)===o&&(c.inverted?c.source:c.target)===s.id))&&!n.has(s.id)&&(n.add(s.id),i.push(s.id))}return n}function K0(e,t,r){const n=r==="downward"||r==="upward",i=new Map;for(const s of e){if(s.source===s.target||s.sourceProperty||s.targetProperty)continue;const a=t(s.source),c=t(s.target);if(!a||!c)continue;const u=n?c.y-a.y:c.x-a.x,l=Math.abs(u)-(n?a.h+c.h:a.w+c.w)/2;if(l<=320)continue;const d=JSON.stringify([s.source,Math.sign(u)]),h=i.get(d)??[];h.push({edge:s,gap:l,cross:n?c.x-a.x:c.y-a.y}),i.set(d,h)}const o=new Map;for(const s of i.values()){if(new Set(s.map(({edge:c})=>c.target)).size<2)continue;const a=new Map;for(const{edge:c}of s)a.set(c.target,(a.get(c.target)??0)+1);for(const c of[-1,0,1]){const u=s.filter(({cross:d})=>Math.sign(d)===c);u.sort((d,h)=>Math.abs(h.cross)-Math.abs(d.cross)||d.edge.id.localeCompare(h.edge.id));const l=Math.min(...u.map(({gap:d})=>d));u.forEach(({edge:d,gap:h,cross:p},y)=>{const m=u.length===1?l/2:120+(l-280)*y/(u.length-1),g=u.find(b=>Math.abs(b.cross)<Math.abs(p));o.set(d.id,{turn:m/h,labelAtTarget:a.get(d.target)===1,labelFraction:p?(p+((g==null?void 0:g.cross)??0))/(2*p):.5})})}}return o}const bt=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}),J0=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function yo(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 Z0=(e,t)=>e.x1<=t.x2&&e.x2>=t.x1&&e.y1<=t.y2&&e.y2>=t.y1,Yl=(e,t)=>e.x>=t.x1&&e.x<=t.x2&&e.y>=t.y1&&e.y<=t.y2,xr=e=>(Math.round(e*10)/10).toString(),Qe=e=>`${xr(e.x)} ${xr(e.y)}`,Y0=e=>e>0?1:e<0?-1:0,Xl=(e,t)=>e>0?Math.max(e-t,0):Math.min(e+t,0);function X0(e,t,r,n,i=10){const o=t.x-e.x,s=t.y-e.y,a=Xl(o,(e.w+t.w)/2),c=Xl(s,(e.h+t.h)/2),u=r==="downward"||r==="upward",l=u?c:a,d=u?s:o,h=Y0(d),p=n*l,y=w=>Math.abs(w)<i||Math.abs(w)>=Math.abs(l),m=y(p)||y(Math.abs(l)-Math.abs(p));let g;if(m)if(u)if(Math.abs(d)<=e.h/2){const w=(e.x+t.x)/2;g=[w,e.y,w,t.y]}else if(Math.abs(o)<=t.w/2){const w=(e.y+t.y)/2;g=[e.x,w,t.x,w]}else g=[e.x,t.y];else if(Math.abs(d)<=e.w/2){const w=(e.y+t.y)/2;g=[e.x,w,t.x,w]}else if(Math.abs(s)<=t.h/2){const w=(e.x+t.x)/2;g=[w,e.y,w,t.y]}else g=[t.x,e.y];else if(u){const w=e.y+p+e.h/2*h;g=[e.x,w,t.x,w]}else{const w=e.x+p+e.w/2*h;g=[w,e.y,w,t.y]}const b=[{x:e.x,y:e.y}];for(let w=0;w<g.length;w+=2)b.push({x:g[w],y:g[w+1]});return b.push({x:t.x,y:t.y}),b}function Q0(e,t,r){const n=t.x-e.x,i=t.y-e.y,o=n>0?(r.x2-e.x)/n:n<0?(r.x1-e.x)/n:1/0,s=i>0?(r.y2-e.y)/i:i<0?(r.y1-e.y)/i:1/0,a=Math.min(o,s);return!Number.isFinite(a)||a>=1||a<0?null:{x:e.x+n*a,y:e.y+i*a}}function kt(e,t,r){var s;if(!((s=r.outline)!=null&&s.length))return Q0(e,t,bt(r));const n=t.x-e.x,i=t.y-e.y;let o=1/0;return r.outline.forEach((a,c,u)=>{const l=u[(c+1)%u.length],d=l.x-a.x,h=l.y-a.y,p=n*h-i*d;if(Math.abs(p)<1e-9)return;const y=a.x-e.x,m=a.y-e.y,g=(y*h-m*d)/p,b=(y*i-m*n)/p;g>=0&&g<1&&b>=-1e-9&&b<=1+1e-9&&(o=Math.min(o,g))}),Number.isFinite(o)?{x:e.x+n*o,y:e.y+i*o}:null}function Hm(e,t,r=.5){const n=Number.isFinite(r)?Math.max(0,Math.min(1,r)):.5,i=t==="top"||t==="bottom",o=t==="top"||t==="left"?-1:1,s={x:i?e.x-e.w/2+e.w*n:e.x,y:i?e.y:e.y-e.h/2+e.h*n},a=Math.max(e.w,e.h)*2+1;return{...kt(s,{x:s.x+(i?0:o*a),y:s.y+(i?o*a:0)},e)??{x:i?s.x:e.x+o*e.w/2,y:i?e.y+o*e.h/2:s.y},side:t}}function wt(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 ew(e,t,r,n){const i=wt(e,r.srcDist),o=wt(t,r.tgtDist);if(n==="straight")return Jm(i,o,r);const s=Math.max(80,Math.min(300,Math.hypot(o.x-i.x,o.y-i.y)/3)),a=e.side==="bottom"&&t.side==="top"?o.y-i.y:e.side==="top"&&t.side==="bottom"?i.y-o.y:e.side==="right"&&t.side==="left"?o.x-i.x:e.side==="left"&&t.side==="right"?i.x-o.x:void 0,c=a!==void 0&&a>0?Math.min(s,a/2):s,u=wt({...i,side:e.side},c),l=wt({...o,side:t.side},c),d=r.arrowAt==="source"?ar(i,u,r.arrowGap):i,h=r.arrowAt==="target"?ar(o,l,r.arrowGap):o,p=r.arrowAt==="source"?Sr(i,u,r.arrowSize,r.headShape):r.arrowAt==="target"?Sr(o,l,r.arrowSize,r.headShape):void 0;if(n==="bezier")return{d:`M${Qe(d)} C${Qe(u)} ${Qe(l)} ${Qe(h)}`,arrow:p,label:{x:(d.x+3*u.x+3*l.x+h.x)/8,y:(d.y+3*u.y+3*l.y+h.y)/8,angle:0}};const y=e.side==="left"||e.side==="right",m=t.side==="left"||t.side==="right";let g;if(y!==m){const w=y?{x:l.x,y:u.y}:{x:u.x,y:l.y},v=(w.x-u.x)*(u.x-i.x)+(w.y-u.y)*(u.y-i.y)>=0,x=(w.x-l.x)*(l.x-o.x)+(w.y-l.y)*(l.y-o.y)>=0;g=[v&&x?w:y?{x:u.x,y:l.y}:{x:l.x,y:u.y}]}else if(a!==void 0&&a<=0)if(y){const w=(u.y+l.y)/2;g=[{x:u.x,y:w},{x:l.x,y:w}]}else{const w=(u.x+l.x)/2;g=[{x:w,y:u.y},{x:w,y:l.y}]}else if(y){const w=e.side===t.side?e.side==="right"?Math.max(u.x,l.x):Math.min(u.x,l.x):(u.x+l.x)/2;g=[{x:w,y:u.y},{x:w,y:l.y}]}else{const w=e.side===t.side?e.side==="bottom"?Math.max(u.y,l.y):Math.min(u.y,l.y):(u.y+l.y)/2;g=[{x:u.x,y:w},{x:l.x,y:w}]}const b=[u,...g,l].filter((w,v,x)=>v===0||w.x!==x[v-1].x||w.y!==x[v-1].y);return Bn(d,b,h,p,n==="orthogonal"?0:r.radius)}function ar(e,t,r){const n=e.x-t.x,i=e.y-t.y,o=Math.hypot(n,i);if(!o)return e;let s=(o-r)/o;return s<0&&(s=1e-5),{x:t.x+s*n,y:t.y+s*i}}function Sr(e,t,r,n="triangle"){const i=e.x-t.x,o=e.y-t.y,s=Math.hypot(i,o)||1,a=i/s,c=o/s,u=(n==="square"?.15:.3)*r,l=.15*r,d=e.x-a*u,h=e.y-c*u;if(n==="square")return`M${Qe(e)} L${xr(e.x-c*l)} ${xr(e.y+a*l)} L${xr(d-c*l)} ${xr(h+a*l)} L${xr(d+c*l)} ${xr(h-a*l)} L${xr(e.x+c*l)} ${xr(e.y-a*l)} Z`;const p=[e,{x:d-c*l,y:h+a*l},{x:d+c*l,y:h-a*l}];return p.map((m,g)=>{const b=p[(g+2)%3],w=p[(g+1)%3],v=Math.hypot(b.x-m.x,b.y-m.y),x=Math.hypot(w.x-m.x,w.y-m.y),C={x:(b.x-m.x)/v,y:(b.y-m.y)/v},S={x:(w.x-m.x)/x,y:(w.y-m.y)/x},E=Math.max(-1,Math.min(1,C.x*S.x+C.y*S.y)),I=Math.sqrt((1-E)/(1+E)),A=Math.min(1/I,v/2,x/2);return{start:{x:m.x+C.x*A,y:m.y+C.y*A},end:{x:m.x+S.x*A,y:m.y+S.y*A},radius:A*I}}).map((m,g)=>`${g?"L":"M"}${Qe(m.start)} A${xr(m.radius)} ${xr(m.radius)} 0 0 1 ${Qe(m.end)}`).join(" ")+" Z"}function Wr(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 rw(e,t,r,n){const i={x:t.x-e.x,y:t.y-e.y},o={x:r.x-t.x,y:r.y-t.y},s=Math.hypot(i.x,i.y),a=Math.hypot(o.x,o.y),c=i.x*o.y-i.y*o.x;if(s<1e-6||a<1e-6||Math.abs(c)<1e-6)return{p1:t,b:t,p2:t,r:0};const u=Math.min(n,s/2,a/2);return{p1:{x:t.x-i.x/s*u,y:t.y-i.y/s*u},b:t,p2:{x:t.x+o.x/a*u,y:t.y+o.y/a*u},r:u}}function Km(e,t,r,n){let i=-1,o=null;for(let y=0;y<e.length-1;y++){const m=kt(e[y],e[y+1],t);if(m){i=y,o=m;break}}let s=-1,a=null;for(let y=e.length-1;y>0;y--){const m=kt(e[y],e[y-1],r);if(m){s=y,a=m;break}}if(!o||!a||i>=s)return null;const c=e.slice(i+1,s),u=c[0]??a,l=c[c.length-1]??o;let d,h,p;if(n.arrowAt==="source"){const y=ar(o,u,n.srcDist);d=ar(o,u,n.srcDist+n.arrowGap),p=Sr(y,u,n.arrowSize,n.headShape)}else d=ar(o,u,n.srcDist);if(n.arrowAt==="target"){const y=ar(a,l,n.tgtDist);h=ar(a,l,n.tgtDist+n.arrowGap),p=Sr(y,l,n.arrowSize,n.headShape)}else h=ar(a,l,n.tgtDist);return Bn(d,c,h,p,n.radius,n.labelTargetLength,n.labelFraction)}function Bn(e,t,r,n,i,o,s){var h;const a=[e,...t,r],c=[];let u=`M${Qe(e)}`;for(let p=1;p<a.length-1;p++){const y=rw(a[p-1],a[p],a[p+1],i);c.push(y),y.r===0?u+=` L${Qe(y.b)}`:u+=` L${Qe(y.p1)} Q${Qe(y.b)} ${Qe(y.p2)}`}u+=` L${Qe(r)}`;let l;const d=t.length;if(d===0)l={x:(e.x+r.x)/2,y:(e.y+r.y)/2,angle:Wr(r.x-e.x,r.y-e.y)};else if(d%2===0){const p=t[d/2-1],y=t[d/2];l={x:(p.x+y.x)/2,y:(p.y+y.y)/2,angle:Wr(y.x-p.x,y.y-p.y)}}else{const p=c[(d-1)/2];if(p.r===0){const y=a[(d-1)/2+2];l={x:p.b.x,y:p.b.y,angle:Wr(y.x-p.b.x,y.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:Wr(p.p2.x-p.p1.x,p.p2.y-p.p1.y)}}if(o!==void 0){if(s!==void 0&&c.length===2){const g=c[0].p2,b=c[1].p1,w=Math.hypot(b.x-g.x,b.y-g.y),v=Math.min(.5,o/(2*w)),x=Math.max(v,Math.min(1-v,s));l={x:g.x+(b.x-g.x)*x,y:g.y+(b.y-g.y)*x,angle:Wr(b.x-g.x,b.y-g.y)}}const p=((h=c[c.length-1])==null?void 0:h.p2)??e,y=r.x-p.x,m=r.y-p.y;Math.hypot(y,m)>=o&&(l={x:(p.x+r.x)/2,y:(p.y+r.y)/2,angle:Wr(y,m)})}return{d:u,arrow:n,label:l}}function Ql(e,t,r,n,i,o,s){const a=r==="leftward"?-1:1,c={x:e.x+a*(e.w/2+s.srcDist),y:n??e.y},u={x:t.x-a*(t.w/2+s.tgtDist),y:i??t.y},l=Math.max(80,s.arrowGap+s.arrowSize*.3),d=c.x+a*l,h=u.x-a*l;let p;if(a*(h-d)>=0){const b=c.x+(u.x-c.x)*o,w=Math.max(Math.min(d,h),Math.min(Math.max(d,h),b));p=[{x:w,y:c.y},{x:w,y:u.y}]}else{const b=Math.min(e.y-e.h/2,t.y-t.h/2)-l*(1+o);p=[{x:d,y:c.y},{x:d,y:b},{x:h,y:b},{x:h,y:u.y}]}const y=s.arrowAt==="source"?ar(c,p[0],s.arrowGap):c,m=s.arrowAt==="target"?ar(u,p[p.length-1],s.arrowGap):u,g=s.arrowAt==="source"?Sr(c,p[0],s.arrowSize,s.headShape):s.arrowAt==="target"?Sr(u,p[p.length-1],s.arrowSize,s.headShape):void 0;return Bn(y,p,m,g,s.radius)}function ed(e,t,r,n,i){return Km(X0(e,t,r,n),e,t,i)}function rd(e,t,r,n,i,o){const s=n===void 0&&i===void 0&&(r==="downward"||r==="upward"),a=r==="leftward"||s&&r==="upward"?-1:1,c=(u,l,d)=>{const h={x:u.x,y:l??u.y},p=Math.max(u.w,u.h)*2+1,y=kt(h,{x:h.x+(s?0:d*p),y:h.y+(s?d*p:0)},u);return y?{x:y.x+(s?0:d*o),y:y.y+(s?d*o:0)}:s?{x:u.x,y:u.y+d*(u.h/2+o)}:{x:u.x+d*(u.w/2+o),y:l??u.y}};return{sourcePoint:c(e,n,a),targetPoint:c(t,i,-a)}}function tw(e,t,r,n){const i=r==="downward"||r==="upward",o=r==="leftward"||r==="upward"?-1:1,s=Math.max(100,Math.abs(i?t.y-e.y:t.x-e.x)/2),a={x:e.x+(i?0:o*s),y:e.y+(i?o*s:0)},c={x:t.x-(i?0:o*s),y:t.y-(i?o*s:0)},u=n.arrowAt==="source"?ar(e,a,n.arrowGap):e,l=n.arrowAt==="target"?ar(t,c,n.arrowGap):t;return{d:`M${Qe(u)} C${Qe(a)} ${Qe(c)} ${Qe(l)}`,arrow:n.arrowAt==="source"?Sr(e,a,n.arrowSize,n.headShape):n.arrowAt==="target"?Sr(t,c,n.arrowSize,n.headShape):void 0,label:{x:(u.x+3*a.x+3*c.x+l.x)/8,y:(u.y+3*a.y+3*c.y+l.y)/8,angle:Wr(l.x+c.x-a.x-u.x,l.y+c.y-a.y-u.y)}}}function Jm(e,t,r){const n=r.arrowAt==="source"?ar(e,t,r.arrowGap):e,i=r.arrowAt==="target"?ar(t,e,r.arrowGap):t,o=r.arrowAt==="source"?Sr(e,t,r.arrowSize,r.headShape):r.arrowAt==="target"?Sr(t,e,r.arrowSize,r.headShape):void 0;return Bn(n,[],i,o,0)}function nw(e,t,r,n=-90,i=-60,o=350){const s=n*Math.PI/180,a=i*Math.PI/180,c=s-Math.PI/2,u=c-a/2,l=c+a/2,d=1.4*o*(t/3+1),h={x:e.x+Math.cos(u)*d,y:e.y+Math.sin(u)*d},p={x:e.x+Math.cos(l)*d,y:e.y+Math.sin(l)*d},y={x:e.x,y:e.y},m=kt(y,h,e),g=kt(y,p,e);if(!m||!g)return null;const b={x:(h.x+p.x)/2,y:(h.y+p.y)/2};let w=ar(m,h,r.srcDist),v=ar(g,p,r.tgtDist),x;if(r.arrowAt==="target"){const S=v;v=ar(g,p,r.tgtDist+r.arrowGap),x=Sr(S,p,r.arrowSize,r.headShape)}else if(r.arrowAt==="source"){const S=w;w=ar(m,h,r.srcDist+r.arrowGap),x=Sr(S,h,r.arrowSize,r.headShape)}return{d:`M${Qe(w)} Q${Qe(h)} ${Qe(b)} Q${Qe(p)} ${Qe(v)}`,arrow:x,label:{x:b.x,y:b.y,angle:Wr(p.x-h.x,p.y-h.y)}}}const yt=e=>Math.round(e*1e3)/1e3;function Zm(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 i=t.getBoundingClientRect();if(!i.width||!i.height)return;const o=t,s=typeof o.getScreenCTM=="function"?o.getScreenCTM():null,a=typeof o.getTotalLength=="function"?o.getTotalLength():0,c=o.points,u=(c==null?void 0:c.numberOfItems)||128,l=s&&a>0?Array.from({length:u},(d,h)=>{const p=c!=null&&c.numberOfItems?c.getItem(h):o.getPointAtLength(a*h/u);return{x:yt((s.a*p.x+s.c*p.y+s.e-r.left)/n),y:yt((s.b*p.x+s.d*p.y+s.f-r.top)/n)}}):void 0;return{left:yt((i.left-r.left)/n),top:yt((i.top-r.top)/n),width:t instanceof HTMLElement?t.offsetWidth:yt(i.width/n),height:t instanceof HTMLElement?t.offsetHeight:yt(i.height/n),radius:parseFloat(getComputedStyle(t).borderTopLeftRadius)||0,...l?{outline:l}:{}}}function en(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(i=>({x:r+i.x,y:n+i.y}))}:{}}}function ow(e,t,r,n,i){var l;const o=i!=="TB"&&i!=="BT",s=o?"top":"left",a=o?"bottom":"right",c=new Map;for(const d of n)for(const[h,p,y]of[[d.source,d.sourceProperty,d.target],[d.target,d.targetProperty,d.source]]){const m=t.get(y);if(p===void 0||!m||y===h)continue;const g=r.get(y),b=JSON.stringify([h,p]),w=c.get(b)??[];w.push(g?en(m,g):m),c.set(b,w)}const u=new Map(e);for(const[d,h]of e){const p=t.get(d);if(!p||!h.some(v=>v.placement==="config"))continue;const y=r.get(d),m=y?en(p,y):p,g={x:p.w/2,y:p.h/2,w:p.w,h:p.h},b=y?en(g,y):g,w=new Map;for(const v of h){if(v.placement!=="config")continue;const C=(c.get(JSON.stringify([d,v.property]))??[]).reduce((E,I)=>E+(o?I.y-m.y:I.x-m.x),0),S=((l=v.anchor)==null?void 0:l.side)===a?a:s;w.set(v,C<-.001?s:C>.001?a:S)}u.set(d,h.map(v=>{const x=w.get(v);if(!x)return v;const C=h.filter(I=>w.get(I)===x),S=(C.indexOf(v)+1)/(C.length+1),E=Hm(b,x,S);return{...v,anchor:E,top:E.y,height:0}}))}return u}function td(e,t,r){const n=new Set(t.map(a=>a.id));if(!n.has(e))return new Set;const i=new Set([e]);let o=!0;for(;o;){o=!1;for(const a of t)!i.has(a.id)&&(i.has(a.parent??"")||a.id.startsWith(`${e}.`))&&(i.add(a.id),o=!0)}const s=new Set(i);for(const a of r)i.has(a.source)&&n.has(a.target)&&s.add(a.target),i.has(a.target)&&n.has(a.source)&&s.add(a.source);return s}const Lr='"Helvetica Neue", Helvetica, sans-serif';let Ft;const Cn=new Map;function un(e,t){const r=`${t}|${e}`,n=Cn.get(r);if(n!==void 0)return n;Ft===void 0&&(Ft=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let i;return Ft?(Ft.font=t,i=Ft.measureText(e).width):i=e.length*(parseFloat(t)||16)*.55,Cn.size>5e3&&Cn.clear(),Cn.set(r,i),i}function iw(e,t,r){const n=[];for(const i of String(e).split(`
|
|
209
|
-
`)){const o=i.split(/\s+/).filter(Boolean);if(!o.length){n.push("");continue}let s="";for(const a of o){const c=s?`${s} ${a}`:a;!s||un(c,t)<=r?s=c:(n.push(s),s=a)}n.push(s)}return n}const nd=e=>e.stopPropagation();function aw({id:e,rect:t,label:r,labelLayer:n,labelContent:i,style:o,onSelect:s,onCollapse:a,selected:c=!1}){const u=t.x2-t.x1,l=t.y2-t.y1,d=o.borderWidth,h=o.borderStyle==="dashed"?`${d*4} ${d*2}`:o.borderStyle==="dotted"?`${d} ${d}`:void 0,p=t.x1+u/2,y=o.labelPosition==="top"?t.y1+o.labelMargin-o.fontSize/2:o.labelPosition==="bottom"?t.y2-o.labelMargin+o.fontSize/2:t.y1+l/2,m=r?un(r,`bold ${o.fontSize}px ${Lr}`):0,g=o.fontSize/5,b=r||c&&a?f.jsxs("g",{className:"flow-sdk-container-label","data-node-id":e,children:[c&&a&&f.jsx("foreignObject",{x:p+m/2+g+8,y:y-24,width:48,height:48,"data-flow-content-toggle":"",style:{pointerEvents:"auto"},children:f.jsx(Ie,{label:"Show icon",children:f.jsx(Se,{"aria-label":"Show icon",icon:f.jsx(K.PiCircleFill,{}),variant:"ghost",style:{width:48,height:48,color:o.textColor},onClick:w=>{w.stopPropagation(),a(e)}})})}),i?f.jsx("foreignObject",{x:p-m/2-g,y:y-o.fontSize/2-g,width:m+2*g,height:o.fontSize+2*g,style:{overflow:"visible"},onClick:nd,children:i}):r&&f.jsxs(f.Fragment,{children:[f.jsx("rect",{x:p-m/2-g,y:y-o.fontSize/2-g,width:m+2*g,height:o.fontSize+2*g,fill:o.textColor==="transparent"?"transparent":o.labelBg}),f.jsx("text",{x:p,y,fill:o.textColor,fontSize:o.fontSize,fontWeight:"bold",fontFamily:Lr,style:{fontSize:o.fontSize,fontWeight:"bold",fontFamily:Lr},textAnchor:"middle",dominantBaseline:"central",children:r})]})]}):null;return f.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:nd,onClick:w=>{w.stopPropagation(),s==null||s(e,{shiftKey:w.shiftKey,ctrlKey:w.ctrlKey,metaKey:w.metaKey,altKey:w.altKey})},children:[f.jsx("rect",{x:t.x1,y:t.y1,width:u,height:l,rx:o.borderRadius,ry:o.borderRadius,fill:o.bgColor,fillOpacity:o.bgOpacity,stroke:o.borderColor,strokeWidth:o.borderStyle==="double"?d/3:d,strokeDasharray:h}),o.borderStyle==="double"&&f.jsx("rect",{x:t.x1+d*2/3,y:t.y1+d*2/3,width:Math.max(0,u-d*4/3),height:Math.max(0,l-d*4/3),rx:Math.max(0,o.borderRadius-d*2/3),ry:Math.max(0,o.borderRadius-d*2/3),fill:"none",stroke:o.borderColor,strokeWidth:d/3}),o.animated&&d>0&&f.jsx(Um,{variant:o.animationVariant,x:t.x1,y:t.y1,width:u,height:l,radius:o.borderRadius,color:o.animationColor||o.borderColor,strokeWidth:Math.max(8,d*1.6)}),n&&b?tn.createPortal(b,n):b]})}const sw=_.memo(aw),Tn=45,Ym=70,nt=15,Xm=50;function Qm(e,t,r=Tn){const n=`${r}px ${Lr}`,i=e?iw(e,n,200*r/Tn):[],o=t?48+(i.length?12:0):0,s=o+Math.max(0,...i.map(u=>un(u,n))),a=Math.max(i.length*r,t?48:0),c=i.length||t?2*nt:0;return{lines:i,iconWidth:o,contentWidth:s,contentHeight:a,width:s+c,height:a+c}}const rn=6,eb=3,tl=.3,cw=8,nl=Math.max(Math.pow(rn*13.37,.9),29)*eb-cw/tl,rb=rn*eb*2,En=80,uw=2*En+nl*tl+100,lw=36+2*Math.max(80,rb+nl*tl);function Fu(e){return e.sourceProperty!==void 0||e.targetProperty!==void 0}function Bu(e,t){return t==="auto"||(t==="properties"?Fu(e):!Fu(e))}function vt(e,t,r){return r!=="properties"||e!=="root"||t.some(n=>(n.source===e||n.target===e)&&Fu(n))}function dw(e,t,r,n=!1,i){if(!n)return{nodes:e,edges:t};const o=e.filter(a=>vt(a.id,t,r)&&(!i||i.has(a.id))),s=new Set(o.map(a=>a.id));return{nodes:o,edges:t.filter(a=>Bu(a,r)&&s.has(a.source)&&s.has(a.target))}}const fw=500,hw="32 18",pw=e=>e.stopPropagation();function gw({id:e,reveal:t,onRevealComplete:r,edgeData:n,validationIssue:i,edgeType:o="rounded-orthogonal",edgeRadius:s,customEdgeTypes:a,source:c,target:u,sourceProperty:l,targetProperty:d,sourceY:h,targetY:p,sourcePort:y,targetPort:m,propertyMode:g=!1,dir:b,turn:w,labelAtTarget:v,labelFraction:x,color:C,connectorColor:S,labelBg:E,labelLayer:I,label:A,dashed:M,animated:j,inverted:R,loopIndex:P=0,onSelect:k}){const q=n==null?void 0:n.icon,O=g?Tn:Ym,{lines:z,iconWidth:U,contentWidth:se,contentHeight:Q}=_.useMemo(()=>Qm(A,q,O),[A,q,O]),Y=_.useMemo(()=>{const G={srcDist:En,tgtDist:En,arrowGap:rb,arrowSize:nl,headShape:g&&(R?h!==void 0||y:p!==void 0||m)?"square":"triangle",radius:s??(v?40:fw),arrowAt:R?"source":"target",labelTargetLength:v?se+2*nt:void 0,labelFraction:v?x:void 0},le=h!==void 0||p!==void 0||!!y||!!m,ue=rd(c,u,b,h,p,0),Ce=h===void 0&&p===void 0&&(b==="downward"||b==="upward"),ye=y??{...ue.sourcePoint,side:Ce?b==="upward"?"top":"bottom":b==="leftward"?"left":"right"},Me=m??{...ue.targetPoint,side:Ce?b==="upward"?"bottom":"top":b==="leftward"?"right":"left"},ee=c.x===u.x&&c.y===u.y,he=y||m?ew(ye,Me,{...G,srcDist:18,tgtDist:18},o):le?Ql(c,u,b,h,p,w,{...G,srcDist:18,tgtDist:18,radius:s??Math.min(G.radius,40)}):ee?nw(c,P,{...G,srcDist:0,tgtDist:0}):ed(c,u,b,w,G);if(!he)return null;const ve=rd(c,u,b,h,p,le?18:En);y&&(ve.sourcePoint=wt(y,18)),m&&(ve.targetPoint=wt(m,18));const je=Object.prototype.hasOwnProperty.call(a??{},o)?a==null?void 0:a[o]:void 0;if(je){const qe={rightward:"LR",leftward:"RL",downward:"TB",upward:"BT"};return je({edge:n??{id:e,source:"",target:""},source:{...c},target:{...u},...ve,direction:qe[b],sourceY:h,targetY:p,inverted:!!R,defaultGeometry:he})??he}return ee||y||m?he:o==="straight"?le?Jm(ve.sourcePoint,ve.targetPoint,G):Km([c,u],c,u,G):o==="bezier"?tw(ve.sourcePoint,ve.targetPoint,le?b==="leftward"?"leftward":"rightward":b,G):o==="orthogonal"?le?Ql(c,u,b,h,p,w,{...G,srcDist:18,tgtDist:18,radius:0}):ed(c,u,b,w,{...G,radius:0}):he},[c,e,n,o,s,a,u,g,h,p,y,m,b,w,R,P,v,x,se]);if(!Y)return null;const ge=(b==="rightward"||b==="leftward")&&!Object.prototype.hasOwnProperty.call(a??{},o)&&!(g&&(h!==void 0||p!==void 0||y||m)),ce=ge?`translate(${Y.label.x} ${Y.label.y-Q/2-2*nt})`:`translate(${Y.label.x} ${Y.label.y}) rotate(${Y.label.angle}) translate(${b==="downward"||b==="upward"||v||Object.prototype.hasOwnProperty.call(a??{},o)?0:Xm} 0)`,$=i!=null&&i.startsWith("Unverified:")?"#b45309":"#dc2626",V=i?$:C,W=i?f.jsxs("g",{className:"flow-sdk-edge-validation",role:"img","aria-label":i,transform:`translate(${Y.label.x} ${Y.label.y-z.length*O/2-55})`,children:[f.jsx("title",{children:i}),f.jsx(Or,{name:"PiWarningCircleFill",svg:!0,size:48,x:-24,y:-24,color:$})]}):null,N=j&&(n==null?void 0:n.edgeAnimationVariant)==="traveling",ne=!N&&(M||j)?hw:void 0,be=j&&!N?`flow-sdk-edge-anim${R?" flow-sdk-edge-anim-rev":""}`:void 0;let fe=null;const J=t?{"--flow-edge-reveal-duration":`${t.durationMs??600}ms`,"--flow-edge-reveal-state":t.paused?"paused":"running"}:void 0;if(z.length||q){const G=se,le=Q;fe=f.jsxs("g",{className:`flow-sdk-edge-label${t?" flow-sdk-edge-reveal-end":""}`,style:J,"data-label-transform":ce,"data-label-horizontal":ge||void 0,"data-edge-id":e,"data-source-property":l,"data-target-property":d,transform:ce,children:[f.jsx("rect",{x:-G/2-nt,y:-le/2-nt,width:G+2*nt,height:le+2*nt,fill:C==="transparent"?"transparent":E}),f.jsx("text",{fill:C,fontSize:O,style:{fontSize:O,fontFamily:Lr},fontFamily:Lr,textAnchor:"middle",dominantBaseline:"central",children:z.map((ue,Ce)=>f.jsx("tspan",{x:U/2,y:(Ce-(z.length-1)/2)*O,children:ue},Ce))}),q&&f.jsxs("g",{className:"flow-sdk-edge-icon",opacity:C==="transparent"?0:1,children:[f.jsx("title",{children:A?`Edge icon: ${A}`:"Edge icon"}),f.jsx("rect",{x:-G/2,y:-24,width:48,height:48,fill:"transparent"}),f.jsx(Or,{name:q,svg:!0,size:48,x:-G/2,y:-24,color:C})]})]})}const te=f.jsxs(f.Fragment,{children:[f.jsx("path",{d:Y.d,fill:"none",stroke:V,strokeWidth:rn,strokeOpacity:N?.35:void 0,strokeDasharray:ne,className:be}),N&&f.jsx(V0,{path:Y.d,color:V,width:rn*1.6,reversed:R})]});return f.jsxs("g",{className:"flow-sdk-edge",style:J,"data-edge-id":e,"data-source-property":l,"data-target-property":d,"data-validation":i?i.startsWith("Unverified:")?"unverified":"invalid":void 0,"aria-label":i,onPointerDown:pw,onClick:G=>{G.stopPropagation(),k==null||k(e)},children:[t?f.jsx(G0,{path:Y.d,width:rn*4,reversed:R,onComplete:()=>r==null?void 0:r(e),children:te}):te,Y.arrow&&f.jsx("path",{className:t?"flow-sdk-edge-reveal-end":void 0,d:Y.arrow,fill:i?$:S??V}),I&&fe?tn.createPortal(fe,I):fe,I&&W?tn.createPortal(W,I):W,f.jsx("path",{className:"flow-sdk-edge-hit",d:Y.d,fill:"none",stroke:"transparent"})]})}const od=_.memo(gw),id=(e,t)=>e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top;function yw(e){const t=e.querySelector(".flow-sdk-labels"),r=t==null?void 0:t.getScreenCTM();if(!t||!r)return;const n=r.inverse(),i=(u,l=0)=>{const d=u.getBoundingClientRect(),h=new DOMPoint(d.left,d.top).matrixTransform(n),p=new DOMPoint(d.right,d.bottom).matrixTransform(n);return{left:h.x-l,right:p.x+l,top:h.y-l,bottom:p.y+l}},o=[...e.querySelectorAll(".flow-sdk-node, .flow-sdk-node button")].filter(u=>{const l=u.getBoundingClientRect(),d=getComputedStyle(u);return l.width>0&&l.height>0&&d.visibility!=="hidden"&&d.opacity!=="0"}).map(u=>i(u,24));for(const u of t.querySelectorAll(".flow-sdk-container-label"))o.push(i(u,12));const s=[...t.querySelectorAll(".flow-sdk-edge-label")];for(const u of s)u.setAttribute("transform",u.dataset.labelTransform??"");const a=new Map(s.map(u=>[u,i(u,8)])),c=new Map([...e.querySelectorAll(".flow-sdk-edge")].map(u=>[u.dataset.edgeId,u.querySelector("path")]));for(const u of s){const l=u.dataset.labelHorizontal==="true",d=a.get(u);a.delete(u);const h=E=>o.some(I=>id(E,I))||[...a.values()].some(I=>id(E,I));if(!l&&!h(d)){a.set(u,d);continue}const p=c.get(u.dataset.edgeId),y=u.querySelector("rect");if(!p||!y)continue;const m=y.getBBox(),g=p.getTotalLength();if(!Number.isFinite(g)||g<=0)continue;const b=(d.left+d.right)/2,w=(d.top+d.bottom)/2,v=Math.min(256,Math.max(16,Math.ceil(g/24))),x=Array.from({length:v+1},(E,I)=>p.getPointAtLength(g*I/v)),S=Array.from({length:v+1},(E,I)=>{const A=g*I/v,M=x[I],j=l?{x:M.x,y:M.y-m.height/2-15}:M,R=p.getPointAtLength(Math.max(0,A-2)),P=p.getPointAtLength(Math.min(g,A+2));let k=Math.atan2(P.y-R.y,P.x-R.x)*180/Math.PI;k>90&&(k-=180),k<-90&&(k+=180);const q=Math.abs(k)<1;l&&(k=0);const O=k*Math.PI/180,z=Math.abs(Math.cos(O))*m.width+Math.abs(Math.sin(O))*m.height,U=Math.abs(Math.sin(O))*m.width+Math.abs(Math.cos(O))*m.height;return{point:j,angle:k,straight:q,score:Math.hypot(j.x-b,j.y-w),bounds:{left:j.x-z/2-8,right:j.x+z/2+8,top:j.y-U/2-8,bottom:j.y+U/2+8}}}).sort((E,I)=>E.score-I.score).find(E=>!h(E.bounds)&&(!l||E.straight&&!x.some(I=>I.x>E.bounds.left&&I.x<E.bounds.right&&I.y>E.bounds.top&&I.y<E.bounds.bottom)));S?(u.setAttribute("transform",`translate(${S.point.x} ${S.point.y}) rotate(${S.angle})`),a.set(u,S.bounds)):a.set(u,d)}}var Sn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function mw(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ol(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 mo,ad;function bw(){if(ad)return mo;ad=1;function e(){this.__data__=[],this.size=0}return mo=e,mo}var bo,sd;function It(){if(sd)return bo;sd=1;function e(t,r){return t===r||t!==t&&r!==r}return bo=e,bo}var vo,cd;function zn(){if(cd)return vo;cd=1;var e=It();function t(r,n){for(var i=r.length;i--;)if(e(r[i][0],n))return i;return-1}return vo=t,vo}var xo,ud;function vw(){if(ud)return xo;ud=1;var e=zn(),t=Array.prototype,r=t.splice;function n(i){var o=this.__data__,s=e(o,i);if(s<0)return!1;var a=o.length-1;return s==a?o.pop():r.call(o,s,1),--this.size,!0}return xo=n,xo}var wo,ld;function xw(){if(ld)return wo;ld=1;var e=zn();function t(r){var n=this.__data__,i=e(n,r);return i<0?void 0:n[i][1]}return wo=t,wo}var Co,dd;function ww(){if(dd)return Co;dd=1;var e=zn();function t(r){return e(this.__data__,r)>-1}return Co=t,Co}var So,fd;function Cw(){if(fd)return So;fd=1;var e=zn();function t(r,n){var i=this.__data__,o=e(i,r);return o<0?(++this.size,i.push([r,n])):i[o][1]=n,this}return So=t,So}var _o,hd;function Dn(){if(hd)return _o;hd=1;var e=bw(),t=vw(),r=xw(),n=ww(),i=Cw();function o(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var u=s[a];this.set(u[0],u[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,_o=o,_o}var Eo,pd;function Sw(){if(pd)return Eo;pd=1;var e=Dn();function t(){this.__data__=new e,this.size=0}return Eo=t,Eo}var jo,gd;function _w(){if(gd)return jo;gd=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return jo=e,jo}var ko,yd;function Ew(){if(yd)return ko;yd=1;function e(t){return this.__data__.get(t)}return ko=e,ko}var Ro,md;function jw(){if(md)return Ro;md=1;function e(t){return this.__data__.has(t)}return Ro=e,Ro}var Po,bd;function tb(){if(bd)return Po;bd=1;var e=typeof Sn=="object"&&Sn&&Sn.Object===Object&&Sn;return Po=e,Po}var Ao,vd;function Ar(){if(vd)return Ao;vd=1;var e=tb(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Ao=r,Ao}var To,xd;function Ot(){if(xd)return To;xd=1;var e=Ar(),t=e.Symbol;return To=t,To}var Io,wd;function kw(){if(wd)return Io;wd=1;var e=Ot(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,i=e?e.toStringTag:void 0;function o(s){var a=r.call(s,i),c=s[i];try{s[i]=void 0;var u=!0}catch{}var l=n.call(s);return u&&(a?s[i]=c:delete s[i]),l}return Io=o,Io}var Oo,Cd;function Rw(){if(Cd)return Oo;Cd=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return Oo=r,Oo}var Mo,Sd;function lt(){if(Sd)return Mo;Sd=1;var e=Ot(),t=kw(),r=Rw(),n="[object Null]",i="[object Undefined]",o=e?e.toStringTag:void 0;function s(a){return a==null?a===void 0?i:n:o&&o in Object(a)?t(a):r(a)}return Mo=s,Mo}var qo,_d;function _r(){if(_d)return qo;_d=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return qo=e,qo}var $o,Ed;function fn(){if(Ed)return $o;Ed=1;var e=lt(),t=_r(),r="[object AsyncFunction]",n="[object Function]",i="[object GeneratorFunction]",o="[object Proxy]";function s(a){if(!t(a))return!1;var c=e(a);return c==n||c==i||c==r||c==o}return $o=s,$o}var No,jd;function Pw(){if(jd)return No;jd=1;var e=Ar(),t=e["__core-js_shared__"];return No=t,No}var Lo,kd;function Aw(){if(kd)return Lo;kd=1;var e=Pw(),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 Lo=r,Lo}var Fo,Rd;function nb(){if(Rd)return Fo;Rd=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 Fo=r,Fo}var Bo,Pd;function Tw(){if(Pd)return Bo;Pd=1;var e=fn(),t=Aw(),r=_r(),n=nb(),i=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,s=Function.prototype,a=Object.prototype,c=s.toString,u=a.hasOwnProperty,l=RegExp("^"+c.call(u).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(h){if(!r(h)||t(h))return!1;var p=e(h)?l:o;return p.test(n(h))}return Bo=d,Bo}var zo,Ad;function Iw(){if(Ad)return zo;Ad=1;function e(t,r){return t==null?void 0:t[r]}return zo=e,zo}var Do,Td;function dt(){if(Td)return Do;Td=1;var e=Tw(),t=Iw();function r(n,i){var o=t(n,i);return e(o)?o:void 0}return Do=r,Do}var Vo,Id;function il(){if(Id)return Vo;Id=1;var e=dt(),t=Ar(),r=e(t,"Map");return Vo=r,Vo}var Wo,Od;function Vn(){if(Od)return Wo;Od=1;var e=dt(),t=e(Object,"create");return Wo=t,Wo}var Go,Md;function Ow(){if(Md)return Go;Md=1;var e=Vn();function t(){this.__data__=e?e(null):{},this.size=0}return Go=t,Go}var Uo,qd;function Mw(){if(qd)return Uo;qd=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return Uo=e,Uo}var Ho,$d;function qw(){if($d)return Ho;$d=1;var e=Vn(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function i(o){var s=this.__data__;if(e){var a=s[o];return a===t?void 0:a}return n.call(s,o)?s[o]:void 0}return Ho=i,Ho}var Ko,Nd;function $w(){if(Nd)return Ko;Nd=1;var e=Vn(),t=Object.prototype,r=t.hasOwnProperty;function n(i){var o=this.__data__;return e?o[i]!==void 0:r.call(o,i)}return Ko=n,Ko}var Jo,Ld;function Nw(){if(Ld)return Jo;Ld=1;var e=Vn(),t="__lodash_hash_undefined__";function r(n,i){var o=this.__data__;return this.size+=this.has(n)?0:1,o[n]=e&&i===void 0?t:i,this}return Jo=r,Jo}var Zo,Fd;function Lw(){if(Fd)return Zo;Fd=1;var e=Ow(),t=Mw(),r=qw(),n=$w(),i=Nw();function o(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var u=s[a];this.set(u[0],u[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,Zo=o,Zo}var Yo,Bd;function Fw(){if(Bd)return Yo;Bd=1;var e=Lw(),t=Dn(),r=il();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return Yo=n,Yo}var Xo,zd;function Bw(){if(zd)return Xo;zd=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return Xo=e,Xo}var Qo,Dd;function Wn(){if(Dd)return Qo;Dd=1;var e=Bw();function t(r,n){var i=r.__data__;return e(n)?i[typeof n=="string"?"string":"hash"]:i.map}return Qo=t,Qo}var ei,Vd;function zw(){if(Vd)return ei;Vd=1;var e=Wn();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return ei=t,ei}var ri,Wd;function Dw(){if(Wd)return ri;Wd=1;var e=Wn();function t(r){return e(this,r).get(r)}return ri=t,ri}var ti,Gd;function Vw(){if(Gd)return ti;Gd=1;var e=Wn();function t(r){return e(this,r).has(r)}return ti=t,ti}var ni,Ud;function Ww(){if(Ud)return ni;Ud=1;var e=Wn();function t(r,n){var i=e(this,r),o=i.size;return i.set(r,n),this.size+=i.size==o?0:1,this}return ni=t,ni}var oi,Hd;function al(){if(Hd)return oi;Hd=1;var e=Fw(),t=zw(),r=Dw(),n=Vw(),i=Ww();function o(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var u=s[a];this.set(u[0],u[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,oi=o,oi}var ii,Kd;function Gw(){if(Kd)return ii;Kd=1;var e=Dn(),t=il(),r=al(),n=200;function i(o,s){var a=this.__data__;if(a instanceof e){var c=a.__data__;if(!t||c.length<n-1)return c.push([o,s]),this.size=++a.size,this;a=this.__data__=new r(c)}return a.set(o,s),this.size=a.size,this}return ii=i,ii}var ai,Jd;function Gn(){if(Jd)return ai;Jd=1;var e=Dn(),t=Sw(),r=_w(),n=Ew(),i=jw(),o=Gw();function s(a){var c=this.__data__=new e(a);this.size=c.size}return s.prototype.clear=t,s.prototype.delete=r,s.prototype.get=n,s.prototype.has=i,s.prototype.set=o,ai=s,ai}var si,Zd;function sl(){if(Zd)return si;Zd=1;function e(t,r){for(var n=-1,i=t==null?0:t.length;++n<i&&r(t[n],n,t)!==!1;);return t}return si=e,si}var ci,Yd;function ob(){if(Yd)return ci;Yd=1;var e=dt(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return ci=t,ci}var ui,Xd;function Un(){if(Xd)return ui;Xd=1;var e=ob();function t(r,n,i){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):r[n]=i}return ui=t,ui}var li,Qd;function Hn(){if(Qd)return li;Qd=1;var e=Un(),t=It(),r=Object.prototype,n=r.hasOwnProperty;function i(o,s,a){var c=o[s];(!(n.call(o,s)&&t(c,a))||a===void 0&&!(s in o))&&e(o,s,a)}return li=i,li}var di,ef;function hn(){if(ef)return di;ef=1;var e=Hn(),t=Un();function r(n,i,o,s){var a=!o;o||(o={});for(var c=-1,u=i.length;++c<u;){var l=i[c],d=s?s(o[l],n[l],l,o,n):void 0;d===void 0&&(d=n[l]),a?t(o,l,d):e(o,l,d)}return o}return di=r,di}var fi,rf;function Uw(){if(rf)return fi;rf=1;function e(t,r){for(var n=-1,i=Array(t);++n<t;)i[n]=r(n);return i}return fi=e,fi}var hi,tf;function Mr(){if(tf)return hi;tf=1;function e(t){return t!=null&&typeof t=="object"}return hi=e,hi}var pi,nf;function Hw(){if(nf)return pi;nf=1;var e=lt(),t=Mr(),r="[object Arguments]";function n(i){return t(i)&&e(i)==r}return pi=n,pi}var gi,of;function pn(){if(of)return gi;of=1;var e=Hw(),t=Mr(),r=Object.prototype,n=r.hasOwnProperty,i=r.propertyIsEnumerable,o=e((function(){return arguments})())?e:function(s){return t(s)&&n.call(s,"callee")&&!i.call(s,"callee")};return gi=o,gi}var yi,af;function rr(){if(af)return yi;af=1;var e=Array.isArray;return yi=e,yi}var Wt={exports:{}},mi,sf;function Kw(){if(sf)return mi;sf=1;function e(){return!1}return mi=e,mi}Wt.exports;var cf;function Mt(){return cf||(cf=1,(function(e,t){var r=Ar(),n=Kw(),i=t&&!t.nodeType&&t,o=i&&!0&&e&&!e.nodeType&&e,s=o&&o.exports===i,a=s?r.Buffer:void 0,c=a?a.isBuffer:void 0,u=c||n;e.exports=u})(Wt,Wt.exports)),Wt.exports}var bi,uf;function Kn(){if(uf)return bi;uf=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,i){var o=typeof n;return i=i??e,!!i&&(o=="number"||o!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<i}return bi=r,bi}var vi,lf;function cl(){if(lf)return vi;lf=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return vi=t,vi}var xi,df;function Jw(){if(df)return xi;df=1;var e=lt(),t=cl(),r=Mr(),n="[object Arguments]",i="[object Array]",o="[object Boolean]",s="[object Date]",a="[object Error]",c="[object Function]",u="[object Map]",l="[object Number]",d="[object Object]",h="[object RegExp]",p="[object Set]",y="[object String]",m="[object WeakMap]",g="[object ArrayBuffer]",b="[object DataView]",w="[object Float32Array]",v="[object Float64Array]",x="[object Int8Array]",C="[object Int16Array]",S="[object Int32Array]",E="[object Uint8Array]",I="[object Uint8ClampedArray]",A="[object Uint16Array]",M="[object Uint32Array]",j={};j[w]=j[v]=j[x]=j[C]=j[S]=j[E]=j[I]=j[A]=j[M]=!0,j[n]=j[i]=j[g]=j[o]=j[b]=j[s]=j[a]=j[c]=j[u]=j[l]=j[d]=j[h]=j[p]=j[y]=j[m]=!1;function R(P){return r(P)&&t(P.length)&&!!j[e(P)]}return xi=R,xi}var wi,ff;function Jn(){if(ff)return wi;ff=1;function e(t){return function(r){return t(r)}}return wi=e,wi}var Gt={exports:{}};Gt.exports;var hf;function ul(){return hf||(hf=1,(function(e,t){var r=tb(),n=t&&!t.nodeType&&t,i=n&&!0&&e&&!e.nodeType&&e,o=i&&i.exports===n,s=o&&r.process,a=(function(){try{var c=i&&i.require&&i.require("util").types;return c||s&&s.binding&&s.binding("util")}catch{}})();e.exports=a})(Gt,Gt.exports)),Gt.exports}var Ci,pf;function gn(){if(pf)return Ci;pf=1;var e=Jw(),t=Jn(),r=ul(),n=r&&r.isTypedArray,i=n?t(n):e;return Ci=i,Ci}var Si,gf;function ib(){if(gf)return Si;gf=1;var e=Uw(),t=pn(),r=rr(),n=Mt(),i=Kn(),o=gn(),s=Object.prototype,a=s.hasOwnProperty;function c(u,l){var d=r(u),h=!d&&t(u),p=!d&&!h&&n(u),y=!d&&!h&&!p&&o(u),m=d||h||p||y,g=m?e(u.length,String):[],b=g.length;for(var w in u)(l||a.call(u,w))&&!(m&&(w=="length"||p&&(w=="offset"||w=="parent")||y&&(w=="buffer"||w=="byteLength"||w=="byteOffset")||i(w,b)))&&g.push(w);return g}return Si=c,Si}var _i,yf;function Zn(){if(yf)return _i;yf=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,i=typeof n=="function"&&n.prototype||e;return r===i}return _i=t,_i}var Ei,mf;function ab(){if(mf)return Ei;mf=1;function e(t,r){return function(n){return t(r(n))}}return Ei=e,Ei}var ji,bf;function Zw(){if(bf)return ji;bf=1;var e=ab(),t=e(Object.keys,Object);return ji=t,ji}var ki,vf;function ll(){if(vf)return ki;vf=1;var e=Zn(),t=Zw(),r=Object.prototype,n=r.hasOwnProperty;function i(o){if(!e(o))return t(o);var s=[];for(var a in Object(o))n.call(o,a)&&a!="constructor"&&s.push(a);return s}return ki=i,ki}var Ri,xf;function Fr(){if(xf)return Ri;xf=1;var e=fn(),t=cl();function r(n){return n!=null&&t(n.length)&&!e(n)}return Ri=r,Ri}var Pi,wf;function Xr(){if(wf)return Pi;wf=1;var e=ib(),t=ll(),r=Fr();function n(i){return r(i)?e(i):t(i)}return Pi=n,Pi}var Ai,Cf;function Yw(){if(Cf)return Ai;Cf=1;var e=hn(),t=Xr();function r(n,i){return n&&e(i,t(i),n)}return Ai=r,Ai}var Ti,Sf;function Xw(){if(Sf)return Ti;Sf=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return Ti=e,Ti}var Ii,_f;function Qw(){if(_f)return Ii;_f=1;var e=_r(),t=Zn(),r=Xw(),n=Object.prototype,i=n.hasOwnProperty;function o(s){if(!e(s))return r(s);var a=t(s),c=[];for(var u in s)u=="constructor"&&(a||!i.call(s,u))||c.push(u);return c}return Ii=o,Ii}var Oi,Ef;function ft(){if(Ef)return Oi;Ef=1;var e=ib(),t=Qw(),r=Fr();function n(i){return r(i)?e(i,!0):t(i)}return Oi=n,Oi}var Mi,jf;function e1(){if(jf)return Mi;jf=1;var e=hn(),t=ft();function r(n,i){return n&&e(i,t(i),n)}return Mi=r,Mi}var Ut={exports:{}};Ut.exports;var kf;function sb(){return kf||(kf=1,(function(e,t){var r=Ar(),n=t&&!t.nodeType&&t,i=n&&!0&&e&&!e.nodeType&&e,o=i&&i.exports===n,s=o?r.Buffer:void 0,a=s?s.allocUnsafe:void 0;function c(u,l){if(l)return u.slice();var d=u.length,h=a?a(d):new u.constructor(d);return u.copy(h),h}e.exports=c})(Ut,Ut.exports)),Ut.exports}var qi,Rf;function cb(){if(Rf)return qi;Rf=1;function e(t,r){var n=-1,i=t.length;for(r||(r=Array(i));++n<i;)r[n]=t[n];return r}return qi=e,qi}var $i,Pf;function ub(){if(Pf)return $i;Pf=1;function e(t,r){for(var n=-1,i=t==null?0:t.length,o=0,s=[];++n<i;){var a=t[n];r(a,n,t)&&(s[o++]=a)}return s}return $i=e,$i}var Ni,Af;function lb(){if(Af)return Ni;Af=1;function e(){return[]}return Ni=e,Ni}var Li,Tf;function dl(){if(Tf)return Li;Tf=1;var e=ub(),t=lb(),r=Object.prototype,n=r.propertyIsEnumerable,i=Object.getOwnPropertySymbols,o=i?function(s){return s==null?[]:(s=Object(s),e(i(s),function(a){return n.call(s,a)}))}:t;return Li=o,Li}var Fi,If;function r1(){if(If)return Fi;If=1;var e=hn(),t=dl();function r(n,i){return e(n,t(n),i)}return Fi=r,Fi}var Bi,Of;function fl(){if(Of)return Bi;Of=1;function e(t,r){for(var n=-1,i=r.length,o=t.length;++n<i;)t[o+n]=r[n];return t}return Bi=e,Bi}var zi,Mf;function Yn(){if(Mf)return zi;Mf=1;var e=ab(),t=e(Object.getPrototypeOf,Object);return zi=t,zi}var Di,qf;function db(){if(qf)return Di;qf=1;var e=fl(),t=Yn(),r=dl(),n=lb(),i=Object.getOwnPropertySymbols,o=i?function(s){for(var a=[];s;)e(a,r(s)),s=t(s);return a}:n;return Di=o,Di}var Vi,$f;function t1(){if($f)return Vi;$f=1;var e=hn(),t=db();function r(n,i){return e(n,t(n),i)}return Vi=r,Vi}var Wi,Nf;function fb(){if(Nf)return Wi;Nf=1;var e=fl(),t=rr();function r(n,i,o){var s=i(n);return t(n)?s:e(s,o(n))}return Wi=r,Wi}var Gi,Lf;function hb(){if(Lf)return Gi;Lf=1;var e=fb(),t=dl(),r=Xr();function n(i){return e(i,r,t)}return Gi=n,Gi}var Ui,Ff;function n1(){if(Ff)return Ui;Ff=1;var e=fb(),t=db(),r=ft();function n(i){return e(i,r,t)}return Ui=n,Ui}var Hi,Bf;function o1(){if(Bf)return Hi;Bf=1;var e=dt(),t=Ar(),r=e(t,"DataView");return Hi=r,Hi}var Ki,zf;function i1(){if(zf)return Ki;zf=1;var e=dt(),t=Ar(),r=e(t,"Promise");return Ki=r,Ki}var Ji,Df;function pb(){if(Df)return Ji;Df=1;var e=dt(),t=Ar(),r=e(t,"Set");return Ji=r,Ji}var Zi,Vf;function a1(){if(Vf)return Zi;Vf=1;var e=dt(),t=Ar(),r=e(t,"WeakMap");return Zi=r,Zi}var Yi,Wf;function qt(){if(Wf)return Yi;Wf=1;var e=o1(),t=il(),r=i1(),n=pb(),i=a1(),o=lt(),s=nb(),a="[object Map]",c="[object Object]",u="[object Promise]",l="[object Set]",d="[object WeakMap]",h="[object DataView]",p=s(e),y=s(t),m=s(r),g=s(n),b=s(i),w=o;return(e&&w(new e(new ArrayBuffer(1)))!=h||t&&w(new t)!=a||r&&w(r.resolve())!=u||n&&w(new n)!=l||i&&w(new i)!=d)&&(w=function(v){var x=o(v),C=x==c?v.constructor:void 0,S=C?s(C):"";if(S)switch(S){case p:return h;case y:return a;case m:return u;case g:return l;case b:return d}return x}),Yi=w,Yi}var Xi,Gf;function s1(){if(Gf)return Xi;Gf=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var i=n.length,o=new n.constructor(i);return i&&typeof n[0]=="string"&&t.call(n,"index")&&(o.index=n.index,o.input=n.input),o}return Xi=r,Xi}var Qi,Uf;function gb(){if(Uf)return Qi;Uf=1;var e=Ar(),t=e.Uint8Array;return Qi=t,Qi}var ea,Hf;function hl(){if(Hf)return ea;Hf=1;var e=gb();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return ea=t,ea}var ra,Kf;function c1(){if(Kf)return ra;Kf=1;var e=hl();function t(r,n){var i=n?e(r.buffer):r.buffer;return new r.constructor(i,r.byteOffset,r.byteLength)}return ra=t,ra}var ta,Jf;function u1(){if(Jf)return ta;Jf=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return ta=t,ta}var na,Zf;function l1(){if(Zf)return na;Zf=1;var e=Ot(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(i){return r?Object(r.call(i)):{}}return na=n,na}var oa,Yf;function yb(){if(Yf)return oa;Yf=1;var e=hl();function t(r,n){var i=n?e(r.buffer):r.buffer;return new r.constructor(i,r.byteOffset,r.length)}return oa=t,oa}var ia,Xf;function d1(){if(Xf)return ia;Xf=1;var e=hl(),t=c1(),r=u1(),n=l1(),i=yb(),o="[object Boolean]",s="[object Date]",a="[object Map]",c="[object Number]",u="[object RegExp]",l="[object Set]",d="[object String]",h="[object Symbol]",p="[object ArrayBuffer]",y="[object DataView]",m="[object Float32Array]",g="[object Float64Array]",b="[object Int8Array]",w="[object Int16Array]",v="[object Int32Array]",x="[object Uint8Array]",C="[object Uint8ClampedArray]",S="[object Uint16Array]",E="[object Uint32Array]";function I(A,M,j){var R=A.constructor;switch(M){case p:return e(A);case o:case s:return new R(+A);case y:return t(A,j);case m:case g:case b:case w:case v:case x:case C:case S:case E:return i(A,j);case a:return new R;case c:case d:return new R(A);case u:return r(A);case l:return new R;case h:return n(A)}}return ia=I,ia}var aa,Qf;function mb(){if(Qf)return aa;Qf=1;var e=_r(),t=Object.create,r=(function(){function n(){}return function(i){if(!e(i))return{};if(t)return t(i);n.prototype=i;var o=new n;return n.prototype=void 0,o}})();return aa=r,aa}var sa,eh;function bb(){if(eh)return sa;eh=1;var e=mb(),t=Yn(),r=Zn();function n(i){return typeof i.constructor=="function"&&!r(i)?e(t(i)):{}}return sa=n,sa}var ca,rh;function f1(){if(rh)return ca;rh=1;var e=qt(),t=Mr(),r="[object Map]";function n(i){return t(i)&&e(i)==r}return ca=n,ca}var ua,th;function h1(){if(th)return ua;th=1;var e=f1(),t=Jn(),r=ul(),n=r&&r.isMap,i=n?t(n):e;return ua=i,ua}var la,nh;function p1(){if(nh)return la;nh=1;var e=qt(),t=Mr(),r="[object Set]";function n(i){return t(i)&&e(i)==r}return la=n,la}var da,oh;function g1(){if(oh)return da;oh=1;var e=p1(),t=Jn(),r=ul(),n=r&&r.isSet,i=n?t(n):e;return da=i,da}var fa,ih;function vb(){if(ih)return fa;ih=1;var e=Gn(),t=sl(),r=Hn(),n=Yw(),i=e1(),o=sb(),s=cb(),a=r1(),c=t1(),u=hb(),l=n1(),d=qt(),h=s1(),p=d1(),y=bb(),m=rr(),g=Mt(),b=h1(),w=_r(),v=g1(),x=Xr(),C=ft(),S=1,E=2,I=4,A="[object Arguments]",M="[object Array]",j="[object Boolean]",R="[object Date]",P="[object Error]",k="[object Function]",q="[object GeneratorFunction]",O="[object Map]",z="[object Number]",U="[object Object]",se="[object RegExp]",Q="[object Set]",Y="[object String]",ge="[object Symbol]",ce="[object WeakMap]",$="[object ArrayBuffer]",V="[object DataView]",W="[object Float32Array]",N="[object Float64Array]",ne="[object Int8Array]",be="[object Int16Array]",fe="[object Int32Array]",J="[object Uint8Array]",te="[object Uint8ClampedArray]",G="[object Uint16Array]",le="[object Uint32Array]",ue={};ue[A]=ue[M]=ue[$]=ue[V]=ue[j]=ue[R]=ue[W]=ue[N]=ue[ne]=ue[be]=ue[fe]=ue[O]=ue[z]=ue[U]=ue[se]=ue[Q]=ue[Y]=ue[ge]=ue[J]=ue[te]=ue[G]=ue[le]=!0,ue[P]=ue[k]=ue[ce]=!1;function Ce(ye,Me,ee,he,ve,je){var qe,We=Me&S,Ye=Me&E,tr=Me&I;if(ee&&(qe=ve?ee(ye,he,ve,je):ee(ye)),qe!==void 0)return qe;if(!w(ye))return ye;var sr=m(ye);if(sr){if(qe=h(ye),!We)return s(ye,qe)}else{var Ae=d(ye),me=Ae==k||Ae==q;if(g(ye))return o(ye,We);if(Ae==U||Ae==A||me&&!ve){if(qe=Ye||me?{}:y(ye),!We)return Ye?c(ye,i(qe,ye)):a(ye,n(qe,ye))}else{if(!ue[Ae])return ve?ye:{};qe=p(ye,Ae,We)}}je||(je=new e);var Oe=je.get(ye);if(Oe)return Oe;je.set(ye,qe),v(ye)?ye.forEach(function(Xe){qe.add(Ce(Xe,Me,ee,Xe,ye,je))}):b(ye)&&ye.forEach(function(Xe,we){qe.set(we,Ce(Xe,Me,ee,we,ye,je))});var nr=tr?Ye?l:u:Ye?C:x,cr=sr?void 0:nr(ye);return t(cr||ye,function(Xe,we){cr&&(we=Xe,Xe=ye[we]),r(qe,we,Ce(Xe,Me,ee,we,ye,je))}),qe}return fa=Ce,fa}var ha,ah;function y1(){if(ah)return ha;ah=1;var e=vb(),t=4;function r(n){return e(n,t)}return ha=r,ha}var pa,sh;function pl(){if(sh)return pa;sh=1;function e(t){return function(){return t}}return pa=e,pa}var ga,ch;function m1(){if(ch)return ga;ch=1;function e(t){return function(r,n,i){for(var o=-1,s=Object(r),a=i(r),c=a.length;c--;){var u=a[t?c:++o];if(n(s[u],u,s)===!1)break}return r}}return ga=e,ga}var ya,uh;function gl(){if(uh)return ya;uh=1;var e=m1(),t=e();return ya=t,ya}var ma,lh;function yl(){if(lh)return ma;lh=1;var e=gl(),t=Xr();function r(n,i){return n&&e(n,i,t)}return ma=r,ma}var ba,dh;function b1(){if(dh)return ba;dh=1;var e=Fr();function t(r,n){return function(i,o){if(i==null)return i;if(!e(i))return r(i,o);for(var s=i.length,a=n?s:-1,c=Object(i);(n?a--:++a<s)&&o(c[a],a,c)!==!1;);return i}}return ba=t,ba}var va,fh;function Xn(){if(fh)return va;fh=1;var e=yl(),t=b1(),r=t(e);return va=r,va}var xa,hh;function ht(){if(hh)return xa;hh=1;function e(t){return t}return xa=e,xa}var wa,ph;function xb(){if(ph)return wa;ph=1;var e=ht();function t(r){return typeof r=="function"?r:e}return wa=t,wa}var Ca,gh;function wb(){if(gh)return Ca;gh=1;var e=sl(),t=Xn(),r=xb(),n=rr();function i(o,s){var a=n(o)?e:t;return a(o,r(s))}return Ca=i,Ca}var Sa,yh;function Cb(){return yh||(yh=1,Sa=wb()),Sa}var _a,mh;function v1(){if(mh)return _a;mh=1;var e=Xn();function t(r,n){var i=[];return e(r,function(o,s,a){n(o,s,a)&&i.push(o)}),i}return _a=t,_a}var Ea,bh;function x1(){if(bh)return Ea;bh=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return Ea=t,Ea}var ja,vh;function w1(){if(vh)return ja;vh=1;function e(t){return this.__data__.has(t)}return ja=e,ja}var ka,xh;function Sb(){if(xh)return ka;xh=1;var e=al(),t=x1(),r=w1();function n(i){var o=-1,s=i==null?0:i.length;for(this.__data__=new e;++o<s;)this.add(i[o])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,ka=n,ka}var Ra,wh;function C1(){if(wh)return Ra;wh=1;function e(t,r){for(var n=-1,i=t==null?0:t.length;++n<i;)if(r(t[n],n,t))return!0;return!1}return Ra=e,Ra}var Pa,Ch;function _b(){if(Ch)return Pa;Ch=1;function e(t,r){return t.has(r)}return Pa=e,Pa}var Aa,Sh;function Eb(){if(Sh)return Aa;Sh=1;var e=Sb(),t=C1(),r=_b(),n=1,i=2;function o(s,a,c,u,l,d){var h=c&n,p=s.length,y=a.length;if(p!=y&&!(h&&y>p))return!1;var m=d.get(s),g=d.get(a);if(m&&g)return m==a&&g==s;var b=-1,w=!0,v=c&i?new e:void 0;for(d.set(s,a),d.set(a,s);++b<p;){var x=s[b],C=a[b];if(u)var S=h?u(C,x,b,a,s,d):u(x,C,b,s,a,d);if(S!==void 0){if(S)continue;w=!1;break}if(v){if(!t(a,function(E,I){if(!r(v,I)&&(x===E||l(x,E,c,u,d)))return v.push(I)})){w=!1;break}}else if(!(x===C||l(x,C,c,u,d))){w=!1;break}}return d.delete(s),d.delete(a),w}return Aa=o,Aa}var Ta,_h;function S1(){if(_h)return Ta;_h=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(i,o){n[++r]=[o,i]}),n}return Ta=e,Ta}var Ia,Eh;function ml(){if(Eh)return Ia;Eh=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(i){n[++r]=i}),n}return Ia=e,Ia}var Oa,jh;function _1(){if(jh)return Oa;jh=1;var e=Ot(),t=gb(),r=It(),n=Eb(),i=S1(),o=ml(),s=1,a=2,c="[object Boolean]",u="[object Date]",l="[object Error]",d="[object Map]",h="[object Number]",p="[object RegExp]",y="[object Set]",m="[object String]",g="[object Symbol]",b="[object ArrayBuffer]",w="[object DataView]",v=e?e.prototype:void 0,x=v?v.valueOf:void 0;function C(S,E,I,A,M,j,R){switch(I){case w:if(S.byteLength!=E.byteLength||S.byteOffset!=E.byteOffset)return!1;S=S.buffer,E=E.buffer;case b:return!(S.byteLength!=E.byteLength||!j(new t(S),new t(E)));case c:case u:case h:return r(+S,+E);case l:return S.name==E.name&&S.message==E.message;case p:case m:return S==E+"";case d:var P=i;case y:var k=A&s;if(P||(P=o),S.size!=E.size&&!k)return!1;var q=R.get(S);if(q)return q==E;A|=a,R.set(S,E);var O=n(P(S),P(E),A,M,j,R);return R.delete(S),O;case g:if(x)return x.call(S)==x.call(E)}return!1}return Oa=C,Oa}var Ma,kh;function E1(){if(kh)return Ma;kh=1;var e=hb(),t=1,r=Object.prototype,n=r.hasOwnProperty;function i(o,s,a,c,u,l){var d=a&t,h=e(o),p=h.length,y=e(s),m=y.length;if(p!=m&&!d)return!1;for(var g=p;g--;){var b=h[g];if(!(d?b in s:n.call(s,b)))return!1}var w=l.get(o),v=l.get(s);if(w&&v)return w==s&&v==o;var x=!0;l.set(o,s),l.set(s,o);for(var C=d;++g<p;){b=h[g];var S=o[b],E=s[b];if(c)var I=d?c(E,S,b,s,o,l):c(S,E,b,o,s,l);if(!(I===void 0?S===E||u(S,E,a,c,l):I)){x=!1;break}C||(C=b=="constructor")}if(x&&!C){var A=o.constructor,M=s.constructor;A!=M&&"constructor"in o&&"constructor"in s&&!(typeof A=="function"&&A instanceof A&&typeof M=="function"&&M instanceof M)&&(x=!1)}return l.delete(o),l.delete(s),x}return Ma=i,Ma}var qa,Rh;function j1(){if(Rh)return qa;Rh=1;var e=Gn(),t=Eb(),r=_1(),n=E1(),i=qt(),o=rr(),s=Mt(),a=gn(),c=1,u="[object Arguments]",l="[object Array]",d="[object Object]",h=Object.prototype,p=h.hasOwnProperty;function y(m,g,b,w,v,x){var C=o(m),S=o(g),E=C?l:i(m),I=S?l:i(g);E=E==u?d:E,I=I==u?d:I;var A=E==d,M=I==d,j=E==I;if(j&&s(m)){if(!s(g))return!1;C=!0,A=!1}if(j&&!A)return x||(x=new e),C||a(m)?t(m,g,b,w,v,x):r(m,g,E,b,w,v,x);if(!(b&c)){var R=A&&p.call(m,"__wrapped__"),P=M&&p.call(g,"__wrapped__");if(R||P){var k=R?m.value():m,q=P?g.value():g;return x||(x=new e),v(k,q,b,w,x)}}return j?(x||(x=new e),n(m,g,b,w,v,x)):!1}return qa=y,qa}var $a,Ph;function jb(){if(Ph)return $a;Ph=1;var e=j1(),t=Mr();function r(n,i,o,s,a){return n===i?!0:n==null||i==null||!t(n)&&!t(i)?n!==n&&i!==i:e(n,i,o,s,r,a)}return $a=r,$a}var Na,Ah;function k1(){if(Ah)return Na;Ah=1;var e=Gn(),t=jb(),r=1,n=2;function i(o,s,a,c){var u=a.length,l=u,d=!c;if(o==null)return!l;for(o=Object(o);u--;){var h=a[u];if(d&&h[2]?h[1]!==o[h[0]]:!(h[0]in o))return!1}for(;++u<l;){h=a[u];var p=h[0],y=o[p],m=h[1];if(d&&h[2]){if(y===void 0&&!(p in o))return!1}else{var g=new e;if(c)var b=c(y,m,p,o,s,g);if(!(b===void 0?t(m,y,r|n,c,g):b))return!1}}return!0}return Na=i,Na}var La,Th;function kb(){if(Th)return La;Th=1;var e=_r();function t(r){return r===r&&!e(r)}return La=t,La}var Fa,Ih;function R1(){if(Ih)return Fa;Ih=1;var e=kb(),t=Xr();function r(n){for(var i=t(n),o=i.length;o--;){var s=i[o],a=n[s];i[o]=[s,a,e(a)]}return i}return Fa=r,Fa}var Ba,Oh;function Rb(){if(Oh)return Ba;Oh=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return Ba=e,Ba}var za,Mh;function P1(){if(Mh)return za;Mh=1;var e=k1(),t=R1(),r=Rb();function n(i){var o=t(i);return o.length==1&&o[0][2]?r(o[0][0],o[0][1]):function(s){return s===i||e(s,i,o)}}return za=n,za}var Da,qh;function $t(){if(qh)return Da;qh=1;var e=lt(),t=Mr(),r="[object Symbol]";function n(i){return typeof i=="symbol"||t(i)&&e(i)==r}return Da=n,Da}var Va,$h;function bl(){if($h)return Va;$h=1;var e=rr(),t=$t(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function i(o,s){if(e(o))return!1;var a=typeof o;return a=="number"||a=="symbol"||a=="boolean"||o==null||t(o)?!0:n.test(o)||!r.test(o)||s!=null&&o in Object(s)}return Va=i,Va}var Wa,Nh;function A1(){if(Nh)return Wa;Nh=1;var e=al(),t="Expected a function";function r(n,i){if(typeof n!="function"||i!=null&&typeof i!="function")throw new TypeError(t);var o=function(){var s=arguments,a=i?i.apply(this,s):s[0],c=o.cache;if(c.has(a))return c.get(a);var u=n.apply(this,s);return o.cache=c.set(a,u)||c,u};return o.cache=new(r.Cache||e),o}return r.Cache=e,Wa=r,Wa}var Ga,Lh;function T1(){if(Lh)return Ga;Lh=1;var e=A1(),t=500;function r(n){var i=e(n,function(s){return o.size===t&&o.clear(),s}),o=i.cache;return i}return Ga=r,Ga}var Ua,Fh;function I1(){if(Fh)return Ua;Fh=1;var e=T1(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(i){var o=[];return i.charCodeAt(0)===46&&o.push(""),i.replace(t,function(s,a,c,u){o.push(c?u.replace(r,"$1"):a||s)}),o});return Ua=n,Ua}var Ha,Bh;function Qn(){if(Bh)return Ha;Bh=1;function e(t,r){for(var n=-1,i=t==null?0:t.length,o=Array(i);++n<i;)o[n]=r(t[n],n,t);return o}return Ha=e,Ha}var Ka,zh;function O1(){if(zh)return Ka;zh=1;var e=Ot(),t=Qn(),r=rr(),n=$t(),i=e?e.prototype:void 0,o=i?i.toString:void 0;function s(a){if(typeof a=="string")return a;if(r(a))return t(a,s)+"";if(n(a))return o?o.call(a):"";var c=a+"";return c=="0"&&1/a==-1/0?"-0":c}return Ka=s,Ka}var Ja,Dh;function Pb(){if(Dh)return Ja;Dh=1;var e=O1();function t(r){return r==null?"":e(r)}return Ja=t,Ja}var Za,Vh;function eo(){if(Vh)return Za;Vh=1;var e=rr(),t=bl(),r=I1(),n=Pb();function i(o,s){return e(o)?o:t(o,s)?[o]:r(n(o))}return Za=i,Za}var Ya,Wh;function yn(){if(Wh)return Ya;Wh=1;var e=$t();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return Ya=t,Ya}var Xa,Gh;function ro(){if(Gh)return Xa;Gh=1;var e=eo(),t=yn();function r(n,i){i=e(i,n);for(var o=0,s=i.length;n!=null&&o<s;)n=n[t(i[o++])];return o&&o==s?n:void 0}return Xa=r,Xa}var Qa,Uh;function M1(){if(Uh)return Qa;Uh=1;var e=ro();function t(r,n,i){var o=r==null?void 0:e(r,n);return o===void 0?i:o}return Qa=t,Qa}var es,Hh;function q1(){if(Hh)return es;Hh=1;function e(t,r){return t!=null&&r in Object(t)}return es=e,es}var rs,Kh;function Ab(){if(Kh)return rs;Kh=1;var e=eo(),t=pn(),r=rr(),n=Kn(),i=cl(),o=yn();function s(a,c,u){c=e(c,a);for(var l=-1,d=c.length,h=!1;++l<d;){var p=o(c[l]);if(!(h=a!=null&&u(a,p)))break;a=a[p]}return h||++l!=d?h:(d=a==null?0:a.length,!!d&&i(d)&&n(p,d)&&(r(a)||t(a)))}return rs=s,rs}var ts,Jh;function Tb(){if(Jh)return ts;Jh=1;var e=q1(),t=Ab();function r(n,i){return n!=null&&t(n,i,e)}return ts=r,ts}var ns,Zh;function $1(){if(Zh)return ns;Zh=1;var e=jb(),t=M1(),r=Tb(),n=bl(),i=kb(),o=Rb(),s=yn(),a=1,c=2;function u(l,d){return n(l)&&i(d)?o(s(l),d):function(h){var p=t(h,l);return p===void 0&&p===d?r(h,l):e(d,p,a|c)}}return ns=u,ns}var os,Yh;function Ib(){if(Yh)return os;Yh=1;function e(t){return function(r){return r==null?void 0:r[t]}}return os=e,os}var is,Xh;function N1(){if(Xh)return is;Xh=1;var e=ro();function t(r){return function(n){return e(n,r)}}return is=t,is}var as,Qh;function L1(){if(Qh)return as;Qh=1;var e=Ib(),t=N1(),r=bl(),n=yn();function i(o){return r(o)?e(n(o)):t(o)}return as=i,as}var ss,ep;function Br(){if(ep)return ss;ep=1;var e=P1(),t=$1(),r=ht(),n=rr(),i=L1();function o(s){return typeof s=="function"?s:s==null?r:typeof s=="object"?n(s)?t(s[0],s[1]):e(s):i(s)}return ss=o,ss}var cs,rp;function Ob(){if(rp)return cs;rp=1;var e=ub(),t=v1(),r=Br(),n=rr();function i(o,s){var a=n(o)?e:t;return a(o,r(s,3))}return cs=i,cs}var us,tp;function F1(){if(tp)return us;tp=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,i){return n!=null&&t.call(n,i)}return us=r,us}var ls,np;function Mb(){if(np)return ls;np=1;var e=F1(),t=Ab();function r(n,i){return n!=null&&t(n,i,e)}return ls=r,ls}var ds,op;function B1(){if(op)return ds;op=1;var e=ll(),t=qt(),r=pn(),n=rr(),i=Fr(),o=Mt(),s=Zn(),a=gn(),c="[object Map]",u="[object Set]",l=Object.prototype,d=l.hasOwnProperty;function h(p){if(p==null)return!0;if(i(p)&&(n(p)||typeof p=="string"||typeof p.splice=="function"||o(p)||a(p)||r(p)))return!p.length;var y=t(p);if(y==c||y==u)return!p.size;if(s(p))return!e(p).length;for(var m in p)if(d.call(p,m))return!1;return!0}return ds=h,ds}var fs,ip;function qb(){if(ip)return fs;ip=1;function e(t){return t===void 0}return fs=e,fs}var hs,ap;function $b(){if(ap)return hs;ap=1;var e=Xn(),t=Fr();function r(n,i){var o=-1,s=t(n)?Array(n.length):[];return e(n,function(a,c,u){s[++o]=i(a,c,u)}),s}return hs=r,hs}var ps,sp;function Nb(){if(sp)return ps;sp=1;var e=Qn(),t=Br(),r=$b(),n=rr();function i(o,s){var a=n(o)?e:r;return a(o,t(s,3))}return ps=i,ps}var gs,cp;function z1(){if(cp)return gs;cp=1;function e(t,r,n,i){var o=-1,s=t==null?0:t.length;for(i&&s&&(n=t[++o]);++o<s;)n=r(n,t[o],o,t);return n}return gs=e,gs}var ys,up;function D1(){if(up)return ys;up=1;function e(t,r,n,i,o){return o(t,function(s,a,c){n=i?(i=!1,s):r(n,s,a,c)}),n}return ys=e,ys}var ms,lp;function Lb(){if(lp)return ms;lp=1;var e=z1(),t=Xn(),r=Br(),n=D1(),i=rr();function o(s,a,c){var u=i(s)?e:n,l=arguments.length<3;return u(s,r(a,4),c,l,t)}return ms=o,ms}var bs,dp;function V1(){if(dp)return bs;dp=1;var e=lt(),t=rr(),r=Mr(),n="[object String]";function i(o){return typeof o=="string"||!t(o)&&r(o)&&e(o)==n}return bs=i,bs}var vs,fp;function W1(){if(fp)return vs;fp=1;var e=Ib(),t=e("length");return vs=t,vs}var xs,hp;function G1(){if(hp)return xs;hp=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",i=t+r+n,o="\\ufe0e\\ufe0f",s="\\u200d",a=RegExp("["+s+e+i+o+"]");function c(u){return a.test(u)}return xs=c,xs}var ws,pp;function U1(){if(pp)return ws;pp=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",i=t+r+n,o="\\ufe0e\\ufe0f",s="["+e+"]",a="["+i+"]",c="\\ud83c[\\udffb-\\udfff]",u="(?:"+a+"|"+c+")",l="[^"+e+"]",d="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",y=u+"?",m="["+o+"]?",g="(?:"+p+"(?:"+[l,d,h].join("|")+")"+m+y+")*",b=m+y+g,w="(?:"+[l+a+"?",a,d,h,s].join("|")+")",v=RegExp(c+"(?="+c+")|"+w+b,"g");function x(C){for(var S=v.lastIndex=0;v.test(C);)++S;return S}return ws=x,ws}var Cs,gp;function H1(){if(gp)return Cs;gp=1;var e=W1(),t=G1(),r=U1();function n(i){return t(i)?r(i):e(i)}return Cs=n,Cs}var Ss,yp;function K1(){if(yp)return Ss;yp=1;var e=ll(),t=qt(),r=Fr(),n=V1(),i=H1(),o="[object Map]",s="[object Set]";function a(c){if(c==null)return 0;if(r(c))return n(c)?i(c):c.length;var u=t(c);return u==o||u==s?c.size:e(c).length}return Ss=a,Ss}var _s,mp;function J1(){if(mp)return _s;mp=1;var e=sl(),t=mb(),r=yl(),n=Br(),i=Yn(),o=rr(),s=Mt(),a=fn(),c=_r(),u=gn();function l(d,h,p){var y=o(d),m=y||s(d)||u(d);if(h=n(h,4),p==null){var g=d&&d.constructor;m?p=y?new g:[]:c(d)?p=a(g)?t(i(d)):{}:p={}}return(m?e:r)(d,function(b,w,v){return h(p,b,w,v)}),p}return _s=l,_s}var Es,bp;function Z1(){if(bp)return Es;bp=1;var e=Ot(),t=pn(),r=rr(),n=e?e.isConcatSpreadable:void 0;function i(o){return r(o)||t(o)||!!(n&&o&&o[n])}return Es=i,Es}var js,vp;function vl(){if(vp)return js;vp=1;var e=fl(),t=Z1();function r(n,i,o,s,a){var c=-1,u=n.length;for(o||(o=t),a||(a=[]);++c<u;){var l=n[c];i>0&&o(l)?i>1?r(l,i-1,o,s,a):e(a,l):s||(a[a.length]=l)}return a}return js=r,js}var ks,xp;function Y1(){if(xp)return ks;xp=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 ks=e,ks}var Rs,wp;function Fb(){if(wp)return Rs;wp=1;var e=Y1(),t=Math.max;function r(n,i,o){return i=t(i===void 0?n.length-1:i,0),function(){for(var s=arguments,a=-1,c=t(s.length-i,0),u=Array(c);++a<c;)u[a]=s[i+a];a=-1;for(var l=Array(i+1);++a<i;)l[a]=s[a];return l[i]=o(u),e(n,this,l)}}return Rs=r,Rs}var Ps,Cp;function X1(){if(Cp)return Ps;Cp=1;var e=pl(),t=ob(),r=ht(),n=t?function(i,o){return t(i,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:r;return Ps=n,Ps}var As,Sp;function Q1(){if(Sp)return As;Sp=1;var e=800,t=16,r=Date.now;function n(i){var o=0,s=0;return function(){var a=r(),c=t-(a-s);if(s=a,c>0){if(++o>=e)return arguments[0]}else o=0;return i.apply(void 0,arguments)}}return As=n,As}var Ts,_p;function Bb(){if(_p)return Ts;_p=1;var e=X1(),t=Q1(),r=t(e);return Ts=r,Ts}var Is,Ep;function to(){if(Ep)return Is;Ep=1;var e=ht(),t=Fb(),r=Bb();function n(i,o){return r(t(i,o,e),i+"")}return Is=n,Is}var Os,jp;function zb(){if(jp)return Os;jp=1;function e(t,r,n,i){for(var o=t.length,s=n+(i?1:-1);i?s--:++s<o;)if(r(t[s],s,t))return s;return-1}return Os=e,Os}var Ms,kp;function eC(){if(kp)return Ms;kp=1;function e(t){return t!==t}return Ms=e,Ms}var qs,Rp;function rC(){if(Rp)return qs;Rp=1;function e(t,r,n){for(var i=n-1,o=t.length;++i<o;)if(t[i]===r)return i;return-1}return qs=e,qs}var $s,Pp;function tC(){if(Pp)return $s;Pp=1;var e=zb(),t=eC(),r=rC();function n(i,o,s){return o===o?r(i,o,s):e(i,t,s)}return $s=n,$s}var Ns,Ap;function nC(){if(Ap)return Ns;Ap=1;var e=tC();function t(r,n){var i=r==null?0:r.length;return!!i&&e(r,n,0)>-1}return Ns=t,Ns}var Ls,Tp;function oC(){if(Tp)return Ls;Tp=1;function e(t,r,n){for(var i=-1,o=t==null?0:t.length;++i<o;)if(n(r,t[i]))return!0;return!1}return Ls=e,Ls}var Fs,Ip;function iC(){if(Ip)return Fs;Ip=1;function e(){}return Fs=e,Fs}var Bs,Op;function aC(){if(Op)return Bs;Op=1;var e=pb(),t=iC(),r=ml(),n=1/0,i=e&&1/r(new e([,-0]))[1]==n?function(o){return new e(o)}:t;return Bs=i,Bs}var zs,Mp;function sC(){if(Mp)return zs;Mp=1;var e=Sb(),t=nC(),r=oC(),n=_b(),i=aC(),o=ml(),s=200;function a(c,u,l){var d=-1,h=t,p=c.length,y=!0,m=[],g=m;if(l)y=!1,h=r;else if(p>=s){var b=u?null:i(c);if(b)return o(b);y=!1,h=n,g=new e}else g=u?[]:m;e:for(;++d<p;){var w=c[d],v=u?u(w):w;if(w=l||w!==0?w:0,y&&v===v){for(var x=g.length;x--;)if(g[x]===v)continue e;u&&g.push(v),m.push(w)}else h(g,v,l)||(g!==m&&g.push(v),m.push(w))}return m}return zs=a,zs}var Ds,qp;function Db(){if(qp)return Ds;qp=1;var e=Fr(),t=Mr();function r(n){return t(n)&&e(n)}return Ds=r,Ds}var Vs,$p;function cC(){if($p)return Vs;$p=1;var e=vl(),t=to(),r=sC(),n=Db(),i=t(function(o){return r(e(o,1,n,!0))});return Vs=i,Vs}var Ws,Np;function uC(){if(Np)return Ws;Np=1;var e=Qn();function t(r,n){return e(n,function(i){return r[i]})}return Ws=t,Ws}var Gs,Lp;function Vb(){if(Lp)return Gs;Lp=1;var e=uC(),t=Xr();function r(n){return n==null?[]:e(n,t(n))}return Gs=r,Gs}var Us,Fp;function Er(){if(Fp)return Us;Fp=1;var e;if(typeof ol=="function")try{e={clone:y1(),constant:pl(),each:Cb(),filter:Ob(),has:Mb(),isArray:rr(),isEmpty:B1(),isFunction:fn(),isUndefined:qb(),keys:Xr(),map:Nb(),reduce:Lb(),size:K1(),transform:J1(),union:cC(),values:Vb()}}catch{}return e||(e=window._),Us=e,Us}var Hs,Bp;function xl(){if(Bp)return Hs;Bp=1;var e=Er();Hs=i;var t="\0",r="\0",n="";function i(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={}}i.prototype._nodeCount=0,i.prototype._edgeCount=0,i.prototype.isDirected=function(){return this._isDirected},i.prototype.isMultigraph=function(){return this._isMultigraph},i.prototype.isCompound=function(){return this._isCompound},i.prototype.setGraph=function(l){return this._label=l,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultNodeLabelFn=l,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return e.keys(this._nodes)},i.prototype.sources=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._in[d])})},i.prototype.sinks=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._out[d])})},i.prototype.setNodes=function(l,d){var h=arguments,p=this;return e.each(l,function(y){h.length>1?p.setNode(y,d):p.setNode(y)}),this},i.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)},i.prototype.node=function(l){return this._nodes[l]},i.prototype.hasNode=function(l){return e.has(this._nodes,l)},i.prototype.removeNode=function(l){var d=this;if(e.has(this._nodes,l)){var h=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]),h),delete this._in[l],delete this._preds[l],e.each(e.keys(this._out[l]),h),delete this._out[l],delete this._sucs[l],--this._nodeCount}return this},i.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 h=d;!e.isUndefined(h);h=this.parent(h))if(h===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},i.prototype._removeFromParentsChildList=function(l){delete this._children[this._parent[l]][l]},i.prototype.parent=function(l){if(this._isCompound){var d=this._parent[l];if(d!==r)return d}},i.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[]}},i.prototype.predecessors=function(l){var d=this._preds[l];if(d)return e.keys(d)},i.prototype.successors=function(l){var d=this._sucs[l];if(d)return e.keys(d)},i.prototype.neighbors=function(l){var d=this.predecessors(l);if(d)return e.union(d,this.successors(l))},i.prototype.isLeaf=function(l){var d;return this.isDirected()?d=this.successors(l):d=this.neighbors(l),d.length===0},i.prototype.filterNodes=function(l){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var h=this;e.each(this._nodes,function(m,g){l(g)&&d.setNode(g,m)}),e.each(this._edgeObjs,function(m){d.hasNode(m.v)&&d.hasNode(m.w)&&d.setEdge(m,h.edge(m))});var p={};function y(m){var g=h.parent(m);return g===void 0||d.hasNode(g)?(p[m]=g,g):g in p?p[g]:y(g)}return this._isCompound&&e.each(d.nodes(),function(m){d.setParent(m,y(m))}),d},i.prototype.setDefaultEdgeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultEdgeLabelFn=l,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return e.values(this._edgeObjs)},i.prototype.setPath=function(l,d){var h=this,p=arguments;return e.reduce(l,function(y,m){return p.length>1?h.setEdge(y,m,d):h.setEdge(y,m),m}),this},i.prototype.setEdge=function(){var l,d,h,p,y=!1,m=arguments[0];typeof m=="object"&&m!==null&&"v"in m?(l=m.v,d=m.w,h=m.name,arguments.length===2&&(p=arguments[1],y=!0)):(l=m,d=arguments[1],h=arguments[3],arguments.length>2&&(p=arguments[2],y=!0)),l=""+l,d=""+d,e.isUndefined(h)||(h=""+h);var g=a(this._isDirected,l,d,h);if(e.has(this._edgeLabels,g))return y&&(this._edgeLabels[g]=p),this;if(!e.isUndefined(h)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(l),this.setNode(d),this._edgeLabels[g]=y?p:this._defaultEdgeLabelFn(l,d,h);var b=c(this._isDirected,l,d,h);return l=b.v,d=b.w,Object.freeze(b),this._edgeObjs[g]=b,o(this._preds[d],l),o(this._sucs[l],d),this._in[d][g]=b,this._out[l][g]=b,this._edgeCount++,this},i.prototype.edge=function(l,d,h){var p=arguments.length===1?u(this._isDirected,arguments[0]):a(this._isDirected,l,d,h);return this._edgeLabels[p]},i.prototype.hasEdge=function(l,d,h){var p=arguments.length===1?u(this._isDirected,arguments[0]):a(this._isDirected,l,d,h);return e.has(this._edgeLabels,p)},i.prototype.removeEdge=function(l,d,h){var p=arguments.length===1?u(this._isDirected,arguments[0]):a(this._isDirected,l,d,h),y=this._edgeObjs[p];return y&&(l=y.v,d=y.w,delete this._edgeLabels[p],delete this._edgeObjs[p],s(this._preds[d],l),s(this._sucs[l],d),delete this._in[d][p],delete this._out[l][p],this._edgeCount--),this},i.prototype.inEdges=function(l,d){var h=this._in[l];if(h){var p=e.values(h);return d?e.filter(p,function(y){return y.v===d}):p}},i.prototype.outEdges=function(l,d){var h=this._out[l];if(h){var p=e.values(h);return d?e.filter(p,function(y){return y.w===d}):p}},i.prototype.nodeEdges=function(l,d){var h=this.inEdges(l,d);if(h)return h.concat(this.outEdges(l,d))};function o(l,d){l[d]?l[d]++:l[d]=1}function s(l,d){--l[d]||delete l[d]}function a(l,d,h,p){var y=""+d,m=""+h;if(!l&&y>m){var g=y;y=m,m=g}return y+n+m+n+(e.isUndefined(p)?t:p)}function c(l,d,h,p){var y=""+d,m=""+h;if(!l&&y>m){var g=y;y=m,m=g}var b={v:y,w:m};return p&&(b.name=p),b}function u(l,d){return a(l,d.v,d.w,d.name)}return Hs}var Ks,zp;function lC(){return zp||(zp=1,Ks="2.1.8"),Ks}var Js,Dp;function dC(){return Dp||(Dp=1,Js={Graph:xl(),version:lC()}),Js}var Zs,Vp;function fC(){if(Vp)return Zs;Vp=1;var e=Er(),t=xl();Zs={write:r,read:o};function r(s){var a={options:{directed:s.isDirected(),multigraph:s.isMultigraph(),compound:s.isCompound()},nodes:n(s),edges:i(s)};return e.isUndefined(s.graph())||(a.value=e.clone(s.graph())),a}function n(s){return e.map(s.nodes(),function(a){var c=s.node(a),u=s.parent(a),l={v:a};return e.isUndefined(c)||(l.value=c),e.isUndefined(u)||(l.parent=u),l})}function i(s){return e.map(s.edges(),function(a){var c=s.edge(a),u={v:a.v,w:a.w};return e.isUndefined(a.name)||(u.name=a.name),e.isUndefined(c)||(u.value=c),u})}function o(s){var a=new t(s.options).setGraph(s.value);return e.each(s.nodes,function(c){a.setNode(c.v,c.value),c.parent&&a.setParent(c.v,c.parent)}),e.each(s.edges,function(c){a.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),a}return Zs}var Ys,Wp;function hC(){if(Wp)return Ys;Wp=1;var e=Er();Ys=t;function t(r){var n={},i=[],o;function s(a){e.has(n,a)||(n[a]=!0,o.push(a),e.each(r.successors(a),s),e.each(r.predecessors(a),s))}return e.each(r.nodes(),function(a){o=[],s(a),o.length&&i.push(o)}),i}return Ys}var Xs,Gp;function Wb(){if(Gp)return Xs;Gp=1;var e=Er();Xs=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 i=this._keyIndices;if(r=String(r),!e.has(i,r)){var o=this._arr,s=o.length;return i[r]=s,o.push({key:r,priority:n}),this._decrease(s),!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 i=this._keyIndices[r];if(n>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[i].priority+" New: "+n);this._arr[i].priority=n,this._decrease(i)},t.prototype._heapify=function(r){var n=this._arr,i=2*r,o=i+1,s=r;i<n.length&&(s=n[i].priority<n[s].priority?i:s,o<n.length&&(s=n[o].priority<n[s].priority?o:s),s!==r&&(this._swap(r,s),this._heapify(s)))},t.prototype._decrease=function(r){for(var n=this._arr,i=n[r].priority,o;r!==0&&(o=r>>1,!(n[o].priority<i));)this._swap(r,o),r=o},t.prototype._swap=function(r,n){var i=this._arr,o=this._keyIndices,s=i[r],a=i[n];i[r]=a,i[n]=s,o[a.key]=r,o[s.key]=n},Xs}var Qs,Up;function Gb(){if(Up)return Qs;Up=1;var e=Er(),t=Wb();Qs=n;var r=e.constant(1);function n(o,s,a,c){return i(o,String(s),a||r,c||function(u){return o.outEdges(u)})}function i(o,s,a,c){var u={},l=new t,d,h,p=function(y){var m=y.v!==d?y.v:y.w,g=u[m],b=a(y),w=h.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+y+" Weight: "+b);w<g.distance&&(g.distance=w,g.predecessor=d,l.decrease(m,w))};for(o.nodes().forEach(function(y){var m=y===s?0:Number.POSITIVE_INFINITY;u[y]={distance:m},l.add(y,m)});l.size()>0&&(d=l.removeMin(),h=u[d],h.distance!==Number.POSITIVE_INFINITY);)c(d).forEach(p);return u}return Qs}var ec,Hp;function pC(){if(Hp)return ec;Hp=1;var e=Gb(),t=Er();ec=r;function r(n,i,o){return t.transform(n.nodes(),function(s,a){s[a]=e(n,a,i,o)},{})}return ec}var rc,Kp;function Ub(){if(Kp)return rc;Kp=1;var e=Er();rc=t;function t(r){var n=0,i=[],o={},s=[];function a(c){var u=o[c]={onStack:!0,lowlink:n,index:n++};if(i.push(c),r.successors(c).forEach(function(h){e.has(o,h)?o[h].onStack&&(u.lowlink=Math.min(u.lowlink,o[h].index)):(a(h),u.lowlink=Math.min(u.lowlink,o[h].lowlink))}),u.lowlink===u.index){var l=[],d;do d=i.pop(),o[d].onStack=!1,l.push(d);while(c!==d);s.push(l)}}return r.nodes().forEach(function(c){e.has(o,c)||a(c)}),s}return rc}var tc,Jp;function gC(){if(Jp)return tc;Jp=1;var e=Er(),t=Ub();tc=r;function r(n){return e.filter(t(n),function(i){return i.length>1||i.length===1&&n.hasEdge(i[0],i[0])})}return tc}var nc,Zp;function yC(){if(Zp)return nc;Zp=1;var e=Er();nc=r;var t=e.constant(1);function r(i,o,s){return n(i,o||t,s||function(a){return i.outEdges(a)})}function n(i,o,s){var a={},c=i.nodes();return c.forEach(function(u){a[u]={},a[u][u]={distance:0},c.forEach(function(l){u!==l&&(a[u][l]={distance:Number.POSITIVE_INFINITY})}),s(u).forEach(function(l){var d=l.v===u?l.w:l.v,h=o(l);a[u][d]={distance:h,predecessor:u}})}),c.forEach(function(u){var l=a[u];c.forEach(function(d){var h=a[d];c.forEach(function(p){var y=h[u],m=l[p],g=h[p],b=y.distance+m.distance;b<g.distance&&(g.distance=b,g.predecessor=m.predecessor)})})}),a}return nc}var oc,Yp;function Hb(){if(Yp)return oc;Yp=1;var e=Er();oc=t,t.CycleException=r;function t(n){var i={},o={},s=[];function a(c){if(e.has(o,c))throw new r;e.has(i,c)||(o[c]=!0,i[c]=!0,e.each(n.predecessors(c),a),delete o[c],s.push(c))}if(e.each(n.sinks(),a),e.size(i)!==n.nodeCount())throw new r;return s}function r(){}return r.prototype=new Error,oc}var ic,Xp;function mC(){if(Xp)return ic;Xp=1;var e=Hb();ic=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return ic}var ac,Qp;function Kb(){if(Qp)return ac;Qp=1;var e=Er();ac=t;function t(n,i,o){e.isArray(i)||(i=[i]);var s=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],c={};return e.each(i,function(u){if(!n.hasNode(u))throw new Error("Graph does not have node: "+u);r(n,u,o==="post",c,s,a)}),a}function r(n,i,o,s,a,c){e.has(s,i)||(s[i]=!0,o||c.push(i),e.each(a(i),function(u){r(n,u,o,s,a,c)}),o&&c.push(i))}return ac}var sc,eg;function bC(){if(eg)return sc;eg=1;var e=Kb();sc=t;function t(r,n){return e(r,n,"post")}return sc}var cc,rg;function vC(){if(rg)return cc;rg=1;var e=Kb();cc=t;function t(r,n){return e(r,n,"pre")}return cc}var uc,tg;function xC(){if(tg)return uc;tg=1;var e=Er(),t=xl(),r=Wb();uc=n;function n(i,o){var s=new t,a={},c=new r,u;function l(h){var p=h.v===u?h.w:h.v,y=c.priority(p);if(y!==void 0){var m=o(h);m<y&&(a[p]=u,c.decrease(p,m))}}if(i.nodeCount()===0)return s;e.each(i.nodes(),function(h){c.add(h,Number.POSITIVE_INFINITY),s.setNode(h)}),c.decrease(i.nodes()[0],0);for(var d=!1;c.size()>0;){if(u=c.removeMin(),e.has(a,u))s.setEdge(u,a[u]);else{if(d)throw new Error("Input graph is not connected: "+i);d=!0}i.nodeEdges(u).forEach(l)}return s}return uc}var lc,ng;function wC(){return ng||(ng=1,lc={components:hC(),dijkstra:Gb(),dijkstraAll:pC(),findCycles:gC(),floydWarshall:yC(),isAcyclic:mC(),postorder:bC(),preorder:vC(),prim:xC(),tarjan:Ub(),topsort:Hb()}),lc}var dc,og;function CC(){if(og)return dc;og=1;var e=dC();return dc={Graph:e.Graph,json:fC(),alg:wC(),version:e.version},dc}var fc,ig;function Pr(){if(ig)return fc;ig=1;var e;if(typeof ol=="function")try{e=CC()}catch{}return e||(e=window.graphlib),fc=e,fc}var hc,ag;function SC(){if(ag)return hc;ag=1;var e=vb(),t=1,r=4;function n(i){return e(i,t|r)}return hc=n,hc}var pc,sg;function no(){if(sg)return pc;sg=1;var e=It(),t=Fr(),r=Kn(),n=_r();function i(o,s,a){if(!n(a))return!1;var c=typeof s;return(c=="number"?t(a)&&r(s,a.length):c=="string"&&s in a)?e(a[s],o):!1}return pc=i,pc}var gc,cg;function _C(){if(cg)return gc;cg=1;var e=to(),t=It(),r=no(),n=ft(),i=Object.prototype,o=i.hasOwnProperty,s=e(function(a,c){a=Object(a);var u=-1,l=c.length,d=l>2?c[2]:void 0;for(d&&r(c[0],c[1],d)&&(l=1);++u<l;)for(var h=c[u],p=n(h),y=-1,m=p.length;++y<m;){var g=p[y],b=a[g];(b===void 0||t(b,i[g])&&!o.call(a,g))&&(a[g]=h[g])}return a});return gc=s,gc}var yc,ug;function EC(){if(ug)return yc;ug=1;var e=Br(),t=Fr(),r=Xr();function n(i){return function(o,s,a){var c=Object(o);if(!t(o)){var u=e(s,3);o=r(o),s=function(d){return u(c[d],d,c)}}var l=i(o,s,a);return l>-1?c[u?o[l]:l]:void 0}}return yc=n,yc}var mc,lg;function jC(){if(lg)return mc;lg=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return mc=t,mc}var bc,dg;function kC(){if(dg)return bc;dg=1;var e=jC(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return bc=r,bc}var vc,fg;function RC(){if(fg)return vc;fg=1;var e=kC(),t=_r(),r=$t(),n=NaN,i=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt;function c(u){if(typeof u=="number")return u;if(r(u))return n;if(t(u)){var l=typeof u.valueOf=="function"?u.valueOf():u;u=t(l)?l+"":l}if(typeof u!="string")return u===0?u:+u;u=e(u);var d=o.test(u);return d||s.test(u)?a(u.slice(2),d?2:8):i.test(u)?n:+u}return vc=c,vc}var xc,hg;function Jb(){if(hg)return xc;hg=1;var e=RC(),t=1/0,r=17976931348623157e292;function n(i){if(!i)return i===0?i:0;if(i=e(i),i===t||i===-t){var o=i<0?-1:1;return o*r}return i===i?i:0}return xc=n,xc}var wc,pg;function PC(){if(pg)return wc;pg=1;var e=Jb();function t(r){var n=e(r),i=n%1;return n===n?i?n-i:n:0}return wc=t,wc}var Cc,gg;function AC(){if(gg)return Cc;gg=1;var e=zb(),t=Br(),r=PC(),n=Math.max;function i(o,s,a){var c=o==null?0:o.length;if(!c)return-1;var u=a==null?0:r(a);return u<0&&(u=n(c+u,0)),e(o,t(s,3),u)}return Cc=i,Cc}var Sc,yg;function TC(){if(yg)return Sc;yg=1;var e=EC(),t=AC(),r=e(t);return Sc=r,Sc}var _c,mg;function Zb(){if(mg)return _c;mg=1;var e=vl();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return _c=t,_c}var Ec,bg;function IC(){if(bg)return Ec;bg=1;var e=gl(),t=xb(),r=ft();function n(i,o){return i==null?i:e(i,t(o),r)}return Ec=n,Ec}var jc,vg;function OC(){if(vg)return jc;vg=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return jc=e,jc}var kc,xg;function MC(){if(xg)return kc;xg=1;var e=Un(),t=yl(),r=Br();function n(i,o){var s={};return o=r(o,3),t(i,function(a,c,u){e(s,c,o(a,c,u))}),s}return kc=n,kc}var Rc,wg;function wl(){if(wg)return Rc;wg=1;var e=$t();function t(r,n,i){for(var o=-1,s=r.length;++o<s;){var a=r[o],c=n(a);if(c!=null&&(u===void 0?c===c&&!e(c):i(c,u)))var u=c,l=a}return l}return Rc=t,Rc}var Pc,Cg;function qC(){if(Cg)return Pc;Cg=1;function e(t,r){return t>r}return Pc=e,Pc}var Ac,Sg;function $C(){if(Sg)return Ac;Sg=1;var e=wl(),t=qC(),r=ht();function n(i){return i&&i.length?e(i,r,t):void 0}return Ac=n,Ac}var Tc,_g;function Yb(){if(_g)return Tc;_g=1;var e=Un(),t=It();function r(n,i,o){(o!==void 0&&!t(n[i],o)||o===void 0&&!(i in n))&&e(n,i,o)}return Tc=r,Tc}var Ic,Eg;function NC(){if(Eg)return Ic;Eg=1;var e=lt(),t=Yn(),r=Mr(),n="[object Object]",i=Function.prototype,o=Object.prototype,s=i.toString,a=o.hasOwnProperty,c=s.call(Object);function u(l){if(!r(l)||e(l)!=n)return!1;var d=t(l);if(d===null)return!0;var h=a.call(d,"constructor")&&d.constructor;return typeof h=="function"&&h instanceof h&&s.call(h)==c}return Ic=u,Ic}var Oc,jg;function Xb(){if(jg)return Oc;jg=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return Oc=e,Oc}var Mc,kg;function LC(){if(kg)return Mc;kg=1;var e=hn(),t=ft();function r(n){return e(n,t(n))}return Mc=r,Mc}var qc,Rg;function FC(){if(Rg)return qc;Rg=1;var e=Yb(),t=sb(),r=yb(),n=cb(),i=bb(),o=pn(),s=rr(),a=Db(),c=Mt(),u=fn(),l=_r(),d=NC(),h=gn(),p=Xb(),y=LC();function m(g,b,w,v,x,C,S){var E=p(g,w),I=p(b,w),A=S.get(I);if(A){e(g,w,A);return}var M=C?C(E,I,w+"",g,b,S):void 0,j=M===void 0;if(j){var R=s(I),P=!R&&c(I),k=!R&&!P&&h(I);M=I,R||P||k?s(E)?M=E:a(E)?M=n(E):P?(j=!1,M=t(I,!0)):k?(j=!1,M=r(I,!0)):M=[]:d(I)||o(I)?(M=E,o(E)?M=y(E):(!l(E)||u(E))&&(M=i(I))):j=!1}j&&(S.set(I,M),x(M,I,v,C,S),S.delete(I)),e(g,w,M)}return qc=m,qc}var $c,Pg;function BC(){if(Pg)return $c;Pg=1;var e=Gn(),t=Yb(),r=gl(),n=FC(),i=_r(),o=ft(),s=Xb();function a(c,u,l,d,h){c!==u&&r(u,function(p,y){if(h||(h=new e),i(p))n(c,u,y,l,a,d,h);else{var m=d?d(s(c,y),p,y+"",c,u,h):void 0;m===void 0&&(m=p),t(c,y,m)}},o)}return $c=a,$c}var Nc,Ag;function zC(){if(Ag)return Nc;Ag=1;var e=to(),t=no();function r(n){return e(function(i,o){var s=-1,a=o.length,c=a>1?o[a-1]:void 0,u=a>2?o[2]:void 0;for(c=n.length>3&&typeof c=="function"?(a--,c):void 0,u&&t(o[0],o[1],u)&&(c=a<3?void 0:c,a=1),i=Object(i);++s<a;){var l=o[s];l&&n(i,l,s,c)}return i})}return Nc=r,Nc}var Lc,Tg;function DC(){if(Tg)return Lc;Tg=1;var e=BC(),t=zC(),r=t(function(n,i,o){e(n,i,o)});return Lc=r,Lc}var Fc,Ig;function Qb(){if(Ig)return Fc;Ig=1;function e(t,r){return t<r}return Fc=e,Fc}var Bc,Og;function VC(){if(Og)return Bc;Og=1;var e=wl(),t=Qb(),r=ht();function n(i){return i&&i.length?e(i,r,t):void 0}return Bc=n,Bc}var zc,Mg;function WC(){if(Mg)return zc;Mg=1;var e=wl(),t=Br(),r=Qb();function n(i,o){return i&&i.length?e(i,t(o,2),r):void 0}return zc=n,zc}var Dc,qg;function GC(){if(qg)return Dc;qg=1;var e=Ar(),t=function(){return e.Date.now()};return Dc=t,Dc}var Vc,$g;function UC(){if($g)return Vc;$g=1;var e=Hn(),t=eo(),r=Kn(),n=_r(),i=yn();function o(s,a,c,u){if(!n(s))return s;a=t(a,s);for(var l=-1,d=a.length,h=d-1,p=s;p!=null&&++l<d;){var y=i(a[l]),m=c;if(y==="__proto__"||y==="constructor"||y==="prototype")return s;if(l!=h){var g=p[y];m=u?u(g,y,p):void 0,m===void 0&&(m=n(g)?g:r(a[l+1])?[]:{})}e(p,y,m),p=p[y]}return s}return Vc=o,Vc}var Wc,Ng;function HC(){if(Ng)return Wc;Ng=1;var e=ro(),t=UC(),r=eo();function n(i,o,s){for(var a=-1,c=o.length,u={};++a<c;){var l=o[a],d=e(i,l);s(d,l)&&t(u,r(l,i),d)}return u}return Wc=n,Wc}var Gc,Lg;function KC(){if(Lg)return Gc;Lg=1;var e=HC(),t=Tb();function r(n,i){return e(n,i,function(o,s){return t(n,s)})}return Gc=r,Gc}var Uc,Fg;function JC(){if(Fg)return Uc;Fg=1;var e=Zb(),t=Fb(),r=Bb();function n(i){return r(t(i,void 0,e),i+"")}return Uc=n,Uc}var Hc,Bg;function ZC(){if(Bg)return Hc;Bg=1;var e=KC(),t=JC(),r=t(function(n,i){return n==null?{}:e(n,i)});return Hc=r,Hc}var Kc,zg;function YC(){if(zg)return Kc;zg=1;var e=Math.ceil,t=Math.max;function r(n,i,o,s){for(var a=-1,c=t(e((i-n)/(o||1)),0),u=Array(c);c--;)u[s?c:++a]=n,n+=o;return u}return Kc=r,Kc}var Jc,Dg;function XC(){if(Dg)return Jc;Dg=1;var e=YC(),t=no(),r=Jb();function n(i){return function(o,s,a){return a&&typeof a!="number"&&t(o,s,a)&&(s=a=void 0),o=r(o),s===void 0?(s=o,o=0):s=r(s),a=a===void 0?o<s?1:-1:r(a),e(o,s,a,i)}}return Jc=n,Jc}var Zc,Vg;function QC(){if(Vg)return Zc;Vg=1;var e=XC(),t=e();return Zc=t,Zc}var Yc,Wg;function eS(){if(Wg)return Yc;Wg=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return Yc=e,Yc}var Xc,Gg;function rS(){if(Gg)return Xc;Gg=1;var e=$t();function t(r,n){if(r!==n){var i=r!==void 0,o=r===null,s=r===r,a=e(r),c=n!==void 0,u=n===null,l=n===n,d=e(n);if(!u&&!d&&!a&&r>n||a&&c&&l&&!u&&!d||o&&c&&l||!i&&l||!s)return 1;if(!o&&!a&&!d&&r<n||d&&i&&s&&!o&&!a||u&&i&&s||!c&&s||!l)return-1}return 0}return Xc=t,Xc}var Qc,Ug;function tS(){if(Ug)return Qc;Ug=1;var e=rS();function t(r,n,i){for(var o=-1,s=r.criteria,a=n.criteria,c=s.length,u=i.length;++o<c;){var l=e(s[o],a[o]);if(l){if(o>=u)return l;var d=i[o];return l*(d=="desc"?-1:1)}}return r.index-n.index}return Qc=t,Qc}var eu,Hg;function nS(){if(Hg)return eu;Hg=1;var e=Qn(),t=ro(),r=Br(),n=$b(),i=eS(),o=Jn(),s=tS(),a=ht(),c=rr();function u(l,d,h){d.length?d=e(d,function(m){return c(m)?function(g){return t(g,m.length===1?m[0]:m)}:m}):d=[a];var p=-1;d=e(d,o(r));var y=n(l,function(m,g,b){var w=e(d,function(v){return v(m)});return{criteria:w,index:++p,value:m}});return i(y,function(m,g){return s(m,g,h)})}return eu=u,eu}var ru,Kg;function oS(){if(Kg)return ru;Kg=1;var e=vl(),t=nS(),r=to(),n=no(),i=r(function(o,s){if(o==null)return[];var a=s.length;return a>1&&n(o,s[0],s[1])?s=[]:a>2&&n(s[0],s[1],s[2])&&(s=[s[0]]),t(o,e(s,1),[])});return ru=i,ru}var tu,Jg;function iS(){if(Jg)return tu;Jg=1;var e=Pb(),t=0;function r(n){var i=++t;return e(n)+i}return tu=r,tu}var nu,Zg;function aS(){if(Zg)return nu;Zg=1;function e(t,r,n){for(var i=-1,o=t.length,s=r.length,a={};++i<o;){var c=i<s?r[i]:void 0;n(a,t[i],c)}return a}return nu=e,nu}var ou,Yg;function sS(){if(Yg)return ou;Yg=1;var e=Hn(),t=aS();function r(n,i){return t(n||[],i||[],e)}return ou=r,ou}var iu,Xg;function Ke(){if(Xg)return iu;Xg=1;var e;if(typeof ol=="function")try{e={cloneDeep:SC(),constant:pl(),defaults:_C(),each:Cb(),filter:Ob(),find:TC(),flatten:Zb(),forEach:wb(),forIn:IC(),has:Mb(),isUndefined:qb(),last:OC(),map:Nb(),mapValues:MC(),max:$C(),merge:DC(),min:VC(),minBy:WC(),now:GC(),pick:ZC(),range:QC(),reduce:Lb(),sortBy:oS(),uniqueId:iS(),values:Vb(),zipObject:sS()}}catch{}return e||(e=window._),iu=e,iu}var au,Qg;function cS(){if(Qg)return au;Qg=1,au=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,i=n._prev;if(i!==n)return t(i),i},e.prototype.enqueue=function(n){var i=this._sentinel;n._prev&&n._next&&t(n),n._next=i._next,i._next._prev=n,i._next=n,n._prev=i},e.prototype.toString=function(){for(var n=[],i=this._sentinel,o=i._prev;o!==i;)n.push(JSON.stringify(o,r)),o=o._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,i){if(n!=="_next"&&n!=="_prev")return i}return au}var su,ey;function uS(){if(ey)return su;ey=1;var e=Ke(),t=Pr().Graph,r=cS();su=i;var n=e.constant(1);function i(u,l){if(u.nodeCount()<=1)return[];var d=a(u,l||n),h=o(d.graph,d.buckets,d.zeroIdx);return e.flatten(e.map(h,function(p){return u.outEdges(p.v,p.w)}),!0)}function o(u,l,d){for(var h=[],p=l[l.length-1],y=l[0],m;u.nodeCount();){for(;m=y.dequeue();)s(u,l,d,m);for(;m=p.dequeue();)s(u,l,d,m);if(u.nodeCount()){for(var g=l.length-2;g>0;--g)if(m=l[g].dequeue(),m){h=h.concat(s(u,l,d,m,!0));break}}}return h}function s(u,l,d,h,p){var y=p?[]:void 0;return e.forEach(u.inEdges(h.v),function(m){var g=u.edge(m),b=u.node(m.v);p&&y.push({v:m.v,w:m.w}),b.out-=g,c(l,d,b)}),e.forEach(u.outEdges(h.v),function(m){var g=u.edge(m),b=m.w,w=u.node(b);w.in-=g,c(l,d,w)}),u.removeNode(h.v),y}function a(u,l){var d=new t,h=0,p=0;e.forEach(u.nodes(),function(g){d.setNode(g,{v:g,in:0,out:0})}),e.forEach(u.edges(),function(g){var b=d.edge(g.v,g.w)||0,w=l(g),v=b+w;d.setEdge(g.v,g.w,v),p=Math.max(p,d.node(g.v).out+=w),h=Math.max(h,d.node(g.w).in+=w)});var y=e.range(p+h+3).map(function(){return new r}),m=h+1;return e.forEach(d.nodes(),function(g){c(y,m,d.node(g))}),{graph:d,buckets:y,zeroIdx:m}}function c(u,l,d){d.out?d.in?u[d.out-d.in+l].enqueue(d):u[u.length-1].enqueue(d):u[0].enqueue(d)}return su}var cu,ry;function lS(){if(ry)return cu;ry=1;var e=Ke(),t=uS();cu={run:r,undo:i};function r(o){var s=o.graph().acyclicer==="greedy"?t(o,a(o)):n(o);e.forEach(s,function(c){var u=o.edge(c);o.removeEdge(c),u.forwardName=c.name,u.reversed=!0,o.setEdge(c.w,c.v,u,e.uniqueId("rev"))});function a(c){return function(u){return c.edge(u).weight}}}function n(o){var s=[],a={},c={};function u(l){e.has(c,l)||(c[l]=!0,a[l]=!0,e.forEach(o.outEdges(l),function(d){e.has(a,d.w)?s.push(d):u(d.w)}),delete a[l])}return e.forEach(o.nodes(),u),s}function i(o){e.forEach(o.edges(),function(s){var a=o.edge(s);if(a.reversed){o.removeEdge(s);var c=a.forwardName;delete a.reversed,delete a.forwardName,o.setEdge(s.w,s.v,a,c)}})}return cu}var uu,ty;function gr(){if(ty)return uu;ty=1;var e=Ke(),t=Pr().Graph;uu={addDummyNode:r,simplify:n,asNonCompoundGraph:i,successorWeights:o,predecessorWeights:s,intersectRect:a,buildLayerMatrix:c,normalizeRanks:u,removeEmptyRanks:l,addBorderNode:d,maxRank:h,partition:p,time:y,notime:m};function r(g,b,w,v){var x;do x=e.uniqueId(v);while(g.hasNode(x));return w.dummy=b,g.setNode(x,w),x}function n(g){var b=new t().setGraph(g.graph());return e.forEach(g.nodes(),function(w){b.setNode(w,g.node(w))}),e.forEach(g.edges(),function(w){var v=b.edge(w.v,w.w)||{weight:0,minlen:1},x=g.edge(w);b.setEdge(w.v,w.w,{weight:v.weight+x.weight,minlen:Math.max(v.minlen,x.minlen)})}),b}function i(g){var b=new t({multigraph:g.isMultigraph()}).setGraph(g.graph());return e.forEach(g.nodes(),function(w){g.children(w).length||b.setNode(w,g.node(w))}),e.forEach(g.edges(),function(w){b.setEdge(w,g.edge(w))}),b}function o(g){var b=e.map(g.nodes(),function(w){var v={};return e.forEach(g.outEdges(w),function(x){v[x.w]=(v[x.w]||0)+g.edge(x).weight}),v});return e.zipObject(g.nodes(),b)}function s(g){var b=e.map(g.nodes(),function(w){var v={};return e.forEach(g.inEdges(w),function(x){v[x.v]=(v[x.v]||0)+g.edge(x).weight}),v});return e.zipObject(g.nodes(),b)}function a(g,b){var w=g.x,v=g.y,x=b.x-w,C=b.y-v,S=g.width/2,E=g.height/2;if(!x&&!C)throw new Error("Not possible to find intersection inside of the rectangle");var I,A;return Math.abs(C)*S>Math.abs(x)*E?(C<0&&(E=-E),I=E*x/C,A=E):(x<0&&(S=-S),I=S,A=S*C/x),{x:w+I,y:v+A}}function c(g){var b=e.map(e.range(h(g)+1),function(){return[]});return e.forEach(g.nodes(),function(w){var v=g.node(w),x=v.rank;e.isUndefined(x)||(b[x][v.order]=w)}),b}function u(g){var b=e.min(e.map(g.nodes(),function(w){return g.node(w).rank}));e.forEach(g.nodes(),function(w){var v=g.node(w);e.has(v,"rank")&&(v.rank-=b)})}function l(g){var b=e.min(e.map(g.nodes(),function(C){return g.node(C).rank})),w=[];e.forEach(g.nodes(),function(C){var S=g.node(C).rank-b;w[S]||(w[S]=[]),w[S].push(C)});var v=0,x=g.graph().nodeRankFactor;e.forEach(w,function(C,S){e.isUndefined(C)&&S%x!==0?--v:v&&e.forEach(C,function(E){g.node(E).rank+=v})})}function d(g,b,w,v){var x={width:0,height:0};return arguments.length>=4&&(x.rank=w,x.order=v),r(g,"border",x,b)}function h(g){return e.max(e.map(g.nodes(),function(b){var w=g.node(b).rank;if(!e.isUndefined(w))return w}))}function p(g,b){var w={lhs:[],rhs:[]};return e.forEach(g,function(v){b(v)?w.lhs.push(v):w.rhs.push(v)}),w}function y(g,b){var w=e.now();try{return b()}finally{console.log(g+" time: "+(e.now()-w)+"ms")}}function m(g,b){return b()}return uu}var lu,ny;function dS(){if(ny)return lu;ny=1;var e=Ke(),t=gr();lu={run:r,undo:i};function r(o){o.graph().dummyChains=[],e.forEach(o.edges(),function(s){n(o,s)})}function n(o,s){var a=s.v,c=o.node(a).rank,u=s.w,l=o.node(u).rank,d=s.name,h=o.edge(s),p=h.labelRank;if(l!==c+1){o.removeEdge(s);var y,m,g;for(g=0,++c;c<l;++g,++c)h.points=[],m={width:0,height:0,edgeLabel:h,edgeObj:s,rank:c},y=t.addDummyNode(o,"edge",m,"_d"),c===p&&(m.width=h.width,m.height=h.height,m.dummy="edge-label",m.labelpos=h.labelpos),o.setEdge(a,y,{weight:h.weight},d),g===0&&o.graph().dummyChains.push(y),a=y;o.setEdge(a,u,{weight:h.weight},d)}}function i(o){e.forEach(o.graph().dummyChains,function(s){var a=o.node(s),c=a.edgeLabel,u;for(o.setEdge(a.edgeObj,c);a.dummy;)u=o.successors(s)[0],o.removeNode(s),c.points.push({x:a.x,y:a.y}),a.dummy==="edge-label"&&(c.x=a.x,c.y=a.y,c.width=a.width,c.height=a.height),s=u,a=o.node(s)})}return lu}var du,oy;function In(){if(oy)return du;oy=1;var e=Ke();du={longestPath:t,slack:r};function t(n){var i={};function o(s){var a=n.node(s);if(e.has(i,s))return a.rank;i[s]=!0;var c=e.min(e.map(n.outEdges(s),function(u){return o(u.w)-n.edge(u).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),a.rank=c}e.forEach(n.sources(),o)}function r(n,i){return n.node(i.w).rank-n.node(i.v).rank-n.edge(i).minlen}return du}var fu,iy;function ev(){if(iy)return fu;iy=1;var e=Ke(),t=Pr().Graph,r=In().slack;fu=n;function n(a){var c=new t({directed:!1}),u=a.nodes()[0],l=a.nodeCount();c.setNode(u,{});for(var d,h;i(c,a)<l;)d=o(c,a),h=c.hasNode(d.v)?r(a,d):-r(a,d),s(c,a,h);return c}function i(a,c){function u(l){e.forEach(c.nodeEdges(l),function(d){var h=d.v,p=l===h?d.w:h;!a.hasNode(p)&&!r(c,d)&&(a.setNode(p,{}),a.setEdge(l,p,{}),u(p))})}return e.forEach(a.nodes(),u),a.nodeCount()}function o(a,c){return e.minBy(c.edges(),function(u){if(a.hasNode(u.v)!==a.hasNode(u.w))return r(c,u)})}function s(a,c,u){e.forEach(a.nodes(),function(l){c.node(l).rank+=u})}return fu}var hu,ay;function fS(){if(ay)return hu;ay=1;var e=Ke(),t=ev(),r=In().slack,n=In().longestPath,i=Pr().alg.preorder,o=Pr().alg.postorder,s=gr().simplify;hu=a,a.initLowLimValues=d,a.initCutValues=c,a.calcCutValue=l,a.leaveEdge=p,a.enterEdge=y,a.exchangeEdges=m;function a(v){v=s(v),n(v);var x=t(v);d(x),c(x,v);for(var C,S;C=p(x);)S=y(x,v,C),m(x,v,C,S)}function c(v,x){var C=o(v,v.nodes());C=C.slice(0,C.length-1),e.forEach(C,function(S){u(v,x,S)})}function u(v,x,C){var S=v.node(C),E=S.parent;v.edge(C,E).cutvalue=l(v,x,C)}function l(v,x,C){var S=v.node(C),E=S.parent,I=!0,A=x.edge(C,E),M=0;return A||(I=!1,A=x.edge(E,C)),M=A.weight,e.forEach(x.nodeEdges(C),function(j){var R=j.v===C,P=R?j.w:j.v;if(P!==E){var k=R===I,q=x.edge(j).weight;if(M+=k?q:-q,b(v,C,P)){var O=v.edge(C,P).cutvalue;M+=k?-O:O}}}),M}function d(v,x){arguments.length<2&&(x=v.nodes()[0]),h(v,{},1,x)}function h(v,x,C,S,E){var I=C,A=v.node(S);return x[S]=!0,e.forEach(v.neighbors(S),function(M){e.has(x,M)||(C=h(v,x,C,M,S))}),A.low=I,A.lim=C++,E?A.parent=E:delete A.parent,C}function p(v){return e.find(v.edges(),function(x){return v.edge(x).cutvalue<0})}function y(v,x,C){var S=C.v,E=C.w;x.hasEdge(S,E)||(S=C.w,E=C.v);var I=v.node(S),A=v.node(E),M=I,j=!1;I.lim>A.lim&&(M=A,j=!0);var R=e.filter(x.edges(),function(P){return j===w(v,v.node(P.v),M)&&j!==w(v,v.node(P.w),M)});return e.minBy(R,function(P){return r(x,P)})}function m(v,x,C,S){var E=C.v,I=C.w;v.removeEdge(E,I),v.setEdge(S.v,S.w,{}),d(v),c(v,x),g(v,x)}function g(v,x){var C=e.find(v.nodes(),function(E){return!x.node(E).parent}),S=i(v,C);S=S.slice(1),e.forEach(S,function(E){var I=v.node(E).parent,A=x.edge(E,I),M=!1;A||(A=x.edge(I,E),M=!0),x.node(E).rank=x.node(I).rank+(M?A.minlen:-A.minlen)})}function b(v,x,C){return v.hasEdge(x,C)}function w(v,x,C){return C.low<=x.lim&&x.lim<=C.lim}return hu}var pu,sy;function hS(){if(sy)return pu;sy=1;var e=In(),t=e.longestPath,r=ev(),n=fS();pu=i;function i(c){switch(c.graph().ranker){case"network-simplex":a(c);break;case"tight-tree":s(c);break;case"longest-path":o(c);break;default:a(c)}}var o=t;function s(c){t(c),r(c)}function a(c){n(c)}return pu}var gu,cy;function pS(){if(cy)return gu;cy=1;var e=Ke();gu=t;function t(i){var o=n(i);e.forEach(i.graph().dummyChains,function(s){for(var a=i.node(s),c=a.edgeObj,u=r(i,o,c.v,c.w),l=u.path,d=u.lca,h=0,p=l[h],y=!0;s!==c.w;){if(a=i.node(s),y){for(;(p=l[h])!==d&&i.node(p).maxRank<a.rank;)h++;p===d&&(y=!1)}if(!y){for(;h<l.length-1&&i.node(p=l[h+1]).minRank<=a.rank;)h++;p=l[h]}i.setParent(s,p),s=i.successors(s)[0]}})}function r(i,o,s,a){var c=[],u=[],l=Math.min(o[s].low,o[a].low),d=Math.max(o[s].lim,o[a].lim),h,p;h=s;do h=i.parent(h),c.push(h);while(h&&(o[h].low>l||d>o[h].lim));for(p=h,h=a;(h=i.parent(h))!==p;)u.push(h);return{path:c.concat(u.reverse()),lca:p}}function n(i){var o={},s=0;function a(c){var u=s;e.forEach(i.children(c),a),o[c]={low:u,lim:s++}}return e.forEach(i.children(),a),o}return gu}var yu,uy;function gS(){if(uy)return yu;uy=1;var e=Ke(),t=gr();yu={run:r,cleanup:s};function r(a){var c=t.addDummyNode(a,"root",{},"_root"),u=i(a),l=e.max(e.values(u))-1,d=2*l+1;a.graph().nestingRoot=c,e.forEach(a.edges(),function(p){a.edge(p).minlen*=d});var h=o(a)+1;e.forEach(a.children(),function(p){n(a,c,d,h,l,u,p)}),a.graph().nodeRankFactor=d}function n(a,c,u,l,d,h,p){var y=a.children(p);if(!y.length){p!==c&&a.setEdge(c,p,{weight:0,minlen:u});return}var m=t.addBorderNode(a,"_bt"),g=t.addBorderNode(a,"_bb"),b=a.node(p);a.setParent(m,p),b.borderTop=m,a.setParent(g,p),b.borderBottom=g,e.forEach(y,function(w){n(a,c,u,l,d,h,w);var v=a.node(w),x=v.borderTop?v.borderTop:w,C=v.borderBottom?v.borderBottom:w,S=v.borderTop?l:2*l,E=x!==C?1:d-h[p]+1;a.setEdge(m,x,{weight:S,minlen:E,nestingEdge:!0}),a.setEdge(C,g,{weight:S,minlen:E,nestingEdge:!0})}),a.parent(p)||a.setEdge(c,m,{weight:0,minlen:d+h[p]})}function i(a){var c={};function u(l,d){var h=a.children(l);h&&h.length&&e.forEach(h,function(p){u(p,d+1)}),c[l]=d}return e.forEach(a.children(),function(l){u(l,1)}),c}function o(a){return e.reduce(a.edges(),function(c,u){return c+a.edge(u).weight},0)}function s(a){var c=a.graph();a.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(a.edges(),function(u){var l=a.edge(u);l.nestingEdge&&a.removeEdge(u)})}return yu}var mu,ly;function yS(){if(ly)return mu;ly=1;var e=Ke(),t=gr();mu=r;function r(i){function o(s){var a=i.children(s),c=i.node(s);if(a.length&&e.forEach(a,o),e.has(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(var u=c.minRank,l=c.maxRank+1;u<l;++u)n(i,"borderLeft","_bl",s,c,u),n(i,"borderRight","_br",s,c,u)}}e.forEach(i.children(),o)}function n(i,o,s,a,c,u){var l={width:0,height:0,rank:u,borderType:o},d=c[o][u-1],h=t.addDummyNode(i,"border",l,s);c[o][u]=h,i.setParent(h,a),d&&i.setEdge(d,h,{weight:1})}return mu}var bu,dy;function mS(){if(dy)return bu;dy=1;var e=Ke();bu={adjust:t,undo:r};function t(u){var l=u.graph().rankdir.toLowerCase();(l==="lr"||l==="rl")&&n(u)}function r(u){var l=u.graph().rankdir.toLowerCase();(l==="bt"||l==="rl")&&o(u),(l==="lr"||l==="rl")&&(a(u),n(u))}function n(u){e.forEach(u.nodes(),function(l){i(u.node(l))}),e.forEach(u.edges(),function(l){i(u.edge(l))})}function i(u){var l=u.width;u.width=u.height,u.height=l}function o(u){e.forEach(u.nodes(),function(l){s(u.node(l))}),e.forEach(u.edges(),function(l){var d=u.edge(l);e.forEach(d.points,s),e.has(d,"y")&&s(d)})}function s(u){u.y=-u.y}function a(u){e.forEach(u.nodes(),function(l){c(u.node(l))}),e.forEach(u.edges(),function(l){var d=u.edge(l);e.forEach(d.points,c),e.has(d,"x")&&c(d)})}function c(u){var l=u.x;u.x=u.y,u.y=l}return bu}var vu,fy;function bS(){if(fy)return vu;fy=1;var e=Ke();vu=t;function t(r){var n={},i=e.filter(r.nodes(),function(u){return!r.children(u).length}),o=e.max(e.map(i,function(u){return r.node(u).rank})),s=e.map(e.range(o+1),function(){return[]});function a(u){if(!e.has(n,u)){n[u]=!0;var l=r.node(u);s[l.rank].push(u),e.forEach(r.successors(u),a)}}var c=e.sortBy(i,function(u){return r.node(u).rank});return e.forEach(c,a),s}return vu}var xu,hy;function vS(){if(hy)return xu;hy=1;var e=Ke();xu=t;function t(n,i){for(var o=0,s=1;s<i.length;++s)o+=r(n,i[s-1],i[s]);return o}function r(n,i,o){for(var s=e.zipObject(o,e.map(o,function(h,p){return p})),a=e.flatten(e.map(i,function(h){return e.sortBy(e.map(n.outEdges(h),function(p){return{pos:s[p.w],weight:n.edge(p).weight}}),"pos")}),!0),c=1;c<o.length;)c<<=1;var u=2*c-1;c-=1;var l=e.map(new Array(u),function(){return 0}),d=0;return e.forEach(a.forEach(function(h){var p=h.pos+c;l[p]+=h.weight;for(var y=0;p>0;)p%2&&(y+=l[p+1]),p=p-1>>1,l[p]+=h.weight;d+=h.weight*y})),d}return xu}var wu,py;function xS(){if(py)return wu;py=1;var e=Ke();wu=t;function t(r,n){return e.map(n,function(i){var o=r.inEdges(i);if(o.length){var s=e.reduce(o,function(a,c){var u=r.edge(c),l=r.node(c.v);return{sum:a.sum+u.weight*l.order,weight:a.weight+u.weight}},{sum:0,weight:0});return{v:i,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:i}})}return wu}var Cu,gy;function wS(){if(gy)return Cu;gy=1;var e=Ke();Cu=t;function t(i,o){var s={};e.forEach(i,function(c,u){var l=s[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:u};e.isUndefined(c.barycenter)||(l.barycenter=c.barycenter,l.weight=c.weight)}),e.forEach(o.edges(),function(c){var u=s[c.v],l=s[c.w];!e.isUndefined(u)&&!e.isUndefined(l)&&(l.indegree++,u.out.push(s[c.w]))});var a=e.filter(s,function(c){return!c.indegree});return r(a)}function r(i){var o=[];function s(u){return function(l){l.merged||(e.isUndefined(l.barycenter)||e.isUndefined(u.barycenter)||l.barycenter>=u.barycenter)&&n(u,l)}}function a(u){return function(l){l.in.push(u),--l.indegree===0&&i.push(l)}}for(;i.length;){var c=i.pop();o.push(c),e.forEach(c.in.reverse(),s(c)),e.forEach(c.out,a(c))}return e.map(e.filter(o,function(u){return!u.merged}),function(u){return e.pick(u,["vs","i","barycenter","weight"])})}function n(i,o){var s=0,a=0;i.weight&&(s+=i.barycenter*i.weight,a+=i.weight),o.weight&&(s+=o.barycenter*o.weight,a+=o.weight),i.vs=o.vs.concat(i.vs),i.barycenter=s/a,i.weight=a,i.i=Math.min(o.i,i.i),o.merged=!0}return Cu}var Su,yy;function CS(){if(yy)return Su;yy=1;var e=Ke(),t=gr();Su=r;function r(o,s){var a=t.partition(o,function(m){return e.has(m,"barycenter")}),c=a.lhs,u=e.sortBy(a.rhs,function(m){return-m.i}),l=[],d=0,h=0,p=0;c.sort(i(!!s)),p=n(l,u,p),e.forEach(c,function(m){p+=m.vs.length,l.push(m.vs),d+=m.barycenter*m.weight,h+=m.weight,p=n(l,u,p)});var y={vs:e.flatten(l,!0)};return h&&(y.barycenter=d/h,y.weight=h),y}function n(o,s,a){for(var c;s.length&&(c=e.last(s)).i<=a;)s.pop(),o.push(c.vs),a++;return a}function i(o){return function(s,a){return s.barycenter<a.barycenter?-1:s.barycenter>a.barycenter?1:o?a.i-s.i:s.i-a.i}}return Su}var _u,my;function SS(){if(my)return _u;my=1;var e=Ke(),t=xS(),r=wS(),n=CS();_u=i;function i(a,c,u,l){var d=a.children(c),h=a.node(c),p=h?h.borderLeft:void 0,y=h?h.borderRight:void 0,m={};p&&(d=e.filter(d,function(C){return C!==p&&C!==y}));var g=t(a,d);e.forEach(g,function(C){if(a.children(C.v).length){var S=i(a,C.v,u,l);m[C.v]=S,e.has(S,"barycenter")&&s(C,S)}});var b=r(g,u);o(b,m);var w=n(b,l);if(p&&(w.vs=e.flatten([p,w.vs,y],!0),a.predecessors(p).length)){var v=a.node(a.predecessors(p)[0]),x=a.node(a.predecessors(y)[0]);e.has(w,"barycenter")||(w.barycenter=0,w.weight=0),w.barycenter=(w.barycenter*w.weight+v.order+x.order)/(w.weight+2),w.weight+=2}return w}function o(a,c){e.forEach(a,function(u){u.vs=e.flatten(u.vs.map(function(l){return c[l]?c[l].vs:l}),!0)})}function s(a,c){e.isUndefined(a.barycenter)?(a.barycenter=c.barycenter,a.weight=c.weight):(a.barycenter=(a.barycenter*a.weight+c.barycenter*c.weight)/(a.weight+c.weight),a.weight+=c.weight)}return _u}var Eu,by;function _S(){if(by)return Eu;by=1;var e=Ke(),t=Pr().Graph;Eu=r;function r(i,o,s){var a=n(i),c=new t({compound:!0}).setGraph({root:a}).setDefaultNodeLabel(function(u){return i.node(u)});return e.forEach(i.nodes(),function(u){var l=i.node(u),d=i.parent(u);(l.rank===o||l.minRank<=o&&o<=l.maxRank)&&(c.setNode(u),c.setParent(u,d||a),e.forEach(i[s](u),function(h){var p=h.v===u?h.w:h.v,y=c.edge(p,u),m=e.isUndefined(y)?0:y.weight;c.setEdge(p,u,{weight:i.edge(h).weight+m})}),e.has(l,"minRank")&&c.setNode(u,{borderLeft:l.borderLeft[o],borderRight:l.borderRight[o]}))}),c}function n(i){for(var o;i.hasNode(o=e.uniqueId("_root")););return o}return Eu}var ju,vy;function ES(){if(vy)return ju;vy=1;var e=Ke();ju=t;function t(r,n,i){var o={},s;e.forEach(i,function(a){for(var c=r.parent(a),u,l;c;){if(u=r.parent(c),u?(l=o[u],o[u]=c):(l=s,s=c),l&&l!==c){n.setEdge(l,c);return}c=u}})}return ju}var ku,xy;function jS(){if(xy)return ku;xy=1;var e=Ke(),t=bS(),r=vS(),n=SS(),i=_S(),o=ES(),s=Pr().Graph,a=gr();ku=c;function c(h){var p=a.maxRank(h),y=u(h,e.range(1,p+1),"inEdges"),m=u(h,e.range(p-1,-1,-1),"outEdges"),g=t(h);d(h,g);for(var b=Number.POSITIVE_INFINITY,w,v=0,x=0;x<4;++v,++x){l(v%2?y:m,v%4>=2),g=a.buildLayerMatrix(h);var C=r(h,g);C<b&&(x=0,w=e.cloneDeep(g),b=C)}d(h,w)}function u(h,p,y){return e.map(p,function(m){return i(h,m,y)})}function l(h,p){var y=new s;e.forEach(h,function(m){var g=m.graph().root,b=n(m,g,y,p);e.forEach(b.vs,function(w,v){m.node(w).order=v}),o(m,y,b.vs)})}function d(h,p){e.forEach(p,function(y){e.forEach(y,function(m,g){h.node(m).order=g})})}return ku}var Ru,wy;function kS(){if(wy)return Ru;wy=1;var e=Ke(),t=Pr().Graph,r=gr();Ru={positionX:y,findType1Conflicts:n,findType2Conflicts:i,addConflict:s,hasConflict:a,verticalAlignment:c,horizontalCompaction:u,alignCoordinates:h,findSmallestWidthAlignment:d,balance:p};function n(b,w){var v={};function x(C,S){var E=0,I=0,A=C.length,M=e.last(S);return e.forEach(S,function(j,R){var P=o(b,j),k=P?b.node(P).order:A;(P||j===M)&&(e.forEach(S.slice(I,R+1),function(q){e.forEach(b.predecessors(q),function(O){var z=b.node(O),U=z.order;(U<E||k<U)&&!(z.dummy&&b.node(q).dummy)&&s(v,O,q)})}),I=R+1,E=k)}),S}return e.reduce(w,x),v}function i(b,w){var v={};function x(S,E,I,A,M){var j;e.forEach(e.range(E,I),function(R){j=S[R],b.node(j).dummy&&e.forEach(b.predecessors(j),function(P){var k=b.node(P);k.dummy&&(k.order<A||k.order>M)&&s(v,P,j)})})}function C(S,E){var I=-1,A,M=0;return e.forEach(E,function(j,R){if(b.node(j).dummy==="border"){var P=b.predecessors(j);P.length&&(A=b.node(P[0]).order,x(E,M,R,I,A),M=R,I=A)}x(E,M,E.length,A,S.length)}),E}return e.reduce(w,C),v}function o(b,w){if(b.node(w).dummy)return e.find(b.predecessors(w),function(v){return b.node(v).dummy})}function s(b,w,v){if(w>v){var x=w;w=v,v=x}var C=b[w];C||(b[w]=C={}),C[v]=!0}function a(b,w,v){if(w>v){var x=w;w=v,v=x}return e.has(b[w],v)}function c(b,w,v,x){var C={},S={},E={};return e.forEach(w,function(I){e.forEach(I,function(A,M){C[A]=A,S[A]=A,E[A]=M})}),e.forEach(w,function(I){var A=-1;e.forEach(I,function(M){var j=x(M);if(j.length){j=e.sortBy(j,function(O){return E[O]});for(var R=(j.length-1)/2,P=Math.floor(R),k=Math.ceil(R);P<=k;++P){var q=j[P];S[M]===M&&A<E[q]&&!a(v,M,q)&&(S[q]=M,S[M]=C[M]=C[q],A=E[q])}}})}),{root:C,align:S}}function u(b,w,v,x,C){var S={},E=l(b,w,v,C),I=C?"borderLeft":"borderRight";function A(R,P){for(var k=E.nodes(),q=k.pop(),O={};q;)O[q]?R(q):(O[q]=!0,k.push(q),k=k.concat(P(q))),q=k.pop()}function M(R){S[R]=E.inEdges(R).reduce(function(P,k){return Math.max(P,S[k.v]+E.edge(k))},0)}function j(R){var P=E.outEdges(R).reduce(function(q,O){return Math.min(q,S[O.w]-E.edge(O))},Number.POSITIVE_INFINITY),k=b.node(R);P!==Number.POSITIVE_INFINITY&&k.borderType!==I&&(S[R]=Math.max(S[R],P))}return A(M,E.predecessors.bind(E)),A(j,E.successors.bind(E)),e.forEach(x,function(R){S[R]=S[v[R]]}),S}function l(b,w,v,x){var C=new t,S=b.graph(),E=m(S.nodesep,S.edgesep,x);return e.forEach(w,function(I){var A;e.forEach(I,function(M){var j=v[M];if(C.setNode(j),A){var R=v[A],P=C.edge(R,j);C.setEdge(R,j,Math.max(E(b,M,A),P||0))}A=M})}),C}function d(b,w){return e.minBy(e.values(w),function(v){var x=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;return e.forIn(v,function(S,E){var I=g(b,E)/2;x=Math.max(S+I,x),C=Math.min(S-I,C)}),x-C})}function h(b,w){var v=e.values(w),x=e.min(v),C=e.max(v);e.forEach(["u","d"],function(S){e.forEach(["l","r"],function(E){var I=S+E,A=b[I],M;if(A!==w){var j=e.values(A);M=E==="l"?x-e.min(j):C-e.max(j),M&&(b[I]=e.mapValues(A,function(R){return R+M}))}})})}function p(b,w){return e.mapValues(b.ul,function(v,x){if(w)return b[w.toLowerCase()][x];var C=e.sortBy(e.map(b,x));return(C[1]+C[2])/2})}function y(b){var w=r.buildLayerMatrix(b),v=e.merge(n(b,w),i(b,w)),x={},C;e.forEach(["u","d"],function(E){C=E==="u"?w:e.values(w).reverse(),e.forEach(["l","r"],function(I){I==="r"&&(C=e.map(C,function(R){return e.values(R).reverse()}));var A=(E==="u"?b.predecessors:b.successors).bind(b),M=c(b,C,v,A),j=u(b,C,M.root,M.align,I==="r");I==="r"&&(j=e.mapValues(j,function(R){return-R})),x[E+I]=j})});var S=d(b,x);return h(x,S),p(x,b.graph().align)}function m(b,w,v){return function(x,C,S){var E=x.node(C),I=x.node(S),A=0,M;if(A+=E.width/2,e.has(E,"labelpos"))switch(E.labelpos.toLowerCase()){case"l":M=-E.width/2;break;case"r":M=E.width/2;break}if(M&&(A+=v?M:-M),M=0,A+=(E.dummy?w:b)/2,A+=(I.dummy?w:b)/2,A+=I.width/2,e.has(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":M=I.width/2;break;case"r":M=-I.width/2;break}return M&&(A+=v?M:-M),M=0,A}}function g(b,w){return b.node(w).width}return Ru}var Pu,Cy;function RS(){if(Cy)return Pu;Cy=1;var e=Ke(),t=gr(),r=kS().positionX;Pu=n;function n(o){o=t.asNonCompoundGraph(o),i(o),e.forEach(r(o),function(s,a){o.node(a).x=s})}function i(o){var s=t.buildLayerMatrix(o),a=o.graph().ranksep,c=0;e.forEach(s,function(u){var l=e.max(e.map(u,function(d){return o.node(d).height}));e.forEach(u,function(d){o.node(d).y=c+l/2}),c+=l+a})}return Pu}var Au,Sy;function PS(){if(Sy)return Au;Sy=1;var e=Ke(),t=lS(),r=dS(),n=hS(),i=gr().normalizeRanks,o=pS(),s=gr().removeEmptyRanks,a=gS(),c=yS(),u=mS(),l=jS(),d=RS(),h=gr(),p=Pr().Graph;Au=y;function y($,V){var W=V&&V.debugTiming?h.time:h.notime;W("layout",function(){var N=W(" buildLayoutGraph",function(){return A($)});W(" runLayout",function(){m(N,W)}),W(" updateInputGraph",function(){g($,N)})})}function m($,V){V(" makeSpaceForEdgeLabels",function(){M($)}),V(" removeSelfEdges",function(){se($)}),V(" acyclic",function(){t.run($)}),V(" nestingGraph.run",function(){a.run($)}),V(" rank",function(){n(h.asNonCompoundGraph($))}),V(" injectEdgeLabelProxies",function(){j($)}),V(" removeEmptyRanks",function(){s($)}),V(" nestingGraph.cleanup",function(){a.cleanup($)}),V(" normalizeRanks",function(){i($)}),V(" assignRankMinMax",function(){R($)}),V(" removeEdgeLabelProxies",function(){P($)}),V(" normalize.run",function(){r.run($)}),V(" parentDummyChains",function(){o($)}),V(" addBorderSegments",function(){c($)}),V(" order",function(){l($)}),V(" insertSelfEdges",function(){Q($)}),V(" adjustCoordinateSystem",function(){u.adjust($)}),V(" position",function(){d($)}),V(" positionSelfEdges",function(){Y($)}),V(" removeBorderNodes",function(){U($)}),V(" normalize.undo",function(){r.undo($)}),V(" fixupEdgeLabelCoords",function(){O($)}),V(" undoCoordinateSystem",function(){u.undo($)}),V(" translateGraph",function(){k($)}),V(" assignNodeIntersects",function(){q($)}),V(" reversePoints",function(){z($)}),V(" acyclic.undo",function(){t.undo($)})}function g($,V){e.forEach($.nodes(),function(W){var N=$.node(W),ne=V.node(W);N&&(N.x=ne.x,N.y=ne.y,V.children(W).length&&(N.width=ne.width,N.height=ne.height))}),e.forEach($.edges(),function(W){var N=$.edge(W),ne=V.edge(W);N.points=ne.points,e.has(ne,"x")&&(N.x=ne.x,N.y=ne.y)}),$.graph().width=V.graph().width,$.graph().height=V.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],w={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},v=["acyclicer","ranker","rankdir","align"],x=["width","height"],C={width:0,height:0},S=["minlen","weight","width","height","labeloffset"],E={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},I=["labelpos"];function A($){var V=new p({multigraph:!0,compound:!0}),W=ce($.graph());return V.setGraph(e.merge({},w,ge(W,b),e.pick(W,v))),e.forEach($.nodes(),function(N){var ne=ce($.node(N));V.setNode(N,e.defaults(ge(ne,x),C)),V.setParent(N,$.parent(N))}),e.forEach($.edges(),function(N){var ne=ce($.edge(N));V.setEdge(N,e.merge({},E,ge(ne,S),e.pick(ne,I)))}),V}function M($){var V=$.graph();V.ranksep/=2,e.forEach($.edges(),function(W){var N=$.edge(W);N.minlen*=2,N.labelpos.toLowerCase()!=="c"&&(V.rankdir==="TB"||V.rankdir==="BT"?N.width+=N.labeloffset:N.height+=N.labeloffset)})}function j($){e.forEach($.edges(),function(V){var W=$.edge(V);if(W.width&&W.height){var N=$.node(V.v),ne=$.node(V.w),be={rank:(ne.rank-N.rank)/2+N.rank,e:V};h.addDummyNode($,"edge-proxy",be,"_ep")}})}function R($){var V=0;e.forEach($.nodes(),function(W){var N=$.node(W);N.borderTop&&(N.minRank=$.node(N.borderTop).rank,N.maxRank=$.node(N.borderBottom).rank,V=e.max(V,N.maxRank))}),$.graph().maxRank=V}function P($){e.forEach($.nodes(),function(V){var W=$.node(V);W.dummy==="edge-proxy"&&($.edge(W.e).labelRank=W.rank,$.removeNode(V))})}function k($){var V=Number.POSITIVE_INFINITY,W=0,N=Number.POSITIVE_INFINITY,ne=0,be=$.graph(),fe=be.marginx||0,J=be.marginy||0;function te(G){var le=G.x,ue=G.y,Ce=G.width,ye=G.height;V=Math.min(V,le-Ce/2),W=Math.max(W,le+Ce/2),N=Math.min(N,ue-ye/2),ne=Math.max(ne,ue+ye/2)}e.forEach($.nodes(),function(G){te($.node(G))}),e.forEach($.edges(),function(G){var le=$.edge(G);e.has(le,"x")&&te(le)}),V-=fe,N-=J,e.forEach($.nodes(),function(G){var le=$.node(G);le.x-=V,le.y-=N}),e.forEach($.edges(),function(G){var le=$.edge(G);e.forEach(le.points,function(ue){ue.x-=V,ue.y-=N}),e.has(le,"x")&&(le.x-=V),e.has(le,"y")&&(le.y-=N)}),be.width=W-V+fe,be.height=ne-N+J}function q($){e.forEach($.edges(),function(V){var W=$.edge(V),N=$.node(V.v),ne=$.node(V.w),be,fe;W.points?(be=W.points[0],fe=W.points[W.points.length-1]):(W.points=[],be=ne,fe=N),W.points.unshift(h.intersectRect(N,be)),W.points.push(h.intersectRect(ne,fe))})}function O($){e.forEach($.edges(),function(V){var W=$.edge(V);if(e.has(W,"x"))switch((W.labelpos==="l"||W.labelpos==="r")&&(W.width-=W.labeloffset),W.labelpos){case"l":W.x-=W.width/2+W.labeloffset;break;case"r":W.x+=W.width/2+W.labeloffset;break}})}function z($){e.forEach($.edges(),function(V){var W=$.edge(V);W.reversed&&W.points.reverse()})}function U($){e.forEach($.nodes(),function(V){if($.children(V).length){var W=$.node(V),N=$.node(W.borderTop),ne=$.node(W.borderBottom),be=$.node(e.last(W.borderLeft)),fe=$.node(e.last(W.borderRight));W.width=Math.abs(fe.x-be.x),W.height=Math.abs(ne.y-N.y),W.x=be.x+W.width/2,W.y=N.y+W.height/2}}),e.forEach($.nodes(),function(V){$.node(V).dummy==="border"&&$.removeNode(V)})}function se($){e.forEach($.edges(),function(V){if(V.v===V.w){var W=$.node(V.v);W.selfEdges||(W.selfEdges=[]),W.selfEdges.push({e:V,label:$.edge(V)}),$.removeEdge(V)}})}function Q($){var V=h.buildLayerMatrix($);e.forEach(V,function(W){var N=0;e.forEach(W,function(ne,be){var fe=$.node(ne);fe.order=be+N,e.forEach(fe.selfEdges,function(J){h.addDummyNode($,"selfedge",{width:J.label.width,height:J.label.height,rank:fe.rank,order:be+ ++N,e:J.e,label:J.label},"_se")}),delete fe.selfEdges})})}function Y($){e.forEach($.nodes(),function(V){var W=$.node(V);if(W.dummy==="selfedge"){var N=$.node(W.e.v),ne=N.x+N.width/2,be=N.y,fe=W.x-ne,J=N.height/2;$.setEdge(W.e,W.label),$.removeNode(V),W.label.points=[{x:ne+2*fe/3,y:be-J},{x:ne+5*fe/6,y:be-J},{x:ne+fe,y:be},{x:ne+5*fe/6,y:be+J},{x:ne+2*fe/3,y:be+J}],W.label.x=W.x,W.label.y=W.y}})}function ge($,V){return e.mapValues(e.pick($,V),Number)}function ce($){var V={};return e.forEach($,function(W,N){V[N.toLowerCase()]=W}),V}return Au}var Tu,_y;function AS(){if(_y)return Tu;_y=1;var e=Ke(),t=gr(),r=Pr().Graph;Tu={debugOrdering:n};function n(i){var o=t.buildLayerMatrix(i),s=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(i.nodes(),function(a){s.setNode(a,{label:a}),s.setParent(a,"layer"+i.node(a).rank)}),e.forEach(i.edges(),function(a){s.setEdge(a.v,a.w,{},a.name)}),e.forEach(o,function(a,c){var u="layer"+c;s.setNode(u,{rank:"same"}),e.reduce(a,function(l,d){return s.setEdge(l,d,{style:"invis"}),d})}),s}return Tu}var Iu,Ey;function TS(){return Ey||(Ey=1,Iu="0.8.5"),Iu}var Ou,jy;function IS(){return jy||(jy=1,Ou={graphlib:Pr(),layout:PS(),debug:AS(),util:{time:gr().time,notime:gr().notime},version:TS()}),Ou}var OS=IS();const ky=mw(OS);function MS(e,t,r){var l;const n=new Set(e.map(d=>d.id)),i=new Set;for(const d of e)d.parent&&n.has(d.parent)&&i.add(d.parent);const o=new ky.graphlib.Graph({multigraph:!0,compound:!0}),s=r.compactSpacingScale??(r.spacingFactor>0?r.spacingFactor/1.3:1);o.setGraph({rankdir:r.rankDir,nodesep:r.compact?Math.max(r.nodeSep,24*s):r.nodeSep,edgesep:r.compact?Math.min(r.edgeSep,24*s):r.edgeSep,ranksep:r.compact?Math.min(r.rankSep,80*s):r.rankSep,ranker:"network-simplex"}),o.setDefaultEdgeLabel(()=>({})),o.setDefaultNodeLabel(()=>({}));for(const d of e)o.setNode(d.id,{width:d.width+2,height:d.height+2});for(const d of e)d.parent&&n.has(d.parent)&&o.setParent(d.id,d.parent);for(const d of t){if(!n.has(d.source)||!n.has(d.target)||i.has(d.source)||i.has(d.target))continue;const h=Qm(d.label,d.icon??((l=d.data)==null?void 0:l.icon),r.edgeLabelFontSize),p=r.rankDir==="LR"||r.rankDir==="RL",y=(h.width?h.width+2*Xm:0)+(d.connectorClearance??0);o.setEdge(d.source,d.target,{minlen:1,weight:1,...y?{width:p?y:Math.max(1,h.height),height:p?Math.max(1,h.height):y,labelpos:"c"}:{}},d.id)}ky.layout(o);const a=new Map;for(const d of e){if(i.has(d.id))continue;const h=o.node(d.id);h&&Number.isFinite(h.x)&&Number.isFinite(h.y)&&a.set(d.id,{x:h.x,y:h.y})}const c=r.compact?1:r.spacingFactor;if(c&&c!==1&&a.size){let d=1/0,h=1/0,p=-1/0,y=-1/0;a.forEach(b=>{d=Math.min(d,b.x),h=Math.min(h,b.y),p=Math.max(p,b.x),y=Math.max(y,b.y)});const m=(d+p)/2,g=(h+y)/2;a.forEach((b,w)=>a.set(w,{x:m+(b.x-m)*c,y:g+(b.y-g)*c}))}const u=r.nodeAlignment??"center";if(u!=="center"){const d=r.rankDir==="LR"||r.rankDir==="RL",h=d?"x":"y",p=d?"width":"height",y=r.rankDir==="RL"||r.rankDir==="BT"?-1:1,m=u==="leading"?-y:y,g=new Map;for(const b of e){const w=a.get(b.id);if(!w)continue;const v=w[h];g.set(v,Math.max(g.get(v)??0,b[p]))}for(const b of e){const w=a.get(b.id);if(!w)continue;const v=w[h],x=(g.get(v)-b[p])/2;a.set(b.id,{...w,[h]:v+m*x})}}return a}function Ry(e,t,r,n,i){const o=new Map,s=new Map(e.map(l=>[l.id,l]));for(const l of e){if(!l.parent||!s.has(l.parent))continue;const d=o.get(l.parent);d?d.push(l.id):o.set(l.parent,[l.id])}const a=(l,d=new Set)=>{var p;const h=(p=s.get(l))==null?void 0:p.parent;return!h||!s.has(h)||d.has(l)?0:(d.add(l),1+a(h,d))},c=[...o.keys()].sort((l,d)=>a(d)-a(l)),u=new Map;for(const l of c){let d=null;for(const y of o.get(l)||[]){let m=u.get(y);if(!m){const g=t.get(y);if(!g)continue;const b=r.get(y)||{w:60,h:60};m={x1:g.x-b.w/2,y1:g.y-b.h/2,x2:g.x+b.w/2,y2:g.y+b.h/2}}d=d?{x1:Math.min(d.x1,m.x1),y1:Math.min(d.y1,m.y1),x2:Math.max(d.x2,m.x2),y2:Math.max(d.y2,m.y2)}:{...m}}if(!d)continue;const h=n(l);d={x1:d.x1-h,y1:d.y1-h,x2:d.x2+h,y2:d.y2+h};const p=i(l);if(p){const y=d.x2-d.x1,m=d.y2-d.y1;if(p.w>y){const g=(p.w-y)/2;d.x1-=g,d.x2+=g}if(p.h>m){const g=(p.h-m)/2;d.y1-=g,d.y2+=g}}u.set(l,d)}return u}function qS(e){const t=e.getBoundingClientRect(),r=t.height/e.offsetHeight;if(!Number.isFinite(r)||r<=0)return[];const n=Zm(e),i={x:e.offsetWidth/2,y:e.offsetHeight/2,w:e.offsetWidth,h:e.offsetHeight},o=[...e.querySelectorAll("[data-flow-property]")],s=new Set(o.filter(a=>a.hasAttribute("data-flow-inspection-row")&&a.getBoundingClientRect().height>0).map(a=>a.dataset.flowProperty));return o.flatMap(a=>{if(a.closest(".flow-sdk-node")!==e)return[];if(s.has(a.dataset.flowProperty)&&!a.hasAttribute("data-flow-inspection-row"))return[];const c=a.dataset.flowPortSide;if(c&&["top","right","bottom","left"].includes(c)){const l=Hm(n?en(i,n):i,c,Number(a.dataset.flowPortPosition??.5));return[{property:a.getAttribute("data-flow-property"),top:l.y,height:0,anchor:l,...a.dataset.flowPortPlacement==="config"?{placement:"config"}:{},...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]}const u=a.getBoundingClientRect();return!u.width||!u.height?[]:[{property:a.getAttribute("data-flow-property"),top:Math.round((u.top-t.top)/r*1e3)/1e3,height:Math.round(u.height/r*1e3)/1e3,...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]})}function $S({id:e,x:t,y:r,placed:n,hidden:i,onMount:o,drawHandles:s,drawMode:a,connectedPorts:c,resolvedRows:u,hasCollapseControl:l,handleColor:d,animated:h,animationColor:p,animationWidth:y=8,animationVariant:m,width:g=0,height:b=0,propertyMode:w,reversePorts:v,direction:x="LR",onPropertyRows:C,onSurface:S,children:E}){const I=_.useRef(null),[A,M]=_.useState([]),j=u??A,[R,P]=_.useState();return _.useLayoutEffect(()=>{const k=I.current;if(!k)return;const q=()=>{const U=Zm(k);P(se=>JSON.stringify(se)===JSON.stringify(U)?se:U),S==null||S(e,U)};q();const O=new ResizeObserver(q);O.observe(k);const z=k.querySelector("[data-flow-node-surface]");return z&&O.observe(z),()=>O.disconnect()},[e,E,S]),_.useLayoutEffect(()=>(o(e,I.current),()=>{o(e,null),S==null||S(e,void 0)}),[e,o,S]),_.useLayoutEffect(()=>{const k=I.current;if(!k)return;let q="";const O=()=>{const Q=qS(k),Y=w?Q:Q.filter(ce=>ce.anchor),ge=JSON.stringify(Y);ge!==q&&(q=ge,M(Y),C==null||C(e,Y))};if(O(),!w&&!k.querySelector("[data-flow-port-side]"))return;const z=new ResizeObserver(O),U=()=>{z.disconnect(),z.observe(k),k.querySelectorAll("[data-flow-property]").forEach(Q=>z.observe(Q)),O()};U();const se=new MutationObserver(U);return se.observe(k,{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"]}),k.addEventListener("scroll",O,!0),()=>{z.disconnect(),se.disconnect(),k.removeEventListener("scroll",O,!0)}},[e,w,C,E]),f.jsxs("div",{ref:I,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&&!i?void 0:"hidden"},children:[E,h&&y>0&&g>0&&b>0&&f.jsx("svg",{className:"flow-sdk-node-animation","aria-hidden":"true",pointerEvents:"none",children:f.jsx(Um,{variant:m,x:((R==null?void 0:R.left)??0)+y/2,y:((R==null?void 0:R.top)??0)+y/2,width:((R==null?void 0:R.width)??g)-y,height:((R==null?void 0:R.height)??b)-y,radius:((R==null?void 0:R.radius)??0)-y/2,path:R!=null&&R.outline?`M${R.outline.map(k=>`${k.x} ${k.y}`).join(" L")} Z`:void 0,color:p||d||"currentColor",strokeWidth:y})}),s&&w&&j.map(k=>["source","target"].filter(q=>!k.role||k.role===q).filter(q=>a||(c==null?void 0:c.has(`${q}:${k.property}`))).map(q=>{var O;return f.jsx("button",{type:"button",className:"flow-sdk-property-port","data-property":k.property,"data-port-role":q,"data-port-side":(O=k.anchor)==null?void 0:O.side,"aria-label":`${q==="source"?"Connect":"Input"} ${k.property}`,title:`${q==="source"?"Connect":"Input"} ${k.property}`,style:{color:d,...k.anchor?{top:k.anchor.y,left:k.anchor.x-16}:{top:k.top+k.height/2,[q==="source"!=!!v?"right":"left"]:-16}},onClick:z=>z.stopPropagation()},`${k.property}:${q}`)})),s&&!l&&(!w||!j.length)&&(!w||!j.some(k=>k.anchor))&&f.jsx("button",{type:"button",className:"flow-sdk-handle","aria-label":"Draw edge",title:"Draw edge",style:{color:d,left:((R==null?void 0:R.left)??0)+(x==="RL"?-36:x==="LR"?(R==null?void 0:R.width)??g:((R==null?void 0:R.width)??g)/2),top:((R==null?void 0:R.top)??0)+(x==="BT"?-36:x==="TB"?(R==null?void 0:R.height)??b:((R==null?void 0:R.height)??b)/2),transform:x==="BT"||x==="TB"?"translateX(-50%)":"translateY(-50%)"},onClick:k=>k.stopPropagation(),children:f.jsx(K.PiPlusBold,{size:24})})]})}const NS=_.memo($S);function LS(e,t,r){const[n,i]=_.useState(()=>({nodes:new Set,edges:new Set})),o=_.useMemo(()=>{const a=new Set(e.map(p=>p.id)),c=t.filter(p=>a.has(p.source)&&a.has(p.target)).map(p=>({id:p.id,source:p.inverted?p.target:p.source,target:p.inverted?p.source:p.target})),u=new Set(c.map(p=>p.id)),l=new Set([...n.nodes].filter(p=>a.has(p))),d=new Set([...n.edges].filter(p=>u.has(p)));if(!r)return{nodes:a,edges:u,ready:u};for(const p of e)c.filter(m=>m.target===p.id&&m.source!==m.target).every(m=>d.has(m.id))&&l.add(p.id);let h=new Set(c.filter(p=>l.has(p.source)).map(p=>p.id));if(l.size<a.size&&!c.some(p=>h.has(p.id)&&!d.has(p.id))){const p=e.find(y=>!l.has(y.id));p&&l.add(p.id),h=new Set(c.filter(y=>l.has(y.source)).map(y=>y.id))}return{nodes:l,edges:d,ready:h}},[e,t,r,n]);_.useLayoutEffect(()=>{i(a=>{const c=r?o:{nodes:new Set,edges:new Set},u=(l,d)=>l.size===d.size&&[...l].every(h=>d.has(h));return u(a.nodes,c.nodes)&&u(a.edges,c.edges)?a:{nodes:c.nodes,edges:c.edges}})},[o,r]);const s=_.useCallback(a=>{i(c=>c.edges.has(a)?c:{...c,edges:new Set([...c.edges,a])})},[]);return{shown:o.nodes,ready:o.ready,complete:s}}class FS{constructor(t,r,n){$r(this,"_pan");$r(this,"_zoom");$r(this,"minZoom");$r(this,"maxZoom");$r(this,"size",{w:0,h:0});$r(this,"listeners",new Set);$r(this,"animationFrame");$r(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,i={pan:{...t.pan},zoom:this.clamp(t.zoom)},o=performance.now(),s=300/1.4,a=()=>{this.cancelAnimation(),this.set(i.pan,i.zoom)},c=u=>{const l=Math.min(1,(u-o)/s);if(l>=1){a();return}const d=l*l*(3-2*l);this.apply({x:n.pan.x+(i.pan.x-n.pan.x)*d,y:n.pan.y+(i.pan.y-n.pan.y)*d},n.zoom+(i.zoom-n.zoom)*d),this.animationFrame=requestAnimationFrame(c)};this.animationFrame=requestAnimationFrame(c),this.animationTimer=setTimeout(a,s+100)}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 i=this.clamp(r);i!==this._zoom&&(this._zoom=i,n=!0)}n&&this.emit()}zoomAt(t,r){const n=this.clamp(t),i=this._zoom;if(n===i)return;const o=n/i;this.set({x:r.x-(r.x-this._pan.x)*o,y:r.y-(r.y-this._pan.y)*o},n)}fit(t,r=0,n=!1,i=1){const o=t.x2-t.x1,s=t.y2-t.y1;if(!(o>0)||!(s>0)||!this.size.w||!this.size.h)return;const a=this.clamp(this.clamp(Math.min((this.size.w-2*r)/o,(this.size.h-2*r)/s))*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 BS={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},_n={w:60,h:60},Py=4,zS=30,Ay=300,DS=500,Ty=45,VS=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2;function Iy(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 WS(e){var kl;const{nodes:t,edges:r,direction:n,nodeAlignment:i="center",edgeMode:o="auto",compactPropertyLayout:s=!1,rankSep:a,edgeSep:c,spacingFactor:u=1.3,compactSpacingScale:l,minZoom:d,maxZoom:h,initialViewport:p,containerStyle:y,lineColor:m,drawMode:g,dragMode:b,multiSelect:w,isPerformanceMode:v}=e,[x,C]=_.useState(null),S=_.useMemo(()=>x?(x.mode==="connections"?td:Zl)(x.id,t,r):null,[x,t,r]),E=o==="auto"||o==="properties",I=_.useMemo(()=>r.filter(T=>Bu(T,o)&&(!S||S.has(T.source)&&S.has(T.target))),[r,o,S]),A=_.useMemo(()=>dw(t,r,o,s,S),[t,r,o,s,S]),M=_.useRef(A);M.current=A;const j=_.useRef(e);j.current=e;const R=_.useRef(null),P=_.useRef(null),k=_.useRef(null),q=_.useRef(null),O=_.useMemo(()=>new FS(p,d,h),[]);_.useEffect(()=>{O.minZoom=d,O.maxZoom=h},[O,d,h]);const z=_.useRef(new Map),U=_.useRef(new Map),se=_.useRef(new Map),Q=_.useRef(null),[Y,ge]=_.useState(new Map),ce=_.useCallback((T,L)=>{ge(D=>{if(JSON.stringify(D.get(T))===JSON.stringify(L))return D;const H=new Map(D);return L?H.set(T,L):H.delete(T),H})},[]),[$,V]=_.useState(new Map),W=_.useRef($),N=_.useCallback((T,L)=>{V(D=>{if(JSON.stringify(D.get(T)??[])===JSON.stringify(L))return D;const H=new Map(D);return L.length?H.set(T,L):H.delete(T),H})},[]),[ne,be]=_.useState(()=>new Map),fe=_.useRef(ne);fe.current=ne;const J=_.useRef(new Map),te=_.useRef(null),G=_.useRef(!1),[le,ue]=_.useState(0),Ce=_.useRef(),ye=_.useRef(),Me=_.useRef(null),ee=_.useRef(),he=_.useRef(!1),ve=_.useRef(null),je=_.useRef(null),qe=_.useRef(u),We=s,Ye=_.useRef(We),[tr,sr]=_.useState(!0),Ae=_.useRef(null);Ae.current=S;const me=_.useRef(1);me.current=(x==null?void 0:x.mode)==="connections"?1.25:1;const Oe=_.useRef(null),nr=_.useRef(t),cr=_.useRef([]),Xe=_.useRef(!1),we=()=>{Me.current!==null&&cancelAnimationFrame(Me.current),Me.current=null,clearTimeout(ee.current)},Qr=()=>{je.current=null,cr.current.length&&(Xe.current=!0),!G.current&&j.current.fitOnInit!==!1&&(he.current=!0),clearTimeout(ye.current),ye.current=setTimeout(()=>{G.current=fe.current.size>0,ue(T=>T+1)},DS)},zr=T=>{we();const L=new Map(fe.current),D=performance.now(),H=()=>{we(),be(T),Qr()},oe=_e=>{const Le=Math.min(1,(_e-D)/Ay);if(Le>=1)return H();const Be=VS(Le),X=new Map;T.forEach((ie,de)=>{const pe=L.get(de);X.set(de,pe?{x:pe.x+(ie.x-pe.x)*Be,y:pe.y+(ie.y-pe.y)*Be}:ie)}),be(X),Me.current=requestAnimationFrame(oe)};Me.current=requestAnimationFrame(oe),ee.current=setTimeout(H,Ay+100)},pt=()=>{var Be;const T=j.current,L=me.current,D=M.current,H=D.nodes.map(X=>{const ie=z.current.get(X.id)||_n;return{id:X.id,parent:X.parent,width:ie.w,height:ie.h}});let oe;try{const X=T.compactPropertyLayout,ie=T.edgeMode!=="nodes"&&T.edgeMode!=="workflow",de=D.edges.map(pe=>({...pe,connectorClearance:X?ie&&(pe.sourceProperty!==void 0||pe.targetProperty!==void 0)?lw:uw:0}));oe=MS(H,de,{edgeLabelFontSize:T.edgeMode==="nodes"||T.edgeMode==="workflow"?Ym:Tn,rankDir:T.direction,compact:X,nodeAlignment:T.nodeAlignment,rankSep:T.rankSep*L,edgeSep:T.edgeSep*L,nodeSep:5*L,spacingFactor:T.spacingFactor??1.3,compactSpacingScale:(T.compactSpacingScale??(T.spacingFactor??1.3)/1.3)*L})}catch(X){console.warn("[flow-sdk] layout failed",X);return}const _e=te.current;te.current=null;const Le=_e&&oe.get(_e.id);if(_e&&Le){const X={x:_e.position.x-Le.x,y:_e.position.y-Le.y};oe=new Map([...oe].map(([ie,de])=>[ie,{x:de.x+X.x,y:de.y+X.y}]))}for(const[X,ie]of J.current)oe.has(X)?oe.set(X,ie):T.nodes.some(de=>de.id===X)||J.current.delete(X);(Be=je.current)==null||Be.call(je,oe),G.current&&!T.isPerformanceMode?zr(oe):(we(),be(oe),Qr())},ae=_.useCallback(()=>{clearTimeout(ye.current),clearTimeout(Ce.current),Ce.current=setTimeout(pt,j.current.layoutDebounce)},[]);_.useLayoutEffect(()=>{const T=new Map(nr.current.map(L=>[L.id,L]));t.some(L=>{var D;return((D=T.get(L.id))==null?void 0:D.collapsed)===!0&&!L.collapsed})&&(cr.current=t.filter(L=>!T.has(L.id)).map(L=>L.id)),nr.current=t,qe.current!==u&&fe.current.size>0&&(G.current=!0,he.current=!1,clearTimeout(ye.current)),qe.current=u,Ye.current!==We&&(he.current=!ve.current),Ye.current=We,je.current&&!ve.current?(clearTimeout(Ce.current),pt()):ae()},[t,r,A.nodes,A.edges,We,n,i,a,c,ae,u,l]),_.useEffect(()=>()=>{clearTimeout(Ce.current),clearTimeout(ye.current),we()},[]);const Ve=_.useCallback((T,L)=>{var D,H;if(!Q.current&&typeof ResizeObserver<"u"&&(Q.current=new ResizeObserver(oe=>{var Le;let _e=!1;for(const Be of oe){const X=se.current.get(Be.target);if(!X)continue;const ie=Be.target,de=ie.offsetWidth,pe=ie.offsetHeight;if(!de&&!pe)continue;const Je=z.current.get(X);if(Je&&Je.w===de&&Je.h===pe)continue;const jr=fe.current.get(X);Je&&jr&&G.current&&!te.current&&(te.current={id:X,position:{...jr}}),z.current.set(X,{w:de,h:pe}),_e=!0}_e&&((Le=je.current)==null||Le.call(je),ae())})),L){U.current.set(T,L),se.current.set(L,T),(D=Q.current)==null||D.observe(L);const oe=L.offsetWidth,_e=L.offsetHeight;(oe||_e)&&z.current.set(T,{w:oe,h:_e})}else{const oe=U.current.get(T);oe&&((H=Q.current)==null||H.unobserve(oe),se.current.delete(oe)),U.current.delete(T),z.current.delete(T),W.current.has(T)&&N(T,[])}ae()},[ae,N]);_.useEffect(()=>()=>{var T;return(T=Q.current)==null?void 0:T.disconnect()},[]);const or=_.useMemo(()=>{const T=new Map;for(const L of t)L.label&&T.set(L.id,L.label);return T},[t]),Ge=_.useMemo(()=>Ry(A.nodes,ne,z.current,T=>y(T).padding,T=>{const L=or.get(T);if(!L)return;const D=y(T);return{w:un(L,`bold ${D.fontSize}px ${Lr}`)+2*Ty,h:0}}),[A.nodes,ne,y,or]),ir=_.useRef(Ge);ir.current=Ge;const er=_.useCallback(T=>{const L=ir.current.get(T);if(L)return J0(L);const D=fe.current.get(T);if(!D)return;const H=z.current.get(T)||_n;return{x:D.x,y:D.y,w:H.w,h:H.h}},[]),Z=_.useMemo(()=>{const T=new Map;for(const L of t){const D=er(L.id);D&&T.set(L.id,D)}return ow($,T,Y,r,n)},[$,t,ne,Ge,Y,r,n,er]);W.current=Z;const B=(T,L)=>{var oe;if(!E||L===void 0)return;const D=(oe=Z.get(T))==null?void 0:oe.find(_e=>_e.property===L),H=er(T);return D&&!D.anchor&&H?H.y-H.h/2+D.top+D.height/2:void 0},re=(T,L)=>{var oe,_e;if(L===void 0)return;const D=(_e=(oe=Z.get(T))==null?void 0:oe.find(Le=>Le.property===L))==null?void 0:_e.anchor,H=er(T);return D&&H?{x:H.x-H.w/2+D.x,y:H.y-H.h/2+D.y,side:D.side}:void 0},Ee=(T,L)=>{const D=er(T),H=Y.get(T);return D&&H&&!Ge.has(T)&&B(T,L)===void 0?en(D,H):D},Te=()=>{const T=[];fe.current.forEach((L,D)=>{if(ir.current.has(D))return;const H=z.current.get(D)||_n;T.push(bt({x:L.x,y:L.y,w:H.w,h:H.h}))}),ir.current.forEach(L=>T.push(L));try{for(const L of[P.current,k.current]){const D=L==null?void 0:L.getBBox();D&&D.width>0&&D.height>0&&T.push({x1:D.x,y1:D.y,x2:D.x+D.width,y2:D.y+D.height})}}catch{}return yo(T)},Pe=()=>{var D,H;const{pan:T,zoom:L}=O;q.current&&(q.current.style.transform=`translate3d(${T.x}px, ${T.y}px, 0) scale(${L})`),(D=P.current)==null||D.setAttribute("transform",`translate(${T.x} ${T.y}) scale(${L})`),(H=k.current)==null||H.setAttribute("transform",`translate(${T.x} ${T.y}) scale(${L})`)};_.useEffect(()=>{Pe();let T=null,L;const D=O.onChange(()=>{Pe();const H=R.current;H&&(H.classList.add("flow-sdk-busy"),clearTimeout(L),L=setTimeout(()=>H.classList.remove("flow-sdk-busy"),150)),T===null&&(T=requestAnimationFrame(()=>{var oe,_e;T=null,(_e=(oe=j.current).onViewportChange)==null||_e.call(oe,O.state)}))});return()=>{D(),clearTimeout(L),T!==null&&cancelAnimationFrame(T)}},[]),_.useLayoutEffect(()=>{const T=R.current;if(!T)return;const L=()=>{let H=T.clientWidth,oe=T.clientHeight;oe||(oe=Math.max(0,window.innerHeight-T.getBoundingClientRect().top-100),oe&&(T.style.height=`${oe}px`)),H||(H=window.innerWidth,H&&(T.style.width=`${H}px`)),O.size={w:H,h:oe},!G.current&&!fe.current.size&&j.current.fitOnInit!==!1&&(O.set({x:H/2,y:oe/2}),Pe())};if(L(),typeof ResizeObserver>"u")return;const D=new ResizeObserver(L);return D.observe(T),()=>D.disconnect()},[O]),_.useLayoutEffect(()=>{if(Xe.current){Xe.current=!1;const L=cr.current.flatMap(H=>{const oe=er(H);return oe?[bt(oe)]:[]});cr.current=[];const D=yo(L);if(D){he.current=!1,O.center(D,j.current.animateViewport);return}}if(!he.current)return;he.current=!1;const T=Te();T&&(O.fit(T,50,G.current&&j.current.animateViewport),G.current||Pe())},[ne]);const Ue=_.useMemo(()=>{const T=X=>Zl(X,j.current.nodes,j.current.edges),L=(X,ie=50,de=j.current.animateViewport,pe=1,Je=!1)=>{let jr=null;const rt=gt=>{const Rl=M.current,mv=new Set(Rl.nodes.map(yr=>yr.parent).filter(Boolean));if(!gt&&[...X].some(yr=>mv.has(yr)))return;const fo=gt&&Ry(Rl.nodes,gt,z.current,yr=>j.current.containerStyle(yr).padding,yr=>{var vn;const Nt=(vn=j.current.nodes.find(xn=>xn.id===yr))==null?void 0:vn.label;if(!Nt)return;const bn=j.current.containerStyle(yr);return{w:un(Nt,`bold ${bn.fontSize}px ${Lr}`)+2*Ty,h:0}}),mn=yo([...X].flatMap(yr=>{const Nt=fo==null?void 0:fo.get(yr);if(Nt)return[Nt];const bn=gt==null?void 0:gt.get(yr),vn=z.current.get(yr)||_n,xn=bn?{...bn,...vn}:er(yr);return xn?[bt(xn)]:[]}));!mn||JSON.stringify(mn)===JSON.stringify(jr)||(jr=mn,he.current=!1,cr.current=[],Xe.current=!1,O.fit(mn,Number.isFinite(ie)?Math.max(0,ie):50,de,pe))};je.current=Je?rt:null,Je||rt(fe.current)},D=(X,ie,de,pe)=>{var jr;if(!er(X))return;const Je=ie==="connections"?oe(X):T(X);if(ie==="connections"&&me.current===1.25&&((jr=Ae.current)==null?void 0:jr.size)===Je.size&&[...Je].every(rt=>Ae.current.has(rt))){C({id:X,mode:ie});return}Oe.current||(Oe.current={pan:{...O.pan},zoom:O.zoom}),Ae.current=Je,j.current.compactPropertyLayout&&(he.current=!1,ve.current=()=>L(Ae.current??Je,de,pe)),C({id:X,mode:ie}),j.current.compactPropertyLayout||L(Je,de,pe)},H=X=>{ve.current?ve.current=X:X()},oe=X=>td(X,j.current.nodes,j.current.edges),_e=(X=>{if(X===void 0)return O.zoom;je.current=null,O.set(void 0,X)}),Le=(X=>{if(X===void 0)return O.pan;je.current=null,O.set(X)}),Be=(X,ie)=>{var pe;const de=(pe=R.current)==null?void 0:pe.getBoundingClientRect();return{x:X-((de==null?void 0:de.left)??0),y:ie-((de==null?void 0:de.top)??0)}};return{zoom:_e,pan:Le,setEdgesVisible:sr,focusNode:(X,ie,de,pe)=>H(()=>L(new Set([X]),ie,de,.6,pe)),focusBranch:(X,ie,de)=>H(()=>L(T(X),ie,de)),focusConnections:(X,ie,de,pe)=>H(()=>L(oe(X),ie,de,1,pe)),isolateConnections:(X,ie,de)=>D(X,"connections",ie,de),isolateBranch:(X,ie,de)=>D(X,"branch",ie,de),restoreView:(X=j.current.animateViewport,ie)=>{je.current=null;const de=j.current.compactPropertyLayout&&!!Ae.current;Ae.current=null,C(null);const pe=ie??Oe.current;Oe.current=null,de?ve.current=()=>{pe&&O.transition(pe,X)}:pe&&H(()=>O.transition(pe,X))},zoomAt:(X,ie)=>{je.current=null,O.zoomAt(X,ie)},fit:(X=0,ie=j.current.animateViewport)=>{je.current=null,H(()=>{const de=Te();de&&O.fit(de,X,ie)})},centerAndFit:(X=0,ie=j.current.animateViewport)=>{je.current=null,H(()=>{const de=Te();de&&O.fit(de,X,ie)})},center:(X=j.current.animateViewport)=>{je.current=null;const ie=Te();ie&&O.center(ie,X)},clientToModel:(X,ie)=>O.renderedToModel(Be(X,ie)),modelToClient:X=>{var pe;const ie=(pe=R.current)==null?void 0:pe.getBoundingClientRect(),de=O.modelToRendered(X);return{x:de.x+((ie==null?void 0:ie.left)??0),y:de.y+((ie==null?void 0:ie.top)??0)}},getNodeBox:X=>er(X),setNodePosition:(X,ie,de)=>{if(!fe.current.has(X)||ie&&(!Number.isFinite(ie.x)||!Number.isFinite(ie.y)))return!1;if(we(),!ie)return J.current.delete(X),ae(),!0;const pe=new Map(fe.current);return pe.set(X,{...ie}),(de==null?void 0:de.persist)===!1?J.current.delete(X):J.current.set(X,{...ie}),fe.current=pe,be(pe),(de==null?void 0:de.persist)===!1&&ae(),!0},onViewportChange:X=>O.onChange(X)}},[]);_.useEffect(()=>{var T,L;return(L=(T=j.current).onInit)==null||L.call(T,Ue),()=>O.cancelAnimation()},[Ue]),_.useEffect(()=>{var T,L;if(le>0){const D=ve.current;ve.current=null,D==null||D(),(L=(T=j.current).onLayoutComplete)==null||L.call(T,Ue)}},[Ue,le]);const ke=_.useRef(null),ze=_.useRef(new Map),He=_.useRef(!1),[dr,fr]=_.useState(null),[$e,Tr]=_.useState(null),qr=T=>{const L=R.current.getBoundingClientRect();return{x:T.clientX-L.left,y:T.clientY-L.top}},Dr=(T,L)=>{const D=j.current.nodes;for(let H=D.length-1;H>=0;H--){const oe=D[H].id;if(!vt(oe,j.current.edges,j.current.edgeMode)||Ae.current&&!Ae.current.has(oe)||oe===L||ir.current.has(oe))continue;const _e=er(oe);if(_e&&Yl(T,bt(_e)))return oe}for(const[H,oe]of ir.current)if(vt(H,j.current.edges,j.current.edgeMode)&&!(Ae.current&&!Ae.current.has(H))&&H!==L&&Yl(T,oe))return H;return null},ao=(T,L)=>{if(j.current.edgeMode==="nodes"||j.current.edgeMode==="workflow")return null;const D=j.current.direction==="RL",H=Math.max(16,6/O.zoom);let oe=null;for(const _e of[...j.current.nodes].reverse()){if(!vt(_e.id,j.current.edges,j.current.edgeMode)||Ae.current&&!Ae.current.has(_e.id))continue;const Le=er(_e.id),Be=W.current.get(_e.id);if(!Le||!Be||ir.current.has(_e.id))continue;const X=Le.x+(L==="source"!==D?1:-1)*Le.w/2;for(const ie of Be){if(ie.role&&ie.role!==L)continue;const de=Le.y-Le.h/2+ie.top,pe=Math.hypot(T.x-(ie.anchor?Le.x-Le.w/2+ie.anchor.x:X),T.y-de-ie.height/2);if(!ie.anchor&&T.x>=Le.x-Le.w/2&&T.x<=Le.x+Le.w/2&&T.y>=de&&T.y<=de+ie.height)return{nodeId:_e.id,property:ie.property};pe<=H&&(!oe||pe<oe.distance)&&(oe={nodeId:_e.id,property:ie.property,distance:pe})}}return oe},lv=T=>{var Le;if(!T.currentTarget.contains(T.target)||T.button!==0||j.current.readOnly)return;ke.current||(He.current=!1);const L=T.target;if(L.closest('input, textarea, select, [contenteditable="true"], [data-flow-content-toggle]'))return;const D=j.current,H=qr(T);if(T.pointerType==="touch"){ze.current.set(T.pointerId,H);const Be=Iy(ze.current);if(Be){ke.current={kind:"pinch",distance:Be.distance,zoom:O.zoom,anchor:O.renderedToModel(Be.center)},Tr(null),fr(null),He.current=!0;for(const X of ze.current.keys())T.currentTarget.setPointerCapture(X);return}}if(ke.current)return;const oe=D.drawHandles&&L.closest(".flow-sdk-handle"),_e=D.drawHandles&&L.closest(".flow-sdk-property-port");if(D.drawMode||oe||_e){const Be=O.renderedToModel(H),X=D.drawMode?ao(Be,"source"):null,ie=_e||oe,de=ie?(Le=ie.closest("[data-node-id]"))==null?void 0:Le.dataset.nodeId:(X==null?void 0:X.nodeId)??Dr(Be),pe=_e?_e.dataset.property:X==null?void 0:X.property;if(de){ke.current={kind:"draw",pointerId:T.pointerId,source:de,sourceProperty:pe,reverse:(_e==null?void 0:_e.dataset.portRole)==="target",startClient:{x:T.clientX,y:T.clientY}},He.current=!0,Tr({source:de,sourceProperty:pe,point:Be,target:null}),T.currentTarget.setPointerCapture(T.pointerId);return}}L.closest(".flow-sdk-node, .flow-sdk-container, .flow-sdk-edge, .flow-sdk-edge-label, .flow-sdk-container-label")||(je.current=null,D.multiSelect?ke.current={kind:"box",pointerId:T.pointerId,start:H,current:H}:D.dragMode?ke.current={kind:"pan",pointerId:T.pointerId,start:H,pan0:O.pan,moved:!1}:ke.current={kind:"tap",pointerId:T.pointerId,start:H,moved:!1},T.currentTarget.setPointerCapture(T.pointerId))},dv=T=>{const L=ke.current;if(!L||j.current.readOnly)return;const D=qr(T);if(ze.current.has(T.pointerId)&&ze.current.set(T.pointerId,D),L.kind==="pinch"){const H=Iy(ze.current);if(!H)return;const oe=Math.max(O.minZoom,Math.min(O.maxZoom,L.zoom*H.distance/L.distance));O.set({x:H.center.x-L.anchor.x*oe,y:H.center.y-L.anchor.y*oe},oe);return}if(L.pointerId===T.pointerId)switch(L.kind){case"pan":{const H=D.x-L.start.x,oe=D.y-L.start.y;if(!L.moved&&Math.hypot(H,oe)<=Py)return;L.moved=!0,He.current=!0,O.set({x:L.pan0.x+H,y:L.pan0.y+oe});break}case"tap":{Math.hypot(D.x-L.start.x,D.y-L.start.y)>Py&&(L.moved=!0);break}case"box":{He.current=!0,L.current=D,fr({x1:Math.min(L.start.x,D.x),y1:Math.min(L.start.y,D.y),x2:Math.max(L.start.x,D.x),y2:Math.max(L.start.y,D.y)});break}case"draw":{const H=O.renderedToModel(D),oe=ao(H,L.reverse?"source":"target");Tr(L.reverse&&oe?{source:oe.nodeId,sourceProperty:oe.property,point:H,target:L.source,targetProperty:L.sourceProperty}:{source:L.source,sourceProperty:L.sourceProperty,point:H,target:(oe==null?void 0:oe.nodeId)??Dr(H,L.source),targetProperty:oe==null?void 0:oe.property});break}}},_l=(T,L)=>{var oe,_e,Le,Be,X;ze.current.delete(T.pointerId);const D=ke.current;if(!D)return;if(D.kind==="pinch"){const ie=[...ze.current][0];ke.current=ie&&j.current.dragMode&&!L?{kind:"pan",pointerId:ie[0],start:ie[1],pan0:O.pan,moved:!0}:null;return}if(D.pointerId!==T.pointerId)return;ke.current=null;try{T.currentTarget.releasePointerCapture(T.pointerId)}catch{}const H=j.current;switch(L=L||!!H.readOnly,D.kind){case"pan":case"tap":!L&&!D.moved&&((oe=H.onBackgroundTap)==null||oe.call(H));break;case"box":{if(fr(null),L)break;const ie=O.renderedToModel(D.start),de=O.renderedToModel(D.current),pe={x1:Math.min(ie.x,de.x),y1:Math.min(ie.y,de.y),x2:Math.max(ie.x,de.x),y2:Math.max(ie.y,de.y)};if(pe.x2-pe.x1<1&&pe.y2-pe.y1<1){(_e=H.onBackgroundTap)==null||_e.call(H);break}const Je=[];for(const jr of H.nodes){const rt=er(jr.id);rt&&Z0(bt(rt),pe)&&Je.push(jr.id)}Je.length&&((Le=H.onBoxSelect)==null||Le.call(H,Je));break}case"draw":{if(Tr(null),L)break;const ie=qr(T),de=O.renderedToModel(ie),pe=ao(de,D.reverse?"source":"target"),Je=(pe==null?void 0:pe.nodeId)??Dr(de);if(Je===D.source&&(D.sourceProperty===void 0||(pe==null?void 0:pe.property)===void 0||pe.property===D.sourceProperty))break;Je?(Be=H.onEdgeDraw)==null||Be.call(H,D.reverse?Je:D.source,D.reverse?D.source:Je,D.sourceProperty!==void 0||(pe==null?void 0:pe.property)!==void 0?{sourceProperty:D.reverse?pe==null?void 0:pe.property:D.sourceProperty,targetProperty:D.reverse?D.sourceProperty:pe==null?void 0:pe.property}:void 0):Math.max(Math.abs(T.clientX-D.startClient.x),Math.abs(T.clientY-D.startClient.y))>zS&&((X=H.onDrawIntoSpace)==null||X.call(H,D.source,de,D.sourceProperty,D.reverse));break}}},et=_.useCallback(()=>{var D;const T=ke.current,L=[...ze.current.keys()];T&&T.kind!=="pinch"&&L.push(T.pointerId),ke.current=null,ze.current.clear(),Tr(null),fr(null);for(const H of L)(D=R.current)!=null&&D.hasPointerCapture(H)&&R.current.releasePointerCapture(H)},[]);_.useEffect(()=>{const T=L=>{L.key==="Escape"&&et()};return window.addEventListener("keydown",T),window.addEventListener("blur",et),()=>{window.removeEventListener("keydown",T),window.removeEventListener("blur",et),ke.current=null,ze.current.clear()}},[et]),_.useEffect(()=>{et()},[g,b,w,o,n,e.drawHandles,e.readOnly,et]);const fv=_.useMemo(()=>{const T=new Map,L=new Map;for(const D of I){if(D.source!==D.target)continue;const H=T.get(D.source)??0;T.set(D.source,H+1),L.set(D.id,H)}return L},[I]),so=BS[n],[co,hv]=_.useState(null),uo=LS(t,I,!!((kl=e.edgeReveal)!=null&&kl.revealNodes));_.useLayoutEffect(()=>{R.current&&co&&yw(R.current)});const lo=K0(I,Ee,so),pv=e.onEdgeSelect,gv=e.onContainerSelect,El=$e?$e.target&&Ee($e.target,$e.targetProperty)||{x:$e.point.x,y:$e.point.y,w:1,h:1}:null,jl=$e?Ee($e.source,$e.sourceProperty):null,yv=["flow-sdk-canvas",g?"flow-sdk-draw":"",v?"flow-sdk-perf":""].filter(Boolean).join(" ");return f.jsxs("div",{ref:R,className:yv,"data-edge-mode":o,onPointerDownCapture:lv,onPointerMove:dv,onPointerUp:T=>_l(T,!1),onPointerCancel:T=>_l(T,!0),onLostPointerCapture:T=>{const L=ke.current;L&&(L.kind==="pinch"||L.pointerId===T.pointerId)&&et()},onClickCapture:T=>{if(!T.currentTarget.contains(T.target))return;const L=T.target instanceof Element&&T.target.closest("button[data-flow-fullscreen]");(He.current||e.readOnly&&!L)&&(T.preventDefault(),T.stopPropagation())},children:[f.jsx("svg",{className:"flow-sdk-svg",children:f.jsxs("g",{ref:P,children:[f.jsx("g",{className:"flow-sdk-containers",children:[...Ge].filter(([T])=>vt(T,r,o)).filter(([T])=>!S||S.has(T)).map(([T,L])=>{var D,H;return f.jsx(sw,{id:T,rect:L,label:or.get(T),labelLayer:co,labelContent:(D=t.find(oe=>oe.id===T&&oe.label!==void 0))==null?void 0:D.element,style:y(T),onSelect:gv,onCollapse:e.readOnly?void 0:e.onContainerCollapse,selected:(H=e.selectedNodeIds)==null?void 0:H.includes(T)},T)})}),f.jsx("g",{className:"flow-sdk-edges",children:tr&&I.map(T=>{var H,oe,_e;if(!uo.ready.has(T.id)||S&&(!S.has(T.source)||!S.has(T.target)))return null;const L=Ee(T.source,T.sourceProperty),D=Ee(T.target,T.targetProperty);return!L||!D?null:f.jsx(od,{id:T.id,edgeData:T.data,validationIssue:T.validationIssue,edgeType:T.type,edgeRadius:e.edgeRadius,propertyMode:E,customEdgeTypes:e.customEdgeTypes,reveal:e.edgeReveal,onRevealComplete:uo.complete,source:L,target:D,sourceProperty:T.sourceProperty,targetProperty:T.targetProperty,sourceY:B(T.source,T.sourceProperty),targetY:B(T.target,T.targetProperty),sourcePort:re(T.source,T.sourceProperty),targetPort:re(T.target,T.targetProperty),dir:so,turn:((H=lo.get(T.id))==null?void 0:H.turn)??T.turn,labelAtTarget:(oe=lo.get(T.id))==null?void 0:oe.labelAtTarget,labelFraction:(_e=lo.get(T.id))==null?void 0:_e.labelFraction,color:T.color,connectorColor:T.connectorColor,labelBg:T.labelBg,label:T.label,labelLayer:co,dashed:T.dashed,animated:T.animated&&!v,inverted:T.inverted,loopIndex:fv.get(T.id)??0,onSelect:pv},T.id)})}),tr&&$e&&Bu($e,o)&&jl&&El&&f.jsx("g",{className:"flow-sdk-ghost",pointerEvents:"none",children:f.jsx(od,{id:"__flow-sdk-ghost",edgeData:{id:"__flow-sdk-ghost",source:$e.source,target:$e.target??"",sourceProperty:$e.sourceProperty,targetProperty:$e.targetProperty},edgeType:e.edgeType,edgeRadius:e.edgeRadius,propertyMode:E,customEdgeTypes:e.customEdgeTypes,source:jl,target:El,sourceProperty:$e.sourceProperty,targetProperty:$e.targetProperty,sourceY:B($e.source,$e.sourceProperty),sourcePort:re($e.source,$e.sourceProperty),targetPort:$e.target?re($e.target,$e.targetProperty):void 0,targetY:$e.target?B($e.target,$e.targetProperty):void 0,dir:so,turn:.5,color:m,labelBg:m})})]})}),f.jsx("div",{ref:q,className:"flow-sdk-nodes",children:t.map(T=>{var _e,Le;const L=ne.get(T.id),D=Ge.get(T.id);if(D&&T.label!==void 0)return null;const H=(L==null?void 0:L.x)??(D?(D.x1+D.x2)/2:0),oe=(L==null?void 0:L.y)??(D?(D.y1+D.y2)/2:0);return f.jsx(NS,{id:T.id,x:H,y:oe,placed:!!L||!!D,hidden:!uo.shown.has(T.id)||!vt(T.id,r,o)||!!S&&!S.has(T.id),onMount:Ve,drawHandles:e.drawHandles&&!e.readOnly,drawMode:g,connectedPorts:new Set(I.flatMap(Be=>[...Be.source===T.id&&Be.sourceProperty!==void 0?[`source:${Be.sourceProperty}`]:[],...Be.target===T.id&&Be.targetProperty!==void 0?[`target:${Be.targetProperty}`]:[]])),hasCollapseControl:T.hasCollapseControl,handleColor:m,animated:T.animated&&!D&&!v,animationColor:T.animationColor,animationWidth:T.animationWidth,animationVariant:T.animationVariant,width:(_e=z.current.get(T.id))==null?void 0:_e.w,height:(Le=z.current.get(T.id))==null?void 0:Le.h,propertyMode:E,resolvedRows:Z.get(T.id),reversePorts:n==="RL",direction:n,onPropertyRows:N,onSurface:ce,children:T.element},T.id)})}),dr&&f.jsx("div",{className:"flow-sdk-box",style:{left:dr.x1,top:dr.y1,width:dr.x2-dr.x1,height:dr.y2-dr.y1}}),f.jsx("svg",{className:"flow-sdk-svg flow-sdk-label-overlay",style:{zIndex:11,pointerEvents:"none"},children:f.jsx("g",{ref:k,transform:`translate(${O.pan.x} ${O.pan.y}) scale(${O.zoom})`,children:f.jsx("g",{ref:hv,className:"flow-sdk-labels",style:{pointerEvents:g?"none":"visiblePainted",outline:"none"}})})})]})}const GS=_.memo(WS);function Cl(e=!0){const t=_.useRef(null);return _.useEffect(()=>{if(!e||!t.current)return;const r=o=>{o.stopPropagation()},n=t.current,i=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return i.forEach(o=>n.addEventListener(o,r)),()=>{i.forEach(o=>n.removeEventListener(o,r))}},[e]),t}const Rt=({nodeId:e,label:t,color:r,fontWeight:n="bold",fontSize:i="5xl",wrap:o=!1,isEditing:s,onEditStart:a,onEditEnd:c})=>{const{callbacks:u,config:l,readOnly:d}=Ne(),h=l.editable&&!d,[p,y]=_.useState(t),[m,g]=_.useState(),b=_.useRef(null),w=_.useRef(!1),v=Cl(s);_.useEffect(()=>{if(s&&(w.current=!1,b.current)){b.current.focus();const C=b.current.value.length;b.current.setSelectionRange(C,C)}},[s]);const x=()=>{var S;if(w.current)return;w.current=!0;const C=p.trim();C&&C!==t&&((S=u.onNodeLabelChange)==null||S.call(u,e,C)),c()};return!h||!s?f.jsx(F.Text,{color:r,fontWeight:n,fontSize:i,minW:0,maxW:"100%",whiteSpace:o?"normal":"nowrap",overflowWrap:o?"anywhere":void 0,overflow:"hidden",textOverflow:"ellipsis",title:t,onDoubleClick:h?C=>{C.stopPropagation(),g({width:C.currentTarget.offsetWidth,height:C.currentTarget.offsetHeight}),y(t),a()}:void 0,cursor:h?"text":void 0,children:t}):f.jsxs("div",{ref:v,style:{position:"relative",width:"max-content",minWidth:m==null?void 0:m.width,maxWidth:900,height:m==null?void 0:m.height},children:[f.jsx(F.Text,{as:"span","aria-hidden":"true",display:"block",visibility:"hidden",fontWeight:n,fontSize:i,lineHeight:"normal",whiteSpace:"pre",overflow:"hidden",children:p||" "}),f.jsx(F.Input,{ref:b,value:p,onChange:C=>y(C.target.value),onBlur:x,onKeyDown:C=>{C.key==="Enter"&&x(),C.key==="Escape"&&(w.current=!0,c())},color:r,fontWeight:n,fontSize:i,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"})]})};function rv({id:e,label:t,role:r,side:n,position:i=.5,placement:o,children:s,style:a}){return f.jsx("div",{"data-flow-property":e,"data-flow-port-role":r,"data-flow-port-side":n,"data-flow-port-position":n?i:void 0,"data-flow-port-placement":o,style:{minHeight:32,display:"flex",alignItems:"center",justifyContent:r==="source"?"flex-end":"flex-start",...a,...n?{display:"none"}:{}},children:s??t??e})}const US=On.default.dialog`
|
|
210
|
-
${e=>
|
|
209
|
+
`;function Jl({request:e,property:t,config:r,value:n,disabled:i}){var le,ue,we,ge,qe;const{callbacks:o,structured:s,references:a}=_.useContext(Sr),{themeColor:c}=Le(),{background:u}=Ze(),l=_.useId(),d=t.type.kind==="object"||t.type.kind==="array"||t.type.kind==="json",h=n===void 0?"":d?JSON.stringify(n,null,2):String(n),[p,y]=_.useState(h),[m,g]=_.useState(""),[b,w]=_.useState(0),v=_.useRef(null),x=_.useRef(),[C,S]=_.useState(!1),[k,I]=_.useState(!1),[R,M]=_.useState(),E=((le=r.$options)==null?void 0:le.$source)==="callback",P=o.resolveFormOptions,{data:A,address:j,nodeAddress:q,nodeId:O}=e;_.useEffect(()=>(S(!1),I(!1),()=>{var ee;(ee=x.current)==null||ee.abort(),x.current=void 0}),[j,q,O,i,h,r.$control,(ue=r.$upload)==null?void 0:ue.accept,(we=r.$upload)==null?void 0:we.maxSizeBytes]);const z=_.useRef(A);z.current=A;const U=JSON.stringify([j,O,(ge=r.$options)!=null&&ge.$dependsOn?r.$options.$dependsOn.map(ee=>ke(A,ee)):ke(A,q)]);_.useEffect(()=>{y(h),g("")},[h,j,O]),_.useEffect(()=>{if(!E)return;const ee=new AbortController;return Promise.resolve().then(()=>{if(!P)throw new Error("No options resolver configured");return P({address:j,nodeAddress:q,nodeId:O,data:jt(z.current),signal:ee.signal})}).then(he=>{if(!Array.isArray(he)||he.some(be=>!be||typeof be.label!="string"||!["string","number","boolean"].includes(typeof be.value)&&be.value!==null))throw new Error("Invalid options response");ee.signal.aborted||M({key:U,options:he})}).catch(he=>{ee.signal.aborted||M({key:U,options:[],error:he instanceof Error?he.message:"Options unavailable"})}),()=>ee.abort()},[E,P,U,j,q,O,b]);const ae=E&&(R==null?void 0:R.key)!==U,Q=E?(R==null?void 0:R.key)===U?R.options:[]:t.type.kind==="null"?[{label:"Null",value:null}]:t.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:Xt(t.type),Y=t.type.kind==="array",pe=(r.$control==="upload"?"upload":s&&d||r.$control==="checkbox"?"pills":r.$control)??(Q?Y||t.type.kind==="boolean"?"pills":"select":t.type.kind==="boolean"?"checkbox":d?"textarea":"input"),se=!t.optional||!!r.$requiredWhen&&Fn(r.$requiredWhen,A),$=se?"Required":"Optional",V=pe!=="upload"&&!!(a!=null&&a.length)&&typeof n=="string"&&n.includes("{{"),W=m||E&&(R==null?void 0:R.key)===U&&R.error||!V&&Rr(t.type,n,se),N=Cr(r.$label??j.split(".").pop()),ne=ee=>{var he;if(!(i||Object.is(ee,n)))try{(he=o.onFormChange)==null||he.call(o,{...e,previousValue:n,value:ee}),g("")}catch(be){g(be instanceof Error?be.message:"Unable to update field")}},me=_.useRef(ne);_.useLayoutEffect(()=>{me.current=ne});const fe=()=>{if(d){try{const Ee=p===""&&t.optional?void 0:JSON.parse(p),$e=Rr(t.type,Ee,se);if($e){g($e);return}ne(Ee)}catch{g("Enter valid JSON")}return}const ee=t.type.kind==="number"||t.type.kind==="integer",he=p===""&&t.optional?void 0:ee&&p!==""?Number(p):p,be=Rr(t.type,he,se);if(ee&&be&&p!==""){g(be);return}ne(he)},J=async ee=>{var be,Ee,$e;if(i||x.current||!ee.length)return;const he=new AbortController;x.current=he,g(""),S(!0);try{if(t.type.kind!=="string"&&!(t.type.kind==="array"&&t.type.items.kind==="string"))throw new Error("Uploads require a string or string-array field.");if(!Y&&ee.length!==1)throw new Error("Choose one file for this field.");if(!o.uploadFormFile)throw new Error("No file upload handler configured.");const Ge=(Ee=(be=r.$upload)==null?void 0:be.accept)==null?void 0:Ee.split(",").map(Pe=>Pe.trim().toLowerCase()).filter(Boolean);for(const Pe of ee){if((($e=r.$upload)==null?void 0:$e.maxSizeBytes)!==void 0&&Pe.size>r.$upload.maxSizeBytes)throw new Error(`${Pe.name} exceeds the file size limit.`);if(Ge!=null&&Ge.length&&!Ge.some(ye=>ye.startsWith(".")?Pe.name.toLowerCase().endsWith(ye):ye.endsWith("/*")?Pe.type.toLowerCase().startsWith(ye.slice(0,-1)):Pe.type.toLowerCase()===ye))throw new Error(`${Pe.name} is not an accepted file type.`)}const Ye=await Promise.all(ee.map(async Pe=>{const ye=await o.uploadFormFile({...e,data:jt(A),file:Pe,signal:he.signal});if(typeof ye!="string")throw new Error("Upload handler must return an HTTP or HTTPS URL.");let Me;try{Me=new URL(ye)}catch{throw new Error("Upload handler must return an HTTP or HTTPS URL.")}if(!["http:","https:"].includes(Me.protocol)||Me.username||Me.password)throw new Error("Upload handler must return an HTTP or HTTPS URL.");return ye}));if(he.signal.aborted||x.current!==he)return;const tr=Y?[...Array.isArray(n)?n:[],...Ye]:Ye[0],sr=Rr(t.type,tr,se);if(sr)throw new Error(sr);me.current(tr)}catch(Ge){he.signal.aborted||g(Ge instanceof Error?Ge.message:"Unable to upload file."),he.abort()}finally{x.current===he&&(x.current=void 0,S(!1))}},te={id:l,disabled:i,"aria-label":N,"aria-required":se,"aria-invalid":!!W,"aria-describedby":W?`${l}-error`:void 0},G=ve(c);return f.jsxs("div",{"data-form-field":j,"data-flow-property":j.slice(q.length+1),children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[f.jsxs("label",{htmlFor:l,children:[N,se?" *":""]}),t.optional&&n!==void 0&&f.jsx("button",{type:"button","aria-label":`Reset ${N}`,title:`Reset ${N}`,disabled:i||C,style:{width:24,height:24,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:0,background:"transparent",color:"inherit"},onClick:()=>ne(void 0),children:f.jsx(K.PiArrowCounterClockwise,{size:14})})]}),!!(a!=null&&a.length)&&!d&&pe!=="upload"&&f.jsx(q0,{label:N,value:n,references:a,disabled:i,onChange:ne}),pe==="upload"?f.jsxs("div",{"data-form-upload":Y?"multiple":"single","aria-busy":C,style:{"--flow-upload-surface":ve(u),outline:k?"2px dashed var(--flow-form-input-background)":void 0,borderRadius:"var(--flow-form-input-radius)"},onDragOver:ee=>{ee.preventDefault(),ee.stopPropagation(),!i&&!C&&(ee.dataTransfer.dropEffect="copy",I(!0))},onDragLeave:ee=>{ee.currentTarget.contains(ee.relatedTarget)||I(!1)},onDrop:ee=>{ee.preventDefault(),ee.stopPropagation(),I(!1),J(Array.from(ee.dataTransfer.files))},children:[f.jsx("input",{ref:v,type:"file",hidden:!0,"aria-label":`Upload ${N}`,accept:(qe=r.$upload)==null?void 0:qe.accept,multiple:Y,disabled:i||C,onChange:ee=>{const he=Array.from(ee.target.files??[]);ee.target.value="",J(he)}}),f.jsxs("div",{"data-upload-items":"",children:[(Y?Array.isArray(n)?n:[]:n?[n]:[]).map((ee,he)=>f.jsxs("div",{"data-upload-preview":"",children:[typeof ee=="string"&&Wr(ee)&&f.jsxs("a",{href:ee,target:"_blank",rel:"noopener noreferrer","aria-label":`${N} file ${he+1}`,children:[f.jsx(K.PiFile,{size:32,"aria-hidden":"true"}),f.jsx(Or,{name:ee,size:120,onError:be=>{be.currentTarget.style.visibility="hidden"}})]}),f.jsxs("div",{"data-upload-actions":"",children:[!Y&&f.jsx(Ce,{"aria-label":`Replace ${N}`,title:`Replace ${N}`,icon:f.jsx(K.PiUploadSimple,{}),size:"xs",variant:"ghost",disabled:i||C,onClick:()=>{var be;return(be=v.current)==null?void 0:be.click()}}),f.jsx(Ce,{"aria-label":`Remove ${N} file ${he+1}`,title:"Remove file",icon:f.jsx(K.PiTrash,{}),size:"xs",variant:"ghost",disabled:i||C,onClick:()=>ne(Y&&Array.isArray(n)?n.filter((be,Ee)=>Ee!==he):"")})]})]},`${he}:${ee}`)),(Y||!n)&&f.jsx("button",{...te,type:"button","data-upload-drop":"",title:`Upload ${N}`,disabled:i||C,onClick:()=>{var ee;return(ee=v.current)==null?void 0:ee.click()},children:f.jsx(K.PiPlus,{size:28,"aria-hidden":"true"})})]}),C&&f.jsx("span",{role:"status",children:"Uploading..."})]}):V?null:pe==="select"?f.jsx("div",{"data-form-select":"",children:f.jsxs(br,{...te,disabled:i||ae||!!(R!=null&&R.error),labelCase:"preserve",value:String((Q==null?void 0:Q.findIndex(ee=>Object.is(ee.value,n)))??-1),onValueChange:ee=>{const he=Q==null?void 0:Q[Number(ee)];he&&ne(he.value)},children:[f.jsx("option",{value:-1,disabled:!0,children:n!==void 0&&n!==""?String(n):$}),Q==null?void 0:Q.map((ee,he)=>f.jsx("option",{value:he,children:Cr(ee.label)||ee.label},he))]})}):pe==="pills"?f.jsxs("div",{id:l,role:"group","aria-label":N,"aria-describedby":te["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[Q==null?void 0:Q.map((ee,he)=>{const be=Y?Array.isArray(n)&&n.includes(ee.value):Object.is(n,ee.value);return f.jsx("button",{type:"button",disabled:i||ae,"aria-pressed":be,style:{padding:"8px 16px",borderRadius:24,border:0,color:be?G:"inherit",background:be?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>ne(Y?be?n.filter(Ee=>Ee!==ee.value):[...Array.isArray(n)?n:[],ee.value]:ee.value),children:Cr(ee.label)||ee.label},he)}),ae&&f.jsx("span",{role:"status",children:"Loading..."})]}):pe==="textarea"?f.jsx("textarea",{...te,placeholder:$,value:p,onChange:ee=>y(ee.target.value),onBlur:fe}):f.jsx("input",{...te,placeholder:$,type:t.type.kind==="number"||t.type.kind==="integer"?"number":"text",step:t.type.kind==="integer"?1:"any",value:p,onChange:ee=>y(ee.target.value),onBlur:fe,onKeyDown:ee=>{ee.key==="Enter"&&fe(),ee.key==="Escape"&&y(n===void 0?"":String(n))}}),W&&f.jsx("div",{role:"alert",id:`${l}-error`,children:W}),E&&(R==null?void 0:R.error)&&f.jsx("button",{type:"button",disabled:i,onClick:()=>{M(void 0),w(b+1)},children:"Retry"})]})}function Pm({nodeAddress:e,structured:t=!1}){return t?f.jsx(N0,{nodeAddress:e},e):f.jsx(Fu,{nodeAddress:e})}function N0({nodeAddress:e}){var d,h,p;const t=_.useContext(Sr),[r,n]=_.useState([]),i=((d=t.structured)==null?void 0:d.sourceSchema)??t.schema,o=((h=t.structured)==null?void 0:h.sourceBindings)??t.bindings,s=_.useMemo(()=>{if(!(!t.data||!i||!o))return km(t.data,o,i,[{data:{id:e,type:"objectView"}}])},[t.data,o,i,e]);if(!s)return f.jsx(Fu,{nodeAddress:e});const a=r.findIndex(y=>!s.containers.has(y)),c=a<0?r:r.slice(0,a),u=c.at(-1)??e,l=(p=[...s.slots.values()].find(y=>y.nodeId===u))==null?void 0:p.label;return f.jsxs(Sr.Provider,{value:{...t,structured:s,schema:s.schema,bindings:s.bindings,renderForm:void 0,onFieldCreate:u===e?t.onFieldCreate:void 0},children:[!!c.length&&f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[f.jsx(Ce,{"aria-label":"Back to parent fields",title:"Back to parent fields",icon:f.jsx(K.PiArrowLeft,{size:18}),size:"sm",variant:"ghost",onClick:()=>n(c.slice(0,-1))}),f.jsx("strong",{style:{minWidth:0,overflowWrap:"anywhere"},children:Cr(l)})]}),f.jsx(Fu,{nodeAddress:u,onOpen:y=>n([...c,y])},u)]})}function Fu({nodeAddress:e,onOpen:t}){var S,k;const{data:r,schema:n,callbacks:i,bindings:o,editable:s,renderForm:a,structured:c}=_.useContext(Sr),{readOnly:u,config:l,colorMode:d}=Le(),h=a==null?void 0:a(e);if(h!==void 0)return f.jsx("fieldset",{"data-flow-form":e,disabled:u||l.editable===!1||!s,style:{border:0,margin:0,padding:0,minWidth:0},children:h});if(!r)return f.jsx(Cn,{$colorMode:d,role:"alert",children:"Forms require a JSON document."});const p=o?dn(o,e,n):void 0,y=o?p:n&&Tt(r,e,n);if(!y)return f.jsx(Cn,{$colorMode:d,role:"status",children:"Form schema unavailable."});const m=(p==null?void 0:p.address)??e,g=ke(r,m),b=(S=c==null?void 0:c.containers.get(e))==null?void 0:S.scalar;if(g===void 0||typeof g!="object"&&!b)return f.jsx(Cn,{$colorMode:d,role:"alert",children:"Bound form state is unavailable."});const w=Object.entries(y.type.properties).filter(([I])=>{var R;return Fn((R=y.fields[I])==null?void 0:R.$visibleWhen,r)}),v=w.length>8||w.some(([I])=>{var R;return(R=y.fields[I])==null?void 0:R.$section}),x=new Map;for(const I of w){const[R,M]=I,E=v?Cr(((k=y.fields[R])==null?void 0:k.$section)??(M.type.kind==="object"||M.type.kind==="array"?R:M.optional?"Options":"General")):"";x.has(E)||x.set(E,[]),x.get(E).push(I)}const C=([I,R])=>f.jsx(Jl,{request:{data:r,address:b?m:`${m}.${I}`,nodeAddress:m,nodeId:typeof(g==null?void 0:g.id)=="string"?g.id:void 0},property:R,config:y.fields[I]??{},value:b?g:g==null?void 0:g[I],disabled:u||l.editable===!1||!(s??!!i.onJsonChange)},`${(g==null?void 0:g.id)??e}:${I}`);return f.jsxs(Cn,{$colorMode:d,"data-flow-form":e,onClick:I=>I.stopPropagation(),onDoubleClick:I=>I.stopPropagation(),children:[c&&f.jsx($0,{nodeAddress:e,onOpen:t}),!c&&p&&y.type.additionalProperties&&w.length===0&&f.jsx(Jl,{request:{data:r,address:m,nodeAddress:m},property:{type:y.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:g,disabled:u||l.editable===!1||!s}),[...x].map(([I,R])=>v&&R.length>1?f.jsxs("details",{open:!0,children:[f.jsxs("summary",{children:[f.jsx("span",{children:I}),f.jsx(K.PiCaretDown,{size:16,"aria-hidden":"true"})]}),R.map(C)]},I):R.map(C))]})}function Am(e){const{viewData:t}=_.useContext(Sr),{nodeById:r,edgeById:n,parentIds:i}=Xr();if(t){const o=ke(t,e),s=o&&typeof o=="object"&&!Array.isArray(o)&&"$"in o?o.$:o;return Array.isArray(s)?s.length>0:!!s&&typeof s=="object"&&Object.entries(s).some(([a,c])=>!a.startsWith("$")&&c!==null&&typeof c=="object")}return i.has(e)?!0:[...n.values()].some(({data:o})=>{const s=o.isInverted?o.target:o.source,a=o.isInverted?o.source:o.target;return s===e&&a!==e&&r.has(a)})}function cn(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:t}function An(e,t,r,n){return{borderColor:t,borderWidth:cn(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...By(t==="transparent"?"currentColor":t,r,".flow-sdk-node:hover &",!r)}}function Tm({label:e,value:t,options:r,onChange:n,disabled:i}){var o;return f.jsxs(br,{"aria-label":e,title:`Animation: ${((o=r.find(s=>s.value===t))==null?void 0:o.label)??"Mixed"}`,value:t,style:{width:104},disabled:i,onValueChange:s=>{const a=r.find(c=>c.value===s);a&&n(a.value)},children:[t===""&&f.jsx("option",{value:"",disabled:!0,children:"Mixed"}),r.map(s=>f.jsx("option",{value:s.value,children:s.label},s.value))]})}function tl({nodeId:e,edgeId:t,value:r,open:n,onOpenChange:i}){const{callbacks:o,readOnly:s,themeColor:a,colorMode:c}=Le(),{background:u,backgroundSecondary:l,border:d,colorText:h,colorInactive:p}=Ze(),y=c==="dark"?Pt:ve(p),m=_.useRef(null),g=_.useRef(null),b=_.useRef(0),[w,v]=_.useState(!1),[x,C]=_.useState("icons"),[S,k]=_.useState([]),[I,R]=_.useState("loading"),[M,E]=_.useState(""),[P,A]=_.useState(0),[j,q]=_.useState(""),[O,z]=_.useState(""),[U,ae]=_.useState(!1);_.useEffect(()=>()=>{b.current++},[]),_.useEffect(()=>{if(!w)return;let N=!0;return import("react-icons/pi").then(ne=>{N&&(k(Object.keys(ne).filter(me=>me.startsWith("Pi")).sort()),R("ready"))}).catch(()=>{N&&R("unavailable")}),()=>{N=!1}},[w]),_.useEffect(()=>{var N;s&&((N=m.current)==null||N.close())},[s]),_.useEffect(()=>{var N,ne,me;if(n!==void 0){if(!n||s){(N=m.current)==null||N.close();return}(ne=m.current)!=null&&ne.open||(z(""),C(r==="PiFileSvg"||r&&Wr(r)?"custom":"icons"),q(r&&!r.startsWith(Qt)&&Wr(r)?r:""),v(!0),(me=m.current)==null||me.showModal())}},[n,s,r]);const Q=N=>{var ne,me,fe;s||(t?(ne=o.onEdgeIconChange)==null||ne.call(o,t,N):e&&((me=o.onNodeIconChange)==null||me.call(o,e,N)),i==null||i(!1),(fe=m.current)==null||fe.close())},Y=S.filter(N=>N.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(M.trim().toLowerCase())),pe=36,se=Math.max(1,Math.ceil(Y.length/pe)),$=Math.min(P,se-1),V=Y.slice($*pe,($+1)*pe),W={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${ve(d)}`,borderRadius:30};return f.jsxs(f.Fragment,{children:[n===void 0&&f.jsx(Oe,{label:t?"Choose edge icon":"Choose node icon",children:f.jsx(Ce,{"aria-label":t?"Choose edge icon":"Choose node icon",icon:f.jsx(K.PiShapes,{size:20}),size:"sm",variant:"ghost",color:ve(a),disabled:s,onClick:()=>{var N;z(""),C(r&&Wr(r)?"custom":"icons"),q(r&&!r.startsWith(Qt)&&Wr(r)?r:""),v(!0),(N=m.current)==null||N.showModal()}})}),f.jsx(F.chakra.dialog,{ref:m,"aria-label":t?"Choose edge icon":"Choose node icon",css:Kr(ve(u),ve(d)),onClose:()=>{v(!1),i==null||i(!1),b.current++,ae(!1)},onClick:N=>{N.stopPropagation(),N.target===N.currentTarget&&N.currentTarget.close()},onKeyDown:N=>N.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",borderRadius:30,background:ve(u),color:ve(h)},children:w&&f.jsxs("div",{style:{display:"grid",gap:8},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsx("strong",{children:t?"Edge icon":"Node icon"}),f.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[r&&f.jsx(Oe,{label:"Remove icon",children:f.jsx(Ce,{"aria-label":t?"Remove edge icon":"Remove node icon",icon:f.jsx(K.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:s||U,onClick:()=>Q("")})}),f.jsx(At,{"aria-label":"Close icon picker",onClick:()=>{var N;return(N=m.current)==null?void 0:N.close()}})]})]}),f.jsxs(F.Tabs.Root,{value:x,onValueChange:({value:N})=>{C(N),z("")},display:"contents",css:{"--indicator-thickness":"1px"},children:[f.jsx(F.Tabs.List,{"aria-label":"Icon source",width:"100%",borderBottomWidth:0,children:["icons","custom"].map(N=>f.jsx(F.Tabs.Trigger,{value:N,flex:1,minW:0,justifyContent:"center",px:3,py:2,fontSize:"13px",_selected:{color:a,borderColor:y,"--indicator-color":y},children:N==="icons"?"React icons":"Custom SVG"},N))}),f.jsx("input",{ref:g,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:U||s,onChange:async N=>{var fe;const ne=(fe=N.target.files)==null?void 0:fe[0];if(N.target.value="",!ne)return;const me=++b.current;ae(!0),z("");try{const J=await k0(ne);me===b.current&&Q(J)}catch(J){me===b.current&&z(J instanceof Error?J.message:"Unable to read SVG.")}finally{me===b.current&&ae(!1)}}}),f.jsx(F.Tabs.Content,{value:x,p:0,style:{display:"grid",gap:8},children:x==="icons"?f.jsxs(f.Fragment,{children:[f.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:M,onChange:N=>{E(N.target.value),A(0)},style:W}),f.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[V.map(N=>f.jsx("button",{type:"button","aria-label":`Choose ${N}`,"aria-pressed":r===N,title:N,onClick:()=>Q(N),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${r===N?2:1}px solid ${ve(r===N?a:d)}`,background:ve(r===N?u:l),color:"inherit",cursor:"pointer"},children:f.jsx(Or,{name:N,size:24})},N)),V.length===0&&f.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:I==="loading"?"Loading icons...":I==="unavailable"?"React icons unavailable":"No icons found"})]}),f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsxs("span",{role:"status",style:{fontSize:12},children:[Y.length," icons · ",$+1," / ",se]}),f.jsxs("div",{style:{display:"flex",gap:4},children:[f.jsx(Oe,{label:"Previous icons",children:f.jsx(Ce,{"aria-label":"Previous icons",icon:f.jsx(K.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:$===0,onClick:()=>A($-1)})}),f.jsx(Oe,{label:"Next icons",children:f.jsx(Ce,{"aria-label":"Next icons",icon:f.jsx(K.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:$+1>=se,onClick:()=>A($+1)})})]})]})]}):f.jsxs(f.Fragment,{children:[r&&Wr(r)&&f.jsx(Or,{name:r,size:64}),f.jsxs("button",{type:"button",disabled:U||s,onClick:()=>{var N;return(N=g.current)==null?void 0:N.click()},style:{...W,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[f.jsx(K.PiUploadSimple,{}),U?"Uploading...":"Upload SVG"]}),f.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:N=>{N.preventDefault(),!(U||s)&&(!Wr(j.trim())||j.trim().startsWith(Qt)?z("Enter an HTTP or HTTPS image URL."):Q(j.trim()))},children:[f.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:j,disabled:U||s,onChange:N=>q(N.target.value),style:{...W,flex:1,minWidth:0}}),f.jsx(Oe,{label:"Apply URL",children:f.jsx(Ce,{type:"submit","aria-label":"Apply URL",icon:f.jsx(K.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:U||s||!j.trim(),style:{flexShrink:0}})})]})]})})]}),O&&f.jsx("div",{role:"alert",style:{fontSize:13},children:O})]})})]})}const Tn=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500",Pt],Im=["gray.900",Pt,"gray.600","gray.200","white"];function Om(){const{config:e}=Le(),t=e.selectionToolbar||{},r=new Set(t.hide||[]);return{palette:t.palette||Tn,show:n=>!r.has(n)}}function gr(){const{border:e}=Ze();return f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:e})}function ct({value:e,placeholder:t,ariaLabel:r,width:n="140px",type:i="text",min:o,onCommit:s}){const{colorText:a}=Ze(),[c,u]=_.useState(e),l=_.useRef(!1);_.useEffect(()=>u(e),[e]);const d=()=>{if(l.current)return;l.current=!0;const h=c.trim();if(i==="number"&&h!==""&&(!Number.isFinite(Number(h))||Number(h)<(o??0))){u(e);return}h!==e&&s(h)};return f.jsx(F.Input,{"aria-label":r,type:i,min:o,size:"xs",fontSize:"16px",w:n,value:c,placeholder:t,color:a,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{l.current=!1},onChange:h=>u(h.target.value),onBlur:d,onKeyDown:h=>{h.key==="Enter"&&(d(),h.target.blur()),h.key==="Escape"&&(l.current=!0,u(e),h.target.blur())}})}function ut({colors:e,value:t,label:r,onPick:n,onReset:i,includeTransparent:o=!0}){const{colorInactive:s,colorText:a}=Ze(),[c,u]=_.useState(!1),l=_.useId(),d=_.useRef(null),h=t??e[0]??"transparent",p=qn(f.jsx(ut,{colors:e,value:t,label:r,onPick:n,onReset:i,includeTransparent:o}));return f.jsx(Et.Provider,{value:null,children:f.jsxs(F.HStack,{gap:1,"aria-label":r,role:"group",onClickCapture:p,onKeyDown:y=>{var m;y.key==="Escape"&&(u(!1),(m=d.current)==null||m.focus())},children:[f.jsx(Oe,{label:`${r}: ${h}`,children:f.jsx(F.chakra.button,{ref:d,type:"button","aria-label":`${r} colors`,"aria-expanded":c,"aria-controls":l,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:ve(h),...h==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${ve(a)}`,outlineOffset:"1px",onClick:()=>u(y=>!y)})}),c&&f.jsxs(F.HStack,{id:l,gap:1,children:[[...new Set([...e,...o?["transparent"]:[]])].map(y=>{const m=t===y;return f.jsx(Oe,{label:`${r}: ${y}`,children:f.jsx(F.Box,{as:"button","aria-label":`${r} ${y}`,"aria-pressed":m,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:ve(y),...y==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:m?`2px solid ${ve(a)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(y),onDoubleClick:g=>{var b;g.stopPropagation(),u(!1),(b=d.current)==null||b.focus()}})},y)}),i&&f.jsx(Oe,{label:`Reset ${r.toLowerCase()}`,children:f.jsx(Ce,{"aria-label":`Reset ${r}`,icon:f.jsx(F.Icon,{as:K.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:s,onClick:()=>{var y;i(),u(!1),(y=d.current)==null||y.focus()}})})]})]})})}function Mm({edgeId:e,onClose:t}){var p;const{callbacks:r,themeColor:n,config:i}=Le(),{colorInactive:o}=Ze(),{edgeById:s}=Xr(),{palette:a,show:c}=Om(),u=(p=s.get(e))==null?void 0:p.data,l=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(i.customEdgeTypes??{}),...u!=null&&u.type?[u.type]:[]])],d=u!=null&&u.isEdgeAnimated?"animated":u!=null&&u.isEdgeDashed?"dashed":"solid",h=[{key:"solid",icon:K.PiLineSegment,label:"Solid"},{key:"dashed",icon:K.PiLineSegments,label:"Dashed"},{key:"animated",icon:K.PiFastForward,label:"Animated"}];return f.jsxs(f.Fragment,{children:[f.jsx(At,{onClick:t}),c("label")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(ct,{ariaLabel:"Edge label",placeholder:"Edge label",value:(u==null?void 0:u.label)||"",onCommit:y=>{var m;return(m=r.onEdgeLabelChange)==null?void 0:m.call(r,e,y)}})]}),c("style")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),h.map(y=>f.jsx(Oe,{label:y.label,children:f.jsx(Ce,{"aria-label":`Edge style ${y.key}`,"aria-pressed":d===y.key,icon:f.jsx(F.Icon,{as:y.icon,boxSize:5}),size:"sm",variant:"ghost",color:d===y.key?n:o,onClick:()=>{var m;return(m=r.onEdgeStyleChange)==null?void 0:m.call(r,e,y.key)}})},y.key)),d==="animated"&&f.jsx(Tm,{label:"Edge animation",value:(u==null?void 0:u.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:i.readOnly,onChange:y=>{var m;return(m=r.onEdgeAnimationVariantChange)==null?void 0:m.call(r,e,y)}}),f.jsxs(br,{"aria-label":"Edge shape",title:`Edge shape: ${(u==null?void 0:u.type)??"Default"}`,icon:f.jsx(K.PiBezierCurve,{size:20}),style:{width:36},value:(u==null?void 0:u.type)??"",disabled:i.readOnly,onValueChange:y=>{var m;return(m=r.onEdgeTypeChange)==null?void 0:m.call(r,e,y||void 0)},children:[f.jsx("option",{value:"",children:"Default"}),l.map(y=>f.jsx("option",{value:y,children:y},y))]})]}),c("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(tl,{edgeId:e,value:u==null?void 0:u.icon},e),f.jsx(ct,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(u==null?void 0:u.icon)??"",onCommit:y=>{var m;return(m=r.onEdgeIconChange)==null?void 0:m.call(r,e,y)}})]}),c("color")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(ut,{label:"Edge color",colors:a,value:u==null?void 0:u.color,onPick:y=>{var m;return(m=r.onEdgeColorChange)==null?void 0:m.call(r,e,y)},onReset:()=>{var y;return(y=r.onEdgeColorChange)==null?void 0:y.call(r,e,"")}})]}),c("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:"Delete edge",children:f.jsx(Ce,{"aria-label":"Delete edge",icon:f.jsx(F.Icon,{as:K.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var y;(y=r.onEdgeDelete)==null||y.call(r,e,u),t()}})})]})]})}function qm({ids:e,showDivider:t=!0}){const{callbacks:r,config:n}=Le(),{colorInactive:i}=Ze(),{nodeById:o}=Xr(),[s,a]=_.useState(!1),c=e.map(y=>{var m,g;return(g=(m=o.get(y))==null?void 0:m.data.viewProps)==null?void 0:g.borderRadius}),u=!c.every(y=>y===c[0]),l=u?"mixed":String(c[0]??""),d=["0","8","16","30","53","100"],h=s||!u&&l!==""&&!d.includes(l),p=y=>e.forEach(m=>{var g;return(g=r.onNodeBorderRadiusChange)==null?void 0:g.call(r,m,y)});return f.jsxs(f.Fragment,{children:[t&&f.jsx(gr,{}),f.jsx(F.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:f.jsxs(br,{icon:f.jsx(F.Icon,{as:Rv.TbBorderRadius,boxSize:5,color:i,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${u?"Mixed":c[0]===void 0?"Default":`${c[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:h?"custom":l,disabled:n.readOnly,onValueChange:y=>{a(y==="custom"),y!=="custom"&&p(y===""?void 0:Number(y))},children:[f.jsx("option",{value:"",children:"Default radius"}),u&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed radii"}),d.map(y=>f.jsxs("option",{value:y,children:[y,"px radius"]},y)),f.jsx("option",{value:"custom",children:"Custom radius"})]})}),h&&f.jsx(ct,{ariaLabel:"Custom border radius",placeholder:u?"Mixed":"Auto",type:"number",min:0,width:"72px",value:u?"":l,onCommit:y=>p(y===""?void 0:Number(y))})]})}function $m({ids:e,onClose:t}){var se,$,V,W,N,ne,me,fe;const{callbacks:r,colorMode:n,themeColor:i,config:o,setNodeViewMode:s}=Le(),{colorText:a,colorInactive:c}=Ze(),{nodeById:u,parentIds:l}=Xr(),{palette:d,show:h}=Om(),p=e.length===1,y=p?(se=u.get(e[0]))==null?void 0:se.data:void 0,m=e.map(J=>{var te,G;return((G=(te=u.get(J))==null?void 0:te.data.config)==null?void 0:G.typeView)??""}),g=m.some(J=>J!==m[0]),b=g?"mixed":m[0]??"",w=e.some(J=>{var G,le;const te=(G=u.get(J))==null?void 0:G.data;return te&&(l.has(J)||((le=te.config)==null?void 0:le.parentContainer)||Object.prototype.hasOwnProperty.call(o.customViews??{},te.type))}),v=($=y==null?void 0:y.config)==null?void 0:$.collapsed,x=Am(e[0]),C=J=>{var te,G,le;return(((G=(te=u.get(J))==null?void 0:te.data.viewProps)==null?void 0:G.outline)??(l.has(J)?(le=o.parentNodeStyle)==null?void 0:le.outline:!1))===!0},S=e.every(C),k=!S&&e.some(C),I=J=>{var te;return((te=u.get(J))==null?void 0:te.data.isNodeAnimated)===!0},R=e.every(I),M=!R&&e.some(I),E=e.map(J=>{var te;return((te=u.get(J))==null?void 0:te.data.nodeAnimationVariant)??"traveling"}),P=E.every(J=>J===E[0])?E[0]:"",A=J=>e.forEach(J),[j,q]=_.useState(!1),O=j&&h("color")&&h("borderColor"),z=J=>{var te,G,le;return(((G=(te=u.get(J))==null?void 0:te.data.viewProps)==null?void 0:G.borderStyle)??(l.has(J)?(le=o.parentNodeStyle)==null?void 0:le.borderStyle:"solid"))==="dashed"},U=e.every(z),ae=!U&&e.some(z),Q=e.map(J=>{var le,ue,we;const te=(le=u.get(J))==null?void 0:le.data,G=l.has(J)?cn((ue=o.parentNodeStyle)==null?void 0:ue.borderWidth,6):(te==null?void 0:te.type)==="objectView"?3:2;return cn((we=te==null?void 0:te.viewProps)==null?void 0:we.borderWidth,G)}),Y=Q.every(J=>J===Q[0])?String(Q[0]??""):"",pe=J=>A(te=>{var G,le;O?(G=r.onNodeBorderColorChange)==null||G.call(r,te,J):(le=r.onNodeColorChange)==null||le.call(r,te,"bg",J)});return f.jsxs(f.Fragment,{children:[f.jsx(At,{onClick:t}),f.jsx(gr,{}),p&&h("label")?f.jsx(ct,{ariaLabel:"Node label",placeholder:"Node label",value:(y==null?void 0:y.label)??(y==null?void 0:y.headerTitle)??"",onCommit:J=>{var te;return(te=r.onNodeLabelChange)==null?void 0:te.call(r,e[0],J)}}):f.jsxs(F.Text,{fontSize:"xs",color:a,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),h("typeView")&&f.jsxs(br,{"aria-label":"Type view",title:w?"Type view is managed by the custom renderer or container":`Type view: ${b||"None (default)"}`,icon:f.jsx(K.PiImage,{size:20}),style:{width:36},value:b,disabled:o.readOnly||o.editable===!1||w,onValueChange:J=>{nn.includes(J)&&A(te=>{var G,le;(G=r.onNodeTypeViewChange)==null||G.call(r,te,J||void 0),s(te,"default"),(le=r.onNodeViewToggle)==null||le.call(r,te)})},children:[g&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),nn.map(J=>f.jsx("option",{value:J,children:J||"None"},J))]}),h("style")&&f.jsx(qm,{ids:e},e.join("\0")),h("outline")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:S?"Restore node fill":"Remove node fill",children:f.jsx(Ce,{"aria-label":"Toggle node outline","aria-pressed":k?"mixed":S,icon:f.jsx(F.Icon,{as:S?K.PiSquare:K.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:S?i:c,onClick:()=>A(J=>{var te;return(te=r.onNodeOutlineChange)==null?void 0:te.call(r,J,!S)})})})]}),h("color")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),h("borderColor")&&f.jsx(Oe,{label:O?"Edit node colors":"Edit node border",children:f.jsx(Ce,{"aria-label":"Edit node border","aria-pressed":O,icon:f.jsx(F.Icon,{as:K.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:O?i:c,bg:O?n==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>q(J=>!J)})}),f.jsx(ut,{label:O?"Border color":"Background",colors:d,value:O?((V=y==null?void 0:y.viewProps)==null?void 0:V.borderColor)??(p&&l.has(e[0])?(W=o.parentNodeStyle)==null?void 0:W.borderColor:void 0):(N=y==null?void 0:y.viewProps)==null?void 0:N.bgColor,onPick:pe,onReset:()=>pe("")}),O&&h("style")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:U?"Solid border":"Dashed border",children:f.jsx(Ce,{"aria-label":"Toggle dashed border","aria-pressed":ae?"mixed":U,icon:f.jsx(F.Icon,{as:U?K.PiLineSegments:K.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:U?i:c,onClick:()=>A(J=>{var te;return(te=r.onNodeBorderStyleChange)==null?void 0:te.call(r,J,U?"solid":"dashed")})})}),f.jsx(ct,{ariaLabel:"Border thickness",placeholder:p?"Auto":"Mixed",width:"64px",type:"number",min:0,value:Y,onCommit:J=>A(te=>{var G;return(G=r.onNodeBorderWidthChange)==null?void 0:G.call(r,te,J===""?void 0:Number(J))})})]})]}),h("animation")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:R?"Stop border animation":"Animate node border",children:f.jsx(Ce,{"aria-label":"Toggle node animation","aria-pressed":M?"mixed":R,icon:f.jsx(F.Icon,{as:K.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:R?i:c,onClick:()=>A(J=>{var te;return(te=r.onNodeAnimationChange)==null?void 0:te.call(r,J,!R)})})}),(R||M)&&f.jsx(Tm,{label:"Node animation",value:P,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:o.readOnly,onChange:J=>A(te=>{var G;return(G=r.onNodeAnimationVariantChange)==null?void 0:G.call(r,te,J)})})]}),!O&&h("textColor")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(ut,{label:"Text color",colors:Im,value:(ne=y==null?void 0:y.viewProps)==null?void 0:ne.textColor,onPick:J=>A(te=>{var G;return(G=r.onNodeColorChange)==null?void 0:G.call(r,te,"text",J)}),onReset:()=>A(J=>{var te;return(te=r.onNodeColorChange)==null?void 0:te.call(r,J,"text","")})})]}),p&&h("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(tl,{nodeId:e[0],value:(me=y==null?void 0:y.config)==null?void 0:me.icon},e[0]),f.jsx(ct,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((fe=y==null?void 0:y.config)==null?void 0:fe.icon)||"",onCommit:J=>{var te;return(te=r.onNodeIconChange)==null?void 0:te.call(r,e[0],J)}})]}),p&&x&&h("collapse")&&v!==void 0&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:v?"Expand":"Collapse",children:f.jsx(Ce,{"aria-label":v?"Expand node":"Collapse node",icon:f.jsx(F.Icon,{as:v?K.PiArrowsOutLineVertical:K.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:c,onClick:()=>{var J;return(J=r.onNodeCollapse)==null?void 0:J.call(r,e[0],!v)}})})]}),h("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:p?"Delete node":`Delete ${e.length} nodes`,children:f.jsx(Ce,{"aria-label":"Delete selected nodes",icon:f.jsx(F.Icon,{as:K.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:n==="dark"?"red.300":"red.500",onClick:()=>{A(J=>{var te,G;return(G=r.onNodeDelete)==null?void 0:G.call(r,J,((te=u.get(J))==null?void 0:te.data)||{id:J})}),t()}})})]})]})}async function Nm(e){const{toSvg:t}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const r=await t(e,{filter:i=>!(i instanceof Element)||!i.matches("button, iframe, [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(i=>i.remove()),n.querySelectorAll("[data-flow-preview-source]").forEach(i=>{i.setAttribute("style","display:block;white-space:pre-wrap;font:16px/1.5 monospace;overflow-wrap:anywhere")}),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}async function Lm(e,t="squeed.svg"){const r=document.createElement("a");r.href=await Nm(e),r.download=t.endsWith(".svg")?t:`${t}.svg`,r.click()}function Fm(){const{themeColor:e}=Le(),[t,r]=_.useState(!1),[n,i]=_.useState("");return f.jsxs(f.Fragment,{children:[f.jsx(Oe,{label:"Download SVG (current view)",children:f.jsx(Ce,{"aria-label":"Download SVG",icon:f.jsx(K.PiDownloadSimpleFill,{size:20}),disabled:t,borderRadius:"30%",color:e,variant:"ghost",onClick:async o=>{var a;const s=(a=o.currentTarget.closest("[data-flow-diagram]"))==null?void 0:a.querySelector("[data-flow-background]");if(!s){i("Diagram not available for export.");return}r(!0),i("");try{await Lm(s)}catch(c){i(c instanceof Error?c.message:"Unable to export SVG.")}finally{r(!1)}}})}),n&&f.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function Bm({children:e,background:t,border:r,endElement:n}){const i=_.useRef(null),[o,s]=_.useState({left:!1,right:!1});_.useLayoutEffect(()=>{const c=i.current;let u=c.parentElement.offsetWidth;const l=()=>{const p=c.parentElement.offsetWidth;if(p>0&&p!==u){const g=u/p;u=p,g>0&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&c.parentElement.animate({transform:[`scaleX(${g})`,"scaleX(1)"],transformOrigin:[n?"right center":"left center",n?"right center":"left center"]},{duration:180,easing:"ease-out",id:"flow-toolbar-grow"})}const y=c.scrollLeft>1,m=c.scrollWidth-c.clientWidth-c.scrollLeft>1;s(g=>g.left===y&&g.right===m?g:{left:y,right:m})},d=p=>{if(p.defaultPrevented||p.ctrlKey||p.deltaX!==0||!p.deltaY||c.scrollWidth<=c.clientWidth)return;p.preventDefault();const y=p.deltaMode===WheelEvent.DOM_DELTA_LINE?16:p.deltaMode===WheelEvent.DOM_DELTA_PAGE?c.clientWidth:1;c.scrollLeft+=p.deltaY*y},h=new ResizeObserver(l);return h.observe(c),c.firstElementChild&&h.observe(c.firstElementChild),c.addEventListener("scroll",l,{passive:!0}),c.addEventListener("wheel",d,{passive:!1}),l(),()=>{h.disconnect(),c.removeEventListener("scroll",l),c.removeEventListener("wheel",d)}},[]);const a=`var(--chakra-colors-${t.replace(".","-")})`;return f.jsxs(F.Box,{position:"relative",bg:t,minW:0,maxW:"100%",flex:"0 1 auto",borderRadius:"30px",css:Kr(a,`var(--chakra-colors-${r.replace(".","-")})`),children:[f.jsx(F.Box,{ref:i,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",mr:n?"44px":void 0,borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(c=>f.jsx(F.Box,{"data-flow-toolbar-fade":c,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",borderRadius:c==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[c]:c==="right"&&n?44:0,opacity:o[c]?1:0,background:`linear-gradient(to ${c==="left"?"right":"left"}, ${a}, transparent)`}},c)),n&&f.jsx(F.Box,{position:"absolute",right:"6px",top:0,h:"50px",w:"32px",display:"flex",alignItems:"center",justifyContent:"center",children:n})]})}async function L0(e,t){const r=new Set,n=[],i=(a,c)=>{var l,d,h;if(!a||typeof a!="object")return;const u=a;n.push(c),typeof((l=u.$form)==null?void 0:l.$type)=="string"&&r.add(u.$form.$type),typeof((h=(d=u.$form)==null?void 0:d.$create)==null?void 0:h.$type)=="string"&&r.add(u.$form.$create.$type);for(const[p,y]of Object.entries(u))p==="$"?i(y,c):p.startsWith("$")||i(y,`${c}.${p}`)};if(i(t,"root"),!r.size)return{contract:await Em(e)};const o=await rl(e,[...r]);for(const a of r)if(!Object.prototype.hasOwnProperty.call(o,a))throw new Error(`Missing form type: ${a}`);const s={};for(const a of n){const c=Tt(t,a,o);c&&(s[a]={type:c.type,optional:!1})}return{schema:o,contract:{name:e.name,nodes:s}}}function zm({message:e,onDismiss:t}){const{background:r,colorText:n,border:i}=Ze();return!e||typeof document>"u"?null:tn.createPortal(f.jsxs(F.chakra.div,{role:"alert","aria-atomic":"true",css:Kr(ve(r),ve(i)),onPointerDown:o=>o.stopPropagation(),onClick:o=>o.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:ve(r),color:ve(n),fontSize:14,lineHeight:1.5},children:[f.jsx(K.PiWarningCircle,{size:20,"aria-hidden":"true",style:{flexShrink:0,color:"#ef4444"}}),f.jsxs("div",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:[f.jsx("strong",{children:"Interface upload failed"}),f.jsx("div",{children:e})]}),f.jsx(At,{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 nl({showDivider:e=!0,compact:t=!1}={}){const{edgeMode:r,setEdgeMode:n,workflowContract:i,setWorkflowContract:o,callbacks:s,readOnly:a,themeColor:c,colorMode:u}=Le(),{edgeById:l}=Xr(),{data:d,schema:h,setSchema:p,bindings:y,structured:m}=_.useContext(Sr),g=(m==null?void 0:m.sourceBindings)??y,b=(m==null?void 0:m.sourceSchema)??h,{colorText:w}=Ze(),v=_.useRef(null),x=_.useRef(0),[C,S]=_.useState(!1),[k,I]=_.useState("");_.useEffect(()=>()=>{x.current++},[]),_.useEffect(()=>{x.current++,S(!1)},[a,d,g]);const R=i?[...l.values()].filter(P=>el(i,P.data)).length:0,M=i?`${i.name}: ${b?`${Object.keys(b).length} form types loaded; `:""}${R} invalid or unverified connections`:"",E=qn(f.jsx(nl,{showDivider:!1,compact:!0}));return f.jsx(Et.Provider,{value:null,children:f.jsxs("span",{style:{display:"contents"},onClickCapture:E,children:[f.jsx(zm,{message:k,onDismiss:()=>I("")}),e&&f.jsx(Ht,{}),f.jsxs(br,{"aria-label":"Edge mode",title:r==="auto"?"Connections: Auto":r==="properties"?"Connections: Properties":"Connections: Nodes",icon:r==="auto"?f.jsx(K.PiGraph,{size:20}):r==="properties"?f.jsx(K.PiTable,{size:20}):f.jsx(K.PiTreeStructure,{size:20}),style:{width:36},value:r,disabled:a,footer:s.onWorkflowConfigurationOpen&&f.jsxs(f.Fragment,{children:[f.jsx("hr",{style:{border:0,borderTop:"1px solid currentColor",opacity:.2,margin:"8px 0"}}),f.jsxs(F.Button,{"data-flow-menu-action":"",variant:"ghost",width:"100%",justifyContent:"flex-start",color:"inherit",bg:"transparent",css:Pn,_hover:{bg:u==="dark"?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:u==="dark"?"whiteAlpha.100":"blackAlpha.50"},onClick:P=>{var A,j;(A=P.currentTarget.closest("[popover]"))==null||A.hidePopover(),(j=s.onWorkflowConfigurationOpen)==null||j.call(s)},children:[f.jsx(K.PiGear,{}),"Configuration"]})]}),onValueChange:P=>{var j;const A=P==="auto"?"auto":P==="properties"?"properties":"nodes";n(A),(j=s.onEdgeModeChange)==null||j.call(s,A)},children:[f.jsx("option",{value:"auto",children:"Auto"}),f.jsx("option",{value:"nodes",children:"Nodes"}),f.jsx("option",{value:"properties",children:"Properties"})]}),f.jsxs("span",{style:{display:r==="auto"||r==="properties"?"contents":"none"},children:[f.jsx(Oe,{label:i?`Replace ${i.name}`:"Upload workflow interface",children:f.jsx(Ce,{"aria-label":"Upload workflow interface",icon:f.jsx(K.PiUploadSimple,{size:20}),color:ve(c),size:"sm",variant:"ghost",disabled:C||a,onClick:()=>{var P;return(P=v.current)==null?void 0:P.click()}})}),f.jsx("input",{ref:v,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:a||C,onChange:async P=>{var q,O;const A=(q=P.target.files)==null?void 0:q[0];if(P.target.value="",!A)return;const j=++x.current;S(!0),I("");try{const z=g?await rl(A,[...new Set(Object.values(g).map(Q=>Q.schemaType??Q.type))]):void 0;if(g&&z){for(const Q of Object.values(g))if(!Object.prototype.hasOwnProperty.call(z,Q.schemaType??Q.type))throw new Error(`Missing form type: ${Q.schemaType??Q.type}`)}const{contract:U,schema:ae}=g&&z?{schema:z,contract:{name:A.name,nodes:Object.fromEntries(Object.entries(g).map(([Q,Y])=>[Q,{type:z[Y.schemaType??Y.type],optional:!1}]))}}:await L0(A,d);if(j!==x.current)return;p==null||p(ae),o(U),(O=s.onWorkflowContractChange)==null||O.call(s,U)}catch(z){j===x.current&&I(`${A.name}: ${z instanceof Error?z.message:"Unable to load interface."}`)}finally{j===x.current&&S(!1)}}}),!t&&(M||C)&&f.jsx("span",{role:"status",title:M,style:{color:ve(w),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:C?"Loading interface...":M}),!t&&i&&f.jsx(Oe,{label:"Remove workflow interface",children:f.jsx(Ce,{"aria-label":"Remove workflow interface",icon:f.jsx(K.PiX,{size:16}),size:"sm",variant:"ghost",disabled:a||C,onClick:()=>{var P;p==null||p(void 0),o(void 0),(P=s.onWorkflowContractChange)==null||P.call(s,void 0),I("")}})})]})]})})}const F0=[{value:"BT",label:"Bottom to Up",icon:K.PiArrowUp,flowType:Bt.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:K.PiArrowDown,flowType:Bt.TOP_DOWN},{value:"LR",label:"Left to Right",icon:K.PiArrowRight,flowType:Bt.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:K.PiArrowLeft,flowType:Bt.RIGHT_LEFT}],Dm=()=>{const{engineRef:e,themeColor:t,setThemeColor:r,edgeColor:n,setEdgeColor:i,backgroundSelected:o,setBackgroundSelected:s,direction:a,edgeMode:c,allNodesIconLabel:u,setAllNodesIconLabel:l,selectedNodeIds:d,setSelectedNodeIds:h,selectedEdgeId:p,setSelectedEdgeId:y,isZoomMode:m,setIsZoomMode:g,isMultiSelectMode:b,setIsMultiSelectMode:w,isDragMode:v,setIsDragMode:x,isEdgeHandlesEnabled:C,setIsEdgeHandlesEnabled:S,isArrayNodeMode:k,setIsArrayNodeMode:I,isPinned:R,setIsPinned:M,callbacks:E,config:P,readOnly:A}=Le(),{nodeById:j,edgeById:q,parentIds:O}=Xr(),z=P.colorMode==="dark",{background:U,border:ae,colorInactive:Q,colorText:Y,colorActive:pe}=Ze(),se=z?ae:"gray.300",$=`var(--chakra-colors-${U.replace(".","-")})`,V=`var(--chakra-colors-${(z?ae:"gray.300").replace(".","-")})`,[W,N]=_.useState(!1),[ne,me]=_.useState(!0),fe=P.bottomBarCollapsed??ne,J=_.useRef(null),te=Ly({edge:"bottom",enabled:!R,bounds:J,inside:[J]}),G=_.useCallback(ye=>{const Me=e.current;if(!Me)return;const nr=P.minZoom??.01,cr=P.maxZoom??1.5,Xe=.02;let xe=Me.zoom();switch(ye){case"increase":xe=Math.min(cr,xe+Xe),Me.zoom(xe),Me.center();break;case"decrease":xe=Math.max(nr,xe-Xe),Me.zoom(xe),Me.center();break;case"reset":Me.fit(50);break}},[e,P.minZoom,P.maxZoom]),le=P.renderSelectedNodeToolbar,ue=d.length>0&&!!le,we=_.useMemo(()=>ue?d.map(ye=>{var nr;return{...((nr=j.get(ye))==null?void 0:nr.data)??{id:ye},isParent:O.has(ye)}}):[],[ue,d,j,O]),ge=_.useCallback(()=>{var ye;h([]),(ye=E.onNodeDeselect)==null||ye.call(E)},[h,E]),qe=P.renderSelectedEdgeToolbar,ee=!!p&&!!qe,he=_.useMemo(()=>{var ye;return!ee||!p?null:((ye=q.get(p))==null?void 0:ye.data)??{id:p}},[ee,p,q]),be=_.useCallback(()=>{var ye;y(null),(ye=E.onEdgeDeselect)==null||ye.call(E)},[y,E]),Ee=P.selectionToolbar!==!1&&!A,$e=Ee&&!!p&&!qe,Ge=Ee&&!$e&&d.length>0&&!le,Ye=$e||Ge,tr=R||te||W||Ye||P.bottomBarCollapsed===!1;_.useEffect(()=>{d.length||p?s(!1):A||(o&&M(!0),P.bottomBarCollapsed===void 0&&me(!o))},[o,d.length,p,A,s,M,P.bottomBarCollapsed]);const sr=P.renderBottomBar,Pe=h0();return sr?f.jsxs(f.Fragment,{children:[ue&&f.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:le({selectedNodeIds:d,selectedNodeData:we,onDeselect:ge})}),ee&&he&&f.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:qe({edgeId:p,edgeData:he,onDeselect:be})}),f.jsx(F.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:sr({zoomIn:()=>G("increase"),zoomOut:()=>G("decrease"),resetZoom:()=>G("reset"),direction:a,isZoomMode:m,setIsZoomMode:g,isMultiSelectMode:b,setIsMultiSelectMode:w,isDragMode:v,setIsDragMode:x,isEdgeHandlesEnabled:C,setIsEdgeHandlesEnabled:S,isArrayNodeMode:k,setIsArrayNodeMode:I,selectedNodeIds:d,selectedNodeData:we,selectedEdgeId:p,selectedEdgeData:he,onNodeDeselect:ge,onEdgeDeselect:be,callbacks:E})})]}):f.jsxs(Et.Provider,{value:Pe,children:[ue&&f.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:le({selectedNodeIds:d,selectedNodeData:we,onDeselect:ge})}),ee&&he&&f.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:qe({edgeId:p,edgeData:he,onDeselect:be})}),f.jsx(F.Box,{ref:J,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:tr?"translateY(0)":"translateY(100%)",pointerEvents:tr?"auto":"none",visibility:tr?"visible":"hidden",opacity:tr?1:0,css:{"@media (hover: none)":{visibility:"visible",opacity:1,transform:"none",pointerEvents:"auto"}},children:f.jsxs(F.Flex,{w:"100%",px:5,position:"absolute",bottom:"calc(20px + env(safe-area-inset-bottom, 0px))",flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:"24px",css:{"@media (min-width: 1024px)":{"& > :first-of-type":{maxWidth:"50vw"}}},children:[f.jsx(Bm,{background:U,border:z?ae:"gray.300",children:f.jsxs(F.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[$e?f.jsx(Mm,{edgeId:p,onClose:be}):Ge?f.jsx($m,{ids:d,onClose:ge}):null,f.jsxs("div",{style:{display:$e||Ge?"none":"contents"},children:[f.jsx(Oe,{label:R?"Unpin":"Pin",children:f.jsx(Ce,{"aria-label":"Pin",icon:f.jsx(F.Icon,{as:R?K.PiPushPinFill:K.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:R?t:Q,onClick:()=>{M(!R),N(!1)}})}),f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:se}),f.jsx(Oe,{label:"Zoom Out",children:f.jsx(Ce,{"aria-label":"Zoom out",rememberAction:!1,icon:f.jsx(F.Icon,{as:K.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:Y,onClick:()=>G("decrease")})}),f.jsx(Oe,{label:"Zoom In",children:f.jsx(Ce,{"aria-label":"Zoom in",rememberAction:!1,icon:f.jsx(F.Icon,{as:K.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:Y,onClick:()=>G("increase")})}),f.jsx(Oe,{label:"Reset Zoom",children:f.jsx(Ce,{"aria-label":"Reset zoom",rememberAction:!1,icon:f.jsx(F.Icon,{as:K.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:Y,onClick:()=>G("reset")})}),fe&&f.jsx(p0,{divider:f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:se,role:"separator","aria-orientation":"vertical"})}),f.jsxs("span",{style:{display:fe?"none":"contents"},children:[P.edgeHandles!==!1&&f.jsx(Oe,{label:C?"Draw Mode On (V)":"Draw Mode Off (V)",children:f.jsx(Ce,{"aria-label":"Toggle draw mode","aria-keyshortcuts":"V","aria-pressed":C,icon:f.jsx(F.Icon,{as:K.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:C?t:Q,onClick:()=>S(!C)})}),f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:se}),f.jsx(Oe,{label:m?"Zoom Mode (z)":"Pan Mode (z)",children:f.jsx(Ce,{"aria-label":"Toggle zoom mode",icon:f.jsx(F.Icon,{as:m?K.PiMagnifyingGlassPlus:K.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:m?t:Q,onClick:()=>g(!m)})}),f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:se}),f.jsx(Oe,{label:b?"Multi-Select On (m)":"Multi-Select Off (m)",children:f.jsx(Ce,{"aria-label":"Toggle multi-select",icon:f.jsx(F.Icon,{as:K.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:b?t:Q,onClick:()=>w(!b)})}),f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:se}),f.jsx(Oe,{label:v?"Drag Mode On (d)":"Drag Mode Off (d)",children:f.jsx(Ce,{"aria-label":"Toggle drag mode",icon:f.jsx(F.Icon,{as:K.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:v?t:Q,onClick:()=>x(!v)})}),P.bottomBarExtra&&f.jsxs(f.Fragment,{children:[f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:se,role:"separator","aria-orientation":"vertical"}),P.bottomBarExtra]}),f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:se,role:"separator","aria-orientation":"vertical"}),f.jsx(fm,{}),f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:se,role:"separator","aria-orientation":"vertical"}),f.jsx(Uu,{label:"Collapse all",hideLabel:!0,checked:u,icon:f.jsx(F.Icon,{as:K.PiArrowsInLineVertical,boxSize:5}),onChange:l}),c!=="properties"&&f.jsxs(f.Fragment,{children:[f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:se}),f.jsx(Oe,{label:k?"Array Mode [ ]":"Set Mode { }",children:f.jsx(Ce,{"aria-label":"Toggle array mode",icon:f.jsx(F.Icon,{as:k?K.PiBracketsSquare:K.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:k?t:Q,onClick:()=>{var Me;const ye=!k;I(ye),(Me=E.onArrayModeChange)==null||Me.call(E,ye)}})})]}),f.jsx(nl,{}),!A&&f.jsxs("span",{style:{display:o?"contents":"none"},children:[f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:se}),f.jsx(ut,{label:"Graph theme",colors:Tn,value:t,includeTransparent:!1,onPick:ye=>{var Me;r(ye),(Me=E.onThemeColorChange)==null||Me.call(E,ye)}})]}),!A&&f.jsxs(f.Fragment,{children:[f.jsx(F.Icon,{as:K.PiLineVerticalThin,boxSize:5,color:se,role:"separator","aria-orientation":"vertical"}),f.jsx(ut,{label:"Graph edge color",colors:Tn,value:n||(z?"gray.500":Pt),onPick:i,onReset:()=>i("")}),f.jsx(F.Icon,{as:K.PiLineVerticalThin,boxSize:5,color:se,role:"separator","aria-orientation":"vertical"})]}),f.jsx(pm,{})]}),f.jsx(F.Icon,{mx:-1,as:K.PiLineVerticalThin,boxSize:5,color:se}),f.jsx(Oe,{label:fe?"Expand toolbar":"Collapse toolbar",children:f.jsx(Ce,{"aria-label":"Toggle toolbar collapse",rememberAction:!1,icon:f.jsx(F.Icon,{as:fe?K.PiCaretRight:K.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:Q,onClick:()=>{var ye;P.bottomBarCollapsed===void 0&&me(!fe),s(fe),(ye=E.onBottomBarCollapsedChange)==null||ye.call(E,!fe)}})}),!fe&&f.jsx(Fm,{})]})]})}),!Ye&&f.jsxs(F.Box,{position:"relative",ml:"auto",flexShrink:0,children:[f.jsx(F.Box,{"data-flow-direction-control":"",bg:U,borderRadius:"30px",h:50,css:Kr($,V),px:3,cursor:"pointer",onClick:()=>N(!W),children:f.jsxs(F.Flex,{align:"center",h:"100%",children:[f.jsx(Oe,{label:"Flow Direction",children:f.jsx(Ce,{"aria-label":"Direction",onClick:ye=>{ye.stopPropagation(),N(!W)},icon:f.jsx(F.Icon,{as:K.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:Q})}),f.jsx(F.Text,{fontSize:"xs",textTransform:"uppercase !important",color:z?"whiteAlpha.600":"blackAlpha.500",ml:1,children:a.toUpperCase()})]})}),W&&f.jsx(F.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:f.jsxs(F.Box,{bg:U,borderRadius:"30px",p:2,minW:"180px",css:Kr($,V),children:[F0.map(ye=>f.jsxs(F.Flex,{align:"center",gap:3,px:3,py:2,css:Pn,cursor:"pointer",_hover:{bg:z?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Me;(Me=E.onDirectionChange)==null||Me.call(E,ye.value),N(!1)},children:[f.jsx(F.Icon,{as:ye.icon,boxSize:5,color:Y}),f.jsx(F.Text,{fontSize:"sm",color:Y,flex:1,whiteSpace:"nowrap",children:ye.label}),a===ye.value&&f.jsx(F.Icon,{as:K.PiCheck,boxSize:4,color:pe})]},ye.value)),f.jsxs(F.Flex,{align:"center",gap:3,px:3,py:2,css:Pn,cursor:"pointer",_hover:{bg:z?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var ye;(ye=E.onDirectionChange)==null||ye.call(E,"C"),N(!1)},children:[f.jsx(F.Icon,{as:K.PiAlignCenterHorizontal,boxSize:5,color:Y}),f.jsx(F.Text,{fontSize:"sm",color:Y,flex:1,whiteSpace:"nowrap",children:"Center"}),a==="C"&&f.jsx(F.Icon,{as:K.PiCheck,boxSize:4,color:pe})]})]})})]})]})})]})};Dm.displayName="BottomBar";const Vm=_.memo(Dm);function B0({checked:e,onChange:t,disabled:r,label:n="Connected nodes"}){return f.jsx(Uu,{hideLabel:!0,label:n,helper:`${n}: isolate node and its connections`,checked:e,onChange:t,disabled:r,icon:f.jsx(F.Icon,{as:K.PiGraph,boxSize:5})})}const Zl={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function Wm(e,t){const r=new Map,n=(o,s)=>{if(Object.is(o,s))return!0;if(!o||!s||typeof o!="object"||typeof s!="object"||Array.isArray(o)!==Array.isArray(s))return!1;const a=Object.keys(o);return a.length===Object.keys(s).length&&a.every(c=>Object.prototype.hasOwnProperty.call(s,c)&&n(o[c],s[c]))},i=(o,s,a)=>{if(o===s)return!0;if(!o||!s||typeof o!="object"||typeof s!="object"||Array.isArray(o)!==Array.isArray(s))return!1;const c=new Set([...Object.keys(o),...Object.keys(s)]);for(const u of c)if(!n(o[u],s[u])){if(Object.prototype.hasOwnProperty.call(Zl,u)){if(typeof s[u]!="string"||!s[u])return!1;r.set(a,{...r.get(a),[Zl[u]]:s[u]})}else if(u.startsWith("$")&&u!=="$"||!i(o[u],s[u],u==="$"?a:`${a}.${u}`))return!1}return!0};if(i(e,t,"root"))return r}function z0(e,t){return Wm(e,t)!==void 0}function D0(e,t,r){if(e===t)return r;const n=Wm(e,t);if(!n)return;const i=new Set(r.nodes.map(o=>o.data.id));for(const o of n.keys())if(!i.has(o)||!ke(t,o))return;return{edges:r.edges,nodes:r.nodes.map(o=>{const s=n.get(o.data.id),a=ke(e,o.data.id),c=ke(t,o.data.id);return!s&&a===c?o:{...o,data:{...o.data,...typeof o.data.code=="string"?{code:JSON.stringify(c,null,2)}:{},...s?{viewProps:{...o.data.viewProps,...s},config:{...o.data.config,...s}}:{}}}})}}function Bu(e){return e.kind==="literal"?e.value:e.kind==="union"?Bu(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,t])=>!t.optional).map(([t,r])=>[t,Bu(r.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function Gm(e,t,r){var g,b,w;const n=(g=ke(e,t))==null?void 0:g.$form,i=n==null?void 0:n.$create;if(!i)return;const o=i.$address.split(".");if(o.shift()!=="root"||!o.length||o.some(v=>!/^[A-Za-z0-9_-]+$/.test(v)||["__proto__","constructor","prototype"].includes(v)))throw new Error("Invalid form creation address.");if(!r||!Object.prototype.hasOwnProperty.call(r,i.$type))throw new Error(`Load form type: ${i.$type}`);const s=o.pop(),a=["root",...o].join("."),c=Tt(e,a,r),u=(b=c==null?void 0:c.type.properties[s])==null?void 0:b.type;if((u==null?void 0:u.kind)!=="array"||u.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const l=r[i.$type],d=i.$defaults??{};for(const[v,x]of Object.entries(d))if(!Object.prototype.hasOwnProperty.call(l.properties,v)||Rr(l.properties[v].type,x,!l.properties[v].optional))throw new Error(`Invalid creation default: ${v}`);const h={...Bu(l),...structuredClone(d)};((w=l.properties.id)==null?void 0:w.type.kind)==="string"&&(h.id=Hu());let p=e;const y=ke(e,i.$address);if(y===void 0)p=xr(e,a,v=>({...v,[s]:[]}));else if(!Array.isArray(y)&&!Array.isArray(y==null?void 0:y.$))throw new Error("Form creation destination is not an array.");const m=Zu(p,i.$address,{...h,$label:i.$label??i.$type,...i.$icon?{$icon:i.$icon}:{},$form:{$type:i.$type,$create:i}});return{address:m.address,json:Yu(m.json,t,{target:m.address,label:i.$edgeLabel})}}function V0(e,t){const r=i=>e&&typeof e=="object"&&i in e;let n=1;for(;r(`${t}_${n}`);)n++;return`${t}_${n}`}function Um(e,t,r,n,i){const o=(a,c)=>{a!==e&&(e=a,n==null||n(a,c))},s=a=>{var u;const c=(u=t.find(l=>l.data.id===a))==null?void 0:u.data;return c&&{source:c.source,target:c.target,isInverted:c.isInverted,sourceProperty:c.sourceProperty,targetProperty:c.targetProperty,connection:c.connection}};return{...r,onFormChange:a=>{const c=ke(e,a.nodeAddress);if(!c||a.nodeId!==void 0&&c.id!==a.nodeId)throw new Error("This form node has moved. Retry the edit.");o(Bn(e,a,r.onFormChange),{type:"form",address:a.address,value:a.value})},onNodeLabelChange:(a,c)=>{var u;(u=r.onNodeLabelChange)==null||u.call(r,a,c),o(hr(e,a,"$label",c),{type:"nodeLabel",address:a,key:"$label",value:c})},onNodeContentChange:(a,c)=>{var u;(u=r.onNodeContentChange)==null||u.call(r,a,c),o(hr(e,a,"$content",c),{type:"nodeContent",address:a,key:"$content",value:c})},onNodeTypeViewChange:(a,c)=>{var u;c!==void 0&&!nn.includes(c)||((u=r.onNodeTypeViewChange)==null||u.call(r,a,c),o(hr(e,a,"$view",c),{type:"nodeStyle",address:a,key:"$view",value:c}))},onNodeColorChange:(a,c,u)=>{var d;(d=r.onNodeColorChange)==null||d.call(r,a,c,u);const l=c==="bg"?"$bgColor":"$textColor";o(hr(e,a,l,u),{type:"nodeColor",address:a,key:l,value:u})},onNodeBorderColorChange:(a,c)=>{var u;(u=r.onNodeBorderColorChange)==null||u.call(r,a,c),o(hr(e,a,"$borderColor",c),{type:"nodeColor",address:a,key:"$borderColor",value:c})},onNodeBorderStyleChange:(a,c)=>{var u;(u=r.onNodeBorderStyleChange)==null||u.call(r,a,c),o(hr(e,a,"$borderStyle",c),{type:"nodeStyle",address:a,key:"$borderStyle",value:c})},onNodeBorderWidthChange:(a,c)=>{var u;c!==void 0&&(!Number.isFinite(c)||c<0)||((u=r.onNodeBorderWidthChange)==null||u.call(r,a,c),o(hr(e,a,"$borderWidth",c),{type:"nodeStyle",address:a,key:"$borderWidth",value:c}))},onNodeBorderRadiusChange:(a,c)=>{var u;c!==void 0&&(!Number.isFinite(c)||c<0)||((u=r.onNodeBorderRadiusChange)==null||u.call(r,a,c),o(hr(e,a,"$borderRadius",c),{type:"nodeStyle",address:a,key:"$borderRadius",value:c}))},onNodeIconChange:(a,c)=>{var u;(u=r.onNodeIconChange)==null||u.call(r,a,c),o(hr(e,a,"$icon",c),{type:"nodeIcon",address:a,key:"$icon",value:c})},onNodeOutlineChange:(a,c)=>{var u;(u=r.onNodeOutlineChange)==null||u.call(r,a,c),o(hr(e,a,"$outline",c),{type:"nodeOutline",address:a,key:"$outline",value:c})},onNodeAnimationChange:(a,c)=>{var u;(u=r.onNodeAnimationChange)==null||u.call(r,a,c),o(hr(e,a,"$isNodeAnimated",c),{type:"nodeAnimation",address:a,key:"$isNodeAnimated",value:c})},onNodeAnimationVariantChange:(a,c)=>{var u;c!=="traveling"&&c!=="pulse"||((u=r.onNodeAnimationVariantChange)==null||u.call(r,a,c),o(hr(e,a,"$nodeAnimationVariant",c),{type:"nodeAnimation",address:a,key:"$nodeAnimationVariant",value:c}))},onNodeCollapse:(a,c)=>{var u;(u=r.onNodeCollapse)==null||u.call(r,a,c),o(vm(e,a,c),{type:"nodeCollapse",address:a,key:"$collapsed",value:c})},onNodeCreate:a=>{var y,m;const c=a.sourceNodeId&&Gm(e,a.sourceNodeId,i);if(c){(y=r.onNodeCreate)==null||y.call(r,a),o(c.json,{type:"nodeCreate",address:c.address,value:"form"});return}(m=r.onNodeCreate)==null||m.call(r,a);const u=a.sourceNodeId||"root",l=ke(e,u),d=V0(l,a.isArrayMode?"list":"node"),h=a.isArrayMode?{$bgColor:"gray.500",$:[]}:{$bgColor:"gray.500"},p=Zu(e,u,h,d);o(p.json,{type:"nodeCreate",address:p.address,value:a.isArrayMode?"array":"set"})},onNodeDelete:(a,c)=>{var u;(u=r.onNodeDelete)==null||u.call(r,a,c),o(wm(e,a),{type:"nodeDelete",address:a})},onEdgeCreate:(a,c,u)=>{var d;(d=r.onEdgeCreate)==null||d.call(r,a,c,u);const l=u&&(u.sourceProperty!==void 0||u.targetProperty!==void 0)?{...u,target:c}:void 0;o(l?Yu(e,a,l):Cm(e,a,c),{type:"edgeCreate",address:a,key:l?"$connections":"$target",value:l??c})},onEdgeLabelChange:(a,c)=>{var l;(l=r.onEdgeLabelChange)==null||l.call(r,a,c);const u=s(a);u&&o(Ur(e,u,"$sourceLabel",c),{type:"edgeLabel",edge:u,key:u.connection?"$connections":"$sourceLabel",value:c})},onEdgeStyleChange:(a,c)=>{var l;(l=r.onEdgeStyleChange)==null||l.call(r,a,c);const u=s(a);u&&o(xm(e,u,c),{type:"edgeStyle",edge:u,value:c})},onEdgeAnimationVariantChange:(a,c)=>{var l;if(c!=="dashed"&&c!=="traveling")return;(l=r.onEdgeAnimationVariantChange)==null||l.call(r,a,c);const u=s(a);u&&o(Ur(e,u,"$edgeAnimationVariant",c),{type:"edgeStyle",edge:u,key:u.connection?"$connections":"$edgeAnimationVariant",value:c})},onEdgeTypeChange:(a,c)=>{var l;(l=r.onEdgeTypeChange)==null||l.call(r,a,c);const u=s(a);u&&o(Ur(e,u,"$edgeType",c),{type:"edgeStyle",edge:u,key:u.connection?"$connections":"$edgeType",value:c})},onEdgeIconChange:(a,c)=>{var l;(l=r.onEdgeIconChange)==null||l.call(r,a,c);const u=s(a);u&&o(Ur(e,u,"$edgeIcon",c||void 0),{type:"edgeStyle",edge:u,key:u.connection?"$connections":"$edgeIcon",value:c})},onEdgeColorChange:(a,c)=>{var l;(l=r.onEdgeColorChange)==null||l.call(r,a,c);const u=s(a);u&&o(Ur(e,u,"$edgeColor",c),{type:"edgeColor",edge:u,key:u.connection?"$connections":"$edgeColor",value:c})},onEdgeDelete:(a,c)=>{var d;(d=r.onEdgeDelete)==null||d.call(r,a,c);const u=s(a);if(!u)return;const l=Sm(e,u);l.removed&&o(l.json,{type:"edgeDelete",edge:u,key:u.connection?"$connections":"$target"})}}}const W0=".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 f.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 U0=".flow-sdk-edge-reveal{animation:flow-sdk-edge-reveal var(--flow-edge-reveal-duration,600ms) linear both;animation-play-state:var(--flow-edge-reveal-state,running)}.flow-sdk-edge-reveal-end{animation:flow-sdk-edge-reveal-end var(--flow-edge-reveal-duration,600ms) steps(1,end) both;animation-play-state:var(--flow-edge-reveal-state,running)}@keyframes flow-sdk-edge-reveal{from{stroke-dashoffset:var(--flow-edge-reveal-from,100)}to{stroke-dashoffset:0}}@keyframes flow-sdk-edge-reveal-end{from{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.flow-sdk-edge-reveal{animation:none;stroke-dashoffset:0}.flow-sdk-edge-reveal-end{animation:none;opacity:1}}";function H0({path:e,width:t,reversed:r,children:n,onComplete:i}){const o=`flow-edge-reveal-${_.useId().replace(/:/g,"")}`,s=_.useRef(null),[a,c]=_.useState({x:0,y:0,width:1,height:1});return _.useEffect(()=>{const u=matchMedia("(prefers-reduced-motion: reduce)"),l=()=>{u.matches&&(i==null||i())};return l(),u.addEventListener("change",l),()=>u.removeEventListener("change",l)},[i]),_.useLayoutEffect(()=>{var l;const u=(l=s.current)==null?void 0:l.getBBox();u&&c({x:u.x-t,y:u.y-t,width:u.width+t*2,height:u.height+t*2})},[e,t]),f.jsxs(f.Fragment,{children:[f.jsx("defs",{children:f.jsx("mask",{id:o,maskUnits:"userSpaceOnUse",...a,children:f.jsx("path",{ref:s,className:"flow-sdk-edge-reveal",onAnimationEnd:u=>{u.animationName==="flow-sdk-edge-reveal"&&(i==null||i())},"data-reveal-direction":r?"reverse":"forward",style:{"--flow-edge-reveal-from":r?-100:100},d:e,fill:"none",stroke:"white",strokeWidth:t,strokeLinecap:"butt",strokeLinejoin:"round",pathLength:100,strokeDasharray:"100 100"})})}),f.jsx("g",{mask:`url(#${o})`,children:n})]})}const K0=".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 Hm({x:e=0,y:t=0,width:r,height:n,radius:i,color:o,strokeWidth:s=8,path:a,variant:c="traveling"}){const u=_.useId(),l=`flow-sdk-node-border-animation${c==="pulse"?" flow-sdk-node-border-pulse":""}`;if(c==="pulse"){const d=a?"path":"rect",h=a?{d:a}:{x:e,y:t,width:Math.max(0,r),height:Math.max(0,n),rx:Math.max(0,Math.min(i,r/2,n/2))},p=s+36,y={x:e-p,y:t-p,width:r+2*p,height:n+2*p};return f.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[f.jsx("defs",{children:f.jsxs("mask",{id:u,maskUnits:"userSpaceOnUse",...y,style:{maskType:"luminance"},children:[f.jsx("rect",{...y,fill:"white"}),f.jsx(d,{...h,fill:"black",stroke:"black",strokeWidth:s,strokeLinejoin:"round"})]})}),f.jsx(d,{...h,className:l,"data-animation-variant":c,fill:"none",stroke:`color-mix(in srgb, ${o} 30%, transparent)`,strokeLinejoin:"round",mask:`url(#${u})`,style:{"--flow-pulse-rest-width":`${s+16}px`,"--flow-pulse-expanded-width":`${s+36}px`}})]})}return a?f.jsx("path",{className:l,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",d:a,fill:"none",stroke:o,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"}):f.jsx("rect",{className:l,"data-animation-variant":c,"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(i,r/2,n/2)),fill:"none",stroke:o,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const J0=e=>{const n=1/(Math.cbrt(e)*.8);let i=Math.round(650*n),o=Math.round(350*n);return i=Math.max(40,Math.min(450,i)),o=Math.max(30,Math.min(300,o)),{edgeSep:i,rankSep:o}};function Yl(e,t,r){const n=new Set([e]),i=[e];for(;i.length;){const o=i.pop();for(const s of t)(s.parent===o||s.id.startsWith(`${o}.`)||r.some(c=>(c.inverted?c.target:c.source)===o&&(c.inverted?c.source:c.target)===s.id))&&!n.has(s.id)&&(n.add(s.id),i.push(s.id))}return n}function Z0(e,t,r){const n=r==="downward"||r==="upward",i=new Map;for(const s of e){if(s.source===s.target||s.sourceProperty||s.targetProperty)continue;const a=t(s.source),c=t(s.target);if(!a||!c)continue;const u=n?c.y-a.y:c.x-a.x,l=Math.abs(u)-(n?a.h+c.h:a.w+c.w)/2;if(l<=320)continue;const d=JSON.stringify([s.source,Math.sign(u)]),h=i.get(d)??[];h.push({edge:s,gap:l,cross:n?c.x-a.x:c.y-a.y}),i.set(d,h)}const o=new Map;for(const s of i.values()){if(new Set(s.map(({edge:c})=>c.target)).size<2)continue;const a=new Map;for(const{edge:c}of s)a.set(c.target,(a.get(c.target)??0)+1);for(const c of[-1,0,1]){const u=s.filter(({cross:d})=>Math.sign(d)===c);u.sort((d,h)=>Math.abs(h.cross)-Math.abs(d.cross)||d.edge.id.localeCompare(h.edge.id));const l=Math.min(...u.map(({gap:d})=>d));u.forEach(({edge:d,gap:h,cross:p},y)=>{const m=u.length===1?l/2:120+(l-280)*y/(u.length-1),g=u.find(b=>Math.abs(b.cross)<Math.abs(p));o.set(d.id,{turn:m/h,labelAtTarget:a.get(d.target)===1,labelFraction:p?(p+((g==null?void 0:g.cross)??0))/(2*p):.5})})}}return o}const bt=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}),Y0=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function bo(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,Xl=(e,t)=>e.x>=t.x1&&e.x<=t.x2&&e.y>=t.y1&&e.y<=t.y2,wr=e=>(Math.round(e*10)/10).toString(),Qe=e=>`${wr(e.x)} ${wr(e.y)}`,Q0=e=>e>0?1:e<0?-1:0,Ql=(e,t)=>e>0?Math.max(e-t,0):Math.min(e+t,0);function ew(e,t,r,n,i=10){const o=t.x-e.x,s=t.y-e.y,a=Ql(o,(e.w+t.w)/2),c=Ql(s,(e.h+t.h)/2),u=r==="downward"||r==="upward",l=u?c:a,d=u?s:o,h=Q0(d),p=n*l,y=w=>Math.abs(w)<i||Math.abs(w)>=Math.abs(l),m=y(p)||y(Math.abs(l)-Math.abs(p));let g;if(m)if(u)if(Math.abs(d)<=e.h/2){const w=(e.x+t.x)/2;g=[w,e.y,w,t.y]}else if(Math.abs(o)<=t.w/2){const w=(e.y+t.y)/2;g=[e.x,w,t.x,w]}else g=[e.x,t.y];else if(Math.abs(d)<=e.w/2){const w=(e.y+t.y)/2;g=[e.x,w,t.x,w]}else if(Math.abs(s)<=t.h/2){const w=(e.x+t.x)/2;g=[w,e.y,w,t.y]}else g=[t.x,e.y];else if(u){const w=e.y+p+e.h/2*h;g=[e.x,w,t.x,w]}else{const w=e.x+p+e.w/2*h;g=[w,e.y,w,t.y]}const b=[{x:e.x,y:e.y}];for(let w=0;w<g.length;w+=2)b.push({x:g[w],y:g[w+1]});return b.push({x:t.x,y:t.y}),b}function rw(e,t,r){const n=t.x-e.x,i=t.y-e.y,o=n>0?(r.x2-e.x)/n:n<0?(r.x1-e.x)/n:1/0,s=i>0?(r.y2-e.y)/i:i<0?(r.y1-e.y)/i:1/0,a=Math.min(o,s);return!Number.isFinite(a)||a>=1||a<0?null:{x:e.x+n*a,y:e.y+i*a}}function kt(e,t,r){var s;if(!((s=r.outline)!=null&&s.length))return rw(e,t,bt(r));const n=t.x-e.x,i=t.y-e.y;let o=1/0;return r.outline.forEach((a,c,u)=>{const l=u[(c+1)%u.length],d=l.x-a.x,h=l.y-a.y,p=n*h-i*d;if(Math.abs(p)<1e-9)return;const y=a.x-e.x,m=a.y-e.y,g=(y*h-m*d)/p,b=(y*i-m*n)/p;g>=0&&g<1&&b>=-1e-9&&b<=1+1e-9&&(o=Math.min(o,g))}),Number.isFinite(o)?{x:e.x+n*o,y:e.y+i*o}:null}function Km(e,t,r=.5){const n=Number.isFinite(r)?Math.max(0,Math.min(1,r)):.5,i=t==="top"||t==="bottom",o=t==="top"||t==="left"?-1:1,s={x:i?e.x-e.w/2+e.w*n:e.x,y:i?e.y:e.y-e.h/2+e.h*n},a=Math.max(e.w,e.h)*2+1;return{...kt(s,{x:s.x+(i?0:o*a),y:s.y+(i?o*a:0)},e)??{x:i?s.x:e.x+o*e.w/2,y:i?e.y+o*e.h/2:s.y},side:t}}function wt(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 tw(e,t,r,n){const i=wt(e,r.srcDist),o=wt(t,r.tgtDist);if(n==="straight")return Zm(i,o,r);const s=Math.max(80,Math.min(300,Math.hypot(o.x-i.x,o.y-i.y)/3)),a=e.side==="bottom"&&t.side==="top"?o.y-i.y:e.side==="top"&&t.side==="bottom"?i.y-o.y:e.side==="right"&&t.side==="left"?o.x-i.x:e.side==="left"&&t.side==="right"?i.x-o.x:void 0,c=a!==void 0&&a>0?Math.min(s,a/2):s,u=wt({...i,side:e.side},c),l=wt({...o,side:t.side},c),d=r.arrowAt==="source"?ar(i,u,r.arrowGap):i,h=r.arrowAt==="target"?ar(o,l,r.arrowGap):o,p=r.arrowAt==="source"?_r(i,u,r.arrowSize,r.headShape):r.arrowAt==="target"?_r(o,l,r.arrowSize,r.headShape):void 0;if(n==="bezier")return{d:`M${Qe(d)} C${Qe(u)} ${Qe(l)} ${Qe(h)}`,arrow:p,label:{x:(d.x+3*u.x+3*l.x+h.x)/8,y:(d.y+3*u.y+3*l.y+h.y)/8,angle:0}};const y=e.side==="left"||e.side==="right",m=t.side==="left"||t.side==="right";let g;if(y!==m){const w=y?{x:l.x,y:u.y}:{x:u.x,y:l.y},v=(w.x-u.x)*(u.x-i.x)+(w.y-u.y)*(u.y-i.y)>=0,x=(w.x-l.x)*(l.x-o.x)+(w.y-l.y)*(l.y-o.y)>=0;g=[v&&x?w:y?{x:u.x,y:l.y}:{x:l.x,y:u.y}]}else if(a!==void 0&&a<=0)if(y){const w=(u.y+l.y)/2;g=[{x:u.x,y:w},{x:l.x,y:w}]}else{const w=(u.x+l.x)/2;g=[{x:w,y:u.y},{x:w,y:l.y}]}else if(y){const w=e.side===t.side?e.side==="right"?Math.max(u.x,l.x):Math.min(u.x,l.x):(u.x+l.x)/2;g=[{x:w,y:u.y},{x:w,y:l.y}]}else{const w=e.side===t.side?e.side==="bottom"?Math.max(u.y,l.y):Math.min(u.y,l.y):(u.y+l.y)/2;g=[{x:u.x,y:w},{x:l.x,y:w}]}const b=[u,...g,l].filter((w,v,x)=>v===0||w.x!==x[v-1].x||w.y!==x[v-1].y);return zn(d,b,h,p,n==="orthogonal"?0:r.radius)}function ar(e,t,r){const n=e.x-t.x,i=e.y-t.y,o=Math.hypot(n,i);if(!o)return e;let s=(o-r)/o;return s<0&&(s=1e-5),{x:t.x+s*n,y:t.y+s*i}}function _r(e,t,r,n="triangle"){const i=e.x-t.x,o=e.y-t.y,s=Math.hypot(i,o)||1,a=i/s,c=o/s,u=(n==="square"?.15:.3)*r,l=.15*r,d=e.x-a*u,h=e.y-c*u;if(n==="square")return`M${Qe(e)} L${wr(e.x-c*l)} ${wr(e.y+a*l)} L${wr(d-c*l)} ${wr(h+a*l)} L${wr(d+c*l)} ${wr(h-a*l)} L${wr(e.x+c*l)} ${wr(e.y-a*l)} Z`;const p=[e,{x:d-c*l,y:h+a*l},{x:d+c*l,y:h-a*l}];return p.map((m,g)=>{const b=p[(g+2)%3],w=p[(g+1)%3],v=Math.hypot(b.x-m.x,b.y-m.y),x=Math.hypot(w.x-m.x,w.y-m.y),C={x:(b.x-m.x)/v,y:(b.y-m.y)/v},S={x:(w.x-m.x)/x,y:(w.y-m.y)/x},k=Math.max(-1,Math.min(1,C.x*S.x+C.y*S.y)),I=Math.sqrt((1-k)/(1+k)),R=Math.min(1/I,v/2,x/2);return{start:{x:m.x+C.x*R,y:m.y+C.y*R},end:{x:m.x+S.x*R,y:m.y+S.y*R},radius:R*I}}).map((m,g)=>`${g?"L":"M"}${Qe(m.start)} A${wr(m.radius)} ${wr(m.radius)} 0 0 1 ${Qe(m.end)}`).join(" ")+" Z"}function Gr(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 nw(e,t,r,n){const i={x:t.x-e.x,y:t.y-e.y},o={x:r.x-t.x,y:r.y-t.y},s=Math.hypot(i.x,i.y),a=Math.hypot(o.x,o.y),c=i.x*o.y-i.y*o.x;if(s<1e-6||a<1e-6||Math.abs(c)<1e-6)return{p1:t,b:t,p2:t,r:0};const u=Math.min(n,s/2,a/2);return{p1:{x:t.x-i.x/s*u,y:t.y-i.y/s*u},b:t,p2:{x:t.x+o.x/a*u,y:t.y+o.y/a*u},r:u}}function Jm(e,t,r,n){let i=-1,o=null;for(let y=0;y<e.length-1;y++){const m=kt(e[y],e[y+1],t);if(m){i=y,o=m;break}}let s=-1,a=null;for(let y=e.length-1;y>0;y--){const m=kt(e[y],e[y-1],r);if(m){s=y,a=m;break}}if(!o||!a||i>=s)return null;const c=e.slice(i+1,s),u=c[0]??a,l=c[c.length-1]??o;let d,h,p;if(n.arrowAt==="source"){const y=ar(o,u,n.srcDist);d=ar(o,u,n.srcDist+n.arrowGap),p=_r(y,u,n.arrowSize,n.headShape)}else d=ar(o,u,n.srcDist);if(n.arrowAt==="target"){const y=ar(a,l,n.tgtDist);h=ar(a,l,n.tgtDist+n.arrowGap),p=_r(y,l,n.arrowSize,n.headShape)}else h=ar(a,l,n.tgtDist);return zn(d,c,h,p,n.radius,n.labelTargetLength,n.labelFraction)}function zn(e,t,r,n,i,o,s){var h;const a=[e,...t,r],c=[];let u=`M${Qe(e)}`;for(let p=1;p<a.length-1;p++){const y=nw(a[p-1],a[p],a[p+1],i);c.push(y),y.r===0?u+=` L${Qe(y.b)}`:u+=` L${Qe(y.p1)} Q${Qe(y.b)} ${Qe(y.p2)}`}u+=` L${Qe(r)}`;let l;const d=t.length;if(d===0)l={x:(e.x+r.x)/2,y:(e.y+r.y)/2,angle:Gr(r.x-e.x,r.y-e.y)};else if(d%2===0){const p=t[d/2-1],y=t[d/2];l={x:(p.x+y.x)/2,y:(p.y+y.y)/2,angle:Gr(y.x-p.x,y.y-p.y)}}else{const p=c[(d-1)/2];if(p.r===0){const y=a[(d-1)/2+2];l={x:p.b.x,y:p.b.y,angle:Gr(y.x-p.b.x,y.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:Gr(p.p2.x-p.p1.x,p.p2.y-p.p1.y)}}if(o!==void 0){if(s!==void 0&&c.length===2){const g=c[0].p2,b=c[1].p1,w=Math.hypot(b.x-g.x,b.y-g.y),v=Math.min(.5,o/(2*w)),x=Math.max(v,Math.min(1-v,s));l={x:g.x+(b.x-g.x)*x,y:g.y+(b.y-g.y)*x,angle:Gr(b.x-g.x,b.y-g.y)}}const p=((h=c[c.length-1])==null?void 0:h.p2)??e,y=r.x-p.x,m=r.y-p.y;Math.hypot(y,m)>=o&&(l={x:(p.x+r.x)/2,y:(p.y+r.y)/2,angle:Gr(y,m)})}return{d:u,arrow:n,label:l}}function ed(e,t,r,n,i,o,s){const a=r==="leftward"?-1:1,c={x:e.x+a*(e.w/2+s.srcDist),y:n??e.y},u={x:t.x-a*(t.w/2+s.tgtDist),y:i??t.y},l=Math.max(80,s.arrowGap+s.arrowSize*.3),d=c.x+a*l,h=u.x-a*l;let p;if(a*(h-d)>=0){const b=c.x+(u.x-c.x)*o,w=Math.max(Math.min(d,h),Math.min(Math.max(d,h),b));p=[{x:w,y:c.y},{x:w,y:u.y}]}else{const b=Math.min(e.y-e.h/2,t.y-t.h/2)-l*(1+o);p=[{x:d,y:c.y},{x:d,y:b},{x:h,y:b},{x:h,y:u.y}]}const y=s.arrowAt==="source"?ar(c,p[0],s.arrowGap):c,m=s.arrowAt==="target"?ar(u,p[p.length-1],s.arrowGap):u,g=s.arrowAt==="source"?_r(c,p[0],s.arrowSize,s.headShape):s.arrowAt==="target"?_r(u,p[p.length-1],s.arrowSize,s.headShape):void 0;return zn(y,p,m,g,s.radius)}function rd(e,t,r,n,i){return Jm(ew(e,t,r,n),e,t,i)}function td(e,t,r,n,i,o){const s=n===void 0&&i===void 0&&(r==="downward"||r==="upward"),a=r==="leftward"||s&&r==="upward"?-1:1,c=(u,l,d)=>{const h={x:u.x,y:l??u.y},p=Math.max(u.w,u.h)*2+1,y=kt(h,{x:h.x+(s?0:d*p),y:h.y+(s?d*p:0)},u);return y?{x:y.x+(s?0:d*o),y:y.y+(s?d*o:0)}:s?{x:u.x,y:u.y+d*(u.h/2+o)}:{x:u.x+d*(u.w/2+o),y:l??u.y}};return{sourcePoint:c(e,n,a),targetPoint:c(t,i,-a)}}function ow(e,t,r,n){const i=r==="downward"||r==="upward",o=r==="leftward"||r==="upward"?-1:1,s=Math.max(100,Math.abs(i?t.y-e.y:t.x-e.x)/2),a={x:e.x+(i?0:o*s),y:e.y+(i?o*s:0)},c={x:t.x-(i?0:o*s),y:t.y-(i?o*s:0)},u=n.arrowAt==="source"?ar(e,a,n.arrowGap):e,l=n.arrowAt==="target"?ar(t,c,n.arrowGap):t;return{d:`M${Qe(u)} C${Qe(a)} ${Qe(c)} ${Qe(l)}`,arrow:n.arrowAt==="source"?_r(e,a,n.arrowSize,n.headShape):n.arrowAt==="target"?_r(t,c,n.arrowSize,n.headShape):void 0,label:{x:(u.x+3*a.x+3*c.x+l.x)/8,y:(u.y+3*a.y+3*c.y+l.y)/8,angle:Gr(l.x+c.x-a.x-u.x,l.y+c.y-a.y-u.y)}}}function Zm(e,t,r){const n=r.arrowAt==="source"?ar(e,t,r.arrowGap):e,i=r.arrowAt==="target"?ar(t,e,r.arrowGap):t,o=r.arrowAt==="source"?_r(e,t,r.arrowSize,r.headShape):r.arrowAt==="target"?_r(t,e,r.arrowSize,r.headShape):void 0;return zn(n,[],i,o,0)}function iw(e,t,r,n=-90,i=-60,o=350){const s=n*Math.PI/180,a=i*Math.PI/180,c=s-Math.PI/2,u=c-a/2,l=c+a/2,d=1.4*o*(t/3+1),h={x:e.x+Math.cos(u)*d,y:e.y+Math.sin(u)*d},p={x:e.x+Math.cos(l)*d,y:e.y+Math.sin(l)*d},y={x:e.x,y:e.y},m=kt(y,h,e),g=kt(y,p,e);if(!m||!g)return null;const b={x:(h.x+p.x)/2,y:(h.y+p.y)/2};let w=ar(m,h,r.srcDist),v=ar(g,p,r.tgtDist),x;if(r.arrowAt==="target"){const S=v;v=ar(g,p,r.tgtDist+r.arrowGap),x=_r(S,p,r.arrowSize,r.headShape)}else if(r.arrowAt==="source"){const S=w;w=ar(m,h,r.srcDist+r.arrowGap),x=_r(S,h,r.arrowSize,r.headShape)}return{d:`M${Qe(w)} Q${Qe(h)} ${Qe(b)} Q${Qe(p)} ${Qe(v)}`,arrow:x,label:{x:b.x,y:b.y,angle:Gr(p.x-h.x,p.y-h.y)}}}const yt=e=>Math.round(e*1e3)/1e3;function Ym(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 i=t.getBoundingClientRect();if(!i.width||!i.height)return;const o=t,s=typeof o.getScreenCTM=="function"?o.getScreenCTM():null,a=typeof o.getTotalLength=="function"?o.getTotalLength():0,c=o.points,u=(c==null?void 0:c.numberOfItems)||128,l=s&&a>0?Array.from({length:u},(d,h)=>{const p=c!=null&&c.numberOfItems?c.getItem(h):o.getPointAtLength(a*h/u);return{x:yt((s.a*p.x+s.c*p.y+s.e-r.left)/n),y:yt((s.b*p.x+s.d*p.y+s.f-r.top)/n)}}):void 0;return{left:yt((i.left-r.left)/n),top:yt((i.top-r.top)/n),width:t instanceof HTMLElement?t.offsetWidth:yt(i.width/n),height:t instanceof HTMLElement?t.offsetHeight:yt(i.height/n),radius:parseFloat(getComputedStyle(t).borderTopLeftRadius)||0,...l?{outline:l}:{}}}function en(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(i=>({x:r+i.x,y:n+i.y}))}:{}}}function aw(e,t,r,n,i){var l;const o=i!=="TB"&&i!=="BT",s=o?"top":"left",a=o?"bottom":"right",c=new Map;for(const d of n)for(const[h,p,y]of[[d.source,d.sourceProperty,d.target],[d.target,d.targetProperty,d.source]]){const m=t.get(y);if(p===void 0||!m||y===h)continue;const g=r.get(y),b=JSON.stringify([h,p]),w=c.get(b)??[];w.push(g?en(m,g):m),c.set(b,w)}const u=new Map(e);for(const[d,h]of e){const p=t.get(d);if(!p||!h.some(v=>v.placement==="config"))continue;const y=r.get(d),m=y?en(p,y):p,g={x:p.w/2,y:p.h/2,w:p.w,h:p.h},b=y?en(g,y):g,w=new Map;for(const v of h){if(v.placement!=="config")continue;const C=(c.get(JSON.stringify([d,v.property]))??[]).reduce((k,I)=>k+(o?I.y-m.y:I.x-m.x),0),S=((l=v.anchor)==null?void 0:l.side)===a?a:s;w.set(v,C<-.001?s:C>.001?a:S)}u.set(d,h.map(v=>{const x=w.get(v);if(!x)return v;const C=h.filter(I=>w.get(I)===x),S=(C.indexOf(v)+1)/(C.length+1),k=Km(b,x,S);return{...v,anchor:k,top:k.y,height:0}}))}return u}function nd(e,t,r){const n=new Set(t.map(a=>a.id));if(!n.has(e))return new Set;const i=new Set([e]);let o=!0;for(;o;){o=!1;for(const a of t)!i.has(a.id)&&(i.has(a.parent??"")||a.id.startsWith(`${e}.`))&&(i.add(a.id),o=!0)}const s=new Set(i);for(const a of r)i.has(a.source)&&n.has(a.target)&&s.add(a.target),i.has(a.target)&&n.has(a.source)&&s.add(a.source);return s}const Lr='"Helvetica Neue", Helvetica, sans-serif';let Ft;const Sn=new Map;function un(e,t){const r=`${t}|${e}`,n=Sn.get(r);if(n!==void 0)return n;Ft===void 0&&(Ft=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let i;return Ft?(Ft.font=t,i=Ft.measureText(e).width):i=e.length*(parseFloat(t)||16)*.55,Sn.size>5e3&&Sn.clear(),Sn.set(r,i),i}function sw(e,t,r){const n=[];for(const i of String(e).split(`
|
|
210
|
+
`)){const o=i.split(/\s+/).filter(Boolean);if(!o.length){n.push("");continue}let s="";for(const a of o){const c=s?`${s} ${a}`:a;!s||un(c,t)<=r?s=c:(n.push(s),s=a)}n.push(s)}return n}const od=e=>e.stopPropagation();function cw({id:e,rect:t,label:r,labelLayer:n,labelContent:i,style:o,onSelect:s,onCollapse:a,selected:c=!1}){const u=t.x2-t.x1,l=t.y2-t.y1,d=o.borderWidth,h=o.borderStyle==="dashed"?`${d*4} ${d*2}`:o.borderStyle==="dotted"?`${d} ${d}`:void 0,p=t.x1+u/2,y=o.labelPosition==="top"?t.y1+o.labelMargin-o.fontSize/2:o.labelPosition==="bottom"?t.y2-o.labelMargin+o.fontSize/2:t.y1+l/2,m=r?un(r,`bold ${o.fontSize}px ${Lr}`):0,g=o.fontSize/5,b=r||c&&a?f.jsxs("g",{className:"flow-sdk-container-label","data-node-id":e,children:[c&&a&&f.jsx("foreignObject",{x:p+m/2+g+8,y:y-24,width:48,height:48,"data-flow-content-toggle":"",style:{pointerEvents:"auto"},children:f.jsx(Oe,{label:"Show icon",children:f.jsx(Ce,{"aria-label":"Show icon",icon:f.jsx(K.PiCircleFill,{}),variant:"ghost",style:{width:48,height:48,color:o.textColor},onClick:w=>{w.stopPropagation(),a(e)}})})}),i?f.jsx("foreignObject",{x:p-m/2-g,y:y-o.fontSize/2-g,width:m+2*g,height:o.fontSize+2*g,style:{overflow:"visible"},onClick:od,children:i}):r&&f.jsxs(f.Fragment,{children:[f.jsx("rect",{x:p-m/2-g,y:y-o.fontSize/2-g,width:m+2*g,height:o.fontSize+2*g,fill:o.textColor==="transparent"?"transparent":o.labelBg}),f.jsx("text",{x:p,y,fill:o.textColor,fontSize:o.fontSize,fontWeight:"bold",fontFamily:Lr,style:{fontSize:o.fontSize,fontWeight:"bold",fontFamily:Lr},textAnchor:"middle",dominantBaseline:"central",children:r})]})]}):null;return f.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:od,onClick:w=>{w.stopPropagation(),s==null||s(e,{shiftKey:w.shiftKey,ctrlKey:w.ctrlKey,metaKey:w.metaKey,altKey:w.altKey})},children:[f.jsx("rect",{x:t.x1,y:t.y1,width:u,height:l,rx:o.borderRadius,ry:o.borderRadius,fill:o.bgColor,fillOpacity:o.bgOpacity,stroke:o.borderColor,strokeWidth:o.borderStyle==="double"?d/3:d,strokeDasharray:h}),o.borderStyle==="double"&&f.jsx("rect",{x:t.x1+d*2/3,y:t.y1+d*2/3,width:Math.max(0,u-d*4/3),height:Math.max(0,l-d*4/3),rx:Math.max(0,o.borderRadius-d*2/3),ry:Math.max(0,o.borderRadius-d*2/3),fill:"none",stroke:o.borderColor,strokeWidth:d/3}),o.animated&&d>0&&f.jsx(Hm,{variant:o.animationVariant,x:t.x1,y:t.y1,width:u,height:l,radius:o.borderRadius,color:o.animationColor||o.borderColor,strokeWidth:Math.max(8,d*1.6)}),n&&b?tn.createPortal(b,n):b]})}const uw=_.memo(cw),In=45,Xm=70,nt=15,Qm=50;function eb(e,t,r=In){const n=`${r}px ${Lr}`,i=e?sw(e,n,200*r/In):[],o=t?48+(i.length?12:0):0,s=o+Math.max(0,...i.map(u=>un(u,n))),a=Math.max(i.length*r,t?48:0),c=i.length||t?2*nt:0;return{lines:i,iconWidth:o,contentWidth:s,contentHeight:a,width:s+c,height:a+c}}const rn=6,rb=3,ol=.3,lw=8,il=Math.max(Math.pow(rn*13.37,.9),29)*rb-lw/ol,tb=rn*rb*2,jn=80,dw=2*jn+il*ol+100,fw=36+2*Math.max(80,tb+il*ol);function zu(e){return e.sourceProperty!==void 0||e.targetProperty!==void 0}function Du(e,t){return t==="auto"||(t==="properties"?zu(e):!zu(e))}function vt(e,t,r){return r!=="properties"||e!=="root"||t.some(n=>(n.source===e||n.target===e)&&zu(n))}function hw(e,t,r,n=!1,i){if(!n)return{nodes:e,edges:t};const o=e.filter(a=>vt(a.id,t,r)&&(!i||i.has(a.id))),s=new Set(o.map(a=>a.id));return{nodes:o,edges:t.filter(a=>Du(a,r)&&s.has(a.source)&&s.has(a.target))}}const pw=500,gw="32 18",yw=e=>e.stopPropagation();function mw({id:e,reveal:t,onRevealComplete:r,edgeData:n,validationIssue:i,edgeType:o="rounded-orthogonal",edgeRadius:s,customEdgeTypes:a,source:c,target:u,sourceProperty:l,targetProperty:d,sourceY:h,targetY:p,sourcePort:y,targetPort:m,propertyMode:g=!1,dir:b,turn:w,labelAtTarget:v,labelFraction:x,color:C,connectorColor:S,labelBg:k,labelLayer:I,label:R,dashed:M,animated:E,inverted:P,loopIndex:A=0,onSelect:j}){const q=n==null?void 0:n.icon,O=g?In:Xm,{lines:z,iconWidth:U,contentWidth:ae,contentHeight:Q}=_.useMemo(()=>eb(R,q,O),[R,q,O]),Y=_.useMemo(()=>{const G={srcDist:jn,tgtDist:jn,arrowGap:tb,arrowSize:il,headShape:g&&(P?h!==void 0||y:p!==void 0||m)?"square":"triangle",radius:s??(v?40:pw),arrowAt:P?"source":"target",labelTargetLength:v?ae+2*nt:void 0,labelFraction:v?x:void 0},le=h!==void 0||p!==void 0||!!y||!!m,ue=td(c,u,b,h,p,0),we=h===void 0&&p===void 0&&(b==="downward"||b==="upward"),ge=y??{...ue.sourcePoint,side:we?b==="upward"?"top":"bottom":b==="leftward"?"left":"right"},qe=m??{...ue.targetPoint,side:we?b==="upward"?"bottom":"top":b==="leftward"?"right":"left"},ee=c.x===u.x&&c.y===u.y,he=y||m?tw(ge,qe,{...G,srcDist:18,tgtDist:18},o):le?ed(c,u,b,h,p,w,{...G,srcDist:18,tgtDist:18,radius:s??Math.min(G.radius,40)}):ee?iw(c,A,{...G,srcDist:0,tgtDist:0}):rd(c,u,b,w,G);if(!he)return null;const be=td(c,u,b,h,p,le?18:jn);y&&(be.sourcePoint=wt(y,18)),m&&(be.targetPoint=wt(m,18));const Ee=Object.prototype.hasOwnProperty.call(a??{},o)?a==null?void 0:a[o]:void 0;if(Ee){const $e={rightward:"LR",leftward:"RL",downward:"TB",upward:"BT"};return Ee({edge:n??{id:e,source:"",target:""},source:{...c},target:{...u},...be,direction:$e[b],sourceY:h,targetY:p,inverted:!!P,defaultGeometry:he})??he}return ee||y||m?he:o==="straight"?le?Zm(be.sourcePoint,be.targetPoint,G):Jm([c,u],c,u,G):o==="bezier"?ow(be.sourcePoint,be.targetPoint,le?b==="leftward"?"leftward":"rightward":b,G):o==="orthogonal"?le?ed(c,u,b,h,p,w,{...G,srcDist:18,tgtDist:18,radius:0}):rd(c,u,b,w,{...G,radius:0}):he},[c,e,n,o,s,a,u,g,h,p,y,m,b,w,P,A,v,x,ae]);if(!Y)return null;const pe=(b==="rightward"||b==="leftward")&&!Object.prototype.hasOwnProperty.call(a??{},o)&&!(g&&(h!==void 0||p!==void 0||y||m)),se=pe?`translate(${Y.label.x} ${Y.label.y-Q/2-2*nt})`:`translate(${Y.label.x} ${Y.label.y}) rotate(${Y.label.angle}) translate(${b==="downward"||b==="upward"||v||Object.prototype.hasOwnProperty.call(a??{},o)?0:Qm} 0)`,$=i!=null&&i.startsWith("Unverified:")?"#b45309":"#dc2626",V=i?$:C,W=i?f.jsxs("g",{className:"flow-sdk-edge-validation",role:"img","aria-label":i,transform:`translate(${Y.label.x} ${Y.label.y-z.length*O/2-55})`,children:[f.jsx("title",{children:i}),f.jsx(Or,{name:"PiWarningCircleFill",svg:!0,size:48,x:-24,y:-24,color:$})]}):null,N=E&&(n==null?void 0:n.edgeAnimationVariant)==="traveling",ne=!N&&(M||E)?gw:void 0,me=E&&!N?`flow-sdk-edge-anim${P?" flow-sdk-edge-anim-rev":""}`:void 0;let fe=null;const J=t?{"--flow-edge-reveal-duration":`${t.durationMs??600}ms`,"--flow-edge-reveal-state":t.paused?"paused":"running"}:void 0;if(z.length||q){const G=ae,le=Q;fe=f.jsxs("g",{className:`flow-sdk-edge-label${t?" flow-sdk-edge-reveal-end":""}`,style:J,"data-label-transform":se,"data-label-horizontal":pe||void 0,"data-edge-id":e,"data-source-property":l,"data-target-property":d,transform:se,children:[f.jsx("rect",{x:-G/2-nt,y:-le/2-nt,width:G+2*nt,height:le+2*nt,fill:C==="transparent"?"transparent":k}),f.jsx("text",{fill:C,fontSize:O,style:{fontSize:O,fontFamily:Lr},fontFamily:Lr,textAnchor:"middle",dominantBaseline:"central",children:z.map((ue,we)=>f.jsx("tspan",{x:U/2,y:(we-(z.length-1)/2)*O,children:ue},we))}),q&&f.jsxs("g",{className:"flow-sdk-edge-icon",opacity:C==="transparent"?0:1,children:[f.jsx("title",{children:R?`Edge icon: ${R}`:"Edge icon"}),f.jsx("rect",{x:-G/2,y:-24,width:48,height:48,fill:"transparent"}),f.jsx(Or,{name:q,svg:!0,size:48,x:-G/2,y:-24,color:C})]})]})}const te=f.jsxs(f.Fragment,{children:[f.jsx("path",{d:Y.d,fill:"none",stroke:V,strokeWidth:rn,strokeOpacity:N?.35:void 0,strokeDasharray:ne,className:me}),N&&f.jsx(G0,{path:Y.d,color:V,width:rn*1.6,reversed:P})]});return f.jsxs("g",{className:"flow-sdk-edge",style:J,"data-edge-id":e,"data-source-property":l,"data-target-property":d,"data-validation":i?i.startsWith("Unverified:")?"unverified":"invalid":void 0,"aria-label":i,onPointerDown:yw,onClick:G=>{G.stopPropagation(),j==null||j(e)},children:[t?f.jsx(H0,{path:Y.d,width:rn*4,reversed:P,onComplete:()=>r==null?void 0:r(e),children:te}):te,Y.arrow&&f.jsx("path",{className:t?"flow-sdk-edge-reveal-end":void 0,d:Y.arrow,fill:i?$:S??V}),I&&fe?tn.createPortal(fe,I):fe,I&&W?tn.createPortal(W,I):W,f.jsx("path",{className:"flow-sdk-edge-hit",d:Y.d,fill:"none",stroke:"transparent"})]})}const id=_.memo(mw),ad=(e,t)=>e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top;function bw(e){const t=e.querySelector(".flow-sdk-labels"),r=t==null?void 0:t.getScreenCTM();if(!t||!r)return;const n=r.inverse(),i=(u,l=0)=>{const d=u.getBoundingClientRect(),h=new DOMPoint(d.left,d.top).matrixTransform(n),p=new DOMPoint(d.right,d.bottom).matrixTransform(n);return{left:h.x-l,right:p.x+l,top:h.y-l,bottom:p.y+l}},o=[...e.querySelectorAll(".flow-sdk-node, .flow-sdk-node button")].filter(u=>{const l=u.getBoundingClientRect(),d=getComputedStyle(u);return l.width>0&&l.height>0&&d.visibility!=="hidden"&&d.opacity!=="0"}).map(u=>i(u,24));for(const u of t.querySelectorAll(".flow-sdk-container-label"))o.push(i(u,12));const s=[...t.querySelectorAll(".flow-sdk-edge-label")];for(const u of s)u.setAttribute("transform",u.dataset.labelTransform??"");const a=new Map(s.map(u=>[u,i(u,8)])),c=new Map([...e.querySelectorAll(".flow-sdk-edge")].map(u=>[u.dataset.edgeId,u.querySelector("path")]));for(const u of s){const l=u.dataset.labelHorizontal==="true",d=a.get(u);a.delete(u);const h=k=>o.some(I=>ad(k,I))||[...a.values()].some(I=>ad(k,I));if(!l&&!h(d)){a.set(u,d);continue}const p=c.get(u.dataset.edgeId),y=u.querySelector("rect");if(!p||!y)continue;const m=y.getBBox(),g=p.getTotalLength();if(!Number.isFinite(g)||g<=0)continue;const b=(d.left+d.right)/2,w=(d.top+d.bottom)/2,v=Math.min(256,Math.max(16,Math.ceil(g/24))),x=Array.from({length:v+1},(k,I)=>p.getPointAtLength(g*I/v)),S=Array.from({length:v+1},(k,I)=>{const R=g*I/v,M=x[I],E=l?{x:M.x,y:M.y-m.height/2-15}:M,P=p.getPointAtLength(Math.max(0,R-2)),A=p.getPointAtLength(Math.min(g,R+2));let j=Math.atan2(A.y-P.y,A.x-P.x)*180/Math.PI;j>90&&(j-=180),j<-90&&(j+=180);const q=Math.abs(j)<1;l&&(j=0);const O=j*Math.PI/180,z=Math.abs(Math.cos(O))*m.width+Math.abs(Math.sin(O))*m.height,U=Math.abs(Math.sin(O))*m.width+Math.abs(Math.cos(O))*m.height;return{point:E,angle:j,straight:q,score:Math.hypot(E.x-b,E.y-w),bounds:{left:E.x-z/2-8,right:E.x+z/2+8,top:E.y-U/2-8,bottom:E.y+U/2+8}}}).sort((k,I)=>k.score-I.score).find(k=>!h(k.bounds)&&(!l||k.straight&&!x.some(I=>I.x>k.bounds.left&&I.x<k.bounds.right&&I.y>k.bounds.top&&I.y<k.bounds.bottom)));S?(u.setAttribute("transform",`translate(${S.point.x} ${S.point.y}) rotate(${S.angle})`),a.set(u,S.bounds)):a.set(u,d)}}var _n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function vw(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function al(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 vo,sd;function xw(){if(sd)return vo;sd=1;function e(){this.__data__=[],this.size=0}return vo=e,vo}var xo,cd;function It(){if(cd)return xo;cd=1;function e(t,r){return t===r||t!==t&&r!==r}return xo=e,xo}var wo,ud;function Dn(){if(ud)return wo;ud=1;var e=It();function t(r,n){for(var i=r.length;i--;)if(e(r[i][0],n))return i;return-1}return wo=t,wo}var Co,ld;function ww(){if(ld)return Co;ld=1;var e=Dn(),t=Array.prototype,r=t.splice;function n(i){var o=this.__data__,s=e(o,i);if(s<0)return!1;var a=o.length-1;return s==a?o.pop():r.call(o,s,1),--this.size,!0}return Co=n,Co}var So,dd;function Cw(){if(dd)return So;dd=1;var e=Dn();function t(r){var n=this.__data__,i=e(n,r);return i<0?void 0:n[i][1]}return So=t,So}var _o,fd;function Sw(){if(fd)return _o;fd=1;var e=Dn();function t(r){return e(this.__data__,r)>-1}return _o=t,_o}var Eo,hd;function _w(){if(hd)return Eo;hd=1;var e=Dn();function t(r,n){var i=this.__data__,o=e(i,r);return o<0?(++this.size,i.push([r,n])):i[o][1]=n,this}return Eo=t,Eo}var jo,pd;function Vn(){if(pd)return jo;pd=1;var e=xw(),t=ww(),r=Cw(),n=Sw(),i=_w();function o(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var u=s[a];this.set(u[0],u[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,jo=o,jo}var ko,gd;function Ew(){if(gd)return ko;gd=1;var e=Vn();function t(){this.__data__=new e,this.size=0}return ko=t,ko}var Ro,yd;function jw(){if(yd)return Ro;yd=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return Ro=e,Ro}var Po,md;function kw(){if(md)return Po;md=1;function e(t){return this.__data__.get(t)}return Po=e,Po}var Ao,bd;function Rw(){if(bd)return Ao;bd=1;function e(t){return this.__data__.has(t)}return Ao=e,Ao}var To,vd;function nb(){if(vd)return To;vd=1;var e=typeof _n=="object"&&_n&&_n.Object===Object&&_n;return To=e,To}var Io,xd;function Ar(){if(xd)return Io;xd=1;var e=nb(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Io=r,Io}var Oo,wd;function Ot(){if(wd)return Oo;wd=1;var e=Ar(),t=e.Symbol;return Oo=t,Oo}var Mo,Cd;function Pw(){if(Cd)return Mo;Cd=1;var e=Ot(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,i=e?e.toStringTag:void 0;function o(s){var a=r.call(s,i),c=s[i];try{s[i]=void 0;var u=!0}catch{}var l=n.call(s);return u&&(a?s[i]=c:delete s[i]),l}return Mo=o,Mo}var qo,Sd;function Aw(){if(Sd)return qo;Sd=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return qo=r,qo}var $o,_d;function lt(){if(_d)return $o;_d=1;var e=Ot(),t=Pw(),r=Aw(),n="[object Null]",i="[object Undefined]",o=e?e.toStringTag:void 0;function s(a){return a==null?a===void 0?i:n:o&&o in Object(a)?t(a):r(a)}return $o=s,$o}var No,Ed;function Er(){if(Ed)return No;Ed=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return No=e,No}var Lo,jd;function fn(){if(jd)return Lo;jd=1;var e=lt(),t=Er(),r="[object AsyncFunction]",n="[object Function]",i="[object GeneratorFunction]",o="[object Proxy]";function s(a){if(!t(a))return!1;var c=e(a);return c==n||c==i||c==r||c==o}return Lo=s,Lo}var Fo,kd;function Tw(){if(kd)return Fo;kd=1;var e=Ar(),t=e["__core-js_shared__"];return Fo=t,Fo}var Bo,Rd;function Iw(){if(Rd)return Bo;Rd=1;var e=Tw(),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 Bo=r,Bo}var zo,Pd;function ob(){if(Pd)return zo;Pd=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 zo=r,zo}var Do,Ad;function Ow(){if(Ad)return Do;Ad=1;var e=fn(),t=Iw(),r=Er(),n=ob(),i=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,s=Function.prototype,a=Object.prototype,c=s.toString,u=a.hasOwnProperty,l=RegExp("^"+c.call(u).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(h){if(!r(h)||t(h))return!1;var p=e(h)?l:o;return p.test(n(h))}return Do=d,Do}var Vo,Td;function Mw(){if(Td)return Vo;Td=1;function e(t,r){return t==null?void 0:t[r]}return Vo=e,Vo}var Wo,Id;function dt(){if(Id)return Wo;Id=1;var e=Ow(),t=Mw();function r(n,i){var o=t(n,i);return e(o)?o:void 0}return Wo=r,Wo}var Go,Od;function sl(){if(Od)return Go;Od=1;var e=dt(),t=Ar(),r=e(t,"Map");return Go=r,Go}var Uo,Md;function Wn(){if(Md)return Uo;Md=1;var e=dt(),t=e(Object,"create");return Uo=t,Uo}var Ho,qd;function qw(){if(qd)return Ho;qd=1;var e=Wn();function t(){this.__data__=e?e(null):{},this.size=0}return Ho=t,Ho}var Ko,$d;function $w(){if($d)return Ko;$d=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 Jo,Nd;function Nw(){if(Nd)return Jo;Nd=1;var e=Wn(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function i(o){var s=this.__data__;if(e){var a=s[o];return a===t?void 0:a}return n.call(s,o)?s[o]:void 0}return Jo=i,Jo}var Zo,Ld;function Lw(){if(Ld)return Zo;Ld=1;var e=Wn(),t=Object.prototype,r=t.hasOwnProperty;function n(i){var o=this.__data__;return e?o[i]!==void 0:r.call(o,i)}return Zo=n,Zo}var Yo,Fd;function Fw(){if(Fd)return Yo;Fd=1;var e=Wn(),t="__lodash_hash_undefined__";function r(n,i){var o=this.__data__;return this.size+=this.has(n)?0:1,o[n]=e&&i===void 0?t:i,this}return Yo=r,Yo}var Xo,Bd;function Bw(){if(Bd)return Xo;Bd=1;var e=qw(),t=$w(),r=Nw(),n=Lw(),i=Fw();function o(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var u=s[a];this.set(u[0],u[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,Xo=o,Xo}var Qo,zd;function zw(){if(zd)return Qo;zd=1;var e=Bw(),t=Vn(),r=sl();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return Qo=n,Qo}var ei,Dd;function Dw(){if(Dd)return ei;Dd=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return ei=e,ei}var ri,Vd;function Gn(){if(Vd)return ri;Vd=1;var e=Dw();function t(r,n){var i=r.__data__;return e(n)?i[typeof n=="string"?"string":"hash"]:i.map}return ri=t,ri}var ti,Wd;function Vw(){if(Wd)return ti;Wd=1;var e=Gn();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return ti=t,ti}var ni,Gd;function Ww(){if(Gd)return ni;Gd=1;var e=Gn();function t(r){return e(this,r).get(r)}return ni=t,ni}var oi,Ud;function Gw(){if(Ud)return oi;Ud=1;var e=Gn();function t(r){return e(this,r).has(r)}return oi=t,oi}var ii,Hd;function Uw(){if(Hd)return ii;Hd=1;var e=Gn();function t(r,n){var i=e(this,r),o=i.size;return i.set(r,n),this.size+=i.size==o?0:1,this}return ii=t,ii}var ai,Kd;function cl(){if(Kd)return ai;Kd=1;var e=zw(),t=Vw(),r=Ww(),n=Gw(),i=Uw();function o(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var u=s[a];this.set(u[0],u[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,ai=o,ai}var si,Jd;function Hw(){if(Jd)return si;Jd=1;var e=Vn(),t=sl(),r=cl(),n=200;function i(o,s){var a=this.__data__;if(a instanceof e){var c=a.__data__;if(!t||c.length<n-1)return c.push([o,s]),this.size=++a.size,this;a=this.__data__=new r(c)}return a.set(o,s),this.size=a.size,this}return si=i,si}var ci,Zd;function Un(){if(Zd)return ci;Zd=1;var e=Vn(),t=Ew(),r=jw(),n=kw(),i=Rw(),o=Hw();function s(a){var c=this.__data__=new e(a);this.size=c.size}return s.prototype.clear=t,s.prototype.delete=r,s.prototype.get=n,s.prototype.has=i,s.prototype.set=o,ci=s,ci}var ui,Yd;function ul(){if(Yd)return ui;Yd=1;function e(t,r){for(var n=-1,i=t==null?0:t.length;++n<i&&r(t[n],n,t)!==!1;);return t}return ui=e,ui}var li,Xd;function ib(){if(Xd)return li;Xd=1;var e=dt(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return li=t,li}var di,Qd;function Hn(){if(Qd)return di;Qd=1;var e=ib();function t(r,n,i){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):r[n]=i}return di=t,di}var fi,ef;function Kn(){if(ef)return fi;ef=1;var e=Hn(),t=It(),r=Object.prototype,n=r.hasOwnProperty;function i(o,s,a){var c=o[s];(!(n.call(o,s)&&t(c,a))||a===void 0&&!(s in o))&&e(o,s,a)}return fi=i,fi}var hi,rf;function hn(){if(rf)return hi;rf=1;var e=Kn(),t=Hn();function r(n,i,o,s){var a=!o;o||(o={});for(var c=-1,u=i.length;++c<u;){var l=i[c],d=s?s(o[l],n[l],l,o,n):void 0;d===void 0&&(d=n[l]),a?t(o,l,d):e(o,l,d)}return o}return hi=r,hi}var pi,tf;function Kw(){if(tf)return pi;tf=1;function e(t,r){for(var n=-1,i=Array(t);++n<t;)i[n]=r(n);return i}return pi=e,pi}var gi,nf;function Mr(){if(nf)return gi;nf=1;function e(t){return t!=null&&typeof t=="object"}return gi=e,gi}var yi,of;function Jw(){if(of)return yi;of=1;var e=lt(),t=Mr(),r="[object Arguments]";function n(i){return t(i)&&e(i)==r}return yi=n,yi}var mi,af;function pn(){if(af)return mi;af=1;var e=Jw(),t=Mr(),r=Object.prototype,n=r.hasOwnProperty,i=r.propertyIsEnumerable,o=e((function(){return arguments})())?e:function(s){return t(s)&&n.call(s,"callee")&&!i.call(s,"callee")};return mi=o,mi}var bi,sf;function rr(){if(sf)return bi;sf=1;var e=Array.isArray;return bi=e,bi}var Wt={exports:{}},vi,cf;function Zw(){if(cf)return vi;cf=1;function e(){return!1}return vi=e,vi}Wt.exports;var uf;function Mt(){return uf||(uf=1,(function(e,t){var r=Ar(),n=Zw(),i=t&&!t.nodeType&&t,o=i&&!0&&e&&!e.nodeType&&e,s=o&&o.exports===i,a=s?r.Buffer:void 0,c=a?a.isBuffer:void 0,u=c||n;e.exports=u})(Wt,Wt.exports)),Wt.exports}var xi,lf;function Jn(){if(lf)return xi;lf=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,i){var o=typeof n;return i=i??e,!!i&&(o=="number"||o!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<i}return xi=r,xi}var wi,df;function ll(){if(df)return wi;df=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return wi=t,wi}var Ci,ff;function Yw(){if(ff)return Ci;ff=1;var e=lt(),t=ll(),r=Mr(),n="[object Arguments]",i="[object Array]",o="[object Boolean]",s="[object Date]",a="[object Error]",c="[object Function]",u="[object Map]",l="[object Number]",d="[object Object]",h="[object RegExp]",p="[object Set]",y="[object String]",m="[object WeakMap]",g="[object ArrayBuffer]",b="[object DataView]",w="[object Float32Array]",v="[object Float64Array]",x="[object Int8Array]",C="[object Int16Array]",S="[object Int32Array]",k="[object Uint8Array]",I="[object Uint8ClampedArray]",R="[object Uint16Array]",M="[object Uint32Array]",E={};E[w]=E[v]=E[x]=E[C]=E[S]=E[k]=E[I]=E[R]=E[M]=!0,E[n]=E[i]=E[g]=E[o]=E[b]=E[s]=E[a]=E[c]=E[u]=E[l]=E[d]=E[h]=E[p]=E[y]=E[m]=!1;function P(A){return r(A)&&t(A.length)&&!!E[e(A)]}return Ci=P,Ci}var Si,hf;function Zn(){if(hf)return Si;hf=1;function e(t){return function(r){return t(r)}}return Si=e,Si}var Gt={exports:{}};Gt.exports;var pf;function dl(){return pf||(pf=1,(function(e,t){var r=nb(),n=t&&!t.nodeType&&t,i=n&&!0&&e&&!e.nodeType&&e,o=i&&i.exports===n,s=o&&r.process,a=(function(){try{var c=i&&i.require&&i.require("util").types;return c||s&&s.binding&&s.binding("util")}catch{}})();e.exports=a})(Gt,Gt.exports)),Gt.exports}var _i,gf;function gn(){if(gf)return _i;gf=1;var e=Yw(),t=Zn(),r=dl(),n=r&&r.isTypedArray,i=n?t(n):e;return _i=i,_i}var Ei,yf;function ab(){if(yf)return Ei;yf=1;var e=Kw(),t=pn(),r=rr(),n=Mt(),i=Jn(),o=gn(),s=Object.prototype,a=s.hasOwnProperty;function c(u,l){var d=r(u),h=!d&&t(u),p=!d&&!h&&n(u),y=!d&&!h&&!p&&o(u),m=d||h||p||y,g=m?e(u.length,String):[],b=g.length;for(var w in u)(l||a.call(u,w))&&!(m&&(w=="length"||p&&(w=="offset"||w=="parent")||y&&(w=="buffer"||w=="byteLength"||w=="byteOffset")||i(w,b)))&&g.push(w);return g}return Ei=c,Ei}var ji,mf;function Yn(){if(mf)return ji;mf=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,i=typeof n=="function"&&n.prototype||e;return r===i}return ji=t,ji}var ki,bf;function sb(){if(bf)return ki;bf=1;function e(t,r){return function(n){return t(r(n))}}return ki=e,ki}var Ri,vf;function Xw(){if(vf)return Ri;vf=1;var e=sb(),t=e(Object.keys,Object);return Ri=t,Ri}var Pi,xf;function fl(){if(xf)return Pi;xf=1;var e=Yn(),t=Xw(),r=Object.prototype,n=r.hasOwnProperty;function i(o){if(!e(o))return t(o);var s=[];for(var a in Object(o))n.call(o,a)&&a!="constructor"&&s.push(a);return s}return Pi=i,Pi}var Ai,wf;function Fr(){if(wf)return Ai;wf=1;var e=fn(),t=ll();function r(n){return n!=null&&t(n.length)&&!e(n)}return Ai=r,Ai}var Ti,Cf;function Qr(){if(Cf)return Ti;Cf=1;var e=ab(),t=fl(),r=Fr();function n(i){return r(i)?e(i):t(i)}return Ti=n,Ti}var Ii,Sf;function Qw(){if(Sf)return Ii;Sf=1;var e=hn(),t=Qr();function r(n,i){return n&&e(i,t(i),n)}return Ii=r,Ii}var Oi,_f;function e1(){if(_f)return Oi;_f=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return Oi=e,Oi}var Mi,Ef;function r1(){if(Ef)return Mi;Ef=1;var e=Er(),t=Yn(),r=e1(),n=Object.prototype,i=n.hasOwnProperty;function o(s){if(!e(s))return r(s);var a=t(s),c=[];for(var u in s)u=="constructor"&&(a||!i.call(s,u))||c.push(u);return c}return Mi=o,Mi}var qi,jf;function ft(){if(jf)return qi;jf=1;var e=ab(),t=r1(),r=Fr();function n(i){return r(i)?e(i,!0):t(i)}return qi=n,qi}var $i,kf;function t1(){if(kf)return $i;kf=1;var e=hn(),t=ft();function r(n,i){return n&&e(i,t(i),n)}return $i=r,$i}var Ut={exports:{}};Ut.exports;var Rf;function cb(){return Rf||(Rf=1,(function(e,t){var r=Ar(),n=t&&!t.nodeType&&t,i=n&&!0&&e&&!e.nodeType&&e,o=i&&i.exports===n,s=o?r.Buffer:void 0,a=s?s.allocUnsafe:void 0;function c(u,l){if(l)return u.slice();var d=u.length,h=a?a(d):new u.constructor(d);return u.copy(h),h}e.exports=c})(Ut,Ut.exports)),Ut.exports}var Ni,Pf;function ub(){if(Pf)return Ni;Pf=1;function e(t,r){var n=-1,i=t.length;for(r||(r=Array(i));++n<i;)r[n]=t[n];return r}return Ni=e,Ni}var Li,Af;function lb(){if(Af)return Li;Af=1;function e(t,r){for(var n=-1,i=t==null?0:t.length,o=0,s=[];++n<i;){var a=t[n];r(a,n,t)&&(s[o++]=a)}return s}return Li=e,Li}var Fi,Tf;function db(){if(Tf)return Fi;Tf=1;function e(){return[]}return Fi=e,Fi}var Bi,If;function hl(){if(If)return Bi;If=1;var e=lb(),t=db(),r=Object.prototype,n=r.propertyIsEnumerable,i=Object.getOwnPropertySymbols,o=i?function(s){return s==null?[]:(s=Object(s),e(i(s),function(a){return n.call(s,a)}))}:t;return Bi=o,Bi}var zi,Of;function n1(){if(Of)return zi;Of=1;var e=hn(),t=hl();function r(n,i){return e(n,t(n),i)}return zi=r,zi}var Di,Mf;function pl(){if(Mf)return Di;Mf=1;function e(t,r){for(var n=-1,i=r.length,o=t.length;++n<i;)t[o+n]=r[n];return t}return Di=e,Di}var Vi,qf;function Xn(){if(qf)return Vi;qf=1;var e=sb(),t=e(Object.getPrototypeOf,Object);return Vi=t,Vi}var Wi,$f;function fb(){if($f)return Wi;$f=1;var e=pl(),t=Xn(),r=hl(),n=db(),i=Object.getOwnPropertySymbols,o=i?function(s){for(var a=[];s;)e(a,r(s)),s=t(s);return a}:n;return Wi=o,Wi}var Gi,Nf;function o1(){if(Nf)return Gi;Nf=1;var e=hn(),t=fb();function r(n,i){return e(n,t(n),i)}return Gi=r,Gi}var Ui,Lf;function hb(){if(Lf)return Ui;Lf=1;var e=pl(),t=rr();function r(n,i,o){var s=i(n);return t(n)?s:e(s,o(n))}return Ui=r,Ui}var Hi,Ff;function pb(){if(Ff)return Hi;Ff=1;var e=hb(),t=hl(),r=Qr();function n(i){return e(i,r,t)}return Hi=n,Hi}var Ki,Bf;function i1(){if(Bf)return Ki;Bf=1;var e=hb(),t=fb(),r=ft();function n(i){return e(i,r,t)}return Ki=n,Ki}var Ji,zf;function a1(){if(zf)return Ji;zf=1;var e=dt(),t=Ar(),r=e(t,"DataView");return Ji=r,Ji}var Zi,Df;function s1(){if(Df)return Zi;Df=1;var e=dt(),t=Ar(),r=e(t,"Promise");return Zi=r,Zi}var Yi,Vf;function gb(){if(Vf)return Yi;Vf=1;var e=dt(),t=Ar(),r=e(t,"Set");return Yi=r,Yi}var Xi,Wf;function c1(){if(Wf)return Xi;Wf=1;var e=dt(),t=Ar(),r=e(t,"WeakMap");return Xi=r,Xi}var Qi,Gf;function qt(){if(Gf)return Qi;Gf=1;var e=a1(),t=sl(),r=s1(),n=gb(),i=c1(),o=lt(),s=ob(),a="[object Map]",c="[object Object]",u="[object Promise]",l="[object Set]",d="[object WeakMap]",h="[object DataView]",p=s(e),y=s(t),m=s(r),g=s(n),b=s(i),w=o;return(e&&w(new e(new ArrayBuffer(1)))!=h||t&&w(new t)!=a||r&&w(r.resolve())!=u||n&&w(new n)!=l||i&&w(new i)!=d)&&(w=function(v){var x=o(v),C=x==c?v.constructor:void 0,S=C?s(C):"";if(S)switch(S){case p:return h;case y:return a;case m:return u;case g:return l;case b:return d}return x}),Qi=w,Qi}var ea,Uf;function u1(){if(Uf)return ea;Uf=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var i=n.length,o=new n.constructor(i);return i&&typeof n[0]=="string"&&t.call(n,"index")&&(o.index=n.index,o.input=n.input),o}return ea=r,ea}var ra,Hf;function yb(){if(Hf)return ra;Hf=1;var e=Ar(),t=e.Uint8Array;return ra=t,ra}var ta,Kf;function gl(){if(Kf)return ta;Kf=1;var e=yb();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return ta=t,ta}var na,Jf;function l1(){if(Jf)return na;Jf=1;var e=gl();function t(r,n){var i=n?e(r.buffer):r.buffer;return new r.constructor(i,r.byteOffset,r.byteLength)}return na=t,na}var oa,Zf;function d1(){if(Zf)return oa;Zf=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return oa=t,oa}var ia,Yf;function f1(){if(Yf)return ia;Yf=1;var e=Ot(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(i){return r?Object(r.call(i)):{}}return ia=n,ia}var aa,Xf;function mb(){if(Xf)return aa;Xf=1;var e=gl();function t(r,n){var i=n?e(r.buffer):r.buffer;return new r.constructor(i,r.byteOffset,r.length)}return aa=t,aa}var sa,Qf;function h1(){if(Qf)return sa;Qf=1;var e=gl(),t=l1(),r=d1(),n=f1(),i=mb(),o="[object Boolean]",s="[object Date]",a="[object Map]",c="[object Number]",u="[object RegExp]",l="[object Set]",d="[object String]",h="[object Symbol]",p="[object ArrayBuffer]",y="[object DataView]",m="[object Float32Array]",g="[object Float64Array]",b="[object Int8Array]",w="[object Int16Array]",v="[object Int32Array]",x="[object Uint8Array]",C="[object Uint8ClampedArray]",S="[object Uint16Array]",k="[object Uint32Array]";function I(R,M,E){var P=R.constructor;switch(M){case p:return e(R);case o:case s:return new P(+R);case y:return t(R,E);case m:case g:case b:case w:case v:case x:case C:case S:case k:return i(R,E);case a:return new P;case c:case d:return new P(R);case u:return r(R);case l:return new P;case h:return n(R)}}return sa=I,sa}var ca,eh;function bb(){if(eh)return ca;eh=1;var e=Er(),t=Object.create,r=(function(){function n(){}return function(i){if(!e(i))return{};if(t)return t(i);n.prototype=i;var o=new n;return n.prototype=void 0,o}})();return ca=r,ca}var ua,rh;function vb(){if(rh)return ua;rh=1;var e=bb(),t=Xn(),r=Yn();function n(i){return typeof i.constructor=="function"&&!r(i)?e(t(i)):{}}return ua=n,ua}var la,th;function p1(){if(th)return la;th=1;var e=qt(),t=Mr(),r="[object Map]";function n(i){return t(i)&&e(i)==r}return la=n,la}var da,nh;function g1(){if(nh)return da;nh=1;var e=p1(),t=Zn(),r=dl(),n=r&&r.isMap,i=n?t(n):e;return da=i,da}var fa,oh;function y1(){if(oh)return fa;oh=1;var e=qt(),t=Mr(),r="[object Set]";function n(i){return t(i)&&e(i)==r}return fa=n,fa}var ha,ih;function m1(){if(ih)return ha;ih=1;var e=y1(),t=Zn(),r=dl(),n=r&&r.isSet,i=n?t(n):e;return ha=i,ha}var pa,ah;function xb(){if(ah)return pa;ah=1;var e=Un(),t=ul(),r=Kn(),n=Qw(),i=t1(),o=cb(),s=ub(),a=n1(),c=o1(),u=pb(),l=i1(),d=qt(),h=u1(),p=h1(),y=vb(),m=rr(),g=Mt(),b=g1(),w=Er(),v=m1(),x=Qr(),C=ft(),S=1,k=2,I=4,R="[object Arguments]",M="[object Array]",E="[object Boolean]",P="[object Date]",A="[object Error]",j="[object Function]",q="[object GeneratorFunction]",O="[object Map]",z="[object Number]",U="[object Object]",ae="[object RegExp]",Q="[object Set]",Y="[object String]",pe="[object Symbol]",se="[object WeakMap]",$="[object ArrayBuffer]",V="[object DataView]",W="[object Float32Array]",N="[object Float64Array]",ne="[object Int8Array]",me="[object Int16Array]",fe="[object Int32Array]",J="[object Uint8Array]",te="[object Uint8ClampedArray]",G="[object Uint16Array]",le="[object Uint32Array]",ue={};ue[R]=ue[M]=ue[$]=ue[V]=ue[E]=ue[P]=ue[W]=ue[N]=ue[ne]=ue[me]=ue[fe]=ue[O]=ue[z]=ue[U]=ue[ae]=ue[Q]=ue[Y]=ue[pe]=ue[J]=ue[te]=ue[G]=ue[le]=!0,ue[A]=ue[j]=ue[se]=!1;function we(ge,qe,ee,he,be,Ee){var $e,Ge=qe&S,Ye=qe&k,tr=qe&I;if(ee&&($e=be?ee(ge,he,be,Ee):ee(ge)),$e!==void 0)return $e;if(!w(ge))return ge;var sr=m(ge);if(sr){if($e=h(ge),!Ge)return s(ge,$e)}else{var Pe=d(ge),ye=Pe==j||Pe==q;if(g(ge))return o(ge,Ge);if(Pe==U||Pe==R||ye&&!be){if($e=Ye||ye?{}:y(ge),!Ge)return Ye?c(ge,i($e,ge)):a(ge,n($e,ge))}else{if(!ue[Pe])return be?ge:{};$e=p(ge,Pe,Ge)}}Ee||(Ee=new e);var Me=Ee.get(ge);if(Me)return Me;Ee.set(ge,$e),v(ge)?ge.forEach(function(Xe){$e.add(we(Xe,qe,ee,Xe,ge,Ee))}):b(ge)&&ge.forEach(function(Xe,xe){$e.set(xe,we(Xe,qe,ee,xe,ge,Ee))});var nr=tr?Ye?l:u:Ye?C:x,cr=sr?void 0:nr(ge);return t(cr||ge,function(Xe,xe){cr&&(xe=Xe,Xe=ge[xe]),r($e,xe,we(Xe,qe,ee,xe,ge,Ee))}),$e}return pa=we,pa}var ga,sh;function b1(){if(sh)return ga;sh=1;var e=xb(),t=4;function r(n){return e(n,t)}return ga=r,ga}var ya,ch;function yl(){if(ch)return ya;ch=1;function e(t){return function(){return t}}return ya=e,ya}var ma,uh;function v1(){if(uh)return ma;uh=1;function e(t){return function(r,n,i){for(var o=-1,s=Object(r),a=i(r),c=a.length;c--;){var u=a[t?c:++o];if(n(s[u],u,s)===!1)break}return r}}return ma=e,ma}var ba,lh;function ml(){if(lh)return ba;lh=1;var e=v1(),t=e();return ba=t,ba}var va,dh;function bl(){if(dh)return va;dh=1;var e=ml(),t=Qr();function r(n,i){return n&&e(n,i,t)}return va=r,va}var xa,fh;function x1(){if(fh)return xa;fh=1;var e=Fr();function t(r,n){return function(i,o){if(i==null)return i;if(!e(i))return r(i,o);for(var s=i.length,a=n?s:-1,c=Object(i);(n?a--:++a<s)&&o(c[a],a,c)!==!1;);return i}}return xa=t,xa}var wa,hh;function Qn(){if(hh)return wa;hh=1;var e=bl(),t=x1(),r=t(e);return wa=r,wa}var Ca,ph;function ht(){if(ph)return Ca;ph=1;function e(t){return t}return Ca=e,Ca}var Sa,gh;function wb(){if(gh)return Sa;gh=1;var e=ht();function t(r){return typeof r=="function"?r:e}return Sa=t,Sa}var _a,yh;function Cb(){if(yh)return _a;yh=1;var e=ul(),t=Qn(),r=wb(),n=rr();function i(o,s){var a=n(o)?e:t;return a(o,r(s))}return _a=i,_a}var Ea,mh;function Sb(){return mh||(mh=1,Ea=Cb()),Ea}var ja,bh;function w1(){if(bh)return ja;bh=1;var e=Qn();function t(r,n){var i=[];return e(r,function(o,s,a){n(o,s,a)&&i.push(o)}),i}return ja=t,ja}var ka,vh;function C1(){if(vh)return ka;vh=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return ka=t,ka}var Ra,xh;function S1(){if(xh)return Ra;xh=1;function e(t){return this.__data__.has(t)}return Ra=e,Ra}var Pa,wh;function _b(){if(wh)return Pa;wh=1;var e=cl(),t=C1(),r=S1();function n(i){var o=-1,s=i==null?0:i.length;for(this.__data__=new e;++o<s;)this.add(i[o])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,Pa=n,Pa}var Aa,Ch;function _1(){if(Ch)return Aa;Ch=1;function e(t,r){for(var n=-1,i=t==null?0:t.length;++n<i;)if(r(t[n],n,t))return!0;return!1}return Aa=e,Aa}var Ta,Sh;function Eb(){if(Sh)return Ta;Sh=1;function e(t,r){return t.has(r)}return Ta=e,Ta}var Ia,_h;function jb(){if(_h)return Ia;_h=1;var e=_b(),t=_1(),r=Eb(),n=1,i=2;function o(s,a,c,u,l,d){var h=c&n,p=s.length,y=a.length;if(p!=y&&!(h&&y>p))return!1;var m=d.get(s),g=d.get(a);if(m&&g)return m==a&&g==s;var b=-1,w=!0,v=c&i?new e:void 0;for(d.set(s,a),d.set(a,s);++b<p;){var x=s[b],C=a[b];if(u)var S=h?u(C,x,b,a,s,d):u(x,C,b,s,a,d);if(S!==void 0){if(S)continue;w=!1;break}if(v){if(!t(a,function(k,I){if(!r(v,I)&&(x===k||l(x,k,c,u,d)))return v.push(I)})){w=!1;break}}else if(!(x===C||l(x,C,c,u,d))){w=!1;break}}return d.delete(s),d.delete(a),w}return Ia=o,Ia}var Oa,Eh;function E1(){if(Eh)return Oa;Eh=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(i,o){n[++r]=[o,i]}),n}return Oa=e,Oa}var Ma,jh;function vl(){if(jh)return Ma;jh=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(i){n[++r]=i}),n}return Ma=e,Ma}var qa,kh;function j1(){if(kh)return qa;kh=1;var e=Ot(),t=yb(),r=It(),n=jb(),i=E1(),o=vl(),s=1,a=2,c="[object Boolean]",u="[object Date]",l="[object Error]",d="[object Map]",h="[object Number]",p="[object RegExp]",y="[object Set]",m="[object String]",g="[object Symbol]",b="[object ArrayBuffer]",w="[object DataView]",v=e?e.prototype:void 0,x=v?v.valueOf:void 0;function C(S,k,I,R,M,E,P){switch(I){case w:if(S.byteLength!=k.byteLength||S.byteOffset!=k.byteOffset)return!1;S=S.buffer,k=k.buffer;case b:return!(S.byteLength!=k.byteLength||!E(new t(S),new t(k)));case c:case u:case h:return r(+S,+k);case l:return S.name==k.name&&S.message==k.message;case p:case m:return S==k+"";case d:var A=i;case y:var j=R&s;if(A||(A=o),S.size!=k.size&&!j)return!1;var q=P.get(S);if(q)return q==k;R|=a,P.set(S,k);var O=n(A(S),A(k),R,M,E,P);return P.delete(S),O;case g:if(x)return x.call(S)==x.call(k)}return!1}return qa=C,qa}var $a,Rh;function k1(){if(Rh)return $a;Rh=1;var e=pb(),t=1,r=Object.prototype,n=r.hasOwnProperty;function i(o,s,a,c,u,l){var d=a&t,h=e(o),p=h.length,y=e(s),m=y.length;if(p!=m&&!d)return!1;for(var g=p;g--;){var b=h[g];if(!(d?b in s:n.call(s,b)))return!1}var w=l.get(o),v=l.get(s);if(w&&v)return w==s&&v==o;var x=!0;l.set(o,s),l.set(s,o);for(var C=d;++g<p;){b=h[g];var S=o[b],k=s[b];if(c)var I=d?c(k,S,b,s,o,l):c(S,k,b,o,s,l);if(!(I===void 0?S===k||u(S,k,a,c,l):I)){x=!1;break}C||(C=b=="constructor")}if(x&&!C){var R=o.constructor,M=s.constructor;R!=M&&"constructor"in o&&"constructor"in s&&!(typeof R=="function"&&R instanceof R&&typeof M=="function"&&M instanceof M)&&(x=!1)}return l.delete(o),l.delete(s),x}return $a=i,$a}var Na,Ph;function R1(){if(Ph)return Na;Ph=1;var e=Un(),t=jb(),r=j1(),n=k1(),i=qt(),o=rr(),s=Mt(),a=gn(),c=1,u="[object Arguments]",l="[object Array]",d="[object Object]",h=Object.prototype,p=h.hasOwnProperty;function y(m,g,b,w,v,x){var C=o(m),S=o(g),k=C?l:i(m),I=S?l:i(g);k=k==u?d:k,I=I==u?d:I;var R=k==d,M=I==d,E=k==I;if(E&&s(m)){if(!s(g))return!1;C=!0,R=!1}if(E&&!R)return x||(x=new e),C||a(m)?t(m,g,b,w,v,x):r(m,g,k,b,w,v,x);if(!(b&c)){var P=R&&p.call(m,"__wrapped__"),A=M&&p.call(g,"__wrapped__");if(P||A){var j=P?m.value():m,q=A?g.value():g;return x||(x=new e),v(j,q,b,w,x)}}return E?(x||(x=new e),n(m,g,b,w,v,x)):!1}return Na=y,Na}var La,Ah;function kb(){if(Ah)return La;Ah=1;var e=R1(),t=Mr();function r(n,i,o,s,a){return n===i?!0:n==null||i==null||!t(n)&&!t(i)?n!==n&&i!==i:e(n,i,o,s,r,a)}return La=r,La}var Fa,Th;function P1(){if(Th)return Fa;Th=1;var e=Un(),t=kb(),r=1,n=2;function i(o,s,a,c){var u=a.length,l=u,d=!c;if(o==null)return!l;for(o=Object(o);u--;){var h=a[u];if(d&&h[2]?h[1]!==o[h[0]]:!(h[0]in o))return!1}for(;++u<l;){h=a[u];var p=h[0],y=o[p],m=h[1];if(d&&h[2]){if(y===void 0&&!(p in o))return!1}else{var g=new e;if(c)var b=c(y,m,p,o,s,g);if(!(b===void 0?t(m,y,r|n,c,g):b))return!1}}return!0}return Fa=i,Fa}var Ba,Ih;function Rb(){if(Ih)return Ba;Ih=1;var e=Er();function t(r){return r===r&&!e(r)}return Ba=t,Ba}var za,Oh;function A1(){if(Oh)return za;Oh=1;var e=Rb(),t=Qr();function r(n){for(var i=t(n),o=i.length;o--;){var s=i[o],a=n[s];i[o]=[s,a,e(a)]}return i}return za=r,za}var Da,Mh;function Pb(){if(Mh)return Da;Mh=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return Da=e,Da}var Va,qh;function T1(){if(qh)return Va;qh=1;var e=P1(),t=A1(),r=Pb();function n(i){var o=t(i);return o.length==1&&o[0][2]?r(o[0][0],o[0][1]):function(s){return s===i||e(s,i,o)}}return Va=n,Va}var Wa,$h;function $t(){if($h)return Wa;$h=1;var e=lt(),t=Mr(),r="[object Symbol]";function n(i){return typeof i=="symbol"||t(i)&&e(i)==r}return Wa=n,Wa}var Ga,Nh;function xl(){if(Nh)return Ga;Nh=1;var e=rr(),t=$t(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function i(o,s){if(e(o))return!1;var a=typeof o;return a=="number"||a=="symbol"||a=="boolean"||o==null||t(o)?!0:n.test(o)||!r.test(o)||s!=null&&o in Object(s)}return Ga=i,Ga}var Ua,Lh;function I1(){if(Lh)return Ua;Lh=1;var e=cl(),t="Expected a function";function r(n,i){if(typeof n!="function"||i!=null&&typeof i!="function")throw new TypeError(t);var o=function(){var s=arguments,a=i?i.apply(this,s):s[0],c=o.cache;if(c.has(a))return c.get(a);var u=n.apply(this,s);return o.cache=c.set(a,u)||c,u};return o.cache=new(r.Cache||e),o}return r.Cache=e,Ua=r,Ua}var Ha,Fh;function O1(){if(Fh)return Ha;Fh=1;var e=I1(),t=500;function r(n){var i=e(n,function(s){return o.size===t&&o.clear(),s}),o=i.cache;return i}return Ha=r,Ha}var Ka,Bh;function M1(){if(Bh)return Ka;Bh=1;var e=O1(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(i){var o=[];return i.charCodeAt(0)===46&&o.push(""),i.replace(t,function(s,a,c,u){o.push(c?u.replace(r,"$1"):a||s)}),o});return Ka=n,Ka}var Ja,zh;function eo(){if(zh)return Ja;zh=1;function e(t,r){for(var n=-1,i=t==null?0:t.length,o=Array(i);++n<i;)o[n]=r(t[n],n,t);return o}return Ja=e,Ja}var Za,Dh;function q1(){if(Dh)return Za;Dh=1;var e=Ot(),t=eo(),r=rr(),n=$t(),i=e?e.prototype:void 0,o=i?i.toString:void 0;function s(a){if(typeof a=="string")return a;if(r(a))return t(a,s)+"";if(n(a))return o?o.call(a):"";var c=a+"";return c=="0"&&1/a==-1/0?"-0":c}return Za=s,Za}var Ya,Vh;function Ab(){if(Vh)return Ya;Vh=1;var e=q1();function t(r){return r==null?"":e(r)}return Ya=t,Ya}var Xa,Wh;function ro(){if(Wh)return Xa;Wh=1;var e=rr(),t=xl(),r=M1(),n=Ab();function i(o,s){return e(o)?o:t(o,s)?[o]:r(n(o))}return Xa=i,Xa}var Qa,Gh;function yn(){if(Gh)return Qa;Gh=1;var e=$t();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return Qa=t,Qa}var es,Uh;function to(){if(Uh)return es;Uh=1;var e=ro(),t=yn();function r(n,i){i=e(i,n);for(var o=0,s=i.length;n!=null&&o<s;)n=n[t(i[o++])];return o&&o==s?n:void 0}return es=r,es}var rs,Hh;function $1(){if(Hh)return rs;Hh=1;var e=to();function t(r,n,i){var o=r==null?void 0:e(r,n);return o===void 0?i:o}return rs=t,rs}var ts,Kh;function N1(){if(Kh)return ts;Kh=1;function e(t,r){return t!=null&&r in Object(t)}return ts=e,ts}var ns,Jh;function Tb(){if(Jh)return ns;Jh=1;var e=ro(),t=pn(),r=rr(),n=Jn(),i=ll(),o=yn();function s(a,c,u){c=e(c,a);for(var l=-1,d=c.length,h=!1;++l<d;){var p=o(c[l]);if(!(h=a!=null&&u(a,p)))break;a=a[p]}return h||++l!=d?h:(d=a==null?0:a.length,!!d&&i(d)&&n(p,d)&&(r(a)||t(a)))}return ns=s,ns}var os,Zh;function Ib(){if(Zh)return os;Zh=1;var e=N1(),t=Tb();function r(n,i){return n!=null&&t(n,i,e)}return os=r,os}var is,Yh;function L1(){if(Yh)return is;Yh=1;var e=kb(),t=$1(),r=Ib(),n=xl(),i=Rb(),o=Pb(),s=yn(),a=1,c=2;function u(l,d){return n(l)&&i(d)?o(s(l),d):function(h){var p=t(h,l);return p===void 0&&p===d?r(h,l):e(d,p,a|c)}}return is=u,is}var as,Xh;function Ob(){if(Xh)return as;Xh=1;function e(t){return function(r){return r==null?void 0:r[t]}}return as=e,as}var ss,Qh;function F1(){if(Qh)return ss;Qh=1;var e=to();function t(r){return function(n){return e(n,r)}}return ss=t,ss}var cs,ep;function B1(){if(ep)return cs;ep=1;var e=Ob(),t=F1(),r=xl(),n=yn();function i(o){return r(o)?e(n(o)):t(o)}return cs=i,cs}var us,rp;function Br(){if(rp)return us;rp=1;var e=T1(),t=L1(),r=ht(),n=rr(),i=B1();function o(s){return typeof s=="function"?s:s==null?r:typeof s=="object"?n(s)?t(s[0],s[1]):e(s):i(s)}return us=o,us}var ls,tp;function Mb(){if(tp)return ls;tp=1;var e=lb(),t=w1(),r=Br(),n=rr();function i(o,s){var a=n(o)?e:t;return a(o,r(s,3))}return ls=i,ls}var ds,np;function z1(){if(np)return ds;np=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,i){return n!=null&&t.call(n,i)}return ds=r,ds}var fs,op;function qb(){if(op)return fs;op=1;var e=z1(),t=Tb();function r(n,i){return n!=null&&t(n,i,e)}return fs=r,fs}var hs,ip;function D1(){if(ip)return hs;ip=1;var e=fl(),t=qt(),r=pn(),n=rr(),i=Fr(),o=Mt(),s=Yn(),a=gn(),c="[object Map]",u="[object Set]",l=Object.prototype,d=l.hasOwnProperty;function h(p){if(p==null)return!0;if(i(p)&&(n(p)||typeof p=="string"||typeof p.splice=="function"||o(p)||a(p)||r(p)))return!p.length;var y=t(p);if(y==c||y==u)return!p.size;if(s(p))return!e(p).length;for(var m in p)if(d.call(p,m))return!1;return!0}return hs=h,hs}var ps,ap;function $b(){if(ap)return ps;ap=1;function e(t){return t===void 0}return ps=e,ps}var gs,sp;function Nb(){if(sp)return gs;sp=1;var e=Qn(),t=Fr();function r(n,i){var o=-1,s=t(n)?Array(n.length):[];return e(n,function(a,c,u){s[++o]=i(a,c,u)}),s}return gs=r,gs}var ys,cp;function Lb(){if(cp)return ys;cp=1;var e=eo(),t=Br(),r=Nb(),n=rr();function i(o,s){var a=n(o)?e:r;return a(o,t(s,3))}return ys=i,ys}var ms,up;function V1(){if(up)return ms;up=1;function e(t,r,n,i){var o=-1,s=t==null?0:t.length;for(i&&s&&(n=t[++o]);++o<s;)n=r(n,t[o],o,t);return n}return ms=e,ms}var bs,lp;function W1(){if(lp)return bs;lp=1;function e(t,r,n,i,o){return o(t,function(s,a,c){n=i?(i=!1,s):r(n,s,a,c)}),n}return bs=e,bs}var vs,dp;function Fb(){if(dp)return vs;dp=1;var e=V1(),t=Qn(),r=Br(),n=W1(),i=rr();function o(s,a,c){var u=i(s)?e:n,l=arguments.length<3;return u(s,r(a,4),c,l,t)}return vs=o,vs}var xs,fp;function G1(){if(fp)return xs;fp=1;var e=lt(),t=rr(),r=Mr(),n="[object String]";function i(o){return typeof o=="string"||!t(o)&&r(o)&&e(o)==n}return xs=i,xs}var ws,hp;function U1(){if(hp)return ws;hp=1;var e=Ob(),t=e("length");return ws=t,ws}var Cs,pp;function H1(){if(pp)return Cs;pp=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",i=t+r+n,o="\\ufe0e\\ufe0f",s="\\u200d",a=RegExp("["+s+e+i+o+"]");function c(u){return a.test(u)}return Cs=c,Cs}var Ss,gp;function K1(){if(gp)return Ss;gp=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",i=t+r+n,o="\\ufe0e\\ufe0f",s="["+e+"]",a="["+i+"]",c="\\ud83c[\\udffb-\\udfff]",u="(?:"+a+"|"+c+")",l="[^"+e+"]",d="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",y=u+"?",m="["+o+"]?",g="(?:"+p+"(?:"+[l,d,h].join("|")+")"+m+y+")*",b=m+y+g,w="(?:"+[l+a+"?",a,d,h,s].join("|")+")",v=RegExp(c+"(?="+c+")|"+w+b,"g");function x(C){for(var S=v.lastIndex=0;v.test(C);)++S;return S}return Ss=x,Ss}var _s,yp;function J1(){if(yp)return _s;yp=1;var e=U1(),t=H1(),r=K1();function n(i){return t(i)?r(i):e(i)}return _s=n,_s}var Es,mp;function Z1(){if(mp)return Es;mp=1;var e=fl(),t=qt(),r=Fr(),n=G1(),i=J1(),o="[object Map]",s="[object Set]";function a(c){if(c==null)return 0;if(r(c))return n(c)?i(c):c.length;var u=t(c);return u==o||u==s?c.size:e(c).length}return Es=a,Es}var js,bp;function Y1(){if(bp)return js;bp=1;var e=ul(),t=bb(),r=bl(),n=Br(),i=Xn(),o=rr(),s=Mt(),a=fn(),c=Er(),u=gn();function l(d,h,p){var y=o(d),m=y||s(d)||u(d);if(h=n(h,4),p==null){var g=d&&d.constructor;m?p=y?new g:[]:c(d)?p=a(g)?t(i(d)):{}:p={}}return(m?e:r)(d,function(b,w,v){return h(p,b,w,v)}),p}return js=l,js}var ks,vp;function X1(){if(vp)return ks;vp=1;var e=Ot(),t=pn(),r=rr(),n=e?e.isConcatSpreadable:void 0;function i(o){return r(o)||t(o)||!!(n&&o&&o[n])}return ks=i,ks}var Rs,xp;function wl(){if(xp)return Rs;xp=1;var e=pl(),t=X1();function r(n,i,o,s,a){var c=-1,u=n.length;for(o||(o=t),a||(a=[]);++c<u;){var l=n[c];i>0&&o(l)?i>1?r(l,i-1,o,s,a):e(a,l):s||(a[a.length]=l)}return a}return Rs=r,Rs}var Ps,wp;function Q1(){if(wp)return Ps;wp=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 Ps=e,Ps}var As,Cp;function Bb(){if(Cp)return As;Cp=1;var e=Q1(),t=Math.max;function r(n,i,o){return i=t(i===void 0?n.length-1:i,0),function(){for(var s=arguments,a=-1,c=t(s.length-i,0),u=Array(c);++a<c;)u[a]=s[i+a];a=-1;for(var l=Array(i+1);++a<i;)l[a]=s[a];return l[i]=o(u),e(n,this,l)}}return As=r,As}var Ts,Sp;function eC(){if(Sp)return Ts;Sp=1;var e=yl(),t=ib(),r=ht(),n=t?function(i,o){return t(i,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:r;return Ts=n,Ts}var Is,_p;function rC(){if(_p)return Is;_p=1;var e=800,t=16,r=Date.now;function n(i){var o=0,s=0;return function(){var a=r(),c=t-(a-s);if(s=a,c>0){if(++o>=e)return arguments[0]}else o=0;return i.apply(void 0,arguments)}}return Is=n,Is}var Os,Ep;function zb(){if(Ep)return Os;Ep=1;var e=eC(),t=rC(),r=t(e);return Os=r,Os}var Ms,jp;function no(){if(jp)return Ms;jp=1;var e=ht(),t=Bb(),r=zb();function n(i,o){return r(t(i,o,e),i+"")}return Ms=n,Ms}var qs,kp;function Db(){if(kp)return qs;kp=1;function e(t,r,n,i){for(var o=t.length,s=n+(i?1:-1);i?s--:++s<o;)if(r(t[s],s,t))return s;return-1}return qs=e,qs}var $s,Rp;function tC(){if(Rp)return $s;Rp=1;function e(t){return t!==t}return $s=e,$s}var Ns,Pp;function nC(){if(Pp)return Ns;Pp=1;function e(t,r,n){for(var i=n-1,o=t.length;++i<o;)if(t[i]===r)return i;return-1}return Ns=e,Ns}var Ls,Ap;function oC(){if(Ap)return Ls;Ap=1;var e=Db(),t=tC(),r=nC();function n(i,o,s){return o===o?r(i,o,s):e(i,t,s)}return Ls=n,Ls}var Fs,Tp;function iC(){if(Tp)return Fs;Tp=1;var e=oC();function t(r,n){var i=r==null?0:r.length;return!!i&&e(r,n,0)>-1}return Fs=t,Fs}var Bs,Ip;function aC(){if(Ip)return Bs;Ip=1;function e(t,r,n){for(var i=-1,o=t==null?0:t.length;++i<o;)if(n(r,t[i]))return!0;return!1}return Bs=e,Bs}var zs,Op;function sC(){if(Op)return zs;Op=1;function e(){}return zs=e,zs}var Ds,Mp;function cC(){if(Mp)return Ds;Mp=1;var e=gb(),t=sC(),r=vl(),n=1/0,i=e&&1/r(new e([,-0]))[1]==n?function(o){return new e(o)}:t;return Ds=i,Ds}var Vs,qp;function uC(){if(qp)return Vs;qp=1;var e=_b(),t=iC(),r=aC(),n=Eb(),i=cC(),o=vl(),s=200;function a(c,u,l){var d=-1,h=t,p=c.length,y=!0,m=[],g=m;if(l)y=!1,h=r;else if(p>=s){var b=u?null:i(c);if(b)return o(b);y=!1,h=n,g=new e}else g=u?[]:m;e:for(;++d<p;){var w=c[d],v=u?u(w):w;if(w=l||w!==0?w:0,y&&v===v){for(var x=g.length;x--;)if(g[x]===v)continue e;u&&g.push(v),m.push(w)}else h(g,v,l)||(g!==m&&g.push(v),m.push(w))}return m}return Vs=a,Vs}var Ws,$p;function Vb(){if($p)return Ws;$p=1;var e=Fr(),t=Mr();function r(n){return t(n)&&e(n)}return Ws=r,Ws}var Gs,Np;function lC(){if(Np)return Gs;Np=1;var e=wl(),t=no(),r=uC(),n=Vb(),i=t(function(o){return r(e(o,1,n,!0))});return Gs=i,Gs}var Us,Lp;function dC(){if(Lp)return Us;Lp=1;var e=eo();function t(r,n){return e(n,function(i){return r[i]})}return Us=t,Us}var Hs,Fp;function Wb(){if(Fp)return Hs;Fp=1;var e=dC(),t=Qr();function r(n){return n==null?[]:e(n,t(n))}return Hs=r,Hs}var Ks,Bp;function jr(){if(Bp)return Ks;Bp=1;var e;if(typeof al=="function")try{e={clone:b1(),constant:yl(),each:Sb(),filter:Mb(),has:qb(),isArray:rr(),isEmpty:D1(),isFunction:fn(),isUndefined:$b(),keys:Qr(),map:Lb(),reduce:Fb(),size:Z1(),transform:Y1(),union:lC(),values:Wb()}}catch{}return e||(e=window._),Ks=e,Ks}var Js,zp;function Cl(){if(zp)return Js;zp=1;var e=jr();Js=i;var t="\0",r="\0",n="";function i(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={}}i.prototype._nodeCount=0,i.prototype._edgeCount=0,i.prototype.isDirected=function(){return this._isDirected},i.prototype.isMultigraph=function(){return this._isMultigraph},i.prototype.isCompound=function(){return this._isCompound},i.prototype.setGraph=function(l){return this._label=l,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultNodeLabelFn=l,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return e.keys(this._nodes)},i.prototype.sources=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._in[d])})},i.prototype.sinks=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._out[d])})},i.prototype.setNodes=function(l,d){var h=arguments,p=this;return e.each(l,function(y){h.length>1?p.setNode(y,d):p.setNode(y)}),this},i.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)},i.prototype.node=function(l){return this._nodes[l]},i.prototype.hasNode=function(l){return e.has(this._nodes,l)},i.prototype.removeNode=function(l){var d=this;if(e.has(this._nodes,l)){var h=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]),h),delete this._in[l],delete this._preds[l],e.each(e.keys(this._out[l]),h),delete this._out[l],delete this._sucs[l],--this._nodeCount}return this},i.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 h=d;!e.isUndefined(h);h=this.parent(h))if(h===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},i.prototype._removeFromParentsChildList=function(l){delete this._children[this._parent[l]][l]},i.prototype.parent=function(l){if(this._isCompound){var d=this._parent[l];if(d!==r)return d}},i.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[]}},i.prototype.predecessors=function(l){var d=this._preds[l];if(d)return e.keys(d)},i.prototype.successors=function(l){var d=this._sucs[l];if(d)return e.keys(d)},i.prototype.neighbors=function(l){var d=this.predecessors(l);if(d)return e.union(d,this.successors(l))},i.prototype.isLeaf=function(l){var d;return this.isDirected()?d=this.successors(l):d=this.neighbors(l),d.length===0},i.prototype.filterNodes=function(l){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var h=this;e.each(this._nodes,function(m,g){l(g)&&d.setNode(g,m)}),e.each(this._edgeObjs,function(m){d.hasNode(m.v)&&d.hasNode(m.w)&&d.setEdge(m,h.edge(m))});var p={};function y(m){var g=h.parent(m);return g===void 0||d.hasNode(g)?(p[m]=g,g):g in p?p[g]:y(g)}return this._isCompound&&e.each(d.nodes(),function(m){d.setParent(m,y(m))}),d},i.prototype.setDefaultEdgeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultEdgeLabelFn=l,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return e.values(this._edgeObjs)},i.prototype.setPath=function(l,d){var h=this,p=arguments;return e.reduce(l,function(y,m){return p.length>1?h.setEdge(y,m,d):h.setEdge(y,m),m}),this},i.prototype.setEdge=function(){var l,d,h,p,y=!1,m=arguments[0];typeof m=="object"&&m!==null&&"v"in m?(l=m.v,d=m.w,h=m.name,arguments.length===2&&(p=arguments[1],y=!0)):(l=m,d=arguments[1],h=arguments[3],arguments.length>2&&(p=arguments[2],y=!0)),l=""+l,d=""+d,e.isUndefined(h)||(h=""+h);var g=a(this._isDirected,l,d,h);if(e.has(this._edgeLabels,g))return y&&(this._edgeLabels[g]=p),this;if(!e.isUndefined(h)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(l),this.setNode(d),this._edgeLabels[g]=y?p:this._defaultEdgeLabelFn(l,d,h);var b=c(this._isDirected,l,d,h);return l=b.v,d=b.w,Object.freeze(b),this._edgeObjs[g]=b,o(this._preds[d],l),o(this._sucs[l],d),this._in[d][g]=b,this._out[l][g]=b,this._edgeCount++,this},i.prototype.edge=function(l,d,h){var p=arguments.length===1?u(this._isDirected,arguments[0]):a(this._isDirected,l,d,h);return this._edgeLabels[p]},i.prototype.hasEdge=function(l,d,h){var p=arguments.length===1?u(this._isDirected,arguments[0]):a(this._isDirected,l,d,h);return e.has(this._edgeLabels,p)},i.prototype.removeEdge=function(l,d,h){var p=arguments.length===1?u(this._isDirected,arguments[0]):a(this._isDirected,l,d,h),y=this._edgeObjs[p];return y&&(l=y.v,d=y.w,delete this._edgeLabels[p],delete this._edgeObjs[p],s(this._preds[d],l),s(this._sucs[l],d),delete this._in[d][p],delete this._out[l][p],this._edgeCount--),this},i.prototype.inEdges=function(l,d){var h=this._in[l];if(h){var p=e.values(h);return d?e.filter(p,function(y){return y.v===d}):p}},i.prototype.outEdges=function(l,d){var h=this._out[l];if(h){var p=e.values(h);return d?e.filter(p,function(y){return y.w===d}):p}},i.prototype.nodeEdges=function(l,d){var h=this.inEdges(l,d);if(h)return h.concat(this.outEdges(l,d))};function o(l,d){l[d]?l[d]++:l[d]=1}function s(l,d){--l[d]||delete l[d]}function a(l,d,h,p){var y=""+d,m=""+h;if(!l&&y>m){var g=y;y=m,m=g}return y+n+m+n+(e.isUndefined(p)?t:p)}function c(l,d,h,p){var y=""+d,m=""+h;if(!l&&y>m){var g=y;y=m,m=g}var b={v:y,w:m};return p&&(b.name=p),b}function u(l,d){return a(l,d.v,d.w,d.name)}return Js}var Zs,Dp;function fC(){return Dp||(Dp=1,Zs="2.1.8"),Zs}var Ys,Vp;function hC(){return Vp||(Vp=1,Ys={Graph:Cl(),version:fC()}),Ys}var Xs,Wp;function pC(){if(Wp)return Xs;Wp=1;var e=jr(),t=Cl();Xs={write:r,read:o};function r(s){var a={options:{directed:s.isDirected(),multigraph:s.isMultigraph(),compound:s.isCompound()},nodes:n(s),edges:i(s)};return e.isUndefined(s.graph())||(a.value=e.clone(s.graph())),a}function n(s){return e.map(s.nodes(),function(a){var c=s.node(a),u=s.parent(a),l={v:a};return e.isUndefined(c)||(l.value=c),e.isUndefined(u)||(l.parent=u),l})}function i(s){return e.map(s.edges(),function(a){var c=s.edge(a),u={v:a.v,w:a.w};return e.isUndefined(a.name)||(u.name=a.name),e.isUndefined(c)||(u.value=c),u})}function o(s){var a=new t(s.options).setGraph(s.value);return e.each(s.nodes,function(c){a.setNode(c.v,c.value),c.parent&&a.setParent(c.v,c.parent)}),e.each(s.edges,function(c){a.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),a}return Xs}var Qs,Gp;function gC(){if(Gp)return Qs;Gp=1;var e=jr();Qs=t;function t(r){var n={},i=[],o;function s(a){e.has(n,a)||(n[a]=!0,o.push(a),e.each(r.successors(a),s),e.each(r.predecessors(a),s))}return e.each(r.nodes(),function(a){o=[],s(a),o.length&&i.push(o)}),i}return Qs}var ec,Up;function Gb(){if(Up)return ec;Up=1;var e=jr();ec=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 i=this._keyIndices;if(r=String(r),!e.has(i,r)){var o=this._arr,s=o.length;return i[r]=s,o.push({key:r,priority:n}),this._decrease(s),!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 i=this._keyIndices[r];if(n>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[i].priority+" New: "+n);this._arr[i].priority=n,this._decrease(i)},t.prototype._heapify=function(r){var n=this._arr,i=2*r,o=i+1,s=r;i<n.length&&(s=n[i].priority<n[s].priority?i:s,o<n.length&&(s=n[o].priority<n[s].priority?o:s),s!==r&&(this._swap(r,s),this._heapify(s)))},t.prototype._decrease=function(r){for(var n=this._arr,i=n[r].priority,o;r!==0&&(o=r>>1,!(n[o].priority<i));)this._swap(r,o),r=o},t.prototype._swap=function(r,n){var i=this._arr,o=this._keyIndices,s=i[r],a=i[n];i[r]=a,i[n]=s,o[a.key]=r,o[s.key]=n},ec}var rc,Hp;function Ub(){if(Hp)return rc;Hp=1;var e=jr(),t=Gb();rc=n;var r=e.constant(1);function n(o,s,a,c){return i(o,String(s),a||r,c||function(u){return o.outEdges(u)})}function i(o,s,a,c){var u={},l=new t,d,h,p=function(y){var m=y.v!==d?y.v:y.w,g=u[m],b=a(y),w=h.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+y+" Weight: "+b);w<g.distance&&(g.distance=w,g.predecessor=d,l.decrease(m,w))};for(o.nodes().forEach(function(y){var m=y===s?0:Number.POSITIVE_INFINITY;u[y]={distance:m},l.add(y,m)});l.size()>0&&(d=l.removeMin(),h=u[d],h.distance!==Number.POSITIVE_INFINITY);)c(d).forEach(p);return u}return rc}var tc,Kp;function yC(){if(Kp)return tc;Kp=1;var e=Ub(),t=jr();tc=r;function r(n,i,o){return t.transform(n.nodes(),function(s,a){s[a]=e(n,a,i,o)},{})}return tc}var nc,Jp;function Hb(){if(Jp)return nc;Jp=1;var e=jr();nc=t;function t(r){var n=0,i=[],o={},s=[];function a(c){var u=o[c]={onStack:!0,lowlink:n,index:n++};if(i.push(c),r.successors(c).forEach(function(h){e.has(o,h)?o[h].onStack&&(u.lowlink=Math.min(u.lowlink,o[h].index)):(a(h),u.lowlink=Math.min(u.lowlink,o[h].lowlink))}),u.lowlink===u.index){var l=[],d;do d=i.pop(),o[d].onStack=!1,l.push(d);while(c!==d);s.push(l)}}return r.nodes().forEach(function(c){e.has(o,c)||a(c)}),s}return nc}var oc,Zp;function mC(){if(Zp)return oc;Zp=1;var e=jr(),t=Hb();oc=r;function r(n){return e.filter(t(n),function(i){return i.length>1||i.length===1&&n.hasEdge(i[0],i[0])})}return oc}var ic,Yp;function bC(){if(Yp)return ic;Yp=1;var e=jr();ic=r;var t=e.constant(1);function r(i,o,s){return n(i,o||t,s||function(a){return i.outEdges(a)})}function n(i,o,s){var a={},c=i.nodes();return c.forEach(function(u){a[u]={},a[u][u]={distance:0},c.forEach(function(l){u!==l&&(a[u][l]={distance:Number.POSITIVE_INFINITY})}),s(u).forEach(function(l){var d=l.v===u?l.w:l.v,h=o(l);a[u][d]={distance:h,predecessor:u}})}),c.forEach(function(u){var l=a[u];c.forEach(function(d){var h=a[d];c.forEach(function(p){var y=h[u],m=l[p],g=h[p],b=y.distance+m.distance;b<g.distance&&(g.distance=b,g.predecessor=m.predecessor)})})}),a}return ic}var ac,Xp;function Kb(){if(Xp)return ac;Xp=1;var e=jr();ac=t,t.CycleException=r;function t(n){var i={},o={},s=[];function a(c){if(e.has(o,c))throw new r;e.has(i,c)||(o[c]=!0,i[c]=!0,e.each(n.predecessors(c),a),delete o[c],s.push(c))}if(e.each(n.sinks(),a),e.size(i)!==n.nodeCount())throw new r;return s}function r(){}return r.prototype=new Error,ac}var sc,Qp;function vC(){if(Qp)return sc;Qp=1;var e=Kb();sc=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return sc}var cc,eg;function Jb(){if(eg)return cc;eg=1;var e=jr();cc=t;function t(n,i,o){e.isArray(i)||(i=[i]);var s=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],c={};return e.each(i,function(u){if(!n.hasNode(u))throw new Error("Graph does not have node: "+u);r(n,u,o==="post",c,s,a)}),a}function r(n,i,o,s,a,c){e.has(s,i)||(s[i]=!0,o||c.push(i),e.each(a(i),function(u){r(n,u,o,s,a,c)}),o&&c.push(i))}return cc}var uc,rg;function xC(){if(rg)return uc;rg=1;var e=Jb();uc=t;function t(r,n){return e(r,n,"post")}return uc}var lc,tg;function wC(){if(tg)return lc;tg=1;var e=Jb();lc=t;function t(r,n){return e(r,n,"pre")}return lc}var dc,ng;function CC(){if(ng)return dc;ng=1;var e=jr(),t=Cl(),r=Gb();dc=n;function n(i,o){var s=new t,a={},c=new r,u;function l(h){var p=h.v===u?h.w:h.v,y=c.priority(p);if(y!==void 0){var m=o(h);m<y&&(a[p]=u,c.decrease(p,m))}}if(i.nodeCount()===0)return s;e.each(i.nodes(),function(h){c.add(h,Number.POSITIVE_INFINITY),s.setNode(h)}),c.decrease(i.nodes()[0],0);for(var d=!1;c.size()>0;){if(u=c.removeMin(),e.has(a,u))s.setEdge(u,a[u]);else{if(d)throw new Error("Input graph is not connected: "+i);d=!0}i.nodeEdges(u).forEach(l)}return s}return dc}var fc,og;function SC(){return og||(og=1,fc={components:gC(),dijkstra:Ub(),dijkstraAll:yC(),findCycles:mC(),floydWarshall:bC(),isAcyclic:vC(),postorder:xC(),preorder:wC(),prim:CC(),tarjan:Hb(),topsort:Kb()}),fc}var hc,ig;function _C(){if(ig)return hc;ig=1;var e=hC();return hc={Graph:e.Graph,json:pC(),alg:SC(),version:e.version},hc}var pc,ag;function Pr(){if(ag)return pc;ag=1;var e;if(typeof al=="function")try{e=_C()}catch{}return e||(e=window.graphlib),pc=e,pc}var gc,sg;function EC(){if(sg)return gc;sg=1;var e=xb(),t=1,r=4;function n(i){return e(i,t|r)}return gc=n,gc}var yc,cg;function oo(){if(cg)return yc;cg=1;var e=It(),t=Fr(),r=Jn(),n=Er();function i(o,s,a){if(!n(a))return!1;var c=typeof s;return(c=="number"?t(a)&&r(s,a.length):c=="string"&&s in a)?e(a[s],o):!1}return yc=i,yc}var mc,ug;function jC(){if(ug)return mc;ug=1;var e=no(),t=It(),r=oo(),n=ft(),i=Object.prototype,o=i.hasOwnProperty,s=e(function(a,c){a=Object(a);var u=-1,l=c.length,d=l>2?c[2]:void 0;for(d&&r(c[0],c[1],d)&&(l=1);++u<l;)for(var h=c[u],p=n(h),y=-1,m=p.length;++y<m;){var g=p[y],b=a[g];(b===void 0||t(b,i[g])&&!o.call(a,g))&&(a[g]=h[g])}return a});return mc=s,mc}var bc,lg;function kC(){if(lg)return bc;lg=1;var e=Br(),t=Fr(),r=Qr();function n(i){return function(o,s,a){var c=Object(o);if(!t(o)){var u=e(s,3);o=r(o),s=function(d){return u(c[d],d,c)}}var l=i(o,s,a);return l>-1?c[u?o[l]:l]:void 0}}return bc=n,bc}var vc,dg;function RC(){if(dg)return vc;dg=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return vc=t,vc}var xc,fg;function PC(){if(fg)return xc;fg=1;var e=RC(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return xc=r,xc}var wc,hg;function AC(){if(hg)return wc;hg=1;var e=PC(),t=Er(),r=$t(),n=NaN,i=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt;function c(u){if(typeof u=="number")return u;if(r(u))return n;if(t(u)){var l=typeof u.valueOf=="function"?u.valueOf():u;u=t(l)?l+"":l}if(typeof u!="string")return u===0?u:+u;u=e(u);var d=o.test(u);return d||s.test(u)?a(u.slice(2),d?2:8):i.test(u)?n:+u}return wc=c,wc}var Cc,pg;function Zb(){if(pg)return Cc;pg=1;var e=AC(),t=1/0,r=17976931348623157e292;function n(i){if(!i)return i===0?i:0;if(i=e(i),i===t||i===-t){var o=i<0?-1:1;return o*r}return i===i?i:0}return Cc=n,Cc}var Sc,gg;function TC(){if(gg)return Sc;gg=1;var e=Zb();function t(r){var n=e(r),i=n%1;return n===n?i?n-i:n:0}return Sc=t,Sc}var _c,yg;function IC(){if(yg)return _c;yg=1;var e=Db(),t=Br(),r=TC(),n=Math.max;function i(o,s,a){var c=o==null?0:o.length;if(!c)return-1;var u=a==null?0:r(a);return u<0&&(u=n(c+u,0)),e(o,t(s,3),u)}return _c=i,_c}var Ec,mg;function OC(){if(mg)return Ec;mg=1;var e=kC(),t=IC(),r=e(t);return Ec=r,Ec}var jc,bg;function Yb(){if(bg)return jc;bg=1;var e=wl();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return jc=t,jc}var kc,vg;function MC(){if(vg)return kc;vg=1;var e=ml(),t=wb(),r=ft();function n(i,o){return i==null?i:e(i,t(o),r)}return kc=n,kc}var Rc,xg;function qC(){if(xg)return Rc;xg=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return Rc=e,Rc}var Pc,wg;function $C(){if(wg)return Pc;wg=1;var e=Hn(),t=bl(),r=Br();function n(i,o){var s={};return o=r(o,3),t(i,function(a,c,u){e(s,c,o(a,c,u))}),s}return Pc=n,Pc}var Ac,Cg;function Sl(){if(Cg)return Ac;Cg=1;var e=$t();function t(r,n,i){for(var o=-1,s=r.length;++o<s;){var a=r[o],c=n(a);if(c!=null&&(u===void 0?c===c&&!e(c):i(c,u)))var u=c,l=a}return l}return Ac=t,Ac}var Tc,Sg;function NC(){if(Sg)return Tc;Sg=1;function e(t,r){return t>r}return Tc=e,Tc}var Ic,_g;function LC(){if(_g)return Ic;_g=1;var e=Sl(),t=NC(),r=ht();function n(i){return i&&i.length?e(i,r,t):void 0}return Ic=n,Ic}var Oc,Eg;function Xb(){if(Eg)return Oc;Eg=1;var e=Hn(),t=It();function r(n,i,o){(o!==void 0&&!t(n[i],o)||o===void 0&&!(i in n))&&e(n,i,o)}return Oc=r,Oc}var Mc,jg;function FC(){if(jg)return Mc;jg=1;var e=lt(),t=Xn(),r=Mr(),n="[object Object]",i=Function.prototype,o=Object.prototype,s=i.toString,a=o.hasOwnProperty,c=s.call(Object);function u(l){if(!r(l)||e(l)!=n)return!1;var d=t(l);if(d===null)return!0;var h=a.call(d,"constructor")&&d.constructor;return typeof h=="function"&&h instanceof h&&s.call(h)==c}return Mc=u,Mc}var qc,kg;function Qb(){if(kg)return qc;kg=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return qc=e,qc}var $c,Rg;function BC(){if(Rg)return $c;Rg=1;var e=hn(),t=ft();function r(n){return e(n,t(n))}return $c=r,$c}var Nc,Pg;function zC(){if(Pg)return Nc;Pg=1;var e=Xb(),t=cb(),r=mb(),n=ub(),i=vb(),o=pn(),s=rr(),a=Vb(),c=Mt(),u=fn(),l=Er(),d=FC(),h=gn(),p=Qb(),y=BC();function m(g,b,w,v,x,C,S){var k=p(g,w),I=p(b,w),R=S.get(I);if(R){e(g,w,R);return}var M=C?C(k,I,w+"",g,b,S):void 0,E=M===void 0;if(E){var P=s(I),A=!P&&c(I),j=!P&&!A&&h(I);M=I,P||A||j?s(k)?M=k:a(k)?M=n(k):A?(E=!1,M=t(I,!0)):j?(E=!1,M=r(I,!0)):M=[]:d(I)||o(I)?(M=k,o(k)?M=y(k):(!l(k)||u(k))&&(M=i(I))):E=!1}E&&(S.set(I,M),x(M,I,v,C,S),S.delete(I)),e(g,w,M)}return Nc=m,Nc}var Lc,Ag;function DC(){if(Ag)return Lc;Ag=1;var e=Un(),t=Xb(),r=ml(),n=zC(),i=Er(),o=ft(),s=Qb();function a(c,u,l,d,h){c!==u&&r(u,function(p,y){if(h||(h=new e),i(p))n(c,u,y,l,a,d,h);else{var m=d?d(s(c,y),p,y+"",c,u,h):void 0;m===void 0&&(m=p),t(c,y,m)}},o)}return Lc=a,Lc}var Fc,Tg;function VC(){if(Tg)return Fc;Tg=1;var e=no(),t=oo();function r(n){return e(function(i,o){var s=-1,a=o.length,c=a>1?o[a-1]:void 0,u=a>2?o[2]:void 0;for(c=n.length>3&&typeof c=="function"?(a--,c):void 0,u&&t(o[0],o[1],u)&&(c=a<3?void 0:c,a=1),i=Object(i);++s<a;){var l=o[s];l&&n(i,l,s,c)}return i})}return Fc=r,Fc}var Bc,Ig;function WC(){if(Ig)return Bc;Ig=1;var e=DC(),t=VC(),r=t(function(n,i,o){e(n,i,o)});return Bc=r,Bc}var zc,Og;function ev(){if(Og)return zc;Og=1;function e(t,r){return t<r}return zc=e,zc}var Dc,Mg;function GC(){if(Mg)return Dc;Mg=1;var e=Sl(),t=ev(),r=ht();function n(i){return i&&i.length?e(i,r,t):void 0}return Dc=n,Dc}var Vc,qg;function UC(){if(qg)return Vc;qg=1;var e=Sl(),t=Br(),r=ev();function n(i,o){return i&&i.length?e(i,t(o,2),r):void 0}return Vc=n,Vc}var Wc,$g;function HC(){if($g)return Wc;$g=1;var e=Ar(),t=function(){return e.Date.now()};return Wc=t,Wc}var Gc,Ng;function KC(){if(Ng)return Gc;Ng=1;var e=Kn(),t=ro(),r=Jn(),n=Er(),i=yn();function o(s,a,c,u){if(!n(s))return s;a=t(a,s);for(var l=-1,d=a.length,h=d-1,p=s;p!=null&&++l<d;){var y=i(a[l]),m=c;if(y==="__proto__"||y==="constructor"||y==="prototype")return s;if(l!=h){var g=p[y];m=u?u(g,y,p):void 0,m===void 0&&(m=n(g)?g:r(a[l+1])?[]:{})}e(p,y,m),p=p[y]}return s}return Gc=o,Gc}var Uc,Lg;function JC(){if(Lg)return Uc;Lg=1;var e=to(),t=KC(),r=ro();function n(i,o,s){for(var a=-1,c=o.length,u={};++a<c;){var l=o[a],d=e(i,l);s(d,l)&&t(u,r(l,i),d)}return u}return Uc=n,Uc}var Hc,Fg;function ZC(){if(Fg)return Hc;Fg=1;var e=JC(),t=Ib();function r(n,i){return e(n,i,function(o,s){return t(n,s)})}return Hc=r,Hc}var Kc,Bg;function YC(){if(Bg)return Kc;Bg=1;var e=Yb(),t=Bb(),r=zb();function n(i){return r(t(i,void 0,e),i+"")}return Kc=n,Kc}var Jc,zg;function XC(){if(zg)return Jc;zg=1;var e=ZC(),t=YC(),r=t(function(n,i){return n==null?{}:e(n,i)});return Jc=r,Jc}var Zc,Dg;function QC(){if(Dg)return Zc;Dg=1;var e=Math.ceil,t=Math.max;function r(n,i,o,s){for(var a=-1,c=t(e((i-n)/(o||1)),0),u=Array(c);c--;)u[s?c:++a]=n,n+=o;return u}return Zc=r,Zc}var Yc,Vg;function eS(){if(Vg)return Yc;Vg=1;var e=QC(),t=oo(),r=Zb();function n(i){return function(o,s,a){return a&&typeof a!="number"&&t(o,s,a)&&(s=a=void 0),o=r(o),s===void 0?(s=o,o=0):s=r(s),a=a===void 0?o<s?1:-1:r(a),e(o,s,a,i)}}return Yc=n,Yc}var Xc,Wg;function rS(){if(Wg)return Xc;Wg=1;var e=eS(),t=e();return Xc=t,Xc}var Qc,Gg;function tS(){if(Gg)return Qc;Gg=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return Qc=e,Qc}var eu,Ug;function nS(){if(Ug)return eu;Ug=1;var e=$t();function t(r,n){if(r!==n){var i=r!==void 0,o=r===null,s=r===r,a=e(r),c=n!==void 0,u=n===null,l=n===n,d=e(n);if(!u&&!d&&!a&&r>n||a&&c&&l&&!u&&!d||o&&c&&l||!i&&l||!s)return 1;if(!o&&!a&&!d&&r<n||d&&i&&s&&!o&&!a||u&&i&&s||!c&&s||!l)return-1}return 0}return eu=t,eu}var ru,Hg;function oS(){if(Hg)return ru;Hg=1;var e=nS();function t(r,n,i){for(var o=-1,s=r.criteria,a=n.criteria,c=s.length,u=i.length;++o<c;){var l=e(s[o],a[o]);if(l){if(o>=u)return l;var d=i[o];return l*(d=="desc"?-1:1)}}return r.index-n.index}return ru=t,ru}var tu,Kg;function iS(){if(Kg)return tu;Kg=1;var e=eo(),t=to(),r=Br(),n=Nb(),i=tS(),o=Zn(),s=oS(),a=ht(),c=rr();function u(l,d,h){d.length?d=e(d,function(m){return c(m)?function(g){return t(g,m.length===1?m[0]:m)}:m}):d=[a];var p=-1;d=e(d,o(r));var y=n(l,function(m,g,b){var w=e(d,function(v){return v(m)});return{criteria:w,index:++p,value:m}});return i(y,function(m,g){return s(m,g,h)})}return tu=u,tu}var nu,Jg;function aS(){if(Jg)return nu;Jg=1;var e=wl(),t=iS(),r=no(),n=oo(),i=r(function(o,s){if(o==null)return[];var a=s.length;return a>1&&n(o,s[0],s[1])?s=[]:a>2&&n(s[0],s[1],s[2])&&(s=[s[0]]),t(o,e(s,1),[])});return nu=i,nu}var ou,Zg;function sS(){if(Zg)return ou;Zg=1;var e=Ab(),t=0;function r(n){var i=++t;return e(n)+i}return ou=r,ou}var iu,Yg;function cS(){if(Yg)return iu;Yg=1;function e(t,r,n){for(var i=-1,o=t.length,s=r.length,a={};++i<o;){var c=i<s?r[i]:void 0;n(a,t[i],c)}return a}return iu=e,iu}var au,Xg;function uS(){if(Xg)return au;Xg=1;var e=Kn(),t=cS();function r(n,i){return t(n||[],i||[],e)}return au=r,au}var su,Qg;function Je(){if(Qg)return su;Qg=1;var e;if(typeof al=="function")try{e={cloneDeep:EC(),constant:yl(),defaults:jC(),each:Sb(),filter:Mb(),find:OC(),flatten:Yb(),forEach:Cb(),forIn:MC(),has:qb(),isUndefined:$b(),last:qC(),map:Lb(),mapValues:$C(),max:LC(),merge:WC(),min:GC(),minBy:UC(),now:HC(),pick:XC(),range:rS(),reduce:Fb(),sortBy:aS(),uniqueId:sS(),values:Wb(),zipObject:uS()}}catch{}return e||(e=window._),su=e,su}var cu,ey;function lS(){if(ey)return cu;ey=1,cu=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,i=n._prev;if(i!==n)return t(i),i},e.prototype.enqueue=function(n){var i=this._sentinel;n._prev&&n._next&&t(n),n._next=i._next,i._next._prev=n,i._next=n,n._prev=i},e.prototype.toString=function(){for(var n=[],i=this._sentinel,o=i._prev;o!==i;)n.push(JSON.stringify(o,r)),o=o._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,i){if(n!=="_next"&&n!=="_prev")return i}return cu}var uu,ry;function dS(){if(ry)return uu;ry=1;var e=Je(),t=Pr().Graph,r=lS();uu=i;var n=e.constant(1);function i(u,l){if(u.nodeCount()<=1)return[];var d=a(u,l||n),h=o(d.graph,d.buckets,d.zeroIdx);return e.flatten(e.map(h,function(p){return u.outEdges(p.v,p.w)}),!0)}function o(u,l,d){for(var h=[],p=l[l.length-1],y=l[0],m;u.nodeCount();){for(;m=y.dequeue();)s(u,l,d,m);for(;m=p.dequeue();)s(u,l,d,m);if(u.nodeCount()){for(var g=l.length-2;g>0;--g)if(m=l[g].dequeue(),m){h=h.concat(s(u,l,d,m,!0));break}}}return h}function s(u,l,d,h,p){var y=p?[]:void 0;return e.forEach(u.inEdges(h.v),function(m){var g=u.edge(m),b=u.node(m.v);p&&y.push({v:m.v,w:m.w}),b.out-=g,c(l,d,b)}),e.forEach(u.outEdges(h.v),function(m){var g=u.edge(m),b=m.w,w=u.node(b);w.in-=g,c(l,d,w)}),u.removeNode(h.v),y}function a(u,l){var d=new t,h=0,p=0;e.forEach(u.nodes(),function(g){d.setNode(g,{v:g,in:0,out:0})}),e.forEach(u.edges(),function(g){var b=d.edge(g.v,g.w)||0,w=l(g),v=b+w;d.setEdge(g.v,g.w,v),p=Math.max(p,d.node(g.v).out+=w),h=Math.max(h,d.node(g.w).in+=w)});var y=e.range(p+h+3).map(function(){return new r}),m=h+1;return e.forEach(d.nodes(),function(g){c(y,m,d.node(g))}),{graph:d,buckets:y,zeroIdx:m}}function c(u,l,d){d.out?d.in?u[d.out-d.in+l].enqueue(d):u[u.length-1].enqueue(d):u[0].enqueue(d)}return uu}var lu,ty;function fS(){if(ty)return lu;ty=1;var e=Je(),t=dS();lu={run:r,undo:i};function r(o){var s=o.graph().acyclicer==="greedy"?t(o,a(o)):n(o);e.forEach(s,function(c){var u=o.edge(c);o.removeEdge(c),u.forwardName=c.name,u.reversed=!0,o.setEdge(c.w,c.v,u,e.uniqueId("rev"))});function a(c){return function(u){return c.edge(u).weight}}}function n(o){var s=[],a={},c={};function u(l){e.has(c,l)||(c[l]=!0,a[l]=!0,e.forEach(o.outEdges(l),function(d){e.has(a,d.w)?s.push(d):u(d.w)}),delete a[l])}return e.forEach(o.nodes(),u),s}function i(o){e.forEach(o.edges(),function(s){var a=o.edge(s);if(a.reversed){o.removeEdge(s);var c=a.forwardName;delete a.reversed,delete a.forwardName,o.setEdge(s.w,s.v,a,c)}})}return lu}var du,ny;function mr(){if(ny)return du;ny=1;var e=Je(),t=Pr().Graph;du={addDummyNode:r,simplify:n,asNonCompoundGraph:i,successorWeights:o,predecessorWeights:s,intersectRect:a,buildLayerMatrix:c,normalizeRanks:u,removeEmptyRanks:l,addBorderNode:d,maxRank:h,partition:p,time:y,notime:m};function r(g,b,w,v){var x;do x=e.uniqueId(v);while(g.hasNode(x));return w.dummy=b,g.setNode(x,w),x}function n(g){var b=new t().setGraph(g.graph());return e.forEach(g.nodes(),function(w){b.setNode(w,g.node(w))}),e.forEach(g.edges(),function(w){var v=b.edge(w.v,w.w)||{weight:0,minlen:1},x=g.edge(w);b.setEdge(w.v,w.w,{weight:v.weight+x.weight,minlen:Math.max(v.minlen,x.minlen)})}),b}function i(g){var b=new t({multigraph:g.isMultigraph()}).setGraph(g.graph());return e.forEach(g.nodes(),function(w){g.children(w).length||b.setNode(w,g.node(w))}),e.forEach(g.edges(),function(w){b.setEdge(w,g.edge(w))}),b}function o(g){var b=e.map(g.nodes(),function(w){var v={};return e.forEach(g.outEdges(w),function(x){v[x.w]=(v[x.w]||0)+g.edge(x).weight}),v});return e.zipObject(g.nodes(),b)}function s(g){var b=e.map(g.nodes(),function(w){var v={};return e.forEach(g.inEdges(w),function(x){v[x.v]=(v[x.v]||0)+g.edge(x).weight}),v});return e.zipObject(g.nodes(),b)}function a(g,b){var w=g.x,v=g.y,x=b.x-w,C=b.y-v,S=g.width/2,k=g.height/2;if(!x&&!C)throw new Error("Not possible to find intersection inside of the rectangle");var I,R;return Math.abs(C)*S>Math.abs(x)*k?(C<0&&(k=-k),I=k*x/C,R=k):(x<0&&(S=-S),I=S,R=S*C/x),{x:w+I,y:v+R}}function c(g){var b=e.map(e.range(h(g)+1),function(){return[]});return e.forEach(g.nodes(),function(w){var v=g.node(w),x=v.rank;e.isUndefined(x)||(b[x][v.order]=w)}),b}function u(g){var b=e.min(e.map(g.nodes(),function(w){return g.node(w).rank}));e.forEach(g.nodes(),function(w){var v=g.node(w);e.has(v,"rank")&&(v.rank-=b)})}function l(g){var b=e.min(e.map(g.nodes(),function(C){return g.node(C).rank})),w=[];e.forEach(g.nodes(),function(C){var S=g.node(C).rank-b;w[S]||(w[S]=[]),w[S].push(C)});var v=0,x=g.graph().nodeRankFactor;e.forEach(w,function(C,S){e.isUndefined(C)&&S%x!==0?--v:v&&e.forEach(C,function(k){g.node(k).rank+=v})})}function d(g,b,w,v){var x={width:0,height:0};return arguments.length>=4&&(x.rank=w,x.order=v),r(g,"border",x,b)}function h(g){return e.max(e.map(g.nodes(),function(b){var w=g.node(b).rank;if(!e.isUndefined(w))return w}))}function p(g,b){var w={lhs:[],rhs:[]};return e.forEach(g,function(v){b(v)?w.lhs.push(v):w.rhs.push(v)}),w}function y(g,b){var w=e.now();try{return b()}finally{console.log(g+" time: "+(e.now()-w)+"ms")}}function m(g,b){return b()}return du}var fu,oy;function hS(){if(oy)return fu;oy=1;var e=Je(),t=mr();fu={run:r,undo:i};function r(o){o.graph().dummyChains=[],e.forEach(o.edges(),function(s){n(o,s)})}function n(o,s){var a=s.v,c=o.node(a).rank,u=s.w,l=o.node(u).rank,d=s.name,h=o.edge(s),p=h.labelRank;if(l!==c+1){o.removeEdge(s);var y,m,g;for(g=0,++c;c<l;++g,++c)h.points=[],m={width:0,height:0,edgeLabel:h,edgeObj:s,rank:c},y=t.addDummyNode(o,"edge",m,"_d"),c===p&&(m.width=h.width,m.height=h.height,m.dummy="edge-label",m.labelpos=h.labelpos),o.setEdge(a,y,{weight:h.weight},d),g===0&&o.graph().dummyChains.push(y),a=y;o.setEdge(a,u,{weight:h.weight},d)}}function i(o){e.forEach(o.graph().dummyChains,function(s){var a=o.node(s),c=a.edgeLabel,u;for(o.setEdge(a.edgeObj,c);a.dummy;)u=o.successors(s)[0],o.removeNode(s),c.points.push({x:a.x,y:a.y}),a.dummy==="edge-label"&&(c.x=a.x,c.y=a.y,c.width=a.width,c.height=a.height),s=u,a=o.node(s)})}return fu}var hu,iy;function On(){if(iy)return hu;iy=1;var e=Je();hu={longestPath:t,slack:r};function t(n){var i={};function o(s){var a=n.node(s);if(e.has(i,s))return a.rank;i[s]=!0;var c=e.min(e.map(n.outEdges(s),function(u){return o(u.w)-n.edge(u).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),a.rank=c}e.forEach(n.sources(),o)}function r(n,i){return n.node(i.w).rank-n.node(i.v).rank-n.edge(i).minlen}return hu}var pu,ay;function rv(){if(ay)return pu;ay=1;var e=Je(),t=Pr().Graph,r=On().slack;pu=n;function n(a){var c=new t({directed:!1}),u=a.nodes()[0],l=a.nodeCount();c.setNode(u,{});for(var d,h;i(c,a)<l;)d=o(c,a),h=c.hasNode(d.v)?r(a,d):-r(a,d),s(c,a,h);return c}function i(a,c){function u(l){e.forEach(c.nodeEdges(l),function(d){var h=d.v,p=l===h?d.w:h;!a.hasNode(p)&&!r(c,d)&&(a.setNode(p,{}),a.setEdge(l,p,{}),u(p))})}return e.forEach(a.nodes(),u),a.nodeCount()}function o(a,c){return e.minBy(c.edges(),function(u){if(a.hasNode(u.v)!==a.hasNode(u.w))return r(c,u)})}function s(a,c,u){e.forEach(a.nodes(),function(l){c.node(l).rank+=u})}return pu}var gu,sy;function pS(){if(sy)return gu;sy=1;var e=Je(),t=rv(),r=On().slack,n=On().longestPath,i=Pr().alg.preorder,o=Pr().alg.postorder,s=mr().simplify;gu=a,a.initLowLimValues=d,a.initCutValues=c,a.calcCutValue=l,a.leaveEdge=p,a.enterEdge=y,a.exchangeEdges=m;function a(v){v=s(v),n(v);var x=t(v);d(x),c(x,v);for(var C,S;C=p(x);)S=y(x,v,C),m(x,v,C,S)}function c(v,x){var C=o(v,v.nodes());C=C.slice(0,C.length-1),e.forEach(C,function(S){u(v,x,S)})}function u(v,x,C){var S=v.node(C),k=S.parent;v.edge(C,k).cutvalue=l(v,x,C)}function l(v,x,C){var S=v.node(C),k=S.parent,I=!0,R=x.edge(C,k),M=0;return R||(I=!1,R=x.edge(k,C)),M=R.weight,e.forEach(x.nodeEdges(C),function(E){var P=E.v===C,A=P?E.w:E.v;if(A!==k){var j=P===I,q=x.edge(E).weight;if(M+=j?q:-q,b(v,C,A)){var O=v.edge(C,A).cutvalue;M+=j?-O:O}}}),M}function d(v,x){arguments.length<2&&(x=v.nodes()[0]),h(v,{},1,x)}function h(v,x,C,S,k){var I=C,R=v.node(S);return x[S]=!0,e.forEach(v.neighbors(S),function(M){e.has(x,M)||(C=h(v,x,C,M,S))}),R.low=I,R.lim=C++,k?R.parent=k:delete R.parent,C}function p(v){return e.find(v.edges(),function(x){return v.edge(x).cutvalue<0})}function y(v,x,C){var S=C.v,k=C.w;x.hasEdge(S,k)||(S=C.w,k=C.v);var I=v.node(S),R=v.node(k),M=I,E=!1;I.lim>R.lim&&(M=R,E=!0);var P=e.filter(x.edges(),function(A){return E===w(v,v.node(A.v),M)&&E!==w(v,v.node(A.w),M)});return e.minBy(P,function(A){return r(x,A)})}function m(v,x,C,S){var k=C.v,I=C.w;v.removeEdge(k,I),v.setEdge(S.v,S.w,{}),d(v),c(v,x),g(v,x)}function g(v,x){var C=e.find(v.nodes(),function(k){return!x.node(k).parent}),S=i(v,C);S=S.slice(1),e.forEach(S,function(k){var I=v.node(k).parent,R=x.edge(k,I),M=!1;R||(R=x.edge(I,k),M=!0),x.node(k).rank=x.node(I).rank+(M?R.minlen:-R.minlen)})}function b(v,x,C){return v.hasEdge(x,C)}function w(v,x,C){return C.low<=x.lim&&x.lim<=C.lim}return gu}var yu,cy;function gS(){if(cy)return yu;cy=1;var e=On(),t=e.longestPath,r=rv(),n=pS();yu=i;function i(c){switch(c.graph().ranker){case"network-simplex":a(c);break;case"tight-tree":s(c);break;case"longest-path":o(c);break;default:a(c)}}var o=t;function s(c){t(c),r(c)}function a(c){n(c)}return yu}var mu,uy;function yS(){if(uy)return mu;uy=1;var e=Je();mu=t;function t(i){var o=n(i);e.forEach(i.graph().dummyChains,function(s){for(var a=i.node(s),c=a.edgeObj,u=r(i,o,c.v,c.w),l=u.path,d=u.lca,h=0,p=l[h],y=!0;s!==c.w;){if(a=i.node(s),y){for(;(p=l[h])!==d&&i.node(p).maxRank<a.rank;)h++;p===d&&(y=!1)}if(!y){for(;h<l.length-1&&i.node(p=l[h+1]).minRank<=a.rank;)h++;p=l[h]}i.setParent(s,p),s=i.successors(s)[0]}})}function r(i,o,s,a){var c=[],u=[],l=Math.min(o[s].low,o[a].low),d=Math.max(o[s].lim,o[a].lim),h,p;h=s;do h=i.parent(h),c.push(h);while(h&&(o[h].low>l||d>o[h].lim));for(p=h,h=a;(h=i.parent(h))!==p;)u.push(h);return{path:c.concat(u.reverse()),lca:p}}function n(i){var o={},s=0;function a(c){var u=s;e.forEach(i.children(c),a),o[c]={low:u,lim:s++}}return e.forEach(i.children(),a),o}return mu}var bu,ly;function mS(){if(ly)return bu;ly=1;var e=Je(),t=mr();bu={run:r,cleanup:s};function r(a){var c=t.addDummyNode(a,"root",{},"_root"),u=i(a),l=e.max(e.values(u))-1,d=2*l+1;a.graph().nestingRoot=c,e.forEach(a.edges(),function(p){a.edge(p).minlen*=d});var h=o(a)+1;e.forEach(a.children(),function(p){n(a,c,d,h,l,u,p)}),a.graph().nodeRankFactor=d}function n(a,c,u,l,d,h,p){var y=a.children(p);if(!y.length){p!==c&&a.setEdge(c,p,{weight:0,minlen:u});return}var m=t.addBorderNode(a,"_bt"),g=t.addBorderNode(a,"_bb"),b=a.node(p);a.setParent(m,p),b.borderTop=m,a.setParent(g,p),b.borderBottom=g,e.forEach(y,function(w){n(a,c,u,l,d,h,w);var v=a.node(w),x=v.borderTop?v.borderTop:w,C=v.borderBottom?v.borderBottom:w,S=v.borderTop?l:2*l,k=x!==C?1:d-h[p]+1;a.setEdge(m,x,{weight:S,minlen:k,nestingEdge:!0}),a.setEdge(C,g,{weight:S,minlen:k,nestingEdge:!0})}),a.parent(p)||a.setEdge(c,m,{weight:0,minlen:d+h[p]})}function i(a){var c={};function u(l,d){var h=a.children(l);h&&h.length&&e.forEach(h,function(p){u(p,d+1)}),c[l]=d}return e.forEach(a.children(),function(l){u(l,1)}),c}function o(a){return e.reduce(a.edges(),function(c,u){return c+a.edge(u).weight},0)}function s(a){var c=a.graph();a.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(a.edges(),function(u){var l=a.edge(u);l.nestingEdge&&a.removeEdge(u)})}return bu}var vu,dy;function bS(){if(dy)return vu;dy=1;var e=Je(),t=mr();vu=r;function r(i){function o(s){var a=i.children(s),c=i.node(s);if(a.length&&e.forEach(a,o),e.has(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(var u=c.minRank,l=c.maxRank+1;u<l;++u)n(i,"borderLeft","_bl",s,c,u),n(i,"borderRight","_br",s,c,u)}}e.forEach(i.children(),o)}function n(i,o,s,a,c,u){var l={width:0,height:0,rank:u,borderType:o},d=c[o][u-1],h=t.addDummyNode(i,"border",l,s);c[o][u]=h,i.setParent(h,a),d&&i.setEdge(d,h,{weight:1})}return vu}var xu,fy;function vS(){if(fy)return xu;fy=1;var e=Je();xu={adjust:t,undo:r};function t(u){var l=u.graph().rankdir.toLowerCase();(l==="lr"||l==="rl")&&n(u)}function r(u){var l=u.graph().rankdir.toLowerCase();(l==="bt"||l==="rl")&&o(u),(l==="lr"||l==="rl")&&(a(u),n(u))}function n(u){e.forEach(u.nodes(),function(l){i(u.node(l))}),e.forEach(u.edges(),function(l){i(u.edge(l))})}function i(u){var l=u.width;u.width=u.height,u.height=l}function o(u){e.forEach(u.nodes(),function(l){s(u.node(l))}),e.forEach(u.edges(),function(l){var d=u.edge(l);e.forEach(d.points,s),e.has(d,"y")&&s(d)})}function s(u){u.y=-u.y}function a(u){e.forEach(u.nodes(),function(l){c(u.node(l))}),e.forEach(u.edges(),function(l){var d=u.edge(l);e.forEach(d.points,c),e.has(d,"x")&&c(d)})}function c(u){var l=u.x;u.x=u.y,u.y=l}return xu}var wu,hy;function xS(){if(hy)return wu;hy=1;var e=Je();wu=t;function t(r){var n={},i=e.filter(r.nodes(),function(u){return!r.children(u).length}),o=e.max(e.map(i,function(u){return r.node(u).rank})),s=e.map(e.range(o+1),function(){return[]});function a(u){if(!e.has(n,u)){n[u]=!0;var l=r.node(u);s[l.rank].push(u),e.forEach(r.successors(u),a)}}var c=e.sortBy(i,function(u){return r.node(u).rank});return e.forEach(c,a),s}return wu}var Cu,py;function wS(){if(py)return Cu;py=1;var e=Je();Cu=t;function t(n,i){for(var o=0,s=1;s<i.length;++s)o+=r(n,i[s-1],i[s]);return o}function r(n,i,o){for(var s=e.zipObject(o,e.map(o,function(h,p){return p})),a=e.flatten(e.map(i,function(h){return e.sortBy(e.map(n.outEdges(h),function(p){return{pos:s[p.w],weight:n.edge(p).weight}}),"pos")}),!0),c=1;c<o.length;)c<<=1;var u=2*c-1;c-=1;var l=e.map(new Array(u),function(){return 0}),d=0;return e.forEach(a.forEach(function(h){var p=h.pos+c;l[p]+=h.weight;for(var y=0;p>0;)p%2&&(y+=l[p+1]),p=p-1>>1,l[p]+=h.weight;d+=h.weight*y})),d}return Cu}var Su,gy;function CS(){if(gy)return Su;gy=1;var e=Je();Su=t;function t(r,n){return e.map(n,function(i){var o=r.inEdges(i);if(o.length){var s=e.reduce(o,function(a,c){var u=r.edge(c),l=r.node(c.v);return{sum:a.sum+u.weight*l.order,weight:a.weight+u.weight}},{sum:0,weight:0});return{v:i,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:i}})}return Su}var _u,yy;function SS(){if(yy)return _u;yy=1;var e=Je();_u=t;function t(i,o){var s={};e.forEach(i,function(c,u){var l=s[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:u};e.isUndefined(c.barycenter)||(l.barycenter=c.barycenter,l.weight=c.weight)}),e.forEach(o.edges(),function(c){var u=s[c.v],l=s[c.w];!e.isUndefined(u)&&!e.isUndefined(l)&&(l.indegree++,u.out.push(s[c.w]))});var a=e.filter(s,function(c){return!c.indegree});return r(a)}function r(i){var o=[];function s(u){return function(l){l.merged||(e.isUndefined(l.barycenter)||e.isUndefined(u.barycenter)||l.barycenter>=u.barycenter)&&n(u,l)}}function a(u){return function(l){l.in.push(u),--l.indegree===0&&i.push(l)}}for(;i.length;){var c=i.pop();o.push(c),e.forEach(c.in.reverse(),s(c)),e.forEach(c.out,a(c))}return e.map(e.filter(o,function(u){return!u.merged}),function(u){return e.pick(u,["vs","i","barycenter","weight"])})}function n(i,o){var s=0,a=0;i.weight&&(s+=i.barycenter*i.weight,a+=i.weight),o.weight&&(s+=o.barycenter*o.weight,a+=o.weight),i.vs=o.vs.concat(i.vs),i.barycenter=s/a,i.weight=a,i.i=Math.min(o.i,i.i),o.merged=!0}return _u}var Eu,my;function _S(){if(my)return Eu;my=1;var e=Je(),t=mr();Eu=r;function r(o,s){var a=t.partition(o,function(m){return e.has(m,"barycenter")}),c=a.lhs,u=e.sortBy(a.rhs,function(m){return-m.i}),l=[],d=0,h=0,p=0;c.sort(i(!!s)),p=n(l,u,p),e.forEach(c,function(m){p+=m.vs.length,l.push(m.vs),d+=m.barycenter*m.weight,h+=m.weight,p=n(l,u,p)});var y={vs:e.flatten(l,!0)};return h&&(y.barycenter=d/h,y.weight=h),y}function n(o,s,a){for(var c;s.length&&(c=e.last(s)).i<=a;)s.pop(),o.push(c.vs),a++;return a}function i(o){return function(s,a){return s.barycenter<a.barycenter?-1:s.barycenter>a.barycenter?1:o?a.i-s.i:s.i-a.i}}return Eu}var ju,by;function ES(){if(by)return ju;by=1;var e=Je(),t=CS(),r=SS(),n=_S();ju=i;function i(a,c,u,l){var d=a.children(c),h=a.node(c),p=h?h.borderLeft:void 0,y=h?h.borderRight:void 0,m={};p&&(d=e.filter(d,function(C){return C!==p&&C!==y}));var g=t(a,d);e.forEach(g,function(C){if(a.children(C.v).length){var S=i(a,C.v,u,l);m[C.v]=S,e.has(S,"barycenter")&&s(C,S)}});var b=r(g,u);o(b,m);var w=n(b,l);if(p&&(w.vs=e.flatten([p,w.vs,y],!0),a.predecessors(p).length)){var v=a.node(a.predecessors(p)[0]),x=a.node(a.predecessors(y)[0]);e.has(w,"barycenter")||(w.barycenter=0,w.weight=0),w.barycenter=(w.barycenter*w.weight+v.order+x.order)/(w.weight+2),w.weight+=2}return w}function o(a,c){e.forEach(a,function(u){u.vs=e.flatten(u.vs.map(function(l){return c[l]?c[l].vs:l}),!0)})}function s(a,c){e.isUndefined(a.barycenter)?(a.barycenter=c.barycenter,a.weight=c.weight):(a.barycenter=(a.barycenter*a.weight+c.barycenter*c.weight)/(a.weight+c.weight),a.weight+=c.weight)}return ju}var ku,vy;function jS(){if(vy)return ku;vy=1;var e=Je(),t=Pr().Graph;ku=r;function r(i,o,s){var a=n(i),c=new t({compound:!0}).setGraph({root:a}).setDefaultNodeLabel(function(u){return i.node(u)});return e.forEach(i.nodes(),function(u){var l=i.node(u),d=i.parent(u);(l.rank===o||l.minRank<=o&&o<=l.maxRank)&&(c.setNode(u),c.setParent(u,d||a),e.forEach(i[s](u),function(h){var p=h.v===u?h.w:h.v,y=c.edge(p,u),m=e.isUndefined(y)?0:y.weight;c.setEdge(p,u,{weight:i.edge(h).weight+m})}),e.has(l,"minRank")&&c.setNode(u,{borderLeft:l.borderLeft[o],borderRight:l.borderRight[o]}))}),c}function n(i){for(var o;i.hasNode(o=e.uniqueId("_root")););return o}return ku}var Ru,xy;function kS(){if(xy)return Ru;xy=1;var e=Je();Ru=t;function t(r,n,i){var o={},s;e.forEach(i,function(a){for(var c=r.parent(a),u,l;c;){if(u=r.parent(c),u?(l=o[u],o[u]=c):(l=s,s=c),l&&l!==c){n.setEdge(l,c);return}c=u}})}return Ru}var Pu,wy;function RS(){if(wy)return Pu;wy=1;var e=Je(),t=xS(),r=wS(),n=ES(),i=jS(),o=kS(),s=Pr().Graph,a=mr();Pu=c;function c(h){var p=a.maxRank(h),y=u(h,e.range(1,p+1),"inEdges"),m=u(h,e.range(p-1,-1,-1),"outEdges"),g=t(h);d(h,g);for(var b=Number.POSITIVE_INFINITY,w,v=0,x=0;x<4;++v,++x){l(v%2?y:m,v%4>=2),g=a.buildLayerMatrix(h);var C=r(h,g);C<b&&(x=0,w=e.cloneDeep(g),b=C)}d(h,w)}function u(h,p,y){return e.map(p,function(m){return i(h,m,y)})}function l(h,p){var y=new s;e.forEach(h,function(m){var g=m.graph().root,b=n(m,g,y,p);e.forEach(b.vs,function(w,v){m.node(w).order=v}),o(m,y,b.vs)})}function d(h,p){e.forEach(p,function(y){e.forEach(y,function(m,g){h.node(m).order=g})})}return Pu}var Au,Cy;function PS(){if(Cy)return Au;Cy=1;var e=Je(),t=Pr().Graph,r=mr();Au={positionX:y,findType1Conflicts:n,findType2Conflicts:i,addConflict:s,hasConflict:a,verticalAlignment:c,horizontalCompaction:u,alignCoordinates:h,findSmallestWidthAlignment:d,balance:p};function n(b,w){var v={};function x(C,S){var k=0,I=0,R=C.length,M=e.last(S);return e.forEach(S,function(E,P){var A=o(b,E),j=A?b.node(A).order:R;(A||E===M)&&(e.forEach(S.slice(I,P+1),function(q){e.forEach(b.predecessors(q),function(O){var z=b.node(O),U=z.order;(U<k||j<U)&&!(z.dummy&&b.node(q).dummy)&&s(v,O,q)})}),I=P+1,k=j)}),S}return e.reduce(w,x),v}function i(b,w){var v={};function x(S,k,I,R,M){var E;e.forEach(e.range(k,I),function(P){E=S[P],b.node(E).dummy&&e.forEach(b.predecessors(E),function(A){var j=b.node(A);j.dummy&&(j.order<R||j.order>M)&&s(v,A,E)})})}function C(S,k){var I=-1,R,M=0;return e.forEach(k,function(E,P){if(b.node(E).dummy==="border"){var A=b.predecessors(E);A.length&&(R=b.node(A[0]).order,x(k,M,P,I,R),M=P,I=R)}x(k,M,k.length,R,S.length)}),k}return e.reduce(w,C),v}function o(b,w){if(b.node(w).dummy)return e.find(b.predecessors(w),function(v){return b.node(v).dummy})}function s(b,w,v){if(w>v){var x=w;w=v,v=x}var C=b[w];C||(b[w]=C={}),C[v]=!0}function a(b,w,v){if(w>v){var x=w;w=v,v=x}return e.has(b[w],v)}function c(b,w,v,x){var C={},S={},k={};return e.forEach(w,function(I){e.forEach(I,function(R,M){C[R]=R,S[R]=R,k[R]=M})}),e.forEach(w,function(I){var R=-1;e.forEach(I,function(M){var E=x(M);if(E.length){E=e.sortBy(E,function(O){return k[O]});for(var P=(E.length-1)/2,A=Math.floor(P),j=Math.ceil(P);A<=j;++A){var q=E[A];S[M]===M&&R<k[q]&&!a(v,M,q)&&(S[q]=M,S[M]=C[M]=C[q],R=k[q])}}})}),{root:C,align:S}}function u(b,w,v,x,C){var S={},k=l(b,w,v,C),I=C?"borderLeft":"borderRight";function R(P,A){for(var j=k.nodes(),q=j.pop(),O={};q;)O[q]?P(q):(O[q]=!0,j.push(q),j=j.concat(A(q))),q=j.pop()}function M(P){S[P]=k.inEdges(P).reduce(function(A,j){return Math.max(A,S[j.v]+k.edge(j))},0)}function E(P){var A=k.outEdges(P).reduce(function(q,O){return Math.min(q,S[O.w]-k.edge(O))},Number.POSITIVE_INFINITY),j=b.node(P);A!==Number.POSITIVE_INFINITY&&j.borderType!==I&&(S[P]=Math.max(S[P],A))}return R(M,k.predecessors.bind(k)),R(E,k.successors.bind(k)),e.forEach(x,function(P){S[P]=S[v[P]]}),S}function l(b,w,v,x){var C=new t,S=b.graph(),k=m(S.nodesep,S.edgesep,x);return e.forEach(w,function(I){var R;e.forEach(I,function(M){var E=v[M];if(C.setNode(E),R){var P=v[R],A=C.edge(P,E);C.setEdge(P,E,Math.max(k(b,M,R),A||0))}R=M})}),C}function d(b,w){return e.minBy(e.values(w),function(v){var x=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;return e.forIn(v,function(S,k){var I=g(b,k)/2;x=Math.max(S+I,x),C=Math.min(S-I,C)}),x-C})}function h(b,w){var v=e.values(w),x=e.min(v),C=e.max(v);e.forEach(["u","d"],function(S){e.forEach(["l","r"],function(k){var I=S+k,R=b[I],M;if(R!==w){var E=e.values(R);M=k==="l"?x-e.min(E):C-e.max(E),M&&(b[I]=e.mapValues(R,function(P){return P+M}))}})})}function p(b,w){return e.mapValues(b.ul,function(v,x){if(w)return b[w.toLowerCase()][x];var C=e.sortBy(e.map(b,x));return(C[1]+C[2])/2})}function y(b){var w=r.buildLayerMatrix(b),v=e.merge(n(b,w),i(b,w)),x={},C;e.forEach(["u","d"],function(k){C=k==="u"?w:e.values(w).reverse(),e.forEach(["l","r"],function(I){I==="r"&&(C=e.map(C,function(P){return e.values(P).reverse()}));var R=(k==="u"?b.predecessors:b.successors).bind(b),M=c(b,C,v,R),E=u(b,C,M.root,M.align,I==="r");I==="r"&&(E=e.mapValues(E,function(P){return-P})),x[k+I]=E})});var S=d(b,x);return h(x,S),p(x,b.graph().align)}function m(b,w,v){return function(x,C,S){var k=x.node(C),I=x.node(S),R=0,M;if(R+=k.width/2,e.has(k,"labelpos"))switch(k.labelpos.toLowerCase()){case"l":M=-k.width/2;break;case"r":M=k.width/2;break}if(M&&(R+=v?M:-M),M=0,R+=(k.dummy?w:b)/2,R+=(I.dummy?w:b)/2,R+=I.width/2,e.has(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":M=I.width/2;break;case"r":M=-I.width/2;break}return M&&(R+=v?M:-M),M=0,R}}function g(b,w){return b.node(w).width}return Au}var Tu,Sy;function AS(){if(Sy)return Tu;Sy=1;var e=Je(),t=mr(),r=PS().positionX;Tu=n;function n(o){o=t.asNonCompoundGraph(o),i(o),e.forEach(r(o),function(s,a){o.node(a).x=s})}function i(o){var s=t.buildLayerMatrix(o),a=o.graph().ranksep,c=0;e.forEach(s,function(u){var l=e.max(e.map(u,function(d){return o.node(d).height}));e.forEach(u,function(d){o.node(d).y=c+l/2}),c+=l+a})}return Tu}var Iu,_y;function TS(){if(_y)return Iu;_y=1;var e=Je(),t=fS(),r=hS(),n=gS(),i=mr().normalizeRanks,o=yS(),s=mr().removeEmptyRanks,a=mS(),c=bS(),u=vS(),l=RS(),d=AS(),h=mr(),p=Pr().Graph;Iu=y;function y($,V){var W=V&&V.debugTiming?h.time:h.notime;W("layout",function(){var N=W(" buildLayoutGraph",function(){return R($)});W(" runLayout",function(){m(N,W)}),W(" updateInputGraph",function(){g($,N)})})}function m($,V){V(" makeSpaceForEdgeLabels",function(){M($)}),V(" removeSelfEdges",function(){ae($)}),V(" acyclic",function(){t.run($)}),V(" nestingGraph.run",function(){a.run($)}),V(" rank",function(){n(h.asNonCompoundGraph($))}),V(" injectEdgeLabelProxies",function(){E($)}),V(" removeEmptyRanks",function(){s($)}),V(" nestingGraph.cleanup",function(){a.cleanup($)}),V(" normalizeRanks",function(){i($)}),V(" assignRankMinMax",function(){P($)}),V(" removeEdgeLabelProxies",function(){A($)}),V(" normalize.run",function(){r.run($)}),V(" parentDummyChains",function(){o($)}),V(" addBorderSegments",function(){c($)}),V(" order",function(){l($)}),V(" insertSelfEdges",function(){Q($)}),V(" adjustCoordinateSystem",function(){u.adjust($)}),V(" position",function(){d($)}),V(" positionSelfEdges",function(){Y($)}),V(" removeBorderNodes",function(){U($)}),V(" normalize.undo",function(){r.undo($)}),V(" fixupEdgeLabelCoords",function(){O($)}),V(" undoCoordinateSystem",function(){u.undo($)}),V(" translateGraph",function(){j($)}),V(" assignNodeIntersects",function(){q($)}),V(" reversePoints",function(){z($)}),V(" acyclic.undo",function(){t.undo($)})}function g($,V){e.forEach($.nodes(),function(W){var N=$.node(W),ne=V.node(W);N&&(N.x=ne.x,N.y=ne.y,V.children(W).length&&(N.width=ne.width,N.height=ne.height))}),e.forEach($.edges(),function(W){var N=$.edge(W),ne=V.edge(W);N.points=ne.points,e.has(ne,"x")&&(N.x=ne.x,N.y=ne.y)}),$.graph().width=V.graph().width,$.graph().height=V.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],w={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},v=["acyclicer","ranker","rankdir","align"],x=["width","height"],C={width:0,height:0},S=["minlen","weight","width","height","labeloffset"],k={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},I=["labelpos"];function R($){var V=new p({multigraph:!0,compound:!0}),W=se($.graph());return V.setGraph(e.merge({},w,pe(W,b),e.pick(W,v))),e.forEach($.nodes(),function(N){var ne=se($.node(N));V.setNode(N,e.defaults(pe(ne,x),C)),V.setParent(N,$.parent(N))}),e.forEach($.edges(),function(N){var ne=se($.edge(N));V.setEdge(N,e.merge({},k,pe(ne,S),e.pick(ne,I)))}),V}function M($){var V=$.graph();V.ranksep/=2,e.forEach($.edges(),function(W){var N=$.edge(W);N.minlen*=2,N.labelpos.toLowerCase()!=="c"&&(V.rankdir==="TB"||V.rankdir==="BT"?N.width+=N.labeloffset:N.height+=N.labeloffset)})}function E($){e.forEach($.edges(),function(V){var W=$.edge(V);if(W.width&&W.height){var N=$.node(V.v),ne=$.node(V.w),me={rank:(ne.rank-N.rank)/2+N.rank,e:V};h.addDummyNode($,"edge-proxy",me,"_ep")}})}function P($){var V=0;e.forEach($.nodes(),function(W){var N=$.node(W);N.borderTop&&(N.minRank=$.node(N.borderTop).rank,N.maxRank=$.node(N.borderBottom).rank,V=e.max(V,N.maxRank))}),$.graph().maxRank=V}function A($){e.forEach($.nodes(),function(V){var W=$.node(V);W.dummy==="edge-proxy"&&($.edge(W.e).labelRank=W.rank,$.removeNode(V))})}function j($){var V=Number.POSITIVE_INFINITY,W=0,N=Number.POSITIVE_INFINITY,ne=0,me=$.graph(),fe=me.marginx||0,J=me.marginy||0;function te(G){var le=G.x,ue=G.y,we=G.width,ge=G.height;V=Math.min(V,le-we/2),W=Math.max(W,le+we/2),N=Math.min(N,ue-ge/2),ne=Math.max(ne,ue+ge/2)}e.forEach($.nodes(),function(G){te($.node(G))}),e.forEach($.edges(),function(G){var le=$.edge(G);e.has(le,"x")&&te(le)}),V-=fe,N-=J,e.forEach($.nodes(),function(G){var le=$.node(G);le.x-=V,le.y-=N}),e.forEach($.edges(),function(G){var le=$.edge(G);e.forEach(le.points,function(ue){ue.x-=V,ue.y-=N}),e.has(le,"x")&&(le.x-=V),e.has(le,"y")&&(le.y-=N)}),me.width=W-V+fe,me.height=ne-N+J}function q($){e.forEach($.edges(),function(V){var W=$.edge(V),N=$.node(V.v),ne=$.node(V.w),me,fe;W.points?(me=W.points[0],fe=W.points[W.points.length-1]):(W.points=[],me=ne,fe=N),W.points.unshift(h.intersectRect(N,me)),W.points.push(h.intersectRect(ne,fe))})}function O($){e.forEach($.edges(),function(V){var W=$.edge(V);if(e.has(W,"x"))switch((W.labelpos==="l"||W.labelpos==="r")&&(W.width-=W.labeloffset),W.labelpos){case"l":W.x-=W.width/2+W.labeloffset;break;case"r":W.x+=W.width/2+W.labeloffset;break}})}function z($){e.forEach($.edges(),function(V){var W=$.edge(V);W.reversed&&W.points.reverse()})}function U($){e.forEach($.nodes(),function(V){if($.children(V).length){var W=$.node(V),N=$.node(W.borderTop),ne=$.node(W.borderBottom),me=$.node(e.last(W.borderLeft)),fe=$.node(e.last(W.borderRight));W.width=Math.abs(fe.x-me.x),W.height=Math.abs(ne.y-N.y),W.x=me.x+W.width/2,W.y=N.y+W.height/2}}),e.forEach($.nodes(),function(V){$.node(V).dummy==="border"&&$.removeNode(V)})}function ae($){e.forEach($.edges(),function(V){if(V.v===V.w){var W=$.node(V.v);W.selfEdges||(W.selfEdges=[]),W.selfEdges.push({e:V,label:$.edge(V)}),$.removeEdge(V)}})}function Q($){var V=h.buildLayerMatrix($);e.forEach(V,function(W){var N=0;e.forEach(W,function(ne,me){var fe=$.node(ne);fe.order=me+N,e.forEach(fe.selfEdges,function(J){h.addDummyNode($,"selfedge",{width:J.label.width,height:J.label.height,rank:fe.rank,order:me+ ++N,e:J.e,label:J.label},"_se")}),delete fe.selfEdges})})}function Y($){e.forEach($.nodes(),function(V){var W=$.node(V);if(W.dummy==="selfedge"){var N=$.node(W.e.v),ne=N.x+N.width/2,me=N.y,fe=W.x-ne,J=N.height/2;$.setEdge(W.e,W.label),$.removeNode(V),W.label.points=[{x:ne+2*fe/3,y:me-J},{x:ne+5*fe/6,y:me-J},{x:ne+fe,y:me},{x:ne+5*fe/6,y:me+J},{x:ne+2*fe/3,y:me+J}],W.label.x=W.x,W.label.y=W.y}})}function pe($,V){return e.mapValues(e.pick($,V),Number)}function se($){var V={};return e.forEach($,function(W,N){V[N.toLowerCase()]=W}),V}return Iu}var Ou,Ey;function IS(){if(Ey)return Ou;Ey=1;var e=Je(),t=mr(),r=Pr().Graph;Ou={debugOrdering:n};function n(i){var o=t.buildLayerMatrix(i),s=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(i.nodes(),function(a){s.setNode(a,{label:a}),s.setParent(a,"layer"+i.node(a).rank)}),e.forEach(i.edges(),function(a){s.setEdge(a.v,a.w,{},a.name)}),e.forEach(o,function(a,c){var u="layer"+c;s.setNode(u,{rank:"same"}),e.reduce(a,function(l,d){return s.setEdge(l,d,{style:"invis"}),d})}),s}return Ou}var Mu,jy;function OS(){return jy||(jy=1,Mu="0.8.5"),Mu}var qu,ky;function MS(){return ky||(ky=1,qu={graphlib:Pr(),layout:TS(),debug:IS(),util:{time:mr().time,notime:mr().notime},version:OS()}),qu}var qS=MS();const Ry=vw(qS);function $S(e,t,r){var l;const n=new Set(e.map(d=>d.id)),i=new Set;for(const d of e)d.parent&&n.has(d.parent)&&i.add(d.parent);const o=new Ry.graphlib.Graph({multigraph:!0,compound:!0}),s=r.compactSpacingScale??(r.spacingFactor>0?r.spacingFactor/1.3:1);o.setGraph({rankdir:r.rankDir,nodesep:r.compact?Math.max(r.nodeSep,24*s):r.nodeSep,edgesep:r.compact?Math.min(r.edgeSep,24*s):r.edgeSep,ranksep:r.compact?Math.min(r.rankSep,80*s):r.rankSep,ranker:"network-simplex"}),o.setDefaultEdgeLabel(()=>({})),o.setDefaultNodeLabel(()=>({}));for(const d of e)o.setNode(d.id,{width:d.width+2,height:d.height+2});for(const d of e)d.parent&&n.has(d.parent)&&o.setParent(d.id,d.parent);for(const d of t){if(!n.has(d.source)||!n.has(d.target)||i.has(d.source)||i.has(d.target))continue;const h=eb(d.label,d.icon??((l=d.data)==null?void 0:l.icon),r.edgeLabelFontSize),p=r.rankDir==="LR"||r.rankDir==="RL",y=(h.width?h.width+2*Qm:0)+(d.connectorClearance??0);o.setEdge(d.source,d.target,{minlen:1,weight:1,...y?{width:p?y:Math.max(1,h.height),height:p?Math.max(1,h.height):y,labelpos:"c"}:{}},d.id)}Ry.layout(o);const a=new Map;for(const d of e){if(i.has(d.id))continue;const h=o.node(d.id);h&&Number.isFinite(h.x)&&Number.isFinite(h.y)&&a.set(d.id,{x:h.x,y:h.y})}const c=r.compact?1:r.spacingFactor;if(c&&c!==1&&a.size){let d=1/0,h=1/0,p=-1/0,y=-1/0;a.forEach(b=>{d=Math.min(d,b.x),h=Math.min(h,b.y),p=Math.max(p,b.x),y=Math.max(y,b.y)});const m=(d+p)/2,g=(h+y)/2;a.forEach((b,w)=>a.set(w,{x:m+(b.x-m)*c,y:g+(b.y-g)*c}))}const u=r.nodeAlignment??"center";if(u!=="center"){const d=r.rankDir==="LR"||r.rankDir==="RL",h=d?"x":"y",p=d?"width":"height",y=r.rankDir==="RL"||r.rankDir==="BT"?-1:1,m=u==="leading"?-y:y,g=new Map;for(const b of e){const w=a.get(b.id);if(!w)continue;const v=w[h];g.set(v,Math.max(g.get(v)??0,b[p]))}for(const b of e){const w=a.get(b.id);if(!w)continue;const v=w[h],x=(g.get(v)-b[p])/2;a.set(b.id,{...w,[h]:v+m*x})}}return a}function Py(e,t,r,n,i){const o=new Map,s=new Map(e.map(l=>[l.id,l]));for(const l of e){if(!l.parent||!s.has(l.parent))continue;const d=o.get(l.parent);d?d.push(l.id):o.set(l.parent,[l.id])}const a=(l,d=new Set)=>{var p;const h=(p=s.get(l))==null?void 0:p.parent;return!h||!s.has(h)||d.has(l)?0:(d.add(l),1+a(h,d))},c=[...o.keys()].sort((l,d)=>a(d)-a(l)),u=new Map;for(const l of c){let d=null;for(const y of o.get(l)||[]){let m=u.get(y);if(!m){const g=t.get(y);if(!g)continue;const b=r.get(y)||{w:60,h:60};m={x1:g.x-b.w/2,y1:g.y-b.h/2,x2:g.x+b.w/2,y2:g.y+b.h/2}}d=d?{x1:Math.min(d.x1,m.x1),y1:Math.min(d.y1,m.y1),x2:Math.max(d.x2,m.x2),y2:Math.max(d.y2,m.y2)}:{...m}}if(!d)continue;const h=n(l);d={x1:d.x1-h,y1:d.y1-h,x2:d.x2+h,y2:d.y2+h};const p=i(l);if(p){const y=d.x2-d.x1,m=d.y2-d.y1;if(p.w>y){const g=(p.w-y)/2;d.x1-=g,d.x2+=g}if(p.h>m){const g=(p.h-m)/2;d.y1-=g,d.y2+=g}}u.set(l,d)}return u}function NS(e){const t=e.getBoundingClientRect(),r=t.height/e.offsetHeight;if(!Number.isFinite(r)||r<=0)return[];const n=Ym(e),i={x:e.offsetWidth/2,y:e.offsetHeight/2,w:e.offsetWidth,h:e.offsetHeight},o=[...e.querySelectorAll("[data-flow-property]")],s=new Set(o.filter(a=>a.hasAttribute("data-flow-inspection-row")&&a.getBoundingClientRect().height>0).map(a=>a.dataset.flowProperty));return o.flatMap(a=>{if(a.closest(".flow-sdk-node")!==e)return[];if(s.has(a.dataset.flowProperty)&&!a.hasAttribute("data-flow-inspection-row"))return[];const c=a.dataset.flowPortSide;if(c&&["top","right","bottom","left"].includes(c)){const l=Km(n?en(i,n):i,c,Number(a.dataset.flowPortPosition??.5));return[{property:a.getAttribute("data-flow-property"),top:l.y,height:0,anchor:l,...a.dataset.flowPortPlacement==="config"?{placement:"config"}:{},...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]}const u=a.getBoundingClientRect();return!u.width||!u.height?[]:[{property:a.getAttribute("data-flow-property"),top:Math.round((u.top-t.top)/r*1e3)/1e3,height:Math.round(u.height/r*1e3)/1e3,...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]})}function LS({id:e,x:t,y:r,placed:n,hidden:i,onMount:o,drawHandles:s,drawMode:a,connectedPorts:c,resolvedRows:u,hasCollapseControl:l,handleColor:d,animated:h,animationColor:p,animationWidth:y=8,animationVariant:m,width:g=0,height:b=0,propertyMode:w,reversePorts:v,direction:x="LR",onPropertyRows:C,onSurface:S,children:k}){const I=_.useRef(null),[R,M]=_.useState([]),E=u??R,[P,A]=_.useState();return _.useLayoutEffect(()=>{const j=I.current;if(!j)return;const q=()=>{const U=Ym(j);A(ae=>JSON.stringify(ae)===JSON.stringify(U)?ae:U),S==null||S(e,U)};q();const O=new ResizeObserver(q);O.observe(j);const z=j.querySelector("[data-flow-node-surface]");return z&&O.observe(z),()=>O.disconnect()},[e,k,S]),_.useLayoutEffect(()=>(o(e,I.current),()=>{o(e,null),S==null||S(e,void 0)}),[e,o,S]),_.useLayoutEffect(()=>{const j=I.current;if(!j)return;let q="";const O=()=>{const Q=NS(j),Y=w?Q:Q.filter(se=>se.anchor),pe=JSON.stringify(Y);pe!==q&&(q=pe,M(Y),C==null||C(e,Y))};if(O(),!w&&!j.querySelector("[data-flow-port-side]"))return;const z=new ResizeObserver(O),U=()=>{z.disconnect(),z.observe(j),j.querySelectorAll("[data-flow-property]").forEach(Q=>z.observe(Q)),O()};U();const ae=new MutationObserver(U);return ae.observe(j,{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"]}),j.addEventListener("scroll",O,!0),()=>{z.disconnect(),ae.disconnect(),j.removeEventListener("scroll",O,!0)}},[e,w,C,k]),f.jsxs("div",{ref:I,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&&!i?void 0:"hidden"},children:[k,h&&y>0&&g>0&&b>0&&f.jsx("svg",{className:"flow-sdk-node-animation","aria-hidden":"true",pointerEvents:"none",children:f.jsx(Hm,{variant:m,x:((P==null?void 0:P.left)??0)+y/2,y:((P==null?void 0:P.top)??0)+y/2,width:((P==null?void 0:P.width)??g)-y,height:((P==null?void 0:P.height)??b)-y,radius:((P==null?void 0:P.radius)??0)-y/2,path:P!=null&&P.outline?`M${P.outline.map(j=>`${j.x} ${j.y}`).join(" L")} Z`:void 0,color:p||d||"currentColor",strokeWidth:y})}),s&&w&&E.map(j=>["source","target"].filter(q=>!j.role||j.role===q).filter(q=>a||(c==null?void 0:c.has(`${q}:${j.property}`))).map(q=>{var O;return f.jsx("button",{type:"button",className:"flow-sdk-property-port","data-property":j.property,"data-port-role":q,"data-port-side":(O=j.anchor)==null?void 0:O.side,"aria-label":`${q==="source"?"Connect":"Input"} ${j.property}`,title:`${q==="source"?"Connect":"Input"} ${j.property}`,style:{color:d,...j.anchor?{top:j.anchor.y,left:j.anchor.x-16}:{top:j.top+j.height/2,[q==="source"!=!!v?"right":"left"]:-16}},onClick:z=>z.stopPropagation()},`${j.property}:${q}`)})),s&&!l&&(!w||!E.length)&&(!w||!E.some(j=>j.anchor))&&f.jsx("button",{type:"button",className:"flow-sdk-handle","aria-label":"Draw edge",title:"Draw edge",style:{color:d,left:((P==null?void 0:P.left)??0)+(x==="RL"?-36:x==="LR"?(P==null?void 0:P.width)??g:((P==null?void 0:P.width)??g)/2),top:((P==null?void 0:P.top)??0)+(x==="BT"?-36:x==="TB"?(P==null?void 0:P.height)??b:((P==null?void 0:P.height)??b)/2),transform:x==="BT"||x==="TB"?"translateX(-50%)":"translateY(-50%)"},onClick:j=>j.stopPropagation(),children:f.jsx(K.PiPlusBold,{size:24})})]})}const FS=_.memo(LS);function BS(e,t,r){const[n,i]=_.useState(()=>({nodes:new Set,edges:new Set})),o=_.useMemo(()=>{const a=new Set(e.map(p=>p.id)),c=t.filter(p=>a.has(p.source)&&a.has(p.target)).map(p=>({id:p.id,source:p.inverted?p.target:p.source,target:p.inverted?p.source:p.target})),u=new Set(c.map(p=>p.id)),l=new Set([...n.nodes].filter(p=>a.has(p))),d=new Set([...n.edges].filter(p=>u.has(p)));if(!r)return{nodes:a,edges:u,ready:u};for(const p of e)c.filter(m=>m.target===p.id&&m.source!==m.target).every(m=>d.has(m.id))&&l.add(p.id);let h=new Set(c.filter(p=>l.has(p.source)).map(p=>p.id));if(l.size<a.size&&!c.some(p=>h.has(p.id)&&!d.has(p.id))){const p=e.find(y=>!l.has(y.id));p&&l.add(p.id),h=new Set(c.filter(y=>l.has(y.source)).map(y=>y.id))}return{nodes:l,edges:d,ready:h}},[e,t,r,n]);_.useLayoutEffect(()=>{i(a=>{const c=r?o:{nodes:new Set,edges:new Set},u=(l,d)=>l.size===d.size&&[...l].every(h=>d.has(h));return u(a.nodes,c.nodes)&&u(a.edges,c.edges)?a:{nodes:c.nodes,edges:c.edges}})},[o,r]);const s=_.useCallback(a=>{i(c=>c.edges.has(a)?c:{...c,edges:new Set([...c.edges,a])})},[]);return{shown:o.nodes,ready:o.ready,complete:s}}class zS{constructor(t,r,n){$r(this,"_pan");$r(this,"_zoom");$r(this,"minZoom");$r(this,"maxZoom");$r(this,"size",{w:0,h:0});$r(this,"listeners",new Set);$r(this,"animationFrame");$r(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,i={pan:{...t.pan},zoom:this.clamp(t.zoom)},o=performance.now(),s=300/1.4,a=()=>{this.cancelAnimation(),this.set(i.pan,i.zoom)},c=u=>{const l=Math.min(1,(u-o)/s);if(l>=1){a();return}const d=l*l*(3-2*l);this.apply({x:n.pan.x+(i.pan.x-n.pan.x)*d,y:n.pan.y+(i.pan.y-n.pan.y)*d},n.zoom+(i.zoom-n.zoom)*d),this.animationFrame=requestAnimationFrame(c)};this.animationFrame=requestAnimationFrame(c),this.animationTimer=setTimeout(a,s+100)}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 i=this.clamp(r);i!==this._zoom&&(this._zoom=i,n=!0)}n&&this.emit()}zoomAt(t,r){const n=this.clamp(t),i=this._zoom;if(n===i)return;const o=n/i;this.set({x:r.x-(r.x-this._pan.x)*o,y:r.y-(r.y-this._pan.y)*o},n)}fit(t,r=0,n=!1,i=1){const o=t.x2-t.x1,s=t.y2-t.y1;if(!(o>0)||!(s>0)||!this.size.w||!this.size.h)return;const a=this.clamp(this.clamp(Math.min((this.size.w-2*r)/o,(this.size.h-2*r)/s))*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 DS={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},En={w:60,h:60},Ay=4,VS=30,Ty=300,WS=500,Iy=45,GS=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2;function Oy(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 US(e){var Pl;const{nodes:t,edges:r,direction:n,nodeAlignment:i="center",edgeMode:o="auto",compactPropertyLayout:s=!1,rankSep:a,edgeSep:c,spacingFactor:u=1.3,compactSpacingScale:l,minZoom:d,maxZoom:h,initialViewport:p,containerStyle:y,lineColor:m,drawMode:g,dragMode:b,multiSelect:w,isPerformanceMode:v}=e,[x,C]=_.useState(null),S=_.useMemo(()=>x?(x.mode==="connections"?nd:Yl)(x.id,t,r):null,[x,t,r]),k=o==="auto"||o==="properties",I=_.useMemo(()=>r.filter(T=>Du(T,o)&&(!S||S.has(T.source)&&S.has(T.target))),[r,o,S]),R=_.useMemo(()=>hw(t,r,o,s,S),[t,r,o,s,S]),M=_.useRef(R);M.current=R;const E=_.useRef(e);E.current=e;const P=_.useRef(null),A=_.useRef(null),j=_.useRef(null),q=_.useRef(null),O=_.useMemo(()=>new zS(p,d,h),[]);_.useEffect(()=>{O.minZoom=d,O.maxZoom=h},[O,d,h]);const z=_.useRef(new Map),U=_.useRef(new Map),ae=_.useRef(new Map),Q=_.useRef(null),[Y,pe]=_.useState(new Map),se=_.useCallback((T,L)=>{pe(D=>{if(JSON.stringify(D.get(T))===JSON.stringify(L))return D;const H=new Map(D);return L?H.set(T,L):H.delete(T),H})},[]),[$,V]=_.useState(new Map),W=_.useRef($),N=_.useCallback((T,L)=>{V(D=>{if(JSON.stringify(D.get(T)??[])===JSON.stringify(L))return D;const H=new Map(D);return L.length?H.set(T,L):H.delete(T),H})},[]),[ne,me]=_.useState(()=>new Map),fe=_.useRef(ne);fe.current=ne;const J=_.useRef(new Map),te=_.useRef(null),G=_.useRef(!1),[le,ue]=_.useState(0),we=_.useRef(),ge=_.useRef(),qe=_.useRef(null),ee=_.useRef(),he=_.useRef(!1),be=_.useRef(null),Ee=_.useRef(null),$e=_.useRef(u),Ge=s,Ye=_.useRef(Ge),[tr,sr]=_.useState(!0),Pe=_.useRef(null);Pe.current=S;const ye=_.useRef(1);ye.current=(x==null?void 0:x.mode)==="connections"?1.25:1;const Me=_.useRef(null),nr=_.useRef(t),cr=_.useRef([]),Xe=_.useRef(!1),xe=()=>{qe.current!==null&&cancelAnimationFrame(qe.current),qe.current=null,clearTimeout(ee.current)},et=()=>{Ee.current=null,cr.current.length&&(Xe.current=!0),!G.current&&E.current.fitOnInit!==!1&&(he.current=!0),clearTimeout(ge.current),ge.current=setTimeout(()=>{G.current=fe.current.size>0,ue(T=>T+1)},WS)},zr=T=>{xe();const L=new Map(fe.current),D=performance.now(),H=()=>{xe(),me(T),et()},oe=Se=>{const Fe=Math.min(1,(Se-D)/Ty);if(Fe>=1)return H();const ze=GS(Fe),Te=new Map;T.forEach((X,de)=>{const ce=L.get(de);Te.set(de,ce?{x:ce.x+(X.x-ce.x)*ze,y:ce.y+(X.y-ce.y)*ze}:X)}),me(Te),qe.current=requestAnimationFrame(oe)};qe.current=requestAnimationFrame(oe),ee.current=setTimeout(H,Ty+100)},pt=()=>{var ze;const T=E.current,L=ye.current,D=M.current,H=D.nodes.map(Te=>{const X=z.current.get(Te.id)||En;return{id:Te.id,parent:Te.parent,width:X.w,height:X.h}});let oe;try{const Te=T.compactPropertyLayout,X=T.edgeMode!=="nodes"&&T.edgeMode!=="workflow",de=D.edges.map(ce=>({...ce,connectorClearance:Te?X&&(ce.sourceProperty!==void 0||ce.targetProperty!==void 0)?fw:dw:0}));oe=$S(H,de,{edgeLabelFontSize:T.edgeMode==="nodes"||T.edgeMode==="workflow"?Xm:In,rankDir:T.direction,compact:Te,nodeAlignment:T.nodeAlignment,rankSep:T.rankSep*L,edgeSep:T.edgeSep*L,nodeSep:5*L,spacingFactor:T.spacingFactor??1.3,compactSpacingScale:(T.compactSpacingScale??(T.spacingFactor??1.3)/1.3)*L})}catch(Te){console.warn("[flow-sdk] layout failed",Te);return}const Se=te.current;te.current=null;const Fe=Se&&oe.get(Se.id);if(Se&&Fe){const Te={x:Se.position.x-Fe.x,y:Se.position.y-Fe.y};oe=new Map([...oe].map(([X,de])=>[X,{x:de.x+Te.x,y:de.y+Te.y}]))}for(const[Te,X]of J.current)oe.has(Te)?oe.set(Te,X):T.nodes.some(de=>de.id===Te)||J.current.delete(Te);(ze=Ee.current)==null||ze.call(Ee,oe),G.current&&!T.isPerformanceMode?zr(oe):(xe(),me(oe),et())},ie=_.useCallback(()=>{clearTimeout(ge.current),clearTimeout(we.current),we.current=setTimeout(pt,E.current.layoutDebounce)},[]);_.useLayoutEffect(()=>{const T=new Map(nr.current.map(L=>[L.id,L]));t.some(L=>{var D;return((D=T.get(L.id))==null?void 0:D.collapsed)===!0&&!L.collapsed})&&(cr.current=t.filter(L=>!T.has(L.id)).map(L=>L.id)),nr.current=t,$e.current!==u&&fe.current.size>0&&(G.current=!0,he.current=!1,clearTimeout(ge.current)),$e.current=u,Ye.current!==Ge&&(he.current=!be.current),Ye.current=Ge,Ee.current&&!be.current?(clearTimeout(we.current),pt()):ie()},[t,r,R.nodes,R.edges,Ge,n,i,a,c,ie,u,l]),_.useEffect(()=>()=>{clearTimeout(we.current),clearTimeout(ge.current),xe()},[]);const We=_.useCallback((T,L)=>{var D,H;if(!Q.current&&typeof ResizeObserver<"u"&&(Q.current=new ResizeObserver(oe=>{var Fe;let Se=!1;for(const ze of oe){const Te=ae.current.get(ze.target);if(!Te)continue;const X=ze.target,de=X.offsetWidth,ce=X.offsetHeight;if(!de&&!ce)continue;const Ie=z.current.get(Te);if(Ie&&Ie.w===de&&Ie.h===ce)continue;const yr=fe.current.get(Te);Ie&&yr&&G.current&&!te.current&&(te.current={id:Te,position:{...yr}}),z.current.set(Te,{w:de,h:ce}),Se=!0}Se&&((Fe=Ee.current)==null||Fe.call(Ee),ie())})),L){U.current.set(T,L),ae.current.set(L,T),(D=Q.current)==null||D.observe(L);const oe=L.offsetWidth,Se=L.offsetHeight;(oe||Se)&&z.current.set(T,{w:oe,h:Se})}else{const oe=U.current.get(T);oe&&((H=Q.current)==null||H.unobserve(oe),ae.current.delete(oe)),U.current.delete(T),z.current.delete(T),W.current.has(T)&&N(T,[])}ie()},[ie,N]);_.useEffect(()=>()=>{var T;return(T=Q.current)==null?void 0:T.disconnect()},[]);const or=_.useMemo(()=>{const T=new Map;for(const L of t)L.label&&T.set(L.id,L.label);return T},[t]),Ue=_.useMemo(()=>Py(R.nodes,ne,z.current,T=>y(T).padding,T=>{const L=or.get(T);if(!L)return;const D=y(T);return{w:un(L,`bold ${D.fontSize}px ${Lr}`)+2*Iy,h:0}}),[R.nodes,ne,y,or]),ir=_.useRef(Ue);ir.current=Ue;const er=_.useCallback(T=>{const L=ir.current.get(T);if(L)return Y0(L);const D=fe.current.get(T);if(!D)return;const H=z.current.get(T)||En;return{x:D.x,y:D.y,w:H.w,h:H.h}},[]),Z=_.useMemo(()=>{const T=new Map;for(const L of t){const D=er(L.id);D&&T.set(L.id,D)}return aw($,T,Y,r,n)},[$,t,ne,Ue,Y,r,n,er]);W.current=Z;const B=(T,L)=>{var oe;if(!k||L===void 0)return;const D=(oe=Z.get(T))==null?void 0:oe.find(Se=>Se.property===L),H=er(T);return D&&!D.anchor&&H?H.y-H.h/2+D.top+D.height/2:void 0},re=(T,L)=>{var oe,Se;if(L===void 0)return;const D=(Se=(oe=Z.get(T))==null?void 0:oe.find(Fe=>Fe.property===L))==null?void 0:Se.anchor,H=er(T);return D&&H?{x:H.x-H.w/2+D.x,y:H.y-H.h/2+D.y,side:D.side}:void 0},_e=(T,L)=>{const D=er(T),H=Y.get(T);return D&&H&&!Ue.has(T)&&B(T,L)===void 0?en(D,H):D},Ae=()=>{const T=[];fe.current.forEach((L,D)=>{if(ir.current.has(D))return;const H=z.current.get(D)||En;T.push(bt({x:L.x,y:L.y,w:H.w,h:H.h}))}),ir.current.forEach(L=>T.push(L));try{for(const L of[A.current,j.current]){const D=L==null?void 0:L.getBBox();D&&D.width>0&&D.height>0&&T.push({x1:D.x,y1:D.y,x2:D.x+D.width,y2:D.y+D.height})}}catch{}return bo(T)},Re=()=>{var D,H;const{pan:T,zoom:L}=O;q.current&&(q.current.style.transform=`translate3d(${T.x}px, ${T.y}px, 0) scale(${L})`),(D=A.current)==null||D.setAttribute("transform",`translate(${T.x} ${T.y}) scale(${L})`),(H=j.current)==null||H.setAttribute("transform",`translate(${T.x} ${T.y}) scale(${L})`)};_.useEffect(()=>{Re();let T=null,L;const D=O.onChange(()=>{Re();const H=P.current;H&&(H.classList.add("flow-sdk-busy"),clearTimeout(L),L=setTimeout(()=>H.classList.remove("flow-sdk-busy"),150)),T===null&&(T=requestAnimationFrame(()=>{var oe,Se;T=null,(Se=(oe=E.current).onViewportChange)==null||Se.call(oe,O.state)}))});return()=>{D(),clearTimeout(L),T!==null&&cancelAnimationFrame(T)}},[]),_.useLayoutEffect(()=>{const T=P.current;if(!T)return;const L=()=>{let H=T.clientWidth,oe=T.clientHeight;oe||(oe=Math.max(0,window.innerHeight-T.getBoundingClientRect().top-100),oe&&(T.style.height=`${oe}px`)),H||(H=window.innerWidth,H&&(T.style.width=`${H}px`)),O.size={w:H,h:oe},!G.current&&!fe.current.size&&E.current.fitOnInit!==!1&&(O.set({x:H/2,y:oe/2}),Re())};if(L(),typeof ResizeObserver>"u")return;const D=new ResizeObserver(L);return D.observe(T),()=>D.disconnect()},[O]),_.useLayoutEffect(()=>{if(Xe.current){Xe.current=!1;const L=cr.current.flatMap(H=>{const oe=er(H);return oe?[bt(oe)]:[]});cr.current=[];const D=bo(L);if(D){he.current=!1,O.center(D,E.current.animateViewport);return}}if(!he.current)return;he.current=!1;const T=Ae();T&&(O.fit(T,50,G.current&&E.current.animateViewport),G.current||Re())},[ne]);const He=_.useMemo(()=>{const T=X=>Yl(X,E.current.nodes,E.current.edges),L=(X,de=50,ce=E.current.animateViewport,Ie=1,yr=!1)=>{let Vr=null;const mn=gt=>{const ho=M.current,bv=X??new Set(ho.nodes.map(pr=>pr.id)),vv=new Set(ho.nodes.map(pr=>pr.parent).filter(Boolean));if(!gt&&(!X||[...X].some(pr=>vv.has(pr))))return;const po=gt&&Py(ho.nodes,gt,z.current,pr=>E.current.containerStyle(pr).padding,pr=>{var xn;const Nt=(xn=E.current.nodes.find(wn=>wn.id===pr))==null?void 0:xn.label;if(!Nt)return;const vn=E.current.containerStyle(pr);return{w:un(Nt,`bold ${vn.fontSize}px ${Lr}`)+2*Iy,h:0}}),bn=bo([...bv].flatMap(pr=>{const Nt=po==null?void 0:po.get(pr);if(Nt)return[Nt];const vn=gt==null?void 0:gt.get(pr),xn=z.current.get(pr)||En,wn=vn?{...vn,...xn}:er(pr);return wn?[bt(wn)]:[]}));!bn||JSON.stringify(bn)===JSON.stringify(Vr)||(Vr=bn,he.current=!1,cr.current=[],Xe.current=!1,O.fit(bn,Number.isFinite(de)?Math.max(0,de):50,ce,Ie))};Ee.current=yr?mn:null,yr||mn(fe.current)},D=(X,de,ce,Ie)=>{var Vr;if(!er(X))return;const yr=de==="connections"?oe(X):T(X);if(de==="connections"&&ye.current===1.25&&((Vr=Pe.current)==null?void 0:Vr.size)===yr.size&&[...yr].every(mn=>Pe.current.has(mn))){C({id:X,mode:de});return}Me.current||(Me.current={pan:{...O.pan},zoom:O.zoom}),Pe.current=yr,E.current.compactPropertyLayout&&(he.current=!1,be.current=()=>L(Pe.current??yr,ce,Ie)),C({id:X,mode:de}),E.current.compactPropertyLayout||L(yr,ce,Ie)},H=X=>{be.current?be.current=X:X()},oe=X=>nd(X,E.current.nodes,E.current.edges),Se=(X=>{if(X===void 0)return O.zoom;Ee.current=null,O.set(void 0,X)}),Fe=(X=>{if(X===void 0)return O.pan;Ee.current=null,O.set(X)}),ze=(X,de)=>{var Ie;const ce=(Ie=P.current)==null?void 0:Ie.getBoundingClientRect();return{x:X-((ce==null?void 0:ce.left)??0),y:de-((ce==null?void 0:ce.top)??0)}},Te=(X=0,de=E.current.animateViewport,ce=!1)=>{if(ce){L(void 0,X,de,1,!0);return}Ee.current=null,H(()=>{const Ie=Ae();Ie&&O.fit(Ie,X,de)})};return{zoom:Se,pan:Fe,setEdgesVisible:sr,focusNode:(X,de,ce,Ie)=>H(()=>L(new Set([X]),de,ce,.6,Ie)),focusBranch:(X,de,ce)=>H(()=>L(T(X),de,ce)),focusConnections:(X,de,ce,Ie)=>H(()=>L(oe(X),de,ce,1,Ie)),isolateConnections:(X,de,ce)=>D(X,"connections",de,ce),isolateBranch:(X,de,ce)=>D(X,"branch",de,ce),restoreView:(X=E.current.animateViewport,de)=>{Ee.current=null;const ce=E.current.compactPropertyLayout&&!!Pe.current;Pe.current=null,C(null);const Ie=de??Me.current;Me.current=null,ce?be.current=()=>{Ie&&O.transition(Ie,X)}:Ie&&H(()=>O.transition(Ie,X))},zoomAt:(X,de)=>{Ee.current=null,O.zoomAt(X,de)},fit:Te,centerAndFit:Te,center:(X=E.current.animateViewport)=>{Ee.current=null;const de=Ae();de&&O.center(de,X)},clientToModel:(X,de)=>O.renderedToModel(ze(X,de)),modelToClient:X=>{var Ie;const de=(Ie=P.current)==null?void 0:Ie.getBoundingClientRect(),ce=O.modelToRendered(X);return{x:ce.x+((de==null?void 0:de.left)??0),y:ce.y+((de==null?void 0:de.top)??0)}},getNodeBox:X=>er(X),setNodePosition:(X,de,ce)=>{if(!fe.current.has(X)||de&&(!Number.isFinite(de.x)||!Number.isFinite(de.y)))return!1;if(xe(),!de)return J.current.delete(X),ie(),!0;const Ie=new Map(fe.current);return Ie.set(X,{...de}),(ce==null?void 0:ce.persist)===!1?J.current.delete(X):J.current.set(X,{...de}),fe.current=Ie,me(Ie),(ce==null?void 0:ce.persist)===!1&&ie(),!0},onViewportChange:X=>O.onChange(X)}},[]);_.useEffect(()=>{var T,L;return(L=(T=E.current).onInit)==null||L.call(T,He),()=>O.cancelAnimation()},[He]),_.useEffect(()=>{var T,L;if(le>0){const D=be.current;be.current=null,D==null||D(),(L=(T=E.current).onLayoutComplete)==null||L.call(T,He)}},[He,le]);const je=_.useRef(null),De=_.useRef(new Map),Ke=_.useRef(!1),[dr,fr]=_.useState(null),[Ne,Tr]=_.useState(null),qr=T=>{const L=P.current.getBoundingClientRect();return{x:T.clientX-L.left,y:T.clientY-L.top}},Dr=(T,L)=>{const D=E.current.nodes;for(let H=D.length-1;H>=0;H--){const oe=D[H].id;if(!vt(oe,E.current.edges,E.current.edgeMode)||Pe.current&&!Pe.current.has(oe)||oe===L||ir.current.has(oe))continue;const Se=er(oe);if(Se&&Xl(T,bt(Se)))return oe}for(const[H,oe]of ir.current)if(vt(H,E.current.edges,E.current.edgeMode)&&!(Pe.current&&!Pe.current.has(H))&&H!==L&&Xl(T,oe))return H;return null},so=(T,L)=>{if(E.current.edgeMode==="nodes"||E.current.edgeMode==="workflow")return null;const D=E.current.direction==="RL",H=Math.max(16,6/O.zoom);let oe=null;for(const Se of[...E.current.nodes].reverse()){if(!vt(Se.id,E.current.edges,E.current.edgeMode)||Pe.current&&!Pe.current.has(Se.id))continue;const Fe=er(Se.id),ze=W.current.get(Se.id);if(!Fe||!ze||ir.current.has(Se.id))continue;const Te=Fe.x+(L==="source"!==D?1:-1)*Fe.w/2;for(const X of ze){if(X.role&&X.role!==L)continue;const de=Fe.y-Fe.h/2+X.top,ce=Math.hypot(T.x-(X.anchor?Fe.x-Fe.w/2+X.anchor.x:Te),T.y-de-X.height/2);if(!X.anchor&&T.x>=Fe.x-Fe.w/2&&T.x<=Fe.x+Fe.w/2&&T.y>=de&&T.y<=de+X.height)return{nodeId:Se.id,property:X.property};ce<=H&&(!oe||ce<oe.distance)&&(oe={nodeId:Se.id,property:X.property,distance:ce})}}return oe},dv=T=>{var Fe;if(!T.currentTarget.contains(T.target)||T.button!==0||E.current.readOnly)return;je.current||(Ke.current=!1);const L=T.target;if(L.closest('input, textarea, select, [contenteditable="true"], [data-flow-content-toggle]'))return;const D=E.current,H=qr(T);if(T.pointerType==="touch"){De.current.set(T.pointerId,H);const ze=Oy(De.current);if(ze){je.current={kind:"pinch",distance:ze.distance,zoom:O.zoom,anchor:O.renderedToModel(ze.center)},Tr(null),fr(null),Ke.current=!0;for(const Te of De.current.keys())T.currentTarget.setPointerCapture(Te);return}}if(je.current)return;const oe=D.drawHandles&&L.closest(".flow-sdk-handle"),Se=D.drawHandles&&L.closest(".flow-sdk-property-port");if(D.drawMode||oe||Se){const ze=O.renderedToModel(H),Te=D.drawMode?so(ze,"source"):null,X=Se||oe,de=X?(Fe=X.closest("[data-node-id]"))==null?void 0:Fe.dataset.nodeId:(Te==null?void 0:Te.nodeId)??Dr(ze),ce=Se?Se.dataset.property:Te==null?void 0:Te.property;if(de){je.current={kind:"draw",pointerId:T.pointerId,source:de,sourceProperty:ce,reverse:(Se==null?void 0:Se.dataset.portRole)==="target",startClient:{x:T.clientX,y:T.clientY}},Ke.current=!0,Tr({source:de,sourceProperty:ce,point:ze,target:null}),T.currentTarget.setPointerCapture(T.pointerId);return}}L.closest(".flow-sdk-node, .flow-sdk-container, .flow-sdk-edge, .flow-sdk-edge-label, .flow-sdk-container-label")||(Ee.current=null,D.multiSelect?je.current={kind:"box",pointerId:T.pointerId,start:H,current:H}:D.dragMode?je.current={kind:"pan",pointerId:T.pointerId,start:H,pan0:O.pan,moved:!1}:je.current={kind:"tap",pointerId:T.pointerId,start:H,moved:!1},T.currentTarget.setPointerCapture(T.pointerId))},fv=T=>{const L=je.current;if(!L||E.current.readOnly)return;const D=qr(T);if(De.current.has(T.pointerId)&&De.current.set(T.pointerId,D),L.kind==="pinch"){const H=Oy(De.current);if(!H)return;const oe=Math.max(O.minZoom,Math.min(O.maxZoom,L.zoom*H.distance/L.distance));O.set({x:H.center.x-L.anchor.x*oe,y:H.center.y-L.anchor.y*oe},oe);return}if(L.pointerId===T.pointerId)switch(L.kind){case"pan":{const H=D.x-L.start.x,oe=D.y-L.start.y;if(!L.moved&&Math.hypot(H,oe)<=Ay)return;L.moved=!0,Ke.current=!0,O.set({x:L.pan0.x+H,y:L.pan0.y+oe});break}case"tap":{Math.hypot(D.x-L.start.x,D.y-L.start.y)>Ay&&(L.moved=!0);break}case"box":{Ke.current=!0,L.current=D,fr({x1:Math.min(L.start.x,D.x),y1:Math.min(L.start.y,D.y),x2:Math.max(L.start.x,D.x),y2:Math.max(L.start.y,D.y)});break}case"draw":{const H=O.renderedToModel(D),oe=so(H,L.reverse?"source":"target");Tr(L.reverse&&oe?{source:oe.nodeId,sourceProperty:oe.property,point:H,target:L.source,targetProperty:L.sourceProperty}:{source:L.source,sourceProperty:L.sourceProperty,point:H,target:(oe==null?void 0:oe.nodeId)??Dr(H,L.source),targetProperty:oe==null?void 0:oe.property});break}}},jl=(T,L)=>{var oe,Se,Fe,ze,Te;De.current.delete(T.pointerId);const D=je.current;if(!D)return;if(D.kind==="pinch"){const X=[...De.current][0];je.current=X&&E.current.dragMode&&!L?{kind:"pan",pointerId:X[0],start:X[1],pan0:O.pan,moved:!0}:null;return}if(D.pointerId!==T.pointerId)return;je.current=null;try{T.currentTarget.releasePointerCapture(T.pointerId)}catch{}const H=E.current;switch(L=L||!!H.readOnly,D.kind){case"pan":case"tap":!L&&!D.moved&&((oe=H.onBackgroundTap)==null||oe.call(H));break;case"box":{if(fr(null),L)break;const X=O.renderedToModel(D.start),de=O.renderedToModel(D.current),ce={x1:Math.min(X.x,de.x),y1:Math.min(X.y,de.y),x2:Math.max(X.x,de.x),y2:Math.max(X.y,de.y)};if(ce.x2-ce.x1<1&&ce.y2-ce.y1<1){(Se=H.onBackgroundTap)==null||Se.call(H);break}const Ie=[];for(const yr of H.nodes){const Vr=er(yr.id);Vr&&X0(bt(Vr),ce)&&Ie.push(yr.id)}Ie.length&&((Fe=H.onBoxSelect)==null||Fe.call(H,Ie));break}case"draw":{if(Tr(null),L)break;const X=qr(T),de=O.renderedToModel(X),ce=so(de,D.reverse?"source":"target"),Ie=(ce==null?void 0:ce.nodeId)??Dr(de);if(Ie===D.source&&(D.sourceProperty===void 0||(ce==null?void 0:ce.property)===void 0||ce.property===D.sourceProperty))break;Ie?(ze=H.onEdgeDraw)==null||ze.call(H,D.reverse?Ie:D.source,D.reverse?D.source:Ie,D.sourceProperty!==void 0||(ce==null?void 0:ce.property)!==void 0?{sourceProperty:D.reverse?ce==null?void 0:ce.property:D.sourceProperty,targetProperty:D.reverse?D.sourceProperty:ce==null?void 0:ce.property}:void 0):Math.max(Math.abs(T.clientX-D.startClient.x),Math.abs(T.clientY-D.startClient.y))>VS&&((Te=H.onDrawIntoSpace)==null||Te.call(H,D.source,de,D.sourceProperty,D.reverse));break}}},rt=_.useCallback(()=>{var D;const T=je.current,L=[...De.current.keys()];T&&T.kind!=="pinch"&&L.push(T.pointerId),je.current=null,De.current.clear(),Tr(null),fr(null);for(const H of L)(D=P.current)!=null&&D.hasPointerCapture(H)&&P.current.releasePointerCapture(H)},[]);_.useEffect(()=>{const T=L=>{L.key==="Escape"&&rt()};return window.addEventListener("keydown",T),window.addEventListener("blur",rt),()=>{window.removeEventListener("keydown",T),window.removeEventListener("blur",rt),je.current=null,De.current.clear()}},[rt]),_.useEffect(()=>{rt()},[g,b,w,o,n,e.drawHandles,e.readOnly,rt]);const hv=_.useMemo(()=>{const T=new Map,L=new Map;for(const D of I){if(D.source!==D.target)continue;const H=T.get(D.source)??0;T.set(D.source,H+1),L.set(D.id,H)}return L},[I]),co=DS[n],[uo,pv]=_.useState(null),lo=BS(t,I,!!((Pl=e.edgeReveal)!=null&&Pl.revealNodes));_.useLayoutEffect(()=>{P.current&&uo&&bw(P.current)});const fo=Z0(I,_e,co),gv=e.onEdgeSelect,yv=e.onContainerSelect,kl=Ne?Ne.target&&_e(Ne.target,Ne.targetProperty)||{x:Ne.point.x,y:Ne.point.y,w:1,h:1}:null,Rl=Ne?_e(Ne.source,Ne.sourceProperty):null,mv=["flow-sdk-canvas",g?"flow-sdk-draw":"",v?"flow-sdk-perf":""].filter(Boolean).join(" ");return f.jsxs("div",{ref:P,className:mv,"data-edge-mode":o,onPointerDownCapture:dv,onPointerMove:fv,onPointerUp:T=>jl(T,!1),onPointerCancel:T=>jl(T,!0),onLostPointerCapture:T=>{const L=je.current;L&&(L.kind==="pinch"||L.pointerId===T.pointerId)&&rt()},onClickCapture:T=>{if(!T.currentTarget.contains(T.target))return;const L=T.target instanceof Element&&T.target.closest("button[data-flow-fullscreen]");(Ke.current||e.readOnly&&!L)&&(T.preventDefault(),T.stopPropagation())},children:[f.jsx("svg",{className:"flow-sdk-svg",children:f.jsxs("g",{ref:A,children:[f.jsx("g",{className:"flow-sdk-containers",children:[...Ue].filter(([T])=>vt(T,r,o)).filter(([T])=>!S||S.has(T)).map(([T,L])=>{var D,H;return f.jsx(uw,{id:T,rect:L,label:or.get(T),labelLayer:uo,labelContent:(D=t.find(oe=>oe.id===T&&oe.label!==void 0))==null?void 0:D.element,style:y(T),onSelect:yv,onCollapse:e.readOnly?void 0:e.onContainerCollapse,selected:(H=e.selectedNodeIds)==null?void 0:H.includes(T)},T)})}),f.jsx("g",{className:"flow-sdk-edges",children:tr&&I.map(T=>{var H,oe,Se;if(!lo.ready.has(T.id)||S&&(!S.has(T.source)||!S.has(T.target)))return null;const L=_e(T.source,T.sourceProperty),D=_e(T.target,T.targetProperty);return!L||!D?null:f.jsx(id,{id:T.id,edgeData:T.data,validationIssue:T.validationIssue,edgeType:T.type,edgeRadius:e.edgeRadius,propertyMode:k,customEdgeTypes:e.customEdgeTypes,reveal:e.edgeReveal,onRevealComplete:lo.complete,source:L,target:D,sourceProperty:T.sourceProperty,targetProperty:T.targetProperty,sourceY:B(T.source,T.sourceProperty),targetY:B(T.target,T.targetProperty),sourcePort:re(T.source,T.sourceProperty),targetPort:re(T.target,T.targetProperty),dir:co,turn:((H=fo.get(T.id))==null?void 0:H.turn)??T.turn,labelAtTarget:(oe=fo.get(T.id))==null?void 0:oe.labelAtTarget,labelFraction:(Se=fo.get(T.id))==null?void 0:Se.labelFraction,color:T.color,connectorColor:T.connectorColor,labelBg:T.labelBg,label:T.label,labelLayer:uo,dashed:T.dashed,animated:T.animated&&!v,inverted:T.inverted,loopIndex:hv.get(T.id)??0,onSelect:gv},T.id)})}),tr&&Ne&&Du(Ne,o)&&Rl&&kl&&f.jsx("g",{className:"flow-sdk-ghost",pointerEvents:"none",children:f.jsx(id,{id:"__flow-sdk-ghost",edgeData:{id:"__flow-sdk-ghost",source:Ne.source,target:Ne.target??"",sourceProperty:Ne.sourceProperty,targetProperty:Ne.targetProperty},edgeType:e.edgeType,edgeRadius:e.edgeRadius,propertyMode:k,customEdgeTypes:e.customEdgeTypes,source:Rl,target:kl,sourceProperty:Ne.sourceProperty,targetProperty:Ne.targetProperty,sourceY:B(Ne.source,Ne.sourceProperty),sourcePort:re(Ne.source,Ne.sourceProperty),targetPort:Ne.target?re(Ne.target,Ne.targetProperty):void 0,targetY:Ne.target?B(Ne.target,Ne.targetProperty):void 0,dir:co,turn:.5,color:m,labelBg:m})})]})}),f.jsx("div",{ref:q,className:"flow-sdk-nodes",children:t.map(T=>{var Se,Fe;const L=ne.get(T.id),D=Ue.get(T.id);if(D&&T.label!==void 0)return null;const H=(L==null?void 0:L.x)??(D?(D.x1+D.x2)/2:0),oe=(L==null?void 0:L.y)??(D?(D.y1+D.y2)/2:0);return f.jsx(FS,{id:T.id,x:H,y:oe,placed:!!L||!!D,hidden:!lo.shown.has(T.id)||!vt(T.id,r,o)||!!S&&!S.has(T.id),onMount:We,drawHandles:e.drawHandles&&!e.readOnly,drawMode:g,connectedPorts:new Set(I.flatMap(ze=>[...ze.source===T.id&&ze.sourceProperty!==void 0?[`source:${ze.sourceProperty}`]:[],...ze.target===T.id&&ze.targetProperty!==void 0?[`target:${ze.targetProperty}`]:[]])),hasCollapseControl:T.hasCollapseControl,handleColor:m,animated:T.animated&&!D&&!v,animationColor:T.animationColor,animationWidth:T.animationWidth,animationVariant:T.animationVariant,width:(Se=z.current.get(T.id))==null?void 0:Se.w,height:(Fe=z.current.get(T.id))==null?void 0:Fe.h,propertyMode:k,resolvedRows:Z.get(T.id),reversePorts:n==="RL",direction:n,onPropertyRows:N,onSurface:se,children:T.element},T.id)})}),dr&&f.jsx("div",{className:"flow-sdk-box",style:{left:dr.x1,top:dr.y1,width:dr.x2-dr.x1,height:dr.y2-dr.y1}}),f.jsx("svg",{className:"flow-sdk-svg flow-sdk-label-overlay",style:{zIndex:11,pointerEvents:"none"},children:f.jsx("g",{ref:j,transform:`translate(${O.pan.x} ${O.pan.y}) scale(${O.zoom})`,children:f.jsx("g",{ref:pv,className:"flow-sdk-labels",style:{pointerEvents:g?"none":"visiblePainted",outline:"none"}})})})]})}const HS=_.memo(US);function _l(e=!0){const t=_.useRef(null);return _.useEffect(()=>{if(!e||!t.current)return;const r=o=>{o.stopPropagation()},n=t.current,i=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return i.forEach(o=>n.addEventListener(o,r)),()=>{i.forEach(o=>n.removeEventListener(o,r))}},[e]),t}const Rt=({nodeId:e,label:t,color:r,fontWeight:n="bold",fontSize:i="5xl",wrap:o=!1,isEditing:s,onEditStart:a,onEditEnd:c})=>{const{callbacks:u,config:l,readOnly:d}=Le(),h=l.editable&&!d,[p,y]=_.useState(t),[m,g]=_.useState(),b=_.useRef(null),w=_.useRef(!1),v=_l(s);_.useEffect(()=>{if(s&&(w.current=!1,b.current)){b.current.focus();const C=b.current.value.length;b.current.setSelectionRange(C,C)}},[s]);const x=()=>{var S;if(w.current)return;w.current=!0;const C=p.trim();C&&C!==t&&((S=u.onNodeLabelChange)==null||S.call(u,e,C)),c()};return!h||!s?f.jsx(F.Text,{color:r,fontWeight:n,fontSize:i,minW:0,maxW:"100%",whiteSpace:o?"normal":"nowrap",overflowWrap:o?"anywhere":void 0,overflow:"hidden",textOverflow:"ellipsis",title:t,onDoubleClick:h?C=>{C.stopPropagation(),g({width:C.currentTarget.offsetWidth,height:C.currentTarget.offsetHeight}),y(t),a()}:void 0,cursor:h?"text":void 0,children:t}):f.jsxs("div",{ref:v,style:{position:"relative",width:"max-content",minWidth:m==null?void 0:m.width,maxWidth:900,height:m==null?void 0:m.height},children:[f.jsx(F.Text,{as:"span","aria-hidden":"true",display:"block",visibility:"hidden",fontWeight:n,fontSize:i,lineHeight:"normal",whiteSpace:"pre",overflow:"hidden",children:p||" "}),f.jsx(F.Input,{ref:b,value:p,onChange:C=>y(C.target.value),onBlur:x,onKeyDown:C=>{C.key==="Enter"&&x(),C.key==="Escape"&&(w.current=!0,c())},color:r,fontWeight:n,fontSize:i,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"})]})};function tv({id:e,label:t,role:r,side:n,position:i=.5,placement:o,children:s,style:a}){return f.jsx("div",{"data-flow-property":e,"data-flow-port-role":r,"data-flow-port-side":n,"data-flow-port-position":n?i:void 0,"data-flow-port-placement":o,style:{minHeight:32,display:"flex",alignItems:"center",justifyContent:r==="source"?"flex-end":"flex-start",...a,...n?{display:"none"}:{}},children:s??t??e})}const KS=Mn.default.dialog`
|
|
211
|
+
${e=>Kr(e.$surface,e.$border)}
|
|
211
212
|
&,
|
|
212
213
|
&:hover {
|
|
213
214
|
box-shadow: none !important;
|
|
@@ -231,7 +232,7 @@
|
|
|
231
232
|
& *::-webkit-scrollbar {
|
|
232
233
|
display: none;
|
|
233
234
|
}
|
|
234
|
-
`,
|
|
235
|
+
`,JS=Mn.default.div`
|
|
235
236
|
min-height: 0;
|
|
236
237
|
container-type: inline-size;
|
|
237
238
|
@container (min-width: 520px) {
|
|
@@ -276,5 +277,5 @@
|
|
|
276
277
|
black calc(100% - 32px),
|
|
277
278
|
transparent
|
|
278
279
|
);
|
|
279
|
-
`;function tv({nodeAddress:e,active:t,label:r,open:n=!1,onClose:i,children:o,filter:s,height:a,width:c}){const{background:u,border:l,colorText:d}=Ze(),{colorMode:h}=Ne(),p=_.useRef(null),y=_.useId(),{data:m,schema:g,bindings:b}=_.useContext(Cr),w=o!==void 0||!!(m&&g&&(b?dn(b,e,g):Tt(m,e,g)));_.useEffect(()=>{var x,C,S,E,I;!t||!w||!n?(x=p.current)==null||x.close():(C=p.current)!=null&&C.open||((S=p.current)==null||S.showModal(),(I=(E=p.current)==null?void 0:E.querySelector("[data-form-filter] input"))==null||I.focus())},[t,w,n]);const v=xe(u);return w?f.jsx(f.Fragment,{children:typeof document<"u"&&tn.createPortal(f.jsx(US,{ref:p,id:y,$surface:v,$border:xe(l),"aria-label":`Configure ${r}`,onClose:i,onPointerDown:x=>x.stopPropagation(),onWheel:x=>x.stopPropagation(),onKeyDown:x=>x.stopPropagation(),onClick:x=>{var C;x.stopPropagation(),x.target===x.currentTarget&&((C=p.current)==null||C.close())},style:{position:"fixed",inset:"94px 20px auto auto",margin:0,padding:20,width:c??"var(--top-toolbar-width, 360px)",boxSizing:"border-box",maxWidth:"calc(100vw - 40px)",maxHeight:"calc(100dvh - 114px)",height:a,overflow:"hidden",borderRadius:30,background:v,color:xe(d),fontSize:16,textTransform:"none"},children:n&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexShrink:0},children:[f.jsx("strong",{style:{overflowWrap:"anywhere",minWidth:0},children:r}),f.jsx(At,{"aria-label":"Close node configuration",onClick:()=>{var x;return(x=p.current)==null?void 0:x.close()}})]}),s&&f.jsx("div",{"data-form-filter":"",style:{flexShrink:0},children:s}),f.jsx(HS,{$divider:`var(--chakra-colors-gray-${h==="dark"?"700":"200"})`,"data-form-scroll":"",style:a?{flex:1}:void 0,children:o??f.jsx(Rm,{nodeAddress:e})})]})}),document.body)}):null}const zu=({icon:e,label:t,onClick:r,color:n,boxSize:i=6,...o})=>{const{background:s,border:a,colorText:c}=Ze();return f.jsx(Ie,{label:t,children:f.jsx(F.Flex,{children:f.jsx(F.Icon,{as:e,boxSize:i,color:n,cursor:r?"pointer":void 0,onClick:r})})})},KS=({data:e,children:t,isInverted:r,isParent:n,onOpenView:i,editOnMount:o=!1})=>{var N,ne,be,fe,J,te;const{selectedNodeIds:s,setSelectedNodeIds:a,selectedEdgeId:c,setSelectedEdgeId:u,isMultiSelectMode:l,isPerformanceMode:d,engineRef:h,callbacks:p,config:y,themeColor:m,direction:g,nodeViewModes:b}=Ne(),{background:w,border:v,colorText:x}=Ze(),C=_.useRef(null),S=_.useRef(null),[E,I]=_.useState(!1),[A,M]=_.useState(o&&!!y.editable&&!y.readOnly),[j,R]=_.useState(!1),P=e==null?void 0:e.id,k=Pm(P),q=s.includes(P),O=y.nodeOverlayActions,z=y.renderNodeOverlay,U=(()=>{var G;try{const le=(G=h.current)==null?void 0:G.zoom();return le!==void 0&&le<.08}catch{return!1}})(),se=_.useCallback(G=>{var ue,Ce,ye,Me;if(A||y.readOnly)return;const le={shiftKey:G.shiftKey,ctrlKey:G.ctrlKey,metaKey:G.metaKey,altKey:G.altKey};if(c&&(u(null),(ue=p.onEdgeDeselect)==null||ue.call(p)),l){const ee=s.includes(P),he=ee?s.filter(ve=>ve!==P):[...s,P];a(he),ee?(Ce=p.onNodeDeselect)==null||Ce.call(p):(ye=p.onNodeSelect)==null||ye.call(p,P,e,le)}else a([P]),(Me=p.onNodeSelect)==null||Me.call(p,P,e,le)},[P,e,s,c,l,A,a,u,p,y]),Q=_.useCallback(()=>{var G;A||y.readOnly||(G=p.onNodeDoubleClick)==null||G.call(p,P,e)},[P,e,A,p,y]),Y=_.useCallback(()=>{S.current&&clearTimeout(S.current),S.current=setTimeout(()=>I(!0),100)},[]),ge=_.useCallback(()=>{S.current&&clearTimeout(S.current),I(!1)},[]),ce=!!((N=e==null?void 0:e.config)!=null&&N.form),$={tabIndex:ce?0:void 0,"aria-haspopup":ce?"dialog":void 0,"aria-expanded":ce?j:void 0,onDoubleClickCapture:G=>{var le;!ce&&!i||y.readOnly||A||!G.currentTarget.contains(G.target)||G.target instanceof Element&&G.target.closest("button, input, textarea, select, a, [contenteditable=true], [data-flow-content]")||(G.preventDefault(),G.stopPropagation(),a([P]),i?i():R(!0),(le=p.onNodeDoubleClick)==null||le.call(p,P,e))},onKeyDown:G=>{!ce&&!i||y.readOnly||G.target!==G.currentTarget||G.key!=="Enter"||(G.preventDefault(),G.stopPropagation(),a([P]),i?i():R(!0))}},V=ce&&f.jsx(tv,{nodeAddress:P,active:q,label:e.label||e.headerTitle||"Node",open:j,onClose:()=>{var G;R(!1),q&&((G=C.current)==null||G.focus({preventScroll:!0}))}}),W=Array.isArray((ne=e==null?void 0:e.config)==null?void 0:ne.ports)?e.config.ports.map(G=>f.jsx(rv,{...G},`${G.id}:${G.role}`)):null;return n?f.jsxs(F.Box,{ref:C,...$,onClick:se,onDoubleClick:Q,onMouseEnter:Y,onMouseLeave:ge,cursor:"pointer",position:"relative",children:[V,!d&&(z||O&&O.length>0)&&E&&!U&&f.jsxs(f.Fragment,{children:[f.jsx(F.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>I(!0),onMouseLeave:ge}),z?f.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>I(!0),onMouseLeave:ge,willChange:"transform",children:z({nodeId:P,nodeData:e,isRoot:P==="root",isParent:!0,isHovered:E,setIsHovered:I})}):f.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:w,p:3,borderColor:v,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>I(!0),onMouseLeave:ge,willChange:"transform",children:f.jsx(F.HStack,{px:2,gap:2,children:O.map((G,le)=>f.jsxs(F.Box,{display:"contents",children:[le>0&&f.jsx(F.Box,{borderColor:v,height:5,borderRightWidth:1}),f.jsx(zu,{icon:G.icon,label:G.label,color:x,bgColor:w,borderColor:v,textColor:x,boxSize:5,onClick:ue=>{var Ce;ue.stopPropagation(),(Ce=p.onNodeHoverAction)==null||Ce.call(p,G.id,P,e)}})]},G.id))})})]}),t({id:P,data:e,isActive:q,isLowZoom:U,isEditing:A,onEditStart:()=>M(!0),onEditEnd:()=>M(!1)}),k&&!((be=e==null?void 0:e.config)!=null&&be.parentContainer)&&((fe=e==null?void 0:e.config)==null?void 0:fe.collapsed)!==void 0&&(()=>{var ue;const G=g==="TB"||g==="BT",le=r||g==="RL";return f.jsx(F.IconButton,{position:"absolute",...G?{[g==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:le?void 0:"-75px",left:le?"-75px":void 0,top:"50%",transform:"translateY(-50%)"},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:y.readOnly,onClick:Ce=>{var ye;Ce.stopPropagation(),(ye=p.onNodeCollapse)==null||ye.call(p,P,!e.config.collapsed)},bgColor:xe(((ue=e==null?void 0:e.viewProps)==null?void 0:ue.bgColor)||m),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(K.PiPlusBold,{size:30,color:xe("gray.800")}):f.jsx(K.PiMinusBold,{size:30,color:xe("gray.800")})})})()]}):f.jsxs(F.Box,{ref:C,...$,onClick:se,onDoubleClick:Q,onMouseEnter:Y,onMouseLeave:ge,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[V,W,!d&&(z||O&&O.length>0)&&E&&!U&&f.jsxs(f.Fragment,{children:[f.jsx(F.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>I(!0),onMouseLeave:ge}),z?f.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>I(!0),onMouseLeave:ge,willChange:"transform",children:z({nodeId:P,nodeData:e,isRoot:P==="root",isParent:!!n,isHovered:E,setIsHovered:I})}):f.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:w,p:3,borderColor:v,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>I(!0),onMouseLeave:ge,willChange:"transform",children:f.jsx(F.HStack,{px:2,gap:2,children:O.map((G,le)=>f.jsxs(F.Box,{display:"contents",children:[le>0&&f.jsx(F.Box,{borderColor:v,height:5,borderRightWidth:1}),f.jsx(zu,{icon:G.icon,label:G.label,color:x,bgColor:w,borderColor:v,textColor:x,boxSize:5,onClick:ue=>{var Ce;ue.stopPropagation(),(Ce=p.onNodeHoverAction)==null||Ce.call(p,G.id,P,e)}})]},G.id))})})]}),f.jsxs(F.Box,{position:"relative",display:"flex",h:"100%",w:"100%",children:[k&&!((J=e==null?void 0:e.config)!=null&&J.parentContainer)&&((te=e==null?void 0:e.config)==null?void 0:te.collapsed)!==void 0&&!n&&(()=>{var Ce,ye,Me;const G=g==="TB"||g==="BT",le=r||g==="RL",ue=(Ce=e==null?void 0:e.config)!=null&&Ce.labelBelow&&b[P]!=="properties"?((((ye=e==null?void 0:e.viewProps)==null?void 0:ye.fontSize)||1)*100+100)/2:void 0;return f.jsx(F.IconButton,{position:"absolute",...G?{[g==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:le?void 0:ue===void 0?"-75px":`calc(50% - ${ue+75}px)`,left:le?ue===void 0?"-75px":`calc(50% - ${ue+75}px)`:void 0,alignSelf:ue===void 0?"center":void 0,top:ue===void 0?void 0:`${ue}px`,transform:ue===void 0?void 0:"translateY(-50%)",zIndex:ue===void 0?void 0:1},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:y.readOnly,onClick:ee=>{var he;ee.stopPropagation(),(he=p.onNodeCollapse)==null||he.call(p,P,!e.config.collapsed)},bgColor:xe(((Me=e==null?void 0:e.viewProps)==null?void 0:Me.bgColor)||m),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(K.PiPlusBold,{size:30,color:xe("gray.800")}):f.jsx(K.PiMinusBold,{size:30,color:xe("gray.800")})})})(),t({id:P,data:e,isActive:q,isLowZoom:U,isEditing:A,onEditStart:()=>M(!0),onEditEnd:()=>M(!1)})]})]})},oo=_.memo(KS),JS=({id:e,data:t,isActive:r,isEditing:n,onEditStart:i,onEditEnd:o})=>{var m,g,b,w,v,x,C,S;const{themeColor:s}=Ne(),{colorText:a}=Ze(),c=((m=t==null?void 0:t.viewProps)==null?void 0:m.bgColor)==="transparent",u=((g=t==null?void 0:t.viewProps)==null?void 0:g.outline)===!0,{highlightColor:l,borderColor:d,textColor:h}=ln(((b=t==null?void 0:t.viewProps)==null?void 0:b.bgColor)||s),p=xe(((w=t==null?void 0:t.viewProps)==null?void 0:w.textColor)||(c||u?a:h)),y=((v=t==null?void 0:t.viewProps)==null?void 0:v.borderColor)||(u?!c&&((x=t==null?void 0:t.viewProps)==null?void 0:x.bgColor)||s:d);return f.jsx(F.Box,{"data-flow-node-surface":"",borderRadius:(C=t==null?void 0:t.viewProps)==null?void 0:C.borderRadius,bgColor:u?"transparent":l,...Pn(t==null?void 0:t.viewProps,y,r,2),py:14,px:20,whiteSpace:"nowrap",w:"fit-content",children:f.jsxs(F.Flex,{justifyContent:"start",alignItems:"center",gap:8,w:"fit-content",maxW:900,minW:0,fontSize:"5xl",lineHeight:"normal",children:[((S=t==null?void 0:t.config)==null?void 0:S.icon)&&f.jsx(F.Box,{flexShrink:0,children:f.jsx(Or,{name:t.config.icon,size:80,color:p})}),f.jsx(Rt,{nodeId:e,label:(t==null?void 0:t.label)||(t==null?void 0:t.text)||"",color:p,isEditing:n,onEditStart:i,onEditEnd:o})]})})};function io(){const{nodeViewModes:e,setNodeViewMode:t,allNodesIconLabel:r,setAllNodesIconLabel:n}=Ne();return{allNodesIconLabel:r,setAllNodesIconLabel:n,getNodeViewMode:i=>e[i]??"default",showNodeProperties:i=>t(i,"properties"),restoreNodeView:i=>t(i,"default"),toggleNodeView:i=>t(i,e[i]==="properties"?"default":"properties"),setNodeViewMode:t}}const ZS=({id:e,isActive:t,data:r,isEditing:n,onEditStart:i,onEditEnd:o})=>{var v,x,C,S,E,I,A,M,j,R,P,k,q,O,z;const{themeColor:s}=Ne(),{colorText:a}=Ze(),c=((v=r==null?void 0:r.viewProps)==null?void 0:v.bgColor)==="transparent",u=((x=r==null?void 0:r.viewProps)==null?void 0:x.outline)===!0,l=!c&&((C=r==null?void 0:r.viewProps)==null?void 0:C.bgColor)||s,{borderColor:d,highlightColor:h,textColor:p}=ln(l),y=xe(((S=r==null?void 0:r.viewProps)==null?void 0:S.textColor)||(c||u?a:p)),m=c&&!u&&!((E=r==null?void 0:r.viewProps)!=null&&E.borderColor)?"transparent":xe(((I=r==null?void 0:r.viewProps)==null?void 0:I.borderColor)||(u?l:d)),g=c||u?"transparent":l!=null&&l.startsWith("#")?l:xe(h),b=(A=r==null?void 0:r.config)==null?void 0:A.icon,w=(r==null?void 0:r.label)??(r==null?void 0:r.text)??"";if((M=r==null?void 0:r.config)!=null&&M.labelBelow){const U=(((j=r==null?void 0:r.viewProps)==null?void 0:j.fontSize)||1)*100;return f.jsxs(F.Flex,{"data-flow-icon-label":"",direction:"column",align:"center",gap:"24px",width:`${Math.max(U+200,360)}px`,position:"relative",children:[f.jsx(F.Flex,{"data-flow-node-surface":"",align:"center",justify:"center",width:`${U+100}px`,height:`${U+100}px`,flexShrink:0,borderRadius:(R=r==null?void 0:r.viewProps)==null?void 0:R.borderRadius,backgroundColor:g,...Pn(r==null?void 0:r.viewProps,m,t,2),children:!!b&&f.jsx(Or,{name:b,size:U,color:y})}),f.jsxs(F.Flex,{"data-flow-icon-caption":"",direction:"column",align:"center",gap:"8px",justify:"center",width:"100%",minW:0,textAlign:"center",children:[f.jsx(Rt,{nodeId:e,label:w,color:xe(((P=r==null?void 0:r.viewProps)==null?void 0:P.textColor)||a),isEditing:n,onEditStart:i,onEditEnd:o,wrap:!0}),typeof((k=r.config)==null?void 0:k.subtitle)=="string"&&r.config.subtitle!==""&&f.jsx(F.Text,{"data-flow-node-subtitle":"",color:xe(((q=r==null?void 0:r.viewProps)==null?void 0:q.textColor)||a),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 f.jsxs(F.Flex,{"data-flow-node-surface":"",align:"center",borderRadius:(O=r==null?void 0:r.viewProps)==null?void 0:O.borderRadius,bgColor:g,style:{backgroundColor:g},textTransform:"capitalize",...Pn(r==null?void 0:r.viewProps,m,t,2),px:50,w:"fit-content",whiteSpace:"nowrap",children:[!!b&&f.jsx(F.Flex,{align:"center",py:14,mr:w?8:0,flexShrink:0,children:f.jsx(Or,{name:b,size:(((z=r==null?void 0:r.viewProps)==null?void 0:z.fontSize)||1)*100,color:y},y)}),(w||!b)&&f.jsx(F.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:"fit-content",maxW:900,minW:0,children:f.jsx(Rt,{nodeId:e,label:w,color:y,isEditing:n,onEditStart:i,onEditEnd:o})})]})};function nv({onExpand:e,toggleLabel:t="Show properties",toggleDisabled:r=!1,renderCompact:n=ZS,...i}){const{colorMode:o,callbacks:s}=Ne();return f.jsx(oo,{...i,children:a=>f.jsxs(F.Box,{position:"relative",children:[f.jsx(n,{...a}),e&&a.isActive&&f.jsx(F.Box,{position:"absolute",top:"-24px",right:"-48px","data-flow-content-toggle":"",children:f.jsx(Ie,{label:t,children:f.jsx(Se,{"aria-label":t,icon:f.jsx(F.Icon,{as:K.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:o==="dark"?"gray.100":"gray.800",disabled:r,onClick:c=>{var u;c.stopPropagation(),e(),(u=s.onNodeViewToggle)==null||u.call(s,i.data.id)}})})})]})})}function YS({content:e,format:t,onEdit:r}){const n=_.useRef(null),i=_.useRef(null),o=_.useRef(null),s=_.useRef(!1),[a,c]=_.useState(!1),[u,l]=_.useState(""),d=!!r;_.useEffect(()=>{const g=()=>{var w;const b=document.fullscreenElement===i.current;c(b),s.current&&!b&&!document.fullscreenElement&&((w=o.current)==null||w.focus({preventScroll:!0})),s.current=b};return document.addEventListener("fullscreenchange",g),()=>document.removeEventListener("fullscreenchange",g)},[]);const h=async()=>{var g;l("");try{if(document.fullscreenElement===i.current)await document.exitFullscreen();else if((g=i.current)!=null&&g.requestFullscreen)await i.current.requestFullscreen();else throw new Error("Fullscreen is not supported in this browser.")}catch(b){l(b instanceof Error?b.message:"Unable to change fullscreen.")}},[p,y]=_.useState();_.useEffect(()=>{let g=!1;return Promise.resolve().then(()=>require("./contentPreviewDocument-B_Jous_v.cjs")).then(({contentPreviewDocument:b})=>b(e,t,d)).then(b=>{g||y({content:e,format:t,editable:d,document:b})},b=>{g||y({content:e,format:t,editable:d,error:b instanceof Error?b.message:String(b)})}),()=>{g=!0}},[e,t,d]),_.useEffect(()=>{if(!r)return;const g=async b=>{var w,v;if(!(!((w=n.current)!=null&&w.contentWindow)||b.source!==n.current.contentWindow||((v=b.data)==null?void 0:v.type)!=="squeed:content-edit"))try{document.fullscreenElement===i.current&&await document.exitFullscreen(),r()}catch(x){l(x instanceof Error?x.message:"Unable to close fullscreen.")}};return window.addEventListener("message",g),()=>window.removeEventListener("message",g)},[r]);const m=(p==null?void 0:p.content)===e&&p.format===t&&p.editable===d?p:void 0;return f.jsxs("div",{"data-flow-content-preview":"",style:{width:"100%",height:360,fontSize:16,overflow:"auto"},children:[f.jsx("pre",{"data-flow-preview-source":"",style:{display:"none",whiteSpace:"pre-wrap"},children:e}),f.jsxs(F.Box,{ref:i,position:"relative",w:"100%",h:"100%",bg:"white",onKeyDownCapture:g=>{g.key!=="Escape"||document.fullscreenElement!==i.current||(g.preventDefault(),g.stopPropagation(),h())},css:{"&:fullscreen":{width:"100vw",height:"100dvh",maxWidth:"none",maxHeight:"none",padding:0},"&:hover > [data-flow-fullscreen], &:focus-within > [data-flow-fullscreen]":{opacity:1,pointerEvents:"auto"},"@media (hover: none)":{"& > [data-flow-fullscreen]":{opacity:1,pointerEvents:"auto"}}},children:[f.jsx(Se,{ref:o,"data-flow-fullscreen":"","aria-label":a?"Exit fullscreen":"Expand preview",title:a?"Exit fullscreen":"Expand preview","aria-expanded":a,icon:a?f.jsx(K.PiArrowsIn,{}):f.jsx(K.PiArrowsOut,{}),position:"absolute",top:"8px",right:"8px",zIndex:1,opacity:a?1:0,pointerEvents:a?"auto":"none",onClick:g=>{g.stopPropagation(),h()}}),u&&f.jsx(F.Box,{role:"alert",position:"absolute",bottom:0,insetInline:0,bg:"white",color:"red.700",fontSize:"14px",children:u}),m!=null&&m.error?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:m.error}):m!=null&&m.document?f.jsx("iframe",{ref:n,title:`${t.toUpperCase()} content preview`,sandbox:t==="jsx"||d?"allow-scripts":"",allowFullScreen:!0,referrerPolicy:"no-referrer",srcDoc:m.document,style:{width:"100%",height:"100%",border:0,display:"block",background:"white"}}):f.jsx("span",{role:"status",children:"Loading preview..."})]})]})}const Oy=1.55;function XS({nodeId:e,content:t,color:r,format:n="markdown"}){const{callbacks:i,config:o,readOnly:s}=Ne(),a=!!o.editable&&!s,[c,u]=_.useState(!1),[l,d]=_.useState(t),[h,p]=_.useState(),y=_.useRef(null),m=_.useRef(!1),g=Cl(c);_.useLayoutEffect(()=>{const v=y.current;!c||!v||(v.style.height="auto",v.style.height=`${Math.max((h==null?void 0:h.height)??0,v.scrollHeight)}px`)},[l,c,h]),_.useEffect(()=>{var v,x;a?c&&(m.current=!1,(v=y.current)==null||v.focus({preventScroll:!0}),(x=y.current)==null||x.select()):u(!1)},[c,a]);const b=v=>{a&&(p({width:v.offsetWidth,height:v.offsetHeight}),d(t),u(!0))},w=()=>{var v;m.current||!a||(m.current=!0,l!==t&&((v=i.onNodeContentChange)==null||v.call(i,e,l)),u(!1))};return(!c||!a)&&n!=="markdown"?f.jsxs(F.Box,{ref:g,w:"100%",position:"relative","data-flow-content":"",css:{"&:hover > [data-flow-content-edit], &:focus-within > [data-flow-content-edit]":{opacity:1,pointerEvents:"auto"}},children:[a&&f.jsx(Se,{"data-flow-content-edit":"","aria-label":"Edit content source",title:"Edit content source",icon:f.jsx(K.PiCode,{}),position:"absolute",top:"8px",right:"48px",zIndex:1,opacity:0,pointerEvents:"none",onClick:v=>{v.stopPropagation(),b(v.currentTarget.parentElement)}}),f.jsx(YS,{content:t,format:n,onEdit:a?()=>{g.current&&b(g.current)}:void 0})]}):!c||!a?f.jsx(F.Box,{"data-flow-content":"",color:r,opacity:t?void 0:.6,w:"100%",minH:"1.2em",whiteSpace:"normal",lineHeight:Oy,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:v=>{v.stopPropagation(),b(v.currentTarget)},onKeyDown:v=>{a&&v.key==="Enter"&&v.target===v.currentTarget&&(v.preventDefault(),v.stopPropagation(),b(v.currentTarget))},children:f.jsx(Rv.default,{options:{forceBlock:!0,wrapper:_.Fragment,disableParsingRawHTML:!0,overrides:{a:{props:{target:"_blank",rel:"noopener noreferrer"}},img:{props:{loading:"lazy",referrerPolicy:"no-referrer"}}}},children:t||(a?"Write your content here":"")})}):f.jsx("div",{ref:g,style:{width:h==null?void 0:h.width,minHeight:h==null?void 0:h.height,maxWidth:"100%"},children:f.jsx(F.Textarea,{ref:y,"aria-label":"Node content",placeholder:"Write your content here",value:l,onChange:v=>d(v.target.value),onBlur:w,onKeyDown:v=>{v.stopPropagation(),!v.nativeEvent.isComposing&&(v.key==="Enter"&&(v.ctrlKey||v.metaKey)&&(v.preventDefault(),w()),v.key==="Escape"&&(m.current=!0,u(!1)))},color:r,fontFamily:"inherit",fontSize:"inherit",lineHeight:Oy,overflowWrap:"anywhere",whiteSpace:"pre-wrap",rows:1,bg:"transparent",display:"block",style:{border:0,outline:"none",boxShadow:"none"},_focus:{border:0,outline:"none",boxShadow:"none"},_focusVisible:{border:0,outline:"none",boxShadow:"none"},p:0,w:"100%",h:"100%",minW:0,minH:0,resize:"none"})})}const QS=(e,t,r)=>{var h,p,y,m;const n=((h=e==null?void 0:e.viewProps)==null?void 0:h.bgColor)||t,[i]=n.split("."),o=ln(n),s=((p=e==null?void 0:e.viewProps)==null?void 0:p.outline)===!0,a=n==="transparent"||s,c=r==="dark"?"gray.200":"gray.900",u=a?"transparent":n!=null&&n.startsWith("#")?xe(n):xe(o.bgColor),l=xe(((y=e==null?void 0:e.viewProps)==null?void 0:y.textColor)||(a?c:o.textColor)),d=xe(((m=e==null?void 0:e.viewProps)==null?void 0:m.borderColor)||(s?n==="transparent"?t:n:o.borderColor));return{...o,bgColor:a?"transparent":o.bgColor,highlightColor:a?"transparent":o.highlightColor,isTransparent:a,propertyColor:a?c:o.propertyColor,bg:n,wordBeforeDot:i,hexbgColor:u,hextextColor:l,hexborderColor:d}},e_=(e,t=350)=>`${String(e).substring(0,t)}${String(e).length>t?"...":""}`,r_=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,ov=600,t_=3,n_=e=>{const t=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(t*28+30,200)};function o_({headerTitle:e,hasContent:t,data:r,icon:n,colors:i,hasConfig:o,id:s,isActive:a,isEditing:c,onEditStart:u,onEditEnd:l,props:d,objVisible:h,setObjVisible:p,onShowNativeIcon:y}){var w,v;const{callbacks:m}=Ne(),g=d.onShowIcon??y,b=g?"Show icon":h?"Show content":"Show properties";return f.jsx(f.Fragment,{children:(e||t||((w=r.config)==null?void 0:w.form)||a&&y)&&f.jsxs(F.Flex,{justify:"flex-start",direction:"row",p:t||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:i.propertyColor,bgColor:i.highlightColor,borderBottomColor:!o&&!t?"transparent":i.hexborderColor,children:[!!n&&f.jsx(F.Flex,{mr:6,alignItems:"center",flexShrink:0,children:f.jsx(Or,{name:n,size:64,color:i.hextextColor},i.hextextColor)}),f.jsx(Rt,{nodeId:s,label:r_(e),color:((v=r==null?void 0:r.viewProps)==null?void 0:v.textColor)||i.propertyColor,isEditing:c,onEditStart:u,onEditEnd:l}),a&&(t||g)&&f.jsx(F.Box,{ml:"auto",pl:6,flexShrink:0,"data-flow-content-toggle":"",children:f.jsx(Ie,{label:b,children:f.jsx(Se,{"aria-label":b,icon:f.jsx(F.Icon,{as:K.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:i.hextextColor,onClick:x=>{var C;x.stopPropagation(),g?g():p(!h),(C=m.onNodeViewToggle)==null||C.call(m,s)}})})})]})})}function i_({data:e,resourcePorts:t,inspecting:r,form:n,inspectionPorts:i,extraPorts:o,colors:s,direction:a,uniformKeyWidth:c}){const{edgeById:u}=Yr(),l=new Set;for(const{data:d}of u.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 f.jsx(F.Box,{children:Object.entries(e.description||{}).map(([d,h],p)=>{var P,k,q;const y=t&&Object.keys(t).find(O=>O.slice(O.indexOf(":")+1)===d),m=r&&((P=n==null?void 0:n.type.ports)==null?void 0:P[d]),g=y??(m?`${m.kind}:${d}`:d),b=i.find(O=>O.id===g),w=y?"source":b==null?void 0:b.role,v=l.has(`source:${g}`),x=l.has(`target:${g}`),C=o.some(O=>O.id===d),S=h===""&&(C||(w?l.has(`${w}:${g}`):v||x)),E=w??(v!==x?v?"source":"target":void 0),I=(b==null?void 0:b.side)??(E?E==="source"!=(a==="RL")?"right":"left":void 0),A=S&&I==="right"?"right":"left",M=(b==null?void 0:b.label)??(m==null?void 0:m.label)??(C?d.replace(/^(template|input|output|config|error):/,""):d),j=Ir(s.wordBeforeDot)[typeof h],R=Ir(s.wordBeforeDot).property;return f.jsxs(F.Box,{"data-flow-property":y&&(a==="TB"||a==="BT")?void 0:g,"data-flow-port-role":w,"data-flow-inspection-row":r?"":void 0,children:[f.jsxs(F.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[f.jsx(F.Flex,{justifyContent:"start",align:"center",background:s.highlightColor,width:S?"100%":`${c}px`,minWidth:`${c}px`,borderRightColor:s.hexborderColor,borderRightWidth:S?0:1,children:f.jsx(F.Text,{py:5,px:10,w:"100%",textAlign:A,whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((k=e==null?void 0:e.viewProps)==null?void 0:k.textColor)||(s.isTransparent?s.hextextColor:R),children:M})}),!S&&f.jsx(F.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:s.hexbgColor,w:ov,maxH:200,children:f.jsx(F.Text,{overflow:"hidden",py:3,px:4,whiteSpace:"normal",textOverflow:"ellipsis",fontSize:"4xl",color:((q=e==null?void 0:e.viewProps)==null?void 0:q.textColor)||(s.isTransparent?s.hextextColor:j),fontWeight:400,children:e_(h)})})]}),p!==Object.entries(e.description||{}).length-1&&f.jsx(F.Box,{borderTopWidth:1,my:0,borderColor:s.hexborderColor})]},d)})})}function a_(e){var v,x,C;const{themeColor:t,colorMode:r,direction:n}=Ne(),i=io(),o=i.getNodeViewMode(e.data.id)==="properties",s=S=>i.setNodeViewMode(e.data.id,S?"properties":"default"),a=!!e.onShowIcon||o||typeof((v=e.data.config)==null?void 0:v.content)!="string",{bindings:c,data:u,schema:l}=_.useContext(Cr),d=(x=c==null?void 0:c[e.data.id])==null?void 0:x.portResources,h=c?dn(c,e.data.id,l):u&&l?Tt(u,e.data.id,l):void 0,p=h&&Re(u,"address"in h?h.address:e.data.id),y=p&&typeof p=="object"&&h?Object.fromEntries(Object.keys(h.type.properties).filter(S=>{var E;return Object.prototype.hasOwnProperty.call(p,S)&&Ln((E=h.fields[S])==null?void 0:E.$visibleWhen,u)}).map(S=>[S,p[S]!==null&&typeof p[S]=="object"?JSON.stringify(p[S],null,2):p[S]===null?"null":p[S]])):{},m=d?Object.fromEntries(Object.entries(d).map(([S,E])=>{var I;return[S.slice(S.indexOf(":")+1),((I=Re(u,E))==null?void 0:I.name)??E.split(".").at(-1)]})):Object.keys(e.data.description??{}).length?e.data.description:y,g=a&&!d?((C=e.data.config)==null?void 0:C.ports)??[]:[],b=g.filter(S=>!Object.prototype.hasOwnProperty.call(m,S.id)&&!Object.entries((h==null?void 0:h.type.ports)??{}).some(([E,I])=>`${I.kind}:${E}`===S.id&&Object.prototype.hasOwnProperty.call(m,E))),w={...m,...Object.fromEntries(b.map(S=>[S.id,""]))};return{themeColor:t,colorMode:r,direction:n,objVisible:o,setObjVisible:s,inspecting:a,resourcePorts:d,form:h,description:w,inspectionPorts:g,extraPorts:b}}const Sl=e=>{var g,b,w;const{themeColor:t,colorMode:r,direction:n,objVisible:i,setObjVisible:o,inspecting:s,resourcePorts:a,form:c,description:u,inspectionPorts:l,extraPorts:d}=a_(e),h=io(),p=h.getNodeViewMode(e.data.id)==="icon-label",m=!e.onShowIcon&&!((g=e.data.config)!=null&&g.parentContainer)&&typeof((b=e.data.config)==null?void 0:b.content)!="string"?()=>h.setNodeViewMode(e.data.id,"icon-label"):void 0;return!e.onShowIcon&&p?f.jsx(nv,{...e,data:{...e.data,label:e.data.label??e.data.headerTitle,config:{...e.data.config,labelBelow:!0,icon:((w=e.data.config)==null?void 0:w.icon)||"PiBracketsCurly"}},onExpand:()=>h.restoreNodeView(e.data.id)}):f.jsx(oo,{...e,data:{...e.data,description:u},children:({id:v,data:x,isActive:C,isEditing:S,onEditStart:E,onEditEnd:I})=>{var U,se,Q,Y,ge,ce,$,V,W,N;const A=QS(x,t,r),M=x.label??x.headerTitle,j=Object.entries(x.description||{}).length>0,R=n_(x.description),P=(se=(U=e.data)==null?void 0:U.config)==null?void 0:se.icon,k=(Y=(Q=e.data)==null?void 0:Q.config)==null?void 0:Y.content,q=typeof k=="string"&&!e.onShowIcon,O=((ge=x==null?void 0:x.viewProps)==null?void 0:ge.borderRadius)??"53px",z=Pn(x==null?void 0:x.viewProps,A.hexborderColor,C,t_);return f.jsx(F.Flex,{justifyContent:"space-between",...x==null?void 0:x.viewProps,"data-flow-node-surface":"",direction:"column",p:0,borderRadius:O,overflow:"hidden",alignItems:"center",style:{backgroundColor:A.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:"100%",minW:q||e.onShowIcon?R+ov+z.borderWidth*2:void 0,...z,children:f.jsxs(F.Flex,{width:"100%",direction:"column",borderRadius:O,borderColor:A.hexborderColor,borderWidth:0,overflow:"hidden",children:[f.jsx(o_,{headerTitle:M,hasContent:q,data:x,icon:P,colors:A,hasConfig:j,id:v,isActive:C,isEditing:S,onEditStart:E,onEditEnd:I,props:e,objVisible:i,setObjVisible:o,onShowNativeIcon:m}),q&&!i?f.jsx(F.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:A.highlightColor,p:["html","jsx"].includes(($=(ce=e.data)==null?void 0:ce.config)==null?void 0:$.contentFormat)?0:12,fontSize:"5xl",lineHeight:"normal",children:f.jsx(XS,{nodeId:v,content:k,format:(W=(V=e.data)==null?void 0:V.config)==null?void 0:W.contentFormat,color:((N=x==null?void 0:x.viewProps)==null?void 0:N.textColor)||A.hextextColor})}):f.jsx(i_,{data:x,resourcePorts:a,inspecting:s,form:c,inspectionPorts:l,extraPorts:d,colors:A,direction:n,uniformKeyWidth:R})]})})}})};Sl.displayName="NodeJsonObjectView";const iv=e=>{var m,g,b,w,v,x,C,S,E,I,A;const t=io(),[r,n]=_.useState(!1),i=t.getNodeViewMode(e.data.id)==="properties",o=M=>{n(M),t.setNodeViewMode(e.data.id,M?"properties":"default")},{callbacks:s,readOnly:a,selectedNodeIds:c}=Ne(),u=(g=(m=e.data)==null?void 0:m.config)==null?void 0:g.parentContainer,l=c.includes(e.data.id),d=_.useRef(l);_.useEffect(()=>{var M,j;d.current&&!l&&i&&((j=(M=e.data)==null?void 0:M.config)!=null&&j.labelBelow)&&!u&&!a&&o(!1),d.current=l},[l,i,(w=(b=e.data)==null?void 0:b.config)==null?void 0:w.labelBelow,u,a]);const h=u?"Show parent":"Show properties",p=u||((x=(v=e.data)==null?void 0:v.config)==null?void 0:x.form)||((E=(S=(C=e.data)==null?void 0:C.config)==null?void 0:S.ports)==null?void 0:E.length),y=p?()=>{var M;u?(M=s.onNodeCollapse)==null||M.call(s,e.data.id,!1):o(!0)}:void 0;return!u&&p&&i?f.jsx(Sl,{...e,editOnMount:r,onShowIcon:()=>o(!1)}):f.jsx(nv,{...e,onOpenView:y&&(u||(A=(I=e.data)==null?void 0:I.config)!=null&&A.labelBelow)?()=>{var M;y(),(M=s.onNodeViewToggle)==null||M.call(s,e.data.id)}:void 0,toggleLabel:h,toggleDisabled:u&&a,onExpand:y})},av=e=>f.jsx(iv,{...e,renderCompact:JS}),sv=e=>f.jsx(iv,{...e}),cv=({containerStyle:e,...t})=>{const{selectedNodeIds:r}=Ne();return f.jsx(oo,{...t,editOnMount:r.includes(t.data.id),children:n=>f.jsx(F.Box,{bg:e.textColor==="transparent"?"transparent":e.labelBg,p:`${e.fontSize/5}px`,fontFamily:Lr,lineHeight:1,w:"fit-content",children:f.jsx(Rt,{nodeId:n.id,label:n.data.label??n.data.headerTitle??"Container",color:e.textColor,fontSize:`${e.fontSize}px`,isEditing:n.isEditing,onEditStart:n.onEditStart,onEditEnd:n.onEditEnd})})})};av.displayName="text";sv.displayName="arrayView";cv.displayName="ParentContainerView";const s_={objectView:Sl,arrayView:sv,text:av,parentContainer:cv},c_=({children:e,pattern:t="dot",backgroundColor:r})=>{const{colorMode:n}=Ne(),i=n==="dark",o=i?"--chakra-colors-gray-700":"--chakra-colors-gray-500",s=i?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return t==="none"?f.jsx(F.Box,{"data-flow-background":"none",width:"100%",height:"100%",padding:0,bg:r,children:e}):f.jsxs(F.Box,{"data-flow-background":t,position:"relative",width:"100%",height:"100%",padding:0,bg:r,children:[f.jsx(F.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(${o}) 8%, transparent 8%)`:t==="steel"?`repeating-linear-gradient(45deg, var(${s}) 0, var(${s}) 1px, transparent 1px, transparent 20px)`:`linear-gradient(var(${s}) 1px, transparent 1px), linear-gradient(90deg, var(${s}) 1px, transparent 1px)`,backgroundSize:"20px 20px",opacity:.3}}),f.jsx(F.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:e})]})},u_=.4,tt={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},l_=({nodes:e,edges:t})=>{const{themeColor:r,spacing:n,edgeRadius:i,backgroundVariant:o,backgroundSelected:s,setBackgroundSelected:a,edgeColor:c,direction:u,nodeAlignment:l,edgeMode:d,compactPropertyLayout:h,workflowContract:p,parentNodeStyle:y,engineRef:m,callbacks:g,config:b,selectedNodeIds:w,setSelectedNodeIds:v,selectedEdgeId:x,setSelectedEdgeId:C,setIsPerformanceMode:S,isZoomMode:E,setIsZoomMode:I,isMultiSelectMode:A,setIsMultiSelectMode:M,isDragMode:j,setIsDragMode:R,isEdgeHandlesEnabled:P,setIsEdgeHandlesEnabled:k,isArrayNodeMode:q}=Ne(),O=_.useRef(null),[z,U]=_.useState(null),se=e.length>200;_.useEffect(()=>{S(se)},[se,S]);const{edgeSep:Q,rankSep:Y,spacingFactor:ge}=_.useMemo(()=>{const Z=H0(e.length),B=n<1?.3+.7*n:.5+.5*n;return{edgeSep:Z.edgeSep*B,rankSep:Z.rankSep*B,spacingFactor:1.3+(n-1)*(n<1?.4:.3)}},[e.length,n]),{bgColor:ce}=ln(r),{canvas:$,borderSecondary:V,colorText:W}=Ze(),N=o==="transparent"?"transparent":b.backgroundColor||$,ne=_.useCallback(Z=>{if(!Z)return xe(r);switch(Z){case"dark":return xe(N);case"light":return xe(V);default:return xe(Z)}},[r,N,V]),be=b.colorMode==="dark",fe=be?xe("gray.500"):Pt,J=be?ce!=null&&ce.includes("gray")?"whitesmoke":ne(ce):fe,te=c?ne(c):fe,G=_.useMemo(()=>b.initialViewport||{pan:{x:0,y:0},zoom:.01},[]),le=u==="C"?"LR":u,ue=_.useCallback(Z=>{const B={...y,...Z};return{...B,bgColor:B.bgColor||r,bgOpacity:B.outline?0:B.bgOpacity??u_}},[y,r]),Ce=_.useMemo(()=>{var B;const Z=new Map;for(const re of e)(B=re.data)!=null&&B.id&&Z.set(re.data.id,re);return Z},[e]),ye=_.useMemo(()=>{var B;const Z=new Map;for(const re of t)(B=re.data)!=null&&B.id&&Z.set(re.data.id,re);return Z},[t]),Me=_.useCallback(Z=>{var Te;const B=(Te=Ce.get(Z))==null?void 0:Te.data,re=ue(B==null?void 0:B.viewProps),Ee=xe(re.bgColor);return{animated:!!(B!=null&&B.isNodeAnimated)&&!se,animationVariant:B==null?void 0:B.nodeAnimationVariant,animationColor:xe(re.borderColor||r),bgColor:re.outline?"transparent":Ee,bgOpacity:re.bgOpacity,borderColor:re.borderColor?xe(re.borderColor):re.outline&&re.bgColor==="transparent"?xe(r):Ee,borderWidth:cn(re.borderWidth,tt.borderWidth),borderStyle:re.borderStyle??tt.borderStyle,borderRadius:re.borderRadius??tt.borderRadius,textColor:re.textColor?xe(re.textColor):re.outline||re.bgColor==="transparent"?xe(W):Ee,fontSize:re.fontSize??tt.fontSize,labelPosition:re.labelPosition??tt.labelPosition,labelMargin:tt.labelMargin,labelBg:Pl(ne("dark"),Ee,re.bgOpacity)??ne("dark"),padding:re.padding??tt.padding}},[ue,Ce,W,r,se,ne]),ee=_.useMemo(()=>{var re,Ee;const Z=new Map;for(const Te of t){const Pe=(re=Te.data)==null?void 0:re.source,Ue=(Ee=Te.data)==null?void 0:Ee.target;if(!Pe||!Ue||Pe===Ue)continue;const ke=Pe<Ue?`${Pe}|${Ue}`:`${Ue}|${Pe}`,ze=Z.get(ke);ze?ze.push({id:Te.data.id,source:Pe}):Z.set(ke,[{id:Te.data.id,source:Pe}])}const B=new Map;for(const[Te,Pe]of Z){if(Pe.length<2)continue;const Ue=Te.split("|")[0],ke=Math.min(20,70/Pe.length);Pe.forEach(({id:ze,source:He},dr)=>{const fr=50+(dr-(Pe.length-1)/2)*ke;B.set(ze,(He===Ue?fr:100-fr)/100)})}return B},[t]),he=_.useMemo(()=>{const Z=ne("dark");return t.filter(B=>{var re;return((re=B.data)==null?void 0:re.id)&&B.data.source&&B.data.target}).map(({data:B})=>{var Pe,Ue,ke,ze,He,dr;let re=Z;const Ee=(Ue=(Pe=Ce.get(B.source))==null?void 0:Pe.data)==null?void 0:Ue.parent,Te=(ze=(ke=Ce.get(B.target))==null?void 0:ke.data)==null?void 0:ze.parent;if(Ee&&Ee===Te){const fr=ue((dr=(He=Ce.get(Ee))==null?void 0:He.data)==null?void 0:dr.viewProps),$e=Pl(Z,xe(fr.bgColor),fr.bgOpacity);$e&&(re=$e)}return{id:B.id,data:B,type:B.type??b.edgeType??"rounded-orthogonal",source:B.source,target:B.target,sourceProperty:B.sourceProperty,targetProperty:B.targetProperty,label:B.label,validationIssue:(d==="auto"||d==="properties")&&(B.sourceProperty!==void 0||B.targetProperty!==void 0)&&p?Xu(p,B):void 0,color:c?te:B.color?xe(B.color):te,connectorColor:c?te:B.color?xe(B.color):J,labelBg:re,dashed:!!B.isEdgeDashed,animated:!!B.isEdgeAnimated,inverted:!!B.isInverted,turn:ee.get(B.id)??.5}})},[t,te,J,c,ee,b.edgeType,d,p,Ce,ue,ne]),ve=_.useMemo(()=>{var B;const Z=new Set;for(const re of e)(B=re.data)!=null&&B.parent&&Z.add(re.data.parent);return Z},[e]),je=_.useMemo(()=>{const Z=new Map;for(const B of t){const re=B.data.isInverted?B.data.target:B.data.source;re&&!Z.has(re)&&Z.set(re,B.data)}for(const B of t){if(B.data.connection)continue;const re=B.data.isInverted?B.data.target:B.data.source,Ee=B.data.isInverted?B.data.source:B.data.target;Ee.startsWith(`${re}.`)&&(Z.set(re,B.data),Z.set(Ee,B.data))}return Z},[t]),qe=_.useMemo(()=>{const Z={...s_,...b.customViews};return e.filter(B=>{var re;return(re=B.data)==null?void 0:re.id}).map(B=>{var Ue,ke,ze,He,dr;const re=ve.has(B.data.id)&&!B.data.parent,Ee=re?B.data.label??B.data.headerTitle??"Container":void 0,Te=re?Z.parentContainer:Z[B.data.type]||Z.text,Pe=je.get(B.data.id);return{id:B.data.id,collapsed:(Ue=B.data.config)==null?void 0:Ue.collapsed,parent:B.data.parent,label:Ee,animated:!!B.data.isNodeAnimated,animationVariant:B.data.nodeAnimationVariant,hasCollapseControl:((ke=B.data.config)==null?void 0:ke.collapsed)!==void 0,animationColor:xe(((ze=B.data.viewProps)==null?void 0:ze.borderColor)||r),animationWidth:cn((He=B.data.viewProps)==null?void 0:He.borderWidth,8),element:_.createElement(Te,{...B,isInverted:((dr=B.data.config)==null?void 0:dr.isInverted)??(Pe==null?void 0:Pe.isInverted),isParent:re,containerStyle:re?Me(B.data.id):void 0,key:`${B.data.id}-${r}`})}})},[e,ve,je,r,b.customViews,Me]),We=_.useMemo(()=>se?300:e.length>50?150:e.length>20?100:50,[e.length,se]),Ye=_.useRef(b);Ye.current=b;const tr=_.useRef(E);tr.current=E;const sr=_.useRef(q);sr.current=q;const Ae=_.useRef(w);Ae.current=w;const me=_.useRef(x);me.current=x;const Oe=_.useRef(A);Oe.current=A;const nr=_.useRef(Ce);nr.current=Ce;const cr=_.useRef(ye);cr.current=ye;const Xe=_.useRef(new Map);_.useEffect(()=>{var re,Ee;const Z=new Map([...ye].filter(([,Te])=>Ce.has(Te.data.source)&&Ce.has(Te.data.target))),B=Xe.current;Xe.current=Z;for(const[Te,Pe]of B)Z.has(Te)||(me.current===Te&&(C(null),(re=g.onEdgeDeselect)==null||re.call(g)),(Ee=g.onEdgeRemove)==null||Ee.call(g,Te,Pe.data))},[ye,Ce,g,C]),_.useEffect(()=>{const Z=O.current;if(!z||!Z)return;let B=null,re=null,Ee=0,Te=0,Pe=0,Ue=0,ke=0;const ze=He=>{if(Ye.current.readOnly)return;He.preventDefault(),He.stopPropagation(),tr.current||He.metaKey||He.ctrlKey?(Pe+=He.deltaY,Ue=He.clientX,ke=He.clientY,re===null&&(re=requestAnimationFrame(()=>{re=null;const fr=Ye.current,$e=z.zoom(),Tr=Pe;Pe=0;let qr=$e-Tr*.05/100;qr=Math.max(fr.minZoom??.01,Math.min(fr.maxZoom??1.5,qr));const Dr=Z.getBoundingClientRect();z.zoomAt(qr,{x:Ue-Dr.left,y:ke-Dr.top})}))):(Ee+=He.deltaX,Te+=He.deltaY,B===null&&(B=requestAnimationFrame(()=>{B=null;const fr=z.pan(),$e=z.zoom(),Tr=.35,qr=Ee,Dr=Te;Ee=0,Te=0,z.pan({x:fr.x+-qr*Tr/$e,y:fr.y+-Dr*Tr/$e})})))};return Z.addEventListener("wheel",ze,{passive:!1}),()=>{Z.removeEventListener("wheel",ze),B!==null&&cancelAnimationFrame(B),re!==null&&cancelAnimationFrame(re)}},[z]),_.useEffect(()=>{if(b.disableKeyboardShortcuts)return;const Z=B=>{var Ee,Te,Pe,Ue;if(Ye.current.readOnly)return;const re=B.target;if(!(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.isContentEditable)){if((B.key==="z"||B.key==="Z")&&I(!tr.current),(B.key==="m"||B.key==="M")&&M(!A),(B.key==="d"||B.key==="D")&&R(!j),(B.key==="v"||B.key==="V")&&!B.repeat&&!B.metaKey&&!B.ctrlKey&&!B.altKey&&re.tagName!=="SELECT"&&k(!P),(B.key==="Delete"||B.key==="Backspace")&&me.current){B.preventDefault();const ke=me.current;(Te=g.onEdgeDelete)==null||Te.call(g,ke,((Ee=cr.current.get(ke))==null?void 0:Ee.data)??{id:ke}),C(null);return}if((B.key==="Delete"||B.key==="Backspace")&&Ae.current.length>0){B.preventDefault();const ke=Ae.current.filter(ze=>ze!=="root");if(ke.length===0)return;for(const ze of ke){const He=(Pe=nr.current.get(ze))==null?void 0:Pe.data;(Ue=g.onNodeDelete)==null||Ue.call(g,ze,He||{})}v([])}}};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[A,j,P,k,I,M,R,b.disableKeyboardShortcuts,g,v,C]);const we=_.useCallback(Z=>{var B;m.current=Z,U(Z),(B=g.onInit)==null||B.call(g,Z)},[m,g]),Qr=_.useCallback(Z=>{var B;return(B=g.onViewportChange)==null?void 0:B.call(g,Z)},[g]),zr=_.useCallback(Z=>{var re,Ee,Te;const B=((re=cr.current.get(Z))==null?void 0:re.data)??{id:Z};if(me.current===Z&&Oe.current){C(null),(Ee=g.onEdgeDeselect)==null||Ee.call(g);return}Ae.current.length&&v([]),C(Z),(Te=g.onEdgeSelect)==null||Te.call(g,Z,B)},[g,C,v]),pt=_.useCallback(()=>{var Z,B,re,Ee,Te;if(a(b.bottomBarCollapsed??(Ae.current.length>0||!!me.current||!s)),(Z=g.onBackgroundClick)==null||Z.call(g),!Ye.current.readOnly){const Pe=new Set;for(const Ue of Ae.current){let ke=nr.current.get(Ue);for(;ke&&!Pe.has(ke.data.id);)Pe.add(ke.data.id),ve.has(ke.data.id)&&((B=ke.data.config)==null?void 0:B.collapsed)!==!0&&((re=g.onNodeCollapse)==null||re.call(g,ke.data.id,!0)),ke=ke.data.parent?nr.current.get(ke.data.parent):void 0}}Ae.current.length&&(v([]),(Ee=g.onNodeDeselect)==null||Ee.call(g)),me.current&&(C(null),(Te=g.onEdgeDeselect)==null||Te.call(g))},[g,v,C,a,s,b.bottomBarCollapsed,ve]),ae=_.useCallback(Z=>{var Ee,Te;const B=Ae.current,re=Z.filter(Pe=>!B.includes(Pe));if(re.length){v([...B,...re]);for(const Pe of re)(Te=g.onNodeSelect)==null||Te.call(g,Pe,((Ee=nr.current.get(Pe))==null?void 0:Ee.data)??{id:Pe})}},[g,v]),Ve=_.useCallback((Z,B)=>{var re,Ee;v([Z]),(Ee=g.onNodeSelect)==null||Ee.call(g,Z,((re=nr.current.get(Z))==null?void 0:re.data)??{id:Z},B)},[g,v]),or=_.useCallback((Z,B,re)=>{var Ee;return(Ee=g.onEdgeCreate)==null?void 0:Ee.call(g,Z,B,re)},[g]),Ge=_.useCallback((Z,B,re,Ee=!1)=>{var Te,Pe;d==="properties"&&((Te=g.onNodeCreateRequest)==null?void 0:Te.call(g,{sourceNodeId:Z,position:B,sourceProperty:re,reverse:Ee}))===!0||re!==void 0||Ee||(Pe=g.onNodeCreate)==null||Pe.call(g,{type:"text",sourceNodeId:Z,position:B,isArrayMode:sr.current})},[g,d]),ir=!b.readOnly&&P&&b.edgeHandles!==!1,er=o==="transparent"?"none":o;return f.jsx(c_,{pattern:er,backgroundColor:N,children:f.jsx(F.Box,{ref:O,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:f.jsx(GS,{nodes:qe,edges:he,direction:le,nodeAlignment:l,onContainerCollapse:Z=>{var B,re;(B=g.onNodeCollapse)==null||B.call(g,Z,!0),(re=g.onNodeViewToggle)==null||re.call(g,Z)},selectedNodeIds:w,edgeMode:d,compactPropertyLayout:h,edgeType:b.edgeType,edgeRadius:i,customEdgeTypes:b.customEdgeTypes,edgeReveal:b.edgeReveal,rankSep:Y,edgeSep:Q,spacingFactor:ge,compactSpacingScale:n,layoutDebounce:We,isPerformanceMode:se,minZoom:b.minZoom??.01,maxZoom:b.maxZoom??1.5,initialViewport:G,fitOnInit:!b.initialViewport,readOnly:!!b.readOnly,containerStyle:Me,lineColor:c?te:J,drawMode:ir,drawHandles:!b.readOnly&&b.edgeHandles!==!1,dragMode:j,multiSelect:!!A,onInit:we,onLayoutComplete:g.onLayoutComplete,animateViewport:b.animateViewport,onViewportChange:Qr,onBackgroundTap:pt,onBoxSelect:ae,onEdgeSelect:zr,onContainerSelect:Ve,onEdgeDraw:or,onDrawIntoSpace:Ge})})})},uv=_.memo(l_),d_=".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 My=!1;function f_(){if(My||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=d_+U0+D0+W0+".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}',My=!0}function h_({loading:e=!1,loader:t,...r}){var c,u;const[n,i]=_.useState(null),o=_.useMemo(()=>!!(n!=null&&n.json)&&!!r.json&&F0(n.json,r.json),[n==null?void 0:n.json,r.json]),s=n===null||n.json!==r.json&&!o,a=e||s;return _.useEffect(()=>{!e&&o&&(n==null?void 0:n.json)!==r.json&&i(r)},[e,o,n==null?void 0:n.json,r.json]),_.useEffect(()=>{if(e||!s)return;let l;const d=requestAnimationFrame(()=>{l=requestAnimationFrame(()=>i(r))});return()=>{cancelAnimationFrame(d),l!==void 0&&cancelAnimationFrame(l)}},[e,s,r.json]),f.jsxs(F.Box,{className:r.className,style:r.style,width:"100%",height:"100%",position:"relative","aria-busy":a,children:[f.jsx("div",{style:{width:"100%",height:"100%"},ref:l=>{a?l==null||l.setAttribute("inert",""):l==null||l.removeAttribute("inert")},children:n&&f.jsx(p_,{...s?n:r,className:void 0,style:void 0})}),a&&t!==null&&f.jsx(F.Box,{"data-flow-loader":"",role:"status","aria-label":"Loading diagram",position:"absolute",inset:0,zIndex:1e3,display:"grid",placeItems:"center",background:((c=r.config)==null?void 0:c.colorMode)==="dark"?"gray.800":"gray.100",color:((u=r.config)==null?void 0:u.colorMode)==="dark"?"whiteAlpha.800":"blackAlpha.800",children:t===void 0?f.jsx("span",{children:"Loading diagram..."}):t})]})}function p_({title:e="untitled",json:t,forms:r,nodes:n,edges:i,config:o={},callbacks:s={},className:a,style:c,showBottomBar:u=!0,children:l}){f_();const[d,h]=_.useState(),[p,y]=_.useState(!1),m=o.formSchema??d,g=_.useMemo(()=>t&&r?Em(t,r.state):t,[t,r==null?void 0:r.state]),b=o.direction==="C",w=_.useMemo(()=>{let j,R;return P=>(R=j&&R?B0(j,P,R)??$u(P,{title:e,isCenter:b}):$u(P,{title:e,isCenter:b}),j=P,R)},[e,b]),v=_.useMemo(()=>g?w(g):null,[g,w]),x=_.useMemo(()=>r!=null&&r.structured&&!p&&m?jm(r.state,r.bindings,m,(v==null?void 0:v.nodes)??n??[]):void 0,[r==null?void 0:r.structured,p,r==null?void 0:r.state,r==null?void 0:r.bindings,m,v,n]),C=(x==null?void 0:x.schema)??m,S=(x==null?void 0:x.bindings)??(r==null?void 0:r.bindings),E=_.useMemo(()=>[...(v==null?void 0:v.nodes)??n??[],...(x==null?void 0:x.nodes)??[]].map(R=>{var se,Q,Y,ge;const P=t?(se=Re(t,R.data.id))==null?void 0:se.$view:(Q=R.data.config)==null?void 0:Q.typeView,k=P&&nn.includes(P)?P:void 0,q=k?k==="icon-label":(Y=R.data.config)==null?void 0:Y.labelBelow,O=k==="object"?"objectView":k==="text"?"text":q?"arrayView":R.data.type,z=C&&(r?dn(S,R.data.id,C):t&&Tt(t,R.data.id,C)),U=(((ge=R.data.config)==null?void 0:ge.ports)??[]).map(ce=>({...ce}));if(x&&z){const ce=o.direction==="RL"?{input:"right",output:"left",config:"bottom",error:"top"}:o.direction==="TB"?{input:"top",output:"bottom",config:"right",error:"left"}:o.direction==="BT"?{input:"bottom",output:"top",config:"left",error:"right"}:{input:"left",output:"right",config:"top",error:"bottom"};for(const[$,V]of Object.entries(z.type.ports??{})){const W=`${V.kind}:${$}`,N=U.find(ne=>ne.id===W);N?N.label===void 0&&V.label!==void 0&&(N.label=V.label):U.push({id:W,...V.label!==void 0?{label:V.label}:{},role:V.kind==="input"||V.kind==="config"?"target":"source",side:ce[V.kind],...V.kind==="config"?{placement:"config"}:{}})}for(const $ of U){const V=U.filter(W=>W.side===$.side);$.position=(V.indexOf($)+1)/(V.length+1)}}return z||q||k?{...R,data:{...R.data,type:O,...r?{description:Object.fromEntries(Object.entries(R.data.description??{}).filter(([ce])=>!ce.startsWith("$")&&!(x!=null&&x.slots.has(Dt(R.data.id,ce)))))}:{},config:{...R.data.config,...x&&z?{ports:U}:{},...z?{form:!0}:{},...k?{typeView:k,labelBelow:!!q}:q?{labelBelow:!0}:{}}}}:R}),[v,n,t,C,S,x,o.direction]),I=[...(v==null?void 0:v.edges)??i??[],...(x==null?void 0:x.edges)??[]],A=_.useMemo(()=>{const j=t&&v?Gm(t,v.edges,s,s.onJsonChange,m):{...s};if(x){const R=new Set([...x.nodes.map(P=>P.data.id),...x.edges.map(P=>P.data.id)]);for(const P of Object.keys(j)){if(!/^on(?:Node|Edge).*(?:Change|Collapse)$/.test(P))continue;const k=j[P];j[P]=(q,...O)=>{if(!R.has(q))return k==null?void 0:k(q,...O)}}}return{...j,onAllNodesIconLabelChange:R=>{var P;y(R),(P=j.onAllNodesIconLabelChange)==null||P.call(j,R)}}},[t,v,s,m,x]),M=_.useMemo(()=>{if(!r)return A;let j=r.state;const R=k=>{if(o.readOnly||o.editable===!1)return;const q=r.onStateChange??r.onChange;if(!q)return;const O=k0(j,k,s.onFormChange);O!==j&&(j=O,q(O,{...k,data:O}))},P=(k,q,O)=>{var U;const z=t&&((U=Re(t,k))==null?void 0:U[q]);return!z||typeof z.$state!="string"?!1:(R({address:z.$state,nodeAddress:k,previousValue:Re(j,z.$state),value:O,data:j}),!0)};return{...A,onFormChange:R,onNodeCreateRequest:k=>{var z,U;const q=(z=k.sourceProperty)!=null&&z.startsWith("config:")?k.sourceProperty.slice(7):void 0,O=q!==void 0&&(x==null?void 0:x.slots.get(Dt(k.sourceNodeId,q)));return O?(O.present||R({data:j,nodeAddress:O.address.split(".").slice(0,-1).join("."),address:O.address,value:Vt(O.type),previousValue:void 0}),!0):((U=A.onNodeCreateRequest)==null?void 0:U.call(A,k))??!1},onNodeDelete:(k,q)=>{var Y,ge;if(!(x!=null&&x.nodes.some(ce=>ce.data.id===k)))return(Y=A.onNodeDelete)==null?void 0:Y.call(A,k,q);const O=x&&[...x.slots.values()].find(ce=>ce.nodeId===k);if(!O)return(ge=A.onNodeDelete)==null?void 0:ge.call(A,k,q);const z=O.address.split("."),U=z.pop(),se=z.join("."),Q=Re(j,se);R(Array.isArray(Q)?{data:j,nodeAddress:se,address:se,previousValue:Q,value:Q.filter((ce,$)=>String($)!==U)}:{data:j,nodeAddress:se,address:O.address,previousValue:Re(j,O.address),value:void 0})},onEdgeCreate:(k,q,O)=>{var se,Q;const z=((se=O==null?void 0:O.targetProperty)==null?void 0:se.startsWith("config:"))&&(x==null?void 0:x.slots.get(Dt(q,O.targetProperty.slice(7)))),U=x==null?void 0:x.containers.get(k);if(z&&U&&(O==null?void 0:O.sourceProperty)==="output:resource"){const Y=A0(j,U,z);Y!==void 0&&R({data:j,nodeAddress:z.address.split(".").slice(0,-1).join("."),address:z.address,previousValue:Re(j,z.address),value:Y});return}z||x!=null&&x.nodes.some(Y=>Y.data.id===k||Y.data.id===q)||(Q=A.onEdgeCreate)==null||Q.call(A,k,q,O)},onEdgeDelete:(k,q)=>{var ge;const O=x==null?void 0:x.edges.find(ce=>ce.data.id===k);if(!O)return(ge=A.onEdgeDelete)==null?void 0:ge.call(A,k,q);const z=x.slots.get(Dt(O.data.target,O.data.targetProperty.slice(7))),U=z.address.split("."),se=U.pop(),Q=U.join("."),Y=Re(j,Q);R(Array.isArray(Y)?{data:j,nodeAddress:Q,address:Q,previousValue:Y,value:Y.filter((ce,$)=>String($)!==se)}:{data:j,nodeAddress:Q,address:z.address,previousValue:Re(j,z.address),value:void 0})},onNodeContentChange:(k,q)=>{var O,z;P(k,"$content",q)?(O=s.onNodeContentChange)==null||O.call(s,k,q):(z=A.onNodeContentChange)==null||z.call(A,k,q)},onNodeLabelChange:(k,q)=>{var O,z;P(k,"$label",q)?(O=s.onNodeLabelChange)==null||O.call(s,k,q):(z=A.onNodeLabelChange)==null||z.call(A,k,q)}}},[A,r,t,s,x,o.readOnly,o.editable]);return f.jsx(Cr.Provider,{value:{data:(r==null?void 0:r.state)??t,viewData:t,bindings:S,references:r==null?void 0:r.references,structured:x,renderForm:r==null?void 0:r.renderForm,editable:r?!!(r.onStateChange??r.onChange):!!s.onJsonChange,schema:C,setSchema:j=>{var R;h(j),(R=s.onFormSchemaChange)==null||R.call(s,j)},callbacks:M},children:f.jsx(Dy,{config:x?{...o,formSchema:C}:o,callbacks:M,nodes:E,edges:I,children:f.jsxs(F.Box,{className:a,"data-flow-diagram":"",style:c,width:"100%",height:"100%",position:"relative",overflow:"hidden",css:{"& input, & textarea, & select":{outline:"none !important",boxShadow:"none !important"}},children:[f.jsx(uv,{nodes:E,edges:I}),u&&f.jsx(Dm,{}),l]})})})}function g_(e){return Du(JSON.parse(e))}function Du(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[i,o]of Object.entries(n)){if(["__proto__","prototype","constructor"].includes(i))throw new Error(`Unsafe document key: ${i}`);r(o)}t.delete(n)}};return r(e),structuredClone(e)}function y_(e){return{replaceJson(t){if(e.readOnly||!e.onJsonChange)throw new Error("JSON document is read-only.");const r=Du(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=Du(t);return e.onStateChange(r,{address:"root",nodeAddress:"root",previousValue:e.state,value:r,data:r}),r}}}function m_(e,t){const r=(n,i)=>{if(n===null||typeof n!="object")return typeof n==typeof i?n:void 0;if(!(!i||typeof i!="object"))return Array.isArray(n)?Array.isArray(i)?n.map((o,s)=>r(o,i[s])).filter(o=>o!==void 0):void 0:Object.fromEntries(Object.entries(n).flatMap(([o,s])=>{if(!Object.prototype.hasOwnProperty.call(i,o))return[];if(o.startsWith("$")&&o!=="$")return JSON.stringify(s)===JSON.stringify(i[o])?[[o,s]]:[];const a=r(s,i[o]);return a===void 0?[]:[[o,a]]}))};return r(e,t)??{}}function jn(e){let t="",r=!1,n="",i;const o=()=>{clearTimeout(i),i=void 0},s=()=>{if(o(),!(r||!t.trim()))try{const c=e.parse(e.repair(t)),u=JSON.stringify(c);if(u===n)return;e.preview(c),n=u}catch{}},a=c=>{if(!r){if(new TextEncoder().encode(c).byteLength>(e.maxBytes??1024*1024))throw r=!0,o(),new Error("JSON stream exceeds the size limit.");t=c,i||(i=setTimeout(s,e.intervalMs??150))}};return{snapshot:a,append(c){a(t+c)},flush:s,finish(){if(r)throw new Error("JSON stream is closed.");r=!0,o();const c=e.parse(t);return e.commit(c),c},cancel(){r=!0,o(),t=""}}}function b_(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 i=jn(e),o=0,s=!1,a=!1,c;const u=Math.max(1,Math.ceil(t.length*r/n)),l=()=>e.onChange({position:o,total:t.length,playing:s}),d=()=>{clearTimeout(c),c=void 0},h=(m=!1)=>{i.snapshot(t.slice(0,o)),o===t.length?(s=!1,d(),i.finish()):m&&i.flush()},p=m=>{s=!1,d(),i.cancel(),l(),e.onError(m)},y=()=>{if(c=void 0,!(!s||a)){o=Math.min(t.length,o+u);try{h()}catch(m){p(m);return}l(),s&&(c=setTimeout(y,r))}};return{play(){a||s||(o===t.length&&(i.cancel(),i=jn(e),o=0),s=!0,l(),c=setTimeout(y,r))},pause(){a||(s=!1,d(),i.flush(),l())},seek(m){if(!a){if(!Number.isFinite(m))throw new Error("Playback position must be finite.");d(),o=Math.max(0,Math.min(t.length,Math.round(m))),i.cancel(),i=jn(e);try{h(!0)}catch(g){p(g);return}l(),s&&(c=setTimeout(y,r))}},dispose(){a=!0,s=!1,d(),i.cancel()}}}function v_({nodeAddress:e,expanded:t=!1}){var u;const{data:r,schema:n,bindings:i}=_.useContext(Cr),{colorText:o,background:s}=Ze();if((u=i==null?void 0:i[e])!=null&&u.portResources)return null;const a=i&&dn(i,e,n);if(!r||!a)return null;const c=Re(r,a.address);return!c||typeof c!="object"?null:f.jsx("div",{"data-flow-config-summary":"",style:{width:"100%",minWidth:0,color:xe(o),background:xe(s),fontSize:24,lineHeight:1.4,textTransform:"none"},children:Object.keys(a.type.properties).map(l=>{const d=a.fields[l]??{};if(!Ln(d.$visibleWhen,r))return null;const h=c[l],p=h==null?"":typeof h=="object"?JSON.stringify(h):String(h);return f.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:[f.jsx("span",{style:{overflowWrap:"anywhere"},children:wr(d.$label??l)}),f.jsx("span",{title:p,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:t?"pre-wrap":"nowrap",overflowWrap:t?"anywhere":void 0},children:p})]},l)})})}exports.BottomBar=Dm;exports.CompactPropertyLayoutToggle=dm;exports.ConnectionsOnlyToggle=L0;exports.DEFAULT_PALETTE=An;exports.DiagramAppearanceControls=hm;exports.DynamicIcon=Or;exports.EdgeTools=Om;exports.EditableLabel=Rt;exports.ErrorToast=Bm;exports.FlowDiagram=h_;exports.FlowDiagramProvider=Dy;exports.FlowPort=rv;exports.FlowView=uv;exports.FormDocumentContext=Cr;exports.LIGHT_BLACK=Pt;exports.NODE_TYPE_VIEWS=nn;exports.NodeBorderRadiusControl=Mm;exports.NodeConfigSummary=v_;exports.NodeForm=Rm;exports.NodeFormPopover=tv;exports.NodeIconPicker=el;exports.NodeTools=qm;exports.NodeView=oo;exports.SvgExportButton=Lm;exports.Swatches=ut;exports.TEXT_PALETTE=Tm;exports.ToolbarCloseButton=At;exports.ToolbarCommitInput=ct;exports.ToolbarDivider=Ht;exports.ToolbarIconButton=Se;exports.ToolbarRangeInput=fm;exports.ToolbarScrollContainer=Fm;exports.ToolbarSelect=mr;exports.ToolbarTooltip=Ie;exports.TooltipIconButton=zu;exports.WorkflowControls=rl;exports.addChild=Ku;exports.addConnection=Ju;exports.addTargetEdge=wm;exports.addressToPath=kr;exports.applyCollapsed=_0;exports.applyFormChange=Fn;exports.applyStateEdits=j0;exports.bindSqueedCallbacks=Gm;exports.compileSqueed=$u;exports.connectionIssue=Xu;exports.contentObjTheme=Ir;exports.createFlowDiagram=st;exports.createFlowDocumentActions=y_;exports.createFormNode=Wm;exports.createJsonPlayback=b_;exports.createJsonStream=jn;exports.createWorkflowExecution=Pv;exports.downloadSvg=Nm;exports.exportSvg=$m;exports.formValueError=Rr;exports.getChakraColorHex=xe;exports.getColorVariant=Ly;exports.getDarkerHexColor=kn;exports.getInteractionSurface=Hr;exports.getNode=Re;exports.parseFlowDocument=g_;exports.parseJsonContract=Zu;exports.parseTypeScriptContract=Sm;exports.parseTypeScriptForm=Yu;exports.projectJsonPlaybackPreview=m_;exports.readFormSchema=Qu;exports.readWorkflowContract=_m;exports.removeEdge=Cm;exports.removeNode=xm;exports.resolveEdgeOwner=it;exports.resolveStateView=Em;exports.setCollapsed=bm;exports.setEdgeProp=Gr;exports.setEdgeStyle=vm;exports.setNodeProp=hr;exports.updateNode=vr;exports.useCustomColors=Ze;exports.useEdgeProximity=Ny;exports.useFlowData=Yr;exports.useFlowDiagramContext=Ne;exports.useNodeViewActions=io;exports.useStopPropagation=Cl;exports.useThemeContentColors=ln;
|
|
280
|
+
`;function nv({nodeAddress:e,active:t,label:r,open:n=!1,onClose:i,children:o,filter:s,height:a,width:c}){const{background:u,border:l,colorText:d}=Ze(),{colorMode:h}=Le(),p=_.useRef(null),y=_.useId(),{data:m,schema:g,bindings:b}=_.useContext(Sr),w=o!==void 0||!!(m&&g&&(b?dn(b,e,g):Tt(m,e,g)));_.useEffect(()=>{var x,C,S,k,I;!t||!w||!n?(x=p.current)==null||x.close():(C=p.current)!=null&&C.open||((S=p.current)==null||S.showModal(),(I=(k=p.current)==null?void 0:k.querySelector("[data-form-filter] input"))==null||I.focus())},[t,w,n]);const v=ve(u);return w?f.jsx(f.Fragment,{children:typeof document<"u"&&tn.createPortal(f.jsx(KS,{ref:p,id:y,$surface:v,$border:ve(l),"aria-label":`Configure ${r}`,onClose:i,onPointerDown:x=>x.stopPropagation(),onWheel:x=>x.stopPropagation(),onKeyDown:x=>x.stopPropagation(),onClick:x=>{var C;x.stopPropagation(),x.target===x.currentTarget&&((C=p.current)==null||C.close())},style:{position:"fixed",inset:"94px 20px auto auto",margin:0,padding:20,width:c??"var(--top-toolbar-width, 360px)",boxSizing:"border-box",maxWidth:"calc(100vw - 40px)",maxHeight:"calc(100dvh - 114px)",height:a,overflow:"hidden",borderRadius:30,background:v,color:ve(d),fontSize:16,textTransform:"none"},children:n&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexShrink:0},children:[f.jsx("strong",{style:{overflowWrap:"anywhere",minWidth:0},children:r}),f.jsx(At,{"aria-label":"Close node configuration",onClick:()=>{var x;return(x=p.current)==null?void 0:x.close()}})]}),s&&f.jsx("div",{"data-form-filter":"",style:{flexShrink:0},children:s}),f.jsx(JS,{$divider:`var(--chakra-colors-gray-${h==="dark"?"700":"200"})`,"data-form-scroll":"",style:a?{flex:1}:void 0,children:o??f.jsx(Pm,{nodeAddress:e})})]})}),document.body)}):null}const Vu=({icon:e,label:t,onClick:r,color:n,boxSize:i=6,...o})=>{const{background:s,border:a,colorText:c}=Ze();return f.jsx(Oe,{label:t,children:f.jsx(F.Flex,{children:f.jsx(F.Icon,{as:e,boxSize:i,color:n,cursor:r?"pointer":void 0,onClick:r})})})},ZS=({data:e,children:t,isInverted:r,isParent:n,onOpenView:i,editOnMount:o=!1})=>{var N,ne,me,fe,J,te;const{selectedNodeIds:s,setSelectedNodeIds:a,selectedEdgeId:c,setSelectedEdgeId:u,isMultiSelectMode:l,isPerformanceMode:d,engineRef:h,callbacks:p,config:y,themeColor:m,direction:g,nodeViewModes:b}=Le(),{background:w,border:v,colorText:x}=Ze(),C=_.useRef(null),S=_.useRef(null),[k,I]=_.useState(!1),[R,M]=_.useState(o&&!!y.editable&&!y.readOnly),[E,P]=_.useState(!1),A=e==null?void 0:e.id,j=Am(A),q=s.includes(A),O=y.nodeOverlayActions,z=y.renderNodeOverlay,U=(()=>{var G;try{const le=(G=h.current)==null?void 0:G.zoom();return le!==void 0&&le<.08}catch{return!1}})(),ae=_.useCallback(G=>{var ue,we,ge,qe;if(R||y.readOnly)return;const le={shiftKey:G.shiftKey,ctrlKey:G.ctrlKey,metaKey:G.metaKey,altKey:G.altKey};if(c&&(u(null),(ue=p.onEdgeDeselect)==null||ue.call(p)),l){const ee=s.includes(A),he=ee?s.filter(be=>be!==A):[...s,A];a(he),ee?(we=p.onNodeDeselect)==null||we.call(p):(ge=p.onNodeSelect)==null||ge.call(p,A,e,le)}else a([A]),(qe=p.onNodeSelect)==null||qe.call(p,A,e,le)},[A,e,s,c,l,R,a,u,p,y]),Q=_.useCallback(()=>{var G;R||y.readOnly||(G=p.onNodeDoubleClick)==null||G.call(p,A,e)},[A,e,R,p,y]),Y=_.useCallback(()=>{S.current&&clearTimeout(S.current),S.current=setTimeout(()=>I(!0),100)},[]),pe=_.useCallback(()=>{S.current&&clearTimeout(S.current),I(!1)},[]),se=!!((N=e==null?void 0:e.config)!=null&&N.form),$={tabIndex:se?0:void 0,"aria-haspopup":se?"dialog":void 0,"aria-expanded":se?E:void 0,onDoubleClickCapture:G=>{var le;!se&&!i||y.readOnly||R||!G.currentTarget.contains(G.target)||G.target instanceof Element&&G.target.closest("button, input, textarea, select, a, [contenteditable=true], [data-flow-content]")||(G.preventDefault(),G.stopPropagation(),a([A]),i?i():P(!0),(le=p.onNodeDoubleClick)==null||le.call(p,A,e))},onKeyDown:G=>{!se&&!i||y.readOnly||G.target!==G.currentTarget||G.key!=="Enter"||(G.preventDefault(),G.stopPropagation(),a([A]),i?i():P(!0))}},V=se&&f.jsx(nv,{nodeAddress:A,active:q,label:e.label||e.headerTitle||"Node",open:E,onClose:()=>{var G;P(!1),q&&((G=C.current)==null||G.focus({preventScroll:!0}))}}),W=Array.isArray((ne=e==null?void 0:e.config)==null?void 0:ne.ports)?e.config.ports.map(G=>f.jsx(tv,{...G},`${G.id}:${G.role}`)):null;return n?f.jsxs(F.Box,{ref:C,...$,onClick:ae,onDoubleClick:Q,onMouseEnter:Y,onMouseLeave:pe,cursor:"pointer",position:"relative",children:[V,!d&&(z||O&&O.length>0)&&k&&!U&&f.jsxs(f.Fragment,{children:[f.jsx(F.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>I(!0),onMouseLeave:pe}),z?f.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>I(!0),onMouseLeave:pe,willChange:"transform",children:z({nodeId:A,nodeData:e,isRoot:A==="root",isParent:!0,isHovered:k,setIsHovered:I})}):f.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:w,p:3,borderColor:v,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>I(!0),onMouseLeave:pe,willChange:"transform",children:f.jsx(F.HStack,{px:2,gap:2,children:O.map((G,le)=>f.jsxs(F.Box,{display:"contents",children:[le>0&&f.jsx(F.Box,{borderColor:v,height:5,borderRightWidth:1}),f.jsx(Vu,{icon:G.icon,label:G.label,color:x,bgColor:w,borderColor:v,textColor:x,boxSize:5,onClick:ue=>{var we;ue.stopPropagation(),(we=p.onNodeHoverAction)==null||we.call(p,G.id,A,e)}})]},G.id))})})]}),t({id:A,data:e,isActive:q,isLowZoom:U,isEditing:R,onEditStart:()=>M(!0),onEditEnd:()=>M(!1)}),j&&!((me=e==null?void 0:e.config)!=null&&me.parentContainer)&&((fe=e==null?void 0:e.config)==null?void 0:fe.collapsed)!==void 0&&(()=>{var ue;const G=g==="TB"||g==="BT",le=r||g==="RL";return f.jsx(F.IconButton,{position:"absolute",...G?{[g==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:le?void 0:"-75px",left:le?"-75px":void 0,top:"50%",transform:"translateY(-50%)"},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:y.readOnly,onClick:we=>{var ge;we.stopPropagation(),(ge=p.onNodeCollapse)==null||ge.call(p,A,!e.config.collapsed)},bgColor:ve(((ue=e==null?void 0:e.viewProps)==null?void 0:ue.bgColor)||m),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(K.PiPlusBold,{size:30,color:ve("gray.800")}):f.jsx(K.PiMinusBold,{size:30,color:ve("gray.800")})})})()]}):f.jsxs(F.Box,{ref:C,...$,onClick:ae,onDoubleClick:Q,onMouseEnter:Y,onMouseLeave:pe,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[V,W,!d&&(z||O&&O.length>0)&&k&&!U&&f.jsxs(f.Fragment,{children:[f.jsx(F.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>I(!0),onMouseLeave:pe}),z?f.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>I(!0),onMouseLeave:pe,willChange:"transform",children:z({nodeId:A,nodeData:e,isRoot:A==="root",isParent:!!n,isHovered:k,setIsHovered:I})}):f.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:w,p:3,borderColor:v,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>I(!0),onMouseLeave:pe,willChange:"transform",children:f.jsx(F.HStack,{px:2,gap:2,children:O.map((G,le)=>f.jsxs(F.Box,{display:"contents",children:[le>0&&f.jsx(F.Box,{borderColor:v,height:5,borderRightWidth:1}),f.jsx(Vu,{icon:G.icon,label:G.label,color:x,bgColor:w,borderColor:v,textColor:x,boxSize:5,onClick:ue=>{var we;ue.stopPropagation(),(we=p.onNodeHoverAction)==null||we.call(p,G.id,A,e)}})]},G.id))})})]}),f.jsxs(F.Box,{position:"relative",display:"flex",h:"100%",w:"100%",children:[j&&!((J=e==null?void 0:e.config)!=null&&J.parentContainer)&&((te=e==null?void 0:e.config)==null?void 0:te.collapsed)!==void 0&&!n&&(()=>{var we,ge,qe;const G=g==="TB"||g==="BT",le=r||g==="RL",ue=(we=e==null?void 0:e.config)!=null&&we.labelBelow&&b[A]!=="properties"?((((ge=e==null?void 0:e.viewProps)==null?void 0:ge.fontSize)||1)*100+100)/2:void 0;return f.jsx(F.IconButton,{position:"absolute",...G?{[g==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:le?void 0:ue===void 0?"-75px":`calc(50% - ${ue+75}px)`,left:le?ue===void 0?"-75px":`calc(50% - ${ue+75}px)`:void 0,alignSelf:ue===void 0?"center":void 0,top:ue===void 0?void 0:`${ue}px`,transform:ue===void 0?void 0:"translateY(-50%)",zIndex:ue===void 0?void 0:1},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:y.readOnly,onClick:ee=>{var he;ee.stopPropagation(),(he=p.onNodeCollapse)==null||he.call(p,A,!e.config.collapsed)},bgColor:ve(((qe=e==null?void 0:e.viewProps)==null?void 0:qe.bgColor)||m),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(K.PiPlusBold,{size:30,color:ve("gray.800")}):f.jsx(K.PiMinusBold,{size:30,color:ve("gray.800")})})})(),t({id:A,data:e,isActive:q,isLowZoom:U,isEditing:R,onEditStart:()=>M(!0),onEditEnd:()=>M(!1)})]})]})},io=_.memo(ZS),YS=({id:e,data:t,isActive:r,isEditing:n,onEditStart:i,onEditEnd:o})=>{var m,g,b,w,v,x,C,S;const{themeColor:s}=Le(),{colorText:a}=Ze(),c=((m=t==null?void 0:t.viewProps)==null?void 0:m.bgColor)==="transparent",u=((g=t==null?void 0:t.viewProps)==null?void 0:g.outline)===!0,{highlightColor:l,borderColor:d,textColor:h}=ln(((b=t==null?void 0:t.viewProps)==null?void 0:b.bgColor)||s),p=ve(((w=t==null?void 0:t.viewProps)==null?void 0:w.textColor)||(c||u?a:h)),y=((v=t==null?void 0:t.viewProps)==null?void 0:v.borderColor)||(u?!c&&((x=t==null?void 0:t.viewProps)==null?void 0:x.bgColor)||s:d);return f.jsx(F.Box,{"data-flow-node-surface":"",borderRadius:(C=t==null?void 0:t.viewProps)==null?void 0:C.borderRadius,bgColor:u?"transparent":l,...An(t==null?void 0:t.viewProps,y,r,2),py:14,px:20,whiteSpace:"nowrap",w:"fit-content",children:f.jsxs(F.Flex,{justifyContent:"start",alignItems:"center",gap:8,w:"fit-content",maxW:900,minW:0,fontSize:"5xl",lineHeight:"normal",children:[((S=t==null?void 0:t.config)==null?void 0:S.icon)&&f.jsx(F.Box,{flexShrink:0,children:f.jsx(Or,{name:t.config.icon,size:80,color:p})}),f.jsx(Rt,{nodeId:e,label:(t==null?void 0:t.label)||(t==null?void 0:t.text)||"",color:p,isEditing:n,onEditStart:i,onEditEnd:o})]})})};function ao(){const{nodeViewModes:e,setNodeViewMode:t,allNodesIconLabel:r,setAllNodesIconLabel:n}=Le();return{allNodesIconLabel:r,setAllNodesIconLabel:n,getNodeViewMode:i=>e[i]??"default",showNodeProperties:i=>t(i,"properties"),restoreNodeView:i=>t(i,"default"),toggleNodeView:i=>t(i,e[i]==="properties"?"default":"properties"),setNodeViewMode:t}}const XS=({id:e,isActive:t,data:r,isEditing:n,onEditStart:i,onEditEnd:o})=>{var v,x,C,S,k,I,R,M,E,P,A,j,q,O,z;const{themeColor:s}=Le(),{colorText:a}=Ze(),c=((v=r==null?void 0:r.viewProps)==null?void 0:v.bgColor)==="transparent",u=((x=r==null?void 0:r.viewProps)==null?void 0:x.outline)===!0,l=!c&&((C=r==null?void 0:r.viewProps)==null?void 0:C.bgColor)||s,{borderColor:d,highlightColor:h,textColor:p}=ln(l),y=ve(((S=r==null?void 0:r.viewProps)==null?void 0:S.textColor)||(c||u?a:p)),m=c&&!u&&!((k=r==null?void 0:r.viewProps)!=null&&k.borderColor)?"transparent":ve(((I=r==null?void 0:r.viewProps)==null?void 0:I.borderColor)||(u?l:d)),g=c||u?"transparent":l!=null&&l.startsWith("#")?l:ve(h),b=(R=r==null?void 0:r.config)==null?void 0:R.icon,w=(r==null?void 0:r.label)??(r==null?void 0:r.text)??"";if((M=r==null?void 0:r.config)!=null&&M.labelBelow){const U=(((E=r==null?void 0:r.viewProps)==null?void 0:E.fontSize)||1)*100;return f.jsxs(F.Flex,{"data-flow-icon-label":"",direction:"column",align:"center",gap:"24px",width:`${Math.max(U+200,360)}px`,position:"relative",children:[f.jsx(F.Flex,{"data-flow-node-surface":"",align:"center",justify:"center",width:`${U+100}px`,height:`${U+100}px`,flexShrink:0,borderRadius:(P=r==null?void 0:r.viewProps)==null?void 0:P.borderRadius,backgroundColor:g,...An(r==null?void 0:r.viewProps,m,t,2),children:!!b&&f.jsx(Or,{name:b,size:U,color:y})}),f.jsxs(F.Flex,{"data-flow-icon-caption":"",direction:"column",align:"center",gap:"8px",justify:"center",width:"100%",minW:0,textAlign:"center",children:[f.jsx(Rt,{nodeId:e,label:w,color:ve(((A=r==null?void 0:r.viewProps)==null?void 0:A.textColor)||a),isEditing:n,onEditStart:i,onEditEnd:o,wrap:!0}),typeof((j=r.config)==null?void 0:j.subtitle)=="string"&&r.config.subtitle!==""&&f.jsx(F.Text,{"data-flow-node-subtitle":"",color:ve(((q=r==null?void 0:r.viewProps)==null?void 0:q.textColor)||a),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 f.jsxs(F.Flex,{"data-flow-node-surface":"",align:"center",borderRadius:(O=r==null?void 0:r.viewProps)==null?void 0:O.borderRadius,bgColor:g,style:{backgroundColor:g},textTransform:"capitalize",...An(r==null?void 0:r.viewProps,m,t,2),px:50,w:"fit-content",whiteSpace:"nowrap",children:[!!b&&f.jsx(F.Flex,{align:"center",py:14,mr:w?8:0,flexShrink:0,children:f.jsx(Or,{name:b,size:(((z=r==null?void 0:r.viewProps)==null?void 0:z.fontSize)||1)*100,color:y},y)}),(w||!b)&&f.jsx(F.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:"fit-content",maxW:900,minW:0,children:f.jsx(Rt,{nodeId:e,label:w,color:y,isEditing:n,onEditStart:i,onEditEnd:o})})]})};function ov({onExpand:e,toggleLabel:t="Show properties",toggleDisabled:r=!1,renderCompact:n=XS,...i}){const{colorMode:o,callbacks:s}=Le();return f.jsx(io,{...i,children:a=>f.jsxs(F.Box,{position:"relative",children:[f.jsx(n,{...a}),e&&a.isActive&&f.jsx(F.Box,{position:"absolute",top:"-24px",right:"-48px","data-flow-content-toggle":"",children:f.jsx(Oe,{label:t,children:f.jsx(Ce,{"aria-label":t,icon:f.jsx(F.Icon,{as:K.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:o==="dark"?"gray.100":"gray.800",disabled:r,onClick:c=>{var u;c.stopPropagation(),e(),(u=s.onNodeViewToggle)==null||u.call(s,i.data.id)}})})})]})})}function QS({content:e,format:t,onEdit:r}){const n=_.useRef(null),i=_.useRef(null),o=_.useRef(null),s=_.useRef(!1),[a,c]=_.useState(!1),[u,l]=_.useState(""),d=!!r;_.useEffect(()=>{const g=()=>{var w;const b=document.fullscreenElement===i.current;c(b),s.current&&!b&&!document.fullscreenElement&&((w=o.current)==null||w.focus({preventScroll:!0})),s.current=b};return document.addEventListener("fullscreenchange",g),()=>document.removeEventListener("fullscreenchange",g)},[]);const h=async()=>{var g;l("");try{if(document.fullscreenElement===i.current)await document.exitFullscreen();else if((g=i.current)!=null&&g.requestFullscreen)await i.current.requestFullscreen();else throw new Error("Fullscreen is not supported in this browser.")}catch(b){l(b instanceof Error?b.message:"Unable to change fullscreen.")}},[p,y]=_.useState();_.useEffect(()=>{let g=!1;return Promise.resolve().then(()=>require("./contentPreviewDocument-B_Jous_v.cjs")).then(({contentPreviewDocument:b})=>b(e,t,d)).then(b=>{g||y({content:e,format:t,editable:d,document:b})},b=>{g||y({content:e,format:t,editable:d,error:b instanceof Error?b.message:String(b)})}),()=>{g=!0}},[e,t,d]),_.useEffect(()=>{if(!r)return;const g=async b=>{var w,v;if(!(!((w=n.current)!=null&&w.contentWindow)||b.source!==n.current.contentWindow||((v=b.data)==null?void 0:v.type)!=="squeed:content-edit"))try{document.fullscreenElement===i.current&&await document.exitFullscreen(),r()}catch(x){l(x instanceof Error?x.message:"Unable to close fullscreen.")}};return window.addEventListener("message",g),()=>window.removeEventListener("message",g)},[r]);const m=(p==null?void 0:p.content)===e&&p.format===t&&p.editable===d?p:void 0;return f.jsxs("div",{"data-flow-content-preview":"",style:{width:"100%",height:360,fontSize:16,overflow:"auto"},children:[f.jsx("pre",{"data-flow-preview-source":"",style:{display:"none",whiteSpace:"pre-wrap"},children:e}),f.jsxs(F.Box,{ref:i,position:"relative",w:"100%",h:"100%",bg:"white",onKeyDownCapture:g=>{g.key!=="Escape"||document.fullscreenElement!==i.current||(g.preventDefault(),g.stopPropagation(),h())},css:{"&:fullscreen":{width:"100vw",height:"100dvh",maxWidth:"none",maxHeight:"none",padding:0},"&:hover > [data-flow-fullscreen], &:focus-within > [data-flow-fullscreen]":{opacity:1,pointerEvents:"auto"},"@media (hover: none)":{"& > [data-flow-fullscreen]":{opacity:1,pointerEvents:"auto"}}},children:[f.jsx(Ce,{ref:o,"data-flow-fullscreen":"","aria-label":a?"Exit fullscreen":"Expand preview",title:a?"Exit fullscreen":"Expand preview","aria-expanded":a,icon:a?f.jsx(K.PiArrowsIn,{}):f.jsx(K.PiArrowsOut,{}),position:"absolute",top:"8px",right:"8px",zIndex:1,opacity:a?1:0,pointerEvents:a?"auto":"none",onClick:g=>{g.stopPropagation(),h()}}),u&&f.jsx(F.Box,{role:"alert",position:"absolute",bottom:0,insetInline:0,bg:"white",color:"red.700",fontSize:"14px",children:u}),m!=null&&m.error?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:m.error}):m!=null&&m.document?f.jsx("iframe",{ref:n,title:`${t.toUpperCase()} content preview`,sandbox:t==="jsx"||d?"allow-scripts":"",allowFullScreen:!0,referrerPolicy:"no-referrer",srcDoc:m.document,style:{width:"100%",height:"100%",border:0,display:"block",background:"white"}}):f.jsx("span",{role:"status",children:"Loading preview..."})]})]})}const My=1.55;function e_({nodeId:e,content:t,color:r,format:n="markdown"}){const{callbacks:i,config:o,readOnly:s}=Le(),a=!!o.editable&&!s,[c,u]=_.useState(!1),[l,d]=_.useState(t),[h,p]=_.useState(),y=_.useRef(null),m=_.useRef(!1),g=_l(c);_.useLayoutEffect(()=>{const v=y.current;!c||!v||(v.style.height="auto",v.style.height=`${Math.max((h==null?void 0:h.height)??0,v.scrollHeight)}px`)},[l,c,h]),_.useEffect(()=>{var v,x;a?c&&(m.current=!1,(v=y.current)==null||v.focus({preventScroll:!0}),(x=y.current)==null||x.select()):u(!1)},[c,a]);const b=v=>{a&&(p({width:v.offsetWidth,height:v.offsetHeight}),d(t),u(!0))},w=()=>{var v;m.current||!a||(m.current=!0,l!==t&&((v=i.onNodeContentChange)==null||v.call(i,e,l)),u(!1))};return(!c||!a)&&n!=="markdown"?f.jsxs(F.Box,{ref:g,w:"100%",position:"relative","data-flow-content":"",css:{"&:hover > [data-flow-content-edit], &:focus-within > [data-flow-content-edit]":{opacity:1,pointerEvents:"auto"}},children:[a&&f.jsx(Ce,{"data-flow-content-edit":"","aria-label":"Edit content source",title:"Edit content source",icon:f.jsx(K.PiCode,{}),position:"absolute",top:"8px",right:"48px",zIndex:1,opacity:0,pointerEvents:"none",onClick:v=>{v.stopPropagation(),b(v.currentTarget.parentElement)}}),f.jsx(QS,{content:t,format:n,onEdit:a?()=>{g.current&&b(g.current)}:void 0})]}):!c||!a?f.jsx(F.Box,{"data-flow-content":"",color:r,opacity:t?void 0:.6,w:"100%",minH:"1.2em",whiteSpace:"normal",lineHeight:My,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:v=>{v.stopPropagation(),b(v.currentTarget)},onKeyDown:v=>{a&&v.key==="Enter"&&v.target===v.currentTarget&&(v.preventDefault(),v.stopPropagation(),b(v.currentTarget))},children:f.jsx(Av.default,{options:{forceBlock:!0,wrapper:_.Fragment,disableParsingRawHTML:!0,overrides:{a:{props:{target:"_blank",rel:"noopener noreferrer"}},img:{props:{loading:"lazy",referrerPolicy:"no-referrer"}}}},children:t||(a?"Write your content here":"")})}):f.jsx("div",{ref:g,style:{width:h==null?void 0:h.width,minHeight:h==null?void 0:h.height,maxWidth:"100%"},children:f.jsx(F.Textarea,{ref:y,"aria-label":"Node content",placeholder:"Write your content here",value:l,onChange:v=>d(v.target.value),onBlur:w,onKeyDown:v=>{v.stopPropagation(),!v.nativeEvent.isComposing&&(v.key==="Enter"&&(v.ctrlKey||v.metaKey)&&(v.preventDefault(),w()),v.key==="Escape"&&(m.current=!0,u(!1)))},color:r,fontFamily:"inherit",fontSize:"inherit",lineHeight:My,overflowWrap:"anywhere",whiteSpace:"pre-wrap",rows:1,bg:"transparent",display:"block",style:{border:0,outline:"none",boxShadow:"none"},_focus:{border:0,outline:"none",boxShadow:"none"},_focusVisible:{border:0,outline:"none",boxShadow:"none"},p:0,w:"100%",h:"100%",minW:0,minH:0,resize:"none"})})}const r_=(e,t,r)=>{var h,p,y,m;const n=((h=e==null?void 0:e.viewProps)==null?void 0:h.bgColor)||t,[i]=n.split("."),o=ln(n),s=((p=e==null?void 0:e.viewProps)==null?void 0:p.outline)===!0,a=n==="transparent"||s,c=r==="dark"?"gray.200":"gray.900",u=a?"transparent":n!=null&&n.startsWith("#")?ve(n):ve(o.bgColor),l=ve(((y=e==null?void 0:e.viewProps)==null?void 0:y.textColor)||(a?c:o.textColor)),d=ve(((m=e==null?void 0:e.viewProps)==null?void 0:m.borderColor)||(s?n==="transparent"?t:n:o.borderColor));return{...o,bgColor:a?"transparent":o.bgColor,highlightColor:a?"transparent":o.highlightColor,isTransparent:a,propertyColor:a?c:o.propertyColor,bg:n,wordBeforeDot:i,hexbgColor:u,hextextColor:l,hexborderColor:d}},t_=(e,t=350)=>`${String(e).substring(0,t)}${String(e).length>t?"...":""}`,n_=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,iv=600,o_=3,i_=e=>{const t=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(t*28+30,200)};function a_({headerTitle:e,hasContent:t,data:r,icon:n,colors:i,hasConfig:o,id:s,isActive:a,isEditing:c,onEditStart:u,onEditEnd:l,props:d,objVisible:h,setObjVisible:p,onShowNativeIcon:y}){var w,v;const{callbacks:m}=Le(),g=d.onShowIcon??y,b=g?"Show icon":h?"Show content":"Show properties";return f.jsx(f.Fragment,{children:(e||t||((w=r.config)==null?void 0:w.form)||a&&y)&&f.jsxs(F.Flex,{justify:"flex-start",direction:"row",p:t||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:i.propertyColor,bgColor:i.highlightColor,borderBottomColor:!o&&!t?"transparent":i.hexborderColor,children:[!!n&&f.jsx(F.Flex,{mr:6,alignItems:"center",flexShrink:0,children:f.jsx(Or,{name:n,size:64,color:i.hextextColor},i.hextextColor)}),f.jsx(Rt,{nodeId:s,label:n_(e),color:((v=r==null?void 0:r.viewProps)==null?void 0:v.textColor)||i.propertyColor,isEditing:c,onEditStart:u,onEditEnd:l}),a&&(t||g)&&f.jsx(F.Box,{ml:"auto",pl:6,flexShrink:0,"data-flow-content-toggle":"",children:f.jsx(Oe,{label:b,children:f.jsx(Ce,{"aria-label":b,icon:f.jsx(F.Icon,{as:K.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:i.hextextColor,onClick:x=>{var C;x.stopPropagation(),g?g():p(!h),(C=m.onNodeViewToggle)==null||C.call(m,s)}})})})]})})}function s_({data:e,resourcePorts:t,inspecting:r,form:n,inspectionPorts:i,extraPorts:o,colors:s,direction:a,uniformKeyWidth:c}){const{edgeById:u}=Xr(),l=new Set;for(const{data:d}of u.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 f.jsx(F.Box,{children:Object.entries(e.description||{}).map(([d,h],p)=>{var A,j,q;const y=t&&Object.keys(t).find(O=>O.slice(O.indexOf(":")+1)===d),m=r&&((A=n==null?void 0:n.type.ports)==null?void 0:A[d]),g=y??(m?`${m.kind}:${d}`:d),b=i.find(O=>O.id===g),w=y?"source":b==null?void 0:b.role,v=l.has(`source:${g}`),x=l.has(`target:${g}`),C=o.some(O=>O.id===d),S=h===""&&(C||(w?l.has(`${w}:${g}`):v||x)),k=w??(v!==x?v?"source":"target":void 0),I=(b==null?void 0:b.side)??(k?k==="source"!=(a==="RL")?"right":"left":void 0),R=S&&I==="right"?"right":"left",M=(b==null?void 0:b.label)??(m==null?void 0:m.label)??(C?d.replace(/^(template|input|output|config|error):/,""):d),E=Ir(s.wordBeforeDot)[typeof h],P=Ir(s.wordBeforeDot).property;return f.jsxs(F.Box,{"data-flow-property":y&&(a==="TB"||a==="BT")?void 0:g,"data-flow-port-role":w,"data-flow-inspection-row":r?"":void 0,children:[f.jsxs(F.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[f.jsx(F.Flex,{justifyContent:"start",align:"center",background:s.highlightColor,width:S?"100%":`${c}px`,minWidth:`${c}px`,borderRightColor:s.hexborderColor,borderRightWidth:S?0:1,children:f.jsx(F.Text,{py:5,px:10,w:"100%",textAlign:R,whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((j=e==null?void 0:e.viewProps)==null?void 0:j.textColor)||(s.isTransparent?s.hextextColor:P),children:M})}),!S&&f.jsx(F.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:s.hexbgColor,w:iv,maxH:200,children:f.jsx(F.Text,{overflow:"hidden",py:3,px:4,whiteSpace:"normal",textOverflow:"ellipsis",fontSize:"4xl",color:((q=e==null?void 0:e.viewProps)==null?void 0:q.textColor)||(s.isTransparent?s.hextextColor:E),fontWeight:400,children:t_(h)})})]}),p!==Object.entries(e.description||{}).length-1&&f.jsx(F.Box,{borderTopWidth:1,my:0,borderColor:s.hexborderColor})]},d)})})}function c_(e){var v,x,C;const{themeColor:t,colorMode:r,direction:n}=Le(),i=ao(),o=i.getNodeViewMode(e.data.id)==="properties",s=S=>i.setNodeViewMode(e.data.id,S?"properties":"default"),a=!!e.onShowIcon||o||typeof((v=e.data.config)==null?void 0:v.content)!="string",{bindings:c,data:u,schema:l}=_.useContext(Sr),d=(x=c==null?void 0:c[e.data.id])==null?void 0:x.portResources,h=c?dn(c,e.data.id,l):u&&l?Tt(u,e.data.id,l):void 0,p=h&&ke(u,"address"in h?h.address:e.data.id),y=p&&typeof p=="object"&&h?Object.fromEntries(Object.keys(h.type.properties).filter(S=>{var k;return Object.prototype.hasOwnProperty.call(p,S)&&Fn((k=h.fields[S])==null?void 0:k.$visibleWhen,u)}).map(S=>[S,p[S]!==null&&typeof p[S]=="object"?JSON.stringify(p[S],null,2):p[S]===null?"null":p[S]])):{},m=d?Object.fromEntries(Object.entries(d).map(([S,k])=>{var I;return[S.slice(S.indexOf(":")+1),((I=ke(u,k))==null?void 0:I.name)??k.split(".").at(-1)]})):Object.keys(e.data.description??{}).length?e.data.description:y,g=a&&!d?((C=e.data.config)==null?void 0:C.ports)??[]:[],b=g.filter(S=>!Object.prototype.hasOwnProperty.call(m,S.id)&&!Object.entries((h==null?void 0:h.type.ports)??{}).some(([k,I])=>`${I.kind}:${k}`===S.id&&Object.prototype.hasOwnProperty.call(m,k))),w={...m,...Object.fromEntries(b.map(S=>[S.id,""]))};return{themeColor:t,colorMode:r,direction:n,objVisible:o,setObjVisible:s,inspecting:a,resourcePorts:d,form:h,description:w,inspectionPorts:g,extraPorts:b}}const El=e=>{var g,b,w;const{themeColor:t,colorMode:r,direction:n,objVisible:i,setObjVisible:o,inspecting:s,resourcePorts:a,form:c,description:u,inspectionPorts:l,extraPorts:d}=c_(e),h=ao(),p=h.getNodeViewMode(e.data.id)==="icon-label",m=!e.onShowIcon&&!((g=e.data.config)!=null&&g.parentContainer)&&typeof((b=e.data.config)==null?void 0:b.content)!="string"?()=>h.setNodeViewMode(e.data.id,"icon-label"):void 0;return!e.onShowIcon&&p?f.jsx(ov,{...e,data:{...e.data,label:e.data.label??e.data.headerTitle,config:{...e.data.config,labelBelow:!0,icon:((w=e.data.config)==null?void 0:w.icon)||"PiBracketsCurly"}},onExpand:()=>h.restoreNodeView(e.data.id)}):f.jsx(io,{...e,data:{...e.data,description:u},children:({id:v,data:x,isActive:C,isEditing:S,onEditStart:k,onEditEnd:I})=>{var U,ae,Q,Y,pe,se,$,V,W,N;const R=r_(x,t,r),M=x.label??x.headerTitle,E=Object.entries(x.description||{}).length>0,P=i_(x.description),A=(ae=(U=e.data)==null?void 0:U.config)==null?void 0:ae.icon,j=(Y=(Q=e.data)==null?void 0:Q.config)==null?void 0:Y.content,q=typeof j=="string"&&!e.onShowIcon,O=((pe=x==null?void 0:x.viewProps)==null?void 0:pe.borderRadius)??"53px",z=An(x==null?void 0:x.viewProps,R.hexborderColor,C,o_);return f.jsx(F.Flex,{justifyContent:"space-between",...x==null?void 0:x.viewProps,"data-flow-node-surface":"",direction:"column",p:0,borderRadius:O,overflow:"hidden",alignItems:"center",style:{backgroundColor:R.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:"100%",minW:q||e.onShowIcon?P+iv+z.borderWidth*2:void 0,...z,children:f.jsxs(F.Flex,{width:"100%",direction:"column",borderRadius:O,borderColor:R.hexborderColor,borderWidth:0,overflow:"hidden",children:[f.jsx(a_,{headerTitle:M,hasContent:q,data:x,icon:A,colors:R,hasConfig:E,id:v,isActive:C,isEditing:S,onEditStart:k,onEditEnd:I,props:e,objVisible:i,setObjVisible:o,onShowNativeIcon:m}),q&&!i?f.jsx(F.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:R.highlightColor,p:["html","jsx"].includes(($=(se=e.data)==null?void 0:se.config)==null?void 0:$.contentFormat)?0:12,fontSize:"5xl",lineHeight:"normal",children:f.jsx(e_,{nodeId:v,content:j,format:(W=(V=e.data)==null?void 0:V.config)==null?void 0:W.contentFormat,color:((N=x==null?void 0:x.viewProps)==null?void 0:N.textColor)||R.hextextColor})}):f.jsx(s_,{data:x,resourcePorts:a,inspecting:s,form:c,inspectionPorts:l,extraPorts:d,colors:R,direction:n,uniformKeyWidth:P})]})})}})};El.displayName="NodeJsonObjectView";const av=e=>{var m,g,b,w,v,x,C,S,k,I,R;const t=ao(),[r,n]=_.useState(!1),i=t.getNodeViewMode(e.data.id)==="properties",o=M=>{n(M),t.setNodeViewMode(e.data.id,M?"properties":"default")},{callbacks:s,readOnly:a,selectedNodeIds:c}=Le(),u=(g=(m=e.data)==null?void 0:m.config)==null?void 0:g.parentContainer,l=c.includes(e.data.id),d=_.useRef(l);_.useEffect(()=>{var M,E;d.current&&!l&&i&&((E=(M=e.data)==null?void 0:M.config)!=null&&E.labelBelow)&&!u&&!a&&o(!1),d.current=l},[l,i,(w=(b=e.data)==null?void 0:b.config)==null?void 0:w.labelBelow,u,a]);const h=u?"Show parent":"Show properties",p=u||((x=(v=e.data)==null?void 0:v.config)==null?void 0:x.form)||((k=(S=(C=e.data)==null?void 0:C.config)==null?void 0:S.ports)==null?void 0:k.length),y=p?()=>{var M;u?(M=s.onNodeCollapse)==null||M.call(s,e.data.id,!1):o(!0)}:void 0;return!u&&p&&i?f.jsx(El,{...e,editOnMount:r,onShowIcon:()=>o(!1)}):f.jsx(ov,{...e,onOpenView:y&&(u||(R=(I=e.data)==null?void 0:I.config)!=null&&R.labelBelow)?()=>{var M;y(),(M=s.onNodeViewToggle)==null||M.call(s,e.data.id)}:void 0,toggleLabel:h,toggleDisabled:u&&a,onExpand:y})},sv=e=>f.jsx(av,{...e,renderCompact:YS}),cv=e=>f.jsx(av,{...e}),uv=({containerStyle:e,...t})=>{const{selectedNodeIds:r}=Le();return f.jsx(io,{...t,editOnMount:r.includes(t.data.id),children:n=>f.jsx(F.Box,{bg:e.textColor==="transparent"?"transparent":e.labelBg,p:`${e.fontSize/5}px`,fontFamily:Lr,lineHeight:1,w:"fit-content",children:f.jsx(Rt,{nodeId:n.id,label:n.data.label??n.data.headerTitle??"Container",color:e.textColor,fontSize:`${e.fontSize}px`,isEditing:n.isEditing,onEditStart:n.onEditStart,onEditEnd:n.onEditEnd})})})};sv.displayName="text";cv.displayName="arrayView";uv.displayName="ParentContainerView";const u_={objectView:El,arrayView:cv,text:sv,parentContainer:uv},l_=({children:e,pattern:t="dot",backgroundColor:r})=>{const{colorMode:n}=Le(),i=n==="dark",o=i?"--chakra-colors-gray-700":"--chakra-colors-gray-500",s=i?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return t==="none"?f.jsx(F.Box,{"data-flow-background":"none",width:"100%",height:"100%",padding:0,bg:r,children:e}):f.jsxs(F.Box,{"data-flow-background":t,position:"relative",width:"100%",height:"100%",padding:0,bg:r,children:[f.jsx(F.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(${o}) 8%, transparent 8%)`:t==="steel"?`repeating-linear-gradient(45deg, var(${s}) 0, var(${s}) 1px, transparent 1px, transparent 20px)`:`linear-gradient(var(${s}) 1px, transparent 1px), linear-gradient(90deg, var(${s}) 1px, transparent 1px)`,backgroundSize:"20px 20px",opacity:.3}}),f.jsx(F.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:e})]})},d_=.4,tt={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},f_=({nodes:e,edges:t})=>{const{themeColor:r,spacing:n,edgeRadius:i,backgroundVariant:o,backgroundSelected:s,setBackgroundSelected:a,edgeColor:c,direction:u,nodeAlignment:l,edgeMode:d,compactPropertyLayout:h,workflowContract:p,parentNodeStyle:y,engineRef:m,callbacks:g,config:b,selectedNodeIds:w,setSelectedNodeIds:v,selectedEdgeId:x,setSelectedEdgeId:C,setIsPerformanceMode:S,isZoomMode:k,setIsZoomMode:I,isMultiSelectMode:R,setIsMultiSelectMode:M,isDragMode:E,setIsDragMode:P,isEdgeHandlesEnabled:A,setIsEdgeHandlesEnabled:j,isArrayNodeMode:q}=Le(),O=_.useRef(null),[z,U]=_.useState(null),ae=e.length>200;_.useEffect(()=>{S(ae)},[ae,S]);const{edgeSep:Q,rankSep:Y,spacingFactor:pe}=_.useMemo(()=>{const Z=J0(e.length),B=n<1?.3+.7*n:.5+.5*n;return{edgeSep:Z.edgeSep*B,rankSep:Z.rankSep*B,spacingFactor:1.3+(n-1)*(n<1?.4:.3)}},[e.length,n]),{bgColor:se}=ln(r),{canvas:$,borderSecondary:V,colorText:W}=Ze(),N=o==="transparent"?"transparent":b.backgroundColor||$,ne=_.useCallback(Z=>{if(!Z)return ve(r);switch(Z){case"dark":return ve(N);case"light":return ve(V);default:return ve(Z)}},[r,N,V]),me=b.colorMode==="dark",fe=me?ve("gray.500"):Pt,J=me?se!=null&&se.includes("gray")?"whitesmoke":ne(se):fe,te=c?ne(c):fe,G=_.useMemo(()=>b.initialViewport||{pan:{x:0,y:0},zoom:.01},[]),le=u==="C"?"LR":u,ue=_.useCallback(Z=>{const B={...y,...Z};return{...B,bgColor:B.bgColor||r,bgOpacity:B.outline?0:B.bgOpacity??d_}},[y,r]),we=_.useMemo(()=>{var B;const Z=new Map;for(const re of e)(B=re.data)!=null&&B.id&&Z.set(re.data.id,re);return Z},[e]),ge=_.useMemo(()=>{var B;const Z=new Map;for(const re of t)(B=re.data)!=null&&B.id&&Z.set(re.data.id,re);return Z},[t]),qe=_.useCallback(Z=>{var Ae;const B=(Ae=we.get(Z))==null?void 0:Ae.data,re=ue(B==null?void 0:B.viewProps),_e=ve(re.bgColor);return{animated:!!(B!=null&&B.isNodeAnimated)&&!ae,animationVariant:B==null?void 0:B.nodeAnimationVariant,animationColor:ve(re.borderColor||r),bgColor:re.outline?"transparent":_e,bgOpacity:re.bgOpacity,borderColor:re.borderColor?ve(re.borderColor):re.outline&&re.bgColor==="transparent"?ve(r):_e,borderWidth:cn(re.borderWidth,tt.borderWidth),borderStyle:re.borderStyle??tt.borderStyle,borderRadius:re.borderRadius??tt.borderRadius,textColor:re.textColor?ve(re.textColor):re.outline||re.bgColor==="transparent"?ve(W):_e,fontSize:re.fontSize??tt.fontSize,labelPosition:re.labelPosition??tt.labelPosition,labelMargin:tt.labelMargin,labelBg:Al(ne("dark"),_e,re.bgOpacity)??ne("dark"),padding:re.padding??tt.padding}},[ue,we,W,r,ae,ne]),ee=_.useMemo(()=>{var re,_e;const Z=new Map;for(const Ae of t){const Re=(re=Ae.data)==null?void 0:re.source,He=(_e=Ae.data)==null?void 0:_e.target;if(!Re||!He||Re===He)continue;const je=Re<He?`${Re}|${He}`:`${He}|${Re}`,De=Z.get(je);De?De.push({id:Ae.data.id,source:Re}):Z.set(je,[{id:Ae.data.id,source:Re}])}const B=new Map;for(const[Ae,Re]of Z){if(Re.length<2)continue;const He=Ae.split("|")[0],je=Math.min(20,70/Re.length);Re.forEach(({id:De,source:Ke},dr)=>{const fr=50+(dr-(Re.length-1)/2)*je;B.set(De,(Ke===He?fr:100-fr)/100)})}return B},[t]),he=_.useMemo(()=>{const Z=ne("dark");return t.filter(B=>{var re;return((re=B.data)==null?void 0:re.id)&&B.data.source&&B.data.target}).map(({data:B})=>{var Re,He,je,De,Ke,dr;let re=Z;const _e=(He=(Re=we.get(B.source))==null?void 0:Re.data)==null?void 0:He.parent,Ae=(De=(je=we.get(B.target))==null?void 0:je.data)==null?void 0:De.parent;if(_e&&_e===Ae){const fr=ue((dr=(Ke=we.get(_e))==null?void 0:Ke.data)==null?void 0:dr.viewProps),Ne=Al(Z,ve(fr.bgColor),fr.bgOpacity);Ne&&(re=Ne)}return{id:B.id,data:B,type:B.type??b.edgeType??"rounded-orthogonal",source:B.source,target:B.target,sourceProperty:B.sourceProperty,targetProperty:B.targetProperty,label:B.label,validationIssue:(d==="auto"||d==="properties")&&(B.sourceProperty!==void 0||B.targetProperty!==void 0)&&p?el(p,B):void 0,color:c?te:B.color?ve(B.color):te,connectorColor:c?te:B.color?ve(B.color):J,labelBg:re,dashed:!!B.isEdgeDashed,animated:!!B.isEdgeAnimated,inverted:!!B.isInverted,turn:ee.get(B.id)??.5}})},[t,te,J,c,ee,b.edgeType,d,p,we,ue,ne]),be=_.useMemo(()=>{var B;const Z=new Set;for(const re of e)(B=re.data)!=null&&B.parent&&Z.add(re.data.parent);return Z},[e]),Ee=_.useMemo(()=>{const Z=new Map;for(const B of t){const re=B.data.isInverted?B.data.target:B.data.source;re&&!Z.has(re)&&Z.set(re,B.data)}for(const B of t){if(B.data.connection)continue;const re=B.data.isInverted?B.data.target:B.data.source,_e=B.data.isInverted?B.data.source:B.data.target;_e.startsWith(`${re}.`)&&(Z.set(re,B.data),Z.set(_e,B.data))}return Z},[t]),$e=_.useMemo(()=>{const Z={...u_,...b.customViews};return e.filter(B=>{var re;return(re=B.data)==null?void 0:re.id}).map(B=>{var He,je,De,Ke,dr;const re=be.has(B.data.id)&&!B.data.parent,_e=re?B.data.label??B.data.headerTitle??"Container":void 0,Ae=re?Z.parentContainer:Z[B.data.type]||Z.text,Re=Ee.get(B.data.id);return{id:B.data.id,collapsed:(He=B.data.config)==null?void 0:He.collapsed,parent:B.data.parent,label:_e,animated:!!B.data.isNodeAnimated,animationVariant:B.data.nodeAnimationVariant,hasCollapseControl:((je=B.data.config)==null?void 0:je.collapsed)!==void 0,animationColor:ve(((De=B.data.viewProps)==null?void 0:De.borderColor)||r),animationWidth:cn((Ke=B.data.viewProps)==null?void 0:Ke.borderWidth,8),element:_.createElement(Ae,{...B,isInverted:((dr=B.data.config)==null?void 0:dr.isInverted)??(Re==null?void 0:Re.isInverted),isParent:re,containerStyle:re?qe(B.data.id):void 0,key:`${B.data.id}-${r}`})}})},[e,be,Ee,r,b.customViews,qe]),Ge=_.useMemo(()=>ae?300:e.length>50?150:e.length>20?100:50,[e.length,ae]),Ye=_.useRef(b);Ye.current=b;const tr=_.useRef(k);tr.current=k;const sr=_.useRef(q);sr.current=q;const Pe=_.useRef(w);Pe.current=w;const ye=_.useRef(x);ye.current=x;const Me=_.useRef(R);Me.current=R;const nr=_.useRef(we);nr.current=we;const cr=_.useRef(ge);cr.current=ge;const Xe=_.useRef(new Map);_.useEffect(()=>{var re,_e;const Z=new Map([...ge].filter(([,Ae])=>we.has(Ae.data.source)&&we.has(Ae.data.target))),B=Xe.current;Xe.current=Z;for(const[Ae,Re]of B)Z.has(Ae)||(ye.current===Ae&&(C(null),(re=g.onEdgeDeselect)==null||re.call(g)),(_e=g.onEdgeRemove)==null||_e.call(g,Ae,Re.data))},[ge,we,g,C]),_.useEffect(()=>{const Z=O.current;if(!z||!Z)return;let B=null,re=null,_e=0,Ae=0,Re=0,He=0,je=0;const De=Ke=>{if(Ye.current.readOnly)return;Ke.preventDefault(),Ke.stopPropagation(),tr.current||Ke.metaKey||Ke.ctrlKey?(Re+=Ke.deltaY,He=Ke.clientX,je=Ke.clientY,re===null&&(re=requestAnimationFrame(()=>{re=null;const fr=Ye.current,Ne=z.zoom(),Tr=Re;Re=0;let qr=Ne-Tr*.05/100;qr=Math.max(fr.minZoom??.01,Math.min(fr.maxZoom??1.5,qr));const Dr=Z.getBoundingClientRect();z.zoomAt(qr,{x:He-Dr.left,y:je-Dr.top})}))):(_e+=Ke.deltaX,Ae+=Ke.deltaY,B===null&&(B=requestAnimationFrame(()=>{B=null;const fr=z.pan(),Ne=z.zoom(),Tr=.35,qr=_e,Dr=Ae;_e=0,Ae=0,z.pan({x:fr.x+-qr*Tr/Ne,y:fr.y+-Dr*Tr/Ne})})))};return Z.addEventListener("wheel",De,{passive:!1}),()=>{Z.removeEventListener("wheel",De),B!==null&&cancelAnimationFrame(B),re!==null&&cancelAnimationFrame(re)}},[z]),_.useEffect(()=>{if(b.disableKeyboardShortcuts)return;const Z=B=>{var _e,Ae,Re,He;if(Ye.current.readOnly)return;const re=B.target;if(!(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.isContentEditable)){if((B.key==="z"||B.key==="Z")&&I(!tr.current),(B.key==="m"||B.key==="M")&&M(!R),(B.key==="d"||B.key==="D")&&P(!E),(B.key==="v"||B.key==="V")&&!B.repeat&&!B.metaKey&&!B.ctrlKey&&!B.altKey&&re.tagName!=="SELECT"&&j(!A),(B.key==="Delete"||B.key==="Backspace")&&ye.current){B.preventDefault();const je=ye.current;(Ae=g.onEdgeDelete)==null||Ae.call(g,je,((_e=cr.current.get(je))==null?void 0:_e.data)??{id:je}),C(null);return}if((B.key==="Delete"||B.key==="Backspace")&&Pe.current.length>0){B.preventDefault();const je=Pe.current.filter(De=>De!=="root");if(je.length===0)return;for(const De of je){const Ke=(Re=nr.current.get(De))==null?void 0:Re.data;(He=g.onNodeDelete)==null||He.call(g,De,Ke||{})}v([])}}};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[R,E,A,j,I,M,P,b.disableKeyboardShortcuts,g,v,C]);const xe=_.useCallback(Z=>{var B;m.current=Z,U(Z),(B=g.onInit)==null||B.call(g,Z)},[m,g]),et=_.useCallback(Z=>{var B;return(B=g.onViewportChange)==null?void 0:B.call(g,Z)},[g]),zr=_.useCallback(Z=>{var re,_e,Ae;const B=((re=cr.current.get(Z))==null?void 0:re.data)??{id:Z};if(ye.current===Z&&Me.current){C(null),(_e=g.onEdgeDeselect)==null||_e.call(g);return}Pe.current.length&&v([]),C(Z),(Ae=g.onEdgeSelect)==null||Ae.call(g,Z,B)},[g,C,v]),pt=_.useCallback(()=>{var Z,B,re,_e,Ae;if(a(b.bottomBarCollapsed??(Pe.current.length>0||!!ye.current||!s)),(Z=g.onBackgroundClick)==null||Z.call(g),!Ye.current.readOnly){const Re=new Set;for(const He of Pe.current){let je=nr.current.get(He);for(;je&&!Re.has(je.data.id);)Re.add(je.data.id),be.has(je.data.id)&&((B=je.data.config)==null?void 0:B.collapsed)!==!0&&((re=g.onNodeCollapse)==null||re.call(g,je.data.id,!0)),je=je.data.parent?nr.current.get(je.data.parent):void 0}}Pe.current.length&&(v([]),(_e=g.onNodeDeselect)==null||_e.call(g)),ye.current&&(C(null),(Ae=g.onEdgeDeselect)==null||Ae.call(g))},[g,v,C,a,s,b.bottomBarCollapsed,be]),ie=_.useCallback(Z=>{var _e,Ae;const B=Pe.current,re=Z.filter(Re=>!B.includes(Re));if(re.length){v([...B,...re]);for(const Re of re)(Ae=g.onNodeSelect)==null||Ae.call(g,Re,((_e=nr.current.get(Re))==null?void 0:_e.data)??{id:Re})}},[g,v]),We=_.useCallback((Z,B)=>{var re,_e;v([Z]),(_e=g.onNodeSelect)==null||_e.call(g,Z,((re=nr.current.get(Z))==null?void 0:re.data)??{id:Z},B)},[g,v]),or=_.useCallback((Z,B,re)=>{var _e;return(_e=g.onEdgeCreate)==null?void 0:_e.call(g,Z,B,re)},[g]),Ue=_.useCallback((Z,B,re,_e=!1)=>{var Ae,Re;d==="properties"&&((Ae=g.onNodeCreateRequest)==null?void 0:Ae.call(g,{sourceNodeId:Z,position:B,sourceProperty:re,reverse:_e}))===!0||re!==void 0||_e||(Re=g.onNodeCreate)==null||Re.call(g,{type:"text",sourceNodeId:Z,position:B,isArrayMode:sr.current})},[g,d]),ir=!b.readOnly&&A&&b.edgeHandles!==!1,er=o==="transparent"?"none":o;return f.jsx(l_,{pattern:er,backgroundColor:N,children:f.jsx(F.Box,{ref:O,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:f.jsx(HS,{nodes:$e,edges:he,direction:le,nodeAlignment:l,onContainerCollapse:Z=>{var B,re;(B=g.onNodeCollapse)==null||B.call(g,Z,!0),(re=g.onNodeViewToggle)==null||re.call(g,Z)},selectedNodeIds:w,edgeMode:d,compactPropertyLayout:h,edgeType:b.edgeType,edgeRadius:i,customEdgeTypes:b.customEdgeTypes,edgeReveal:b.edgeReveal,rankSep:Y,edgeSep:Q,spacingFactor:pe,compactSpacingScale:n,layoutDebounce:Ge,isPerformanceMode:ae,minZoom:b.minZoom??.01,maxZoom:b.maxZoom??1.5,initialViewport:G,fitOnInit:!b.initialViewport,readOnly:!!b.readOnly,containerStyle:qe,lineColor:c?te:J,drawMode:ir,drawHandles:!b.readOnly&&b.edgeHandles!==!1,dragMode:E,multiSelect:!!R,onInit:xe,onLayoutComplete:g.onLayoutComplete,animateViewport:b.animateViewport,onViewportChange:et,onBackgroundTap:pt,onBoxSelect:ie,onEdgeSelect:zr,onContainerSelect:We,onEdgeDraw:or,onDrawIntoSpace:Ue})})})},lv=_.memo(f_),h_=".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 qy=!1;function p_(){if(qy||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=h_+K0+W0+U0+".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}',qy=!0}function g_({loading:e=!1,loader:t,...r}){var c,u;const[n,i]=_.useState(null),o=_.useMemo(()=>!!(n!=null&&n.json)&&!!r.json&&z0(n.json,r.json),[n==null?void 0:n.json,r.json]),s=n===null||n.json!==r.json&&!o,a=e||s;return _.useEffect(()=>{!e&&o&&(n==null?void 0:n.json)!==r.json&&i(r)},[e,o,n==null?void 0:n.json,r.json]),_.useEffect(()=>{if(e||!s)return;let l;const d=requestAnimationFrame(()=>{l=requestAnimationFrame(()=>i(r))});return()=>{cancelAnimationFrame(d),l!==void 0&&cancelAnimationFrame(l)}},[e,s,r.json]),f.jsxs(F.Box,{className:r.className,style:r.style,width:"100%",height:"100%",position:"relative","aria-busy":a,children:[f.jsx("div",{style:{width:"100%",height:"100%"},ref:l=>{a?l==null||l.setAttribute("inert",""):l==null||l.removeAttribute("inert")},children:n&&f.jsx(y_,{...s?n:r,className:void 0,style:void 0})}),a&&t!==null&&f.jsx(F.Box,{"data-flow-loader":"",role:"status","aria-label":"Loading diagram",position:"absolute",inset:0,zIndex:1e3,display:"grid",placeItems:"center",background:((c=r.config)==null?void 0:c.colorMode)==="dark"?"gray.800":"gray.100",color:((u=r.config)==null?void 0:u.colorMode)==="dark"?"whiteAlpha.800":"blackAlpha.800",children:t===void 0?f.jsx("span",{children:"Loading diagram..."}):t})]})}function y_({title:e="untitled",json:t,forms:r,nodes:n,edges:i,config:o={},callbacks:s={},className:a,style:c,showBottomBar:u=!0,children:l}){p_();const[d,h]=_.useState(),[p,y]=_.useState(!1),m=o.formSchema??d,g=_.useMemo(()=>t&&r?jm(t,r.state):t,[t,r==null?void 0:r.state]),b=o.direction==="C",w=_.useMemo(()=>{let E,P;return A=>(P=E&&P?D0(E,A,P)??Lu(A,{title:e,isCenter:b}):Lu(A,{title:e,isCenter:b}),E=A,P)},[e,b]),v=_.useMemo(()=>g?w(g):null,[g,w]),x=_.useMemo(()=>r!=null&&r.structured&&!p&&m?km(r.state,r.bindings,m,(v==null?void 0:v.nodes)??n??[]):void 0,[r==null?void 0:r.structured,p,r==null?void 0:r.state,r==null?void 0:r.bindings,m,v,n]),C=(x==null?void 0:x.schema)??m,S=(x==null?void 0:x.bindings)??(r==null?void 0:r.bindings),k=_.useMemo(()=>[...(v==null?void 0:v.nodes)??n??[],...(x==null?void 0:x.nodes)??[]].map(P=>{var ae,Q,Y,pe;const A=t?(ae=ke(t,P.data.id))==null?void 0:ae.$view:(Q=P.data.config)==null?void 0:Q.typeView,j=A&&nn.includes(A)?A:void 0,q=j?j==="icon-label":(Y=P.data.config)==null?void 0:Y.labelBelow,O=j==="object"?"objectView":j==="text"?"text":q?"arrayView":P.data.type,z=C&&(r?dn(S,P.data.id,C):t&&Tt(t,P.data.id,C)),U=(((pe=P.data.config)==null?void 0:pe.ports)??[]).map(se=>({...se}));if(x&&z){const se=o.direction==="RL"?{input:"right",output:"left",config:"bottom",error:"top"}:o.direction==="TB"?{input:"top",output:"bottom",config:"right",error:"left"}:o.direction==="BT"?{input:"bottom",output:"top",config:"left",error:"right"}:{input:"left",output:"right",config:"top",error:"bottom"};for(const[$,V]of Object.entries(z.type.ports??{})){const W=`${V.kind}:${$}`,N=U.find(ne=>ne.id===W);N?N.label===void 0&&V.label!==void 0&&(N.label=V.label):U.push({id:W,...V.label!==void 0?{label:V.label}:{},role:V.kind==="input"||V.kind==="config"?"target":"source",side:se[V.kind],...V.kind==="config"?{placement:"config"}:{}})}for(const $ of U){const V=U.filter(W=>W.side===$.side);$.position=(V.indexOf($)+1)/(V.length+1)}}return z||q||j?{...P,data:{...P.data,type:O,...r?{description:Object.fromEntries(Object.entries(P.data.description??{}).filter(([se])=>!se.startsWith("$")&&!(x!=null&&x.slots.has(Dt(P.data.id,se)))))}:{},config:{...P.data.config,...x&&z?{ports:U}:{},...z?{form:!0}:{},...j?{typeView:j,labelBelow:!!q}:q?{labelBelow:!0}:{}}}}:P}),[v,n,t,C,S,x,o.direction]),I=[...(v==null?void 0:v.edges)??i??[],...(x==null?void 0:x.edges)??[]],R=_.useMemo(()=>{const E=t&&v?Um(t,v.edges,s,s.onJsonChange,m):{...s};if(x){const P=new Set([...x.nodes.map(A=>A.data.id),...x.edges.map(A=>A.data.id)]);for(const A of Object.keys(E)){if(!/^on(?:Node|Edge).*(?:Change|Collapse)$/.test(A))continue;const j=E[A];E[A]=(q,...O)=>{if(!P.has(q))return j==null?void 0:j(q,...O)}}}return{...E,onAllNodesIconLabelChange:P=>{var A;y(P),(A=E.onAllNodesIconLabelChange)==null||A.call(E,P)}}},[t,v,s,m,x]),M=_.useMemo(()=>{if(!r)return R;let E=r.state;const P=j=>{if(o.readOnly||o.editable===!1)return;const q=r.onStateChange??r.onChange;if(!q)return;const O=P0(E,j,s.onFormChange);O!==E&&(E=O,q(O,{...j,data:O}))},A=(j,q,O)=>{var U;const z=t&&((U=ke(t,j))==null?void 0:U[q]);return!z||typeof z.$state!="string"?!1:(P({address:z.$state,nodeAddress:j,previousValue:ke(E,z.$state),value:O,data:E}),!0)};return{...R,onFormChange:P,onNodeCreateRequest:j=>{var z,U;const q=(z=j.sourceProperty)!=null&&z.startsWith("config:")?j.sourceProperty.slice(7):void 0,O=q!==void 0&&(x==null?void 0:x.slots.get(Dt(j.sourceNodeId,q)));return O?(O.present||P({data:E,nodeAddress:O.address.split(".").slice(0,-1).join("."),address:O.address,value:Vt(O.type),previousValue:void 0}),!0):((U=R.onNodeCreateRequest)==null?void 0:U.call(R,j))??!1},onNodeDelete:(j,q)=>{var Y,pe;if(!(x!=null&&x.nodes.some(se=>se.data.id===j)))return(Y=R.onNodeDelete)==null?void 0:Y.call(R,j,q);const O=x&&[...x.slots.values()].find(se=>se.nodeId===j);if(!O)return(pe=R.onNodeDelete)==null?void 0:pe.call(R,j,q);const z=O.address.split("."),U=z.pop(),ae=z.join("."),Q=ke(E,ae);P(Array.isArray(Q)?{data:E,nodeAddress:ae,address:ae,previousValue:Q,value:Q.filter((se,$)=>String($)!==U)}:{data:E,nodeAddress:ae,address:O.address,previousValue:ke(E,O.address),value:void 0})},onEdgeCreate:(j,q,O)=>{var ae,Q;const z=((ae=O==null?void 0:O.targetProperty)==null?void 0:ae.startsWith("config:"))&&(x==null?void 0:x.slots.get(Dt(q,O.targetProperty.slice(7)))),U=x==null?void 0:x.containers.get(j);if(z&&U&&(O==null?void 0:O.sourceProperty)==="output:resource"){const Y=I0(E,U,z);Y!==void 0&&P({data:E,nodeAddress:z.address.split(".").slice(0,-1).join("."),address:z.address,previousValue:ke(E,z.address),value:Y});return}z||x!=null&&x.nodes.some(Y=>Y.data.id===j||Y.data.id===q)||(Q=R.onEdgeCreate)==null||Q.call(R,j,q,O)},onEdgeDelete:(j,q)=>{var pe;const O=x==null?void 0:x.edges.find(se=>se.data.id===j);if(!O)return(pe=R.onEdgeDelete)==null?void 0:pe.call(R,j,q);const z=x.slots.get(Dt(O.data.target,O.data.targetProperty.slice(7))),U=z.address.split("."),ae=U.pop(),Q=U.join("."),Y=ke(E,Q);P(Array.isArray(Y)?{data:E,nodeAddress:Q,address:Q,previousValue:Y,value:Y.filter((se,$)=>String($)!==ae)}:{data:E,nodeAddress:Q,address:z.address,previousValue:ke(E,z.address),value:void 0})},onNodeContentChange:(j,q)=>{var O,z;A(j,"$content",q)?(O=s.onNodeContentChange)==null||O.call(s,j,q):(z=R.onNodeContentChange)==null||z.call(R,j,q)},onNodeLabelChange:(j,q)=>{var O,z;A(j,"$label",q)?(O=s.onNodeLabelChange)==null||O.call(s,j,q):(z=R.onNodeLabelChange)==null||z.call(R,j,q)}}},[R,r,t,s,x,o.readOnly,o.editable]);return f.jsx(Sr.Provider,{value:{data:(r==null?void 0:r.state)??t,viewData:t,bindings:S,references:r==null?void 0:r.references,structured:x,renderForm:r==null?void 0:r.renderForm,editable:r?!!(r.onStateChange??r.onChange):!!s.onJsonChange,schema:C,setSchema:E=>{var P;h(E),(P=s.onFormSchemaChange)==null||P.call(s,E)},callbacks:M},children:f.jsx(Vy,{config:x?{...o,formSchema:C}:o,callbacks:M,nodes:k,edges:I,children:f.jsxs(F.Box,{className:a,"data-flow-diagram":"",style:c,width:"100%",height:"100%",position:"relative",overflow:"hidden",css:{"& input, & textarea, & select":{outline:"none !important",boxShadow:"none !important"}},children:[f.jsx(lv,{nodes:k,edges:I}),u&&f.jsx(Vm,{}),l]})})})}function m_(e){return Wu(JSON.parse(e))}function Wu(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[i,o]of Object.entries(n)){if(["__proto__","prototype","constructor"].includes(i))throw new Error(`Unsafe document key: ${i}`);r(o)}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=Wu(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=Wu(t);return e.onStateChange(r,{address:"root",nodeAddress:"root",previousValue:e.state,value:r,data:r}),r}}}function v_(e,t){const r=(n,i)=>{if(n===null||typeof n!="object")return typeof n==typeof i?n:void 0;if(!(!i||typeof i!="object"))return Array.isArray(n)?Array.isArray(i)?n.map((o,s)=>r(o,i[s])).filter(o=>o!==void 0):void 0:Object.fromEntries(Object.entries(n).flatMap(([o,s])=>{if(!Object.prototype.hasOwnProperty.call(i,o))return[];if(o.startsWith("$")&&o!=="$")return JSON.stringify(s)===JSON.stringify(i[o])?[[o,s]]:[];const a=r(s,i[o]);return a===void 0?[]:[[o,a]]}))};return r(e,t)??{}}function kn(e){let t="",r=!1,n="",i;const o=()=>{clearTimeout(i),i=void 0},s=()=>{if(o(),!(r||!t.trim()))try{const c=e.parse(e.repair(t)),u=JSON.stringify(c);if(u===n)return;e.preview(c),n=u}catch{}},a=c=>{if(!r){if(new TextEncoder().encode(c).byteLength>(e.maxBytes??1024*1024))throw r=!0,o(),new Error("JSON stream exceeds the size limit.");t=c,i||(i=setTimeout(s,e.intervalMs??150))}};return{snapshot:a,append(c){a(t+c)},flush:s,finish(){if(r)throw new Error("JSON stream is closed.");r=!0,o();const c=e.parse(t);return e.commit(c),c},cancel(){r=!0,o(),t=""}}}function x_(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 i=kn(e),o=0,s=!1,a=!1,c;const u=Math.max(1,Math.ceil(t.length*r/n)),l=()=>e.onChange({position:o,total:t.length,playing:s}),d=()=>{clearTimeout(c),c=void 0},h=(m=!1)=>{i.snapshot(t.slice(0,o)),o===t.length?(s=!1,d(),i.finish()):m&&i.flush()},p=m=>{s=!1,d(),i.cancel(),l(),e.onError(m)},y=()=>{if(c=void 0,!(!s||a)){o=Math.min(t.length,o+u);try{h()}catch(m){p(m);return}l(),s&&(c=setTimeout(y,r))}};return{play(){a||s||(o===t.length&&(i.cancel(),i=kn(e),o=0),s=!0,l(),c=setTimeout(y,r))},pause(){a||(s=!1,d(),i.flush(),l())},seek(m){if(!a){if(!Number.isFinite(m))throw new Error("Playback position must be finite.");d(),o=Math.max(0,Math.min(t.length,Math.round(m))),i.cancel(),i=kn(e);try{h(!0)}catch(g){p(g);return}l(),s&&(c=setTimeout(y,r))}},dispose(){a=!0,s=!1,d(),i.cancel()}}}function w_({nodeAddress:e,expanded:t=!1}){var u;const{data:r,schema:n,bindings:i}=_.useContext(Sr),{colorText:o,background:s}=Ze();if((u=i==null?void 0:i[e])!=null&&u.portResources)return null;const a=i&&dn(i,e,n);if(!r||!a)return null;const c=ke(r,a.address);return!c||typeof c!="object"?null:f.jsx("div",{"data-flow-config-summary":"",style:{width:"100%",minWidth:0,color:ve(o),background:ve(s),fontSize:24,lineHeight:1.4,textTransform:"none"},children:Object.keys(a.type.properties).map(l=>{const d=a.fields[l]??{};if(!Fn(d.$visibleWhen,r))return null;const h=c[l],p=h==null?"":typeof h=="object"?JSON.stringify(h):String(h);return f.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:[f.jsx("span",{style:{overflowWrap:"anywhere"},children:Cr(d.$label??l)}),f.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=fm;exports.ConnectionsOnlyToggle=B0;exports.DEFAULT_PALETTE=Tn;exports.DiagramAppearanceControls=pm;exports.DynamicIcon=Or;exports.EdgeTools=Mm;exports.EditableLabel=Rt;exports.ErrorToast=zm;exports.FlowDiagram=g_;exports.FlowDiagramProvider=Vy;exports.FlowPort=tv;exports.FlowView=lv;exports.FormDocumentContext=Sr;exports.LIGHT_BLACK=Pt;exports.NODE_TYPE_VIEWS=nn;exports.NodeBorderRadiusControl=qm;exports.NodeConfigSummary=w_;exports.NodeForm=Pm;exports.NodeFormPopover=nv;exports.NodeIconPicker=tl;exports.NodeTools=$m;exports.NodeView=io;exports.SvgExportButton=Fm;exports.Swatches=ut;exports.TEXT_PALETTE=Im;exports.ToolbarCloseButton=At;exports.ToolbarCommitInput=ct;exports.ToolbarDivider=Ht;exports.ToolbarIconButton=Ce;exports.ToolbarRangeInput=hm;exports.ToolbarScrollContainer=Bm;exports.ToolbarSelect=br;exports.ToolbarTooltip=Oe;exports.TooltipIconButton=Vu;exports.WorkflowControls=nl;exports.addChild=Zu;exports.addConnection=Yu;exports.addTargetEdge=Cm;exports.addressToPath=kr;exports.applyCollapsed=j0;exports.applyFormChange=Bn;exports.applyStateEdits=R0;exports.bindSqueedCallbacks=Um;exports.compileSqueed=Lu;exports.connectionIssue=el;exports.contentObjTheme=Ir;exports.createFlowDiagram=st;exports.createFlowDocumentActions=b_;exports.createFormNode=Gm;exports.createJsonPlayback=x_;exports.createJsonStream=kn;exports.createWorkflowExecution=Tv;exports.downloadSvg=Lm;exports.exportSvg=Nm;exports.formValueError=Rr;exports.getChakraColorHex=ve;exports.getColorVariant=Fy;exports.getDarkerHexColor=Rn;exports.getInteractionSurface=Kr;exports.getNode=ke;exports.parseFlowDocument=m_;exports.parseJsonContract=Xu;exports.parseTypeScriptContract=_m;exports.parseTypeScriptForm=Qu;exports.projectJsonPlaybackPreview=v_;exports.readFormSchema=rl;exports.readWorkflowContract=Em;exports.removeEdge=Sm;exports.removeNode=wm;exports.resolveEdgeOwner=it;exports.resolveStateView=jm;exports.setCollapsed=vm;exports.setEdgeProp=Ur;exports.setEdgeStyle=xm;exports.setNodeProp=hr;exports.updateNode=xr;exports.useCustomColors=Ze;exports.useEdgeProximity=Ly;exports.useFlowData=Xr;exports.useFlowDiagramContext=Le;exports.useNodeViewActions=ao;exports.useStopPropagation=_l;exports.useThemeContentColors=ln;
|
|
280
281
|
//# sourceMappingURL=index.cjs.map
|