@squeed/flow-sdk 2.0.24 → 2.0.25
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/{contentPreviewDocument-B0nOMpw0.js → _virtual_content-preview-runtime-Deui59HN.cjs} +3 -961
- package/dist/_virtual_content-preview-runtime-Deui59HN.cjs.map +1 -0
- package/dist/{contentPreviewDocument-B_Jous_v.cjs → _virtual_content-preview-runtime-X_KtOyFO.js} +6 -11
- package/dist/_virtual_content-preview-runtime-X_KtOyFO.js.map +1 -0
- package/dist/contentPreviewDocument-BsKd0dD4.cjs +10 -0
- package/dist/{contentPreviewDocument-B_Jous_v.cjs.map → contentPreviewDocument-BsKd0dD4.cjs.map} +1 -1
- package/dist/contentPreviewDocument-C2D0H-Lr.js +962 -0
- package/dist/{contentPreviewDocument-B0nOMpw0.js.map → contentPreviewDocument-C2D0H-Lr.js.map} +1 -1
- package/dist/index.cjs +8 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +6580 -6535
- 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 tx=Object.create;var Mo=Object.defineProperty;var rx=Object.getOwnPropertyDescriptor;var nx=Object.getOwnPropertyNames;var ox=Object.getPrototypeOf,ix=Object.prototype.hasOwnProperty;var ax=(e,r,t)=>r in e?Mo(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var sx=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of nx(r))!ix.call(e,i)&&i!==t&&Mo(e,i,{get:()=>r[i],enumerable:!(n=rx(r,i))||n.enumerable});return e};var
|
|
1
|
+
"use strict";var tx=Object.create;var Mo=Object.defineProperty;var rx=Object.getOwnPropertyDescriptor;var nx=Object.getOwnPropertyNames;var ox=Object.getPrototypeOf,ix=Object.prototype.hasOwnProperty;var ax=(e,r,t)=>r in e?Mo(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var sx=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of nx(r))!ix.call(e,i)&&i!==t&&Mo(e,i,{get:()=>r[i],enumerable:!(n=rx(r,i))||n.enumerable});return e};var tt=(e,r,t)=>(t=e!=null?tx(ox(e)):{},sx(r||!e||!e.__esModule?Mo(t,"default",{value:e,enumerable:!0}):t,e));var Mt=(e,r,t)=>ax(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),W=require("@chakra-ui/react"),S=require("react"),Br=require("react-dom"),X=require("react-icons/pi"),gm=require("@emotion/react"),cx=require("@emotion/styled"),lx=require("react-icons/tb"),dx=require("markdown-to-jsx/react"),ym=e=>e&&e.__esModule?e:{default:e},Qn=ym(cx),ux=ym(dx);function fx(e,r){let t,n,i,o;const s=(l=t)=>!!l&&["completed","failed","cancelled"].includes(l.status),a=()=>{const l=o;o=void 0,l==null||l()},c=l=>{if(!n||n.signal.aborted||!t||l.executionId!==t.executionId||s())return;const{step:d,...u}=l;t={...t,...u,steps:d?{...t.steps,[d.id]:{...t.steps[d.id],...d}}:t.steps},n.state=t,s()&&a(),r(t)};return{getState:()=>t,async run(l,d=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 u={executionId:d,input:l,signal:i.signal,state:{executionId:d,status:"subscribing",steps:{}}};n=u,t=u.state,r(t);try{const h=await e.subscribe(u,y=>{n===u&&c(y)});if(n!==u||u.signal.aborted||s())return h(),u.state;if(o=h,c({executionId:d,status:"running"}),n!==u||u.signal.aborted||s(u.state))return u.state;const p=await e.execute(u);n===u&&p&&c(p)}catch(h){if(s(u.state))return u.state;throw n===u&&!u.signal.aborted&&c({executionId:d,status:"failed",error:h instanceof Error?h.message:String(h)}),h}return u.state},async cancel(){const l=n;if(!(!l||l.signal.aborted||s())){if(!e.cancel)throw new Error("This adapter does not support cancellation.");await e.cancel(l),n===l&&c({executionId:l.executionId,status:"cancelled"})}},dispose(){i==null||i.abort(),n=void 0,a()}}}function mm({edge:e,enabled:r,bounds:t,inside:n=[],threshold:i=80}){const[o,s]=S.useState(!1),[a,c]=S.useState(!1),l=S.useRef(n);return l.current=n,S.useEffect(()=>{if(!r)return;const d=()=>{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"))},u=new MutationObserver(d);return u.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["open","hidden","aria-hidden","data-state"]}),document.addEventListener("toggle",d,!0),d(),()=>{u.disconnect(),document.removeEventListener("toggle",d,!0)}},[r]),S.useEffect(()=>{const d=h=>{var v;const p=(v=t.current)==null?void 0:v.getBoundingClientRect();if(!p)return;const y=h.target instanceof Node?h.target:null,m=!!y&&l.current.some(x=>{var w;return(w=x.current)==null?void 0:w.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)},u=()=>s(!1);return document.addEventListener("pointermove",d,!0),document.addEventListener("pointerdown",d,!0),document.documentElement.addEventListener("pointerleave",u),()=>{document.removeEventListener("pointermove",d,!0),document.removeEventListener("pointerdown",d,!0),document.documentElement.removeEventListener("pointerleave",u)}},[e,t,i]),r&&(o||a)}const Hr="#c6c6c6";function Hn(e,r=.2){const t=e.replace(/^#/,""),n=parseInt(t,16);let i=n>>16&255,o=n>>8&255,s=n&255;return i=Math.max(0,Math.floor(i*(1-r))),o=Math.max(0,Math.floor(o*(1-r))),s=Math.max(0,Math.floor(s*(1-r))),"#"+((1<<24)+(i<<16)+(o<<8)+s).toString(16).slice(1).toUpperCase()}function hu(e,r,t){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(r);if(i===null||o===null)return null;const s=a=>Math.round((i>>a&255)*(1-t)+(o>>a&255)*t);return"#"+((1<<24)+(s(16)<<16)+(s(8)<<8)+s(0)).toString(16).slice(1).toUpperCase()}const Ut=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:Hn(e,.1),border:Hn(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"},bm=e=>{if(e==="transparent")return{primary:e,secondary:e,light:e};let r=e;if(r!=null&&r.startsWith("#"))return{secondary:Hn(e)};let t=String(Number(e.slice(-3))+200);t=e.slice(0,-3).concat(t);let n=String(Number(e.slice(-3))-100);return n=e.slice(0,-3).concat(n),{primary:r,secondary:t,light:n}},pu={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"}},_e=(e,r)=>{var o;if(e==="transparent"||e!=null&&e.startsWith("#")||e!=null&&e.startsWith("var(--"))return e;if(!e)return"whitesmoke";const t=e.replace(/\./g,"-");try{const a=getComputedStyle(document.documentElement).getPropertyValue(`--chakra-colors-${t}`).trim();if(a&&a!=="")return a}catch{}const[n,i]=e.split(".");return n&&i&&((o=pu[n])!=null&&o[Number(i)])?pu[n][Number(i)]:`var(--chakra-colors-${t})`},hx=gm.keyframes`
|
|
2
2
|
0%, 100% { box-shadow: var(--flow-rest-shadow); }
|
|
3
3
|
25%, 50% { box-shadow: var(--flow-hover-shadow); }
|
|
4
|
-
`,px=
|
|
4
|
+
`,px=gm.keyframes`
|
|
5
5
|
from { box-shadow: var(--flow-start-shadow); }
|
|
6
6
|
to { box-shadow: var(--flow-rest-shadow); }
|
|
7
|
-
`;function bm(e,r=!0,t="&:hover",n=!0){const i=`color-mix(in srgb, ${e} 60%, transparent)`,s=`0 0 0 ${r?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)":{[t]:{boxShadow:a,"@media (prefers-reduced-motion: no-preference)":{animation:n?`${hx} 1200ms steps(10, end) 600ms`:"none"}}}}}}function lr(e,r){const{boxShadow:t,css:n}=bm(e,!1),i=n["@media (hover: hover)"]["&:hover"];return{borderWidth:"1px",borderStyle:"solid",borderColor:"transparent",boxShadow:t,...n,"--flow-start-shadow":t,"@media (hover: hover)":{"&:hover":{...i,borderColor:r,"@media (prefers-reduced-motion: no-preference)":{animation:`${px} 600ms steps(5, end)`}}}}}const vm=j.createContext(null),xm=j.createContext({nodeById:new Map,edgeById:new Map,parentIds:new Set});function hr(){return j.useContext(xm)}function Ve(){const e=j.useContext(vm);if(!e)throw new Error("useFlowDiagramContext must be used within FlowDiagram");return e}function wm({config:e,callbacks:r,nodes:t=[],edges:n=[],children:i}){const o=j.useMemo(()=>{var be,Ge,Je;const H=new Map;for(const De of t)(be=De.data)!=null&&be.id&&H.set(De.data.id,De);const ge=new Map;for(const De of n)(Ge=De.data)!=null&&Ge.id&&ge.set(De.data.id,De);const Re=new Set;for(const De of t)(Je=De.data)!=null&&Je.parent&&Re.add(De.data.parent);return{nodeById:H,edgeById:ge,parentIds:Re}},[t,n]),s=j.useRef(null),[a,l]=j.useState([]),[c,d]=j.useState(null),[u,h]=j.useState(!0),[p,y]=j.useState(!1),[m,g]=j.useState(!0),[b,v]=j.useState(!1),[x,w]=j.useState(!1),[C,S]=j.useState(!0),[_,R]=j.useState(!1),[A,O]=j.useState(null),T=j.useRef(A),[E,M]=j.useState({gaps:15,fill:!1,padding:0}),[P,$]=j.useState(()=>new Set),N=j.useCallback(H=>{var ge;!!(H!=null&&H.fill)!=!!((ge=T.current)!=null&&ge.fill)&&$(new Set),T.current=H,H&&M(H),O(H)},[]),[I,K]=j.useState("auto"),[le,ie]=j.useState(!1),te=e.compactPropertyLayout??le,[fe,xe]=j.useState({}),q=e.nodeViewModes??fe,[W,U]=j.useState(e.allNodesIconLabel);j.useEffect(()=>U(e.allNodesIconLabel),[e.allNodesIconLabel]);const[z,de]=j.useState({}),Q=j.useCallback((H,ge)=>{de(Re=>{const be={...Re};for(const Ge of H)ge===void 0?delete be[Ge]:be[Ge]=ge;return be})},[]),ae=[...o.nodeById.values()].filter(H=>{var ge;return o.parentIds.has(H.data.id)||((ge=H.data.config)==null?void 0:ge.parentContainer)||H.data.type==="objectView"||H.data.type==="arrayView"||H.data.type==="grid"}),se=ae.every(H=>{var ge,Re,be;return o.parentIds.has(H.data.id)||(ge=H.data.config)!=null&&ge.parentContainer?!!((Re=H.data.config)!=null&&Re.collapsed):q[H.data.id]==="icon-label"||H.data.type==="grid"&&q[H.data.id]===void 0||((be=H.data.config)==null?void 0:be.labelBelow)&&q[H.data.id]!=="properties"}),Ce=W??e.allNodesIconLabel??se,[Se,he]=j.useState("normal"),[G,F]=j.useState(),re=e.edgeRadius??G,ce=re!==void 0&&Number.isFinite(re)?Math.min(500,Math.max(0,re)):void 0,[X,ye]=j.useState(),ve=e.spacing??Se,Oe=typeof ve=="number"?Number.isFinite(ve)?Math.min(2,Math.max(e.nodeGridSpacing==="layout"?0:.5,ve)):1:ve==="compact"?.5:ve==="spacious"?2:1,Ne=e.backgroundVariant??X??(e.backgroundPattern==="none"&&e.backgroundColor==="transparent"?"transparent":e.backgroundPattern??"dot"),[Be,et]=j.useState(),We=Object.prototype.hasOwnProperty.call(e,"workflowContract")?e.workflowContract:Be,[ft,Ke]=j.useState("blue.500"),[nt,Ie]=j.useState(!1),He=j.useRef(r);He.current=r;const tt=j.useMemo(()=>{const H=ge=>(...Re)=>{var be,Ge;return(Ge=(be=He.current)==null?void 0:be[ge])==null?void 0:Ge.call(be,...Re)};return{onNodeSelect:H("onNodeSelect"),onNodesCopy:H("onNodesCopy"),onNodesDuplicate:H("onNodesDuplicate"),onBackgroundClick:H("onBackgroundClick"),onBottomBarCollapsedChange:H("onBottomBarCollapsedChange"),onNodeGridZoomOut:H("onNodeGridZoomOut"),onNodeGridFillRequest:H("onNodeGridFillRequest"),onNodeGridModeRequest:H("onNodeGridModeRequest"),onNodeGridDrop:H("onNodeGridDrop"),onNodeParentChange:H("onNodeParentChange"),onNodeDeselect:H("onNodeDeselect"),onNodeDoubleClick:H("onNodeDoubleClick"),onNodeViewToggle:H("onNodeViewToggle"),onNodeTypeViewChange:H("onNodeTypeViewChange"),onNodeCreate:H("onNodeCreate"),onNodeCreateRequest:H("onNodeCreateRequest"),onNodeDelete:H("onNodeDelete"),onNodeLabelChange:H("onNodeLabelChange"),onNodeSubtitleChange:H("onNodeSubtitleChange"),onNodeContentChange:H("onNodeContentChange"),onNodeCollapse:H("onNodeCollapse"),onNodeColorChange:H("onNodeColorChange"),onNodeBorderColorChange:H("onNodeBorderColorChange"),onNodeBorderStyleChange:H("onNodeBorderStyleChange"),onNodeBorderWidthChange:H("onNodeBorderWidthChange"),onNodeBorderRadiusChange:(ge,Re)=>{var be,Ge,Je;(be=T.current)!=null&&be.fill&&$(De=>new Set([...De,ge])),(Je=(Ge=He.current).onNodeBorderRadiusChange)==null||Je.call(Ge,ge,Re)},onNodeIconChange:H("onNodeIconChange"),onNodeOutlineChange:H("onNodeOutlineChange"),onNodeAnimationChange:H("onNodeAnimationChange"),onNodeAnimationVariantChange:H("onNodeAnimationVariantChange"),onEdgeAnimationVariantChange:H("onEdgeAnimationVariantChange"),onNodeHoverAction:H("onNodeHoverAction"),onEdgeCreate:H("onEdgeCreate"),onEdgeSelect:H("onEdgeSelect"),onEdgeDeselect:H("onEdgeDeselect"),onEdgeRemove:H("onEdgeRemove"),onEdgeDelete:H("onEdgeDelete"),onEdgeColorChange:H("onEdgeColorChange"),onEdgeTypeChange:H("onEdgeTypeChange"),onEdgeIconChange:H("onEdgeIconChange"),onEdgeLabelChange:H("onEdgeLabelChange"),onEdgeStyleChange:H("onEdgeStyleChange"),onViewportChange:H("onViewportChange"),onDirectionChange:H("onDirectionChange"),onThemeColorChange:H("onThemeColorChange"),onSpacingChange:H("onSpacingChange"),onEdgeRadiusChange:H("onEdgeRadiusChange"),onBackgroundVariantChange:H("onBackgroundVariantChange"),onEdgeModeChange:H("onEdgeModeChange"),onCompactPropertyLayoutChange:H("onCompactPropertyLayoutChange"),onWorkflowContractChange:H("onWorkflowContractChange"),onWorkflowConfigurationOpen:r.onWorkflowConfigurationOpen?H("onWorkflowConfigurationOpen"):void 0,onArrayModeChange:H("onArrayModeChange"),onInit:H("onInit"),onLayoutComplete:H("onLayoutComplete"),onJsonChange:H("onJsonChange")}},[]),gt=e.themeColor||ft,[at,Et]=j.useState(""),Ye=e.edgeColor??at,Xe=e.colorMode||"light",Vt=e.direction||"LR",ct=e.nodeAlignment??"center",tr=e.edgeMode==="workflow"?"nodes":e.edgeMode??I,Wt=e.readOnly??!1,Ir=JSON.stringify(e.parentNodeStyle??null),Rt=j.useMemo(()=>e.parentNodeStyle,[Ir]),Gt=e.isZoomMode!==void 0?e.isZoomMode:u,Jt=e.isMultiSelectMode!==void 0?e.isMultiSelectMode:p,Mr=e.isEdgeHandlesEnabled!==void 0?e.isEdgeHandlesEnabled:b,gr=e.isDragMode!==void 0?e.isDragMode:m,J=j.useRef(e);J.current=e;const B=j.useMemo(()=>({get direction(){return J.current.direction},get nodeAlignment(){return J.current.nodeAlignment},get edgeMode(){return J.current.edgeMode},get compactPropertyLayout(){return J.current.compactPropertyLayout},get bottomBarCollapsed(){return J.current.bottomBarCollapsed},get bottomBarNavigation(){return J.current.bottomBarNavigation},get bottomBarFill(){return J.current.bottomBarFill},get nodeGridConnections(){return J.current.nodeGridConnections},get edgeType(){return J.current.edgeType},get edgeReveal(){return J.current.edgeReveal},get customEdgeTypes(){return J.current.customEdgeTypes},get themeColor(){return J.current.themeColor},get colorMode(){return J.current.colorMode},get readOnly(){return J.current.readOnly},get editable(){return J.current.editable},get minZoom(){return J.current.minZoom},get nodeGridSpacing(){return J.current.nodeGridSpacing},get maxZoom(){return J.current.maxZoom},get backgroundPattern(){return J.current.backgroundPattern},get edgeColor(){return J.current.edgeColor},get parentNodeStyle(){return J.current.parentNodeStyle},get backgroundColor(){return J.current.backgroundColor},get edgeHandles(){return J.current.edgeHandles},get initialViewport(){return J.current.initialViewport},get animateViewport(){return J.current.animateViewport},get disableAnimations(){return J.current.disableAnimations},get nodeOverlayActions(){return J.current.nodeOverlayActions},get renderNodeOverlay(){return J.current.renderNodeOverlay},get renderSelectedNodeToolbar(){return J.current.renderSelectedNodeToolbar},get renderSelectedEdgeToolbar(){return J.current.renderSelectedEdgeToolbar},get renderBottomBar(){return J.current.renderBottomBar},get bottomBarExtra(){return J.current.bottomBarExtra},get selectionToolbar(){return J.current.selectionToolbar},get customViews(){return J.current.customViews},get disableKeyboardShortcuts(){return J.current.disableKeyboardShortcuts},get isZoomMode(){return J.current.isZoomMode},get isMultiSelectMode(){return J.current.isMultiSelectMode},get isEdgeHandlesEnabled(){return J.current.isEdgeHandlesEnabled},get isDragMode(){return J.current.isDragMode}}),[]),ne=j.useCallback((H,ge)=>{var Re;if(ge!=="default"&&ge!=="properties"&&ge!=="icon-label")throw new Error("Unknown node view mode.");U(be=>be??Ce),xe(be=>be[H]===ge?be:{...be,[H]:ge}),(Re=r.onNodeViewModeChange)==null||Re.call(r,H,ge)},[r.onNodeViewModeChange,Ce]),Me=j.useMemo(()=>({allNodesIconLabel:Ce,setAllNodesIconLabel:H=>{var ge,Re,be,Ge,Je;if(U(H),!H)for(const[De,mt]of Object.entries(q))mt==="icon-label"&&!o.nodeById.has(De)&&ne(De,"default");for(const De of ae)o.parentIds.has(De.data.id)||(ge=De.data.config)!=null&&ge.parentContainer?!Wt&&!!((Re=De.data.config)!=null&&Re.collapsed)!==H&&((be=r.onNodeCollapse)==null||be.call(r,De.data.id,H)):ne(De.data.id,H?"icon-label":(Ge=De.data.config)!=null&&Ge.labelBelow?"properties":"default");(Je=r.onAllNodesIconLabelChange)==null||Je.call(r,H)},nodeViewModes:q,setNodeViewMode:ne,nodeRadiusPreviews:z,setNodeRadiusPreview:Q,spacing:Oe,setSpacing:he,edgeRadius:ce,setEdgeRadius:F,backgroundVariant:Ne,setBackgroundVariant:ye,themeColor:gt,setThemeColor:Ke,backgroundSelected:nt,setBackgroundSelected:Ie,edgeColor:Ye,setEdgeColor:H=>{var ge;Et(H),(ge=r.onGraphEdgeColorChange)==null||ge.call(r,H)},colorMode:Xe,direction:Vt,nodeAlignment:ct,edgeMode:tr,setEdgeMode:K,compactPropertyLayout:te,setCompactPropertyLayout:ie,workflowContract:We,setWorkflowContract:et,parentNodeStyle:Rt,selectedNodeIds:a,setSelectedNodeIds:l,selectedEdgeId:c,setSelectedEdgeId:d,isZoomMode:Gt,setIsZoomMode:h,isMultiSelectMode:Jt,setIsMultiSelectMode:y,isDragMode:gr,setIsDragMode:g,isEdgeHandlesEnabled:Mr,setIsEdgeHandlesEnabled:v,isArrayNodeMode:x,setIsArrayNodeMode:w,isPinned:C,setIsPinned:S,isPerformanceMode:_,setIsPerformanceMode:R,nodeGridOptions:A,setNodeGridOptions:N,lastNodeGridOptions:E,fillRadiusEditedIds:P,setFillRadiusEditedIds:$,engineRef:s,callbacks:tt,config:B,readOnly:Wt}),[Ce,o,ne,r.onNodeCollapse,r.onAllNodesIconLabelChange,r.onGraphEdgeColorChange,q,r.onNodeViewModeChange,z,Q,gt,Oe,Ne,ce,e.backgroundColor,nt,Ye,Xe,Vt,ct,tr,We,Rt,a,c,Gt,Jt,gr,Mr,x,C,_,A,E,P,Wt,e.edgeHandles,e.edgeType,e.edgeReveal,e.animateViewport,e.disableAnimations,e.customEdgeTypes,e.selectionToolbar,e.bottomBarExtra,e.bottomBarCollapsed,e.bottomBarNavigation,e.bottomBarFill,e.nodeGridSpacing,e.nodeGridConnections,e.compactPropertyLayout,te,tt,B]);return f.jsx(vm.Provider,{value:Me,children:f.jsx(xm.Provider,{value:o,children:i})})}function bt(e,r,t){return e?t:r}function An(e){const[r]=(e==null?void 0:e.split("."))||[],{secondary:t}=mm(e),n=Ut(r).background,i=Ut(r).highlight,o=Ut(r).border,s=Ut(r).property,a=Ut(r).property;let l=Ut(r).background,c=Ut(r).highlight;return l=e==="transparent"?e:_e(l)+50,c=e==="transparent"?e:_e(c)+20,{bgColor:n,highlightColor:i,borderColor:o,textColor:s,propertyColor:a,secondary:t,bgColorFaint:l,highlightColorFaint:c}}function it(e=null){const{colorMode:r}=Ve(),t=e==null?void 0:e.includes("gray"),n=r==="dark",i=bt(n,"white","gray.900"),o=bt(n,"gray.100","gray.800"),s=bt(n,"gray.200","blackAlpha.400"),a=bt(n,"gray.200","blackAlpha.600"),l=bt(n,"gray.500","gray.700"),c=bt(n,"gray.700","gray.700"),d=bt(n,"gray.900","gray.900"),u=bt(n,"gray.400","gray.500"),h=bt(n,"gray.400","gray.500"),p=bt(n,"gray.900","gray.200"),y=bt(n,t?"gray.900":"gray.200",t?"gray.200":"gray.900"),m=bt(n,"gray.900","gray.200"),g=bt(n,e&&"#000000",e||"#ffffff"),b=bt(n,e||"#ffffff",e?"#000000":"#ffffff"),v=c,x=bt(n,"gray.300","gray.800"),w=bt(n,"white","blackAlpha.400"),C=bt(n,"green.100","green.700");return{canvas:i,background:o,backgroundSecondary:s,darkBackgroundSecondary:a,border:l,darkColor:d,backgroundWhiteColor:w,borderSecondary:c,colorActive:u,colorInactive:h,iconColor:m,moreIconColor:v,colorText:p,themedColorText:y,logoColor:g,logoColorSecondary:b,darkColorActive:x,greenColor:C}}var an=(e=>(e.TOP_DOWN="TB",e.BOTTOM_UP="BT",e.LEFT_RIGHT="LR",e.RIGHT_LEFT="RL",e.CENTER="C",e))(an||{});const fd=["","icon-label","object","text","grid","parent"];var gx=typeof global=="object"&&global&&global.Object===Object&&global,yx=typeof self=="object"&&self&&self.Object===Object&&self,mx=gx||yx||Function("return this")(),Br=mx.Symbol,Cm=Object.prototype,bx=Cm.hasOwnProperty,vx=Cm.toString,nn=Br?Br.toStringTag:void 0;function xx(e){var r=bx.call(e,nn),t=e[nn];try{e[nn]=void 0;var n=!0}catch{}var i=vx.call(e);return n&&(r?e[nn]=t:delete e[nn]),i}var wx=Object.prototype,Cx=wx.toString;function Sx(e){return Cx.call(e)}var jx="[object Null]",_x="[object Undefined]",hu=Br?Br.toStringTag:void 0;function Ex(e){return e==null?e===void 0?_x:jx:hu&&hu in Object(e)?xx(e):Sx(e)}function Rx(e){return e!=null&&typeof e=="object"}var kx="[object Symbol]";function Ax(e){return typeof e=="symbol"||Rx(e)&&Ex(e)==kx}function Px(e,r){for(var t=-1,n=e==null?0:e.length,i=Array(n);++t<n;)i[t]=r(e[t],t,e);return i}var Qe=Array.isArray,pu=Br?Br.prototype:void 0,gu=pu?pu.toString:void 0;function Sm(e){if(typeof e=="string")return e;if(Qe(e))return Px(e,Sm)+"";if(Ax(e))return gu?gu.call(e):"";var r=e+"";return r=="0"&&1/e==-1/0?"-0":r}function hd(e){return e==null?"":Sm(e)}function Ix(e,r,t){var n=-1,i=e.length;r<0&&(r=-r>i?0:i+r),t=t>i?i:t,t<0&&(t+=i),i=r>t?0:t-r>>>0,r>>>=0;for(var o=Array(i);++n<i;)o[n]=e[n+r];return o}function Mx(e,r,t){var n=e.length;return t=t===void 0?n:t,!r&&t>=n?e:Ix(e,r,t)}var Tx="\\ud800-\\udfff",Ox="\\u0300-\\u036f",Nx="\\ufe20-\\ufe2f",$x="\\u20d0-\\u20ff",qx=Ox+Nx+$x,Lx="\\ufe0e\\ufe0f",Fx="\\u200d",zx=RegExp("["+Fx+Tx+qx+Lx+"]");function jm(e){return zx.test(e)}function Bx(e){return e.split("")}var _m="\\ud800-\\udfff",Dx="\\u0300-\\u036f",Vx="\\ufe20-\\ufe2f",Wx="\\u20d0-\\u20ff",Gx=Dx+Vx+Wx,Ux="\\ufe0e\\ufe0f",Hx="["+_m+"]",td="["+Gx+"]",rd="\\ud83c[\\udffb-\\udfff]",Kx="(?:"+td+"|"+rd+")",Em="[^"+_m+"]",Rm="(?:\\ud83c[\\udde6-\\uddff]){2}",km="[\\ud800-\\udbff][\\udc00-\\udfff]",Jx="\\u200d",Am=Kx+"?",Pm="["+Ux+"]?",Zx="(?:"+Jx+"(?:"+[Em,Rm,km].join("|")+")"+Pm+Am+")*",Xx=Pm+Am+Zx,Yx="(?:"+[Em+td+"?",td,Rm,km,Hx].join("|")+")",Qx=RegExp(rd+"(?="+rd+")|"+Yx+Xx,"g");function e0(e){return e.match(Qx)||[]}function t0(e){return jm(e)?e0(e):Bx(e)}function r0(e){return function(r){r=hd(r);var t=jm(r)?t0(r):void 0,n=t?t[0]:r.charAt(0),i=t?Mx(t,1).join(""):r.slice(1);return n[e]()+i}}var n0=r0("toUpperCase");function o0(e,r,t,n){for(var i=-1,o=e==null?0:e.length;++i<o;)t=r(t,e[i],i,e);return t}function i0(e){return function(r){return e==null?void 0:e[r]}}var a0={À:"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"},s0=i0(a0),c0=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,l0="\\u0300-\\u036f",d0="\\ufe20-\\ufe2f",u0="\\u20d0-\\u20ff",f0=l0+d0+u0,h0="["+f0+"]",p0=RegExp(h0,"g");function g0(e){return e=hd(e),e&&e.replace(c0,s0).replace(p0,"")}var y0=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function m0(e){return e.match(y0)||[]}var b0=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function v0(e){return b0.test(e)}var Im="\\ud800-\\udfff",x0="\\u0300-\\u036f",w0="\\ufe20-\\ufe2f",C0="\\u20d0-\\u20ff",S0=x0+w0+C0,Mm="\\u2700-\\u27bf",Tm="a-z\\xdf-\\xf6\\xf8-\\xff",j0="\\xac\\xb1\\xd7\\xf7",_0="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",E0="\\u2000-\\u206f",R0=" \\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",Om="A-Z\\xc0-\\xd6\\xd8-\\xde",k0="\\ufe0e\\ufe0f",Nm=j0+_0+E0+R0,$m="['’]",yu="["+Nm+"]",A0="["+S0+"]",qm="\\d+",P0="["+Mm+"]",Lm="["+Tm+"]",Fm="[^"+Im+Nm+qm+Mm+Tm+Om+"]",I0="\\ud83c[\\udffb-\\udfff]",M0="(?:"+A0+"|"+I0+")",T0="[^"+Im+"]",zm="(?:\\ud83c[\\udde6-\\uddff]){2}",Bm="[\\ud800-\\udbff][\\udc00-\\udfff]",Or="["+Om+"]",O0="\\u200d",mu="(?:"+Lm+"|"+Fm+")",N0="(?:"+Or+"|"+Fm+")",bu="(?:"+$m+"(?:d|ll|m|re|s|t|ve))?",vu="(?:"+$m+"(?:D|LL|M|RE|S|T|VE))?",Dm=M0+"?",Vm="["+k0+"]?",$0="(?:"+O0+"(?:"+[T0,zm,Bm].join("|")+")"+Vm+Dm+")*",q0="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",L0="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",F0=Vm+Dm+$0,z0="(?:"+[P0,zm,Bm].join("|")+")"+F0,B0=RegExp([Or+"?"+Lm+"+"+bu+"(?="+[yu,Or,"$"].join("|")+")",N0+"+"+vu+"(?="+[yu,Or+mu,"$"].join("|")+")",Or+"?"+mu+"+"+bu,Or+"+"+vu,L0,q0,qm,z0].join("|"),"g");function D0(e){return e.match(B0)||[]}function V0(e,r,t){return e=hd(e),r=r,r===void 0?v0(e)?D0(e):m0(e):e.match(r)||[]}var W0="['’]",G0=RegExp(W0,"g");function U0(e){return function(r){return o0(V0(g0(r).replace(G0,"")),e,"")}}var Nt=U0(function(e,r,t){return e+(t?" ":"")+n0(r)});function H0(){let e,r=null;const t=new Set,n=i=>{r=i,t.forEach(o=>o())};return{subscribe:i=>(t.add(i),()=>{t.delete(i)}),getSnapshot:()=>r,select(i,o){e=i,n(o)},update(i,o){e===i&&n(o)},remove(i){e===i&&(e=void 0,n(null))}}}const Dr=j.createContext(null),K0=()=>j.useState(H0)[0];function eo(e,r=!0){const t=j.useContext(Dr),n=j.useId();return j.useEffect(()=>{r?t==null||t.update(n,e):t==null||t.remove(n)}),j.useEffect(()=>()=>t==null?void 0:t.remove(n),[t,n]),()=>{r&&(t==null||t.select(n,e))}}function J0({divider:e,visibleActions:r=[]}){const t=j.useContext(Dr),n=j.useSyncExternalStore(t.subscribe,t.getSnapshot,()=>null),i=n&&r.includes(n.props["aria-label"]??"");return f.jsx(Dr.Provider,{value:null,children:f.jsxs("span",{"data-recent-toolbar-action":"",style:{display:n&&!i?"contents":"none"},children:[n&&!i&&e,!i&&n]})})}function Fe({label:e,children:r}){const t=j.cloneElement(r,{title:r.props.title??e});if(!D.Tooltip.Root){const n=D.Tooltip;return f.jsx(n,{label:e,placement:"top",fontSize:"xs",borderRadius:"15px",children:t})}return f.jsxs(D.Tooltip.Root,{positioning:{placement:"top"},children:[f.jsx(D.Tooltip.Trigger,{asChild:!0,children:t}),f.jsx(D.Portal,{children:f.jsx(D.Tooltip.Positioner,{children:f.jsx(D.Tooltip.Content,{fontSize:"xs",borderRadius:"15px",children:e})})})]})}function hn(){const{border:e}=it(),{colorMode:r}=Ve();return f.jsx(D.chakra.span,{role:"separator","aria-orientation":"vertical",display:"block",flexShrink:0,w:"1px",h:"20px",mx:"4px",bg:r==="dark"?e:"gray.300"})}function Pt({children:e,value:r,onValueChange:t,disabled:n,style:i,title:o,icon:s,popupContent:a,footer:l,labelCase:c="title","aria-label":d,...u}){var M;const{colorMode:h}=Ve(),{background:p,border:y,colorText:m,colorInactive:g}=it(),b=h==="dark",v=j.useId(),x=j.useRef(null),w=j.useRef(null),[C,S]=j.useState(!1),_=eo(f.jsx(Pt,{value:r,onValueChange:t,disabled:n,style:i,title:o,icon:s,popupContent:a,footer:l,labelCase:c,"aria-label":d,children:e}),!!s);j.useEffect(()=>{const P=w.current;P.setAttribute("popover","auto");const $=N=>S(N.newState==="open");return P.addEventListener("toggle",$),()=>P.removeEventListener("toggle",$)},[]);const R=j.Children.toArray(e).filter(j.isValidElement).map(P=>{const $=P.props;return{value:String($.value),label:typeof $.children=="string"&&c==="title"?Nt($.children):$.children,disabled:$.disabled}}),A=()=>{var P;return(P=w.current)==null?void 0:P.hidePopover()},O=()=>{var le,ie,te,fe,xe;const P=(le=x.current)==null?void 0:le.getBoundingClientRect(),$=w.current;if(!P||!$)return;if((ie=x.current)!=null&&ie.closest("[popover]")){const q=window.innerHeight-P.bottom-16,W=P.top-16;$.style.maxHeight=`${Math.max(60,q,W)}px`;const U=$.getBoundingClientRect();$.style.left=`${Math.max(12,Math.min(P.right-U.width,window.innerWidth-U.width-12))}px`,$.style.top=`${Math.max(12,U.height<=q?P.bottom+4:P.top-U.height-4)}px`;return}const N=(xe=(fe=(te=x.current)==null?void 0:te.closest("[data-flow-toolbar-scroll]"))==null?void 0:fe.parentElement)==null?void 0:xe.getBoundingClientRect(),I=N??P;$.style.maxHeight=`${Math.max(60,Math.max(I.top-40,window.innerHeight-I.bottom-40))}px`;const K=$.getBoundingClientRect();$.style.left=`${Math.max(12,Math.min(Math.max((N==null?void 0:N.left)??12,P.right-K.width),((N==null?void 0:N.right)??window.innerWidth-12)-K.width,window.innerWidth-K.width-12))}px`,$.style.top=`${Math.max(12,I.top>=K.height+36?I.top-K.height-24:Math.min(I.bottom+24,window.innerHeight-K.height-12))}px`},T=()=>{var N,I,K,le,ie,te;if(n)return;if((N=w.current)==null||N.showPopover(),O(),a){(K=(I=w.current)==null?void 0:I.querySelector("input"))==null||K.focus({preventScroll:!0});return}const P=(le=w.current)==null?void 0:le.querySelectorAll('[role="option"]:not(:disabled)');(te=((ie=w.current)==null?void 0:ie.querySelector('[aria-selected="true"]:not(:disabled)'))??(P==null?void 0:P[0]))==null||te.focus()};j.useEffect(()=>{if(C){if(n){A();return}return window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}}},[C,n]);const E=`var(--chakra-colors-${p.replace(".","-")})`;return f.jsxs(f.Fragment,{children:[f.jsx(Fe,{label:o??d,children:f.jsx(D.chakra.button,{...u,ref:x,type:"button",role:"combobox","data-flow-select-icon":s?"":void 0,"aria-label":d,title:o??d,"aria-haspopup":a?"dialog":"listbox","aria-expanded":C,"aria-controls":v,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:()=>{_(),C?A():T()},onKeyDown:P=>{["ArrowDown","ArrowUp"].includes(P.key)&&(P.preventDefault(),T())},children:s??f.jsxs(f.Fragment,{children:[f.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((M=R.find(P=>P.value===r))==null?void 0:M.label)??r}),f.jsx(Z.PiCaretUp,{size:16,style:{flexShrink:0}})]})})}),f.jsxs(D.chakra.div,{ref:w,id:v,role:a?"dialog":"listbox","aria-label":d,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"]':Kn,'& details [role="option"]:first-child':{borderTopLeftRadius:"4px",borderTopRightRadius:"4px"},...lr(E,`var(--chakra-colors-${(b?y:"gray.300").replace(".","-")})`)},onKeyDown:P=>{var I,K,le;if(a&&!["Escape","Tab"].includes(P.key))return;const $=[...P.currentTarget.querySelectorAll('[role="option"]:not(:disabled), [data-flow-menu-action]:not(:disabled)')],N=$.indexOf(document.activeElement);if(["ArrowDown","ArrowUp","Home","End"].includes(P.key)){P.preventDefault();const ie=P.key==="Home"?0:P.key==="End"?$.length-1:(N+(P.key==="ArrowDown"?1:-1)+$.length)%$.length;(I=$[ie])==null||I.focus()}else P.key==="Escape"||P.key==="Tab"?(P.key==="Escape"&&(P.preventDefault(),P.stopPropagation()),A(),(K=x.current)==null||K.focus()):P.key.length===1&&P.key!==" "&&((le=$.find((ie,te)=>{var fe;return te>N&&((fe=ie.textContent)==null?void 0:fe.toLowerCase().startsWith(P.key.toLowerCase()))}))==null||le.focus())},children:[a??R.map(P=>f.jsxs(D.chakra.button,{type:"button",role:"option","aria-selected":P.value===r,disabled:P.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 $;A(),($=x.current)==null||$.focus(),t(P.value)},children:[f.jsx("span",{style:{flex:1},children:P.label}),f.jsx(Z.PiCheck,{size:16,color:`var(--chakra-colors-${m.replace(".","-")})`,"aria-hidden":"true",style:{flexShrink:0,visibility:P.value===r?"visible":"hidden"}})]},P.value)),l]})]})}const Kn={borderRadius:"4px","&:first-child":{borderTopLeftRadius:"22px",borderTopRightRadius:"22px"},"&:last-child":{borderBottomLeftRadius:"22px",borderBottomRightRadius:"22px"}},Ae=j.forwardRef(function({icon:r,rememberAction:t=!0,...n},i){const{colorMode:o}=Ve(),s=Object.fromEntries(Object.entries(n).filter(([l])=>l!=="id"&&l!=="aria-describedby"&&!l.startsWith("data-")&&!/^on(Pointer|Mouse|Focus|Blur)/.test(l))),a=eo(f.jsx(Fe,{label:n.title??n["aria-label"]??"Last used action",children:f.jsx(Ae,{...s,icon:r})}),t&&!!n.onClick);return f.jsx(D.IconButton,{ref:i,_hover:{bg:o==="dark"?"whiteAlpha.100":"blackAlpha.50"},title:n.title??n["aria-label"],...n,onClick:l=>{var c;a(),(c=n.onClick)==null||c.call(n,l)},children:r})}),Hr=j.forwardRef(function(r,t){const{themeColor:n}=Ve();return f.jsx(Fe,{label:"Close",children:f.jsx(Ae,{ref:t,size:"sm",variant:"plain",bg:"transparent",_hover:{bg:"transparent",color:n},color:n,focusRingColor:n,...r,"aria-label":r["aria-label"]??"Close selection tools",icon:f.jsx(Z.PiXLight,{size:20,"aria-hidden":"true"})})})});function qr({label:e,icon:r,checked:t,onChange:n,disabled:i,hideLabel:o=!1,helper:s=e}){const{themeColor:a,readOnly:l}=Ve(),{colorInactive:c}=it();return f.jsx(Fe,{label:s,children:f.jsx(Ae,{"aria-label":e,"aria-pressed":t,icon:f.jsxs(f.Fragment,{children:[r,!o&&f.jsx(D.Text,{as:"span",fontSize:"16px",fontWeight:t?"bold":"normal",whiteSpace:"nowrap",children:e})]}),size:"sm",variant:"ghost",width:"auto",px:2,gap:2,color:t?a:c,disabled:i||l,onClick:()=>n(!t)})})}function Wm({label:e="Compact layout"}={}){const{compactPropertyLayout:r,setCompactPropertyLayout:t,callbacks:n}=Ve();return f.jsx(qr,{hideLabel:!0,label:e,checked:r,icon:f.jsx(D.Icon,{as:Z.PiArrowsIn,boxSize:5}),onChange:i=>{var o;t(i),(o=n.onCompactPropertyLayoutChange)==null||o.call(n,i)}})}const Z0=Qn.default.input`
|
|
7
|
+
`;function vm(e,r=!0,t="&:hover",n=!0){const i=`color-mix(in srgb, ${e} 60%, transparent)`,s=`0 0 0 ${r?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)":{[t]:{boxShadow:a,"@media (prefers-reduced-motion: no-preference)":{animation:n?`${hx} 1200ms steps(10, end) 600ms`:"none"}}}}}}function lr(e,r){const{boxShadow:t,css:n}=vm(e,!1),i=n["@media (hover: hover)"]["&:hover"];return{borderWidth:"1px",borderStyle:"solid",borderColor:"transparent",boxShadow:t,...n,"--flow-start-shadow":t,"@media (hover: hover)":{"&:hover":{...i,borderColor:r,"@media (prefers-reduced-motion: no-preference)":{animation:`${px} 600ms steps(5, end)`}}}}}const xm=S.createContext(null),wm=S.createContext({nodeById:new Map,edgeById:new Map,parentIds:new Set});function hr(){return S.useContext(wm)}function Ue(){const e=S.useContext(xm);if(!e)throw new Error("useFlowDiagramContext must be used within FlowDiagram");return e}function Cm({config:e,callbacks:r,nodes:t=[],edges:n=[],children:i}){const o=S.useMemo(()=>{var ve,Ke,Ze;const K=new Map;for(const Ge of t)(ve=Ge.data)!=null&&ve.id&&K.set(Ge.data.id,Ge);const ge=new Map;for(const Ge of n)(Ke=Ge.data)!=null&&Ke.id&&ge.set(Ge.data.id,Ge);const Re=new Set;for(const Ge of t)(Ze=Ge.data)!=null&&Ze.parent&&Re.add(Ge.data.parent);return{nodeById:K,edgeById:ge,parentIds:Re}},[t,n]),s=S.useRef(null),[a,c]=S.useState([]),[l,d]=S.useState(null),[u,h]=S.useState(!0),[p,y]=S.useState(!1),[m,g]=S.useState(!0),[b,v]=S.useState(!1),[x,w]=S.useState(!1),[C,j]=S.useState(!0),[_,k]=S.useState(!1),[E,O]=S.useState(null),T=S.useRef(E),[P,I]=S.useState({gaps:15,fill:!1,padding:0}),[R,$]=S.useState(()=>new Set),N=S.useCallback(K=>{var ge;!!(K!=null&&K.fill)!=!!((ge=T.current)!=null&&ge.fill)&&$(new Set),T.current=K,K&&I(K),O(K)},[]),[M,J]=S.useState("auto"),[ie,ae]=S.useState(!1),te=e.compactPropertyLayout??ie,[he,me]=S.useState({}),q=e.nodeViewModes??he,[F,U]=S.useState(e.allNodesIconLabel);S.useEffect(()=>U(e.allNodesIconLabel),[e.allNodesIconLabel]);const[D,de]=S.useState({}),Q=S.useCallback((K,ge)=>{de(Re=>{const ve={...Re};for(const Ke of K)ge===void 0?delete ve[Ke]:ve[Ke]=ge;return ve})},[]),oe=[...o.nodeById.values()].filter(K=>{var ge;return o.parentIds.has(K.data.id)||((ge=K.data.config)==null?void 0:ge.parentContainer)||K.data.type==="objectView"||K.data.type==="arrayView"||K.data.type==="grid"}),ce=oe.every(K=>{var ge,Re,ve;return o.parentIds.has(K.data.id)||(ge=K.data.config)!=null&&ge.parentContainer?!!((Re=K.data.config)!=null&&Re.collapsed):q[K.data.id]==="icon-label"||K.data.type==="grid"&&q[K.data.id]===void 0||((ve=K.data.config)==null?void 0:ve.labelBelow)&&q[K.data.id]!=="properties"}),we=F??e.allNodesIconLabel??ce,[Se,ye]=S.useState("normal"),[pe,B]=S.useState(),G=e.edgeRadius??pe,se=G!==void 0&&Number.isFinite(G)?Math.min(500,Math.max(0,G)):void 0,[H,ue]=S.useState(),xe=e.spacing??Se,Oe=typeof xe=="number"?Number.isFinite(xe)?Math.min(2,Math.max(e.nodeGridSpacing==="layout"?0:.5,xe)):1:xe==="compact"?.5:xe==="spacious"?2:1,Ne=e.backgroundVariant??H??(e.backgroundPattern==="none"&&e.backgroundColor==="transparent"?"transparent":e.backgroundPattern??"dot"),[Be,et]=S.useState(),We=Object.prototype.hasOwnProperty.call(e,"workflowContract")?e.workflowContract:Be,[gt,He]=S.useState("blue.500"),[rt,ft]=S.useState(!1),Pe=S.useRef(r);Pe.current=r;const Fe=S.useMemo(()=>{const K=ge=>(...Re)=>{var ve,Ke;return(Ke=(ve=Pe.current)==null?void 0:ve[ge])==null?void 0:Ke.call(ve,...Re)};return{onNodeSelect:K("onNodeSelect"),onNodesCopy:K("onNodesCopy"),onNodesDuplicate:K("onNodesDuplicate"),onBackgroundClick:K("onBackgroundClick"),onBottomBarCollapsedChange:K("onBottomBarCollapsedChange"),onNodeGridZoomOut:K("onNodeGridZoomOut"),onNodeGridFillRequest:K("onNodeGridFillRequest"),onNodeGridModeRequest:K("onNodeGridModeRequest"),onNodeGridDrop:K("onNodeGridDrop"),onNodeParentChange:K("onNodeParentChange"),onNodeDeselect:K("onNodeDeselect"),onNodeDoubleClick:K("onNodeDoubleClick"),onNodeViewToggle:K("onNodeViewToggle"),onNodeTypeViewChange:K("onNodeTypeViewChange"),onNodeCreate:K("onNodeCreate"),onNodeCreateRequest:K("onNodeCreateRequest"),onNodeDelete:K("onNodeDelete"),onNodeLabelChange:K("onNodeLabelChange"),onNodeSubtitleChange:K("onNodeSubtitleChange"),onNodeContentChange:K("onNodeContentChange"),onNodeCollapse:K("onNodeCollapse"),onNodeColorChange:K("onNodeColorChange"),onNodeBorderColorChange:K("onNodeBorderColorChange"),onNodeBorderStyleChange:K("onNodeBorderStyleChange"),onNodeBorderWidthChange:K("onNodeBorderWidthChange"),onNodeBorderRadiusChange:(ge,Re)=>{var ve,Ke,Ze;(ve=T.current)!=null&&ve.fill&&$(Ge=>new Set([...Ge,ge])),(Ze=(Ke=Pe.current).onNodeBorderRadiusChange)==null||Ze.call(Ke,ge,Re)},onNodeIconChange:K("onNodeIconChange"),onNodeOutlineChange:K("onNodeOutlineChange"),onNodeAnimationChange:K("onNodeAnimationChange"),onNodeAnimationVariantChange:K("onNodeAnimationVariantChange"),onEdgeAnimationVariantChange:K("onEdgeAnimationVariantChange"),onNodeHoverAction:K("onNodeHoverAction"),onEdgeCreate:K("onEdgeCreate"),onEdgeSelect:K("onEdgeSelect"),onEdgeDeselect:K("onEdgeDeselect"),onEdgeRemove:K("onEdgeRemove"),onEdgeDelete:K("onEdgeDelete"),onEdgeColorChange:K("onEdgeColorChange"),onEdgeTypeChange:K("onEdgeTypeChange"),onEdgeIconChange:K("onEdgeIconChange"),onEdgeLabelChange:K("onEdgeLabelChange"),onEdgeStyleChange:K("onEdgeStyleChange"),onViewportChange:K("onViewportChange"),onDirectionChange:K("onDirectionChange"),onThemeColorChange:K("onThemeColorChange"),onSpacingChange:K("onSpacingChange"),onEdgeRadiusChange:K("onEdgeRadiusChange"),onBackgroundVariantChange:K("onBackgroundVariantChange"),onEdgeModeChange:K("onEdgeModeChange"),onCompactPropertyLayoutChange:K("onCompactPropertyLayoutChange"),onWorkflowContractChange:K("onWorkflowContractChange"),onWorkflowConfigurationOpen:r.onWorkflowConfigurationOpen?K("onWorkflowConfigurationOpen"):void 0,onArrayModeChange:K("onArrayModeChange"),onInit:K("onInit"),onLayoutComplete:K("onLayoutComplete"),onJsonChange:K("onJsonChange")}},[]),it=e.themeColor||gt,[at,Lt]=S.useState(""),De=e.edgeColor??at,Ye=e.colorMode||"light",Vt=e.direction||"LR",ct=e.nodeAlignment??"center",tr=e.edgeMode==="workflow"?"nodes":e.edgeMode??M,Wt=e.readOnly??!1,Ir=JSON.stringify(e.parentNodeStyle??null),Et=S.useMemo(()=>e.parentNodeStyle,[Ir]),Gt=e.isZoomMode!==void 0?e.isZoomMode:u,Jt=e.isMultiSelectMode!==void 0?e.isMultiSelectMode:p,Mr=e.isEdgeHandlesEnabled!==void 0?e.isEdgeHandlesEnabled:b,gr=e.isDragMode!==void 0?e.isDragMode:m,Z=S.useRef(e);Z.current=e;const z=S.useMemo(()=>({get direction(){return Z.current.direction},get nodeAlignment(){return Z.current.nodeAlignment},get edgeMode(){return Z.current.edgeMode},get compactPropertyLayout(){return Z.current.compactPropertyLayout},get bottomBarCollapsed(){return Z.current.bottomBarCollapsed},get bottomBarNavigation(){return Z.current.bottomBarNavigation},get bottomBarFill(){return Z.current.bottomBarFill},get bottomBarCollision(){return Z.current.bottomBarCollision},get nodeGridConnections(){return Z.current.nodeGridConnections},get edgeType(){return Z.current.edgeType},get edgeReveal(){return Z.current.edgeReveal},get customEdgeTypes(){return Z.current.customEdgeTypes},get themeColor(){return Z.current.themeColor},get colorMode(){return Z.current.colorMode},get readOnly(){return Z.current.readOnly},get editable(){return Z.current.editable},get minZoom(){return Z.current.minZoom},get nodeGridSpacing(){return Z.current.nodeGridSpacing},get maxZoom(){return Z.current.maxZoom},get backgroundPattern(){return Z.current.backgroundPattern},get edgeColor(){return Z.current.edgeColor},get parentNodeStyle(){return Z.current.parentNodeStyle},get backgroundColor(){return Z.current.backgroundColor},get edgeHandles(){return Z.current.edgeHandles},get initialViewport(){return Z.current.initialViewport},get animateViewport(){return Z.current.animateViewport},get disableAnimations(){return Z.current.disableAnimations},get nodeOverlayActions(){return Z.current.nodeOverlayActions},get renderNodeOverlay(){return Z.current.renderNodeOverlay},get renderSelectedNodeToolbar(){return Z.current.renderSelectedNodeToolbar},get renderSelectedEdgeToolbar(){return Z.current.renderSelectedEdgeToolbar},get renderBottomBar(){return Z.current.renderBottomBar},get bottomBarExtra(){return Z.current.bottomBarExtra},get selectionToolbar(){return Z.current.selectionToolbar},get customViews(){return Z.current.customViews},get disableKeyboardShortcuts(){return Z.current.disableKeyboardShortcuts},get isZoomMode(){return Z.current.isZoomMode},get isMultiSelectMode(){return Z.current.isMultiSelectMode},get isEdgeHandlesEnabled(){return Z.current.isEdgeHandlesEnabled},get isDragMode(){return Z.current.isDragMode}}),[]),re=S.useCallback((K,ge)=>{var Re;if(ge!=="default"&&ge!=="properties"&&ge!=="icon-label")throw new Error("Unknown node view mode.");U(ve=>ve??we),me(ve=>ve[K]===ge?ve:{...ve,[K]:ge}),(Re=r.onNodeViewModeChange)==null||Re.call(r,K,ge)},[r.onNodeViewModeChange,we]),Me=S.useMemo(()=>({allNodesIconLabel:we,setAllNodesIconLabel:K=>{var ge,Re,ve,Ke,Ze;if(U(K),!K)for(const[Ge,mt]of Object.entries(q))mt==="icon-label"&&!o.nodeById.has(Ge)&&re(Ge,"default");for(const Ge of oe)o.parentIds.has(Ge.data.id)||(ge=Ge.data.config)!=null&&ge.parentContainer?!Wt&&!!((Re=Ge.data.config)!=null&&Re.collapsed)!==K&&((ve=r.onNodeCollapse)==null||ve.call(r,Ge.data.id,K)):re(Ge.data.id,K?"icon-label":(Ke=Ge.data.config)!=null&&Ke.labelBelow?"properties":"default");(Ze=r.onAllNodesIconLabelChange)==null||Ze.call(r,K)},nodeViewModes:q,setNodeViewMode:re,nodeRadiusPreviews:D,setNodeRadiusPreview:Q,spacing:Oe,setSpacing:ye,edgeRadius:se,setEdgeRadius:B,backgroundVariant:Ne,setBackgroundVariant:ue,themeColor:it,setThemeColor:He,backgroundSelected:rt,setBackgroundSelected:ft,edgeColor:De,setEdgeColor:K=>{var ge;Lt(K),(ge=r.onGraphEdgeColorChange)==null||ge.call(r,K)},colorMode:Ye,direction:Vt,nodeAlignment:ct,edgeMode:tr,setEdgeMode:J,compactPropertyLayout:te,setCompactPropertyLayout:ae,workflowContract:We,setWorkflowContract:et,parentNodeStyle:Et,selectedNodeIds:a,setSelectedNodeIds:c,selectedEdgeId:l,setSelectedEdgeId:d,isZoomMode:Gt,setIsZoomMode:h,isMultiSelectMode:Jt,setIsMultiSelectMode:y,isDragMode:gr,setIsDragMode:g,isEdgeHandlesEnabled:Mr,setIsEdgeHandlesEnabled:v,isArrayNodeMode:x,setIsArrayNodeMode:w,isPinned:C,setIsPinned:j,isPerformanceMode:_,setIsPerformanceMode:k,nodeGridOptions:E,setNodeGridOptions:N,lastNodeGridOptions:P,fillRadiusEditedIds:R,setFillRadiusEditedIds:$,engineRef:s,callbacks:Fe,config:z,readOnly:Wt}),[we,o,re,r.onNodeCollapse,r.onAllNodesIconLabelChange,r.onGraphEdgeColorChange,q,r.onNodeViewModeChange,D,Q,it,Oe,Ne,se,e.backgroundColor,rt,De,Ye,Vt,ct,tr,We,Et,a,l,Gt,Jt,gr,Mr,x,C,_,E,P,R,Wt,e.edgeHandles,e.edgeType,e.edgeReveal,e.animateViewport,e.disableAnimations,e.customEdgeTypes,e.selectionToolbar,e.bottomBarExtra,e.bottomBarCollapsed,e.bottomBarNavigation,e.bottomBarFill,e.bottomBarCollision,e.nodeGridSpacing,e.nodeGridConnections,e.compactPropertyLayout,te,Fe,z]);return f.jsx(xm.Provider,{value:Me,children:f.jsx(wm.Provider,{value:o,children:i})})}function bt(e,r,t){return e?t:r}function An(e){const[r]=(e==null?void 0:e.split("."))||[],{secondary:t}=bm(e),n=Ut(r).background,i=Ut(r).highlight,o=Ut(r).border,s=Ut(r).property,a=Ut(r).property;let c=Ut(r).background,l=Ut(r).highlight;return c=e==="transparent"?e:_e(c)+50,l=e==="transparent"?e:_e(l)+20,{bgColor:n,highlightColor:i,borderColor:o,textColor:s,propertyColor:a,secondary:t,bgColorFaint:c,highlightColorFaint:l}}function ot(e=null){const{colorMode:r}=Ue(),t=e==null?void 0:e.includes("gray"),n=r==="dark",i=bt(n,"white","gray.900"),o=bt(n,"gray.100","gray.800"),s=bt(n,"gray.200","blackAlpha.400"),a=bt(n,"gray.200","blackAlpha.600"),c=bt(n,"gray.500","gray.700"),l=bt(n,"gray.700","gray.700"),d=bt(n,"gray.900","gray.900"),u=bt(n,"gray.400","gray.500"),h=bt(n,"gray.400","gray.500"),p=bt(n,"gray.900","gray.200"),y=bt(n,t?"gray.900":"gray.200",t?"gray.200":"gray.900"),m=bt(n,"gray.900","gray.200"),g=bt(n,e&&"#000000",e||"#ffffff"),b=bt(n,e||"#ffffff",e?"#000000":"#ffffff"),v=l,x=bt(n,"gray.300","gray.800"),w=bt(n,"white","blackAlpha.400"),C=bt(n,"green.100","green.700");return{canvas:i,background:o,backgroundSecondary:s,darkBackgroundSecondary:a,border:c,darkColor:d,backgroundWhiteColor:w,borderSecondary:l,colorActive:u,colorInactive:h,iconColor:m,moreIconColor:v,colorText:p,themedColorText:y,logoColor:g,logoColorSecondary:b,darkColorActive:x,greenColor:C}}var sn=(e=>(e.TOP_DOWN="TB",e.BOTTOM_UP="BT",e.LEFT_RIGHT="LR",e.RIGHT_LEFT="RL",e.CENTER="C",e))(sn||{});const hd=["","icon-label","object","text","grid","parent"];var gx=typeof global=="object"&&global&&global.Object===Object&&global,yx=typeof self=="object"&&self&&self.Object===Object&&self,mx=gx||yx||Function("return this")(),Dr=mx.Symbol,Sm=Object.prototype,bx=Sm.hasOwnProperty,vx=Sm.toString,on=Dr?Dr.toStringTag:void 0;function xx(e){var r=bx.call(e,on),t=e[on];try{e[on]=void 0;var n=!0}catch{}var i=vx.call(e);return n&&(r?e[on]=t:delete e[on]),i}var wx=Object.prototype,Cx=wx.toString;function Sx(e){return Cx.call(e)}var jx="[object Null]",_x="[object Undefined]",gu=Dr?Dr.toStringTag:void 0;function Ex(e){return e==null?e===void 0?_x:jx:gu&&gu in Object(e)?xx(e):Sx(e)}function Rx(e){return e!=null&&typeof e=="object"}var kx="[object Symbol]";function Ax(e){return typeof e=="symbol"||Rx(e)&&Ex(e)==kx}function Px(e,r){for(var t=-1,n=e==null?0:e.length,i=Array(n);++t<n;)i[t]=r(e[t],t,e);return i}var Qe=Array.isArray,yu=Dr?Dr.prototype:void 0,mu=yu?yu.toString:void 0;function jm(e){if(typeof e=="string")return e;if(Qe(e))return Px(e,jm)+"";if(Ax(e))return mu?mu.call(e):"";var r=e+"";return r=="0"&&1/e==-1/0?"-0":r}function pd(e){return e==null?"":jm(e)}function Ix(e,r,t){var n=-1,i=e.length;r<0&&(r=-r>i?0:i+r),t=t>i?i:t,t<0&&(t+=i),i=r>t?0:t-r>>>0,r>>>=0;for(var o=Array(i);++n<i;)o[n]=e[n+r];return o}function Mx(e,r,t){var n=e.length;return t=t===void 0?n:t,!r&&t>=n?e:Ix(e,r,t)}var Tx="\\ud800-\\udfff",Ox="\\u0300-\\u036f",Nx="\\ufe20-\\ufe2f",$x="\\u20d0-\\u20ff",qx=Ox+Nx+$x,Lx="\\ufe0e\\ufe0f",Fx="\\u200d",zx=RegExp("["+Fx+Tx+qx+Lx+"]");function _m(e){return zx.test(e)}function Bx(e){return e.split("")}var Em="\\ud800-\\udfff",Dx="\\u0300-\\u036f",Vx="\\ufe20-\\ufe2f",Wx="\\u20d0-\\u20ff",Gx=Dx+Vx+Wx,Ux="\\ufe0e\\ufe0f",Hx="["+Em+"]",rd="["+Gx+"]",nd="\\ud83c[\\udffb-\\udfff]",Kx="(?:"+rd+"|"+nd+")",Rm="[^"+Em+"]",km="(?:\\ud83c[\\udde6-\\uddff]){2}",Am="[\\ud800-\\udbff][\\udc00-\\udfff]",Jx="\\u200d",Pm=Kx+"?",Im="["+Ux+"]?",Zx="(?:"+Jx+"(?:"+[Rm,km,Am].join("|")+")"+Im+Pm+")*",Xx=Im+Pm+Zx,Yx="(?:"+[Rm+rd+"?",rd,km,Am,Hx].join("|")+")",Qx=RegExp(nd+"(?="+nd+")|"+Yx+Xx,"g");function e0(e){return e.match(Qx)||[]}function t0(e){return _m(e)?e0(e):Bx(e)}function r0(e){return function(r){r=pd(r);var t=_m(r)?t0(r):void 0,n=t?t[0]:r.charAt(0),i=t?Mx(t,1).join(""):r.slice(1);return n[e]()+i}}var n0=r0("toUpperCase");function o0(e,r,t,n){for(var i=-1,o=e==null?0:e.length;++i<o;)t=r(t,e[i],i,e);return t}function i0(e){return function(r){return e==null?void 0:e[r]}}var a0={À:"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"},s0=i0(a0),c0=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,l0="\\u0300-\\u036f",d0="\\ufe20-\\ufe2f",u0="\\u20d0-\\u20ff",f0=l0+d0+u0,h0="["+f0+"]",p0=RegExp(h0,"g");function g0(e){return e=pd(e),e&&e.replace(c0,s0).replace(p0,"")}var y0=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function m0(e){return e.match(y0)||[]}var b0=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function v0(e){return b0.test(e)}var Mm="\\ud800-\\udfff",x0="\\u0300-\\u036f",w0="\\ufe20-\\ufe2f",C0="\\u20d0-\\u20ff",S0=x0+w0+C0,Tm="\\u2700-\\u27bf",Om="a-z\\xdf-\\xf6\\xf8-\\xff",j0="\\xac\\xb1\\xd7\\xf7",_0="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",E0="\\u2000-\\u206f",R0=" \\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",Nm="A-Z\\xc0-\\xd6\\xd8-\\xde",k0="\\ufe0e\\ufe0f",$m=j0+_0+E0+R0,qm="['’]",bu="["+$m+"]",A0="["+S0+"]",Lm="\\d+",P0="["+Tm+"]",Fm="["+Om+"]",zm="[^"+Mm+$m+Lm+Tm+Om+Nm+"]",I0="\\ud83c[\\udffb-\\udfff]",M0="(?:"+A0+"|"+I0+")",T0="[^"+Mm+"]",Bm="(?:\\ud83c[\\udde6-\\uddff]){2}",Dm="[\\ud800-\\udbff][\\udc00-\\udfff]",Or="["+Nm+"]",O0="\\u200d",vu="(?:"+Fm+"|"+zm+")",N0="(?:"+Or+"|"+zm+")",xu="(?:"+qm+"(?:d|ll|m|re|s|t|ve))?",wu="(?:"+qm+"(?:D|LL|M|RE|S|T|VE))?",Vm=M0+"?",Wm="["+k0+"]?",$0="(?:"+O0+"(?:"+[T0,Bm,Dm].join("|")+")"+Wm+Vm+")*",q0="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",L0="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",F0=Wm+Vm+$0,z0="(?:"+[P0,Bm,Dm].join("|")+")"+F0,B0=RegExp([Or+"?"+Fm+"+"+xu+"(?="+[bu,Or,"$"].join("|")+")",N0+"+"+wu+"(?="+[bu,Or+vu,"$"].join("|")+")",Or+"?"+vu+"+"+xu,Or+"+"+wu,L0,q0,Lm,z0].join("|"),"g");function D0(e){return e.match(B0)||[]}function V0(e,r,t){return e=pd(e),r=r,r===void 0?v0(e)?D0(e):m0(e):e.match(r)||[]}var W0="['’]",G0=RegExp(W0,"g");function U0(e){return function(r){return o0(V0(g0(r).replace(G0,"")),e,"")}}var Ot=U0(function(e,r,t){return e+(t?" ":"")+n0(r)});function H0(){let e,r=null;const t=new Set,n=i=>{r=i,t.forEach(o=>o())};return{subscribe:i=>(t.add(i),()=>{t.delete(i)}),getSnapshot:()=>r,select(i,o){e=i,n(o)},update(i,o){e===i&&n(o)},remove(i){e===i&&(e=void 0,n(null))}}}const Vr=S.createContext(null),K0=()=>S.useState(H0)[0];function eo(e,r=!0){const t=S.useContext(Vr),n=S.useId();return S.useEffect(()=>{r?t==null||t.update(n,e):t==null||t.remove(n)}),S.useEffect(()=>()=>t==null?void 0:t.remove(n),[t,n]),()=>{r&&(t==null||t.select(n,e))}}function J0({divider:e,visibleActions:r=[]}){const t=S.useContext(Vr),n=S.useSyncExternalStore(t.subscribe,t.getSnapshot,()=>null),i=n&&r.includes(n.props["aria-label"]??"");return f.jsx(Vr.Provider,{value:null,children:f.jsxs("span",{"data-recent-toolbar-action":"",style:{display:n&&!i?"contents":"none"},children:[n&&!i&&e,!i&&n]})})}function ze({label:e,children:r}){const t=S.cloneElement(r,{title:r.props.title??e});if(!W.Tooltip.Root){const n=W.Tooltip;return f.jsx(n,{label:e,placement:"top",fontSize:"xs",borderRadius:"15px",children:t})}return f.jsxs(W.Tooltip.Root,{positioning:{placement:"top"},children:[f.jsx(W.Tooltip.Trigger,{asChild:!0,children:t}),f.jsx(W.Portal,{children:f.jsx(W.Tooltip.Positioner,{children:f.jsx(W.Tooltip.Content,{fontSize:"xs",borderRadius:"15px",children:e})})})]})}function pn(){const{border:e}=ot(),{colorMode:r}=Ue();return f.jsx(W.chakra.span,{role:"separator","aria-orientation":"vertical",display:"block",flexShrink:0,w:"1px",h:"20px",mx:"4px",bg:r==="dark"?e:"gray.300"})}function At({children:e,value:r,onValueChange:t,disabled:n,style:i,title:o,icon:s,popupContent:a,footer:c,labelCase:l="title","aria-label":d,...u}){var I;const{colorMode:h}=Ue(),{background:p,border:y,colorText:m,colorInactive:g}=ot(),b=h==="dark",v=S.useId(),x=S.useRef(null),w=S.useRef(null),[C,j]=S.useState(!1),_=eo(f.jsx(At,{value:r,onValueChange:t,disabled:n,style:i,title:o,icon:s,popupContent:a,footer:c,labelCase:l,"aria-label":d,children:e}),!!s);S.useEffect(()=>{const R=w.current;R.setAttribute("popover","auto");const $=N=>j(N.newState==="open");return R.addEventListener("toggle",$),()=>R.removeEventListener("toggle",$)},[]);const k=S.Children.toArray(e).filter(S.isValidElement).map(R=>{const $=R.props;return{value:String($.value),label:typeof $.children=="string"&&l==="title"?Ot($.children):$.children,disabled:$.disabled}}),E=()=>{var R;return(R=w.current)==null?void 0:R.hidePopover()},O=()=>{var ie,ae,te,he,me;const R=(ie=x.current)==null?void 0:ie.getBoundingClientRect(),$=w.current;if(!R||!$)return;if((ae=x.current)!=null&&ae.closest("[popover]")){const q=window.innerHeight-R.bottom-16,F=R.top-16;$.style.maxHeight=`${Math.max(60,q,F)}px`;const U=$.getBoundingClientRect();$.style.left=`${Math.max(12,Math.min(R.right-U.width,window.innerWidth-U.width-12))}px`,$.style.top=`${Math.max(12,U.height<=q?R.bottom+4:R.top-U.height-4)}px`;return}const N=(me=(he=(te=x.current)==null?void 0:te.closest("[data-flow-toolbar-scroll]"))==null?void 0:he.parentElement)==null?void 0:me.getBoundingClientRect(),M=N??R;$.style.maxHeight=`${Math.max(60,Math.max(M.top-40,window.innerHeight-M.bottom-40))}px`;const J=$.getBoundingClientRect();$.style.left=`${Math.max(12,Math.min(Math.max((N==null?void 0:N.left)??12,R.right-J.width),((N==null?void 0:N.right)??window.innerWidth-12)-J.width,window.innerWidth-J.width-12))}px`,$.style.top=`${Math.max(12,M.top>=J.height+36?M.top-J.height-24:Math.min(M.bottom+24,window.innerHeight-J.height-12))}px`},T=()=>{var N,M,J,ie,ae,te;if(n)return;if((N=w.current)==null||N.showPopover(),O(),a){(J=(M=w.current)==null?void 0:M.querySelector("input"))==null||J.focus({preventScroll:!0});return}const R=(ie=w.current)==null?void 0:ie.querySelectorAll('[role="option"]:not(:disabled)');(te=((ae=w.current)==null?void 0:ae.querySelector('[aria-selected="true"]:not(:disabled)'))??(R==null?void 0:R[0]))==null||te.focus()};S.useEffect(()=>{if(C){if(n){E();return}return window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}}},[C,n]);const P=`var(--chakra-colors-${p.replace(".","-")})`;return f.jsxs(f.Fragment,{children:[f.jsx(ze,{label:o??d,children:f.jsx(W.chakra.button,{...u,ref:x,type:"button",role:"combobox","data-flow-select-icon":s?"":void 0,"aria-label":d,title:o??d,"aria-haspopup":a?"dialog":"listbox","aria-expanded":C,"aria-controls":v,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:()=>{_(),C?E():T()},onKeyDown:R=>{["ArrowDown","ArrowUp"].includes(R.key)&&(R.preventDefault(),T())},children:s??f.jsxs(f.Fragment,{children:[f.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((I=k.find(R=>R.value===r))==null?void 0:I.label)??r}),f.jsx(X.PiCaretUp,{size:16,style:{flexShrink:0}})]})})}),f.jsxs(W.chakra.div,{ref:w,id:v,role:a?"dialog":"listbox","aria-label":d,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"]':Kn,'& details [role="option"]:first-child':{borderTopLeftRadius:"4px",borderTopRightRadius:"4px"},...lr(P,`var(--chakra-colors-${(b?y:"gray.300").replace(".","-")})`)},onKeyDown:R=>{var M,J,ie;if(a&&!["Escape","Tab"].includes(R.key))return;const $=[...R.currentTarget.querySelectorAll('[role="option"]:not(:disabled), [data-flow-menu-action]:not(:disabled)')],N=$.indexOf(document.activeElement);if(["ArrowDown","ArrowUp","Home","End"].includes(R.key)){R.preventDefault();const ae=R.key==="Home"?0:R.key==="End"?$.length-1:(N+(R.key==="ArrowDown"?1:-1)+$.length)%$.length;(M=$[ae])==null||M.focus()}else R.key==="Escape"||R.key==="Tab"?(R.key==="Escape"&&(R.preventDefault(),R.stopPropagation()),E(),(J=x.current)==null||J.focus()):R.key.length===1&&R.key!==" "&&((ie=$.find((ae,te)=>{var he;return te>N&&((he=ae.textContent)==null?void 0:he.toLowerCase().startsWith(R.key.toLowerCase()))}))==null||ie.focus())},children:[a??k.map(R=>f.jsxs(W.chakra.button,{type:"button",role:"option","aria-selected":R.value===r,disabled:R.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 $;E(),($=x.current)==null||$.focus(),t(R.value)},children:[f.jsx("span",{style:{flex:1},children:R.label}),f.jsx(X.PiCheck,{size:16,color:`var(--chakra-colors-${m.replace(".","-")})`,"aria-hidden":"true",style:{flexShrink:0,visibility:R.value===r?"visible":"hidden"}})]},R.value)),c]})]})}const Kn={borderRadius:"4px","&:first-child":{borderTopLeftRadius:"22px",borderTopRightRadius:"22px"},"&:last-child":{borderBottomLeftRadius:"22px",borderBottomRightRadius:"22px"}},Ae=S.forwardRef(function({icon:r,rememberAction:t=!0,...n},i){const{colorMode:o}=Ue(),s=Object.fromEntries(Object.entries(n).filter(([c])=>c!=="id"&&c!=="aria-describedby"&&!c.startsWith("data-")&&!/^on(Pointer|Mouse|Focus|Blur)/.test(c))),a=eo(f.jsx(ze,{label:n.title??n["aria-label"]??"Last used action",children:f.jsx(Ae,{...s,icon:r})}),t&&!!n.onClick);return f.jsx(W.IconButton,{ref:i,_hover:{bg:o==="dark"?"whiteAlpha.100":"blackAlpha.50"},title:n.title??n["aria-label"],...n,onClick:c=>{var l;a(),(l=n.onClick)==null||l.call(n,c)},children:r})}),Kr=S.forwardRef(function(r,t){const{themeColor:n}=Ue();return f.jsx(ze,{label:"Close",children:f.jsx(Ae,{ref:t,size:"sm",variant:"plain",bg:"transparent",_hover:{bg:"transparent",color:n},color:n,focusRingColor:n,...r,"aria-label":r["aria-label"]??"Close selection tools",icon:f.jsx(X.PiXLight,{size:20,"aria-hidden":"true"})})})});function qr({label:e,icon:r,checked:t,onChange:n,disabled:i,hideLabel:o=!1,helper:s=e}){const{themeColor:a,readOnly:c}=Ue(),{colorInactive:l}=ot();return f.jsx(ze,{label:s,children:f.jsx(Ae,{"aria-label":e,"aria-pressed":t,icon:f.jsxs(f.Fragment,{children:[r,!o&&f.jsx(W.Text,{as:"span",fontSize:"16px",fontWeight:t?"bold":"normal",whiteSpace:"nowrap",children:e})]}),size:"sm",variant:"ghost",width:"auto",px:2,gap:2,color:t?a:l,disabled:i||c,onClick:()=>n(!t)})})}function Gm({label:e="Compact layout"}={}){const{compactPropertyLayout:r,setCompactPropertyLayout:t,callbacks:n}=Ue();return f.jsx(qr,{hideLabel:!0,label:e,checked:r,icon:f.jsx(W.Icon,{as:X.PiArrowsIn,boxSize:5}),onChange:i=>{var o;t(i),(o=n.onCompactPropertyLayoutChange)==null||o.call(n,i)}})}const Z0=Qn.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
|
-
`,pd=j.forwardRef(function({style:r,...t},n){return f.jsx(Z0,{...t,ref:n,style:{...r,backgroundImage:"none","--flow-range-track":(r==null?void 0:r.backgroundImage)??"none"}})});function nd({label:e,inputLabel:r,value:t,displayValue:n,min:i,max:o,step:s=5,onChange:a,onChangeEnd:l}){const c=j.useId(),{readOnly:d,themeColor:u}=Ve(),{colorInactive:h}=it(),p=(t-i)/(o-i)*100,y=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:c,style:{display:"flex",justifyContent:"space-between",fontSize:14,marginBottom:12},children:[e," ",f.jsx("span",{children:n})]}),f.jsx(pd,{id:c,"aria-label":r,type:"range",min:i,max:o,step:s,value:t,disabled:d,style:{color:y,accentColor:y,backgroundImage:`linear-gradient(to right, currentColor ${p}%, var(--chakra-colors-${h.replace(".","-")}) ${p}%)`},onChange:m=>a(Number(m.target.value)),onPointerUp:l,onKeyUp:l,onBlur:l})]})}const xu={dot:{label:"Dots",icon:Z.PiDotsNine},grid:{label:"Grid",icon:Z.PiGridFour},steel:{label:"Steel",icon:Z.PiLineSegments},none:{label:"Solid",icon:Z.PiSquareFill},transparent:{label:"Transparent",icon:Z.PiSelection}};function Gm(){const{spacing:e,setSpacing:r,edgeRadius:t,setEdgeRadius:n,backgroundVariant:i,setBackgroundVariant:o,callbacks:s,readOnly:a,config:l}=Ve(),c=xu[i].icon;return f.jsxs(f.Fragment,{children:[f.jsx(hn,{}),f.jsx(Pt,{"aria-label":"Node spacing",title:`Spacing: ${Math.round(e*100)}%`,icon:f.jsx(Z.PiArrowsOutCardinal,{size:20}),style:{width:36},value:"spacing",disabled:a,onValueChange:()=>{},popupContent:f.jsx(nd,{label:"Spacing",inputLabel:"Node spacing percentage",min:l.nodeGridSpacing==="layout"?0:50,max:200,value:Math.round(e*100),displayValue:`${Math.round(e*100)}%`,onChange:d=>{var u;r(d/100),(u=s.onSpacingChange)==null||u.call(s,d/100)}}),children:f.jsx("option",{value:"spacing",children:"Spacing"})}),f.jsx(hn,{}),f.jsx(Pt,{"aria-label":"Edge radius",title:`Edge radius: ${t??"Default"}`,icon:f.jsx(Z.PiBezierCurve,{size:20}),style:{width:36},value:"radius",disabled:a,onValueChange:()=>{},popupContent:f.jsx(nd,{label:"Edge radius",inputLabel:"Edge corner radius",min:0,max:500,value:t??500,displayValue:t??"Default",onChange:d=>{var u;n(d),(u=s.onEdgeRadiusChange)==null||u.call(s,d)}}),children:f.jsx("option",{value:"radius",children:"Edge radius"})}),f.jsx(hn,{}),f.jsxs(Pt,{"aria-label":"Background variant",title:`Background: ${xu[i].label}`,icon:f.jsx(c,{size:20,"data-background-icon":i}),style:{width:36},value:i,disabled:a,onValueChange:d=>{var u;o(d),(u=s.onBackgroundVariantChange)==null||u.call(s,d)},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"})]})]})}function wu(){var p;const{engineRef:e,nodeGridOptions:r,lastNodeGridOptions:t,readOnly:n,themeColor:i,callbacks:o,config:s}=Ve(),{colorText:a,colorInactive:l}=it(),c=r??t,d=typeof c.gaps=="object"?c.gaps.x:c.gaps??c.margin??15,u=Math.max(200,d),h=y=>{var m;return(m=e.current)==null?void 0:m.setNodeGridMode(!0,{...c,...y})};return f.jsxs(f.Fragment,{children:[f.jsx(qr,{label:"Collision mode",hideLabel:!0,icon:f.jsx(Z.PiGridFour,{size:20}),checked:r!==null,onChange:y=>{var m,g;((m=o.onNodeGridModeRequest)==null?void 0:m.call(o,y,c))!==!0&&((g=e.current)==null||g.setNodeGridMode(y,c))}}),r&&f.jsxs(D.HStack,{role:"group","aria-label":"Collision settings",gap:2,flexShrink:0,children:[r&&s.nodeGridSpacing!=="layout"&&f.jsxs(f.Fragment,{children:[f.jsx(D.Box,{width:"96px",flexShrink:0,display:"flex",alignItems:"center",children:f.jsx(pd,{type:"range","aria-label":"Collision gap",title:`Gap: ${d}`,min:0,max:u,step:5,value:d,disabled:n,style:{color:_e(i),backgroundImage:`linear-gradient(to right, currentColor ${d/u*100}%, ${_e(l)} ${d/u*100}%)`},onChange:y=>h({gaps:Number(y.target.value)})})}),f.jsx(D.Text,{fontSize:"xs",color:a,width:"28px",textAlign:"right",fontVariantNumeric:"tabular-nums",children:d})]}),s.bottomBarFill!==!1&&f.jsx(qr,{label:"Fill",hideLabel:!0,helper:"Fill available canvas space",icon:f.jsx(Z.PiArrowsOut,{size:18}),checked:!!r&&!!c.fill,onChange:y=>{var m,g;!r&&((m=o.onNodeGridModeRequest)==null?void 0:m.call(o,!0,{...c,fill:y}))===!0||y&&((g=o.onNodeGridFillRequest)==null?void 0:g.call(o,{...c,fill:y}))===!0||h({fill:y})}}),r&&c.fill&&f.jsx(qr,{label:"Grid adjustment",hideLabel:!0,icon:f.jsx(Z.PiArrowsHorizontal,{size:20}),checked:!!((p=c.adjustment)!=null&&p.enabled),onChange:y=>{n||h({adjustment:{...c.adjustment,enabled:y}})}})]})]})}const vt=[];for(let e=0;e<256;++e)vt.push((e+256).toString(16).slice(1));function X0(e,r=0){return(vt[e[r+0]]+vt[e[r+1]]+vt[e[r+2]]+vt[e[r+3]]+"-"+vt[e[r+4]]+vt[e[r+5]]+"-"+vt[e[r+6]]+vt[e[r+7]]+"-"+vt[e[r+8]]+vt[e[r+9]]+"-"+vt[e[r+10]]+vt[e[r+11]]+vt[e[r+12]]+vt[e[r+13]]+vt[e[r+14]]+vt[e[r+15]]).toLowerCase()}let To;const Y0=new Uint8Array(16);function Q0(){if(!To){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");To=crypto.getRandomValues.bind(crypto)}return To(Y0)}const ew=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Cu={randomUUID:ew};function gd(e,r,t){var i;if(Cu.randomUUID&&!e)return Cu.randomUUID();e=e||{};const n=e.random??((i=e.rng)==null?void 0:i.call(e))??Q0();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,X0(n)}const to={label:"Untitled",description:"",isTask:!1,isLocked:!1},yd={id:null,type:"text",data:{...to,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"}}},Su={id:null,type:"objectView",data:{...to,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:53,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},tw={id:null,type:"arrayView",data:{...to,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"}}},ju={id:null,type:"workflowStep",data:{...to,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}},It=e=>typeof e=="object",Um=e=>Array.isArray(e),rw=["order","position","selected","locked","grabbed","grabbable","scratch"],dr=e=>Object.entries(e).reduce((r,[t,n])=>(!It(n)&&!t.startsWith("$")&&(r[t]=n),r),{}),md=(e,r)=>typeof e=="string"&&e.startsWith("$")?Oo(e,r):It(e)&&!Um(e)?Object.entries(e).reduce((t,[n,i])=>(typeof i=="string"&&i.startsWith("$")&&n==="..."?(delete t["..."],t[n]={...Oo(i,r),...e}):typeof i=="string"&&i.startsWith("$")?t[n]=Oo(i,r):t[n]=i,t),{}):e,ur=e=>Object.entries(e).reduce((r,[t,n])=>(It(n)&&t&&n&&!t.startsWith("$")&&(rw.includes(t)&&(t=t+"#"),r[t]=n),r),{}),wr=(e,r,{label:t,parent:n=void 0},i,o=null)=>(o!==null&&(It(o)||Um(o))&&(o=JSON.stringify(o,null,2)),{data:{parent:n,...e.data,id:r,text:t||"",label:t,code:o||null,type:e.type,description:i}}),sr=(e,r,t=null,n=null,i=null,o=!1,s=null)=>({data:{id:gd(),source:i?r:e,target:i?e:r,label:n||"",isInverted:i,isEdgeAnimated:o,parent:s}}),fr=(e,r=[])=>{const t={},n={};let i=[];if(e)for(const[o,s]of Object.entries(e))o.startsWith("$")&&o!=="$"?t[o.slice(1)]=s:o!=="$"?n[o]=s:o==="$"&&(i=s);return{newConfig:t,updatedObject:n,arrayObject:i}},Nr=(e,r)=>{let t=Su;const{view:n,borderColor:i,borderRadius:o,bgColor:s,textColor:a,fontSize:l,stepType:c}=r;e=n||e,c?t={...ju}:e==="object"?t=Su:e==="text"?t=yd:e==="array"?t=tw:e==="workflowStep"&&(t={...ju});const d=t.data.viewProps;return t.data.viewProps={...d,borderRadius:o||(c?15:53),bgColor:s,borderColor:i,textColor:a,fontSize:l},t.data.config=r,{config:t}},Sn=(e,r)=>(e=r.find(n=>n.data.id===e)?`${e}.#`:e,e),Oo=(e,{ids:r,jsnObjct:t})=>{if(typeof e=="string"&&(e!=null&&e.startsWith("$"))){const n=e.replace("$","").replace("*","");e==null||e.endsWith("*");const i=r.find(a=>a.split(".").slice(-1)[0]===n||n===a);if(!i)return e;const o=nw(i,t);return JSON.stringify(o).includes(e)?e:o||e}return e},nw=(e,r)=>{let t=e.split(".").splice(1);return t=t[t.length-1]==="#"||t[t.length-1].includes("{")?t.slice(0,-2):t,(o=>t.reduce((s,a)=>{a=a.replace("[","").replace("]","");const{arrayObject:l}=fr(s);return s=l.length?l:s,s[a]},o))(r)};function Lr(e,r="root",t=[]){try{const{arrayObject:n}=fr(e);n.length&&(e=n);const i=dr(e),o=ur(e);return It(e)?(Qe(e)||Qe(e)&&r==="root"||!Qe(e)&&Object.keys(i).length||r==="root")&&t.push(r):t.push(r),Object.keys(o).length&&!Qe(e)?pn({chldPth:null,itrblObjct:o,nodes:t,path:r}):Qe(e)&&e.forEach((s,a)=>{const l=dr(s),c=ur(s),{newConfig:d,arrayObject:u}=fr(s);let h=`${r}.${a}`;It(s)?Object.keys(l).length?(Lr(l,h,t),Object.keys(c).length&&!Qe(s)&&pn({chldPth:h,itrblObjct:c,nodes:t,path:r})):Object.keys(c).length&&!Qe(s)?pn({chldPth:h,itrblObjct:c,nodes:t,path:r}):Qe(s)&&Hm({chldPth:h,item:s,nodes:t,path:r}):t.push(h)}),{nodes:t}}catch{return{nodes:t}}}const pn=({chldPth:e,itrblObjct:r,nodes:t,path:n})=>Object.entries(r).forEach(([i,o],s)=>{const a=dr(o),l=ur(o),{newConfig:c,arrayObject:d}=fr(o);d.length&&(o=d),n.split(".").slice(0,2).join(".");let u=e?`${e}.${i}`:`${n}.${i}`;if(It(o)&&!Qe(o)){const h=Object.keys(a).length===0;if(h&&(Nr("array",c),t.push(u)),Object.keys(a).length){const p=Qe(o)?`${o.length||""}`:`{${Object.keys(o).length||""}}`;let y=u;h&&(y=`${u}.${p}`),Lr(o,y,t)}else Object.keys(l).length&&!Qe(o)?pn({chldPth:u,itrblObjct:l,path:u,nodes:t}):Lr(o,u,t)}else Qe(o)&&Lr(o,u,t)}),Hm=({chldPth:e,item:r,nodes:t,path:n})=>r.forEach((i,o)=>{let s=`${e}.${o}`;const a=ur(i),l=dr(i);It(i)?!Qe(i)&&Object.keys(l).length?Lr(i,s,t):Object.keys(a).length&&!Qe(i)?pn({chldPth:s,itrblObjct:a,path:n,nodes:t}):Qe(i)&&Hm({chldPth:s,item:i,nodes:t,path:n}):t.push(s)}),gn=[];let yn;function jr(e,r="root",t=[],n=[],i="untitled",o={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},s={}){if(!e||typeof e!="object")return console.error("Invalid object passed",e),{nodes:t,edges:n};const a=e;if(r==="root"&&(gn.length=0),!yn){const{nodes:d}=Lr(e);yn={ids:d,jsnObjct:e}}let{hideDefaultObject:l,sprtObjctKy:c}=o;try{r=Sn(r,t);const{newConfig:d,arrayObject:u}=fr(e),h=Object.keys(s).length>0?s:d;u.length&&(e=u);const p=dr(e),y=ur(e),{label:m,collapsed:g,parent:b}=h;if(!It(e))t.push(wr(yd,r,{label:m||r,parent:b},e,a));else if(Qe(e)||Qe(e)&&r==="root"){const{config:v}=Nr("array",h),x=Qe(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,w=r==="root"?i:`${i} ${x}`;t.push(wr(v,r,{label:m||w,parent:b},e,Qe(a)?{[i]:a}:a))}else if(!Qe(e)&&Object.keys(p).length||r==="root"){const{config:v}=Nr(null,h),x=Qe(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,w=r.split("."),C=w[w.length-1];let S=isNaN(Number(C))?null:Number(C)+1;const _=isNaN(Number(C))?C:w[w.length-2]+" "+S,R=r==="root"?i:_;let A=!1;Number.isNaN(Number(i))||(A=!0);const O=e;if(m){const{config:T}=Nr("object",h);t.push(wr(T,r,{label:m||`${m} ${x}`,parent:b},p,O))}else v.data.headerTitle=R,t.push(wr(v,r,{label:m,parent:b},p,O))}return g||(Object.keys(y).length&&!Qe(e)?mn({flowConfig:o,chldPth:null,edges:n,isInverted:null,itrblObjct:y,nodes:t,path:r,newConfig:h}):Qe(e)&&e.forEach((v,x)=>{v=md(v,yn);const w=v,C=dr(v),S=ur(v),{newConfig:_,arrayObject:R}=fr(v);R.length&&(v=R);const{config:A}=Nr(typeof v=="string"?"text":"array",_),{hideConfig:O,sourceLabel:T,label:E,isEdgeAnimated:M,parent:P}=_;l=l||O;const $=r==="root"&&o.isCntr,N=r.split(".").slice(0,2).join("."),I=gn.includes(N),K=o.isCntr&&I||x%2===0&&$;let le=`${r}.${x}`;le=Sn(le,t),K&&gn.push(le),It(v)?Object.keys(C).length&&!Qe(v)?(n.push(sr(r,le,null,T,K,M)),jr(v,le,t,n,E||x,o,_)):Object.keys(S).length&&!Qe(v)?mn({flowConfig:o,chldPth:le,isInverted:K,edges:n,itrblObjct:S,nodes:t,path:r,newConfig:_,forceIsInverted:!0}):Qe(v)?Km({flowConfig:o,chldPth:le,edges:n,isInverted:K,item:v,nodes:t,path:r}):It(v)&&mn({flowConfig:o,chldPth:le,isInverted:K,edges:n,itrblObjct:[v],nodes:t,path:r,newConfig:_}):(n.push(sr(r,le,null,T,K,M)),t.push(wr(A,le,{label:E||String(v),parent:P},v,w)))})),{nodes:t,edges:n}}catch{return{nodes:t,edges:n}}}const mn=({chldPth:e,flowConfig:r,edges:t,itrblObjct:n,nodes:i,isInverted:o,path:s,newConfig:a,forceIsInverted:l=!1})=>{let{hideDefaultObject:c,sprtObjctKy:d}=r;return Object.entries(n).forEach(([u,h],p)=>{h=md(h,yn);const y=h,m=dr(h),g=ur(h),{newConfig:b,arrayObject:v}=fr(h);v.length&&(h=v);const{hideConfig:x,sourceLabel:w,label:C,content:S,target:_,targetLabel:R,collapsed:A,isEdgeAnimated:O,parent:T}=b;c=c||x;const E=s==="root"&&r.isCntr,M=s.split(".").slice(0,2).join("."),P=gn.includes(M);l||(o=r.isCntr&&P||p%2===0&&E);let $=e?`${e}.${u}`:`${s}.${u}`;if($=Sn($,i),o&&gn.push($),_&&t.push(sr($,_,null,R,o,O)),It(h)&&!Qe(h)){t.push(sr(s,$,null,w,o,O));const N=d||Object.keys(m).length===0;if(N){const I=S?"object":"array",{config:K}=Nr(I,b);K.data.headerTitle=S?C:null,i.push(wr(K,$,{label:C||u,parent:T},h,y))}if(Object.keys(m).length&&!c){const I=Qe(h)?` ${h.length||""}`:`{${Object.keys(h).length||""}}`;let K=$;N&&(K=`${$}.${I}`,K=Sn(K,i),t.push(sr($,K,null,w,o,O))),jr(h,K,i,t,C||u,r,b)}else Object.keys(g).length&&!Qe(h)?mn({chldPth:$,flowConfig:r,itrblObjct:g,path:$,edges:t,nodes:i,newConfig:b,isInverted:o}):jr(h,$,i,t,u,r,b)}else Qe(h)&&(t.push(sr(s,$,null,w,o,O)),jr(h,$,i,t,u,r,b))})},Km=({flowConfig:e,chldPth:r,edges:t,isInverted:n,item:i,nodes:o,path:s})=>i.forEach((a,l)=>{let c=`${r}.${l}`;c=Sn(c,o);const d=a;a=md(a,yn);const u=ur(a),h=dr(a),{newConfig:p}=fr(a),{collapsed:y,label:m,parent:g,sourceLabel:b,isEdgeAnimated:v,content:x}=p;It(a)?!Qe(a)&&Object.keys(h).length?(t.push(sr(s,c,null,b,n,v)),jr(a,c,o,t,l,e,p)):Object.keys(u).length&&!Qe(a)&&!y?mn({chldPth:c,flowConfig:e,itrblObjct:u,path:s,edges:t,nodes:o,isInverted:n,newConfig:p}):Qe(a)&&Km({flowConfig:e,chldPth:c,edges:t,isInverted:n,item:a,nodes:o,path:s}):(t.push(sr(s,c,null,b,n,v)),o.push(wr(yd,c,{label:m||String(a),parent:g},a,d)))});function ow(e,r){const t=new Set,n=(c,d="root")=>{if(!(!c||typeof c!="object")){c.$view==="parent"&&t.add(d),typeof c.$parent=="string"&&t.add(c.$parent);for(const[u,h]of Object.entries(c))(!u.startsWith("$")||u==="$")&&n(h,u==="$"?d:`${d}.${u}`)}};if(n(e),!t.size)return r;const i=new Map(r.nodes.map(c=>[c.data.id,c])),o=c=>{var p,y;let d=c.data.id;const u=new Set([c.data.id]);let h=c.data.parent;for(;h&&!u.has(h);)t.has(h)&&i.has(h)&&((p=Te(e,h))!=null&&p.$collapsed)&&(d=h),u.add(h),h=(y=i.get(h))==null?void 0:y.data.parent;return d},s=new Map(r.nodes.map(c=>[c.data.id,o(c)])),a=r.nodes.filter(c=>s.get(c.data.id)===c.data.id).map(c=>{if(!t.has(c.data.id))return c;const d=Te(e,c.data.id),u=!!(d!=null&&d.$collapsed);return{...c,data:{...c.data,...u?{type:"arrayView"}:{},config:{...c.data.config,parentContainer:!0,collapsed:u,...u?{labelBelow:!0,icon:(d==null?void 0:d.$icon)||"PiStack"}:{}}}}}),l=new Set(a.map(c=>c.data.id));return{nodes:a,edges:r.edges.flatMap(c=>{const d=s.get(c.data.source),u=s.get(c.data.target);return!d||!u||!l.has(d)||!l.has(u)?[]:d===c.data.source&&u===c.data.target?[c]:d===u?[]:[{...c,data:{...c.data,source:d,target:u,collapsedEndpoints:c.data.collapsedEndpoints??{source:c.data.source,target:c.data.target}}}]})}}function ro(e){if(!Array.isArray(e==null?void 0:e.$connections))return[];const r=new Map;return e.$connections.flatMap((t,n)=>{if(!t||typeof t!="object")return[];const i=t;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=r.get(o)??0;return r.set(o,s+1),[{value:i,key:`${o}#${s}`,index:n}]})}function Jm(e,r,t){const n=ro(e).find(l=>l.key===r);if(!n)return e;const i=t(n.value),o=e.$connections.flatMap((l,c)=>c===n.index?i?[i]:[]:[l]);if(o.length)return{...e,$connections:o};const{$connections:s,...a}=e;return a}function iw(e){const r=[],t=(n,i)=>{if(!n||typeof n!="object")return n;if(Array.isArray(n))return n.map((o,s)=>t(o,`${i}.${s}`));for(const o of ro(n)){const s=o.value;r.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==="$"?t(s,i):o.startsWith("$")?s:t(s,`${i}.${o}`)]))};return{json:t(e,"root"),edges:r}}const Fr="root",_u=e=>e==="#"||e.startsWith("{")||/^\s\d*$/.test(e);function Ft(e){const r=e.split(".");for(r[0]===Fr&&r.shift();r.length&&_u(r[r.length-1]);)r.pop();return r.filter(t=>!_u(t))}function no(e){return e==null||typeof e!="object"?e:Array.isArray(e.$)?e.$:e}function Te(e,r){return Ft(r).reduce((t,n)=>{var i;if(t!=null)return(i=no(t))==null?void 0:i[n]},e)}function aw(e){return Array.isArray(e)?[...e]:{...e}}function _t(e,r,t){const n=Ft(r),i=(o,s)=>{if(s===n.length)return t(o);const a=n[s],l=no(o);if(l==null||typeof l!="object")return o;const c=i(l[a],s+1);if(Object.is(c,l[a]))return o;const d=aw(l);return d[a]=c,l!==o?{...o,$:d}:d};return i(e,0)}function Yt(e,r,t){const n=t===""&&r!=="$content"||t===void 0||t===null;if(Array.isArray(e))return n?e:{[r]:t,$:[...e]};const i=e!=null&&typeof e=="object"?{...e}:{};return e!=null&&typeof e!="object"&&(i.$label=String(e)),n?delete i[r]:i[r]=t,i}function xt(e,r,t,n){return _t(e,r,i=>t==="$label"&&typeof i=="string"&&typeof n=="string"&&n!==""?n:Yt(i,t,n))}const bd=(e,r,t)=>xt(e,r,"$collapsed",t);function Cr(e){if(e.connection)return{address:e.connection.address,kind:"connection"};const r=e.collapsedEndpoints??e,t=e.isInverted?r.target:r.source,n=e.isInverted?r.source:r.target,i=Ft(t).join("."),o=Ft(n).join(".");return o.startsWith(i?i+".":"")&&o!==i?{address:n,kind:"hierarchy"}:i.startsWith(o?o+".":"")&&i!==o?{address:t,kind:"hierarchy"}:{address:t,kind:"target"}}function ar(e,r,t,n){if(r.connection){const a=r.connection;return _t(e,a.address,l=>Jm(l,a.key,c=>{if(t==="$edgeIcon")return Yt(c,"icon",n);if(t==="$edgeType")return Yt(c,"type",n);if(t==="$edgeAnimationVariant")return Yt(c,"animationVariant",n);if(t==="$sourceLabel"||t==="$edgeColor")return Yt(c,t==="$sourceLabel"?"label":"color",n);const d=t==="$isEdgeAnimated"?"animated":"dashed";return n?{...c,style:d}:c.style===d?Yt(c,"style",void 0):c}))}const{address:i,kind:o}=Cr(r),s=o==="target"&&t==="$sourceLabel"?"$targetLabel":o==="target"&&t==="$edgeType"?"$targetEdgeType":o==="target"&&t==="$edgeIcon"?"$targetIcon":o==="target"&&t==="$edgeAnimationVariant"?"$targetAnimationVariant":t;return _t(e,i,a=>Yt(a,s,n))}const Zm=(e,r,t)=>ar(ar(e,r,"$isEdgeAnimated",t==="animated"||void 0),r,"$isEdgeDashed",t==="dashed"||void 0);function vd(e,r,t,n){let i=n||"";const o=_t(e,r,a=>{const l=no(a);if(Array.isArray(l)){i=String(l.length);const d=[...l,t];return l===a?d:{...a,$:d}}const c=a!=null&&typeof a=="object"&&!Array.isArray(a)?{...a}:a!=null&&typeof a!="object"?{$label:String(a)}:{};if(!i){let d=1;for(;`node_${d}`in c;)d++;i=`node_${d}`}return c[i]=t,c}),s=Ft(r);return{json:o,address:[Fr,...s,i].join(".")}}function Xm(e,r){const t=Ft(r);if(!t.length)return e;const n=t[t.length-1],i=[Fr,...t.slice(0,-1)].join(".");return _t(e,i,o=>{const s=no(o);if(s==null||typeof s!="object"||!Object.prototype.hasOwnProperty.call(s,n))return o;if(Array.isArray(s)){const c=s.filter((d,u)=>String(u)!==n);return s===o?c:{...o,$:c}}const{[n]:a,...l}=o;return l})}const Ym=(e,r,t,n)=>xt(n?_t(e,r,i=>Yt(i,"$targetLabel",n)):e,r,"$target",t);function xd(e,r,t){const n=Te(e,r);return ro(n).some(({value:o})=>o.target===t.target&&o.sourceProperty===t.sourceProperty&&o.targetProperty===t.targetProperty)?e:_t(e,r,o=>Yt(o,"$connections",[...Array.isArray(o==null?void 0:o.$connections)?o.$connections:[],{...t,id:t.id||gd()}]))}function Qm(e,r){if(r.connection){const o=r.connection;return ro(Te(e,o.address)).some(s=>s.key===o.key)?{json:_t(e,o.address,s=>Jm(s,o.key,()=>null)),removed:!0}:{json:e,removed:!1}}const{address:t,kind:n}=Cr(r);return n==="hierarchy"?Te(e,t)===void 0?{json:e,removed:!1}:{json:_t(e,t,o=>({...o,$hideParentEdge:!0})),removed:!0}:n!=="target"?{json:e,removed:!1}:{json:_t(e,t,o=>{const{$target:s,$targetLabel:a,...l}=o||{};return l}),removed:!0}}function od(e,r={}){var v;const t=iw(e),{nodes:n,edges:i}=jr(t.json,Fr,[],[],r.title||"untitled",{hideDefaultObject:!!r.hideDefaultObject,sprtObjctKy:!!r.separateObjectKeys,isCntr:!!r.isCenter}),o=new Set(n.map(x=>x.data.id)),s=new Map;for(const x of n){const w=x.data.id;if(!w.endsWith(".0")||Te(e,w)!==void 0)continue;const C=w.slice(0,-2),S=Te(e,C);!o.has(C)&&S&&typeof S=="object"&&!Array.isArray(S)&&typeof S.$label=="string"&&Object.keys(S).every(_=>_.startsWith("$")&&_!=="$")&&s.set(w,C)}const a=x=>s.get(x)??x,l=new Set(n.flatMap(x=>x.data.parent?[a(x.data.parent)]:[])),c=new Map;if(r.isCenter){const x=new Map;for(const{data:w}of i){const C=Cr(w);if(C.kind==="hierarchy")c.set(a(C.address),!!w.isInverted);else if(!Array.isArray(e)&&e.$hideRoot===!0){const S=a(w.isInverted?w.source:w.target);if(Ft(S).length!==1)continue;const _=!!w.isInverted;x.set(S,x.has(S)&&x.get(S)!==_?null:_)}}for(const[w]of c){const C=`${Fr}.${Ft(w)[0]}`,S=x.get(C);typeof S=="boolean"&&c.set(w,S)}}const d=n.map(x=>{var A;const w=a(x.data.id),C=Te(e,w),S={...x.data,id:w};c.has(w)&&(S.config={...S.config,isInverted:c.get(w)});const _=C&&typeof C=="object"&&!Array.isArray(C)&&"$"in C?C.$:C;if((Array.isArray(_)?_.length>0:_&&typeof _=="object"&&Object.keys(_).some(O=>!O.startsWith("$")))&&(S.config={...S.config,collapsed:!!C.$collapsed}),l.has(w)||(S.viewProps={...S.viewProps},delete S.viewProps.borderWidth),!C||typeof C!="object"||Array.isArray(C))return{data:S};if(C.$view==="parent"&&(S.type="objectView",S.config={...S.config,typeView:"parent",parentContainer:!0,collapsed:!!C.$collapsed}),C.$view==="grid"){S.type="grid";const O=C.$gridSize;if(O!==void 0&&(!O||![O.width,O.height].every(T=>Number.isFinite(T)&&T>0&&T<=16384)))throw new Error("Invalid grid frame size.");S.config={...S.config,typeView:"grid",documentId:C.$document,gridSize:O},S.viewProps={...S.viewProps,bgColor:C.$bgColor??"transparent",borderRadius:C.$borderRadius??0,borderWidth:C.$borderWidth??0}}if(C.$form&&typeof C.$form=="object"&&(S.config={...S.config,form:C.$form},S.type="objectView"),Array.isArray(C.$ports)){const O=C.$ports.filter(T=>T&&typeof T.id=="string"&&["source","target"].includes(T.role)&&["top","right","bottom","left"].includes(T.side));S.config={...S.config,ports:O}}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"||C.$contentFormat==="jsx"&&Array.isArray(C.$content)){S.config={...S.config,content:C.$content};const O=C.$contentFormat??"markdown";if(!["markdown","html","jsx"].includes(O))throw new Error("Invalid content format: expected markdown, html, or jsx.");S.config.contentFormat=O,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}}),u=new Map,h=i.map(x=>{let w=a(x.data.source),C=a(x.data.target),S=x.data.isInverted;const _=Cr(x.data),R=c.get(a(_.address));_.kind==="hierarchy"&&R!==void 0&&R!==!!S&&([w,C]=[C,w],S=R);const A=`${w}->${C}`,O=u.get(A)??0;u.set(A,O+1);const T={...x.data,id:O?`${A}#${O}`:A,source:w,target:C,isInverted:S},E=Cr(T),M=Te(e,E.address);if(M&&typeof M=="object"){const P=M[E.kind==="target"?"$targetEdgeType":"$edgeType"];typeof P=="string"&&(T.type=P);const $=M[E.kind==="target"?"$targetIcon":"$edgeIcon"];typeof $=="string"&&(T.icon=$),M.$isEdgeAnimated!==void 0&&(T.isEdgeAnimated=!!M.$isEdgeAnimated);const N=M[E.kind==="target"?"$targetAnimationVariant":"$edgeAnimationVariant"];["dashed","traveling"].includes(N)&&(T.edgeAnimationVariant=N),M.$isEdgeDashed!==void 0&&(T.isEdgeDashed=!!M.$isEdgeDashed),M.$edgeColor&&(T.color=M.$edgeColor)}return{data:T}});if(!Array.isArray(e)&&(e==null?void 0:e.$hideRoot)===!0){const x=d.findIndex(w=>w.data.id===Fr);x!==-1&&d.splice(x,1)}const p=new Set(d.map(x=>x.data.id));for(let x=h.length-1;x>=0;x--){const w=h[x].data,C=Cr(w);(!p.has(w.source)||!p.has(w.target)||C.kind==="hierarchy"&&((v=Te(e,C.address))==null?void 0:v.$hideParentEdge)===!0)&&h.splice(x,1)}h.push(...t.edges.filter(x=>p.has(x.data.source)&&p.has(x.data.target)));const y=ow(e,{nodes:d,edges:h}),m=y.nodes.filter(x=>{var w;return(w=x.data.config)==null?void 0:w.collapsed}).map(x=>Ft(x.data.id));if(!m.length)return y;const g=y.nodes.filter(x=>{const w=Ft(x.data.id);return!m.some(C=>C.length<w.length&&C.every((S,_)=>S===w[_]))}),b=new Set(g.map(x=>x.data.id));return{nodes:g,edges:y.edges.filter(x=>b.has(x.data.source)&&b.has(x.data.target))}}function sw(e,r){const t=new Set(e.filter(l=>{var c,d;return(d=(c=l.data)==null?void 0:c.config)==null?void 0:d.collapsed}).map(l=>l.data.id));if(!t.size)return{nodes:e,edges:r};const n=new Map(e.map(l=>[l.data.id,l])),i=new Set(e.map(l=>l.data.parent).filter(Boolean)),o=new Map(e.map(l=>{var h;let c=l.data.id,d=l.data.parent;const u=new Set([c]);for(;d&&!u.has(d);)t.has(d)&&(c=d),u.add(d),d=(h=n.get(d))==null?void 0:h.data.parent;return[l.data.id,c]})),s=new Map;for(const l of r){const c=l.data.isInverted?l.data.target:l.data.source,d=l.data.isInverted?l.data.source:l.data.target;(s.get(c)??s.set(c,[]).get(c)).push(d)}const a=new Set(e.filter(l=>o.get(l.data.id)!==l.data.id).map(l=>l.data.id));for(const l of t){if(i.has(l))continue;const c=[...s.get(l)||[]];for(;c.length;){const d=c.pop();t.has(d)||a.has(d)||(a.add(d),c.push(...s.get(d)||[]))}}return{nodes:e.filter(l=>!a.has(l.data.id)).map(l=>{var c;return t.has(l.data.id)&&i.has(l.data.id)?{...l,data:{...l.data,type:"arrayView",label:l.data.label??l.data.headerTitle,config:{...l.data.config,parentContainer:!0,labelBelow:!0,icon:((c=l.data.config)==null?void 0:c.icon)||"PiStack"}}}:l}),edges:r.flatMap(l=>{const c=o.get(l.data.source)??l.data.source,d=o.get(l.data.target)??l.data.target;return a.has(c)||a.has(d)?[]:c===l.data.source&&d===l.data.target?[l]:c===d?[]:[{...l,data:{...l.data,source:c,target:d,collapsedEndpoints:l.data.collapsedEndpoints??{source:l.data.source,target:l.data.target}}}]})}}function wd(e,r){const t=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 l=new Set(["$schema","$id","$defs","definitions","$ref","title","description","default","examples","type","properties","required","items","enum","const","anyOf","additionalProperties"]);for(const d of Object.keys(s))if(!l.has(d))throw new Error(`Unsupported JSON Schema keyword: ${d}`);const c=["$schema","$id","$defs","definitions","title","description","default","examples"];if(s.$ref){if(Object.keys(s).some(u=>!["$ref","title","description"].includes(u)))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 d=t;for(const u of s.$ref.slice(2).split("/")){const h=u.replace(/~1/g,"/").replace(/~0/g,"~");if(!d||!Object.prototype.hasOwnProperty.call(d,h))throw new Error(`Unresolved reference: ${s.$ref}`);d=d[h]}return i(d,[...a,s.$ref])}if(s.anyOf){if(!Array.isArray(s.anyOf)||!s.anyOf.length||Object.keys(s).some(d=>d!=="anyOf"&&!c.includes(d)))throw new Error("Use a nonempty anyOf without sibling type constraints.");return{kind:"union",types:s.anyOf.map(d=>i(d,a))}}if(Object.prototype.hasOwnProperty.call(s,"const")||s.enum){if(Object.keys(s).some(h=>![...c,"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 d=Object.prototype.hasOwnProperty.call(s,"const")?[s.const]:s.enum;if(!Array.isArray(d)||!d.length)throw new Error("Expected a nonempty enum.");return{kind:"union",types:d.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(d=>typeof d!="string"))throw new Error("Expected a nonempty list of primitive types.");if(Object.keys(s).some(d=>d!=="type"&&!c.includes(d)))throw new Error("Use anyOf for unions with object or array constraints.");return{kind:"union",types:s.type.map(d=>i({type:d},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(u=>typeof u!="string"||!Object.prototype.hasOwnProperty.call(s.properties,u))))throw new Error("required must list declared property names.");return{kind:"object",properties:Object.fromEntries(Object.entries(s.properties).map(([u,h])=>[u,{type:i(h,a),optional:!(s.required??[]).includes(u)}]))}}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(t);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:r,nodes:o.properties}}async function Cd(e,r,t,n={}){var y;let i=512;const o=await import("typescript"),s=o.createSourceFile(r,e,o.ScriptTarget.Latest,!0,o.ScriptKind.TS),a=s.parseDiagnostics;if(a!=null&&a.length)throw new Error("Invalid TypeScript syntax.");const l=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||l.has(m.name.text))throw new Error("Generics and duplicate declarations are not supported.");l.set(m.name.text,m)}const c=(m,g)=>{var C;const b={},v=m.find(S=>o.isIndexSignatureDeclaration(S));let x;if(v&&n.allowJson&&o.isIndexSignatureDeclaration(v)){if(m.filter(S=>o.isIndexSignatureDeclaration(S)).length!==1||v.parameters.length!==1||((C=v.parameters[0].type)==null?void 0:C.kind)!==o.SyntaxKind.StringKeyword||!v.type)throw new Error("Only one string-keyed index signature is supported for forms.");x=u(v.type,g)}return{kind:"object",properties:Object.fromEntries(m.filter(S=>S!==v||!x).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 _=u(S.type,g),R=n.allowJson?o.getJSDocTags(S).filter(A=>A.tagName.text==="port"):[];if(R.length>1)throw new Error(`Duplicate port declaration: ${S.name.text}`);if(R.length){const[A,O,T]=String(R[0].comment??"").trim().split(/\s+/);if(A!=="config"||!O||T||!l.has(O))throw new Error(`Config port ${S.name.text} requires @port config ResourceType`);const E=_.kind==="array";if((_.kind==="array"?_.items.kind:_.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:O,multiple:E}}return[S.name.text,{type:_,optional:!!S.questionToken}]})),...x?{additionalProperties:x}:{},...Object.keys(b).length?{ports:b}:{}}},d=(m,g)=>{var C;if(g.includes(m))throw new Error("Recursive types are not supported.");const b=l.get(m);if(!b)throw new Error(`Unknown type: ${m}`);let v;if(o.isInterfaceDeclaration(b)){if((C=b.heritageClauses)!=null&&C.length)throw new Error("Interface inheritance is not supported; declare properties explicitly.");v=c(b.members,[...g,m])}else v=u(b.type,[...g,m]);const x=n.allowJson?o.getJSDocTags(b).filter(S=>S.tagName.text==="port"):[];if(!x.length)return v;if(v.kind!=="object")throw new Error("Node ports require an object interface");const w={...v.ports};for(const S of x){const[_,R,...A]=String(S.comment??"").trim().split(/\s+/);if(!["input","output","error"].includes(_)||!/^[A-Za-z][\w-]*$/.test(R??""))throw new Error("Node ports require @port input|output|error Name");const O=A.length?JSON.parse(A.join(" ")):void 0;if(O!==void 0&&typeof O!="string")throw new Error("Node port labels must be JSON strings");if(Object.prototype.hasOwnProperty.call(w,R))throw new Error(`Duplicate port declaration: ${R}`);w[R]={kind:_,...typeof O=="string"?{label:O}:{}}}return{...v,ports:w}},u=(m,g)=>{var b,v,x;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 u(m.type,g);if(o.isUnionTypeNode(m))return{kind:"union",types:m.types.map(w=>u(w,g))};if(o.isArrayTypeNode(m))return{kind:"array",items:u(m.elementType,g)};if(o.isTypeLiteralNode(m))return c(m.members,g);if(o.isLiteralTypeNode(m)){const w=m.literal;if(o.isStringLiteral(w))return{kind:"literal",value:w.text};if(o.isNumericLiteral(w))return{kind:"literal",value:Number(w.text)};if(w.kind===o.SyntaxKind.NullKeyword)return{kind:"null"};if(w.kind===o.SyntaxKind.TrueKeyword||w.kind===o.SyntaxKind.FalseKeyword)return{kind:"literal",value:w.kind===o.SyntaxKind.TrueKeyword}}if(o.isTypeReferenceNode(m)&&o.isIdentifier(m.typeName)){if(n.allowJson&&m.typeName.text==="Record"&&!l.has("Record")&&((b=m.typeArguments)==null?void 0:b.length)===2&&m.typeArguments[0].kind===o.SyntaxKind.StringKeyword)return{kind:"object",properties:{},additionalProperties:u(m.typeArguments[1],g)};if(m.typeName.text==="Array"&&((v=m.typeArguments)==null?void 0:v.length)===1)return{kind:"array",items:u(m.typeArguments[0],g)};if(!((x=m.typeArguments)!=null&&x.length))return d(m.typeName.text,g)}throw new Error(`Unsupported TypeScript type: ${m.getText(s)}`)},h=t??(l.has("Graph")?"Graph":l.size===1?[...l.keys()][0]:void 0);if(!h)throw new Error("Declare an interface Graph keyed by node ID.");const p=d(h,[]);if(p.kind!=="object")throw new Error("Graph must be an object keyed by node ID.");return p}async function eb(e,r){const t=await Cd(e,r);if(Object.values(t.properties).some(n=>n.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:r,nodes:t.properties}}function sn(e,r){if(e.kind==="json"||r.kind==="json"||e.kind==="object"&&e.additionalProperties||r.kind==="object"&&r.additionalProperties)return!1;if(e.kind==="union")return e.types.every(t=>sn(t,r));if(r.kind==="union")return r.types.some(t=>sn(e,t));if(e.kind==="literal"){if(r.kind==="literal")return e.value===r.value;const t=e.value===null?"null":typeof e.value;return r.kind===t||r.kind==="integer"&&typeof e.value=="number"&&Number.isInteger(e.value)}return e.kind==="integer"&&r.kind==="number"?!0:e.kind==="array"&&r.kind==="array"?sn(e.items,r.items):e.kind==="object"&&r.kind==="object"?Object.entries(r.properties).every(([t,n])=>{const i=Object.prototype.hasOwnProperty.call(e.properties,t)?e.properties[t]:void 0;return i?(n.optional||!i.optional)&&sn(i.type,n.type):n.optional}):e.kind===r.kind}function Sd(e,r){if(!r.sourceProperty&&!r.targetProperty)return;const t=(s,a)=>{var d;const l=Object.prototype.hasOwnProperty.call(e.nodes,s)?s:s.replace(/^root\./,""),c=Object.prototype.hasOwnProperty.call(e.nodes,l)?(d=e.nodes[l])==null?void 0:d.type:void 0;return a&&(c==null?void 0:c.kind)==="object"&&Object.prototype.hasOwnProperty.call(c.properties,a)?c.properties[a]:void 0},n=t(r.source,r.sourceProperty),i=t(r.target,r.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(!sn(n.type,i.type))return`Incompatible property types: ${r.sourceProperty} -> ${r.targetProperty}.`}async function tb(e){if(e.size>256*1024)throw new Error("Interface must be 256 KB or smaller.");const r=await e.text();if(/\.json$/i.test(e.name))return wd(r,e.name);if(/\.ts$/i.test(e.name))return eb(r,e.name);throw new Error("Choose a .ts interface or .json JSON Schema file.")}const Eu=new WeakMap;function Vr(e){if(!e||typeof e!="object")return e;const r=Eu.get(e);if(r)return r;const t=()=>{throw new Error("Form callback data is read-only. Return edits instead.")},n=new Proxy(Array.isArray(e)?[]:{},{get:(i,o)=>Vr(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:Vr(Reflect.get(e,o)),configurable:o!=="length"||!Array.isArray(e)}},set:t,deleteProperty:t,defineProperty:t,setPrototypeOf:t,preventExtensions:t});return Eu.set(e,n),n}function Kr(e,r,t){var i;const n=r.split(".");for(let o=n.length;o>0;o--){const s=n.slice(0,o).join("."),a=(i=Te(e,s))==null?void 0:i.$form;if(!(a!=null&&a.$type))continue;let l=Object.prototype.hasOwnProperty.call(t,a.$type)?t[a.$type]:void 0;for(const u of n.slice(o))(l==null?void 0:l.kind)==="array"&&/^\d+$/.test(u)?l=l.items:(l==null?void 0:l.kind)==="object"?l=Object.prototype.hasOwnProperty.call(l.properties,u)?l.properties[u].type:void 0:l=void 0;if((l==null?void 0:l.kind)!=="object")return;const c=n.slice(o).join("."),d=Object.fromEntries(Object.entries(a.$fields??{}).filter(([u])=>!c||u.startsWith(`${c}.`)).map(([u,h])=>[c?u.slice(c.length+1):u,h]));return{type:l,fields:d,binding:a}}}async function jd(e,r){if(e.size>256*1024)throw new Error("Form schema exceeds 256 KB.");const t=await e.text();if(e.name.endsWith(".ts")){if(!r.length||r.length>32)throw new Error("Choose between 1 and 32 form interface names.");const i=[],o=new Set(r);for(const s of o){if(o.size>32)throw new Error("Choose between 1 and 32 form interface names.");const a=await Cd(t,e.name,s,{allowJson:!0});i.push([s,a]);for(const l of Object.values(a.ports??{}))l.resourceType&&o.add(l.resourceType)}return Object.fromEntries(i)}if(!e.name.endsWith(".json"))throw new Error("Choose a .ts interface or .json schema file.");const n=wd(t,e.name);return Object.fromEntries(Object.entries(n.nodes).map(([i,o])=>[i,o.type]))}function oo(e,r){return!e||("$in"in e?e.$in.includes(Te(r,e.$address)):Te(r,e.$address)===e.$equals)}function bn(e){const r=e.kind==="array"?e.items:e,t=r.kind==="union"?r.types:[r];if(t.every(n=>n.kind==="literal"))return t.map(n=>({label:String(n.value),value:n.value}))}function zt(e,r,t){if(r===void 0||r==="")return t?"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(r)?void 0:"Expected a JSON value"}if(e.kind==="union")return e.types.some(n=>!zt(n,r,!0))?void 0:"Choose a valid value";if(e.kind==="literal")return r===e.value?void 0:"Choose a valid value";if(e.kind==="array")return Array.isArray(r)&&r.every(n=>!zt(e.items,n,!0))?void 0:"Invalid list value";if(e.kind==="object")return!r||typeof r!="object"||Array.isArray(r)?"Expected an object":e.additionalProperties&&Object.entries(r).some(([n,i])=>!Object.prototype.hasOwnProperty.call(e.properties,n)&&zt(e.additionalProperties,i,!0))?"Invalid dictionary value":Object.entries(e.properties).some(([n,i])=>zt(i.type,r[n],!i.optional))?"Invalid object fields":void 0;if(e.kind==="null")return r===null?void 0:"Expected null";if(e.kind==="integer")return Number.isInteger(r)?void 0:"Expected a whole number";if(typeof r!==e.kind||typeof r=="number"&&!Number.isFinite(r))return`Expected ${e.kind}`}function Ru(e,r){const t=r.address.split(".");if(t.shift()!=="root"||!t.length||t.some(a=>!a||["__proto__","prototype","constructor","#"].includes(a)))throw new Error("Invalid form field address.");const n=t.pop(),i=n==="$bgColor"||n==="$textColor"||n==="$borderColor";if(t.some(a=>a.startsWith("$"))||n.startsWith("$")&&!i)throw new Error("Unsupported form metadata address.");const o=["root",...t].join("."),s=Te(e,o);if(!s||typeof s!="object")throw new Error(`Missing form parent: ${o}`);if(i){if(r.op==="set"&&typeof r.value!="string")throw new Error("Node colors must be strings.");return xt(e,o,n,r.op==="remove"?void 0:r.value)}return _t(e,o,a=>{const l=Array.isArray(a.$)?a.$:a;if(r.op==="remove"&&!Object.prototype.hasOwnProperty.call(l,n)||r.op==="set"&&Object.is(l[n],r.value))return a;const c=Array.isArray(l)?[...l]:{...l};if(Array.isArray(c)&&(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=c.length))throw new Error("Invalid array address.");return r.op==="remove"?Array.isArray(c)?c.splice(Number(n),1):delete c[n]:Object.defineProperty(c,n,{value:structuredClone(r.value),enumerable:!0,writable:!0,configurable:!0}),l===a?c:{...a,$:c}})}function io(e,r,t){let n=Ru(e,r.value===void 0?{op:"remove",address:r.address}:{op:"set",address:r.address,value:r.value});const i=t==null?void 0:t({...r,previousValue:Vr(Te(e,r.address)),data:Vr(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=Ru(n,o)}return n}const vn="data:image/svg+xml;base64,";function or(e){if(e.startsWith(vn))return!0;try{const r=new URL(e);return(r.protocol==="https:"||r.protocol==="http:")&&!r.username&&!r.password}catch{return!1}}async function cw(e){if(e.size>256*1024)throw new Error("SVG must be 256 KB or smaller.");const r=await e.text(),t=new DOMParser().parseFromString(r,"image/svg+xml");if(t.doctype||t.querySelector("parsererror")||t.documentElement.localName!=="svg"||t.documentElement.namespaceURI!=="http://www.w3.org/2000/svg")throw new Error("Choose a valid SVG file.");if(t.querySelector("script, foreignObject")||[...t.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(r);let i="";for(const o of n)i+=String.fromCharCode(o);return vn+btoa(i)}const Ht=({name:e,svg:r=!1,...t})=>{const[n,i]=j.useState(null),[o,s]=j.useState(!0),[a,l]=j.useState(!1),c=typeof e=="string"&&or(e);if(j.useEffect(()=>{if(c||!e||e.length<2){i(null),s(!1);return}s(!0),l(!1),(async()=>{try{let u;if(e.startsWith("Md"))u="md";else if(e.startsWith("Fa"))u="fa6";else if(e.startsWith("Io5"))u="io5";else if(e.startsWith("Io"))u="io";else if(e.startsWith("Ti"))u="ti";else if(e.startsWith("Go"))u="go";else if(e.startsWith("Fi"))u="fi";else if(e.startsWith("Di"))u="di";else if(e.startsWith("Ai"))u="ai";else if(e.startsWith("Bs"))u="bs";else if(e.startsWith("Ri"))u="ri";else if(e.startsWith("Fc"))u="fc";else if(e.startsWith("Gi"))u="gi";else if(e.startsWith("Hi2"))u="hi2";else if(e.startsWith("Hi"))u="hi";else if(e.startsWith("Si"))u="si";else if(e.startsWith("Sl"))u="sl";else if(e.startsWith("Im"))u="im";else if(e.startsWith("Bi"))u="bi";else if(e.startsWith("Pi"))u="pi";else if(e.startsWith("Vsc"))u="vsc";else if(e.startsWith("Tb"))u="tb";else if(e.startsWith("Tfi"))u="tfi";else if(e.startsWith("Cg"))u="cg";else if(e.startsWith("Lia"))u="lia";else if(e.startsWith("Lu"))u="lu";else throw new Error(`Unknown library prefix for icon: ${e}`);let h;switch(u){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: ${u}`)}const p=h[e];if(!p)throw new Error(`Icon ${e} not found in library ${u}`);i(()=>p)}catch(u){console.warn(`Failed to load icon ${e}:`,u.message),l(!0),i(null)}finally{s(!1)}})()},[e,c]),c){const{size:d=80,style:u,...h}=t;return r?f.jsx("image",{...h,href:e,width:d,height:d,preserveAspectRatio:"xMidYMid meet",style:u}):f.jsx("img",{...h,src:e,alt:"",width:d,height:d,referrerPolicy:"no-referrer",style:{objectFit:"contain",...u}})}return o||!n?null:f.jsx(n,{...t})};function lw(e,r){let t=e;for(const n of r){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;jn(o),t=io(t,{address:n.address,nodeAddress:i.slice(0,-1).join("."),value:o})}return jn(t),t}function Pn(e,r,t){const n=Object.prototype.hasOwnProperty.call(e,r)?e[r]:void 0;if(!(!n||!t||!Object.prototype.hasOwnProperty.call(t,n.type)))return{address:n.address,type:t[n.type],fields:n.fields??{}}}function jn(e){if(!(!e||typeof e!="object"))for(const[r,t]of Object.entries(e)){if(r.startsWith("$")||["__proto__","prototype","constructor"].includes(r))throw new Error(`Form state cannot contain view metadata or unsafe keys: ${r}`);jn(t)}}function dw(e,r,t){jn(r.value);const n=io(e,r,t);return jn(n),n}function rb(e,r){const t=(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=Te(r,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 l=t(a,s);l!==a&&(o===n&&(o=Array.isArray(n)?[...n]:{...n}),Object.defineProperty(o,s,{value:l,enumerable:!0,writable:!0,configurable:!0}))}return o};return t(e)}const uw=e=>!!e&&!e.includes(".")&&!e.startsWith("$")&&!["__proto__","constructor","prototype"].includes(e),fw=e=>`root.__form_${encodeURIComponent(e).replace(/\./g,"%2E")}`,cn=(e,r)=>JSON.stringify([e,r]);function _n(e,r){if(e.kind==="union"){const t=e.types.find(n=>n.kind===(Array.isArray(r)?"array":r===null?"null":typeof r)||n.kind==="literal"&&Object.is(n.value,r));return _n(t??e.types.find(n=>n.kind!=="null")??e.types[0]??{kind:"json"},r)}return e.kind!=="json"?e:Array.isArray(r)?{kind:"array",items:{kind:"json"}}:r!==null&&typeof r=="object"||r===void 0?{kind:"object",properties:{},additionalProperties:{kind:"json"}}:{kind:r===null?"null":typeof r}}function ln(e){const r=_n(e,void 0);return r.kind==="object"?{}:r.kind==="array"?[]:r.kind==="literal"?r.value:r.kind==="number"||r.kind==="integer"?0:r.kind==="boolean"?!1:r.kind==="null"?null:""}function ku(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"&&!bn(e)?e.types:[e]}function hw(e,r,t){if(r.address===t.address)return;const n=Te(e,r.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,l])=>l.optional&&s[a]===void 0||i(l.type,s[a]))&&Object.entries(s).every(([a,l])=>Object.prototype.hasOwnProperty.call(o.properties,a)||!o.additionalProperties||i(o.additionalProperties,l)):s===""?o.kind==="string"||o.kind==="json"||o.kind==="literal"&&o.value==="":!zt(o,s,!0);if(i(t.type,n))return structuredClone(n)}function nb(e,r,t,n){var l,c;const i={sourceSchema:t,sourceBindings:r,nodes:[],edges:[],schema:{...t},bindings:{...r},slots:new Map,containers:new Map},o=new Set(n.map(d=>d.data.id)),s=new Map(n.flatMap(d=>{const u=r[d.data.id];return u&&t[u.type]?[[u.address,d.data.id]]:[]})),a=(d,u,h,p,y,m=!1)=>{var _,R,A,O,T;if(y>24||i.containers.size>512)throw new Error("Structured form exceeds the flow node limit.");const g=Te(e,u),b=_n(h,g),v=b.kind!=="object"&&b.kind!=="array";i.containers.set(d,{address:u,type:b,declared:h,scalar:v});const x=`__form:${d}`,w={...(_=i.bindings[d])==null?void 0:_.fields},C={kind:"object",properties:{},ports:{...b.kind==="object"?b.ports:{},...m?{resource:{label:"output",...b.kind==="object"?(R=b.ports)==null?void 0:R.resource:{},kind:"output"}}:{}}},S=b.kind==="object"?{...b.properties,...Object.fromEntries(Object.keys(g??{}).filter(E=>!Object.prototype.hasOwnProperty.call(b.properties,E)&&b.additionalProperties).map(E=>[E,{type:b.additionalProperties,optional:!0}]))}:b.kind==="array"?Object.fromEntries((Array.isArray(g)?g:[]).map((E,M)=>[String(M),{type:b.items,optional:!0}])):{value:{type:bn(h)?h:b,optional:!1}};for(const[E,M]of Object.entries(S)){if(!uw(E))throw new Error(`Unsupported structured property key: ${E}`);const P=v?u:`${u}.${E}`,$=Te(e,P),N=_n(M.type,$),I=N.kind==="object"||N.kind==="array",K=(A=C.ports)==null?void 0:A[E],le=(K==null?void 0:K.kind)==="config"&&(((O=w[E])==null?void 0:O.$options)||bn(M.type)),ie=M.type.kind==="json"||M.type.kind==="union"&&!bn(M.type);if(((T=w[E])==null?void 0:T.$control)==="upload"||!I&&b.kind!=="array"&&(!ie||v)||le){C.properties[E]={...M,type:M.type.kind==="json"?N:M.type};continue}const te=s.get(P)??fw(P),fe=b.kind==="array"?`Item ${Number(E)+1}`:E,xe={address:P,owner:d,field:E,type:M.type,label:fe,nodeId:te,present:$!==void 0};if(i.slots.set(cn(d,E),xe),C.ports[E]={kind:"config",resourceType:`__form:${te}`},$===void 0||(i.edges.push({data:{id:`__form-edge:${d}:${E}`,source:te,target:d,sourceProperty:"output:resource",targetProperty:`config:${E}`,isEdgeDashed:!0}}),i.containers.has(te)||s.has(P)))continue;if(o.has(te))throw new Error(`Structured node identity conflict: ${te}`);o.add(te);const q={data:{id:te,type:"objectView",label:fe,headerTitle:fe,description:{},config:{form:!0,icon:N.kind==="array"?"PiListNumbers":I?"PiBracketsCurly":"PiTextT"},viewProps:{bgColor:p}}};i.nodes.push(q),a(te,P,M.type,p,y+1,!0);const W=i.schema[`__form:${te}`];q.data.description=Object.fromEntries(Object.keys(W.properties).map(U=>[U,Te(e,N.kind==="array"||N.kind==="object"?`${P}.${U}`:P)]).filter(([,U])=>U!==void 0))}i.schema[x]=C,i.bindings[d]={...i.bindings[d],address:u,type:x,fields:w}};for(const d of n){const u=r[d.data.id];if(u!=null&&u.portResources)continue;const h=u&&t[u.type];!u||!h||Te(e,u.address)===void 0||a(d.data.id,u.address,h,(l=d.data.viewProps)==null?void 0:l.bgColor,0,i.edges.some(p=>p.data.source===d.data.id))}for(const d of i.edges){const u=i.bindings[d.data.source],h=i.schema[u.type].ports;h.resource={...h.resource,kind:"output",label:((c=h.resource)==null?void 0:c.label)??"output"}}return i}const Sr=(e="reference")=>({kind:e,text:"",paths:[""]}),ob=e=>/^[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*|\.\d+)+$/.test(e)&&!e.split(".").some(r=>["__proto__","constructor","prototype"].includes(r));function pw(e,r){const t=new Set(r.map(s=>s.path)),n=s=>{if(!s.paths.length||s.paths.some(a=>!ob(a)||!t.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 gw(e){const r=await import("typescript"),t=s=>{const a=r.createSourceFile("binding.ts",`(${s})`,r.ScriptTarget.Latest,!0,r.ScriptKind.TS);if(a.parseDiagnostics.length)throw new Error("Unsupported reference expression.");const l=a.statements[0];if(!l||!r.isExpressionStatement(l))throw new Error("Unsupported reference expression.");const c=Sr();c.paths=[];const d=u=>{if(r.isParenthesizedExpression(u))return d(u.expression);if(r.isBinaryExpression(u)&&u.operatorToken.kind===r.SyntaxKind.BarBarToken){d(u.left),d(u.right);return}if(r.isStringLiteral(u)){if(c.fallback!==void 0)throw new Error("Multiple fallback values.");c.fallback=u.text;return}const h=u.getText(a);if(!ob(h)||c.fallback!==void 0)throw new Error("Unsupported reference expression.");c.paths.push(h)};if(d(l.expression),!c.paths.length)throw new Error("A binding needs a reference.");return c},n=s=>{const a=[];let l=0;const c=/\{\{([\s\S]*?)\}\}/g;for(const d of s.matchAll(c)){const u=d.index;if(u<l)continue;u>l&&a.push({...Sr("text"),text:s.slice(l,u)});const h=d[1].trim();if(h.startsWith("#if ")){const p=s.indexOf("{{/if}}",u+d[0].length);if(p<0)throw new Error("Unclosed condition.");a.push({...t(h.slice(4)),kind:"conditional",text:s.slice(u+d[0].length,p)}),l=p+7}else a.push(t(h)),l=u+d[0].length}return l<s.length&&a.push({...Sr("text"),text:s.slice(l)}),a},i={mode:"reference",parts:[Sr()],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,l])=>({key:a,parts:n(l)}))}}catch{}const o=n(e);if(o.length===2&&o[0].kind==="reference"&&o[1].kind==="text"){const s=r.createSourceFile("condition.ts",`value ${o[1].text}`,r.ScriptTarget.Latest,!0,r.ScriptKind.TS),a=s.statements[0];if(s.statements.length===1&&r.isExpressionStatement(a)&&r.isBinaryExpression(a.expression)&&a.expression.operatorToken.kind===r.SyntaxKind.EqualsEqualsToken&&r.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 Au({parts:e,references:r,onChange:t,disabled:n}){const i=(o,s)=>t(e.map((a,l)=>l===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(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}),f.jsx(Ae,{"aria-label":`Remove part ${s+1}`,title:"Remove part",icon:f.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>t(e.filter((a,l)=>l!==s))})]}),o.kind!=="text"&&f.jsxs(f.Fragment,{children:[o.paths.map((a,l)=>f.jsxs("label",{children:["Reference ",l+1,f.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[f.jsxs("select",{"aria-label":`Reference ${l+1}`,disabled:n,value:a,onChange:c=>i(s,{paths:o.paths.map((d,u)=>u===l?c.target.value:d)}),children:[f.jsx("option",{value:"",children:"Select reference"}),r.map(c=>f.jsx("option",{value:c.path,children:c.label},c.path))]}),f.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]},l)),o.kind==="reference"&&f.jsxs(f.Fragment,{children:[f.jsx(Ae,{"aria-label":"Add fallback reference",title:"Add fallback reference",icon:f.jsx(Z.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(Ae,{"aria-label":"Add part",title:"Add part",icon:f.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>t([...e,Sr()])})]})}function yw({label:e,value:r,references:t,disabled:n,onChange:i}){const[o,s]=j.useState(),[a,l]=j.useState(""),[c,d]=j.useState(!1),u=async()=>{d(!0),l("");try{s(await gw(typeof r=="string"?r:""))}catch(h){l(h instanceof Error?h.message:"Unable to read binding.")}finally{d(!1)}};return f.jsxs("div",{"data-runtime-binding":e,style:{marginBottom:8},children:[f.jsx(Ae,{"aria-label":`Bind ${e}`,title:`Bind ${e}`,icon:f.jsx(Z.PiLink,{size:18}),size:"sm",variant:"ghost",disabled:n||c,onClick:u}),typeof r=="string"&&r.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:[Sr()]}),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(Z.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(Au,{parts:h.parts,references:t,disabled:n,onChange:y=>s({...o,fields:o.fields.map((m,g)=>g===p?{...m,parts:y}:m)})}),f.jsx(Ae,{"aria-label":"Remove output field",title:"Remove output field",icon:f.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...o,fields:o.fields.filter((y,m)=>m!==p)})})]},p)),f.jsx(Ae,{"aria-label":"Add output field",title:"Add output field",icon:f.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...o,fields:[...o.fields,{key:"",parts:[Sr()]}]})})]}):f.jsx(Au,{parts:o.parts,references:t,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(Ae,{"aria-label":"Apply binding",title:"Apply binding",icon:f.jsx(Z.PiCheck,{size:20}),size:"sm",variant:"ghost",onClick:()=>{try{i(pw(o,t)),s(void 0),l("")}catch(h){l(h instanceof Error?h.message:"Unable to apply binding.")}}}),f.jsx(Ae,{"aria-label":"Cancel binding",title:"Cancel binding",icon:f.jsx(Z.PiX,{size:20}),size:"sm",variant:"ghost",onClick:()=>{s(void 0),l("")}})]})]}),a&&f.jsx("p",{role:"alert",children:a})]})}function mw({nodeAddress:e,onOpen:r}){const{structured:t,data:n,callbacks:i,editable:o,onFieldCreate:s}=j.useContext(Mt),a=Ve(),[l,c]=j.useState(""),[d,u]=j.useState("0"),[h,p]=j.useState(""),y=t==null?void 0:t.containers.get(e);if(!y||!n||!t)return null;const m=a.readOnly||a.config.editable===!1||!o,g=Te(n,y.address),b=ku(y.declared),v=y.type.kind==="array"?y.type.items:y.type.kind==="object"?y.type.additionalProperties:void 0,x=v?ku(v):[],w=!!s&&y.type.kind==="object"&&(v==null?void 0:v.kind)==="json",C=M=>M.kind==="literal"?String(M.value):M.kind==="string"?"Text":Nt(M.kind),S=[...t.slots.values()].filter(M=>M.owner===e),_=(M,P)=>{var $;return($=i.onFormChange)==null?void 0:$.call(i,{data:n,nodeAddress:y.address,address:M,previousValue:Te(n,M),value:P})},R=M=>{var P;a.setSelectedNodeIds([M]),(P=a.engineRef.current)==null||P.focusNode(M,90,!1)},A=(M,P)=>{if(!Array.isArray(g))return;const $=[...g];[$[M],$[M+P]]=[$[M+P],$[M]],_(y.address,$)},O=()=>{const M=x[Number(d)]??x[0];if(M)if(y.type.kind==="array")_(y.address,[...Array.isArray(g)?g:[],ln(M)]);else{if(!l||l.includes(".")||l.startsWith("$")||["__proto__","constructor","prototype"].includes(l)){p("Choose a property name without dots or reserved prefixes.");return}if(Object.prototype.hasOwnProperty.call(g,l)){p("Property already exists.");return}w&&(d==="file"||d==="files")?s==null||s({data:n,nodeAddress:y.address,address:`${y.address}.${l}`,previousValue:void 0,value:d==="files"?[]:""},{$control:"upload"}):_(`${y.address}.${l}`,ln(M)),c(""),p("")}},T=y.type.kind==="object"&&!!y.type.additionalProperties,E=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(Pt,{"aria-label":"Value type",disabled:m,value:String(b.findIndex(M=>_n(M,g).kind===y.type.kind)),onValueChange:M=>_(y.address,ln(b[Number(M)])),children:b.map((M,P)=>f.jsx("option",{value:P,children:C(M)},P))})})]}),S.map((M,P)=>f.jsxs("div",{"data-structured-slot":M.address,style:{display:"flex",gap:6,alignItems:"center",minWidth:0},children:[M.type.kind==="array"?f.jsx(Z.PiListNumbers,{size:20}):f.jsx(Z.PiBracketsCurly,{size:20}),f.jsx("span",{style:{flex:1,overflowWrap:"anywhere"},children:Nt(M.label)}),f.jsx(Ae,{"aria-label":`${M.present?r?"Edit":"Focus":"Create"} ${Nt(M.label)}`,title:`${M.present?r?"Edit":"Focus":"Create"} ${Nt(M.label)}`,icon:M.present?f.jsx(Z.PiMagnifyingGlass,{size:18}):f.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:m&&!M.present,onClick:$=>{var N;M.present?r?r(M.nodeId):((N=$.currentTarget.closest("dialog"))==null||N.close(),R(M.nodeId)):_(M.address,ln(M.type))}}),E&&f.jsxs(f.Fragment,{children:[f.jsx(Ae,{"aria-label":`Move item ${P+1} up`,icon:f.jsx(Z.PiArrowUp,{size:18}),size:"sm",variant:"ghost",disabled:m||P===0,onClick:()=>A(P,-1)}),f.jsx(Ae,{"aria-label":`Move item ${P+1} down`,icon:f.jsx(Z.PiArrowDown,{size:18}),size:"sm",variant:"ghost",disabled:m||P===S.length-1,onClick:()=>A(P,1)})]}),M.present&&f.jsx(Ae,{"aria-label":`Remove ${Nt(M.label)}`,icon:f.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:m,onClick:()=>E?_(y.address,g.filter(($,N)=>N!==P)):_(M.address,void 0)})]},M.address)),(E||T)&&f.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"end"},children:[T&&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:l,disabled:m,onChange:M=>c(M.target.value)})]}),x.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(Pt,{"aria-label":"New value type",value:d,disabled:m,onValueChange:u,children:[x.map((M,P)=>f.jsx("option",{value:P,children:C(M)},P)),w&&f.jsx("option",{value:"file",children:"File"}),w&&f.jsx("option",{value:"files",children:"Files"})]})})]}),f.jsx("span",{style:{display:"flex",alignItems:"center",flexShrink:0,...T||x.length>1?{height:"calc(1.4em + 20px)",fontSize:15,marginBottom:6}:{}},children:f.jsx(Ae,{"aria-label":E?"Add item":"Add property",icon:f.jsx(Z.PiPlus,{size:20}),size:"sm",variant:"ghost",disabled:m,onClick:O})})]}),h&&f.jsx("p",{role:"alert",children:h})]})}const Mt=j.createContext({callbacks:{}}),Bn=Qn.default.div`
|
|
58
|
+
`,gd=S.forwardRef(function({style:r,...t},n){return f.jsx(Z0,{...t,ref:n,style:{...r,backgroundImage:"none","--flow-range-track":(r==null?void 0:r.backgroundImage)??"none"}})});function od({label:e,inputLabel:r,value:t,displayValue:n,min:i,max:o,step:s=5,onChange:a,onChangeEnd:c}){const l=S.useId(),{readOnly:d,themeColor:u}=Ue(),{colorInactive:h}=ot(),p=(t-i)/(o-i)*100,y=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:l,style:{display:"flex",justifyContent:"space-between",fontSize:14,marginBottom:12},children:[e," ",f.jsx("span",{children:n})]}),f.jsx(gd,{id:l,"aria-label":r,type:"range",min:i,max:o,step:s,value:t,disabled:d,style:{color:y,accentColor:y,backgroundImage:`linear-gradient(to right, currentColor ${p}%, var(--chakra-colors-${h.replace(".","-")}) ${p}%)`},onChange:m=>a(Number(m.target.value)),onPointerUp:c,onKeyUp:c,onBlur:c})]})}const Cu={dot:{label:"Dots",icon:X.PiDotsNine},grid:{label:"Grid",icon:X.PiGridFour},steel:{label:"Steel",icon:X.PiLineSegments},none:{label:"Solid",icon:X.PiSquareFill},transparent:{label:"Transparent",icon:X.PiSelection}};function Um(){const{spacing:e,setSpacing:r,edgeRadius:t,setEdgeRadius:n,backgroundVariant:i,setBackgroundVariant:o,callbacks:s,readOnly:a,config:c}=Ue(),l=Cu[i].icon;return f.jsxs(f.Fragment,{children:[f.jsx(pn,{}),f.jsx(At,{"aria-label":"Node spacing",title:`Spacing: ${Math.round(e*100)}%`,icon:f.jsx(X.PiArrowsOutCardinal,{size:20}),style:{width:36},value:"spacing",disabled:a,onValueChange:()=>{},popupContent:f.jsx(od,{label:"Spacing",inputLabel:"Node spacing percentage",min:c.nodeGridSpacing==="layout"?0:50,max:200,value:Math.round(e*100),displayValue:`${Math.round(e*100)}%`,onChange:d=>{var u;r(d/100),(u=s.onSpacingChange)==null||u.call(s,d/100)}}),children:f.jsx("option",{value:"spacing",children:"Spacing"})}),f.jsx(pn,{}),f.jsx(At,{"aria-label":"Edge radius",title:`Edge radius: ${t??"Default"}`,icon:f.jsx(X.PiBezierCurve,{size:20}),style:{width:36},value:"radius",disabled:a,onValueChange:()=>{},popupContent:f.jsx(od,{label:"Edge radius",inputLabel:"Edge corner radius",min:0,max:500,value:t??500,displayValue:t??"Default",onChange:d=>{var u;n(d),(u=s.onEdgeRadiusChange)==null||u.call(s,d)}}),children:f.jsx("option",{value:"radius",children:"Edge radius"})}),f.jsx(pn,{}),f.jsxs(At,{"aria-label":"Background variant",title:`Background: ${Cu[i].label}`,icon:f.jsx(l,{size:20,"data-background-icon":i}),style:{width:36},value:i,disabled:a,onValueChange:d=>{var u;o(d),(u=s.onBackgroundVariantChange)==null||u.call(s,d)},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"})]})]})}function To(){var p;const{engineRef:e,nodeGridOptions:r,lastNodeGridOptions:t,readOnly:n,themeColor:i,callbacks:o,config:s}=Ue(),{colorText:a,colorInactive:c}=ot(),l=r??t,d=typeof l.gaps=="object"?l.gaps.x:l.gaps??l.margin??15,u=Math.max(200,d),h=y=>{var m;return(m=e.current)==null?void 0:m.setNodeGridMode(!0,{...l,...y})};return f.jsxs(f.Fragment,{children:[s.bottomBarCollision!==!1&&f.jsx(qr,{label:"Collision mode",hideLabel:!0,icon:f.jsx(X.PiGridFour,{size:20}),checked:r!==null,onChange:y=>{var m,g;((m=o.onNodeGridModeRequest)==null?void 0:m.call(o,y,l))!==!0&&((g=e.current)==null||g.setNodeGridMode(y,l))}}),r&&f.jsxs(W.HStack,{role:"group","aria-label":"Collision settings",gap:2,flexShrink:0,children:[r&&s.nodeGridSpacing!=="layout"&&f.jsxs(f.Fragment,{children:[f.jsx(W.Box,{width:"96px",flexShrink:0,display:"flex",alignItems:"center",children:f.jsx(gd,{type:"range","aria-label":"Collision gap",title:`Gap: ${d}`,min:0,max:u,step:5,value:d,disabled:n,style:{color:_e(i),backgroundImage:`linear-gradient(to right, currentColor ${d/u*100}%, ${_e(c)} ${d/u*100}%)`},onChange:y=>h({gaps:Number(y.target.value)})})}),f.jsx(W.Text,{fontSize:"xs",color:a,width:"28px",textAlign:"right",fontVariantNumeric:"tabular-nums",children:d})]}),s.bottomBarFill!==!1&&f.jsx(qr,{label:"Fill",hideLabel:!0,helper:"Fill available canvas space",icon:f.jsx(X.PiArrowsOut,{size:18}),checked:!!r&&!!l.fill,onChange:y=>{var m,g;!r&&((m=o.onNodeGridModeRequest)==null?void 0:m.call(o,!0,{...l,fill:y}))===!0||y&&((g=o.onNodeGridFillRequest)==null?void 0:g.call(o,{...l,fill:y}))===!0||h({fill:y})}}),r&&l.fill&&f.jsx(qr,{label:"Grid adjustment",hideLabel:!0,icon:f.jsx(X.PiArrowsHorizontal,{size:20}),checked:!!((p=l.adjustment)!=null&&p.enabled),onChange:y=>{n||h({adjustment:{...l.adjustment,enabled:y}})}})]})]})}const vt=[];for(let e=0;e<256;++e)vt.push((e+256).toString(16).slice(1));function X0(e,r=0){return(vt[e[r+0]]+vt[e[r+1]]+vt[e[r+2]]+vt[e[r+3]]+"-"+vt[e[r+4]]+vt[e[r+5]]+"-"+vt[e[r+6]]+vt[e[r+7]]+"-"+vt[e[r+8]]+vt[e[r+9]]+"-"+vt[e[r+10]]+vt[e[r+11]]+vt[e[r+12]]+vt[e[r+13]]+vt[e[r+14]]+vt[e[r+15]]).toLowerCase()}let Oo;const Y0=new Uint8Array(16);function Q0(){if(!Oo){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Oo=crypto.getRandomValues.bind(crypto)}return Oo(Y0)}const ew=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Su={randomUUID:ew};function yd(e,r,t){var i;if(Su.randomUUID&&!e)return Su.randomUUID();e=e||{};const n=e.random??((i=e.rng)==null?void 0:i.call(e))??Q0();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,X0(n)}const to={label:"Untitled",description:"",isTask:!1,isLocked:!1},md={id:null,type:"text",data:{...to,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"}}},ju={id:null,type:"objectView",data:{...to,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:53,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},tw={id:null,type:"arrayView",data:{...to,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"}}},_u={id:null,type:"workflowStep",data:{...to,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}},Pt=e=>typeof e=="object",Hm=e=>Array.isArray(e),rw=["order","position","selected","locked","grabbed","grabbable","scratch"],dr=e=>Object.entries(e).reduce((r,[t,n])=>(!Pt(n)&&!t.startsWith("$")&&(r[t]=n),r),{}),bd=(e,r)=>typeof e=="string"&&e.startsWith("$")?No(e,r):Pt(e)&&!Hm(e)?Object.entries(e).reduce((t,[n,i])=>(typeof i=="string"&&i.startsWith("$")&&n==="..."?(delete t["..."],t[n]={...No(i,r),...e}):typeof i=="string"&&i.startsWith("$")?t[n]=No(i,r):t[n]=i,t),{}):e,ur=e=>Object.entries(e).reduce((r,[t,n])=>(Pt(n)&&t&&n&&!t.startsWith("$")&&(rw.includes(t)&&(t=t+"#"),r[t]=n),r),{}),wr=(e,r,{label:t,parent:n=void 0},i,o=null)=>(o!==null&&(Pt(o)||Hm(o))&&(o=JSON.stringify(o,null,2)),{data:{parent:n,...e.data,id:r,text:t||"",label:t,code:o||null,type:e.type,description:i}}),sr=(e,r,t=null,n=null,i=null,o=!1,s=null)=>({data:{id:yd(),source:i?r:e,target:i?e:r,label:n||"",isInverted:i,isEdgeAnimated:o,parent:s}}),fr=(e,r=[])=>{const t={},n={};let i=[];if(e)for(const[o,s]of Object.entries(e))o.startsWith("$")&&o!=="$"?t[o.slice(1)]=s:o!=="$"?n[o]=s:o==="$"&&(i=s);return{newConfig:t,updatedObject:n,arrayObject:i}},Nr=(e,r)=>{let t=ju;const{view:n,borderColor:i,borderRadius:o,bgColor:s,textColor:a,fontSize:c,stepType:l}=r;e=n||e,l?t={..._u}:e==="object"?t=ju:e==="text"?t=md:e==="array"?t=tw:e==="workflowStep"&&(t={..._u});const d=t.data.viewProps;return t.data.viewProps={...d,borderRadius:o||(l?15:53),bgColor:s,borderColor:i,textColor:a,fontSize:c},t.data.config=r,{config:t}},Sn=(e,r)=>(e=r.find(n=>n.data.id===e)?`${e}.#`:e,e),No=(e,{ids:r,jsnObjct:t})=>{if(typeof e=="string"&&(e!=null&&e.startsWith("$"))){const n=e.replace("$","").replace("*","");e==null||e.endsWith("*");const i=r.find(a=>a.split(".").slice(-1)[0]===n||n===a);if(!i)return e;const o=nw(i,t);return JSON.stringify(o).includes(e)?e:o||e}return e},nw=(e,r)=>{let t=e.split(".").splice(1);return t=t[t.length-1]==="#"||t[t.length-1].includes("{")?t.slice(0,-2):t,(o=>t.reduce((s,a)=>{a=a.replace("[","").replace("]","");const{arrayObject:c}=fr(s);return s=c.length?c:s,s[a]},o))(r)};function Lr(e,r="root",t=[]){try{const{arrayObject:n}=fr(e);n.length&&(e=n);const i=dr(e),o=ur(e);return Pt(e)?(Qe(e)||Qe(e)&&r==="root"||!Qe(e)&&Object.keys(i).length||r==="root")&&t.push(r):t.push(r),Object.keys(o).length&&!Qe(e)?gn({chldPth:null,itrblObjct:o,nodes:t,path:r}):Qe(e)&&e.forEach((s,a)=>{const c=dr(s),l=ur(s),{newConfig:d,arrayObject:u}=fr(s);let h=`${r}.${a}`;Pt(s)?Object.keys(c).length?(Lr(c,h,t),Object.keys(l).length&&!Qe(s)&&gn({chldPth:h,itrblObjct:l,nodes:t,path:r})):Object.keys(l).length&&!Qe(s)?gn({chldPth:h,itrblObjct:l,nodes:t,path:r}):Qe(s)&&Km({chldPth:h,item:s,nodes:t,path:r}):t.push(h)}),{nodes:t}}catch{return{nodes:t}}}const gn=({chldPth:e,itrblObjct:r,nodes:t,path:n})=>Object.entries(r).forEach(([i,o],s)=>{const a=dr(o),c=ur(o),{newConfig:l,arrayObject:d}=fr(o);d.length&&(o=d),n.split(".").slice(0,2).join(".");let u=e?`${e}.${i}`:`${n}.${i}`;if(Pt(o)&&!Qe(o)){const h=Object.keys(a).length===0;if(h&&(Nr("array",l),t.push(u)),Object.keys(a).length){const p=Qe(o)?`${o.length||""}`:`{${Object.keys(o).length||""}}`;let y=u;h&&(y=`${u}.${p}`),Lr(o,y,t)}else Object.keys(c).length&&!Qe(o)?gn({chldPth:u,itrblObjct:c,path:u,nodes:t}):Lr(o,u,t)}else Qe(o)&&Lr(o,u,t)}),Km=({chldPth:e,item:r,nodes:t,path:n})=>r.forEach((i,o)=>{let s=`${e}.${o}`;const a=ur(i),c=dr(i);Pt(i)?!Qe(i)&&Object.keys(c).length?Lr(i,s,t):Object.keys(a).length&&!Qe(i)?gn({chldPth:s,itrblObjct:a,path:n,nodes:t}):Qe(i)&&Km({chldPth:s,item:i,nodes:t,path:n}):t.push(s)}),yn=[];let mn;function jr(e,r="root",t=[],n=[],i="untitled",o={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},s={}){if(!e||typeof e!="object")return console.error("Invalid object passed",e),{nodes:t,edges:n};const a=e;if(r==="root"&&(yn.length=0),!mn){const{nodes:d}=Lr(e);mn={ids:d,jsnObjct:e}}let{hideDefaultObject:c,sprtObjctKy:l}=o;try{r=Sn(r,t);const{newConfig:d,arrayObject:u}=fr(e),h=Object.keys(s).length>0?s:d;u.length&&(e=u);const p=dr(e),y=ur(e),{label:m,collapsed:g,parent:b}=h;if(!Pt(e))t.push(wr(md,r,{label:m||r,parent:b},e,a));else if(Qe(e)||Qe(e)&&r==="root"){const{config:v}=Nr("array",h),x=Qe(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,w=r==="root"?i:`${i} ${x}`;t.push(wr(v,r,{label:m||w,parent:b},e,Qe(a)?{[i]:a}:a))}else if(!Qe(e)&&Object.keys(p).length||r==="root"){const{config:v}=Nr(null,h),x=Qe(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,w=r.split("."),C=w[w.length-1];let j=isNaN(Number(C))?null:Number(C)+1;const _=isNaN(Number(C))?C:w[w.length-2]+" "+j,k=r==="root"?i:_;let E=!1;Number.isNaN(Number(i))||(E=!0);const O=e;if(m){const{config:T}=Nr("object",h);t.push(wr(T,r,{label:m||`${m} ${x}`,parent:b},p,O))}else v.data.headerTitle=k,t.push(wr(v,r,{label:m,parent:b},p,O))}return g||(Object.keys(y).length&&!Qe(e)?bn({flowConfig:o,chldPth:null,edges:n,isInverted:null,itrblObjct:y,nodes:t,path:r,newConfig:h}):Qe(e)&&e.forEach((v,x)=>{v=bd(v,mn);const w=v,C=dr(v),j=ur(v),{newConfig:_,arrayObject:k}=fr(v);k.length&&(v=k);const{config:E}=Nr(typeof v=="string"?"text":"array",_),{hideConfig:O,sourceLabel:T,label:P,isEdgeAnimated:I,parent:R}=_;c=c||O;const $=r==="root"&&o.isCntr,N=r.split(".").slice(0,2).join("."),M=yn.includes(N),J=o.isCntr&&M||x%2===0&&$;let ie=`${r}.${x}`;ie=Sn(ie,t),J&&yn.push(ie),Pt(v)?Object.keys(C).length&&!Qe(v)?(n.push(sr(r,ie,null,T,J,I)),jr(v,ie,t,n,P||x,o,_)):Object.keys(j).length&&!Qe(v)?bn({flowConfig:o,chldPth:ie,isInverted:J,edges:n,itrblObjct:j,nodes:t,path:r,newConfig:_,forceIsInverted:!0}):Qe(v)?Jm({flowConfig:o,chldPth:ie,edges:n,isInverted:J,item:v,nodes:t,path:r}):Pt(v)&&bn({flowConfig:o,chldPth:ie,isInverted:J,edges:n,itrblObjct:[v],nodes:t,path:r,newConfig:_}):(n.push(sr(r,ie,null,T,J,I)),t.push(wr(E,ie,{label:P||String(v),parent:R},v,w)))})),{nodes:t,edges:n}}catch{return{nodes:t,edges:n}}}const bn=({chldPth:e,flowConfig:r,edges:t,itrblObjct:n,nodes:i,isInverted:o,path:s,newConfig:a,forceIsInverted:c=!1})=>{let{hideDefaultObject:l,sprtObjctKy:d}=r;return Object.entries(n).forEach(([u,h],p)=>{h=bd(h,mn);const y=h,m=dr(h),g=ur(h),{newConfig:b,arrayObject:v}=fr(h);v.length&&(h=v);const{hideConfig:x,sourceLabel:w,label:C,content:j,target:_,targetLabel:k,collapsed:E,isEdgeAnimated:O,parent:T}=b;l=l||x;const P=s==="root"&&r.isCntr,I=s.split(".").slice(0,2).join("."),R=yn.includes(I);c||(o=r.isCntr&&R||p%2===0&&P);let $=e?`${e}.${u}`:`${s}.${u}`;if($=Sn($,i),o&&yn.push($),_&&t.push(sr($,_,null,k,o,O)),Pt(h)&&!Qe(h)){t.push(sr(s,$,null,w,o,O));const N=d||Object.keys(m).length===0;if(N){const M=j?"object":"array",{config:J}=Nr(M,b);J.data.headerTitle=j?C:null,i.push(wr(J,$,{label:C||u,parent:T},h,y))}if(Object.keys(m).length&&!l){const M=Qe(h)?` ${h.length||""}`:`{${Object.keys(h).length||""}}`;let J=$;N&&(J=`${$}.${M}`,J=Sn(J,i),t.push(sr($,J,null,w,o,O))),jr(h,J,i,t,C||u,r,b)}else Object.keys(g).length&&!Qe(h)?bn({chldPth:$,flowConfig:r,itrblObjct:g,path:$,edges:t,nodes:i,newConfig:b,isInverted:o}):jr(h,$,i,t,u,r,b)}else Qe(h)&&(t.push(sr(s,$,null,w,o,O)),jr(h,$,i,t,u,r,b))})},Jm=({flowConfig:e,chldPth:r,edges:t,isInverted:n,item:i,nodes:o,path:s})=>i.forEach((a,c)=>{let l=`${r}.${c}`;l=Sn(l,o);const d=a;a=bd(a,mn);const u=ur(a),h=dr(a),{newConfig:p}=fr(a),{collapsed:y,label:m,parent:g,sourceLabel:b,isEdgeAnimated:v,content:x}=p;Pt(a)?!Qe(a)&&Object.keys(h).length?(t.push(sr(s,l,null,b,n,v)),jr(a,l,o,t,c,e,p)):Object.keys(u).length&&!Qe(a)&&!y?bn({chldPth:l,flowConfig:e,itrblObjct:u,path:s,edges:t,nodes:o,isInverted:n,newConfig:p}):Qe(a)&&Jm({flowConfig:e,chldPth:l,edges:t,isInverted:n,item:a,nodes:o,path:s}):(t.push(sr(s,l,null,b,n,v)),o.push(wr(md,l,{label:m||String(a),parent:g},a,d)))});function ow(e,r){const t=new Set,n=(l,d="root")=>{if(!(!l||typeof l!="object")){l.$view==="parent"&&t.add(d),typeof l.$parent=="string"&&t.add(l.$parent);for(const[u,h]of Object.entries(l))(!u.startsWith("$")||u==="$")&&n(h,u==="$"?d:`${d}.${u}`)}};if(n(e),!t.size)return r;const i=new Map(r.nodes.map(l=>[l.data.id,l])),o=l=>{var p,y;let d=l.data.id;const u=new Set([l.data.id]);let h=l.data.parent;for(;h&&!u.has(h);)t.has(h)&&i.has(h)&&((p=Te(e,h))!=null&&p.$collapsed)&&(d=h),u.add(h),h=(y=i.get(h))==null?void 0:y.data.parent;return d},s=new Map(r.nodes.map(l=>[l.data.id,o(l)])),a=r.nodes.filter(l=>s.get(l.data.id)===l.data.id).map(l=>{if(!t.has(l.data.id))return l;const d=Te(e,l.data.id),u=!!(d!=null&&d.$collapsed);return{...l,data:{...l.data,...u?{type:"arrayView"}:{},config:{...l.data.config,parentContainer:!0,collapsed:u,...u?{labelBelow:!0,icon:(d==null?void 0:d.$icon)||"PiStack"}:{}}}}}),c=new Set(a.map(l=>l.data.id));return{nodes:a,edges:r.edges.flatMap(l=>{const d=s.get(l.data.source),u=s.get(l.data.target);return!d||!u||!c.has(d)||!c.has(u)?[]:d===l.data.source&&u===l.data.target?[l]:d===u?[]:[{...l,data:{...l.data,source:d,target:u,collapsedEndpoints:l.data.collapsedEndpoints??{source:l.data.source,target:l.data.target}}}]})}}function ro(e){if(!Array.isArray(e==null?void 0:e.$connections))return[];const r=new Map;return e.$connections.flatMap((t,n)=>{if(!t||typeof t!="object")return[];const i=t;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=r.get(o)??0;return r.set(o,s+1),[{value:i,key:`${o}#${s}`,index:n}]})}function Zm(e,r,t){const n=ro(e).find(c=>c.key===r);if(!n)return e;const i=t(n.value),o=e.$connections.flatMap((c,l)=>l===n.index?i?[i]:[]:[c]);if(o.length)return{...e,$connections:o};const{$connections:s,...a}=e;return a}function iw(e){const r=[],t=(n,i)=>{if(!n||typeof n!="object")return n;if(Array.isArray(n))return n.map((o,s)=>t(o,`${i}.${s}`));for(const o of ro(n)){const s=o.value;r.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==="$"?t(s,i):o.startsWith("$")?s:t(s,`${i}.${o}`)]))};return{json:t(e,"root"),edges:r}}const Fr="root",Eu=e=>e==="#"||e.startsWith("{")||/^\s\d*$/.test(e);function Ft(e){const r=e.split(".");for(r[0]===Fr&&r.shift();r.length&&Eu(r[r.length-1]);)r.pop();return r.filter(t=>!Eu(t))}function no(e){return e==null||typeof e!="object"?e:Array.isArray(e.$)?e.$:e}function Te(e,r){return Ft(r).reduce((t,n)=>{var i;if(t!=null)return(i=no(t))==null?void 0:i[n]},e)}function aw(e){return Array.isArray(e)?[...e]:{...e}}function _t(e,r,t){const n=Ft(r),i=(o,s)=>{if(s===n.length)return t(o);const a=n[s],c=no(o);if(c==null||typeof c!="object")return o;const l=i(c[a],s+1);if(Object.is(l,c[a]))return o;const d=aw(c);return d[a]=l,c!==o?{...o,$:d}:d};return i(e,0)}function Yt(e,r,t){const n=t===""&&r!=="$content"||t===void 0||t===null;if(Array.isArray(e))return n?e:{[r]:t,$:[...e]};const i=e!=null&&typeof e=="object"?{...e}:{};return e!=null&&typeof e!="object"&&(i.$label=String(e)),n?delete i[r]:i[r]=t,i}function xt(e,r,t,n){return _t(e,r,i=>t==="$label"&&typeof i=="string"&&typeof n=="string"&&n!==""?n:Yt(i,t,n))}const vd=(e,r,t)=>xt(e,r,"$collapsed",t);function Cr(e){if(e.connection)return{address:e.connection.address,kind:"connection"};const r=e.collapsedEndpoints??e,t=e.isInverted?r.target:r.source,n=e.isInverted?r.source:r.target,i=Ft(t).join("."),o=Ft(n).join(".");return o.startsWith(i?i+".":"")&&o!==i?{address:n,kind:"hierarchy"}:i.startsWith(o?o+".":"")&&i!==o?{address:t,kind:"hierarchy"}:{address:t,kind:"target"}}function ar(e,r,t,n){if(r.connection){const a=r.connection;return _t(e,a.address,c=>Zm(c,a.key,l=>{if(t==="$edgeIcon")return Yt(l,"icon",n);if(t==="$edgeType")return Yt(l,"type",n);if(t==="$edgeAnimationVariant")return Yt(l,"animationVariant",n);if(t==="$sourceLabel"||t==="$edgeColor")return Yt(l,t==="$sourceLabel"?"label":"color",n);const d=t==="$isEdgeAnimated"?"animated":"dashed";return n?{...l,style:d}:l.style===d?Yt(l,"style",void 0):l}))}const{address:i,kind:o}=Cr(r),s=o==="target"&&t==="$sourceLabel"?"$targetLabel":o==="target"&&t==="$edgeType"?"$targetEdgeType":o==="target"&&t==="$edgeIcon"?"$targetIcon":o==="target"&&t==="$edgeAnimationVariant"?"$targetAnimationVariant":t;return _t(e,i,a=>Yt(a,s,n))}const Xm=(e,r,t)=>ar(ar(e,r,"$isEdgeAnimated",t==="animated"||void 0),r,"$isEdgeDashed",t==="dashed"||void 0);function xd(e,r,t,n){let i=n||"";const o=_t(e,r,a=>{const c=no(a);if(Array.isArray(c)){i=String(c.length);const d=[...c,t];return c===a?d:{...a,$:d}}const l=a!=null&&typeof a=="object"&&!Array.isArray(a)?{...a}:a!=null&&typeof a!="object"?{$label:String(a)}:{};if(!i){let d=1;for(;`node_${d}`in l;)d++;i=`node_${d}`}return l[i]=t,l}),s=Ft(r);return{json:o,address:[Fr,...s,i].join(".")}}function Ym(e,r){const t=Ft(r);if(!t.length)return e;const n=t[t.length-1],i=[Fr,...t.slice(0,-1)].join(".");return _t(e,i,o=>{const s=no(o);if(s==null||typeof s!="object"||!Object.prototype.hasOwnProperty.call(s,n))return o;if(Array.isArray(s)){const l=s.filter((d,u)=>String(u)!==n);return s===o?l:{...o,$:l}}const{[n]:a,...c}=o;return c})}const Qm=(e,r,t,n)=>xt(n?_t(e,r,i=>Yt(i,"$targetLabel",n)):e,r,"$target",t);function wd(e,r,t){const n=Te(e,r);return ro(n).some(({value:o})=>o.target===t.target&&o.sourceProperty===t.sourceProperty&&o.targetProperty===t.targetProperty)?e:_t(e,r,o=>Yt(o,"$connections",[...Array.isArray(o==null?void 0:o.$connections)?o.$connections:[],{...t,id:t.id||yd()}]))}function eb(e,r){if(r.connection){const o=r.connection;return ro(Te(e,o.address)).some(s=>s.key===o.key)?{json:_t(e,o.address,s=>Zm(s,o.key,()=>null)),removed:!0}:{json:e,removed:!1}}const{address:t,kind:n}=Cr(r);return n==="hierarchy"?Te(e,t)===void 0?{json:e,removed:!1}:{json:_t(e,t,o=>({...o,$hideParentEdge:!0})),removed:!0}:n!=="target"?{json:e,removed:!1}:{json:_t(e,t,o=>{const{$target:s,$targetLabel:a,...c}=o||{};return c}),removed:!0}}function id(e,r={}){var v;const t=iw(e),{nodes:n,edges:i}=jr(t.json,Fr,[],[],r.title||"untitled",{hideDefaultObject:!!r.hideDefaultObject,sprtObjctKy:!!r.separateObjectKeys,isCntr:!!r.isCenter}),o=new Set(n.map(x=>x.data.id)),s=new Map;for(const x of n){const w=x.data.id;if(!w.endsWith(".0")||Te(e,w)!==void 0)continue;const C=w.slice(0,-2),j=Te(e,C);!o.has(C)&&j&&typeof j=="object"&&!Array.isArray(j)&&typeof j.$label=="string"&&Object.keys(j).every(_=>_.startsWith("$")&&_!=="$")&&s.set(w,C)}const a=x=>s.get(x)??x,c=new Set(n.flatMap(x=>x.data.parent?[a(x.data.parent)]:[])),l=new Map;if(r.isCenter){const x=new Map;for(const{data:w}of i){const C=Cr(w);if(C.kind==="hierarchy")l.set(a(C.address),!!w.isInverted);else if(!Array.isArray(e)&&e.$hideRoot===!0){const j=a(w.isInverted?w.source:w.target);if(Ft(j).length!==1)continue;const _=!!w.isInverted;x.set(j,x.has(j)&&x.get(j)!==_?null:_)}}for(const[w]of l){const C=`${Fr}.${Ft(w)[0]}`,j=x.get(C);typeof j=="boolean"&&l.set(w,j)}}const d=n.map(x=>{var E;const w=a(x.data.id),C=Te(e,w),j={...x.data,id:w};l.has(w)&&(j.config={...j.config,isInverted:l.get(w)});const _=C&&typeof C=="object"&&!Array.isArray(C)&&"$"in C?C.$:C;if((Array.isArray(_)?_.length>0:_&&typeof _=="object"&&Object.keys(_).some(O=>!O.startsWith("$")))&&(j.config={...j.config,collapsed:!!C.$collapsed}),c.has(w)||(j.viewProps={...j.viewProps},delete j.viewProps.borderWidth),!C||typeof C!="object"||Array.isArray(C))return{data:j};if(C.$view==="parent"&&(j.type="objectView",j.config={...j.config,typeView:"parent",parentContainer:!0,collapsed:!!C.$collapsed}),C.$view==="grid"){j.type="grid";const O=C.$gridSize;if(O!==void 0&&(!O||![O.width,O.height].every(T=>Number.isFinite(T)&&T>0&&T<=16384)))throw new Error("Invalid grid frame size.");j.config={...j.config,typeView:"grid",documentId:C.$document,gridSize:O},j.viewProps={...j.viewProps,bgColor:C.$bgColor??"transparent",borderRadius:C.$borderRadius??0,borderWidth:C.$borderWidth??0}}if(C.$form&&typeof C.$form=="object"&&(j.config={...j.config,form:C.$form},j.type="objectView"),Array.isArray(C.$ports)){const O=C.$ports.filter(T=>T&&typeof T.id=="string"&&["source","target"].includes(T.role)&&["top","right","bottom","left"].includes(T.side));j.config={...j.config,ports:O}}if(j.parent&&(j.parent=a(j.parent)),typeof C.$label=="string"&&(j.label=C.$label,j.headerTitle=C.$label),typeof C.$subtitle=="string"&&(j.config={...j.config,subtitle:C.$subtitle}),typeof C.$outline=="boolean"&&(j.viewProps={...j.viewProps,outline:C.$outline}),["solid","dashed","dotted","double"].includes(C.$borderStyle)&&(j.viewProps={...j.viewProps,borderStyle:C.$borderStyle}),Number.isFinite(C.$borderWidth)&&C.$borderWidth>=0&&(j.viewProps={...j.viewProps,borderWidth:C.$borderWidth}),Number.isFinite(C.$borderRadius)&&C.$borderRadius>=0&&(j.viewProps={...j.viewProps,borderRadius:C.$borderRadius}),typeof C.$isNodeAnimated=="boolean"&&(j.isNodeAnimated=C.$isNodeAnimated),["traveling","pulse"].includes(C.$nodeAnimationVariant)&&(j.nodeAnimationVariant=C.$nodeAnimationVariant),typeof C.$content=="string"||C.$contentFormat==="jsx"&&Array.isArray(C.$content)){j.config={...j.config,content:C.$content};const O=C.$contentFormat??"markdown";if(!["markdown","html","jsx"].includes(O))throw new Error("Invalid content format: expected markdown, html, or jsx.");j.config.contentFormat=O,C.$view||(j.type="objectView")}return(((E=j.config)==null?void 0:E.collapsed)!==void 0||C.$collapsed!==void 0||C.$icon!==void 0)&&(j.config={...j.config||{}},(C.$collapsed!==void 0||j.config.collapsed!==void 0)&&(j.config.collapsed=!!C.$collapsed),C.$icon!==void 0&&(j.config.icon=C.$icon)),{data:j}}),u=new Map,h=i.map(x=>{let w=a(x.data.source),C=a(x.data.target),j=x.data.isInverted;const _=Cr(x.data),k=l.get(a(_.address));_.kind==="hierarchy"&&k!==void 0&&k!==!!j&&([w,C]=[C,w],j=k);const E=`${w}->${C}`,O=u.get(E)??0;u.set(E,O+1);const T={...x.data,id:O?`${E}#${O}`:E,source:w,target:C,isInverted:j},P=Cr(T),I=Te(e,P.address);if(I&&typeof I=="object"){const R=I[P.kind==="target"?"$targetEdgeType":"$edgeType"];typeof R=="string"&&(T.type=R);const $=I[P.kind==="target"?"$targetIcon":"$edgeIcon"];typeof $=="string"&&(T.icon=$),I.$isEdgeAnimated!==void 0&&(T.isEdgeAnimated=!!I.$isEdgeAnimated);const N=I[P.kind==="target"?"$targetAnimationVariant":"$edgeAnimationVariant"];["dashed","traveling"].includes(N)&&(T.edgeAnimationVariant=N),I.$isEdgeDashed!==void 0&&(T.isEdgeDashed=!!I.$isEdgeDashed),I.$edgeColor&&(T.color=I.$edgeColor)}return{data:T}});if(!Array.isArray(e)&&(e==null?void 0:e.$hideRoot)===!0){const x=d.findIndex(w=>w.data.id===Fr);x!==-1&&d.splice(x,1)}const p=new Set(d.map(x=>x.data.id));for(let x=h.length-1;x>=0;x--){const w=h[x].data,C=Cr(w);(!p.has(w.source)||!p.has(w.target)||C.kind==="hierarchy"&&((v=Te(e,C.address))==null?void 0:v.$hideParentEdge)===!0)&&h.splice(x,1)}h.push(...t.edges.filter(x=>p.has(x.data.source)&&p.has(x.data.target)));const y=ow(e,{nodes:d,edges:h}),m=y.nodes.filter(x=>{var w;return(w=x.data.config)==null?void 0:w.collapsed}).map(x=>Ft(x.data.id));if(!m.length)return y;const g=y.nodes.filter(x=>{const w=Ft(x.data.id);return!m.some(C=>C.length<w.length&&C.every((j,_)=>j===w[_]))}),b=new Set(g.map(x=>x.data.id));return{nodes:g,edges:y.edges.filter(x=>b.has(x.data.source)&&b.has(x.data.target))}}function sw(e,r){const t=new Set(e.filter(c=>{var l,d;return(d=(l=c.data)==null?void 0:l.config)==null?void 0:d.collapsed}).map(c=>c.data.id));if(!t.size)return{nodes:e,edges:r};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 l=c.data.id,d=c.data.parent;const u=new Set([l]);for(;d&&!u.has(d);)t.has(d)&&(l=d),u.add(d),d=(h=n.get(d))==null?void 0:h.data.parent;return[c.data.id,l]})),s=new Map;for(const c of r){const l=c.data.isInverted?c.data.target:c.data.source,d=c.data.isInverted?c.data.source:c.data.target;(s.get(l)??s.set(l,[]).get(l)).push(d)}const a=new Set(e.filter(c=>o.get(c.data.id)!==c.data.id).map(c=>c.data.id));for(const c of t){if(i.has(c))continue;const l=[...s.get(c)||[]];for(;l.length;){const d=l.pop();t.has(d)||a.has(d)||(a.add(d),l.push(...s.get(d)||[]))}}return{nodes:e.filter(c=>!a.has(c.data.id)).map(c=>{var l;return t.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:((l=c.data.config)==null?void 0:l.icon)||"PiStack"}}}:c}),edges:r.flatMap(c=>{const l=o.get(c.data.source)??c.data.source,d=o.get(c.data.target)??c.data.target;return a.has(l)||a.has(d)?[]:l===c.data.source&&d===c.data.target?[c]:l===d?[]:[{...c,data:{...c.data,source:l,target:d,collapsedEndpoints:c.data.collapsedEndpoints??{source:c.data.source,target:c.data.target}}}]})}}function Cd(e,r){const t=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 d of Object.keys(s))if(!c.has(d))throw new Error(`Unsupported JSON Schema keyword: ${d}`);const l=["$schema","$id","$defs","definitions","title","description","default","examples"];if(s.$ref){if(Object.keys(s).some(u=>!["$ref","title","description"].includes(u)))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 d=t;for(const u of s.$ref.slice(2).split("/")){const h=u.replace(/~1/g,"/").replace(/~0/g,"~");if(!d||!Object.prototype.hasOwnProperty.call(d,h))throw new Error(`Unresolved reference: ${s.$ref}`);d=d[h]}return i(d,[...a,s.$ref])}if(s.anyOf){if(!Array.isArray(s.anyOf)||!s.anyOf.length||Object.keys(s).some(d=>d!=="anyOf"&&!l.includes(d)))throw new Error("Use a nonempty anyOf without sibling type constraints.");return{kind:"union",types:s.anyOf.map(d=>i(d,a))}}if(Object.prototype.hasOwnProperty.call(s,"const")||s.enum){if(Object.keys(s).some(h=>![...l,"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 d=Object.prototype.hasOwnProperty.call(s,"const")?[s.const]:s.enum;if(!Array.isArray(d)||!d.length)throw new Error("Expected a nonempty enum.");return{kind:"union",types:d.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(d=>typeof d!="string"))throw new Error("Expected a nonempty list of primitive types.");if(Object.keys(s).some(d=>d!=="type"&&!l.includes(d)))throw new Error("Use anyOf for unions with object or array constraints.");return{kind:"union",types:s.type.map(d=>i({type:d},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(u=>typeof u!="string"||!Object.prototype.hasOwnProperty.call(s.properties,u))))throw new Error("required must list declared property names.");return{kind:"object",properties:Object.fromEntries(Object.entries(s.properties).map(([u,h])=>[u,{type:i(h,a),optional:!(s.required??[]).includes(u)}]))}}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(t);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:r,nodes:o.properties}}async function Sd(e,r,t,n={}){var y;let i=512;const o=await import("typescript"),s=o.createSourceFile(r,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 l=(m,g)=>{var C;const b={},v=m.find(j=>o.isIndexSignatureDeclaration(j));let x;if(v&&n.allowJson&&o.isIndexSignatureDeclaration(v)){if(m.filter(j=>o.isIndexSignatureDeclaration(j)).length!==1||v.parameters.length!==1||((C=v.parameters[0].type)==null?void 0:C.kind)!==o.SyntaxKind.StringKeyword||!v.type)throw new Error("Only one string-keyed index signature is supported for forms.");x=u(v.type,g)}return{kind:"object",properties:Object.fromEntries(m.filter(j=>j!==v||!x).map(j=>{if(!o.isPropertySignature(j)||!j.type||!j.name||!o.isIdentifier(j.name)&&!o.isStringLiteral(j.name))throw new Error("Only explicitly typed named properties are supported.");const _=u(j.type,g),k=n.allowJson?o.getJSDocTags(j).filter(E=>E.tagName.text==="port"):[];if(k.length>1)throw new Error(`Duplicate port declaration: ${j.name.text}`);if(k.length){const[E,O,T]=String(k[0].comment??"").trim().split(/\s+/);if(E!=="config"||!O||T||!c.has(O))throw new Error(`Config port ${j.name.text} requires @port config ResourceType`);const P=_.kind==="array";if((_.kind==="array"?_.items.kind:_.kind)!=="string")throw new Error(`Config port ${j.name.text} must be a string or string array reference`);b[j.name.text]={kind:"config",resourceType:O,multiple:P}}return[j.name.text,{type:_,optional:!!j.questionToken}]})),...x?{additionalProperties:x}:{},...Object.keys(b).length?{ports:b}:{}}},d=(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 v;if(o.isInterfaceDeclaration(b)){if((C=b.heritageClauses)!=null&&C.length)throw new Error("Interface inheritance is not supported; declare properties explicitly.");v=l(b.members,[...g,m])}else v=u(b.type,[...g,m]);const x=n.allowJson?o.getJSDocTags(b).filter(j=>j.tagName.text==="port"):[];if(!x.length)return v;if(v.kind!=="object")throw new Error("Node ports require an object interface");const w={...v.ports};for(const j of x){const[_,k,...E]=String(j.comment??"").trim().split(/\s+/);if(!["input","output","error"].includes(_)||!/^[A-Za-z][\w-]*$/.test(k??""))throw new Error("Node ports require @port input|output|error Name");const O=E.length?JSON.parse(E.join(" ")):void 0;if(O!==void 0&&typeof O!="string")throw new Error("Node port labels must be JSON strings");if(Object.prototype.hasOwnProperty.call(w,k))throw new Error(`Duplicate port declaration: ${k}`);w[k]={kind:_,...typeof O=="string"?{label:O}:{}}}return{...v,ports:w}},u=(m,g)=>{var b,v,x;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 u(m.type,g);if(o.isUnionTypeNode(m))return{kind:"union",types:m.types.map(w=>u(w,g))};if(o.isArrayTypeNode(m))return{kind:"array",items:u(m.elementType,g)};if(o.isTypeLiteralNode(m))return l(m.members,g);if(o.isLiteralTypeNode(m)){const w=m.literal;if(o.isStringLiteral(w))return{kind:"literal",value:w.text};if(o.isNumericLiteral(w))return{kind:"literal",value:Number(w.text)};if(w.kind===o.SyntaxKind.NullKeyword)return{kind:"null"};if(w.kind===o.SyntaxKind.TrueKeyword||w.kind===o.SyntaxKind.FalseKeyword)return{kind:"literal",value:w.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:u(m.typeArguments[1],g)};if(m.typeName.text==="Array"&&((v=m.typeArguments)==null?void 0:v.length)===1)return{kind:"array",items:u(m.typeArguments[0],g)};if(!((x=m.typeArguments)!=null&&x.length))return d(m.typeName.text,g)}throw new Error(`Unsupported TypeScript type: ${m.getText(s)}`)},h=t??(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=d(h,[]);if(p.kind!=="object")throw new Error("Graph must be an object keyed by node ID.");return p}async function tb(e,r){const t=await Sd(e,r);if(Object.values(t.properties).some(n=>n.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:r,nodes:t.properties}}function cn(e,r){if(e.kind==="json"||r.kind==="json"||e.kind==="object"&&e.additionalProperties||r.kind==="object"&&r.additionalProperties)return!1;if(e.kind==="union")return e.types.every(t=>cn(t,r));if(r.kind==="union")return r.types.some(t=>cn(e,t));if(e.kind==="literal"){if(r.kind==="literal")return e.value===r.value;const t=e.value===null?"null":typeof e.value;return r.kind===t||r.kind==="integer"&&typeof e.value=="number"&&Number.isInteger(e.value)}return e.kind==="integer"&&r.kind==="number"?!0:e.kind==="array"&&r.kind==="array"?cn(e.items,r.items):e.kind==="object"&&r.kind==="object"?Object.entries(r.properties).every(([t,n])=>{const i=Object.prototype.hasOwnProperty.call(e.properties,t)?e.properties[t]:void 0;return i?(n.optional||!i.optional)&&cn(i.type,n.type):n.optional}):e.kind===r.kind}function jd(e,r){if(!r.sourceProperty&&!r.targetProperty)return;const t=(s,a)=>{var d;const c=Object.prototype.hasOwnProperty.call(e.nodes,s)?s:s.replace(/^root\./,""),l=Object.prototype.hasOwnProperty.call(e.nodes,c)?(d=e.nodes[c])==null?void 0:d.type:void 0;return a&&(l==null?void 0:l.kind)==="object"&&Object.prototype.hasOwnProperty.call(l.properties,a)?l.properties[a]:void 0},n=t(r.source,r.sourceProperty),i=t(r.target,r.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(!cn(n.type,i.type))return`Incompatible property types: ${r.sourceProperty} -> ${r.targetProperty}.`}async function rb(e){if(e.size>256*1024)throw new Error("Interface must be 256 KB or smaller.");const r=await e.text();if(/\.json$/i.test(e.name))return Cd(r,e.name);if(/\.ts$/i.test(e.name))return tb(r,e.name);throw new Error("Choose a .ts interface or .json JSON Schema file.")}const Ru=new WeakMap;function Wr(e){if(!e||typeof e!="object")return e;const r=Ru.get(e);if(r)return r;const t=()=>{throw new Error("Form callback data is read-only. Return edits instead.")},n=new Proxy(Array.isArray(e)?[]:{},{get:(i,o)=>Wr(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:Wr(Reflect.get(e,o)),configurable:o!=="length"||!Array.isArray(e)}},set:t,deleteProperty:t,defineProperty:t,setPrototypeOf:t,preventExtensions:t});return Ru.set(e,n),n}function Jr(e,r,t){var i;const n=r.split(".");for(let o=n.length;o>0;o--){const s=n.slice(0,o).join("."),a=(i=Te(e,s))==null?void 0:i.$form;if(!(a!=null&&a.$type))continue;let c=Object.prototype.hasOwnProperty.call(t,a.$type)?t[a.$type]:void 0;for(const u of n.slice(o))(c==null?void 0:c.kind)==="array"&&/^\d+$/.test(u)?c=c.items:(c==null?void 0:c.kind)==="object"?c=Object.prototype.hasOwnProperty.call(c.properties,u)?c.properties[u].type:void 0:c=void 0;if((c==null?void 0:c.kind)!=="object")return;const l=n.slice(o).join("."),d=Object.fromEntries(Object.entries(a.$fields??{}).filter(([u])=>!l||u.startsWith(`${l}.`)).map(([u,h])=>[l?u.slice(l.length+1):u,h]));return{type:c,fields:d,binding:a}}}async function _d(e,r){if(e.size>256*1024)throw new Error("Form schema exceeds 256 KB.");const t=await e.text();if(e.name.endsWith(".ts")){if(!r.length||r.length>32)throw new Error("Choose between 1 and 32 form interface names.");const i=[],o=new Set(r);for(const s of o){if(o.size>32)throw new Error("Choose between 1 and 32 form interface names.");const a=await Sd(t,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=Cd(t,e.name);return Object.fromEntries(Object.entries(n.nodes).map(([i,o])=>[i,o.type]))}function oo(e,r){return!e||("$in"in e?e.$in.includes(Te(r,e.$address)):Te(r,e.$address)===e.$equals)}function vn(e){const r=e.kind==="array"?e.items:e,t=r.kind==="union"?r.types:[r];if(t.every(n=>n.kind==="literal"))return t.map(n=>({label:String(n.value),value:n.value}))}function zt(e,r,t){if(r===void 0||r==="")return t?"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(r)?void 0:"Expected a JSON value"}if(e.kind==="union")return e.types.some(n=>!zt(n,r,!0))?void 0:"Choose a valid value";if(e.kind==="literal")return r===e.value?void 0:"Choose a valid value";if(e.kind==="array")return Array.isArray(r)&&r.every(n=>!zt(e.items,n,!0))?void 0:"Invalid list value";if(e.kind==="object")return!r||typeof r!="object"||Array.isArray(r)?"Expected an object":e.additionalProperties&&Object.entries(r).some(([n,i])=>!Object.prototype.hasOwnProperty.call(e.properties,n)&&zt(e.additionalProperties,i,!0))?"Invalid dictionary value":Object.entries(e.properties).some(([n,i])=>zt(i.type,r[n],!i.optional))?"Invalid object fields":void 0;if(e.kind==="null")return r===null?void 0:"Expected null";if(e.kind==="integer")return Number.isInteger(r)?void 0:"Expected a whole number";if(typeof r!==e.kind||typeof r=="number"&&!Number.isFinite(r))return`Expected ${e.kind}`}function ku(e,r){const t=r.address.split(".");if(t.shift()!=="root"||!t.length||t.some(a=>!a||["__proto__","prototype","constructor","#"].includes(a)))throw new Error("Invalid form field address.");const n=t.pop(),i=n==="$bgColor"||n==="$textColor"||n==="$borderColor";if(t.some(a=>a.startsWith("$"))||n.startsWith("$")&&!i)throw new Error("Unsupported form metadata address.");const o=["root",...t].join("."),s=Te(e,o);if(!s||typeof s!="object")throw new Error(`Missing form parent: ${o}`);if(i){if(r.op==="set"&&typeof r.value!="string")throw new Error("Node colors must be strings.");return xt(e,o,n,r.op==="remove"?void 0:r.value)}return _t(e,o,a=>{const c=Array.isArray(a.$)?a.$:a;if(r.op==="remove"&&!Object.prototype.hasOwnProperty.call(c,n)||r.op==="set"&&Object.is(c[n],r.value))return a;const l=Array.isArray(c)?[...c]:{...c};if(Array.isArray(l)&&(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=l.length))throw new Error("Invalid array address.");return r.op==="remove"?Array.isArray(l)?l.splice(Number(n),1):delete l[n]:Object.defineProperty(l,n,{value:structuredClone(r.value),enumerable:!0,writable:!0,configurable:!0}),c===a?l:{...a,$:l}})}function io(e,r,t){let n=ku(e,r.value===void 0?{op:"remove",address:r.address}:{op:"set",address:r.address,value:r.value});const i=t==null?void 0:t({...r,previousValue:Wr(Te(e,r.address)),data:Wr(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=ku(n,o)}return n}const xn="data:image/svg+xml;base64,";function or(e){if(e.startsWith(xn))return!0;try{const r=new URL(e);return(r.protocol==="https:"||r.protocol==="http:")&&!r.username&&!r.password}catch{return!1}}async function cw(e){if(e.size>256*1024)throw new Error("SVG must be 256 KB or smaller.");const r=await e.text(),t=new DOMParser().parseFromString(r,"image/svg+xml");if(t.doctype||t.querySelector("parsererror")||t.documentElement.localName!=="svg"||t.documentElement.namespaceURI!=="http://www.w3.org/2000/svg")throw new Error("Choose a valid SVG file.");if(t.querySelector("script, foreignObject")||[...t.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(r);let i="";for(const o of n)i+=String.fromCharCode(o);return xn+btoa(i)}const Ht=({name:e,svg:r=!1,...t})=>{const[n,i]=S.useState(null),[o,s]=S.useState(!0),[a,c]=S.useState(!1),l=typeof e=="string"&&or(e);if(S.useEffect(()=>{if(l||!e||e.length<2){i(null),s(!1);return}s(!0),c(!1),(async()=>{try{let u;if(e.startsWith("Md"))u="md";else if(e.startsWith("Fa"))u="fa6";else if(e.startsWith("Io5"))u="io5";else if(e.startsWith("Io"))u="io";else if(e.startsWith("Ti"))u="ti";else if(e.startsWith("Go"))u="go";else if(e.startsWith("Fi"))u="fi";else if(e.startsWith("Di"))u="di";else if(e.startsWith("Ai"))u="ai";else if(e.startsWith("Bs"))u="bs";else if(e.startsWith("Ri"))u="ri";else if(e.startsWith("Fc"))u="fc";else if(e.startsWith("Gi"))u="gi";else if(e.startsWith("Hi2"))u="hi2";else if(e.startsWith("Hi"))u="hi";else if(e.startsWith("Si"))u="si";else if(e.startsWith("Sl"))u="sl";else if(e.startsWith("Im"))u="im";else if(e.startsWith("Bi"))u="bi";else if(e.startsWith("Pi"))u="pi";else if(e.startsWith("Vsc"))u="vsc";else if(e.startsWith("Tb"))u="tb";else if(e.startsWith("Tfi"))u="tfi";else if(e.startsWith("Cg"))u="cg";else if(e.startsWith("Lia"))u="lia";else if(e.startsWith("Lu"))u="lu";else throw new Error(`Unknown library prefix for icon: ${e}`);let h;switch(u){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: ${u}`)}const p=h[e];if(!p)throw new Error(`Icon ${e} not found in library ${u}`);i(()=>p)}catch(u){console.warn(`Failed to load icon ${e}:`,u.message),c(!0),i(null)}finally{s(!1)}})()},[e,l]),l){const{size:d=80,style:u,...h}=t;return r?f.jsx("image",{...h,href:e,width:d,height:d,preserveAspectRatio:"xMidYMid meet",style:u}):f.jsx("img",{...h,src:e,alt:"",width:d,height:d,referrerPolicy:"no-referrer",style:{objectFit:"contain",...u}})}return o||!n?null:f.jsx(n,{...t})};function lw(e,r){let t=e;for(const n of r){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;jn(o),t=io(t,{address:n.address,nodeAddress:i.slice(0,-1).join("."),value:o})}return jn(t),t}function Pn(e,r,t){const n=Object.prototype.hasOwnProperty.call(e,r)?e[r]:void 0;if(!(!n||!t||!Object.prototype.hasOwnProperty.call(t,n.type)))return{address:n.address,type:t[n.type],fields:n.fields??{}}}function jn(e){if(!(!e||typeof e!="object"))for(const[r,t]of Object.entries(e)){if(r.startsWith("$")||["__proto__","prototype","constructor"].includes(r))throw new Error(`Form state cannot contain view metadata or unsafe keys: ${r}`);jn(t)}}function dw(e,r,t){jn(r.value);const n=io(e,r,t);return jn(n),n}function nb(e,r){const t=(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=Te(r,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=t(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 t(e)}const uw=e=>!!e&&!e.includes(".")&&!e.startsWith("$")&&!["__proto__","constructor","prototype"].includes(e),fw=e=>`root.__form_${encodeURIComponent(e).replace(/\./g,"%2E")}`,ln=(e,r)=>JSON.stringify([e,r]);function _n(e,r){if(e.kind==="union"){const t=e.types.find(n=>n.kind===(Array.isArray(r)?"array":r===null?"null":typeof r)||n.kind==="literal"&&Object.is(n.value,r));return _n(t??e.types.find(n=>n.kind!=="null")??e.types[0]??{kind:"json"},r)}return e.kind!=="json"?e:Array.isArray(r)?{kind:"array",items:{kind:"json"}}:r!==null&&typeof r=="object"||r===void 0?{kind:"object",properties:{},additionalProperties:{kind:"json"}}:{kind:r===null?"null":typeof r}}function dn(e){const r=_n(e,void 0);return r.kind==="object"?{}:r.kind==="array"?[]:r.kind==="literal"?r.value:r.kind==="number"||r.kind==="integer"?0:r.kind==="boolean"?!1:r.kind==="null"?null:""}function Au(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"&&!vn(e)?e.types:[e]}function hw(e,r,t){if(r.address===t.address)return;const n=Te(e,r.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==="":!zt(o,s,!0);if(i(t.type,n))return structuredClone(n)}function ob(e,r,t,n){var c,l;const i={sourceSchema:t,sourceBindings:r,nodes:[],edges:[],schema:{...t},bindings:{...r},slots:new Map,containers:new Map},o=new Set(n.map(d=>d.data.id)),s=new Map(n.flatMap(d=>{const u=r[d.data.id];return u&&t[u.type]?[[u.address,d.data.id]]:[]})),a=(d,u,h,p,y,m=!1)=>{var _,k,E,O,T;if(y>24||i.containers.size>512)throw new Error("Structured form exceeds the flow node limit.");const g=Te(e,u),b=_n(h,g),v=b.kind!=="object"&&b.kind!=="array";i.containers.set(d,{address:u,type:b,declared:h,scalar:v});const x=`__form:${d}`,w={...(_=i.bindings[d])==null?void 0:_.fields},C={kind:"object",properties:{},ports:{...b.kind==="object"?b.ports:{},...m?{resource:{label:"output",...b.kind==="object"?(k=b.ports)==null?void 0:k.resource:{},kind:"output"}}:{}}},j=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,I)=>[String(I),{type:b.items,optional:!0}])):{value:{type:vn(h)?h:b,optional:!1}};for(const[P,I]of Object.entries(j)){if(!uw(P))throw new Error(`Unsupported structured property key: ${P}`);const R=v?u:`${u}.${P}`,$=Te(e,R),N=_n(I.type,$),M=N.kind==="object"||N.kind==="array",J=(E=C.ports)==null?void 0:E[P],ie=(J==null?void 0:J.kind)==="config"&&(((O=w[P])==null?void 0:O.$options)||vn(I.type)),ae=I.type.kind==="json"||I.type.kind==="union"&&!vn(I.type);if(((T=w[P])==null?void 0:T.$control)==="upload"||!M&&b.kind!=="array"&&(!ae||v)||ie){C.properties[P]={...I,type:I.type.kind==="json"?N:I.type};continue}const te=s.get(R)??fw(R),he=b.kind==="array"?`Item ${Number(P)+1}`:P,me={address:R,owner:d,field:P,type:I.type,label:he,nodeId:te,present:$!==void 0};if(i.slots.set(ln(d,P),me),C.ports[P]={kind:"config",resourceType:`__form:${te}`},$===void 0||(i.edges.push({data:{id:`__form-edge:${d}:${P}`,source:te,target:d,sourceProperty:"output:resource",targetProperty:`config:${P}`,isEdgeDashed:!0}}),i.containers.has(te)||s.has(R)))continue;if(o.has(te))throw new Error(`Structured node identity conflict: ${te}`);o.add(te);const q={data:{id:te,type:"objectView",label:he,headerTitle:he,description:{},config:{form:!0,icon:N.kind==="array"?"PiListNumbers":M?"PiBracketsCurly":"PiTextT"},viewProps:{bgColor:p}}};i.nodes.push(q),a(te,R,I.type,p,y+1,!0);const F=i.schema[`__form:${te}`];q.data.description=Object.fromEntries(Object.keys(F.properties).map(U=>[U,Te(e,N.kind==="array"||N.kind==="object"?`${R}.${U}`:R)]).filter(([,U])=>U!==void 0))}i.schema[x]=C,i.bindings[d]={...i.bindings[d],address:u,type:x,fields:w}};for(const d of n){const u=r[d.data.id];if(u!=null&&u.portResources)continue;const h=u&&t[u.type];!u||!h||Te(e,u.address)===void 0||a(d.data.id,u.address,h,(c=d.data.viewProps)==null?void 0:c.bgColor,0,i.edges.some(p=>p.data.source===d.data.id))}for(const d of i.edges){const u=i.bindings[d.data.source],h=i.schema[u.type].ports;h.resource={...h.resource,kind:"output",label:((l=h.resource)==null?void 0:l.label)??"output"}}return i}const Sr=(e="reference")=>({kind:e,text:"",paths:[""]}),ib=e=>/^[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*|\.\d+)+$/.test(e)&&!e.split(".").some(r=>["__proto__","constructor","prototype"].includes(r));function pw(e,r){const t=new Set(r.map(s=>s.path)),n=s=>{if(!s.paths.length||s.paths.some(a=>!ib(a)||!t.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 gw(e){const r=await import("typescript"),t=s=>{const a=r.createSourceFile("binding.ts",`(${s})`,r.ScriptTarget.Latest,!0,r.ScriptKind.TS);if(a.parseDiagnostics.length)throw new Error("Unsupported reference expression.");const c=a.statements[0];if(!c||!r.isExpressionStatement(c))throw new Error("Unsupported reference expression.");const l=Sr();l.paths=[];const d=u=>{if(r.isParenthesizedExpression(u))return d(u.expression);if(r.isBinaryExpression(u)&&u.operatorToken.kind===r.SyntaxKind.BarBarToken){d(u.left),d(u.right);return}if(r.isStringLiteral(u)){if(l.fallback!==void 0)throw new Error("Multiple fallback values.");l.fallback=u.text;return}const h=u.getText(a);if(!ib(h)||l.fallback!==void 0)throw new Error("Unsupported reference expression.");l.paths.push(h)};if(d(c.expression),!l.paths.length)throw new Error("A binding needs a reference.");return l},n=s=>{const a=[];let c=0;const l=/\{\{([\s\S]*?)\}\}/g;for(const d of s.matchAll(l)){const u=d.index;if(u<c)continue;u>c&&a.push({...Sr("text"),text:s.slice(c,u)});const h=d[1].trim();if(h.startsWith("#if ")){const p=s.indexOf("{{/if}}",u+d[0].length);if(p<0)throw new Error("Unclosed condition.");a.push({...t(h.slice(4)),kind:"conditional",text:s.slice(u+d[0].length,p)}),c=p+7}else a.push(t(h)),c=u+d[0].length}return c<s.length&&a.push({...Sr("text"),text:s.slice(c)}),a},i={mode:"reference",parts:[Sr()],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=r.createSourceFile("condition.ts",`value ${o[1].text}`,r.ScriptTarget.Latest,!0,r.ScriptKind.TS),a=s.statements[0];if(s.statements.length===1&&r.isExpressionStatement(a)&&r.isBinaryExpression(a.expression)&&a.expression.operatorToken.kind===r.SyntaxKind.EqualsEqualsToken&&r.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 Pu({parts:e,references:r,onChange:t,disabled:n}){const i=(o,s)=>t(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(X.PiCaretDown,{size:16,"aria-hidden":"true"})]}),f.jsx(Ae,{"aria-label":`Remove part ${s+1}`,title:"Remove part",icon:f.jsx(X.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>t(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:l=>i(s,{paths:o.paths.map((d,u)=>u===c?l.target.value:d)}),children:[f.jsx("option",{value:"",children:"Select reference"}),r.map(l=>f.jsx("option",{value:l.path,children:l.label},l.path))]}),f.jsx(X.PiCaretDown,{size:16,"aria-hidden":"true"})]})]},c)),o.kind==="reference"&&f.jsxs(f.Fragment,{children:[f.jsx(Ae,{"aria-label":"Add fallback reference",title:"Add fallback reference",icon:f.jsx(X.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(Ae,{"aria-label":"Add part",title:"Add part",icon:f.jsx(X.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>t([...e,Sr()])})]})}function yw({label:e,value:r,references:t,disabled:n,onChange:i}){const[o,s]=S.useState(),[a,c]=S.useState(""),[l,d]=S.useState(!1),u=async()=>{d(!0),c("");try{s(await gw(typeof r=="string"?r:""))}catch(h){c(h instanceof Error?h.message:"Unable to read binding.")}finally{d(!1)}};return f.jsxs("div",{"data-runtime-binding":e,style:{marginBottom:8},children:[f.jsx(Ae,{"aria-label":`Bind ${e}`,title:`Bind ${e}`,icon:f.jsx(X.PiLink,{size:18}),size:"sm",variant:"ghost",disabled:n||l,onClick:u}),typeof r=="string"&&r.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:[Sr()]}),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(X.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(Pu,{parts:h.parts,references:t,disabled:n,onChange:y=>s({...o,fields:o.fields.map((m,g)=>g===p?{...m,parts:y}:m)})}),f.jsx(Ae,{"aria-label":"Remove output field",title:"Remove output field",icon:f.jsx(X.PiTrash,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...o,fields:o.fields.filter((y,m)=>m!==p)})})]},p)),f.jsx(Ae,{"aria-label":"Add output field",title:"Add output field",icon:f.jsx(X.PiPlus,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...o,fields:[...o.fields,{key:"",parts:[Sr()]}]})})]}):f.jsx(Pu,{parts:o.parts,references:t,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(Ae,{"aria-label":"Apply binding",title:"Apply binding",icon:f.jsx(X.PiCheck,{size:20}),size:"sm",variant:"ghost",onClick:()=>{try{i(pw(o,t)),s(void 0),c("")}catch(h){c(h instanceof Error?h.message:"Unable to apply binding.")}}}),f.jsx(Ae,{"aria-label":"Cancel binding",title:"Cancel binding",icon:f.jsx(X.PiX,{size:20}),size:"sm",variant:"ghost",onClick:()=>{s(void 0),c("")}})]})]}),a&&f.jsx("p",{role:"alert",children:a})]})}function mw({nodeAddress:e,onOpen:r}){const{structured:t,data:n,callbacks:i,editable:o,onFieldCreate:s}=S.useContext(It),a=Ue(),[c,l]=S.useState(""),[d,u]=S.useState("0"),[h,p]=S.useState(""),y=t==null?void 0:t.containers.get(e);if(!y||!n||!t)return null;const m=a.readOnly||a.config.editable===!1||!o,g=Te(n,y.address),b=Au(y.declared),v=y.type.kind==="array"?y.type.items:y.type.kind==="object"?y.type.additionalProperties:void 0,x=v?Au(v):[],w=!!s&&y.type.kind==="object"&&(v==null?void 0:v.kind)==="json",C=I=>I.kind==="literal"?String(I.value):I.kind==="string"?"Text":Ot(I.kind),j=[...t.slots.values()].filter(I=>I.owner===e),_=(I,R)=>{var $;return($=i.onFormChange)==null?void 0:$.call(i,{data:n,nodeAddress:y.address,address:I,previousValue:Te(n,I),value:R})},k=I=>{var R;a.setSelectedNodeIds([I]),(R=a.engineRef.current)==null||R.focusNode(I,90,!1)},E=(I,R)=>{if(!Array.isArray(g))return;const $=[...g];[$[I],$[I+R]]=[$[I+R],$[I]],_(y.address,$)},O=()=>{const I=x[Number(d)]??x[0];if(I)if(y.type.kind==="array")_(y.address,[...Array.isArray(g)?g:[],dn(I)]);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}w&&(d==="file"||d==="files")?s==null||s({data:n,nodeAddress:y.address,address:`${y.address}.${c}`,previousValue:void 0,value:d==="files"?[]:""},{$control:"upload"}):_(`${y.address}.${c}`,dn(I)),l(""),p("")}},T=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(At,{"aria-label":"Value type",disabled:m,value:String(b.findIndex(I=>_n(I,g).kind===y.type.kind)),onValueChange:I=>_(y.address,dn(b[Number(I)])),children:b.map((I,R)=>f.jsx("option",{value:R,children:C(I)},R))})})]}),j.map((I,R)=>f.jsxs("div",{"data-structured-slot":I.address,style:{display:"flex",gap:6,alignItems:"center",minWidth:0},children:[I.type.kind==="array"?f.jsx(X.PiListNumbers,{size:20}):f.jsx(X.PiBracketsCurly,{size:20}),f.jsx("span",{style:{flex:1,overflowWrap:"anywhere"},children:Ot(I.label)}),f.jsx(Ae,{"aria-label":`${I.present?r?"Edit":"Focus":"Create"} ${Ot(I.label)}`,title:`${I.present?r?"Edit":"Focus":"Create"} ${Ot(I.label)}`,icon:I.present?f.jsx(X.PiMagnifyingGlass,{size:18}):f.jsx(X.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:m&&!I.present,onClick:$=>{var N;I.present?r?r(I.nodeId):((N=$.currentTarget.closest("dialog"))==null||N.close(),k(I.nodeId)):_(I.address,dn(I.type))}}),P&&f.jsxs(f.Fragment,{children:[f.jsx(Ae,{"aria-label":`Move item ${R+1} up`,icon:f.jsx(X.PiArrowUp,{size:18}),size:"sm",variant:"ghost",disabled:m||R===0,onClick:()=>E(R,-1)}),f.jsx(Ae,{"aria-label":`Move item ${R+1} down`,icon:f.jsx(X.PiArrowDown,{size:18}),size:"sm",variant:"ghost",disabled:m||R===j.length-1,onClick:()=>E(R,1)})]}),I.present&&f.jsx(Ae,{"aria-label":`Remove ${Ot(I.label)}`,icon:f.jsx(X.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:m,onClick:()=>P?_(y.address,g.filter(($,N)=>N!==R)):_(I.address,void 0)})]},I.address)),(P||T)&&f.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"end"},children:[T&&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:I=>l(I.target.value)})]}),x.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(At,{"aria-label":"New value type",value:d,disabled:m,onValueChange:u,children:[x.map((I,R)=>f.jsx("option",{value:R,children:C(I)},R)),w&&f.jsx("option",{value:"file",children:"File"}),w&&f.jsx("option",{value:"files",children:"Files"})]})})]}),f.jsx("span",{style:{display:"flex",alignItems:"center",flexShrink:0,...T||x.length>1?{height:"calc(1.4em + 20px)",fontSize:15,marginBottom:6}:{}},children:f.jsx(Ae,{"aria-label":P?"Add item":"Add property",icon:f.jsx(X.PiPlus,{size:20}),size:"sm",variant:"ghost",disabled:m,onClick:O})})]}),h&&f.jsx("p",{role:"alert",children:h})]})}const It=S.createContext({callbacks:{}}),Bn=Qn.default.div`
|
|
59
59
|
--flow-form-input-radius: 16px;
|
|
60
60
|
--flow-form-input-background: color-mix(
|
|
61
61
|
in srgb,
|
|
@@ -206,8 +206,8 @@
|
|
|
206
206
|
font-size: 14px;
|
|
207
207
|
margin-top: 8px;
|
|
208
208
|
}
|
|
209
|
-
`;function Pu({request:e,property:r,config:t,value:n,disabled:i}){var he,G,F,re,ce;const{callbacks:o,structured:s,references:a}=j.useContext(Mt),{themeColor:l}=Ve(),{background:c}=it(),d=j.useId(),u=r.type.kind==="object"||r.type.kind==="array"||r.type.kind==="json",h=n===void 0?"":u?JSON.stringify(n,null,2):String(n),[p,y]=j.useState(h),[m,g]=j.useState(""),[b,v]=j.useState(0),x=j.useRef(null),w=j.useRef(),[C,S]=j.useState(!1),[_,R]=j.useState(!1),[A,O]=j.useState(),T=((he=t.$options)==null?void 0:he.$source)==="callback",E=o.resolveFormOptions,{data:M,address:P,nodeAddress:$,nodeId:N}=e;j.useEffect(()=>(S(!1),R(!1),()=>{var X;(X=w.current)==null||X.abort(),w.current=void 0}),[P,$,N,i,h,t.$control,(G=t.$upload)==null?void 0:G.accept,(F=t.$upload)==null?void 0:F.maxSizeBytes]);const I=j.useRef(M);I.current=M;const K=JSON.stringify([P,N,(re=t.$options)!=null&&re.$dependsOn?t.$options.$dependsOn.map(X=>Te(M,X)):Te(M,$)]);j.useEffect(()=>{y(h),g("")},[h,P,N]),j.useEffect(()=>{if(!T)return;const X=new AbortController;return Promise.resolve().then(()=>{if(!E)throw new Error("No options resolver configured");return E({address:P,nodeAddress:$,nodeId:N,data:Vr(I.current),signal:X.signal})}).then(ye=>{if(!Array.isArray(ye)||ye.some(ve=>!ve||typeof ve.label!="string"||!["string","number","boolean"].includes(typeof ve.value)&&ve.value!==null))throw new Error("Invalid options response");X.signal.aborted||O({key:K,options:ye})}).catch(ye=>{X.signal.aborted||O({key:K,options:[],error:ye instanceof Error?ye.message:"Options unavailable"})}),()=>X.abort()},[T,E,K,P,$,N,b]);const le=T&&(A==null?void 0:A.key)!==K,ie=T?(A==null?void 0:A.key)===K?A.options:[]:r.type.kind==="null"?[{label:"Null",value:null}]:r.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:bn(r.type),te=r.type.kind==="array",fe=(t.$control==="upload"?"upload":s&&u||t.$control==="checkbox"?"pills":t.$control)??(ie?te||r.type.kind==="boolean"?"pills":"select":r.type.kind==="boolean"?"checkbox":u?"textarea":"input"),xe=!r.optional||!!t.$requiredWhen&&oo(t.$requiredWhen,M),q=xe?"Required":"Optional",W=fe!=="upload"&&!!(a!=null&&a.length)&&typeof n=="string"&&n.includes("{{"),U=m||T&&(A==null?void 0:A.key)===K&&A.error||!W&&zt(r.type,n,xe),z=Nt(t.$label??P.split(".").pop()),de=X=>{var ye;if(!(i||Object.is(X,n)))try{(ye=o.onFormChange)==null||ye.call(o,{...e,previousValue:n,value:X}),g("")}catch(ve){g(ve instanceof Error?ve.message:"Unable to update field")}},Q=j.useRef(de);j.useLayoutEffect(()=>{Q.current=de});const ae=()=>{if(u){try{const Oe=p===""&&r.optional?void 0:JSON.parse(p),Ne=zt(r.type,Oe,xe);if(Ne){g(Ne);return}de(Oe)}catch{g("Enter valid JSON")}return}const X=r.type.kind==="number"||r.type.kind==="integer",ye=p===""&&r.optional?void 0:X&&p!==""?Number(p):p,ve=zt(r.type,ye,xe);if(X&&ve&&p!==""){g(ve);return}de(ye)},se=async X=>{var ve,Oe,Ne;if(i||w.current||!X.length)return;const ye=new AbortController;w.current=ye,g(""),S(!0);try{if(r.type.kind!=="string"&&!(r.type.kind==="array"&&r.type.items.kind==="string"))throw new Error("Uploads require a string or string-array field.");if(!te&&X.length!==1)throw new Error("Choose one file for this field.");if(!o.uploadFormFile)throw new Error("No file upload handler configured.");const Be=(Oe=(ve=t.$upload)==null?void 0:ve.accept)==null?void 0:Oe.split(",").map(Ke=>Ke.trim().toLowerCase()).filter(Boolean);for(const Ke of X){if(((Ne=t.$upload)==null?void 0:Ne.maxSizeBytes)!==void 0&&Ke.size>t.$upload.maxSizeBytes)throw new Error(`${Ke.name} exceeds the file size limit.`);if(Be!=null&&Be.length&&!Be.some(nt=>nt.startsWith(".")?Ke.name.toLowerCase().endsWith(nt):nt.endsWith("/*")?Ke.type.toLowerCase().startsWith(nt.slice(0,-1)):Ke.type.toLowerCase()===nt))throw new Error(`${Ke.name} is not an accepted file type.`)}const et=await Promise.all(X.map(async Ke=>{const nt=await o.uploadFormFile({...e,data:Vr(M),file:Ke,signal:ye.signal});if(typeof nt!="string")throw new Error("Upload handler must return an HTTP or HTTPS URL.");let Ie;try{Ie=new URL(nt)}catch{throw new Error("Upload handler must return an HTTP or HTTPS URL.")}if(!["http:","https:"].includes(Ie.protocol)||Ie.username||Ie.password)throw new Error("Upload handler must return an HTTP or HTTPS URL.");return nt}));if(ye.signal.aborted||w.current!==ye)return;const We=te?[...Array.isArray(n)?n:[],...et]:et[0],ft=zt(r.type,We,xe);if(ft)throw new Error(ft);Q.current(We)}catch(Be){ye.signal.aborted||g(Be instanceof Error?Be.message:"Unable to upload file."),ye.abort()}finally{w.current===ye&&(w.current=void 0,S(!1))}},Ce={id:d,disabled:i,"aria-label":z,"aria-required":xe,"aria-invalid":!!U,"aria-describedby":U?`${d}-error`:void 0},Se=_e(l);return f.jsxs("div",{"data-form-field":P,"data-flow-property":P.slice($.length+1),children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[f.jsxs("label",{htmlFor:d,children:[z,xe?" *":""]}),r.optional&&n!==void 0&&f.jsx("button",{type:"button","aria-label":`Reset ${z}`,title:`Reset ${z}`,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:()=>de(void 0),children:f.jsx(Z.PiArrowCounterClockwise,{size:14})})]}),!!(a!=null&&a.length)&&!u&&fe!=="upload"&&f.jsx(yw,{label:z,value:n,references:a,disabled:i,onChange:de}),fe==="upload"?f.jsxs("div",{"data-form-upload":te?"multiple":"single","aria-busy":C,style:{"--flow-upload-surface":_e(c),outline:_?"2px dashed var(--flow-form-input-background)":void 0,borderRadius:"var(--flow-form-input-radius)"},onDragOver:X=>{X.preventDefault(),X.stopPropagation(),!i&&!C&&(X.dataTransfer.dropEffect="copy",R(!0))},onDragLeave:X=>{X.currentTarget.contains(X.relatedTarget)||R(!1)},onDrop:X=>{X.preventDefault(),X.stopPropagation(),R(!1),se(Array.from(X.dataTransfer.files))},children:[f.jsx("input",{ref:x,type:"file",hidden:!0,"aria-label":`Upload ${z}`,accept:(ce=t.$upload)==null?void 0:ce.accept,multiple:te,disabled:i||C,onChange:X=>{const ye=Array.from(X.target.files??[]);X.target.value="",se(ye)}}),f.jsxs("div",{"data-upload-items":"",children:[(te?Array.isArray(n)?n:[]:n?[n]:[]).map((X,ye)=>f.jsxs("div",{"data-upload-preview":"",children:[typeof X=="string"&&or(X)&&f.jsxs("a",{href:X,target:"_blank",rel:"noopener noreferrer","aria-label":`${z} file ${ye+1}`,children:[f.jsx(Z.PiFile,{size:32,"aria-hidden":"true"}),f.jsx(Ht,{name:X,size:120,onError:ve=>{ve.currentTarget.style.visibility="hidden"}})]}),f.jsxs("div",{"data-upload-actions":"",children:[!te&&f.jsx(Ae,{"aria-label":`Replace ${z}`,title:`Replace ${z}`,icon:f.jsx(Z.PiUploadSimple,{}),size:"xs",variant:"ghost",disabled:i||C,onClick:()=>{var ve;return(ve=x.current)==null?void 0:ve.click()}}),f.jsx(Ae,{"aria-label":`Remove ${z} file ${ye+1}`,title:"Remove file",icon:f.jsx(Z.PiTrash,{}),size:"xs",variant:"ghost",disabled:i||C,onClick:()=>de(te&&Array.isArray(n)?n.filter((ve,Oe)=>Oe!==ye):"")})]})]},`${ye}:${X}`)),(te||!n)&&f.jsx("button",{...Ce,type:"button","data-upload-drop":"",title:`Upload ${z}`,disabled:i||C,onClick:()=>{var X;return(X=x.current)==null?void 0:X.click()},children:f.jsx(Z.PiPlus,{size:28,"aria-hidden":"true"})})]}),C&&f.jsx("span",{role:"status",children:"Uploading..."})]}):W?null:fe==="select"?f.jsx("div",{"data-form-select":"",children:f.jsxs(Pt,{...Ce,disabled:i||le||!!(A!=null&&A.error),labelCase:"preserve",value:String((ie==null?void 0:ie.findIndex(X=>Object.is(X.value,n)))??-1),onValueChange:X=>{const ye=ie==null?void 0:ie[Number(X)];ye&&de(ye.value)},children:[f.jsx("option",{value:-1,disabled:!0,children:n!==void 0&&n!==""?String(n):q}),ie==null?void 0:ie.map((X,ye)=>f.jsx("option",{value:ye,children:Nt(X.label)||X.label},ye))]})}):fe==="pills"?f.jsxs("div",{id:d,role:"group","aria-label":z,"aria-describedby":Ce["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[ie==null?void 0:ie.map((X,ye)=>{const ve=te?Array.isArray(n)&&n.includes(X.value):Object.is(n,X.value);return f.jsx("button",{type:"button",disabled:i||le,"aria-pressed":ve,style:{padding:"8px 16px",borderRadius:24,border:0,color:ve?Se:"inherit",background:ve?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>de(te?ve?n.filter(Oe=>Oe!==X.value):[...Array.isArray(n)?n:[],X.value]:X.value),children:Nt(X.label)||X.label},ye)}),le&&f.jsx("span",{role:"status",children:"Loading..."})]}):fe==="textarea"?f.jsx("textarea",{...Ce,placeholder:q,value:p,onChange:X=>y(X.target.value),onBlur:ae}):f.jsx("input",{...Ce,placeholder:q,type:r.type.kind==="number"||r.type.kind==="integer"?"number":"text",step:r.type.kind==="integer"?1:"any",value:p,onChange:X=>y(X.target.value),onBlur:ae,onKeyDown:X=>{X.key==="Enter"&&ae(),X.key==="Escape"&&y(n===void 0?"":String(n))}}),U&&f.jsx("div",{role:"alert",id:`${d}-error`,children:U}),T&&(A==null?void 0:A.error)&&f.jsx("button",{type:"button",disabled:i,onClick:()=>{O(void 0),v(b+1)},children:"Retry"})]})}function _d({nodeAddress:e,structured:r=!1}){return r?f.jsx(bw,{nodeAddress:e},e):f.jsx(id,{nodeAddress:e})}function bw({nodeAddress:e}){var u,h,p;const r=j.useContext(Mt),[t,n]=j.useState([]),i=((u=r.structured)==null?void 0:u.sourceSchema)??r.schema,o=((h=r.structured)==null?void 0:h.sourceBindings)??r.bindings,s=j.useMemo(()=>{if(!(!r.data||!i||!o))return nb(r.data,o,i,[{data:{id:e,type:"objectView"}}])},[r.data,o,i,e]);if(!s)return f.jsx(id,{nodeAddress:e});const a=t.findIndex(y=>!s.containers.has(y)),l=a<0?t:t.slice(0,a),c=l.at(-1)??e,d=(p=[...s.slots.values()].find(y=>y.nodeId===c))==null?void 0:p.label;return f.jsxs(Mt.Provider,{value:{...r,structured:s,schema:s.schema,bindings:s.bindings,renderForm:void 0,onFieldCreate:c===e?r.onFieldCreate:void 0},children:[!!l.length&&f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[f.jsx(Ae,{"aria-label":"Back to parent fields",title:"Back to parent fields",icon:f.jsx(Z.PiArrowLeft,{size:18}),size:"sm",variant:"ghost",onClick:()=>n(l.slice(0,-1))}),f.jsx("strong",{style:{minWidth:0,overflowWrap:"anywhere"},children:Nt(d)})]}),f.jsx(id,{nodeAddress:c,onOpen:y=>n([...l,y])},c)]})}function id({nodeAddress:e,onOpen:r}){var S,_;const{data:t,schema:n,callbacks:i,bindings:o,editable:s,renderForm:a,structured:l}=j.useContext(Mt),{readOnly:c,config:d,colorMode:u}=Ve(),h=a==null?void 0:a(e);if(h!==void 0)return f.jsx("fieldset",{"data-flow-form":e,disabled:c||d.editable===!1||!s,style:{border:0,margin:0,padding:0,minWidth:0},children:h});if(!t)return f.jsx(Bn,{$colorMode:u,role:"alert",children:"Forms require a JSON document."});const p=o?Pn(o,e,n):void 0,y=o?p:n&&Kr(t,e,n);if(!y)return f.jsx(Bn,{$colorMode:u,role:"status",children:"Form schema unavailable."});const m=(p==null?void 0:p.address)??e,g=Te(t,m),b=(S=l==null?void 0:l.containers.get(e))==null?void 0:S.scalar;if(g===void 0||typeof g!="object"&&!b)return f.jsx(Bn,{$colorMode:u,role:"alert",children:"Bound form state is unavailable."});const v=Object.entries(y.type.properties).filter(([R])=>{var A;return oo((A=y.fields[R])==null?void 0:A.$visibleWhen,t)}),x=v.length>8||v.some(([R])=>{var A;return(A=y.fields[R])==null?void 0:A.$section}),w=new Map;for(const R of v){const[A,O]=R,T=x?Nt(((_=y.fields[A])==null?void 0:_.$section)??(O.type.kind==="object"||O.type.kind==="array"?A:O.optional?"Options":"General")):"";w.has(T)||w.set(T,[]),w.get(T).push(R)}const C=([R,A])=>f.jsx(Pu,{request:{data:t,address:b?m:`${m}.${R}`,nodeAddress:m,nodeId:typeof(g==null?void 0:g.id)=="string"?g.id:void 0},property:A,config:y.fields[R]??{},value:b?g:g==null?void 0:g[R],disabled:c||d.editable===!1||!(s??!!i.onJsonChange)},`${(g==null?void 0:g.id)??e}:${R}`);return f.jsxs(Bn,{$colorMode:u,"data-flow-form":e,onClick:R=>R.stopPropagation(),onDoubleClick:R=>R.stopPropagation(),children:[l&&f.jsx(mw,{nodeAddress:e,onOpen:r}),!l&&p&&y.type.additionalProperties&&v.length===0&&f.jsx(Pu,{request:{data:t,address:m,nodeAddress:m},property:{type:y.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:g,disabled:c||d.editable===!1||!s}),[...w].map(([R,A])=>x&&A.length>1?f.jsxs("details",{open:!0,children:[f.jsxs("summary",{children:[f.jsx("span",{children:R}),f.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}),A.map(C)]},R):A.map(C))]})}function ib(e){const{viewData:r}=j.useContext(Mt),{nodeById:t,edgeById:n,parentIds:i}=hr();if(r){const o=Te(r,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,l])=>!a.startsWith("$")&&l!==null&&typeof l=="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&&t.has(a)})}function En(e,r){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:r}function Rn(e,r,t,n){return{borderColor:r,borderWidth:En(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...bm(r==="transparent"?"currentColor":r,t,".flow-sdk-node:hover &",!t)}}function ab({label:e,value:r,options:t,onChange:n,disabled:i}){var o;return f.jsxs(Pt,{"aria-label":e,title:`Animation: ${((o=t.find(s=>s.value===r))==null?void 0:o.label)??"Mixed"}`,value:r,style:{width:104},disabled:i,onValueChange:s=>{const a=t.find(l=>l.value===s);a&&n(a.value)},children:[r===""&&f.jsx("option",{value:"",disabled:!0,children:"Mixed"}),t.map(s=>f.jsx("option",{value:s.value,children:s.label},s.value))]})}function Ed({nodeId:e,edgeId:r,value:t,open:n,onOpenChange:i}){const{callbacks:o,readOnly:s,themeColor:a,colorMode:l}=Ve(),{background:c,backgroundSecondary:d,border:u,colorText:h,colorInactive:p}=it(),y=l==="dark"?Ur:_e(p),m=j.useRef(null),g=j.useRef(null),b=j.useRef(0),[v,x]=j.useState(!1),[w,C]=j.useState("icons"),[S,_]=j.useState([]),[R,A]=j.useState("loading"),[O,T]=j.useState(""),[E,M]=j.useState(0),[P,$]=j.useState(""),[N,I]=j.useState(""),[K,le]=j.useState(!1);j.useEffect(()=>()=>{b.current++},[]),j.useEffect(()=>{if(!v)return;let z=!0;return import("react-icons/pi").then(de=>{z&&(_(Object.keys(de).filter(Q=>Q.startsWith("Pi")).sort()),A("ready"))}).catch(()=>{z&&A("unavailable")}),()=>{z=!1}},[v]),j.useEffect(()=>{var z;s&&((z=m.current)==null||z.close())},[s]),j.useEffect(()=>{var z,de,Q;if(n!==void 0){if(!n||s){(z=m.current)==null||z.close();return}(de=m.current)!=null&&de.open||(I(""),C(t==="PiFileSvg"||t&&or(t)?"custom":"icons"),$(t&&!t.startsWith(vn)&&or(t)?t:""),x(!0),(Q=m.current)==null||Q.showModal())}},[n,s,t]);const ie=z=>{var de,Q,ae;s||(r?(de=o.onEdgeIconChange)==null||de.call(o,r,z):e&&((Q=o.onNodeIconChange)==null||Q.call(o,e,z)),i==null||i(!1),(ae=m.current)==null||ae.close())},te=S.filter(z=>z.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(O.trim().toLowerCase())),fe=36,xe=Math.max(1,Math.ceil(te.length/fe)),q=Math.min(E,xe-1),W=te.slice(q*fe,(q+1)*fe),U={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${_e(u)}`,borderRadius:30};return f.jsxs(f.Fragment,{children:[n===void 0&&f.jsx(Fe,{label:r?"Choose edge icon":"Choose node icon",children:f.jsx(Ae,{"aria-label":r?"Choose edge icon":"Choose node icon",icon:f.jsx(Z.PiShapes,{size:20}),size:"sm",variant:"ghost",color:_e(a),disabled:s,onClick:()=>{var z;I(""),C(t&&or(t)?"custom":"icons"),$(t&&!t.startsWith(vn)&&or(t)?t:""),x(!0),(z=m.current)==null||z.showModal()}})}),f.jsx(D.chakra.dialog,{ref:m,"aria-label":r?"Choose edge icon":"Choose node icon",css:lr(_e(c),_e(u)),onClose:()=>{x(!1),i==null||i(!1),b.current++,le(!1)},onClick:z=>{z.stopPropagation(),z.target===z.currentTarget&&z.currentTarget.close()},onKeyDown:z=>z.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",borderRadius:30,background:_e(c),color:_e(h)},children:v&&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:r?"Edge icon":"Node icon"}),f.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[t&&f.jsx(Fe,{label:"Remove icon",children:f.jsx(Ae,{"aria-label":r?"Remove edge icon":"Remove node icon",icon:f.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:s||K,onClick:()=>ie("")})}),f.jsx(Hr,{"aria-label":"Close icon picker",onClick:()=>{var z;return(z=m.current)==null?void 0:z.close()}})]})]}),f.jsxs(D.Tabs.Root,{value:w,onValueChange:({value:z})=>{C(z),I("")},display:"contents",css:{"--indicator-thickness":"1px"},children:[f.jsx(D.Tabs.List,{"aria-label":"Icon source",width:"100%",borderBottomWidth:0,children:["icons","custom"].map(z=>f.jsx(D.Tabs.Trigger,{value:z,flex:1,minW:0,justifyContent:"center",px:3,py:2,fontSize:"13px",_selected:{color:a,borderColor:y,"--indicator-color":y},children:z==="icons"?"React icons":"Custom SVG"},z))}),f.jsx("input",{ref:g,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:K||s,onChange:async z=>{var ae;const de=(ae=z.target.files)==null?void 0:ae[0];if(z.target.value="",!de)return;const Q=++b.current;le(!0),I("");try{const se=await cw(de);Q===b.current&&ie(se)}catch(se){Q===b.current&&I(se instanceof Error?se.message:"Unable to read SVG.")}finally{Q===b.current&&le(!1)}}}),f.jsx(D.Tabs.Content,{value:w,p:0,style:{display:"grid",gap:8},children:w==="icons"?f.jsxs(f.Fragment,{children:[f.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:O,onChange:z=>{T(z.target.value),M(0)},style:U}),f.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[W.map(z=>f.jsx("button",{type:"button","aria-label":`Choose ${z}`,"aria-pressed":t===z,title:z,onClick:()=>ie(z),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${t===z?2:1}px solid ${_e(t===z?a:u)}`,background:_e(t===z?c:d),color:"inherit",cursor:"pointer"},children:f.jsx(Ht,{name:z,size:24})},z)),W.length===0&&f.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:R==="loading"?"Loading icons...":R==="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:[te.length," icons · ",q+1," / ",xe]}),f.jsxs("div",{style:{display:"flex",gap:4},children:[f.jsx(Fe,{label:"Previous icons",children:f.jsx(Ae,{"aria-label":"Previous icons",icon:f.jsx(Z.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:q===0,onClick:()=>M(q-1)})}),f.jsx(Fe,{label:"Next icons",children:f.jsx(Ae,{"aria-label":"Next icons",icon:f.jsx(Z.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:q+1>=xe,onClick:()=>M(q+1)})})]})]})]}):f.jsxs(f.Fragment,{children:[t&&or(t)&&f.jsx(Ht,{name:t,size:64}),f.jsxs("button",{type:"button",disabled:K||s,onClick:()=>{var z;return(z=g.current)==null?void 0:z.click()},style:{...U,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[f.jsx(Z.PiUploadSimple,{}),K?"Uploading...":"Upload SVG"]}),f.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:z=>{z.preventDefault(),!(K||s)&&(!or(P.trim())||P.trim().startsWith(vn)?I("Enter an HTTP or HTTPS image URL."):ie(P.trim()))},children:[f.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:P,disabled:K||s,onChange:z=>$(z.target.value),style:{...U,flex:1,minWidth:0}}),f.jsx(Fe,{label:"Apply URL",children:f.jsx(Ae,{type:"submit","aria-label":"Apply URL",icon:f.jsx(Z.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:K||s||!P.trim(),style:{flexShrink:0}})})]})]})})]}),N&&f.jsx("div",{role:"alert",style:{fontSize:13},children:N})]})})]})}const Jn=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500",Ur],sb=["gray.900",Ur,"gray.600","gray.200","white"];function cb(){const{config:e}=Ve(),r=e.selectionToolbar||{},t=new Set(r.hide||[]);return{palette:r.palette||Jn,show:n=>!t.has(n)}}function jt(){const{border:e}=it();return f.jsx(D.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:e})}function zr({value:e,placeholder:r,ariaLabel:t,width:n="140px",type:i="text",min:o,onCommit:s}){const{colorText:a}=it(),[l,c]=j.useState(e),d=j.useRef(!1);j.useEffect(()=>c(e),[e]);const u=()=>{if(d.current)return;d.current=!0;const h=l.trim();if(i==="number"&&h!==""&&(!Number.isFinite(Number(h))||Number(h)<(o??0))){c(e);return}h!==e&&s(h)};return f.jsx(D.Input,{"aria-label":t,type:i,min:o,size:"xs",fontSize:"16px",w:n,value:l,placeholder:r,color:a,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{d.current=!1},onChange:h=>c(h.target.value),onBlur:u,onKeyDown:h=>{h.key==="Enter"&&(u(),h.target.blur()),h.key==="Escape"&&(d.current=!0,c(e),h.target.blur())}})}function Er({colors:e,value:r,label:t,onPick:n,onReset:i,includeTransparent:o=!0}){const{colorInactive:s,colorText:a}=it(),[l,c]=j.useState(!1),d=j.useId(),u=j.useRef(null),h=r??e[0]??"transparent",p=eo(f.jsx(Er,{colors:e,value:r,label:t,onPick:n,onReset:i,includeTransparent:o}));return f.jsx(Dr.Provider,{value:null,children:f.jsxs(D.HStack,{gap:1,"aria-label":t,role:"group",onClickCapture:p,onKeyDown:y=>{var m;y.key==="Escape"&&(c(!1),(m=u.current)==null||m.focus())},children:[f.jsx(Fe,{label:`${t}: ${h}`,children:f.jsx(D.chakra.button,{ref:u,type:"button","aria-label":`${t} colors`,"aria-expanded":l,"aria-controls":d,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:_e(h),...h==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${_e(a)}`,outlineOffset:"1px",onClick:()=>c(y=>!y)})}),l&&f.jsxs(D.HStack,{id:d,gap:1,children:[[...new Set([...e,...o?["transparent"]:[]])].map(y=>{const m=r===y;return f.jsx(Fe,{label:`${t}: ${y}`,children:f.jsx(D.Box,{as:"button","aria-label":`${t} ${y}`,"aria-pressed":m,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:_e(y),...y==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:m?`2px solid ${_e(a)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(y),onDoubleClick:g=>{var b;g.stopPropagation(),c(!1),(b=u.current)==null||b.focus()}})},y)}),i&&f.jsx(Fe,{label:`Reset ${t.toLowerCase()}`,children:f.jsx(Ae,{"aria-label":`Reset ${t}`,icon:f.jsx(D.Icon,{as:Z.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:s,onClick:()=>{var y;i(),c(!1),(y=u.current)==null||y.focus()}})})]})]})})}function lb({edgeId:e,onClose:r}){var p;const{callbacks:t,themeColor:n,config:i}=Ve(),{colorInactive:o}=it(),{edgeById:s}=hr(),{palette:a,show:l}=cb(),c=(p=s.get(e))==null?void 0:p.data,d=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(i.customEdgeTypes??{}),...c!=null&&c.type?[c.type]:[]])],u=c!=null&&c.isEdgeAnimated?"animated":c!=null&&c.isEdgeDashed?"dashed":"solid",h=[{key:"solid",icon:Z.PiLineSegment,label:"Solid"},{key:"dashed",icon:Z.PiLineSegments,label:"Dashed"},{key:"animated",icon:Z.PiFastForward,label:"Animated"}];return f.jsxs(f.Fragment,{children:[f.jsx(Hr,{onClick:r}),l("label")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(zr,{ariaLabel:"Edge label",placeholder:"Edge label",value:(c==null?void 0:c.label)||"",onCommit:y=>{var m;return(m=t.onEdgeLabelChange)==null?void 0:m.call(t,e,y)}})]}),l("style")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),h.map(y=>f.jsx(Fe,{label:y.label,children:f.jsx(Ae,{"aria-label":`Edge style ${y.key}`,"aria-pressed":u===y.key,icon:f.jsx(D.Icon,{as:y.icon,boxSize:5}),size:"sm",variant:"ghost",color:u===y.key?n:o,onClick:()=>{var m;return(m=t.onEdgeStyleChange)==null?void 0:m.call(t,e,y.key)}})},y.key)),u==="animated"&&f.jsx(ab,{label:"Edge animation",value:(c==null?void 0:c.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:i.readOnly,onChange:y=>{var m;return(m=t.onEdgeAnimationVariantChange)==null?void 0:m.call(t,e,y)}}),f.jsxs(Pt,{"aria-label":"Edge shape",title:`Edge shape: ${(c==null?void 0:c.type)??"Default"}`,icon:f.jsx(Z.PiBezierCurve,{size:20}),style:{width:36},value:(c==null?void 0:c.type)??"",disabled:i.readOnly,onValueChange:y=>{var m;return(m=t.onEdgeTypeChange)==null?void 0:m.call(t,e,y||void 0)},children:[f.jsx("option",{value:"",children:"Default"}),d.map(y=>f.jsx("option",{value:y,children:y},y))]})]}),l("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Ed,{edgeId:e,value:c==null?void 0:c.icon},e),f.jsx(zr,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(c==null?void 0:c.icon)??"",onCommit:y=>{var m;return(m=t.onEdgeIconChange)==null?void 0:m.call(t,e,y)}})]}),l("color")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Er,{label:"Edge color",colors:a,value:c==null?void 0:c.color,onPick:y=>{var m;return(m=t.onEdgeColorChange)==null?void 0:m.call(t,e,y)},onReset:()=>{var y;return(y=t.onEdgeColorChange)==null?void 0:y.call(t,e,"")}})]}),l("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Fe,{label:"Delete edge",children:f.jsx(Ae,{"aria-label":"Delete edge",icon:f.jsx(D.Icon,{as:Z.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var y;(y=t.onEdgeDelete)==null||y.call(t,e,c),r()}})})]})]})}function db({ids:e,showDivider:r=!0}){const{callbacks:t,config:n,nodeGridOptions:i,fillRadiusEditedIds:o,setNodeRadiusPreview:s}=Ve(),{colorInactive:a}=it(),{nodeById:l}=hr(),[c,d]=j.useState(),u=j.useRef(),h=j.useRef(),p=j.useRef({callbacks:t,readOnly:n.readOnly,nodeById:l});p.current={callbacks:t,readOnly:n.readOnly,nodeById:l};const y=()=>{var C,S;clearTimeout(h.current);const w=u.current;if(u.current=void 0,!!w){if(!p.current.readOnly)for(const _ of w.ids)p.current.nodeById.has(_)&&((S=(C=p.current.callbacks).onNodeBorderRadiusChange)==null||S.call(C,_,w.radius));s(w.ids,void 0),d(void 0)}},m=j.useRef(y);m.current=y,j.useEffect(()=>{const w=()=>m.current();return window.addEventListener("pagehide",w),()=>{window.removeEventListener("pagehide",w),w()}},[]);const g=e.map(w=>{var C,S;return i!=null&&i.fill&&!o.has(w)?0:(S=(C=l.get(w))==null?void 0:C.data.viewProps)==null?void 0:S.borderRadius}),b=!g.every(w=>w===g[0]),v=c??g[0]??0,x=w=>{n.readOnly||(w!==void 0&&e.every(C=>{var S;return((S=l.get(C))==null?void 0:S.data.type)==="grid"})?(d(w),s(e,w),u.current={ids:[...e],radius:w},clearTimeout(h.current),h.current=setTimeout(y,150)):(clearTimeout(h.current),u.current=void 0,d(void 0),s(e,void 0),e.forEach(C=>{var S;return(S=t.onNodeBorderRadiusChange)==null?void 0:S.call(t,C,w)})))};return f.jsxs(f.Fragment,{children:[r&&f.jsx(jt,{}),f.jsx(D.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:f.jsx(Pt,{icon:f.jsx(D.Icon,{as:lx.TbBorderRadius,boxSize:5,color:a,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${b?"Mixed":g[0]===void 0?"Default":`${g[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:"radius",disabled:n.readOnly,onValueChange:()=>{},popupContent:f.jsxs(f.Fragment,{children:[f.jsx(nd,{label:"Border radius",inputLabel:"Node corner radius",min:0,max:Math.max(500,...g.map(w=>w??0)),step:1,value:v,displayValue:c!==void 0?`${c}px`:b?"Mixed":g[0]===void 0?"Default":`${v}px`,onChange:x,onChangeEnd:y}),f.jsx(Fe,{label:"Reset border radius",children:f.jsx(Ae,{"aria-label":"Reset border radius",icon:f.jsx(Z.PiEraser,{size:20}),size:"sm",variant:"ghost",color:a,disabled:n.readOnly,onClick:()=>x(void 0)})})]}),children:f.jsx("option",{value:"radius",children:"Border radius"})})})]})}function ub({ids:e,onClose:r}){var z,de,Q,ae,se,Ce,Se,he;const{callbacks:t,colorMode:n,themeColor:i,config:o,setNodeViewMode:s,nodeViewModes:a}=Ve(),{colorText:l,colorInactive:c}=it(),{nodeById:d,parentIds:u}=hr(),{palette:h,show:p}=cb(),y=e.length===1,[m,g]=j.useState(""),b=y?(z=d.get(e[0]))==null?void 0:z.data:void 0,v=e.map(G=>{var ce,X,ye,ve,Oe,Ne;const F=(ce=d.get(G))==null?void 0:ce.data,re=((X=F==null?void 0:F.config)==null?void 0:X.typeView)??"";return re==="object"&&((ye=F==null?void 0:F.config)==null?void 0:ye.content)!==void 0&&a[G]!=="properties"?"content":re==="icon-label"&&((ve=F==null?void 0:F.viewProps)==null?void 0:ve.bgColor)==="transparent"&&((Oe=F==null?void 0:F.viewProps)==null?void 0:Oe.borderWidth)===0&&((Ne=F==null?void 0:F.viewProps)==null?void 0:Ne.outline)===!1?"media":re}),x=v.some(G=>G!==v[0]),w=x?"mixed":v[0]??"",C=[{value:"text",label:"Text",view:"text",icon:Z.PiTextT},{value:"icon-label",label:"Icon Label",view:"icon-label",icon:Z.PiShapes},{value:"object",label:"Object",view:"object",icon:Z.PiBracketsCurly},{value:"grid",label:"Grid",view:"grid",icon:Z.PiGridFour},{value:"parent",label:"Parent",view:"parent",icon:Z.PiStack},{value:"media",label:"Media",view:"icon-label",icon:Z.PiFileSvg},{value:"content",label:"Content",view:"object",icon:Z.PiTextAlignLeft}],S=e.some(G=>{var re,ce,X,ye;const F=(re=d.get(G))==null?void 0:re.data;return F&&((ce=F.config)==null?void 0:ce.typeView)!=="grid"&&((X=F.config)==null?void 0:X.typeView)!=="parent"&&(u.has(G)||((ye=F.config)==null?void 0:ye.parentContainer)||Object.prototype.hasOwnProperty.call(o.customViews??{},F.type))}),_=(de=b==null?void 0:b.config)==null?void 0:de.collapsed,R=ib(e[0]),A=G=>{var F,re,ce;return(((re=(F=d.get(G))==null?void 0:F.data.viewProps)==null?void 0:re.outline)??(u.has(G)?(ce=o.parentNodeStyle)==null?void 0:ce.outline:!1))===!0},O=e.every(A),T=!O&&e.some(A),E=G=>{var F;return((F=d.get(G))==null?void 0:F.data.isNodeAnimated)===!0},M=e.every(E),P=!M&&e.some(E),$=e.map(G=>{var F;return((F=d.get(G))==null?void 0:F.data.nodeAnimationVariant)??"traveling"}),N=$.every(G=>G===$[0])?$[0]:"",I=G=>e.forEach(G),[K,le]=j.useState(!1),ie=K&&p("color")&&p("borderColor"),te=G=>{var F,re,ce;return(((re=(F=d.get(G))==null?void 0:F.data.viewProps)==null?void 0:re.borderStyle)??(u.has(G)?(ce=o.parentNodeStyle)==null?void 0:ce.borderStyle:"solid"))==="dashed"},fe=e.every(te),xe=!fe&&e.some(te),q=e.map(G=>{var ce,X,ye;const F=(ce=d.get(G))==null?void 0:ce.data,re=u.has(G)?En((X=o.parentNodeStyle)==null?void 0:X.borderWidth,6):(F==null?void 0:F.type)==="objectView"?3:2;return En((ye=F==null?void 0:F.viewProps)==null?void 0:ye.borderWidth,re)}),W=q.every(G=>G===q[0])?String(q[0]??""):"",U=G=>I(F=>{var re,ce;ie?(re=t.onNodeBorderColorChange)==null||re.call(t,F,G):(ce=t.onNodeColorChange)==null||ce.call(t,F,"bg",G)});return f.jsxs(f.Fragment,{children:[f.jsx(Hr,{onClick:r}),f.jsx(jt,{}),y&&p("label")?f.jsx(zr,{ariaLabel:"Node label",placeholder:"Node label",value:(b==null?void 0:b.label)??(b==null?void 0:b.headerTitle)??"",onCommit:G=>{var F;return(F=t.onNodeLabelChange)==null?void 0:F.call(t,e[0],G)}}):f.jsxs(D.Text,{fontSize:"xs",color:l,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),p("typeView")&&f.jsxs(Pt,{"aria-label":"Type view",title:S?"Type view is managed by the custom renderer or container":`Type view: ${w||"None (default)"}`,icon:f.jsx(Z.PiCards,{size:20}),style:{width:36},value:w,disabled:o.readOnly||o.editable===!1||S,onValueChange:G=>{var re;const F=(re=C.find(ce=>ce.value===G))==null?void 0:re.view;F&&I(ce=>{var ye,ve,Oe,Ne,Be,et,We,ft,Ke,nt,Ie,He,tt;const X=(ye=d.get(ce))==null?void 0:ye.data;G==="media"?((ve=t.onNodeColorChange)==null||ve.call(t,ce,"bg","transparent"),(Oe=t.onNodeBorderColorChange)==null||Oe.call(t,ce,"#00000000"),(Ne=t.onNodeBorderWidthChange)==null||Ne.call(t,ce,0),(Be=t.onNodeOutlineChange)==null||Be.call(t,ce,!1)):v[e.indexOf(ce)]==="media"&&((et=t.onNodeColorChange)==null||et.call(t,ce,"bg",""),(We=t.onNodeBorderColorChange)==null||We.call(t,ce,""),(ft=t.onNodeBorderWidthChange)==null||ft.call(t,ce,void 0)),G==="content"&&((Ke=X==null?void 0:X.config)==null?void 0:Ke.content)===void 0&&((nt=t.onNodeContentChange)==null||nt.call(t,ce,"")),(Ie=t.onNodeTypeViewChange)==null||Ie.call(t,ce,F),s(ce,G==="object"&&((He=X==null?void 0:X.config)==null?void 0:He.content)!==void 0?"properties":"default"),(tt=t.onNodeViewToggle)==null||tt.call(t,ce)})},children:[x&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),C.map(G=>f.jsx("option",{value:G.value,children:f.jsxs(D.HStack,{gap:"12px",children:[f.jsx(G.icon,{size:20,"aria-hidden":"true",style:{flexShrink:0}}),f.jsx("span",{children:G.label})]})},G.value))]}),p("style")&&f.jsx(db,{ids:e},e.join("\0")),p("outline")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Fe,{label:O?"Restore node fill":"Remove node fill",children:f.jsx(Ae,{"aria-label":"Toggle node outline","aria-pressed":T?"mixed":O,icon:f.jsx(D.Icon,{as:O?Z.PiSquare:Z.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:O?i:c,onClick:()=>I(G=>{var F;return(F=t.onNodeOutlineChange)==null?void 0:F.call(t,G,!O)})})})]}),p("color")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),p("borderColor")&&f.jsx(Fe,{label:ie?"Edit node colors":"Edit node border",children:f.jsx(Ae,{"aria-label":"Edit node border","aria-pressed":ie,icon:f.jsx(D.Icon,{as:Z.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:ie?i:c,bg:ie?n==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>le(G=>!G)})}),f.jsx(Er,{label:ie?"Border color":"Background",colors:h,value:ie?((Q=b==null?void 0:b.viewProps)==null?void 0:Q.borderColor)??(y&&u.has(e[0])?(ae=o.parentNodeStyle)==null?void 0:ae.borderColor:void 0):(se=b==null?void 0:b.viewProps)==null?void 0:se.bgColor,onPick:U,onReset:()=>U("")}),ie&&p("style")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Fe,{label:fe?"Solid border":"Dashed border",children:f.jsx(Ae,{"aria-label":"Toggle dashed border","aria-pressed":xe?"mixed":fe,icon:f.jsx(D.Icon,{as:fe?Z.PiLineSegments:Z.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:fe?i:c,onClick:()=>I(G=>{var F;return(F=t.onNodeBorderStyleChange)==null?void 0:F.call(t,G,fe?"solid":"dashed")})})}),f.jsx(zr,{ariaLabel:"Border thickness",placeholder:y?"Auto":"Mixed",width:"64px",type:"number",min:0,value:W,onCommit:G=>I(F=>{var re;return(re=t.onNodeBorderWidthChange)==null?void 0:re.call(t,F,G===""?void 0:Number(G))})})]})]}),p("animation")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Fe,{label:M?"Stop border animation":"Animate node border",children:f.jsx(Ae,{"aria-label":"Toggle node animation","aria-pressed":P?"mixed":M,icon:f.jsx(D.Icon,{as:Z.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:M?i:c,onClick:()=>I(G=>{var F;return(F=t.onNodeAnimationChange)==null?void 0:F.call(t,G,!M)})})}),(M||P)&&f.jsx(ab,{label:"Node animation",value:N,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:o.readOnly,onChange:G=>I(F=>{var re;return(re=t.onNodeAnimationVariantChange)==null?void 0:re.call(t,F,G)})})]}),!ie&&p("textColor")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Er,{label:"Text color",colors:sb,value:(Ce=b==null?void 0:b.viewProps)==null?void 0:Ce.textColor,onPick:G=>I(F=>{var re;return(re=t.onNodeColorChange)==null?void 0:re.call(t,F,"text",G)}),onReset:()=>I(G=>{var F;return(F=t.onNodeColorChange)==null?void 0:F.call(t,G,"text","")})})]}),y&&p("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Ed,{nodeId:e[0],value:(Se=b==null?void 0:b.config)==null?void 0:Se.icon},e[0]),f.jsx(zr,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((he=b==null?void 0:b.config)==null?void 0:he.icon)||"",onCommit:G=>{var F;return(F=t.onNodeIconChange)==null?void 0:F.call(t,e[0],G)}})]}),y&&R&&p("collapse")&&_!==void 0&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Fe,{label:_?"Expand":"Collapse",children:f.jsx(Ae,{"aria-label":_?"Expand node":"Collapse node",icon:f.jsx(D.Icon,{as:_?Z.PiArrowsOutLineVertical:Z.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:c,onClick:()=>{var G;return(G=t.onNodeCollapse)==null?void 0:G.call(t,e[0],!_)}})})]}),p("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Fe,{label:y?"Delete node":`Delete ${e.length} nodes`,children:f.jsx(Ae,{"aria-label":"Delete selected nodes",icon:f.jsx(D.Icon,{as:Z.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:n==="dark"?"red.300":"red.500",onClick:()=>{I(G=>{var F,re;return(re=t.onNodeDelete)==null?void 0:re.call(t,G,((F=d.get(G))==null?void 0:F.data)||{id:G})}),r()}})})]}),f.jsx(jt,{}),f.jsx(Fe,{label:"Copy selection",children:f.jsx(Ae,{"aria-label":"Copy selection",icon:f.jsx(Z.PiCopy,{size:20}),size:"sm",variant:"ghost",color:c,onClick:async()=>{var G;try{await((G=t.onNodesCopy)==null?void 0:G.call(t,e)),g("")}catch(F){g(String(F))}}})}),f.jsx(Fe,{label:"Duplicate selection",children:f.jsx(Ae,{"aria-label":"Duplicate selection",icon:f.jsx(Z.PiCopySimple,{size:20}),size:"sm",variant:"ghost",color:c,disabled:o.readOnly||o.editable===!1,onClick:()=>{var G;try{(G=t.onNodesDuplicate)==null||G.call(t,e),g("")}catch(F){g(String(F))}}})}),m&&f.jsx(D.Text,{role:"alert",fontSize:"xs",children:m})]})}async function fb(e){const{toSvg:r}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const t=await r(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(t.slice(t.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 hb(e,r="squeed.svg"){const t=document.createElement("a");t.href=await fb(e),t.download=r.endsWith(".svg")?r:`${r}.svg`,t.click()}function pb(){const{themeColor:e}=Ve(),[r,t]=j.useState(!1),[n,i]=j.useState("");return f.jsxs(f.Fragment,{children:[f.jsx(Fe,{label:"Download SVG (current view)",children:f.jsx(Ae,{"aria-label":"Download SVG",icon:f.jsx(Z.PiDownloadSimpleFill,{size:20}),disabled:r,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}t(!0),i("");try{await hb(s)}catch(l){i(l instanceof Error?l.message:"Unable to export SVG.")}finally{t(!1)}}})}),n&&f.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function Rd({children:e,background:r,border:t,endElement:n,startElement:i,startElementWidth:o=44,framed:s=!0}){const a=j.useRef(null),[l,c]=j.useState({left:!1,right:!1});j.useLayoutEffect(()=>{const u=a.current;let h=u.parentElement.offsetWidth;const p=()=>{const g=u.parentElement.offsetWidth;if(g>0&&g!==h){const x=h/g;h=g,x>0&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&u.parentElement.animate({transform:[`scaleX(${x})`,"scaleX(1)"],transformOrigin:[n?"right center":"left center",n?"right center":"left center"]},{duration:180,easing:"ease-out",id:"flow-toolbar-grow"})}const b=u.scrollLeft>1,v=u.scrollWidth-u.clientWidth-u.scrollLeft>1;c(x=>x.left===b&&x.right===v?x:{left:b,right:v})},y=g=>{if(g.defaultPrevented||g.ctrlKey||s&&g.deltaX!==0||!(g.deltaX||g.deltaY)||u.scrollWidth<=u.clientWidth)return;g.preventDefault();const b=g.deltaMode===WheelEvent.DOM_DELTA_LINE?16:g.deltaMode===WheelEvent.DOM_DELTA_PAGE?u.clientWidth:1;u.scrollLeft+=(g.deltaX||g.deltaY)*b},m=new ResizeObserver(p);return m.observe(u),u.firstElementChild&&m.observe(u.firstElementChild),u.addEventListener("scroll",p,{passive:!0}),u.addEventListener("wheel",y,{passive:!1}),p(),()=>{m.disconnect(),u.removeEventListener("scroll",p),u.removeEventListener("wheel",y)}},[]);const d=`var(--chakra-colors-${r.replace(".","-")})`;return f.jsxs(D.Box,{position:"relative",bg:s?r:"transparent",minW:0,maxW:"100%",flex:"0 1 auto",borderRadius:s?"30px":0,css:{...s?lr(d,`var(--chakra-colors-${t.replace(".","-")})`):{},...s||i?{"--flow-toolbar-start-width":i?`${o}px`:"0px"}:{}},children:[f.jsx(D.Box,{ref:a,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",mr:n?"44px":void 0,ml:i?`${o}px`:void 0,borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(u=>f.jsx(D.Box,{"data-flow-toolbar-fade":u,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",borderRadius:u==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[u]:u==="right"&&n?44:u==="left"&&i?o:0,opacity:l[u]?1:0,background:`linear-gradient(to ${u==="left"?"right":"left"}, ${d}, transparent)`}},u)),n&&f.jsx(D.Box,{position:"absolute",right:"6px",top:0,h:"50px",w:"32px",display:"flex",alignItems:"center",justifyContent:"center",children:n}),i&&f.jsx(D.Box,{position:"absolute",left:"6px",top:0,h:"50px",w:`${o-12}px`,display:"flex",alignItems:"center",justifyContent:"center",children:i})]})}async function vw(e,r){const t=new Set,n=[],i=(a,l)=>{var d,u,h;if(!a||typeof a!="object")return;const c=a;n.push(l),typeof((d=c.$form)==null?void 0:d.$type)=="string"&&t.add(c.$form.$type),typeof((h=(u=c.$form)==null?void 0:u.$create)==null?void 0:h.$type)=="string"&&t.add(c.$form.$create.$type);for(const[p,y]of Object.entries(c))p==="$"?i(y,l):p.startsWith("$")||i(y,`${l}.${p}`)};if(i(r,"root"),!t.size)return{contract:await tb(e)};const o=await jd(e,[...t]);for(const a of t)if(!Object.prototype.hasOwnProperty.call(o,a))throw new Error(`Missing form type: ${a}`);const s={};for(const a of n){const l=Kr(r,a,o);l&&(s[a]={type:l.type,optional:!1})}return{schema:o,contract:{name:e.name,nodes:s}}}function gb({message:e,onDismiss:r}){const{background:t,colorText:n,border:i}=it();return!e||typeof document>"u"?null:Cn.createPortal(f.jsxs(D.chakra.div,{role:"alert","aria-atomic":"true",css:lr(_e(t),_e(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:_e(t),color:_e(n),fontSize:14,lineHeight:1.5},children:[f.jsx(Z.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(Hr,{type:"button","aria-label":"Dismiss upload error",title:"Dismiss upload error",onClick:r,flexShrink:0,width:"24px",height:"24px",minWidth:"24px",padding:0})]}),document.body)}function kd({showDivider:e=!0,compact:r=!1}={}){const{edgeMode:t,setEdgeMode:n,workflowContract:i,setWorkflowContract:o,callbacks:s,readOnly:a,themeColor:l,colorMode:c}=Ve(),{edgeById:d}=hr(),{data:u,schema:h,setSchema:p,bindings:y,structured:m}=j.useContext(Mt),g=(m==null?void 0:m.sourceBindings)??y,b=(m==null?void 0:m.sourceSchema)??h,{colorText:v}=it(),x=j.useRef(null),w=j.useRef(0),[C,S]=j.useState(!1),[_,R]=j.useState("");j.useEffect(()=>()=>{w.current++},[]),j.useEffect(()=>{w.current++,S(!1)},[a,u,g]);const A=i?[...d.values()].filter(E=>Sd(i,E.data)).length:0,O=i?`${i.name}: ${b?`${Object.keys(b).length} form types loaded; `:""}${A} invalid or unverified connections`:"",T=eo(f.jsx(kd,{showDivider:!1,compact:!0}));return f.jsx(Dr.Provider,{value:null,children:f.jsxs("span",{style:{display:"contents"},onClickCapture:T,children:[f.jsx(gb,{message:_,onDismiss:()=>R("")}),e&&f.jsx(hn,{}),f.jsxs(Pt,{"aria-label":"Edge mode",title:t==="auto"?"Connections: Auto":t==="properties"?"Connections: Properties":"Connections: Nodes",icon:t==="auto"?f.jsx(Z.PiGraph,{size:20}):t==="properties"?f.jsx(Z.PiTable,{size:20}):f.jsx(Z.PiTreeStructure,{size:20}),style:{width:36},value:t,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(D.Button,{"data-flow-menu-action":"",variant:"ghost",width:"100%",justifyContent:"flex-start",color:"inherit",bg:"transparent",css:Kn,_hover:{bg:c==="dark"?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:c==="dark"?"whiteAlpha.100":"blackAlpha.50"},onClick:E=>{var M,P;(M=E.currentTarget.closest("[popover]"))==null||M.hidePopover(),(P=s.onWorkflowConfigurationOpen)==null||P.call(s)},children:[f.jsx(Z.PiGear,{}),"Configuration"]})]}),onValueChange:E=>{var P;const M=E==="auto"?"auto":E==="properties"?"properties":"nodes";n(M),(P=s.onEdgeModeChange)==null||P.call(s,M)},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:t==="auto"||t==="properties"?"contents":"none"},children:[f.jsx(Fe,{label:i?`Replace ${i.name}`:"Upload workflow interface",children:f.jsx(Ae,{"aria-label":"Upload workflow interface",icon:f.jsx(Z.PiUploadSimple,{size:20}),color:_e(l),size:"sm",variant:"ghost",disabled:C||a,onClick:()=>{var E;return(E=x.current)==null?void 0:E.click()}})}),f.jsx("input",{ref:x,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:a||C,onChange:async E=>{var $,N;const M=($=E.target.files)==null?void 0:$[0];if(E.target.value="",!M)return;const P=++w.current;S(!0),R("");try{const I=g?await jd(M,[...new Set(Object.values(g).map(ie=>ie.schemaType??ie.type))]):void 0;if(g&&I){for(const ie of Object.values(g))if(!Object.prototype.hasOwnProperty.call(I,ie.schemaType??ie.type))throw new Error(`Missing form type: ${ie.schemaType??ie.type}`)}const{contract:K,schema:le}=g&&I?{schema:I,contract:{name:M.name,nodes:Object.fromEntries(Object.entries(g).map(([ie,te])=>[ie,{type:I[te.schemaType??te.type],optional:!1}]))}}:await vw(M,u);if(P!==w.current)return;p==null||p(le),o(K),(N=s.onWorkflowContractChange)==null||N.call(s,K)}catch(I){P===w.current&&R(`${M.name}: ${I instanceof Error?I.message:"Unable to load interface."}`)}finally{P===w.current&&S(!1)}}}),!r&&(O||C)&&f.jsx("span",{role:"status",title:O,style:{color:_e(v),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:C?"Loading interface...":O}),!r&&i&&f.jsx(Fe,{label:"Remove workflow interface",children:f.jsx(Ae,{"aria-label":"Remove workflow interface",icon:f.jsx(Z.PiX,{size:16}),size:"sm",variant:"ghost",disabled:a||C,onClick:()=>{var E;p==null||p(void 0),o(void 0),(E=s.onWorkflowContractChange)==null||E.call(s,void 0),R("")}})})]})]})})}const xw=[{value:"BT",label:"Bottom to Up",icon:Z.PiArrowUp,flowType:an.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:Z.PiArrowDown,flowType:an.TOP_DOWN},{value:"LR",label:"Left to Right",icon:Z.PiArrowRight,flowType:an.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:Z.PiArrowLeft,flowType:an.RIGHT_LEFT}],yb=()=>{const{engineRef:e,themeColor:r,setThemeColor:t,edgeColor:n,setEdgeColor:i,backgroundSelected:o,setBackgroundSelected:s,direction:a,edgeMode:l,allNodesIconLabel:c,setAllNodesIconLabel:d,nodeGridOptions:u,selectedNodeIds:h,setSelectedNodeIds:p,selectedEdgeId:y,setSelectedEdgeId:m,isZoomMode:g,setIsZoomMode:b,isMultiSelectMode:v,setIsMultiSelectMode:x,isDragMode:w,setIsDragMode:C,isEdgeHandlesEnabled:S,setIsEdgeHandlesEnabled:_,isArrayNodeMode:R,setIsArrayNodeMode:A,isPinned:O,setIsPinned:T,callbacks:E,config:M,readOnly:P}=Ve(),{nodeById:$,edgeById:N,parentIds:I}=hr(),K=M.colorMode==="dark",{background:le,border:ie,colorInactive:te,colorText:fe,colorActive:xe}=it(),q=K?ie:"gray.300",W=`var(--chakra-colors-${le.replace(".","-")})`,U=`var(--chakra-colors-${(K?ie:"gray.300").replace(".","-")})`,[z,de]=j.useState(!1),[Q,ae]=j.useState(!0),se=M.bottomBarCollapsed??Q,Ce=j.useRef(null),Se=ym({edge:"bottom",enabled:!O,bounds:Ce,inside:[Ce]}),he=j.useCallback(Ie=>{const He=e.current;if(!He)return;const tt=M.minZoom??.01,gt=M.maxZoom??1.5,at=.02;let Et=He.zoom();switch(Ie){case"increase":Et=Math.min(gt,Et+at),He.zoom(Et),He.center(!1);break;case"decrease":Et=Math.max(tt,Et-at),He.zoom(Et),He.center(!1);break;case"reset":He.fit(50);break}},[e,M.minZoom,M.maxZoom]),G=M.renderSelectedNodeToolbar,F=h.length>0&&!!G,re=j.useMemo(()=>F?h.map(Ie=>{var tt;return{...((tt=$.get(Ie))==null?void 0:tt.data)??{id:Ie},isParent:I.has(Ie)}}):[],[F,h,$,I]),ce=j.useCallback(()=>{var Ie;p([]),(Ie=E.onNodeDeselect)==null||Ie.call(E)},[p,E]),X=M.renderSelectedEdgeToolbar,ye=!!y&&!!X,ve=j.useMemo(()=>{var Ie;return!ye||!y?null:((Ie=N.get(y))==null?void 0:Ie.data)??{id:y}},[ye,y,N]),Oe=j.useCallback(()=>{var Ie;m(null),(Ie=E.onEdgeDeselect)==null||Ie.call(E)},[m,E]),Ne=M.selectionToolbar!==!1&&!P,Be=Ne&&!!y&&!X,et=Ne&&!Be&&h.length>0&&!G,We=Be||et,ft=O||Se||z||We||M.bottomBarCollapsed===!1;j.useEffect(()=>{h.length||y?s(!1):P||(o&&T(!0),M.bottomBarCollapsed===void 0&&ae(!o))},[o,h.length,y,P,s,T,M.bottomBarCollapsed]);const Ke=M.renderBottomBar,nt=K0();return Ke?f.jsxs(f.Fragment,{children:[F&&f.jsx(D.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:G({selectedNodeIds:h,selectedNodeData:re,onDeselect:ce})}),ye&&ve&&f.jsx(D.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:X({edgeId:y,edgeData:ve,onDeselect:Oe})}),f.jsx(D.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:Ke({zoomIn:()=>he("increase"),zoomOut:()=>he("decrease"),resetZoom:()=>he("reset"),direction:a,isZoomMode:g,setIsZoomMode:b,isMultiSelectMode:v,setIsMultiSelectMode:x,isDragMode:w,setIsDragMode:C,isEdgeHandlesEnabled:S,setIsEdgeHandlesEnabled:_,isArrayNodeMode:R,setIsArrayNodeMode:A,selectedNodeIds:h,selectedNodeData:re,selectedEdgeId:y,selectedEdgeData:ve,onNodeDeselect:ce,onEdgeDeselect:Oe,callbacks:E})})]}):f.jsxs(Dr.Provider,{value:nt,children:[F&&f.jsx(D.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:G({selectedNodeIds:h,selectedNodeData:re,onDeselect:ce})}),ye&&ve&&f.jsx(D.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:X({edgeId:y,edgeData:ve,onDeselect:Oe})}),f.jsx(D.Box,{ref:Ce,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:ft?"translateY(0)":"translateY(100%)",pointerEvents:ft?"auto":"none",visibility:ft?"visible":"hidden",opacity:ft?1:0,css:{"& button > svg:not([popover] *)":{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",flexShrink:0},"@media (hover: none)":{visibility:"visible",opacity:1,transform:"none",pointerEvents:"auto"}},children:f.jsxs(D.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(Rd,{background:le,border:K?ie:"gray.300",children:f.jsxs(D.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[Be?f.jsx(lb,{edgeId:y,onClose:Oe}):et?f.jsx(ub,{ids:h,onClose:ce}):null,f.jsxs("div",{style:{display:Be||et?"none":"contents"},children:[f.jsxs("span",{style:{display:M.bottomBarNavigation===!1?"none":"contents"},children:[f.jsx(Fe,{label:O?"Unpin":"Pin",children:f.jsx(Ae,{"aria-label":"Pin",icon:f.jsx(D.Icon,{as:O?Z.PiPushPinFill:Z.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:O?r:te,onClick:()=>{T(!O),de(!1)}})}),f.jsx(D.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:q}),f.jsx(Fe,{label:"Zoom Out",children:f.jsx(Ae,{"aria-label":"Zoom out",rememberAction:!1,icon:f.jsx(D.Icon,{as:Z.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:fe,onClick:()=>he("decrease")})}),f.jsx(Fe,{label:"Zoom In",children:f.jsx(Ae,{"aria-label":"Zoom in",rememberAction:!1,icon:f.jsx(D.Icon,{as:Z.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:fe,onClick:()=>he("increase")})}),f.jsx(Fe,{label:"Reset Zoom",children:f.jsx(Ae,{"aria-label":"Reset zoom",rememberAction:!1,icon:f.jsx(D.Icon,{as:Z.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:fe,onClick:()=>he("reset")})}),se&&f.jsx(J0,{visibleActions:u?["Collision mode","Fill",...u.fill?["Grid adjustment"]:[]]:[],divider:f.jsx(D.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:q,role:"separator","aria-orientation":"vertical"})})]}),f.jsxs("span",{style:{display:se?"none":"contents"},children:[f.jsxs("span",{style:{display:M.bottomBarNavigation===!1?"none":"contents"},children:[M.edgeHandles!==!1&&f.jsx(Fe,{label:S?"Draw Mode On (V)":"Draw Mode Off (V)",children:f.jsx(Ae,{"aria-label":"Toggle draw mode","aria-keyshortcuts":"V","aria-pressed":S,icon:f.jsx(D.Icon,{as:Z.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:S?r:te,onClick:()=>_(!S)})}),f.jsx(D.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:q}),f.jsx(Fe,{label:g?"Zoom Mode (z)":"Pan Mode (z)",children:f.jsx(Ae,{"aria-label":"Toggle zoom mode",icon:f.jsx(D.Icon,{as:g?Z.PiMagnifyingGlassPlus:Z.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:g?r:te,onClick:()=>b(!g)})}),f.jsx(D.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:q}),f.jsx(Fe,{label:v?"Multi-Select On (m)":"Multi-Select Off (m)",children:f.jsx(Ae,{"aria-label":"Toggle multi-select",icon:f.jsx(D.Icon,{as:Z.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:v?r:te,onClick:()=>x(!v)})}),f.jsx(D.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:q}),f.jsx(Fe,{label:w?"Drag Mode On (d)":"Drag Mode Off (d)",children:f.jsx(Ae,{"aria-label":"Toggle drag mode",icon:f.jsx(D.Icon,{as:Z.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:w?r:te,onClick:()=>C(!w)})})]}),M.bottomBarNavigation===!1&&f.jsx(wu,{}),M.bottomBarExtra&&f.jsxs(f.Fragment,{children:[M.bottomBarNavigation!==!1&&f.jsx(D.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:q,role:"separator","aria-orientation":"vertical"}),M.bottomBarExtra]}),f.jsx(D.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:q,role:"separator","aria-orientation":"vertical"}),f.jsx(Wm,{})]}),f.jsx("span",{style:{display:M.bottomBarNavigation===!1||se&&!u?"none":"contents"},children:f.jsx(wu,{})}),f.jsxs("span",{style:{display:se?"none":"contents"},children:[f.jsx(D.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:q,role:"separator","aria-orientation":"vertical"}),f.jsx(qr,{label:"Collapse all",hideLabel:!0,checked:c,icon:f.jsx(D.Icon,{as:Z.PiArrowsInLineVertical,boxSize:5}),onChange:d}),l!=="properties"&&f.jsxs(f.Fragment,{children:[f.jsx(D.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:q}),f.jsx(Fe,{label:R?"Array Mode [ ]":"Set Mode { }",children:f.jsx(Ae,{"aria-label":"Toggle array mode",icon:f.jsx(D.Icon,{as:R?Z.PiBracketsSquare:Z.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:R?r:te,onClick:()=>{var He;const Ie=!R;A(Ie),(He=E.onArrayModeChange)==null||He.call(E,Ie)}})})]}),f.jsx(kd,{}),!P&&f.jsxs("span",{style:{display:o?"contents":"none"},children:[f.jsx(D.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:q}),f.jsx(Er,{label:"Graph theme",colors:Jn,value:r,includeTransparent:!1,onPick:Ie=>{var He;t(Ie),(He=E.onThemeColorChange)==null||He.call(E,Ie)}})]}),!P&&f.jsxs(f.Fragment,{children:[f.jsx(D.Icon,{as:Z.PiLineVerticalThin,boxSize:5,color:q,role:"separator","aria-orientation":"vertical"}),f.jsx(Er,{label:"Graph edge color",colors:Jn,value:n||(K?"gray.500":Ur),onPick:i,onReset:()=>i("")}),f.jsx(D.Icon,{as:Z.PiLineVerticalThin,boxSize:5,color:q,role:"separator","aria-orientation":"vertical"})]}),f.jsx(Gm,{})]}),f.jsx(D.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:q}),f.jsx(Fe,{label:se?"Expand toolbar":"Collapse toolbar",children:f.jsx(Ae,{"aria-label":"Toggle toolbar collapse",rememberAction:!1,icon:f.jsx(D.Icon,{as:se?Z.PiCaretRight:Z.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:te,onClick:()=>{var Ie;M.bottomBarCollapsed===void 0&&ae(!se),s(se),(Ie=E.onBottomBarCollapsedChange)==null||Ie.call(E,!se)}})}),!se&&f.jsx(pb,{})]})]})}),!We&&f.jsxs(D.Box,{position:"relative",ml:"auto",flexShrink:0,children:[f.jsx(D.Box,{"data-flow-direction-control":"",bg:le,borderRadius:"30px",h:50,css:lr(W,U),px:3,cursor:"pointer",onClick:()=>de(!z),children:f.jsxs(D.Flex,{align:"center",h:"100%",children:[f.jsx(Fe,{label:"Flow Direction",children:f.jsx(Ae,{"aria-label":"Direction",onClick:Ie=>{Ie.stopPropagation(),de(!z)},icon:f.jsx(D.Icon,{as:Z.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:te})}),f.jsx(D.Text,{fontSize:"xs",textTransform:"uppercase !important",color:K?"whiteAlpha.600":"blackAlpha.500",ml:1,children:a.toUpperCase()})]})}),z&&f.jsx(D.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:f.jsxs(D.Box,{bg:le,borderRadius:"30px",p:2,minW:"180px",css:lr(W,U),children:[xw.map(Ie=>f.jsxs(D.Flex,{align:"center",gap:3,px:3,py:2,css:Kn,cursor:"pointer",_hover:{bg:K?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var He;(He=E.onDirectionChange)==null||He.call(E,Ie.value),de(!1)},children:[f.jsx(D.Icon,{as:Ie.icon,boxSize:5,color:fe}),f.jsx(D.Text,{fontSize:"sm",color:fe,flex:1,whiteSpace:"nowrap",children:Ie.label}),a===Ie.value&&f.jsx(D.Icon,{as:Z.PiCheck,boxSize:4,color:xe})]},Ie.value)),f.jsxs(D.Flex,{align:"center",gap:3,px:3,py:2,css:Kn,cursor:"pointer",_hover:{bg:K?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Ie;(Ie=E.onDirectionChange)==null||Ie.call(E,"C"),de(!1)},children:[f.jsx(D.Icon,{as:Z.PiAlignCenterHorizontal,boxSize:5,color:fe}),f.jsx(D.Text,{fontSize:"sm",color:fe,flex:1,whiteSpace:"nowrap",children:"Center"}),a==="C"&&f.jsx(D.Icon,{as:Z.PiCheck,boxSize:4,color:xe})]})]})})]})]})})]})};yb.displayName="BottomBar";const mb=j.memo(yb);function ww({checked:e,onChange:r,disabled:t,label:n="Connected nodes"}){return f.jsx(qr,{hideLabel:!0,label:n,helper:`${n}: isolate node and its connections`,checked:e,onChange:r,disabled:t,icon:f.jsx(D.Icon,{as:Z.PiGraph,boxSize:5})})}const Iu={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function bb(e,r){const t=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(l=>Object.prototype.hasOwnProperty.call(s,l)&&n(o[l],s[l]))},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 l=new Set([...Object.keys(o),...Object.keys(s)]);for(const c of l)if(!n(o[c],s[c])){if(Object.prototype.hasOwnProperty.call(Iu,c)){if(typeof s[c]!="string"||!s[c])return!1;t.set(a,{...t.get(a),[Iu[c]]:s[c]})}else if(c.startsWith("$")&&c!=="$"||!i(o[c],s[c],c==="$"?a:`${a}.${c}`))return!1}return!0};if(i(e,r,"root"))return t}function Cw(e,r){return bb(e,r)!==void 0}function Sw(e,r,t){if(e===r)return t;const n=bb(e,r);if(!n)return;const i=new Set(t.nodes.map(o=>o.data.id));for(const o of n.keys())if(!i.has(o)||!Te(r,o))return;return{edges:t.edges,nodes:t.nodes.map(o=>{const s=n.get(o.data.id),a=Te(e,o.data.id),l=Te(r,o.data.id);return!s&&a===l?o:{...o,data:{...o.data,...typeof o.data.code=="string"?{code:JSON.stringify(l,null,2)}:{},...s?{viewProps:{...o.data.viewProps,...s},config:{...o.data.config,...s}}:{}}}})}}function ad(e){return e.kind==="literal"?e.value:e.kind==="union"?ad(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,r])=>!r.optional).map(([r,t])=>[r,ad(t.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function vb(e,r,t){var g,b,v;const n=(g=Te(e,r))==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(x=>!/^[A-Za-z0-9_-]+$/.test(x)||["__proto__","constructor","prototype"].includes(x)))throw new Error("Invalid form creation address.");if(!t||!Object.prototype.hasOwnProperty.call(t,i.$type))throw new Error(`Load form type: ${i.$type}`);const s=o.pop(),a=["root",...o].join("."),l=Kr(e,a,t),c=(b=l==null?void 0:l.type.properties[s])==null?void 0:b.type;if((c==null?void 0:c.kind)!=="array"||c.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const d=t[i.$type],u=i.$defaults??{};for(const[x,w]of Object.entries(u))if(!Object.prototype.hasOwnProperty.call(d.properties,x)||zt(d.properties[x].type,w,!d.properties[x].optional))throw new Error(`Invalid creation default: ${x}`);const h={...ad(d),...structuredClone(u)};((v=d.properties.id)==null?void 0:v.type.kind)==="string"&&(h.id=gd());let p=e;const y=Te(e,i.$address);if(y===void 0)p=_t(e,a,x=>({...x,[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=vd(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:xd(m.json,r,{target:m.address,label:i.$edgeLabel})}}function xb(e,r,t){var o;if(r==="root"||!Te(e,r)||!Te(e,t))throw new Error("The source or Parent no longer exists.");const n=new Set;let i=t;for(;i;){if(i===r||i.startsWith(`${r}.`)||n.has(i))throw new Error("A node cannot be moved inside itself or its descendants.");n.add(i);const s=(o=Te(e,i))==null?void 0:o.$parent;i=typeof s=="string"?s:i.includes(".")?i.slice(0,i.lastIndexOf(".")):void 0}return bd(_t(e,r,s=>({...s,$parent:t})),t,!1)}function wb(e,r){const t=new Set(r.filter(a=>Te(e,a)!==void 0)),n=[],i=(a,l)=>{if(!(!a||typeof a!="object")){n.push([l,a]);for(const[c,d]of Object.entries(a))c.startsWith("$")||i(d,`${l}.${c}`)}};i(e,"root");const o=a=>[...t].some(l=>a===l||a.startsWith(`${l}.`));let s=!0;for(;s;){s=!1;for(const[a,l]of n)!o(a)&&typeof l.$parent=="string"&&o(l.$parent)&&(t.add(a),s=!0)}return[...t].filter(a=>![...t].some(l=>l!==a&&a.startsWith(`${l}.`)))}function Ad(e,r){const t=wb(e,r),n=new Map(t.map((a,l)=>[a,`root.node_${l+1}`])),i=a=>{const l=t.find(c=>a===c||a.startsWith(`${c}.`));return l?`${n.get(l)}${a.slice(l.length)}`:void 0},o=a=>{if(!(!a||typeof a!="object")){Array.isArray(a.$connections)&&(a.$connections=a.$connections.flatMap(l=>{const c=typeof l.target=="string"&&i(l.target);return c?[{...l,id:void 0,target:c}]:[]}));for(const l of["$parent","$target"])if(typeof a[l]=="string"){const c=i(a[l]);c?a[l]=c:delete a[l]}for(const[l,c]of Object.entries(a))l.startsWith("$")||o(c)}},s={$hideRoot:!0};return t.forEach((a,l)=>{const c=structuredClone(Te(e,a));o(c),s[`node_${l+1}`]=c}),s}function Cb(e,r){const t=Ad(e,r),n=Object.keys(t).filter(a=>!a.startsWith("$")),i=new Map(n.map(a=>[a,`copy_${crypto.randomUUID()}`])),o=a=>{if(!a||typeof a!="object")return;const l=c=>{const d=c.split(".");return d[0]==="root"&&i.has(d[1])&&(d[1]=i.get(d[1])),d.join(".")};for(const c of a.$connections??[])c.target=l(c.target),c.id=crypto.randomUUID();for(const c of["$parent","$target"])typeof a[c]=="string"&&(a[c]=l(a[c]));for(const[c,d]of Object.entries(a))c.startsWith("$")||o(d)},s=Object.fromEntries(n.map(a=>{const l=t[a];return o(l),[i.get(a),l]}));return{json:_t(e,"root",a=>({...a,...s})),ids:[...i.values()].map(a=>`root.${a}`)}}function jw(e,r){const t=i=>e&&typeof e=="object"&&i in e;let n=1;for(;t(`${r}_${n}`);)n++;return`${r}_${n}`}function Sb(e,r,t,n,i){const o=(a,l)=>{a!==e&&(e=a,n==null||n(a,l))},s=a=>{var c;const l=(c=r.find(d=>d.data.id===a))==null?void 0:c.data;return l&&{source:l.source,target:l.target,isInverted:l.isInverted,sourceProperty:l.sourceProperty,targetProperty:l.targetProperty,connection:l.connection}};return{...t,onNodeParentChange:(a,l)=>{var d;const c=xb(e,a,l);(d=t.onNodeParentChange)==null||d.call(t,a,l),o(c,{type:"nodeStyle",address:a,key:"$parent",value:l})},onNodesCopy:async a=>{var l;await((l=t.onNodesCopy)==null?void 0:l.call(t,a))!==!0&&await navigator.clipboard.writeText(JSON.stringify(Ad(e,a),null,2))},onNodesDuplicate:a=>{var c;if(((c=t.onNodesDuplicate)==null?void 0:c.call(t,a))===!0)return;const l=Cb(e,a);o(l.json,{type:"nodeCreate",address:l.ids[0]})},onFormChange:a=>{const l=Te(e,a.nodeAddress);if(!l||a.nodeId!==void 0&&l.id!==a.nodeId)throw new Error("This form node has moved. Retry the edit.");o(io(e,a,t.onFormChange),{type:"form",address:a.address,value:a.value})},onNodeLabelChange:(a,l)=>{var c;(c=t.onNodeLabelChange)==null||c.call(t,a,l),o(xt(e,a,"$label",l),{type:"nodeLabel",address:a,key:"$label",value:l})},onNodeSubtitleChange:(a,l)=>{var c;(c=t.onNodeSubtitleChange)==null||c.call(t,a,l),o(xt(e,a,"$subtitle",l),{type:"nodeStyle",address:a,key:"$subtitle",value:l})},onNodeContentChange:(a,l)=>{var c;(c=t.onNodeContentChange)==null||c.call(t,a,l),o(xt(e,a,"$content",l),{type:"nodeContent",address:a,key:"$content",value:l})},onNodeTypeViewChange:(a,l)=>{var c;l!==void 0&&!fd.includes(l)||((c=t.onNodeTypeViewChange)==null||c.call(t,a,l),o(xt(e,a,"$view",l),{type:"nodeStyle",address:a,key:"$view",value:l}))},onNodeColorChange:(a,l,c)=>{var u;(u=t.onNodeColorChange)==null||u.call(t,a,l,c);const d=l==="bg"?"$bgColor":"$textColor";o(xt(e,a,d,c),{type:"nodeColor",address:a,key:d,value:c})},onNodeBorderColorChange:(a,l)=>{var c;(c=t.onNodeBorderColorChange)==null||c.call(t,a,l),o(xt(e,a,"$borderColor",l),{type:"nodeColor",address:a,key:"$borderColor",value:l})},onNodeBorderStyleChange:(a,l)=>{var c;(c=t.onNodeBorderStyleChange)==null||c.call(t,a,l),o(xt(e,a,"$borderStyle",l),{type:"nodeStyle",address:a,key:"$borderStyle",value:l})},onNodeBorderWidthChange:(a,l)=>{var c;l!==void 0&&(!Number.isFinite(l)||l<0)||((c=t.onNodeBorderWidthChange)==null||c.call(t,a,l),o(xt(e,a,"$borderWidth",l),{type:"nodeStyle",address:a,key:"$borderWidth",value:l}))},onNodeBorderRadiusChange:(a,l)=>{var c;l!==void 0&&(!Number.isFinite(l)||l<0)||((c=t.onNodeBorderRadiusChange)==null||c.call(t,a,l),o(xt(e,a,"$borderRadius",l),{type:"nodeStyle",address:a,key:"$borderRadius",value:l}))},onNodeIconChange:(a,l)=>{var c;(c=t.onNodeIconChange)==null||c.call(t,a,l),o(xt(e,a,"$icon",l),{type:"nodeIcon",address:a,key:"$icon",value:l})},onNodeOutlineChange:(a,l)=>{var c;(c=t.onNodeOutlineChange)==null||c.call(t,a,l),o(xt(e,a,"$outline",l),{type:"nodeOutline",address:a,key:"$outline",value:l})},onNodeAnimationChange:(a,l)=>{var c;(c=t.onNodeAnimationChange)==null||c.call(t,a,l),o(xt(e,a,"$isNodeAnimated",l),{type:"nodeAnimation",address:a,key:"$isNodeAnimated",value:l})},onNodeAnimationVariantChange:(a,l)=>{var c;l!=="traveling"&&l!=="pulse"||((c=t.onNodeAnimationVariantChange)==null||c.call(t,a,l),o(xt(e,a,"$nodeAnimationVariant",l),{type:"nodeAnimation",address:a,key:"$nodeAnimationVariant",value:l}))},onNodeCollapse:(a,l)=>{var c;(c=t.onNodeCollapse)==null||c.call(t,a,l),o(bd(e,a,l),{type:"nodeCollapse",address:a,key:"$collapsed",value:l})},onNodeCreate:a=>{var p,y;if(((p=t.onNodeCreate)==null?void 0:p.call(t,a))===!0)return;const l=a.sourceNodeId||"root",c=!!a.sourceNodeId&&a.isArrayMode&&!((y=Te(e,l))!=null&&y.$arrayDrawInitialized);let d=e,u,h=a.isArrayMode?"array":"set";for(let m=0;m<(c?2:1);m++){const g=a.sourceNodeId&&vb(d,a.sourceNodeId,i);if(g)d=g.json,u??(u=g.address),h="form";else{const b=jw(Te(d,l),a.isArrayMode?"list":"node"),v=a.isArrayMode?{$bgColor:"gray.500",$:[]}:{$bgColor:"gray.500"},x=vd(d,l,v,b);d=x.json,u??(u=x.address)}}c&&(d=_t(d,l,m=>Array.isArray(m)?{$:m,$arrayDrawInitialized:!0}:{...m,$arrayDrawInitialized:!0})),o(d,{type:"nodeCreate",address:u,value:h})},onNodeDelete:(a,l)=>{var c;(c=t.onNodeDelete)==null||c.call(t,a,l),o(Xm(e,a),{type:"nodeDelete",address:a})},onEdgeCreate:(a,l,c)=>{var u;(u=t.onEdgeCreate)==null||u.call(t,a,l,c);const d=c&&(c.sourceProperty!==void 0||c.targetProperty!==void 0)?{...c,target:l}:void 0;o(d?xd(e,a,d):Ym(e,a,l),{type:"edgeCreate",address:a,key:d?"$connections":"$target",value:d??l})},onEdgeLabelChange:(a,l)=>{var d;(d=t.onEdgeLabelChange)==null||d.call(t,a,l);const c=s(a);c&&o(ar(e,c,"$sourceLabel",l),{type:"edgeLabel",edge:c,key:c.connection?"$connections":"$sourceLabel",value:l})},onEdgeStyleChange:(a,l)=>{var d;(d=t.onEdgeStyleChange)==null||d.call(t,a,l);const c=s(a);c&&o(Zm(e,c,l),{type:"edgeStyle",edge:c,value:l})},onEdgeAnimationVariantChange:(a,l)=>{var d;if(l!=="dashed"&&l!=="traveling")return;(d=t.onEdgeAnimationVariantChange)==null||d.call(t,a,l);const c=s(a);c&&o(ar(e,c,"$edgeAnimationVariant",l),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeAnimationVariant",value:l})},onEdgeTypeChange:(a,l)=>{var d;(d=t.onEdgeTypeChange)==null||d.call(t,a,l);const c=s(a);c&&o(ar(e,c,"$edgeType",l),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeType",value:l})},onEdgeIconChange:(a,l)=>{var d;(d=t.onEdgeIconChange)==null||d.call(t,a,l);const c=s(a);c&&o(ar(e,c,"$edgeIcon",l||void 0),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeIcon",value:l})},onEdgeColorChange:(a,l)=>{var d;(d=t.onEdgeColorChange)==null||d.call(t,a,l);const c=s(a);c&&o(ar(e,c,"$edgeColor",l),{type:"edgeColor",edge:c,key:c.connection?"$connections":"$edgeColor",value:l})},onEdgeDelete:(a,l)=>{var u;(u=t.onEdgeDelete)==null||u.call(t,a,l);const c=s(a);if(!c)return;const d=Qm(e,c);d.removed&&o(d.json,{type:"edgeDelete",edge:c,key:c.connection?"$connections":"$target"})}}}const _w=".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 Ew({path:e,width:r,reversed:t,children:n,onComplete:i}){const o=`flow-edge-reveal-${j.useId().replace(/:/g,"")}`,s=j.useRef(null),[a,l]=j.useState({x:0,y:0,width:1,height:1});return j.useEffect(()=>{const c=matchMedia("(prefers-reduced-motion: reduce)"),d=()=>{c.matches&&(i==null||i())};return d(),c.addEventListener("change",d),()=>c.removeEventListener("change",d)},[i]),j.useLayoutEffect(()=>{var d;const c=(d=s.current)==null?void 0:d.getBBox();c&&l({x:c.x-r,y:c.y-r,width:c.width+r*2,height:c.height+r*2})},[e,r]),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:c=>{c.animationName==="flow-sdk-edge-reveal"&&(i==null||i())},"data-reveal-direction":t?"reverse":"forward",style:{"--flow-edge-reveal-from":t?-100:100},d:e,fill:"none",stroke:"white",strokeWidth:r,strokeLinecap:"butt",strokeLinejoin:"round",pathLength:100,strokeDasharray:"100 100"})})}),f.jsx("g",{mask:`url(#${o})`,children:n})]})}const Rw=".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 kw({path:e,color:r,width:t,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:r,strokeWidth:t,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 100"})}const jb=".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 Zn({x:e=0,y:r=0,width:t,height:n,radius:i,color:o,strokeWidth:s=8,path:a,variant:l="traveling"}){const c=j.useId(),d=`flow-sdk-node-border-animation${l==="pulse"?" flow-sdk-node-border-pulse":""}`;if(l==="pulse"){const u=a?"path":"rect",h=a?{d:a}:{x:e,y:r,width:Math.max(0,t),height:Math.max(0,n),rx:Math.max(0,Math.min(i,t/2,n/2))},p=s+36,y={x:e-p,y:r-p,width:t+2*p,height:n+2*p};return f.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[f.jsx("defs",{children:f.jsxs("mask",{id:c,maskUnits:"userSpaceOnUse",...y,style:{maskType:"luminance"},children:[f.jsx("rect",{...y,fill:"white"}),f.jsx(u,{...h,fill:"black",stroke:"black",strokeWidth:s,strokeLinejoin:"round"})]})}),f.jsx(u,{...h,className:d,"data-animation-variant":l,fill:"none",stroke:`color-mix(in srgb, ${o} 30%, transparent)`,strokeLinejoin:"round",mask:`url(#${c})`,style:{"--flow-pulse-rest-width":`${s+16}px`,"--flow-pulse-expanded-width":`${s+36}px`}})]})}return a?f.jsx("path",{className:d,"data-animation-variant":l,"aria-hidden":"true",pointerEvents:"none",d:a,fill:"none",stroke:o,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"}):f.jsx("rect",{className:d,"data-animation-variant":l,"aria-hidden":"true",pointerEvents:"none",x:e,y:r,width:Math.max(0,t),height:Math.max(0,n),rx:Math.max(0,Math.min(i,t/2,n/2)),fill:"none",stroke:o,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const Aw=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 _b(e,r=!1){return e&&!r&&typeof requestAnimationFrame<"u"&&!(typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches)}function Eb(e,r,t=()=>{},n=300){let i,o,s=!1;const a=()=>{s=!0,i!==void 0&&cancelAnimationFrame(i),clearTimeout(o)},l=()=>{s||(a(),r(1),t())};if(!_b(e))return l(),a;const c=performance.now(),d=u=>{if(s)return;const h=Math.max(0,Math.min(1,(u-c)/n));if(h>=1)return l();r(h<.5?4*h**3:1-(-2*h+2)**3/2),s||(i=requestAnimationFrame(d))};return i=requestAnimationFrame(d),o=setTimeout(l,n+100),a}function Mu(e,r,t){const n=new Set([e]),i=[e];for(;i.length;){const o=i.pop();for(const s of r)(s.parent===o||s.id.startsWith(`${o}.`)||t.some(l=>(l.inverted?l.target:l.source)===o&&(l.inverted?l.source:l.target)===s.id))&&!n.has(s.id)&&(n.add(s.id),i.push(s.id))}return n}function Pw(e,r,t){const n=t==="downward"||t==="upward",i=new Map;for(const s of e){if(s.source===s.target||s.sourceProperty||s.targetProperty)continue;const a=r(s.source),l=r(s.target);if(!a||!l)continue;const c=n?l.y-a.y:l.x-a.x,d=Math.abs(c)-(n?a.h+l.h:a.w+l.w)/2;if(d<=320)continue;const u=JSON.stringify([s.source,Math.sign(c)]),h=i.get(u)??[];h.push({edge:s,gap:d,cross:n?l.x-a.x:l.y-a.y}),i.set(u,h)}const o=new Map;for(const s of i.values()){if(new Set(s.map(({edge:l})=>l.target)).size<2)continue;const a=new Map;for(const{edge:l}of s)a.set(l.target,(a.get(l.target)??0)+1);for(const l of[-1,0,1]){const c=s.filter(({cross:u})=>Math.sign(u)===l);c.sort((u,h)=>Math.abs(h.cross)-Math.abs(u.cross)||u.edge.id.localeCompare(h.edge.id));const d=Math.min(...c.map(({gap:u})=>u));c.forEach(({edge:u,gap:h,cross:p},y)=>{const m=c.length===1?d/2:120+(d-280)*y/(c.length-1),g=c.find(b=>Math.abs(b.cross)<Math.abs(p));o.set(u.id,{turn:m/h,labelAtTarget:a.get(u.target)===1,labelFraction:p?(p+((g==null?void 0:g.cross)??0))/(2*p):.5})})}}return o}const Xt=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}),Iw=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function No(e){if(!e.length)return null;const r={...e[0]};for(let t=1;t<e.length;t++)r.x1=Math.min(r.x1,e[t].x1),r.y1=Math.min(r.y1,e[t].y1),r.x2=Math.max(r.x2,e[t].x2),r.y2=Math.max(r.y2,e[t].y2);return r}const Mw=(e,r)=>e.x1<=r.x2&&e.x2>=r.x1&&e.y1<=r.y2&&e.y2>=r.y1,Tu=(e,r)=>e.x>=r.x1&&e.x<=r.x2&&e.y>=r.y1&&e.y<=r.y2,Ot=e=>(Math.round(e*10)/10).toString(),ut=e=>`${Ot(e.x)} ${Ot(e.y)}`,Tw=e=>e>0?1:e<0?-1:0,Ou=(e,r)=>e>0?Math.max(e-r,0):Math.min(e+r,0);function Ow(e,r,t,n,i=10){const o=r.x-e.x,s=r.y-e.y,a=Ou(o,(e.w+r.w)/2),l=Ou(s,(e.h+r.h)/2),c=t==="downward"||t==="upward",d=c?l:a,u=c?s:o,h=Tw(u),p=n*d,y=v=>Math.abs(v)<i||Math.abs(v)>=Math.abs(d),m=y(p)||y(Math.abs(d)-Math.abs(p));let g;if(m)if(c)if(Math.abs(u)<=e.h/2){const v=(e.x+r.x)/2;g=[v,e.y,v,r.y]}else if(Math.abs(o)<=r.w/2){const v=(e.y+r.y)/2;g=[e.x,v,r.x,v]}else g=[e.x,r.y];else if(Math.abs(u)<=e.w/2){const v=(e.y+r.y)/2;g=[e.x,v,r.x,v]}else if(Math.abs(s)<=r.h/2){const v=(e.x+r.x)/2;g=[v,e.y,v,r.y]}else g=[r.x,e.y];else if(c){const v=e.y+p+e.h/2*h;g=[e.x,v,r.x,v]}else{const v=e.x+p+e.w/2*h;g=[v,e.y,v,r.y]}const b=[{x:e.x,y:e.y}];for(let v=0;v<g.length;v+=2)b.push({x:g[v],y:g[v+1]});return b.push({x:r.x,y:r.y}),b}function Nw(e,r,t){const n=r.x-e.x,i=r.y-e.y,o=n>0?(t.x2-e.x)/n:n<0?(t.x1-e.x)/n:1/0,s=i>0?(t.y2-e.y)/i:i<0?(t.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 Wr(e,r,t){var s;if(!((s=t.outline)!=null&&s.length))return Nw(e,r,Xt(t));const n=r.x-e.x,i=r.y-e.y;let o=1/0;return t.outline.forEach((a,l,c)=>{const d=c[(l+1)%c.length],u=d.x-a.x,h=d.y-a.y,p=n*h-i*u;if(Math.abs(p)<1e-9)return;const y=a.x-e.x,m=a.y-e.y,g=(y*h-m*u)/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 Rb(e,r,t=.5){const n=Number.isFinite(t)?Math.max(0,Math.min(1,t)):.5,i=r==="top"||r==="bottom",o=r==="top"||r==="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{...Wr(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:r}}function $r(e,r){return{x:e.x+(e.side==="right"?r:e.side==="left"?-r:0),y:e.y+(e.side==="bottom"?r:e.side==="top"?-r:0)}}function $w(e,r,t,n){const i=$r(e,t.srcDist),o=$r(r,t.tgtDist);if(n==="straight")return Ab(i,o,t);const s=Math.max(80,Math.min(300,Math.hypot(o.x-i.x,o.y-i.y)/3)),a=e.side==="bottom"&&r.side==="top"?o.y-i.y:e.side==="top"&&r.side==="bottom"?i.y-o.y:e.side==="right"&&r.side==="left"?o.x-i.x:e.side==="left"&&r.side==="right"?i.x-o.x:void 0,l=a!==void 0&&a>0?Math.min(s,a/2):s,c=$r({...i,side:e.side},l),d=$r({...o,side:r.side},l),u=t.arrowAt==="source"?yt(i,c,t.arrowGap):i,h=t.arrowAt==="target"?yt(o,d,t.arrowGap):o,p=t.arrowAt==="source"?$t(i,c,t.arrowSize,t.headShape):t.arrowAt==="target"?$t(o,d,t.arrowSize,t.headShape):void 0;if(n==="bezier")return{d:`M${ut(u)} C${ut(c)} ${ut(d)} ${ut(h)}`,arrow:p,label:{x:(u.x+3*c.x+3*d.x+h.x)/8,y:(u.y+3*c.y+3*d.y+h.y)/8,angle:0}};const y=e.side==="left"||e.side==="right",m=r.side==="left"||r.side==="right";let g;if(y!==m){const v=y?{x:d.x,y:c.y}:{x:c.x,y:d.y},x=(v.x-c.x)*(c.x-i.x)+(v.y-c.y)*(c.y-i.y)>=0,w=(v.x-d.x)*(d.x-o.x)+(v.y-d.y)*(d.y-o.y)>=0;g=[x&&w?v:y?{x:c.x,y:d.y}:{x:d.x,y:c.y}]}else if(a!==void 0&&a<=0)if(y){const v=(c.y+d.y)/2;g=[{x:c.x,y:v},{x:d.x,y:v}]}else{const v=(c.x+d.x)/2;g=[{x:v,y:c.y},{x:v,y:d.y}]}else if(y){const v=e.side===r.side?e.side==="right"?Math.max(c.x,d.x):Math.min(c.x,d.x):(c.x+d.x)/2;g=[{x:v,y:c.y},{x:v,y:d.y}]}else{const v=e.side===r.side?e.side==="bottom"?Math.max(c.y,d.y):Math.min(c.y,d.y):(c.y+d.y)/2;g=[{x:c.x,y:v},{x:d.x,y:v}]}const b=[c,...g,d].filter((v,x,w)=>x===0||v.x!==w[x-1].x||v.y!==w[x-1].y);return ao(u,b,h,p,n==="orthogonal"?0:t.radius)}function yt(e,r,t){const n=e.x-r.x,i=e.y-r.y,o=Math.hypot(n,i);if(!o)return e;let s=(o-t)/o;return s<0&&(s=1e-5),{x:r.x+s*n,y:r.y+s*i}}function $t(e,r,t,n="triangle"){const i=e.x-r.x,o=e.y-r.y,s=Math.hypot(i,o)||1,a=i/s,l=o/s,c=(n==="square"?.15:.3)*t,d=.15*t,u=e.x-a*c,h=e.y-l*c;if(n==="square")return`M${ut(e)} L${Ot(e.x-l*d)} ${Ot(e.y+a*d)} L${Ot(u-l*d)} ${Ot(h+a*d)} L${Ot(u+l*d)} ${Ot(h-a*d)} L${Ot(e.x+l*d)} ${Ot(e.y-a*d)} Z`;const p=[e,{x:u-l*d,y:h+a*d},{x:u+l*d,y:h-a*d}];return p.map((m,g)=>{const b=p[(g+2)%3],v=p[(g+1)%3],x=Math.hypot(b.x-m.x,b.y-m.y),w=Math.hypot(v.x-m.x,v.y-m.y),C={x:(b.x-m.x)/x,y:(b.y-m.y)/x},S={x:(v.x-m.x)/w,y:(v.y-m.y)/w},_=Math.max(-1,Math.min(1,C.x*S.x+C.y*S.y)),R=Math.sqrt((1-_)/(1+_)),A=Math.min(1/R,x/2,w/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*R}}).map((m,g)=>`${g?"L":"M"}${ut(m.start)} A${Ot(m.radius)} ${Ot(m.radius)} 0 0 1 ${ut(m.end)}`).join(" ")+" Z"}function ir(e,r){let t=Math.atan(r/e);return e===0&&t<0&&(t=-t),Number.isFinite(t)||(t=0),t*180/Math.PI}function qw(e,r,t,n){const i={x:r.x-e.x,y:r.y-e.y},o={x:t.x-r.x,y:t.y-r.y},s=Math.hypot(i.x,i.y),a=Math.hypot(o.x,o.y),l=i.x*o.y-i.y*o.x;if(s<1e-6||a<1e-6||Math.abs(l)<1e-6)return{p1:r,b:r,p2:r,r:0};const c=Math.min(n,s/2,a/2);return{p1:{x:r.x-i.x/s*c,y:r.y-i.y/s*c},b:r,p2:{x:r.x+o.x/a*c,y:r.y+o.y/a*c},r:c}}function kb(e,r,t,n){let i=-1,o=null;for(let y=0;y<e.length-1;y++){const m=Wr(e[y],e[y+1],r);if(m){i=y,o=m;break}}let s=-1,a=null;for(let y=e.length-1;y>0;y--){const m=Wr(e[y],e[y-1],t);if(m){s=y,a=m;break}}if(!o||!a||i>=s)return null;const l=e.slice(i+1,s),c=l[0]??a,d=l[l.length-1]??o;let u,h,p;if(n.arrowAt==="source"){const y=yt(o,c,n.srcDist);u=yt(o,c,n.srcDist+n.arrowGap),p=$t(y,c,n.arrowSize,n.headShape)}else u=yt(o,c,n.srcDist);if(n.arrowAt==="target"){const y=yt(a,d,n.tgtDist);h=yt(a,d,n.tgtDist+n.arrowGap),p=$t(y,d,n.arrowSize,n.headShape)}else h=yt(a,d,n.tgtDist);return ao(u,l,h,p,n.radius,n.labelTargetLength,n.labelFraction)}function ao(e,r,t,n,i,o,s){var h;const a=[e,...r,t],l=[];let c=`M${ut(e)}`;for(let p=1;p<a.length-1;p++){const y=qw(a[p-1],a[p],a[p+1],i);l.push(y),y.r===0?c+=` L${ut(y.b)}`:c+=` L${ut(y.p1)} Q${ut(y.b)} ${ut(y.p2)}`}c+=` L${ut(t)}`;let d;const u=r.length;if(u===0)d={x:(e.x+t.x)/2,y:(e.y+t.y)/2,angle:ir(t.x-e.x,t.y-e.y)};else if(u%2===0){const p=r[u/2-1],y=r[u/2];d={x:(p.x+y.x)/2,y:(p.y+y.y)/2,angle:ir(y.x-p.x,y.y-p.y)}}else{const p=l[(u-1)/2];if(p.r===0){const y=a[(u-1)/2+2];d={x:p.b.x,y:p.b.y,angle:ir(y.x-p.b.x,y.y-p.b.y)}}else d={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:ir(p.p2.x-p.p1.x,p.p2.y-p.p1.y)}}if(o!==void 0){if(s!==void 0&&l.length===2){const g=l[0].p2,b=l[1].p1,v=Math.hypot(b.x-g.x,b.y-g.y),x=Math.min(.5,o/(2*v)),w=Math.max(x,Math.min(1-x,s));d={x:g.x+(b.x-g.x)*w,y:g.y+(b.y-g.y)*w,angle:ir(b.x-g.x,b.y-g.y)}}const p=((h=l[l.length-1])==null?void 0:h.p2)??e,y=t.x-p.x,m=t.y-p.y;Math.hypot(y,m)>=o&&(d={x:(p.x+t.x)/2,y:(p.y+t.y)/2,angle:ir(y,m)})}return{d:c,arrow:n,label:d}}function Nu(e,r,t,n,i,o,s){const a=t==="leftward"?-1:1,l={x:e.x+a*(e.w/2+s.srcDist),y:n??e.y},c={x:r.x-a*(r.w/2+s.tgtDist),y:i??r.y},d=Math.max(80,s.arrowGap+s.arrowSize*.3),u=l.x+a*d,h=c.x-a*d;let p;if(a*(h-u)>=0){const b=l.x+(c.x-l.x)*o,v=Math.max(Math.min(u,h),Math.min(Math.max(u,h),b));p=[{x:v,y:l.y},{x:v,y:c.y}]}else{const b=Math.min(e.y-e.h/2,r.y-r.h/2)-d*(1+o);p=[{x:u,y:l.y},{x:u,y:b},{x:h,y:b},{x:h,y:c.y}]}const y=s.arrowAt==="source"?yt(l,p[0],s.arrowGap):l,m=s.arrowAt==="target"?yt(c,p[p.length-1],s.arrowGap):c,g=s.arrowAt==="source"?$t(l,p[0],s.arrowSize,s.headShape):s.arrowAt==="target"?$t(c,p[p.length-1],s.arrowSize,s.headShape):void 0;return ao(y,p,m,g,s.radius)}function $u(e,r,t,n,i){return kb(Ow(e,r,t,n),e,r,i)}function qu(e,r,t,n,i,o){const s=n===void 0&&i===void 0&&(t==="downward"||t==="upward"),a=t==="leftward"||s&&t==="upward"?-1:1,l=(c,d,u)=>{const h={x:c.x,y:d??c.y},p=Math.max(c.w,c.h)*2+1,y=Wr(h,{x:h.x+(s?0:u*p),y:h.y+(s?u*p:0)},c);return y?{x:y.x+(s?0:u*o),y:y.y+(s?u*o:0)}:s?{x:c.x,y:c.y+u*(c.h/2+o)}:{x:c.x+u*(c.w/2+o),y:d??c.y}};return{sourcePoint:l(e,n,a),targetPoint:l(r,i,-a)}}function Lw(e,r,t,n){const i=t==="downward"||t==="upward",o=t==="leftward"||t==="upward"?-1:1,s=Math.max(100,Math.abs(i?r.y-e.y:r.x-e.x)/2),a={x:e.x+(i?0:o*s),y:e.y+(i?o*s:0)},l={x:r.x-(i?0:o*s),y:r.y-(i?o*s:0)},c=n.arrowAt==="source"?yt(e,a,n.arrowGap):e,d=n.arrowAt==="target"?yt(r,l,n.arrowGap):r;return{d:`M${ut(c)} C${ut(a)} ${ut(l)} ${ut(d)}`,arrow:n.arrowAt==="source"?$t(e,a,n.arrowSize,n.headShape):n.arrowAt==="target"?$t(r,l,n.arrowSize,n.headShape):void 0,label:{x:(c.x+3*a.x+3*l.x+d.x)/8,y:(c.y+3*a.y+3*l.y+d.y)/8,angle:ir(d.x+l.x-a.x-c.x,d.y+l.y-a.y-c.y)}}}function Ab(e,r,t){const n=t.arrowAt==="source"?yt(e,r,t.arrowGap):e,i=t.arrowAt==="target"?yt(r,e,t.arrowGap):r,o=t.arrowAt==="source"?$t(e,r,t.arrowSize,t.headShape):t.arrowAt==="target"?$t(r,e,t.arrowSize,t.headShape):void 0;return ao(n,[],i,o,0)}function Fw(e,r,t,n=-90,i=-60,o=350){const s=n*Math.PI/180,a=i*Math.PI/180,l=s-Math.PI/2,c=l-a/2,d=l+a/2,u=1.4*o*(r/3+1),h={x:e.x+Math.cos(c)*u,y:e.y+Math.sin(c)*u},p={x:e.x+Math.cos(d)*u,y:e.y+Math.sin(d)*u},y={x:e.x,y:e.y},m=Wr(y,h,e),g=Wr(y,p,e);if(!m||!g)return null;const b={x:(h.x+p.x)/2,y:(h.y+p.y)/2};let v=yt(m,h,t.srcDist),x=yt(g,p,t.tgtDist),w;if(t.arrowAt==="target"){const S=x;x=yt(g,p,t.tgtDist+t.arrowGap),w=$t(S,p,t.arrowSize,t.headShape)}else if(t.arrowAt==="source"){const S=v;v=yt(m,h,t.srcDist+t.arrowGap),w=$t(S,h,t.arrowSize,t.headShape)}return{d:`M${ut(v)} Q${ut(h)} ${ut(b)} Q${ut(p)} ${ut(x)}`,arrow:w,label:{x:b.x,y:b.y,angle:ir(p.x-h.x,p.y-h.y)}}}const Tr=e=>Math.round(e*1e3)/1e3;function Pb(e){const r=e.querySelector("[data-flow-node-surface]");if(!r)return;const t=e.getBoundingClientRect(),n=t.width/e.offsetWidth;if(!Number.isFinite(n)||n<=0)return;const i=r.getBoundingClientRect();if(!i.width||!i.height)return;const o=r,s=typeof o.getScreenCTM=="function"?o.getScreenCTM():null,a=typeof o.getTotalLength=="function"?o.getTotalLength():0,l=o.points,c=(l==null?void 0:l.numberOfItems)||128,d=s&&a>0?Array.from({length:c},(u,h)=>{const p=l!=null&&l.numberOfItems?l.getItem(h):o.getPointAtLength(a*h/c);return{x:Tr((s.a*p.x+s.c*p.y+s.e-t.left)/n),y:Tr((s.b*p.x+s.d*p.y+s.f-t.top)/n)}}):void 0;return{left:Tr((i.left-t.left)/n),top:Tr((i.top-t.top)/n),width:r instanceof HTMLElement?r.offsetWidth:Tr(i.width/n),height:r instanceof HTMLElement?r.offsetHeight:Tr(i.height/n),radius:parseFloat(getComputedStyle(r).borderTopLeftRadius)||0,...d?{outline:d}:{}}}function xn(e,r){const t=e.x-e.w/2,n=e.y-e.h/2;return{x:t+r.left+r.width/2,y:n+r.top+r.height/2,w:r.width,h:r.height,...r.outline?{outline:r.outline.map(i=>({x:t+i.x,y:n+i.y}))}:{}}}function zw(e,r,t,n,i){var d;const o=i!=="TB"&&i!=="BT",s=o?"top":"left",a=o?"bottom":"right",l=new Map;for(const u of n)for(const[h,p,y]of[[u.source,u.sourceProperty,u.target],[u.target,u.targetProperty,u.source]]){const m=r.get(y);if(p===void 0||!m||y===h)continue;const g=t.get(y),b=JSON.stringify([h,p]),v=l.get(b)??[];v.push(g?xn(m,g):m),l.set(b,v)}const c=new Map(e);for(const[u,h]of e){const p=r.get(u);if(!p||!h.some(x=>x.placement==="config"))continue;const y=t.get(u),m=y?xn(p,y):p,g={x:p.w/2,y:p.h/2,w:p.w,h:p.h},b=y?xn(g,y):g,v=new Map;for(const x of h){if(x.placement!=="config")continue;const C=(l.get(JSON.stringify([u,x.property]))??[]).reduce((_,R)=>_+(o?R.y-m.y:R.x-m.x),0),S=((d=x.anchor)==null?void 0:d.side)===a?a:s;v.set(x,C<-.001?s:C>.001?a:S)}c.set(u,h.map(x=>{const w=v.get(x);if(!w)return x;const C=h.filter(R=>v.get(R)===w),S=(C.indexOf(x)+1)/(C.length+1),_=Rb(b,w,S);return{...x,anchor:_,top:_.y,height:0}}))}return c}function Lu(e,r,t){const n=new Set(r.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 r)!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 t)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 cr='"Helvetica Neue", Helvetica, sans-serif';let on;const Dn=new Map;function so(e,r){const t=`${r}|${e}`,n=Dn.get(t);if(n!==void 0)return n;on===void 0&&(on=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let i;return on?(on.font=r,i=on.measureText(e).width):i=e.length*(parseFloat(r)||16)*.55,Dn.size>5e3&&Dn.clear(),Dn.set(t,i),i}function Bw(e,r,t){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 l=s?`${s} ${a}`:a;!s||so(l,r)<=t?s=l:(n.push(s),s=a)}n.push(s)}return n}const Fu=e=>e.stopPropagation();function Dw({id:e,rect:r,label:t,labelLayer:n,labelContent:i,style:o,onSelect:s,onCollapse:a,selected:l=!1}){const c=r.x2-r.x1,d=r.y2-r.y1,u=o.borderWidth,h=o.borderStyle==="dashed"?`${u*4} ${u*2}`:o.borderStyle==="dotted"?`${u} ${u}`:void 0,p=r.x1+c/2,y=o.labelPosition==="top"?r.y1+o.labelMargin-o.fontSize/2:o.labelPosition==="bottom"?r.y2-o.labelMargin+o.fontSize/2:r.y1+d/2,m=t?so(t,`bold ${o.fontSize}px ${cr}`):0,g=o.fontSize/5,b=t||l&&a?f.jsxs("g",{className:"flow-sdk-container-label","data-node-id":e,children:[l&&a&&f.jsx("foreignObject",{x:p+m/2+g+8,y:y-24,width:48,height:48,"data-flow-content-toggle":"","data-flow-collapse-control":"",style:{pointerEvents:"auto"},children:f.jsx(Fe,{label:"Show icon",children:f.jsx(Ae,{"aria-label":"Show icon",icon:f.jsx(Z.PiCircleFill,{}),variant:"ghost",style:{width:48,height:48,color:o.textColor},onClick:v=>{v.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:Fu,children:i}):t&&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:cr,style:{fontSize:o.fontSize,fontWeight:"bold",fontFamily:cr},textAnchor:"middle",dominantBaseline:"central",children:t})]})]}):null;return f.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:Fu,onClick:v=>{v.stopPropagation(),s==null||s(e,{shiftKey:v.shiftKey,ctrlKey:v.ctrlKey,metaKey:v.metaKey,altKey:v.altKey})},children:[f.jsx("rect",{x:r.x1,y:r.y1,width:c,height:d,rx:o.borderRadius,ry:o.borderRadius,fill:o.bgColor,fillOpacity:o.bgOpacity,stroke:o.borderColor,strokeWidth:o.borderStyle==="double"?u/3:u,strokeDasharray:h}),o.borderStyle==="double"&&f.jsx("rect",{x:r.x1+u*2/3,y:r.y1+u*2/3,width:Math.max(0,c-u*4/3),height:Math.max(0,d-u*4/3),rx:Math.max(0,o.borderRadius-u*2/3),ry:Math.max(0,o.borderRadius-u*2/3),fill:"none",stroke:o.borderColor,strokeWidth:u/3}),o.animated&&u>0&&f.jsx(Zn,{variant:o.animationVariant,x:r.x1,y:r.y1,width:c,height:d,radius:o.borderRadius,color:o.animationColor||o.borderColor,strokeWidth:Math.max(8,u*1.6)}),n&&b?Cn.createPortal(b,n):b]})}const Vw=j.memo(Dw),Xn=45,Ib=70,xr=15,Mb=50;function Tb(e,r,t=Xn){const n=`${t}px ${cr}`,i=e?Bw(e,n,200*t/Xn):[],o=r?48+(i.length?12:0):0,s=o+Math.max(0,...i.map(c=>so(c,n))),a=Math.max(i.length*t,r?48:0),l=i.length||r?2*xr:0;return{lines:i,iconWidth:o,contentWidth:s,contentHeight:a,width:s+l,height:a+l}}const wn=6,Ob=3,Pd=.3,Ww=8,Id=Math.max(Math.pow(wn*13.37,.9),29)*Ob-Ww/Pd,Nb=wn*Ob*2,Gn=80,Gw=2*Gn+Id*Pd+100,Uw=36+2*Math.max(80,Nb+Id*Pd);function sd(e){return e.sourceProperty!==void 0||e.targetProperty!==void 0}function cd(e,r){return r==="auto"||(r==="properties"?sd(e):!sd(e))}function nr(e,r,t){return t!=="properties"||e!=="root"||r.some(n=>(n.source===e||n.target===e)&&sd(n))}function Hw(e,r,t,n=!1,i){if(!n)return{nodes:e,edges:r};const o=e.filter(a=>nr(a.id,r,t)&&(!i||i.has(a.id))),s=new Set(o.map(a=>a.id));return{nodes:o,edges:r.filter(a=>cd(a,t)&&s.has(a.source)&&s.has(a.target))}}const Kw=500,Jw="32 18",Zw=e=>e.stopPropagation();function Xw({id:e,reveal:r,onRevealComplete:t,edgeData:n,validationIssue:i,edgeType:o="rounded-orthogonal",edgeRadius:s,customEdgeTypes:a,source:l,target:c,sourceProperty:d,targetProperty:u,sourceY:h,targetY:p,sourcePort:y,targetPort:m,propertyMode:g=!1,dir:b,turn:v,labelAtTarget:x,labelFraction:w,color:C,connectorColor:S,labelBg:_,labelLayer:R,label:A,dashed:O,animated:T,inverted:E,loopIndex:M=0,onSelect:P}){const $=n==null?void 0:n.icon,N=g?Xn:Ib,{lines:I,iconWidth:K,contentWidth:le,contentHeight:ie}=j.useMemo(()=>Tb(A,$,N),[A,$,N]),te=j.useMemo(()=>{const Se={srcDist:Gn,tgtDist:Gn,arrowGap:Nb,arrowSize:Id,headShape:g&&(E?h!==void 0||y:p!==void 0||m)?"square":"triangle",radius:s??(x?40:Kw),arrowAt:E?"source":"target",labelTargetLength:x?le+2*xr:void 0,labelFraction:x?w:void 0},he=h!==void 0||p!==void 0||!!y||!!m,G=qu(l,c,b,h,p,0),F=h===void 0&&p===void 0&&(b==="downward"||b==="upward"),re=y??{...G.sourcePoint,side:F?b==="upward"?"top":"bottom":b==="leftward"?"left":"right"},ce=m??{...G.targetPoint,side:F?b==="upward"?"bottom":"top":b==="leftward"?"right":"left"},X=l.x===c.x&&l.y===c.y,ye=y||m?$w(re,ce,{...Se,srcDist:18,tgtDist:18},o):he?Nu(l,c,b,h,p,v,{...Se,srcDist:18,tgtDist:18,radius:s??Math.min(Se.radius,40)}):X?Fw(l,M,{...Se,srcDist:0,tgtDist:0}):$u(l,c,b,v,Se);if(!ye)return null;const ve=qu(l,c,b,h,p,he?18:Gn);y&&(ve.sourcePoint=$r(y,18)),m&&(ve.targetPoint=$r(m,18));const Oe=Object.prototype.hasOwnProperty.call(a??{},o)?a==null?void 0:a[o]:void 0;if(Oe){const Ne={rightward:"LR",leftward:"RL",downward:"TB",upward:"BT"};return Oe({edge:n??{id:e,source:"",target:""},source:{...l},target:{...c},...ve,direction:Ne[b],sourceY:h,targetY:p,inverted:!!E,defaultGeometry:ye})??ye}return X||y||m?ye:o==="straight"?he?Ab(ve.sourcePoint,ve.targetPoint,Se):kb([l,c],l,c,Se):o==="bezier"?Lw(ve.sourcePoint,ve.targetPoint,he?b==="leftward"?"leftward":"rightward":b,Se):o==="orthogonal"?he?Nu(l,c,b,h,p,v,{...Se,srcDist:18,tgtDist:18,radius:0}):$u(l,c,b,v,{...Se,radius:0}):ye},[l,e,n,o,s,a,c,g,h,p,y,m,b,v,E,M,x,w,le]);if(!te)return null;const fe=(b==="rightward"||b==="leftward")&&!Object.prototype.hasOwnProperty.call(a??{},o)&&!(g&&(h!==void 0||p!==void 0||y||m)),xe=fe?`translate(${te.label.x} ${te.label.y-ie/2-2*xr})`:`translate(${te.label.x} ${te.label.y}) rotate(${te.label.angle}) translate(${b==="downward"||b==="upward"||x||Object.prototype.hasOwnProperty.call(a??{},o)?0:Mb} 0)`,q=i!=null&&i.startsWith("Unverified:")?"#b45309":"#dc2626",W=i?q:C,U=i?f.jsxs("g",{className:"flow-sdk-edge-validation",role:"img","aria-label":i,transform:`translate(${te.label.x} ${te.label.y-I.length*N/2-55})`,children:[f.jsx("title",{children:i}),f.jsx(Ht,{name:"PiWarningCircleFill",svg:!0,size:48,x:-24,y:-24,color:q})]}):null,z=T&&(n==null?void 0:n.edgeAnimationVariant)==="traveling",de=!z&&(O||T)?Jw:void 0,Q=T&&!z?`flow-sdk-edge-anim${E?" flow-sdk-edge-anim-rev":""}`:void 0;let ae=null;const se=r?{"--flow-edge-reveal-duration":`${r.durationMs??600}ms`,"--flow-edge-reveal-state":r.paused?"paused":"running"}:void 0;if(I.length||$){const Se=le,he=ie;ae=f.jsxs("g",{className:`flow-sdk-edge-label${r?" flow-sdk-edge-reveal-end":""}`,style:se,"data-label-transform":xe,"data-label-horizontal":fe||void 0,"data-edge-id":e,"data-source-property":d,"data-target-property":u,transform:xe,children:[f.jsx("rect",{x:-Se/2-xr,y:-he/2-xr,width:Se+2*xr,height:he+2*xr,fill:C==="transparent"?"transparent":_}),f.jsx("text",{fill:C,fontSize:N,style:{fontSize:N,fontFamily:cr},fontFamily:cr,textAnchor:"middle",dominantBaseline:"central",children:I.map((G,F)=>f.jsx("tspan",{x:K/2,y:(F-(I.length-1)/2)*N,children:G},F))}),$&&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:-Se/2,y:-24,width:48,height:48,fill:"transparent"}),f.jsx(Ht,{name:$,svg:!0,size:48,x:-Se/2,y:-24,color:C})]})]})}const Ce=f.jsxs(f.Fragment,{children:[f.jsx("path",{d:te.d,fill:"none",stroke:W,strokeWidth:wn,strokeOpacity:z?.35:void 0,strokeDasharray:de,className:Q}),z&&f.jsx(kw,{path:te.d,color:W,width:wn*1.6,reversed:E})]});return f.jsxs("g",{className:"flow-sdk-edge",style:se,"data-edge-id":e,"data-source-property":d,"data-target-property":u,"data-validation":i?i.startsWith("Unverified:")?"unverified":"invalid":void 0,"aria-label":i,onPointerDown:Zw,onClick:Se=>{Se.stopPropagation(),P==null||P(e)},children:[r?f.jsx(Ew,{path:te.d,width:wn*4,reversed:E,onComplete:()=>t==null?void 0:t(e),children:Ce}):Ce,te.arrow&&f.jsx("path",{className:r?"flow-sdk-edge-reveal-end":void 0,d:te.arrow,fill:i?q:S??W}),R&&ae?Cn.createPortal(ae,R):ae,R&&U?Cn.createPortal(U,R):U,f.jsx("path",{className:"flow-sdk-edge-hit",d:te.d,fill:"none",stroke:"transparent"})]})}const zu=j.memo(Xw);var Vn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yw(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Md(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 $o,Bu;function Qw(){if(Bu)return $o;Bu=1;function e(){this.__data__=[],this.size=0}return $o=e,$o}var qo,Du;function Jr(){if(Du)return qo;Du=1;function e(r,t){return r===t||r!==r&&t!==t}return qo=e,qo}var Lo,Vu;function co(){if(Vu)return Lo;Vu=1;var e=Jr();function r(t,n){for(var i=t.length;i--;)if(e(t[i][0],n))return i;return-1}return Lo=r,Lo}var Fo,Wu;function e1(){if(Wu)return Fo;Wu=1;var e=co(),r=Array.prototype,t=r.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():t.call(o,s,1),--this.size,!0}return Fo=n,Fo}var zo,Gu;function t1(){if(Gu)return zo;Gu=1;var e=co();function r(t){var n=this.__data__,i=e(n,t);return i<0?void 0:n[i][1]}return zo=r,zo}var Bo,Uu;function r1(){if(Uu)return Bo;Uu=1;var e=co();function r(t){return e(this.__data__,t)>-1}return Bo=r,Bo}var Do,Hu;function n1(){if(Hu)return Do;Hu=1;var e=co();function r(t,n){var i=this.__data__,o=e(i,t);return o<0?(++this.size,i.push([t,n])):i[o][1]=n,this}return Do=r,Do}var Vo,Ku;function lo(){if(Ku)return Vo;Ku=1;var e=Qw(),r=e1(),t=t1(),n=r1(),i=n1();function o(s){var a=-1,l=s==null?0:s.length;for(this.clear();++a<l;){var c=s[a];this.set(c[0],c[1])}}return o.prototype.clear=e,o.prototype.delete=r,o.prototype.get=t,o.prototype.has=n,o.prototype.set=i,Vo=o,Vo}var Wo,Ju;function o1(){if(Ju)return Wo;Ju=1;var e=lo();function r(){this.__data__=new e,this.size=0}return Wo=r,Wo}var Go,Zu;function i1(){if(Zu)return Go;Zu=1;function e(r){var t=this.__data__,n=t.delete(r);return this.size=t.size,n}return Go=e,Go}var Uo,Xu;function a1(){if(Xu)return Uo;Xu=1;function e(r){return this.__data__.get(r)}return Uo=e,Uo}var Ho,Yu;function s1(){if(Yu)return Ho;Yu=1;function e(r){return this.__data__.has(r)}return Ho=e,Ho}var Ko,Qu;function $b(){if(Qu)return Ko;Qu=1;var e=typeof Vn=="object"&&Vn&&Vn.Object===Object&&Vn;return Ko=e,Ko}var Jo,ef;function Dt(){if(ef)return Jo;ef=1;var e=$b(),r=typeof self=="object"&&self&&self.Object===Object&&self,t=e||r||Function("return this")();return Jo=t,Jo}var Zo,tf;function Zr(){if(tf)return Zo;tf=1;var e=Dt(),r=e.Symbol;return Zo=r,Zo}var Xo,rf;function c1(){if(rf)return Xo;rf=1;var e=Zr(),r=Object.prototype,t=r.hasOwnProperty,n=r.toString,i=e?e.toStringTag:void 0;function o(s){var a=t.call(s,i),l=s[i];try{s[i]=void 0;var c=!0}catch{}var d=n.call(s);return c&&(a?s[i]=l:delete s[i]),d}return Xo=o,Xo}var Yo,nf;function l1(){if(nf)return Yo;nf=1;var e=Object.prototype,r=e.toString;function t(n){return r.call(n)}return Yo=t,Yo}var Qo,of;function Rr(){if(of)return Qo;of=1;var e=Zr(),r=c1(),t=l1(),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)?r(a):t(a)}return Qo=s,Qo}var ei,af;function qt(){if(af)return ei;af=1;function e(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}return ei=e,ei}var ti,sf;function In(){if(sf)return ti;sf=1;var e=Rr(),r=qt(),t="[object AsyncFunction]",n="[object Function]",i="[object GeneratorFunction]",o="[object Proxy]";function s(a){if(!r(a))return!1;var l=e(a);return l==n||l==i||l==t||l==o}return ti=s,ti}var ri,cf;function d1(){if(cf)return ri;cf=1;var e=Dt(),r=e["__core-js_shared__"];return ri=r,ri}var ni,lf;function u1(){if(lf)return ni;lf=1;var e=d1(),r=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function t(n){return!!r&&r in n}return ni=t,ni}var oi,df;function qb(){if(df)return oi;df=1;var e=Function.prototype,r=e.toString;function t(n){if(n!=null){try{return r.call(n)}catch{}try{return n+""}catch{}}return""}return oi=t,oi}var ii,uf;function f1(){if(uf)return ii;uf=1;var e=In(),r=u1(),t=qt(),n=qb(),i=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,s=Function.prototype,a=Object.prototype,l=s.toString,c=a.hasOwnProperty,d=RegExp("^"+l.call(c).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function u(h){if(!t(h)||r(h))return!1;var p=e(h)?d:o;return p.test(n(h))}return ii=u,ii}var ai,ff;function h1(){if(ff)return ai;ff=1;function e(r,t){return r==null?void 0:r[t]}return ai=e,ai}var si,hf;function kr(){if(hf)return si;hf=1;var e=f1(),r=h1();function t(n,i){var o=r(n,i);return e(o)?o:void 0}return si=t,si}var ci,pf;function Td(){if(pf)return ci;pf=1;var e=kr(),r=Dt(),t=e(r,"Map");return ci=t,ci}var li,gf;function uo(){if(gf)return li;gf=1;var e=kr(),r=e(Object,"create");return li=r,li}var di,yf;function p1(){if(yf)return di;yf=1;var e=uo();function r(){this.__data__=e?e(null):{},this.size=0}return di=r,di}var ui,mf;function g1(){if(mf)return ui;mf=1;function e(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}return ui=e,ui}var fi,bf;function y1(){if(bf)return fi;bf=1;var e=uo(),r="__lodash_hash_undefined__",t=Object.prototype,n=t.hasOwnProperty;function i(o){var s=this.__data__;if(e){var a=s[o];return a===r?void 0:a}return n.call(s,o)?s[o]:void 0}return fi=i,fi}var hi,vf;function m1(){if(vf)return hi;vf=1;var e=uo(),r=Object.prototype,t=r.hasOwnProperty;function n(i){var o=this.__data__;return e?o[i]!==void 0:t.call(o,i)}return hi=n,hi}var pi,xf;function b1(){if(xf)return pi;xf=1;var e=uo(),r="__lodash_hash_undefined__";function t(n,i){var o=this.__data__;return this.size+=this.has(n)?0:1,o[n]=e&&i===void 0?r:i,this}return pi=t,pi}var gi,wf;function v1(){if(wf)return gi;wf=1;var e=p1(),r=g1(),t=y1(),n=m1(),i=b1();function o(s){var a=-1,l=s==null?0:s.length;for(this.clear();++a<l;){var c=s[a];this.set(c[0],c[1])}}return o.prototype.clear=e,o.prototype.delete=r,o.prototype.get=t,o.prototype.has=n,o.prototype.set=i,gi=o,gi}var yi,Cf;function x1(){if(Cf)return yi;Cf=1;var e=v1(),r=lo(),t=Td();function n(){this.size=0,this.__data__={hash:new e,map:new(t||r),string:new e}}return yi=n,yi}var mi,Sf;function w1(){if(Sf)return mi;Sf=1;function e(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}return mi=e,mi}var bi,jf;function fo(){if(jf)return bi;jf=1;var e=w1();function r(t,n){var i=t.__data__;return e(n)?i[typeof n=="string"?"string":"hash"]:i.map}return bi=r,bi}var vi,_f;function C1(){if(_f)return vi;_f=1;var e=fo();function r(t){var n=e(this,t).delete(t);return this.size-=n?1:0,n}return vi=r,vi}var xi,Ef;function S1(){if(Ef)return xi;Ef=1;var e=fo();function r(t){return e(this,t).get(t)}return xi=r,xi}var wi,Rf;function j1(){if(Rf)return wi;Rf=1;var e=fo();function r(t){return e(this,t).has(t)}return wi=r,wi}var Ci,kf;function _1(){if(kf)return Ci;kf=1;var e=fo();function r(t,n){var i=e(this,t),o=i.size;return i.set(t,n),this.size+=i.size==o?0:1,this}return Ci=r,Ci}var Si,Af;function Od(){if(Af)return Si;Af=1;var e=x1(),r=C1(),t=S1(),n=j1(),i=_1();function o(s){var a=-1,l=s==null?0:s.length;for(this.clear();++a<l;){var c=s[a];this.set(c[0],c[1])}}return o.prototype.clear=e,o.prototype.delete=r,o.prototype.get=t,o.prototype.has=n,o.prototype.set=i,Si=o,Si}var ji,Pf;function E1(){if(Pf)return ji;Pf=1;var e=lo(),r=Td(),t=Od(),n=200;function i(o,s){var a=this.__data__;if(a instanceof e){var l=a.__data__;if(!r||l.length<n-1)return l.push([o,s]),this.size=++a.size,this;a=this.__data__=new t(l)}return a.set(o,s),this.size=a.size,this}return ji=i,ji}var _i,If;function ho(){if(If)return _i;If=1;var e=lo(),r=o1(),t=i1(),n=a1(),i=s1(),o=E1();function s(a){var l=this.__data__=new e(a);this.size=l.size}return s.prototype.clear=r,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=i,s.prototype.set=o,_i=s,_i}var Ei,Mf;function Nd(){if(Mf)return Ei;Mf=1;function e(r,t){for(var n=-1,i=r==null?0:r.length;++n<i&&t(r[n],n,r)!==!1;);return r}return Ei=e,Ei}var Ri,Tf;function Lb(){if(Tf)return Ri;Tf=1;var e=kr(),r=(function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch{}})();return Ri=r,Ri}var ki,Of;function po(){if(Of)return ki;Of=1;var e=Lb();function r(t,n,i){n=="__proto__"&&e?e(t,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[n]=i}return ki=r,ki}var Ai,Nf;function go(){if(Nf)return Ai;Nf=1;var e=po(),r=Jr(),t=Object.prototype,n=t.hasOwnProperty;function i(o,s,a){var l=o[s];(!(n.call(o,s)&&r(l,a))||a===void 0&&!(s in o))&&e(o,s,a)}return Ai=i,Ai}var Pi,$f;function Mn(){if($f)return Pi;$f=1;var e=go(),r=po();function t(n,i,o,s){var a=!o;o||(o={});for(var l=-1,c=i.length;++l<c;){var d=i[l],u=s?s(o[d],n[d],d,o,n):void 0;u===void 0&&(u=n[d]),a?r(o,d,u):e(o,d,u)}return o}return Pi=t,Pi}var Ii,qf;function R1(){if(qf)return Ii;qf=1;function e(r,t){for(var n=-1,i=Array(r);++n<r;)i[n]=t(n);return i}return Ii=e,Ii}var Mi,Lf;function Kt(){if(Lf)return Mi;Lf=1;function e(r){return r!=null&&typeof r=="object"}return Mi=e,Mi}var Ti,Ff;function k1(){if(Ff)return Ti;Ff=1;var e=Rr(),r=Kt(),t="[object Arguments]";function n(i){return r(i)&&e(i)==t}return Ti=n,Ti}var Oi,zf;function Tn(){if(zf)return Oi;zf=1;var e=k1(),r=Kt(),t=Object.prototype,n=t.hasOwnProperty,i=t.propertyIsEnumerable,o=e((function(){return arguments})())?e:function(s){return r(s)&&n.call(s,"callee")&&!i.call(s,"callee")};return Oi=o,Oi}var Ni,Bf;function pt(){if(Bf)return Ni;Bf=1;var e=Array.isArray;return Ni=e,Ni}var dn={exports:{}},$i,Df;function A1(){if(Df)return $i;Df=1;function e(){return!1}return $i=e,$i}dn.exports;var Vf;function Xr(){return Vf||(Vf=1,(function(e,r){var t=Dt(),n=A1(),i=r&&!r.nodeType&&r,o=i&&!0&&e&&!e.nodeType&&e,s=o&&o.exports===i,a=s?t.Buffer:void 0,l=a?a.isBuffer:void 0,c=l||n;e.exports=c})(dn,dn.exports)),dn.exports}var qi,Wf;function yo(){if(Wf)return qi;Wf=1;var e=9007199254740991,r=/^(?:0|[1-9]\d*)$/;function t(n,i){var o=typeof n;return i=i??e,!!i&&(o=="number"||o!="symbol"&&r.test(n))&&n>-1&&n%1==0&&n<i}return qi=t,qi}var Li,Gf;function $d(){if(Gf)return Li;Gf=1;var e=9007199254740991;function r(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=e}return Li=r,Li}var Fi,Uf;function P1(){if(Uf)return Fi;Uf=1;var e=Rr(),r=$d(),t=Kt(),n="[object Arguments]",i="[object Array]",o="[object Boolean]",s="[object Date]",a="[object Error]",l="[object Function]",c="[object Map]",d="[object Number]",u="[object Object]",h="[object RegExp]",p="[object Set]",y="[object String]",m="[object WeakMap]",g="[object ArrayBuffer]",b="[object DataView]",v="[object Float32Array]",x="[object Float64Array]",w="[object Int8Array]",C="[object Int16Array]",S="[object Int32Array]",_="[object Uint8Array]",R="[object Uint8ClampedArray]",A="[object Uint16Array]",O="[object Uint32Array]",T={};T[v]=T[x]=T[w]=T[C]=T[S]=T[_]=T[R]=T[A]=T[O]=!0,T[n]=T[i]=T[g]=T[o]=T[b]=T[s]=T[a]=T[l]=T[c]=T[d]=T[u]=T[h]=T[p]=T[y]=T[m]=!1;function E(M){return t(M)&&r(M.length)&&!!T[e(M)]}return Fi=E,Fi}var zi,Hf;function mo(){if(Hf)return zi;Hf=1;function e(r){return function(t){return r(t)}}return zi=e,zi}var un={exports:{}};un.exports;var Kf;function qd(){return Kf||(Kf=1,(function(e,r){var t=$b(),n=r&&!r.nodeType&&r,i=n&&!0&&e&&!e.nodeType&&e,o=i&&i.exports===n,s=o&&t.process,a=(function(){try{var l=i&&i.require&&i.require("util").types;return l||s&&s.binding&&s.binding("util")}catch{}})();e.exports=a})(un,un.exports)),un.exports}var Bi,Jf;function On(){if(Jf)return Bi;Jf=1;var e=P1(),r=mo(),t=qd(),n=t&&t.isTypedArray,i=n?r(n):e;return Bi=i,Bi}var Di,Zf;function Fb(){if(Zf)return Di;Zf=1;var e=R1(),r=Tn(),t=pt(),n=Xr(),i=yo(),o=On(),s=Object.prototype,a=s.hasOwnProperty;function l(c,d){var u=t(c),h=!u&&r(c),p=!u&&!h&&n(c),y=!u&&!h&&!p&&o(c),m=u||h||p||y,g=m?e(c.length,String):[],b=g.length;for(var v in c)(d||a.call(c,v))&&!(m&&(v=="length"||p&&(v=="offset"||v=="parent")||y&&(v=="buffer"||v=="byteLength"||v=="byteOffset")||i(v,b)))&&g.push(v);return g}return Di=l,Di}var Vi,Xf;function bo(){if(Xf)return Vi;Xf=1;var e=Object.prototype;function r(t){var n=t&&t.constructor,i=typeof n=="function"&&n.prototype||e;return t===i}return Vi=r,Vi}var Wi,Yf;function zb(){if(Yf)return Wi;Yf=1;function e(r,t){return function(n){return r(t(n))}}return Wi=e,Wi}var Gi,Qf;function I1(){if(Qf)return Gi;Qf=1;var e=zb(),r=e(Object.keys,Object);return Gi=r,Gi}var Ui,eh;function Ld(){if(eh)return Ui;eh=1;var e=bo(),r=I1(),t=Object.prototype,n=t.hasOwnProperty;function i(o){if(!e(o))return r(o);var s=[];for(var a in Object(o))n.call(o,a)&&a!="constructor"&&s.push(a);return s}return Ui=i,Ui}var Hi,th;function Qt(){if(th)return Hi;th=1;var e=In(),r=$d();function t(n){return n!=null&&r(n.length)&&!e(n)}return Hi=t,Hi}var Ki,rh;function pr(){if(rh)return Ki;rh=1;var e=Fb(),r=Ld(),t=Qt();function n(i){return t(i)?e(i):r(i)}return Ki=n,Ki}var Ji,nh;function M1(){if(nh)return Ji;nh=1;var e=Mn(),r=pr();function t(n,i){return n&&e(i,r(i),n)}return Ji=t,Ji}var Zi,oh;function T1(){if(oh)return Zi;oh=1;function e(r){var t=[];if(r!=null)for(var n in Object(r))t.push(n);return t}return Zi=e,Zi}var Xi,ih;function O1(){if(ih)return Xi;ih=1;var e=qt(),r=bo(),t=T1(),n=Object.prototype,i=n.hasOwnProperty;function o(s){if(!e(s))return t(s);var a=r(s),l=[];for(var c in s)c=="constructor"&&(a||!i.call(s,c))||l.push(c);return l}return Xi=o,Xi}var Yi,ah;function Ar(){if(ah)return Yi;ah=1;var e=Fb(),r=O1(),t=Qt();function n(i){return t(i)?e(i,!0):r(i)}return Yi=n,Yi}var Qi,sh;function N1(){if(sh)return Qi;sh=1;var e=Mn(),r=Ar();function t(n,i){return n&&e(i,r(i),n)}return Qi=t,Qi}var fn={exports:{}};fn.exports;var ch;function Bb(){return ch||(ch=1,(function(e,r){var t=Dt(),n=r&&!r.nodeType&&r,i=n&&!0&&e&&!e.nodeType&&e,o=i&&i.exports===n,s=o?t.Buffer:void 0,a=s?s.allocUnsafe:void 0;function l(c,d){if(d)return c.slice();var u=c.length,h=a?a(u):new c.constructor(u);return c.copy(h),h}e.exports=l})(fn,fn.exports)),fn.exports}var ea,lh;function Db(){if(lh)return ea;lh=1;function e(r,t){var n=-1,i=r.length;for(t||(t=Array(i));++n<i;)t[n]=r[n];return t}return ea=e,ea}var ta,dh;function Vb(){if(dh)return ta;dh=1;function e(r,t){for(var n=-1,i=r==null?0:r.length,o=0,s=[];++n<i;){var a=r[n];t(a,n,r)&&(s[o++]=a)}return s}return ta=e,ta}var ra,uh;function Wb(){if(uh)return ra;uh=1;function e(){return[]}return ra=e,ra}var na,fh;function Fd(){if(fh)return na;fh=1;var e=Vb(),r=Wb(),t=Object.prototype,n=t.propertyIsEnumerable,i=Object.getOwnPropertySymbols,o=i?function(s){return s==null?[]:(s=Object(s),e(i(s),function(a){return n.call(s,a)}))}:r;return na=o,na}var oa,hh;function $1(){if(hh)return oa;hh=1;var e=Mn(),r=Fd();function t(n,i){return e(n,r(n),i)}return oa=t,oa}var ia,ph;function zd(){if(ph)return ia;ph=1;function e(r,t){for(var n=-1,i=t.length,o=r.length;++n<i;)r[o+n]=t[n];return r}return ia=e,ia}var aa,gh;function vo(){if(gh)return aa;gh=1;var e=zb(),r=e(Object.getPrototypeOf,Object);return aa=r,aa}var sa,yh;function Gb(){if(yh)return sa;yh=1;var e=zd(),r=vo(),t=Fd(),n=Wb(),i=Object.getOwnPropertySymbols,o=i?function(s){for(var a=[];s;)e(a,t(s)),s=r(s);return a}:n;return sa=o,sa}var ca,mh;function q1(){if(mh)return ca;mh=1;var e=Mn(),r=Gb();function t(n,i){return e(n,r(n),i)}return ca=t,ca}var la,bh;function Ub(){if(bh)return la;bh=1;var e=zd(),r=pt();function t(n,i,o){var s=i(n);return r(n)?s:e(s,o(n))}return la=t,la}var da,vh;function Hb(){if(vh)return da;vh=1;var e=Ub(),r=Fd(),t=pr();function n(i){return e(i,t,r)}return da=n,da}var ua,xh;function L1(){if(xh)return ua;xh=1;var e=Ub(),r=Gb(),t=Ar();function n(i){return e(i,t,r)}return ua=n,ua}var fa,wh;function F1(){if(wh)return fa;wh=1;var e=kr(),r=Dt(),t=e(r,"DataView");return fa=t,fa}var ha,Ch;function z1(){if(Ch)return ha;Ch=1;var e=kr(),r=Dt(),t=e(r,"Promise");return ha=t,ha}var pa,Sh;function Kb(){if(Sh)return pa;Sh=1;var e=kr(),r=Dt(),t=e(r,"Set");return pa=t,pa}var ga,jh;function B1(){if(jh)return ga;jh=1;var e=kr(),r=Dt(),t=e(r,"WeakMap");return ga=t,ga}var ya,_h;function Yr(){if(_h)return ya;_h=1;var e=F1(),r=Td(),t=z1(),n=Kb(),i=B1(),o=Rr(),s=qb(),a="[object Map]",l="[object Object]",c="[object Promise]",d="[object Set]",u="[object WeakMap]",h="[object DataView]",p=s(e),y=s(r),m=s(t),g=s(n),b=s(i),v=o;return(e&&v(new e(new ArrayBuffer(1)))!=h||r&&v(new r)!=a||t&&v(t.resolve())!=c||n&&v(new n)!=d||i&&v(new i)!=u)&&(v=function(x){var w=o(x),C=w==l?x.constructor:void 0,S=C?s(C):"";if(S)switch(S){case p:return h;case y:return a;case m:return c;case g:return d;case b:return u}return w}),ya=v,ya}var ma,Eh;function D1(){if(Eh)return ma;Eh=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n){var i=n.length,o=new n.constructor(i);return i&&typeof n[0]=="string"&&r.call(n,"index")&&(o.index=n.index,o.input=n.input),o}return ma=t,ma}var ba,Rh;function Jb(){if(Rh)return ba;Rh=1;var e=Dt(),r=e.Uint8Array;return ba=r,ba}var va,kh;function Bd(){if(kh)return va;kh=1;var e=Jb();function r(t){var n=new t.constructor(t.byteLength);return new e(n).set(new e(t)),n}return va=r,va}var xa,Ah;function V1(){if(Ah)return xa;Ah=1;var e=Bd();function r(t,n){var i=n?e(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)}return xa=r,xa}var wa,Ph;function W1(){if(Ph)return wa;Ph=1;var e=/\w*$/;function r(t){var n=new t.constructor(t.source,e.exec(t));return n.lastIndex=t.lastIndex,n}return wa=r,wa}var Ca,Ih;function G1(){if(Ih)return Ca;Ih=1;var e=Zr(),r=e?e.prototype:void 0,t=r?r.valueOf:void 0;function n(i){return t?Object(t.call(i)):{}}return Ca=n,Ca}var Sa,Mh;function Zb(){if(Mh)return Sa;Mh=1;var e=Bd();function r(t,n){var i=n?e(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}return Sa=r,Sa}var ja,Th;function U1(){if(Th)return ja;Th=1;var e=Bd(),r=V1(),t=W1(),n=G1(),i=Zb(),o="[object Boolean]",s="[object Date]",a="[object Map]",l="[object Number]",c="[object RegExp]",d="[object Set]",u="[object String]",h="[object Symbol]",p="[object ArrayBuffer]",y="[object DataView]",m="[object Float32Array]",g="[object Float64Array]",b="[object Int8Array]",v="[object Int16Array]",x="[object Int32Array]",w="[object Uint8Array]",C="[object Uint8ClampedArray]",S="[object Uint16Array]",_="[object Uint32Array]";function R(A,O,T){var E=A.constructor;switch(O){case p:return e(A);case o:case s:return new E(+A);case y:return r(A,T);case m:case g:case b:case v:case x:case w:case C:case S:case _:return i(A,T);case a:return new E;case l:case u:return new E(A);case c:return t(A);case d:return new E;case h:return n(A)}}return ja=R,ja}var _a,Oh;function Xb(){if(Oh)return _a;Oh=1;var e=qt(),r=Object.create,t=(function(){function n(){}return function(i){if(!e(i))return{};if(r)return r(i);n.prototype=i;var o=new n;return n.prototype=void 0,o}})();return _a=t,_a}var Ea,Nh;function Yb(){if(Nh)return Ea;Nh=1;var e=Xb(),r=vo(),t=bo();function n(i){return typeof i.constructor=="function"&&!t(i)?e(r(i)):{}}return Ea=n,Ea}var Ra,$h;function H1(){if($h)return Ra;$h=1;var e=Yr(),r=Kt(),t="[object Map]";function n(i){return r(i)&&e(i)==t}return Ra=n,Ra}var ka,qh;function K1(){if(qh)return ka;qh=1;var e=H1(),r=mo(),t=qd(),n=t&&t.isMap,i=n?r(n):e;return ka=i,ka}var Aa,Lh;function J1(){if(Lh)return Aa;Lh=1;var e=Yr(),r=Kt(),t="[object Set]";function n(i){return r(i)&&e(i)==t}return Aa=n,Aa}var Pa,Fh;function Z1(){if(Fh)return Pa;Fh=1;var e=J1(),r=mo(),t=qd(),n=t&&t.isSet,i=n?r(n):e;return Pa=i,Pa}var Ia,zh;function Qb(){if(zh)return Ia;zh=1;var e=ho(),r=Nd(),t=go(),n=M1(),i=N1(),o=Bb(),s=Db(),a=$1(),l=q1(),c=Hb(),d=L1(),u=Yr(),h=D1(),p=U1(),y=Yb(),m=pt(),g=Xr(),b=K1(),v=qt(),x=Z1(),w=pr(),C=Ar(),S=1,_=2,R=4,A="[object Arguments]",O="[object Array]",T="[object Boolean]",E="[object Date]",M="[object Error]",P="[object Function]",$="[object GeneratorFunction]",N="[object Map]",I="[object Number]",K="[object Object]",le="[object RegExp]",ie="[object Set]",te="[object String]",fe="[object Symbol]",xe="[object WeakMap]",q="[object ArrayBuffer]",W="[object DataView]",U="[object Float32Array]",z="[object Float64Array]",de="[object Int8Array]",Q="[object Int16Array]",ae="[object Int32Array]",se="[object Uint8Array]",Ce="[object Uint8ClampedArray]",Se="[object Uint16Array]",he="[object Uint32Array]",G={};G[A]=G[O]=G[q]=G[W]=G[T]=G[E]=G[U]=G[z]=G[de]=G[Q]=G[ae]=G[N]=G[I]=G[K]=G[le]=G[ie]=G[te]=G[fe]=G[se]=G[Ce]=G[Se]=G[he]=!0,G[M]=G[P]=G[xe]=!1;function F(re,ce,X,ye,ve,Oe){var Ne,Be=ce&S,et=ce&_,We=ce&R;if(X&&(Ne=ve?X(re,ye,ve,Oe):X(re)),Ne!==void 0)return Ne;if(!v(re))return re;var ft=m(re);if(ft){if(Ne=h(re),!Be)return s(re,Ne)}else{var Ke=u(re),nt=Ke==P||Ke==$;if(g(re))return o(re,Be);if(Ke==K||Ke==A||nt&&!ve){if(Ne=et||nt?{}:y(re),!Be)return et?l(re,i(Ne,re)):a(re,n(Ne,re))}else{if(!G[Ke])return ve?re:{};Ne=p(re,Ke,Be)}}Oe||(Oe=new e);var Ie=Oe.get(re);if(Ie)return Ie;Oe.set(re,Ne),x(re)?re.forEach(function(gt){Ne.add(F(gt,ce,X,gt,re,Oe))}):b(re)&&re.forEach(function(gt,at){Ne.set(at,F(gt,ce,X,at,re,Oe))});var He=We?et?d:c:et?C:w,tt=ft?void 0:He(re);return r(tt||re,function(gt,at){tt&&(at=gt,gt=re[at]),t(Ne,at,F(gt,ce,X,at,re,Oe))}),Ne}return Ia=F,Ia}var Ma,Bh;function X1(){if(Bh)return Ma;Bh=1;var e=Qb(),r=4;function t(n){return e(n,r)}return Ma=t,Ma}var Ta,Dh;function Dd(){if(Dh)return Ta;Dh=1;function e(r){return function(){return r}}return Ta=e,Ta}var Oa,Vh;function Y1(){if(Vh)return Oa;Vh=1;function e(r){return function(t,n,i){for(var o=-1,s=Object(t),a=i(t),l=a.length;l--;){var c=a[r?l:++o];if(n(s[c],c,s)===!1)break}return t}}return Oa=e,Oa}var Na,Wh;function Vd(){if(Wh)return Na;Wh=1;var e=Y1(),r=e();return Na=r,Na}var $a,Gh;function Wd(){if(Gh)return $a;Gh=1;var e=Vd(),r=pr();function t(n,i){return n&&e(n,i,r)}return $a=t,$a}var qa,Uh;function Q1(){if(Uh)return qa;Uh=1;var e=Qt();function r(t,n){return function(i,o){if(i==null)return i;if(!e(i))return t(i,o);for(var s=i.length,a=n?s:-1,l=Object(i);(n?a--:++a<s)&&o(l[a],a,l)!==!1;);return i}}return qa=r,qa}var La,Hh;function xo(){if(Hh)return La;Hh=1;var e=Wd(),r=Q1(),t=r(e);return La=t,La}var Fa,Kh;function Pr(){if(Kh)return Fa;Kh=1;function e(r){return r}return Fa=e,Fa}var za,Jh;function ev(){if(Jh)return za;Jh=1;var e=Pr();function r(t){return typeof t=="function"?t:e}return za=r,za}var Ba,Zh;function tv(){if(Zh)return Ba;Zh=1;var e=Nd(),r=xo(),t=ev(),n=pt();function i(o,s){var a=n(o)?e:r;return a(o,t(s))}return Ba=i,Ba}var Da,Xh;function rv(){return Xh||(Xh=1,Da=tv()),Da}var Va,Yh;function eC(){if(Yh)return Va;Yh=1;var e=xo();function r(t,n){var i=[];return e(t,function(o,s,a){n(o,s,a)&&i.push(o)}),i}return Va=r,Va}var Wa,Qh;function tC(){if(Qh)return Wa;Qh=1;var e="__lodash_hash_undefined__";function r(t){return this.__data__.set(t,e),this}return Wa=r,Wa}var Ga,ep;function rC(){if(ep)return Ga;ep=1;function e(r){return this.__data__.has(r)}return Ga=e,Ga}var Ua,tp;function nv(){if(tp)return Ua;tp=1;var e=Od(),r=tC(),t=rC();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=r,n.prototype.has=t,Ua=n,Ua}var Ha,rp;function nC(){if(rp)return Ha;rp=1;function e(r,t){for(var n=-1,i=r==null?0:r.length;++n<i;)if(t(r[n],n,r))return!0;return!1}return Ha=e,Ha}var Ka,np;function ov(){if(np)return Ka;np=1;function e(r,t){return r.has(t)}return Ka=e,Ka}var Ja,op;function iv(){if(op)return Ja;op=1;var e=nv(),r=nC(),t=ov(),n=1,i=2;function o(s,a,l,c,d,u){var h=l&n,p=s.length,y=a.length;if(p!=y&&!(h&&y>p))return!1;var m=u.get(s),g=u.get(a);if(m&&g)return m==a&&g==s;var b=-1,v=!0,x=l&i?new e:void 0;for(u.set(s,a),u.set(a,s);++b<p;){var w=s[b],C=a[b];if(c)var S=h?c(C,w,b,a,s,u):c(w,C,b,s,a,u);if(S!==void 0){if(S)continue;v=!1;break}if(x){if(!r(a,function(_,R){if(!t(x,R)&&(w===_||d(w,_,l,c,u)))return x.push(R)})){v=!1;break}}else if(!(w===C||d(w,C,l,c,u))){v=!1;break}}return u.delete(s),u.delete(a),v}return Ja=o,Ja}var Za,ip;function oC(){if(ip)return Za;ip=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(i,o){n[++t]=[o,i]}),n}return Za=e,Za}var Xa,ap;function Gd(){if(ap)return Xa;ap=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(i){n[++t]=i}),n}return Xa=e,Xa}var Ya,sp;function iC(){if(sp)return Ya;sp=1;var e=Zr(),r=Jb(),t=Jr(),n=iv(),i=oC(),o=Gd(),s=1,a=2,l="[object Boolean]",c="[object Date]",d="[object Error]",u="[object Map]",h="[object Number]",p="[object RegExp]",y="[object Set]",m="[object String]",g="[object Symbol]",b="[object ArrayBuffer]",v="[object DataView]",x=e?e.prototype:void 0,w=x?x.valueOf:void 0;function C(S,_,R,A,O,T,E){switch(R){case v:if(S.byteLength!=_.byteLength||S.byteOffset!=_.byteOffset)return!1;S=S.buffer,_=_.buffer;case b:return!(S.byteLength!=_.byteLength||!T(new r(S),new r(_)));case l:case c:case h:return t(+S,+_);case d:return S.name==_.name&&S.message==_.message;case p:case m:return S==_+"";case u:var M=i;case y:var P=A&s;if(M||(M=o),S.size!=_.size&&!P)return!1;var $=E.get(S);if($)return $==_;A|=a,E.set(S,_);var N=n(M(S),M(_),A,O,T,E);return E.delete(S),N;case g:if(w)return w.call(S)==w.call(_)}return!1}return Ya=C,Ya}var Qa,cp;function aC(){if(cp)return Qa;cp=1;var e=Hb(),r=1,t=Object.prototype,n=t.hasOwnProperty;function i(o,s,a,l,c,d){var u=a&r,h=e(o),p=h.length,y=e(s),m=y.length;if(p!=m&&!u)return!1;for(var g=p;g--;){var b=h[g];if(!(u?b in s:n.call(s,b)))return!1}var v=d.get(o),x=d.get(s);if(v&&x)return v==s&&x==o;var w=!0;d.set(o,s),d.set(s,o);for(var C=u;++g<p;){b=h[g];var S=o[b],_=s[b];if(l)var R=u?l(_,S,b,s,o,d):l(S,_,b,o,s,d);if(!(R===void 0?S===_||c(S,_,a,l,d):R)){w=!1;break}C||(C=b=="constructor")}if(w&&!C){var A=o.constructor,O=s.constructor;A!=O&&"constructor"in o&&"constructor"in s&&!(typeof A=="function"&&A instanceof A&&typeof O=="function"&&O instanceof O)&&(w=!1)}return d.delete(o),d.delete(s),w}return Qa=i,Qa}var es,lp;function sC(){if(lp)return es;lp=1;var e=ho(),r=iv(),t=iC(),n=aC(),i=Yr(),o=pt(),s=Xr(),a=On(),l=1,c="[object Arguments]",d="[object Array]",u="[object Object]",h=Object.prototype,p=h.hasOwnProperty;function y(m,g,b,v,x,w){var C=o(m),S=o(g),_=C?d:i(m),R=S?d:i(g);_=_==c?u:_,R=R==c?u:R;var A=_==u,O=R==u,T=_==R;if(T&&s(m)){if(!s(g))return!1;C=!0,A=!1}if(T&&!A)return w||(w=new e),C||a(m)?r(m,g,b,v,x,w):t(m,g,_,b,v,x,w);if(!(b&l)){var E=A&&p.call(m,"__wrapped__"),M=O&&p.call(g,"__wrapped__");if(E||M){var P=E?m.value():m,$=M?g.value():g;return w||(w=new e),x(P,$,b,v,w)}}return T?(w||(w=new e),n(m,g,b,v,x,w)):!1}return es=y,es}var ts,dp;function av(){if(dp)return ts;dp=1;var e=sC(),r=Kt();function t(n,i,o,s,a){return n===i?!0:n==null||i==null||!r(n)&&!r(i)?n!==n&&i!==i:e(n,i,o,s,t,a)}return ts=t,ts}var rs,up;function cC(){if(up)return rs;up=1;var e=ho(),r=av(),t=1,n=2;function i(o,s,a,l){var c=a.length,d=c,u=!l;if(o==null)return!d;for(o=Object(o);c--;){var h=a[c];if(u&&h[2]?h[1]!==o[h[0]]:!(h[0]in o))return!1}for(;++c<d;){h=a[c];var p=h[0],y=o[p],m=h[1];if(u&&h[2]){if(y===void 0&&!(p in o))return!1}else{var g=new e;if(l)var b=l(y,m,p,o,s,g);if(!(b===void 0?r(m,y,t|n,l,g):b))return!1}}return!0}return rs=i,rs}var ns,fp;function sv(){if(fp)return ns;fp=1;var e=qt();function r(t){return t===t&&!e(t)}return ns=r,ns}var os,hp;function lC(){if(hp)return os;hp=1;var e=sv(),r=pr();function t(n){for(var i=r(n),o=i.length;o--;){var s=i[o],a=n[s];i[o]=[s,a,e(a)]}return i}return os=t,os}var is,pp;function cv(){if(pp)return is;pp=1;function e(r,t){return function(n){return n==null?!1:n[r]===t&&(t!==void 0||r in Object(n))}}return is=e,is}var as,gp;function dC(){if(gp)return as;gp=1;var e=cC(),r=lC(),t=cv();function n(i){var o=r(i);return o.length==1&&o[0][2]?t(o[0][0],o[0][1]):function(s){return s===i||e(s,i,o)}}return as=n,as}var ss,yp;function Qr(){if(yp)return ss;yp=1;var e=Rr(),r=Kt(),t="[object Symbol]";function n(i){return typeof i=="symbol"||r(i)&&e(i)==t}return ss=n,ss}var cs,mp;function Ud(){if(mp)return cs;mp=1;var e=pt(),r=Qr(),t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\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||r(o)?!0:n.test(o)||!t.test(o)||s!=null&&o in Object(s)}return cs=i,cs}var ls,bp;function uC(){if(bp)return ls;bp=1;var e=Od(),r="Expected a function";function t(n,i){if(typeof n!="function"||i!=null&&typeof i!="function")throw new TypeError(r);var o=function(){var s=arguments,a=i?i.apply(this,s):s[0],l=o.cache;if(l.has(a))return l.get(a);var c=n.apply(this,s);return o.cache=l.set(a,c)||l,c};return o.cache=new(t.Cache||e),o}return t.Cache=e,ls=t,ls}var ds,vp;function fC(){if(vp)return ds;vp=1;var e=uC(),r=500;function t(n){var i=e(n,function(s){return o.size===r&&o.clear(),s}),o=i.cache;return i}return ds=t,ds}var us,xp;function hC(){if(xp)return us;xp=1;var e=fC(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,n=e(function(i){var o=[];return i.charCodeAt(0)===46&&o.push(""),i.replace(r,function(s,a,l,c){o.push(l?c.replace(t,"$1"):a||s)}),o});return us=n,us}var fs,wp;function wo(){if(wp)return fs;wp=1;function e(r,t){for(var n=-1,i=r==null?0:r.length,o=Array(i);++n<i;)o[n]=t(r[n],n,r);return o}return fs=e,fs}var hs,Cp;function pC(){if(Cp)return hs;Cp=1;var e=Zr(),r=wo(),t=pt(),n=Qr(),i=e?e.prototype:void 0,o=i?i.toString:void 0;function s(a){if(typeof a=="string")return a;if(t(a))return r(a,s)+"";if(n(a))return o?o.call(a):"";var l=a+"";return l=="0"&&1/a==-1/0?"-0":l}return hs=s,hs}var ps,Sp;function lv(){if(Sp)return ps;Sp=1;var e=pC();function r(t){return t==null?"":e(t)}return ps=r,ps}var gs,jp;function Co(){if(jp)return gs;jp=1;var e=pt(),r=Ud(),t=hC(),n=lv();function i(o,s){return e(o)?o:r(o,s)?[o]:t(n(o))}return gs=i,gs}var ys,_p;function Nn(){if(_p)return ys;_p=1;var e=Qr();function r(t){if(typeof t=="string"||e(t))return t;var n=t+"";return n=="0"&&1/t==-1/0?"-0":n}return ys=r,ys}var ms,Ep;function So(){if(Ep)return ms;Ep=1;var e=Co(),r=Nn();function t(n,i){i=e(i,n);for(var o=0,s=i.length;n!=null&&o<s;)n=n[r(i[o++])];return o&&o==s?n:void 0}return ms=t,ms}var bs,Rp;function gC(){if(Rp)return bs;Rp=1;var e=So();function r(t,n,i){var o=t==null?void 0:e(t,n);return o===void 0?i:o}return bs=r,bs}var vs,kp;function yC(){if(kp)return vs;kp=1;function e(r,t){return r!=null&&t in Object(r)}return vs=e,vs}var xs,Ap;function dv(){if(Ap)return xs;Ap=1;var e=Co(),r=Tn(),t=pt(),n=yo(),i=$d(),o=Nn();function s(a,l,c){l=e(l,a);for(var d=-1,u=l.length,h=!1;++d<u;){var p=o(l[d]);if(!(h=a!=null&&c(a,p)))break;a=a[p]}return h||++d!=u?h:(u=a==null?0:a.length,!!u&&i(u)&&n(p,u)&&(t(a)||r(a)))}return xs=s,xs}var ws,Pp;function uv(){if(Pp)return ws;Pp=1;var e=yC(),r=dv();function t(n,i){return n!=null&&r(n,i,e)}return ws=t,ws}var Cs,Ip;function mC(){if(Ip)return Cs;Ip=1;var e=av(),r=gC(),t=uv(),n=Ud(),i=sv(),o=cv(),s=Nn(),a=1,l=2;function c(d,u){return n(d)&&i(u)?o(s(d),u):function(h){var p=r(h,d);return p===void 0&&p===u?t(h,d):e(u,p,a|l)}}return Cs=c,Cs}var Ss,Mp;function fv(){if(Mp)return Ss;Mp=1;function e(r){return function(t){return t==null?void 0:t[r]}}return Ss=e,Ss}var js,Tp;function bC(){if(Tp)return js;Tp=1;var e=So();function r(t){return function(n){return e(n,t)}}return js=r,js}var _s,Op;function vC(){if(Op)return _s;Op=1;var e=fv(),r=bC(),t=Ud(),n=Nn();function i(o){return t(o)?e(n(o)):r(o)}return _s=i,_s}var Es,Np;function er(){if(Np)return Es;Np=1;var e=dC(),r=mC(),t=Pr(),n=pt(),i=vC();function o(s){return typeof s=="function"?s:s==null?t:typeof s=="object"?n(s)?r(s[0],s[1]):e(s):i(s)}return Es=o,Es}var Rs,$p;function hv(){if($p)return Rs;$p=1;var e=Vb(),r=eC(),t=er(),n=pt();function i(o,s){var a=n(o)?e:r;return a(o,t(s,3))}return Rs=i,Rs}var ks,qp;function xC(){if(qp)return ks;qp=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n,i){return n!=null&&r.call(n,i)}return ks=t,ks}var As,Lp;function pv(){if(Lp)return As;Lp=1;var e=xC(),r=dv();function t(n,i){return n!=null&&r(n,i,e)}return As=t,As}var Ps,Fp;function wC(){if(Fp)return Ps;Fp=1;var e=Ld(),r=Yr(),t=Tn(),n=pt(),i=Qt(),o=Xr(),s=bo(),a=On(),l="[object Map]",c="[object Set]",d=Object.prototype,u=d.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)||t(p)))return!p.length;var y=r(p);if(y==l||y==c)return!p.size;if(s(p))return!e(p).length;for(var m in p)if(u.call(p,m))return!1;return!0}return Ps=h,Ps}var Is,zp;function gv(){if(zp)return Is;zp=1;function e(r){return r===void 0}return Is=e,Is}var Ms,Bp;function yv(){if(Bp)return Ms;Bp=1;var e=xo(),r=Qt();function t(n,i){var o=-1,s=r(n)?Array(n.length):[];return e(n,function(a,l,c){s[++o]=i(a,l,c)}),s}return Ms=t,Ms}var Ts,Dp;function mv(){if(Dp)return Ts;Dp=1;var e=wo(),r=er(),t=yv(),n=pt();function i(o,s){var a=n(o)?e:t;return a(o,r(s,3))}return Ts=i,Ts}var Os,Vp;function CC(){if(Vp)return Os;Vp=1;function e(r,t,n,i){var o=-1,s=r==null?0:r.length;for(i&&s&&(n=r[++o]);++o<s;)n=t(n,r[o],o,r);return n}return Os=e,Os}var Ns,Wp;function SC(){if(Wp)return Ns;Wp=1;function e(r,t,n,i,o){return o(r,function(s,a,l){n=i?(i=!1,s):t(n,s,a,l)}),n}return Ns=e,Ns}var $s,Gp;function bv(){if(Gp)return $s;Gp=1;var e=CC(),r=xo(),t=er(),n=SC(),i=pt();function o(s,a,l){var c=i(s)?e:n,d=arguments.length<3;return c(s,t(a,4),l,d,r)}return $s=o,$s}var qs,Up;function jC(){if(Up)return qs;Up=1;var e=Rr(),r=pt(),t=Kt(),n="[object String]";function i(o){return typeof o=="string"||!r(o)&&t(o)&&e(o)==n}return qs=i,qs}var Ls,Hp;function _C(){if(Hp)return Ls;Hp=1;var e=fv(),r=e("length");return Ls=r,Ls}var Fs,Kp;function EC(){if(Kp)return Fs;Kp=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",i=r+t+n,o="\\ufe0e\\ufe0f",s="\\u200d",a=RegExp("["+s+e+i+o+"]");function l(c){return a.test(c)}return Fs=l,Fs}var zs,Jp;function RC(){if(Jp)return zs;Jp=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",i=r+t+n,o="\\ufe0e\\ufe0f",s="["+e+"]",a="["+i+"]",l="\\ud83c[\\udffb-\\udfff]",c="(?:"+a+"|"+l+")",d="[^"+e+"]",u="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",y=c+"?",m="["+o+"]?",g="(?:"+p+"(?:"+[d,u,h].join("|")+")"+m+y+")*",b=m+y+g,v="(?:"+[d+a+"?",a,u,h,s].join("|")+")",x=RegExp(l+"(?="+l+")|"+v+b,"g");function w(C){for(var S=x.lastIndex=0;x.test(C);)++S;return S}return zs=w,zs}var Bs,Zp;function kC(){if(Zp)return Bs;Zp=1;var e=_C(),r=EC(),t=RC();function n(i){return r(i)?t(i):e(i)}return Bs=n,Bs}var Ds,Xp;function AC(){if(Xp)return Ds;Xp=1;var e=Ld(),r=Yr(),t=Qt(),n=jC(),i=kC(),o="[object Map]",s="[object Set]";function a(l){if(l==null)return 0;if(t(l))return n(l)?i(l):l.length;var c=r(l);return c==o||c==s?l.size:e(l).length}return Ds=a,Ds}var Vs,Yp;function PC(){if(Yp)return Vs;Yp=1;var e=Nd(),r=Xb(),t=Wd(),n=er(),i=vo(),o=pt(),s=Xr(),a=In(),l=qt(),c=On();function d(u,h,p){var y=o(u),m=y||s(u)||c(u);if(h=n(h,4),p==null){var g=u&&u.constructor;m?p=y?new g:[]:l(u)?p=a(g)?r(i(u)):{}:p={}}return(m?e:t)(u,function(b,v,x){return h(p,b,v,x)}),p}return Vs=d,Vs}var Ws,Qp;function IC(){if(Qp)return Ws;Qp=1;var e=Zr(),r=Tn(),t=pt(),n=e?e.isConcatSpreadable:void 0;function i(o){return t(o)||r(o)||!!(n&&o&&o[n])}return Ws=i,Ws}var Gs,eg;function Hd(){if(eg)return Gs;eg=1;var e=zd(),r=IC();function t(n,i,o,s,a){var l=-1,c=n.length;for(o||(o=r),a||(a=[]);++l<c;){var d=n[l];i>0&&o(d)?i>1?t(d,i-1,o,s,a):e(a,d):s||(a[a.length]=d)}return a}return Gs=t,Gs}var Us,tg;function MC(){if(tg)return Us;tg=1;function e(r,t,n){switch(n.length){case 0:return r.call(t);case 1:return r.call(t,n[0]);case 2:return r.call(t,n[0],n[1]);case 3:return r.call(t,n[0],n[1],n[2])}return r.apply(t,n)}return Us=e,Us}var Hs,rg;function vv(){if(rg)return Hs;rg=1;var e=MC(),r=Math.max;function t(n,i,o){return i=r(i===void 0?n.length-1:i,0),function(){for(var s=arguments,a=-1,l=r(s.length-i,0),c=Array(l);++a<l;)c[a]=s[i+a];a=-1;for(var d=Array(i+1);++a<i;)d[a]=s[a];return d[i]=o(c),e(n,this,d)}}return Hs=t,Hs}var Ks,ng;function TC(){if(ng)return Ks;ng=1;var e=Dd(),r=Lb(),t=Pr(),n=r?function(i,o){return r(i,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:t;return Ks=n,Ks}var Js,og;function OC(){if(og)return Js;og=1;var e=800,r=16,t=Date.now;function n(i){var o=0,s=0;return function(){var a=t(),l=r-(a-s);if(s=a,l>0){if(++o>=e)return arguments[0]}else o=0;return i.apply(void 0,arguments)}}return Js=n,Js}var Zs,ig;function xv(){if(ig)return Zs;ig=1;var e=TC(),r=OC(),t=r(e);return Zs=t,Zs}var Xs,ag;function jo(){if(ag)return Xs;ag=1;var e=Pr(),r=vv(),t=xv();function n(i,o){return t(r(i,o,e),i+"")}return Xs=n,Xs}var Ys,sg;function wv(){if(sg)return Ys;sg=1;function e(r,t,n,i){for(var o=r.length,s=n+(i?1:-1);i?s--:++s<o;)if(t(r[s],s,r))return s;return-1}return Ys=e,Ys}var Qs,cg;function NC(){if(cg)return Qs;cg=1;function e(r){return r!==r}return Qs=e,Qs}var ec,lg;function $C(){if(lg)return ec;lg=1;function e(r,t,n){for(var i=n-1,o=r.length;++i<o;)if(r[i]===t)return i;return-1}return ec=e,ec}var tc,dg;function qC(){if(dg)return tc;dg=1;var e=wv(),r=NC(),t=$C();function n(i,o,s){return o===o?t(i,o,s):e(i,r,s)}return tc=n,tc}var rc,ug;function LC(){if(ug)return rc;ug=1;var e=qC();function r(t,n){var i=t==null?0:t.length;return!!i&&e(t,n,0)>-1}return rc=r,rc}var nc,fg;function FC(){if(fg)return nc;fg=1;function e(r,t,n){for(var i=-1,o=r==null?0:r.length;++i<o;)if(n(t,r[i]))return!0;return!1}return nc=e,nc}var oc,hg;function zC(){if(hg)return oc;hg=1;function e(){}return oc=e,oc}var ic,pg;function BC(){if(pg)return ic;pg=1;var e=Kb(),r=zC(),t=Gd(),n=1/0,i=e&&1/t(new e([,-0]))[1]==n?function(o){return new e(o)}:r;return ic=i,ic}var ac,gg;function DC(){if(gg)return ac;gg=1;var e=nv(),r=LC(),t=FC(),n=ov(),i=BC(),o=Gd(),s=200;function a(l,c,d){var u=-1,h=r,p=l.length,y=!0,m=[],g=m;if(d)y=!1,h=t;else if(p>=s){var b=c?null:i(l);if(b)return o(b);y=!1,h=n,g=new e}else g=c?[]:m;e:for(;++u<p;){var v=l[u],x=c?c(v):v;if(v=d||v!==0?v:0,y&&x===x){for(var w=g.length;w--;)if(g[w]===x)continue e;c&&g.push(x),m.push(v)}else h(g,x,d)||(g!==m&&g.push(x),m.push(v))}return m}return ac=a,ac}var sc,yg;function Cv(){if(yg)return sc;yg=1;var e=Qt(),r=Kt();function t(n){return r(n)&&e(n)}return sc=t,sc}var cc,mg;function VC(){if(mg)return cc;mg=1;var e=Hd(),r=jo(),t=DC(),n=Cv(),i=r(function(o){return t(e(o,1,n,!0))});return cc=i,cc}var lc,bg;function WC(){if(bg)return lc;bg=1;var e=wo();function r(t,n){return e(n,function(i){return t[i]})}return lc=r,lc}var dc,vg;function Sv(){if(vg)return dc;vg=1;var e=WC(),r=pr();function t(n){return n==null?[]:e(n,r(n))}return dc=t,dc}var uc,xg;function Lt(){if(xg)return uc;xg=1;var e;if(typeof Md=="function")try{e={clone:X1(),constant:Dd(),each:rv(),filter:hv(),has:pv(),isArray:pt(),isEmpty:wC(),isFunction:In(),isUndefined:gv(),keys:pr(),map:mv(),reduce:bv(),size:AC(),transform:PC(),union:VC(),values:Sv()}}catch{}return e||(e=window._),uc=e,uc}var fc,wg;function Kd(){if(wg)return fc;wg=1;var e=Lt();fc=i;var r="\0",t="\0",n="";function i(d){this._isDirected=e.has(d,"directed")?d.directed:!0,this._isMultigraph=e.has(d,"multigraph")?d.multigraph:!1,this._isCompound=e.has(d,"compound")?d.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[t]={}),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(d){return this._label=d,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return e.keys(this._nodes)},i.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(u){return e.isEmpty(d._in[u])})},i.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(u){return e.isEmpty(d._out[u])})},i.prototype.setNodes=function(d,u){var h=arguments,p=this;return e.each(d,function(y){h.length>1?p.setNode(y,u):p.setNode(y)}),this},i.prototype.setNode=function(d,u){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=u),this):(this._nodes[d]=arguments.length>1?u:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=t,this._children[d]={},this._children[t][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},i.prototype.node=function(d){return this._nodes[d]},i.prototype.hasNode=function(d){return e.has(this._nodes,d)},i.prototype.removeNode=function(d){var u=this;if(e.has(this._nodes,d)){var h=function(p){u.removeEdge(u._edgeObjs[p])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(p){u.setParent(p)}),delete this._children[d]),e.each(e.keys(this._in[d]),h),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),h),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},i.prototype.setParent=function(d,u){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(u))u=t;else{u+="";for(var h=u;!e.isUndefined(h);h=this.parent(h))if(h===d)throw new Error("Setting "+u+" as parent of "+d+" would create a cycle");this.setNode(u)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=u,this._children[u][d]=!0,this},i.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},i.prototype.parent=function(d){if(this._isCompound){var u=this._parent[d];if(u!==t)return u}},i.prototype.children=function(d){if(e.isUndefined(d)&&(d=t),this._isCompound){var u=this._children[d];if(u)return e.keys(u)}else{if(d===t)return this.nodes();if(this.hasNode(d))return[]}},i.prototype.predecessors=function(d){var u=this._preds[d];if(u)return e.keys(u)},i.prototype.successors=function(d){var u=this._sucs[d];if(u)return e.keys(u)},i.prototype.neighbors=function(d){var u=this.predecessors(d);if(u)return e.union(u,this.successors(d))},i.prototype.isLeaf=function(d){var u;return this.isDirected()?u=this.successors(d):u=this.neighbors(d),u.length===0},i.prototype.filterNodes=function(d){var u=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});u.setGraph(this.graph());var h=this;e.each(this._nodes,function(m,g){d(g)&&u.setNode(g,m)}),e.each(this._edgeObjs,function(m){u.hasNode(m.v)&&u.hasNode(m.w)&&u.setEdge(m,h.edge(m))});var p={};function y(m){var g=h.parent(m);return g===void 0||u.hasNode(g)?(p[m]=g,g):g in p?p[g]:y(g)}return this._isCompound&&e.each(u.nodes(),function(m){u.setParent(m,y(m))}),u},i.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return e.values(this._edgeObjs)},i.prototype.setPath=function(d,u){var h=this,p=arguments;return e.reduce(d,function(y,m){return p.length>1?h.setEdge(y,m,u):h.setEdge(y,m),m}),this},i.prototype.setEdge=function(){var d,u,h,p,y=!1,m=arguments[0];typeof m=="object"&&m!==null&&"v"in m?(d=m.v,u=m.w,h=m.name,arguments.length===2&&(p=arguments[1],y=!0)):(d=m,u=arguments[1],h=arguments[3],arguments.length>2&&(p=arguments[2],y=!0)),d=""+d,u=""+u,e.isUndefined(h)||(h=""+h);var g=a(this._isDirected,d,u,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(d),this.setNode(u),this._edgeLabels[g]=y?p:this._defaultEdgeLabelFn(d,u,h);var b=l(this._isDirected,d,u,h);return d=b.v,u=b.w,Object.freeze(b),this._edgeObjs[g]=b,o(this._preds[u],d),o(this._sucs[d],u),this._in[u][g]=b,this._out[d][g]=b,this._edgeCount++,this},i.prototype.edge=function(d,u,h){var p=arguments.length===1?c(this._isDirected,arguments[0]):a(this._isDirected,d,u,h);return this._edgeLabels[p]},i.prototype.hasEdge=function(d,u,h){var p=arguments.length===1?c(this._isDirected,arguments[0]):a(this._isDirected,d,u,h);return e.has(this._edgeLabels,p)},i.prototype.removeEdge=function(d,u,h){var p=arguments.length===1?c(this._isDirected,arguments[0]):a(this._isDirected,d,u,h),y=this._edgeObjs[p];return y&&(d=y.v,u=y.w,delete this._edgeLabels[p],delete this._edgeObjs[p],s(this._preds[u],d),s(this._sucs[d],u),delete this._in[u][p],delete this._out[d][p],this._edgeCount--),this},i.prototype.inEdges=function(d,u){var h=this._in[d];if(h){var p=e.values(h);return u?e.filter(p,function(y){return y.v===u}):p}},i.prototype.outEdges=function(d,u){var h=this._out[d];if(h){var p=e.values(h);return u?e.filter(p,function(y){return y.w===u}):p}},i.prototype.nodeEdges=function(d,u){var h=this.inEdges(d,u);if(h)return h.concat(this.outEdges(d,u))};function o(d,u){d[u]?d[u]++:d[u]=1}function s(d,u){--d[u]||delete d[u]}function a(d,u,h,p){var y=""+u,m=""+h;if(!d&&y>m){var g=y;y=m,m=g}return y+n+m+n+(e.isUndefined(p)?r:p)}function l(d,u,h,p){var y=""+u,m=""+h;if(!d&&y>m){var g=y;y=m,m=g}var b={v:y,w:m};return p&&(b.name=p),b}function c(d,u){return a(d,u.v,u.w,u.name)}return fc}var hc,Cg;function GC(){return Cg||(Cg=1,hc="2.1.8"),hc}var pc,Sg;function UC(){return Sg||(Sg=1,pc={Graph:Kd(),version:GC()}),pc}var gc,jg;function HC(){if(jg)return gc;jg=1;var e=Lt(),r=Kd();gc={write:t,read:o};function t(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 l=s.node(a),c=s.parent(a),d={v:a};return e.isUndefined(l)||(d.value=l),e.isUndefined(c)||(d.parent=c),d})}function i(s){return e.map(s.edges(),function(a){var l=s.edge(a),c={v:a.v,w:a.w};return e.isUndefined(a.name)||(c.name=a.name),e.isUndefined(l)||(c.value=l),c})}function o(s){var a=new r(s.options).setGraph(s.value);return e.each(s.nodes,function(l){a.setNode(l.v,l.value),l.parent&&a.setParent(l.v,l.parent)}),e.each(s.edges,function(l){a.setEdge({v:l.v,w:l.w,name:l.name},l.value)}),a}return gc}var yc,_g;function KC(){if(_g)return yc;_g=1;var e=Lt();yc=r;function r(t){var n={},i=[],o;function s(a){e.has(n,a)||(n[a]=!0,o.push(a),e.each(t.successors(a),s),e.each(t.predecessors(a),s))}return e.each(t.nodes(),function(a){o=[],s(a),o.length&&i.push(o)}),i}return yc}var mc,Eg;function jv(){if(Eg)return mc;Eg=1;var e=Lt();mc=r;function r(){this._arr=[],this._keyIndices={}}return r.prototype.size=function(){return this._arr.length},r.prototype.keys=function(){return this._arr.map(function(t){return t.key})},r.prototype.has=function(t){return e.has(this._keyIndices,t)},r.prototype.priority=function(t){var n=this._keyIndices[t];if(n!==void 0)return this._arr[n].priority},r.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},r.prototype.add=function(t,n){var i=this._keyIndices;if(t=String(t),!e.has(i,t)){var o=this._arr,s=o.length;return i[t]=s,o.push({key:t,priority:n}),this._decrease(s),!0}return!1},r.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},r.prototype.decrease=function(t,n){var i=this._keyIndices[t];if(n>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[i].priority+" New: "+n);this._arr[i].priority=n,this._decrease(i)},r.prototype._heapify=function(t){var n=this._arr,i=2*t,o=i+1,s=t;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!==t&&(this._swap(t,s),this._heapify(s)))},r.prototype._decrease=function(t){for(var n=this._arr,i=n[t].priority,o;t!==0&&(o=t>>1,!(n[o].priority<i));)this._swap(t,o),t=o},r.prototype._swap=function(t,n){var i=this._arr,o=this._keyIndices,s=i[t],a=i[n];i[t]=a,i[n]=s,o[a.key]=t,o[s.key]=n},mc}var bc,Rg;function _v(){if(Rg)return bc;Rg=1;var e=Lt(),r=jv();bc=n;var t=e.constant(1);function n(o,s,a,l){return i(o,String(s),a||t,l||function(c){return o.outEdges(c)})}function i(o,s,a,l){var c={},d=new r,u,h,p=function(y){var m=y.v!==u?y.v:y.w,g=c[m],b=a(y),v=h.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+y+" Weight: "+b);v<g.distance&&(g.distance=v,g.predecessor=u,d.decrease(m,v))};for(o.nodes().forEach(function(y){var m=y===s?0:Number.POSITIVE_INFINITY;c[y]={distance:m},d.add(y,m)});d.size()>0&&(u=d.removeMin(),h=c[u],h.distance!==Number.POSITIVE_INFINITY);)l(u).forEach(p);return c}return bc}var vc,kg;function JC(){if(kg)return vc;kg=1;var e=_v(),r=Lt();vc=t;function t(n,i,o){return r.transform(n.nodes(),function(s,a){s[a]=e(n,a,i,o)},{})}return vc}var xc,Ag;function Ev(){if(Ag)return xc;Ag=1;var e=Lt();xc=r;function r(t){var n=0,i=[],o={},s=[];function a(l){var c=o[l]={onStack:!0,lowlink:n,index:n++};if(i.push(l),t.successors(l).forEach(function(h){e.has(o,h)?o[h].onStack&&(c.lowlink=Math.min(c.lowlink,o[h].index)):(a(h),c.lowlink=Math.min(c.lowlink,o[h].lowlink))}),c.lowlink===c.index){var d=[],u;do u=i.pop(),o[u].onStack=!1,d.push(u);while(l!==u);s.push(d)}}return t.nodes().forEach(function(l){e.has(o,l)||a(l)}),s}return xc}var wc,Pg;function ZC(){if(Pg)return wc;Pg=1;var e=Lt(),r=Ev();wc=t;function t(n){return e.filter(r(n),function(i){return i.length>1||i.length===1&&n.hasEdge(i[0],i[0])})}return wc}var Cc,Ig;function XC(){if(Ig)return Cc;Ig=1;var e=Lt();Cc=t;var r=e.constant(1);function t(i,o,s){return n(i,o||r,s||function(a){return i.outEdges(a)})}function n(i,o,s){var a={},l=i.nodes();return l.forEach(function(c){a[c]={},a[c][c]={distance:0},l.forEach(function(d){c!==d&&(a[c][d]={distance:Number.POSITIVE_INFINITY})}),s(c).forEach(function(d){var u=d.v===c?d.w:d.v,h=o(d);a[c][u]={distance:h,predecessor:c}})}),l.forEach(function(c){var d=a[c];l.forEach(function(u){var h=a[u];l.forEach(function(p){var y=h[c],m=d[p],g=h[p],b=y.distance+m.distance;b<g.distance&&(g.distance=b,g.predecessor=m.predecessor)})})}),a}return Cc}var Sc,Mg;function Rv(){if(Mg)return Sc;Mg=1;var e=Lt();Sc=r,r.CycleException=t;function r(n){var i={},o={},s=[];function a(l){if(e.has(o,l))throw new t;e.has(i,l)||(o[l]=!0,i[l]=!0,e.each(n.predecessors(l),a),delete o[l],s.push(l))}if(e.each(n.sinks(),a),e.size(i)!==n.nodeCount())throw new t;return s}function t(){}return t.prototype=new Error,Sc}var jc,Tg;function YC(){if(Tg)return jc;Tg=1;var e=Rv();jc=r;function r(t){try{e(t)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return jc}var _c,Og;function kv(){if(Og)return _c;Og=1;var e=Lt();_c=r;function r(n,i,o){e.isArray(i)||(i=[i]);var s=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],l={};return e.each(i,function(c){if(!n.hasNode(c))throw new Error("Graph does not have node: "+c);t(n,c,o==="post",l,s,a)}),a}function t(n,i,o,s,a,l){e.has(s,i)||(s[i]=!0,o||l.push(i),e.each(a(i),function(c){t(n,c,o,s,a,l)}),o&&l.push(i))}return _c}var Ec,Ng;function QC(){if(Ng)return Ec;Ng=1;var e=kv();Ec=r;function r(t,n){return e(t,n,"post")}return Ec}var Rc,$g;function eS(){if($g)return Rc;$g=1;var e=kv();Rc=r;function r(t,n){return e(t,n,"pre")}return Rc}var kc,qg;function tS(){if(qg)return kc;qg=1;var e=Lt(),r=Kd(),t=jv();kc=n;function n(i,o){var s=new r,a={},l=new t,c;function d(h){var p=h.v===c?h.w:h.v,y=l.priority(p);if(y!==void 0){var m=o(h);m<y&&(a[p]=c,l.decrease(p,m))}}if(i.nodeCount()===0)return s;e.each(i.nodes(),function(h){l.add(h,Number.POSITIVE_INFINITY),s.setNode(h)}),l.decrease(i.nodes()[0],0);for(var u=!1;l.size()>0;){if(c=l.removeMin(),e.has(a,c))s.setEdge(c,a[c]);else{if(u)throw new Error("Input graph is not connected: "+i);u=!0}i.nodeEdges(c).forEach(d)}return s}return kc}var Ac,Lg;function rS(){return Lg||(Lg=1,Ac={components:KC(),dijkstra:_v(),dijkstraAll:JC(),findCycles:ZC(),floydWarshall:XC(),isAcyclic:YC(),postorder:QC(),preorder:eS(),prim:tS(),tarjan:Ev(),topsort:Rv()}),Ac}var Pc,Fg;function nS(){if(Fg)return Pc;Fg=1;var e=UC();return Pc={Graph:e.Graph,json:HC(),alg:rS(),version:e.version},Pc}var Ic,zg;function Bt(){if(zg)return Ic;zg=1;var e;if(typeof Md=="function")try{e=nS()}catch{}return e||(e=window.graphlib),Ic=e,Ic}var Mc,Bg;function oS(){if(Bg)return Mc;Bg=1;var e=Qb(),r=1,t=4;function n(i){return e(i,r|t)}return Mc=n,Mc}var Tc,Dg;function _o(){if(Dg)return Tc;Dg=1;var e=Jr(),r=Qt(),t=yo(),n=qt();function i(o,s,a){if(!n(a))return!1;var l=typeof s;return(l=="number"?r(a)&&t(s,a.length):l=="string"&&s in a)?e(a[s],o):!1}return Tc=i,Tc}var Oc,Vg;function iS(){if(Vg)return Oc;Vg=1;var e=jo(),r=Jr(),t=_o(),n=Ar(),i=Object.prototype,o=i.hasOwnProperty,s=e(function(a,l){a=Object(a);var c=-1,d=l.length,u=d>2?l[2]:void 0;for(u&&t(l[0],l[1],u)&&(d=1);++c<d;)for(var h=l[c],p=n(h),y=-1,m=p.length;++y<m;){var g=p[y],b=a[g];(b===void 0||r(b,i[g])&&!o.call(a,g))&&(a[g]=h[g])}return a});return Oc=s,Oc}var Nc,Wg;function aS(){if(Wg)return Nc;Wg=1;var e=er(),r=Qt(),t=pr();function n(i){return function(o,s,a){var l=Object(o);if(!r(o)){var c=e(s,3);o=t(o),s=function(u){return c(l[u],u,l)}}var d=i(o,s,a);return d>-1?l[c?o[d]:d]:void 0}}return Nc=n,Nc}var $c,Gg;function sS(){if(Gg)return $c;Gg=1;var e=/\s/;function r(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}return $c=r,$c}var qc,Ug;function cS(){if(Ug)return qc;Ug=1;var e=sS(),r=/^\s+/;function t(n){return n&&n.slice(0,e(n)+1).replace(r,"")}return qc=t,qc}var Lc,Hg;function lS(){if(Hg)return Lc;Hg=1;var e=cS(),r=qt(),t=Qr(),n=NaN,i=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt;function l(c){if(typeof c=="number")return c;if(t(c))return n;if(r(c)){var d=typeof c.valueOf=="function"?c.valueOf():c;c=r(d)?d+"":d}if(typeof c!="string")return c===0?c:+c;c=e(c);var u=o.test(c);return u||s.test(c)?a(c.slice(2),u?2:8):i.test(c)?n:+c}return Lc=l,Lc}var Fc,Kg;function Av(){if(Kg)return Fc;Kg=1;var e=lS(),r=1/0,t=17976931348623157e292;function n(i){if(!i)return i===0?i:0;if(i=e(i),i===r||i===-r){var o=i<0?-1:1;return o*t}return i===i?i:0}return Fc=n,Fc}var zc,Jg;function dS(){if(Jg)return zc;Jg=1;var e=Av();function r(t){var n=e(t),i=n%1;return n===n?i?n-i:n:0}return zc=r,zc}var Bc,Zg;function uS(){if(Zg)return Bc;Zg=1;var e=wv(),r=er(),t=dS(),n=Math.max;function i(o,s,a){var l=o==null?0:o.length;if(!l)return-1;var c=a==null?0:t(a);return c<0&&(c=n(l+c,0)),e(o,r(s,3),c)}return Bc=i,Bc}var Dc,Xg;function fS(){if(Xg)return Dc;Xg=1;var e=aS(),r=uS(),t=e(r);return Dc=t,Dc}var Vc,Yg;function Pv(){if(Yg)return Vc;Yg=1;var e=Hd();function r(t){var n=t==null?0:t.length;return n?e(t,1):[]}return Vc=r,Vc}var Wc,Qg;function hS(){if(Qg)return Wc;Qg=1;var e=Vd(),r=ev(),t=Ar();function n(i,o){return i==null?i:e(i,r(o),t)}return Wc=n,Wc}var Gc,ey;function pS(){if(ey)return Gc;ey=1;function e(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}return Gc=e,Gc}var Uc,ty;function gS(){if(ty)return Uc;ty=1;var e=po(),r=Wd(),t=er();function n(i,o){var s={};return o=t(o,3),r(i,function(a,l,c){e(s,l,o(a,l,c))}),s}return Uc=n,Uc}var Hc,ry;function Jd(){if(ry)return Hc;ry=1;var e=Qr();function r(t,n,i){for(var o=-1,s=t.length;++o<s;){var a=t[o],l=n(a);if(l!=null&&(c===void 0?l===l&&!e(l):i(l,c)))var c=l,d=a}return d}return Hc=r,Hc}var Kc,ny;function yS(){if(ny)return Kc;ny=1;function e(r,t){return r>t}return Kc=e,Kc}var Jc,oy;function mS(){if(oy)return Jc;oy=1;var e=Jd(),r=yS(),t=Pr();function n(i){return i&&i.length?e(i,t,r):void 0}return Jc=n,Jc}var Zc,iy;function Iv(){if(iy)return Zc;iy=1;var e=po(),r=Jr();function t(n,i,o){(o!==void 0&&!r(n[i],o)||o===void 0&&!(i in n))&&e(n,i,o)}return Zc=t,Zc}var Xc,ay;function bS(){if(ay)return Xc;ay=1;var e=Rr(),r=vo(),t=Kt(),n="[object Object]",i=Function.prototype,o=Object.prototype,s=i.toString,a=o.hasOwnProperty,l=s.call(Object);function c(d){if(!t(d)||e(d)!=n)return!1;var u=r(d);if(u===null)return!0;var h=a.call(u,"constructor")&&u.constructor;return typeof h=="function"&&h instanceof h&&s.call(h)==l}return Xc=c,Xc}var Yc,sy;function Mv(){if(sy)return Yc;sy=1;function e(r,t){if(!(t==="constructor"&&typeof r[t]=="function")&&t!="__proto__")return r[t]}return Yc=e,Yc}var Qc,cy;function vS(){if(cy)return Qc;cy=1;var e=Mn(),r=Ar();function t(n){return e(n,r(n))}return Qc=t,Qc}var el,ly;function xS(){if(ly)return el;ly=1;var e=Iv(),r=Bb(),t=Zb(),n=Db(),i=Yb(),o=Tn(),s=pt(),a=Cv(),l=Xr(),c=In(),d=qt(),u=bS(),h=On(),p=Mv(),y=vS();function m(g,b,v,x,w,C,S){var _=p(g,v),R=p(b,v),A=S.get(R);if(A){e(g,v,A);return}var O=C?C(_,R,v+"",g,b,S):void 0,T=O===void 0;if(T){var E=s(R),M=!E&&l(R),P=!E&&!M&&h(R);O=R,E||M||P?s(_)?O=_:a(_)?O=n(_):M?(T=!1,O=r(R,!0)):P?(T=!1,O=t(R,!0)):O=[]:u(R)||o(R)?(O=_,o(_)?O=y(_):(!d(_)||c(_))&&(O=i(R))):T=!1}T&&(S.set(R,O),w(O,R,x,C,S),S.delete(R)),e(g,v,O)}return el=m,el}var tl,dy;function wS(){if(dy)return tl;dy=1;var e=ho(),r=Iv(),t=Vd(),n=xS(),i=qt(),o=Ar(),s=Mv();function a(l,c,d,u,h){l!==c&&t(c,function(p,y){if(h||(h=new e),i(p))n(l,c,y,d,a,u,h);else{var m=u?u(s(l,y),p,y+"",l,c,h):void 0;m===void 0&&(m=p),r(l,y,m)}},o)}return tl=a,tl}var rl,uy;function CS(){if(uy)return rl;uy=1;var e=jo(),r=_o();function t(n){return e(function(i,o){var s=-1,a=o.length,l=a>1?o[a-1]:void 0,c=a>2?o[2]:void 0;for(l=n.length>3&&typeof l=="function"?(a--,l):void 0,c&&r(o[0],o[1],c)&&(l=a<3?void 0:l,a=1),i=Object(i);++s<a;){var d=o[s];d&&n(i,d,s,l)}return i})}return rl=t,rl}var nl,fy;function SS(){if(fy)return nl;fy=1;var e=wS(),r=CS(),t=r(function(n,i,o){e(n,i,o)});return nl=t,nl}var ol,hy;function Tv(){if(hy)return ol;hy=1;function e(r,t){return r<t}return ol=e,ol}var il,py;function jS(){if(py)return il;py=1;var e=Jd(),r=Tv(),t=Pr();function n(i){return i&&i.length?e(i,t,r):void 0}return il=n,il}var al,gy;function _S(){if(gy)return al;gy=1;var e=Jd(),r=er(),t=Tv();function n(i,o){return i&&i.length?e(i,r(o,2),t):void 0}return al=n,al}var sl,yy;function ES(){if(yy)return sl;yy=1;var e=Dt(),r=function(){return e.Date.now()};return sl=r,sl}var cl,my;function RS(){if(my)return cl;my=1;var e=go(),r=Co(),t=yo(),n=qt(),i=Nn();function o(s,a,l,c){if(!n(s))return s;a=r(a,s);for(var d=-1,u=a.length,h=u-1,p=s;p!=null&&++d<u;){var y=i(a[d]),m=l;if(y==="__proto__"||y==="constructor"||y==="prototype")return s;if(d!=h){var g=p[y];m=c?c(g,y,p):void 0,m===void 0&&(m=n(g)?g:t(a[d+1])?[]:{})}e(p,y,m),p=p[y]}return s}return cl=o,cl}var ll,by;function kS(){if(by)return ll;by=1;var e=So(),r=RS(),t=Co();function n(i,o,s){for(var a=-1,l=o.length,c={};++a<l;){var d=o[a],u=e(i,d);s(u,d)&&r(c,t(d,i),u)}return c}return ll=n,ll}var dl,vy;function AS(){if(vy)return dl;vy=1;var e=kS(),r=uv();function t(n,i){return e(n,i,function(o,s){return r(n,s)})}return dl=t,dl}var ul,xy;function PS(){if(xy)return ul;xy=1;var e=Pv(),r=vv(),t=xv();function n(i){return t(r(i,void 0,e),i+"")}return ul=n,ul}var fl,wy;function IS(){if(wy)return fl;wy=1;var e=AS(),r=PS(),t=r(function(n,i){return n==null?{}:e(n,i)});return fl=t,fl}var hl,Cy;function MS(){if(Cy)return hl;Cy=1;var e=Math.ceil,r=Math.max;function t(n,i,o,s){for(var a=-1,l=r(e((i-n)/(o||1)),0),c=Array(l);l--;)c[s?l:++a]=n,n+=o;return c}return hl=t,hl}var pl,Sy;function TS(){if(Sy)return pl;Sy=1;var e=MS(),r=_o(),t=Av();function n(i){return function(o,s,a){return a&&typeof a!="number"&&r(o,s,a)&&(s=a=void 0),o=t(o),s===void 0?(s=o,o=0):s=t(s),a=a===void 0?o<s?1:-1:t(a),e(o,s,a,i)}}return pl=n,pl}var gl,jy;function OS(){if(jy)return gl;jy=1;var e=TS(),r=e();return gl=r,gl}var yl,_y;function NS(){if(_y)return yl;_y=1;function e(r,t){var n=r.length;for(r.sort(t);n--;)r[n]=r[n].value;return r}return yl=e,yl}var ml,Ey;function $S(){if(Ey)return ml;Ey=1;var e=Qr();function r(t,n){if(t!==n){var i=t!==void 0,o=t===null,s=t===t,a=e(t),l=n!==void 0,c=n===null,d=n===n,u=e(n);if(!c&&!u&&!a&&t>n||a&&l&&d&&!c&&!u||o&&l&&d||!i&&d||!s)return 1;if(!o&&!a&&!u&&t<n||u&&i&&s&&!o&&!a||c&&i&&s||!l&&s||!d)return-1}return 0}return ml=r,ml}var bl,Ry;function qS(){if(Ry)return bl;Ry=1;var e=$S();function r(t,n,i){for(var o=-1,s=t.criteria,a=n.criteria,l=s.length,c=i.length;++o<l;){var d=e(s[o],a[o]);if(d){if(o>=c)return d;var u=i[o];return d*(u=="desc"?-1:1)}}return t.index-n.index}return bl=r,bl}var vl,ky;function LS(){if(ky)return vl;ky=1;var e=wo(),r=So(),t=er(),n=yv(),i=NS(),o=mo(),s=qS(),a=Pr(),l=pt();function c(d,u,h){u.length?u=e(u,function(m){return l(m)?function(g){return r(g,m.length===1?m[0]:m)}:m}):u=[a];var p=-1;u=e(u,o(t));var y=n(d,function(m,g,b){var v=e(u,function(x){return x(m)});return{criteria:v,index:++p,value:m}});return i(y,function(m,g){return s(m,g,h)})}return vl=c,vl}var xl,Ay;function FS(){if(Ay)return xl;Ay=1;var e=Hd(),r=LS(),t=jo(),n=_o(),i=t(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]]),r(o,e(s,1),[])});return xl=i,xl}var wl,Py;function zS(){if(Py)return wl;Py=1;var e=lv(),r=0;function t(n){var i=++r;return e(n)+i}return wl=t,wl}var Cl,Iy;function BS(){if(Iy)return Cl;Iy=1;function e(r,t,n){for(var i=-1,o=r.length,s=t.length,a={};++i<o;){var l=i<s?t[i]:void 0;n(a,r[i],l)}return a}return Cl=e,Cl}var Sl,My;function DS(){if(My)return Sl;My=1;var e=go(),r=BS();function t(n,i){return r(n||[],i||[],e)}return Sl=t,Sl}var jl,Ty;function st(){if(Ty)return jl;Ty=1;var e;if(typeof Md=="function")try{e={cloneDeep:oS(),constant:Dd(),defaults:iS(),each:rv(),filter:hv(),find:fS(),flatten:Pv(),forEach:tv(),forIn:hS(),has:pv(),isUndefined:gv(),last:pS(),map:mv(),mapValues:gS(),max:mS(),merge:SS(),min:jS(),minBy:_S(),now:ES(),pick:IS(),range:OS(),reduce:bv(),sortBy:FS(),uniqueId:zS(),values:Sv(),zipObject:DS()}}catch{}return e||(e=window._),jl=e,jl}var _l,Oy;function VS(){if(Oy)return _l;Oy=1,_l=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 r(i),i},e.prototype.enqueue=function(n){var i=this._sentinel;n._prev&&n._next&&r(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,t)),o=o._prev;return"["+n.join(", ")+"]"};function r(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function t(n,i){if(n!=="_next"&&n!=="_prev")return i}return _l}var El,Ny;function WS(){if(Ny)return El;Ny=1;var e=st(),r=Bt().Graph,t=VS();El=i;var n=e.constant(1);function i(c,d){if(c.nodeCount()<=1)return[];var u=a(c,d||n),h=o(u.graph,u.buckets,u.zeroIdx);return e.flatten(e.map(h,function(p){return c.outEdges(p.v,p.w)}),!0)}function o(c,d,u){for(var h=[],p=d[d.length-1],y=d[0],m;c.nodeCount();){for(;m=y.dequeue();)s(c,d,u,m);for(;m=p.dequeue();)s(c,d,u,m);if(c.nodeCount()){for(var g=d.length-2;g>0;--g)if(m=d[g].dequeue(),m){h=h.concat(s(c,d,u,m,!0));break}}}return h}function s(c,d,u,h,p){var y=p?[]:void 0;return e.forEach(c.inEdges(h.v),function(m){var g=c.edge(m),b=c.node(m.v);p&&y.push({v:m.v,w:m.w}),b.out-=g,l(d,u,b)}),e.forEach(c.outEdges(h.v),function(m){var g=c.edge(m),b=m.w,v=c.node(b);v.in-=g,l(d,u,v)}),c.removeNode(h.v),y}function a(c,d){var u=new r,h=0,p=0;e.forEach(c.nodes(),function(g){u.setNode(g,{v:g,in:0,out:0})}),e.forEach(c.edges(),function(g){var b=u.edge(g.v,g.w)||0,v=d(g),x=b+v;u.setEdge(g.v,g.w,x),p=Math.max(p,u.node(g.v).out+=v),h=Math.max(h,u.node(g.w).in+=v)});var y=e.range(p+h+3).map(function(){return new t}),m=h+1;return e.forEach(u.nodes(),function(g){l(y,m,u.node(g))}),{graph:u,buckets:y,zeroIdx:m}}function l(c,d,u){u.out?u.in?c[u.out-u.in+d].enqueue(u):c[c.length-1].enqueue(u):c[0].enqueue(u)}return El}var Rl,$y;function GS(){if($y)return Rl;$y=1;var e=st(),r=WS();Rl={run:t,undo:i};function t(o){var s=o.graph().acyclicer==="greedy"?r(o,a(o)):n(o);e.forEach(s,function(l){var c=o.edge(l);o.removeEdge(l),c.forwardName=l.name,c.reversed=!0,o.setEdge(l.w,l.v,c,e.uniqueId("rev"))});function a(l){return function(c){return l.edge(c).weight}}}function n(o){var s=[],a={},l={};function c(d){e.has(l,d)||(l[d]=!0,a[d]=!0,e.forEach(o.outEdges(d),function(u){e.has(a,u.w)?s.push(u):c(u.w)}),delete a[d])}return e.forEach(o.nodes(),c),s}function i(o){e.forEach(o.edges(),function(s){var a=o.edge(s);if(a.reversed){o.removeEdge(s);var l=a.forwardName;delete a.reversed,delete a.forwardName,o.setEdge(s.w,s.v,a,l)}})}return Rl}var kl,qy;function At(){if(qy)return kl;qy=1;var e=st(),r=Bt().Graph;kl={addDummyNode:t,simplify:n,asNonCompoundGraph:i,successorWeights:o,predecessorWeights:s,intersectRect:a,buildLayerMatrix:l,normalizeRanks:c,removeEmptyRanks:d,addBorderNode:u,maxRank:h,partition:p,time:y,notime:m};function t(g,b,v,x){var w;do w=e.uniqueId(x);while(g.hasNode(w));return v.dummy=b,g.setNode(w,v),w}function n(g){var b=new r().setGraph(g.graph());return e.forEach(g.nodes(),function(v){b.setNode(v,g.node(v))}),e.forEach(g.edges(),function(v){var x=b.edge(v.v,v.w)||{weight:0,minlen:1},w=g.edge(v);b.setEdge(v.v,v.w,{weight:x.weight+w.weight,minlen:Math.max(x.minlen,w.minlen)})}),b}function i(g){var b=new r({multigraph:g.isMultigraph()}).setGraph(g.graph());return e.forEach(g.nodes(),function(v){g.children(v).length||b.setNode(v,g.node(v))}),e.forEach(g.edges(),function(v){b.setEdge(v,g.edge(v))}),b}function o(g){var b=e.map(g.nodes(),function(v){var x={};return e.forEach(g.outEdges(v),function(w){x[w.w]=(x[w.w]||0)+g.edge(w).weight}),x});return e.zipObject(g.nodes(),b)}function s(g){var b=e.map(g.nodes(),function(v){var x={};return e.forEach(g.inEdges(v),function(w){x[w.v]=(x[w.v]||0)+g.edge(w).weight}),x});return e.zipObject(g.nodes(),b)}function a(g,b){var v=g.x,x=g.y,w=b.x-v,C=b.y-x,S=g.width/2,_=g.height/2;if(!w&&!C)throw new Error("Not possible to find intersection inside of the rectangle");var R,A;return Math.abs(C)*S>Math.abs(w)*_?(C<0&&(_=-_),R=_*w/C,A=_):(w<0&&(S=-S),R=S,A=S*C/w),{x:v+R,y:x+A}}function l(g){var b=e.map(e.range(h(g)+1),function(){return[]});return e.forEach(g.nodes(),function(v){var x=g.node(v),w=x.rank;e.isUndefined(w)||(b[w][x.order]=v)}),b}function c(g){var b=e.min(e.map(g.nodes(),function(v){return g.node(v).rank}));e.forEach(g.nodes(),function(v){var x=g.node(v);e.has(x,"rank")&&(x.rank-=b)})}function d(g){var b=e.min(e.map(g.nodes(),function(C){return g.node(C).rank})),v=[];e.forEach(g.nodes(),function(C){var S=g.node(C).rank-b;v[S]||(v[S]=[]),v[S].push(C)});var x=0,w=g.graph().nodeRankFactor;e.forEach(v,function(C,S){e.isUndefined(C)&&S%w!==0?--x:x&&e.forEach(C,function(_){g.node(_).rank+=x})})}function u(g,b,v,x){var w={width:0,height:0};return arguments.length>=4&&(w.rank=v,w.order=x),t(g,"border",w,b)}function h(g){return e.max(e.map(g.nodes(),function(b){var v=g.node(b).rank;if(!e.isUndefined(v))return v}))}function p(g,b){var v={lhs:[],rhs:[]};return e.forEach(g,function(x){b(x)?v.lhs.push(x):v.rhs.push(x)}),v}function y(g,b){var v=e.now();try{return b()}finally{console.log(g+" time: "+(e.now()-v)+"ms")}}function m(g,b){return b()}return kl}var Al,Ly;function US(){if(Ly)return Al;Ly=1;var e=st(),r=At();Al={run:t,undo:i};function t(o){o.graph().dummyChains=[],e.forEach(o.edges(),function(s){n(o,s)})}function n(o,s){var a=s.v,l=o.node(a).rank,c=s.w,d=o.node(c).rank,u=s.name,h=o.edge(s),p=h.labelRank;if(d!==l+1){o.removeEdge(s);var y,m,g;for(g=0,++l;l<d;++g,++l)h.points=[],m={width:0,height:0,edgeLabel:h,edgeObj:s,rank:l},y=r.addDummyNode(o,"edge",m,"_d"),l===p&&(m.width=h.width,m.height=h.height,m.dummy="edge-label",m.labelpos=h.labelpos),o.setEdge(a,y,{weight:h.weight},u),g===0&&o.graph().dummyChains.push(y),a=y;o.setEdge(a,c,{weight:h.weight},u)}}function i(o){e.forEach(o.graph().dummyChains,function(s){var a=o.node(s),l=a.edgeLabel,c;for(o.setEdge(a.edgeObj,l);a.dummy;)c=o.successors(s)[0],o.removeNode(s),l.points.push({x:a.x,y:a.y}),a.dummy==="edge-label"&&(l.x=a.x,l.y=a.y,l.width=a.width,l.height=a.height),s=c,a=o.node(s)})}return Al}var Pl,Fy;function Yn(){if(Fy)return Pl;Fy=1;var e=st();Pl={longestPath:r,slack:t};function r(n){var i={};function o(s){var a=n.node(s);if(e.has(i,s))return a.rank;i[s]=!0;var l=e.min(e.map(n.outEdges(s),function(c){return o(c.w)-n.edge(c).minlen}));return(l===Number.POSITIVE_INFINITY||l===void 0||l===null)&&(l=0),a.rank=l}e.forEach(n.sources(),o)}function t(n,i){return n.node(i.w).rank-n.node(i.v).rank-n.edge(i).minlen}return Pl}var Il,zy;function Ov(){if(zy)return Il;zy=1;var e=st(),r=Bt().Graph,t=Yn().slack;Il=n;function n(a){var l=new r({directed:!1}),c=a.nodes()[0],d=a.nodeCount();l.setNode(c,{});for(var u,h;i(l,a)<d;)u=o(l,a),h=l.hasNode(u.v)?t(a,u):-t(a,u),s(l,a,h);return l}function i(a,l){function c(d){e.forEach(l.nodeEdges(d),function(u){var h=u.v,p=d===h?u.w:h;!a.hasNode(p)&&!t(l,u)&&(a.setNode(p,{}),a.setEdge(d,p,{}),c(p))})}return e.forEach(a.nodes(),c),a.nodeCount()}function o(a,l){return e.minBy(l.edges(),function(c){if(a.hasNode(c.v)!==a.hasNode(c.w))return t(l,c)})}function s(a,l,c){e.forEach(a.nodes(),function(d){l.node(d).rank+=c})}return Il}var Ml,By;function HS(){if(By)return Ml;By=1;var e=st(),r=Ov(),t=Yn().slack,n=Yn().longestPath,i=Bt().alg.preorder,o=Bt().alg.postorder,s=At().simplify;Ml=a,a.initLowLimValues=u,a.initCutValues=l,a.calcCutValue=d,a.leaveEdge=p,a.enterEdge=y,a.exchangeEdges=m;function a(x){x=s(x),n(x);var w=r(x);u(w),l(w,x);for(var C,S;C=p(w);)S=y(w,x,C),m(w,x,C,S)}function l(x,w){var C=o(x,x.nodes());C=C.slice(0,C.length-1),e.forEach(C,function(S){c(x,w,S)})}function c(x,w,C){var S=x.node(C),_=S.parent;x.edge(C,_).cutvalue=d(x,w,C)}function d(x,w,C){var S=x.node(C),_=S.parent,R=!0,A=w.edge(C,_),O=0;return A||(R=!1,A=w.edge(_,C)),O=A.weight,e.forEach(w.nodeEdges(C),function(T){var E=T.v===C,M=E?T.w:T.v;if(M!==_){var P=E===R,$=w.edge(T).weight;if(O+=P?$:-$,b(x,C,M)){var N=x.edge(C,M).cutvalue;O+=P?-N:N}}}),O}function u(x,w){arguments.length<2&&(w=x.nodes()[0]),h(x,{},1,w)}function h(x,w,C,S,_){var R=C,A=x.node(S);return w[S]=!0,e.forEach(x.neighbors(S),function(O){e.has(w,O)||(C=h(x,w,C,O,S))}),A.low=R,A.lim=C++,_?A.parent=_:delete A.parent,C}function p(x){return e.find(x.edges(),function(w){return x.edge(w).cutvalue<0})}function y(x,w,C){var S=C.v,_=C.w;w.hasEdge(S,_)||(S=C.w,_=C.v);var R=x.node(S),A=x.node(_),O=R,T=!1;R.lim>A.lim&&(O=A,T=!0);var E=e.filter(w.edges(),function(M){return T===v(x,x.node(M.v),O)&&T!==v(x,x.node(M.w),O)});return e.minBy(E,function(M){return t(w,M)})}function m(x,w,C,S){var _=C.v,R=C.w;x.removeEdge(_,R),x.setEdge(S.v,S.w,{}),u(x),l(x,w),g(x,w)}function g(x,w){var C=e.find(x.nodes(),function(_){return!w.node(_).parent}),S=i(x,C);S=S.slice(1),e.forEach(S,function(_){var R=x.node(_).parent,A=w.edge(_,R),O=!1;A||(A=w.edge(R,_),O=!0),w.node(_).rank=w.node(R).rank+(O?A.minlen:-A.minlen)})}function b(x,w,C){return x.hasEdge(w,C)}function v(x,w,C){return C.low<=w.lim&&w.lim<=C.lim}return Ml}var Tl,Dy;function KS(){if(Dy)return Tl;Dy=1;var e=Yn(),r=e.longestPath,t=Ov(),n=HS();Tl=i;function i(l){switch(l.graph().ranker){case"network-simplex":a(l);break;case"tight-tree":s(l);break;case"longest-path":o(l);break;default:a(l)}}var o=r;function s(l){r(l),t(l)}function a(l){n(l)}return Tl}var Ol,Vy;function JS(){if(Vy)return Ol;Vy=1;var e=st();Ol=r;function r(i){var o=n(i);e.forEach(i.graph().dummyChains,function(s){for(var a=i.node(s),l=a.edgeObj,c=t(i,o,l.v,l.w),d=c.path,u=c.lca,h=0,p=d[h],y=!0;s!==l.w;){if(a=i.node(s),y){for(;(p=d[h])!==u&&i.node(p).maxRank<a.rank;)h++;p===u&&(y=!1)}if(!y){for(;h<d.length-1&&i.node(p=d[h+1]).minRank<=a.rank;)h++;p=d[h]}i.setParent(s,p),s=i.successors(s)[0]}})}function t(i,o,s,a){var l=[],c=[],d=Math.min(o[s].low,o[a].low),u=Math.max(o[s].lim,o[a].lim),h,p;h=s;do h=i.parent(h),l.push(h);while(h&&(o[h].low>d||u>o[h].lim));for(p=h,h=a;(h=i.parent(h))!==p;)c.push(h);return{path:l.concat(c.reverse()),lca:p}}function n(i){var o={},s=0;function a(l){var c=s;e.forEach(i.children(l),a),o[l]={low:c,lim:s++}}return e.forEach(i.children(),a),o}return Ol}var Nl,Wy;function ZS(){if(Wy)return Nl;Wy=1;var e=st(),r=At();Nl={run:t,cleanup:s};function t(a){var l=r.addDummyNode(a,"root",{},"_root"),c=i(a),d=e.max(e.values(c))-1,u=2*d+1;a.graph().nestingRoot=l,e.forEach(a.edges(),function(p){a.edge(p).minlen*=u});var h=o(a)+1;e.forEach(a.children(),function(p){n(a,l,u,h,d,c,p)}),a.graph().nodeRankFactor=u}function n(a,l,c,d,u,h,p){var y=a.children(p);if(!y.length){p!==l&&a.setEdge(l,p,{weight:0,minlen:c});return}var m=r.addBorderNode(a,"_bt"),g=r.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(v){n(a,l,c,d,u,h,v);var x=a.node(v),w=x.borderTop?x.borderTop:v,C=x.borderBottom?x.borderBottom:v,S=x.borderTop?d:2*d,_=w!==C?1:u-h[p]+1;a.setEdge(m,w,{weight:S,minlen:_,nestingEdge:!0}),a.setEdge(C,g,{weight:S,minlen:_,nestingEdge:!0})}),a.parent(p)||a.setEdge(l,m,{weight:0,minlen:u+h[p]})}function i(a){var l={};function c(d,u){var h=a.children(d);h&&h.length&&e.forEach(h,function(p){c(p,u+1)}),l[d]=u}return e.forEach(a.children(),function(d){c(d,1)}),l}function o(a){return e.reduce(a.edges(),function(l,c){return l+a.edge(c).weight},0)}function s(a){var l=a.graph();a.removeNode(l.nestingRoot),delete l.nestingRoot,e.forEach(a.edges(),function(c){var d=a.edge(c);d.nestingEdge&&a.removeEdge(c)})}return Nl}var $l,Gy;function XS(){if(Gy)return $l;Gy=1;var e=st(),r=At();$l=t;function t(i){function o(s){var a=i.children(s),l=i.node(s);if(a.length&&e.forEach(a,o),e.has(l,"minRank")){l.borderLeft=[],l.borderRight=[];for(var c=l.minRank,d=l.maxRank+1;c<d;++c)n(i,"borderLeft","_bl",s,l,c),n(i,"borderRight","_br",s,l,c)}}e.forEach(i.children(),o)}function n(i,o,s,a,l,c){var d={width:0,height:0,rank:c,borderType:o},u=l[o][c-1],h=r.addDummyNode(i,"border",d,s);l[o][c]=h,i.setParent(h,a),u&&i.setEdge(u,h,{weight:1})}return $l}var ql,Uy;function YS(){if(Uy)return ql;Uy=1;var e=st();ql={adjust:r,undo:t};function r(c){var d=c.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&n(c)}function t(c){var d=c.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&o(c),(d==="lr"||d==="rl")&&(a(c),n(c))}function n(c){e.forEach(c.nodes(),function(d){i(c.node(d))}),e.forEach(c.edges(),function(d){i(c.edge(d))})}function i(c){var d=c.width;c.width=c.height,c.height=d}function o(c){e.forEach(c.nodes(),function(d){s(c.node(d))}),e.forEach(c.edges(),function(d){var u=c.edge(d);e.forEach(u.points,s),e.has(u,"y")&&s(u)})}function s(c){c.y=-c.y}function a(c){e.forEach(c.nodes(),function(d){l(c.node(d))}),e.forEach(c.edges(),function(d){var u=c.edge(d);e.forEach(u.points,l),e.has(u,"x")&&l(u)})}function l(c){var d=c.x;c.x=c.y,c.y=d}return ql}var Ll,Hy;function QS(){if(Hy)return Ll;Hy=1;var e=st();Ll=r;function r(t){var n={},i=e.filter(t.nodes(),function(c){return!t.children(c).length}),o=e.max(e.map(i,function(c){return t.node(c).rank})),s=e.map(e.range(o+1),function(){return[]});function a(c){if(!e.has(n,c)){n[c]=!0;var d=t.node(c);s[d.rank].push(c),e.forEach(t.successors(c),a)}}var l=e.sortBy(i,function(c){return t.node(c).rank});return e.forEach(l,a),s}return Ll}var Fl,Ky;function ej(){if(Ky)return Fl;Ky=1;var e=st();Fl=r;function r(n,i){for(var o=0,s=1;s<i.length;++s)o+=t(n,i[s-1],i[s]);return o}function t(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),l=1;l<o.length;)l<<=1;var c=2*l-1;l-=1;var d=e.map(new Array(c),function(){return 0}),u=0;return e.forEach(a.forEach(function(h){var p=h.pos+l;d[p]+=h.weight;for(var y=0;p>0;)p%2&&(y+=d[p+1]),p=p-1>>1,d[p]+=h.weight;u+=h.weight*y})),u}return Fl}var zl,Jy;function tj(){if(Jy)return zl;Jy=1;var e=st();zl=r;function r(t,n){return e.map(n,function(i){var o=t.inEdges(i);if(o.length){var s=e.reduce(o,function(a,l){var c=t.edge(l),d=t.node(l.v);return{sum:a.sum+c.weight*d.order,weight:a.weight+c.weight}},{sum:0,weight:0});return{v:i,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:i}})}return zl}var Bl,Zy;function rj(){if(Zy)return Bl;Zy=1;var e=st();Bl=r;function r(i,o){var s={};e.forEach(i,function(l,c){var d=s[l.v]={indegree:0,in:[],out:[],vs:[l.v],i:c};e.isUndefined(l.barycenter)||(d.barycenter=l.barycenter,d.weight=l.weight)}),e.forEach(o.edges(),function(l){var c=s[l.v],d=s[l.w];!e.isUndefined(c)&&!e.isUndefined(d)&&(d.indegree++,c.out.push(s[l.w]))});var a=e.filter(s,function(l){return!l.indegree});return t(a)}function t(i){var o=[];function s(c){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(c.barycenter)||d.barycenter>=c.barycenter)&&n(c,d)}}function a(c){return function(d){d.in.push(c),--d.indegree===0&&i.push(d)}}for(;i.length;){var l=i.pop();o.push(l),e.forEach(l.in.reverse(),s(l)),e.forEach(l.out,a(l))}return e.map(e.filter(o,function(c){return!c.merged}),function(c){return e.pick(c,["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 Bl}var Dl,Xy;function nj(){if(Xy)return Dl;Xy=1;var e=st(),r=At();Dl=t;function t(o,s){var a=r.partition(o,function(m){return e.has(m,"barycenter")}),l=a.lhs,c=e.sortBy(a.rhs,function(m){return-m.i}),d=[],u=0,h=0,p=0;l.sort(i(!!s)),p=n(d,c,p),e.forEach(l,function(m){p+=m.vs.length,d.push(m.vs),u+=m.barycenter*m.weight,h+=m.weight,p=n(d,c,p)});var y={vs:e.flatten(d,!0)};return h&&(y.barycenter=u/h,y.weight=h),y}function n(o,s,a){for(var l;s.length&&(l=e.last(s)).i<=a;)s.pop(),o.push(l.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 Dl}var Vl,Yy;function oj(){if(Yy)return Vl;Yy=1;var e=st(),r=tj(),t=rj(),n=nj();Vl=i;function i(a,l,c,d){var u=a.children(l),h=a.node(l),p=h?h.borderLeft:void 0,y=h?h.borderRight:void 0,m={};p&&(u=e.filter(u,function(C){return C!==p&&C!==y}));var g=r(a,u);e.forEach(g,function(C){if(a.children(C.v).length){var S=i(a,C.v,c,d);m[C.v]=S,e.has(S,"barycenter")&&s(C,S)}});var b=t(g,c);o(b,m);var v=n(b,d);if(p&&(v.vs=e.flatten([p,v.vs,y],!0),a.predecessors(p).length)){var x=a.node(a.predecessors(p)[0]),w=a.node(a.predecessors(y)[0]);e.has(v,"barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+x.order+w.order)/(v.weight+2),v.weight+=2}return v}function o(a,l){e.forEach(a,function(c){c.vs=e.flatten(c.vs.map(function(d){return l[d]?l[d].vs:d}),!0)})}function s(a,l){e.isUndefined(a.barycenter)?(a.barycenter=l.barycenter,a.weight=l.weight):(a.barycenter=(a.barycenter*a.weight+l.barycenter*l.weight)/(a.weight+l.weight),a.weight+=l.weight)}return Vl}var Wl,Qy;function ij(){if(Qy)return Wl;Qy=1;var e=st(),r=Bt().Graph;Wl=t;function t(i,o,s){var a=n(i),l=new r({compound:!0}).setGraph({root:a}).setDefaultNodeLabel(function(c){return i.node(c)});return e.forEach(i.nodes(),function(c){var d=i.node(c),u=i.parent(c);(d.rank===o||d.minRank<=o&&o<=d.maxRank)&&(l.setNode(c),l.setParent(c,u||a),e.forEach(i[s](c),function(h){var p=h.v===c?h.w:h.v,y=l.edge(p,c),m=e.isUndefined(y)?0:y.weight;l.setEdge(p,c,{weight:i.edge(h).weight+m})}),e.has(d,"minRank")&&l.setNode(c,{borderLeft:d.borderLeft[o],borderRight:d.borderRight[o]}))}),l}function n(i){for(var o;i.hasNode(o=e.uniqueId("_root")););return o}return Wl}var Gl,em;function aj(){if(em)return Gl;em=1;var e=st();Gl=r;function r(t,n,i){var o={},s;e.forEach(i,function(a){for(var l=t.parent(a),c,d;l;){if(c=t.parent(l),c?(d=o[c],o[c]=l):(d=s,s=l),d&&d!==l){n.setEdge(d,l);return}l=c}})}return Gl}var Ul,tm;function sj(){if(tm)return Ul;tm=1;var e=st(),r=QS(),t=ej(),n=oj(),i=ij(),o=aj(),s=Bt().Graph,a=At();Ul=l;function l(h){var p=a.maxRank(h),y=c(h,e.range(1,p+1),"inEdges"),m=c(h,e.range(p-1,-1,-1),"outEdges"),g=r(h);u(h,g);for(var b=Number.POSITIVE_INFINITY,v,x=0,w=0;w<4;++x,++w){d(x%2?y:m,x%4>=2),g=a.buildLayerMatrix(h);var C=t(h,g);C<b&&(w=0,v=e.cloneDeep(g),b=C)}u(h,v)}function c(h,p,y){return e.map(p,function(m){return i(h,m,y)})}function d(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(v,x){m.node(v).order=x}),o(m,y,b.vs)})}function u(h,p){e.forEach(p,function(y){e.forEach(y,function(m,g){h.node(m).order=g})})}return Ul}var Hl,rm;function cj(){if(rm)return Hl;rm=1;var e=st(),r=Bt().Graph,t=At();Hl={positionX:y,findType1Conflicts:n,findType2Conflicts:i,addConflict:s,hasConflict:a,verticalAlignment:l,horizontalCompaction:c,alignCoordinates:h,findSmallestWidthAlignment:u,balance:p};function n(b,v){var x={};function w(C,S){var _=0,R=0,A=C.length,O=e.last(S);return e.forEach(S,function(T,E){var M=o(b,T),P=M?b.node(M).order:A;(M||T===O)&&(e.forEach(S.slice(R,E+1),function($){e.forEach(b.predecessors($),function(N){var I=b.node(N),K=I.order;(K<_||P<K)&&!(I.dummy&&b.node($).dummy)&&s(x,N,$)})}),R=E+1,_=P)}),S}return e.reduce(v,w),x}function i(b,v){var x={};function w(S,_,R,A,O){var T;e.forEach(e.range(_,R),function(E){T=S[E],b.node(T).dummy&&e.forEach(b.predecessors(T),function(M){var P=b.node(M);P.dummy&&(P.order<A||P.order>O)&&s(x,M,T)})})}function C(S,_){var R=-1,A,O=0;return e.forEach(_,function(T,E){if(b.node(T).dummy==="border"){var M=b.predecessors(T);M.length&&(A=b.node(M[0]).order,w(_,O,E,R,A),O=E,R=A)}w(_,O,_.length,A,S.length)}),_}return e.reduce(v,C),x}function o(b,v){if(b.node(v).dummy)return e.find(b.predecessors(v),function(x){return b.node(x).dummy})}function s(b,v,x){if(v>x){var w=v;v=x,x=w}var C=b[v];C||(b[v]=C={}),C[x]=!0}function a(b,v,x){if(v>x){var w=v;v=x,x=w}return e.has(b[v],x)}function l(b,v,x,w){var C={},S={},_={};return e.forEach(v,function(R){e.forEach(R,function(A,O){C[A]=A,S[A]=A,_[A]=O})}),e.forEach(v,function(R){var A=-1;e.forEach(R,function(O){var T=w(O);if(T.length){T=e.sortBy(T,function(N){return _[N]});for(var E=(T.length-1)/2,M=Math.floor(E),P=Math.ceil(E);M<=P;++M){var $=T[M];S[O]===O&&A<_[$]&&!a(x,O,$)&&(S[$]=O,S[O]=C[O]=C[$],A=_[$])}}})}),{root:C,align:S}}function c(b,v,x,w,C){var S={},_=d(b,v,x,C),R=C?"borderLeft":"borderRight";function A(E,M){for(var P=_.nodes(),$=P.pop(),N={};$;)N[$]?E($):(N[$]=!0,P.push($),P=P.concat(M($))),$=P.pop()}function O(E){S[E]=_.inEdges(E).reduce(function(M,P){return Math.max(M,S[P.v]+_.edge(P))},0)}function T(E){var M=_.outEdges(E).reduce(function($,N){return Math.min($,S[N.w]-_.edge(N))},Number.POSITIVE_INFINITY),P=b.node(E);M!==Number.POSITIVE_INFINITY&&P.borderType!==R&&(S[E]=Math.max(S[E],M))}return A(O,_.predecessors.bind(_)),A(T,_.successors.bind(_)),e.forEach(w,function(E){S[E]=S[x[E]]}),S}function d(b,v,x,w){var C=new r,S=b.graph(),_=m(S.nodesep,S.edgesep,w);return e.forEach(v,function(R){var A;e.forEach(R,function(O){var T=x[O];if(C.setNode(T),A){var E=x[A],M=C.edge(E,T);C.setEdge(E,T,Math.max(_(b,O,A),M||0))}A=O})}),C}function u(b,v){return e.minBy(e.values(v),function(x){var w=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;return e.forIn(x,function(S,_){var R=g(b,_)/2;w=Math.max(S+R,w),C=Math.min(S-R,C)}),w-C})}function h(b,v){var x=e.values(v),w=e.min(x),C=e.max(x);e.forEach(["u","d"],function(S){e.forEach(["l","r"],function(_){var R=S+_,A=b[R],O;if(A!==v){var T=e.values(A);O=_==="l"?w-e.min(T):C-e.max(T),O&&(b[R]=e.mapValues(A,function(E){return E+O}))}})})}function p(b,v){return e.mapValues(b.ul,function(x,w){if(v)return b[v.toLowerCase()][w];var C=e.sortBy(e.map(b,w));return(C[1]+C[2])/2})}function y(b){var v=t.buildLayerMatrix(b),x=e.merge(n(b,v),i(b,v)),w={},C;e.forEach(["u","d"],function(_){C=_==="u"?v:e.values(v).reverse(),e.forEach(["l","r"],function(R){R==="r"&&(C=e.map(C,function(E){return e.values(E).reverse()}));var A=(_==="u"?b.predecessors:b.successors).bind(b),O=l(b,C,x,A),T=c(b,C,O.root,O.align,R==="r");R==="r"&&(T=e.mapValues(T,function(E){return-E})),w[_+R]=T})});var S=u(b,w);return h(w,S),p(w,b.graph().align)}function m(b,v,x){return function(w,C,S){var _=w.node(C),R=w.node(S),A=0,O;if(A+=_.width/2,e.has(_,"labelpos"))switch(_.labelpos.toLowerCase()){case"l":O=-_.width/2;break;case"r":O=_.width/2;break}if(O&&(A+=x?O:-O),O=0,A+=(_.dummy?v:b)/2,A+=(R.dummy?v:b)/2,A+=R.width/2,e.has(R,"labelpos"))switch(R.labelpos.toLowerCase()){case"l":O=R.width/2;break;case"r":O=-R.width/2;break}return O&&(A+=x?O:-O),O=0,A}}function g(b,v){return b.node(v).width}return Hl}var Kl,nm;function lj(){if(nm)return Kl;nm=1;var e=st(),r=At(),t=cj().positionX;Kl=n;function n(o){o=r.asNonCompoundGraph(o),i(o),e.forEach(t(o),function(s,a){o.node(a).x=s})}function i(o){var s=r.buildLayerMatrix(o),a=o.graph().ranksep,l=0;e.forEach(s,function(c){var d=e.max(e.map(c,function(u){return o.node(u).height}));e.forEach(c,function(u){o.node(u).y=l+d/2}),l+=d+a})}return Kl}var Jl,om;function dj(){if(om)return Jl;om=1;var e=st(),r=GS(),t=US(),n=KS(),i=At().normalizeRanks,o=JS(),s=At().removeEmptyRanks,a=ZS(),l=XS(),c=YS(),d=sj(),u=lj(),h=At(),p=Bt().Graph;Jl=y;function y(q,W){var U=W&&W.debugTiming?h.time:h.notime;U("layout",function(){var z=U(" buildLayoutGraph",function(){return A(q)});U(" runLayout",function(){m(z,U)}),U(" updateInputGraph",function(){g(q,z)})})}function m(q,W){W(" makeSpaceForEdgeLabels",function(){O(q)}),W(" removeSelfEdges",function(){le(q)}),W(" acyclic",function(){r.run(q)}),W(" nestingGraph.run",function(){a.run(q)}),W(" rank",function(){n(h.asNonCompoundGraph(q))}),W(" injectEdgeLabelProxies",function(){T(q)}),W(" removeEmptyRanks",function(){s(q)}),W(" nestingGraph.cleanup",function(){a.cleanup(q)}),W(" normalizeRanks",function(){i(q)}),W(" assignRankMinMax",function(){E(q)}),W(" removeEdgeLabelProxies",function(){M(q)}),W(" normalize.run",function(){t.run(q)}),W(" parentDummyChains",function(){o(q)}),W(" addBorderSegments",function(){l(q)}),W(" order",function(){d(q)}),W(" insertSelfEdges",function(){ie(q)}),W(" adjustCoordinateSystem",function(){c.adjust(q)}),W(" position",function(){u(q)}),W(" positionSelfEdges",function(){te(q)}),W(" removeBorderNodes",function(){K(q)}),W(" normalize.undo",function(){t.undo(q)}),W(" fixupEdgeLabelCoords",function(){N(q)}),W(" undoCoordinateSystem",function(){c.undo(q)}),W(" translateGraph",function(){P(q)}),W(" assignNodeIntersects",function(){$(q)}),W(" reversePoints",function(){I(q)}),W(" acyclic.undo",function(){r.undo(q)})}function g(q,W){e.forEach(q.nodes(),function(U){var z=q.node(U),de=W.node(U);z&&(z.x=de.x,z.y=de.y,W.children(U).length&&(z.width=de.width,z.height=de.height))}),e.forEach(q.edges(),function(U){var z=q.edge(U),de=W.edge(U);z.points=de.points,e.has(de,"x")&&(z.x=de.x,z.y=de.y)}),q.graph().width=W.graph().width,q.graph().height=W.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],v={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},x=["acyclicer","ranker","rankdir","align"],w=["width","height"],C={width:0,height:0},S=["minlen","weight","width","height","labeloffset"],_={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},R=["labelpos"];function A(q){var W=new p({multigraph:!0,compound:!0}),U=xe(q.graph());return W.setGraph(e.merge({},v,fe(U,b),e.pick(U,x))),e.forEach(q.nodes(),function(z){var de=xe(q.node(z));W.setNode(z,e.defaults(fe(de,w),C)),W.setParent(z,q.parent(z))}),e.forEach(q.edges(),function(z){var de=xe(q.edge(z));W.setEdge(z,e.merge({},_,fe(de,S),e.pick(de,R)))}),W}function O(q){var W=q.graph();W.ranksep/=2,e.forEach(q.edges(),function(U){var z=q.edge(U);z.minlen*=2,z.labelpos.toLowerCase()!=="c"&&(W.rankdir==="TB"||W.rankdir==="BT"?z.width+=z.labeloffset:z.height+=z.labeloffset)})}function T(q){e.forEach(q.edges(),function(W){var U=q.edge(W);if(U.width&&U.height){var z=q.node(W.v),de=q.node(W.w),Q={rank:(de.rank-z.rank)/2+z.rank,e:W};h.addDummyNode(q,"edge-proxy",Q,"_ep")}})}function E(q){var W=0;e.forEach(q.nodes(),function(U){var z=q.node(U);z.borderTop&&(z.minRank=q.node(z.borderTop).rank,z.maxRank=q.node(z.borderBottom).rank,W=e.max(W,z.maxRank))}),q.graph().maxRank=W}function M(q){e.forEach(q.nodes(),function(W){var U=q.node(W);U.dummy==="edge-proxy"&&(q.edge(U.e).labelRank=U.rank,q.removeNode(W))})}function P(q){var W=Number.POSITIVE_INFINITY,U=0,z=Number.POSITIVE_INFINITY,de=0,Q=q.graph(),ae=Q.marginx||0,se=Q.marginy||0;function Ce(Se){var he=Se.x,G=Se.y,F=Se.width,re=Se.height;W=Math.min(W,he-F/2),U=Math.max(U,he+F/2),z=Math.min(z,G-re/2),de=Math.max(de,G+re/2)}e.forEach(q.nodes(),function(Se){Ce(q.node(Se))}),e.forEach(q.edges(),function(Se){var he=q.edge(Se);e.has(he,"x")&&Ce(he)}),W-=ae,z-=se,e.forEach(q.nodes(),function(Se){var he=q.node(Se);he.x-=W,he.y-=z}),e.forEach(q.edges(),function(Se){var he=q.edge(Se);e.forEach(he.points,function(G){G.x-=W,G.y-=z}),e.has(he,"x")&&(he.x-=W),e.has(he,"y")&&(he.y-=z)}),Q.width=U-W+ae,Q.height=de-z+se}function $(q){e.forEach(q.edges(),function(W){var U=q.edge(W),z=q.node(W.v),de=q.node(W.w),Q,ae;U.points?(Q=U.points[0],ae=U.points[U.points.length-1]):(U.points=[],Q=de,ae=z),U.points.unshift(h.intersectRect(z,Q)),U.points.push(h.intersectRect(de,ae))})}function N(q){e.forEach(q.edges(),function(W){var U=q.edge(W);if(e.has(U,"x"))switch((U.labelpos==="l"||U.labelpos==="r")&&(U.width-=U.labeloffset),U.labelpos){case"l":U.x-=U.width/2+U.labeloffset;break;case"r":U.x+=U.width/2+U.labeloffset;break}})}function I(q){e.forEach(q.edges(),function(W){var U=q.edge(W);U.reversed&&U.points.reverse()})}function K(q){e.forEach(q.nodes(),function(W){if(q.children(W).length){var U=q.node(W),z=q.node(U.borderTop),de=q.node(U.borderBottom),Q=q.node(e.last(U.borderLeft)),ae=q.node(e.last(U.borderRight));U.width=Math.abs(ae.x-Q.x),U.height=Math.abs(de.y-z.y),U.x=Q.x+U.width/2,U.y=z.y+U.height/2}}),e.forEach(q.nodes(),function(W){q.node(W).dummy==="border"&&q.removeNode(W)})}function le(q){e.forEach(q.edges(),function(W){if(W.v===W.w){var U=q.node(W.v);U.selfEdges||(U.selfEdges=[]),U.selfEdges.push({e:W,label:q.edge(W)}),q.removeEdge(W)}})}function ie(q){var W=h.buildLayerMatrix(q);e.forEach(W,function(U){var z=0;e.forEach(U,function(de,Q){var ae=q.node(de);ae.order=Q+z,e.forEach(ae.selfEdges,function(se){h.addDummyNode(q,"selfedge",{width:se.label.width,height:se.label.height,rank:ae.rank,order:Q+ ++z,e:se.e,label:se.label},"_se")}),delete ae.selfEdges})})}function te(q){e.forEach(q.nodes(),function(W){var U=q.node(W);if(U.dummy==="selfedge"){var z=q.node(U.e.v),de=z.x+z.width/2,Q=z.y,ae=U.x-de,se=z.height/2;q.setEdge(U.e,U.label),q.removeNode(W),U.label.points=[{x:de+2*ae/3,y:Q-se},{x:de+5*ae/6,y:Q-se},{x:de+ae,y:Q},{x:de+5*ae/6,y:Q+se},{x:de+2*ae/3,y:Q+se}],U.label.x=U.x,U.label.y=U.y}})}function fe(q,W){return e.mapValues(e.pick(q,W),Number)}function xe(q){var W={};return e.forEach(q,function(U,z){W[z.toLowerCase()]=U}),W}return Jl}var Zl,im;function uj(){if(im)return Zl;im=1;var e=st(),r=At(),t=Bt().Graph;Zl={debugOrdering:n};function n(i){var o=r.buildLayerMatrix(i),s=new t({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,l){var c="layer"+l;s.setNode(c,{rank:"same"}),e.reduce(a,function(d,u){return s.setEdge(d,u,{style:"invis"}),u})}),s}return Zl}var Xl,am;function fj(){return am||(am=1,Xl="0.8.5"),Xl}var Yl,sm;function hj(){return sm||(sm=1,Yl={graphlib:Bt(),layout:dj(),debug:uj(),util:{time:At().time,notime:At().notime},version:fj()}),Yl}var pj=hj();const cm=Yw(pj);function gj(e,r,t){var d;const n=new Set(e.map(u=>u.id)),i=new Set;for(const u of e)u.parent&&n.has(u.parent)&&i.add(u.parent);const o=new cm.graphlib.Graph({multigraph:!0,compound:!0}),s=t.compactSpacingScale??(t.spacingFactor>0?t.spacingFactor/1.3:1);o.setGraph({rankdir:t.rankDir,nodesep:t.compact?Math.max(t.nodeSep,24*s):t.nodeSep,edgesep:t.compact?Math.min(t.edgeSep,24*s):t.edgeSep,ranksep:t.compact?Math.min(t.rankSep,80*s):t.rankSep,ranker:"network-simplex"}),o.setDefaultEdgeLabel(()=>({})),o.setDefaultNodeLabel(()=>({}));for(const u of e)o.setNode(u.id,{width:u.width+2,height:u.height+2});for(const u of e)u.parent&&n.has(u.parent)&&o.setParent(u.id,u.parent);for(const u of r){if(!n.has(u.source)||!n.has(u.target)||i.has(u.source)||i.has(u.target))continue;const h=Tb(u.label,u.icon??((d=u.data)==null?void 0:d.icon),t.edgeLabelFontSize),p=t.rankDir==="LR"||t.rankDir==="RL",y=(h.width?h.width+2*Mb:0)+(u.connectorClearance??0);o.setEdge(u.source,u.target,{minlen:1,weight:1,...y?{width:p?y:Math.max(1,h.height),height:p?Math.max(1,h.height):y,labelpos:"c"}:{}},u.id)}cm.layout(o);const a=new Map;for(const u of e){if(i.has(u.id))continue;const h=o.node(u.id);h&&Number.isFinite(h.x)&&Number.isFinite(h.y)&&a.set(u.id,{x:h.x,y:h.y})}const l=t.compact?1:t.spacingFactor;if(l&&l!==1&&a.size){let u=1/0,h=1/0,p=-1/0,y=-1/0;a.forEach(b=>{u=Math.min(u,b.x),h=Math.min(h,b.y),p=Math.max(p,b.x),y=Math.max(y,b.y)});const m=(u+p)/2,g=(h+y)/2;a.forEach((b,v)=>a.set(v,{x:m+(b.x-m)*l,y:g+(b.y-g)*l}))}const c=t.nodeAlignment??"center";if(c!=="center"){const u=t.rankDir==="LR"||t.rankDir==="RL",h=u?"x":"y",p=u?"width":"height",y=t.rankDir==="RL"||t.rankDir==="BT"?-1:1,m=c==="leading"?-y:y,g=new Map;for(const b of e){const v=a.get(b.id);if(!v)continue;const x=v[h];g.set(x,Math.max(g.get(x)??0,b[p]))}for(const b of e){const v=a.get(b.id);if(!v)continue;const x=v[h],w=(g.get(x)-b[p])/2;a.set(b.id,{...v,[h]:x+m*w})}}return a}function ld(e,r,t,n,i,o){const s=new Map,a=new Map(e.map(u=>[u.id,u]));for(const u of e){if(!u.parent||!a.has(u.parent))continue;const h=s.get(u.parent);h?h.push(u.id):s.set(u.parent,[u.id])}const l=(u,h=new Set)=>{var y;const p=(y=a.get(u))==null?void 0:y.parent;return!p||!a.has(p)||h.has(u)?0:(h.add(u),1+l(p,h))},c=[...s.keys()].sort((u,h)=>l(h)-l(u)),d=new Map;for(const u of c){const h=o==null?void 0:o.get(u),p=r.get(u);if(h&&p){d.set(u,{x1:p.x-h.w/2,y1:p.y-h.h/2,x2:p.x+h.w/2,y2:p.y+h.h/2});continue}let y=null;for(const b of s.get(u)||[]){let v=d.get(b);if(!v){const x=r.get(b);if(!x)continue;const w=t.get(b)||{w:60,h:60};v={x1:x.x-w.w/2,y1:x.y-w.h/2,x2:x.x+w.w/2,y2:x.y+w.h/2}}y=y?{x1:Math.min(y.x1,v.x1),y1:Math.min(y.y1,v.y1),x2:Math.max(y.x2,v.x2),y2:Math.max(y.y2,v.y2)}:{...v}}if(!y)continue;const m=n(u);y={x1:y.x1-m,y1:y.y1-m,x2:y.x2+m,y2:y.y2+m};const g=i(u);if(g){const b=y.x2-y.x1,v=y.y2-y.y1;if(g.w>b){const x=(g.w-b)/2;y.x1-=x,y.x2+=x}if(g.h>v){const x=(g.h-v)/2;y.y1-=x,y.y2+=x}}d.set(u,y)}return d}function lm(e,r,t){var l,c,d;const n=[...r.weights],i=n.reduce((u,h)=>u+h,0),o=n[r.index]+n[r.index+1],s=Math.min(o*.95,Math.max(o*.05,n[r.index]+t/r.length*i));n[r.index]=s,n[r.index+1]=o-s;const a={...(c=(l=e.adjustment)==null?void 0:l.sections)==null?void 0:c[r.section]};if(r.axis==="y")a.rows=n;else{for(a.columns=[...a.columns??[]];a.columns.length<=r.row;)a.columns.push([]);a.columns[r.row]=n}return{...e,adjustment:{...e.adjustment,sections:{...(d=e.adjustment)==null?void 0:d.sections,[r.section]:a}}}}function Nv(e){if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e)||e.enabled!==void 0&&typeof e.enabled!="boolean")throw new RangeError("Invalid grid adjustment.");const r=t=>Array.isArray(t)&&t.length<=1e4&&t.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1e6);if(e.sections!==void 0&&(!e.sections||typeof e.sections!="object"||Array.isArray(e.sections)))throw new RangeError("Invalid grid sections.");for(const[t,n]of Object.entries(e.sections??{}))if(["__proto__","constructor","prototype"].includes(t)||!n||typeof n!="object"||Array.isArray(n)||n.rows!==void 0&&!r(n.rows)||n.columns!==void 0&&(!Array.isArray(n.columns)||n.columns.length>1e4||!n.columns.every(r)))throw new RangeError("Invalid grid section proportions.")}function Zd(e){const r=e.margin??15;if(!Number.isFinite(r)||r<0)throw new RangeError("Collision margin must be finite and non-negative.");return r}function Eo(e){const r=new Map(e.nodes.map(a=>[a.id,a])),t=new Map;for(const a of e.nodes){const l=a.parent&&r.has(a.parent)?a.parent:void 0,c=t.get(l)??[];c.push(a.id),t.set(l,c)}const n=[],i=new Map,o=a=>{const l=t.get(a),c=l?l.flatMap(o):e.positions.has(a)?[a]:[];return i.set(a,c),l&&n.push(l),c},s=t.get(void 0)??[];return s.forEach(o),n.push(s),{groups:n,leaves:i,children:t,roots:s}}function _r(e,r,t=e.fixedSizes){const n=ld(e.nodes,r,e.sizes,e.padding,e.minSize,t);for(const i of e.nodes){if(n.has(i.id))continue;const o=r.get(i.id),s=e.sizes.get(i.id);o&&s&&n.set(i.id,Xt({...o,...s}))}return n}function $v(e,r,t,n){const i=t.get(e),o=t.get(r);if(!i||!o)return;const s={x:Math.min(i.x2-o.x1,o.x2-i.x1)+n,y:Math.min(i.y2-o.y1,o.y2-i.y1)+n};if(s.x>.001&&s.y>.001)return{source:e,target:r,overlap:s}}function kn(e,r,t){const n=[];for(const i of e)for(let o=0;o<i.length;o++)for(let s=o+1;s<i.length;s++){const a=$v(i[o],i[s],r,t);a&&n.push(a)}return n}function qv(e,r={}){const t=Zd(r),{groups:n}=Eo(e);return kn(n,_r(e,e.positions),t)}function Ql(e,r={}){Nv(r.adjustment);const t=Zd(r),n=typeof r.gaps=="object"?r.gaps:{x:r.gaps??t,y:r.gaps??t};if(!n||[n.x,n.y].some(d=>!Number.isFinite(d)||d<0))throw new RangeError("Grid gaps must be finite and non-negative.");const i=r.padding??0;if(!Number.isFinite(i)||i<0)throw new RangeError("Grid padding must be finite and non-negative.");if(r.columns!==void 0&&(!Number.isSafeInteger(r.columns)||r.columns<1))throw new RangeError("Grid columns must be a positive safe integer.");if(r.fill&&e.viewportSize)return yj(e,r,n,i);const{groups:o,leaves:s}=Eo(e),a=new Map([...e.positions].map(([d,u])=>[d,{...u}])),l=new Set;for(const d of o){const u=_r(e,a),h=d.filter(R=>u.has(R));if(h.length<2)continue;if(h.some(R=>e.fixedIds.has(R)||(s.get(R)??[]).some(A=>e.fixedIds.has(A)))){h.forEach(R=>l.add(R));continue}const y=h.map(R=>u.get(R)),m=Math.max(...y.map(R=>R.x2-R.x1)),g=Math.max(...y.map(R=>R.y2-R.y1)),b=Math.min(h.length,r.columns??Math.ceil(Math.sqrt(h.length))),v=Math.ceil(h.length/b),x=m+n.x,w=g+n.y,C=y.map(R=>({x:(R.x1+R.x2)/2,y:(R.y1+R.y2)/2})),S=(Math.min(...C.map(R=>R.x))+Math.max(...C.map(R=>R.x)))/2,_=(Math.min(...C.map(R=>R.y))+Math.max(...C.map(R=>R.y)))/2;h.forEach((R,A)=>{const O=u.get(R),T={x:S+(A%b-(b-1)/2)*x-(O.x1+O.x2)/2,y:_+(Math.floor(A/b)-(v-1)/2)*w-(O.y1+O.y2)/2};for(const E of s.get(R)??[]){const M=a.get(E);a.set(E,{x:M.x+T.x,y:M.y+T.y})}})}const c=[...a].filter(([d,u])=>{const h=e.positions.get(d);return u.x!==h.x||u.y!==h.y}).map(([d])=>d);return{positions:a,movedNodeIds:c,skippedNodeIds:[...l],collisions:kn(o,_r(e,a),Math.min(n.x,n.y))}}function yj(e,r,t,n){const{groups:i,children:o,roots:s}=Eo(e),a=new Map([...e.positions].map(([g,b])=>[g,{...b}]));if(e.nodes.some(g=>e.fixedIds.has(g.id)))return{positions:a,movedNodeIds:[],skippedNodeIds:e.nodes.map(g=>g.id),collisions:qv(e,{margin:Math.min(t.x,t.y)})};const l=e.viewportSize,c=Math.min(n,Math.max(0,(l.w-1)/2)),d=Math.min(n,Math.max(0,(l.h-1)/2)),u={x1:c,y1:d,x2:Math.max(c+1,l.w-c),y2:Math.max(d+1,l.h-d)},h=new Map,p=[],y=(g,b,v="canvas")=>{var M,P;if(!g.length)return;const x=b.x2-b.x1,w=b.y2-b.y1,C=Math.min(g.length,r.columns??Math.max(1,Math.round(Math.sqrt(g.length*x/w)))),S=Math.ceil(g.length/C),_=Math.min(t.y,w/(2*S)),R=(P=(M=r.adjustment)==null?void 0:M.sections)==null?void 0:P[v],A=Array.from({length:S},($,N)=>{var I;return((I=R==null?void 0:R.rows)==null?void 0:I[N])??1}),O=A.reduce(($,N)=>$+N,0),T=w-(S-1)*_;let E=b.y1;for(let $=0;$<S;$++){const N=T*A[$]/O,I=Math.min(C,g.length-$*C),K=Math.min(t.x,x/(2*I)),le=Array.from({length:I},(xe,q)=>{var W,U;return((U=(W=R==null?void 0:R.columns)==null?void 0:W[$])==null?void 0:U[q])??1}),ie=le.reduce((xe,q)=>xe+q,0),te=x-(I-1)*K;let fe=b.x1;for(let xe=0;xe<I;xe++){const q=g[$*C+xe],W=te*le[xe]/ie,U=o.get(q);if(U){a.set(q,{x:fe+W/2,y:E+N/2}),h.set(q,{w:W,h:N});const z=Math.min(e.padding(q),Math.max(0,(Math.min(W,N)-1)/2));y(U,{x1:fe+z,y1:E+z,x2:fe+W-z,y2:E+N-z},q)}else a.has(q)&&(a.set(q,{x:fe+W/2,y:E+N/2}),h.set(q,{w:W,h:N}));xe<I-1&&p.push({section:v,axis:"x",row:$,index:xe,weights:le,length:te,position:{x:fe+W+K/2,y:E+N/2}}),fe+=W+K}$<S-1&&p.push({section:v,axis:"y",row:$,index:$,weights:A,length:T,position:{x:b.x1+x/2,y:E+N+_/2}}),E+=N+_}};y(s,u);const m=[...a].filter(([g,b])=>{const v=e.positions.get(g);return!v||b.x!==v.x||b.y!==v.y}).map(([g])=>g);return{positions:a,movedNodeIds:m,skippedNodeIds:[],bounds:u,sizes:h,dividers:p,collisions:kn(i,_r({...e,sizes:h},a,h),0)}}function mj(e,r={}){const t=Zd(r),n=r.maxIterations??50;if(!Number.isInteger(n)||n<0||n>1e3)throw new RangeError("Collision maxIterations must be an integer between 0 and 1000.");const{groups:i,leaves:o}=Eo(e),s=new Map([...e.positions].map(([u,h])=>[u,{...h}])),a=u=>e.fixedIds.has(u)||(o.get(u)??[]).some(h=>e.fixedIds.has(h));let l=kn(i,_r(e,s),t),c=0;for(;l.length&&c<n;){let u=!1;for(const h of i){if(h.length<2)continue;const p=_r(e,s),y=(m,g,b)=>{for(const x of o.get(m)??[])s.get(x)[g]+=b;const v=p.get(m);g==="x"?(v.x1+=b,v.x2+=b):(v.y1+=b,v.y2+=b)};for(let m=0;m<h.length;m++)for(let g=m+1;g<h.length;g++){const b=h[m],v=h[g],x=$v(b,v,p,t);if(!x)continue;const w=a(b),C=a(v);if(w&&C)continue;const S=x.overlap.x<=x.overlap.y?"x":"y",_=p.get(b),R=p.get(v),A=S==="x"?_.x1+_.x2<=R.x1+R.x2?-1:1:_.y1+_.y2<=R.y1+R.y2?-1:1,O=x.overlap[S];w||y(b,S,A*O/(C?1:2)),C||y(v,S,-A*O/(w?1:2)),u=!0}}if(c++,l=kn(i,_r(e,s),t),!u)break}const d=[...s].filter(([u,h])=>{const p=e.positions.get(u);return h.x!==p.x||h.y!==p.y}).map(([u])=>u);return{positions:s,movedNodeIds:d,collisions:l,iterations:c,resolved:l.length===0}}function bj({dividers:e,options:r,zoom:t,onChange:n}){const i=j.useRef();return f.jsx(f.Fragment,{children:e.map(o=>{const s=o.axis==="x",a=s?Z.PiArrowsHorizontal:Z.PiArrowsVertical,l=`${s?"Column":"Row"} divider ${o.index+1}${s?` in row ${o.row+1}`:""}`;return f.jsx("button",{type:"button",role:"separator","aria-label":l,"aria-orientation":s?"vertical":"horizontal","aria-valuemin":5,"aria-valuemax":95,"aria-valuenow":Math.round(100*o.weights[o.index]/(o.weights[o.index]+o.weights[o.index+1])),title:l,"data-flow-grid-adjustment":"",style:{position:"absolute",left:o.position.x,top:o.position.y,transform:"translate(-50%, -50%)",width:28,height:28,padding:3,border:"1px solid currentColor",borderRadius:4,background:"var(--chakra-colors-gray-100)",color:"var(--chakra-colors-gray-800)",display:"grid",placeItems:"center",cursor:s?"col-resize":"row-resize",touchAction:"none",pointerEvents:"auto",zIndex:30},onPointerDown:c=>{if(c.button!==0)return;c.preventDefault(),c.stopPropagation();const d=c.currentTarget.closest(".flow-sdk-canvas"),u=d.getBoundingClientRect();i.current={pointerId:c.pointerId,start:s?c.clientX:c.clientY,scale:t*(s?u.width/d.clientWidth:u.height/d.clientHeight),divider:o,options:r},c.currentTarget.setPointerCapture(c.pointerId)},onPointerMove:c=>{const d=i.current;if(!d||d.pointerId!==c.pointerId)return;c.preventDefault(),c.stopPropagation();const u=((s?c.clientX:c.clientY)-d.start)/d.scale;n(lm(d.options,d.divider,u))},onPointerUp:c=>{i.current&&(c.stopPropagation(),i.current=void 0,c.currentTarget.releasePointerCapture(c.pointerId))},onPointerCancel:()=>{i.current&&n(i.current.options),i.current=void 0},onLostPointerCapture:()=>{i.current=void 0},onClick:c=>c.stopPropagation(),onKeyDown:c=>{c.key==="Escape"&&i.current&&(n(i.current.options),i.current=void 0);const d=(s?["ArrowLeft","ArrowRight"]:["ArrowUp","ArrowDown"]).indexOf(c.key);d<0||(c.preventDefault(),c.stopPropagation(),n(lm(r,o,o.length*(c.shiftKey?.1:.02)*(d===0?-1:1))))},children:f.jsx(a,{size:20,"aria-hidden":"true"})},`${o.section}:${o.axis}:${o.row}:${o.index}`)})})}const dm=(e,r)=>e.left<r.right&&e.right>r.left&&e.top<r.bottom&&e.bottom>r.top;function vj(e){const r=e.querySelector(".flow-sdk-labels"),t=r==null?void 0:r.getScreenCTM();if(!r||!t)return;const n=t.inverse(),i=(c,d=0)=>{const u=c.getBoundingClientRect(),h=new DOMPoint(u.left,u.top).matrixTransform(n),p=new DOMPoint(u.right,u.bottom).matrixTransform(n);return{left:h.x-d,right:p.x+d,top:h.y-d,bottom:p.y+d}},o=[...e.querySelectorAll(".flow-sdk-node, .flow-sdk-node button")].filter(c=>{const d=c.getBoundingClientRect(),u=getComputedStyle(c);return d.width>0&&d.height>0&&u.visibility!=="hidden"&&u.opacity!=="0"}).map(c=>i(c,24));for(const c of r.querySelectorAll(".flow-sdk-container-label"))o.push(i(c,12));const s=[...r.querySelectorAll(".flow-sdk-edge-label")];for(const c of s)c.setAttribute("transform",c.dataset.labelTransform??"");const a=new Map(s.map(c=>[c,i(c,8)])),l=new Map([...e.querySelectorAll(".flow-sdk-edge")].map(c=>[c.dataset.edgeId,c.querySelector("path")]));for(const c of s){const d=c.dataset.labelHorizontal==="true",u=a.get(c);a.delete(c);const h=_=>o.some(R=>dm(_,R))||[...a.values()].some(R=>dm(_,R));if(!d&&!h(u)){a.set(c,u);continue}const p=l.get(c.dataset.edgeId),y=c.querySelector("rect");if(!p||!y)continue;const m=y.getBBox(),g=p.getTotalLength();if(!Number.isFinite(g)||g<=0)continue;const b=(u.left+u.right)/2,v=(u.top+u.bottom)/2,x=Math.min(256,Math.max(16,Math.ceil(g/24))),w=Array.from({length:x+1},(_,R)=>p.getPointAtLength(g*R/x)),S=Array.from({length:x+1},(_,R)=>{const A=g*R/x,O=w[R],T=d?{x:O.x,y:O.y-m.height/2-15}:O,E=p.getPointAtLength(Math.max(0,A-2)),M=p.getPointAtLength(Math.min(g,A+2));let P=Math.atan2(M.y-E.y,M.x-E.x)*180/Math.PI;P>90&&(P-=180),P<-90&&(P+=180);const $=Math.abs(P)<1;d&&(P=0);const N=P*Math.PI/180,I=Math.abs(Math.cos(N))*m.width+Math.abs(Math.sin(N))*m.height,K=Math.abs(Math.sin(N))*m.width+Math.abs(Math.cos(N))*m.height;return{point:T,angle:P,straight:$,score:Math.hypot(T.x-b,T.y-v),bounds:{left:T.x-I/2-8,right:T.x+I/2+8,top:T.y-K/2-8,bottom:T.y+K/2+8}}}).sort((_,R)=>_.score-R.score).find(_=>!h(_.bounds)&&(!d||_.straight&&!w.some(R=>R.x>_.bounds.left&&R.x<_.bounds.right&&R.y>_.bounds.top&&R.y<_.bounds.bottom)));S?(c.setAttribute("transform",`translate(${S.point.x} ${S.point.y}) rotate(${S.angle})`),a.set(c,S.bounds)):a.set(c,u)}}function xj(e){const r=e.getBoundingClientRect(),t=r.height/e.offsetHeight;if(!Number.isFinite(t)||t<=0)return[];const n=Pb(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 l=a.dataset.flowPortSide;if(l&&["top","right","bottom","left"].includes(l)){const d=Rb(n?xn(i,n):i,l,Number(a.dataset.flowPortPosition??.5));return[{property:a.getAttribute("data-flow-property"),top:d.y,height:0,anchor:d,...a.dataset.flowPortPlacement==="config"?{placement:"config"}:{},...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]}const c=a.getBoundingClientRect();return!c.width||!c.height?[]:[{property:a.getAttribute("data-flow-property"),top:Math.round((c.top-r.top)/t*1e3)/1e3,height:Math.round(c.height/t*1e3)/1e3,...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]})}function wj({id:e,x:r,y:t,placed:n,hidden:i,gridDraggable:o,gridDragging:s,gridDropTarget:a,gridSize:l,gridPreview:c,onMount:d,drawHandles:u,drawMode:h,connectedPorts:p,resolvedRows:y,hasCollapseControl:m,handleColor:g,animated:b,animationColor:v,animationWidth:x=8,animationVariant:w,width:C=0,height:S=0,propertyMode:_,reversePorts:R,direction:A="LR",onPropertyRows:O,onSurface:T,children:E}){var z,de;const M=j.useRef(null),[P,$]=j.useState([]),N=y??P,[I,K]=j.useState(),le=j.useId(),ie=j.useRef(),te=!!c,fe=!!(c!=null&&c.floating);j.useLayoutEffect(()=>{var Se;const Q=M.current;if(!Q||!te)return;const ae=Q.cloneNode(!0);ae.removeAttribute("data-node-id"),ae.removeAttribute("data-grid-dragging"),ae.removeAttribute("data-grid-draggable"),ae.removeAttribute("data-grid-drop-target"),ae.setAttribute("data-grid-preview",e),ae.setAttribute("aria-hidden","true"),ae.setAttribute("inert","");const se=[ae,...ae.querySelectorAll("*")],Ce=new Map(se.filter(he=>he.id).map(he=>[he.id,`${he.id}-${le}`]));for(const he of se){he.id&&(he.id=Ce.get(he.id));for(const G of[...he.attributes]){if(G.name==="id")continue;let F=G.value;for(const[re,ce]of Ce)F===`#${re}`&&(F=`#${ce}`),F=F.split(`url(#${re})`).join(`url(#${ce})`);F!==G.value&&he.setAttribute(G.name,F)}}if(Object.assign(ae.style,{opacity:"0.35",zIndex:fe?"2147483647":"11",pointerEvents:"none",outline:"none",visibility:"visible"}),fe){const he=getComputedStyle(Q);ae.setAttribute("data-grid-preview-floating",""),Object.assign(ae.style,{position:"fixed",left:"0",top:"0",transformOrigin:"top left",font:he.font,color:he.color});for(const G of se)G.removeAttribute("data-node-id"),G.style.pointerEvents="none"}return ae.querySelectorAll(".flow-sdk-node-animation, .flow-sdk-handle, .flow-sdk-property-port, [data-flow-collapse-control]").forEach(he=>he.remove()),(Se=fe?document.body:Q.parentElement)==null||Se.appendChild(ae),ie.current=ae,()=>{ae.remove(),ie.current=void 0}},[e,le,te,fe]),j.useLayoutEffect(()=>{const Q=ie.current;if(!Q||!c)return;const{x:ae,y:se,size:Ce}=c;if(fe&&M.current){const G=M.current,F=G.getBoundingClientRect(),re=F.width/G.offsetWidth||1,ce=F.height/G.offsetHeight||1,X=F.left+(ae-r)*re,ye=F.top+(se-t)*ce;Q.style.transform=`translate3d(${X}px, ${ye}px, 0) scale(${re}, ${ce})`,Q.style.width=`${G.offsetWidth}px`,Q.style.height=`${G.offsetHeight}px`;return}const Se=Ce?Math.round(ae-Ce.w/2):ae,he=Ce?Math.round(se-Ce.h/2):se;Q.style.transform=Ce?`translate3d(${Se}px, ${he}px, 0)`:`translate(-50%, -50%) translate3d(${Se}px, ${he}px, 0)`,Q.style.width=Ce?`${Math.round(ae+Ce.w/2)-Se}px`:"",Q.style.height=Ce?`${Math.round(se+Ce.h/2)-he}px`:"",Ce&&(Q.style.setProperty("--flow-grid-width",`${Ce.w}px`),Q.style.setProperty("--flow-grid-height",`${Ce.h}px`),Q.style.setProperty("--flow-grid-font",`${Math.max(12,Math.min(48,Ce.w/8,Ce.h/5))}px`))},[c==null?void 0:c.x,c==null?void 0:c.y,(z=c==null?void 0:c.size)==null?void 0:z.w,(de=c==null?void 0:c.size)==null?void 0:de.h,fe,r,t]),j.useLayoutEffect(()=>{const Q=M.current;if(!Q)return;const ae=()=>{const Se=Pb(Q);K(he=>JSON.stringify(he)===JSON.stringify(Se)?he:Se),T==null||T(e,Se)};ae();const se=new ResizeObserver(ae);se.observe(Q);const Ce=Q.querySelector("[data-flow-node-surface]");return Ce&&se.observe(Ce),()=>se.disconnect()},[e,E,T]),j.useLayoutEffect(()=>(d(e,M.current),()=>{d(e,null),T==null||T(e,void 0)}),[e,d,T]),j.useLayoutEffect(()=>{const Q=M.current;if(!Q)return;let ae="";const se=()=>{const G=xj(Q),F=_?G:G.filter(ce=>ce.anchor),re=JSON.stringify(F);re!==ae&&(ae=re,$(F),O==null||O(e,F))};if(se(),!_&&!Q.querySelector("[data-flow-port-side]"))return;const Ce=new ResizeObserver(se),Se=()=>{Ce.disconnect(),Ce.observe(Q),Q.querySelectorAll("[data-flow-property]").forEach(G=>Ce.observe(G)),se()};Se();const he=new MutationObserver(Se);return he.observe(Q,{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"]}),Q.addEventListener("scroll",se,!0),()=>{Ce.disconnect(),he.disconnect(),Q.removeEventListener("scroll",se,!0)}},[e,_,O,E]);const xe=l?Math.round(r-l.w/2):0,q=l?Math.round(t-l.h/2):0,W=l?Math.round(r+l.w/2)-xe:void 0,U=l?Math.round(t+l.h/2)-q:void 0;return f.jsxs("div",{ref:M,className:"flow-sdk-node","data-node-id":e,"data-grid-draggable":o||void 0,"data-grid-dragging":s||void 0,"data-grid-drop-target":a||void 0,"data-grid-fill":l?"":void 0,style:{transform:l?`translate3d(${xe}px, ${q}px, 0)`:`translate(-50%, -50%) translate3d(${r.toFixed(2)}px, ${t.toFixed(2)}px, 0)`,visibility:n&&!i?void 0:"hidden",cursor:o?s?"grabbing":"grab":void 0,zIndex:s?12:void 0,opacity:c?0:s?.75:void 0,outline:a?`2px solid ${g||"currentColor"}`:void 0,outlineOffset:a?8:void 0,width:W,height:U,...l?{"--flow-grid-width":`${l.w}px`,"--flow-grid-height":`${l.h}px`,"--flow-grid-font":`${Math.max(12,Math.min(48,l.w/8,l.h/5))}px`}:{}},children:[E,!l&&b&&x>0&&C>0&&S>0&&f.jsx("svg",{className:"flow-sdk-node-animation","aria-hidden":"true",pointerEvents:"none",children:f.jsx(Zn,{variant:w,x:((I==null?void 0:I.left)??0)+x/2,y:((I==null?void 0:I.top)??0)+x/2,width:((I==null?void 0:I.width)??C)-x,height:((I==null?void 0:I.height)??S)-x,radius:((I==null?void 0:I.radius)??0)-x/2,path:I!=null&&I.outline?`M${I.outline.map(Q=>`${Q.x} ${Q.y}`).join(" L")} Z`:void 0,color:v||g||"currentColor",strokeWidth:x})}),u&&_&&N.map(Q=>["source","target"].filter(ae=>!Q.role||Q.role===ae).filter(ae=>h||(p==null?void 0:p.has(`${ae}:${Q.property}`))).map(ae=>{var se;return f.jsx("button",{type:"button",className:"flow-sdk-property-port","data-property":Q.property,"data-port-role":ae,"data-port-side":(se=Q.anchor)==null?void 0:se.side,"aria-label":`${ae==="source"?"Connect":"Input"} ${Q.property}`,title:`${ae==="source"?"Connect":"Input"} ${Q.property}`,style:{color:g,...Q.anchor?{top:Q.anchor.y,left:Q.anchor.x-16}:{top:Q.top+Q.height/2,[ae==="source"!=!!R?"right":"left"]:-16}},onClick:Ce=>Ce.stopPropagation()},`${Q.property}:${ae}`)})),u&&!m&&(!_||!N.length)&&(!_||!N.some(Q=>Q.anchor))&&f.jsx("button",{type:"button",className:"flow-sdk-handle","aria-label":"Draw edge",title:"Draw edge",style:{color:g,left:((I==null?void 0:I.left)??0)+(A==="RL"?-36:A==="LR"?(I==null?void 0:I.width)??C:((I==null?void 0:I.width)??C)/2),top:((I==null?void 0:I.top)??0)+(A==="BT"?-36:A==="TB"?(I==null?void 0:I.height)??S:((I==null?void 0:I.height)??S)/2),transform:A==="BT"||A==="TB"?"translateX(-50%)":"translateY(-50%)"},onClick:Q=>Q.stopPropagation(),children:f.jsx(Z.PiPlusBold,{size:24})})]})}const Cj=j.memo(wj);function Sj(e,r,t){const[n,i]=j.useState(()=>({nodes:new Set,edges:new Set})),o=j.useMemo(()=>{const a=new Set(e.map(p=>p.id)),l=r.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})),c=new Set(l.map(p=>p.id)),d=new Set([...n.nodes].filter(p=>a.has(p))),u=new Set([...n.edges].filter(p=>c.has(p)));if(!t)return{nodes:a,edges:c,ready:c};for(const p of e)l.filter(m=>m.target===p.id&&m.source!==m.target).every(m=>u.has(m.id))&&d.add(p.id);let h=new Set(l.filter(p=>d.has(p.source)).map(p=>p.id));if(d.size<a.size&&!l.some(p=>h.has(p.id)&&!u.has(p.id))){const p=e.find(y=>!d.has(y.id));p&&d.add(p.id),h=new Set(l.filter(y=>d.has(y.source)).map(y=>y.id))}return{nodes:d,edges:u,ready:h}},[e,r,t,n]);j.useLayoutEffect(()=>{i(a=>{const l=t?o:{nodes:new Set,edges:new Set},c=(d,u)=>d.size===u.size&&[...d].every(h=>u.has(h));return c(a.nodes,l.nodes)&&c(a.edges,l.edges)?a:{nodes:l.nodes,edges:l.edges}})},[o,t]);const s=j.useCallback(a=>{i(l=>l.edges.has(a)?l:{...l,edges:new Set([...l.edges,a])})},[]);return{shown:o.nodes,ready:o.ready,complete:s}}class jj{constructor(r,t,n){Tt(this,"_pan");Tt(this,"_zoom");Tt(this,"minZoom");Tt(this,"maxZoom");Tt(this,"size",{w:0,h:0});Tt(this,"listeners",new Set);Tt(this,"cancelTransition");Tt(this,"animationVersion",0);Tt(this,"captureTransition");Tt(this,"animationsDisabled",!1);Tt(this,"finishTransition");this.minZoom=t,this.maxZoom=n,this._pan={...r.pan},this._zoom=this.clamp(r.zoom)}setAnimationsDisabled(r){var t;r!==this.animationsDisabled&&(this.animationsDisabled=r,r&&((t=this.finishTransition)==null||t.call(this),this.cancelAnimation()))}cancelAnimation(){var r;(r=this.cancelTransition)==null||r.call(this),this.cancelTransition=void 0,this.finishTransition=void 0,this.animationVersion++}coordinate(r){let t;this.captureTransition=n=>{t=n};try{r()}finally{this.captureTransition=void 0}return t}transition(r,t=!1){this.cancelAnimation();const n=this.state,i={pan:{...r.pan},zoom:this.clamp(r.zoom)},o=this.animationVersion,s=_b(t,this.animationsDisabled),a=l=>{if(o!==this.animationVersion)return;const c=s?l:1;this.apply({x:n.pan.x+(i.pan.x-n.pan.x)*c,y:n.pan.y+(i.pan.y-n.pan.y)*c},n.zoom+(i.zoom-n.zoom)*c)};this.finishTransition=()=>a(1),this.captureTransition?this.captureTransition(a):this.cancelTransition=Eb(s,a,void 0,300/1.4)}get pan(){return{...this._pan}}get zoom(){return this._zoom}get state(){return{pan:this.pan,zoom:this._zoom}}clamp(r){return Number.isFinite(r)?Math.max(this.minZoom,Math.min(this.maxZoom,r)):this.minZoom}set(r,t){this.cancelAnimation(),this.apply(r,t)}apply(r,t){let n=!1;if(r&&(r.x!==this._pan.x||r.y!==this._pan.y)&&(this._pan={x:r.x,y:r.y},n=!0),t!==void 0){const i=this.clamp(t);i!==this._zoom&&(this._zoom=i,n=!0)}n&&this.emit()}zoomAt(r,t){const n=this.clamp(r),i=this._zoom;if(n===i)return;const o=n/i;this.set({x:t.x-(t.x-this._pan.x)*o,y:t.y-(t.y-this._pan.y)*o},n)}fit(r,t=0,n=!1,i=1){const o=r.x2-r.x1,s=r.y2-r.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*t)/o,(this.size.h-2*t)/s))*i);this.transition({pan:{x:(this.size.w-a*(r.x1+r.x2))/2,y:(this.size.h-a*(r.y1+r.y2))/2},zoom:a},n)}center(r,t=!1){if(!this.size.w||!this.size.h)return;const n=this._zoom;this.transition({pan:{x:(this.size.w-n*(r.x1+r.x2))/2,y:(this.size.h-n*(r.y1+r.y2))/2},zoom:n},t)}renderedToModel(r){return{x:(r.x-this._pan.x)/this._zoom,y:(r.y-this._pan.y)/this._zoom}}modelToRendered(r){return{x:r.x*this._zoom+this._pan.x,y:r.y*this._zoom+this._pan.y}}onChange(r){return this.listeners.add(r),()=>{this.listeners.delete(r)}}emit(){const r=this.state;this.listeners.forEach(t=>t(r))}}const _j={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},Wn={w:60,h:60},ed=4,Ej=30,Rj=500,kj=45;function um(e){const[r,t]=[...e.values()];return!r||!t?null:{center:{x:(r.x+t.x)/2,y:(r.y+t.y)/2},distance:Math.max(1,Math.hypot(t.x-r.x,t.y-r.y))}}function Aj(e){var iu,au,su;const{nodes:r,edges:t,direction:n,nodeAlignment:i="center",edgeMode:o="auto",compactPropertyLayout:s=!1,rankSep:a,edgeSep:l,spacingFactor:c=1.3,compactSpacingScale:d,minZoom:u,maxZoom:h,initialViewport:p,containerStyle:y,lineColor:m,drawMode:g,dragMode:b,multiSelect:v,isPerformanceMode:x,disableAnimations:w=!1}=e,[C,S]=j.useState(null),_=j.useMemo(()=>C?(C.mode==="connections"?Lu:Mu)(C.id,r,t):null,[C,r,t]),R=o==="auto"||o==="properties",A=j.useMemo(()=>t.filter(k=>cd(k,o)&&(!_||_.has(k.source)&&_.has(k.target))),[t,o,_]),O=j.useMemo(()=>Hw(r,t,o,s,_),[r,t,o,s,_]),T=j.useRef(O);T.current=O;const E=j.useRef(e);E.current=e;const M=j.useRef(null),P=j.useRef(null),$=j.useRef(null),N=j.useRef(null),I=j.useMemo(()=>new jj(p,u,h),[]);j.useEffect(()=>{I.minZoom=u,I.maxZoom=h},[I,u,h]),j.useLayoutEffect(()=>{I.setAnimationsDisabled(w)},[I,w]);const K=j.useRef(new Map),le=j.useRef(new Map),ie=j.useRef(new Map),te=j.useRef(null),[fe,xe]=j.useState(new Map),q=j.useCallback((k,L)=>{xe(V=>{if(JSON.stringify(V.get(k))===JSON.stringify(L))return V;const Y=new Map(V);return L?Y.set(k,L):Y.delete(k),Y})},[]),[W,U]=j.useState(new Map),z=j.useRef(W),de=j.useCallback((k,L)=>{U(V=>{if(JSON.stringify(V.get(k)??[])===JSON.stringify(L))return V;const Y=new Map(V);return L.length?Y.set(k,L):Y.delete(k),Y})},[]),[Q,ae]=j.useState(()=>new Map),se=j.useRef(Q);se.current=Q;const[Ce,Se]=j.useState(new Map),he=j.useRef(Ce),G=()=>{he.current=new Map,Se(he.current)},F=j.useRef(new Map),re=j.useRef(null),ce=j.useRef(!1),[X,ye]=j.useState(0),ve=j.useRef(),Oe=j.useRef(),Ne=j.useRef(null),Be=j.useRef(!1),et=j.useRef(null),We=j.useRef(null),ft=j.useRef(c),Ke=s,nt=j.useRef(Ke),[Ie,He]=j.useState(!0),[tt,gt]=j.useState(!1),[at,Et]=j.useState([]),Ye=j.useRef(null),[Xe,Vt]=j.useState(null),ct=j.useRef(null);ct.current=_;const tr=j.useRef(1);tr.current=(C==null?void 0:C.mode)==="connections"?1.25:1;const Wt=j.useRef(null),Ir=j.useRef(r),Rt=j.useRef([]),Gt=j.useRef(!1),Jt=()=>{var k;(k=Ne.current)==null||k.call(Ne),Ne.current=null},Mr=()=>{We.current=null,Rt.current.length&&(Gt.current=!0),!ce.current&&E.current.fitOnInit!==!1&&(Be.current=!0),clearTimeout(Oe.current),Oe.current=setTimeout(()=>{ce.current=se.current.size>0,ye(k=>k+1)},Rj)},gr=(k,L,V,Y=Mr,ue)=>{Jt();const ke=new Map(se.current),we=new Map([...K.current,...he.current]);Ne.current=Eb(L,Ee=>{const qe=new Map;if(k.forEach((je,Le)=>{const Ze=ke.get(Le);qe.set(Le,Ze?{x:Ze.x+(je.x-Ze.x)*Ee,y:Ze.y+(je.y-Ze.y)*Ee}:je)}),se.current=qe,ae(qe),ue){const je=new Map;for(const[Le,Ze]of ue){const oe=we.get(Le)??Ze;je.set(Le,{w:oe.w+(Ze.w-oe.w)*Ee,h:oe.h+(Ze.h-oe.h)*Ee})}he.current=je,Se(je)}V==null||V(Ee)},Y)},J=()=>{if(clearTimeout(ve.current),Ye.current){wt.arrangeNodesInGrid(Ye.current.options);return}he.current.size&&G();const k=E.current,L=tr.current,V=T.current,Y=V.nodes.map(qe=>{const je=le.current.get(qe.id);je&&(je.offsetWidth||je.offsetHeight)&&K.current.set(qe.id,{w:je.offsetWidth,h:je.offsetHeight});const Le=K.current.get(qe.id)||Wn;return{id:qe.id,parent:qe.parent,width:Le.w,height:Le.h}});let ue;try{const qe=k.compactPropertyLayout,je=k.edgeMode!=="nodes"&&k.edgeMode!=="workflow",Le=V.edges.map(Ze=>({...Ze,connectorClearance:qe?je&&(Ze.sourceProperty!==void 0||Ze.targetProperty!==void 0)?Uw:Gw:0}));ue=gj(Y,Le,{edgeLabelFontSize:k.edgeMode==="nodes"||k.edgeMode==="workflow"?Ib:Xn,rankDir:k.direction,compact:qe,nodeAlignment:k.nodeAlignment,rankSep:k.rankSep*L,edgeSep:k.edgeSep*L,nodeSep:5*L,spacingFactor:k.spacingFactor??1.3,compactSpacingScale:(k.compactSpacingScale??(k.spacingFactor??1.3)/1.3)*L})}catch(qe){console.warn("[flow-sdk] layout failed",qe);return}const ke=re.current;re.current=null;const we=ke&&ue.get(ke.id);if(ke&&we){const qe={x:ke.position.x-we.x,y:ke.position.y-we.y};ue=new Map([...ue].map(([je,Le])=>[je,{x:Le.x+qe.x,y:Le.y+qe.y}]))}for(const[qe,je]of F.current)ue.has(qe)?ue.set(qe,je):k.nodes.some(Le=>Le.id===qe)||F.current.delete(qe);const Ee=I.coordinate(()=>{var qe;return(qe=We.current)==null?void 0:qe.call(We,ue)});gr(ue,ce.current&&!k.isPerformanceMode&&!k.disableAnimations,Ee)},B=j.useCallback(()=>{clearTimeout(Oe.current),clearTimeout(ve.current),ve.current=setTimeout(J,E.current.layoutDebounce)},[]);j.useLayoutEffect(()=>{const k=new Map(Ir.current.map(L=>[L.id,L]));r.some(L=>{var V;return((V=k.get(L.id))==null?void 0:V.collapsed)===!0&&!L.collapsed})&&(Rt.current=r.filter(L=>!k.has(L.id)).map(L=>L.id)),Ir.current=r,ft.current!==c&&se.current.size>0&&(ce.current=!0,Be.current=!1,clearTimeout(Oe.current)),ft.current=c,nt.current!==Ke&&(Be.current=!et.current),nt.current=Ke,We.current&&!et.current?(clearTimeout(ve.current),J()):B()},[r,t,O.nodes,O.edges,Ke,n,i,a,l,B,c,d,w,e.nodeGridSpacing]),j.useEffect(()=>()=>{clearTimeout(ve.current),clearTimeout(Oe.current),Jt()},[]);const ne=j.useCallback((k,L)=>{var V,Y;if(!te.current&&typeof ResizeObserver<"u"&&(te.current=new ResizeObserver(ue=>{let ke=!1;for(const we of ue){const Ee=ie.current.get(we.target);if(!Ee||he.current.has(Ee))continue;const qe=we.target,je=qe.offsetWidth,Le=qe.offsetHeight;if(!je&&!Le)continue;const Ze=K.current.get(Ee);if(Ze&&Ze.w===je&&Ze.h===Le)continue;const oe=se.current.get(Ee);Ze&&oe&&ce.current&&!re.current&&(re.current={id:Ee,position:{...oe}}),K.current.set(Ee,{w:je,h:Le}),ke=!0}ke&&(We.current&&!et.current?J():B())})),L){le.current.set(k,L),ie.current.set(L,k),(V=te.current)==null||V.observe(L);const ue=L.offsetWidth,ke=L.offsetHeight;!he.current.has(k)&&(ue||ke)&&K.current.set(k,{w:ue,h:ke})}else{const ue=le.current.get(k);ue&&((Y=te.current)==null||Y.unobserve(ue),ie.current.delete(ue)),le.current.delete(k),K.current.delete(k),z.current.has(k)&&de(k,[])}B()},[B,de]);j.useEffect(()=>()=>{var k;return(k=te.current)==null?void 0:k.disconnect()},[]);const Me=k=>{var Y;const L=(Y=E.current.nodes.find(ue=>ue.id===k))==null?void 0:Y.label;if(!L)return;const V=E.current.containerStyle(k);return{w:so(L,`bold ${V.fontSize}px ${cr}`)+2*kj,h:0}},H=j.useMemo(()=>{const k=new Map;for(const L of r)L.label&&k.set(L.id,L.label);return k},[r]),ge=j.useMemo(()=>ld(O.nodes,Q,new Map([...K.current,...Ce]),k=>y(k).padding,Me,Ce),[O.nodes,Q,y,H,Ce]),Re=j.useRef(ge);Re.current=ge;const be=j.useCallback(k=>{const L=Re.current.get(k);if(L)return Iw(L);const V=se.current.get(k);if(!V)return;const Y=he.current.get(k)||K.current.get(k)||Wn;return{x:V.x,y:V.y,w:Y.w,h:Y.h}},[]),Ge=j.useMemo(()=>{const k=new Map;for(const L of r){const V=be(L.id);V&&k.set(L.id,V)}return zw(W,k,fe,t,n)},[W,r,Q,ge,fe,t,n,be]);z.current=Ge;const Je=(k,L)=>{var ue;if(!R||L===void 0)return;const V=(ue=Ge.get(k))==null?void 0:ue.find(ke=>ke.property===L),Y=be(k);return V&&!V.anchor&&Y?Y.y-Y.h/2+V.top+V.height/2:void 0},De=(k,L)=>{var ue,ke;if(L===void 0)return;const V=(ke=(ue=Ge.get(k))==null?void 0:ue.find(we=>we.property===L))==null?void 0:ke.anchor,Y=be(k);return V&&Y?{x:Y.x-Y.w/2+V.x,y:Y.y-Y.h/2+V.y,side:V.side}:void 0},mt=(k,L)=>{const V=be(k),Y=fe.get(k);return V&&Y&&!ge.has(k)&&Je(k,L)===void 0?xn(V,Y):V},kt=()=>{const k=[];se.current.forEach((L,V)=>{if(Re.current.has(V))return;const Y=be(V);Y&&k.push(Xt(Y))}),Re.current.forEach(L=>k.push(L));try{for(const L of[P.current,$.current]){const V=L==null?void 0:L.getBBox();V&&V.width>0&&V.height>0&&k.push({x1:V.x,y1:V.y,x2:V.x+V.width,y2:V.y+V.height})}}catch{}return No(k)},Zt=()=>{var V,Y;const{pan:k,zoom:L}=I;N.current&&(N.current.style.transform=`translate3d(${k.x}px, ${k.y}px, 0) scale(${L})`),(V=P.current)==null||V.setAttribute("transform",`translate(${k.x} ${k.y}) scale(${L})`),(Y=$.current)==null||Y.setAttribute("transform",`translate(${k.x} ${k.y}) scale(${L})`)};j.useEffect(()=>{Zt();let k=null,L;const V=I.onChange(()=>{Zt();const Y=M.current;Y&&(Y.classList.add("flow-sdk-busy"),clearTimeout(L),L=setTimeout(()=>Y.classList.remove("flow-sdk-busy"),150)),k===null&&(k=requestAnimationFrame(()=>{var ue,ke;k=null,(ke=(ue=E.current).onViewportChange)==null||ke.call(ue,I.state)}))});return()=>{V(),clearTimeout(L),k!==null&&cancelAnimationFrame(k)}},[]),j.useLayoutEffect(()=>{const k=M.current;if(!k)return;const L=()=>{var we;if(!k.getClientRects().length)return;let Y=k.clientWidth,ue=k.clientHeight;ue||(ue=Math.max(0,window.innerHeight-k.getBoundingClientRect().top-100),ue&&(k.style.height=`${ue}px`)),Y||(Y=window.innerWidth,Y&&(k.style.width=`${Y}px`));const ke=I.size.w!==Y||I.size.h!==ue;I.size={w:Y,h:ue},ke&&((we=Ye.current)!=null&&we.options.fill)&&B(),!ce.current&&!se.current.size&&E.current.fitOnInit!==!1&&(I.set({x:Y/2,y:ue/2}),Zt())};if(L(),typeof ResizeObserver>"u")return;const V=new ResizeObserver(L);return V.observe(k),()=>V.disconnect()},[I]),j.useLayoutEffect(()=>{if(Gt.current){Gt.current=!1;const L=Rt.current.flatMap(Y=>{const ue=be(Y);return ue?[Xt(ue)]:[]});Rt.current=[];const V=No(L);if(V){Be.current=!1,I.center(V,E.current.animateViewport);return}}if(!Be.current)return;Be.current=!1;const k=kt();k&&(I.fit(k,50,ce.current&&E.current.animateViewport),ce.current||Zt())},[Q]);const wt=j.useMemo(()=>{const k=oe=>{const ee=E.current;if(ee.nodeGridSpacing!=="layout")return oe;const me=ee.direction==="LR"||ee.direction==="RL";return{...oe,gaps:{x:me?ee.rankSep:ee.edgeSep,y:me?ee.edgeSep:ee.rankSep}}},L=()=>{const oe=E.current,ee=T.current.nodes.filter(me=>nr(me.id,oe.edges,oe.edgeMode)&&(!ct.current||ct.current.has(me.id)));return{nodes:ee,positions:se.current,sizes:new Map(ee.map(me=>[me.id,K.current.get(me.id)??Wn])),padding:me=>E.current.containerStyle(me).padding,minSize:Me,fixedIds:new Set(F.current.keys()),viewportSize:{...I.size}}},V=oe=>Mu(oe,E.current.nodes,E.current.edges),Y=(oe,ee=!0,me=()=>{},pe,Ue,$e=!1)=>{clearTimeout(ve.current),clearTimeout(Oe.current),$e||(We.current=null),et.current=null,Be.current=!1,Rt.current=[],Gt.current=!1,I.cancelAnimation();const Pe=ee&&!E.current.isPerformanceMode&&!E.current.disableAnimations,dt=I.coordinate(()=>{var ze;pe?pe(Pe):$e&&((ze=We.current)==null||ze.call(We,oe))});gr(new Map([...oe].map(([ze,ht])=>[ze,{...ht}])),Pe,dt,me,Ue)},ue=(oe,ee=50,me=E.current.animateViewport,pe=1,Ue=!1)=>{const $e=Pe=>{const dt=T.current,ze=oe??new Set(dt.nodes.map(St=>St.id)),ht=new Set(dt.nodes.map(St=>St.parent).filter(Boolean));if(!Pe&&(!oe||[...oe].some(St=>ht.has(St))))return;const rr=Pe&&ld(dt.nodes,Pe,K.current,St=>E.current.containerStyle(St).padding,Me),rn=No([...ze].flatMap(St=>{const cu=rr==null?void 0:rr.get(St);if(cu)return[cu];const lu=Pe==null?void 0:Pe.get(St),ex=K.current.get(St)||Wn,du=lu?{...lu,...ex}:be(St);return du?[Xt(du)]:[]}));rn&&(Be.current=!1,Rt.current=[],Gt.current=!1,I.fit(rn,Number.isFinite(ee)?Math.max(0,ee):50,me,pe))};We.current=Ue?$e:null,Ue||$e(se.current)},ke=(oe,ee,me,pe)=>{var $e;if(!be(oe))return;const Ue=ee==="connections"?Ee(oe):V(oe);if(ee==="connections"&&tr.current===1.25&&(($e=ct.current)==null?void 0:$e.size)===Ue.size&&[...Ue].every(Pe=>ct.current.has(Pe))){S({id:oe,mode:ee});return}Wt.current||(Wt.current={pan:{...I.pan},zoom:I.zoom}),ct.current=Ue,E.current.compactPropertyLayout&&(Be.current=!1,et.current=()=>ue(ct.current??Ue,me,pe)),S({id:oe,mode:ee}),E.current.compactPropertyLayout||ue(Ue,me,pe)},we=oe=>{et.current?et.current=oe:oe()},Ee=oe=>Lu(oe,E.current.nodes,E.current.edges),qe=(oe=>{var ee,me,pe;if(oe===void 0)return I.zoom;oe<I.zoom&&((ee=Ye.current)!=null&&ee.options.fill)&&!E.current.readOnly&&((pe=(me=E.current).onNodeGridZoomOut)==null?void 0:pe.call(me,Ye.current.options))===!0||(We.current=null,I.set(void 0,oe))}),je=(oe=>{if(oe===void 0)return I.pan;We.current=null,I.set(oe)}),Le=(oe,ee)=>{var pe;const me=(pe=M.current)==null?void 0:pe.getBoundingClientRect();return{x:oe-((me==null?void 0:me.left)??0),y:ee-((me==null?void 0:me.top)??0)}},Ze=(oe=0,ee=E.current.animateViewport,me=!1)=>{if(me){ue(void 0,oe,ee,1,!0);return}We.current=null,we(()=>{const pe=kt();pe&&I.fit(pe,oe,ee)})};return{zoom:qe,pan:je,setEdgesVisible:He,focusNode:(oe,ee,me,pe)=>we(()=>ue(new Set([oe]),ee,me,.6,pe)),focusBranch:(oe,ee,me)=>we(()=>ue(V(oe),ee,me)),focusConnections:(oe,ee,me,pe)=>we(()=>ue(Ee(oe),ee,me,1,pe)),isolateConnections:(oe,ee,me)=>ke(oe,"connections",ee,me),isolateBranch:(oe,ee,me)=>ke(oe,"branch",ee,me),restoreView:(oe=E.current.animateViewport,ee)=>{We.current=null;const me=E.current.compactPropertyLayout&&!!ct.current;ct.current=null,S(null);const pe=ee??Wt.current;Wt.current=null,me?et.current=()=>{pe&&I.transition(pe,oe)}:pe&&we(()=>I.transition(pe,oe))},zoomAt:(oe,ee)=>{var me,pe,Ue;oe<I.zoom&&((me=Ye.current)!=null&&me.options.fill)&&!E.current.readOnly&&((Ue=(pe=E.current).onNodeGridZoomOut)==null?void 0:Ue.call(pe,Ye.current.options))===!0||(We.current=null,I.zoomAt(oe,ee))},fit:Ze,centerAndFit:Ze,center:(oe=E.current.animateViewport)=>{We.current=null;const ee=kt();ee&&I.center(ee,oe)},clientToModel:(oe,ee)=>I.renderedToModel(Le(oe,ee)),modelToClient:oe=>{var pe;const ee=(pe=M.current)==null?void 0:pe.getBoundingClientRect(),me=I.modelToRendered(oe);return{x:me.x+((ee==null?void 0:ee.left)??0),y:me.y+((ee==null?void 0:ee.top)??0)}},getNodeBox:oe=>be(oe),detectNodeCollisions:oe=>{const ee=L();return qv({...ee,sizes:new Map([...ee.sizes,...he.current]),fixedSizes:he.current},oe)},resolveNodeCollisions:(oe={})=>{const ee=mj(L(),oe);return ee.movedNodeIds.length&&Y(ee.positions,oe.animate),ee},arrangeNodesInGrid:(oe={})=>{const ee=L(),me=Ye.current;if(me){ee.positions=new Map(ee.positions);for(const ze of ee.nodes)ee.positions.has(ze.id)||ee.positions.set(ze.id,I.renderedToModel({x:I.size.w/2,y:I.size.h/2}));const $e=new Set(ee.nodes.map(ze=>ze.id));me.order=me.order.filter(ze=>$e.has(ze));const Pe=new Set(me.order);me.order.push(...ee.nodes.filter(ze=>!Pe.has(ze.id)).map(ze=>ze.id));const dt=new Map(me.order.map((ze,ht)=>[ze,ht]));ee.nodes=[...ee.nodes].sort((ze,ht)=>dt.get(ze.id)-dt.get(ht.id))}const pe=Ql(ee,k(oe));Et(pe.dividers??[]),me&&(me.ready=!1);const Ue=()=>{me&&(me.ready=!0)};return!pe.sizes&&he.current.size&&G(),pe.movedNodeIds.length||pe.bounds||We.current?Y(pe.positions,oe.animate,Ue,pe.bounds&&(!me||!he.current.size)?()=>I.transition({zoom:1,pan:{x:0,y:0}},!1):void 0,pe.sizes,!!me&&!pe.bounds):Ue(),pe},setNodeGridMode:(oe,ee={})=>{var me,pe,Ue,$e;if(ee.order&&(!Array.isArray(ee.order)||ee.order.some(Pe=>typeof Pe!="string")||new Set(ee.order).size!==ee.order.length))throw new Error("Invalid grid node order.");if(oe){Ql(L(),k(ee));const Pe=!Ye.current||Ye.current.options.fill&&!ee.fill;We.current=null,Ye.current||(Ye.current={options:ee,order:L().nodes.map(dt=>dt.id),previousPositions:new Map([...se.current].map(([dt,ze])=>[dt,{...ze}])),previousViewport:{zoom:I.zoom,pan:{...I.pan}},previousSize:{...I.size},ready:!1}),Pe&&wt.centerAndFit(80,ee.animate,!0),ee.order&&(Ye.current.order=[...ee.order]),Ye.current.options={...ee},gt(!0),wt.arrangeNodesInGrid(ee),(pe=(me=E.current).onNodeGridModeChange)==null||pe.call(me,{...ee,order:[...Ye.current.order]})}else{const Pe=Ye.current;if(!Pe)return;I.size.w===Pe.previousSize.w&&I.size.h===Pe.previousSize.h&&se.current.size===Pe.previousPositions.size&&[...se.current.keys()].every(ht=>Pe.previousPositions.has(ht))?We.current=()=>I.transition(Pe.previousViewport,ee.animate!==!1&&!E.current.disableAnimations&&!E.current.isPerformanceMode):wt.centerAndFit(80,ee.animate,!0),Ye.current=null,gt(!1),G(),($e=(Ue=E.current).onNodeGridModeChange)==null||$e.call(Ue,null),Vt(null);const ze=new Map([...se.current].map(([ht,rr])=>[ht,Pe.previousPositions.get(ht)??rr]));Y(ze,ee.animate,void 0,void 0,void 0,!0)}},swapGridNodes:(oe,ee,me)=>{var rr,rn;const pe=Ye.current;if(!pe||!pe.ready||E.current.readOnly||oe===ee)return!1;const Ue=L(),$e=Ue.nodes.find(St=>St.id===oe),Pe=Ue.nodes.find(St=>St.id===ee);if(!$e||!Pe||$e.parent!==Pe.parent)return!1;const dt=Ql(Ue,k(pe.options));if(dt.skippedNodeIds.includes(oe)||dt.skippedNodeIds.includes(ee))return!1;const ze=pe.order.indexOf(oe),ht=pe.order.indexOf(ee);return ze<0||ht<0?!1:([pe.order[ze],pe.order[ht]]=[pe.order[ht],pe.order[ze]],We.current=null,pe.options={...pe.options,order:[...pe.order]},wt.arrangeNodesInGrid({...pe.options,animate:me??pe.options.animate}),(rn=(rr=E.current).onNodeGridModeChange)==null||rn.call(rr,{...pe.options}),!0)},setNodePosition:(oe,ee,me)=>{if(!se.current.has(oe)||ee&&(!Number.isFinite(ee.x)||!Number.isFinite(ee.y)))return!1;if(Jt(),!ee)return F.current.delete(oe),B(),!0;const pe=new Map(se.current);return pe.set(oe,{...ee}),(me==null?void 0:me.persist)===!1?F.current.delete(oe):F.current.set(oe,{...ee}),se.current=pe,ae(pe),(me==null?void 0:me.persist)===!1&&B(),!0},onViewportChange:oe=>I.onChange(oe)}},[]);j.useEffect(()=>{var k,L;return(L=(k=E.current).onInit)==null||L.call(k,wt),()=>I.cancelAnimation()},[wt]),j.useEffect(()=>{var k,L;if(X>0){const V=et.current;et.current=null,V==null||V(),(L=(k=E.current).onLayoutComplete)==null||L.call(k,wt)}},[wt,X]);const lt=j.useRef(null),Ct=j.useRef(new Map),yr=j.useRef(!1),[mr,Ln]=j.useState(null),[ot,en]=j.useState(null),Fn=k=>{const L=M.current.getBoundingClientRect();return{x:(k.clientX-L.left)*(M.current.clientWidth/L.width||1),y:(k.clientY-L.top)*(M.current.clientHeight/L.height||1)}},zn=(k,L)=>{const V=E.current.nodes;for(let Y=V.length-1;Y>=0;Y--){const ue=V[Y].id;if(!nr(ue,E.current.edges,E.current.edgeMode)||ct.current&&!ct.current.has(ue)||ue===L||Re.current.has(ue))continue;const ke=be(ue);if(ke&&Tu(k,Xt(ke)))return ue}for(const[Y,ue]of Re.current)if(nr(Y,E.current.edges,E.current.edgeMode)&&!(ct.current&&!ct.current.has(Y))&&Y!==L&&Tu(k,ue))return Y;return null},tu=(k,L)=>{const V=E.current.nodes.find(Ee=>Ee.id===k),Y=be(k);if(!V||!Y)return null;const ue=Xt({...Y,x:Y.x+L.x,y:Y.y+L.y});let ke=null,we=0;for(const Ee of E.current.nodes){if(Ee.id===k||Ee.parent!==V.parent||F.current.has(Ee.id)||Re.current.has(Ee.id)||!nr(Ee.id,E.current.edges,E.current.edgeMode)||ct.current&&!ct.current.has(Ee.id))continue;const qe=be(Ee.id);if(!qe)continue;const je=Xt(qe),Le=Math.max(0,Math.min(ue.x2,je.x2)-Math.max(ue.x1,je.x1))*Math.max(0,Math.min(ue.y2,je.y2)-Math.max(ue.y1,je.y1));Le>we&&(we=Le,ke=Ee.id)}return ke},Ro=(k,L)=>{if(E.current.edgeMode==="nodes"||E.current.edgeMode==="workflow")return null;const V=E.current.direction==="RL",Y=Math.max(16,6/I.zoom);let ue=null;for(const ke of[...E.current.nodes].reverse()){if(!nr(ke.id,E.current.edges,E.current.edgeMode)||ct.current&&!ct.current.has(ke.id))continue;const we=be(ke.id),Ee=z.current.get(ke.id);if(!we||!Ee||Re.current.has(ke.id))continue;const qe=we.x+(L==="source"!==V?1:-1)*we.w/2;for(const je of Ee){if(je.role&&je.role!==L)continue;const Le=we.y-we.h/2+je.top,Ze=Math.hypot(k.x-(je.anchor?we.x-we.w/2+je.anchor.x:qe),k.y-Le-je.height/2);if(!je.anchor&&k.x>=we.x-we.w/2&&k.x<=we.x+we.w/2&&k.y>=Le&&k.y<=Le+je.height)return{nodeId:ke.id,property:je.property};Ze<=Y&&(!ue||Ze<ue.distance)&&(ue={nodeId:ke.id,property:je.property,distance:Ze})}}return ue},Hv=k=>{var Ee,qe;if(!k.currentTarget.contains(k.target)||(lt.current||(yr.current=!1),k.target.closest(".flow-sdk-canvas")!==k.currentTarget)||k.button!==0||E.current.readOnly)return;const L=k.target;if(L.closest('input, textarea, select, [contenteditable="true"], [data-flow-content-toggle]'))return;const V=E.current,Y=Fn(k);if(k.pointerType==="touch"){Ct.current.set(k.pointerId,Y);const je=um(Ct.current);if(je){Vt(null),lt.current={kind:"pinch",distance:je.distance,zoom:I.zoom,anchor:I.renderedToModel(je.center)},en(null),Ln(null),yr.current=!0;for(const Le of Ct.current.keys())k.currentTarget.setPointerCapture(Le);return}}if(lt.current)return;const ue=!Ye.current||!!V.nodeGridConnections,ke=V.drawHandles&&L.closest(".flow-sdk-handle"),we=V.drawHandles&&L.closest(".flow-sdk-property-port");if((!ue||!ke&&!we&&(!V.drawMode||k.shiftKey))&&(Ye.current||k.shiftKey&&(V.onNodeGridDrop||V.onNodeParentChange))){if(Ye.current&&!Ye.current.ready||L.closest("button, input, textarea, select, a, [contenteditable=true], [data-flow-content]"))return;const je=(Ee=L.closest("[data-node-id]"))==null?void 0:Ee.dataset.nodeId;if(je&&!F.current.has(je)){lt.current={kind:"grid",pointerId:k.pointerId,source:je,start:Y,moved:!1};return}if(je)return}if(ue&&(V.drawMode||ke||we)){const je=I.renderedToModel(Y),Le=V.drawMode?Ro(je,"source"):null,Ze=we||ke,oe=Ze?(qe=Ze.closest("[data-node-id]"))==null?void 0:qe.dataset.nodeId:(Le==null?void 0:Le.nodeId)??zn(je),ee=we?we.dataset.property:Le==null?void 0:Le.property;if(oe){lt.current={kind:"draw",pointerId:k.pointerId,source:oe,sourceProperty:ee,reverse:(we==null?void 0:we.dataset.portRole)==="target",startClient:{x:k.clientX,y:k.clientY}},yr.current=!0,en({source:oe,sourceProperty:ee,point:je,target:null}),k.currentTarget.setPointerCapture(k.pointerId);return}}L.closest(".flow-sdk-node, .flow-sdk-container, .flow-sdk-edge, .flow-sdk-edge-label, .flow-sdk-container-label")||(We.current=null,V.multiSelect?lt.current={kind:"box",pointerId:k.pointerId,start:Y,current:Y}:V.dragMode?lt.current={kind:"pan",pointerId:k.pointerId,start:Y,pan0:I.pan,moved:!1}:lt.current={kind:"tap",pointerId:k.pointerId,start:Y,moved:!1},k.currentTarget.setPointerCapture(k.pointerId))},Kv=k=>{var Y,ue,ke;const L=lt.current;if(!L||E.current.readOnly)return;const V=Fn(k);if(Ct.current.has(k.pointerId)&&Ct.current.set(k.pointerId,V),L.kind==="pinch"){const we=um(Ct.current);if(!we)return;const Ee=Math.max(I.minZoom,Math.min(I.maxZoom,L.zoom*we.distance/L.distance));if(Ee<I.zoom&&((Y=Ye.current)!=null&&Y.options.fill)&&((ke=(ue=E.current).onNodeGridZoomOut)==null?void 0:ke.call(ue,Ye.current.options))===!0)return;I.set({x:we.center.x-L.anchor.x*Ee,y:we.center.y-L.anchor.y*Ee},Ee);return}if(L.pointerId===k.pointerId)switch(L.kind){case"grid":{const we={x:V.x-L.start.x,y:V.y-L.start.y};if(!L.moved&&Math.hypot(we.x,we.y)<=ed)return;L.moved||(Jt(),We.current=null,I.cancelAnimation(),k.currentTarget.setPointerCapture(k.pointerId)),L.moved=!0,yr.current=!0,k.preventDefault();const Ee={x:we.x/I.zoom,y:we.y/I.zoom};Vt({source:L.source,offset:Ee,target:k.shiftKey?null:tu(L.source,Ee),shiftKey:k.shiftKey});break}case"pan":{const we=V.x-L.start.x,Ee=V.y-L.start.y;if(!L.moved&&Math.hypot(we,Ee)<=ed)return;L.moved=!0,yr.current=!0,I.set({x:L.pan0.x+we,y:L.pan0.y+Ee});break}case"tap":{Math.hypot(V.x-L.start.x,V.y-L.start.y)>ed&&(L.moved=!0);break}case"box":{yr.current=!0,L.current=V,Ln({x1:Math.min(L.start.x,V.x),y1:Math.min(L.start.y,V.y),x2:Math.max(L.start.x,V.x),y2:Math.max(L.start.y,V.y)});break}case"draw":{const we=I.renderedToModel(V),Ee=Ro(we,L.reverse?"source":"target");en(L.reverse&&Ee?{source:Ee.nodeId,sourceProperty:Ee.property,point:we,target:L.source,targetProperty:L.sourceProperty}:{source:L.source,sourceProperty:L.sourceProperty,point:we,target:(Ee==null?void 0:Ee.nodeId)??zn(we,L.source),targetProperty:Ee==null?void 0:Ee.property});break}}},ru=(k,L)=>{var ue,ke,we,Ee,qe,je,Le,Ze,oe,ee,me;Ct.current.delete(k.pointerId);const V=lt.current;if(!V)return;if(V.kind==="pinch"){const pe=[...Ct.current][0];lt.current=pe&&E.current.dragMode&&!L?{kind:"pan",pointerId:pe[0],start:pe[1],pan0:I.pan,moved:!0}:null;return}if(V.pointerId!==k.pointerId)return;lt.current=null;try{k.currentTarget.releasePointerCapture(k.pointerId)}catch{}const Y=E.current;switch(L=L||!!Y.readOnly,V.kind){case"grid":{if(Vt(null),L||!V.moved||((ue=Y.onNodeGridDrop)==null?void 0:ue.call(Y,V.source,{x:k.clientX,y:k.clientY},{shiftKey:k.shiftKey,ctrlKey:k.ctrlKey,metaKey:k.metaKey,altKey:k.altKey}))===!0)break;const pe=Fn(k);if(pe.x<0||pe.y<0||pe.x>I.size.w||pe.y>I.size.h)break;if(k.shiftKey){const $e=new Map(Y.nodes.map(ze=>[ze.id,ze]));let Pe=zn(I.renderedToModel(pe),V.source);const dt=new Set;for(;Pe&&!((ke=$e.get(Pe))!=null&&ke.acceptsChildren)&&!dt.has(Pe);)dt.add(Pe),Pe=((we=$e.get(Pe))==null?void 0:we.parent)??null;if(Pe&&((Ee=$e.get(Pe))!=null&&Ee.acceptsChildren)){let ze=Pe;const ht=new Set;for(;ze&&!ht.has(ze);)ht.add(ze),ze=(qe=$e.get(ze))==null?void 0:qe.parent;ht.has(V.source)||(je=Y.onNodeParentChange)==null||je.call(Y,V.source,Pe)}break}if(!Ye.current)break;const Ue=tu(V.source,{x:(pe.x-V.start.x)/I.zoom,y:(pe.y-V.start.y)/I.zoom});Ue&&wt.swapGridNodes(V.source,Ue,!1);break}case"pan":case"tap":!L&&!V.moved&&((Le=Y.onBackgroundTap)==null||Le.call(Y));break;case"box":{if(Ln(null),L)break;const pe=I.renderedToModel(V.start),Ue=I.renderedToModel(V.current),$e={x1:Math.min(pe.x,Ue.x),y1:Math.min(pe.y,Ue.y),x2:Math.max(pe.x,Ue.x),y2:Math.max(pe.y,Ue.y)};if($e.x2-$e.x1<1&&$e.y2-$e.y1<1){(Ze=Y.onBackgroundTap)==null||Ze.call(Y);break}const Pe=[];for(const dt of Y.nodes){const ze=be(dt.id);ze&&Mw(Xt(ze),$e)&&Pe.push(dt.id)}Pe.length&&((oe=Y.onBoxSelect)==null||oe.call(Y,Pe));break}case"draw":{if(en(null),L)break;const pe=Fn(k),Ue=I.renderedToModel(pe),$e=Ro(Ue,V.reverse?"source":"target"),Pe=($e==null?void 0:$e.nodeId)??zn(Ue);if(Pe===V.source&&(V.sourceProperty===void 0||($e==null?void 0:$e.property)===void 0||$e.property===V.sourceProperty))break;Pe?(ee=Y.onEdgeDraw)==null||ee.call(Y,V.reverse?Pe:V.source,V.reverse?V.source:Pe,V.sourceProperty!==void 0||($e==null?void 0:$e.property)!==void 0?{sourceProperty:V.reverse?$e==null?void 0:$e.property:V.sourceProperty,targetProperty:V.reverse?V.sourceProperty:$e==null?void 0:$e.property}:void 0):Math.max(Math.abs(k.clientX-V.startClient.x),Math.abs(k.clientY-V.startClient.y))>Ej&&((me=Y.onDrawIntoSpace)==null||me.call(Y,V.source,Ue,V.sourceProperty,V.reverse));break}}},br=j.useCallback(()=>{var V;const k=lt.current,L=[...Ct.current.keys()];k&&k.kind!=="pinch"&&L.push(k.pointerId),lt.current=null,Ct.current.clear(),Vt(null),en(null),Ln(null);for(const Y of L)(V=M.current)!=null&&V.hasPointerCapture(Y)&&M.current.releasePointerCapture(Y)},[]);j.useEffect(()=>{const k=L=>{L.key==="Escape"&&br()};return window.addEventListener("keydown",k),window.addEventListener("blur",br),()=>{window.removeEventListener("keydown",k),window.removeEventListener("blur",br),lt.current=null,Ct.current.clear()}},[br]),j.useEffect(()=>{br()},[g,b,v,o,n,e.drawHandles,e.readOnly,tt,br]);const Jv=j.useMemo(()=>{const k=new Map,L=new Map;for(const V of A){if(V.source!==V.target)continue;const Y=k.get(V.source)??0;k.set(V.source,Y+1),L.set(V.id,Y)}return L},[A]),ko=_j[n],[Ao,Zv]=j.useState(null),Po=Sj(r,A,!!((iu=e.edgeReveal)!=null&&iu.revealNodes));j.useLayoutEffect(()=>{M.current&&Ao&&vj(M.current)});const Io=Pw(A,mt,ko),Xv=e.onEdgeSelect,Yv=e.onContainerSelect,nu=ot?ot.target&&mt(ot.target,ot.targetProperty)||{x:ot.point.x,y:ot.point.y,w:1,h:1}:null,ou=ot?mt(ot.source,ot.sourceProperty):null,tn=!tt||!!e.nodeGridConnections,Qv=["flow-sdk-canvas",g&&tn?"flow-sdk-draw":"",x?"flow-sdk-perf":""].filter(Boolean).join(" ");return f.jsxs("div",{ref:M,className:Qv,"data-edge-mode":o,"data-node-grid":tt||void 0,"data-grid-connections":e.nodeGridConnections||void 0,onPointerDownCapture:Hv,onPointerMove:Kv,onPointerUp:k=>ru(k,!1),onPointerCancel:k=>ru(k,!0),onLostPointerCapture:k=>{const L=lt.current;L&&(L.kind==="pinch"||L.pointerId===k.pointerId)&&br()},onClickCapture:k=>{if(!k.currentTarget.contains(k.target))return;const L=k.target instanceof Element&&k.target.closest("button[data-flow-fullscreen]");(yr.current||e.readOnly&&!L)&&(k.preventDefault(),k.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(([k])=>nr(k,t,o)).filter(([k])=>!_||_.has(k)).map(([k,L])=>{var V,Y;return f.jsx(Vw,{id:k,rect:L,label:H.get(k),labelLayer:Ao,labelContent:(V=r.find(ue=>ue.id===k&&ue.label!==void 0))==null?void 0:V.element,style:y(k),onSelect:Yv,onCollapse:e.readOnly?void 0:e.onContainerCollapse,selected:(Y=e.selectedNodeIds)==null?void 0:Y.includes(k)},k)})}),f.jsx("g",{className:"flow-sdk-edges",children:Ie&&tn&&A.map(k=>{var Y,ue,ke;if(!Po.ready.has(k.id)||_&&(!_.has(k.source)||!_.has(k.target)))return null;const L=mt(k.source,k.sourceProperty),V=mt(k.target,k.targetProperty);return!L||!V?null:f.jsx(zu,{id:k.id,edgeData:k.data,validationIssue:k.validationIssue,edgeType:k.type,edgeRadius:e.edgeRadius,propertyMode:R,customEdgeTypes:e.customEdgeTypes,reveal:e.edgeReveal,onRevealComplete:Po.complete,source:L,target:V,sourceProperty:k.sourceProperty,targetProperty:k.targetProperty,sourceY:Je(k.source,k.sourceProperty),targetY:Je(k.target,k.targetProperty),sourcePort:De(k.source,k.sourceProperty),targetPort:De(k.target,k.targetProperty),dir:ko,turn:((Y=Io.get(k.id))==null?void 0:Y.turn)??k.turn,labelAtTarget:(ue=Io.get(k.id))==null?void 0:ue.labelAtTarget,labelFraction:(ke=Io.get(k.id))==null?void 0:ke.labelFraction,color:k.color,connectorColor:k.connectorColor,labelBg:k.labelBg,label:k.label,labelLayer:Ao,dashed:k.dashed,animated:k.animated&&!x,inverted:k.inverted,loopIndex:Jv.get(k.id)??0,onSelect:Xv},k.id)})}),Ie&&tn&&ot&&cd(ot,o)&&ou&&nu&&f.jsx("g",{className:"flow-sdk-ghost",pointerEvents:"none",children:f.jsx(zu,{id:"__flow-sdk-ghost",edgeData:{id:"__flow-sdk-ghost",source:ot.source,target:ot.target??"",sourceProperty:ot.sourceProperty,targetProperty:ot.targetProperty},edgeType:e.edgeType,edgeRadius:e.edgeRadius,propertyMode:R,customEdgeTypes:e.customEdgeTypes,source:ou,target:nu,sourceProperty:ot.sourceProperty,targetProperty:ot.targetProperty,sourceY:Je(ot.source,ot.sourceProperty),sourcePort:De(ot.source,ot.sourceProperty),targetPort:ot.target?De(ot.target,ot.targetProperty):void 0,targetY:ot.target?Je(ot.target,ot.targetProperty):void 0,dir:ko,turn:.5,color:m,labelBg:m})})]})}),f.jsxs("div",{ref:N,className:"flow-sdk-nodes",children:[tt&&((au=Ye.current)==null?void 0:au.options.fill)&&((su=Ye.current.options.adjustment)==null?void 0:su.enabled)&&!e.readOnly&&f.jsx(bj,{dividers:at,options:Ye.current.options,zoom:I.zoom,onChange:k=>wt.setNodeGridMode(!0,{...k,animate:!1})}),r.map(k=>{var Ue,$e;const L=Q.get(k.id),V=ge.get(k.id);if(V&&k.label!==void 0)return null;const Y=(L==null?void 0:L.x)??(V?(V.x1+V.x2)/2:0),ue=(L==null?void 0:L.y)??(V?(V.y1+V.y2)/2:0),ke=Xe!=null&&Xe.target?k.id===Xe.source?Xe.target:k.id===Xe.target?Xe.source:void 0:void 0,we=ke?Q.get(ke):void 0,Ee=Xe?Q.get(Xe.source):void 0,qe=Xe!=null&&Xe.target?Q.get(Xe.target):void 0,je=Ee&&qe?{x:qe.x-Ee.x,y:qe.y-Ee.y}:void 0,Le=je?je.x**2+je.y**2:0,Ze=Le&&Xe&&je?Math.max(0,Math.min(1,(Xe.offset.x*je.x+Xe.offset.y*je.y)/Le)):0,oe=we?{x:Y+(we.x-Y)*Ze,y:ue+(we.y-ue)*Ze}:(Xe==null?void 0:Xe.source)===k.id?{x:Y+Xe.offset.x,y:ue+Xe.offset.y}:void 0,ee=Ce.get(k.id),me=ke?Ce.get(ke):void 0,pe=ee&&me?{w:ee.w+(me.w-ee.w)*Ze,h:ee.h+(me.h-ee.h)*Ze}:ee;return f.jsx(Cj,{id:k.id,x:Y,y:ue,gridDraggable:tt&&!e.readOnly&&!F.current.has(k.id),gridDragging:(Xe==null?void 0:Xe.source)===k.id,gridDropTarget:(Xe==null?void 0:Xe.target)===k.id,gridSize:Ce.get(k.id),gridPreview:oe?{...oe,size:pe,floating:Xe==null?void 0:Xe.shiftKey}:void 0,placed:!!L||!!V,hidden:!tt&&!Po.shown.has(k.id)||!nr(k.id,t,o)||!!_&&!_.has(k.id),onMount:ne,drawHandles:e.drawHandles&&!e.readOnly&&tn,drawMode:g&&tn,connectedPorts:new Set(A.flatMap(Pe=>[...Pe.source===k.id&&Pe.sourceProperty!==void 0?[`source:${Pe.sourceProperty}`]:[],...Pe.target===k.id&&Pe.targetProperty!==void 0?[`target:${Pe.targetProperty}`]:[]])),hasCollapseControl:k.hasCollapseControl,handleColor:m,animated:k.animated&&!V&&!x&&!tt,animationColor:k.animationColor,animationWidth:k.animationWidth,animationVariant:k.animationVariant,width:(Ue=K.current.get(k.id))==null?void 0:Ue.w,height:($e=K.current.get(k.id))==null?void 0:$e.h,propertyMode:R,resolvedRows:Ge.get(k.id),reversePorts:n==="RL",direction:n,onPropertyRows:de,onSurface:q,children:ee?k.fillElement??k.element:k.element},k.id)})]}),mr&&f.jsx("div",{className:"flow-sdk-box",style:{left:mr.x1,top:mr.y1,width:mr.x2-mr.x1,height:mr.y2-mr.y1}}),f.jsx("svg",{className:"flow-sdk-svg flow-sdk-label-overlay",style:{zIndex:11,pointerEvents:"none"},children:f.jsx("g",{ref:$,transform:`translate(${I.pan.x} ${I.pan.y}) scale(${I.zoom})`,children:f.jsx("g",{ref:Zv,className:"flow-sdk-labels",style:{pointerEvents:g?"none":"visiblePainted",outline:"none"}})})})]})}const Pj=j.memo(Aj);function Xd(e=!0){const r=j.useRef(null);return j.useEffect(()=>{if(!e||!r.current)return;const t=o=>{o.stopPropagation()},n=r.current,i=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return i.forEach(o=>n.addEventListener(o,t)),()=>{i.forEach(o=>n.removeEventListener(o,t))}},[e]),r}const Gr=({nodeId:e,label:r,color:t,fontWeight:n="bold",fontSize:i="5xl",wrap:o=!1,isEditing:s,onEditStart:a,onEditEnd:l})=>{const{callbacks:c,config:d,readOnly:u}=Ve(),h=d.editable&&!u,[p,y]=j.useState(r),[m,g]=j.useState(),b=j.useRef(null),v=j.useRef(!1),x=Xd(s);j.useEffect(()=>{if(s&&(v.current=!1,b.current)){b.current.focus();const C=b.current.value.length;b.current.setSelectionRange(C,C)}},[s]);const w=()=>{var S;if(v.current)return;v.current=!0;const C=p.trim();C&&C!==r&&((S=c.onNodeLabelChange)==null||S.call(c,e,C)),l()};return!h||!s?f.jsx(D.Text,{color:t,fontWeight:n,fontSize:i,minW:0,maxW:"100%",whiteSpace:o?"normal":"nowrap",overflowWrap:o?"anywhere":void 0,overflow:"hidden",textOverflow:"ellipsis",title:r,onDoubleClick:h?C=>{C.stopPropagation(),g({width:C.currentTarget.offsetWidth,height:C.currentTarget.offsetHeight}),y(r),a()}:void 0,cursor:h?"text":void 0,children:r}):f.jsxs("div",{ref:x,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(D.Text,{as:"span","aria-hidden":"true",display:"block",visibility:"hidden",fontWeight:n,fontSize:i,lineHeight:"normal",whiteSpace:"pre",overflow:"hidden",children:p||" "}),f.jsx(D.Input,{ref:b,value:p,onChange:C=>y(C.target.value),onBlur:w,onKeyDown:C=>{C.key==="Enter"&&w(),C.key==="Escape"&&(v.current=!0,l())},color:t,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 Lv({id:e,label:r,role:t,side:n,position:i=.5,placement:o,children:s,style:a}){return f.jsx("div",{"data-flow-property":e,"data-flow-port-role":t,"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:t==="source"?"flex-end":"flex-start",...a,...n?{display:"none"}:{}},children:s??r??e})}const Ij=Qn.default.dialog`
|
|
209
|
+
`;function Iu({request:e,property:r,config:t,value:n,disabled:i}){var ye,pe,B,G,se;const{callbacks:o,structured:s,references:a}=S.useContext(It),{themeColor:c}=Ue(),{background:l}=ot(),d=S.useId(),u=r.type.kind==="object"||r.type.kind==="array"||r.type.kind==="json",h=n===void 0?"":u?JSON.stringify(n,null,2):String(n),[p,y]=S.useState(h),[m,g]=S.useState(""),[b,v]=S.useState(0),x=S.useRef(null),w=S.useRef(),[C,j]=S.useState(!1),[_,k]=S.useState(!1),[E,O]=S.useState(),T=((ye=t.$options)==null?void 0:ye.$source)==="callback",P=o.resolveFormOptions,{data:I,address:R,nodeAddress:$,nodeId:N}=e;S.useEffect(()=>(j(!1),k(!1),()=>{var H;(H=w.current)==null||H.abort(),w.current=void 0}),[R,$,N,i,h,t.$control,(pe=t.$upload)==null?void 0:pe.accept,(B=t.$upload)==null?void 0:B.maxSizeBytes]);const M=S.useRef(I);M.current=I;const J=JSON.stringify([R,N,(G=t.$options)!=null&&G.$dependsOn?t.$options.$dependsOn.map(H=>Te(I,H)):Te(I,$)]);S.useEffect(()=>{y(h),g("")},[h,R,N]),S.useEffect(()=>{if(!T)return;const H=new AbortController;return Promise.resolve().then(()=>{if(!P)throw new Error("No options resolver configured");return P({address:R,nodeAddress:$,nodeId:N,data:Wr(M.current),signal:H.signal})}).then(ue=>{if(!Array.isArray(ue)||ue.some(xe=>!xe||typeof xe.label!="string"||!["string","number","boolean"].includes(typeof xe.value)&&xe.value!==null))throw new Error("Invalid options response");H.signal.aborted||O({key:J,options:ue})}).catch(ue=>{H.signal.aborted||O({key:J,options:[],error:ue instanceof Error?ue.message:"Options unavailable"})}),()=>H.abort()},[T,P,J,R,$,N,b]);const ie=T&&(E==null?void 0:E.key)!==J,ae=T?(E==null?void 0:E.key)===J?E.options:[]:r.type.kind==="null"?[{label:"Null",value:null}]:r.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:vn(r.type),te=r.type.kind==="array",he=(t.$control==="upload"?"upload":s&&u||t.$control==="checkbox"?"pills":t.$control)??(ae?te||r.type.kind==="boolean"?"pills":"select":r.type.kind==="boolean"?"checkbox":u?"textarea":"input"),me=!r.optional||!!t.$requiredWhen&&oo(t.$requiredWhen,I),q=me?"Required":"Optional",F=he!=="upload"&&!!(a!=null&&a.length)&&typeof n=="string"&&n.includes("{{"),U=m||T&&(E==null?void 0:E.key)===J&&E.error||!F&&zt(r.type,n,me),D=Ot(t.$label??R.split(".").pop()),de=H=>{var ue;if(!(i||Object.is(H,n)))try{(ue=o.onFormChange)==null||ue.call(o,{...e,previousValue:n,value:H}),g("")}catch(xe){g(xe instanceof Error?xe.message:"Unable to update field")}},Q=S.useRef(de);S.useLayoutEffect(()=>{Q.current=de});const oe=()=>{if(u){try{const Oe=p===""&&r.optional?void 0:JSON.parse(p),Ne=zt(r.type,Oe,me);if(Ne){g(Ne);return}de(Oe)}catch{g("Enter valid JSON")}return}const H=r.type.kind==="number"||r.type.kind==="integer",ue=p===""&&r.optional?void 0:H&&p!==""?Number(p):p,xe=zt(r.type,ue,me);if(H&&xe&&p!==""){g(xe);return}de(ue)},ce=async H=>{var xe,Oe,Ne;if(i||w.current||!H.length)return;const ue=new AbortController;w.current=ue,g(""),j(!0);try{if(r.type.kind!=="string"&&!(r.type.kind==="array"&&r.type.items.kind==="string"))throw new Error("Uploads require a string or string-array field.");if(!te&&H.length!==1)throw new Error("Choose one file for this field.");if(!o.uploadFormFile)throw new Error("No file upload handler configured.");const Be=(Oe=(xe=t.$upload)==null?void 0:xe.accept)==null?void 0:Oe.split(",").map(He=>He.trim().toLowerCase()).filter(Boolean);for(const He of H){if(((Ne=t.$upload)==null?void 0:Ne.maxSizeBytes)!==void 0&&He.size>t.$upload.maxSizeBytes)throw new Error(`${He.name} exceeds the file size limit.`);if(Be!=null&&Be.length&&!Be.some(rt=>rt.startsWith(".")?He.name.toLowerCase().endsWith(rt):rt.endsWith("/*")?He.type.toLowerCase().startsWith(rt.slice(0,-1)):He.type.toLowerCase()===rt))throw new Error(`${He.name} is not an accepted file type.`)}const et=await Promise.all(H.map(async He=>{const rt=await o.uploadFormFile({...e,data:Wr(I),file:He,signal:ue.signal});if(typeof rt!="string")throw new Error("Upload handler must return an HTTP or HTTPS URL.");let ft;try{ft=new URL(rt)}catch{throw new Error("Upload handler must return an HTTP or HTTPS URL.")}if(!["http:","https:"].includes(ft.protocol)||ft.username||ft.password)throw new Error("Upload handler must return an HTTP or HTTPS URL.");return rt}));if(ue.signal.aborted||w.current!==ue)return;const We=te?[...Array.isArray(n)?n:[],...et]:et[0],gt=zt(r.type,We,me);if(gt)throw new Error(gt);Q.current(We)}catch(Be){ue.signal.aborted||g(Be instanceof Error?Be.message:"Unable to upload file."),ue.abort()}finally{w.current===ue&&(w.current=void 0,j(!1))}},we={id:d,disabled:i,"aria-label":D,"aria-required":me,"aria-invalid":!!U,"aria-describedby":U?`${d}-error`:void 0},Se=_e(c);return f.jsxs("div",{"data-form-field":R,"data-flow-property":R.slice($.length+1),children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[f.jsxs("label",{htmlFor:d,children:[D,me?" *":""]}),r.optional&&n!==void 0&&f.jsx("button",{type:"button","aria-label":`Reset ${D}`,title:`Reset ${D}`,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:()=>de(void 0),children:f.jsx(X.PiArrowCounterClockwise,{size:14})})]}),!!(a!=null&&a.length)&&!u&&he!=="upload"&&f.jsx(yw,{label:D,value:n,references:a,disabled:i,onChange:de}),he==="upload"?f.jsxs("div",{"data-form-upload":te?"multiple":"single","aria-busy":C,style:{"--flow-upload-surface":_e(l),outline:_?"2px dashed var(--flow-form-input-background)":void 0,borderRadius:"var(--flow-form-input-radius)"},onDragOver:H=>{H.preventDefault(),H.stopPropagation(),!i&&!C&&(H.dataTransfer.dropEffect="copy",k(!0))},onDragLeave:H=>{H.currentTarget.contains(H.relatedTarget)||k(!1)},onDrop:H=>{H.preventDefault(),H.stopPropagation(),k(!1),ce(Array.from(H.dataTransfer.files))},children:[f.jsx("input",{ref:x,type:"file",hidden:!0,"aria-label":`Upload ${D}`,accept:(se=t.$upload)==null?void 0:se.accept,multiple:te,disabled:i||C,onChange:H=>{const ue=Array.from(H.target.files??[]);H.target.value="",ce(ue)}}),f.jsxs("div",{"data-upload-items":"",children:[(te?Array.isArray(n)?n:[]:n?[n]:[]).map((H,ue)=>f.jsxs("div",{"data-upload-preview":"",children:[typeof H=="string"&&or(H)&&f.jsxs("a",{href:H,target:"_blank",rel:"noopener noreferrer","aria-label":`${D} file ${ue+1}`,children:[f.jsx(X.PiFile,{size:32,"aria-hidden":"true"}),f.jsx(Ht,{name:H,size:120,onError:xe=>{xe.currentTarget.style.visibility="hidden"}})]}),f.jsxs("div",{"data-upload-actions":"",children:[!te&&f.jsx(Ae,{"aria-label":`Replace ${D}`,title:`Replace ${D}`,icon:f.jsx(X.PiUploadSimple,{}),size:"xs",variant:"ghost",disabled:i||C,onClick:()=>{var xe;return(xe=x.current)==null?void 0:xe.click()}}),f.jsx(Ae,{"aria-label":`Remove ${D} file ${ue+1}`,title:"Remove file",icon:f.jsx(X.PiTrash,{}),size:"xs",variant:"ghost",disabled:i||C,onClick:()=>de(te&&Array.isArray(n)?n.filter((xe,Oe)=>Oe!==ue):"")})]})]},`${ue}:${H}`)),(te||!n)&&f.jsx("button",{...we,type:"button","data-upload-drop":"",title:`Upload ${D}`,disabled:i||C,onClick:()=>{var H;return(H=x.current)==null?void 0:H.click()},children:f.jsx(X.PiPlus,{size:28,"aria-hidden":"true"})})]}),C&&f.jsx("span",{role:"status",children:"Uploading..."})]}):F?null:he==="select"?f.jsx("div",{"data-form-select":"",children:f.jsxs(At,{...we,disabled:i||ie||!!(E!=null&&E.error),labelCase:"preserve",value:String((ae==null?void 0:ae.findIndex(H=>Object.is(H.value,n)))??-1),onValueChange:H=>{const ue=ae==null?void 0:ae[Number(H)];ue&&de(ue.value)},children:[f.jsx("option",{value:-1,disabled:!0,children:n!==void 0&&n!==""?String(n):q}),ae==null?void 0:ae.map((H,ue)=>f.jsx("option",{value:ue,children:Ot(H.label)||H.label},ue))]})}):he==="pills"?f.jsxs("div",{id:d,role:"group","aria-label":D,"aria-describedby":we["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[ae==null?void 0:ae.map((H,ue)=>{const xe=te?Array.isArray(n)&&n.includes(H.value):Object.is(n,H.value);return f.jsx("button",{type:"button",disabled:i||ie,"aria-pressed":xe,style:{padding:"8px 16px",borderRadius:24,border:0,color:xe?Se:"inherit",background:xe?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>de(te?xe?n.filter(Oe=>Oe!==H.value):[...Array.isArray(n)?n:[],H.value]:H.value),children:Ot(H.label)||H.label},ue)}),ie&&f.jsx("span",{role:"status",children:"Loading..."})]}):he==="textarea"?f.jsx("textarea",{...we,placeholder:q,value:p,onChange:H=>y(H.target.value),onBlur:oe}):f.jsx("input",{...we,placeholder:q,type:r.type.kind==="number"||r.type.kind==="integer"?"number":"text",step:r.type.kind==="integer"?1:"any",value:p,onChange:H=>y(H.target.value),onBlur:oe,onKeyDown:H=>{H.key==="Enter"&&oe(),H.key==="Escape"&&y(n===void 0?"":String(n))}}),U&&f.jsx("div",{role:"alert",id:`${d}-error`,children:U}),T&&(E==null?void 0:E.error)&&f.jsx("button",{type:"button",disabled:i,onClick:()=>{O(void 0),v(b+1)},children:"Retry"})]})}function Ed({nodeAddress:e,structured:r=!1}){return r?f.jsx(bw,{nodeAddress:e},e):f.jsx(ad,{nodeAddress:e})}function bw({nodeAddress:e}){var u,h,p;const r=S.useContext(It),[t,n]=S.useState([]),i=((u=r.structured)==null?void 0:u.sourceSchema)??r.schema,o=((h=r.structured)==null?void 0:h.sourceBindings)??r.bindings,s=S.useMemo(()=>{if(!(!r.data||!i||!o))return ob(r.data,o,i,[{data:{id:e,type:"objectView"}}])},[r.data,o,i,e]);if(!s)return f.jsx(ad,{nodeAddress:e});const a=t.findIndex(y=>!s.containers.has(y)),c=a<0?t:t.slice(0,a),l=c.at(-1)??e,d=(p=[...s.slots.values()].find(y=>y.nodeId===l))==null?void 0:p.label;return f.jsxs(It.Provider,{value:{...r,structured:s,schema:s.schema,bindings:s.bindings,renderForm:void 0,onFieldCreate:l===e?r.onFieldCreate:void 0},children:[!!c.length&&f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[f.jsx(Ae,{"aria-label":"Back to parent fields",title:"Back to parent fields",icon:f.jsx(X.PiArrowLeft,{size:18}),size:"sm",variant:"ghost",onClick:()=>n(c.slice(0,-1))}),f.jsx("strong",{style:{minWidth:0,overflowWrap:"anywhere"},children:Ot(d)})]}),f.jsx(ad,{nodeAddress:l,onOpen:y=>n([...c,y])},l)]})}function ad({nodeAddress:e,onOpen:r}){var j,_;const{data:t,schema:n,callbacks:i,bindings:o,editable:s,renderForm:a,structured:c}=S.useContext(It),{readOnly:l,config:d,colorMode:u}=Ue(),h=a==null?void 0:a(e);if(h!==void 0)return f.jsx("fieldset",{"data-flow-form":e,disabled:l||d.editable===!1||!s,style:{border:0,margin:0,padding:0,minWidth:0},children:h});if(!t)return f.jsx(Bn,{$colorMode:u,role:"alert",children:"Forms require a JSON document."});const p=o?Pn(o,e,n):void 0,y=o?p:n&&Jr(t,e,n);if(!y)return f.jsx(Bn,{$colorMode:u,role:"status",children:"Form schema unavailable."});const m=(p==null?void 0:p.address)??e,g=Te(t,m),b=(j=c==null?void 0:c.containers.get(e))==null?void 0:j.scalar;if(g===void 0||typeof g!="object"&&!b)return f.jsx(Bn,{$colorMode:u,role:"alert",children:"Bound form state is unavailable."});const v=Object.entries(y.type.properties).filter(([k])=>{var E;return oo((E=y.fields[k])==null?void 0:E.$visibleWhen,t)}),x=v.length>8||v.some(([k])=>{var E;return(E=y.fields[k])==null?void 0:E.$section}),w=new Map;for(const k of v){const[E,O]=k,T=x?Ot(((_=y.fields[E])==null?void 0:_.$section)??(O.type.kind==="object"||O.type.kind==="array"?E:O.optional?"Options":"General")):"";w.has(T)||w.set(T,[]),w.get(T).push(k)}const C=([k,E])=>f.jsx(Iu,{request:{data:t,address:b?m:`${m}.${k}`,nodeAddress:m,nodeId:typeof(g==null?void 0:g.id)=="string"?g.id:void 0},property:E,config:y.fields[k]??{},value:b?g:g==null?void 0:g[k],disabled:l||d.editable===!1||!(s??!!i.onJsonChange)},`${(g==null?void 0:g.id)??e}:${k}`);return f.jsxs(Bn,{$colorMode:u,"data-flow-form":e,onClick:k=>k.stopPropagation(),onDoubleClick:k=>k.stopPropagation(),children:[c&&f.jsx(mw,{nodeAddress:e,onOpen:r}),!c&&p&&y.type.additionalProperties&&v.length===0&&f.jsx(Iu,{request:{data:t,address:m,nodeAddress:m},property:{type:y.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:g,disabled:l||d.editable===!1||!s}),[...w].map(([k,E])=>x&&E.length>1?f.jsxs("details",{open:!0,children:[f.jsxs("summary",{children:[f.jsx("span",{children:k}),f.jsx(X.PiCaretDown,{size:16,"aria-hidden":"true"})]}),E.map(C)]},k):E.map(C))]})}function ab(e){const{viewData:r}=S.useContext(It),{nodeById:t,edgeById:n,parentIds:i}=hr();if(r){const o=Te(r,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&&t.has(a)})}function En(e,r){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:r}function Rn(e,r,t,n){return{borderColor:r,borderWidth:En(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...vm(r==="transparent"?"currentColor":r,t,".flow-sdk-node:hover &",!t)}}function sb({label:e,value:r,options:t,onChange:n,disabled:i}){var o;return f.jsxs(At,{"aria-label":e,title:`Animation: ${((o=t.find(s=>s.value===r))==null?void 0:o.label)??"Mixed"}`,value:r,style:{width:104},disabled:i,onValueChange:s=>{const a=t.find(c=>c.value===s);a&&n(a.value)},children:[r===""&&f.jsx("option",{value:"",disabled:!0,children:"Mixed"}),t.map(s=>f.jsx("option",{value:s.value,children:s.label},s.value))]})}function Rd({nodeId:e,edgeId:r,value:t,open:n,onOpenChange:i}){const{callbacks:o,readOnly:s,themeColor:a,colorMode:c}=Ue(),{background:l,backgroundSecondary:d,border:u,colorText:h,colorInactive:p}=ot(),y=c==="dark"?Hr:_e(p),m=S.useRef(null),g=S.useRef(null),b=S.useRef(0),[v,x]=S.useState(!1),[w,C]=S.useState("icons"),[j,_]=S.useState([]),[k,E]=S.useState("loading"),[O,T]=S.useState(""),[P,I]=S.useState(0),[R,$]=S.useState(""),[N,M]=S.useState(""),[J,ie]=S.useState(!1);S.useEffect(()=>()=>{b.current++},[]),S.useEffect(()=>{if(!v)return;let D=!0;return import("react-icons/pi").then(de=>{D&&(_(Object.keys(de).filter(Q=>Q.startsWith("Pi")).sort()),E("ready"))}).catch(()=>{D&&E("unavailable")}),()=>{D=!1}},[v]),S.useEffect(()=>{var D;s&&((D=m.current)==null||D.close())},[s]),S.useEffect(()=>{var D,de,Q;if(n!==void 0){if(!n||s){(D=m.current)==null||D.close();return}(de=m.current)!=null&&de.open||(M(""),C(t==="PiFileSvg"||t&&or(t)?"custom":"icons"),$(t&&!t.startsWith(xn)&&or(t)?t:""),x(!0),(Q=m.current)==null||Q.showModal())}},[n,s,t]);const ae=D=>{var de,Q,oe;s||(r?(de=o.onEdgeIconChange)==null||de.call(o,r,D):e&&((Q=o.onNodeIconChange)==null||Q.call(o,e,D)),i==null||i(!1),(oe=m.current)==null||oe.close())},te=j.filter(D=>D.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(O.trim().toLowerCase())),he=36,me=Math.max(1,Math.ceil(te.length/he)),q=Math.min(P,me-1),F=te.slice(q*he,(q+1)*he),U={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${_e(u)}`,borderRadius:30};return f.jsxs(f.Fragment,{children:[n===void 0&&f.jsx(ze,{label:r?"Choose edge icon":"Choose node icon",children:f.jsx(Ae,{"aria-label":r?"Choose edge icon":"Choose node icon",icon:f.jsx(X.PiShapes,{size:20}),size:"sm",variant:"ghost",color:_e(a),disabled:s,onClick:()=>{var D;M(""),C(t&&or(t)?"custom":"icons"),$(t&&!t.startsWith(xn)&&or(t)?t:""),x(!0),(D=m.current)==null||D.showModal()}})}),f.jsx(W.chakra.dialog,{ref:m,"aria-label":r?"Choose edge icon":"Choose node icon",css:lr(_e(l),_e(u)),onClose:()=>{x(!1),i==null||i(!1),b.current++,ie(!1)},onClick:D=>{D.stopPropagation(),D.target===D.currentTarget&&D.currentTarget.close()},onKeyDown:D=>D.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",borderRadius:30,background:_e(l),color:_e(h)},children:v&&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:r?"Edge icon":"Node icon"}),f.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[t&&f.jsx(ze,{label:"Remove icon",children:f.jsx(Ae,{"aria-label":r?"Remove edge icon":"Remove node icon",icon:f.jsx(X.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:s||J,onClick:()=>ae("")})}),f.jsx(Kr,{"aria-label":"Close icon picker",onClick:()=>{var D;return(D=m.current)==null?void 0:D.close()}})]})]}),f.jsxs(W.Tabs.Root,{value:w,onValueChange:({value:D})=>{C(D),M("")},display:"contents",css:{"--indicator-thickness":"1px"},children:[f.jsx(W.Tabs.List,{"aria-label":"Icon source",width:"100%",borderBottomWidth:0,children:["icons","custom"].map(D=>f.jsx(W.Tabs.Trigger,{value:D,flex:1,minW:0,justifyContent:"center",px:3,py:2,fontSize:"13px",_selected:{color:a,borderColor:y,"--indicator-color":y},children:D==="icons"?"React icons":"Custom SVG"},D))}),f.jsx("input",{ref:g,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:J||s,onChange:async D=>{var oe;const de=(oe=D.target.files)==null?void 0:oe[0];if(D.target.value="",!de)return;const Q=++b.current;ie(!0),M("");try{const ce=await cw(de);Q===b.current&&ae(ce)}catch(ce){Q===b.current&&M(ce instanceof Error?ce.message:"Unable to read SVG.")}finally{Q===b.current&&ie(!1)}}}),f.jsx(W.Tabs.Content,{value:w,p:0,style:{display:"grid",gap:8},children:w==="icons"?f.jsxs(f.Fragment,{children:[f.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:O,onChange:D=>{T(D.target.value),I(0)},style:U}),f.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[F.map(D=>f.jsx("button",{type:"button","aria-label":`Choose ${D}`,"aria-pressed":t===D,title:D,onClick:()=>ae(D),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${t===D?2:1}px solid ${_e(t===D?a:u)}`,background:_e(t===D?l:d),color:"inherit",cursor:"pointer"},children:f.jsx(Ht,{name:D,size:24})},D)),F.length===0&&f.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:k==="loading"?"Loading icons...":k==="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:[te.length," icons · ",q+1," / ",me]}),f.jsxs("div",{style:{display:"flex",gap:4},children:[f.jsx(ze,{label:"Previous icons",children:f.jsx(Ae,{"aria-label":"Previous icons",icon:f.jsx(X.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:q===0,onClick:()=>I(q-1)})}),f.jsx(ze,{label:"Next icons",children:f.jsx(Ae,{"aria-label":"Next icons",icon:f.jsx(X.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:q+1>=me,onClick:()=>I(q+1)})})]})]})]}):f.jsxs(f.Fragment,{children:[t&&or(t)&&f.jsx(Ht,{name:t,size:64}),f.jsxs("button",{type:"button",disabled:J||s,onClick:()=>{var D;return(D=g.current)==null?void 0:D.click()},style:{...U,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[f.jsx(X.PiUploadSimple,{}),J?"Uploading...":"Upload SVG"]}),f.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:D=>{D.preventDefault(),!(J||s)&&(!or(R.trim())||R.trim().startsWith(xn)?M("Enter an HTTP or HTTPS image URL."):ae(R.trim()))},children:[f.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:R,disabled:J||s,onChange:D=>$(D.target.value),style:{...U,flex:1,minWidth:0}}),f.jsx(ze,{label:"Apply URL",children:f.jsx(Ae,{type:"submit","aria-label":"Apply URL",icon:f.jsx(X.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:J||s||!R.trim(),style:{flexShrink:0}})})]})]})})]}),N&&f.jsx("div",{role:"alert",style:{fontSize:13},children:N})]})})]})}const Jn=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500",Hr],cb=["gray.900",Hr,"gray.600","gray.200","white"];function lb(){const{config:e}=Ue(),r=e.selectionToolbar||{},t=new Set(r.hide||[]);return{palette:r.palette||Jn,show:n=>!t.has(n)}}function jt(){const{border:e}=ot();return f.jsx(W.Icon,{mx:-1,as:X.PiLineVerticalThin,boxSize:5,color:e})}function zr({value:e,placeholder:r,ariaLabel:t,width:n="140px",type:i="text",min:o,onCommit:s}){const{colorText:a}=ot(),[c,l]=S.useState(e),d=S.useRef(!1);S.useEffect(()=>l(e),[e]);const u=()=>{if(d.current)return;d.current=!0;const h=c.trim();if(i==="number"&&h!==""&&(!Number.isFinite(Number(h))||Number(h)<(o??0))){l(e);return}h!==e&&s(h)};return f.jsx(W.Input,{"aria-label":t,type:i,min:o,size:"xs",fontSize:"16px",w:n,value:c,placeholder:r,color:a,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{d.current=!1},onChange:h=>l(h.target.value),onBlur:u,onKeyDown:h=>{h.key==="Enter"&&(u(),h.target.blur()),h.key==="Escape"&&(d.current=!0,l(e),h.target.blur())}})}function Er({colors:e,value:r,label:t,onPick:n,onReset:i,includeTransparent:o=!0}){const{colorInactive:s,colorText:a}=ot(),[c,l]=S.useState(!1),d=S.useId(),u=S.useRef(null),h=r??e[0]??"transparent",p=eo(f.jsx(Er,{colors:e,value:r,label:t,onPick:n,onReset:i,includeTransparent:o}));return f.jsx(Vr.Provider,{value:null,children:f.jsxs(W.HStack,{gap:1,"aria-label":t,role:"group",onClickCapture:p,onKeyDown:y=>{var m;y.key==="Escape"&&(l(!1),(m=u.current)==null||m.focus())},children:[f.jsx(ze,{label:`${t}: ${h}`,children:f.jsx(W.chakra.button,{ref:u,type:"button","aria-label":`${t} colors`,"aria-expanded":c,"aria-controls":d,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:_e(h),...h==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${_e(a)}`,outlineOffset:"1px",onClick:()=>l(y=>!y)})}),c&&f.jsxs(W.HStack,{id:d,gap:1,children:[[...new Set([...e,...o?["transparent"]:[]])].map(y=>{const m=r===y;return f.jsx(ze,{label:`${t}: ${y}`,children:f.jsx(W.Box,{as:"button","aria-label":`${t} ${y}`,"aria-pressed":m,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:_e(y),...y==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:m?`2px solid ${_e(a)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(y),onDoubleClick:g=>{var b;g.stopPropagation(),l(!1),(b=u.current)==null||b.focus()}})},y)}),i&&f.jsx(ze,{label:`Reset ${t.toLowerCase()}`,children:f.jsx(Ae,{"aria-label":`Reset ${t}`,icon:f.jsx(W.Icon,{as:X.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:s,onClick:()=>{var y;i(),l(!1),(y=u.current)==null||y.focus()}})})]})]})})}function db({edgeId:e,onClose:r}){var p;const{callbacks:t,themeColor:n,config:i}=Ue(),{colorInactive:o}=ot(),{edgeById:s}=hr(),{palette:a,show:c}=lb(),l=(p=s.get(e))==null?void 0:p.data,d=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(i.customEdgeTypes??{}),...l!=null&&l.type?[l.type]:[]])],u=l!=null&&l.isEdgeAnimated?"animated":l!=null&&l.isEdgeDashed?"dashed":"solid",h=[{key:"solid",icon:X.PiLineSegment,label:"Solid"},{key:"dashed",icon:X.PiLineSegments,label:"Dashed"},{key:"animated",icon:X.PiFastForward,label:"Animated"}];return f.jsxs(f.Fragment,{children:[f.jsx(Kr,{onClick:r}),c("label")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(zr,{ariaLabel:"Edge label",placeholder:"Edge label",value:(l==null?void 0:l.label)||"",onCommit:y=>{var m;return(m=t.onEdgeLabelChange)==null?void 0:m.call(t,e,y)}})]}),c("style")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),h.map(y=>f.jsx(ze,{label:y.label,children:f.jsx(Ae,{"aria-label":`Edge style ${y.key}`,"aria-pressed":u===y.key,icon:f.jsx(W.Icon,{as:y.icon,boxSize:5}),size:"sm",variant:"ghost",color:u===y.key?n:o,onClick:()=>{var m;return(m=t.onEdgeStyleChange)==null?void 0:m.call(t,e,y.key)}})},y.key)),u==="animated"&&f.jsx(sb,{label:"Edge animation",value:(l==null?void 0:l.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:i.readOnly,onChange:y=>{var m;return(m=t.onEdgeAnimationVariantChange)==null?void 0:m.call(t,e,y)}}),f.jsxs(At,{"aria-label":"Edge shape",title:`Edge shape: ${(l==null?void 0:l.type)??"Default"}`,icon:f.jsx(X.PiBezierCurve,{size:20}),style:{width:36},value:(l==null?void 0:l.type)??"",disabled:i.readOnly,onValueChange:y=>{var m;return(m=t.onEdgeTypeChange)==null?void 0:m.call(t,e,y||void 0)},children:[f.jsx("option",{value:"",children:"Default"}),d.map(y=>f.jsx("option",{value:y,children:y},y))]})]}),c("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Rd,{edgeId:e,value:l==null?void 0:l.icon},e),f.jsx(zr,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(l==null?void 0:l.icon)??"",onCommit:y=>{var m;return(m=t.onEdgeIconChange)==null?void 0:m.call(t,e,y)}})]}),c("color")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Er,{label:"Edge color",colors:a,value:l==null?void 0:l.color,onPick:y=>{var m;return(m=t.onEdgeColorChange)==null?void 0:m.call(t,e,y)},onReset:()=>{var y;return(y=t.onEdgeColorChange)==null?void 0:y.call(t,e,"")}})]}),c("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(ze,{label:"Delete edge",children:f.jsx(Ae,{"aria-label":"Delete edge",icon:f.jsx(W.Icon,{as:X.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var y;(y=t.onEdgeDelete)==null||y.call(t,e,l),r()}})})]})]})}function ub({ids:e,showDivider:r=!0}){const{callbacks:t,config:n,nodeGridOptions:i,fillRadiusEditedIds:o,setNodeRadiusPreview:s}=Ue(),{colorInactive:a}=ot(),{nodeById:c}=hr(),[l,d]=S.useState(),u=S.useRef(),h=S.useRef(),p=S.useRef({callbacks:t,readOnly:n.readOnly,nodeById:c});p.current={callbacks:t,readOnly:n.readOnly,nodeById:c};const y=()=>{var C,j;clearTimeout(h.current);const w=u.current;if(u.current=void 0,!!w){if(!p.current.readOnly)for(const _ of w.ids)p.current.nodeById.has(_)&&((j=(C=p.current.callbacks).onNodeBorderRadiusChange)==null||j.call(C,_,w.radius));s(w.ids,void 0),d(void 0)}},m=S.useRef(y);m.current=y,S.useEffect(()=>{const w=()=>m.current();return window.addEventListener("pagehide",w),()=>{window.removeEventListener("pagehide",w),w()}},[]);const g=e.map(w=>{var C,j;return i!=null&&i.fill&&!o.has(w)?0:(j=(C=c.get(w))==null?void 0:C.data.viewProps)==null?void 0:j.borderRadius}),b=!g.every(w=>w===g[0]),v=l??g[0]??0,x=w=>{n.readOnly||(w!==void 0&&e.every(C=>{var j;return((j=c.get(C))==null?void 0:j.data.type)==="grid"})?(d(w),s(e,w),u.current={ids:[...e],radius:w},clearTimeout(h.current),h.current=setTimeout(y,150)):(clearTimeout(h.current),u.current=void 0,d(void 0),s(e,void 0),e.forEach(C=>{var j;return(j=t.onNodeBorderRadiusChange)==null?void 0:j.call(t,C,w)})))};return f.jsxs(f.Fragment,{children:[r&&f.jsx(jt,{}),f.jsx(W.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:f.jsx(At,{icon:f.jsx(W.Icon,{as:lx.TbBorderRadius,boxSize:5,color:a,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${b?"Mixed":g[0]===void 0?"Default":`${g[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:"radius",disabled:n.readOnly,onValueChange:()=>{},popupContent:f.jsxs(f.Fragment,{children:[f.jsx(od,{label:"Border radius",inputLabel:"Node corner radius",min:0,max:Math.max(500,...g.map(w=>w??0)),step:1,value:v,displayValue:l!==void 0?`${l}px`:b?"Mixed":g[0]===void 0?"Default":`${v}px`,onChange:x,onChangeEnd:y}),f.jsx(ze,{label:"Reset border radius",children:f.jsx(Ae,{"aria-label":"Reset border radius",icon:f.jsx(X.PiEraser,{size:20}),size:"sm",variant:"ghost",color:a,disabled:n.readOnly,onClick:()=>x(void 0)})})]}),children:f.jsx("option",{value:"radius",children:"Border radius"})})})]})}function fb({ids:e,onClose:r,afterLabel:t}){var de,Q,oe,ce,we,Se,ye,pe;const{callbacks:n,colorMode:i,themeColor:o,config:s,setNodeViewMode:a,nodeViewModes:c}=Ue(),{colorText:l,colorInactive:d}=ot(),{nodeById:u,parentIds:h}=hr(),{palette:p,show:y}=lb(),m=e.length===1,[g,b]=S.useState(""),v=m?(de=u.get(e[0]))==null?void 0:de.data:void 0,x=e.map(B=>{var H,ue,xe,Oe,Ne,Be;const G=(H=u.get(B))==null?void 0:H.data,se=((ue=G==null?void 0:G.config)==null?void 0:ue.typeView)??"";return se==="object"&&((xe=G==null?void 0:G.config)==null?void 0:xe.content)!==void 0&&c[B]!=="properties"?"content":se==="icon-label"&&((Oe=G==null?void 0:G.viewProps)==null?void 0:Oe.bgColor)==="transparent"&&((Ne=G==null?void 0:G.viewProps)==null?void 0:Ne.borderWidth)===0&&((Be=G==null?void 0:G.viewProps)==null?void 0:Be.outline)===!1?"media":se}),w=x.some(B=>B!==x[0]),C=w?"mixed":x[0]??"",j=[{value:"text",label:"Text",view:"text",icon:X.PiTextT},{value:"icon-label",label:"Icon Label",view:"icon-label",icon:X.PiShapes},{value:"object",label:"Object",view:"object",icon:X.PiBracketsCurly},{value:"grid",label:"Grid",view:"grid",icon:X.PiGridFour},{value:"parent",label:"Parent",view:"parent",icon:X.PiStack},{value:"media",label:"Media",view:"icon-label",icon:X.PiFileSvg},{value:"content",label:"Content",view:"object",icon:X.PiTextAlignLeft}],_=e.some(B=>{var se,H,ue,xe;const G=(se=u.get(B))==null?void 0:se.data;return G&&((H=G.config)==null?void 0:H.typeView)!=="grid"&&((ue=G.config)==null?void 0:ue.typeView)!=="parent"&&(h.has(B)||((xe=G.config)==null?void 0:xe.parentContainer)||Object.prototype.hasOwnProperty.call(s.customViews??{},G.type))}),k=(Q=v==null?void 0:v.config)==null?void 0:Q.collapsed,E=ab(e[0]),O=B=>{var G,se,H;return(((se=(G=u.get(B))==null?void 0:G.data.viewProps)==null?void 0:se.outline)??(h.has(B)?(H=s.parentNodeStyle)==null?void 0:H.outline:!1))===!0},T=e.every(O),P=!T&&e.some(O),I=B=>{var G;return((G=u.get(B))==null?void 0:G.data.isNodeAnimated)===!0},R=e.every(I),$=!R&&e.some(I),N=e.map(B=>{var G;return((G=u.get(B))==null?void 0:G.data.nodeAnimationVariant)??"traveling"}),M=N.every(B=>B===N[0])?N[0]:"",J=B=>e.forEach(B),[ie,ae]=S.useState(!1),te=ie&&y("color")&&y("borderColor"),he=B=>{var G,se,H;return(((se=(G=u.get(B))==null?void 0:G.data.viewProps)==null?void 0:se.borderStyle)??(h.has(B)?(H=s.parentNodeStyle)==null?void 0:H.borderStyle:"solid"))==="dashed"},me=e.every(he),q=!me&&e.some(he),F=e.map(B=>{var H,ue,xe;const G=(H=u.get(B))==null?void 0:H.data,se=h.has(B)?En((ue=s.parentNodeStyle)==null?void 0:ue.borderWidth,6):(G==null?void 0:G.type)==="objectView"?3:2;return En((xe=G==null?void 0:G.viewProps)==null?void 0:xe.borderWidth,se)}),U=F.every(B=>B===F[0])?String(F[0]??""):"",D=B=>J(G=>{var se,H;te?(se=n.onNodeBorderColorChange)==null||se.call(n,G,B):(H=n.onNodeColorChange)==null||H.call(n,G,"bg",B)});return f.jsxs(f.Fragment,{children:[f.jsx(Kr,{onClick:r}),f.jsx(jt,{}),m&&y("label")?f.jsx(zr,{ariaLabel:"Node label",placeholder:"Node label",value:(v==null?void 0:v.label)??(v==null?void 0:v.headerTitle)??"",onCommit:B=>{var G;return(G=n.onNodeLabelChange)==null?void 0:G.call(n,e[0],B)}}):f.jsxs(W.Text,{fontSize:"xs",color:l,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),t,y("typeView")&&f.jsxs(At,{"aria-label":"Type view",title:_?"Type view is managed by the custom renderer or container":`Type view: ${C||"None (default)"}`,icon:f.jsx(X.PiCards,{size:20}),style:{width:36},value:C,disabled:s.readOnly||s.editable===!1||_,onValueChange:B=>{var se;const G=(se=j.find(H=>H.value===B))==null?void 0:se.view;G&&J(H=>{var xe,Oe,Ne,Be,et,We,gt,He,rt,ft,Pe,Fe,it;const ue=(xe=u.get(H))==null?void 0:xe.data;B==="media"?((Oe=n.onNodeColorChange)==null||Oe.call(n,H,"bg","transparent"),(Ne=n.onNodeBorderColorChange)==null||Ne.call(n,H,"#00000000"),(Be=n.onNodeBorderWidthChange)==null||Be.call(n,H,0),(et=n.onNodeOutlineChange)==null||et.call(n,H,!1)):x[e.indexOf(H)]==="media"&&((We=n.onNodeColorChange)==null||We.call(n,H,"bg",""),(gt=n.onNodeBorderColorChange)==null||gt.call(n,H,""),(He=n.onNodeBorderWidthChange)==null||He.call(n,H,void 0)),B==="content"&&((rt=ue==null?void 0:ue.config)==null?void 0:rt.content)===void 0&&((ft=n.onNodeContentChange)==null||ft.call(n,H,"")),(Pe=n.onNodeTypeViewChange)==null||Pe.call(n,H,G),a(H,B==="object"&&((Fe=ue==null?void 0:ue.config)==null?void 0:Fe.content)!==void 0?"properties":"default"),(it=n.onNodeViewToggle)==null||it.call(n,H)})},children:[w&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),j.map(B=>f.jsx("option",{value:B.value,children:f.jsxs(W.HStack,{gap:"12px",children:[f.jsx(B.icon,{size:20,"aria-hidden":"true",style:{flexShrink:0}}),f.jsx("span",{children:B.label})]})},B.value))]}),y("style")&&f.jsx(ub,{ids:e},e.join("\0")),y("outline")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(ze,{label:T?"Restore node fill":"Remove node fill",children:f.jsx(Ae,{"aria-label":"Toggle node outline","aria-pressed":P?"mixed":T,icon:f.jsx(W.Icon,{as:T?X.PiSquare:X.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:T?o:d,onClick:()=>J(B=>{var G;return(G=n.onNodeOutlineChange)==null?void 0:G.call(n,B,!T)})})})]}),y("color")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),y("borderColor")&&f.jsx(ze,{label:te?"Edit node colors":"Edit node border",children:f.jsx(Ae,{"aria-label":"Edit node border","aria-pressed":te,icon:f.jsx(W.Icon,{as:X.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:te?o:d,bg:te?i==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>ae(B=>!B)})}),f.jsx(Er,{label:te?"Border color":"Background",colors:p,value:te?((oe=v==null?void 0:v.viewProps)==null?void 0:oe.borderColor)??(m&&h.has(e[0])?(ce=s.parentNodeStyle)==null?void 0:ce.borderColor:void 0):(we=v==null?void 0:v.viewProps)==null?void 0:we.bgColor,onPick:D,onReset:()=>D("")}),te&&y("style")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(ze,{label:me?"Solid border":"Dashed border",children:f.jsx(Ae,{"aria-label":"Toggle dashed border","aria-pressed":q?"mixed":me,icon:f.jsx(W.Icon,{as:me?X.PiLineSegments:X.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:me?o:d,onClick:()=>J(B=>{var G;return(G=n.onNodeBorderStyleChange)==null?void 0:G.call(n,B,me?"solid":"dashed")})})}),f.jsx(zr,{ariaLabel:"Border thickness",placeholder:m?"Auto":"Mixed",width:"64px",type:"number",min:0,value:U,onCommit:B=>J(G=>{var se;return(se=n.onNodeBorderWidthChange)==null?void 0:se.call(n,G,B===""?void 0:Number(B))})})]})]}),y("animation")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(ze,{label:R?"Stop border animation":"Animate node border",children:f.jsx(Ae,{"aria-label":"Toggle node animation","aria-pressed":$?"mixed":R,icon:f.jsx(W.Icon,{as:X.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:R?o:d,onClick:()=>J(B=>{var G;return(G=n.onNodeAnimationChange)==null?void 0:G.call(n,B,!R)})})}),(R||$)&&f.jsx(sb,{label:"Node animation",value:M,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:s.readOnly,onChange:B=>J(G=>{var se;return(se=n.onNodeAnimationVariantChange)==null?void 0:se.call(n,G,B)})})]}),!te&&y("textColor")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Er,{label:"Text color",colors:cb,value:(Se=v==null?void 0:v.viewProps)==null?void 0:Se.textColor,onPick:B=>J(G=>{var se;return(se=n.onNodeColorChange)==null?void 0:se.call(n,G,"text",B)}),onReset:()=>J(B=>{var G;return(G=n.onNodeColorChange)==null?void 0:G.call(n,B,"text","")})})]}),m&&y("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(Rd,{nodeId:e[0],value:(ye=v==null?void 0:v.config)==null?void 0:ye.icon},e[0]),f.jsx(zr,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((pe=v==null?void 0:v.config)==null?void 0:pe.icon)||"",onCommit:B=>{var G;return(G=n.onNodeIconChange)==null?void 0:G.call(n,e[0],B)}})]}),m&&E&&y("collapse")&&k!==void 0&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(ze,{label:k?"Expand":"Collapse",children:f.jsx(Ae,{"aria-label":k?"Expand node":"Collapse node",icon:f.jsx(W.Icon,{as:k?X.PiArrowsOutLineVertical:X.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:d,onClick:()=>{var B;return(B=n.onNodeCollapse)==null?void 0:B.call(n,e[0],!k)}})})]}),y("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(jt,{}),f.jsx(ze,{label:m?"Delete node":`Delete ${e.length} nodes`,children:f.jsx(Ae,{"aria-label":"Delete selected nodes",icon:f.jsx(W.Icon,{as:X.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:i==="dark"?"red.300":"red.500",onClick:()=>{J(B=>{var G,se;return(se=n.onNodeDelete)==null?void 0:se.call(n,B,((G=u.get(B))==null?void 0:G.data)||{id:B})}),r()}})})]}),f.jsx(jt,{}),f.jsx(ze,{label:"Copy selection",children:f.jsx(Ae,{"aria-label":"Copy selection",icon:f.jsx(X.PiCopy,{size:20}),size:"sm",variant:"ghost",color:d,onClick:async()=>{var B;try{await((B=n.onNodesCopy)==null?void 0:B.call(n,e)),b("")}catch(G){b(String(G))}}})}),f.jsx(ze,{label:"Duplicate selection",children:f.jsx(Ae,{"aria-label":"Duplicate selection",icon:f.jsx(X.PiCopySimple,{size:20}),size:"sm",variant:"ghost",color:d,disabled:s.readOnly||s.editable===!1,onClick:()=>{var B;try{(B=n.onNodesDuplicate)==null||B.call(n,e),b("")}catch(G){b(String(G))}}})}),g&&f.jsx(W.Text,{role:"alert",fontSize:"xs",children:g})]})}async function hb(e){const{toSvg:r}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const t=await r(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(t.slice(t.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 pb(e,r="squeed.svg"){const t=document.createElement("a");t.href=await hb(e),t.download=r.endsWith(".svg")?r:`${r}.svg`,t.click()}function gb(){const{themeColor:e}=Ue(),[r,t]=S.useState(!1),[n,i]=S.useState("");return f.jsxs(f.Fragment,{children:[f.jsx(ze,{label:"Download SVG (current view)",children:f.jsx(Ae,{"aria-label":"Download SVG",icon:f.jsx(X.PiDownloadSimpleFill,{size:20}),disabled:r,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}t(!0),i("");try{await pb(s)}catch(c){i(c instanceof Error?c.message:"Unable to export SVG.")}finally{t(!1)}}})}),n&&f.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function kd({children:e,background:r,border:t,endElement:n,startElement:i,startElementWidth:o=44,framed:s=!0}){const a=S.useRef(null),[c,l]=S.useState({left:!1,right:!1});S.useLayoutEffect(()=>{const u=a.current;let h=u.parentElement.offsetWidth;const p=()=>{const g=u.parentElement.offsetWidth;if(g>0&&g!==h){const x=h/g;h=g,x>0&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&u.parentElement.animate({transform:[`scaleX(${x})`,"scaleX(1)"],transformOrigin:[n?"right center":"left center",n?"right center":"left center"]},{duration:180,easing:"ease-out",id:"flow-toolbar-grow"})}const b=u.scrollLeft>1,v=u.scrollWidth-u.clientWidth-u.scrollLeft>1;l(x=>x.left===b&&x.right===v?x:{left:b,right:v})},y=g=>{if(g.defaultPrevented||g.ctrlKey||s&&g.deltaX!==0||!(g.deltaX||g.deltaY)||u.scrollWidth<=u.clientWidth)return;g.preventDefault();const b=g.deltaMode===WheelEvent.DOM_DELTA_LINE?16:g.deltaMode===WheelEvent.DOM_DELTA_PAGE?u.clientWidth:1;u.scrollLeft+=(g.deltaX||g.deltaY)*b},m=new ResizeObserver(p);return m.observe(u),u.firstElementChild&&m.observe(u.firstElementChild),u.addEventListener("scroll",p,{passive:!0}),u.addEventListener("wheel",y,{passive:!1}),p(),()=>{m.disconnect(),u.removeEventListener("scroll",p),u.removeEventListener("wheel",y)}},[]);const d=`var(--chakra-colors-${r.replace(".","-")})`;return f.jsxs(W.Box,{position:"relative",bg:s?r:"transparent",minW:0,maxW:"100%",flex:"0 1 auto",borderRadius:s?"30px":0,css:{...s?lr(d,`var(--chakra-colors-${t.replace(".","-")})`):{},...s||i?{"--flow-toolbar-start-width":i?`${o}px`:"0px"}:{}},children:[f.jsx(W.Box,{ref:a,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",mr:n?"44px":void 0,ml:i?`${o}px`:void 0,borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(u=>f.jsx(W.Box,{"data-flow-toolbar-fade":u,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",borderRadius:u==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[u]:u==="right"&&n?44:u==="left"&&i?o:0,opacity:c[u]?1:0,background:`linear-gradient(to ${u==="left"?"right":"left"}, ${d}, transparent)`}},u)),n&&f.jsx(W.Box,{position:"absolute",right:"6px",top:0,h:"50px",w:"32px",display:"flex",alignItems:"center",justifyContent:"center",children:n}),i&&f.jsx(W.Box,{position:"absolute",left:"6px",top:0,h:"50px",w:`${o-12}px`,display:"flex",alignItems:"center",justifyContent:"center",children:i})]})}async function vw(e,r){const t=new Set,n=[],i=(a,c)=>{var d,u,h;if(!a||typeof a!="object")return;const l=a;n.push(c),typeof((d=l.$form)==null?void 0:d.$type)=="string"&&t.add(l.$form.$type),typeof((h=(u=l.$form)==null?void 0:u.$create)==null?void 0:h.$type)=="string"&&t.add(l.$form.$create.$type);for(const[p,y]of Object.entries(l))p==="$"?i(y,c):p.startsWith("$")||i(y,`${c}.${p}`)};if(i(r,"root"),!t.size)return{contract:await rb(e)};const o=await _d(e,[...t]);for(const a of t)if(!Object.prototype.hasOwnProperty.call(o,a))throw new Error(`Missing form type: ${a}`);const s={};for(const a of n){const c=Jr(r,a,o);c&&(s[a]={type:c.type,optional:!1})}return{schema:o,contract:{name:e.name,nodes:s}}}function yb({message:e,onDismiss:r}){const{background:t,colorText:n,border:i}=ot();return!e||typeof document>"u"?null:Br.createPortal(f.jsxs(W.chakra.div,{role:"alert","aria-atomic":"true",css:lr(_e(t),_e(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:_e(t),color:_e(n),fontSize:14,lineHeight:1.5},children:[f.jsx(X.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(Kr,{type:"button","aria-label":"Dismiss upload error",title:"Dismiss upload error",onClick:r,flexShrink:0,width:"24px",height:"24px",minWidth:"24px",padding:0})]}),document.body)}function Ad({showDivider:e=!0,compact:r=!1}={}){const{edgeMode:t,setEdgeMode:n,workflowContract:i,setWorkflowContract:o,callbacks:s,readOnly:a,themeColor:c,colorMode:l}=Ue(),{edgeById:d}=hr(),{data:u,schema:h,setSchema:p,bindings:y,structured:m}=S.useContext(It),g=(m==null?void 0:m.sourceBindings)??y,b=(m==null?void 0:m.sourceSchema)??h,{colorText:v}=ot(),x=S.useRef(null),w=S.useRef(0),[C,j]=S.useState(!1),[_,k]=S.useState("");S.useEffect(()=>()=>{w.current++},[]),S.useEffect(()=>{w.current++,j(!1)},[a,u,g]);const E=i?[...d.values()].filter(P=>jd(i,P.data)).length:0,O=i?`${i.name}: ${b?`${Object.keys(b).length} form types loaded; `:""}${E} invalid or unverified connections`:"",T=eo(f.jsx(Ad,{showDivider:!1,compact:!0}));return f.jsx(Vr.Provider,{value:null,children:f.jsxs("span",{style:{display:"contents"},onClickCapture:T,children:[f.jsx(yb,{message:_,onDismiss:()=>k("")}),e&&f.jsx(pn,{}),f.jsxs(At,{"aria-label":"Edge mode",title:t==="auto"?"Connections: Auto":t==="properties"?"Connections: Properties":"Connections: Nodes",icon:t==="auto"?f.jsx(X.PiGraph,{size:20}):t==="properties"?f.jsx(X.PiTable,{size:20}):f.jsx(X.PiTreeStructure,{size:20}),style:{width:36},value:t,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(W.Button,{"data-flow-menu-action":"",variant:"ghost",width:"100%",justifyContent:"flex-start",color:"inherit",bg:"transparent",css:Kn,_hover:{bg:l==="dark"?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:l==="dark"?"whiteAlpha.100":"blackAlpha.50"},onClick:P=>{var I,R;(I=P.currentTarget.closest("[popover]"))==null||I.hidePopover(),(R=s.onWorkflowConfigurationOpen)==null||R.call(s)},children:[f.jsx(X.PiGear,{}),"Configuration"]})]}),onValueChange:P=>{var R;const I=P==="auto"?"auto":P==="properties"?"properties":"nodes";n(I),(R=s.onEdgeModeChange)==null||R.call(s,I)},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:t==="auto"||t==="properties"?"contents":"none"},children:[f.jsx(ze,{label:i?`Replace ${i.name}`:"Upload workflow interface",children:f.jsx(Ae,{"aria-label":"Upload workflow interface",icon:f.jsx(X.PiUploadSimple,{size:20}),color:_e(c),size:"sm",variant:"ghost",disabled:C||a,onClick:()=>{var P;return(P=x.current)==null?void 0:P.click()}})}),f.jsx("input",{ref:x,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:a||C,onChange:async P=>{var $,N;const I=($=P.target.files)==null?void 0:$[0];if(P.target.value="",!I)return;const R=++w.current;j(!0),k("");try{const M=g?await _d(I,[...new Set(Object.values(g).map(ae=>ae.schemaType??ae.type))]):void 0;if(g&&M){for(const ae of Object.values(g))if(!Object.prototype.hasOwnProperty.call(M,ae.schemaType??ae.type))throw new Error(`Missing form type: ${ae.schemaType??ae.type}`)}const{contract:J,schema:ie}=g&&M?{schema:M,contract:{name:I.name,nodes:Object.fromEntries(Object.entries(g).map(([ae,te])=>[ae,{type:M[te.schemaType??te.type],optional:!1}]))}}:await vw(I,u);if(R!==w.current)return;p==null||p(ie),o(J),(N=s.onWorkflowContractChange)==null||N.call(s,J)}catch(M){R===w.current&&k(`${I.name}: ${M instanceof Error?M.message:"Unable to load interface."}`)}finally{R===w.current&&j(!1)}}}),!r&&(O||C)&&f.jsx("span",{role:"status",title:O,style:{color:_e(v),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:C?"Loading interface...":O}),!r&&i&&f.jsx(ze,{label:"Remove workflow interface",children:f.jsx(Ae,{"aria-label":"Remove workflow interface",icon:f.jsx(X.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),k("")}})})]})]})})}const xw=[{value:"BT",label:"Bottom to Up",icon:X.PiArrowUp,flowType:sn.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:X.PiArrowDown,flowType:sn.TOP_DOWN},{value:"LR",label:"Left to Right",icon:X.PiArrowRight,flowType:sn.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:X.PiArrowLeft,flowType:sn.RIGHT_LEFT}],mb=({nodeGridControlsTarget:e}={})=>{const{engineRef:r,themeColor:t,setThemeColor:n,edgeColor:i,setEdgeColor:o,backgroundSelected:s,setBackgroundSelected:a,direction:c,edgeMode:l,allNodesIconLabel:d,setAllNodesIconLabel:u,nodeGridOptions:h,selectedNodeIds:p,setSelectedNodeIds:y,selectedEdgeId:m,setSelectedEdgeId:g,isZoomMode:b,setIsZoomMode:v,isMultiSelectMode:x,setIsMultiSelectMode:w,isDragMode:C,setIsDragMode:j,isEdgeHandlesEnabled:_,setIsEdgeHandlesEnabled:k,isArrayNodeMode:E,setIsArrayNodeMode:O,isPinned:T,setIsPinned:P,callbacks:I,config:R,readOnly:$}=Ue(),{nodeById:N,edgeById:M,parentIds:J}=hr(),ie=R.colorMode==="dark",{background:ae,border:te,colorInactive:he,colorText:me,colorActive:q}=ot(),F=ie?te:"gray.300",U=`var(--chakra-colors-${ae.replace(".","-")})`,D=`var(--chakra-colors-${(ie?te:"gray.300").replace(".","-")})`,[de,Q]=S.useState(!1),[oe,ce]=S.useState(!0),we=R.bottomBarCollapsed??oe,Se=S.useRef(null),ye=mm({edge:"bottom",enabled:!T,bounds:Se,inside:[Se]}),pe=S.useCallback(Pe=>{const Fe=r.current;if(!Fe)return;const it=R.minZoom??.01,at=R.maxZoom??1.5,Lt=.02;let De=Fe.zoom();switch(Pe){case"increase":De=Math.min(at,De+Lt),Fe.zoom(De),Fe.center(!1);break;case"decrease":De=Math.max(it,De-Lt),Fe.zoom(De),Fe.center(!1);break;case"reset":Fe.fit(50);break}},[r,R.minZoom,R.maxZoom]),B=R.renderSelectedNodeToolbar,G=p.length>0&&!!B,se=S.useMemo(()=>G?p.map(Pe=>{var it;return{...((it=N.get(Pe))==null?void 0:it.data)??{id:Pe},isParent:J.has(Pe)}}):[],[G,p,N,J]),H=S.useCallback(()=>{var Pe;y([]),(Pe=I.onNodeDeselect)==null||Pe.call(I)},[y,I]),ue=R.renderSelectedEdgeToolbar,xe=!!m&&!!ue,Oe=S.useMemo(()=>{var Pe;return!xe||!m?null:((Pe=M.get(m))==null?void 0:Pe.data)??{id:m}},[xe,m,M]),Ne=S.useCallback(()=>{var Pe;g(null),(Pe=I.onEdgeDeselect)==null||Pe.call(I)},[g,I]),Be=R.selectionToolbar!==!1&&!$,et=Be&&!!m&&!ue,We=Be&&!et&&p.length>0&&!B,gt=et||We,He=T||ye||de||gt||R.bottomBarCollapsed===!1;S.useEffect(()=>{p.length||m?a(!1):$||(s&&P(!0),R.bottomBarCollapsed===void 0&&ce(!s))},[s,p.length,m,$,a,P,R.bottomBarCollapsed]);const rt=R.renderBottomBar,ft=K0();return rt?f.jsxs(f.Fragment,{children:[G&&f.jsx(W.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:B({selectedNodeIds:p,selectedNodeData:se,onDeselect:H})}),xe&&Oe&&f.jsx(W.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:ue({edgeId:m,edgeData:Oe,onDeselect:Ne})}),f.jsx(W.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:rt({zoomIn:()=>pe("increase"),zoomOut:()=>pe("decrease"),resetZoom:()=>pe("reset"),direction:c,isZoomMode:b,setIsZoomMode:v,isMultiSelectMode:x,setIsMultiSelectMode:w,isDragMode:C,setIsDragMode:j,isEdgeHandlesEnabled:_,setIsEdgeHandlesEnabled:k,isArrayNodeMode:E,setIsArrayNodeMode:O,selectedNodeIds:p,selectedNodeData:se,selectedEdgeId:m,selectedEdgeData:Oe,onNodeDeselect:H,onEdgeDeselect:Ne,callbacks:I})})]}):f.jsxs(Vr.Provider,{value:ft,children:[G&&f.jsx(W.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:B({selectedNodeIds:p,selectedNodeData:se,onDeselect:H})}),xe&&Oe&&f.jsx(W.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:ue({edgeId:m,edgeData:Oe,onDeselect:Ne})}),f.jsx(W.Box,{ref:Se,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:He?"translateY(0)":"translateY(100%)",pointerEvents:He?"auto":"none",visibility:He?"visible":"hidden",opacity:He?1:0,css:{"& button > svg:not([popover] *)":{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",flexShrink:0},"@media (hover: none)":{visibility:"visible",opacity:1,transform:"none",pointerEvents:"auto"}},children:f.jsxs(W.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(kd,{background:ae,border:ie?te:"gray.300",children:f.jsxs(W.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[et?f.jsx(db,{edgeId:m,onClose:Ne}):We?f.jsx(fb,{ids:p,onClose:H}):null,f.jsxs("div",{style:{display:et||We?"none":"contents"},children:[f.jsxs("span",{style:{display:R.bottomBarNavigation===!1?"none":"contents"},children:[f.jsx(ze,{label:T?"Unpin":"Pin",children:f.jsx(Ae,{"aria-label":"Pin",icon:f.jsx(W.Icon,{as:T?X.PiPushPinFill:X.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:T?t:he,onClick:()=>{P(!T),Q(!1)}})}),f.jsx(W.Icon,{mx:-1,as:X.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(ze,{label:"Zoom Out",children:f.jsx(Ae,{"aria-label":"Zoom out",rememberAction:!1,icon:f.jsx(W.Icon,{as:X.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:me,onClick:()=>pe("decrease")})}),f.jsx(ze,{label:"Zoom In",children:f.jsx(Ae,{"aria-label":"Zoom in",rememberAction:!1,icon:f.jsx(W.Icon,{as:X.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:me,onClick:()=>pe("increase")})}),f.jsx(ze,{label:"Reset Zoom",children:f.jsx(Ae,{"aria-label":"Reset zoom",rememberAction:!1,icon:f.jsx(W.Icon,{as:X.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:me,onClick:()=>pe("reset")})}),we&&f.jsx(J0,{visibleActions:h?["Collision mode","Fill",...h.fill?["Grid adjustment"]:[]]:[],divider:f.jsx(W.Icon,{mx:-1,as:X.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"})})]}),f.jsxs("span",{style:{display:we?"none":"contents"},children:[f.jsxs("span",{style:{display:R.bottomBarNavigation===!1?"none":"contents"},children:[R.edgeHandles!==!1&&f.jsx(ze,{label:_?"Draw Mode On (V)":"Draw Mode Off (V)",children:f.jsx(Ae,{"aria-label":"Toggle draw mode","aria-keyshortcuts":"V","aria-pressed":_,icon:f.jsx(W.Icon,{as:X.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:_?t:he,onClick:()=>k(!_)})}),f.jsx(W.Icon,{mx:-1,as:X.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(ze,{label:b?"Zoom Mode (z)":"Pan Mode (z)",children:f.jsx(Ae,{"aria-label":"Toggle zoom mode",icon:f.jsx(W.Icon,{as:b?X.PiMagnifyingGlassPlus:X.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:b?t:he,onClick:()=>v(!b)})}),f.jsx(W.Icon,{mx:-1,as:X.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(ze,{label:x?"Multi-Select On (m)":"Multi-Select Off (m)",children:f.jsx(Ae,{"aria-label":"Toggle multi-select",icon:f.jsx(W.Icon,{as:X.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:x?t:he,onClick:()=>w(!x)})}),f.jsx(W.Icon,{mx:-1,as:X.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(ze,{label:C?"Drag Mode On (d)":"Drag Mode Off (d)",children:f.jsx(Ae,{"aria-label":"Toggle drag mode",icon:f.jsx(W.Icon,{as:X.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:C?t:he,onClick:()=>j(!C)})})]}),R.bottomBarNavigation===!1&&(e===void 0?f.jsx(To,{}):e?Br.createPortal(f.jsx(To,{}),e):null),R.bottomBarExtra&&f.jsxs(f.Fragment,{children:[R.bottomBarNavigation!==!1&&f.jsx(W.Icon,{mx:-1,as:X.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"}),R.bottomBarExtra]}),f.jsx(W.Icon,{mx:-1,as:X.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"}),f.jsx(Gm,{})]}),f.jsx("span",{style:{display:R.bottomBarNavigation===!1||we&&!h?"none":"contents"},children:f.jsx(To,{})}),f.jsxs("span",{style:{display:we?"none":"contents"},children:[f.jsx(W.Icon,{mx:-1,as:X.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"}),f.jsx(qr,{label:"Collapse all",hideLabel:!0,checked:d,icon:f.jsx(W.Icon,{as:X.PiArrowsInLineVertical,boxSize:5}),onChange:u}),l!=="properties"&&f.jsxs(f.Fragment,{children:[f.jsx(W.Icon,{mx:-1,as:X.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(ze,{label:E?"Array Mode [ ]":"Set Mode { }",children:f.jsx(Ae,{"aria-label":"Toggle array mode",icon:f.jsx(W.Icon,{as:E?X.PiBracketsSquare:X.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:E?t:he,onClick:()=>{var Fe;const Pe=!E;O(Pe),(Fe=I.onArrayModeChange)==null||Fe.call(I,Pe)}})})]}),f.jsx(Ad,{}),!$&&f.jsxs("span",{style:{display:s?"contents":"none"},children:[f.jsx(W.Icon,{mx:-1,as:X.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(Er,{label:"Graph theme",colors:Jn,value:t,includeTransparent:!1,onPick:Pe=>{var Fe;n(Pe),(Fe=I.onThemeColorChange)==null||Fe.call(I,Pe)}})]}),!$&&f.jsxs(f.Fragment,{children:[f.jsx(W.Icon,{as:X.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"}),f.jsx(Er,{label:"Graph edge color",colors:Jn,value:i||(ie?"gray.500":Hr),onPick:o,onReset:()=>o("")}),f.jsx(W.Icon,{as:X.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"})]}),f.jsx(Um,{})]}),f.jsx(W.Icon,{mx:-1,as:X.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(ze,{label:we?"Expand toolbar":"Collapse toolbar",children:f.jsx(Ae,{"aria-label":"Toggle toolbar collapse",rememberAction:!1,icon:f.jsx(W.Icon,{as:we?X.PiCaretRight:X.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:he,onClick:()=>{var Pe;R.bottomBarCollapsed===void 0&&ce(!we),a(we),(Pe=I.onBottomBarCollapsedChange)==null||Pe.call(I,!we)}})}),!we&&f.jsx(gb,{})]})]})}),!gt&&f.jsxs(W.Box,{position:"relative",ml:"auto",flexShrink:0,children:[f.jsx(W.Box,{"data-flow-direction-control":"",bg:ae,borderRadius:"30px",h:50,css:lr(U,D),px:3,cursor:"pointer",onClick:()=>Q(!de),children:f.jsxs(W.Flex,{align:"center",h:"100%",children:[f.jsx(ze,{label:"Flow Direction",children:f.jsx(Ae,{"aria-label":"Direction",onClick:Pe=>{Pe.stopPropagation(),Q(!de)},icon:f.jsx(W.Icon,{as:X.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:he})}),f.jsx(W.Text,{fontSize:"xs",textTransform:"uppercase !important",color:ie?"whiteAlpha.600":"blackAlpha.500",ml:1,children:c.toUpperCase()})]})}),de&&f.jsx(W.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:f.jsxs(W.Box,{bg:ae,borderRadius:"30px",p:2,minW:"180px",css:lr(U,D),children:[xw.map(Pe=>f.jsxs(W.Flex,{align:"center",gap:3,px:3,py:2,css:Kn,cursor:"pointer",_hover:{bg:ie?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Fe;(Fe=I.onDirectionChange)==null||Fe.call(I,Pe.value),Q(!1)},children:[f.jsx(W.Icon,{as:Pe.icon,boxSize:5,color:me}),f.jsx(W.Text,{fontSize:"sm",color:me,flex:1,whiteSpace:"nowrap",children:Pe.label}),c===Pe.value&&f.jsx(W.Icon,{as:X.PiCheck,boxSize:4,color:q})]},Pe.value)),f.jsxs(W.Flex,{align:"center",gap:3,px:3,py:2,css:Kn,cursor:"pointer",_hover:{bg:ie?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Pe;(Pe=I.onDirectionChange)==null||Pe.call(I,"C"),Q(!1)},children:[f.jsx(W.Icon,{as:X.PiAlignCenterHorizontal,boxSize:5,color:me}),f.jsx(W.Text,{fontSize:"sm",color:me,flex:1,whiteSpace:"nowrap",children:"Center"}),c==="C"&&f.jsx(W.Icon,{as:X.PiCheck,boxSize:4,color:q})]})]})})]})]})})]})};mb.displayName="BottomBar";const bb=S.memo(mb);function ww({checked:e,onChange:r,disabled:t,label:n="Connected nodes"}){return f.jsx(qr,{hideLabel:!0,label:n,helper:`${n}: isolate node and its connections`,checked:e,onChange:r,disabled:t,icon:f.jsx(W.Icon,{as:X.PiGraph,boxSize:5})})}const Mu={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function vb(e,r){const t=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 l of c)if(!n(o[l],s[l])){if(Object.prototype.hasOwnProperty.call(Mu,l)){if(typeof s[l]!="string"||!s[l])return!1;t.set(a,{...t.get(a),[Mu[l]]:s[l]})}else if(l.startsWith("$")&&l!=="$"||!i(o[l],s[l],l==="$"?a:`${a}.${l}`))return!1}return!0};if(i(e,r,"root"))return t}function Cw(e,r){return vb(e,r)!==void 0}function Sw(e,r,t){if(e===r)return t;const n=vb(e,r);if(!n)return;const i=new Set(t.nodes.map(o=>o.data.id));for(const o of n.keys())if(!i.has(o)||!Te(r,o))return;return{edges:t.edges,nodes:t.nodes.map(o=>{const s=n.get(o.data.id),a=Te(e,o.data.id),c=Te(r,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 sd(e){return e.kind==="literal"?e.value:e.kind==="union"?sd(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,r])=>!r.optional).map(([r,t])=>[r,sd(t.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function xb(e,r,t){var g,b,v;const n=(g=Te(e,r))==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(x=>!/^[A-Za-z0-9_-]+$/.test(x)||["__proto__","constructor","prototype"].includes(x)))throw new Error("Invalid form creation address.");if(!t||!Object.prototype.hasOwnProperty.call(t,i.$type))throw new Error(`Load form type: ${i.$type}`);const s=o.pop(),a=["root",...o].join("."),c=Jr(e,a,t),l=(b=c==null?void 0:c.type.properties[s])==null?void 0:b.type;if((l==null?void 0:l.kind)!=="array"||l.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const d=t[i.$type],u=i.$defaults??{};for(const[x,w]of Object.entries(u))if(!Object.prototype.hasOwnProperty.call(d.properties,x)||zt(d.properties[x].type,w,!d.properties[x].optional))throw new Error(`Invalid creation default: ${x}`);const h={...sd(d),...structuredClone(u)};((v=d.properties.id)==null?void 0:v.type.kind)==="string"&&(h.id=yd());let p=e;const y=Te(e,i.$address);if(y===void 0)p=_t(e,a,x=>({...x,[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=xd(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:wd(m.json,r,{target:m.address,label:i.$edgeLabel})}}function wb(e,r,t){var o;if(r==="root"||!Te(e,r)||!Te(e,t))throw new Error("The source or Parent no longer exists.");const n=new Set;let i=t;for(;i;){if(i===r||i.startsWith(`${r}.`)||n.has(i))throw new Error("A node cannot be moved inside itself or its descendants.");n.add(i);const s=(o=Te(e,i))==null?void 0:o.$parent;i=typeof s=="string"?s:i.includes(".")?i.slice(0,i.lastIndexOf(".")):void 0}return vd(_t(e,r,s=>({...s,$parent:t})),t,!1)}function Cb(e,r){const t=new Set(r.filter(a=>Te(e,a)!==void 0)),n=[],i=(a,c)=>{if(!(!a||typeof a!="object")){n.push([c,a]);for(const[l,d]of Object.entries(a))l.startsWith("$")||i(d,`${c}.${l}`)}};i(e,"root");const o=a=>[...t].some(c=>a===c||a.startsWith(`${c}.`));let s=!0;for(;s;){s=!1;for(const[a,c]of n)!o(a)&&typeof c.$parent=="string"&&o(c.$parent)&&(t.add(a),s=!0)}return[...t].filter(a=>![...t].some(c=>c!==a&&a.startsWith(`${c}.`)))}function Pd(e,r){const t=Cb(e,r),n=new Map(t.map((a,c)=>[a,`root.node_${c+1}`])),i=a=>{const c=t.find(l=>a===l||a.startsWith(`${l}.`));return c?`${n.get(c)}${a.slice(c.length)}`:void 0},o=a=>{if(!(!a||typeof a!="object")){Array.isArray(a.$connections)&&(a.$connections=a.$connections.flatMap(c=>{const l=typeof c.target=="string"&&i(c.target);return l?[{...c,id:void 0,target:l}]:[]}));for(const c of["$parent","$target"])if(typeof a[c]=="string"){const l=i(a[c]);l?a[c]=l:delete a[c]}for(const[c,l]of Object.entries(a))c.startsWith("$")||o(l)}},s={$hideRoot:!0};return t.forEach((a,c)=>{const l=structuredClone(Te(e,a));o(l),s[`node_${c+1}`]=l}),s}function Sb(e,r){const t=Pd(e,r),n=Object.keys(t).filter(a=>!a.startsWith("$")),i=new Map(n.map(a=>[a,`copy_${crypto.randomUUID()}`])),o=a=>{if(!a||typeof a!="object")return;const c=l=>{const d=l.split(".");return d[0]==="root"&&i.has(d[1])&&(d[1]=i.get(d[1])),d.join(".")};for(const l of a.$connections??[])l.target=c(l.target),l.id=crypto.randomUUID();for(const l of["$parent","$target"])typeof a[l]=="string"&&(a[l]=c(a[l]));for(const[l,d]of Object.entries(a))l.startsWith("$")||o(d)},s=Object.fromEntries(n.map(a=>{const c=t[a];return o(c),[i.get(a),c]}));return{json:_t(e,"root",a=>({...a,...s})),ids:[...i.values()].map(a=>`root.${a}`)}}function jw(e,r){const t=i=>e&&typeof e=="object"&&i in e;let n=1;for(;t(`${r}_${n}`);)n++;return`${r}_${n}`}function jb(e,r,t,n,i){const o=(a,c)=>{a!==e&&(e=a,n==null||n(a,c))},s=a=>{var l;const c=(l=r.find(d=>d.data.id===a))==null?void 0:l.data;return c&&{source:c.source,target:c.target,isInverted:c.isInverted,sourceProperty:c.sourceProperty,targetProperty:c.targetProperty,connection:c.connection}};return{...t,onNodeParentChange:(a,c)=>{var d;const l=wb(e,a,c);(d=t.onNodeParentChange)==null||d.call(t,a,c),o(l,{type:"nodeStyle",address:a,key:"$parent",value:c})},onNodesCopy:async a=>{var c;await((c=t.onNodesCopy)==null?void 0:c.call(t,a))!==!0&&await navigator.clipboard.writeText(JSON.stringify(Pd(e,a),null,2))},onNodesDuplicate:a=>{var l;if(((l=t.onNodesDuplicate)==null?void 0:l.call(t,a))===!0)return;const c=Sb(e,a);o(c.json,{type:"nodeCreate",address:c.ids[0]})},onFormChange:a=>{const c=Te(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(io(e,a,t.onFormChange),{type:"form",address:a.address,value:a.value})},onNodeLabelChange:(a,c)=>{var l;(l=t.onNodeLabelChange)==null||l.call(t,a,c),o(xt(e,a,"$label",c),{type:"nodeLabel",address:a,key:"$label",value:c})},onNodeSubtitleChange:(a,c)=>{var l;(l=t.onNodeSubtitleChange)==null||l.call(t,a,c),o(xt(e,a,"$subtitle",c),{type:"nodeStyle",address:a,key:"$subtitle",value:c})},onNodeContentChange:(a,c)=>{var l;(l=t.onNodeContentChange)==null||l.call(t,a,c),o(xt(e,a,"$content",c),{type:"nodeContent",address:a,key:"$content",value:c})},onNodeTypeViewChange:(a,c)=>{var l;c!==void 0&&!hd.includes(c)||((l=t.onNodeTypeViewChange)==null||l.call(t,a,c),o(xt(e,a,"$view",c),{type:"nodeStyle",address:a,key:"$view",value:c}))},onNodeColorChange:(a,c,l)=>{var u;(u=t.onNodeColorChange)==null||u.call(t,a,c,l);const d=c==="bg"?"$bgColor":"$textColor";o(xt(e,a,d,l),{type:"nodeColor",address:a,key:d,value:l})},onNodeBorderColorChange:(a,c)=>{var l;(l=t.onNodeBorderColorChange)==null||l.call(t,a,c),o(xt(e,a,"$borderColor",c),{type:"nodeColor",address:a,key:"$borderColor",value:c})},onNodeBorderStyleChange:(a,c)=>{var l;(l=t.onNodeBorderStyleChange)==null||l.call(t,a,c),o(xt(e,a,"$borderStyle",c),{type:"nodeStyle",address:a,key:"$borderStyle",value:c})},onNodeBorderWidthChange:(a,c)=>{var l;c!==void 0&&(!Number.isFinite(c)||c<0)||((l=t.onNodeBorderWidthChange)==null||l.call(t,a,c),o(xt(e,a,"$borderWidth",c),{type:"nodeStyle",address:a,key:"$borderWidth",value:c}))},onNodeBorderRadiusChange:(a,c)=>{var l;c!==void 0&&(!Number.isFinite(c)||c<0)||((l=t.onNodeBorderRadiusChange)==null||l.call(t,a,c),o(xt(e,a,"$borderRadius",c),{type:"nodeStyle",address:a,key:"$borderRadius",value:c}))},onNodeIconChange:(a,c)=>{var l;(l=t.onNodeIconChange)==null||l.call(t,a,c),o(xt(e,a,"$icon",c),{type:"nodeIcon",address:a,key:"$icon",value:c})},onNodeOutlineChange:(a,c)=>{var l;(l=t.onNodeOutlineChange)==null||l.call(t,a,c),o(xt(e,a,"$outline",c),{type:"nodeOutline",address:a,key:"$outline",value:c})},onNodeAnimationChange:(a,c)=>{var l;(l=t.onNodeAnimationChange)==null||l.call(t,a,c),o(xt(e,a,"$isNodeAnimated",c),{type:"nodeAnimation",address:a,key:"$isNodeAnimated",value:c})},onNodeAnimationVariantChange:(a,c)=>{var l;c!=="traveling"&&c!=="pulse"||((l=t.onNodeAnimationVariantChange)==null||l.call(t,a,c),o(xt(e,a,"$nodeAnimationVariant",c),{type:"nodeAnimation",address:a,key:"$nodeAnimationVariant",value:c}))},onNodeCollapse:(a,c)=>{var l;(l=t.onNodeCollapse)==null||l.call(t,a,c),o(vd(e,a,c),{type:"nodeCollapse",address:a,key:"$collapsed",value:c})},onNodeCreate:a=>{var p,y;if(((p=t.onNodeCreate)==null?void 0:p.call(t,a))===!0)return;const c=a.sourceNodeId||"root",l=!!a.sourceNodeId&&a.isArrayMode&&!((y=Te(e,c))!=null&&y.$arrayDrawInitialized);let d=e,u,h=a.isArrayMode?"array":"set";for(let m=0;m<(l?2:1);m++){const g=a.sourceNodeId&&xb(d,a.sourceNodeId,i);if(g)d=g.json,u??(u=g.address),h="form";else{const b=jw(Te(d,c),a.isArrayMode?"list":"node"),v=a.isArrayMode?{$bgColor:"gray.500",$:[]}:{$bgColor:"gray.500"},x=xd(d,c,v,b);d=x.json,u??(u=x.address)}}l&&(d=_t(d,c,m=>Array.isArray(m)?{$:m,$arrayDrawInitialized:!0}:{...m,$arrayDrawInitialized:!0})),o(d,{type:"nodeCreate",address:u,value:h})},onNodeDelete:(a,c)=>{var l;(l=t.onNodeDelete)==null||l.call(t,a,c),o(Ym(e,a),{type:"nodeDelete",address:a})},onEdgeCreate:(a,c,l)=>{var u;(u=t.onEdgeCreate)==null||u.call(t,a,c,l);const d=l&&(l.sourceProperty!==void 0||l.targetProperty!==void 0)?{...l,target:c}:void 0;o(d?wd(e,a,d):Qm(e,a,c),{type:"edgeCreate",address:a,key:d?"$connections":"$target",value:d??c})},onEdgeLabelChange:(a,c)=>{var d;(d=t.onEdgeLabelChange)==null||d.call(t,a,c);const l=s(a);l&&o(ar(e,l,"$sourceLabel",c),{type:"edgeLabel",edge:l,key:l.connection?"$connections":"$sourceLabel",value:c})},onEdgeStyleChange:(a,c)=>{var d;(d=t.onEdgeStyleChange)==null||d.call(t,a,c);const l=s(a);l&&o(Xm(e,l,c),{type:"edgeStyle",edge:l,value:c})},onEdgeAnimationVariantChange:(a,c)=>{var d;if(c!=="dashed"&&c!=="traveling")return;(d=t.onEdgeAnimationVariantChange)==null||d.call(t,a,c);const l=s(a);l&&o(ar(e,l,"$edgeAnimationVariant",c),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeAnimationVariant",value:c})},onEdgeTypeChange:(a,c)=>{var d;(d=t.onEdgeTypeChange)==null||d.call(t,a,c);const l=s(a);l&&o(ar(e,l,"$edgeType",c),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeType",value:c})},onEdgeIconChange:(a,c)=>{var d;(d=t.onEdgeIconChange)==null||d.call(t,a,c);const l=s(a);l&&o(ar(e,l,"$edgeIcon",c||void 0),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeIcon",value:c})},onEdgeColorChange:(a,c)=>{var d;(d=t.onEdgeColorChange)==null||d.call(t,a,c);const l=s(a);l&&o(ar(e,l,"$edgeColor",c),{type:"edgeColor",edge:l,key:l.connection?"$connections":"$edgeColor",value:c})},onEdgeDelete:(a,c)=>{var u;(u=t.onEdgeDelete)==null||u.call(t,a,c);const l=s(a);if(!l)return;const d=eb(e,l);d.removed&&o(d.json,{type:"edgeDelete",edge:l,key:l.connection?"$connections":"$target"})}}}const _w=".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 Ew({path:e,width:r,reversed:t,children:n,onComplete:i}){const o=`flow-edge-reveal-${S.useId().replace(/:/g,"")}`,s=S.useRef(null),[a,c]=S.useState({x:0,y:0,width:1,height:1});return S.useEffect(()=>{const l=matchMedia("(prefers-reduced-motion: reduce)"),d=()=>{l.matches&&(i==null||i())};return d(),l.addEventListener("change",d),()=>l.removeEventListener("change",d)},[i]),S.useLayoutEffect(()=>{var d;const l=(d=s.current)==null?void 0:d.getBBox();l&&c({x:l.x-r,y:l.y-r,width:l.width+r*2,height:l.height+r*2})},[e,r]),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:l=>{l.animationName==="flow-sdk-edge-reveal"&&(i==null||i())},"data-reveal-direction":t?"reverse":"forward",style:{"--flow-edge-reveal-from":t?-100:100},d:e,fill:"none",stroke:"white",strokeWidth:r,strokeLinecap:"butt",strokeLinejoin:"round",pathLength:100,strokeDasharray:"100 100"})})}),f.jsx("g",{mask:`url(#${o})`,children:n})]})}const Rw=".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 kw({path:e,color:r,width:t,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:r,strokeWidth:t,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 100"})}const _b=".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 Zn({x:e=0,y:r=0,width:t,height:n,radius:i,color:o,strokeWidth:s=8,path:a,variant:c="traveling"}){const l=S.useId(),d=`flow-sdk-node-border-animation${c==="pulse"?" flow-sdk-node-border-pulse":""}`;if(c==="pulse"){const u=a?"path":"rect",h=a?{d:a}:{x:e,y:r,width:Math.max(0,t),height:Math.max(0,n),rx:Math.max(0,Math.min(i,t/2,n/2))},p=s+36,y={x:e-p,y:r-p,width:t+2*p,height:n+2*p};return f.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[f.jsx("defs",{children:f.jsxs("mask",{id:l,maskUnits:"userSpaceOnUse",...y,style:{maskType:"luminance"},children:[f.jsx("rect",{...y,fill:"white"}),f.jsx(u,{...h,fill:"black",stroke:"black",strokeWidth:s,strokeLinejoin:"round"})]})}),f.jsx(u,{...h,className:d,"data-animation-variant":c,fill:"none",stroke:`color-mix(in srgb, ${o} 30%, transparent)`,strokeLinejoin:"round",mask:`url(#${l})`,style:{"--flow-pulse-rest-width":`${s+16}px`,"--flow-pulse-expanded-width":`${s+36}px`}})]})}return a?f.jsx("path",{className:d,"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:d,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",x:e,y:r,width:Math.max(0,t),height:Math.max(0,n),rx:Math.max(0,Math.min(i,t/2,n/2)),fill:"none",stroke:o,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const Aw=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 Eb(e,r=!1){return e&&!r&&typeof requestAnimationFrame<"u"&&!(typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches)}function Rb(e,r,t=()=>{},n=300){let i,o,s=!1;const a=()=>{s=!0,i!==void 0&&cancelAnimationFrame(i),clearTimeout(o)},c=()=>{s||(a(),r(1),t())};if(!Eb(e))return c(),a;const l=performance.now(),d=u=>{if(s)return;const h=Math.max(0,Math.min(1,(u-l)/n));if(h>=1)return c();r(h<.5?4*h**3:1-(-2*h+2)**3/2),s||(i=requestAnimationFrame(d))};return i=requestAnimationFrame(d),o=setTimeout(c,n+100),a}function Tu(e,r,t){const n=new Set([e]),i=[e];for(;i.length;){const o=i.pop();for(const s of r)(s.parent===o||s.id.startsWith(`${o}.`)||t.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 Pw(e,r,t){const n=t==="downward"||t==="upward",i=new Map;for(const s of e){if(s.source===s.target||s.sourceProperty||s.targetProperty)continue;const a=r(s.source),c=r(s.target);if(!a||!c)continue;const l=n?c.y-a.y:c.x-a.x,d=Math.abs(l)-(n?a.h+c.h:a.w+c.w)/2;if(d<=320)continue;const u=JSON.stringify([s.source,Math.sign(l)]),h=i.get(u)??[];h.push({edge:s,gap:d,cross:n?c.x-a.x:c.y-a.y}),i.set(u,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 l=s.filter(({cross:u})=>Math.sign(u)===c);l.sort((u,h)=>Math.abs(h.cross)-Math.abs(u.cross)||u.edge.id.localeCompare(h.edge.id));const d=Math.min(...l.map(({gap:u})=>u));l.forEach(({edge:u,gap:h,cross:p},y)=>{const m=l.length===1?d/2:120+(d-280)*y/(l.length-1),g=l.find(b=>Math.abs(b.cross)<Math.abs(p));o.set(u.id,{turn:m/h,labelAtTarget:a.get(u.target)===1,labelFraction:p?(p+((g==null?void 0:g.cross)??0))/(2*p):.5})})}}return o}const Xt=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}),Iw=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function $o(e){if(!e.length)return null;const r={...e[0]};for(let t=1;t<e.length;t++)r.x1=Math.min(r.x1,e[t].x1),r.y1=Math.min(r.y1,e[t].y1),r.x2=Math.max(r.x2,e[t].x2),r.y2=Math.max(r.y2,e[t].y2);return r}const Mw=(e,r)=>e.x1<=r.x2&&e.x2>=r.x1&&e.y1<=r.y2&&e.y2>=r.y1,Ou=(e,r)=>e.x>=r.x1&&e.x<=r.x2&&e.y>=r.y1&&e.y<=r.y2,Tt=e=>(Math.round(e*10)/10).toString(),ut=e=>`${Tt(e.x)} ${Tt(e.y)}`,Tw=e=>e>0?1:e<0?-1:0,Nu=(e,r)=>e>0?Math.max(e-r,0):Math.min(e+r,0);function Ow(e,r,t,n,i=10){const o=r.x-e.x,s=r.y-e.y,a=Nu(o,(e.w+r.w)/2),c=Nu(s,(e.h+r.h)/2),l=t==="downward"||t==="upward",d=l?c:a,u=l?s:o,h=Tw(u),p=n*d,y=v=>Math.abs(v)<i||Math.abs(v)>=Math.abs(d),m=y(p)||y(Math.abs(d)-Math.abs(p));let g;if(m)if(l)if(Math.abs(u)<=e.h/2){const v=(e.x+r.x)/2;g=[v,e.y,v,r.y]}else if(Math.abs(o)<=r.w/2){const v=(e.y+r.y)/2;g=[e.x,v,r.x,v]}else g=[e.x,r.y];else if(Math.abs(u)<=e.w/2){const v=(e.y+r.y)/2;g=[e.x,v,r.x,v]}else if(Math.abs(s)<=r.h/2){const v=(e.x+r.x)/2;g=[v,e.y,v,r.y]}else g=[r.x,e.y];else if(l){const v=e.y+p+e.h/2*h;g=[e.x,v,r.x,v]}else{const v=e.x+p+e.w/2*h;g=[v,e.y,v,r.y]}const b=[{x:e.x,y:e.y}];for(let v=0;v<g.length;v+=2)b.push({x:g[v],y:g[v+1]});return b.push({x:r.x,y:r.y}),b}function Nw(e,r,t){const n=r.x-e.x,i=r.y-e.y,o=n>0?(t.x2-e.x)/n:n<0?(t.x1-e.x)/n:1/0,s=i>0?(t.y2-e.y)/i:i<0?(t.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 Gr(e,r,t){var s;if(!((s=t.outline)!=null&&s.length))return Nw(e,r,Xt(t));const n=r.x-e.x,i=r.y-e.y;let o=1/0;return t.outline.forEach((a,c,l)=>{const d=l[(c+1)%l.length],u=d.x-a.x,h=d.y-a.y,p=n*h-i*u;if(Math.abs(p)<1e-9)return;const y=a.x-e.x,m=a.y-e.y,g=(y*h-m*u)/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 kb(e,r,t=.5){const n=Number.isFinite(t)?Math.max(0,Math.min(1,t)):.5,i=r==="top"||r==="bottom",o=r==="top"||r==="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{...Gr(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:r}}function $r(e,r){return{x:e.x+(e.side==="right"?r:e.side==="left"?-r:0),y:e.y+(e.side==="bottom"?r:e.side==="top"?-r:0)}}function $w(e,r,t,n){const i=$r(e,t.srcDist),o=$r(r,t.tgtDist);if(n==="straight")return Pb(i,o,t);const s=Math.max(80,Math.min(300,Math.hypot(o.x-i.x,o.y-i.y)/3)),a=e.side==="bottom"&&r.side==="top"?o.y-i.y:e.side==="top"&&r.side==="bottom"?i.y-o.y:e.side==="right"&&r.side==="left"?o.x-i.x:e.side==="left"&&r.side==="right"?i.x-o.x:void 0,c=a!==void 0&&a>0?Math.min(s,a/2):s,l=$r({...i,side:e.side},c),d=$r({...o,side:r.side},c),u=t.arrowAt==="source"?yt(i,l,t.arrowGap):i,h=t.arrowAt==="target"?yt(o,d,t.arrowGap):o,p=t.arrowAt==="source"?Nt(i,l,t.arrowSize,t.headShape):t.arrowAt==="target"?Nt(o,d,t.arrowSize,t.headShape):void 0;if(n==="bezier")return{d:`M${ut(u)} C${ut(l)} ${ut(d)} ${ut(h)}`,arrow:p,label:{x:(u.x+3*l.x+3*d.x+h.x)/8,y:(u.y+3*l.y+3*d.y+h.y)/8,angle:0}};const y=e.side==="left"||e.side==="right",m=r.side==="left"||r.side==="right";let g;if(y!==m){const v=y?{x:d.x,y:l.y}:{x:l.x,y:d.y},x=(v.x-l.x)*(l.x-i.x)+(v.y-l.y)*(l.y-i.y)>=0,w=(v.x-d.x)*(d.x-o.x)+(v.y-d.y)*(d.y-o.y)>=0;g=[x&&w?v:y?{x:l.x,y:d.y}:{x:d.x,y:l.y}]}else if(a!==void 0&&a<=0)if(y){const v=(l.y+d.y)/2;g=[{x:l.x,y:v},{x:d.x,y:v}]}else{const v=(l.x+d.x)/2;g=[{x:v,y:l.y},{x:v,y:d.y}]}else if(y){const v=e.side===r.side?e.side==="right"?Math.max(l.x,d.x):Math.min(l.x,d.x):(l.x+d.x)/2;g=[{x:v,y:l.y},{x:v,y:d.y}]}else{const v=e.side===r.side?e.side==="bottom"?Math.max(l.y,d.y):Math.min(l.y,d.y):(l.y+d.y)/2;g=[{x:l.x,y:v},{x:d.x,y:v}]}const b=[l,...g,d].filter((v,x,w)=>x===0||v.x!==w[x-1].x||v.y!==w[x-1].y);return ao(u,b,h,p,n==="orthogonal"?0:t.radius)}function yt(e,r,t){const n=e.x-r.x,i=e.y-r.y,o=Math.hypot(n,i);if(!o)return e;let s=(o-t)/o;return s<0&&(s=1e-5),{x:r.x+s*n,y:r.y+s*i}}function Nt(e,r,t,n="triangle"){const i=e.x-r.x,o=e.y-r.y,s=Math.hypot(i,o)||1,a=i/s,c=o/s,l=(n==="square"?.15:.3)*t,d=.15*t,u=e.x-a*l,h=e.y-c*l;if(n==="square")return`M${ut(e)} L${Tt(e.x-c*d)} ${Tt(e.y+a*d)} L${Tt(u-c*d)} ${Tt(h+a*d)} L${Tt(u+c*d)} ${Tt(h-a*d)} L${Tt(e.x+c*d)} ${Tt(e.y-a*d)} Z`;const p=[e,{x:u-c*d,y:h+a*d},{x:u+c*d,y:h-a*d}];return p.map((m,g)=>{const b=p[(g+2)%3],v=p[(g+1)%3],x=Math.hypot(b.x-m.x,b.y-m.y),w=Math.hypot(v.x-m.x,v.y-m.y),C={x:(b.x-m.x)/x,y:(b.y-m.y)/x},j={x:(v.x-m.x)/w,y:(v.y-m.y)/w},_=Math.max(-1,Math.min(1,C.x*j.x+C.y*j.y)),k=Math.sqrt((1-_)/(1+_)),E=Math.min(1/k,x/2,w/2);return{start:{x:m.x+C.x*E,y:m.y+C.y*E},end:{x:m.x+j.x*E,y:m.y+j.y*E},radius:E*k}}).map((m,g)=>`${g?"L":"M"}${ut(m.start)} A${Tt(m.radius)} ${Tt(m.radius)} 0 0 1 ${ut(m.end)}`).join(" ")+" Z"}function ir(e,r){let t=Math.atan(r/e);return e===0&&t<0&&(t=-t),Number.isFinite(t)||(t=0),t*180/Math.PI}function qw(e,r,t,n){const i={x:r.x-e.x,y:r.y-e.y},o={x:t.x-r.x,y:t.y-r.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:r,b:r,p2:r,r:0};const l=Math.min(n,s/2,a/2);return{p1:{x:r.x-i.x/s*l,y:r.y-i.y/s*l},b:r,p2:{x:r.x+o.x/a*l,y:r.y+o.y/a*l},r:l}}function Ab(e,r,t,n){let i=-1,o=null;for(let y=0;y<e.length-1;y++){const m=Gr(e[y],e[y+1],r);if(m){i=y,o=m;break}}let s=-1,a=null;for(let y=e.length-1;y>0;y--){const m=Gr(e[y],e[y-1],t);if(m){s=y,a=m;break}}if(!o||!a||i>=s)return null;const c=e.slice(i+1,s),l=c[0]??a,d=c[c.length-1]??o;let u,h,p;if(n.arrowAt==="source"){const y=yt(o,l,n.srcDist);u=yt(o,l,n.srcDist+n.arrowGap),p=Nt(y,l,n.arrowSize,n.headShape)}else u=yt(o,l,n.srcDist);if(n.arrowAt==="target"){const y=yt(a,d,n.tgtDist);h=yt(a,d,n.tgtDist+n.arrowGap),p=Nt(y,d,n.arrowSize,n.headShape)}else h=yt(a,d,n.tgtDist);return ao(u,c,h,p,n.radius,n.labelTargetLength,n.labelFraction)}function ao(e,r,t,n,i,o,s){var h;const a=[e,...r,t],c=[];let l=`M${ut(e)}`;for(let p=1;p<a.length-1;p++){const y=qw(a[p-1],a[p],a[p+1],i);c.push(y),y.r===0?l+=` L${ut(y.b)}`:l+=` L${ut(y.p1)} Q${ut(y.b)} ${ut(y.p2)}`}l+=` L${ut(t)}`;let d;const u=r.length;if(u===0)d={x:(e.x+t.x)/2,y:(e.y+t.y)/2,angle:ir(t.x-e.x,t.y-e.y)};else if(u%2===0){const p=r[u/2-1],y=r[u/2];d={x:(p.x+y.x)/2,y:(p.y+y.y)/2,angle:ir(y.x-p.x,y.y-p.y)}}else{const p=c[(u-1)/2];if(p.r===0){const y=a[(u-1)/2+2];d={x:p.b.x,y:p.b.y,angle:ir(y.x-p.b.x,y.y-p.b.y)}}else d={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:ir(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,v=Math.hypot(b.x-g.x,b.y-g.y),x=Math.min(.5,o/(2*v)),w=Math.max(x,Math.min(1-x,s));d={x:g.x+(b.x-g.x)*w,y:g.y+(b.y-g.y)*w,angle:ir(b.x-g.x,b.y-g.y)}}const p=((h=c[c.length-1])==null?void 0:h.p2)??e,y=t.x-p.x,m=t.y-p.y;Math.hypot(y,m)>=o&&(d={x:(p.x+t.x)/2,y:(p.y+t.y)/2,angle:ir(y,m)})}return{d:l,arrow:n,label:d}}function $u(e,r,t,n,i,o,s){const a=t==="leftward"?-1:1,c={x:e.x+a*(e.w/2+s.srcDist),y:n??e.y},l={x:r.x-a*(r.w/2+s.tgtDist),y:i??r.y},d=Math.max(80,s.arrowGap+s.arrowSize*.3),u=c.x+a*d,h=l.x-a*d;let p;if(a*(h-u)>=0){const b=c.x+(l.x-c.x)*o,v=Math.max(Math.min(u,h),Math.min(Math.max(u,h),b));p=[{x:v,y:c.y},{x:v,y:l.y}]}else{const b=Math.min(e.y-e.h/2,r.y-r.h/2)-d*(1+o);p=[{x:u,y:c.y},{x:u,y:b},{x:h,y:b},{x:h,y:l.y}]}const y=s.arrowAt==="source"?yt(c,p[0],s.arrowGap):c,m=s.arrowAt==="target"?yt(l,p[p.length-1],s.arrowGap):l,g=s.arrowAt==="source"?Nt(c,p[0],s.arrowSize,s.headShape):s.arrowAt==="target"?Nt(l,p[p.length-1],s.arrowSize,s.headShape):void 0;return ao(y,p,m,g,s.radius)}function qu(e,r,t,n,i){return Ab(Ow(e,r,t,n),e,r,i)}function Lu(e,r,t,n,i,o){const s=n===void 0&&i===void 0&&(t==="downward"||t==="upward"),a=t==="leftward"||s&&t==="upward"?-1:1,c=(l,d,u)=>{const h={x:l.x,y:d??l.y},p=Math.max(l.w,l.h)*2+1,y=Gr(h,{x:h.x+(s?0:u*p),y:h.y+(s?u*p:0)},l);return y?{x:y.x+(s?0:u*o),y:y.y+(s?u*o:0)}:s?{x:l.x,y:l.y+u*(l.h/2+o)}:{x:l.x+u*(l.w/2+o),y:d??l.y}};return{sourcePoint:c(e,n,a),targetPoint:c(r,i,-a)}}function Lw(e,r,t,n){const i=t==="downward"||t==="upward",o=t==="leftward"||t==="upward"?-1:1,s=Math.max(100,Math.abs(i?r.y-e.y:r.x-e.x)/2),a={x:e.x+(i?0:o*s),y:e.y+(i?o*s:0)},c={x:r.x-(i?0:o*s),y:r.y-(i?o*s:0)},l=n.arrowAt==="source"?yt(e,a,n.arrowGap):e,d=n.arrowAt==="target"?yt(r,c,n.arrowGap):r;return{d:`M${ut(l)} C${ut(a)} ${ut(c)} ${ut(d)}`,arrow:n.arrowAt==="source"?Nt(e,a,n.arrowSize,n.headShape):n.arrowAt==="target"?Nt(r,c,n.arrowSize,n.headShape):void 0,label:{x:(l.x+3*a.x+3*c.x+d.x)/8,y:(l.y+3*a.y+3*c.y+d.y)/8,angle:ir(d.x+c.x-a.x-l.x,d.y+c.y-a.y-l.y)}}}function Pb(e,r,t){const n=t.arrowAt==="source"?yt(e,r,t.arrowGap):e,i=t.arrowAt==="target"?yt(r,e,t.arrowGap):r,o=t.arrowAt==="source"?Nt(e,r,t.arrowSize,t.headShape):t.arrowAt==="target"?Nt(r,e,t.arrowSize,t.headShape):void 0;return ao(n,[],i,o,0)}function Fw(e,r,t,n=-90,i=-60,o=350){const s=n*Math.PI/180,a=i*Math.PI/180,c=s-Math.PI/2,l=c-a/2,d=c+a/2,u=1.4*o*(r/3+1),h={x:e.x+Math.cos(l)*u,y:e.y+Math.sin(l)*u},p={x:e.x+Math.cos(d)*u,y:e.y+Math.sin(d)*u},y={x:e.x,y:e.y},m=Gr(y,h,e),g=Gr(y,p,e);if(!m||!g)return null;const b={x:(h.x+p.x)/2,y:(h.y+p.y)/2};let v=yt(m,h,t.srcDist),x=yt(g,p,t.tgtDist),w;if(t.arrowAt==="target"){const j=x;x=yt(g,p,t.tgtDist+t.arrowGap),w=Nt(j,p,t.arrowSize,t.headShape)}else if(t.arrowAt==="source"){const j=v;v=yt(m,h,t.srcDist+t.arrowGap),w=Nt(j,h,t.arrowSize,t.headShape)}return{d:`M${ut(v)} Q${ut(h)} ${ut(b)} Q${ut(p)} ${ut(x)}`,arrow:w,label:{x:b.x,y:b.y,angle:ir(p.x-h.x,p.y-h.y)}}}const Tr=e=>Math.round(e*1e3)/1e3;function Ib(e){const r=e.querySelector("[data-flow-node-surface]");if(!r)return;const t=e.getBoundingClientRect(),n=t.width/e.offsetWidth;if(!Number.isFinite(n)||n<=0)return;const i=r.getBoundingClientRect();if(!i.width||!i.height)return;const o=r,s=typeof o.getScreenCTM=="function"?o.getScreenCTM():null,a=typeof o.getTotalLength=="function"?o.getTotalLength():0,c=o.points,l=(c==null?void 0:c.numberOfItems)||128,d=s&&a>0?Array.from({length:l},(u,h)=>{const p=c!=null&&c.numberOfItems?c.getItem(h):o.getPointAtLength(a*h/l);return{x:Tr((s.a*p.x+s.c*p.y+s.e-t.left)/n),y:Tr((s.b*p.x+s.d*p.y+s.f-t.top)/n)}}):void 0;return{left:Tr((i.left-t.left)/n),top:Tr((i.top-t.top)/n),width:r instanceof HTMLElement?r.offsetWidth:Tr(i.width/n),height:r instanceof HTMLElement?r.offsetHeight:Tr(i.height/n),radius:parseFloat(getComputedStyle(r).borderTopLeftRadius)||0,...d?{outline:d}:{}}}function wn(e,r){const t=e.x-e.w/2,n=e.y-e.h/2;return{x:t+r.left+r.width/2,y:n+r.top+r.height/2,w:r.width,h:r.height,...r.outline?{outline:r.outline.map(i=>({x:t+i.x,y:n+i.y}))}:{}}}function zw(e,r,t,n,i){var d;const o=i!=="TB"&&i!=="BT",s=o?"top":"left",a=o?"bottom":"right",c=new Map;for(const u of n)for(const[h,p,y]of[[u.source,u.sourceProperty,u.target],[u.target,u.targetProperty,u.source]]){const m=r.get(y);if(p===void 0||!m||y===h)continue;const g=t.get(y),b=JSON.stringify([h,p]),v=c.get(b)??[];v.push(g?wn(m,g):m),c.set(b,v)}const l=new Map(e);for(const[u,h]of e){const p=r.get(u);if(!p||!h.some(x=>x.placement==="config"))continue;const y=t.get(u),m=y?wn(p,y):p,g={x:p.w/2,y:p.h/2,w:p.w,h:p.h},b=y?wn(g,y):g,v=new Map;for(const x of h){if(x.placement!=="config")continue;const C=(c.get(JSON.stringify([u,x.property]))??[]).reduce((_,k)=>_+(o?k.y-m.y:k.x-m.x),0),j=((d=x.anchor)==null?void 0:d.side)===a?a:s;v.set(x,C<-.001?s:C>.001?a:j)}l.set(u,h.map(x=>{const w=v.get(x);if(!w)return x;const C=h.filter(k=>v.get(k)===w),j=(C.indexOf(x)+1)/(C.length+1),_=kb(b,w,j);return{...x,anchor:_,top:_.y,height:0}}))}return l}function Fu(e,r,t){const n=new Set(r.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 r)!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 t)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 cr='"Helvetica Neue", Helvetica, sans-serif';let an;const Dn=new Map;function so(e,r){const t=`${r}|${e}`,n=Dn.get(t);if(n!==void 0)return n;an===void 0&&(an=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let i;return an?(an.font=r,i=an.measureText(e).width):i=e.length*(parseFloat(r)||16)*.55,Dn.size>5e3&&Dn.clear(),Dn.set(t,i),i}function Bw(e,r,t){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||so(c,r)<=t?s=c:(n.push(s),s=a)}n.push(s)}return n}const zu=e=>e.stopPropagation();function Dw({id:e,rect:r,label:t,labelLayer:n,labelContent:i,style:o,onSelect:s,onCollapse:a,selected:c=!1}){const l=r.x2-r.x1,d=r.y2-r.y1,u=o.borderWidth,h=o.borderStyle==="dashed"?`${u*4} ${u*2}`:o.borderStyle==="dotted"?`${u} ${u}`:void 0,p=r.x1+l/2,y=o.labelPosition==="top"?r.y1+o.labelMargin-o.fontSize/2:o.labelPosition==="bottom"?r.y2-o.labelMargin+o.fontSize/2:r.y1+d/2,m=t?so(t,`bold ${o.fontSize}px ${cr}`):0,g=o.fontSize/5,b=t||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":"","data-flow-collapse-control":"",style:{pointerEvents:"auto"},children:f.jsx(ze,{label:"Show icon",children:f.jsx(Ae,{"aria-label":"Show icon",icon:f.jsx(X.PiCircleFill,{}),variant:"ghost",style:{width:48,height:48,color:o.textColor},onClick:v=>{v.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:zu,children:i}):t&&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:cr,style:{fontSize:o.fontSize,fontWeight:"bold",fontFamily:cr},textAnchor:"middle",dominantBaseline:"central",children:t})]})]}):null;return f.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:zu,onClick:v=>{v.stopPropagation(),s==null||s(e,{shiftKey:v.shiftKey,ctrlKey:v.ctrlKey,metaKey:v.metaKey,altKey:v.altKey})},children:[f.jsx("rect",{x:r.x1,y:r.y1,width:l,height:d,rx:o.borderRadius,ry:o.borderRadius,fill:o.bgColor,fillOpacity:o.bgOpacity,stroke:o.borderColor,strokeWidth:o.borderStyle==="double"?u/3:u,strokeDasharray:h}),o.borderStyle==="double"&&f.jsx("rect",{x:r.x1+u*2/3,y:r.y1+u*2/3,width:Math.max(0,l-u*4/3),height:Math.max(0,d-u*4/3),rx:Math.max(0,o.borderRadius-u*2/3),ry:Math.max(0,o.borderRadius-u*2/3),fill:"none",stroke:o.borderColor,strokeWidth:u/3}),o.animated&&u>0&&f.jsx(Zn,{variant:o.animationVariant,x:r.x1,y:r.y1,width:l,height:d,radius:o.borderRadius,color:o.animationColor||o.borderColor,strokeWidth:Math.max(8,u*1.6)}),n&&b?Br.createPortal(b,n):b]})}const Vw=S.memo(Dw),Xn=45,Mb=70,xr=15,Tb=50;function Ob(e,r,t=Xn){const n=`${t}px ${cr}`,i=e?Bw(e,n,200*t/Xn):[],o=r?48+(i.length?12:0):0,s=o+Math.max(0,...i.map(l=>so(l,n))),a=Math.max(i.length*t,r?48:0),c=i.length||r?2*xr:0;return{lines:i,iconWidth:o,contentWidth:s,contentHeight:a,width:s+c,height:a+c}}const Cn=6,Nb=3,Id=.3,Ww=8,Md=Math.max(Math.pow(Cn*13.37,.9),29)*Nb-Ww/Id,$b=Cn*Nb*2,Gn=80,Gw=2*Gn+Md*Id+100,Uw=36+2*Math.max(80,$b+Md*Id);function cd(e){return e.sourceProperty!==void 0||e.targetProperty!==void 0}function ld(e,r){return r==="auto"||(r==="properties"?cd(e):!cd(e))}function nr(e,r,t){return t!=="properties"||e!=="root"||r.some(n=>(n.source===e||n.target===e)&&cd(n))}function Hw(e,r,t,n=!1,i){if(!n)return{nodes:e,edges:r};const o=e.filter(a=>nr(a.id,r,t)&&(!i||i.has(a.id))),s=new Set(o.map(a=>a.id));return{nodes:o,edges:r.filter(a=>ld(a,t)&&s.has(a.source)&&s.has(a.target))}}const Kw=500,Jw="32 18",Zw=e=>e.stopPropagation();function Xw({id:e,reveal:r,onRevealComplete:t,edgeData:n,validationIssue:i,edgeType:o="rounded-orthogonal",edgeRadius:s,customEdgeTypes:a,source:c,target:l,sourceProperty:d,targetProperty:u,sourceY:h,targetY:p,sourcePort:y,targetPort:m,propertyMode:g=!1,dir:b,turn:v,labelAtTarget:x,labelFraction:w,color:C,connectorColor:j,labelBg:_,labelLayer:k,label:E,dashed:O,animated:T,inverted:P,loopIndex:I=0,onSelect:R}){const $=n==null?void 0:n.icon,N=g?Xn:Mb,{lines:M,iconWidth:J,contentWidth:ie,contentHeight:ae}=S.useMemo(()=>Ob(E,$,N),[E,$,N]),te=S.useMemo(()=>{const Se={srcDist:Gn,tgtDist:Gn,arrowGap:$b,arrowSize:Md,headShape:g&&(P?h!==void 0||y:p!==void 0||m)?"square":"triangle",radius:s??(x?40:Kw),arrowAt:P?"source":"target",labelTargetLength:x?ie+2*xr:void 0,labelFraction:x?w:void 0},ye=h!==void 0||p!==void 0||!!y||!!m,pe=Lu(c,l,b,h,p,0),B=h===void 0&&p===void 0&&(b==="downward"||b==="upward"),G=y??{...pe.sourcePoint,side:B?b==="upward"?"top":"bottom":b==="leftward"?"left":"right"},se=m??{...pe.targetPoint,side:B?b==="upward"?"bottom":"top":b==="leftward"?"right":"left"},H=c.x===l.x&&c.y===l.y,ue=y||m?$w(G,se,{...Se,srcDist:18,tgtDist:18},o):ye?$u(c,l,b,h,p,v,{...Se,srcDist:18,tgtDist:18,radius:s??Math.min(Se.radius,40)}):H?Fw(c,I,{...Se,srcDist:0,tgtDist:0}):qu(c,l,b,v,Se);if(!ue)return null;const xe=Lu(c,l,b,h,p,ye?18:Gn);y&&(xe.sourcePoint=$r(y,18)),m&&(xe.targetPoint=$r(m,18));const Oe=Object.prototype.hasOwnProperty.call(a??{},o)?a==null?void 0:a[o]:void 0;if(Oe){const Ne={rightward:"LR",leftward:"RL",downward:"TB",upward:"BT"};return Oe({edge:n??{id:e,source:"",target:""},source:{...c},target:{...l},...xe,direction:Ne[b],sourceY:h,targetY:p,inverted:!!P,defaultGeometry:ue})??ue}return H||y||m?ue:o==="straight"?ye?Pb(xe.sourcePoint,xe.targetPoint,Se):Ab([c,l],c,l,Se):o==="bezier"?Lw(xe.sourcePoint,xe.targetPoint,ye?b==="leftward"?"leftward":"rightward":b,Se):o==="orthogonal"?ye?$u(c,l,b,h,p,v,{...Se,srcDist:18,tgtDist:18,radius:0}):qu(c,l,b,v,{...Se,radius:0}):ue},[c,e,n,o,s,a,l,g,h,p,y,m,b,v,P,I,x,w,ie]);if(!te)return null;const he=(b==="rightward"||b==="leftward")&&!Object.prototype.hasOwnProperty.call(a??{},o)&&!(g&&(h!==void 0||p!==void 0||y||m)),me=he?`translate(${te.label.x} ${te.label.y-ae/2-2*xr})`:`translate(${te.label.x} ${te.label.y}) rotate(${te.label.angle}) translate(${b==="downward"||b==="upward"||x||Object.prototype.hasOwnProperty.call(a??{},o)?0:Tb} 0)`,q=i!=null&&i.startsWith("Unverified:")?"#b45309":"#dc2626",F=i?q:C,U=i?f.jsxs("g",{className:"flow-sdk-edge-validation",role:"img","aria-label":i,transform:`translate(${te.label.x} ${te.label.y-M.length*N/2-55})`,children:[f.jsx("title",{children:i}),f.jsx(Ht,{name:"PiWarningCircleFill",svg:!0,size:48,x:-24,y:-24,color:q})]}):null,D=T&&(n==null?void 0:n.edgeAnimationVariant)==="traveling",de=!D&&(O||T)?Jw:void 0,Q=T&&!D?`flow-sdk-edge-anim${P?" flow-sdk-edge-anim-rev":""}`:void 0;let oe=null;const ce=r?{"--flow-edge-reveal-duration":`${r.durationMs??600}ms`,"--flow-edge-reveal-state":r.paused?"paused":"running"}:void 0;if(M.length||$){const Se=ie,ye=ae;oe=f.jsxs("g",{className:`flow-sdk-edge-label${r?" flow-sdk-edge-reveal-end":""}`,style:ce,"data-label-transform":me,"data-label-horizontal":he||void 0,"data-edge-id":e,"data-source-property":d,"data-target-property":u,transform:me,children:[f.jsx("rect",{x:-Se/2-xr,y:-ye/2-xr,width:Se+2*xr,height:ye+2*xr,fill:C==="transparent"?"transparent":_}),f.jsx("text",{fill:C,fontSize:N,style:{fontSize:N,fontFamily:cr},fontFamily:cr,textAnchor:"middle",dominantBaseline:"central",children:M.map((pe,B)=>f.jsx("tspan",{x:J/2,y:(B-(M.length-1)/2)*N,children:pe},B))}),$&&f.jsxs("g",{className:"flow-sdk-edge-icon",opacity:C==="transparent"?0:1,children:[f.jsx("title",{children:E?`Edge icon: ${E}`:"Edge icon"}),f.jsx("rect",{x:-Se/2,y:-24,width:48,height:48,fill:"transparent"}),f.jsx(Ht,{name:$,svg:!0,size:48,x:-Se/2,y:-24,color:C})]})]})}const we=f.jsxs(f.Fragment,{children:[f.jsx("path",{d:te.d,fill:"none",stroke:F,strokeWidth:Cn,strokeOpacity:D?.35:void 0,strokeDasharray:de,className:Q}),D&&f.jsx(kw,{path:te.d,color:F,width:Cn*1.6,reversed:P})]});return f.jsxs("g",{className:"flow-sdk-edge",style:ce,"data-edge-id":e,"data-source-property":d,"data-target-property":u,"data-validation":i?i.startsWith("Unverified:")?"unverified":"invalid":void 0,"aria-label":i,onPointerDown:Zw,onClick:Se=>{Se.stopPropagation(),R==null||R(e)},children:[r?f.jsx(Ew,{path:te.d,width:Cn*4,reversed:P,onComplete:()=>t==null?void 0:t(e),children:we}):we,te.arrow&&f.jsx("path",{className:r?"flow-sdk-edge-reveal-end":void 0,d:te.arrow,fill:i?q:j??F}),k&&oe?Br.createPortal(oe,k):oe,k&&U?Br.createPortal(U,k):U,f.jsx("path",{className:"flow-sdk-edge-hit",d:te.d,fill:"none",stroke:"transparent"})]})}const Bu=S.memo(Xw);var Vn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yw(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Td(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 qo,Du;function Qw(){if(Du)return qo;Du=1;function e(){this.__data__=[],this.size=0}return qo=e,qo}var Lo,Vu;function Zr(){if(Vu)return Lo;Vu=1;function e(r,t){return r===t||r!==r&&t!==t}return Lo=e,Lo}var Fo,Wu;function co(){if(Wu)return Fo;Wu=1;var e=Zr();function r(t,n){for(var i=t.length;i--;)if(e(t[i][0],n))return i;return-1}return Fo=r,Fo}var zo,Gu;function e1(){if(Gu)return zo;Gu=1;var e=co(),r=Array.prototype,t=r.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():t.call(o,s,1),--this.size,!0}return zo=n,zo}var Bo,Uu;function t1(){if(Uu)return Bo;Uu=1;var e=co();function r(t){var n=this.__data__,i=e(n,t);return i<0?void 0:n[i][1]}return Bo=r,Bo}var Do,Hu;function r1(){if(Hu)return Do;Hu=1;var e=co();function r(t){return e(this.__data__,t)>-1}return Do=r,Do}var Vo,Ku;function n1(){if(Ku)return Vo;Ku=1;var e=co();function r(t,n){var i=this.__data__,o=e(i,t);return o<0?(++this.size,i.push([t,n])):i[o][1]=n,this}return Vo=r,Vo}var Wo,Ju;function lo(){if(Ju)return Wo;Ju=1;var e=Qw(),r=e1(),t=t1(),n=r1(),i=n1();function o(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return o.prototype.clear=e,o.prototype.delete=r,o.prototype.get=t,o.prototype.has=n,o.prototype.set=i,Wo=o,Wo}var Go,Zu;function o1(){if(Zu)return Go;Zu=1;var e=lo();function r(){this.__data__=new e,this.size=0}return Go=r,Go}var Uo,Xu;function i1(){if(Xu)return Uo;Xu=1;function e(r){var t=this.__data__,n=t.delete(r);return this.size=t.size,n}return Uo=e,Uo}var Ho,Yu;function a1(){if(Yu)return Ho;Yu=1;function e(r){return this.__data__.get(r)}return Ho=e,Ho}var Ko,Qu;function s1(){if(Qu)return Ko;Qu=1;function e(r){return this.__data__.has(r)}return Ko=e,Ko}var Jo,ef;function qb(){if(ef)return Jo;ef=1;var e=typeof Vn=="object"&&Vn&&Vn.Object===Object&&Vn;return Jo=e,Jo}var Zo,tf;function Dt(){if(tf)return Zo;tf=1;var e=qb(),r=typeof self=="object"&&self&&self.Object===Object&&self,t=e||r||Function("return this")();return Zo=t,Zo}var Xo,rf;function Xr(){if(rf)return Xo;rf=1;var e=Dt(),r=e.Symbol;return Xo=r,Xo}var Yo,nf;function c1(){if(nf)return Yo;nf=1;var e=Xr(),r=Object.prototype,t=r.hasOwnProperty,n=r.toString,i=e?e.toStringTag:void 0;function o(s){var a=t.call(s,i),c=s[i];try{s[i]=void 0;var l=!0}catch{}var d=n.call(s);return l&&(a?s[i]=c:delete s[i]),d}return Yo=o,Yo}var Qo,of;function l1(){if(of)return Qo;of=1;var e=Object.prototype,r=e.toString;function t(n){return r.call(n)}return Qo=t,Qo}var ei,af;function Rr(){if(af)return ei;af=1;var e=Xr(),r=c1(),t=l1(),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)?r(a):t(a)}return ei=s,ei}var ti,sf;function $t(){if(sf)return ti;sf=1;function e(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}return ti=e,ti}var ri,cf;function In(){if(cf)return ri;cf=1;var e=Rr(),r=$t(),t="[object AsyncFunction]",n="[object Function]",i="[object GeneratorFunction]",o="[object Proxy]";function s(a){if(!r(a))return!1;var c=e(a);return c==n||c==i||c==t||c==o}return ri=s,ri}var ni,lf;function d1(){if(lf)return ni;lf=1;var e=Dt(),r=e["__core-js_shared__"];return ni=r,ni}var oi,df;function u1(){if(df)return oi;df=1;var e=d1(),r=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function t(n){return!!r&&r in n}return oi=t,oi}var ii,uf;function Lb(){if(uf)return ii;uf=1;var e=Function.prototype,r=e.toString;function t(n){if(n!=null){try{return r.call(n)}catch{}try{return n+""}catch{}}return""}return ii=t,ii}var ai,ff;function f1(){if(ff)return ai;ff=1;var e=In(),r=u1(),t=$t(),n=Lb(),i=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,s=Function.prototype,a=Object.prototype,c=s.toString,l=a.hasOwnProperty,d=RegExp("^"+c.call(l).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function u(h){if(!t(h)||r(h))return!1;var p=e(h)?d:o;return p.test(n(h))}return ai=u,ai}var si,hf;function h1(){if(hf)return si;hf=1;function e(r,t){return r==null?void 0:r[t]}return si=e,si}var ci,pf;function kr(){if(pf)return ci;pf=1;var e=f1(),r=h1();function t(n,i){var o=r(n,i);return e(o)?o:void 0}return ci=t,ci}var li,gf;function Od(){if(gf)return li;gf=1;var e=kr(),r=Dt(),t=e(r,"Map");return li=t,li}var di,yf;function uo(){if(yf)return di;yf=1;var e=kr(),r=e(Object,"create");return di=r,di}var ui,mf;function p1(){if(mf)return ui;mf=1;var e=uo();function r(){this.__data__=e?e(null):{},this.size=0}return ui=r,ui}var fi,bf;function g1(){if(bf)return fi;bf=1;function e(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}return fi=e,fi}var hi,vf;function y1(){if(vf)return hi;vf=1;var e=uo(),r="__lodash_hash_undefined__",t=Object.prototype,n=t.hasOwnProperty;function i(o){var s=this.__data__;if(e){var a=s[o];return a===r?void 0:a}return n.call(s,o)?s[o]:void 0}return hi=i,hi}var pi,xf;function m1(){if(xf)return pi;xf=1;var e=uo(),r=Object.prototype,t=r.hasOwnProperty;function n(i){var o=this.__data__;return e?o[i]!==void 0:t.call(o,i)}return pi=n,pi}var gi,wf;function b1(){if(wf)return gi;wf=1;var e=uo(),r="__lodash_hash_undefined__";function t(n,i){var o=this.__data__;return this.size+=this.has(n)?0:1,o[n]=e&&i===void 0?r:i,this}return gi=t,gi}var yi,Cf;function v1(){if(Cf)return yi;Cf=1;var e=p1(),r=g1(),t=y1(),n=m1(),i=b1();function o(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return o.prototype.clear=e,o.prototype.delete=r,o.prototype.get=t,o.prototype.has=n,o.prototype.set=i,yi=o,yi}var mi,Sf;function x1(){if(Sf)return mi;Sf=1;var e=v1(),r=lo(),t=Od();function n(){this.size=0,this.__data__={hash:new e,map:new(t||r),string:new e}}return mi=n,mi}var bi,jf;function w1(){if(jf)return bi;jf=1;function e(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}return bi=e,bi}var vi,_f;function fo(){if(_f)return vi;_f=1;var e=w1();function r(t,n){var i=t.__data__;return e(n)?i[typeof n=="string"?"string":"hash"]:i.map}return vi=r,vi}var xi,Ef;function C1(){if(Ef)return xi;Ef=1;var e=fo();function r(t){var n=e(this,t).delete(t);return this.size-=n?1:0,n}return xi=r,xi}var wi,Rf;function S1(){if(Rf)return wi;Rf=1;var e=fo();function r(t){return e(this,t).get(t)}return wi=r,wi}var Ci,kf;function j1(){if(kf)return Ci;kf=1;var e=fo();function r(t){return e(this,t).has(t)}return Ci=r,Ci}var Si,Af;function _1(){if(Af)return Si;Af=1;var e=fo();function r(t,n){var i=e(this,t),o=i.size;return i.set(t,n),this.size+=i.size==o?0:1,this}return Si=r,Si}var ji,Pf;function Nd(){if(Pf)return ji;Pf=1;var e=x1(),r=C1(),t=S1(),n=j1(),i=_1();function o(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return o.prototype.clear=e,o.prototype.delete=r,o.prototype.get=t,o.prototype.has=n,o.prototype.set=i,ji=o,ji}var _i,If;function E1(){if(If)return _i;If=1;var e=lo(),r=Od(),t=Nd(),n=200;function i(o,s){var a=this.__data__;if(a instanceof e){var c=a.__data__;if(!r||c.length<n-1)return c.push([o,s]),this.size=++a.size,this;a=this.__data__=new t(c)}return a.set(o,s),this.size=a.size,this}return _i=i,_i}var Ei,Mf;function ho(){if(Mf)return Ei;Mf=1;var e=lo(),r=o1(),t=i1(),n=a1(),i=s1(),o=E1();function s(a){var c=this.__data__=new e(a);this.size=c.size}return s.prototype.clear=r,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=i,s.prototype.set=o,Ei=s,Ei}var Ri,Tf;function $d(){if(Tf)return Ri;Tf=1;function e(r,t){for(var n=-1,i=r==null?0:r.length;++n<i&&t(r[n],n,r)!==!1;);return r}return Ri=e,Ri}var ki,Of;function Fb(){if(Of)return ki;Of=1;var e=kr(),r=(function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch{}})();return ki=r,ki}var Ai,Nf;function po(){if(Nf)return Ai;Nf=1;var e=Fb();function r(t,n,i){n=="__proto__"&&e?e(t,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[n]=i}return Ai=r,Ai}var Pi,$f;function go(){if($f)return Pi;$f=1;var e=po(),r=Zr(),t=Object.prototype,n=t.hasOwnProperty;function i(o,s,a){var c=o[s];(!(n.call(o,s)&&r(c,a))||a===void 0&&!(s in o))&&e(o,s,a)}return Pi=i,Pi}var Ii,qf;function Mn(){if(qf)return Ii;qf=1;var e=go(),r=po();function t(n,i,o,s){var a=!o;o||(o={});for(var c=-1,l=i.length;++c<l;){var d=i[c],u=s?s(o[d],n[d],d,o,n):void 0;u===void 0&&(u=n[d]),a?r(o,d,u):e(o,d,u)}return o}return Ii=t,Ii}var Mi,Lf;function R1(){if(Lf)return Mi;Lf=1;function e(r,t){for(var n=-1,i=Array(r);++n<r;)i[n]=t(n);return i}return Mi=e,Mi}var Ti,Ff;function Kt(){if(Ff)return Ti;Ff=1;function e(r){return r!=null&&typeof r=="object"}return Ti=e,Ti}var Oi,zf;function k1(){if(zf)return Oi;zf=1;var e=Rr(),r=Kt(),t="[object Arguments]";function n(i){return r(i)&&e(i)==t}return Oi=n,Oi}var Ni,Bf;function Tn(){if(Bf)return Ni;Bf=1;var e=k1(),r=Kt(),t=Object.prototype,n=t.hasOwnProperty,i=t.propertyIsEnumerable,o=e((function(){return arguments})())?e:function(s){return r(s)&&n.call(s,"callee")&&!i.call(s,"callee")};return Ni=o,Ni}var $i,Df;function pt(){if(Df)return $i;Df=1;var e=Array.isArray;return $i=e,$i}var un={exports:{}},qi,Vf;function A1(){if(Vf)return qi;Vf=1;function e(){return!1}return qi=e,qi}un.exports;var Wf;function Yr(){return Wf||(Wf=1,(function(e,r){var t=Dt(),n=A1(),i=r&&!r.nodeType&&r,o=i&&!0&&e&&!e.nodeType&&e,s=o&&o.exports===i,a=s?t.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||n;e.exports=l})(un,un.exports)),un.exports}var Li,Gf;function yo(){if(Gf)return Li;Gf=1;var e=9007199254740991,r=/^(?:0|[1-9]\d*)$/;function t(n,i){var o=typeof n;return i=i??e,!!i&&(o=="number"||o!="symbol"&&r.test(n))&&n>-1&&n%1==0&&n<i}return Li=t,Li}var Fi,Uf;function qd(){if(Uf)return Fi;Uf=1;var e=9007199254740991;function r(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=e}return Fi=r,Fi}var zi,Hf;function P1(){if(Hf)return zi;Hf=1;var e=Rr(),r=qd(),t=Kt(),n="[object Arguments]",i="[object Array]",o="[object Boolean]",s="[object Date]",a="[object Error]",c="[object Function]",l="[object Map]",d="[object Number]",u="[object Object]",h="[object RegExp]",p="[object Set]",y="[object String]",m="[object WeakMap]",g="[object ArrayBuffer]",b="[object DataView]",v="[object Float32Array]",x="[object Float64Array]",w="[object Int8Array]",C="[object Int16Array]",j="[object Int32Array]",_="[object Uint8Array]",k="[object Uint8ClampedArray]",E="[object Uint16Array]",O="[object Uint32Array]",T={};T[v]=T[x]=T[w]=T[C]=T[j]=T[_]=T[k]=T[E]=T[O]=!0,T[n]=T[i]=T[g]=T[o]=T[b]=T[s]=T[a]=T[c]=T[l]=T[d]=T[u]=T[h]=T[p]=T[y]=T[m]=!1;function P(I){return t(I)&&r(I.length)&&!!T[e(I)]}return zi=P,zi}var Bi,Kf;function mo(){if(Kf)return Bi;Kf=1;function e(r){return function(t){return r(t)}}return Bi=e,Bi}var fn={exports:{}};fn.exports;var Jf;function Ld(){return Jf||(Jf=1,(function(e,r){var t=qb(),n=r&&!r.nodeType&&r,i=n&&!0&&e&&!e.nodeType&&e,o=i&&i.exports===n,s=o&&t.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})(fn,fn.exports)),fn.exports}var Di,Zf;function On(){if(Zf)return Di;Zf=1;var e=P1(),r=mo(),t=Ld(),n=t&&t.isTypedArray,i=n?r(n):e;return Di=i,Di}var Vi,Xf;function zb(){if(Xf)return Vi;Xf=1;var e=R1(),r=Tn(),t=pt(),n=Yr(),i=yo(),o=On(),s=Object.prototype,a=s.hasOwnProperty;function c(l,d){var u=t(l),h=!u&&r(l),p=!u&&!h&&n(l),y=!u&&!h&&!p&&o(l),m=u||h||p||y,g=m?e(l.length,String):[],b=g.length;for(var v in l)(d||a.call(l,v))&&!(m&&(v=="length"||p&&(v=="offset"||v=="parent")||y&&(v=="buffer"||v=="byteLength"||v=="byteOffset")||i(v,b)))&&g.push(v);return g}return Vi=c,Vi}var Wi,Yf;function bo(){if(Yf)return Wi;Yf=1;var e=Object.prototype;function r(t){var n=t&&t.constructor,i=typeof n=="function"&&n.prototype||e;return t===i}return Wi=r,Wi}var Gi,Qf;function Bb(){if(Qf)return Gi;Qf=1;function e(r,t){return function(n){return r(t(n))}}return Gi=e,Gi}var Ui,eh;function I1(){if(eh)return Ui;eh=1;var e=Bb(),r=e(Object.keys,Object);return Ui=r,Ui}var Hi,th;function Fd(){if(th)return Hi;th=1;var e=bo(),r=I1(),t=Object.prototype,n=t.hasOwnProperty;function i(o){if(!e(o))return r(o);var s=[];for(var a in Object(o))n.call(o,a)&&a!="constructor"&&s.push(a);return s}return Hi=i,Hi}var Ki,rh;function Qt(){if(rh)return Ki;rh=1;var e=In(),r=qd();function t(n){return n!=null&&r(n.length)&&!e(n)}return Ki=t,Ki}var Ji,nh;function pr(){if(nh)return Ji;nh=1;var e=zb(),r=Fd(),t=Qt();function n(i){return t(i)?e(i):r(i)}return Ji=n,Ji}var Zi,oh;function M1(){if(oh)return Zi;oh=1;var e=Mn(),r=pr();function t(n,i){return n&&e(i,r(i),n)}return Zi=t,Zi}var Xi,ih;function T1(){if(ih)return Xi;ih=1;function e(r){var t=[];if(r!=null)for(var n in Object(r))t.push(n);return t}return Xi=e,Xi}var Yi,ah;function O1(){if(ah)return Yi;ah=1;var e=$t(),r=bo(),t=T1(),n=Object.prototype,i=n.hasOwnProperty;function o(s){if(!e(s))return t(s);var a=r(s),c=[];for(var l in s)l=="constructor"&&(a||!i.call(s,l))||c.push(l);return c}return Yi=o,Yi}var Qi,sh;function Ar(){if(sh)return Qi;sh=1;var e=zb(),r=O1(),t=Qt();function n(i){return t(i)?e(i,!0):r(i)}return Qi=n,Qi}var ea,ch;function N1(){if(ch)return ea;ch=1;var e=Mn(),r=Ar();function t(n,i){return n&&e(i,r(i),n)}return ea=t,ea}var hn={exports:{}};hn.exports;var lh;function Db(){return lh||(lh=1,(function(e,r){var t=Dt(),n=r&&!r.nodeType&&r,i=n&&!0&&e&&!e.nodeType&&e,o=i&&i.exports===n,s=o?t.Buffer:void 0,a=s?s.allocUnsafe:void 0;function c(l,d){if(d)return l.slice();var u=l.length,h=a?a(u):new l.constructor(u);return l.copy(h),h}e.exports=c})(hn,hn.exports)),hn.exports}var ta,dh;function Vb(){if(dh)return ta;dh=1;function e(r,t){var n=-1,i=r.length;for(t||(t=Array(i));++n<i;)t[n]=r[n];return t}return ta=e,ta}var ra,uh;function Wb(){if(uh)return ra;uh=1;function e(r,t){for(var n=-1,i=r==null?0:r.length,o=0,s=[];++n<i;){var a=r[n];t(a,n,r)&&(s[o++]=a)}return s}return ra=e,ra}var na,fh;function Gb(){if(fh)return na;fh=1;function e(){return[]}return na=e,na}var oa,hh;function zd(){if(hh)return oa;hh=1;var e=Wb(),r=Gb(),t=Object.prototype,n=t.propertyIsEnumerable,i=Object.getOwnPropertySymbols,o=i?function(s){return s==null?[]:(s=Object(s),e(i(s),function(a){return n.call(s,a)}))}:r;return oa=o,oa}var ia,ph;function $1(){if(ph)return ia;ph=1;var e=Mn(),r=zd();function t(n,i){return e(n,r(n),i)}return ia=t,ia}var aa,gh;function Bd(){if(gh)return aa;gh=1;function e(r,t){for(var n=-1,i=t.length,o=r.length;++n<i;)r[o+n]=t[n];return r}return aa=e,aa}var sa,yh;function vo(){if(yh)return sa;yh=1;var e=Bb(),r=e(Object.getPrototypeOf,Object);return sa=r,sa}var ca,mh;function Ub(){if(mh)return ca;mh=1;var e=Bd(),r=vo(),t=zd(),n=Gb(),i=Object.getOwnPropertySymbols,o=i?function(s){for(var a=[];s;)e(a,t(s)),s=r(s);return a}:n;return ca=o,ca}var la,bh;function q1(){if(bh)return la;bh=1;var e=Mn(),r=Ub();function t(n,i){return e(n,r(n),i)}return la=t,la}var da,vh;function Hb(){if(vh)return da;vh=1;var e=Bd(),r=pt();function t(n,i,o){var s=i(n);return r(n)?s:e(s,o(n))}return da=t,da}var ua,xh;function Kb(){if(xh)return ua;xh=1;var e=Hb(),r=zd(),t=pr();function n(i){return e(i,t,r)}return ua=n,ua}var fa,wh;function L1(){if(wh)return fa;wh=1;var e=Hb(),r=Ub(),t=Ar();function n(i){return e(i,t,r)}return fa=n,fa}var ha,Ch;function F1(){if(Ch)return ha;Ch=1;var e=kr(),r=Dt(),t=e(r,"DataView");return ha=t,ha}var pa,Sh;function z1(){if(Sh)return pa;Sh=1;var e=kr(),r=Dt(),t=e(r,"Promise");return pa=t,pa}var ga,jh;function Jb(){if(jh)return ga;jh=1;var e=kr(),r=Dt(),t=e(r,"Set");return ga=t,ga}var ya,_h;function B1(){if(_h)return ya;_h=1;var e=kr(),r=Dt(),t=e(r,"WeakMap");return ya=t,ya}var ma,Eh;function Qr(){if(Eh)return ma;Eh=1;var e=F1(),r=Od(),t=z1(),n=Jb(),i=B1(),o=Rr(),s=Lb(),a="[object Map]",c="[object Object]",l="[object Promise]",d="[object Set]",u="[object WeakMap]",h="[object DataView]",p=s(e),y=s(r),m=s(t),g=s(n),b=s(i),v=o;return(e&&v(new e(new ArrayBuffer(1)))!=h||r&&v(new r)!=a||t&&v(t.resolve())!=l||n&&v(new n)!=d||i&&v(new i)!=u)&&(v=function(x){var w=o(x),C=w==c?x.constructor:void 0,j=C?s(C):"";if(j)switch(j){case p:return h;case y:return a;case m:return l;case g:return d;case b:return u}return w}),ma=v,ma}var ba,Rh;function D1(){if(Rh)return ba;Rh=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n){var i=n.length,o=new n.constructor(i);return i&&typeof n[0]=="string"&&r.call(n,"index")&&(o.index=n.index,o.input=n.input),o}return ba=t,ba}var va,kh;function Zb(){if(kh)return va;kh=1;var e=Dt(),r=e.Uint8Array;return va=r,va}var xa,Ah;function Dd(){if(Ah)return xa;Ah=1;var e=Zb();function r(t){var n=new t.constructor(t.byteLength);return new e(n).set(new e(t)),n}return xa=r,xa}var wa,Ph;function V1(){if(Ph)return wa;Ph=1;var e=Dd();function r(t,n){var i=n?e(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)}return wa=r,wa}var Ca,Ih;function W1(){if(Ih)return Ca;Ih=1;var e=/\w*$/;function r(t){var n=new t.constructor(t.source,e.exec(t));return n.lastIndex=t.lastIndex,n}return Ca=r,Ca}var Sa,Mh;function G1(){if(Mh)return Sa;Mh=1;var e=Xr(),r=e?e.prototype:void 0,t=r?r.valueOf:void 0;function n(i){return t?Object(t.call(i)):{}}return Sa=n,Sa}var ja,Th;function Xb(){if(Th)return ja;Th=1;var e=Dd();function r(t,n){var i=n?e(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}return ja=r,ja}var _a,Oh;function U1(){if(Oh)return _a;Oh=1;var e=Dd(),r=V1(),t=W1(),n=G1(),i=Xb(),o="[object Boolean]",s="[object Date]",a="[object Map]",c="[object Number]",l="[object RegExp]",d="[object Set]",u="[object String]",h="[object Symbol]",p="[object ArrayBuffer]",y="[object DataView]",m="[object Float32Array]",g="[object Float64Array]",b="[object Int8Array]",v="[object Int16Array]",x="[object Int32Array]",w="[object Uint8Array]",C="[object Uint8ClampedArray]",j="[object Uint16Array]",_="[object Uint32Array]";function k(E,O,T){var P=E.constructor;switch(O){case p:return e(E);case o:case s:return new P(+E);case y:return r(E,T);case m:case g:case b:case v:case x:case w:case C:case j:case _:return i(E,T);case a:return new P;case c:case u:return new P(E);case l:return t(E);case d:return new P;case h:return n(E)}}return _a=k,_a}var Ea,Nh;function Yb(){if(Nh)return Ea;Nh=1;var e=$t(),r=Object.create,t=(function(){function n(){}return function(i){if(!e(i))return{};if(r)return r(i);n.prototype=i;var o=new n;return n.prototype=void 0,o}})();return Ea=t,Ea}var Ra,$h;function Qb(){if($h)return Ra;$h=1;var e=Yb(),r=vo(),t=bo();function n(i){return typeof i.constructor=="function"&&!t(i)?e(r(i)):{}}return Ra=n,Ra}var ka,qh;function H1(){if(qh)return ka;qh=1;var e=Qr(),r=Kt(),t="[object Map]";function n(i){return r(i)&&e(i)==t}return ka=n,ka}var Aa,Lh;function K1(){if(Lh)return Aa;Lh=1;var e=H1(),r=mo(),t=Ld(),n=t&&t.isMap,i=n?r(n):e;return Aa=i,Aa}var Pa,Fh;function J1(){if(Fh)return Pa;Fh=1;var e=Qr(),r=Kt(),t="[object Set]";function n(i){return r(i)&&e(i)==t}return Pa=n,Pa}var Ia,zh;function Z1(){if(zh)return Ia;zh=1;var e=J1(),r=mo(),t=Ld(),n=t&&t.isSet,i=n?r(n):e;return Ia=i,Ia}var Ma,Bh;function ev(){if(Bh)return Ma;Bh=1;var e=ho(),r=$d(),t=go(),n=M1(),i=N1(),o=Db(),s=Vb(),a=$1(),c=q1(),l=Kb(),d=L1(),u=Qr(),h=D1(),p=U1(),y=Qb(),m=pt(),g=Yr(),b=K1(),v=$t(),x=Z1(),w=pr(),C=Ar(),j=1,_=2,k=4,E="[object Arguments]",O="[object Array]",T="[object Boolean]",P="[object Date]",I="[object Error]",R="[object Function]",$="[object GeneratorFunction]",N="[object Map]",M="[object Number]",J="[object Object]",ie="[object RegExp]",ae="[object Set]",te="[object String]",he="[object Symbol]",me="[object WeakMap]",q="[object ArrayBuffer]",F="[object DataView]",U="[object Float32Array]",D="[object Float64Array]",de="[object Int8Array]",Q="[object Int16Array]",oe="[object Int32Array]",ce="[object Uint8Array]",we="[object Uint8ClampedArray]",Se="[object Uint16Array]",ye="[object Uint32Array]",pe={};pe[E]=pe[O]=pe[q]=pe[F]=pe[T]=pe[P]=pe[U]=pe[D]=pe[de]=pe[Q]=pe[oe]=pe[N]=pe[M]=pe[J]=pe[ie]=pe[ae]=pe[te]=pe[he]=pe[ce]=pe[we]=pe[Se]=pe[ye]=!0,pe[I]=pe[R]=pe[me]=!1;function B(G,se,H,ue,xe,Oe){var Ne,Be=se&j,et=se&_,We=se&k;if(H&&(Ne=xe?H(G,ue,xe,Oe):H(G)),Ne!==void 0)return Ne;if(!v(G))return G;var gt=m(G);if(gt){if(Ne=h(G),!Be)return s(G,Ne)}else{var He=u(G),rt=He==R||He==$;if(g(G))return o(G,Be);if(He==J||He==E||rt&&!xe){if(Ne=et||rt?{}:y(G),!Be)return et?c(G,i(Ne,G)):a(G,n(Ne,G))}else{if(!pe[He])return xe?G:{};Ne=p(G,He,Be)}}Oe||(Oe=new e);var ft=Oe.get(G);if(ft)return ft;Oe.set(G,Ne),x(G)?G.forEach(function(it){Ne.add(B(it,se,H,it,G,Oe))}):b(G)&&G.forEach(function(it,at){Ne.set(at,B(it,se,H,at,G,Oe))});var Pe=We?et?d:l:et?C:w,Fe=gt?void 0:Pe(G);return r(Fe||G,function(it,at){Fe&&(at=it,it=G[at]),t(Ne,at,B(it,se,H,at,G,Oe))}),Ne}return Ma=B,Ma}var Ta,Dh;function X1(){if(Dh)return Ta;Dh=1;var e=ev(),r=4;function t(n){return e(n,r)}return Ta=t,Ta}var Oa,Vh;function Vd(){if(Vh)return Oa;Vh=1;function e(r){return function(){return r}}return Oa=e,Oa}var Na,Wh;function Y1(){if(Wh)return Na;Wh=1;function e(r){return function(t,n,i){for(var o=-1,s=Object(t),a=i(t),c=a.length;c--;){var l=a[r?c:++o];if(n(s[l],l,s)===!1)break}return t}}return Na=e,Na}var $a,Gh;function Wd(){if(Gh)return $a;Gh=1;var e=Y1(),r=e();return $a=r,$a}var qa,Uh;function Gd(){if(Uh)return qa;Uh=1;var e=Wd(),r=pr();function t(n,i){return n&&e(n,i,r)}return qa=t,qa}var La,Hh;function Q1(){if(Hh)return La;Hh=1;var e=Qt();function r(t,n){return function(i,o){if(i==null)return i;if(!e(i))return t(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 La=r,La}var Fa,Kh;function xo(){if(Kh)return Fa;Kh=1;var e=Gd(),r=Q1(),t=r(e);return Fa=t,Fa}var za,Jh;function Pr(){if(Jh)return za;Jh=1;function e(r){return r}return za=e,za}var Ba,Zh;function tv(){if(Zh)return Ba;Zh=1;var e=Pr();function r(t){return typeof t=="function"?t:e}return Ba=r,Ba}var Da,Xh;function rv(){if(Xh)return Da;Xh=1;var e=$d(),r=xo(),t=tv(),n=pt();function i(o,s){var a=n(o)?e:r;return a(o,t(s))}return Da=i,Da}var Va,Yh;function nv(){return Yh||(Yh=1,Va=rv()),Va}var Wa,Qh;function eC(){if(Qh)return Wa;Qh=1;var e=xo();function r(t,n){var i=[];return e(t,function(o,s,a){n(o,s,a)&&i.push(o)}),i}return Wa=r,Wa}var Ga,ep;function tC(){if(ep)return Ga;ep=1;var e="__lodash_hash_undefined__";function r(t){return this.__data__.set(t,e),this}return Ga=r,Ga}var Ua,tp;function rC(){if(tp)return Ua;tp=1;function e(r){return this.__data__.has(r)}return Ua=e,Ua}var Ha,rp;function ov(){if(rp)return Ha;rp=1;var e=Nd(),r=tC(),t=rC();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=r,n.prototype.has=t,Ha=n,Ha}var Ka,np;function nC(){if(np)return Ka;np=1;function e(r,t){for(var n=-1,i=r==null?0:r.length;++n<i;)if(t(r[n],n,r))return!0;return!1}return Ka=e,Ka}var Ja,op;function iv(){if(op)return Ja;op=1;function e(r,t){return r.has(t)}return Ja=e,Ja}var Za,ip;function av(){if(ip)return Za;ip=1;var e=ov(),r=nC(),t=iv(),n=1,i=2;function o(s,a,c,l,d,u){var h=c&n,p=s.length,y=a.length;if(p!=y&&!(h&&y>p))return!1;var m=u.get(s),g=u.get(a);if(m&&g)return m==a&&g==s;var b=-1,v=!0,x=c&i?new e:void 0;for(u.set(s,a),u.set(a,s);++b<p;){var w=s[b],C=a[b];if(l)var j=h?l(C,w,b,a,s,u):l(w,C,b,s,a,u);if(j!==void 0){if(j)continue;v=!1;break}if(x){if(!r(a,function(_,k){if(!t(x,k)&&(w===_||d(w,_,c,l,u)))return x.push(k)})){v=!1;break}}else if(!(w===C||d(w,C,c,l,u))){v=!1;break}}return u.delete(s),u.delete(a),v}return Za=o,Za}var Xa,ap;function oC(){if(ap)return Xa;ap=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(i,o){n[++t]=[o,i]}),n}return Xa=e,Xa}var Ya,sp;function Ud(){if(sp)return Ya;sp=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(i){n[++t]=i}),n}return Ya=e,Ya}var Qa,cp;function iC(){if(cp)return Qa;cp=1;var e=Xr(),r=Zb(),t=Zr(),n=av(),i=oC(),o=Ud(),s=1,a=2,c="[object Boolean]",l="[object Date]",d="[object Error]",u="[object Map]",h="[object Number]",p="[object RegExp]",y="[object Set]",m="[object String]",g="[object Symbol]",b="[object ArrayBuffer]",v="[object DataView]",x=e?e.prototype:void 0,w=x?x.valueOf:void 0;function C(j,_,k,E,O,T,P){switch(k){case v:if(j.byteLength!=_.byteLength||j.byteOffset!=_.byteOffset)return!1;j=j.buffer,_=_.buffer;case b:return!(j.byteLength!=_.byteLength||!T(new r(j),new r(_)));case c:case l:case h:return t(+j,+_);case d:return j.name==_.name&&j.message==_.message;case p:case m:return j==_+"";case u:var I=i;case y:var R=E&s;if(I||(I=o),j.size!=_.size&&!R)return!1;var $=P.get(j);if($)return $==_;E|=a,P.set(j,_);var N=n(I(j),I(_),E,O,T,P);return P.delete(j),N;case g:if(w)return w.call(j)==w.call(_)}return!1}return Qa=C,Qa}var es,lp;function aC(){if(lp)return es;lp=1;var e=Kb(),r=1,t=Object.prototype,n=t.hasOwnProperty;function i(o,s,a,c,l,d){var u=a&r,h=e(o),p=h.length,y=e(s),m=y.length;if(p!=m&&!u)return!1;for(var g=p;g--;){var b=h[g];if(!(u?b in s:n.call(s,b)))return!1}var v=d.get(o),x=d.get(s);if(v&&x)return v==s&&x==o;var w=!0;d.set(o,s),d.set(s,o);for(var C=u;++g<p;){b=h[g];var j=o[b],_=s[b];if(c)var k=u?c(_,j,b,s,o,d):c(j,_,b,o,s,d);if(!(k===void 0?j===_||l(j,_,a,c,d):k)){w=!1;break}C||(C=b=="constructor")}if(w&&!C){var E=o.constructor,O=s.constructor;E!=O&&"constructor"in o&&"constructor"in s&&!(typeof E=="function"&&E instanceof E&&typeof O=="function"&&O instanceof O)&&(w=!1)}return d.delete(o),d.delete(s),w}return es=i,es}var ts,dp;function sC(){if(dp)return ts;dp=1;var e=ho(),r=av(),t=iC(),n=aC(),i=Qr(),o=pt(),s=Yr(),a=On(),c=1,l="[object Arguments]",d="[object Array]",u="[object Object]",h=Object.prototype,p=h.hasOwnProperty;function y(m,g,b,v,x,w){var C=o(m),j=o(g),_=C?d:i(m),k=j?d:i(g);_=_==l?u:_,k=k==l?u:k;var E=_==u,O=k==u,T=_==k;if(T&&s(m)){if(!s(g))return!1;C=!0,E=!1}if(T&&!E)return w||(w=new e),C||a(m)?r(m,g,b,v,x,w):t(m,g,_,b,v,x,w);if(!(b&c)){var P=E&&p.call(m,"__wrapped__"),I=O&&p.call(g,"__wrapped__");if(P||I){var R=P?m.value():m,$=I?g.value():g;return w||(w=new e),x(R,$,b,v,w)}}return T?(w||(w=new e),n(m,g,b,v,x,w)):!1}return ts=y,ts}var rs,up;function sv(){if(up)return rs;up=1;var e=sC(),r=Kt();function t(n,i,o,s,a){return n===i?!0:n==null||i==null||!r(n)&&!r(i)?n!==n&&i!==i:e(n,i,o,s,t,a)}return rs=t,rs}var ns,fp;function cC(){if(fp)return ns;fp=1;var e=ho(),r=sv(),t=1,n=2;function i(o,s,a,c){var l=a.length,d=l,u=!c;if(o==null)return!d;for(o=Object(o);l--;){var h=a[l];if(u&&h[2]?h[1]!==o[h[0]]:!(h[0]in o))return!1}for(;++l<d;){h=a[l];var p=h[0],y=o[p],m=h[1];if(u&&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?r(m,y,t|n,c,g):b))return!1}}return!0}return ns=i,ns}var os,hp;function cv(){if(hp)return os;hp=1;var e=$t();function r(t){return t===t&&!e(t)}return os=r,os}var is,pp;function lC(){if(pp)return is;pp=1;var e=cv(),r=pr();function t(n){for(var i=r(n),o=i.length;o--;){var s=i[o],a=n[s];i[o]=[s,a,e(a)]}return i}return is=t,is}var as,gp;function lv(){if(gp)return as;gp=1;function e(r,t){return function(n){return n==null?!1:n[r]===t&&(t!==void 0||r in Object(n))}}return as=e,as}var ss,yp;function dC(){if(yp)return ss;yp=1;var e=cC(),r=lC(),t=lv();function n(i){var o=r(i);return o.length==1&&o[0][2]?t(o[0][0],o[0][1]):function(s){return s===i||e(s,i,o)}}return ss=n,ss}var cs,mp;function en(){if(mp)return cs;mp=1;var e=Rr(),r=Kt(),t="[object Symbol]";function n(i){return typeof i=="symbol"||r(i)&&e(i)==t}return cs=n,cs}var ls,bp;function Hd(){if(bp)return ls;bp=1;var e=pt(),r=en(),t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\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||r(o)?!0:n.test(o)||!t.test(o)||s!=null&&o in Object(s)}return ls=i,ls}var ds,vp;function uC(){if(vp)return ds;vp=1;var e=Nd(),r="Expected a function";function t(n,i){if(typeof n!="function"||i!=null&&typeof i!="function")throw new TypeError(r);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 l=n.apply(this,s);return o.cache=c.set(a,l)||c,l};return o.cache=new(t.Cache||e),o}return t.Cache=e,ds=t,ds}var us,xp;function fC(){if(xp)return us;xp=1;var e=uC(),r=500;function t(n){var i=e(n,function(s){return o.size===r&&o.clear(),s}),o=i.cache;return i}return us=t,us}var fs,wp;function hC(){if(wp)return fs;wp=1;var e=fC(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,n=e(function(i){var o=[];return i.charCodeAt(0)===46&&o.push(""),i.replace(r,function(s,a,c,l){o.push(c?l.replace(t,"$1"):a||s)}),o});return fs=n,fs}var hs,Cp;function wo(){if(Cp)return hs;Cp=1;function e(r,t){for(var n=-1,i=r==null?0:r.length,o=Array(i);++n<i;)o[n]=t(r[n],n,r);return o}return hs=e,hs}var ps,Sp;function pC(){if(Sp)return ps;Sp=1;var e=Xr(),r=wo(),t=pt(),n=en(),i=e?e.prototype:void 0,o=i?i.toString:void 0;function s(a){if(typeof a=="string")return a;if(t(a))return r(a,s)+"";if(n(a))return o?o.call(a):"";var c=a+"";return c=="0"&&1/a==-1/0?"-0":c}return ps=s,ps}var gs,jp;function dv(){if(jp)return gs;jp=1;var e=pC();function r(t){return t==null?"":e(t)}return gs=r,gs}var ys,_p;function Co(){if(_p)return ys;_p=1;var e=pt(),r=Hd(),t=hC(),n=dv();function i(o,s){return e(o)?o:r(o,s)?[o]:t(n(o))}return ys=i,ys}var ms,Ep;function Nn(){if(Ep)return ms;Ep=1;var e=en();function r(t){if(typeof t=="string"||e(t))return t;var n=t+"";return n=="0"&&1/t==-1/0?"-0":n}return ms=r,ms}var bs,Rp;function So(){if(Rp)return bs;Rp=1;var e=Co(),r=Nn();function t(n,i){i=e(i,n);for(var o=0,s=i.length;n!=null&&o<s;)n=n[r(i[o++])];return o&&o==s?n:void 0}return bs=t,bs}var vs,kp;function gC(){if(kp)return vs;kp=1;var e=So();function r(t,n,i){var o=t==null?void 0:e(t,n);return o===void 0?i:o}return vs=r,vs}var xs,Ap;function yC(){if(Ap)return xs;Ap=1;function e(r,t){return r!=null&&t in Object(r)}return xs=e,xs}var ws,Pp;function uv(){if(Pp)return ws;Pp=1;var e=Co(),r=Tn(),t=pt(),n=yo(),i=qd(),o=Nn();function s(a,c,l){c=e(c,a);for(var d=-1,u=c.length,h=!1;++d<u;){var p=o(c[d]);if(!(h=a!=null&&l(a,p)))break;a=a[p]}return h||++d!=u?h:(u=a==null?0:a.length,!!u&&i(u)&&n(p,u)&&(t(a)||r(a)))}return ws=s,ws}var Cs,Ip;function fv(){if(Ip)return Cs;Ip=1;var e=yC(),r=uv();function t(n,i){return n!=null&&r(n,i,e)}return Cs=t,Cs}var Ss,Mp;function mC(){if(Mp)return Ss;Mp=1;var e=sv(),r=gC(),t=fv(),n=Hd(),i=cv(),o=lv(),s=Nn(),a=1,c=2;function l(d,u){return n(d)&&i(u)?o(s(d),u):function(h){var p=r(h,d);return p===void 0&&p===u?t(h,d):e(u,p,a|c)}}return Ss=l,Ss}var js,Tp;function hv(){if(Tp)return js;Tp=1;function e(r){return function(t){return t==null?void 0:t[r]}}return js=e,js}var _s,Op;function bC(){if(Op)return _s;Op=1;var e=So();function r(t){return function(n){return e(n,t)}}return _s=r,_s}var Es,Np;function vC(){if(Np)return Es;Np=1;var e=hv(),r=bC(),t=Hd(),n=Nn();function i(o){return t(o)?e(n(o)):r(o)}return Es=i,Es}var Rs,$p;function er(){if($p)return Rs;$p=1;var e=dC(),r=mC(),t=Pr(),n=pt(),i=vC();function o(s){return typeof s=="function"?s:s==null?t:typeof s=="object"?n(s)?r(s[0],s[1]):e(s):i(s)}return Rs=o,Rs}var ks,qp;function pv(){if(qp)return ks;qp=1;var e=Wb(),r=eC(),t=er(),n=pt();function i(o,s){var a=n(o)?e:r;return a(o,t(s,3))}return ks=i,ks}var As,Lp;function xC(){if(Lp)return As;Lp=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n,i){return n!=null&&r.call(n,i)}return As=t,As}var Ps,Fp;function gv(){if(Fp)return Ps;Fp=1;var e=xC(),r=uv();function t(n,i){return n!=null&&r(n,i,e)}return Ps=t,Ps}var Is,zp;function wC(){if(zp)return Is;zp=1;var e=Fd(),r=Qr(),t=Tn(),n=pt(),i=Qt(),o=Yr(),s=bo(),a=On(),c="[object Map]",l="[object Set]",d=Object.prototype,u=d.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)||t(p)))return!p.length;var y=r(p);if(y==c||y==l)return!p.size;if(s(p))return!e(p).length;for(var m in p)if(u.call(p,m))return!1;return!0}return Is=h,Is}var Ms,Bp;function yv(){if(Bp)return Ms;Bp=1;function e(r){return r===void 0}return Ms=e,Ms}var Ts,Dp;function mv(){if(Dp)return Ts;Dp=1;var e=xo(),r=Qt();function t(n,i){var o=-1,s=r(n)?Array(n.length):[];return e(n,function(a,c,l){s[++o]=i(a,c,l)}),s}return Ts=t,Ts}var Os,Vp;function bv(){if(Vp)return Os;Vp=1;var e=wo(),r=er(),t=mv(),n=pt();function i(o,s){var a=n(o)?e:t;return a(o,r(s,3))}return Os=i,Os}var Ns,Wp;function CC(){if(Wp)return Ns;Wp=1;function e(r,t,n,i){var o=-1,s=r==null?0:r.length;for(i&&s&&(n=r[++o]);++o<s;)n=t(n,r[o],o,r);return n}return Ns=e,Ns}var $s,Gp;function SC(){if(Gp)return $s;Gp=1;function e(r,t,n,i,o){return o(r,function(s,a,c){n=i?(i=!1,s):t(n,s,a,c)}),n}return $s=e,$s}var qs,Up;function vv(){if(Up)return qs;Up=1;var e=CC(),r=xo(),t=er(),n=SC(),i=pt();function o(s,a,c){var l=i(s)?e:n,d=arguments.length<3;return l(s,t(a,4),c,d,r)}return qs=o,qs}var Ls,Hp;function jC(){if(Hp)return Ls;Hp=1;var e=Rr(),r=pt(),t=Kt(),n="[object String]";function i(o){return typeof o=="string"||!r(o)&&t(o)&&e(o)==n}return Ls=i,Ls}var Fs,Kp;function _C(){if(Kp)return Fs;Kp=1;var e=hv(),r=e("length");return Fs=r,Fs}var zs,Jp;function EC(){if(Jp)return zs;Jp=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",i=r+t+n,o="\\ufe0e\\ufe0f",s="\\u200d",a=RegExp("["+s+e+i+o+"]");function c(l){return a.test(l)}return zs=c,zs}var Bs,Zp;function RC(){if(Zp)return Bs;Zp=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",i=r+t+n,o="\\ufe0e\\ufe0f",s="["+e+"]",a="["+i+"]",c="\\ud83c[\\udffb-\\udfff]",l="(?:"+a+"|"+c+")",d="[^"+e+"]",u="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",y=l+"?",m="["+o+"]?",g="(?:"+p+"(?:"+[d,u,h].join("|")+")"+m+y+")*",b=m+y+g,v="(?:"+[d+a+"?",a,u,h,s].join("|")+")",x=RegExp(c+"(?="+c+")|"+v+b,"g");function w(C){for(var j=x.lastIndex=0;x.test(C);)++j;return j}return Bs=w,Bs}var Ds,Xp;function kC(){if(Xp)return Ds;Xp=1;var e=_C(),r=EC(),t=RC();function n(i){return r(i)?t(i):e(i)}return Ds=n,Ds}var Vs,Yp;function AC(){if(Yp)return Vs;Yp=1;var e=Fd(),r=Qr(),t=Qt(),n=jC(),i=kC(),o="[object Map]",s="[object Set]";function a(c){if(c==null)return 0;if(t(c))return n(c)?i(c):c.length;var l=r(c);return l==o||l==s?c.size:e(c).length}return Vs=a,Vs}var Ws,Qp;function PC(){if(Qp)return Ws;Qp=1;var e=$d(),r=Yb(),t=Gd(),n=er(),i=vo(),o=pt(),s=Yr(),a=In(),c=$t(),l=On();function d(u,h,p){var y=o(u),m=y||s(u)||l(u);if(h=n(h,4),p==null){var g=u&&u.constructor;m?p=y?new g:[]:c(u)?p=a(g)?r(i(u)):{}:p={}}return(m?e:t)(u,function(b,v,x){return h(p,b,v,x)}),p}return Ws=d,Ws}var Gs,eg;function IC(){if(eg)return Gs;eg=1;var e=Xr(),r=Tn(),t=pt(),n=e?e.isConcatSpreadable:void 0;function i(o){return t(o)||r(o)||!!(n&&o&&o[n])}return Gs=i,Gs}var Us,tg;function Kd(){if(tg)return Us;tg=1;var e=Bd(),r=IC();function t(n,i,o,s,a){var c=-1,l=n.length;for(o||(o=r),a||(a=[]);++c<l;){var d=n[c];i>0&&o(d)?i>1?t(d,i-1,o,s,a):e(a,d):s||(a[a.length]=d)}return a}return Us=t,Us}var Hs,rg;function MC(){if(rg)return Hs;rg=1;function e(r,t,n){switch(n.length){case 0:return r.call(t);case 1:return r.call(t,n[0]);case 2:return r.call(t,n[0],n[1]);case 3:return r.call(t,n[0],n[1],n[2])}return r.apply(t,n)}return Hs=e,Hs}var Ks,ng;function xv(){if(ng)return Ks;ng=1;var e=MC(),r=Math.max;function t(n,i,o){return i=r(i===void 0?n.length-1:i,0),function(){for(var s=arguments,a=-1,c=r(s.length-i,0),l=Array(c);++a<c;)l[a]=s[i+a];a=-1;for(var d=Array(i+1);++a<i;)d[a]=s[a];return d[i]=o(l),e(n,this,d)}}return Ks=t,Ks}var Js,og;function TC(){if(og)return Js;og=1;var e=Vd(),r=Fb(),t=Pr(),n=r?function(i,o){return r(i,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:t;return Js=n,Js}var Zs,ig;function OC(){if(ig)return Zs;ig=1;var e=800,r=16,t=Date.now;function n(i){var o=0,s=0;return function(){var a=t(),c=r-(a-s);if(s=a,c>0){if(++o>=e)return arguments[0]}else o=0;return i.apply(void 0,arguments)}}return Zs=n,Zs}var Xs,ag;function wv(){if(ag)return Xs;ag=1;var e=TC(),r=OC(),t=r(e);return Xs=t,Xs}var Ys,sg;function jo(){if(sg)return Ys;sg=1;var e=Pr(),r=xv(),t=wv();function n(i,o){return t(r(i,o,e),i+"")}return Ys=n,Ys}var Qs,cg;function Cv(){if(cg)return Qs;cg=1;function e(r,t,n,i){for(var o=r.length,s=n+(i?1:-1);i?s--:++s<o;)if(t(r[s],s,r))return s;return-1}return Qs=e,Qs}var ec,lg;function NC(){if(lg)return ec;lg=1;function e(r){return r!==r}return ec=e,ec}var tc,dg;function $C(){if(dg)return tc;dg=1;function e(r,t,n){for(var i=n-1,o=r.length;++i<o;)if(r[i]===t)return i;return-1}return tc=e,tc}var rc,ug;function qC(){if(ug)return rc;ug=1;var e=Cv(),r=NC(),t=$C();function n(i,o,s){return o===o?t(i,o,s):e(i,r,s)}return rc=n,rc}var nc,fg;function LC(){if(fg)return nc;fg=1;var e=qC();function r(t,n){var i=t==null?0:t.length;return!!i&&e(t,n,0)>-1}return nc=r,nc}var oc,hg;function FC(){if(hg)return oc;hg=1;function e(r,t,n){for(var i=-1,o=r==null?0:r.length;++i<o;)if(n(t,r[i]))return!0;return!1}return oc=e,oc}var ic,pg;function zC(){if(pg)return ic;pg=1;function e(){}return ic=e,ic}var ac,gg;function BC(){if(gg)return ac;gg=1;var e=Jb(),r=zC(),t=Ud(),n=1/0,i=e&&1/t(new e([,-0]))[1]==n?function(o){return new e(o)}:r;return ac=i,ac}var sc,yg;function DC(){if(yg)return sc;yg=1;var e=ov(),r=LC(),t=FC(),n=iv(),i=BC(),o=Ud(),s=200;function a(c,l,d){var u=-1,h=r,p=c.length,y=!0,m=[],g=m;if(d)y=!1,h=t;else if(p>=s){var b=l?null:i(c);if(b)return o(b);y=!1,h=n,g=new e}else g=l?[]:m;e:for(;++u<p;){var v=c[u],x=l?l(v):v;if(v=d||v!==0?v:0,y&&x===x){for(var w=g.length;w--;)if(g[w]===x)continue e;l&&g.push(x),m.push(v)}else h(g,x,d)||(g!==m&&g.push(x),m.push(v))}return m}return sc=a,sc}var cc,mg;function Sv(){if(mg)return cc;mg=1;var e=Qt(),r=Kt();function t(n){return r(n)&&e(n)}return cc=t,cc}var lc,bg;function VC(){if(bg)return lc;bg=1;var e=Kd(),r=jo(),t=DC(),n=Sv(),i=r(function(o){return t(e(o,1,n,!0))});return lc=i,lc}var dc,vg;function WC(){if(vg)return dc;vg=1;var e=wo();function r(t,n){return e(n,function(i){return t[i]})}return dc=r,dc}var uc,xg;function jv(){if(xg)return uc;xg=1;var e=WC(),r=pr();function t(n){return n==null?[]:e(n,r(n))}return uc=t,uc}var fc,wg;function qt(){if(wg)return fc;wg=1;var e;if(typeof Td=="function")try{e={clone:X1(),constant:Vd(),each:nv(),filter:pv(),has:gv(),isArray:pt(),isEmpty:wC(),isFunction:In(),isUndefined:yv(),keys:pr(),map:bv(),reduce:vv(),size:AC(),transform:PC(),union:VC(),values:jv()}}catch{}return e||(e=window._),fc=e,fc}var hc,Cg;function Jd(){if(Cg)return hc;Cg=1;var e=qt();hc=i;var r="\0",t="\0",n="";function i(d){this._isDirected=e.has(d,"directed")?d.directed:!0,this._isMultigraph=e.has(d,"multigraph")?d.multigraph:!1,this._isCompound=e.has(d,"compound")?d.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[t]={}),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(d){return this._label=d,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return e.keys(this._nodes)},i.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(u){return e.isEmpty(d._in[u])})},i.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(u){return e.isEmpty(d._out[u])})},i.prototype.setNodes=function(d,u){var h=arguments,p=this;return e.each(d,function(y){h.length>1?p.setNode(y,u):p.setNode(y)}),this},i.prototype.setNode=function(d,u){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=u),this):(this._nodes[d]=arguments.length>1?u:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=t,this._children[d]={},this._children[t][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},i.prototype.node=function(d){return this._nodes[d]},i.prototype.hasNode=function(d){return e.has(this._nodes,d)},i.prototype.removeNode=function(d){var u=this;if(e.has(this._nodes,d)){var h=function(p){u.removeEdge(u._edgeObjs[p])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(p){u.setParent(p)}),delete this._children[d]),e.each(e.keys(this._in[d]),h),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),h),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},i.prototype.setParent=function(d,u){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(u))u=t;else{u+="";for(var h=u;!e.isUndefined(h);h=this.parent(h))if(h===d)throw new Error("Setting "+u+" as parent of "+d+" would create a cycle");this.setNode(u)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=u,this._children[u][d]=!0,this},i.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},i.prototype.parent=function(d){if(this._isCompound){var u=this._parent[d];if(u!==t)return u}},i.prototype.children=function(d){if(e.isUndefined(d)&&(d=t),this._isCompound){var u=this._children[d];if(u)return e.keys(u)}else{if(d===t)return this.nodes();if(this.hasNode(d))return[]}},i.prototype.predecessors=function(d){var u=this._preds[d];if(u)return e.keys(u)},i.prototype.successors=function(d){var u=this._sucs[d];if(u)return e.keys(u)},i.prototype.neighbors=function(d){var u=this.predecessors(d);if(u)return e.union(u,this.successors(d))},i.prototype.isLeaf=function(d){var u;return this.isDirected()?u=this.successors(d):u=this.neighbors(d),u.length===0},i.prototype.filterNodes=function(d){var u=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});u.setGraph(this.graph());var h=this;e.each(this._nodes,function(m,g){d(g)&&u.setNode(g,m)}),e.each(this._edgeObjs,function(m){u.hasNode(m.v)&&u.hasNode(m.w)&&u.setEdge(m,h.edge(m))});var p={};function y(m){var g=h.parent(m);return g===void 0||u.hasNode(g)?(p[m]=g,g):g in p?p[g]:y(g)}return this._isCompound&&e.each(u.nodes(),function(m){u.setParent(m,y(m))}),u},i.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return e.values(this._edgeObjs)},i.prototype.setPath=function(d,u){var h=this,p=arguments;return e.reduce(d,function(y,m){return p.length>1?h.setEdge(y,m,u):h.setEdge(y,m),m}),this},i.prototype.setEdge=function(){var d,u,h,p,y=!1,m=arguments[0];typeof m=="object"&&m!==null&&"v"in m?(d=m.v,u=m.w,h=m.name,arguments.length===2&&(p=arguments[1],y=!0)):(d=m,u=arguments[1],h=arguments[3],arguments.length>2&&(p=arguments[2],y=!0)),d=""+d,u=""+u,e.isUndefined(h)||(h=""+h);var g=a(this._isDirected,d,u,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(d),this.setNode(u),this._edgeLabels[g]=y?p:this._defaultEdgeLabelFn(d,u,h);var b=c(this._isDirected,d,u,h);return d=b.v,u=b.w,Object.freeze(b),this._edgeObjs[g]=b,o(this._preds[u],d),o(this._sucs[d],u),this._in[u][g]=b,this._out[d][g]=b,this._edgeCount++,this},i.prototype.edge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h);return this._edgeLabels[p]},i.prototype.hasEdge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h);return e.has(this._edgeLabels,p)},i.prototype.removeEdge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h),y=this._edgeObjs[p];return y&&(d=y.v,u=y.w,delete this._edgeLabels[p],delete this._edgeObjs[p],s(this._preds[u],d),s(this._sucs[d],u),delete this._in[u][p],delete this._out[d][p],this._edgeCount--),this},i.prototype.inEdges=function(d,u){var h=this._in[d];if(h){var p=e.values(h);return u?e.filter(p,function(y){return y.v===u}):p}},i.prototype.outEdges=function(d,u){var h=this._out[d];if(h){var p=e.values(h);return u?e.filter(p,function(y){return y.w===u}):p}},i.prototype.nodeEdges=function(d,u){var h=this.inEdges(d,u);if(h)return h.concat(this.outEdges(d,u))};function o(d,u){d[u]?d[u]++:d[u]=1}function s(d,u){--d[u]||delete d[u]}function a(d,u,h,p){var y=""+u,m=""+h;if(!d&&y>m){var g=y;y=m,m=g}return y+n+m+n+(e.isUndefined(p)?r:p)}function c(d,u,h,p){var y=""+u,m=""+h;if(!d&&y>m){var g=y;y=m,m=g}var b={v:y,w:m};return p&&(b.name=p),b}function l(d,u){return a(d,u.v,u.w,u.name)}return hc}var pc,Sg;function GC(){return Sg||(Sg=1,pc="2.1.8"),pc}var gc,jg;function UC(){return jg||(jg=1,gc={Graph:Jd(),version:GC()}),gc}var yc,_g;function HC(){if(_g)return yc;_g=1;var e=qt(),r=Jd();yc={write:t,read:o};function t(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),l=s.parent(a),d={v:a};return e.isUndefined(c)||(d.value=c),e.isUndefined(l)||(d.parent=l),d})}function i(s){return e.map(s.edges(),function(a){var c=s.edge(a),l={v:a.v,w:a.w};return e.isUndefined(a.name)||(l.name=a.name),e.isUndefined(c)||(l.value=c),l})}function o(s){var a=new r(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 yc}var mc,Eg;function KC(){if(Eg)return mc;Eg=1;var e=qt();mc=r;function r(t){var n={},i=[],o;function s(a){e.has(n,a)||(n[a]=!0,o.push(a),e.each(t.successors(a),s),e.each(t.predecessors(a),s))}return e.each(t.nodes(),function(a){o=[],s(a),o.length&&i.push(o)}),i}return mc}var bc,Rg;function _v(){if(Rg)return bc;Rg=1;var e=qt();bc=r;function r(){this._arr=[],this._keyIndices={}}return r.prototype.size=function(){return this._arr.length},r.prototype.keys=function(){return this._arr.map(function(t){return t.key})},r.prototype.has=function(t){return e.has(this._keyIndices,t)},r.prototype.priority=function(t){var n=this._keyIndices[t];if(n!==void 0)return this._arr[n].priority},r.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},r.prototype.add=function(t,n){var i=this._keyIndices;if(t=String(t),!e.has(i,t)){var o=this._arr,s=o.length;return i[t]=s,o.push({key:t,priority:n}),this._decrease(s),!0}return!1},r.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},r.prototype.decrease=function(t,n){var i=this._keyIndices[t];if(n>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[i].priority+" New: "+n);this._arr[i].priority=n,this._decrease(i)},r.prototype._heapify=function(t){var n=this._arr,i=2*t,o=i+1,s=t;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!==t&&(this._swap(t,s),this._heapify(s)))},r.prototype._decrease=function(t){for(var n=this._arr,i=n[t].priority,o;t!==0&&(o=t>>1,!(n[o].priority<i));)this._swap(t,o),t=o},r.prototype._swap=function(t,n){var i=this._arr,o=this._keyIndices,s=i[t],a=i[n];i[t]=a,i[n]=s,o[a.key]=t,o[s.key]=n},bc}var vc,kg;function Ev(){if(kg)return vc;kg=1;var e=qt(),r=_v();vc=n;var t=e.constant(1);function n(o,s,a,c){return i(o,String(s),a||t,c||function(l){return o.outEdges(l)})}function i(o,s,a,c){var l={},d=new r,u,h,p=function(y){var m=y.v!==u?y.v:y.w,g=l[m],b=a(y),v=h.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+y+" Weight: "+b);v<g.distance&&(g.distance=v,g.predecessor=u,d.decrease(m,v))};for(o.nodes().forEach(function(y){var m=y===s?0:Number.POSITIVE_INFINITY;l[y]={distance:m},d.add(y,m)});d.size()>0&&(u=d.removeMin(),h=l[u],h.distance!==Number.POSITIVE_INFINITY);)c(u).forEach(p);return l}return vc}var xc,Ag;function JC(){if(Ag)return xc;Ag=1;var e=Ev(),r=qt();xc=t;function t(n,i,o){return r.transform(n.nodes(),function(s,a){s[a]=e(n,a,i,o)},{})}return xc}var wc,Pg;function Rv(){if(Pg)return wc;Pg=1;var e=qt();wc=r;function r(t){var n=0,i=[],o={},s=[];function a(c){var l=o[c]={onStack:!0,lowlink:n,index:n++};if(i.push(c),t.successors(c).forEach(function(h){e.has(o,h)?o[h].onStack&&(l.lowlink=Math.min(l.lowlink,o[h].index)):(a(h),l.lowlink=Math.min(l.lowlink,o[h].lowlink))}),l.lowlink===l.index){var d=[],u;do u=i.pop(),o[u].onStack=!1,d.push(u);while(c!==u);s.push(d)}}return t.nodes().forEach(function(c){e.has(o,c)||a(c)}),s}return wc}var Cc,Ig;function ZC(){if(Ig)return Cc;Ig=1;var e=qt(),r=Rv();Cc=t;function t(n){return e.filter(r(n),function(i){return i.length>1||i.length===1&&n.hasEdge(i[0],i[0])})}return Cc}var Sc,Mg;function XC(){if(Mg)return Sc;Mg=1;var e=qt();Sc=t;var r=e.constant(1);function t(i,o,s){return n(i,o||r,s||function(a){return i.outEdges(a)})}function n(i,o,s){var a={},c=i.nodes();return c.forEach(function(l){a[l]={},a[l][l]={distance:0},c.forEach(function(d){l!==d&&(a[l][d]={distance:Number.POSITIVE_INFINITY})}),s(l).forEach(function(d){var u=d.v===l?d.w:d.v,h=o(d);a[l][u]={distance:h,predecessor:l}})}),c.forEach(function(l){var d=a[l];c.forEach(function(u){var h=a[u];c.forEach(function(p){var y=h[l],m=d[p],g=h[p],b=y.distance+m.distance;b<g.distance&&(g.distance=b,g.predecessor=m.predecessor)})})}),a}return Sc}var jc,Tg;function kv(){if(Tg)return jc;Tg=1;var e=qt();jc=r,r.CycleException=t;function r(n){var i={},o={},s=[];function a(c){if(e.has(o,c))throw new t;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 t;return s}function t(){}return t.prototype=new Error,jc}var _c,Og;function YC(){if(Og)return _c;Og=1;var e=kv();_c=r;function r(t){try{e(t)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return _c}var Ec,Ng;function Av(){if(Ng)return Ec;Ng=1;var e=qt();Ec=r;function r(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(l){if(!n.hasNode(l))throw new Error("Graph does not have node: "+l);t(n,l,o==="post",c,s,a)}),a}function t(n,i,o,s,a,c){e.has(s,i)||(s[i]=!0,o||c.push(i),e.each(a(i),function(l){t(n,l,o,s,a,c)}),o&&c.push(i))}return Ec}var Rc,$g;function QC(){if($g)return Rc;$g=1;var e=Av();Rc=r;function r(t,n){return e(t,n,"post")}return Rc}var kc,qg;function eS(){if(qg)return kc;qg=1;var e=Av();kc=r;function r(t,n){return e(t,n,"pre")}return kc}var Ac,Lg;function tS(){if(Lg)return Ac;Lg=1;var e=qt(),r=Jd(),t=_v();Ac=n;function n(i,o){var s=new r,a={},c=new t,l;function d(h){var p=h.v===l?h.w:h.v,y=c.priority(p);if(y!==void 0){var m=o(h);m<y&&(a[p]=l,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 u=!1;c.size()>0;){if(l=c.removeMin(),e.has(a,l))s.setEdge(l,a[l]);else{if(u)throw new Error("Input graph is not connected: "+i);u=!0}i.nodeEdges(l).forEach(d)}return s}return Ac}var Pc,Fg;function rS(){return Fg||(Fg=1,Pc={components:KC(),dijkstra:Ev(),dijkstraAll:JC(),findCycles:ZC(),floydWarshall:XC(),isAcyclic:YC(),postorder:QC(),preorder:eS(),prim:tS(),tarjan:Rv(),topsort:kv()}),Pc}var Ic,zg;function nS(){if(zg)return Ic;zg=1;var e=UC();return Ic={Graph:e.Graph,json:HC(),alg:rS(),version:e.version},Ic}var Mc,Bg;function Bt(){if(Bg)return Mc;Bg=1;var e;if(typeof Td=="function")try{e=nS()}catch{}return e||(e=window.graphlib),Mc=e,Mc}var Tc,Dg;function oS(){if(Dg)return Tc;Dg=1;var e=ev(),r=1,t=4;function n(i){return e(i,r|t)}return Tc=n,Tc}var Oc,Vg;function _o(){if(Vg)return Oc;Vg=1;var e=Zr(),r=Qt(),t=yo(),n=$t();function i(o,s,a){if(!n(a))return!1;var c=typeof s;return(c=="number"?r(a)&&t(s,a.length):c=="string"&&s in a)?e(a[s],o):!1}return Oc=i,Oc}var Nc,Wg;function iS(){if(Wg)return Nc;Wg=1;var e=jo(),r=Zr(),t=_o(),n=Ar(),i=Object.prototype,o=i.hasOwnProperty,s=e(function(a,c){a=Object(a);var l=-1,d=c.length,u=d>2?c[2]:void 0;for(u&&t(c[0],c[1],u)&&(d=1);++l<d;)for(var h=c[l],p=n(h),y=-1,m=p.length;++y<m;){var g=p[y],b=a[g];(b===void 0||r(b,i[g])&&!o.call(a,g))&&(a[g]=h[g])}return a});return Nc=s,Nc}var $c,Gg;function aS(){if(Gg)return $c;Gg=1;var e=er(),r=Qt(),t=pr();function n(i){return function(o,s,a){var c=Object(o);if(!r(o)){var l=e(s,3);o=t(o),s=function(u){return l(c[u],u,c)}}var d=i(o,s,a);return d>-1?c[l?o[d]:d]:void 0}}return $c=n,$c}var qc,Ug;function sS(){if(Ug)return qc;Ug=1;var e=/\s/;function r(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}return qc=r,qc}var Lc,Hg;function cS(){if(Hg)return Lc;Hg=1;var e=sS(),r=/^\s+/;function t(n){return n&&n.slice(0,e(n)+1).replace(r,"")}return Lc=t,Lc}var Fc,Kg;function lS(){if(Kg)return Fc;Kg=1;var e=cS(),r=$t(),t=en(),n=NaN,i=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt;function c(l){if(typeof l=="number")return l;if(t(l))return n;if(r(l)){var d=typeof l.valueOf=="function"?l.valueOf():l;l=r(d)?d+"":d}if(typeof l!="string")return l===0?l:+l;l=e(l);var u=o.test(l);return u||s.test(l)?a(l.slice(2),u?2:8):i.test(l)?n:+l}return Fc=c,Fc}var zc,Jg;function Pv(){if(Jg)return zc;Jg=1;var e=lS(),r=1/0,t=17976931348623157e292;function n(i){if(!i)return i===0?i:0;if(i=e(i),i===r||i===-r){var o=i<0?-1:1;return o*t}return i===i?i:0}return zc=n,zc}var Bc,Zg;function dS(){if(Zg)return Bc;Zg=1;var e=Pv();function r(t){var n=e(t),i=n%1;return n===n?i?n-i:n:0}return Bc=r,Bc}var Dc,Xg;function uS(){if(Xg)return Dc;Xg=1;var e=Cv(),r=er(),t=dS(),n=Math.max;function i(o,s,a){var c=o==null?0:o.length;if(!c)return-1;var l=a==null?0:t(a);return l<0&&(l=n(c+l,0)),e(o,r(s,3),l)}return Dc=i,Dc}var Vc,Yg;function fS(){if(Yg)return Vc;Yg=1;var e=aS(),r=uS(),t=e(r);return Vc=t,Vc}var Wc,Qg;function Iv(){if(Qg)return Wc;Qg=1;var e=Kd();function r(t){var n=t==null?0:t.length;return n?e(t,1):[]}return Wc=r,Wc}var Gc,ey;function hS(){if(ey)return Gc;ey=1;var e=Wd(),r=tv(),t=Ar();function n(i,o){return i==null?i:e(i,r(o),t)}return Gc=n,Gc}var Uc,ty;function pS(){if(ty)return Uc;ty=1;function e(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}return Uc=e,Uc}var Hc,ry;function gS(){if(ry)return Hc;ry=1;var e=po(),r=Gd(),t=er();function n(i,o){var s={};return o=t(o,3),r(i,function(a,c,l){e(s,c,o(a,c,l))}),s}return Hc=n,Hc}var Kc,ny;function Zd(){if(ny)return Kc;ny=1;var e=en();function r(t,n,i){for(var o=-1,s=t.length;++o<s;){var a=t[o],c=n(a);if(c!=null&&(l===void 0?c===c&&!e(c):i(c,l)))var l=c,d=a}return d}return Kc=r,Kc}var Jc,oy;function yS(){if(oy)return Jc;oy=1;function e(r,t){return r>t}return Jc=e,Jc}var Zc,iy;function mS(){if(iy)return Zc;iy=1;var e=Zd(),r=yS(),t=Pr();function n(i){return i&&i.length?e(i,t,r):void 0}return Zc=n,Zc}var Xc,ay;function Mv(){if(ay)return Xc;ay=1;var e=po(),r=Zr();function t(n,i,o){(o!==void 0&&!r(n[i],o)||o===void 0&&!(i in n))&&e(n,i,o)}return Xc=t,Xc}var Yc,sy;function bS(){if(sy)return Yc;sy=1;var e=Rr(),r=vo(),t=Kt(),n="[object Object]",i=Function.prototype,o=Object.prototype,s=i.toString,a=o.hasOwnProperty,c=s.call(Object);function l(d){if(!t(d)||e(d)!=n)return!1;var u=r(d);if(u===null)return!0;var h=a.call(u,"constructor")&&u.constructor;return typeof h=="function"&&h instanceof h&&s.call(h)==c}return Yc=l,Yc}var Qc,cy;function Tv(){if(cy)return Qc;cy=1;function e(r,t){if(!(t==="constructor"&&typeof r[t]=="function")&&t!="__proto__")return r[t]}return Qc=e,Qc}var el,ly;function vS(){if(ly)return el;ly=1;var e=Mn(),r=Ar();function t(n){return e(n,r(n))}return el=t,el}var tl,dy;function xS(){if(dy)return tl;dy=1;var e=Mv(),r=Db(),t=Xb(),n=Vb(),i=Qb(),o=Tn(),s=pt(),a=Sv(),c=Yr(),l=In(),d=$t(),u=bS(),h=On(),p=Tv(),y=vS();function m(g,b,v,x,w,C,j){var _=p(g,v),k=p(b,v),E=j.get(k);if(E){e(g,v,E);return}var O=C?C(_,k,v+"",g,b,j):void 0,T=O===void 0;if(T){var P=s(k),I=!P&&c(k),R=!P&&!I&&h(k);O=k,P||I||R?s(_)?O=_:a(_)?O=n(_):I?(T=!1,O=r(k,!0)):R?(T=!1,O=t(k,!0)):O=[]:u(k)||o(k)?(O=_,o(_)?O=y(_):(!d(_)||l(_))&&(O=i(k))):T=!1}T&&(j.set(k,O),w(O,k,x,C,j),j.delete(k)),e(g,v,O)}return tl=m,tl}var rl,uy;function wS(){if(uy)return rl;uy=1;var e=ho(),r=Mv(),t=Wd(),n=xS(),i=$t(),o=Ar(),s=Tv();function a(c,l,d,u,h){c!==l&&t(l,function(p,y){if(h||(h=new e),i(p))n(c,l,y,d,a,u,h);else{var m=u?u(s(c,y),p,y+"",c,l,h):void 0;m===void 0&&(m=p),r(c,y,m)}},o)}return rl=a,rl}var nl,fy;function CS(){if(fy)return nl;fy=1;var e=jo(),r=_o();function t(n){return e(function(i,o){var s=-1,a=o.length,c=a>1?o[a-1]:void 0,l=a>2?o[2]:void 0;for(c=n.length>3&&typeof c=="function"?(a--,c):void 0,l&&r(o[0],o[1],l)&&(c=a<3?void 0:c,a=1),i=Object(i);++s<a;){var d=o[s];d&&n(i,d,s,c)}return i})}return nl=t,nl}var ol,hy;function SS(){if(hy)return ol;hy=1;var e=wS(),r=CS(),t=r(function(n,i,o){e(n,i,o)});return ol=t,ol}var il,py;function Ov(){if(py)return il;py=1;function e(r,t){return r<t}return il=e,il}var al,gy;function jS(){if(gy)return al;gy=1;var e=Zd(),r=Ov(),t=Pr();function n(i){return i&&i.length?e(i,t,r):void 0}return al=n,al}var sl,yy;function _S(){if(yy)return sl;yy=1;var e=Zd(),r=er(),t=Ov();function n(i,o){return i&&i.length?e(i,r(o,2),t):void 0}return sl=n,sl}var cl,my;function ES(){if(my)return cl;my=1;var e=Dt(),r=function(){return e.Date.now()};return cl=r,cl}var ll,by;function RS(){if(by)return ll;by=1;var e=go(),r=Co(),t=yo(),n=$t(),i=Nn();function o(s,a,c,l){if(!n(s))return s;a=r(a,s);for(var d=-1,u=a.length,h=u-1,p=s;p!=null&&++d<u;){var y=i(a[d]),m=c;if(y==="__proto__"||y==="constructor"||y==="prototype")return s;if(d!=h){var g=p[y];m=l?l(g,y,p):void 0,m===void 0&&(m=n(g)?g:t(a[d+1])?[]:{})}e(p,y,m),p=p[y]}return s}return ll=o,ll}var dl,vy;function kS(){if(vy)return dl;vy=1;var e=So(),r=RS(),t=Co();function n(i,o,s){for(var a=-1,c=o.length,l={};++a<c;){var d=o[a],u=e(i,d);s(u,d)&&r(l,t(d,i),u)}return l}return dl=n,dl}var ul,xy;function AS(){if(xy)return ul;xy=1;var e=kS(),r=fv();function t(n,i){return e(n,i,function(o,s){return r(n,s)})}return ul=t,ul}var fl,wy;function PS(){if(wy)return fl;wy=1;var e=Iv(),r=xv(),t=wv();function n(i){return t(r(i,void 0,e),i+"")}return fl=n,fl}var hl,Cy;function IS(){if(Cy)return hl;Cy=1;var e=AS(),r=PS(),t=r(function(n,i){return n==null?{}:e(n,i)});return hl=t,hl}var pl,Sy;function MS(){if(Sy)return pl;Sy=1;var e=Math.ceil,r=Math.max;function t(n,i,o,s){for(var a=-1,c=r(e((i-n)/(o||1)),0),l=Array(c);c--;)l[s?c:++a]=n,n+=o;return l}return pl=t,pl}var gl,jy;function TS(){if(jy)return gl;jy=1;var e=MS(),r=_o(),t=Pv();function n(i){return function(o,s,a){return a&&typeof a!="number"&&r(o,s,a)&&(s=a=void 0),o=t(o),s===void 0?(s=o,o=0):s=t(s),a=a===void 0?o<s?1:-1:t(a),e(o,s,a,i)}}return gl=n,gl}var yl,_y;function OS(){if(_y)return yl;_y=1;var e=TS(),r=e();return yl=r,yl}var ml,Ey;function NS(){if(Ey)return ml;Ey=1;function e(r,t){var n=r.length;for(r.sort(t);n--;)r[n]=r[n].value;return r}return ml=e,ml}var bl,Ry;function $S(){if(Ry)return bl;Ry=1;var e=en();function r(t,n){if(t!==n){var i=t!==void 0,o=t===null,s=t===t,a=e(t),c=n!==void 0,l=n===null,d=n===n,u=e(n);if(!l&&!u&&!a&&t>n||a&&c&&d&&!l&&!u||o&&c&&d||!i&&d||!s)return 1;if(!o&&!a&&!u&&t<n||u&&i&&s&&!o&&!a||l&&i&&s||!c&&s||!d)return-1}return 0}return bl=r,bl}var vl,ky;function qS(){if(ky)return vl;ky=1;var e=$S();function r(t,n,i){for(var o=-1,s=t.criteria,a=n.criteria,c=s.length,l=i.length;++o<c;){var d=e(s[o],a[o]);if(d){if(o>=l)return d;var u=i[o];return d*(u=="desc"?-1:1)}}return t.index-n.index}return vl=r,vl}var xl,Ay;function LS(){if(Ay)return xl;Ay=1;var e=wo(),r=So(),t=er(),n=mv(),i=NS(),o=mo(),s=qS(),a=Pr(),c=pt();function l(d,u,h){u.length?u=e(u,function(m){return c(m)?function(g){return r(g,m.length===1?m[0]:m)}:m}):u=[a];var p=-1;u=e(u,o(t));var y=n(d,function(m,g,b){var v=e(u,function(x){return x(m)});return{criteria:v,index:++p,value:m}});return i(y,function(m,g){return s(m,g,h)})}return xl=l,xl}var wl,Py;function FS(){if(Py)return wl;Py=1;var e=Kd(),r=LS(),t=jo(),n=_o(),i=t(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]]),r(o,e(s,1),[])});return wl=i,wl}var Cl,Iy;function zS(){if(Iy)return Cl;Iy=1;var e=dv(),r=0;function t(n){var i=++r;return e(n)+i}return Cl=t,Cl}var Sl,My;function BS(){if(My)return Sl;My=1;function e(r,t,n){for(var i=-1,o=r.length,s=t.length,a={};++i<o;){var c=i<s?t[i]:void 0;n(a,r[i],c)}return a}return Sl=e,Sl}var jl,Ty;function DS(){if(Ty)return jl;Ty=1;var e=go(),r=BS();function t(n,i){return r(n||[],i||[],e)}return jl=t,jl}var _l,Oy;function st(){if(Oy)return _l;Oy=1;var e;if(typeof Td=="function")try{e={cloneDeep:oS(),constant:Vd(),defaults:iS(),each:nv(),filter:pv(),find:fS(),flatten:Iv(),forEach:rv(),forIn:hS(),has:gv(),isUndefined:yv(),last:pS(),map:bv(),mapValues:gS(),max:mS(),merge:SS(),min:jS(),minBy:_S(),now:ES(),pick:IS(),range:OS(),reduce:vv(),sortBy:FS(),uniqueId:zS(),values:jv(),zipObject:DS()}}catch{}return e||(e=window._),_l=e,_l}var El,Ny;function VS(){if(Ny)return El;Ny=1,El=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 r(i),i},e.prototype.enqueue=function(n){var i=this._sentinel;n._prev&&n._next&&r(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,t)),o=o._prev;return"["+n.join(", ")+"]"};function r(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function t(n,i){if(n!=="_next"&&n!=="_prev")return i}return El}var Rl,$y;function WS(){if($y)return Rl;$y=1;var e=st(),r=Bt().Graph,t=VS();Rl=i;var n=e.constant(1);function i(l,d){if(l.nodeCount()<=1)return[];var u=a(l,d||n),h=o(u.graph,u.buckets,u.zeroIdx);return e.flatten(e.map(h,function(p){return l.outEdges(p.v,p.w)}),!0)}function o(l,d,u){for(var h=[],p=d[d.length-1],y=d[0],m;l.nodeCount();){for(;m=y.dequeue();)s(l,d,u,m);for(;m=p.dequeue();)s(l,d,u,m);if(l.nodeCount()){for(var g=d.length-2;g>0;--g)if(m=d[g].dequeue(),m){h=h.concat(s(l,d,u,m,!0));break}}}return h}function s(l,d,u,h,p){var y=p?[]:void 0;return e.forEach(l.inEdges(h.v),function(m){var g=l.edge(m),b=l.node(m.v);p&&y.push({v:m.v,w:m.w}),b.out-=g,c(d,u,b)}),e.forEach(l.outEdges(h.v),function(m){var g=l.edge(m),b=m.w,v=l.node(b);v.in-=g,c(d,u,v)}),l.removeNode(h.v),y}function a(l,d){var u=new r,h=0,p=0;e.forEach(l.nodes(),function(g){u.setNode(g,{v:g,in:0,out:0})}),e.forEach(l.edges(),function(g){var b=u.edge(g.v,g.w)||0,v=d(g),x=b+v;u.setEdge(g.v,g.w,x),p=Math.max(p,u.node(g.v).out+=v),h=Math.max(h,u.node(g.w).in+=v)});var y=e.range(p+h+3).map(function(){return new t}),m=h+1;return e.forEach(u.nodes(),function(g){c(y,m,u.node(g))}),{graph:u,buckets:y,zeroIdx:m}}function c(l,d,u){u.out?u.in?l[u.out-u.in+d].enqueue(u):l[l.length-1].enqueue(u):l[0].enqueue(u)}return Rl}var kl,qy;function GS(){if(qy)return kl;qy=1;var e=st(),r=WS();kl={run:t,undo:i};function t(o){var s=o.graph().acyclicer==="greedy"?r(o,a(o)):n(o);e.forEach(s,function(c){var l=o.edge(c);o.removeEdge(c),l.forwardName=c.name,l.reversed=!0,o.setEdge(c.w,c.v,l,e.uniqueId("rev"))});function a(c){return function(l){return c.edge(l).weight}}}function n(o){var s=[],a={},c={};function l(d){e.has(c,d)||(c[d]=!0,a[d]=!0,e.forEach(o.outEdges(d),function(u){e.has(a,u.w)?s.push(u):l(u.w)}),delete a[d])}return e.forEach(o.nodes(),l),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 kl}var Al,Ly;function kt(){if(Ly)return Al;Ly=1;var e=st(),r=Bt().Graph;Al={addDummyNode:t,simplify:n,asNonCompoundGraph:i,successorWeights:o,predecessorWeights:s,intersectRect:a,buildLayerMatrix:c,normalizeRanks:l,removeEmptyRanks:d,addBorderNode:u,maxRank:h,partition:p,time:y,notime:m};function t(g,b,v,x){var w;do w=e.uniqueId(x);while(g.hasNode(w));return v.dummy=b,g.setNode(w,v),w}function n(g){var b=new r().setGraph(g.graph());return e.forEach(g.nodes(),function(v){b.setNode(v,g.node(v))}),e.forEach(g.edges(),function(v){var x=b.edge(v.v,v.w)||{weight:0,minlen:1},w=g.edge(v);b.setEdge(v.v,v.w,{weight:x.weight+w.weight,minlen:Math.max(x.minlen,w.minlen)})}),b}function i(g){var b=new r({multigraph:g.isMultigraph()}).setGraph(g.graph());return e.forEach(g.nodes(),function(v){g.children(v).length||b.setNode(v,g.node(v))}),e.forEach(g.edges(),function(v){b.setEdge(v,g.edge(v))}),b}function o(g){var b=e.map(g.nodes(),function(v){var x={};return e.forEach(g.outEdges(v),function(w){x[w.w]=(x[w.w]||0)+g.edge(w).weight}),x});return e.zipObject(g.nodes(),b)}function s(g){var b=e.map(g.nodes(),function(v){var x={};return e.forEach(g.inEdges(v),function(w){x[w.v]=(x[w.v]||0)+g.edge(w).weight}),x});return e.zipObject(g.nodes(),b)}function a(g,b){var v=g.x,x=g.y,w=b.x-v,C=b.y-x,j=g.width/2,_=g.height/2;if(!w&&!C)throw new Error("Not possible to find intersection inside of the rectangle");var k,E;return Math.abs(C)*j>Math.abs(w)*_?(C<0&&(_=-_),k=_*w/C,E=_):(w<0&&(j=-j),k=j,E=j*C/w),{x:v+k,y:x+E}}function c(g){var b=e.map(e.range(h(g)+1),function(){return[]});return e.forEach(g.nodes(),function(v){var x=g.node(v),w=x.rank;e.isUndefined(w)||(b[w][x.order]=v)}),b}function l(g){var b=e.min(e.map(g.nodes(),function(v){return g.node(v).rank}));e.forEach(g.nodes(),function(v){var x=g.node(v);e.has(x,"rank")&&(x.rank-=b)})}function d(g){var b=e.min(e.map(g.nodes(),function(C){return g.node(C).rank})),v=[];e.forEach(g.nodes(),function(C){var j=g.node(C).rank-b;v[j]||(v[j]=[]),v[j].push(C)});var x=0,w=g.graph().nodeRankFactor;e.forEach(v,function(C,j){e.isUndefined(C)&&j%w!==0?--x:x&&e.forEach(C,function(_){g.node(_).rank+=x})})}function u(g,b,v,x){var w={width:0,height:0};return arguments.length>=4&&(w.rank=v,w.order=x),t(g,"border",w,b)}function h(g){return e.max(e.map(g.nodes(),function(b){var v=g.node(b).rank;if(!e.isUndefined(v))return v}))}function p(g,b){var v={lhs:[],rhs:[]};return e.forEach(g,function(x){b(x)?v.lhs.push(x):v.rhs.push(x)}),v}function y(g,b){var v=e.now();try{return b()}finally{console.log(g+" time: "+(e.now()-v)+"ms")}}function m(g,b){return b()}return Al}var Pl,Fy;function US(){if(Fy)return Pl;Fy=1;var e=st(),r=kt();Pl={run:t,undo:i};function t(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,l=s.w,d=o.node(l).rank,u=s.name,h=o.edge(s),p=h.labelRank;if(d!==c+1){o.removeEdge(s);var y,m,g;for(g=0,++c;c<d;++g,++c)h.points=[],m={width:0,height:0,edgeLabel:h,edgeObj:s,rank:c},y=r.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},u),g===0&&o.graph().dummyChains.push(y),a=y;o.setEdge(a,l,{weight:h.weight},u)}}function i(o){e.forEach(o.graph().dummyChains,function(s){var a=o.node(s),c=a.edgeLabel,l;for(o.setEdge(a.edgeObj,c);a.dummy;)l=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=l,a=o.node(s)})}return Pl}var Il,zy;function Yn(){if(zy)return Il;zy=1;var e=st();Il={longestPath:r,slack:t};function r(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(l){return o(l.w)-n.edge(l).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),a.rank=c}e.forEach(n.sources(),o)}function t(n,i){return n.node(i.w).rank-n.node(i.v).rank-n.edge(i).minlen}return Il}var Ml,By;function Nv(){if(By)return Ml;By=1;var e=st(),r=Bt().Graph,t=Yn().slack;Ml=n;function n(a){var c=new r({directed:!1}),l=a.nodes()[0],d=a.nodeCount();c.setNode(l,{});for(var u,h;i(c,a)<d;)u=o(c,a),h=c.hasNode(u.v)?t(a,u):-t(a,u),s(c,a,h);return c}function i(a,c){function l(d){e.forEach(c.nodeEdges(d),function(u){var h=u.v,p=d===h?u.w:h;!a.hasNode(p)&&!t(c,u)&&(a.setNode(p,{}),a.setEdge(d,p,{}),l(p))})}return e.forEach(a.nodes(),l),a.nodeCount()}function o(a,c){return e.minBy(c.edges(),function(l){if(a.hasNode(l.v)!==a.hasNode(l.w))return t(c,l)})}function s(a,c,l){e.forEach(a.nodes(),function(d){c.node(d).rank+=l})}return Ml}var Tl,Dy;function HS(){if(Dy)return Tl;Dy=1;var e=st(),r=Nv(),t=Yn().slack,n=Yn().longestPath,i=Bt().alg.preorder,o=Bt().alg.postorder,s=kt().simplify;Tl=a,a.initLowLimValues=u,a.initCutValues=c,a.calcCutValue=d,a.leaveEdge=p,a.enterEdge=y,a.exchangeEdges=m;function a(x){x=s(x),n(x);var w=r(x);u(w),c(w,x);for(var C,j;C=p(w);)j=y(w,x,C),m(w,x,C,j)}function c(x,w){var C=o(x,x.nodes());C=C.slice(0,C.length-1),e.forEach(C,function(j){l(x,w,j)})}function l(x,w,C){var j=x.node(C),_=j.parent;x.edge(C,_).cutvalue=d(x,w,C)}function d(x,w,C){var j=x.node(C),_=j.parent,k=!0,E=w.edge(C,_),O=0;return E||(k=!1,E=w.edge(_,C)),O=E.weight,e.forEach(w.nodeEdges(C),function(T){var P=T.v===C,I=P?T.w:T.v;if(I!==_){var R=P===k,$=w.edge(T).weight;if(O+=R?$:-$,b(x,C,I)){var N=x.edge(C,I).cutvalue;O+=R?-N:N}}}),O}function u(x,w){arguments.length<2&&(w=x.nodes()[0]),h(x,{},1,w)}function h(x,w,C,j,_){var k=C,E=x.node(j);return w[j]=!0,e.forEach(x.neighbors(j),function(O){e.has(w,O)||(C=h(x,w,C,O,j))}),E.low=k,E.lim=C++,_?E.parent=_:delete E.parent,C}function p(x){return e.find(x.edges(),function(w){return x.edge(w).cutvalue<0})}function y(x,w,C){var j=C.v,_=C.w;w.hasEdge(j,_)||(j=C.w,_=C.v);var k=x.node(j),E=x.node(_),O=k,T=!1;k.lim>E.lim&&(O=E,T=!0);var P=e.filter(w.edges(),function(I){return T===v(x,x.node(I.v),O)&&T!==v(x,x.node(I.w),O)});return e.minBy(P,function(I){return t(w,I)})}function m(x,w,C,j){var _=C.v,k=C.w;x.removeEdge(_,k),x.setEdge(j.v,j.w,{}),u(x),c(x,w),g(x,w)}function g(x,w){var C=e.find(x.nodes(),function(_){return!w.node(_).parent}),j=i(x,C);j=j.slice(1),e.forEach(j,function(_){var k=x.node(_).parent,E=w.edge(_,k),O=!1;E||(E=w.edge(k,_),O=!0),w.node(_).rank=w.node(k).rank+(O?E.minlen:-E.minlen)})}function b(x,w,C){return x.hasEdge(w,C)}function v(x,w,C){return C.low<=w.lim&&w.lim<=C.lim}return Tl}var Ol,Vy;function KS(){if(Vy)return Ol;Vy=1;var e=Yn(),r=e.longestPath,t=Nv(),n=HS();Ol=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=r;function s(c){r(c),t(c)}function a(c){n(c)}return Ol}var Nl,Wy;function JS(){if(Wy)return Nl;Wy=1;var e=st();Nl=r;function r(i){var o=n(i);e.forEach(i.graph().dummyChains,function(s){for(var a=i.node(s),c=a.edgeObj,l=t(i,o,c.v,c.w),d=l.path,u=l.lca,h=0,p=d[h],y=!0;s!==c.w;){if(a=i.node(s),y){for(;(p=d[h])!==u&&i.node(p).maxRank<a.rank;)h++;p===u&&(y=!1)}if(!y){for(;h<d.length-1&&i.node(p=d[h+1]).minRank<=a.rank;)h++;p=d[h]}i.setParent(s,p),s=i.successors(s)[0]}})}function t(i,o,s,a){var c=[],l=[],d=Math.min(o[s].low,o[a].low),u=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>d||u>o[h].lim));for(p=h,h=a;(h=i.parent(h))!==p;)l.push(h);return{path:c.concat(l.reverse()),lca:p}}function n(i){var o={},s=0;function a(c){var l=s;e.forEach(i.children(c),a),o[c]={low:l,lim:s++}}return e.forEach(i.children(),a),o}return Nl}var $l,Gy;function ZS(){if(Gy)return $l;Gy=1;var e=st(),r=kt();$l={run:t,cleanup:s};function t(a){var c=r.addDummyNode(a,"root",{},"_root"),l=i(a),d=e.max(e.values(l))-1,u=2*d+1;a.graph().nestingRoot=c,e.forEach(a.edges(),function(p){a.edge(p).minlen*=u});var h=o(a)+1;e.forEach(a.children(),function(p){n(a,c,u,h,d,l,p)}),a.graph().nodeRankFactor=u}function n(a,c,l,d,u,h,p){var y=a.children(p);if(!y.length){p!==c&&a.setEdge(c,p,{weight:0,minlen:l});return}var m=r.addBorderNode(a,"_bt"),g=r.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(v){n(a,c,l,d,u,h,v);var x=a.node(v),w=x.borderTop?x.borderTop:v,C=x.borderBottom?x.borderBottom:v,j=x.borderTop?d:2*d,_=w!==C?1:u-h[p]+1;a.setEdge(m,w,{weight:j,minlen:_,nestingEdge:!0}),a.setEdge(C,g,{weight:j,minlen:_,nestingEdge:!0})}),a.parent(p)||a.setEdge(c,m,{weight:0,minlen:u+h[p]})}function i(a){var c={};function l(d,u){var h=a.children(d);h&&h.length&&e.forEach(h,function(p){l(p,u+1)}),c[d]=u}return e.forEach(a.children(),function(d){l(d,1)}),c}function o(a){return e.reduce(a.edges(),function(c,l){return c+a.edge(l).weight},0)}function s(a){var c=a.graph();a.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(a.edges(),function(l){var d=a.edge(l);d.nestingEdge&&a.removeEdge(l)})}return $l}var ql,Uy;function XS(){if(Uy)return ql;Uy=1;var e=st(),r=kt();ql=t;function t(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 l=c.minRank,d=c.maxRank+1;l<d;++l)n(i,"borderLeft","_bl",s,c,l),n(i,"borderRight","_br",s,c,l)}}e.forEach(i.children(),o)}function n(i,o,s,a,c,l){var d={width:0,height:0,rank:l,borderType:o},u=c[o][l-1],h=r.addDummyNode(i,"border",d,s);c[o][l]=h,i.setParent(h,a),u&&i.setEdge(u,h,{weight:1})}return ql}var Ll,Hy;function YS(){if(Hy)return Ll;Hy=1;var e=st();Ll={adjust:r,undo:t};function r(l){var d=l.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&n(l)}function t(l){var d=l.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&o(l),(d==="lr"||d==="rl")&&(a(l),n(l))}function n(l){e.forEach(l.nodes(),function(d){i(l.node(d))}),e.forEach(l.edges(),function(d){i(l.edge(d))})}function i(l){var d=l.width;l.width=l.height,l.height=d}function o(l){e.forEach(l.nodes(),function(d){s(l.node(d))}),e.forEach(l.edges(),function(d){var u=l.edge(d);e.forEach(u.points,s),e.has(u,"y")&&s(u)})}function s(l){l.y=-l.y}function a(l){e.forEach(l.nodes(),function(d){c(l.node(d))}),e.forEach(l.edges(),function(d){var u=l.edge(d);e.forEach(u.points,c),e.has(u,"x")&&c(u)})}function c(l){var d=l.x;l.x=l.y,l.y=d}return Ll}var Fl,Ky;function QS(){if(Ky)return Fl;Ky=1;var e=st();Fl=r;function r(t){var n={},i=e.filter(t.nodes(),function(l){return!t.children(l).length}),o=e.max(e.map(i,function(l){return t.node(l).rank})),s=e.map(e.range(o+1),function(){return[]});function a(l){if(!e.has(n,l)){n[l]=!0;var d=t.node(l);s[d.rank].push(l),e.forEach(t.successors(l),a)}}var c=e.sortBy(i,function(l){return t.node(l).rank});return e.forEach(c,a),s}return Fl}var zl,Jy;function ej(){if(Jy)return zl;Jy=1;var e=st();zl=r;function r(n,i){for(var o=0,s=1;s<i.length;++s)o+=t(n,i[s-1],i[s]);return o}function t(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 l=2*c-1;c-=1;var d=e.map(new Array(l),function(){return 0}),u=0;return e.forEach(a.forEach(function(h){var p=h.pos+c;d[p]+=h.weight;for(var y=0;p>0;)p%2&&(y+=d[p+1]),p=p-1>>1,d[p]+=h.weight;u+=h.weight*y})),u}return zl}var Bl,Zy;function tj(){if(Zy)return Bl;Zy=1;var e=st();Bl=r;function r(t,n){return e.map(n,function(i){var o=t.inEdges(i);if(o.length){var s=e.reduce(o,function(a,c){var l=t.edge(c),d=t.node(c.v);return{sum:a.sum+l.weight*d.order,weight:a.weight+l.weight}},{sum:0,weight:0});return{v:i,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:i}})}return Bl}var Dl,Xy;function rj(){if(Xy)return Dl;Xy=1;var e=st();Dl=r;function r(i,o){var s={};e.forEach(i,function(c,l){var d=s[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:l};e.isUndefined(c.barycenter)||(d.barycenter=c.barycenter,d.weight=c.weight)}),e.forEach(o.edges(),function(c){var l=s[c.v],d=s[c.w];!e.isUndefined(l)&&!e.isUndefined(d)&&(d.indegree++,l.out.push(s[c.w]))});var a=e.filter(s,function(c){return!c.indegree});return t(a)}function t(i){var o=[];function s(l){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(l.barycenter)||d.barycenter>=l.barycenter)&&n(l,d)}}function a(l){return function(d){d.in.push(l),--d.indegree===0&&i.push(d)}}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(l){return!l.merged}),function(l){return e.pick(l,["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 Dl}var Vl,Yy;function nj(){if(Yy)return Vl;Yy=1;var e=st(),r=kt();Vl=t;function t(o,s){var a=r.partition(o,function(m){return e.has(m,"barycenter")}),c=a.lhs,l=e.sortBy(a.rhs,function(m){return-m.i}),d=[],u=0,h=0,p=0;c.sort(i(!!s)),p=n(d,l,p),e.forEach(c,function(m){p+=m.vs.length,d.push(m.vs),u+=m.barycenter*m.weight,h+=m.weight,p=n(d,l,p)});var y={vs:e.flatten(d,!0)};return h&&(y.barycenter=u/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 Vl}var Wl,Qy;function oj(){if(Qy)return Wl;Qy=1;var e=st(),r=tj(),t=rj(),n=nj();Wl=i;function i(a,c,l,d){var u=a.children(c),h=a.node(c),p=h?h.borderLeft:void 0,y=h?h.borderRight:void 0,m={};p&&(u=e.filter(u,function(C){return C!==p&&C!==y}));var g=r(a,u);e.forEach(g,function(C){if(a.children(C.v).length){var j=i(a,C.v,l,d);m[C.v]=j,e.has(j,"barycenter")&&s(C,j)}});var b=t(g,l);o(b,m);var v=n(b,d);if(p&&(v.vs=e.flatten([p,v.vs,y],!0),a.predecessors(p).length)){var x=a.node(a.predecessors(p)[0]),w=a.node(a.predecessors(y)[0]);e.has(v,"barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+x.order+w.order)/(v.weight+2),v.weight+=2}return v}function o(a,c){e.forEach(a,function(l){l.vs=e.flatten(l.vs.map(function(d){return c[d]?c[d].vs:d}),!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 Wl}var Gl,em;function ij(){if(em)return Gl;em=1;var e=st(),r=Bt().Graph;Gl=t;function t(i,o,s){var a=n(i),c=new r({compound:!0}).setGraph({root:a}).setDefaultNodeLabel(function(l){return i.node(l)});return e.forEach(i.nodes(),function(l){var d=i.node(l),u=i.parent(l);(d.rank===o||d.minRank<=o&&o<=d.maxRank)&&(c.setNode(l),c.setParent(l,u||a),e.forEach(i[s](l),function(h){var p=h.v===l?h.w:h.v,y=c.edge(p,l),m=e.isUndefined(y)?0:y.weight;c.setEdge(p,l,{weight:i.edge(h).weight+m})}),e.has(d,"minRank")&&c.setNode(l,{borderLeft:d.borderLeft[o],borderRight:d.borderRight[o]}))}),c}function n(i){for(var o;i.hasNode(o=e.uniqueId("_root")););return o}return Gl}var Ul,tm;function aj(){if(tm)return Ul;tm=1;var e=st();Ul=r;function r(t,n,i){var o={},s;e.forEach(i,function(a){for(var c=t.parent(a),l,d;c;){if(l=t.parent(c),l?(d=o[l],o[l]=c):(d=s,s=c),d&&d!==c){n.setEdge(d,c);return}c=l}})}return Ul}var Hl,rm;function sj(){if(rm)return Hl;rm=1;var e=st(),r=QS(),t=ej(),n=oj(),i=ij(),o=aj(),s=Bt().Graph,a=kt();Hl=c;function c(h){var p=a.maxRank(h),y=l(h,e.range(1,p+1),"inEdges"),m=l(h,e.range(p-1,-1,-1),"outEdges"),g=r(h);u(h,g);for(var b=Number.POSITIVE_INFINITY,v,x=0,w=0;w<4;++x,++w){d(x%2?y:m,x%4>=2),g=a.buildLayerMatrix(h);var C=t(h,g);C<b&&(w=0,v=e.cloneDeep(g),b=C)}u(h,v)}function l(h,p,y){return e.map(p,function(m){return i(h,m,y)})}function d(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(v,x){m.node(v).order=x}),o(m,y,b.vs)})}function u(h,p){e.forEach(p,function(y){e.forEach(y,function(m,g){h.node(m).order=g})})}return Hl}var Kl,nm;function cj(){if(nm)return Kl;nm=1;var e=st(),r=Bt().Graph,t=kt();Kl={positionX:y,findType1Conflicts:n,findType2Conflicts:i,addConflict:s,hasConflict:a,verticalAlignment:c,horizontalCompaction:l,alignCoordinates:h,findSmallestWidthAlignment:u,balance:p};function n(b,v){var x={};function w(C,j){var _=0,k=0,E=C.length,O=e.last(j);return e.forEach(j,function(T,P){var I=o(b,T),R=I?b.node(I).order:E;(I||T===O)&&(e.forEach(j.slice(k,P+1),function($){e.forEach(b.predecessors($),function(N){var M=b.node(N),J=M.order;(J<_||R<J)&&!(M.dummy&&b.node($).dummy)&&s(x,N,$)})}),k=P+1,_=R)}),j}return e.reduce(v,w),x}function i(b,v){var x={};function w(j,_,k,E,O){var T;e.forEach(e.range(_,k),function(P){T=j[P],b.node(T).dummy&&e.forEach(b.predecessors(T),function(I){var R=b.node(I);R.dummy&&(R.order<E||R.order>O)&&s(x,I,T)})})}function C(j,_){var k=-1,E,O=0;return e.forEach(_,function(T,P){if(b.node(T).dummy==="border"){var I=b.predecessors(T);I.length&&(E=b.node(I[0]).order,w(_,O,P,k,E),O=P,k=E)}w(_,O,_.length,E,j.length)}),_}return e.reduce(v,C),x}function o(b,v){if(b.node(v).dummy)return e.find(b.predecessors(v),function(x){return b.node(x).dummy})}function s(b,v,x){if(v>x){var w=v;v=x,x=w}var C=b[v];C||(b[v]=C={}),C[x]=!0}function a(b,v,x){if(v>x){var w=v;v=x,x=w}return e.has(b[v],x)}function c(b,v,x,w){var C={},j={},_={};return e.forEach(v,function(k){e.forEach(k,function(E,O){C[E]=E,j[E]=E,_[E]=O})}),e.forEach(v,function(k){var E=-1;e.forEach(k,function(O){var T=w(O);if(T.length){T=e.sortBy(T,function(N){return _[N]});for(var P=(T.length-1)/2,I=Math.floor(P),R=Math.ceil(P);I<=R;++I){var $=T[I];j[O]===O&&E<_[$]&&!a(x,O,$)&&(j[$]=O,j[O]=C[O]=C[$],E=_[$])}}})}),{root:C,align:j}}function l(b,v,x,w,C){var j={},_=d(b,v,x,C),k=C?"borderLeft":"borderRight";function E(P,I){for(var R=_.nodes(),$=R.pop(),N={};$;)N[$]?P($):(N[$]=!0,R.push($),R=R.concat(I($))),$=R.pop()}function O(P){j[P]=_.inEdges(P).reduce(function(I,R){return Math.max(I,j[R.v]+_.edge(R))},0)}function T(P){var I=_.outEdges(P).reduce(function($,N){return Math.min($,j[N.w]-_.edge(N))},Number.POSITIVE_INFINITY),R=b.node(P);I!==Number.POSITIVE_INFINITY&&R.borderType!==k&&(j[P]=Math.max(j[P],I))}return E(O,_.predecessors.bind(_)),E(T,_.successors.bind(_)),e.forEach(w,function(P){j[P]=j[x[P]]}),j}function d(b,v,x,w){var C=new r,j=b.graph(),_=m(j.nodesep,j.edgesep,w);return e.forEach(v,function(k){var E;e.forEach(k,function(O){var T=x[O];if(C.setNode(T),E){var P=x[E],I=C.edge(P,T);C.setEdge(P,T,Math.max(_(b,O,E),I||0))}E=O})}),C}function u(b,v){return e.minBy(e.values(v),function(x){var w=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;return e.forIn(x,function(j,_){var k=g(b,_)/2;w=Math.max(j+k,w),C=Math.min(j-k,C)}),w-C})}function h(b,v){var x=e.values(v),w=e.min(x),C=e.max(x);e.forEach(["u","d"],function(j){e.forEach(["l","r"],function(_){var k=j+_,E=b[k],O;if(E!==v){var T=e.values(E);O=_==="l"?w-e.min(T):C-e.max(T),O&&(b[k]=e.mapValues(E,function(P){return P+O}))}})})}function p(b,v){return e.mapValues(b.ul,function(x,w){if(v)return b[v.toLowerCase()][w];var C=e.sortBy(e.map(b,w));return(C[1]+C[2])/2})}function y(b){var v=t.buildLayerMatrix(b),x=e.merge(n(b,v),i(b,v)),w={},C;e.forEach(["u","d"],function(_){C=_==="u"?v:e.values(v).reverse(),e.forEach(["l","r"],function(k){k==="r"&&(C=e.map(C,function(P){return e.values(P).reverse()}));var E=(_==="u"?b.predecessors:b.successors).bind(b),O=c(b,C,x,E),T=l(b,C,O.root,O.align,k==="r");k==="r"&&(T=e.mapValues(T,function(P){return-P})),w[_+k]=T})});var j=u(b,w);return h(w,j),p(w,b.graph().align)}function m(b,v,x){return function(w,C,j){var _=w.node(C),k=w.node(j),E=0,O;if(E+=_.width/2,e.has(_,"labelpos"))switch(_.labelpos.toLowerCase()){case"l":O=-_.width/2;break;case"r":O=_.width/2;break}if(O&&(E+=x?O:-O),O=0,E+=(_.dummy?v:b)/2,E+=(k.dummy?v:b)/2,E+=k.width/2,e.has(k,"labelpos"))switch(k.labelpos.toLowerCase()){case"l":O=k.width/2;break;case"r":O=-k.width/2;break}return O&&(E+=x?O:-O),O=0,E}}function g(b,v){return b.node(v).width}return Kl}var Jl,om;function lj(){if(om)return Jl;om=1;var e=st(),r=kt(),t=cj().positionX;Jl=n;function n(o){o=r.asNonCompoundGraph(o),i(o),e.forEach(t(o),function(s,a){o.node(a).x=s})}function i(o){var s=r.buildLayerMatrix(o),a=o.graph().ranksep,c=0;e.forEach(s,function(l){var d=e.max(e.map(l,function(u){return o.node(u).height}));e.forEach(l,function(u){o.node(u).y=c+d/2}),c+=d+a})}return Jl}var Zl,im;function dj(){if(im)return Zl;im=1;var e=st(),r=GS(),t=US(),n=KS(),i=kt().normalizeRanks,o=JS(),s=kt().removeEmptyRanks,a=ZS(),c=XS(),l=YS(),d=sj(),u=lj(),h=kt(),p=Bt().Graph;Zl=y;function y(q,F){var U=F&&F.debugTiming?h.time:h.notime;U("layout",function(){var D=U(" buildLayoutGraph",function(){return E(q)});U(" runLayout",function(){m(D,U)}),U(" updateInputGraph",function(){g(q,D)})})}function m(q,F){F(" makeSpaceForEdgeLabels",function(){O(q)}),F(" removeSelfEdges",function(){ie(q)}),F(" acyclic",function(){r.run(q)}),F(" nestingGraph.run",function(){a.run(q)}),F(" rank",function(){n(h.asNonCompoundGraph(q))}),F(" injectEdgeLabelProxies",function(){T(q)}),F(" removeEmptyRanks",function(){s(q)}),F(" nestingGraph.cleanup",function(){a.cleanup(q)}),F(" normalizeRanks",function(){i(q)}),F(" assignRankMinMax",function(){P(q)}),F(" removeEdgeLabelProxies",function(){I(q)}),F(" normalize.run",function(){t.run(q)}),F(" parentDummyChains",function(){o(q)}),F(" addBorderSegments",function(){c(q)}),F(" order",function(){d(q)}),F(" insertSelfEdges",function(){ae(q)}),F(" adjustCoordinateSystem",function(){l.adjust(q)}),F(" position",function(){u(q)}),F(" positionSelfEdges",function(){te(q)}),F(" removeBorderNodes",function(){J(q)}),F(" normalize.undo",function(){t.undo(q)}),F(" fixupEdgeLabelCoords",function(){N(q)}),F(" undoCoordinateSystem",function(){l.undo(q)}),F(" translateGraph",function(){R(q)}),F(" assignNodeIntersects",function(){$(q)}),F(" reversePoints",function(){M(q)}),F(" acyclic.undo",function(){r.undo(q)})}function g(q,F){e.forEach(q.nodes(),function(U){var D=q.node(U),de=F.node(U);D&&(D.x=de.x,D.y=de.y,F.children(U).length&&(D.width=de.width,D.height=de.height))}),e.forEach(q.edges(),function(U){var D=q.edge(U),de=F.edge(U);D.points=de.points,e.has(de,"x")&&(D.x=de.x,D.y=de.y)}),q.graph().width=F.graph().width,q.graph().height=F.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],v={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},x=["acyclicer","ranker","rankdir","align"],w=["width","height"],C={width:0,height:0},j=["minlen","weight","width","height","labeloffset"],_={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},k=["labelpos"];function E(q){var F=new p({multigraph:!0,compound:!0}),U=me(q.graph());return F.setGraph(e.merge({},v,he(U,b),e.pick(U,x))),e.forEach(q.nodes(),function(D){var de=me(q.node(D));F.setNode(D,e.defaults(he(de,w),C)),F.setParent(D,q.parent(D))}),e.forEach(q.edges(),function(D){var de=me(q.edge(D));F.setEdge(D,e.merge({},_,he(de,j),e.pick(de,k)))}),F}function O(q){var F=q.graph();F.ranksep/=2,e.forEach(q.edges(),function(U){var D=q.edge(U);D.minlen*=2,D.labelpos.toLowerCase()!=="c"&&(F.rankdir==="TB"||F.rankdir==="BT"?D.width+=D.labeloffset:D.height+=D.labeloffset)})}function T(q){e.forEach(q.edges(),function(F){var U=q.edge(F);if(U.width&&U.height){var D=q.node(F.v),de=q.node(F.w),Q={rank:(de.rank-D.rank)/2+D.rank,e:F};h.addDummyNode(q,"edge-proxy",Q,"_ep")}})}function P(q){var F=0;e.forEach(q.nodes(),function(U){var D=q.node(U);D.borderTop&&(D.minRank=q.node(D.borderTop).rank,D.maxRank=q.node(D.borderBottom).rank,F=e.max(F,D.maxRank))}),q.graph().maxRank=F}function I(q){e.forEach(q.nodes(),function(F){var U=q.node(F);U.dummy==="edge-proxy"&&(q.edge(U.e).labelRank=U.rank,q.removeNode(F))})}function R(q){var F=Number.POSITIVE_INFINITY,U=0,D=Number.POSITIVE_INFINITY,de=0,Q=q.graph(),oe=Q.marginx||0,ce=Q.marginy||0;function we(Se){var ye=Se.x,pe=Se.y,B=Se.width,G=Se.height;F=Math.min(F,ye-B/2),U=Math.max(U,ye+B/2),D=Math.min(D,pe-G/2),de=Math.max(de,pe+G/2)}e.forEach(q.nodes(),function(Se){we(q.node(Se))}),e.forEach(q.edges(),function(Se){var ye=q.edge(Se);e.has(ye,"x")&&we(ye)}),F-=oe,D-=ce,e.forEach(q.nodes(),function(Se){var ye=q.node(Se);ye.x-=F,ye.y-=D}),e.forEach(q.edges(),function(Se){var ye=q.edge(Se);e.forEach(ye.points,function(pe){pe.x-=F,pe.y-=D}),e.has(ye,"x")&&(ye.x-=F),e.has(ye,"y")&&(ye.y-=D)}),Q.width=U-F+oe,Q.height=de-D+ce}function $(q){e.forEach(q.edges(),function(F){var U=q.edge(F),D=q.node(F.v),de=q.node(F.w),Q,oe;U.points?(Q=U.points[0],oe=U.points[U.points.length-1]):(U.points=[],Q=de,oe=D),U.points.unshift(h.intersectRect(D,Q)),U.points.push(h.intersectRect(de,oe))})}function N(q){e.forEach(q.edges(),function(F){var U=q.edge(F);if(e.has(U,"x"))switch((U.labelpos==="l"||U.labelpos==="r")&&(U.width-=U.labeloffset),U.labelpos){case"l":U.x-=U.width/2+U.labeloffset;break;case"r":U.x+=U.width/2+U.labeloffset;break}})}function M(q){e.forEach(q.edges(),function(F){var U=q.edge(F);U.reversed&&U.points.reverse()})}function J(q){e.forEach(q.nodes(),function(F){if(q.children(F).length){var U=q.node(F),D=q.node(U.borderTop),de=q.node(U.borderBottom),Q=q.node(e.last(U.borderLeft)),oe=q.node(e.last(U.borderRight));U.width=Math.abs(oe.x-Q.x),U.height=Math.abs(de.y-D.y),U.x=Q.x+U.width/2,U.y=D.y+U.height/2}}),e.forEach(q.nodes(),function(F){q.node(F).dummy==="border"&&q.removeNode(F)})}function ie(q){e.forEach(q.edges(),function(F){if(F.v===F.w){var U=q.node(F.v);U.selfEdges||(U.selfEdges=[]),U.selfEdges.push({e:F,label:q.edge(F)}),q.removeEdge(F)}})}function ae(q){var F=h.buildLayerMatrix(q);e.forEach(F,function(U){var D=0;e.forEach(U,function(de,Q){var oe=q.node(de);oe.order=Q+D,e.forEach(oe.selfEdges,function(ce){h.addDummyNode(q,"selfedge",{width:ce.label.width,height:ce.label.height,rank:oe.rank,order:Q+ ++D,e:ce.e,label:ce.label},"_se")}),delete oe.selfEdges})})}function te(q){e.forEach(q.nodes(),function(F){var U=q.node(F);if(U.dummy==="selfedge"){var D=q.node(U.e.v),de=D.x+D.width/2,Q=D.y,oe=U.x-de,ce=D.height/2;q.setEdge(U.e,U.label),q.removeNode(F),U.label.points=[{x:de+2*oe/3,y:Q-ce},{x:de+5*oe/6,y:Q-ce},{x:de+oe,y:Q},{x:de+5*oe/6,y:Q+ce},{x:de+2*oe/3,y:Q+ce}],U.label.x=U.x,U.label.y=U.y}})}function he(q,F){return e.mapValues(e.pick(q,F),Number)}function me(q){var F={};return e.forEach(q,function(U,D){F[D.toLowerCase()]=U}),F}return Zl}var Xl,am;function uj(){if(am)return Xl;am=1;var e=st(),r=kt(),t=Bt().Graph;Xl={debugOrdering:n};function n(i){var o=r.buildLayerMatrix(i),s=new t({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 l="layer"+c;s.setNode(l,{rank:"same"}),e.reduce(a,function(d,u){return s.setEdge(d,u,{style:"invis"}),u})}),s}return Xl}var Yl,sm;function fj(){return sm||(sm=1,Yl="0.8.5"),Yl}var Ql,cm;function hj(){return cm||(cm=1,Ql={graphlib:Bt(),layout:dj(),debug:uj(),util:{time:kt().time,notime:kt().notime},version:fj()}),Ql}var pj=hj();const lm=Yw(pj);function gj(e,r,t){var d;const n=new Set(e.map(u=>u.id)),i=new Set;for(const u of e)u.parent&&n.has(u.parent)&&i.add(u.parent);const o=new lm.graphlib.Graph({multigraph:!0,compound:!0}),s=t.compactSpacingScale??(t.spacingFactor>0?t.spacingFactor/1.3:1);o.setGraph({rankdir:t.rankDir,nodesep:t.compact?Math.max(t.nodeSep,24*s):t.nodeSep,edgesep:t.compact?Math.min(t.edgeSep,24*s):t.edgeSep,ranksep:t.compact?Math.min(t.rankSep,80*s):t.rankSep,ranker:"network-simplex"}),o.setDefaultEdgeLabel(()=>({})),o.setDefaultNodeLabel(()=>({}));for(const u of e)o.setNode(u.id,{width:u.width+2,height:u.height+2});for(const u of e)u.parent&&n.has(u.parent)&&o.setParent(u.id,u.parent);for(const u of r){if(!n.has(u.source)||!n.has(u.target)||i.has(u.source)||i.has(u.target))continue;const h=Ob(u.label,u.icon??((d=u.data)==null?void 0:d.icon),t.edgeLabelFontSize),p=t.rankDir==="LR"||t.rankDir==="RL",y=(h.width?h.width+2*Tb:0)+(u.connectorClearance??0);o.setEdge(u.source,u.target,{minlen:1,weight:1,...y?{width:p?y:Math.max(1,h.height),height:p?Math.max(1,h.height):y,labelpos:"c"}:{}},u.id)}lm.layout(o);const a=new Map;for(const u of e){if(i.has(u.id))continue;const h=o.node(u.id);h&&Number.isFinite(h.x)&&Number.isFinite(h.y)&&a.set(u.id,{x:h.x,y:h.y})}const c=t.compact?1:t.spacingFactor;if(c&&c!==1&&a.size){let u=1/0,h=1/0,p=-1/0,y=-1/0;a.forEach(b=>{u=Math.min(u,b.x),h=Math.min(h,b.y),p=Math.max(p,b.x),y=Math.max(y,b.y)});const m=(u+p)/2,g=(h+y)/2;a.forEach((b,v)=>a.set(v,{x:m+(b.x-m)*c,y:g+(b.y-g)*c}))}const l=t.nodeAlignment??"center";if(l!=="center"){const u=t.rankDir==="LR"||t.rankDir==="RL",h=u?"x":"y",p=u?"width":"height",y=t.rankDir==="RL"||t.rankDir==="BT"?-1:1,m=l==="leading"?-y:y,g=new Map;for(const b of e){const v=a.get(b.id);if(!v)continue;const x=v[h];g.set(x,Math.max(g.get(x)??0,b[p]))}for(const b of e){const v=a.get(b.id);if(!v)continue;const x=v[h],w=(g.get(x)-b[p])/2;a.set(b.id,{...v,[h]:x+m*w})}}return a}function dd(e,r,t,n,i,o){const s=new Map,a=new Map(e.map(u=>[u.id,u]));for(const u of e){if(!u.parent||!a.has(u.parent))continue;const h=s.get(u.parent);h?h.push(u.id):s.set(u.parent,[u.id])}const c=(u,h=new Set)=>{var y;const p=(y=a.get(u))==null?void 0:y.parent;return!p||!a.has(p)||h.has(u)?0:(h.add(u),1+c(p,h))},l=[...s.keys()].sort((u,h)=>c(h)-c(u)),d=new Map;for(const u of l){const h=o==null?void 0:o.get(u),p=r.get(u);if(h&&p){d.set(u,{x1:p.x-h.w/2,y1:p.y-h.h/2,x2:p.x+h.w/2,y2:p.y+h.h/2});continue}let y=null;for(const b of s.get(u)||[]){let v=d.get(b);if(!v){const x=r.get(b);if(!x)continue;const w=t.get(b)||{w:60,h:60};v={x1:x.x-w.w/2,y1:x.y-w.h/2,x2:x.x+w.w/2,y2:x.y+w.h/2}}y=y?{x1:Math.min(y.x1,v.x1),y1:Math.min(y.y1,v.y1),x2:Math.max(y.x2,v.x2),y2:Math.max(y.y2,v.y2)}:{...v}}if(!y)continue;const m=n(u);y={x1:y.x1-m,y1:y.y1-m,x2:y.x2+m,y2:y.y2+m};const g=i(u);if(g){const b=y.x2-y.x1,v=y.y2-y.y1;if(g.w>b){const x=(g.w-b)/2;y.x1-=x,y.x2+=x}if(g.h>v){const x=(g.h-v)/2;y.y1-=x,y.y2+=x}}d.set(u,y)}return d}function dm(e,r,t){var c,l,d;const n=[...r.weights],i=n.reduce((u,h)=>u+h,0),o=n[r.index]+n[r.index+1],s=Math.min(o*.95,Math.max(o*.05,n[r.index]+t/r.length*i));n[r.index]=s,n[r.index+1]=o-s;const a={...(l=(c=e.adjustment)==null?void 0:c.sections)==null?void 0:l[r.section]};if(r.axis==="y")a.rows=n;else{for(a.columns=[...a.columns??[]];a.columns.length<=r.row;)a.columns.push([]);a.columns[r.row]=n}return{...e,adjustment:{...e.adjustment,sections:{...(d=e.adjustment)==null?void 0:d.sections,[r.section]:a}}}}function $v(e){if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e)||e.enabled!==void 0&&typeof e.enabled!="boolean")throw new RangeError("Invalid grid adjustment.");const r=t=>Array.isArray(t)&&t.length<=1e4&&t.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1e6);if(e.sections!==void 0&&(!e.sections||typeof e.sections!="object"||Array.isArray(e.sections)))throw new RangeError("Invalid grid sections.");for(const[t,n]of Object.entries(e.sections??{}))if(["__proto__","constructor","prototype"].includes(t)||!n||typeof n!="object"||Array.isArray(n)||n.rows!==void 0&&!r(n.rows)||n.columns!==void 0&&(!Array.isArray(n.columns)||n.columns.length>1e4||!n.columns.every(r)))throw new RangeError("Invalid grid section proportions.")}function Xd(e){const r=e.margin??15;if(!Number.isFinite(r)||r<0)throw new RangeError("Collision margin must be finite and non-negative.");return r}function Eo(e){const r=new Map(e.nodes.map(a=>[a.id,a])),t=new Map;for(const a of e.nodes){const c=a.parent&&r.has(a.parent)?a.parent:void 0,l=t.get(c)??[];l.push(a.id),t.set(c,l)}const n=[],i=new Map,o=a=>{const c=t.get(a),l=c?c.flatMap(o):e.positions.has(a)?[a]:[];return i.set(a,l),c&&n.push(c),l},s=t.get(void 0)??[];return s.forEach(o),n.push(s),{groups:n,leaves:i,children:t,roots:s}}function _r(e,r,t=e.fixedSizes){const n=dd(e.nodes,r,e.sizes,e.padding,e.minSize,t);for(const i of e.nodes){if(n.has(i.id))continue;const o=r.get(i.id),s=e.sizes.get(i.id);o&&s&&n.set(i.id,Xt({...o,...s}))}return n}function qv(e,r,t,n){const i=t.get(e),o=t.get(r);if(!i||!o)return;const s={x:Math.min(i.x2-o.x1,o.x2-i.x1)+n,y:Math.min(i.y2-o.y1,o.y2-i.y1)+n};if(s.x>.001&&s.y>.001)return{source:e,target:r,overlap:s}}function kn(e,r,t){const n=[];for(const i of e)for(let o=0;o<i.length;o++)for(let s=o+1;s<i.length;s++){const a=qv(i[o],i[s],r,t);a&&n.push(a)}return n}function Lv(e,r={}){const t=Xd(r),{groups:n}=Eo(e);return kn(n,_r(e,e.positions),t)}function ed(e,r={}){$v(r.adjustment);const t=Xd(r),n=typeof r.gaps=="object"?r.gaps:{x:r.gaps??t,y:r.gaps??t};if(!n||[n.x,n.y].some(d=>!Number.isFinite(d)||d<0))throw new RangeError("Grid gaps must be finite and non-negative.");const i=r.padding??0;if(!Number.isFinite(i)||i<0)throw new RangeError("Grid padding must be finite and non-negative.");if(r.columns!==void 0&&(!Number.isSafeInteger(r.columns)||r.columns<1))throw new RangeError("Grid columns must be a positive safe integer.");if(r.fill&&e.viewportSize)return yj(e,r,n,i);const{groups:o,leaves:s}=Eo(e),a=new Map([...e.positions].map(([d,u])=>[d,{...u}])),c=new Set;for(const d of o){const u=_r(e,a),h=d.filter(k=>u.has(k));if(h.length<2)continue;if(h.some(k=>e.fixedIds.has(k)||(s.get(k)??[]).some(E=>e.fixedIds.has(E)))){h.forEach(k=>c.add(k));continue}const y=h.map(k=>u.get(k)),m=Math.max(...y.map(k=>k.x2-k.x1)),g=Math.max(...y.map(k=>k.y2-k.y1)),b=Math.min(h.length,r.columns??Math.ceil(Math.sqrt(h.length))),v=Math.ceil(h.length/b),x=m+n.x,w=g+n.y,C=y.map(k=>({x:(k.x1+k.x2)/2,y:(k.y1+k.y2)/2})),j=(Math.min(...C.map(k=>k.x))+Math.max(...C.map(k=>k.x)))/2,_=(Math.min(...C.map(k=>k.y))+Math.max(...C.map(k=>k.y)))/2;h.forEach((k,E)=>{const O=u.get(k),T={x:j+(E%b-(b-1)/2)*x-(O.x1+O.x2)/2,y:_+(Math.floor(E/b)-(v-1)/2)*w-(O.y1+O.y2)/2};for(const P of s.get(k)??[]){const I=a.get(P);a.set(P,{x:I.x+T.x,y:I.y+T.y})}})}const l=[...a].filter(([d,u])=>{const h=e.positions.get(d);return u.x!==h.x||u.y!==h.y}).map(([d])=>d);return{positions:a,movedNodeIds:l,skippedNodeIds:[...c],collisions:kn(o,_r(e,a),Math.min(n.x,n.y))}}function yj(e,r,t,n){const{groups:i,children:o,roots:s}=Eo(e),a=new Map([...e.positions].map(([g,b])=>[g,{...b}]));if(e.nodes.some(g=>e.fixedIds.has(g.id)))return{positions:a,movedNodeIds:[],skippedNodeIds:e.nodes.map(g=>g.id),collisions:Lv(e,{margin:Math.min(t.x,t.y)})};const c=e.viewportSize,l=Math.min(n,Math.max(0,(c.w-1)/2)),d=Math.min(n,Math.max(0,(c.h-1)/2)),u={x1:l,y1:d,x2:Math.max(l+1,c.w-l),y2:Math.max(d+1,c.h-d)},h=new Map,p=[],y=(g,b,v="canvas")=>{var I,R;if(!g.length)return;const x=b.x2-b.x1,w=b.y2-b.y1,C=Math.min(g.length,r.columns??Math.max(1,Math.round(Math.sqrt(g.length*x/w)))),j=Math.ceil(g.length/C),_=Math.min(t.y,w/(2*j)),k=(R=(I=r.adjustment)==null?void 0:I.sections)==null?void 0:R[v],E=Array.from({length:j},($,N)=>{var M;return((M=k==null?void 0:k.rows)==null?void 0:M[N])??1}),O=E.reduce(($,N)=>$+N,0),T=w-(j-1)*_;let P=b.y1;for(let $=0;$<j;$++){const N=T*E[$]/O,M=Math.min(C,g.length-$*C),J=Math.min(t.x,x/(2*M)),ie=Array.from({length:M},(me,q)=>{var F,U;return((U=(F=k==null?void 0:k.columns)==null?void 0:F[$])==null?void 0:U[q])??1}),ae=ie.reduce((me,q)=>me+q,0),te=x-(M-1)*J;let he=b.x1;for(let me=0;me<M;me++){const q=g[$*C+me],F=te*ie[me]/ae,U=o.get(q);if(U){a.set(q,{x:he+F/2,y:P+N/2}),h.set(q,{w:F,h:N});const D=Math.min(e.padding(q),Math.max(0,(Math.min(F,N)-1)/2));y(U,{x1:he+D,y1:P+D,x2:he+F-D,y2:P+N-D},q)}else a.has(q)&&(a.set(q,{x:he+F/2,y:P+N/2}),h.set(q,{w:F,h:N}));me<M-1&&p.push({section:v,axis:"x",row:$,index:me,weights:ie,length:te,position:{x:he+F+J/2,y:P+N/2}}),he+=F+J}$<j-1&&p.push({section:v,axis:"y",row:$,index:$,weights:E,length:T,position:{x:b.x1+x/2,y:P+N+_/2}}),P+=N+_}};y(s,u);const m=[...a].filter(([g,b])=>{const v=e.positions.get(g);return!v||b.x!==v.x||b.y!==v.y}).map(([g])=>g);return{positions:a,movedNodeIds:m,skippedNodeIds:[],bounds:u,sizes:h,dividers:p,collisions:kn(i,_r({...e,sizes:h},a,h),0)}}function mj(e,r={}){const t=Xd(r),n=r.maxIterations??50;if(!Number.isInteger(n)||n<0||n>1e3)throw new RangeError("Collision maxIterations must be an integer between 0 and 1000.");const{groups:i,leaves:o}=Eo(e),s=new Map([...e.positions].map(([u,h])=>[u,{...h}])),a=u=>e.fixedIds.has(u)||(o.get(u)??[]).some(h=>e.fixedIds.has(h));let c=kn(i,_r(e,s),t),l=0;for(;c.length&&l<n;){let u=!1;for(const h of i){if(h.length<2)continue;const p=_r(e,s),y=(m,g,b)=>{for(const x of o.get(m)??[])s.get(x)[g]+=b;const v=p.get(m);g==="x"?(v.x1+=b,v.x2+=b):(v.y1+=b,v.y2+=b)};for(let m=0;m<h.length;m++)for(let g=m+1;g<h.length;g++){const b=h[m],v=h[g],x=qv(b,v,p,t);if(!x)continue;const w=a(b),C=a(v);if(w&&C)continue;const j=x.overlap.x<=x.overlap.y?"x":"y",_=p.get(b),k=p.get(v),E=j==="x"?_.x1+_.x2<=k.x1+k.x2?-1:1:_.y1+_.y2<=k.y1+k.y2?-1:1,O=x.overlap[j];w||y(b,j,E*O/(C?1:2)),C||y(v,j,-E*O/(w?1:2)),u=!0}}if(l++,c=kn(i,_r(e,s),t),!u)break}const d=[...s].filter(([u,h])=>{const p=e.positions.get(u);return h.x!==p.x||h.y!==p.y}).map(([u])=>u);return{positions:s,movedNodeIds:d,collisions:c,iterations:l,resolved:c.length===0}}function bj({dividers:e,options:r,zoom:t,onChange:n}){const i=S.useRef();return f.jsx(f.Fragment,{children:e.map(o=>{const s=o.axis==="x",a=s?X.PiArrowsHorizontal:X.PiArrowsVertical,c=`${s?"Column":"Row"} divider ${o.index+1}${s?` in row ${o.row+1}`:""}`;return f.jsx("button",{type:"button",role:"separator","aria-label":c,"aria-orientation":s?"vertical":"horizontal","aria-valuemin":5,"aria-valuemax":95,"aria-valuenow":Math.round(100*o.weights[o.index]/(o.weights[o.index]+o.weights[o.index+1])),title:c,"data-flow-grid-adjustment":"",style:{position:"absolute",left:o.position.x,top:o.position.y,transform:"translate(-50%, -50%)",width:28,height:28,padding:3,border:"1px solid currentColor",borderRadius:4,background:"var(--chakra-colors-gray-100)",color:"var(--chakra-colors-gray-800)",display:"grid",placeItems:"center",cursor:s?"col-resize":"row-resize",touchAction:"none",pointerEvents:"auto",zIndex:30},onPointerDown:l=>{if(l.button!==0)return;l.preventDefault(),l.stopPropagation();const d=l.currentTarget.closest(".flow-sdk-canvas"),u=d.getBoundingClientRect();i.current={pointerId:l.pointerId,start:s?l.clientX:l.clientY,scale:t*(s?u.width/d.clientWidth:u.height/d.clientHeight),divider:o,options:r},l.currentTarget.setPointerCapture(l.pointerId)},onPointerMove:l=>{const d=i.current;if(!d||d.pointerId!==l.pointerId)return;l.preventDefault(),l.stopPropagation();const u=((s?l.clientX:l.clientY)-d.start)/d.scale;n(dm(d.options,d.divider,u))},onPointerUp:l=>{i.current&&(l.stopPropagation(),i.current=void 0,l.currentTarget.releasePointerCapture(l.pointerId))},onPointerCancel:()=>{i.current&&n(i.current.options),i.current=void 0},onLostPointerCapture:()=>{i.current=void 0},onClick:l=>l.stopPropagation(),onKeyDown:l=>{l.key==="Escape"&&i.current&&(n(i.current.options),i.current=void 0);const d=(s?["ArrowLeft","ArrowRight"]:["ArrowUp","ArrowDown"]).indexOf(l.key);d<0||(l.preventDefault(),l.stopPropagation(),n(dm(r,o,o.length*(l.shiftKey?.1:.02)*(d===0?-1:1))))},children:f.jsx(a,{size:20,"aria-hidden":"true"})},`${o.section}:${o.axis}:${o.row}:${o.index}`)})})}const um=(e,r)=>e.left<r.right&&e.right>r.left&&e.top<r.bottom&&e.bottom>r.top;function vj(e){const r=e.querySelector(".flow-sdk-labels"),t=r==null?void 0:r.getScreenCTM();if(!r||!t)return;const n=t.inverse(),i=(l,d=0)=>{const u=l.getBoundingClientRect(),h=new DOMPoint(u.left,u.top).matrixTransform(n),p=new DOMPoint(u.right,u.bottom).matrixTransform(n);return{left:h.x-d,right:p.x+d,top:h.y-d,bottom:p.y+d}},o=[...e.querySelectorAll(".flow-sdk-node, .flow-sdk-node button")].filter(l=>{const d=l.getBoundingClientRect(),u=getComputedStyle(l);return d.width>0&&d.height>0&&u.visibility!=="hidden"&&u.opacity!=="0"}).map(l=>i(l,24));for(const l of r.querySelectorAll(".flow-sdk-container-label"))o.push(i(l,12));const s=[...r.querySelectorAll(".flow-sdk-edge-label")];for(const l of s)l.setAttribute("transform",l.dataset.labelTransform??"");const a=new Map(s.map(l=>[l,i(l,8)])),c=new Map([...e.querySelectorAll(".flow-sdk-edge")].map(l=>[l.dataset.edgeId,l.querySelector("path")]));for(const l of s){const d=l.dataset.labelHorizontal==="true",u=a.get(l);a.delete(l);const h=_=>o.some(k=>um(_,k))||[...a.values()].some(k=>um(_,k));if(!d&&!h(u)){a.set(l,u);continue}const p=c.get(l.dataset.edgeId),y=l.querySelector("rect");if(!p||!y)continue;const m=y.getBBox(),g=p.getTotalLength();if(!Number.isFinite(g)||g<=0)continue;const b=(u.left+u.right)/2,v=(u.top+u.bottom)/2,x=Math.min(256,Math.max(16,Math.ceil(g/24))),w=Array.from({length:x+1},(_,k)=>p.getPointAtLength(g*k/x)),j=Array.from({length:x+1},(_,k)=>{const E=g*k/x,O=w[k],T=d?{x:O.x,y:O.y-m.height/2-15}:O,P=p.getPointAtLength(Math.max(0,E-2)),I=p.getPointAtLength(Math.min(g,E+2));let R=Math.atan2(I.y-P.y,I.x-P.x)*180/Math.PI;R>90&&(R-=180),R<-90&&(R+=180);const $=Math.abs(R)<1;d&&(R=0);const N=R*Math.PI/180,M=Math.abs(Math.cos(N))*m.width+Math.abs(Math.sin(N))*m.height,J=Math.abs(Math.sin(N))*m.width+Math.abs(Math.cos(N))*m.height;return{point:T,angle:R,straight:$,score:Math.hypot(T.x-b,T.y-v),bounds:{left:T.x-M/2-8,right:T.x+M/2+8,top:T.y-J/2-8,bottom:T.y+J/2+8}}}).sort((_,k)=>_.score-k.score).find(_=>!h(_.bounds)&&(!d||_.straight&&!w.some(k=>k.x>_.bounds.left&&k.x<_.bounds.right&&k.y>_.bounds.top&&k.y<_.bounds.bottom)));j?(l.setAttribute("transform",`translate(${j.point.x} ${j.point.y}) rotate(${j.angle})`),a.set(l,j.bounds)):a.set(l,u)}}function xj(e){const r=e.getBoundingClientRect(),t=r.height/e.offsetHeight;if(!Number.isFinite(t)||t<=0)return[];const n=Ib(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 d=kb(n?wn(i,n):i,c,Number(a.dataset.flowPortPosition??.5));return[{property:a.getAttribute("data-flow-property"),top:d.y,height:0,anchor:d,...a.dataset.flowPortPlacement==="config"?{placement:"config"}:{},...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]}const l=a.getBoundingClientRect();return!l.width||!l.height?[]:[{property:a.getAttribute("data-flow-property"),top:Math.round((l.top-r.top)/t*1e3)/1e3,height:Math.round(l.height/t*1e3)/1e3,...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]})}function wj({id:e,x:r,y:t,placed:n,hidden:i,gridDraggable:o,gridDragging:s,gridDropTarget:a,gridSize:c,gridPreview:l,onMount:d,drawHandles:u,drawMode:h,connectedPorts:p,resolvedRows:y,hasCollapseControl:m,handleColor:g,animated:b,animationColor:v,animationWidth:x=8,animationVariant:w,width:C=0,height:j=0,propertyMode:_,reversePorts:k,direction:E="LR",onPropertyRows:O,onSurface:T,children:P}){var D,de;const I=S.useRef(null),[R,$]=S.useState([]),N=y??R,[M,J]=S.useState(),ie=S.useId(),ae=S.useRef(),te=!!l,he=!!(l!=null&&l.floating);S.useLayoutEffect(()=>{var Se;const Q=I.current;if(!Q||!te)return;const oe=Q.cloneNode(!0);oe.removeAttribute("data-node-id"),oe.removeAttribute("data-grid-dragging"),oe.removeAttribute("data-grid-draggable"),oe.removeAttribute("data-grid-drop-target"),oe.setAttribute("data-grid-preview",e),oe.setAttribute("aria-hidden","true"),oe.setAttribute("inert","");const ce=[oe,...oe.querySelectorAll("*")],we=new Map(ce.filter(ye=>ye.id).map(ye=>[ye.id,`${ye.id}-${ie}`]));for(const ye of ce){ye.id&&(ye.id=we.get(ye.id));for(const pe of[...ye.attributes]){if(pe.name==="id")continue;let B=pe.value;for(const[G,se]of we)B===`#${G}`&&(B=`#${se}`),B=B.split(`url(#${G})`).join(`url(#${se})`);B!==pe.value&&ye.setAttribute(pe.name,B)}}if(Object.assign(oe.style,{opacity:"0.35",zIndex:he?"2147483647":"11",pointerEvents:"none",outline:"none",visibility:"visible"}),he){const ye=getComputedStyle(Q);oe.setAttribute("data-grid-preview-floating",""),Object.assign(oe.style,{position:"fixed",left:"0",top:"0",transformOrigin:"top left",font:ye.font,color:ye.color});for(const pe of ce)pe.removeAttribute("data-node-id"),pe.style.pointerEvents="none"}return oe.querySelectorAll(".flow-sdk-node-animation, .flow-sdk-handle, .flow-sdk-property-port, [data-flow-collapse-control]").forEach(ye=>ye.remove()),(Se=he?document.body:Q.parentElement)==null||Se.appendChild(oe),ae.current=oe,()=>{oe.remove(),ae.current=void 0}},[e,ie,te,he]),S.useLayoutEffect(()=>{const Q=ae.current;if(!Q||!l)return;const{x:oe,y:ce,size:we}=l;if(he&&I.current){const pe=I.current,B=pe.getBoundingClientRect(),G=B.width/pe.offsetWidth||1,se=B.height/pe.offsetHeight||1,H=B.left+(oe-r)*G,ue=B.top+(ce-t)*se;Q.style.transform=`translate3d(${H}px, ${ue}px, 0) scale(${G}, ${se})`,Q.style.width=`${pe.offsetWidth}px`,Q.style.height=`${pe.offsetHeight}px`;return}const Se=we?Math.round(oe-we.w/2):oe,ye=we?Math.round(ce-we.h/2):ce;Q.style.transform=we?`translate3d(${Se}px, ${ye}px, 0)`:`translate(-50%, -50%) translate3d(${Se}px, ${ye}px, 0)`,Q.style.width=we?`${Math.round(oe+we.w/2)-Se}px`:"",Q.style.height=we?`${Math.round(ce+we.h/2)-ye}px`:"",we&&(Q.style.setProperty("--flow-grid-width",`${we.w}px`),Q.style.setProperty("--flow-grid-height",`${we.h}px`),Q.style.setProperty("--flow-grid-font",`${Math.max(12,Math.min(48,we.w/8,we.h/5))}px`))},[l==null?void 0:l.x,l==null?void 0:l.y,(D=l==null?void 0:l.size)==null?void 0:D.w,(de=l==null?void 0:l.size)==null?void 0:de.h,he,r,t]),S.useLayoutEffect(()=>{const Q=I.current;if(!Q)return;const oe=()=>{const Se=Ib(Q);J(ye=>JSON.stringify(ye)===JSON.stringify(Se)?ye:Se),T==null||T(e,Se)};oe();const ce=new ResizeObserver(oe);ce.observe(Q);const we=Q.querySelector("[data-flow-node-surface]");return we&&ce.observe(we),()=>ce.disconnect()},[e,P,T]),S.useLayoutEffect(()=>(d(e,I.current),()=>{d(e,null),T==null||T(e,void 0)}),[e,d,T]),S.useLayoutEffect(()=>{const Q=I.current;if(!Q)return;let oe="";const ce=()=>{const pe=xj(Q),B=_?pe:pe.filter(se=>se.anchor),G=JSON.stringify(B);G!==oe&&(oe=G,$(B),O==null||O(e,B))};if(ce(),!_&&!Q.querySelector("[data-flow-port-side]"))return;const we=new ResizeObserver(ce),Se=()=>{we.disconnect(),we.observe(Q),Q.querySelectorAll("[data-flow-property]").forEach(pe=>we.observe(pe)),ce()};Se();const ye=new MutationObserver(Se);return ye.observe(Q,{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"]}),Q.addEventListener("scroll",ce,!0),()=>{we.disconnect(),ye.disconnect(),Q.removeEventListener("scroll",ce,!0)}},[e,_,O,P]);const me=c?Math.round(r-c.w/2):0,q=c?Math.round(t-c.h/2):0,F=c?Math.round(r+c.w/2)-me:void 0,U=c?Math.round(t+c.h/2)-q:void 0;return f.jsxs("div",{ref:I,className:"flow-sdk-node","data-node-id":e,"data-grid-draggable":o||void 0,"data-grid-dragging":s||void 0,"data-grid-drop-target":a||void 0,"data-grid-fill":c?"":void 0,style:{transform:c?`translate3d(${me}px, ${q}px, 0)`:`translate(-50%, -50%) translate3d(${r.toFixed(2)}px, ${t.toFixed(2)}px, 0)`,visibility:n&&!i?void 0:"hidden",cursor:o?s?"grabbing":"grab":void 0,zIndex:s?12:void 0,opacity:l?0:s?.75:void 0,outline:a?`2px solid ${g||"currentColor"}`:void 0,outlineOffset:a?8:void 0,width:F,height:U,...c?{"--flow-grid-width":`${c.w}px`,"--flow-grid-height":`${c.h}px`,"--flow-grid-font":`${Math.max(12,Math.min(48,c.w/8,c.h/5))}px`}:{}},children:[P,!c&&b&&x>0&&C>0&&j>0&&f.jsx("svg",{className:"flow-sdk-node-animation","aria-hidden":"true",pointerEvents:"none",children:f.jsx(Zn,{variant:w,x:((M==null?void 0:M.left)??0)+x/2,y:((M==null?void 0:M.top)??0)+x/2,width:((M==null?void 0:M.width)??C)-x,height:((M==null?void 0:M.height)??j)-x,radius:((M==null?void 0:M.radius)??0)-x/2,path:M!=null&&M.outline?`M${M.outline.map(Q=>`${Q.x} ${Q.y}`).join(" L")} Z`:void 0,color:v||g||"currentColor",strokeWidth:x})}),u&&_&&N.map(Q=>["source","target"].filter(oe=>!Q.role||Q.role===oe).filter(oe=>h||(p==null?void 0:p.has(`${oe}:${Q.property}`))).map(oe=>{var ce;return f.jsx("button",{type:"button",className:"flow-sdk-property-port","data-property":Q.property,"data-port-role":oe,"data-port-side":(ce=Q.anchor)==null?void 0:ce.side,"aria-label":`${oe==="source"?"Connect":"Input"} ${Q.property}`,title:`${oe==="source"?"Connect":"Input"} ${Q.property}`,style:{color:g,...Q.anchor?{top:Q.anchor.y,left:Q.anchor.x-16}:{top:Q.top+Q.height/2,[oe==="source"!=!!k?"right":"left"]:-16}},onClick:we=>we.stopPropagation()},`${Q.property}:${oe}`)})),u&&!m&&(!_||!N.length)&&(!_||!N.some(Q=>Q.anchor))&&f.jsx("button",{type:"button",className:"flow-sdk-handle","aria-label":"Draw edge",title:"Draw edge",style:{color:g,left:((M==null?void 0:M.left)??0)+(E==="RL"?-36:E==="LR"?(M==null?void 0:M.width)??C:((M==null?void 0:M.width)??C)/2),top:((M==null?void 0:M.top)??0)+(E==="BT"?-36:E==="TB"?(M==null?void 0:M.height)??j:((M==null?void 0:M.height)??j)/2),transform:E==="BT"||E==="TB"?"translateX(-50%)":"translateY(-50%)"},onClick:Q=>Q.stopPropagation(),children:f.jsx(X.PiPlusBold,{size:24})})]})}const Cj=S.memo(wj);function Sj(e,r,t){const[n,i]=S.useState(()=>({nodes:new Set,edges:new Set})),o=S.useMemo(()=>{const a=new Set(e.map(p=>p.id)),c=r.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})),l=new Set(c.map(p=>p.id)),d=new Set([...n.nodes].filter(p=>a.has(p))),u=new Set([...n.edges].filter(p=>l.has(p)));if(!t)return{nodes:a,edges:l,ready:l};for(const p of e)c.filter(m=>m.target===p.id&&m.source!==m.target).every(m=>u.has(m.id))&&d.add(p.id);let h=new Set(c.filter(p=>d.has(p.source)).map(p=>p.id));if(d.size<a.size&&!c.some(p=>h.has(p.id)&&!u.has(p.id))){const p=e.find(y=>!d.has(y.id));p&&d.add(p.id),h=new Set(c.filter(y=>d.has(y.source)).map(y=>y.id))}return{nodes:d,edges:u,ready:h}},[e,r,t,n]);S.useLayoutEffect(()=>{i(a=>{const c=t?o:{nodes:new Set,edges:new Set},l=(d,u)=>d.size===u.size&&[...d].every(h=>u.has(h));return l(a.nodes,c.nodes)&&l(a.edges,c.edges)?a:{nodes:c.nodes,edges:c.edges}})},[o,t]);const s=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 jj{constructor(r,t,n){Mt(this,"_pan");Mt(this,"_zoom");Mt(this,"minZoom");Mt(this,"maxZoom");Mt(this,"size",{w:0,h:0});Mt(this,"listeners",new Set);Mt(this,"cancelTransition");Mt(this,"animationVersion",0);Mt(this,"captureTransition");Mt(this,"animationsDisabled",!1);Mt(this,"finishTransition");this.minZoom=t,this.maxZoom=n,this._pan={...r.pan},this._zoom=this.clamp(r.zoom)}setAnimationsDisabled(r){var t;r!==this.animationsDisabled&&(this.animationsDisabled=r,r&&((t=this.finishTransition)==null||t.call(this),this.cancelAnimation()))}cancelAnimation(){var r;(r=this.cancelTransition)==null||r.call(this),this.cancelTransition=void 0,this.finishTransition=void 0,this.animationVersion++}coordinate(r){let t;this.captureTransition=n=>{t=n};try{r()}finally{this.captureTransition=void 0}return t}transition(r,t=!1){this.cancelAnimation();const n=this.state,i={pan:{...r.pan},zoom:this.clamp(r.zoom)},o=this.animationVersion,s=Eb(t,this.animationsDisabled),a=c=>{if(o!==this.animationVersion)return;const l=s?c:1;this.apply({x:n.pan.x+(i.pan.x-n.pan.x)*l,y:n.pan.y+(i.pan.y-n.pan.y)*l},n.zoom+(i.zoom-n.zoom)*l)};this.finishTransition=()=>a(1),this.captureTransition?this.captureTransition(a):this.cancelTransition=Rb(s,a,void 0,300/1.4)}get pan(){return{...this._pan}}get zoom(){return this._zoom}get state(){return{pan:this.pan,zoom:this._zoom}}clamp(r){return Number.isFinite(r)?Math.max(this.minZoom,Math.min(this.maxZoom,r)):this.minZoom}set(r,t){this.cancelAnimation(),this.apply(r,t)}apply(r,t){let n=!1;if(r&&(r.x!==this._pan.x||r.y!==this._pan.y)&&(this._pan={x:r.x,y:r.y},n=!0),t!==void 0){const i=this.clamp(t);i!==this._zoom&&(this._zoom=i,n=!0)}n&&this.emit()}zoomAt(r,t){const n=this.clamp(r),i=this._zoom;if(n===i)return;const o=n/i;this.set({x:t.x-(t.x-this._pan.x)*o,y:t.y-(t.y-this._pan.y)*o},n)}fit(r,t=0,n=!1,i=1){const o=r.x2-r.x1,s=r.y2-r.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*t)/o,(this.size.h-2*t)/s))*i);this.transition({pan:{x:(this.size.w-a*(r.x1+r.x2))/2,y:(this.size.h-a*(r.y1+r.y2))/2},zoom:a},n)}center(r,t=!1){if(!this.size.w||!this.size.h)return;const n=this._zoom;this.transition({pan:{x:(this.size.w-n*(r.x1+r.x2))/2,y:(this.size.h-n*(r.y1+r.y2))/2},zoom:n},t)}renderedToModel(r){return{x:(r.x-this._pan.x)/this._zoom,y:(r.y-this._pan.y)/this._zoom}}modelToRendered(r){return{x:r.x*this._zoom+this._pan.x,y:r.y*this._zoom+this._pan.y}}onChange(r){return this.listeners.add(r),()=>{this.listeners.delete(r)}}emit(){const r=this.state;this.listeners.forEach(t=>t(r))}}const _j={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},Wn={w:60,h:60},td=4,Ej=30,Rj=500,kj=45;function fm(e){const[r,t]=[...e.values()];return!r||!t?null:{center:{x:(r.x+t.x)/2,y:(r.y+t.y)/2},distance:Math.max(1,Math.hypot(t.x-r.x,t.y-r.y))}}function Aj(e){var su,cu,lu;const{nodes:r,edges:t,direction:n,nodeAlignment:i="center",edgeMode:o="auto",compactPropertyLayout:s=!1,rankSep:a,edgeSep:c,spacingFactor:l=1.3,compactSpacingScale:d,minZoom:u,maxZoom:h,initialViewport:p,containerStyle:y,lineColor:m,drawMode:g,dragMode:b,multiSelect:v,isPerformanceMode:x,disableAnimations:w=!1}=e,[C,j]=S.useState(null),_=S.useMemo(()=>C?(C.mode==="connections"?Fu:Tu)(C.id,r,t):null,[C,r,t]),k=o==="auto"||o==="properties",E=S.useMemo(()=>t.filter(A=>ld(A,o)&&(!_||_.has(A.source)&&_.has(A.target))),[t,o,_]),O=S.useMemo(()=>Hw(r,t,o,s,_),[r,t,o,s,_]),T=S.useRef(O);T.current=O;const P=S.useRef(e);P.current=e;const I=S.useRef(null),R=S.useRef(null),$=S.useRef(null),N=S.useRef(null),M=S.useMemo(()=>new jj(p,u,h),[]);S.useEffect(()=>{M.minZoom=u,M.maxZoom=h},[M,u,h]),S.useLayoutEffect(()=>{M.setAnimationsDisabled(w)},[M,w]);const J=S.useRef(new Map),ie=S.useRef(new Map),ae=S.useRef(new Map),te=S.useRef(null),[he,me]=S.useState(new Map),q=S.useCallback((A,L)=>{me(V=>{if(JSON.stringify(V.get(A))===JSON.stringify(L))return V;const Y=new Map(V);return L?Y.set(A,L):Y.delete(A),Y})},[]),[F,U]=S.useState(new Map),D=S.useRef(F),de=S.useCallback((A,L)=>{U(V=>{if(JSON.stringify(V.get(A)??[])===JSON.stringify(L))return V;const Y=new Map(V);return L.length?Y.set(A,L):Y.delete(A),Y})},[]),[Q,oe]=S.useState(()=>new Map),ce=S.useRef(Q);ce.current=Q;const[we,Se]=S.useState(new Map),ye=S.useRef(we),pe=()=>{ye.current=new Map,Se(ye.current)},B=S.useRef(new Map),G=S.useRef(null),se=S.useRef(!1),[H,ue]=S.useState(0),xe=S.useRef(),Oe=S.useRef(),Ne=S.useRef(null),Be=S.useRef(!1),et=S.useRef(null),We=S.useRef(null),gt=S.useRef(l),He=s,rt=S.useRef(He),[ft,Pe]=S.useState(!0),[Fe,it]=S.useState(!1),[at,Lt]=S.useState([]),De=S.useRef(null),[Ye,Vt]=S.useState(null),ct=S.useRef(null);ct.current=_;const tr=S.useRef(1);tr.current=(C==null?void 0:C.mode)==="connections"?1.25:1;const Wt=S.useRef(null),Ir=S.useRef(r),Et=S.useRef([]),Gt=S.useRef(!1),Jt=()=>{var A;(A=Ne.current)==null||A.call(Ne),Ne.current=null},Mr=()=>{We.current=null,Et.current.length&&(Gt.current=!0),!se.current&&P.current.fitOnInit!==!1&&(Be.current=!0),clearTimeout(Oe.current),Oe.current=setTimeout(()=>{se.current=ce.current.size>0,ue(A=>A+1)},Rj)},gr=(A,L,V,Y=Mr,le)=>{Jt();const ke=new Map(ce.current),Ce=new Map([...J.current,...ye.current]);Ne.current=Rb(L,Ee=>{const qe=new Map;if(A.forEach((je,Le)=>{const Xe=ke.get(Le);qe.set(Le,Xe?{x:Xe.x+(je.x-Xe.x)*Ee,y:Xe.y+(je.y-Xe.y)*Ee}:je)}),ce.current=qe,oe(qe),le){const je=new Map;for(const[Le,Xe]of le){const ne=Ce.get(Le)??Xe;je.set(Le,{w:ne.w+(Xe.w-ne.w)*Ee,h:ne.h+(Xe.h-ne.h)*Ee})}ye.current=je,Se(je)}V==null||V(Ee)},Y)},Z=()=>{if(clearTimeout(xe.current),De.current){wt.arrangeNodesInGrid(De.current.options);return}ye.current.size&&pe();const A=P.current,L=tr.current,V=T.current,Y=V.nodes.map(qe=>{const je=ie.current.get(qe.id);je&&(je.offsetWidth||je.offsetHeight)&&J.current.set(qe.id,{w:je.offsetWidth,h:je.offsetHeight});const Le=J.current.get(qe.id)||Wn;return{id:qe.id,parent:qe.parent,width:Le.w,height:Le.h}});let le;try{const qe=A.compactPropertyLayout,je=A.edgeMode!=="nodes"&&A.edgeMode!=="workflow",Le=V.edges.map(Xe=>({...Xe,connectorClearance:qe?je&&(Xe.sourceProperty!==void 0||Xe.targetProperty!==void 0)?Uw:Gw:0}));le=gj(Y,Le,{edgeLabelFontSize:A.edgeMode==="nodes"||A.edgeMode==="workflow"?Mb:Xn,rankDir:A.direction,compact:qe,nodeAlignment:A.nodeAlignment,rankSep:A.rankSep*L,edgeSep:A.edgeSep*L,nodeSep:5*L,spacingFactor:A.spacingFactor??1.3,compactSpacingScale:(A.compactSpacingScale??(A.spacingFactor??1.3)/1.3)*L})}catch(qe){console.warn("[flow-sdk] layout failed",qe);return}const ke=G.current;G.current=null;const Ce=ke&&le.get(ke.id);if(ke&&Ce){const qe={x:ke.position.x-Ce.x,y:ke.position.y-Ce.y};le=new Map([...le].map(([je,Le])=>[je,{x:Le.x+qe.x,y:Le.y+qe.y}]))}for(const[qe,je]of B.current)le.has(qe)?le.set(qe,je):A.nodes.some(Le=>Le.id===qe)||B.current.delete(qe);const Ee=M.coordinate(()=>{var qe;return(qe=We.current)==null?void 0:qe.call(We,le)});gr(le,se.current&&!A.isPerformanceMode&&!A.disableAnimations,Ee)},z=S.useCallback(()=>{clearTimeout(Oe.current),clearTimeout(xe.current),xe.current=setTimeout(Z,P.current.layoutDebounce)},[]);S.useLayoutEffect(()=>{const A=new Map(Ir.current.map(L=>[L.id,L]));r.some(L=>{var V;return((V=A.get(L.id))==null?void 0:V.collapsed)===!0&&!L.collapsed})&&(Et.current=r.filter(L=>!A.has(L.id)).map(L=>L.id)),Ir.current=r,gt.current!==l&&ce.current.size>0&&(se.current=!0,Be.current=!1,clearTimeout(Oe.current)),gt.current=l,rt.current!==He&&(Be.current=!et.current),rt.current=He,We.current&&!et.current?(clearTimeout(xe.current),Z()):z()},[r,t,O.nodes,O.edges,He,n,i,a,c,z,l,d,w,e.nodeGridSpacing]),S.useEffect(()=>()=>{clearTimeout(xe.current),clearTimeout(Oe.current),Jt()},[]);const re=S.useCallback((A,L)=>{var V,Y;if(!te.current&&typeof ResizeObserver<"u"&&(te.current=new ResizeObserver(le=>{let ke=!1;for(const Ce of le){const Ee=ae.current.get(Ce.target);if(!Ee||ye.current.has(Ee))continue;const qe=Ce.target,je=qe.offsetWidth,Le=qe.offsetHeight;if(!je&&!Le)continue;const Xe=J.current.get(Ee);if(Xe&&Xe.w===je&&Xe.h===Le)continue;const ne=ce.current.get(Ee);Xe&&ne&&se.current&&!G.current&&(G.current={id:Ee,position:{...ne}}),J.current.set(Ee,{w:je,h:Le}),ke=!0}ke&&(We.current&&!et.current?Z():z())})),L){ie.current.set(A,L),ae.current.set(L,A),(V=te.current)==null||V.observe(L);const le=L.offsetWidth,ke=L.offsetHeight;!ye.current.has(A)&&(le||ke)&&J.current.set(A,{w:le,h:ke})}else{const le=ie.current.get(A);le&&((Y=te.current)==null||Y.unobserve(le),ae.current.delete(le)),ie.current.delete(A),J.current.delete(A),D.current.has(A)&&de(A,[])}z()},[z,de]);S.useEffect(()=>()=>{var A;return(A=te.current)==null?void 0:A.disconnect()},[]);const Me=A=>{var Y;const L=(Y=P.current.nodes.find(le=>le.id===A))==null?void 0:Y.label;if(!L)return;const V=P.current.containerStyle(A);return{w:so(L,`bold ${V.fontSize}px ${cr}`)+2*kj,h:0}},K=S.useMemo(()=>{const A=new Map;for(const L of r)L.label&&A.set(L.id,L.label);return A},[r]),ge=S.useMemo(()=>dd(O.nodes,Q,new Map([...J.current,...we]),A=>y(A).padding,Me,we),[O.nodes,Q,y,K,we]),Re=S.useRef(ge);Re.current=ge;const ve=S.useCallback(A=>{const L=Re.current.get(A);if(L)return Iw(L);const V=ce.current.get(A);if(!V)return;const Y=ye.current.get(A)||J.current.get(A)||Wn;return{x:V.x,y:V.y,w:Y.w,h:Y.h}},[]),Ke=S.useMemo(()=>{const A=new Map;for(const L of r){const V=ve(L.id);V&&A.set(L.id,V)}return zw(F,A,he,t,n)},[F,r,Q,ge,he,t,n,ve]);D.current=Ke;const Ze=(A,L)=>{var le;if(!k||L===void 0)return;const V=(le=Ke.get(A))==null?void 0:le.find(ke=>ke.property===L),Y=ve(A);return V&&!V.anchor&&Y?Y.y-Y.h/2+V.top+V.height/2:void 0},Ge=(A,L)=>{var le,ke;if(L===void 0)return;const V=(ke=(le=Ke.get(A))==null?void 0:le.find(Ce=>Ce.property===L))==null?void 0:ke.anchor,Y=ve(A);return V&&Y?{x:Y.x-Y.w/2+V.x,y:Y.y-Y.h/2+V.y,side:V.side}:void 0},mt=(A,L)=>{const V=ve(A),Y=he.get(A);return V&&Y&&!ge.has(A)&&Ze(A,L)===void 0?wn(V,Y):V},Rt=()=>{const A=[];ce.current.forEach((L,V)=>{if(Re.current.has(V))return;const Y=ve(V);Y&&A.push(Xt(Y))}),Re.current.forEach(L=>A.push(L));try{for(const L of[R.current,$.current]){const V=L==null?void 0:L.getBBox();V&&V.width>0&&V.height>0&&A.push({x1:V.x,y1:V.y,x2:V.x+V.width,y2:V.y+V.height})}}catch{}return $o(A)},Zt=()=>{var V,Y;const{pan:A,zoom:L}=M;N.current&&(N.current.style.transform=`translate3d(${A.x}px, ${A.y}px, 0) scale(${L})`),(V=R.current)==null||V.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${L})`),(Y=$.current)==null||Y.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${L})`)};S.useEffect(()=>{Zt();let A=null,L;const V=M.onChange(()=>{Zt();const Y=I.current;Y&&(Y.classList.add("flow-sdk-busy"),clearTimeout(L),L=setTimeout(()=>Y.classList.remove("flow-sdk-busy"),150)),A===null&&(A=requestAnimationFrame(()=>{var le,ke;A=null,(ke=(le=P.current).onViewportChange)==null||ke.call(le,M.state)}))});return()=>{V(),clearTimeout(L),A!==null&&cancelAnimationFrame(A)}},[]),S.useLayoutEffect(()=>{const A=I.current;if(!A)return;const L=()=>{var Ce;if(!A.getClientRects().length)return;let Y=A.clientWidth,le=A.clientHeight;le||(le=Math.max(0,window.innerHeight-A.getBoundingClientRect().top-100),le&&(A.style.height=`${le}px`)),Y||(Y=window.innerWidth,Y&&(A.style.width=`${Y}px`));const ke=M.size.w!==Y||M.size.h!==le;M.size={w:Y,h:le},ke&&((Ce=De.current)!=null&&Ce.options.fill)&&z(),!se.current&&!ce.current.size&&P.current.fitOnInit!==!1&&(M.set({x:Y/2,y:le/2}),Zt())};if(L(),typeof ResizeObserver>"u")return;const V=new ResizeObserver(L);return V.observe(A),()=>V.disconnect()},[M]),S.useLayoutEffect(()=>{if(Gt.current){Gt.current=!1;const L=Et.current.flatMap(Y=>{const le=ve(Y);return le?[Xt(le)]:[]});Et.current=[];const V=$o(L);if(V){Be.current=!1,M.center(V,P.current.animateViewport);return}}if(!Be.current)return;Be.current=!1;const A=Rt();A&&(M.fit(A,50,se.current&&P.current.animateViewport),se.current||Zt())},[Q]);const wt=S.useMemo(()=>{const A=ne=>{const ee=P.current;if(ee.nodeGridSpacing!=="layout")return ne;const be=ee.direction==="LR"||ee.direction==="RL";return{...ne,gaps:{x:be?ee.rankSep:ee.edgeSep,y:be?ee.edgeSep:ee.rankSep}}},L=()=>{const ne=P.current,ee=T.current.nodes.filter(be=>nr(be.id,ne.edges,ne.edgeMode)&&(!ct.current||ct.current.has(be.id)));return{nodes:ee,positions:ce.current,sizes:new Map(ee.map(be=>[be.id,J.current.get(be.id)??Wn])),padding:be=>P.current.containerStyle(be).padding,minSize:Me,fixedIds:new Set(B.current.keys()),viewportSize:{...M.size}}},V=ne=>Tu(ne,P.current.nodes,P.current.edges),Y=(ne,ee=!0,be=()=>{},fe,Je,$e=!1)=>{clearTimeout(xe.current),clearTimeout(Oe.current),$e||(We.current=null),et.current=null,Be.current=!1,Et.current=[],Gt.current=!1,M.cancelAnimation();const Ie=ee&&!P.current.isPerformanceMode&&!P.current.disableAnimations,dt=M.coordinate(()=>{var Ve;fe?fe(Ie):$e&&((Ve=We.current)==null||Ve.call(We,ne))});gr(new Map([...ne].map(([Ve,ht])=>[Ve,{...ht}])),Ie,dt,be,Je)},le=(ne,ee=50,be=P.current.animateViewport,fe=1,Je=!1)=>{const $e=Ie=>{const dt=T.current,Ve=ne??new Set(dt.nodes.map(St=>St.id)),ht=new Set(dt.nodes.map(St=>St.parent).filter(Boolean));if(!Ie&&(!ne||[...ne].some(St=>ht.has(St))))return;const rr=Ie&&dd(dt.nodes,Ie,J.current,St=>P.current.containerStyle(St).padding,Me),nn=$o([...Ve].flatMap(St=>{const du=rr==null?void 0:rr.get(St);if(du)return[du];const uu=Ie==null?void 0:Ie.get(St),ex=J.current.get(St)||Wn,fu=uu?{...uu,...ex}:ve(St);return fu?[Xt(fu)]:[]}));nn&&(Be.current=!1,Et.current=[],Gt.current=!1,M.fit(nn,Number.isFinite(ee)?Math.max(0,ee):50,be,fe))};We.current=Je?$e:null,Je||$e(ce.current)},ke=(ne,ee,be,fe)=>{var $e;if(!ve(ne))return;const Je=ee==="connections"?Ee(ne):V(ne);if(ee==="connections"&&tr.current===1.25&&(($e=ct.current)==null?void 0:$e.size)===Je.size&&[...Je].every(Ie=>ct.current.has(Ie))){j({id:ne,mode:ee});return}Wt.current||(Wt.current={pan:{...M.pan},zoom:M.zoom}),ct.current=Je,P.current.compactPropertyLayout&&(Be.current=!1,et.current=()=>le(ct.current??Je,be,fe)),j({id:ne,mode:ee}),P.current.compactPropertyLayout||le(Je,be,fe)},Ce=ne=>{et.current?et.current=ne:ne()},Ee=ne=>Fu(ne,P.current.nodes,P.current.edges),qe=(ne=>{var ee,be,fe;if(ne===void 0)return M.zoom;ne<M.zoom&&((ee=De.current)!=null&&ee.options.fill)&&!P.current.readOnly&&((fe=(be=P.current).onNodeGridZoomOut)==null?void 0:fe.call(be,De.current.options))===!0||(We.current=null,M.set(void 0,ne))}),je=(ne=>{if(ne===void 0)return M.pan;We.current=null,M.set(ne)}),Le=(ne,ee)=>{var fe;const be=(fe=I.current)==null?void 0:fe.getBoundingClientRect();return{x:ne-((be==null?void 0:be.left)??0),y:ee-((be==null?void 0:be.top)??0)}},Xe=(ne=0,ee=P.current.animateViewport,be=!1)=>{if(be){le(void 0,ne,ee,1,!0);return}We.current=null,Ce(()=>{const fe=Rt();fe&&M.fit(fe,ne,ee)})};return{zoom:qe,pan:je,setEdgesVisible:Pe,focusNode:(ne,ee,be,fe)=>Ce(()=>le(new Set([ne]),ee,be,.6,fe)),focusBranch:(ne,ee,be)=>Ce(()=>le(V(ne),ee,be)),focusConnections:(ne,ee,be,fe)=>Ce(()=>le(Ee(ne),ee,be,1,fe)),isolateConnections:(ne,ee,be)=>ke(ne,"connections",ee,be),isolateBranch:(ne,ee,be)=>ke(ne,"branch",ee,be),restoreView:(ne=P.current.animateViewport,ee)=>{We.current=null;const be=P.current.compactPropertyLayout&&!!ct.current;ct.current=null,j(null);const fe=ee??Wt.current;Wt.current=null,be?et.current=()=>{fe&&M.transition(fe,ne)}:fe&&Ce(()=>M.transition(fe,ne))},zoomAt:(ne,ee)=>{var be,fe,Je;ne<M.zoom&&((be=De.current)!=null&&be.options.fill)&&!P.current.readOnly&&((Je=(fe=P.current).onNodeGridZoomOut)==null?void 0:Je.call(fe,De.current.options))===!0||(We.current=null,M.zoomAt(ne,ee))},fit:Xe,centerAndFit:Xe,center:(ne=P.current.animateViewport)=>{We.current=null;const ee=Rt();ee&&M.center(ee,ne)},clientToModel:(ne,ee)=>M.renderedToModel(Le(ne,ee)),modelToClient:ne=>{var fe;const ee=(fe=I.current)==null?void 0:fe.getBoundingClientRect(),be=M.modelToRendered(ne);return{x:be.x+((ee==null?void 0:ee.left)??0),y:be.y+((ee==null?void 0:ee.top)??0)}},getNodeBox:ne=>ve(ne),detectNodeCollisions:ne=>{const ee=L();return Lv({...ee,sizes:new Map([...ee.sizes,...ye.current]),fixedSizes:ye.current},ne)},resolveNodeCollisions:(ne={})=>{const ee=mj(L(),ne);return ee.movedNodeIds.length&&Y(ee.positions,ne.animate),ee},arrangeNodesInGrid:(ne={})=>{const ee=L(),be=De.current;if(be){ee.positions=new Map(ee.positions);for(const Ve of ee.nodes)ee.positions.has(Ve.id)||ee.positions.set(Ve.id,M.renderedToModel({x:M.size.w/2,y:M.size.h/2}));const $e=new Set(ee.nodes.map(Ve=>Ve.id));be.order=be.order.filter(Ve=>$e.has(Ve));const Ie=new Set(be.order);be.order.push(...ee.nodes.filter(Ve=>!Ie.has(Ve.id)).map(Ve=>Ve.id));const dt=new Map(be.order.map((Ve,ht)=>[Ve,ht]));ee.nodes=[...ee.nodes].sort((Ve,ht)=>dt.get(Ve.id)-dt.get(ht.id))}const fe=ed(ee,A(ne));Lt(fe.dividers??[]),be&&(be.ready=!1);const Je=()=>{be&&(be.ready=!0),ue($e=>$e+1)};return!fe.sizes&&ye.current.size&&pe(),fe.movedNodeIds.length||fe.bounds||We.current?Y(fe.positions,ne.animate,Je,fe.bounds&&(!be||!ye.current.size)?()=>M.transition({zoom:1,pan:{x:0,y:0}},!1):void 0,fe.sizes,!!be&&!fe.bounds):Je(),fe},setNodeGridMode:(ne,ee={})=>{var be,fe,Je,$e;if(ee.order&&(!Array.isArray(ee.order)||ee.order.some(Ie=>typeof Ie!="string")||new Set(ee.order).size!==ee.order.length))throw new Error("Invalid grid node order.");if(ne){ed(L(),A(ee));const Ie=!De.current||De.current.options.fill&&!ee.fill;We.current=null,De.current||(De.current={options:ee,order:L().nodes.map(dt=>dt.id),previousPositions:new Map([...ce.current].map(([dt,Ve])=>[dt,{...Ve}])),previousViewport:{zoom:M.zoom,pan:{...M.pan}},previousSize:{...M.size},ready:!1}),Ie&&wt.centerAndFit(80,ee.animate,!0),ee.order&&(De.current.order=[...ee.order]),De.current.options={...ee},it(!0),wt.arrangeNodesInGrid(ee),(fe=(be=P.current).onNodeGridModeChange)==null||fe.call(be,{...ee,order:[...De.current.order]})}else{const Ie=De.current;if(!Ie)return;M.size.w===Ie.previousSize.w&&M.size.h===Ie.previousSize.h&&ce.current.size===Ie.previousPositions.size&&[...ce.current.keys()].every(ht=>Ie.previousPositions.has(ht))?We.current=()=>M.transition(Ie.previousViewport,ee.animate!==!1&&!P.current.disableAnimations&&!P.current.isPerformanceMode):wt.centerAndFit(80,ee.animate,!0),De.current=null,it(!1),pe(),($e=(Je=P.current).onNodeGridModeChange)==null||$e.call(Je,null),Vt(null);const Ve=new Map([...ce.current].map(([ht,rr])=>[ht,Ie.previousPositions.get(ht)??rr]));Y(Ve,ee.animate,void 0,void 0,void 0,!0)}},swapGridNodes:(ne,ee,be)=>{var rr,nn;const fe=De.current;if(!fe||!fe.ready||P.current.readOnly||ne===ee)return!1;const Je=L(),$e=Je.nodes.find(St=>St.id===ne),Ie=Je.nodes.find(St=>St.id===ee);if(!$e||!Ie||$e.parent!==Ie.parent)return!1;const dt=ed(Je,A(fe.options));if(dt.skippedNodeIds.includes(ne)||dt.skippedNodeIds.includes(ee))return!1;const Ve=fe.order.indexOf(ne),ht=fe.order.indexOf(ee);return Ve<0||ht<0?!1:([fe.order[Ve],fe.order[ht]]=[fe.order[ht],fe.order[Ve]],We.current=null,fe.options={...fe.options,order:[...fe.order]},wt.arrangeNodesInGrid({...fe.options,animate:be??fe.options.animate}),(nn=(rr=P.current).onNodeGridModeChange)==null||nn.call(rr,{...fe.options}),!0)},setNodePosition:(ne,ee,be)=>{if(!ce.current.has(ne)||ee&&(!Number.isFinite(ee.x)||!Number.isFinite(ee.y)))return!1;if(Jt(),!ee)return B.current.delete(ne),z(),!0;const fe=new Map(ce.current);return fe.set(ne,{...ee}),(be==null?void 0:be.persist)===!1?B.current.delete(ne):B.current.set(ne,{...ee}),ce.current=fe,oe(fe),(be==null?void 0:be.persist)===!1&&z(),!0},onViewportChange:ne=>M.onChange(ne)}},[]);S.useEffect(()=>{var A,L;return(L=(A=P.current).onInit)==null||L.call(A,wt),()=>M.cancelAnimation()},[wt]),S.useEffect(()=>{var A,L;if(H>0){const V=et.current;et.current=null,V==null||V(),(L=(A=P.current).onLayoutComplete)==null||L.call(A,wt)}},[wt,H]);const lt=S.useRef(null),Ct=S.useRef(new Map),yr=S.useRef(!1),[mr,Ln]=S.useState(null),[nt,tn]=S.useState(null),Fn=A=>{const L=I.current.getBoundingClientRect();return{x:(A.clientX-L.left)*(I.current.clientWidth/L.width||1),y:(A.clientY-L.top)*(I.current.clientHeight/L.height||1)}},zn=(A,L)=>{const V=P.current.nodes;for(let Y=V.length-1;Y>=0;Y--){const le=V[Y].id;if(!nr(le,P.current.edges,P.current.edgeMode)||ct.current&&!ct.current.has(le)||le===L||Re.current.has(le))continue;const ke=ve(le);if(ke&&Ou(A,Xt(ke)))return le}for(const[Y,le]of Re.current)if(nr(Y,P.current.edges,P.current.edgeMode)&&!(ct.current&&!ct.current.has(Y))&&Y!==L&&Ou(A,le))return Y;return null},nu=(A,L)=>{const V=P.current.nodes.find(Ee=>Ee.id===A),Y=ve(A);if(!V||!Y)return null;const le=Xt({...Y,x:Y.x+L.x,y:Y.y+L.y});let ke=null,Ce=0;for(const Ee of P.current.nodes){if(Ee.id===A||Ee.parent!==V.parent||B.current.has(Ee.id)||Re.current.has(Ee.id)||!nr(Ee.id,P.current.edges,P.current.edgeMode)||ct.current&&!ct.current.has(Ee.id))continue;const qe=ve(Ee.id);if(!qe)continue;const je=Xt(qe),Le=Math.max(0,Math.min(le.x2,je.x2)-Math.max(le.x1,je.x1))*Math.max(0,Math.min(le.y2,je.y2)-Math.max(le.y1,je.y1));Le>Ce&&(Ce=Le,ke=Ee.id)}return ke},Ro=(A,L)=>{if(P.current.edgeMode==="nodes"||P.current.edgeMode==="workflow")return null;const V=P.current.direction==="RL",Y=Math.max(16,6/M.zoom);let le=null;for(const ke of[...P.current.nodes].reverse()){if(!nr(ke.id,P.current.edges,P.current.edgeMode)||ct.current&&!ct.current.has(ke.id))continue;const Ce=ve(ke.id),Ee=D.current.get(ke.id);if(!Ce||!Ee||Re.current.has(ke.id))continue;const qe=Ce.x+(L==="source"!==V?1:-1)*Ce.w/2;for(const je of Ee){if(je.role&&je.role!==L)continue;const Le=Ce.y-Ce.h/2+je.top,Xe=Math.hypot(A.x-(je.anchor?Ce.x-Ce.w/2+je.anchor.x:qe),A.y-Le-je.height/2);if(!je.anchor&&A.x>=Ce.x-Ce.w/2&&A.x<=Ce.x+Ce.w/2&&A.y>=Le&&A.y<=Le+je.height)return{nodeId:ke.id,property:je.property};Xe<=Y&&(!le||Xe<le.distance)&&(le={nodeId:ke.id,property:je.property,distance:Xe})}}return le},Hv=A=>{var Ee,qe;if(!A.currentTarget.contains(A.target)||(lt.current||(yr.current=!1),A.target.closest(".flow-sdk-canvas")!==A.currentTarget)||A.button!==0||P.current.readOnly)return;const L=A.target;if(L.closest('input, textarea, select, [contenteditable="true"], [data-flow-content-toggle]'))return;const V=P.current,Y=Fn(A);if(A.pointerType==="touch"){Ct.current.set(A.pointerId,Y);const je=fm(Ct.current);if(je){Vt(null),lt.current={kind:"pinch",distance:je.distance,zoom:M.zoom,anchor:M.renderedToModel(je.center)},tn(null),Ln(null),yr.current=!0;for(const Le of Ct.current.keys())A.currentTarget.setPointerCapture(Le);return}}if(lt.current)return;const le=!De.current||!!V.nodeGridConnections,ke=V.drawHandles&&L.closest(".flow-sdk-handle"),Ce=V.drawHandles&&L.closest(".flow-sdk-property-port");if((!le||!ke&&!Ce&&(!V.drawMode||A.shiftKey))&&(De.current||A.shiftKey&&(V.onNodeGridDrop||V.onNodeParentChange))){if(De.current&&!De.current.ready||L.closest("button, input, textarea, select, a, [contenteditable=true], [data-flow-content]"))return;const je=(Ee=L.closest("[data-node-id]"))==null?void 0:Ee.dataset.nodeId;if(je&&!B.current.has(je)){L.setPointerCapture(A.pointerId),lt.current={kind:"grid",pointerId:A.pointerId,captureTarget:L,source:je,start:Y,moved:!1};return}if(je)return}if(le&&(V.drawMode||ke||Ce)){const je=M.renderedToModel(Y),Le=V.drawMode?Ro(je,"source"):null,Xe=Ce||ke,ne=Xe?(qe=Xe.closest("[data-node-id]"))==null?void 0:qe.dataset.nodeId:(Le==null?void 0:Le.nodeId)??zn(je),ee=Ce?Ce.dataset.property:Le==null?void 0:Le.property;if(ne){lt.current={kind:"draw",pointerId:A.pointerId,source:ne,sourceProperty:ee,reverse:(Ce==null?void 0:Ce.dataset.portRole)==="target",startClient:{x:A.clientX,y:A.clientY}},yr.current=!0,tn({source:ne,sourceProperty:ee,point:je,target:null}),A.currentTarget.setPointerCapture(A.pointerId);return}}L.closest(".flow-sdk-node, .flow-sdk-container, .flow-sdk-edge, .flow-sdk-edge-label, .flow-sdk-container-label")||(We.current=null,V.multiSelect?lt.current={kind:"box",pointerId:A.pointerId,start:Y,current:Y}:V.dragMode?lt.current={kind:"pan",pointerId:A.pointerId,start:Y,pan0:M.pan,moved:!1}:lt.current={kind:"tap",pointerId:A.pointerId,start:Y,moved:!1},A.currentTarget.setPointerCapture(A.pointerId))},Kv=A=>{var Y,le,ke;const L=lt.current;if(!L||P.current.readOnly)return;const V=Fn(A);if(Ct.current.has(A.pointerId)&&Ct.current.set(A.pointerId,V),L.kind==="pinch"){const Ce=fm(Ct.current);if(!Ce)return;const Ee=Math.max(M.minZoom,Math.min(M.maxZoom,L.zoom*Ce.distance/L.distance));if(Ee<M.zoom&&((Y=De.current)!=null&&Y.options.fill)&&((ke=(le=P.current).onNodeGridZoomOut)==null?void 0:ke.call(le,De.current.options))===!0)return;M.set({x:Ce.center.x-L.anchor.x*Ee,y:Ce.center.y-L.anchor.y*Ee},Ee);return}if(L.pointerId===A.pointerId)switch(L.kind){case"grid":{const Ce={x:V.x-L.start.x,y:V.y-L.start.y};if(!L.moved&&Math.hypot(Ce.x,Ce.y)<=td)return;L.moved||(Jt(),We.current=null,M.cancelAnimation()),L.moved=!0,yr.current=!0,A.preventDefault();const Ee={x:Ce.x/M.zoom,y:Ce.y/M.zoom};Vt({source:L.source,offset:Ee,target:A.shiftKey?null:nu(L.source,Ee),shiftKey:A.shiftKey});break}case"pan":{const Ce=V.x-L.start.x,Ee=V.y-L.start.y;if(!L.moved&&Math.hypot(Ce,Ee)<=td)return;L.moved=!0,yr.current=!0,M.set({x:L.pan0.x+Ce,y:L.pan0.y+Ee});break}case"tap":{Math.hypot(V.x-L.start.x,V.y-L.start.y)>td&&(L.moved=!0);break}case"box":{yr.current=!0,L.current=V,Ln({x1:Math.min(L.start.x,V.x),y1:Math.min(L.start.y,V.y),x2:Math.max(L.start.x,V.x),y2:Math.max(L.start.y,V.y)});break}case"draw":{const Ce=M.renderedToModel(V),Ee=Ro(Ce,L.reverse?"source":"target");tn(L.reverse&&Ee?{source:Ee.nodeId,sourceProperty:Ee.property,point:Ce,target:L.source,targetProperty:L.sourceProperty}:{source:L.source,sourceProperty:L.sourceProperty,point:Ce,target:(Ee==null?void 0:Ee.nodeId)??zn(Ce,L.source),targetProperty:Ee==null?void 0:Ee.property});break}}},ou=(A,L)=>{var le,ke,Ce,Ee,qe,je,Le,Xe,ne,ee,be;Ct.current.delete(A.pointerId);const V=lt.current;if(!V)return;if(V.kind==="pinch"){const fe=[...Ct.current][0];lt.current=fe&&P.current.dragMode&&!L?{kind:"pan",pointerId:fe[0],start:fe[1],pan0:M.pan,moved:!0}:null;return}if(V.pointerId!==A.pointerId)return;lt.current=null;try{(V.kind==="grid"?V.captureTarget:A.currentTarget).releasePointerCapture(A.pointerId)}catch{}const Y=P.current;switch(L=L||!!Y.readOnly,V.kind){case"grid":{if(Vt(null),L||!V.moved||((le=Y.onNodeGridDrop)==null?void 0:le.call(Y,V.source,{x:A.clientX,y:A.clientY},{shiftKey:A.shiftKey,ctrlKey:A.ctrlKey,metaKey:A.metaKey,altKey:A.altKey}))===!0)break;const fe=Fn(A);if(fe.x<0||fe.y<0||fe.x>M.size.w||fe.y>M.size.h)break;if(A.shiftKey){const $e=new Map(Y.nodes.map(Ve=>[Ve.id,Ve]));let Ie=zn(M.renderedToModel(fe),V.source);const dt=new Set;for(;Ie&&!((ke=$e.get(Ie))!=null&&ke.acceptsChildren)&&!dt.has(Ie);)dt.add(Ie),Ie=((Ce=$e.get(Ie))==null?void 0:Ce.parent)??null;if(Ie&&((Ee=$e.get(Ie))!=null&&Ee.acceptsChildren)){let Ve=Ie;const ht=new Set;for(;Ve&&!ht.has(Ve);)ht.add(Ve),Ve=(qe=$e.get(Ve))==null?void 0:qe.parent;ht.has(V.source)||(je=Y.onNodeParentChange)==null||je.call(Y,V.source,Ie)}break}if(!De.current)break;const Je=nu(V.source,{x:(fe.x-V.start.x)/M.zoom,y:(fe.y-V.start.y)/M.zoom});Je&&wt.swapGridNodes(V.source,Je,!1);break}case"pan":case"tap":!L&&!V.moved&&((Le=Y.onBackgroundTap)==null||Le.call(Y));break;case"box":{if(Ln(null),L)break;const fe=M.renderedToModel(V.start),Je=M.renderedToModel(V.current),$e={x1:Math.min(fe.x,Je.x),y1:Math.min(fe.y,Je.y),x2:Math.max(fe.x,Je.x),y2:Math.max(fe.y,Je.y)};if($e.x2-$e.x1<1&&$e.y2-$e.y1<1){(Xe=Y.onBackgroundTap)==null||Xe.call(Y);break}const Ie=[];for(const dt of Y.nodes){const Ve=ve(dt.id);Ve&&Mw(Xt(Ve),$e)&&Ie.push(dt.id)}Ie.length&&((ne=Y.onBoxSelect)==null||ne.call(Y,Ie));break}case"draw":{if(tn(null),L)break;const fe=Fn(A),Je=M.renderedToModel(fe),$e=Ro(Je,V.reverse?"source":"target"),Ie=($e==null?void 0:$e.nodeId)??zn(Je);if(Ie===V.source&&(V.sourceProperty===void 0||($e==null?void 0:$e.property)===void 0||$e.property===V.sourceProperty))break;Ie?(ee=Y.onEdgeDraw)==null||ee.call(Y,V.reverse?Ie:V.source,V.reverse?V.source:Ie,V.sourceProperty!==void 0||($e==null?void 0:$e.property)!==void 0?{sourceProperty:V.reverse?$e==null?void 0:$e.property:V.sourceProperty,targetProperty:V.reverse?V.sourceProperty:$e==null?void 0:$e.property}:void 0):Math.max(Math.abs(A.clientX-V.startClient.x),Math.abs(A.clientY-V.startClient.y))>Ej&&((be=Y.onDrawIntoSpace)==null||be.call(Y,V.source,Je,V.sourceProperty,V.reverse));break}}},br=S.useCallback(()=>{var V;const A=lt.current,L=[...Ct.current.keys()];A&&A.kind!=="pinch"&&L.push(A.pointerId),lt.current=null,Ct.current.clear(),Vt(null),tn(null),Ln(null);for(const Y of L)(A==null?void 0:A.kind)==="grid"&&A.captureTarget.hasPointerCapture(Y)&&A.captureTarget.releasePointerCapture(Y),(V=I.current)!=null&&V.hasPointerCapture(Y)&&I.current.releasePointerCapture(Y)},[]);S.useEffect(()=>{const A=L=>{L.key==="Escape"&&br()};return window.addEventListener("keydown",A),window.addEventListener("blur",br),()=>{window.removeEventListener("keydown",A),window.removeEventListener("blur",br),lt.current=null,Ct.current.clear()}},[br]),S.useEffect(()=>{br()},[g,b,v,o,n,e.drawHandles,e.readOnly,Fe,br]);const Jv=S.useMemo(()=>{const A=new Map,L=new Map;for(const V of E){if(V.source!==V.target)continue;const Y=A.get(V.source)??0;A.set(V.source,Y+1),L.set(V.id,Y)}return L},[E]),ko=_j[n],[Ao,Zv]=S.useState(null),Po=Sj(r,E,!!((su=e.edgeReveal)!=null&&su.revealNodes));S.useLayoutEffect(()=>{I.current&&Ao&&vj(I.current)});const Io=Pw(E,mt,ko),Xv=e.onEdgeSelect,Yv=e.onContainerSelect,iu=nt?nt.target&&mt(nt.target,nt.targetProperty)||{x:nt.point.x,y:nt.point.y,w:1,h:1}:null,au=nt?mt(nt.source,nt.sourceProperty):null,rn=!Fe||!!e.nodeGridConnections,Qv=["flow-sdk-canvas",g&&rn?"flow-sdk-draw":"",x?"flow-sdk-perf":""].filter(Boolean).join(" ");return f.jsxs("div",{ref:I,className:Qv,"data-edge-mode":o,"data-node-grid":Fe||void 0,"data-grid-connections":e.nodeGridConnections||void 0,onPointerDownCapture:Hv,onPointerMove:Kv,onPointerUp:A=>ou(A,!1),onPointerCancel:A=>ou(A,!0),onLostPointerCapture:A=>{const L=lt.current;L&&(L.kind==="pinch"||L.pointerId===A.pointerId)&&br()},onClickCapture:A=>{if(!A.currentTarget.contains(A.target))return;const L=A.target instanceof Element&&A.target.closest("button[data-flow-fullscreen]");(yr.current||e.readOnly&&!L)&&(A.preventDefault(),A.stopPropagation())},children:[f.jsx("svg",{className:"flow-sdk-svg",children:f.jsxs("g",{ref:R,children:[f.jsx("g",{className:"flow-sdk-containers",children:[...ge].filter(([A])=>nr(A,t,o)).filter(([A])=>!_||_.has(A)).map(([A,L])=>{var V,Y;return f.jsx(Vw,{id:A,rect:L,label:K.get(A),labelLayer:Ao,labelContent:(V=r.find(le=>le.id===A&&le.label!==void 0))==null?void 0:V.element,style:y(A),onSelect:Yv,onCollapse:e.readOnly?void 0:e.onContainerCollapse,selected:(Y=e.selectedNodeIds)==null?void 0:Y.includes(A)},A)})}),f.jsx("g",{className:"flow-sdk-edges",children:ft&&rn&&E.map(A=>{var Y,le,ke;if(!Po.ready.has(A.id)||_&&(!_.has(A.source)||!_.has(A.target)))return null;const L=mt(A.source,A.sourceProperty),V=mt(A.target,A.targetProperty);return!L||!V?null:f.jsx(Bu,{id:A.id,edgeData:A.data,validationIssue:A.validationIssue,edgeType:A.type,edgeRadius:e.edgeRadius,propertyMode:k,customEdgeTypes:e.customEdgeTypes,reveal:e.edgeReveal,onRevealComplete:Po.complete,source:L,target:V,sourceProperty:A.sourceProperty,targetProperty:A.targetProperty,sourceY:Ze(A.source,A.sourceProperty),targetY:Ze(A.target,A.targetProperty),sourcePort:Ge(A.source,A.sourceProperty),targetPort:Ge(A.target,A.targetProperty),dir:ko,turn:((Y=Io.get(A.id))==null?void 0:Y.turn)??A.turn,labelAtTarget:(le=Io.get(A.id))==null?void 0:le.labelAtTarget,labelFraction:(ke=Io.get(A.id))==null?void 0:ke.labelFraction,color:A.color,connectorColor:A.connectorColor,labelBg:A.labelBg,label:A.label,labelLayer:Ao,dashed:A.dashed,animated:A.animated&&!x,inverted:A.inverted,loopIndex:Jv.get(A.id)??0,onSelect:Xv},A.id)})}),ft&&rn&&nt&&ld(nt,o)&&au&&iu&&f.jsx("g",{className:"flow-sdk-ghost",pointerEvents:"none",children:f.jsx(Bu,{id:"__flow-sdk-ghost",edgeData:{id:"__flow-sdk-ghost",source:nt.source,target:nt.target??"",sourceProperty:nt.sourceProperty,targetProperty:nt.targetProperty},edgeType:e.edgeType,edgeRadius:e.edgeRadius,propertyMode:k,customEdgeTypes:e.customEdgeTypes,source:au,target:iu,sourceProperty:nt.sourceProperty,targetProperty:nt.targetProperty,sourceY:Ze(nt.source,nt.sourceProperty),sourcePort:Ge(nt.source,nt.sourceProperty),targetPort:nt.target?Ge(nt.target,nt.targetProperty):void 0,targetY:nt.target?Ze(nt.target,nt.targetProperty):void 0,dir:ko,turn:.5,color:m,labelBg:m})})]})}),f.jsxs("div",{ref:N,className:"flow-sdk-nodes",children:[Fe&&((cu=De.current)==null?void 0:cu.options.fill)&&((lu=De.current.options.adjustment)==null?void 0:lu.enabled)&&!e.readOnly&&f.jsx(bj,{dividers:at,options:De.current.options,zoom:M.zoom,onChange:A=>wt.setNodeGridMode(!0,{...A,animate:!1})}),r.map(A=>{var Je,$e;const L=Q.get(A.id),V=ge.get(A.id);if(V&&A.label!==void 0)return null;const Y=(L==null?void 0:L.x)??(V?(V.x1+V.x2)/2:0),le=(L==null?void 0:L.y)??(V?(V.y1+V.y2)/2:0),ke=Ye!=null&&Ye.target?A.id===Ye.source?Ye.target:A.id===Ye.target?Ye.source:void 0:void 0,Ce=ke?Q.get(ke):void 0,Ee=Ye?Q.get(Ye.source):void 0,qe=Ye!=null&&Ye.target?Q.get(Ye.target):void 0,je=Ee&&qe?{x:qe.x-Ee.x,y:qe.y-Ee.y}:void 0,Le=je?je.x**2+je.y**2:0,Xe=Le&&Ye&&je?Math.max(0,Math.min(1,(Ye.offset.x*je.x+Ye.offset.y*je.y)/Le)):0,ne=Ce?{x:Y+(Ce.x-Y)*Xe,y:le+(Ce.y-le)*Xe}:(Ye==null?void 0:Ye.source)===A.id?{x:Y+Ye.offset.x,y:le+Ye.offset.y}:void 0,ee=we.get(A.id),be=ke?we.get(ke):void 0,fe=ee&&be?{w:ee.w+(be.w-ee.w)*Xe,h:ee.h+(be.h-ee.h)*Xe}:ee;return f.jsx(Cj,{id:A.id,x:Y,y:le,gridDraggable:Fe&&!e.readOnly&&!B.current.has(A.id),gridDragging:(Ye==null?void 0:Ye.source)===A.id,gridDropTarget:(Ye==null?void 0:Ye.target)===A.id,gridSize:we.get(A.id),gridPreview:ne?{...ne,size:fe,floating:Ye==null?void 0:Ye.shiftKey}:void 0,placed:!!L||!!V,hidden:!Fe&&!Po.shown.has(A.id)||!nr(A.id,t,o)||!!_&&!_.has(A.id),onMount:re,drawHandles:e.drawHandles&&!e.readOnly&&rn,drawMode:g&&rn,connectedPorts:new Set(E.flatMap(Ie=>[...Ie.source===A.id&&Ie.sourceProperty!==void 0?[`source:${Ie.sourceProperty}`]:[],...Ie.target===A.id&&Ie.targetProperty!==void 0?[`target:${Ie.targetProperty}`]:[]])),hasCollapseControl:A.hasCollapseControl,handleColor:m,animated:A.animated&&!V&&!x&&!Fe,animationColor:A.animationColor,animationWidth:A.animationWidth,animationVariant:A.animationVariant,width:(Je=J.current.get(A.id))==null?void 0:Je.w,height:($e=J.current.get(A.id))==null?void 0:$e.h,propertyMode:k,resolvedRows:Ke.get(A.id),reversePorts:n==="RL",direction:n,onPropertyRows:de,onSurface:q,children:ee?A.fillElement??A.element:A.element},A.id)})]}),mr&&f.jsx("div",{className:"flow-sdk-box",style:{left:mr.x1,top:mr.y1,width:mr.x2-mr.x1,height:mr.y2-mr.y1}}),f.jsx("svg",{className:"flow-sdk-svg flow-sdk-label-overlay",style:{zIndex:11,pointerEvents:"none"},children:f.jsx("g",{ref:$,transform:`translate(${M.pan.x} ${M.pan.y}) scale(${M.zoom})`,children:f.jsx("g",{ref:Zv,className:"flow-sdk-labels",style:{pointerEvents:g?"none":"visiblePainted",outline:"none"}})})})]})}const Pj=S.memo(Aj);function Yd(e=!0){const r=S.useRef(null);return S.useEffect(()=>{if(!e||!r.current)return;const t=o=>{o.stopPropagation()},n=r.current,i=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return i.forEach(o=>n.addEventListener(o,t)),()=>{i.forEach(o=>n.removeEventListener(o,t))}},[e]),r}const Ur=({nodeId:e,label:r,color:t,fontWeight:n="bold",fontSize:i="5xl",wrap:o=!1,isEditing:s,onEditStart:a,onEditEnd:c})=>{const{callbacks:l,config:d,readOnly:u}=Ue(),h=d.editable&&!u,[p,y]=S.useState(r),[m,g]=S.useState(),b=S.useRef(null),v=S.useRef(!1),x=Yd(s);S.useEffect(()=>{if(s&&(v.current=!1,b.current)){b.current.focus();const C=b.current.value.length;b.current.setSelectionRange(C,C)}},[s]);const w=()=>{var j;if(v.current)return;v.current=!0;const C=p.trim();C&&C!==r&&((j=l.onNodeLabelChange)==null||j.call(l,e,C)),c()};return!h||!s?f.jsx(W.Text,{color:t,fontWeight:n,fontSize:i,minW:0,maxW:"100%",whiteSpace:o?"normal":"nowrap",overflowWrap:o?"anywhere":void 0,overflow:"hidden",textOverflow:"ellipsis",title:r,onDoubleClick:h?C=>{C.stopPropagation(),g({width:C.currentTarget.offsetWidth,height:C.currentTarget.offsetHeight}),y(r),a()}:void 0,cursor:h?"text":void 0,children:r}):f.jsxs("div",{ref:x,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(W.Text,{as:"span","aria-hidden":"true",display:"block",visibility:"hidden",fontWeight:n,fontSize:i,lineHeight:"normal",whiteSpace:"pre",overflow:"hidden",children:p||" "}),f.jsx(W.Input,{ref:b,value:p,onChange:C=>y(C.target.value),onBlur:w,onKeyDown:C=>{C.key==="Enter"&&w(),C.key==="Escape"&&(v.current=!0,c())},color:t,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 Fv({id:e,label:r,role:t,side:n,position:i=.5,placement:o,children:s,style:a}){return f.jsx("div",{"data-flow-property":e,"data-flow-port-role":t,"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:t==="source"?"flex-end":"flex-start",...a,...n?{display:"none"}:{}},children:s??r??e})}const Ij=Qn.default.dialog`
|
|
211
211
|
${e=>lr(e.$surface,e.$border)}
|
|
212
212
|
&,
|
|
213
213
|
&:hover {
|
|
@@ -277,8 +277,8 @@
|
|
|
277
277
|
black calc(100% - 32px),
|
|
278
278
|
transparent
|
|
279
279
|
);
|
|
280
|
-
`;function Yd({nodeAddress:e,active:r,label:t,open:n=!1,onClose:i,children:o,filter:s,height:a,width:l}){const{background:c,border:d,colorText:u}=it(),{colorMode:h}=Ve(),p=j.useRef(null),y=j.useId(),{data:m,schema:g,bindings:b}=j.useContext(Mt),v=o!==void 0||!!(m&&g&&(b?Pn(b,e,g):Kr(m,e,g)));j.useEffect(()=>{var w,C,S,_,R;!r||!v||!n?(w=p.current)==null||w.close():(C=p.current)!=null&&C.open||((S=p.current)==null||S.showModal(),(R=(_=p.current)==null?void 0:_.querySelector("[data-form-filter] input"))==null||R.focus())},[r,v,n]);const x=_e(c);return v?f.jsx(f.Fragment,{children:typeof document<"u"&&Cn.createPortal(f.jsx(Ij,{ref:p,id:y,$surface:x,$border:_e(d),"aria-label":`Configure ${t}`,onClose:i,onPointerDown:w=>w.stopPropagation(),onWheel:w=>w.stopPropagation(),onKeyDown:w=>w.stopPropagation(),onClick:w=>{var C;w.stopPropagation(),w.target===w.currentTarget&&((C=p.current)==null||C.close())},style:{position:"fixed",inset:"94px 20px auto auto",margin:0,padding:20,width:l??"var(--top-toolbar-width, 360px)",boxSizing:"border-box",maxWidth:"calc(100vw - 40px)",maxHeight:"calc(100dvh - 114px)",height:a,overflow:"hidden",borderRadius:30,background:x,color:_e(u),fontSize:16,textTransform:"none"},children:n&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexShrink:0},children:[f.jsx("strong",{style:{overflowWrap:"anywhere",minWidth:0},children:t}),f.jsx(Hr,{"aria-label":"Close node configuration",onClick:()=>{var w;return(w=p.current)==null?void 0:w.close()}})]}),s&&f.jsx("div",{"data-form-filter":"",style:{flexShrink:0},children:s}),f.jsx(Mj,{$divider:`var(--chakra-colors-gray-${h==="dark"?"700":"200"})`,"data-form-scroll":"",style:a?{flex:1}:void 0,children:o??f.jsx(_d,{nodeAddress:e})})]})}),document.body)}):null}const dd=({icon:e,label:r,onClick:t,color:n,boxSize:i=6,...o})=>{const{background:s,border:a,colorText:l}=it();return f.jsx(Fe,{label:r,children:f.jsx(D.Flex,{asChild:!0,p:0,border:0,bg:"transparent",children:f.jsx("button",{type:"button","aria-label":r,onClick:t,children:f.jsx(D.Icon,{as:e,boxSize:i,color:n,cursor:t?"pointer":void 0})})})})},Tj=({data:e,children:r,isInverted:t,isParent:n,onOpenView:i,editOnMount:o=!1})=>{var ae,se,Ce,Se,he,G;const{selectedNodeIds:s,setSelectedNodeIds:a,selectedEdgeId:l,setSelectedEdgeId:c,isMultiSelectMode:d,nodeGridOptions:u,isPerformanceMode:h,engineRef:p,callbacks:y,config:m,themeColor:g,direction:b,nodeViewModes:v}=Ve(),{background:x,border:w,colorText:C}=it(),S=j.useRef(null),_=j.useRef(null),[R,A]=j.useState(!1),[O,T]=j.useState(o&&!!m.editable&&!m.readOnly),[E,M]=j.useState(!1),P=e==null?void 0:e.id,$=ib(P),N=s.includes(P),I=m.nodeOverlayActions,K=m.renderNodeOverlay,le=(e==null?void 0:e.type)==="grid"?"20px":"-100px",ie=(e==null?void 0:e.type)==="grid"?"top center":void 0,te=(()=>{var F;try{const re=(F=p.current)==null?void 0:F.zoom();return re!==void 0&&re<.08}catch{return!1}})(),fe=j.useCallback(F=>{var ce,X,ye,ve;if(O||m.readOnly)return;const re={shiftKey:F.shiftKey,ctrlKey:F.ctrlKey,metaKey:F.metaKey,altKey:F.altKey};if(l&&(c(null),(ce=y.onEdgeDeselect)==null||ce.call(y)),d||F.shiftKey&&(u!=null&&u.fill)){const Oe=s.includes(P),Ne=Oe?s.filter(Be=>Be!==P):[...s,P];a(Ne),Oe?(X=y.onNodeDeselect)==null||X.call(y):(ye=y.onNodeSelect)==null||ye.call(y,P,e,re)}else a([P]),(ve=y.onNodeSelect)==null||ve.call(y,P,e,re)},[P,e,s,l,d,u,O,a,c,y,m]),xe=j.useCallback(()=>{var F;O||m.readOnly||(F=y.onNodeDoubleClick)==null||F.call(y,P,e)},[P,e,O,y,m]),q=j.useCallback(()=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>A(!0),100)},[]),W=j.useCallback(()=>{_.current&&clearTimeout(_.current),A(!1)},[]),U=!!((ae=e==null?void 0:e.config)!=null&&ae.form),z={tabIndex:U?0:void 0,"aria-haspopup":U?"dialog":void 0,"aria-expanded":U?E:void 0,onDoubleClickCapture:F=>{var re;!U&&!i||m.readOnly||O||!F.currentTarget.contains(F.target)||F.target instanceof Element&&F.target.closest("button, input, textarea, select, a, [contenteditable=true], [data-flow-content]")||(F.preventDefault(),F.stopPropagation(),a([P]),i?i():M(!0),(re=y.onNodeDoubleClick)==null||re.call(y,P,e))},onKeyDown:F=>{!U&&!i||m.readOnly||F.target!==F.currentTarget||F.key!=="Enter"||(F.preventDefault(),F.stopPropagation(),a([P]),i?i():M(!0))}},de=U&&f.jsx(Yd,{nodeAddress:P,active:N,label:e.label||e.headerTitle||"Node",open:E,onClose:()=>{var F;M(!1),N&&((F=S.current)==null||F.focus({preventScroll:!0}))}}),Q=Array.isArray((se=e==null?void 0:e.config)==null?void 0:se.ports)?e.config.ports.map(F=>f.jsx(Lv,{...F},`${F.id}:${F.role}`)):null;return n?f.jsxs(D.Box,{ref:S,...z,onClick:fe,onDoubleClick:xe,onMouseEnter:q,onMouseLeave:W,cursor:"pointer",position:"relative",children:[de,!h&&(K||I&&I.length>0)&&R&&!te&&f.jsxs(f.Fragment,{children:[f.jsx(D.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>A(!0),onMouseLeave:W}),K?f.jsx(D.Box,{position:"absolute",zIndex:1e3,top:le,transformOrigin:ie,left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>A(!0),onMouseLeave:W,willChange:"transform",children:K({nodeId:P,nodeData:e,isRoot:P==="root",isParent:!0,isHovered:R,setIsHovered:A})}):f.jsx(D.Box,{position:"absolute",zIndex:1e3,top:le,transformOrigin:ie,left:"50%",bg:x,p:3,borderColor:w,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>A(!0),onMouseLeave:W,willChange:"transform",children:f.jsx(D.HStack,{px:2,gap:2,children:I.map((F,re)=>f.jsxs(D.Box,{display:"contents",children:[re>0&&f.jsx(D.Box,{borderColor:w,height:5,borderRightWidth:1}),f.jsx(dd,{icon:F.icon,label:F.label,color:C,bgColor:x,borderColor:w,textColor:C,boxSize:5,onClick:ce=>{var X;ce.stopPropagation(),(X=y.onNodeHoverAction)==null||X.call(y,F.id,P,e)}})]},F.id))})})]}),r({id:P,data:e,isActive:N,isLowZoom:te,isEditing:O,onEditStart:()=>T(!0),onEditEnd:()=>T(!1)}),$&&!((Ce=e==null?void 0:e.config)!=null&&Ce.parentContainer)&&((Se=e==null?void 0:e.config)==null?void 0:Se.collapsed)!==void 0&&(()=>{var ce;const F=b==="TB"||b==="BT",re=t||b==="RL";return f.jsx(D.IconButton,{position:"absolute",...F?{[b==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:re?void 0:"-75px",left:re?"-75px":void 0,top:"50%",transform:"translateY(-50%)"},"data-flow-collapse-control":"","aria-label":e.config.collapsed?"Expand":"Collapse",disabled:m.readOnly,onClick:X=>{var ye;X.stopPropagation(),(ye=y.onNodeCollapse)==null||ye.call(y,P,!e.config.collapsed)},bgColor:_e(((ce=e==null?void 0:e.viewProps)==null?void 0:ce.bgColor)||g),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(Z.PiPlusBold,{size:30,color:_e("gray.800")}):f.jsx(Z.PiMinusBold,{size:30,color:_e("gray.800")})})})()]}):f.jsxs(D.Box,{ref:S,...z,onClick:fe,onDoubleClick:xe,onMouseEnter:q,onMouseLeave:W,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[de,Q,!h&&(K||I&&I.length>0)&&R&&!te&&f.jsxs(f.Fragment,{children:[f.jsx(D.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>A(!0),onMouseLeave:W}),K?f.jsx(D.Box,{position:"absolute",zIndex:1e3,top:le,transformOrigin:ie,left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>A(!0),onMouseLeave:W,willChange:"transform",children:K({nodeId:P,nodeData:e,isRoot:P==="root",isParent:!!n,isHovered:R,setIsHovered:A})}):f.jsx(D.Box,{position:"absolute",zIndex:1e3,top:le,transformOrigin:ie,left:"50%",bg:x,p:3,borderColor:w,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>A(!0),onMouseLeave:W,willChange:"transform",children:f.jsx(D.HStack,{px:2,gap:2,children:I.map((F,re)=>f.jsxs(D.Box,{display:"contents",children:[re>0&&f.jsx(D.Box,{borderColor:w,height:5,borderRightWidth:1}),f.jsx(dd,{icon:F.icon,label:F.label,color:C,bgColor:x,borderColor:w,textColor:C,boxSize:5,onClick:ce=>{var X;ce.stopPropagation(),(X=y.onNodeHoverAction)==null||X.call(y,F.id,P,e)}})]},F.id))})})]}),f.jsxs(D.Box,{position:"relative",display:"flex",h:"100%",w:"100%",children:[$&&!((he=e==null?void 0:e.config)!=null&&he.parentContainer)&&((G=e==null?void 0:e.config)==null?void 0:G.collapsed)!==void 0&&!n&&(()=>{var X,ye,ve;const F=b==="TB"||b==="BT",re=t||b==="RL",ce=(X=e==null?void 0:e.config)!=null&&X.labelBelow&&v[P]!=="properties"?((((ye=e==null?void 0:e.viewProps)==null?void 0:ye.fontSize)||1)*100+100)/2:void 0;return f.jsx(D.IconButton,{position:"absolute",...F?{[b==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:re?void 0:ce===void 0?"-75px":`calc(50% - ${ce+75}px)`,left:re?ce===void 0?"-75px":`calc(50% - ${ce+75}px)`:void 0,alignSelf:ce===void 0?"center":void 0,top:ce===void 0?void 0:`${ce}px`,transform:ce===void 0?void 0:"translateY(-50%)",zIndex:ce===void 0?void 0:1},"data-flow-collapse-control":"","aria-label":e.config.collapsed?"Expand":"Collapse",disabled:m.readOnly,onClick:Oe=>{var Ne;Oe.stopPropagation(),(Ne=y.onNodeCollapse)==null||Ne.call(y,P,!e.config.collapsed)},bgColor:_e(((ve=e==null?void 0:e.viewProps)==null?void 0:ve.bgColor)||g),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(Z.PiPlusBold,{size:30,color:_e("gray.800")}):f.jsx(Z.PiMinusBold,{size:30,color:_e("gray.800")})})})(),r({id:P,data:e,isActive:N,isLowZoom:te,isEditing:O,onEditStart:()=>T(!0),onEditEnd:()=>T(!1)})]})]})},$n=j.memo(Tj),Oj=({id:e,data:r,isActive:t,isEditing:n,onEditStart:i,onEditEnd:o})=>{var m,g,b,v,x,w,C,S;const{themeColor:s}=Ve(),{colorText:a}=it(),l=((m=r==null?void 0:r.viewProps)==null?void 0:m.bgColor)==="transparent",c=((g=r==null?void 0:r.viewProps)==null?void 0:g.outline)===!0,{highlightColor:d,borderColor:u,textColor:h}=An(((b=r==null?void 0:r.viewProps)==null?void 0:b.bgColor)||s),p=_e(((v=r==null?void 0:r.viewProps)==null?void 0:v.textColor)||(l||c?a:h)),y=((x=r==null?void 0:r.viewProps)==null?void 0:x.borderColor)||(c?!l&&((w=r==null?void 0:r.viewProps)==null?void 0:w.bgColor)||s:u);return f.jsx(D.Box,{"data-flow-node-surface":"",borderRadius:(C=r==null?void 0:r.viewProps)==null?void 0:C.borderRadius,bgColor:c?"transparent":d,...Rn(r==null?void 0:r.viewProps,y,t,2),py:14,px:20,whiteSpace:"nowrap",w:"fit-content",children:f.jsxs(D.Flex,{justifyContent:"start",alignItems:"center",gap:8,w:"fit-content",maxW:900,minW:0,fontSize:"5xl",lineHeight:"normal",children:[((S=r==null?void 0:r.config)==null?void 0:S.icon)&&f.jsx(D.Box,{flexShrink:0,children:f.jsx(Ht,{name:r.config.icon,size:80,color:p})}),f.jsx(Gr,{nodeId:e,label:(r==null?void 0:r.label)||(r==null?void 0:r.text)||"",color:p,isEditing:n,onEditStart:i,onEditEnd:o})]})})};function qn(){const{nodeViewModes:e,setNodeViewMode:r,allNodesIconLabel:t,setAllNodesIconLabel:n}=Ve();return{allNodesIconLabel:t,setAllNodesIconLabel:n,getNodeViewMode:i=>e[i]??"default",showNodeProperties:i=>r(i,"properties"),restoreNodeView:i=>r(i,"default"),toggleNodeView:i=>r(i,e[i]==="properties"?"default":"properties"),setNodeViewMode:r}}function Fv(e,r,t){const{readOnly:n,selectedNodeIds:i}=Ve(),o=i.includes(e),s=j.useRef(o),a=j.useRef(t);a.current=t,j.useEffect(()=>{s.current&&!o&&r&&!n&&a.current(),s.current=o},[o,r,n])}const Nj=({id:e,isActive:r,data:t,isEditing:n,onEditStart:i,onEditEnd:o})=>{var x,w,C,S,_,R,A,O,T,E,M,P,$,N,I;const{themeColor:s}=Ve(),{colorText:a}=it(),l=((x=t==null?void 0:t.viewProps)==null?void 0:x.bgColor)==="transparent",c=((w=t==null?void 0:t.viewProps)==null?void 0:w.outline)===!0,d=!l&&((C=t==null?void 0:t.viewProps)==null?void 0:C.bgColor)||s,{borderColor:u,highlightColor:h,textColor:p}=An(d),y=_e(((S=t==null?void 0:t.viewProps)==null?void 0:S.textColor)||(l||c?a:p)),m=l&&!c&&!((_=t==null?void 0:t.viewProps)!=null&&_.borderColor)?"transparent":_e(((R=t==null?void 0:t.viewProps)==null?void 0:R.borderColor)||(c?d:u)),g=l||c?"transparent":d!=null&&d.startsWith("#")?d:_e(h),b=(A=t==null?void 0:t.config)==null?void 0:A.icon,v=(t==null?void 0:t.label)??(t==null?void 0:t.text)??"";if((O=t==null?void 0:t.config)!=null&&O.labelBelow){const K=(((T=t==null?void 0:t.viewProps)==null?void 0:T.fontSize)||1)*100;return f.jsxs(D.Flex,{"data-flow-icon-label":"",css:{"--flow-grid-on-surface-color":y},direction:"column",align:"center",gap:"24px",width:`${Math.max(K+200,360)}px`,position:"relative",children:[f.jsx(D.Flex,{"data-flow-node-surface":"",align:"center",justify:"center",width:`${K+100}px`,height:`${K+100}px`,flexShrink:0,borderRadius:(E=t==null?void 0:t.viewProps)==null?void 0:E.borderRadius,backgroundColor:g,...Rn(t==null?void 0:t.viewProps,m,r,2),children:!!b&&f.jsx(Ht,{name:b,size:K,color:y})}),f.jsxs(D.Flex,{"data-flow-icon-caption":"",direction:"column",align:"center",gap:"8px",justify:"center",width:"100%",minW:0,textAlign:"center",children:[f.jsx(Gr,{nodeId:e,label:v,color:`var(--flow-grid-caption-color, ${_e(((M=t==null?void 0:t.viewProps)==null?void 0:M.textColor)||a)})`,isEditing:n,onEditStart:i,onEditEnd:o,wrap:!0}),typeof((P=t.config)==null?void 0:P.subtitle)=="string"&&t.config.subtitle!==""&&f.jsx(D.Text,{"data-flow-node-subtitle":"",color:_e((($=t==null?void 0:t.viewProps)==null?void 0:$.textColor)||a),opacity:.65,fontSize:"32px",fontWeight:"normal",lineHeight:1.3,width:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",title:t.config.subtitle,children:t.config.subtitle})]})]})}return f.jsxs(D.Flex,{"data-flow-node-surface":"",align:"center",borderRadius:(N=t==null?void 0:t.viewProps)==null?void 0:N.borderRadius,bgColor:g,style:{backgroundColor:g},textTransform:"capitalize",...Rn(t==null?void 0:t.viewProps,m,r,2),px:50,w:"fit-content",whiteSpace:"nowrap",children:[!!b&&f.jsx(D.Flex,{align:"center",py:14,mr:v?8:0,flexShrink:0,children:f.jsx(Ht,{name:b,size:(((I=t==null?void 0:t.viewProps)==null?void 0:I.fontSize)||1)*100,color:y},y)}),(v||!b)&&f.jsx(D.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:"fit-content",maxW:900,minW:0,children:f.jsx(Gr,{nodeId:e,label:v,color:y,isEditing:n,onEditStart:i,onEditEnd:o})})]})};function Qd({onExpand:e,toggleLabel:r="Show properties",toggleDisabled:t=!1,renderCompact:n=Nj,...i}){const{colorMode:o,callbacks:s}=Ve();return f.jsx($n,{...i,children:a=>f.jsxs(D.Box,{position:"relative",children:[f.jsx(n,{...a}),e&&a.isActive&&f.jsx(D.Box,{position:"absolute",top:"-24px",right:"-48px","data-flow-content-toggle":"",children:f.jsx(Fe,{label:r,children:f.jsx(Ae,{"aria-label":r,icon:f.jsx(D.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:o==="dark"?"gray.100":"gray.800",disabled:t,onClick:l=>{var c;l.stopPropagation(),e(),(c=s.onNodeViewToggle)==null||c.call(s,i.data.id)}})})})]})})}const $j=`${jb}
|
|
280
|
+
`;function Qd({nodeAddress:e,active:r,label:t,open:n=!1,onClose:i,children:o,filter:s,height:a,width:c}){const{background:l,border:d,colorText:u}=ot(),{colorMode:h}=Ue(),p=S.useRef(null),y=S.useId(),{data:m,schema:g,bindings:b}=S.useContext(It),v=o!==void 0||!!(m&&g&&(b?Pn(b,e,g):Jr(m,e,g)));S.useEffect(()=>{var w,C,j,_,k;!r||!v||!n?(w=p.current)==null||w.close():(C=p.current)!=null&&C.open||((j=p.current)==null||j.showModal(),(k=(_=p.current)==null?void 0:_.querySelector("[data-form-filter] input"))==null||k.focus())},[r,v,n]);const x=_e(l);return v?f.jsx(f.Fragment,{children:typeof document<"u"&&Br.createPortal(f.jsx(Ij,{ref:p,id:y,$surface:x,$border:_e(d),"aria-label":`Configure ${t}`,onClose:i,onPointerDown:w=>w.stopPropagation(),onWheel:w=>w.stopPropagation(),onKeyDown:w=>w.stopPropagation(),onClick:w=>{var C;w.stopPropagation(),w.target===w.currentTarget&&((C=p.current)==null||C.close())},style:{position:"fixed",inset:"94px 20px auto auto",margin:0,padding:20,width:c??"var(--top-toolbar-width, 360px)",boxSizing:"border-box",maxWidth:"calc(100vw - 40px)",maxHeight:"calc(100dvh - 114px)",height:a,overflow:"hidden",borderRadius:30,background:x,color:_e(u),fontSize:16,textTransform:"none"},children:n&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexShrink:0},children:[f.jsx("strong",{style:{overflowWrap:"anywhere",minWidth:0},children:t}),f.jsx(Kr,{"aria-label":"Close node configuration",onClick:()=>{var w;return(w=p.current)==null?void 0:w.close()}})]}),s&&f.jsx("div",{"data-form-filter":"",style:{flexShrink:0},children:s}),f.jsx(Mj,{$divider:`var(--chakra-colors-gray-${h==="dark"?"700":"200"})`,"data-form-scroll":"",style:a?{flex:1}:void 0,children:o??f.jsx(Ed,{nodeAddress:e})})]})}),document.body)}):null}const ud=({icon:e,label:r,onClick:t,color:n,boxSize:i=6,...o})=>{const{background:s,border:a,colorText:c}=ot();return f.jsx(ze,{label:r,children:f.jsx(W.Flex,{asChild:!0,p:0,border:0,bg:"transparent",children:f.jsx("button",{type:"button","aria-label":r,onClick:t,children:f.jsx(W.Icon,{as:e,boxSize:i,color:n,cursor:t?"pointer":void 0})})})})},Tj=({data:e,children:r,isInverted:t,isParent:n,onOpenView:i,editOnMount:o=!1})=>{var oe,ce,we,Se,ye,pe;const{selectedNodeIds:s,setSelectedNodeIds:a,selectedEdgeId:c,setSelectedEdgeId:l,isMultiSelectMode:d,nodeGridOptions:u,isPerformanceMode:h,engineRef:p,callbacks:y,config:m,themeColor:g,direction:b,nodeViewModes:v}=Ue(),{background:x,border:w,colorText:C}=ot(),j=S.useRef(null),_=S.useRef(null),[k,E]=S.useState(!1),[O,T]=S.useState(o&&!!m.editable&&!m.readOnly),[P,I]=S.useState(!1),R=e==null?void 0:e.id,$=ab(R),N=s.includes(R),M=m.nodeOverlayActions,J=m.renderNodeOverlay,ie=(e==null?void 0:e.type)==="grid"?"20px":"-100px",ae=(e==null?void 0:e.type)==="grid"?"top center":void 0,te=(()=>{var B;try{const G=(B=p.current)==null?void 0:B.zoom();return G!==void 0&&G<.08}catch{return!1}})(),he=S.useCallback(B=>{var se,H,ue,xe;if(O||m.readOnly)return;const G={shiftKey:B.shiftKey,ctrlKey:B.ctrlKey,metaKey:B.metaKey,altKey:B.altKey};if(c&&(l(null),(se=y.onEdgeDeselect)==null||se.call(y)),d||B.shiftKey&&(u!=null&&u.fill)){const Oe=s.includes(R),Ne=Oe?s.filter(Be=>Be!==R):[...s,R];a(Ne),Oe?(H=y.onNodeDeselect)==null||H.call(y):(ue=y.onNodeSelect)==null||ue.call(y,R,e,G)}else a([R]),(xe=y.onNodeSelect)==null||xe.call(y,R,e,G)},[R,e,s,c,d,u,O,a,l,y,m]),me=S.useCallback(()=>{var B;O||m.readOnly||(B=y.onNodeDoubleClick)==null||B.call(y,R,e)},[R,e,O,y,m]),q=S.useCallback(()=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>E(!0),100)},[]),F=S.useCallback(()=>{_.current&&clearTimeout(_.current),E(!1)},[]),U=!!((oe=e==null?void 0:e.config)!=null&&oe.form),D={tabIndex:U?0:void 0,"aria-haspopup":U?"dialog":void 0,"aria-expanded":U?P:void 0,onDoubleClickCapture:B=>{var G;!U&&!i||m.readOnly||O||!B.currentTarget.contains(B.target)||B.target instanceof Element&&B.target.closest("button, input, textarea, select, a, [contenteditable=true], [data-flow-content]")||(B.preventDefault(),B.stopPropagation(),a([R]),i?i():I(!0),(G=y.onNodeDoubleClick)==null||G.call(y,R,e))},onKeyDown:B=>{!U&&!i||m.readOnly||B.target!==B.currentTarget||B.key!=="Enter"||(B.preventDefault(),B.stopPropagation(),a([R]),i?i():I(!0))}},de=U&&f.jsx(Qd,{nodeAddress:R,active:N,label:e.label||e.headerTitle||"Node",open:P,onClose:()=>{var B;I(!1),N&&((B=j.current)==null||B.focus({preventScroll:!0}))}}),Q=Array.isArray((ce=e==null?void 0:e.config)==null?void 0:ce.ports)?e.config.ports.map(B=>f.jsx(Fv,{...B},`${B.id}:${B.role}`)):null;return n?f.jsxs(W.Box,{ref:j,...D,onClick:he,onDoubleClick:me,onMouseEnter:q,onMouseLeave:F,cursor:"pointer",position:"relative",children:[de,!h&&(J||M&&M.length>0)&&k&&!te&&f.jsxs(f.Fragment,{children:[f.jsx(W.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>E(!0),onMouseLeave:F}),J?f.jsx(W.Box,{position:"absolute",zIndex:1e3,top:ie,transformOrigin:ae,left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>E(!0),onMouseLeave:F,willChange:"transform",children:J({nodeId:R,nodeData:e,isRoot:R==="root",isParent:!0,isHovered:k,setIsHovered:E})}):f.jsx(W.Box,{position:"absolute",zIndex:1e3,top:ie,transformOrigin:ae,left:"50%",bg:x,p:3,borderColor:w,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>E(!0),onMouseLeave:F,willChange:"transform",children:f.jsx(W.HStack,{px:2,gap:2,children:M.map((B,G)=>f.jsxs(W.Box,{display:"contents",children:[G>0&&f.jsx(W.Box,{borderColor:w,height:5,borderRightWidth:1}),f.jsx(ud,{icon:B.icon,label:B.label,color:C,bgColor:x,borderColor:w,textColor:C,boxSize:5,onClick:se=>{var H;se.stopPropagation(),(H=y.onNodeHoverAction)==null||H.call(y,B.id,R,e)}})]},B.id))})})]}),r({id:R,data:e,isActive:N,isLowZoom:te,isEditing:O,onEditStart:()=>T(!0),onEditEnd:()=>T(!1)}),$&&!((we=e==null?void 0:e.config)!=null&&we.parentContainer)&&((Se=e==null?void 0:e.config)==null?void 0:Se.collapsed)!==void 0&&(()=>{var se;const B=b==="TB"||b==="BT",G=t||b==="RL";return f.jsx(W.IconButton,{position:"absolute",...B?{[b==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:G?void 0:"-75px",left:G?"-75px":void 0,top:"50%",transform:"translateY(-50%)"},"data-flow-collapse-control":"","aria-label":e.config.collapsed?"Expand":"Collapse",disabled:m.readOnly,onClick:H=>{var ue;H.stopPropagation(),(ue=y.onNodeCollapse)==null||ue.call(y,R,!e.config.collapsed)},bgColor:_e(((se=e==null?void 0:e.viewProps)==null?void 0:se.bgColor)||g),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(X.PiPlusBold,{size:30,color:_e("gray.800")}):f.jsx(X.PiMinusBold,{size:30,color:_e("gray.800")})})})()]}):f.jsxs(W.Box,{ref:j,...D,onClick:he,onDoubleClick:me,onMouseEnter:q,onMouseLeave:F,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[de,Q,!h&&(J||M&&M.length>0)&&k&&!te&&f.jsxs(f.Fragment,{children:[f.jsx(W.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>E(!0),onMouseLeave:F}),J?f.jsx(W.Box,{position:"absolute",zIndex:1e3,top:ie,transformOrigin:ae,left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>E(!0),onMouseLeave:F,willChange:"transform",children:J({nodeId:R,nodeData:e,isRoot:R==="root",isParent:!!n,isHovered:k,setIsHovered:E})}):f.jsx(W.Box,{position:"absolute",zIndex:1e3,top:ie,transformOrigin:ae,left:"50%",bg:x,p:3,borderColor:w,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>E(!0),onMouseLeave:F,willChange:"transform",children:f.jsx(W.HStack,{px:2,gap:2,children:M.map((B,G)=>f.jsxs(W.Box,{display:"contents",children:[G>0&&f.jsx(W.Box,{borderColor:w,height:5,borderRightWidth:1}),f.jsx(ud,{icon:B.icon,label:B.label,color:C,bgColor:x,borderColor:w,textColor:C,boxSize:5,onClick:se=>{var H;se.stopPropagation(),(H=y.onNodeHoverAction)==null||H.call(y,B.id,R,e)}})]},B.id))})})]}),f.jsxs(W.Box,{position:"relative",display:"flex",h:"100%",w:"100%",children:[$&&!((ye=e==null?void 0:e.config)!=null&&ye.parentContainer)&&((pe=e==null?void 0:e.config)==null?void 0:pe.collapsed)!==void 0&&!n&&(()=>{var H,ue,xe;const B=b==="TB"||b==="BT",G=t||b==="RL",se=(H=e==null?void 0:e.config)!=null&&H.labelBelow&&v[R]!=="properties"?((((ue=e==null?void 0:e.viewProps)==null?void 0:ue.fontSize)||1)*100+100)/2:void 0;return f.jsx(W.IconButton,{position:"absolute",...B?{[b==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:G?void 0:se===void 0?"-75px":`calc(50% - ${se+75}px)`,left:G?se===void 0?"-75px":`calc(50% - ${se+75}px)`:void 0,alignSelf:se===void 0?"center":void 0,top:se===void 0?void 0:`${se}px`,transform:se===void 0?void 0:"translateY(-50%)",zIndex:se===void 0?void 0:1},"data-flow-collapse-control":"","aria-label":e.config.collapsed?"Expand":"Collapse",disabled:m.readOnly,onClick:Oe=>{var Ne;Oe.stopPropagation(),(Ne=y.onNodeCollapse)==null||Ne.call(y,R,!e.config.collapsed)},bgColor:_e(((xe=e==null?void 0:e.viewProps)==null?void 0:xe.bgColor)||g),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(X.PiPlusBold,{size:30,color:_e("gray.800")}):f.jsx(X.PiMinusBold,{size:30,color:_e("gray.800")})})})(),r({id:R,data:e,isActive:N,isLowZoom:te,isEditing:O,onEditStart:()=>T(!0),onEditEnd:()=>T(!1)})]})]})},$n=S.memo(Tj),Oj=({id:e,data:r,isActive:t,isEditing:n,onEditStart:i,onEditEnd:o})=>{var m,g,b,v,x,w,C,j;const{themeColor:s}=Ue(),{colorText:a}=ot(),c=((m=r==null?void 0:r.viewProps)==null?void 0:m.bgColor)==="transparent",l=((g=r==null?void 0:r.viewProps)==null?void 0:g.outline)===!0,{highlightColor:d,borderColor:u,textColor:h}=An(((b=r==null?void 0:r.viewProps)==null?void 0:b.bgColor)||s),p=_e(((v=r==null?void 0:r.viewProps)==null?void 0:v.textColor)||(c||l?a:h)),y=((x=r==null?void 0:r.viewProps)==null?void 0:x.borderColor)||(l?!c&&((w=r==null?void 0:r.viewProps)==null?void 0:w.bgColor)||s:u);return f.jsx(W.Box,{"data-flow-node-surface":"",borderRadius:(C=r==null?void 0:r.viewProps)==null?void 0:C.borderRadius,bgColor:l?"transparent":d,...Rn(r==null?void 0:r.viewProps,y,t,2),py:14,px:20,whiteSpace:"nowrap",w:"fit-content",children:f.jsxs(W.Flex,{justifyContent:"start",alignItems:"center",gap:8,w:"fit-content",maxW:900,minW:0,fontSize:"5xl",lineHeight:"normal",children:[((j=r==null?void 0:r.config)==null?void 0:j.icon)&&f.jsx(W.Box,{flexShrink:0,children:f.jsx(Ht,{name:r.config.icon,size:80,color:p})}),f.jsx(Ur,{nodeId:e,label:(r==null?void 0:r.label)||(r==null?void 0:r.text)||"",color:p,isEditing:n,onEditStart:i,onEditEnd:o})]})})};function qn(){const{nodeViewModes:e,setNodeViewMode:r,allNodesIconLabel:t,setAllNodesIconLabel:n}=Ue();return{allNodesIconLabel:t,setAllNodesIconLabel:n,getNodeViewMode:i=>e[i]??"default",showNodeProperties:i=>r(i,"properties"),restoreNodeView:i=>r(i,"default"),toggleNodeView:i=>r(i,e[i]==="properties"?"default":"properties"),setNodeViewMode:r}}function eu(e,r,t){const{readOnly:n,selectedNodeIds:i}=Ue(),o=i.includes(e),s=S.useRef(o),a=S.useRef(t);a.current=t,S.useEffect(()=>{s.current&&!o&&r&&!n&&a.current(),s.current=o},[o,r,n])}const Nj=({id:e,isActive:r,data:t,isEditing:n,onEditStart:i,onEditEnd:o})=>{var x,w,C,j,_,k,E,O,T,P,I,R,$,N,M;const{themeColor:s}=Ue(),{colorText:a}=ot(),c=((x=t==null?void 0:t.viewProps)==null?void 0:x.bgColor)==="transparent",l=((w=t==null?void 0:t.viewProps)==null?void 0:w.outline)===!0,d=!c&&((C=t==null?void 0:t.viewProps)==null?void 0:C.bgColor)||s,{borderColor:u,highlightColor:h,textColor:p}=An(d),y=_e(((j=t==null?void 0:t.viewProps)==null?void 0:j.textColor)||(c||l?a:p)),m=c&&!l&&!((_=t==null?void 0:t.viewProps)!=null&&_.borderColor)?"transparent":_e(((k=t==null?void 0:t.viewProps)==null?void 0:k.borderColor)||(l?d:u)),g=c||l?"transparent":d!=null&&d.startsWith("#")?d:_e(h),b=(E=t==null?void 0:t.config)==null?void 0:E.icon,v=(t==null?void 0:t.label)??(t==null?void 0:t.text)??"";if((O=t==null?void 0:t.config)!=null&&O.labelBelow){const J=(((T=t==null?void 0:t.viewProps)==null?void 0:T.fontSize)||1)*100;return f.jsxs(W.Flex,{"data-flow-icon-label":"",css:{"--flow-grid-on-surface-color":y},direction:"column",align:"center",gap:"24px",width:`${Math.max(J+200,360)}px`,position:"relative",children:[f.jsx(W.Flex,{"data-flow-node-surface":"",align:"center",justify:"center",width:`${J+100}px`,height:`${J+100}px`,flexShrink:0,borderRadius:(P=t==null?void 0:t.viewProps)==null?void 0:P.borderRadius,backgroundColor:g,...Rn(t==null?void 0:t.viewProps,m,r,2),children:!!b&&f.jsx(Ht,{name:b,size:J,color:y})}),f.jsxs(W.Flex,{"data-flow-icon-caption":"",direction:"column",align:"center",gap:"8px",justify:"center",width:"100%",minW:0,textAlign:"center",children:[f.jsx(Ur,{nodeId:e,label:v,color:`var(--flow-grid-caption-color, ${_e(((I=t==null?void 0:t.viewProps)==null?void 0:I.textColor)||a)})`,isEditing:n,onEditStart:i,onEditEnd:o,wrap:!0}),typeof((R=t.config)==null?void 0:R.subtitle)=="string"&&t.config.subtitle!==""&&f.jsx(W.Text,{"data-flow-node-subtitle":"",color:_e((($=t==null?void 0:t.viewProps)==null?void 0:$.textColor)||a),opacity:.65,fontSize:"32px",fontWeight:"normal",lineHeight:1.3,width:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",title:t.config.subtitle,children:t.config.subtitle})]})]})}return f.jsxs(W.Flex,{"data-flow-node-surface":"",align:"center",borderRadius:(N=t==null?void 0:t.viewProps)==null?void 0:N.borderRadius,bgColor:g,style:{backgroundColor:g},textTransform:"capitalize",...Rn(t==null?void 0:t.viewProps,m,r,2),px:50,w:"fit-content",whiteSpace:"nowrap",children:[!!b&&f.jsx(W.Flex,{align:"center",py:14,mr:v?8:0,flexShrink:0,children:f.jsx(Ht,{name:b,size:(((M=t==null?void 0:t.viewProps)==null?void 0:M.fontSize)||1)*100,color:y},y)}),(v||!b)&&f.jsx(W.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:"fit-content",maxW:900,minW:0,children:f.jsx(Ur,{nodeId:e,label:v,color:y,isEditing:n,onEditStart:i,onEditEnd:o})})]})};function tu({onExpand:e,toggleLabel:r="Show properties",toggleDisabled:t=!1,renderCompact:n=Nj,...i}){const{colorMode:o,callbacks:s}=Ue();return f.jsx($n,{...i,children:a=>f.jsxs(W.Box,{position:"relative",children:[f.jsx(n,{...a}),e&&a.isActive&&f.jsx(W.Box,{position:"absolute",top:"-24px",right:"-48px","data-flow-content-toggle":"",children:f.jsx(ze,{label:r,children:f.jsx(Ae,{"aria-label":r,icon:f.jsx(W.Icon,{as:X.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:o==="dark"?"gray.100":"gray.800",disabled:t,onClick:c=>{var l;c.stopPropagation(),e(),(l=s.onNodeViewToggle)==null||l.call(s,i.data.id)}})})})]})})}const $j=`${_b}
|
|
281
281
|
[data-flow-loading-border][data-flow-loading-border] .flow-sdk-node-border-animation{animation:flow-sdk-node-border 2.4s linear infinite!important}
|
|
282
282
|
[data-flow-loading-border][data-flow-loading-border][data-motion-disabled] .flow-sdk-node-border-animation{animation:none!important}
|
|
283
|
-
@media(prefers-reduced-motion:reduce){[data-flow-loading-border][data-flow-loading-border] .flow-sdk-node-border-animation{animation:none!important}}`;function zv({active:e=!0,label:r="Loading content",radius:t}){const{config:n,themeColor:i}=Ve(),{colorText:o}=it(),s=j.useRef(null),[a,l]=j.useState({width:0,height:0,radius:0});if(j.useLayoutEffect(()=>{const u=s.current;if(!e||!u)return;const h=()=>{const y=u.parentElement,m={width:u.clientWidth,height:u.clientHeight,radius:t??(y&&parseFloat(getComputedStyle(y).borderTopLeftRadius)||0)};l(g=>g.width===m.width&&g.height===m.height&&g.radius===m.radius?g:m)},p=new ResizeObserver(h);return p.observe(u),h(),()=>p.disconnect()},[e,t]),!e)return null;const c=_e(i||o),d={x:4,y:4,width:a.width-8,height:a.height-8,radius:Math.max(0,a.radius-4),color:c,strokeWidth:2};return f.jsxs("div",{ref:s,role:"status","aria-label":r,"data-flow-loading-border":"","data-motion-disabled":n.disableAnimations||void 0,style:{position:"absolute",inset:0,pointerEvents:"none",borderRadius:"inherit",overflow:"hidden",zIndex:2},children:[f.jsx("style",{children:$j}),f.jsxs("svg",{width:"100%",height:"100%","aria-hidden":"true",style:{display:"block",pointerEvents:"none"},children:[f.jsx("g",{opacity:.5,style:{filter:"blur(3px)"},children:f.jsx(Zn,{...d,strokeWidth:6})}),f.jsx(Zn,{...d})]})]})}function qj({content:e,format:r,onEdit:t}){var $;const{config:n,colorMode:i}=Ve(),{background:o,border:s,colorInactive:a}=it(),l=($=n.customViews)==null?void 0:$.jsxContent,c=typeof e=="string"?e:JSON.stringify(e,null,2);let d,u;if(r==="jsx")try{const N=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(N)||N.some(I=>!I||typeof I!="object"||Array.isArray(I)||typeof I.type!="string"))throw new Error("JSX content must be an array of components with a type.");d=N}catch(N){u=N instanceof Error?N.message:"Invalid components array."}const h=j.useRef(null),p=j.useRef(null),y=j.useRef(null),m=j.useRef(!1),[g,b]=j.useState(!1),[v,x]=j.useState(""),w=!!t;j.useEffect(()=>{const N=()=>{var K;const I=document.fullscreenElement===p.current;b(I),m.current&&!I&&!document.fullscreenElement&&((K=y.current)==null||K.focus({preventScroll:!0})),m.current=I};return document.addEventListener("fullscreenchange",N),()=>document.removeEventListener("fullscreenchange",N)},[]);const C=async()=>{var N;x("");try{if(document.fullscreenElement===p.current)await document.exitFullscreen();else if((N=p.current)!=null&&N.requestFullscreen)await p.current.requestFullscreen();else throw new Error("Fullscreen is not supported in this browser.")}catch(I){x(I instanceof Error?I.message:"Unable to change fullscreen.")}},[S,_]=j.useState(),[R,A]=j.useState(),[O,T]=j.useState();j.useEffect(()=>{if(r==="jsx")return;let N=!1;return Promise.resolve().then(()=>require("./contentPreviewDocument-B_Jous_v.cjs")).then(({contentPreviewDocument:I})=>I(c,r,w)).then(I=>{N||_({content:c,format:r,editable:w,document:I})},I=>{N||_({content:c,format:r,editable:w,error:I instanceof Error?I.message:String(I)})}),()=>{N=!0}},[c,r,w]),j.useEffect(()=>{if(!t)return;const N=async I=>{var K,le;if(!(!((K=h.current)!=null&&K.contentWindow)||I.source!==h.current.contentWindow||((le=I.data)==null?void 0:le.type)!=="squeed:content-edit"))try{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()}catch(ie){x(ie instanceof Error?ie.message:"Unable to close fullscreen.")}};return window.addEventListener("message",N),()=>window.removeEventListener("message",N)},[t]);const E=(S==null?void 0:S.content)===c&&S.format===r&&S.editable===w?S:void 0,M=!!E&&E===O,P=r!=="jsx"&&!(E!=null&&E.error)&&!M&&(!E||R!==E);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:c}),f.jsxs(D.Box,{ref:p,position:"relative",w:"100%",h:"100%","aria-busy":r!=="jsx"?P:void 0,bg:r==="jsx"&&i==="dark"?"gray.900":"white",onDoubleClick:N=>{r!=="jsx"||!t||N.defaultPrevented||N.target.closest('button, a, input, textarea, select, [contenteditable], [role="button"], [role="textbox"]')||(N.stopPropagation(),(async()=>{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()})().catch(I=>x(String(I))))},onKeyDownCapture:N=>{N.key!=="Escape"||document.fullscreenElement!==p.current||(N.preventDefault(),N.stopPropagation(),C())},css:{"&:fullscreen":{width:"100vw",height:"100dvh",maxWidth:"none",maxHeight:"none",padding:0},"&:hover > [data-flow-content-toolbar], &:focus-within > [data-flow-content-toolbar]":{opacity:1,pointerEvents:"auto"},"@media (hover: none)":{"& > [data-flow-content-toolbar]":{opacity:1,pointerEvents:"auto"}}},children:[f.jsx(D.Box,{role:"toolbar","aria-label":"Content controls","data-flow-content-toolbar":"",position:"absolute",top:"8px",right:"8px",zIndex:1,w:"max-content",maxW:"calc(100% - 16px)",opacity:g?1:0,pointerEvents:g?"auto":"none",children:f.jsx(Rd,{background:o,border:i==="dark"?s:"gray.300",children:f.jsxs(D.HStack,{px:"8px",gap:"8px",h:"100%",w:"max-content",css:{"& button > svg":{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",flexShrink:0}},children:[t&&f.jsx(Ae,{"data-flow-content-edit":"","aria-label":"Edit content source",title:"Edit content source",icon:f.jsx(Z.PiCode,{size:20}),size:"sm",variant:"plain",bg:"transparent",color:a,borderRadius:"30px",w:"32px",h:"32px",minW:"32px",p:0,onClick:N=>{N.stopPropagation(),(async()=>{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()})().catch(I=>x(String(I)))}}),f.jsx(Ae,{ref:y,"data-flow-fullscreen":"","aria-label":g?"Exit fullscreen":"Expand preview",title:g?"Exit fullscreen":"Expand preview","aria-expanded":g,icon:g?f.jsx(Z.PiArrowsIn,{size:20}):f.jsx(Z.PiArrowsOut,{size:20}),size:"sm",variant:"plain",bg:"transparent",color:a,borderRadius:"30px",w:"32px",h:"32px",minW:"32px",p:0,onClick:N=>{N.stopPropagation(),C()}})]})})}),v&&f.jsx(D.Box,{role:"alert",position:"absolute",bottom:0,insetInline:0,bg:"white",color:"red.700",fontSize:"14px",children:v}),r==="jsx"?u?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:u}):l&&d?f.jsx(l,{components:d,colorMode:i,fillHeight:!0}):f.jsx(D.Box,{role:"status",fontSize:"14px",children:"JSX content renderer is not available."}):E!=null&&E.error||M?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:(E==null?void 0:E.error)||"Content preview could not be loaded."}):E!=null&&E.document?f.jsx("iframe",{ref:h,title:`${r.toUpperCase()} content preview`,sandbox:w?"allow-scripts":"",allowFullScreen:!0,referrerPolicy:"no-referrer",srcDoc:E.document,onLoad:()=>A(E),onError:()=>T(E),style:{width:"100%",height:"100%",border:0,display:"block",background:"white",visibility:P?"hidden":"visible"}},E.document):null,f.jsx(zv,{active:P,label:"Loading HTML content"})]})]})}const fm=1.55;function Lj({nodeId:e,content:r,color:t,format:n="markdown"}){const{callbacks:i,config:o,readOnly:s,nodeGridOptions:a}=Ve(),l=!!o.editable&&!s&&!a,c=typeof r=="string"?r:JSON.stringify(r,null,2),[d,u]=j.useState(!1),[h,p]=j.useState(c),[y,m]=j.useState(""),[g,b]=j.useState(),v=j.useRef(null),x=j.useRef(!1),w=Xd(d);j.useLayoutEffect(()=>{const _=v.current;!d||!_||(_.style.height="auto",_.style.height=`${Math.max((g==null?void 0:g.height)??0,_.scrollHeight)}px`)},[h,d,g]),j.useEffect(()=>{var _,R;l?d&&(x.current=!1,(_=v.current)==null||_.focus({preventScroll:!0}),(R=v.current)==null||R.select()):u(!1)},[d,l]);const C=_=>{l&&(b({width:_.offsetWidth,height:_.offsetHeight}),p(c),m(""),u(!0))},S=()=>{var R;if(x.current||!l)return;let _=h;if(n==="jsx")try{if(_=JSON.parse(h),!Array.isArray(_)||_.some(A=>!A||typeof A!="object"||Array.isArray(A)||typeof A.type!="string"))throw new Error("JSX content must be an array of components with a type.")}catch(A){m(A instanceof Error?A.message:"Invalid components array.");return}x.current=!0,h!==c&&((R=i.onNodeContentChange)==null||R.call(i,e,_)),u(!1)};return(!d||!l)&&n!=="markdown"?f.jsx(D.Box,{ref:w,w:"100%",position:"relative","data-flow-content":"",children:f.jsx(qj,{content:r,format:n,onEdit:l?()=>{w.current&&C(w.current)}:void 0})}):!d||!l?f.jsx(D.Box,{"data-flow-content":"",color:t,opacity:r?void 0:.6,w:"100%",minH:"1.2em",whiteSpace:"normal",lineHeight:fm,overflowWrap:"anywhere",css:{"& > :first-of-type":{marginTop:0},"& > :last-of-type":{marginBottom:0},"& h1, & h2, & h3, & h4, & h5, & h6":{fontWeight:700,lineHeight:1.2,margin:"1em 0 0.45em"},"& h1":{fontSize:"1.5em"},"& h2":{fontSize:"1.3em"},"& h3":{fontSize:"1.1em"},"& p":{margin:"0.65em 0",whiteSpace:"pre-wrap"},"& ul, & ol":{margin:"0.65em 0",paddingInlineStart:"1.6em"},"& ul":{listStyleType:"disc"},"& ol":{listStyleType:"decimal"},"& li":{display:"list-item",margin:"0.3em 0",paddingInlineStart:"0.15em"},"& li > ul, & li > ol":{margin:"0.25em 0"},"& li > p":{margin:0},"& a":{color:"inherit",textDecoration:"underline"},"& code":{fontFamily:"monospace",fontSize:"0.85em"},"& :not(pre) > code":{background:"color-mix(in srgb, currentColor 10%, transparent)",padding:"0.1em 0.25em",borderRadius:"0.2em"},"& pre":{margin:"0.75em 0",padding:"0.75em",background:"color-mix(in srgb, currentColor 8%, transparent)",border:0,borderRadius:"6px",maxWidth:"100%",overflowX:"auto",whiteSpace:"pre",overflowWrap:"normal",lineHeight:1.5},"& pre code":{background:"transparent",padding:0,whiteSpace:"inherit"},"& strong":{fontWeight:700},"& em":{fontStyle:"italic"},"& blockquote":{margin:"0.4em 0",borderInlineStart:"0.1em solid currentColor",paddingInlineStart:"0.6em"},"& table":{width:"100%",tableLayout:"fixed",borderCollapse:"collapse",margin:"0.4em 0"},"& th, & td":{border:"1px solid currentColor",padding:"0.2em 0.3em",textAlign:"left"},"& th":{fontWeight:700},"& img":{maxWidth:"100%",height:"auto"}},cursor:l?"text":void 0,tabIndex:l?0:void 0,outline:"none",_focusVisible:{outline:"none",boxShadow:"none"},onClick:_=>{!l||_.target instanceof Element&&_.target.closest("a, button, input")||(_.stopPropagation(),C(_.currentTarget))},onDoubleClick:_=>{_.stopPropagation(),C(_.currentTarget)},onKeyDown:_=>{l&&_.key==="Enter"&&_.target===_.currentTarget&&(_.preventDefault(),_.stopPropagation(),C(_.currentTarget))},children:f.jsx(ux.default,{options:{forceBlock:!0,wrapper:j.Fragment,disableParsingRawHTML:!0,overrides:{a:{props:{target:"_blank",rel:"noopener noreferrer"}},img:{props:{loading:"lazy",referrerPolicy:"no-referrer"}}}},children:c||(l?"Write your content here":"")})}):f.jsxs("div",{ref:w,style:{width:g==null?void 0:g.width,minHeight:g==null?void 0:g.height,maxWidth:"100%"},children:[f.jsx(D.Textarea,{ref:v,"aria-label":"Node content",placeholder:"Write your content here",value:h,"aria-invalid":!!y,onChange:_=>p(_.target.value),onBlur:S,onKeyDown:_=>{_.stopPropagation(),!_.nativeEvent.isComposing&&(_.key==="Enter"&&(_.ctrlKey||_.metaKey)&&(_.preventDefault(),S()),_.key==="Escape"&&(x.current=!0,u(!1)))},color:t,fontFamily:"inherit",fontSize:"inherit",lineHeight:fm,overflowWrap:"anywhere",whiteSpace:"pre-wrap",rows:1,bg:"transparent",display:"block",style:{border:0,outline:"none",boxShadow:"none"},_focus:{border:0,outline:"none",boxShadow:"none"},_focusVisible:{border:0,outline:"none",boxShadow:"none"},p:0,w:"100%",h:"100%",minW:0,minH:0,resize:"none"}),y&&f.jsx(D.Box,{role:"alert",fontSize:"14px",color:"red.500",children:y})]})}const Fj=(e,r,t)=>{var h,p,y,m;const n=((h=e==null?void 0:e.viewProps)==null?void 0:h.bgColor)||r,[i]=n.split("."),o=An(n),s=((p=e==null?void 0:e.viewProps)==null?void 0:p.outline)===!0,a=n==="transparent"||s,l=t==="dark"?"gray.200":"gray.900",c=a?"transparent":n!=null&&n.startsWith("#")?_e(n):_e(o.bgColor),d=_e(((y=e==null?void 0:e.viewProps)==null?void 0:y.textColor)||(a?l:o.textColor)),u=_e(((m=e==null?void 0:e.viewProps)==null?void 0:m.borderColor)||(s?n==="transparent"?r:n:o.borderColor));return{...o,bgColor:a?"transparent":o.bgColor,highlightColor:a?"transparent":o.highlightColor,isTransparent:a,propertyColor:a?l:o.propertyColor,bg:n,wordBeforeDot:i,hexbgColor:c,hextextColor:d,hexborderColor:u}},zj=(e,r=350)=>`${String(e).substring(0,r)}${String(e).length>r?"...":""}`,Bj=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,Bv=600,Dj=3,Vj=e=>{const r=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(r*28+30,200)};function Wj({headerTitle:e,hasContent:r,data:t,icon:n,colors:i,hasConfig:o,id:s,isActive:a,isEditing:l,onEditStart:c,onEditEnd:d,props:u,objVisible:h,setObjVisible:p,onShowNativeIcon:y}){var v,x;const{callbacks:m}=Ve(),g=u.onShowIcon??y,b=g?"Show icon":h?"Show content":"Show properties";return f.jsx(f.Fragment,{children:(e||r||((v=t.config)==null?void 0:v.form)||a&&y)&&f.jsxs(D.Flex,{justify:"flex-start",direction:"row",p:r||Object.entries(t.description||{}).length?8:20,borderBottomWidth:1,minWidth:"max-content !important",width:"100%",textTransform:"capitalize",align:"center",textOverflow:"ellipsis",alignItems:"center",fontWeight:"bold",color:i.propertyColor,bgColor:i.highlightColor,borderBottomColor:!o&&!r?"transparent":i.hexborderColor,children:[!!n&&f.jsx(D.Flex,{mr:6,alignItems:"center",flexShrink:0,children:f.jsx(Ht,{name:n,size:64,color:i.hextextColor},i.hextextColor)}),f.jsx(Gr,{nodeId:s,label:Bj(e),color:((x=t==null?void 0:t.viewProps)==null?void 0:x.textColor)||i.propertyColor,isEditing:l,onEditStart:c,onEditEnd:d}),a&&(r||g)&&f.jsx(D.Box,{ml:"auto",pl:6,flexShrink:0,"data-flow-content-toggle":"",children:f.jsx(Fe,{label:b,children:f.jsx(Ae,{"aria-label":b,icon:f.jsx(D.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:i.hextextColor,onClick:w=>{var C;w.stopPropagation(),g?g():p(!h),(C=m.onNodeViewToggle)==null||C.call(m,s)}})})})]})})}function Gj({data:e,resourcePorts:r,inspecting:t,form:n,inspectionPorts:i,extraPorts:o,colors:s,direction:a,uniformKeyWidth:l}){const{edgeById:c}=hr(),d=new Set;for(const{data:u}of c.values())u.source===e.id&&u.sourceProperty!==void 0&&d.add(`source:${u.sourceProperty}`),u.target===e.id&&u.targetProperty!==void 0&&d.add(`target:${u.targetProperty}`);return f.jsx(D.Box,{children:Object.entries(e.description||{}).map(([u,h],p)=>{var M,P,$;const y=r&&Object.keys(r).find(N=>N.slice(N.indexOf(":")+1)===u),m=t&&((M=n==null?void 0:n.type.ports)==null?void 0:M[u]),g=y??(m?`${m.kind}:${u}`:u),b=i.find(N=>N.id===g),v=y?"source":b==null?void 0:b.role,x=d.has(`source:${g}`),w=d.has(`target:${g}`),C=o.some(N=>N.id===u),S=h===""&&(C||(v?d.has(`${v}:${g}`):x||w)),_=v??(x!==w?x?"source":"target":void 0),R=(b==null?void 0:b.side)??(_?_==="source"!=(a==="RL")?"right":"left":void 0),A=S&&R==="right"?"right":"left",O=(b==null?void 0:b.label)??(m==null?void 0:m.label)??(C?u.replace(/^(template|input|output|config|error):/,""):u),T=Ut(s.wordBeforeDot)[typeof h],E=Ut(s.wordBeforeDot).property;return f.jsxs(D.Box,{"data-flow-property":y&&(a==="TB"||a==="BT")?void 0:g,"data-flow-port-role":v,"data-flow-inspection-row":t?"":void 0,children:[f.jsxs(D.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[f.jsx(D.Flex,{justifyContent:"start",align:"center",background:s.highlightColor,width:S?"100%":`${l}px`,minWidth:`${l}px`,borderRightColor:s.hexborderColor,borderRightWidth:S?0:1,children:f.jsx(D.Text,{py:5,px:10,w:"100%",textAlign:A,whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((P=e==null?void 0:e.viewProps)==null?void 0:P.textColor)||(s.isTransparent?s.hextextColor:E),children:O})}),!S&&f.jsx(D.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:s.hexbgColor,w:Bv,maxH:200,children:f.jsx(D.Text,{overflow:"hidden",py:3,px:4,whiteSpace:"normal",textOverflow:"ellipsis",fontSize:"4xl",color:(($=e==null?void 0:e.viewProps)==null?void 0:$.textColor)||(s.isTransparent?s.hextextColor:T),fontWeight:400,children:zj(h)})})]}),p!==Object.entries(e.description||{}).length-1&&f.jsx(D.Box,{borderTopWidth:1,my:0,borderColor:s.hexborderColor})]},u)})})}function Uj(e){var x,w,C,S,_;const{themeColor:r,colorMode:t,direction:n}=Ve(),i=qn(),o=i.getNodeViewMode(e.data.id)==="properties",s=R=>i.setNodeViewMode(e.data.id,R?"properties":"default"),a=!!e.onShowIcon||o||typeof((x=e.data.config)==null?void 0:x.content)!="string"&&!(((w=e.data.config)==null?void 0:w.contentFormat)==="jsx"&&Array.isArray((C=e.data.config)==null?void 0:C.content)),{bindings:l,data:c,schema:d}=j.useContext(Mt),u=(S=l==null?void 0:l[e.data.id])==null?void 0:S.portResources,h=l?Pn(l,e.data.id,d):c&&d?Kr(c,e.data.id,d):void 0,p=h&&Te(c,"address"in h?h.address:e.data.id),y=p&&typeof p=="object"&&h?Object.fromEntries(Object.keys(h.type.properties).filter(R=>{var A;return Object.prototype.hasOwnProperty.call(p,R)&&oo((A=h.fields[R])==null?void 0:A.$visibleWhen,c)}).map(R=>[R,p[R]!==null&&typeof p[R]=="object"?JSON.stringify(p[R],null,2):p[R]===null?"null":p[R]])):{},m=u?Object.fromEntries(Object.entries(u).map(([R,A])=>{var O;return[R.slice(R.indexOf(":")+1),((O=Te(c,A))==null?void 0:O.name)??A.split(".").at(-1)]})):Object.keys(e.data.description??{}).length?e.data.description:y,g=a&&!u?((_=e.data.config)==null?void 0:_.ports)??[]:[],b=g.filter(R=>!Object.prototype.hasOwnProperty.call(m,R.id)&&!Object.entries((h==null?void 0:h.type.ports)??{}).some(([A,O])=>`${O.kind}:${A}`===R.id&&Object.prototype.hasOwnProperty.call(m,A))),v={...m,...Object.fromEntries(b.map(R=>[R.id,""]))};return{themeColor:r,colorMode:t,direction:n,objVisible:o,setObjVisible:s,inspecting:a,resourcePorts:u,form:h,description:v,inspectionPorts:g,extraPorts:b}}const eu=e=>{var g,b,v,x,w;const{themeColor:r,colorMode:t,direction:n,objVisible:i,setObjVisible:o,inspecting:s,resourcePorts:a,form:l,description:c,inspectionPorts:d,extraPorts:u}=Uj(e),h=qn(),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"&&!(((v=e.data.config)==null?void 0:v.contentFormat)==="jsx"&&Array.isArray((x=e.data.config)==null?void 0:x.content))?()=>h.setNodeViewMode(e.data.id,"icon-label"):void 0;return!e.onShowIcon&&p?f.jsx(Qd,{...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($n,{...e,data:{...e.data,description:c},children:({id:C,data:S,isActive:_,isEditing:R,onEditStart:A,onEditEnd:O})=>{var ie,te,fe,xe,q,W,U,z,de,Q,ae,se;const T=Fj(S,r,t),E=S.label??S.headerTitle,M=Object.entries(S.description||{}).length>0,P=Vj(S.description),$=(te=(ie=e.data)==null?void 0:ie.config)==null?void 0:te.icon,N=(xe=(fe=e.data)==null?void 0:fe.config)==null?void 0:xe.content,I=(typeof N=="string"||((W=(q=e.data)==null?void 0:q.config)==null?void 0:W.contentFormat)==="jsx"&&Array.isArray(N))&&!e.onShowIcon,K=((U=S==null?void 0:S.viewProps)==null?void 0:U.borderRadius)??"53px",le=Rn(S==null?void 0:S.viewProps,T.hexborderColor,_,Dj);return f.jsx(D.Flex,{justifyContent:"space-between",...S==null?void 0:S.viewProps,"data-flow-node-surface":"",direction:"column",p:0,borderRadius:K,overflow:"hidden",alignItems:"center",style:{backgroundColor:T.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:"100%",minW:I||e.onShowIcon?P+Bv+le.borderWidth*2:void 0,...le,children:f.jsxs(D.Flex,{width:"100%",direction:"column",borderRadius:K,borderColor:T.hexborderColor,borderWidth:0,overflow:"hidden",children:[f.jsx(Wj,{headerTitle:E,hasContent:I,data:S,icon:$,colors:T,hasConfig:M,id:C,isActive:_,isEditing:R,onEditStart:A,onEditEnd:O,props:e,objVisible:i,setObjVisible:o,onShowNativeIcon:m}),I&&!i?f.jsx(D.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:T.highlightColor,p:["html","jsx"].includes((de=(z=e.data)==null?void 0:z.config)==null?void 0:de.contentFormat)?0:12,fontSize:"5xl",lineHeight:"normal",children:f.jsx(Lj,{nodeId:C,content:N,format:(ae=(Q=e.data)==null?void 0:Q.config)==null?void 0:ae.contentFormat,color:((se=S==null?void 0:S.viewProps)==null?void 0:se.textColor)||T.hextextColor})}):f.jsx(Gj,{data:S,resourcePorts:a,inspecting:s,form:l,inspectionPorts:d,extraPorts:u,colors:T,direction:n,uniformKeyWidth:P})]})})}})};eu.displayName="NodeJsonObjectView";const Dv=e=>{var h,p,y,m,g,b,v,x,w,C,S;const r=qn(),[t,n]=j.useState(!1),i=r.getNodeViewMode(e.data.id)==="properties",o=_=>{n(_),r.setNodeViewMode(e.data.id,_?"properties":"default")},{callbacks:s,readOnly:a}=Ve(),l=(p=(h=e.data)==null?void 0:h.config)==null?void 0:p.parentContainer;Fv(e.data.id,i&&((m=(y=e.data)==null?void 0:y.config)==null?void 0:m.labelBelow)&&!l,()=>o(!1));const c=l?"Show parent":"Show properties",d=l||((b=(g=e.data)==null?void 0:g.config)==null?void 0:b.form)||((w=(x=(v=e.data)==null?void 0:v.config)==null?void 0:x.ports)==null?void 0:w.length),u=d?()=>{var _;l?(_=s.onNodeCollapse)==null||_.call(s,e.data.id,!1):o(!0)}:void 0;return!l&&d&&i?f.jsx(eu,{...e,editOnMount:t,onShowIcon:()=>o(!1)}):f.jsx(Qd,{...e,onOpenView:u&&(l||(S=(C=e.data)==null?void 0:C.config)!=null&&S.labelBelow)?()=>{var _;u(),(_=s.onNodeViewToggle)==null||_.call(s,e.data.id)}:void 0,toggleLabel:c,toggleDisabled:l&&a,onExpand:u})};function Hj(e){var b,v,x,w,C,S;const{config:r,callbacks:t,readOnly:n,selectedNodeIds:i,nodeRadiusPreviews:o,nodeViewModes:s,allNodesIconLabel:a}=Ve(),l=o[e.data.id]??((b=e.data.viewProps)==null?void 0:b.borderRadius),[c,d]=j.useState(!1),u=qn(),{border:h,colorText:p}=it(),y=(v=r.customViews)==null?void 0:v.gridContent,m=(s[e.data.id]??(a?"icon-label":"default"))==="icon-label",g=j.useRef(m);return m&&(g.current=!0),Fv(e.data.id,a&&!m&&g.current,()=>u.setNodeViewMode(e.data.id,"icon-label")),m?f.jsx(D.Box,{"data-grid-document":((x=e.data.config)==null?void 0:x.documentId)??"",children:f.jsx(Qd,{...e,data:{...e.data,viewProps:{...e.data.viewProps,borderRadius:l},config:{...e.data.config,labelBelow:!0,icon:((w=e.data.config)==null?void 0:w.icon)||"PiGridFour"}},toggleLabel:"Show grid",onExpand:()=>u.restoreNodeView(e.data.id)})}):f.jsxs(f.Fragment,{children:[f.jsx($n,{...e,onOpenView:()=>d(!0),children:({data:_,isActive:R})=>{var A,O,T,E,M,P,$,N;return f.jsx(D.Box,{"data-flow-node-surface":"","data-grid-document":((A=_.config)==null?void 0:A.documentId)??"",width:`${((T=(O=_.config)==null?void 0:O.gridSize)==null?void 0:T.width)??600}px`,height:`${((M=(E=_.config)==null?void 0:E.gridSize)==null?void 0:M.height)??440}px`,overflow:"hidden",position:"relative",bg:((P=_.viewProps)==null?void 0:P.bgColor)??"transparent",color:(($=_.viewProps)==null?void 0:$.textColor)??p,borderRadius:`${l??0}px`,...Rn(_.viewProps,_e(((N=_.viewProps)==null?void 0:N.borderColor)??h),R,0),children:y?f.jsx(y,{...e}):f.jsx(D.Box,{p:4,children:_.label??"Grid"})})}}),f.jsx(Yd,{nodeAddress:e.data.id,active:i.includes(e.data.id),label:e.data.label??"Grid",open:c&&!n,onClose:()=>d(!1),children:f.jsx(Mt.Provider,{value:{data:{metadata:{label:e.data.label??"",subtitle:((C=e.data.config)==null?void 0:C.subtitle)??"",icon:((S=e.data.config)==null?void 0:S.icon)??"PiGridFour"}},bindings:{[e.data.id]:{address:"root.metadata",type:"GridMetadata"}},schema:{GridMetadata:{kind:"object",properties:{label:{optional:!0,type:{kind:"string"}},subtitle:{optional:!0,type:{kind:"string"}},icon:{optional:!0,type:{kind:"string"}}}}},editable:!!r.editable&&!n,callbacks:{onFormChange:_=>{var A,O,T;if(n||!r.editable)return;const R=String(_.value??"");_.address==="root.metadata.label"?(A=t.onNodeLabelChange)==null||A.call(t,e.data.id,R):_.address==="root.metadata.subtitle"?(O=t.onNodeSubtitleChange)==null||O.call(t,e.data.id,R):_.address==="root.metadata.icon"&&((T=t.onNodeIconChange)==null||T.call(t,e.data.id,R))}}},children:f.jsx(_d,{nodeAddress:e.data.id})})})]})}const Vv=e=>f.jsx(Dv,{...e,renderCompact:Oj}),Wv=e=>f.jsx(Dv,{...e}),Gv=({containerStyle:e,...r})=>{const{selectedNodeIds:t}=Ve();return f.jsx($n,{...r,editOnMount:t.includes(r.data.id),children:n=>f.jsx(D.Box,{bg:e.textColor==="transparent"?"transparent":e.labelBg,p:`${e.fontSize/5}px`,fontFamily:cr,lineHeight:1,w:"fit-content",children:f.jsx(Gr,{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})})})};Vv.displayName="text";Wv.displayName="arrayView";Gv.displayName="ParentContainerView";const Kj={grid:Hj,objectView:eu,arrayView:Wv,text:Vv,parentContainer:Gv},Jj=({children:e,pattern:r="dot",backgroundColor:t})=>{const{colorMode:n}=Ve(),i=n==="dark",o=i?"--chakra-colors-gray-700":"--chakra-colors-gray-500",s=i?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return r==="none"?f.jsx(D.Box,{"data-flow-background":"none",width:"100%",height:"100%",padding:0,bg:t,children:e}):f.jsxs(D.Box,{"data-flow-background":r,position:"relative",width:"100%",height:"100%",padding:0,bg:t,children:[f.jsx(D.Box,{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:0,pointerEvents:"none",style:{backgroundImage:r==="dot"?`radial-gradient(var(${o}) 8%, transparent 8%)`:r==="steel"?`repeating-linear-gradient(45deg, var(${s}) 0, var(${s}) 1px, transparent 1px, transparent 20px)`:`linear-gradient(var(${s}) 1px, transparent 1px), linear-gradient(90deg, var(${s}) 1px, transparent 1px)`,backgroundSize:"20px 20px",opacity:.3}}),f.jsx(D.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:e})]})},Zj=.4,vr={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},Xj=({nodes:e,edges:r})=>{const{themeColor:t,spacing:n,edgeRadius:i,backgroundVariant:o,backgroundSelected:s,setBackgroundSelected:a,edgeColor:l,direction:c,nodeAlignment:d,edgeMode:u,compactPropertyLayout:h,workflowContract:p,parentNodeStyle:y,engineRef:m,callbacks:g,config:b,selectedNodeIds:v,setSelectedNodeIds:x,selectedEdgeId:w,setSelectedEdgeId:C,setIsPerformanceMode:S,setNodeGridOptions:_,fillRadiusEditedIds:R,isZoomMode:A,setIsZoomMode:O,isMultiSelectMode:T,setIsMultiSelectMode:E,isDragMode:M,setIsDragMode:P,isEdgeHandlesEnabled:$,setIsEdgeHandlesEnabled:N,isArrayNodeMode:I}=Ve(),K=j.useRef(null),[le,ie]=j.useState(null),te=j.useRef(null),fe=e.length>200;j.useEffect(()=>{S(fe)},[fe,S]);const{edgeSep:xe,rankSep:q,spacingFactor:W}=j.useMemo(()=>{const J=Aw(e.length),B=b.nodeGridSpacing==="layout"&&n<.5?n*1.3:n<1?.3+.7*n:.5+.5*n;return{edgeSep:J.edgeSep*B,rankSep:J.rankSep*B,spacingFactor:1.3+(n-1)*(n<1?.4:.3)}},[e.length,n,b.nodeGridSpacing]),{bgColor:U}=An(t),{canvas:z,borderSecondary:de,colorText:Q}=it(),ae=o==="transparent"?"transparent":b.backgroundColor||z,se=j.useCallback(J=>{if(!J)return _e(t);switch(J){case"dark":return _e(ae);case"light":return _e(de);default:return _e(J)}},[t,ae,de]),Ce=b.colorMode==="dark",Se=Ce?_e("gray.500"):Ur,he=Ce?U!=null&&U.includes("gray")?"whitesmoke":se(U):Se,G=l?se(l):Se,F=j.useMemo(()=>b.initialViewport||{pan:{x:0,y:0},zoom:.01},[]),re=c==="C"?"LR":c,ce=j.useCallback(J=>{const B={...y,...J};return{...B,bgColor:B.bgColor||t,bgOpacity:B.outline?0:B.bgOpacity??Zj}},[y,t]),X=j.useMemo(()=>{var B;const J=new Map;for(const ne of e)(B=ne.data)!=null&&B.id&&J.set(ne.data.id,ne);return J},[e]),ye=j.useMemo(()=>{var B;const J=new Map;for(const ne of r)(B=ne.data)!=null&&B.id&&J.set(ne.data.id,ne);return J},[r]),ve=j.useCallback(J=>{var H;const B=(H=X.get(J))==null?void 0:H.data,ne=ce(B==null?void 0:B.viewProps),Me=_e(ne.bgColor);return{animated:!!(B!=null&&B.isNodeAnimated)&&!fe,animationVariant:B==null?void 0:B.nodeAnimationVariant,animationColor:_e(ne.borderColor||t),bgColor:ne.outline?"transparent":Me,bgOpacity:ne.bgOpacity,borderColor:ne.borderColor?_e(ne.borderColor):ne.outline&&ne.bgColor==="transparent"?_e(t):Me,borderWidth:En(ne.borderWidth,vr.borderWidth),borderStyle:ne.borderStyle??vr.borderStyle,borderRadius:ne.borderRadius??vr.borderRadius,textColor:ne.textColor?_e(ne.textColor):ne.outline||ne.bgColor==="transparent"?_e(Q):Me,fontSize:ne.fontSize??vr.fontSize,labelPosition:ne.labelPosition??vr.labelPosition,labelMargin:vr.labelMargin,labelBg:uu(se("dark"),Me,ne.bgOpacity)??se("dark"),padding:ne.padding??vr.padding}},[ce,X,Q,t,fe,se]),Oe=j.useMemo(()=>{var ne,Me;const J=new Map;for(const H of r){const ge=(ne=H.data)==null?void 0:ne.source,Re=(Me=H.data)==null?void 0:Me.target;if(!ge||!Re||ge===Re)continue;const be=ge<Re?`${ge}|${Re}`:`${Re}|${ge}`,Ge=J.get(be);Ge?Ge.push({id:H.data.id,source:ge}):J.set(be,[{id:H.data.id,source:ge}])}const B=new Map;for(const[H,ge]of J){if(ge.length<2)continue;const Re=H.split("|")[0],be=Math.min(20,70/ge.length);ge.forEach(({id:Ge,source:Je},De)=>{const mt=50+(De-(ge.length-1)/2)*be;B.set(Ge,(Je===Re?mt:100-mt)/100)})}return B},[r]),Ne=j.useMemo(()=>{const J=se("dark");return r.filter(B=>{var ne;return((ne=B.data)==null?void 0:ne.id)&&B.data.source&&B.data.target}).map(({data:B})=>{var ge,Re,be,Ge,Je,De;let ne=J;const Me=(Re=(ge=X.get(B.source))==null?void 0:ge.data)==null?void 0:Re.parent,H=(Ge=(be=X.get(B.target))==null?void 0:be.data)==null?void 0:Ge.parent;if(Me&&Me===H){const mt=ce((De=(Je=X.get(Me))==null?void 0:Je.data)==null?void 0:De.viewProps),kt=uu(J,_e(mt.bgColor),mt.bgOpacity);kt&&(ne=kt)}return{id:B.id,data:B,type:B.type??b.edgeType??"rounded-orthogonal",source:B.source,target:B.target,sourceProperty:B.sourceProperty,targetProperty:B.targetProperty,label:B.label,validationIssue:(u==="auto"||u==="properties")&&(B.sourceProperty!==void 0||B.targetProperty!==void 0)&&p?Sd(p,B):void 0,color:l?G:B.color?_e(B.color):G,connectorColor:l?G:B.color?_e(B.color):he,labelBg:ne,dashed:!!B.isEdgeDashed,animated:!!B.isEdgeAnimated,inverted:!!B.isInverted,turn:Oe.get(B.id)??.5}})},[r,G,he,l,Oe,b.edgeType,u,p,X,ce,se]),Be=j.useMemo(()=>{var B;const J=new Set;for(const ne of e)(B=ne.data)!=null&&B.parent&&J.add(ne.data.parent);return J},[e]),et=j.useMemo(()=>{const J=new Map;for(const B of r){const ne=B.data.isInverted?B.data.target:B.data.source;ne&&!J.has(ne)&&J.set(ne,B.data)}for(const B of r){if(B.data.connection)continue;const ne=B.data.isInverted?B.data.target:B.data.source,Me=B.data.isInverted?B.data.source:B.data.target;Me.startsWith(`${ne}.`)&&(J.set(ne,B.data),J.set(Me,B.data))}return J},[r]),We=j.useMemo(()=>{const J={...Kj,...b.customViews};return e.filter(B=>{var ne;return(ne=B.data)==null?void 0:ne.id}).map(B=>{var be,Ge,Je,De,mt,kt;const ne=Be.has(B.data.id)&&!B.data.parent,Me=ne?B.data.label??B.data.headerTitle??"Container":void 0,H=ne?J.parentContainer:J[B.data.type]||J.text,ge=et.get(B.data.id),Re={...B,isInverted:((be=B.data.config)==null?void 0:be.isInverted)??(ge==null?void 0:ge.isInverted),isParent:ne,containerStyle:ne?ve(B.data.id):void 0};return{id:B.data.id,collapsed:(Ge=B.data.config)==null?void 0:Ge.collapsed,parent:B.data.parent,acceptsChildren:!!((Je=B.data.config)!=null&&Je.parentContainer)||Be.has(B.data.id),label:Me,animated:!!B.data.isNodeAnimated,animationVariant:B.data.nodeAnimationVariant,hasCollapseControl:((De=B.data.config)==null?void 0:De.collapsed)!==void 0,animationColor:_e(((mt=B.data.viewProps)==null?void 0:mt.borderColor)||t),animationWidth:En((kt=B.data.viewProps)==null?void 0:kt.borderWidth,8),element:j.createElement(H,{...Re,key:`${B.data.id}-${t}`}),fillElement:R.has(B.data.id)?void 0:j.createElement(H,{...Re,data:{...B.data,viewProps:{...B.data.viewProps,borderRadius:0}},containerStyle:Re.containerStyle?{...Re.containerStyle,borderRadius:0}:void 0,key:`${B.data.id}-${t}`})}})},[e,Be,et,t,b.customViews,ve,R]),ft=j.useMemo(()=>fe?300:e.length>50?150:e.length>20?100:50,[e.length,fe]),Ke=j.useRef(b);Ke.current=b;const nt=j.useRef(A);nt.current=A;const Ie=j.useRef(I);Ie.current=I;const He=j.useRef(v);He.current=v;const tt=j.useRef(w);tt.current=w;const gt=j.useRef(T);gt.current=T;const at=j.useRef(X);at.current=X;const Et=j.useRef(ye);Et.current=ye;const Ye=j.useRef(new Map);j.useEffect(()=>{var ne,Me;const J=new Map([...ye].filter(([,H])=>X.has(H.data.source)&&X.has(H.data.target))),B=Ye.current;Ye.current=J;for(const[H,ge]of B)J.has(H)||(tt.current===H&&(C(null),(ne=g.onEdgeDeselect)==null||ne.call(g)),(Me=g.onEdgeRemove)==null||Me.call(g,H,ge.data))},[ye,X,g,C]),j.useEffect(()=>{const J=K.current;if(!le||!J)return;let B=null,ne=null,Me=0,H=0,ge=0,Re=0,be=0;const Ge=Je=>{if(Ke.current.readOnly)return;const De=J.ownerDocument.fullscreenElement;if(De&&De!==J&&J.contains(De)&&Je.target instanceof Node&&De.contains(Je.target))return;Je.preventDefault(),Je.stopPropagation(),nt.current||Je.metaKey||Je.ctrlKey?(ge+=Je.deltaY,Re=Je.clientX,be=Je.clientY,ne===null&&(ne=requestAnimationFrame(()=>{ne=null;const kt=Ke.current,Zt=le.zoom(),wt=ge;ge=0;let lt=Zt-wt*.05/100;lt=Math.max(kt.minZoom??.01,Math.min(kt.maxZoom??1.5,lt));const Ct=J.getBoundingClientRect();le.zoomAt(lt,{x:Re-Ct.left,y:be-Ct.top})}))):(Me+=Je.deltaX,H+=Je.deltaY,B===null&&(B=requestAnimationFrame(()=>{B=null;const kt=le.pan(),Zt=le.zoom(),wt=.35,lt=Me,Ct=H;Me=0,H=0,le.pan({x:kt.x+-lt*wt/Zt,y:kt.y+-Ct*wt/Zt})})))};return J.addEventListener("wheel",Ge,{passive:!1}),()=>{J.removeEventListener("wheel",Ge),B!==null&&cancelAnimationFrame(B),ne!==null&&cancelAnimationFrame(ne)}},[le]),j.useEffect(()=>{if(b.disableKeyboardShortcuts)return;const J=B=>{var Me,H,ge,Re;if(Ke.current.readOnly)return;const ne=B.target;if(!(ne.tagName==="INPUT"||ne.tagName==="TEXTAREA"||ne.isContentEditable)){if((B.key==="z"||B.key==="Z")&&O(!nt.current),(B.key==="m"||B.key==="M")&&E(!T),(B.key==="d"||B.key==="D")&&P(!M),(B.key==="v"||B.key==="V")&&!B.repeat&&!B.metaKey&&!B.ctrlKey&&!B.altKey&&ne.tagName!=="SELECT"&&N(!$),(B.key==="Delete"||B.key==="Backspace")&&tt.current){B.preventDefault();const be=tt.current;(H=g.onEdgeDelete)==null||H.call(g,be,((Me=Et.current.get(be))==null?void 0:Me.data)??{id:be}),C(null);return}if((B.key==="Delete"||B.key==="Backspace")&&He.current.length>0){B.preventDefault();const be=He.current.filter(Ge=>Ge!=="root");if(be.length===0)return;for(const Ge of be){const Je=(ge=at.current.get(Ge))==null?void 0:ge.data;(Re=g.onNodeDelete)==null||Re.call(g,Ge,Je||{})}x([])}}};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[T,M,$,N,O,E,P,b.disableKeyboardShortcuts,g,x,C]);const Xe=j.useCallback(J=>{var B;m.current=J,ie(J),(B=g.onInit)==null||B.call(g,J)},[m,g]),Vt=j.useCallback(J=>{var B;return(B=g.onViewportChange)==null?void 0:B.call(g,J)},[g]),ct=j.useCallback(J=>{var ne,Me,H;const B=((ne=Et.current.get(J))==null?void 0:ne.data)??{id:J};if(tt.current===J&>.current){C(null),(Me=g.onEdgeDeselect)==null||Me.call(g);return}He.current.length&&x([]),C(J),(H=g.onEdgeSelect)==null||H.call(g,J,B)},[g,C,x]),tr=j.useCallback(()=>{var J,B,ne,Me,H;if(a(b.bottomBarCollapsed??(He.current.length>0||!!tt.current||!s)),(J=g.onBackgroundClick)==null||J.call(g),!Ke.current.readOnly){const ge=new Set;for(const Re of He.current){let be=at.current.get(Re);for(;be&&!ge.has(be.data.id);)ge.add(be.data.id),Be.has(be.data.id)&&((B=be.data.config)==null?void 0:B.collapsed)!==!0&&((ne=g.onNodeCollapse)==null||ne.call(g,be.data.id,!0)),be=be.data.parent?at.current.get(be.data.parent):void 0}}He.current.length&&(x([]),(Me=g.onNodeDeselect)==null||Me.call(g)),tt.current&&(C(null),(H=g.onEdgeDeselect)==null||H.call(g))},[g,x,C,a,s,b.bottomBarCollapsed,Be]),Wt=j.useCallback(J=>{var Me,H;const B=He.current,ne=J.filter(ge=>!B.includes(ge));if(ne.length){x([...B,...ne]);for(const ge of ne)(H=g.onNodeSelect)==null||H.call(g,ge,((Me=at.current.get(ge))==null?void 0:Me.data)??{id:ge})}},[g,x]),Ir=j.useCallback((J,B)=>{var ne,Me;x([J]),(Me=g.onNodeSelect)==null||Me.call(g,J,((ne=at.current.get(J))==null?void 0:ne.data)??{id:J},B)},[g,x]),Rt=j.useRef(null),Gt=j.useCallback((J,B,ne)=>{var Me;Rt.current={source:J,target:B,edgeIds:new Set(Et.current.keys())};try{(Me=g.onEdgeCreate)==null||Me.call(g,J,B,ne)}catch(H){throw Rt.current=null,H}},[g]),Jt=j.useCallback((J,B,ne,Me=!1)=>{var H,ge;if(te.current={sourceId:J,nodeIds:new Set(at.current.keys()),reverse:Me},!(u==="properties"&&((H=g.onNodeCreateRequest)==null?void 0:H.call(g,{sourceNodeId:J,position:B,sourceProperty:ne,reverse:Me}))===!0)){if(ne!==void 0||Me){te.current=null;return}(ge=g.onNodeCreate)==null||ge.call(g,{type:"text",sourceNodeId:J,position:B,isArrayMode:Ie.current})}},[g,u]),Mr=!b.readOnly&&$&&b.edgeHandles!==!1,gr=o==="transparent"?"none":o;return f.jsx(Jj,{pattern:gr,backgroundColor:ae,children:f.jsx(D.Box,{ref:K,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:f.jsx(Pj,{nodes:We,edges:Ne,direction:re,nodeAlignment:d,onContainerCollapse:J=>{var B,ne;(B=g.onNodeCollapse)==null||B.call(g,J,!0),(ne=g.onNodeViewToggle)==null||ne.call(g,J)},selectedNodeIds:v,edgeMode:u,compactPropertyLayout:h,edgeType:b.edgeType,edgeRadius:i,customEdgeTypes:b.customEdgeTypes,edgeReveal:b.disableAnimations?void 0:b.edgeReveal,rankSep:q,edgeSep:xe,nodeGridSpacing:b.nodeGridSpacing,nodeGridConnections:b.nodeGridConnections,spacingFactor:W,compactSpacingScale:n,layoutDebounce:ft,isPerformanceMode:fe,minZoom:b.minZoom??.01,maxZoom:b.maxZoom??1.5,initialViewport:F,fitOnInit:!b.initialViewport,readOnly:!!b.readOnly,containerStyle:ve,lineColor:l?G:he,drawMode:Mr,drawHandles:!b.readOnly&&b.edgeHandles!==!1,dragMode:M,multiSelect:!!T,onInit:Xe,onLayoutComplete:J=>{var ge;(ge=g.onLayoutComplete)==null||ge.call(g,J);const B=Rt.current;B&&(!at.current.has(B.source)||!at.current.has(B.target)?Rt.current=null:r.some(({data:Re})=>Re.source===B.source&&Re.target===B.target&&!B.edgeIds.has(Re.id))&&J.getNodeBox(B.source)&&J.getNodeBox(B.target)&&(Rt.current=null,J.focusConnections(B.source)));const ne=te.current;if(!ne)return;if(!at.current.has(ne.sourceId)){te.current=null;return}const H=e.filter(Re=>!ne.nodeIds.has(Re.data.id)).filter(Re=>r.some(({data:be})=>be.source===ne.sourceId&&be.target===Re.data.id||be.target===ne.sourceId&&be.source===Re.data.id));!H.length||H.some(Re=>!J.getNodeBox(Re.data.id))||(te.current=null,J.focusBranch(ne.reverse?H[0].data.id:ne.sourceId))},onNodeGridModeChange:_,onNodeGridZoomOut:g.onNodeGridZoomOut,onNodeGridDrop:g.onNodeGridDrop,onNodeParentChange:g.onNodeParentChange,animateViewport:b.animateViewport,disableAnimations:b.disableAnimations,onViewportChange:Vt,onBackgroundTap:tr,onBoxSelect:Wt,onEdgeSelect:ct,onContainerSelect:Ir,onEdgeDraw:Gt,onDrawIntoSpace:Jt})})})},Uv=j.memo(Xj),Yj=".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 hm=!1;function Qj(){if(hm||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=Yj+".flow-sdk-canvas[data-node-grid] .flow-sdk-node,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *::before,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *::after{animation:none!important;transition:none!important}.flow-sdk-node[data-grid-fill] [data-flow-icon-label]{--flow-grid-caption-color:var(--flow-grid-on-surface-color)}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]{border:0;outline:none;box-shadow:none}.flow-sdk-node[data-grid-fill]{box-sizing:border-box}.flow-sdk-node[data-grid-fill] :not(svg):has([data-flow-node-surface]),.flow-sdk-node[data-grid-fill]>:not(svg):not(button){width:100%;height:100%;min-width:0;max-width:none}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]{width:100%;height:100%;min-width:0;max-width:none;box-sizing:border-box;overflow:hidden}.flow-sdk-node[data-grid-fill] [data-flow-icon-label]{gap:0}.flow-sdk-node[data-grid-fill] [data-flow-icon-caption]{position:absolute;bottom:12px;left:12px;width:calc(100% - 24px);max-height:40%;overflow:hidden}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]>svg{max-width:45%;max-height:55%}.flow-sdk-node[data-grid-fill] p{font-size:var(--flow-grid-font);white-space:normal;overflow-wrap:anywhere}.flow-sdk-canvas[data-node-grid]:not([data-grid-connections]) .flow-sdk-property-port,.flow-sdk-canvas[data-node-grid]:not([data-grid-connections]) .flow-sdk-handle,.flow-sdk-canvas[data-node-grid] [data-flow-collapse-control]{display:none}.flow-sdk-node[data-grid-draggable] :not(button):not(input):not(textarea):not(select):not(a){cursor:inherit}"+jb+Rw+_w+".flow-sdk-handle{position:absolute;left:-36px;top:50%;transform:translateY(-50%);width:36px;height:36px;display:grid;place-items:center;border:2px solid currentColor;border-radius:50%;background:white;cursor:crosshair;opacity:0;pointer-events:none}.flow-sdk-node:hover>.flow-sdk-handle,.flow-sdk-handle:focus-visible{opacity:1;pointer-events:auto}.flow-sdk-draw .flow-sdk-node *,.flow-sdk-draw .flow-sdk-edge *,.flow-sdk-draw .flow-sdk-container *,.flow-sdk-ghost *{pointer-events:none}",document.head.appendChild(e),e.textContent+=".flow-sdk-draw .flow-sdk-node{pointer-events:auto}.flow-sdk-draw .flow-sdk-node>.flow-sdk-handle{opacity:0;pointer-events:none}.flow-sdk-draw .flow-sdk-node:hover>.flow-sdk-handle,.flow-sdk-draw .flow-sdk-node>.flow-sdk-handle:focus-visible{opacity:1;pointer-events:auto}",e.textContent+='.flow-sdk-property-port{position:absolute;transform:translateY(-50%);width:32px;height:32px;margin:0;padding:0;border:3px solid currentColor;border-radius:50%;background:white;cursor:crosshair;pointer-events:auto;z-index:20}.flow-sdk-property-port[data-port-role="source"]{background:currentColor}.flow-sdk-property-port:hover{outline:3px solid currentColor;outline-offset:3px}.flow-sdk-draw .flow-sdk-node .flow-sdk-property-port{pointer-events:auto}',hm=!0}function e_({loading:e=!1,loader:r,...t}){var l,c;const[n,i]=j.useState(null),o=j.useMemo(()=>!!(n!=null&&n.json)&&!!t.json&&Cw(n.json,t.json),[n==null?void 0:n.json,t.json]),s=n===null||n.json!==t.json&&!o,a=e||s;return j.useEffect(()=>{!e&&o&&(n==null?void 0:n.json)!==t.json&&i(t)},[e,o,n==null?void 0:n.json,t.json]),j.useEffect(()=>{if(e||!s)return;let d;const u=requestAnimationFrame(()=>{d=requestAnimationFrame(()=>i(t))});return()=>{cancelAnimationFrame(u),d!==void 0&&cancelAnimationFrame(d)}},[e,s,t.json]),f.jsxs(D.Box,{className:t.className,style:t.style,width:"100%",height:"100%",position:"relative","aria-busy":a,children:[f.jsx("div",{style:{width:"100%",height:"100%"},ref:d=>{a?d==null||d.setAttribute("inert",""):d==null||d.removeAttribute("inert")},children:n&&f.jsx(t_,{...s?n:t,children:t.children,config:t.config,className:void 0,style:void 0})}),a&&r!==null&&f.jsx(D.Box,{"data-flow-loader":"",role:"status","aria-label":"Loading diagram",position:"absolute",inset:0,zIndex:1e3,display:"grid",placeItems:"center",background:((l=t.config)==null?void 0:l.colorMode)==="dark"?"gray.800":"gray.100",color:((c=t.config)==null?void 0:c.colorMode)==="dark"?"whiteAlpha.800":"blackAlpha.800",children:r===void 0?f.jsx("span",{children:"Loading diagram..."}):r})]})}function t_({title:e="untitled",json:r,forms:t,nodes:n,edges:i,config:o={},callbacks:s={},className:a,style:l,showBottomBar:c=!0,children:d}){Qj();const[u,h]=j.useState(),[p,y]=j.useState(!1),m=o.formSchema??u,g=j.useMemo(()=>r&&t?rb(r,t.state):r,[r,t==null?void 0:t.state]),b=o.direction==="C",v=j.useMemo(()=>{let T,E;return M=>(E=T&&E?Sw(T,M,E)??od(M,{title:e,isCenter:b}):od(M,{title:e,isCenter:b}),T=M,E)},[e,b]),x=j.useMemo(()=>g?v(g):null,[g,v]),w=j.useMemo(()=>t!=null&&t.structured&&!p&&m?nb(t.state,t.bindings,m,(x==null?void 0:x.nodes)??n??[]):void 0,[t==null?void 0:t.structured,p,t==null?void 0:t.state,t==null?void 0:t.bindings,m,x,n]),C=(w==null?void 0:w.schema)??m,S=(w==null?void 0:w.bindings)??(t==null?void 0:t.bindings),_=j.useMemo(()=>[...(x==null?void 0:x.nodes)??n??[],...(w==null?void 0:w.nodes)??[]].map(E=>{var le,ie,te,fe;const M=r?(le=Te(r,E.data.id))==null?void 0:le.$view:(ie=E.data.config)==null?void 0:ie.typeView,P=M&&fd.includes(M)?M:void 0,$=P?P==="icon-label":(te=E.data.config)==null?void 0:te.labelBelow,N=P==="object"?"objectView":P==="text"?"text":$?"arrayView":E.data.type,I=C&&(t?Pn(S,E.data.id,C):r&&Kr(r,E.data.id,C)),K=(((fe=E.data.config)==null?void 0:fe.ports)??[]).map(xe=>({...xe}));if(w&&I){const xe=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[q,W]of Object.entries(I.type.ports??{})){const U=`${W.kind}:${q}`,z=K.find(de=>de.id===U);z?z.label===void 0&&W.label!==void 0&&(z.label=W.label):K.push({id:U,...W.label!==void 0?{label:W.label}:{},role:W.kind==="input"||W.kind==="config"?"target":"source",side:xe[W.kind],...W.kind==="config"?{placement:"config"}:{}})}for(const q of K){const W=K.filter(U=>U.side===q.side);q.position=(W.indexOf(q)+1)/(W.length+1)}}return I||$||P?{...E,data:{...E.data,type:N,...t?{description:Object.fromEntries(Object.entries(E.data.description??{}).filter(([xe])=>!xe.startsWith("$")&&!(w!=null&&w.slots.has(cn(E.data.id,xe)))))}:{},config:{...E.data.config,...w&&I?{ports:K}:{},...I?{form:!0}:{},...P?{typeView:P,labelBelow:!!$}:$?{labelBelow:!0}:{}}}}:E}),[x,n,r,C,S,w,o.direction]),R=[...(x==null?void 0:x.edges)??i??[],...(w==null?void 0:w.edges)??[]],A=j.useMemo(()=>{const T=r&&x?Sb(r,x.edges,s,s.onJsonChange,m):{...s};if(w){const E=new Set([...w.nodes.map(M=>M.data.id),...w.edges.map(M=>M.data.id)]);for(const M of Object.keys(T)){if(!/^on(?:Node|Edge).*(?:Change|Collapse)$/.test(M))continue;const P=T[M];T[M]=($,...N)=>{if(!E.has($))return P==null?void 0:P($,...N)}}}return{...T,onAllNodesIconLabelChange:E=>{var M;y(E),(M=T.onAllNodesIconLabelChange)==null||M.call(T,E)}}},[r,x,s,m,w]),O=j.useMemo(()=>{if(!t)return A;let T=t.state;const E=P=>{if(o.readOnly||o.editable===!1)return;const $=t.onStateChange??t.onChange;if(!$)return;const N=dw(T,P,s.onFormChange);N!==T&&(T=N,$(N,{...P,data:N}))},M=(P,$,N)=>{var K;const I=r&&((K=Te(r,P))==null?void 0:K[$]);return!I||typeof I.$state!="string"?!1:(E({address:I.$state,nodeAddress:P,previousValue:Te(T,I.$state),value:N,data:T}),!0)};return{...A,onFormChange:E,onNodeCreateRequest:P=>{var I,K;const $=(I=P.sourceProperty)!=null&&I.startsWith("config:")?P.sourceProperty.slice(7):void 0,N=$!==void 0&&(w==null?void 0:w.slots.get(cn(P.sourceNodeId,$)));return N?(N.present||E({data:T,nodeAddress:N.address.split(".").slice(0,-1).join("."),address:N.address,value:ln(N.type),previousValue:void 0}),!0):((K=A.onNodeCreateRequest)==null?void 0:K.call(A,P))??!1},onNodeDelete:(P,$)=>{var te,fe;if(!(w!=null&&w.nodes.some(xe=>xe.data.id===P)))return(te=A.onNodeDelete)==null?void 0:te.call(A,P,$);const N=w&&[...w.slots.values()].find(xe=>xe.nodeId===P);if(!N)return(fe=A.onNodeDelete)==null?void 0:fe.call(A,P,$);const I=N.address.split("."),K=I.pop(),le=I.join("."),ie=Te(T,le);E(Array.isArray(ie)?{data:T,nodeAddress:le,address:le,previousValue:ie,value:ie.filter((xe,q)=>String(q)!==K)}:{data:T,nodeAddress:le,address:N.address,previousValue:Te(T,N.address),value:void 0})},onEdgeCreate:(P,$,N)=>{var le,ie;const I=((le=N==null?void 0:N.targetProperty)==null?void 0:le.startsWith("config:"))&&(w==null?void 0:w.slots.get(cn($,N.targetProperty.slice(7)))),K=w==null?void 0:w.containers.get(P);if(I&&K&&(N==null?void 0:N.sourceProperty)==="output:resource"){const te=hw(T,K,I);te!==void 0&&E({data:T,nodeAddress:I.address.split(".").slice(0,-1).join("."),address:I.address,previousValue:Te(T,I.address),value:te});return}I||w!=null&&w.nodes.some(te=>te.data.id===P||te.data.id===$)||(ie=A.onEdgeCreate)==null||ie.call(A,P,$,N)},onEdgeDelete:(P,$)=>{var fe;const N=w==null?void 0:w.edges.find(xe=>xe.data.id===P);if(!N)return(fe=A.onEdgeDelete)==null?void 0:fe.call(A,P,$);const I=w.slots.get(cn(N.data.target,N.data.targetProperty.slice(7))),K=I.address.split("."),le=K.pop(),ie=K.join("."),te=Te(T,ie);E(Array.isArray(te)?{data:T,nodeAddress:ie,address:ie,previousValue:te,value:te.filter((xe,q)=>String(q)!==le)}:{data:T,nodeAddress:ie,address:I.address,previousValue:Te(T,I.address),value:void 0})},onNodeContentChange:(P,$)=>{var N,I;M(P,"$content",$)?(N=s.onNodeContentChange)==null||N.call(s,P,$):(I=A.onNodeContentChange)==null||I.call(A,P,$)},onNodeLabelChange:(P,$)=>{var N,I;M(P,"$label",$)?(N=s.onNodeLabelChange)==null||N.call(s,P,$):(I=A.onNodeLabelChange)==null||I.call(A,P,$)}}},[A,t,r,s,w,o.readOnly,o.editable]);return f.jsx(Mt.Provider,{value:{data:(t==null?void 0:t.state)??r,viewData:r,bindings:S,references:t==null?void 0:t.references,structured:w,renderForm:t==null?void 0:t.renderForm,editable:t?!!(t.onStateChange??t.onChange):!!s.onJsonChange,schema:C,setSchema:T=>{var E;h(T),(E=s.onFormSchemaChange)==null||E.call(s,T)},callbacks:O},children:f.jsx(wm,{config:w?{...o,formSchema:C}:o,callbacks:O,nodes:_,edges:R,children:f.jsxs(D.Box,{className:a,"data-flow-diagram":"","data-animations-disabled":o.disableAnimations||void 0,style:l,width:"100%",height:"100%",position:"relative",overflow:"hidden",css:{"&[data-animations-disabled], &[data-animations-disabled] *, &[data-animations-disabled] *::before, &[data-animations-disabled] *::after":{animation:"none !important",transition:"none !important"},"& input, & textarea, & select":{outline:"none !important",boxShadow:"none !important"}},children:[f.jsx(Uv,{nodes:_,edges:R}),c&&f.jsx(mb,{}),d]})})})}function r_(e){return ud(JSON.parse(e))}function ud(e){if(!e||typeof e!="object")throw new Error("Expected a JSON object or array.");const r=new Set,t=n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(!n||typeof n!="object"||r.has(n)||!Array.isArray(n)&&![Object.prototype,null].includes(Object.getPrototypeOf(n)))throw new Error("Document must contain only finite, acyclic JSON values.");r.add(n);for(const[i,o]of Object.entries(n)){if(["__proto__","prototype","constructor"].includes(i))throw new Error(`Unsafe document key: ${i}`);t(o)}r.delete(n)}};return t(e),structuredClone(e)}function n_(e){return{replaceJson(r){if(e.readOnly||!e.onJsonChange)throw new Error("JSON document is read-only.");const t=ud(r);return e.onJsonChange(t,{type:"documentReplace",address:"root"}),t},replaceState(r){if(e.readOnly||!e.onStateChange)throw new Error("Form state is read-only.");const t=ud(r);return e.onStateChange(t,{address:"root",nodeAddress:"root",previousValue:e.state,value:t,data:t}),t}}}function o_(e,r){const t=(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)=>t(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==="$content"&&n.$contentFormat==="jsx"&&i.$contentFormat==="jsx"&&Array.isArray(s)&&Array.isArray(i[o]))return[[o,s.filter((l,c)=>JSON.stringify(l)===JSON.stringify(i[o][c]))]];if(o.startsWith("$")&&o!=="$")return JSON.stringify(s)===JSON.stringify(i[o])?[[o,s]]:[];const a=t(s,i[o]);return a===void 0?[]:[[o,a]]}))};return t(e,r)??{}}function Un(e){let r="",t=!1,n="",i;const o=()=>{clearTimeout(i),i=void 0},s=()=>{if(o(),!(t||!r.trim()))try{const l=e.parse(e.repair(r)),c=JSON.stringify(l);if(c===n)return;e.preview(l),n=c}catch{}},a=l=>{if(!t){if(new TextEncoder().encode(l).byteLength>(e.maxBytes??1024*1024))throw t=!0,o(),new Error("JSON stream exceeds the size limit.");r=l,i||(i=setTimeout(s,e.intervalMs??150))}};return{snapshot:a,append(l){a(r+l)},flush:s,finish(){if(t)throw new Error("JSON stream is closed.");t=!0,o();const l=e.parse(r);return e.commit(l),l},cancel(){t=!0,o(),r=""}}}function i_(e){const{source:r}=e,t=e.tickMs??50,n=e.durationMs??8e3;if(!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0)throw new Error("Playback timing must be positive.");if(new TextEncoder().encode(r).byteLength>(e.maxBytes??1024*1024))throw new Error("JSON stream exceeds the size limit.");e.parse(r);let i=Un(e),o=0,s=!1,a=!1,l;const c=Math.max(1,Math.ceil(r.length*t/n)),d=()=>e.onChange({position:o,total:r.length,playing:s}),u=()=>{clearTimeout(l),l=void 0},h=(m=!1)=>{i.snapshot(r.slice(0,o)),o===r.length?(s=!1,u(),i.finish()):m&&i.flush()},p=m=>{s=!1,u(),i.cancel(),d(),e.onError(m)},y=()=>{if(l=void 0,!(!s||a)){o=Math.min(r.length,o+c);try{h()}catch(m){p(m);return}d(),s&&(l=setTimeout(y,t))}};return{play(){a||s||(o===r.length&&(i.cancel(),i=Un(e),o=0),s=!0,d(),l=setTimeout(y,t))},pause(){a||(s=!1,u(),i.flush(),d())},seek(m){if(!a){if(!Number.isFinite(m))throw new Error("Playback position must be finite.");u(),o=Math.max(0,Math.min(r.length,Math.round(m))),i.cancel(),i=Un(e);try{h(!0)}catch(g){p(g);return}d(),s&&(l=setTimeout(y,t))}},dispose(){a=!0,s=!1,u(),i.cancel()}}}function a_({nodeAddress:e,expanded:r=!1}){var c;const{data:t,schema:n,bindings:i}=j.useContext(Mt),{colorText:o,background:s}=it();if((c=i==null?void 0:i[e])!=null&&c.portResources)return null;const a=i&&Pn(i,e,n);if(!t||!a)return null;const l=Te(t,a.address);return!l||typeof l!="object"?null:f.jsx("div",{"data-flow-config-summary":"",style:{width:"100%",minWidth:0,color:_e(o),background:_e(s),fontSize:24,lineHeight:1.4,textTransform:"none"},children:Object.keys(a.type.properties).map(d=>{const u=a.fields[d]??{};if(!oo(u.$visibleWhen,t))return null;const h=l[d],p=h==null?"":typeof h=="object"?JSON.stringify(h):String(h);return f.jsxs("div",{"data-flow-property":d,style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1fr)",gap:12,padding:"10px 16px",borderTop:"1px solid color-mix(in srgb, currentColor 12%, transparent)"},children:[f.jsx("span",{style:{overflowWrap:"anywhere"},children:Nt(u.$label??d)}),f.jsx("span",{title:p,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:r?"pre-wrap":"nowrap",overflowWrap:r?"anywhere":void 0},children:p})]},d)})})}exports.BottomBar=mb;exports.CompactPropertyLayoutToggle=Wm;exports.ConnectionsOnlyToggle=ww;exports.DEFAULT_PALETTE=Jn;exports.DiagramAppearanceControls=Gm;exports.DynamicIcon=Ht;exports.EdgeTools=lb;exports.EditableLabel=Gr;exports.ErrorToast=gb;exports.FlowDiagram=e_;exports.FlowDiagramProvider=wm;exports.FlowPort=Lv;exports.FlowView=Uv;exports.FormDocumentContext=Mt;exports.LIGHT_BLACK=Ur;exports.LoadingBorder=zv;exports.NODE_TYPE_VIEWS=fd;exports.NodeBorderRadiusControl=db;exports.NodeConfigSummary=a_;exports.NodeForm=_d;exports.NodeFormPopover=Yd;exports.NodeIconPicker=Ed;exports.NodeTools=ub;exports.NodeView=$n;exports.SvgExportButton=pb;exports.Swatches=Er;exports.TEXT_PALETTE=sb;exports.ToolbarCloseButton=Hr;exports.ToolbarCommitInput=zr;exports.ToolbarDivider=hn;exports.ToolbarIconButton=Ae;exports.ToolbarRangeInput=pd;exports.ToolbarScrollContainer=Rd;exports.ToolbarSelect=Pt;exports.ToolbarTooltip=Fe;exports.TooltipIconButton=dd;exports.WorkflowControls=kd;exports.addChild=vd;exports.addConnection=xd;exports.addTargetEdge=Ym;exports.addressToPath=Ft;exports.applyCollapsed=sw;exports.applyFormChange=io;exports.applyStateEdits=lw;exports.bindSqueedCallbacks=Sb;exports.compileSqueed=od;exports.connectionIssue=Sd;exports.contentObjTheme=Ut;exports.copySelection=Ad;exports.createFlowDiagram=jr;exports.createFlowDocumentActions=n_;exports.createFormNode=vb;exports.createJsonPlayback=i_;exports.createJsonStream=Un;exports.createWorkflowExecution=fx;exports.downloadSvg=hb;exports.duplicateSelection=Cb;exports.exportSvg=fb;exports.formValueError=zt;exports.getChakraColorHex=_e;exports.getColorVariant=mm;exports.getDarkerHexColor=Hn;exports.getInteractionSurface=lr;exports.getNode=Te;exports.getSelectionRoots=wb;exports.parseFlowDocument=r_;exports.parseJsonContract=wd;exports.parseTypeScriptContract=eb;exports.parseTypeScriptForm=Cd;exports.projectJsonPlaybackPreview=o_;exports.readFormSchema=jd;exports.readWorkflowContract=tb;exports.removeEdge=Qm;exports.removeNode=Xm;exports.reparentNode=xb;exports.resolveEdgeOwner=Cr;exports.resolveStateView=rb;exports.setCollapsed=bd;exports.setEdgeProp=ar;exports.setEdgeStyle=Zm;exports.setNodeProp=xt;exports.updateNode=_t;exports.useCustomColors=it;exports.useEdgeProximity=ym;exports.useFlowData=hr;exports.useFlowDiagramContext=Ve;exports.useNodeViewActions=qn;exports.useStopPropagation=Xd;exports.useThemeContentColors=An;exports.validateGridAdjustment=Nv;
|
|
283
|
+
@media(prefers-reduced-motion:reduce){[data-flow-loading-border][data-flow-loading-border] .flow-sdk-node-border-animation{animation:none!important}}`;function zv({active:e=!0,label:r="Loading content",radius:t}){const{config:n,themeColor:i}=Ue(),{colorText:o}=ot(),s=S.useRef(null),[a,c]=S.useState({width:0,height:0,radius:0});if(S.useLayoutEffect(()=>{const u=s.current;if(!e||!u)return;const h=()=>{const y=u.parentElement,m={width:u.clientWidth,height:u.clientHeight,radius:t??(y&&parseFloat(getComputedStyle(y).borderTopLeftRadius)||0)};c(g=>g.width===m.width&&g.height===m.height&&g.radius===m.radius?g:m)},p=new ResizeObserver(h);return p.observe(u),h(),()=>p.disconnect()},[e,t]),!e)return null;const l=_e(i||o),d={x:4,y:4,width:a.width-8,height:a.height-8,radius:Math.max(0,a.radius-4),color:l,strokeWidth:2};return f.jsxs("div",{ref:s,role:"status","aria-label":r,"data-flow-loading-border":"","data-motion-disabled":n.disableAnimations||void 0,style:{position:"absolute",inset:0,pointerEvents:"none",borderRadius:"inherit",overflow:"hidden",zIndex:2},children:[f.jsx("style",{children:$j}),f.jsxs("svg",{width:"100%",height:"100%","aria-hidden":"true",style:{display:"block",pointerEvents:"none"},children:[f.jsx("g",{opacity:.5,style:{filter:"blur(3px)"},children:f.jsx(Zn,{...d,strokeWidth:6})}),f.jsx(Zn,{...d})]})]})}function qj({content:e,format:r,onEdit:t}){var $;const{config:n,colorMode:i}=Ue(),{background:o,border:s,colorInactive:a}=ot(),c=($=n.customViews)==null?void 0:$.jsxContent,l=typeof e=="string"?e:JSON.stringify(e,null,2);let d,u;if(r==="jsx")try{const N=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(N)||N.some(M=>!M||typeof M!="object"||Array.isArray(M)||typeof M.type!="string"))throw new Error("JSX content must be an array of components with a type.");d=N}catch(N){u=N instanceof Error?N.message:"Invalid components array."}const h=S.useRef(null),p=S.useRef(null),y=S.useRef(null),m=S.useRef(!1),[g,b]=S.useState(!1),[v,x]=S.useState(""),w=!!t;S.useEffect(()=>{const N=()=>{var J;const M=document.fullscreenElement===p.current;b(M),m.current&&!M&&!document.fullscreenElement&&((J=y.current)==null||J.focus({preventScroll:!0})),m.current=M};return document.addEventListener("fullscreenchange",N),()=>document.removeEventListener("fullscreenchange",N)},[]);const C=async()=>{var N;x("");try{if(document.fullscreenElement===p.current)await document.exitFullscreen();else if((N=p.current)!=null&&N.requestFullscreen)await p.current.requestFullscreen();else throw new Error("Fullscreen is not supported in this browser.")}catch(M){x(M instanceof Error?M.message:"Unable to change fullscreen.")}},[j,_]=S.useState(),[k,E]=S.useState(),[O,T]=S.useState();S.useEffect(()=>{if(r==="jsx")return;let N=!1;return Promise.resolve().then(()=>require("./contentPreviewDocument-BsKd0dD4.cjs")).then(({contentPreviewDocument:M})=>M(l,r,w)).then(M=>{N||_({content:l,format:r,editable:w,document:M})},M=>{N||_({content:l,format:r,editable:w,error:M instanceof Error?M.message:String(M)})}),()=>{N=!0}},[l,r,w]),S.useEffect(()=>{if(!t)return;const N=async M=>{var J,ie;if(!(!((J=h.current)!=null&&J.contentWindow)||M.source!==h.current.contentWindow||((ie=M.data)==null?void 0:ie.type)!=="squeed:content-edit"))try{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()}catch(ae){x(ae instanceof Error?ae.message:"Unable to close fullscreen.")}};return window.addEventListener("message",N),()=>window.removeEventListener("message",N)},[t]);const P=(j==null?void 0:j.content)===l&&j.format===r&&j.editable===w?j:void 0,I=!!P&&P===O,R=r!=="jsx"&&!(P!=null&&P.error)&&!I&&(!P||k!==P);return f.jsxs("div",{"data-flow-content-preview":"",style:{width:"100%",height:360,fontSize:16,overflow:"auto"},children:[f.jsx("pre",{"data-flow-preview-source":"",style:{display:"none",whiteSpace:"pre-wrap"},children:l}),f.jsxs(W.Box,{ref:p,position:"relative",w:"100%",h:"100%","aria-busy":r!=="jsx"?R:void 0,bg:r==="jsx"&&i==="dark"?"gray.900":"white",onDoubleClick:N=>{r!=="jsx"||!t||N.defaultPrevented||N.target.closest('button, a, input, textarea, select, [contenteditable], [role="button"], [role="textbox"]')||(N.stopPropagation(),(async()=>{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()})().catch(M=>x(String(M))))},onKeyDownCapture:N=>{N.key!=="Escape"||document.fullscreenElement!==p.current||(N.preventDefault(),N.stopPropagation(),C())},css:{"&:fullscreen":{width:"100vw",height:"100dvh",maxWidth:"none",maxHeight:"none",padding:0},"&:hover > [data-flow-content-toolbar], &:focus-within > [data-flow-content-toolbar]":{opacity:1,pointerEvents:"auto"},"@media (hover: none)":{"& > [data-flow-content-toolbar]":{opacity:1,pointerEvents:"auto"}}},children:[f.jsx(W.Box,{role:"toolbar","aria-label":"Content controls","data-flow-content-toolbar":"",position:"absolute",top:"8px",right:"8px",zIndex:1,w:"max-content",maxW:"calc(100% - 16px)",opacity:g?1:0,pointerEvents:g?"auto":"none",children:f.jsx(kd,{background:o,border:i==="dark"?s:"gray.300",children:f.jsxs(W.HStack,{px:"8px",gap:"8px",h:"100%",w:"max-content",css:{"& button > svg":{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",flexShrink:0}},children:[t&&f.jsx(Ae,{"data-flow-content-edit":"","aria-label":"Edit content source",title:"Edit content source",icon:f.jsx(X.PiCode,{size:20}),size:"sm",variant:"plain",bg:"transparent",color:a,borderRadius:"30px",w:"32px",h:"32px",minW:"32px",p:0,onClick:N=>{N.stopPropagation(),(async()=>{document.fullscreenElement===p.current&&await document.exitFullscreen(),t()})().catch(M=>x(String(M)))}}),f.jsx(Ae,{ref:y,"data-flow-fullscreen":"","aria-label":g?"Exit fullscreen":"Expand preview",title:g?"Exit fullscreen":"Expand preview","aria-expanded":g,icon:g?f.jsx(X.PiArrowsIn,{size:20}):f.jsx(X.PiArrowsOut,{size:20}),size:"sm",variant:"plain",bg:"transparent",color:a,borderRadius:"30px",w:"32px",h:"32px",minW:"32px",p:0,onClick:N=>{N.stopPropagation(),C()}})]})})}),v&&f.jsx(W.Box,{role:"alert",position:"absolute",bottom:0,insetInline:0,bg:"white",color:"red.700",fontSize:"14px",children:v}),r==="jsx"?u?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:u}):c&&d?f.jsx(c,{components:d,colorMode:i,fillHeight:!0}):f.jsx(W.Box,{role:"status",fontSize:"14px",children:"JSX content renderer is not available."}):P!=null&&P.error||I?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:(P==null?void 0:P.error)||"Content preview could not be loaded."}):P!=null&&P.document?f.jsx("iframe",{ref:h,title:`${r.toUpperCase()} content preview`,sandbox:w?"allow-scripts":"",allowFullScreen:!0,referrerPolicy:"no-referrer",srcDoc:P.document,onLoad:()=>E(P),onError:()=>T(P),style:{width:"100%",height:"100%",border:0,display:"block",background:"white",visibility:R?"hidden":"visible"}},P.document):null,f.jsx(zv,{active:R,label:"Loading HTML content"})]})]})}const hm=1.55;function Lj({nodeId:e,content:r,color:t,format:n="markdown"}){const{callbacks:i,config:o,readOnly:s,nodeGridOptions:a}=Ue(),c=!!o.editable&&!s&&!a,l=typeof r=="string"?r:JSON.stringify(r,null,2),[d,u]=S.useState(!1),[h,p]=S.useState(l),[y,m]=S.useState(""),[g,b]=S.useState(),v=S.useRef(null),x=S.useRef(!1),w=Yd(d);S.useLayoutEffect(()=>{const _=v.current;!d||!_||(_.style.height="auto",_.style.height=`${Math.max((g==null?void 0:g.height)??0,_.scrollHeight)}px`)},[h,d,g]),S.useEffect(()=>{var _,k;c?d&&(x.current=!1,(_=v.current)==null||_.focus({preventScroll:!0}),(k=v.current)==null||k.select()):u(!1)},[d,c]);const C=_=>{c&&(b({width:_.offsetWidth,height:_.offsetHeight}),p(l),m(""),u(!0))},j=()=>{var k;if(x.current||!c)return;let _=h;if(n==="jsx")try{if(_=JSON.parse(h),!Array.isArray(_)||_.some(E=>!E||typeof E!="object"||Array.isArray(E)||typeof E.type!="string"))throw new Error("JSX content must be an array of components with a type.")}catch(E){m(E instanceof Error?E.message:"Invalid components array.");return}x.current=!0,h!==l&&((k=i.onNodeContentChange)==null||k.call(i,e,_)),u(!1)};return(!d||!c)&&n!=="markdown"?f.jsx(W.Box,{ref:w,w:"100%",position:"relative","data-flow-content":"",children:f.jsx(qj,{content:r,format:n,onEdit:c?()=>{w.current&&C(w.current)}:void 0})}):!d||!c?f.jsx(W.Box,{"data-flow-content":"",color:t,opacity:r?void 0:.6,w:"100%",minH:"1.2em",whiteSpace:"normal",lineHeight:hm,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:c?"text":void 0,tabIndex:c?0:void 0,outline:"none",_focusVisible:{outline:"none",boxShadow:"none"},onClick:_=>{!c||_.target instanceof Element&&_.target.closest("a, button, input")||(_.stopPropagation(),C(_.currentTarget))},onDoubleClick:_=>{_.stopPropagation(),C(_.currentTarget)},onKeyDown:_=>{c&&_.key==="Enter"&&_.target===_.currentTarget&&(_.preventDefault(),_.stopPropagation(),C(_.currentTarget))},children:f.jsx(ux.default,{options:{forceBlock:!0,wrapper:S.Fragment,disableParsingRawHTML:!0,overrides:{a:{props:{target:"_blank",rel:"noopener noreferrer"}},img:{props:{loading:"lazy",referrerPolicy:"no-referrer"}}}},children:l||(c?"Write your content here":"")})}):f.jsxs("div",{ref:w,style:{width:g==null?void 0:g.width,minHeight:g==null?void 0:g.height,maxWidth:"100%"},children:[f.jsx(W.Textarea,{ref:v,"aria-label":"Node content",placeholder:"Write your content here",value:h,"aria-invalid":!!y,onChange:_=>p(_.target.value),onBlur:j,onKeyDown:_=>{_.stopPropagation(),!_.nativeEvent.isComposing&&(_.key==="Enter"&&(_.ctrlKey||_.metaKey)&&(_.preventDefault(),j()),_.key==="Escape"&&(x.current=!0,u(!1)))},color:t,fontFamily:"inherit",fontSize:"inherit",lineHeight:hm,overflowWrap:"anywhere",whiteSpace:"pre-wrap",rows:1,bg:"transparent",display:"block",style:{border:0,outline:"none",boxShadow:"none"},_focus:{border:0,outline:"none",boxShadow:"none"},_focusVisible:{border:0,outline:"none",boxShadow:"none"},p:0,w:"100%",h:"100%",minW:0,minH:0,resize:"none"}),y&&f.jsx(W.Box,{role:"alert",fontSize:"14px",color:"red.500",children:y})]})}const Fj=(e,r,t)=>{var h,p,y,m;const n=((h=e==null?void 0:e.viewProps)==null?void 0:h.bgColor)||r,[i]=n.split("."),o=An(n),s=((p=e==null?void 0:e.viewProps)==null?void 0:p.outline)===!0,a=n==="transparent"||s,c=t==="dark"?"gray.200":"gray.900",l=a?"transparent":n!=null&&n.startsWith("#")?_e(n):_e(o.bgColor),d=_e(((y=e==null?void 0:e.viewProps)==null?void 0:y.textColor)||(a?c:o.textColor)),u=_e(((m=e==null?void 0:e.viewProps)==null?void 0:m.borderColor)||(s?n==="transparent"?r: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:l,hextextColor:d,hexborderColor:u}},zj=(e,r=350)=>`${String(e).substring(0,r)}${String(e).length>r?"...":""}`,Bj=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,Bv=600,Dj=3,Vj=e=>{const r=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(r*28+30,200)};function Wj({headerTitle:e,hasContent:r,data:t,icon:n,colors:i,hasConfig:o,id:s,isActive:a,isEditing:c,onEditStart:l,onEditEnd:d,props:u,objVisible:h,setObjVisible:p,onShowNativeIcon:y}){var v,x;const{callbacks:m}=Ue(),g=u.onShowIcon??y,b=g?"Show icon":h?"Show content":"Show properties";return f.jsx(f.Fragment,{children:(e||r||((v=t.config)==null?void 0:v.form)||a&&y)&&f.jsxs(W.Flex,{justify:"flex-start",direction:"row",p:r||Object.entries(t.description||{}).length?8:20,borderBottomWidth:1,minWidth:"max-content !important",width:"100%",textTransform:"capitalize",align:"center",textOverflow:"ellipsis",alignItems:"center",fontWeight:"bold",color:i.propertyColor,bgColor:i.highlightColor,borderBottomColor:!o&&!r?"transparent":i.hexborderColor,children:[!!n&&f.jsx(W.Flex,{mr:6,alignItems:"center",flexShrink:0,children:f.jsx(Ht,{name:n,size:64,color:i.hextextColor},i.hextextColor)}),f.jsx(Ur,{nodeId:s,label:Bj(e),color:((x=t==null?void 0:t.viewProps)==null?void 0:x.textColor)||i.propertyColor,isEditing:c,onEditStart:l,onEditEnd:d}),a&&(r||g)&&f.jsx(W.Box,{ml:"auto",pl:6,flexShrink:0,"data-flow-content-toggle":"",children:f.jsx(ze,{label:b,children:f.jsx(Ae,{"aria-label":b,icon:f.jsx(W.Icon,{as:X.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:i.hextextColor,onClick:w=>{var C;w.stopPropagation(),g?g():p(!h),(C=m.onNodeViewToggle)==null||C.call(m,s)}})})})]})})}function Gj({data:e,resourcePorts:r,inspecting:t,form:n,inspectionPorts:i,extraPorts:o,colors:s,direction:a,uniformKeyWidth:c}){const{edgeById:l}=hr(),d=new Set;for(const{data:u}of l.values())u.source===e.id&&u.sourceProperty!==void 0&&d.add(`source:${u.sourceProperty}`),u.target===e.id&&u.targetProperty!==void 0&&d.add(`target:${u.targetProperty}`);return f.jsx(W.Box,{children:Object.entries(e.description||{}).map(([u,h],p)=>{var I,R,$;const y=r&&Object.keys(r).find(N=>N.slice(N.indexOf(":")+1)===u),m=t&&((I=n==null?void 0:n.type.ports)==null?void 0:I[u]),g=y??(m?`${m.kind}:${u}`:u),b=i.find(N=>N.id===g),v=y?"source":b==null?void 0:b.role,x=d.has(`source:${g}`),w=d.has(`target:${g}`),C=o.some(N=>N.id===u),j=h===""&&(C||(v?d.has(`${v}:${g}`):x||w)),_=v??(x!==w?x?"source":"target":void 0),k=(b==null?void 0:b.side)??(_?_==="source"!=(a==="RL")?"right":"left":void 0),E=j&&k==="right"?"right":"left",O=(b==null?void 0:b.label)??(m==null?void 0:m.label)??(C?u.replace(/^(template|input|output|config|error):/,""):u),T=Ut(s.wordBeforeDot)[typeof h],P=Ut(s.wordBeforeDot).property;return f.jsxs(W.Box,{"data-flow-property":y&&(a==="TB"||a==="BT")?void 0:g,"data-flow-port-role":v,"data-flow-inspection-row":t?"":void 0,children:[f.jsxs(W.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[f.jsx(W.Flex,{justifyContent:"start",align:"center",background:s.highlightColor,width:j?"100%":`${c}px`,minWidth:`${c}px`,borderRightColor:s.hexborderColor,borderRightWidth:j?0:1,children:f.jsx(W.Text,{py:5,px:10,w:"100%",textAlign:E,whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((R=e==null?void 0:e.viewProps)==null?void 0:R.textColor)||(s.isTransparent?s.hextextColor:P),children:O})}),!j&&f.jsx(W.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:s.hexbgColor,w:Bv,maxH:200,children:f.jsx(W.Text,{overflow:"hidden",py:3,px:4,whiteSpace:"normal",textOverflow:"ellipsis",fontSize:"4xl",color:(($=e==null?void 0:e.viewProps)==null?void 0:$.textColor)||(s.isTransparent?s.hextextColor:T),fontWeight:400,children:zj(h)})})]}),p!==Object.entries(e.description||{}).length-1&&f.jsx(W.Box,{borderTopWidth:1,my:0,borderColor:s.hexborderColor})]},u)})})}function Uj(e){var x,w,C,j,_;const{themeColor:r,colorMode:t,direction:n}=Ue(),i=qn(),o=i.getNodeViewMode(e.data.id)==="properties",s=k=>i.setNodeViewMode(e.data.id,k?"properties":"default"),a=!!e.onShowIcon||o||typeof((x=e.data.config)==null?void 0:x.content)!="string"&&!(((w=e.data.config)==null?void 0:w.contentFormat)==="jsx"&&Array.isArray((C=e.data.config)==null?void 0:C.content)),{bindings:c,data:l,schema:d}=S.useContext(It),u=(j=c==null?void 0:c[e.data.id])==null?void 0:j.portResources,h=c?Pn(c,e.data.id,d):l&&d?Jr(l,e.data.id,d):void 0,p=h&&Te(l,"address"in h?h.address:e.data.id),y=p&&typeof p=="object"&&h?Object.fromEntries(Object.keys(h.type.properties).filter(k=>{var E;return Object.prototype.hasOwnProperty.call(p,k)&&oo((E=h.fields[k])==null?void 0:E.$visibleWhen,l)}).map(k=>[k,p[k]!==null&&typeof p[k]=="object"?JSON.stringify(p[k],null,2):p[k]===null?"null":p[k]])):{},m=u?Object.fromEntries(Object.entries(u).map(([k,E])=>{var O;return[k.slice(k.indexOf(":")+1),((O=Te(l,E))==null?void 0:O.name)??E.split(".").at(-1)]})):Object.keys(e.data.description??{}).length?e.data.description:y,g=a&&!u?((_=e.data.config)==null?void 0:_.ports)??[]:[],b=g.filter(k=>!Object.prototype.hasOwnProperty.call(m,k.id)&&!Object.entries((h==null?void 0:h.type.ports)??{}).some(([E,O])=>`${O.kind}:${E}`===k.id&&Object.prototype.hasOwnProperty.call(m,E))),v={...m,...Object.fromEntries(b.map(k=>[k.id,""]))};return{themeColor:r,colorMode:t,direction:n,objVisible:o,setObjVisible:s,inspecting:a,resourcePorts:u,form:h,description:v,inspectionPorts:g,extraPorts:b}}const ru=e=>{var v,x,w,C,j,_;const{themeColor:r,colorMode:t,direction:n,objVisible:i,setObjVisible:o,inspecting:s,resourcePorts:a,form:c,description:l,inspectionPorts:d,extraPorts:u}=Uj(e),h=qn(),p=h.getNodeViewMode(e.data.id)==="icon-label",y=!e.onShowIcon&&(typeof((v=e.data.config)==null?void 0:v.content)=="string"||((x=e.data.config)==null?void 0:x.contentFormat)==="jsx"&&Array.isArray((w=e.data.config)==null?void 0:w.content)),m=S.useRef(p);p&&(m.current=!0),eu(e.data.id,y&&!((C=e.data.config)!=null&&C.parentContainer)&&h.allNodesIconLabel&&!p&&m.current,()=>h.setNodeViewMode(e.data.id,"icon-label"));const b=!e.onShowIcon&&!((j=e.data.config)!=null&&j.parentContainer)&&!y?()=>h.setNodeViewMode(e.data.id,"icon-label"):void 0;return!e.onShowIcon&&p?f.jsx(tu,{...e,data:{...e.data,label:e.data.label??e.data.headerTitle,config:{...e.data.config,labelBelow:!0,icon:((_=e.data.config)==null?void 0:_.icon)||"PiBracketsCurly"}},onExpand:()=>h.restoreNodeView(e.data.id)}):f.jsx($n,{...e,data:{...e.data,description:l},children:({id:k,data:E,isActive:O,isEditing:T,onEditStart:P,onEditEnd:I})=>{var he,me,q,F,U,D,de,Q,oe,ce;const R=Fj(E,r,t),$=E.label??E.headerTitle,N=Object.entries(E.description||{}).length>0,M=Vj(E.description),J=(me=(he=e.data)==null?void 0:he.config)==null?void 0:me.icon,ie=(F=(q=e.data)==null?void 0:q.config)==null?void 0:F.content,ae=((U=E==null?void 0:E.viewProps)==null?void 0:U.borderRadius)??"53px",te=Rn(E==null?void 0:E.viewProps,R.hexborderColor,O,Dj);return f.jsx(W.Flex,{justifyContent:"space-between",...E==null?void 0:E.viewProps,"data-flow-node-surface":"",direction:"column",p:0,borderRadius:ae,overflow:"hidden",alignItems:"center",style:{backgroundColor:R.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:"100%",minW:y||e.onShowIcon?M+Bv+te.borderWidth*2:void 0,...te,children:f.jsxs(W.Flex,{width:"100%",direction:"column",borderRadius:ae,borderColor:R.hexborderColor,borderWidth:0,overflow:"hidden",children:[f.jsx(Wj,{headerTitle:$,hasContent:y,data:E,icon:J,colors:R,hasConfig:N,id:k,isActive:O,isEditing:T,onEditStart:P,onEditEnd:I,props:e,objVisible:i,setObjVisible:o,onShowNativeIcon:b}),y&&!i?f.jsx(W.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:R.highlightColor,p:["html","jsx"].includes((de=(D=e.data)==null?void 0:D.config)==null?void 0:de.contentFormat)?0:12,fontSize:"5xl",lineHeight:"normal",children:f.jsx(Lj,{nodeId:k,content:ie,format:(oe=(Q=e.data)==null?void 0:Q.config)==null?void 0:oe.contentFormat,color:((ce=E==null?void 0:E.viewProps)==null?void 0:ce.textColor)||R.hextextColor})}):f.jsx(Gj,{data:E,resourcePorts:a,inspecting:s,form:c,inspectionPorts:d,extraPorts:u,colors:R,direction:n,uniformKeyWidth:M})]})})}})};ru.displayName="NodeJsonObjectView";const Dv=e=>{var h,p,y,m,g,b,v,x,w,C,j;const r=qn(),[t,n]=S.useState(!1),i=r.getNodeViewMode(e.data.id)==="properties",o=_=>{n(_),r.setNodeViewMode(e.data.id,_?"properties":"default")},{callbacks:s,readOnly:a}=Ue(),c=(p=(h=e.data)==null?void 0:h.config)==null?void 0:p.parentContainer;eu(e.data.id,i&&((m=(y=e.data)==null?void 0:y.config)==null?void 0:m.labelBelow)&&!c,()=>o(!1));const l=c?"Show parent":"Show properties",d=c||((b=(g=e.data)==null?void 0:g.config)==null?void 0:b.form)||((w=(x=(v=e.data)==null?void 0:v.config)==null?void 0:x.ports)==null?void 0:w.length),u=d?()=>{var _;c?(_=s.onNodeCollapse)==null||_.call(s,e.data.id,!1):o(!0)}:void 0;return!c&&d&&i?f.jsx(ru,{...e,editOnMount:t,onShowIcon:()=>o(!1)}):f.jsx(tu,{...e,onOpenView:u&&(c||(j=(C=e.data)==null?void 0:C.config)!=null&&j.labelBelow)?()=>{var _;u(),(_=s.onNodeViewToggle)==null||_.call(s,e.data.id)}:void 0,toggleLabel:l,toggleDisabled:c&&a,onExpand:u})};function Hj(e){var b,v,x,w,C,j;const{config:r,callbacks:t,readOnly:n,selectedNodeIds:i,nodeRadiusPreviews:o,nodeViewModes:s,allNodesIconLabel:a}=Ue(),c=o[e.data.id]??((b=e.data.viewProps)==null?void 0:b.borderRadius),[l,d]=S.useState(!1),u=qn(),{border:h,colorText:p}=ot(),y=(v=r.customViews)==null?void 0:v.gridContent,m=(s[e.data.id]??(a?"icon-label":"default"))==="icon-label",g=S.useRef(m);return m&&(g.current=!0),eu(e.data.id,a&&!m&&g.current,()=>u.setNodeViewMode(e.data.id,"icon-label")),m?f.jsx(W.Box,{"data-grid-document":((x=e.data.config)==null?void 0:x.documentId)??"",children:f.jsx(tu,{...e,data:{...e.data,viewProps:{...e.data.viewProps,borderRadius:c},config:{...e.data.config,labelBelow:!0,icon:((w=e.data.config)==null?void 0:w.icon)||"PiGridFour"}},toggleLabel:"Show grid",onExpand:()=>u.restoreNodeView(e.data.id)})}):f.jsxs(f.Fragment,{children:[f.jsx($n,{...e,onOpenView:()=>d(!0),children:({data:_,isActive:k})=>{var E,O,T,P,I,R,$,N;return f.jsx(W.Box,{"data-flow-node-surface":"","data-grid-document":((E=_.config)==null?void 0:E.documentId)??"",width:`${((T=(O=_.config)==null?void 0:O.gridSize)==null?void 0:T.width)??600}px`,height:`${((I=(P=_.config)==null?void 0:P.gridSize)==null?void 0:I.height)??440}px`,overflow:"hidden",position:"relative",bg:((R=_.viewProps)==null?void 0:R.bgColor)??"transparent",color:(($=_.viewProps)==null?void 0:$.textColor)??p,borderRadius:`${c??0}px`,...Rn(_.viewProps,_e(((N=_.viewProps)==null?void 0:N.borderColor)??h),k,0),children:y?f.jsx(y,{...e}):f.jsx(W.Box,{p:4,children:_.label??"Grid"})})}}),f.jsx(Qd,{nodeAddress:e.data.id,active:i.includes(e.data.id),label:e.data.label??"Grid",open:l&&!n,onClose:()=>d(!1),children:f.jsx(It.Provider,{value:{data:{metadata:{label:e.data.label??"",subtitle:((C=e.data.config)==null?void 0:C.subtitle)??"",icon:((j=e.data.config)==null?void 0:j.icon)??"PiGridFour"}},bindings:{[e.data.id]:{address:"root.metadata",type:"GridMetadata"}},schema:{GridMetadata:{kind:"object",properties:{label:{optional:!0,type:{kind:"string"}},subtitle:{optional:!0,type:{kind:"string"}},icon:{optional:!0,type:{kind:"string"}}}}},editable:!!r.editable&&!n,callbacks:{onFormChange:_=>{var E,O,T;if(n||!r.editable)return;const k=String(_.value??"");_.address==="root.metadata.label"?(E=t.onNodeLabelChange)==null||E.call(t,e.data.id,k):_.address==="root.metadata.subtitle"?(O=t.onNodeSubtitleChange)==null||O.call(t,e.data.id,k):_.address==="root.metadata.icon"&&((T=t.onNodeIconChange)==null||T.call(t,e.data.id,k))}}},children:f.jsx(Ed,{nodeAddress:e.data.id})})})]})}const Vv=e=>f.jsx(Dv,{...e,renderCompact:Oj}),Wv=e=>f.jsx(Dv,{...e}),Gv=({containerStyle:e,...r})=>{const{selectedNodeIds:t}=Ue();return f.jsx($n,{...r,editOnMount:t.includes(r.data.id),children:n=>f.jsx(W.Box,{bg:e.textColor==="transparent"?"transparent":e.labelBg,p:`${e.fontSize/5}px`,fontFamily:cr,lineHeight:1,w:"fit-content",children:f.jsx(Ur,{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})})})};Vv.displayName="text";Wv.displayName="arrayView";Gv.displayName="ParentContainerView";const Kj={grid:Hj,objectView:ru,arrayView:Wv,text:Vv,parentContainer:Gv},Jj=({children:e,pattern:r="dot",backgroundColor:t})=>{const{colorMode:n}=Ue(),i=n==="dark",o=i?"--chakra-colors-gray-700":"--chakra-colors-gray-500",s=i?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return r==="none"?f.jsx(W.Box,{"data-flow-background":"none",width:"100%",height:"100%",padding:0,bg:t,children:e}):f.jsxs(W.Box,{"data-flow-background":r,position:"relative",width:"100%",height:"100%",padding:0,bg:t,children:[f.jsx(W.Box,{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:0,pointerEvents:"none",style:{backgroundImage:r==="dot"?`radial-gradient(var(${o}) 8%, transparent 8%)`:r==="steel"?`repeating-linear-gradient(45deg, var(${s}) 0, var(${s}) 1px, transparent 1px, transparent 20px)`:`linear-gradient(var(${s}) 1px, transparent 1px), linear-gradient(90deg, var(${s}) 1px, transparent 1px)`,backgroundSize:"20px 20px",opacity:.3}}),f.jsx(W.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:e})]})},Zj=.4,vr={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},Xj=({nodes:e,edges:r})=>{const{themeColor:t,spacing:n,edgeRadius:i,backgroundVariant:o,backgroundSelected:s,setBackgroundSelected:a,edgeColor:c,direction:l,nodeAlignment:d,edgeMode:u,compactPropertyLayout:h,workflowContract:p,parentNodeStyle:y,engineRef:m,callbacks:g,config:b,selectedNodeIds:v,setSelectedNodeIds:x,selectedEdgeId:w,setSelectedEdgeId:C,setIsPerformanceMode:j,setNodeGridOptions:_,fillRadiusEditedIds:k,isZoomMode:E,setIsZoomMode:O,isMultiSelectMode:T,setIsMultiSelectMode:P,isDragMode:I,setIsDragMode:R,isEdgeHandlesEnabled:$,setIsEdgeHandlesEnabled:N,isArrayNodeMode:M}=Ue(),J=S.useRef(null),[ie,ae]=S.useState(null),te=S.useRef(null),he=e.length>200;S.useEffect(()=>{j(he)},[he,j]);const{edgeSep:me,rankSep:q,spacingFactor:F}=S.useMemo(()=>{const Z=Aw(e.length),z=b.nodeGridSpacing==="layout"&&n<.5?n*1.3:n<1?.3+.7*n:.5+.5*n;return{edgeSep:Z.edgeSep*z,rankSep:Z.rankSep*z,spacingFactor:1.3+(n-1)*(n<1?.4:.3)}},[e.length,n,b.nodeGridSpacing]),{bgColor:U}=An(t),{canvas:D,borderSecondary:de,colorText:Q}=ot(),oe=o==="transparent"?"transparent":b.backgroundColor||D,ce=S.useCallback(Z=>{if(!Z)return _e(t);switch(Z){case"dark":return _e(oe);case"light":return _e(de);default:return _e(Z)}},[t,oe,de]),we=b.colorMode==="dark",Se=we?_e("gray.500"):Hr,ye=we?U!=null&&U.includes("gray")?"whitesmoke":ce(U):Se,pe=c?ce(c):Se,B=S.useMemo(()=>b.initialViewport||{pan:{x:0,y:0},zoom:.01},[]),G=l==="C"?"LR":l,se=S.useCallback(Z=>{const z={...y,...Z};return{...z,bgColor:z.bgColor||t,bgOpacity:z.outline?0:z.bgOpacity??Zj}},[y,t]),H=S.useMemo(()=>{var z;const Z=new Map;for(const re of e)(z=re.data)!=null&&z.id&&Z.set(re.data.id,re);return Z},[e]),ue=S.useMemo(()=>{var z;const Z=new Map;for(const re of r)(z=re.data)!=null&&z.id&&Z.set(re.data.id,re);return Z},[r]),xe=S.useCallback(Z=>{var K;const z=(K=H.get(Z))==null?void 0:K.data,re=se(z==null?void 0:z.viewProps),Me=_e(re.bgColor);return{animated:!!(z!=null&&z.isNodeAnimated)&&!he,animationVariant:z==null?void 0:z.nodeAnimationVariant,animationColor:_e(re.borderColor||t),bgColor:re.outline?"transparent":Me,bgOpacity:re.bgOpacity,borderColor:re.borderColor?_e(re.borderColor):re.outline&&re.bgColor==="transparent"?_e(t):Me,borderWidth:En(re.borderWidth,vr.borderWidth),borderStyle:re.borderStyle??vr.borderStyle,borderRadius:re.borderRadius??vr.borderRadius,textColor:re.textColor?_e(re.textColor):re.outline||re.bgColor==="transparent"?_e(Q):Me,fontSize:re.fontSize??vr.fontSize,labelPosition:re.labelPosition??vr.labelPosition,labelMargin:vr.labelMargin,labelBg:hu(ce("dark"),Me,re.bgOpacity)??ce("dark"),padding:re.padding??vr.padding}},[se,H,Q,t,he,ce]),Oe=S.useMemo(()=>{var re,Me;const Z=new Map;for(const K of r){const ge=(re=K.data)==null?void 0:re.source,Re=(Me=K.data)==null?void 0:Me.target;if(!ge||!Re||ge===Re)continue;const ve=ge<Re?`${ge}|${Re}`:`${Re}|${ge}`,Ke=Z.get(ve);Ke?Ke.push({id:K.data.id,source:ge}):Z.set(ve,[{id:K.data.id,source:ge}])}const z=new Map;for(const[K,ge]of Z){if(ge.length<2)continue;const Re=K.split("|")[0],ve=Math.min(20,70/ge.length);ge.forEach(({id:Ke,source:Ze},Ge)=>{const mt=50+(Ge-(ge.length-1)/2)*ve;z.set(Ke,(Ze===Re?mt:100-mt)/100)})}return z},[r]),Ne=S.useMemo(()=>{const Z=ce("dark");return r.filter(z=>{var re;return((re=z.data)==null?void 0:re.id)&&z.data.source&&z.data.target}).map(({data:z})=>{var ge,Re,ve,Ke,Ze,Ge;let re=Z;const Me=(Re=(ge=H.get(z.source))==null?void 0:ge.data)==null?void 0:Re.parent,K=(Ke=(ve=H.get(z.target))==null?void 0:ve.data)==null?void 0:Ke.parent;if(Me&&Me===K){const mt=se((Ge=(Ze=H.get(Me))==null?void 0:Ze.data)==null?void 0:Ge.viewProps),Rt=hu(Z,_e(mt.bgColor),mt.bgOpacity);Rt&&(re=Rt)}return{id:z.id,data:z,type:z.type??b.edgeType??"rounded-orthogonal",source:z.source,target:z.target,sourceProperty:z.sourceProperty,targetProperty:z.targetProperty,label:z.label,validationIssue:(u==="auto"||u==="properties")&&(z.sourceProperty!==void 0||z.targetProperty!==void 0)&&p?jd(p,z):void 0,color:c?pe:z.color?_e(z.color):pe,connectorColor:c?pe:z.color?_e(z.color):ye,labelBg:re,dashed:!!z.isEdgeDashed,animated:!!z.isEdgeAnimated,inverted:!!z.isInverted,turn:Oe.get(z.id)??.5}})},[r,pe,ye,c,Oe,b.edgeType,u,p,H,se,ce]),Be=S.useMemo(()=>{var z;const Z=new Set;for(const re of e)(z=re.data)!=null&&z.parent&&Z.add(re.data.parent);return Z},[e]),et=S.useMemo(()=>{const Z=new Map;for(const z of r){const re=z.data.isInverted?z.data.target:z.data.source;re&&!Z.has(re)&&Z.set(re,z.data)}for(const z of r){if(z.data.connection)continue;const re=z.data.isInverted?z.data.target:z.data.source,Me=z.data.isInverted?z.data.source:z.data.target;Me.startsWith(`${re}.`)&&(Z.set(re,z.data),Z.set(Me,z.data))}return Z},[r]),We=S.useMemo(()=>{const Z={...Kj,...b.customViews};return e.filter(z=>{var re;return(re=z.data)==null?void 0:re.id}).map(z=>{var ve,Ke,Ze,Ge,mt,Rt;const re=Be.has(z.data.id)&&!z.data.parent,Me=re?z.data.label??z.data.headerTitle??"Container":void 0,K=re?Z.parentContainer:Z[z.data.type]||Z.text,ge=et.get(z.data.id),Re={...z,isInverted:((ve=z.data.config)==null?void 0:ve.isInverted)??(ge==null?void 0:ge.isInverted),isParent:re,containerStyle:re?xe(z.data.id):void 0};return{id:z.data.id,collapsed:(Ke=z.data.config)==null?void 0:Ke.collapsed,parent:z.data.parent,acceptsChildren:!!((Ze=z.data.config)!=null&&Ze.parentContainer)||Be.has(z.data.id),label:Me,animated:!!z.data.isNodeAnimated,animationVariant:z.data.nodeAnimationVariant,hasCollapseControl:((Ge=z.data.config)==null?void 0:Ge.collapsed)!==void 0,animationColor:_e(((mt=z.data.viewProps)==null?void 0:mt.borderColor)||t),animationWidth:En((Rt=z.data.viewProps)==null?void 0:Rt.borderWidth,8),element:S.createElement(K,{...Re,key:`${z.data.id}-${t}`}),fillElement:k.has(z.data.id)?void 0:S.createElement(K,{...Re,data:{...z.data,viewProps:{...z.data.viewProps,borderRadius:0}},containerStyle:Re.containerStyle?{...Re.containerStyle,borderRadius:0}:void 0,key:`${z.data.id}-${t}`})}})},[e,Be,et,t,b.customViews,xe,k]),gt=S.useMemo(()=>he?300:e.length>50?150:e.length>20?100:50,[e.length,he]),He=S.useRef(b);He.current=b;const rt=S.useRef(E);rt.current=E;const ft=S.useRef(M);ft.current=M;const Pe=S.useRef(v);Pe.current=v;const Fe=S.useRef(w);Fe.current=w;const it=S.useRef(T);it.current=T;const at=S.useRef(H);at.current=H;const Lt=S.useRef(ue);Lt.current=ue;const De=S.useRef(new Map);S.useEffect(()=>{var re,Me;const Z=new Map([...ue].filter(([,K])=>H.has(K.data.source)&&H.has(K.data.target))),z=De.current;De.current=Z;for(const[K,ge]of z)Z.has(K)||(Fe.current===K&&(C(null),(re=g.onEdgeDeselect)==null||re.call(g)),(Me=g.onEdgeRemove)==null||Me.call(g,K,ge.data))},[ue,H,g,C]),S.useEffect(()=>{const Z=J.current;if(!ie||!Z)return;let z=null,re=null,Me=0,K=0,ge=0,Re=0,ve=0;const Ke=Ze=>{if(He.current.readOnly)return;const Ge=Z.ownerDocument.fullscreenElement;if(Ge&&Ge!==Z&&Z.contains(Ge)&&Ze.target instanceof Node&&Ge.contains(Ze.target))return;Ze.preventDefault(),Ze.stopPropagation(),rt.current||Ze.metaKey||Ze.ctrlKey?(ge+=Ze.deltaY,Re=Ze.clientX,ve=Ze.clientY,re===null&&(re=requestAnimationFrame(()=>{re=null;const Rt=He.current,Zt=ie.zoom(),wt=ge;ge=0;let lt=Zt-wt*.05/100;lt=Math.max(Rt.minZoom??.01,Math.min(Rt.maxZoom??1.5,lt));const Ct=Z.getBoundingClientRect();ie.zoomAt(lt,{x:Re-Ct.left,y:ve-Ct.top})}))):(Me+=Ze.deltaX,K+=Ze.deltaY,z===null&&(z=requestAnimationFrame(()=>{z=null;const Rt=ie.pan(),Zt=ie.zoom(),wt=.35,lt=Me,Ct=K;Me=0,K=0,ie.pan({x:Rt.x+-lt*wt/Zt,y:Rt.y+-Ct*wt/Zt})})))};return Z.addEventListener("wheel",Ke,{passive:!1}),()=>{Z.removeEventListener("wheel",Ke),z!==null&&cancelAnimationFrame(z),re!==null&&cancelAnimationFrame(re)}},[ie]),S.useEffect(()=>{if(b.disableKeyboardShortcuts)return;const Z=z=>{var Me,K,ge,Re;if(He.current.readOnly)return;const re=z.target;if(!(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.isContentEditable)){if((z.key==="z"||z.key==="Z")&&O(!rt.current),(z.key==="m"||z.key==="M")&&P(!T),(z.key==="d"||z.key==="D")&&R(!I),(z.key==="v"||z.key==="V")&&!z.repeat&&!z.metaKey&&!z.ctrlKey&&!z.altKey&&re.tagName!=="SELECT"&&N(!$),(z.key==="Delete"||z.key==="Backspace")&&Fe.current){z.preventDefault();const ve=Fe.current;(K=g.onEdgeDelete)==null||K.call(g,ve,((Me=Lt.current.get(ve))==null?void 0:Me.data)??{id:ve}),C(null);return}if((z.key==="Delete"||z.key==="Backspace")&&Pe.current.length>0){z.preventDefault();const ve=Pe.current.filter(Ke=>Ke!=="root");if(ve.length===0)return;for(const Ke of ve){const Ze=(ge=at.current.get(Ke))==null?void 0:ge.data;(Re=g.onNodeDelete)==null||Re.call(g,Ke,Ze||{})}x([])}}};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[T,I,$,N,O,P,R,b.disableKeyboardShortcuts,g,x,C]);const Ye=S.useCallback(Z=>{var z;m.current=Z,ae(Z),(z=g.onInit)==null||z.call(g,Z)},[m,g]),Vt=S.useCallback(Z=>{var z;return(z=g.onViewportChange)==null?void 0:z.call(g,Z)},[g]),ct=S.useCallback(Z=>{var re,Me,K;const z=((re=Lt.current.get(Z))==null?void 0:re.data)??{id:Z};if(Fe.current===Z&&it.current){C(null),(Me=g.onEdgeDeselect)==null||Me.call(g);return}Pe.current.length&&x([]),C(Z),(K=g.onEdgeSelect)==null||K.call(g,Z,z)},[g,C,x]),tr=S.useCallback(()=>{var Z,z,re,Me,K;if(a(b.bottomBarCollapsed??(Pe.current.length>0||!!Fe.current||!s)),(Z=g.onBackgroundClick)==null||Z.call(g),!He.current.readOnly){const ge=new Set;for(const Re of Pe.current){let ve=at.current.get(Re);for(;ve&&!ge.has(ve.data.id);)ge.add(ve.data.id),Be.has(ve.data.id)&&((z=ve.data.config)==null?void 0:z.collapsed)!==!0&&((re=g.onNodeCollapse)==null||re.call(g,ve.data.id,!0)),ve=ve.data.parent?at.current.get(ve.data.parent):void 0}}Pe.current.length&&(x([]),(Me=g.onNodeDeselect)==null||Me.call(g)),Fe.current&&(C(null),(K=g.onEdgeDeselect)==null||K.call(g))},[g,x,C,a,s,b.bottomBarCollapsed,Be]),Wt=S.useCallback(Z=>{var Me,K;const z=Pe.current,re=Z.filter(ge=>!z.includes(ge));if(re.length){x([...z,...re]);for(const ge of re)(K=g.onNodeSelect)==null||K.call(g,ge,((Me=at.current.get(ge))==null?void 0:Me.data)??{id:ge})}},[g,x]),Ir=S.useCallback((Z,z)=>{var re,Me;x([Z]),(Me=g.onNodeSelect)==null||Me.call(g,Z,((re=at.current.get(Z))==null?void 0:re.data)??{id:Z},z)},[g,x]),Et=S.useRef(null),Gt=S.useCallback((Z,z,re)=>{var Me;Et.current={source:Z,target:z,edgeIds:new Set(Lt.current.keys())};try{(Me=g.onEdgeCreate)==null||Me.call(g,Z,z,re)}catch(K){throw Et.current=null,K}},[g]),Jt=S.useCallback((Z,z,re,Me=!1)=>{var K,ge;if(te.current={sourceId:Z,nodeIds:new Set(at.current.keys()),reverse:Me},!(u==="properties"&&((K=g.onNodeCreateRequest)==null?void 0:K.call(g,{sourceNodeId:Z,position:z,sourceProperty:re,reverse:Me}))===!0)){if(re!==void 0||Me){te.current=null;return}(ge=g.onNodeCreate)==null||ge.call(g,{type:"text",sourceNodeId:Z,position:z,isArrayMode:ft.current})}},[g,u]),Mr=!b.readOnly&&$&&b.edgeHandles!==!1,gr=o==="transparent"?"none":o;return f.jsx(Jj,{pattern:gr,backgroundColor:oe,children:f.jsx(W.Box,{ref:J,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:f.jsx(Pj,{nodes:We,edges:Ne,direction:G,nodeAlignment:d,onContainerCollapse:Z=>{var z,re;(z=g.onNodeCollapse)==null||z.call(g,Z,!0),(re=g.onNodeViewToggle)==null||re.call(g,Z)},selectedNodeIds:v,edgeMode:u,compactPropertyLayout:h,edgeType:b.edgeType,edgeRadius:i,customEdgeTypes:b.customEdgeTypes,edgeReveal:b.disableAnimations?void 0:b.edgeReveal,rankSep:q,edgeSep:me,nodeGridSpacing:b.nodeGridSpacing,nodeGridConnections:b.nodeGridConnections,spacingFactor:F,compactSpacingScale:n,layoutDebounce:gt,isPerformanceMode:he,minZoom:b.minZoom??.01,maxZoom:b.maxZoom??1.5,initialViewport:B,fitOnInit:!b.initialViewport,readOnly:!!b.readOnly,containerStyle:xe,lineColor:c?pe:ye,drawMode:Mr,drawHandles:!b.readOnly&&b.edgeHandles!==!1,dragMode:I,multiSelect:!!T,onInit:Ye,onLayoutComplete:Z=>{var ge;(ge=g.onLayoutComplete)==null||ge.call(g,Z);const z=Et.current;z&&(!at.current.has(z.source)||!at.current.has(z.target)?Et.current=null:r.some(({data:Re})=>Re.source===z.source&&Re.target===z.target&&!z.edgeIds.has(Re.id))&&Z.getNodeBox(z.source)&&Z.getNodeBox(z.target)&&(Et.current=null,Z.focusConnections(z.source)));const re=te.current;if(!re)return;if(!at.current.has(re.sourceId)){te.current=null;return}const K=e.filter(Re=>!re.nodeIds.has(Re.data.id)).filter(Re=>r.some(({data:ve})=>ve.source===re.sourceId&&ve.target===Re.data.id||ve.target===re.sourceId&&ve.source===Re.data.id));!K.length||K.some(Re=>!Z.getNodeBox(Re.data.id))||(te.current=null,Z.focusBranch(re.reverse?K[0].data.id:re.sourceId))},onNodeGridModeChange:_,onNodeGridZoomOut:g.onNodeGridZoomOut,onNodeGridDrop:g.onNodeGridDrop,onNodeParentChange:g.onNodeParentChange,animateViewport:b.animateViewport,disableAnimations:b.disableAnimations,onViewportChange:Vt,onBackgroundTap:tr,onBoxSelect:Wt,onEdgeSelect:ct,onContainerSelect:Ir,onEdgeDraw:Gt,onDrawIntoSpace:Jt})})})},Uv=S.memo(Xj),Yj=".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 pm=!1;function Qj(){if(pm||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=Yj+".flow-sdk-canvas[data-node-grid] .flow-sdk-node,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *::before,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *::after{animation:none!important;transition:none!important}.flow-sdk-node[data-grid-fill] [data-flow-icon-label]{--flow-grid-caption-color:var(--flow-grid-on-surface-color)}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]{border:0;outline:none;box-shadow:none}.flow-sdk-node[data-grid-fill]{box-sizing:border-box}.flow-sdk-node[data-grid-fill] :not(svg):has([data-flow-node-surface]),.flow-sdk-node[data-grid-fill]>:not(svg):not(button){width:100%;height:100%;min-width:0;max-width:none}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]{width:100%;height:100%;min-width:0;max-width:none;box-sizing:border-box;overflow:hidden}.flow-sdk-node[data-grid-fill] [data-flow-icon-label]{gap:0}.flow-sdk-node[data-grid-fill] [data-flow-icon-caption]{position:absolute;bottom:12px;left:12px;width:calc(100% - 24px);max-height:40%;overflow:hidden}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]>svg{max-width:45%;max-height:55%}.flow-sdk-node[data-grid-fill] p{font-size:var(--flow-grid-font);white-space:normal;overflow-wrap:anywhere}.flow-sdk-canvas[data-node-grid]:not([data-grid-connections]) .flow-sdk-property-port,.flow-sdk-canvas[data-node-grid]:not([data-grid-connections]) .flow-sdk-handle,.flow-sdk-canvas[data-node-grid] [data-flow-collapse-control]{display:none}.flow-sdk-node[data-grid-draggable] :not(button):not(input):not(textarea):not(select):not(a){cursor:inherit}"+_b+Rw+_w+".flow-sdk-handle{position:absolute;left:-36px;top:50%;transform:translateY(-50%);width:36px;height:36px;display:grid;place-items:center;border:2px solid currentColor;border-radius:50%;background:white;cursor:crosshair;opacity:0;pointer-events:none}.flow-sdk-node:hover>.flow-sdk-handle,.flow-sdk-handle:focus-visible{opacity:1;pointer-events:auto}.flow-sdk-draw .flow-sdk-node *,.flow-sdk-draw .flow-sdk-edge *,.flow-sdk-draw .flow-sdk-container *,.flow-sdk-ghost *{pointer-events:none}",document.head.appendChild(e),e.textContent+=".flow-sdk-draw .flow-sdk-node{pointer-events:auto}.flow-sdk-draw .flow-sdk-node>.flow-sdk-handle{opacity:0;pointer-events:none}.flow-sdk-draw .flow-sdk-node:hover>.flow-sdk-handle,.flow-sdk-draw .flow-sdk-node>.flow-sdk-handle:focus-visible{opacity:1;pointer-events:auto}",e.textContent+='.flow-sdk-property-port{position:absolute;transform:translateY(-50%);width:32px;height:32px;margin:0;padding:0;border:3px solid currentColor;border-radius:50%;background:white;cursor:crosshair;pointer-events:auto;z-index:20}.flow-sdk-property-port[data-port-role="source"]{background:currentColor}.flow-sdk-property-port:hover{outline:3px solid currentColor;outline-offset:3px}.flow-sdk-draw .flow-sdk-node .flow-sdk-property-port{pointer-events:auto}',pm=!0}function e_({loading:e=!1,loader:r,...t}){var c,l;const[n,i]=S.useState(null),o=S.useMemo(()=>!!(n!=null&&n.json)&&!!t.json&&Cw(n.json,t.json),[n==null?void 0:n.json,t.json]),s=n===null||n.json!==t.json&&!o,a=e||s;return S.useEffect(()=>{!e&&o&&(n==null?void 0:n.json)!==t.json&&i(t)},[e,o,n==null?void 0:n.json,t.json]),S.useEffect(()=>{if(e||!s)return;let d;const u=requestAnimationFrame(()=>{d=requestAnimationFrame(()=>i(t))});return()=>{cancelAnimationFrame(u),d!==void 0&&cancelAnimationFrame(d)}},[e,s,t.json]),f.jsxs(W.Box,{className:t.className,style:t.style,width:"100%",height:"100%",position:"relative","aria-busy":a,children:[f.jsx("div",{style:{width:"100%",height:"100%"},ref:d=>{a?d==null||d.setAttribute("inert",""):d==null||d.removeAttribute("inert")},children:n&&f.jsx(t_,{...s?n:t,children:t.children,config:t.config,className:void 0,style:void 0})}),a&&r!==null&&f.jsx(W.Box,{"data-flow-loader":"",role:"status","aria-label":"Loading diagram",position:"absolute",inset:0,zIndex:1e3,display:"grid",placeItems:"center",background:((c=t.config)==null?void 0:c.colorMode)==="dark"?"gray.800":"gray.100",color:((l=t.config)==null?void 0:l.colorMode)==="dark"?"whiteAlpha.800":"blackAlpha.800",children:r===void 0?f.jsx("span",{children:"Loading diagram..."}):r})]})}function t_({title:e="untitled",json:r,forms:t,nodes:n,edges:i,config:o={},callbacks:s={},className:a,style:c,showBottomBar:l=!0,children:d}){Qj();const[u,h]=S.useState(),[p,y]=S.useState(!1),m=o.formSchema??u,g=S.useMemo(()=>r&&t?nb(r,t.state):r,[r,t==null?void 0:t.state]),b=o.direction==="C",v=S.useMemo(()=>{let T,P;return I=>(P=T&&P?Sw(T,I,P)??id(I,{title:e,isCenter:b}):id(I,{title:e,isCenter:b}),T=I,P)},[e,b]),x=S.useMemo(()=>g?v(g):null,[g,v]),w=S.useMemo(()=>t!=null&&t.structured&&!p&&m?ob(t.state,t.bindings,m,(x==null?void 0:x.nodes)??n??[]):void 0,[t==null?void 0:t.structured,p,t==null?void 0:t.state,t==null?void 0:t.bindings,m,x,n]),C=(w==null?void 0:w.schema)??m,j=(w==null?void 0:w.bindings)??(t==null?void 0:t.bindings),_=S.useMemo(()=>[...(x==null?void 0:x.nodes)??n??[],...(w==null?void 0:w.nodes)??[]].map(P=>{var ie,ae,te,he;const I=r?(ie=Te(r,P.data.id))==null?void 0:ie.$view:(ae=P.data.config)==null?void 0:ae.typeView,R=I&&hd.includes(I)?I:void 0,$=R?R==="icon-label":(te=P.data.config)==null?void 0:te.labelBelow,N=R==="object"?"objectView":R==="text"?"text":$?"arrayView":P.data.type,M=C&&(t?Pn(j,P.data.id,C):r&&Jr(r,P.data.id,C)),J=(((he=P.data.config)==null?void 0:he.ports)??[]).map(me=>({...me}));if(w&&M){const me=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[q,F]of Object.entries(M.type.ports??{})){const U=`${F.kind}:${q}`,D=J.find(de=>de.id===U);D?D.label===void 0&&F.label!==void 0&&(D.label=F.label):J.push({id:U,...F.label!==void 0?{label:F.label}:{},role:F.kind==="input"||F.kind==="config"?"target":"source",side:me[F.kind],...F.kind==="config"?{placement:"config"}:{}})}for(const q of J){const F=J.filter(U=>U.side===q.side);q.position=(F.indexOf(q)+1)/(F.length+1)}}return M||$||R?{...P,data:{...P.data,type:N,...t?{description:Object.fromEntries(Object.entries(P.data.description??{}).filter(([me])=>!me.startsWith("$")&&!(w!=null&&w.slots.has(ln(P.data.id,me)))))}:{},config:{...P.data.config,...w&&M?{ports:J}:{},...M?{form:!0}:{},...R?{typeView:R,labelBelow:!!$}:$?{labelBelow:!0}:{}}}}:P}),[x,n,r,C,j,w,o.direction]),k=[...(x==null?void 0:x.edges)??i??[],...(w==null?void 0:w.edges)??[]],E=S.useMemo(()=>{const T=r&&x?jb(r,x.edges,s,s.onJsonChange,m):{...s};if(w){const P=new Set([...w.nodes.map(I=>I.data.id),...w.edges.map(I=>I.data.id)]);for(const I of Object.keys(T)){if(!/^on(?:Node|Edge).*(?:Change|Collapse)$/.test(I))continue;const R=T[I];T[I]=($,...N)=>{if(!P.has($))return R==null?void 0:R($,...N)}}}return{...T,onAllNodesIconLabelChange:P=>{var I;y(P),(I=T.onAllNodesIconLabelChange)==null||I.call(T,P)}}},[r,x,s,m,w]),O=S.useMemo(()=>{if(!t)return E;let T=t.state;const P=R=>{if(o.readOnly||o.editable===!1)return;const $=t.onStateChange??t.onChange;if(!$)return;const N=dw(T,R,s.onFormChange);N!==T&&(T=N,$(N,{...R,data:N}))},I=(R,$,N)=>{var J;const M=r&&((J=Te(r,R))==null?void 0:J[$]);return!M||typeof M.$state!="string"?!1:(P({address:M.$state,nodeAddress:R,previousValue:Te(T,M.$state),value:N,data:T}),!0)};return{...E,onFormChange:P,onNodeCreateRequest:R=>{var M,J;const $=(M=R.sourceProperty)!=null&&M.startsWith("config:")?R.sourceProperty.slice(7):void 0,N=$!==void 0&&(w==null?void 0:w.slots.get(ln(R.sourceNodeId,$)));return N?(N.present||P({data:T,nodeAddress:N.address.split(".").slice(0,-1).join("."),address:N.address,value:dn(N.type),previousValue:void 0}),!0):((J=E.onNodeCreateRequest)==null?void 0:J.call(E,R))??!1},onNodeDelete:(R,$)=>{var te,he;if(!(w!=null&&w.nodes.some(me=>me.data.id===R)))return(te=E.onNodeDelete)==null?void 0:te.call(E,R,$);const N=w&&[...w.slots.values()].find(me=>me.nodeId===R);if(!N)return(he=E.onNodeDelete)==null?void 0:he.call(E,R,$);const M=N.address.split("."),J=M.pop(),ie=M.join("."),ae=Te(T,ie);P(Array.isArray(ae)?{data:T,nodeAddress:ie,address:ie,previousValue:ae,value:ae.filter((me,q)=>String(q)!==J)}:{data:T,nodeAddress:ie,address:N.address,previousValue:Te(T,N.address),value:void 0})},onEdgeCreate:(R,$,N)=>{var ie,ae;const M=((ie=N==null?void 0:N.targetProperty)==null?void 0:ie.startsWith("config:"))&&(w==null?void 0:w.slots.get(ln($,N.targetProperty.slice(7)))),J=w==null?void 0:w.containers.get(R);if(M&&J&&(N==null?void 0:N.sourceProperty)==="output:resource"){const te=hw(T,J,M);te!==void 0&&P({data:T,nodeAddress:M.address.split(".").slice(0,-1).join("."),address:M.address,previousValue:Te(T,M.address),value:te});return}M||w!=null&&w.nodes.some(te=>te.data.id===R||te.data.id===$)||(ae=E.onEdgeCreate)==null||ae.call(E,R,$,N)},onEdgeDelete:(R,$)=>{var he;const N=w==null?void 0:w.edges.find(me=>me.data.id===R);if(!N)return(he=E.onEdgeDelete)==null?void 0:he.call(E,R,$);const M=w.slots.get(ln(N.data.target,N.data.targetProperty.slice(7))),J=M.address.split("."),ie=J.pop(),ae=J.join("."),te=Te(T,ae);P(Array.isArray(te)?{data:T,nodeAddress:ae,address:ae,previousValue:te,value:te.filter((me,q)=>String(q)!==ie)}:{data:T,nodeAddress:ae,address:M.address,previousValue:Te(T,M.address),value:void 0})},onNodeContentChange:(R,$)=>{var N,M;I(R,"$content",$)?(N=s.onNodeContentChange)==null||N.call(s,R,$):(M=E.onNodeContentChange)==null||M.call(E,R,$)},onNodeLabelChange:(R,$)=>{var N,M;I(R,"$label",$)?(N=s.onNodeLabelChange)==null||N.call(s,R,$):(M=E.onNodeLabelChange)==null||M.call(E,R,$)}}},[E,t,r,s,w,o.readOnly,o.editable]);return f.jsx(It.Provider,{value:{data:(t==null?void 0:t.state)??r,viewData:r,bindings:j,references:t==null?void 0:t.references,structured:w,renderForm:t==null?void 0:t.renderForm,editable:t?!!(t.onStateChange??t.onChange):!!s.onJsonChange,schema:C,setSchema:T=>{var P;h(T),(P=s.onFormSchemaChange)==null||P.call(s,T)},callbacks:O},children:f.jsx(Cm,{config:w?{...o,formSchema:C}:o,callbacks:O,nodes:_,edges:k,children:f.jsxs(W.Box,{className:a,"data-flow-diagram":"","data-animations-disabled":o.disableAnimations||void 0,style:c,width:"100%",height:"100%",position:"relative",overflow:"hidden",css:{"&[data-animations-disabled], &[data-animations-disabled] *, &[data-animations-disabled] *::before, &[data-animations-disabled] *::after":{animation:"none !important",transition:"none !important"},"& input, & textarea, & select":{outline:"none !important",boxShadow:"none !important"}},children:[f.jsx(Uv,{nodes:_,edges:k}),l&&f.jsx(bb,{}),d]})})})}function r_(e){return fd(JSON.parse(e))}function fd(e){if(!e||typeof e!="object")throw new Error("Expected a JSON object or array.");const r=new Set,t=n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(!n||typeof n!="object"||r.has(n)||!Array.isArray(n)&&![Object.prototype,null].includes(Object.getPrototypeOf(n)))throw new Error("Document must contain only finite, acyclic JSON values.");r.add(n);for(const[i,o]of Object.entries(n)){if(["__proto__","prototype","constructor"].includes(i))throw new Error(`Unsafe document key: ${i}`);t(o)}r.delete(n)}};return t(e),structuredClone(e)}function n_(e){return{replaceJson(r){if(e.readOnly||!e.onJsonChange)throw new Error("JSON document is read-only.");const t=fd(r);return e.onJsonChange(t,{type:"documentReplace",address:"root"}),t},replaceState(r){if(e.readOnly||!e.onStateChange)throw new Error("Form state is read-only.");const t=fd(r);return e.onStateChange(t,{address:"root",nodeAddress:"root",previousValue:e.state,value:t,data:t}),t}}}function o_(e,r){const t=(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)=>t(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==="$content"&&n.$contentFormat==="jsx"&&i.$contentFormat==="jsx"&&Array.isArray(s)&&Array.isArray(i[o]))return[[o,s.filter((c,l)=>JSON.stringify(c)===JSON.stringify(i[o][l]))]];if(o.startsWith("$")&&o!=="$")return JSON.stringify(s)===JSON.stringify(i[o])?[[o,s]]:[];const a=t(s,i[o]);return a===void 0?[]:[[o,a]]}))};return t(e,r)??{}}function Un(e){let r="",t=!1,n="",i;const o=()=>{clearTimeout(i),i=void 0},s=()=>{if(o(),!(t||!r.trim()))try{const c=e.parse(e.repair(r)),l=JSON.stringify(c);if(l===n)return;e.preview(c),n=l}catch{}},a=c=>{if(!t){if(new TextEncoder().encode(c).byteLength>(e.maxBytes??1024*1024))throw t=!0,o(),new Error("JSON stream exceeds the size limit.");r=c,i||(i=setTimeout(s,e.intervalMs??150))}};return{snapshot:a,append(c){a(r+c)},flush:s,finish(){if(t)throw new Error("JSON stream is closed.");t=!0,o();const c=e.parse(r);return e.commit(c),c},cancel(){t=!0,o(),r=""}}}function i_(e){const{source:r}=e,t=e.tickMs??50,n=e.durationMs??8e3;if(!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0)throw new Error("Playback timing must be positive.");if(new TextEncoder().encode(r).byteLength>(e.maxBytes??1024*1024))throw new Error("JSON stream exceeds the size limit.");e.parse(r);let i=Un(e),o=0,s=!1,a=!1,c;const l=Math.max(1,Math.ceil(r.length*t/n)),d=()=>e.onChange({position:o,total:r.length,playing:s}),u=()=>{clearTimeout(c),c=void 0},h=(m=!1)=>{i.snapshot(r.slice(0,o)),o===r.length?(s=!1,u(),i.finish()):m&&i.flush()},p=m=>{s=!1,u(),i.cancel(),d(),e.onError(m)},y=()=>{if(c=void 0,!(!s||a)){o=Math.min(r.length,o+l);try{h()}catch(m){p(m);return}d(),s&&(c=setTimeout(y,t))}};return{play(){a||s||(o===r.length&&(i.cancel(),i=Un(e),o=0),s=!0,d(),c=setTimeout(y,t))},pause(){a||(s=!1,u(),i.flush(),d())},seek(m){if(!a){if(!Number.isFinite(m))throw new Error("Playback position must be finite.");u(),o=Math.max(0,Math.min(r.length,Math.round(m))),i.cancel(),i=Un(e);try{h(!0)}catch(g){p(g);return}d(),s&&(c=setTimeout(y,t))}},dispose(){a=!0,s=!1,u(),i.cancel()}}}function a_({nodeAddress:e,expanded:r=!1}){var l;const{data:t,schema:n,bindings:i}=S.useContext(It),{colorText:o,background:s}=ot();if((l=i==null?void 0:i[e])!=null&&l.portResources)return null;const a=i&&Pn(i,e,n);if(!t||!a)return null;const c=Te(t,a.address);return!c||typeof c!="object"?null:f.jsx("div",{"data-flow-config-summary":"",style:{width:"100%",minWidth:0,color:_e(o),background:_e(s),fontSize:24,lineHeight:1.4,textTransform:"none"},children:Object.keys(a.type.properties).map(d=>{const u=a.fields[d]??{};if(!oo(u.$visibleWhen,t))return null;const h=c[d],p=h==null?"":typeof h=="object"?JSON.stringify(h):String(h);return f.jsxs("div",{"data-flow-property":d,style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1fr)",gap:12,padding:"10px 16px",borderTop:"1px solid color-mix(in srgb, currentColor 12%, transparent)"},children:[f.jsx("span",{style:{overflowWrap:"anywhere"},children:Ot(u.$label??d)}),f.jsx("span",{title:p,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:r?"pre-wrap":"nowrap",overflowWrap:r?"anywhere":void 0},children:p})]},d)})})}exports.BottomBar=bb;exports.CompactPropertyLayoutToggle=Gm;exports.ConnectionsOnlyToggle=ww;exports.DEFAULT_PALETTE=Jn;exports.DiagramAppearanceControls=Um;exports.DynamicIcon=Ht;exports.EdgeTools=db;exports.EditableLabel=Ur;exports.ErrorToast=yb;exports.FlowDiagram=e_;exports.FlowDiagramProvider=Cm;exports.FlowPort=Fv;exports.FlowView=Uv;exports.FormDocumentContext=It;exports.LIGHT_BLACK=Hr;exports.LoadingBorder=zv;exports.NODE_TYPE_VIEWS=hd;exports.NodeBorderRadiusControl=ub;exports.NodeConfigSummary=a_;exports.NodeForm=Ed;exports.NodeFormPopover=Qd;exports.NodeIconPicker=Rd;exports.NodeTools=fb;exports.NodeView=$n;exports.SvgExportButton=gb;exports.Swatches=Er;exports.TEXT_PALETTE=cb;exports.ToolbarCloseButton=Kr;exports.ToolbarCommitInput=zr;exports.ToolbarDivider=pn;exports.ToolbarIconButton=Ae;exports.ToolbarRangeInput=gd;exports.ToolbarScrollContainer=kd;exports.ToolbarSelect=At;exports.ToolbarTooltip=ze;exports.TooltipIconButton=ud;exports.WorkflowControls=Ad;exports.addChild=xd;exports.addConnection=wd;exports.addTargetEdge=Qm;exports.addressToPath=Ft;exports.applyCollapsed=sw;exports.applyFormChange=io;exports.applyStateEdits=lw;exports.bindSqueedCallbacks=jb;exports.compileSqueed=id;exports.connectionIssue=jd;exports.contentObjTheme=Ut;exports.copySelection=Pd;exports.createFlowDiagram=jr;exports.createFlowDocumentActions=n_;exports.createFormNode=xb;exports.createJsonPlayback=i_;exports.createJsonStream=Un;exports.createWorkflowExecution=fx;exports.downloadSvg=pb;exports.duplicateSelection=Sb;exports.exportSvg=hb;exports.formValueError=zt;exports.getChakraColorHex=_e;exports.getColorVariant=bm;exports.getDarkerHexColor=Hn;exports.getInteractionSurface=lr;exports.getNode=Te;exports.getSelectionRoots=Cb;exports.parseFlowDocument=r_;exports.parseJsonContract=Cd;exports.parseTypeScriptContract=tb;exports.parseTypeScriptForm=Sd;exports.projectJsonPlaybackPreview=o_;exports.readFormSchema=_d;exports.readWorkflowContract=rb;exports.removeEdge=eb;exports.removeNode=Ym;exports.reparentNode=wb;exports.resolveEdgeOwner=Cr;exports.resolveStateView=nb;exports.setCollapsed=vd;exports.setEdgeProp=ar;exports.setEdgeStyle=Xm;exports.setNodeProp=xt;exports.updateNode=_t;exports.useCustomColors=ot;exports.useEdgeProximity=mm;exports.useFlowData=hr;exports.useFlowDiagramContext=Ue;exports.useNodeViewActions=qn;exports.useStopPropagation=Yd;exports.useThemeContentColors=An;exports.validateGridAdjustment=$v;
|
|
284
284
|
//# sourceMappingURL=index.cjs.map
|