@squeed/flow-sdk 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -354,5 +354,5 @@ __p += '`),vr&&(Ie+=`' +
354
354
  function print() { __p += __j.call(arguments, '') }
355
355
  `:`;
356
356
  `)+Ie+`return __p
357
- }`;var sr=D1(function(){return mr(F,Ue+"return "+Ie).apply(t,H)});if(sr.source=Ie,Yf(sr))throw sr;return sr}function nL(f){return wr(f).toLowerCase()}function aL(f){return wr(f).toUpperCase()}function iL(f,v,m){if(f=wr(f),f&&(m||v===t))return z0(f);if(!f||!(v=Ut(v)))return f;var R=hn(f),B=hn(v),F=$0(R,B),H=V0(R,B)+1;return da(R,F,H).join("")}function oL(f,v,m){if(f=wr(f),f&&(m||v===t))return f.slice(0,W0(f)+1);if(!f||!(v=Ut(v)))return f;var R=hn(f),B=V0(R,hn(v))+1;return da(R,0,B).join("")}function sL(f,v,m){if(f=wr(f),f&&(m||v===t))return f.replace(Nr,"");if(!f||!(v=Ut(v)))return f;var R=hn(f),B=$0(R,hn(v));return da(R,B).join("")}function uL(f,v){var m=I,R=D;if(Fr(v)){var B="separator"in v?v.separator:B;m="length"in v?ir(v.length):m,R="omission"in v?Ut(v.omission):R}f=wr(f);var F=f.length;if(Ci(f)){var H=hn(f);F=H.length}if(m>=F)return f;var J=m-_i(R);if(J<1)return R;var ie=H?da(H,0,J).join(""):f.slice(0,J);if(B===t)return ie+R;if(H&&(J+=ie.length-J),Zf(B)){if(f.slice(J).search(B)){var Te,Re=ie;for(B.global||(B=df(B.source,wr(ft.exec(B))+"g")),B.lastIndex=0;Te=B.exec(Re);)var Ie=Te.index;ie=ie.slice(0,Ie===t?J:Ie)}}else if(f.indexOf(Ut(B),J)!=J){var Oe=ie.lastIndexOf(B);Oe>-1&&(ie=ie.slice(0,Oe))}return ie+R}function lL(f){return f=wr(f),f&&or.test(f)?f.replace(Fe,NI):f}var fL=Di(function(f,v,m){return f+(m?" ":"")+v.toUpperCase()}),Jf=Bb("toUpperCase");function I1(f,v,m){return f=wr(f),v=m?t:v,v===t?MI(f)?$I(f):_I(f):f.match(v)||[]}var D1=lr(function(f,v){try{return Gt(f,t,v)}catch(m){return Yf(m)?m:new rr(m)}}),cL=$n(function(f,v){return Qt(v,function(m){m=Tn(m),Fn(f,m,Kf(f[m],f))}),f});function dL(f){var v=f==null?0:f.length,m=Ze();return f=v?Or(f,function(R){if(typeof R[1]!="function")throw new Jt(o);return[m(R[0]),R[1]]}):[],lr(function(R){for(var B=-1;++B<v;){var F=f[B];if(Gt(F[0],this,R))return Gt(F[1],this,R)}})}function vL(f){return ND(rn(f,d))}function ec(f){return function(){return f}}function hL(f,v){return f==null||f!==f?v:f}var gL=kb(),pL=kb(!0);function qt(f){return f}function rc(f){return fb(typeof f=="function"?f:rn(f,d))}function yL(f){return db(rn(f,d))}function mL(f,v){return vb(f,rn(v,d))}var bL=lr(function(f,v){return function(m){return Co(m,f,v)}}),wL=lr(function(f,v){return function(m){return Co(f,m,v)}});function tc(f,v,m){var R=it(v),B=js(v,R);m==null&&!(Fr(v)&&(B.length||!R.length))&&(m=v,v=f,f=this,B=js(v,it(v)));var F=!(Fr(m)&&"chain"in m)||!!m.chain,H=Gn(f);return Qt(B,function(J){var ie=v[J];f[J]=ie,H&&(f.prototype[J]=function(){var Te=this.__chain__;if(F||Te){var Re=f(this.__wrapped__),Ie=Re.__actions__=kt(this.__actions__);return Ie.push({func:ie,args:arguments,thisArg:f}),Re.__chain__=Te,Re}return ie.apply(f,oa([this.value()],arguments))})}),f}function xL(){return ct._===this&&(ct._=KI),this}function nc(){}function EL(f){return f=ir(f),lr(function(v){return hb(v,f)})}var CL=kf(Or),_L=kf(O0),SL=kf(af);function B1(f){return $f(f)?of(Tn(f)):rB(f)}function TL(f){return function(v){return f==null?t:Ua(f,v)}}var RL=Lb(),AL=Lb(!0);function ac(){return[]}function ic(){return!1}function PL(){return{}}function IL(){return""}function DL(){return!0}function BL(f,v){if(f=ir(f),f<1||f>V)return[];var m=j,R=wt(f,j);v=Ze(v),f-=j;for(var B=lf(R,v);++m<f;)v(m);return B}function ML(f){return tr(f)?Or(f,Tn):Ht(f)?[f]:kt(Qb(wr(f)))}function kL(f){var v=++UI;return wr(f)+v}var OL=eu(function(f,v){return f+v},0),LL=Of("ceil"),qL=eu(function(f,v){return f/v},1),NL=Of("floor");function FL(f){return f&&f.length?Ks(f,qt,wf):t}function zL(f,v){return f&&f.length?Ks(f,Ze(v,2),wf):t}function $L(f){return N0(f,qt)}function VL(f,v){return N0(f,Ze(v,2))}function GL(f){return f&&f.length?Ks(f,qt,_f):t}function WL(f,v){return f&&f.length?Ks(f,Ze(v,2),_f):t}var UL=eu(function(f,v){return f*v},1),HL=Of("round"),KL=eu(function(f,v){return f-v},0);function jL(f){return f&&f.length?uf(f,qt):0}function YL(f,v){return f&&f.length?uf(f,Ze(v,2)):0}return L.after=yk,L.ary=l1,L.assign=aO,L.assignIn=C1,L.assignInWith=vu,L.assignWith=iO,L.at=oO,L.before=f1,L.bind=Kf,L.bindAll=cL,L.bindKey=c1,L.castArray=Pk,L.chain=o1,L.chunk=NB,L.compact=FB,L.concat=zB,L.cond=dL,L.conforms=vL,L.constant=ec,L.countBy=jM,L.create=sO,L.curry=d1,L.curryRight=v1,L.debounce=h1,L.defaults=uO,L.defaultsDeep=lO,L.defer=mk,L.delay=bk,L.difference=$B,L.differenceBy=VB,L.differenceWith=GB,L.drop=WB,L.dropRight=UB,L.dropRightWhile=HB,L.dropWhile=KB,L.fill=jB,L.filter=ZM,L.flatMap=JM,L.flatMapDeep=ek,L.flatMapDepth=rk,L.flatten=t1,L.flattenDeep=YB,L.flattenDepth=ZB,L.flip=wk,L.flow=gL,L.flowRight=pL,L.fromPairs=XB,L.functions=pO,L.functionsIn=yO,L.groupBy=tk,L.initial=JB,L.intersection=eM,L.intersectionBy=rM,L.intersectionWith=tM,L.invert=bO,L.invertBy=wO,L.invokeMap=ak,L.iteratee=rc,L.keyBy=ik,L.keys=it,L.keysIn=Lt,L.map=su,L.mapKeys=EO,L.mapValues=CO,L.matches=yL,L.matchesProperty=mL,L.memoize=lu,L.merge=_O,L.mergeWith=_1,L.method=bL,L.methodOf=wL,L.mixin=tc,L.negate=fu,L.nthArg=EL,L.omit=SO,L.omitBy=TO,L.once=xk,L.orderBy=ok,L.over=CL,L.overArgs=Ek,L.overEvery=_L,L.overSome=SL,L.partial=jf,L.partialRight=g1,L.partition=sk,L.pick=RO,L.pickBy=S1,L.property=B1,L.propertyOf=TL,L.pull=oM,L.pullAll=a1,L.pullAllBy=sM,L.pullAllWith=uM,L.pullAt=lM,L.range=RL,L.rangeRight=AL,L.rearg=Ck,L.reject=fk,L.remove=fM,L.rest=_k,L.reverse=Uf,L.sampleSize=dk,L.set=PO,L.setWith=IO,L.shuffle=vk,L.slice=cM,L.sortBy=pk,L.sortedUniq=mM,L.sortedUniqBy=bM,L.split=JO,L.spread=Sk,L.tail=wM,L.take=xM,L.takeRight=EM,L.takeRightWhile=CM,L.takeWhile=_M,L.tap=FM,L.throttle=Tk,L.thru=ou,L.toArray=w1,L.toPairs=T1,L.toPairsIn=R1,L.toPath=ML,L.toPlainObject=E1,L.transform=DO,L.unary=Rk,L.union=SM,L.unionBy=TM,L.unionWith=RM,L.uniq=AM,L.uniqBy=PM,L.uniqWith=IM,L.unset=BO,L.unzip=Hf,L.unzipWith=i1,L.update=MO,L.updateWith=kO,L.values=ki,L.valuesIn=OO,L.without=DM,L.words=I1,L.wrap=Ak,L.xor=BM,L.xorBy=MM,L.xorWith=kM,L.zip=OM,L.zipObject=LM,L.zipObjectDeep=qM,L.zipWith=NM,L.entries=T1,L.entriesIn=R1,L.extend=C1,L.extendWith=vu,tc(L,L),L.add=OL,L.attempt=D1,L.camelCase=FO,L.capitalize=A1,L.ceil=LL,L.clamp=LO,L.clone=Ik,L.cloneDeep=Bk,L.cloneDeepWith=Mk,L.cloneWith=Dk,L.conformsTo=kk,L.deburr=P1,L.defaultTo=hL,L.divide=qL,L.endsWith=zO,L.eq=pn,L.escape=$O,L.escapeRegExp=VO,L.every=YM,L.find=XM,L.findIndex=e1,L.findKey=fO,L.findLast=QM,L.findLastIndex=r1,L.findLastKey=cO,L.floor=NL,L.forEach=s1,L.forEachRight=u1,L.forIn=dO,L.forInRight=vO,L.forOwn=hO,L.forOwnRight=gO,L.get=Xf,L.gt=Ok,L.gte=Lk,L.has=mO,L.hasIn=Qf,L.head=n1,L.identity=qt,L.includes=nk,L.indexOf=QB,L.inRange=qO,L.invoke=xO,L.isArguments=ja,L.isArray=tr,L.isArrayBuffer=qk,L.isArrayLike=Ot,L.isArrayLikeObject=Ur,L.isBoolean=Nk,L.isBuffer=va,L.isDate=Fk,L.isElement=zk,L.isEmpty=$k,L.isEqual=Vk,L.isEqualWith=Gk,L.isError=Yf,L.isFinite=Wk,L.isFunction=Gn,L.isInteger=p1,L.isLength=cu,L.isMap=y1,L.isMatch=Uk,L.isMatchWith=Hk,L.isNaN=Kk,L.isNative=jk,L.isNil=Zk,L.isNull=Yk,L.isNumber=m1,L.isObject=Fr,L.isObjectLike=Vr,L.isPlainObject=Po,L.isRegExp=Zf,L.isSafeInteger=Xk,L.isSet=b1,L.isString=du,L.isSymbol=Ht,L.isTypedArray=Mi,L.isUndefined=Qk,L.isWeakMap=Jk,L.isWeakSet=eO,L.join=nM,L.kebabCase=GO,L.last=nn,L.lastIndexOf=aM,L.lowerCase=WO,L.lowerFirst=UO,L.lt=rO,L.lte=tO,L.max=FL,L.maxBy=zL,L.mean=$L,L.meanBy=VL,L.min=GL,L.minBy=WL,L.stubArray=ac,L.stubFalse=ic,L.stubObject=PL,L.stubString=IL,L.stubTrue=DL,L.multiply=UL,L.nth=iM,L.noConflict=xL,L.noop=nc,L.now=uu,L.pad=HO,L.padEnd=KO,L.padStart=jO,L.parseInt=YO,L.random=NO,L.reduce=uk,L.reduceRight=lk,L.repeat=ZO,L.replace=XO,L.result=AO,L.round=HL,L.runInContext=ne,L.sample=ck,L.size=hk,L.snakeCase=QO,L.some=gk,L.sortedIndex=dM,L.sortedIndexBy=vM,L.sortedIndexOf=hM,L.sortedLastIndex=gM,L.sortedLastIndexBy=pM,L.sortedLastIndexOf=yM,L.startCase=eL,L.startsWith=rL,L.subtract=KL,L.sum=jL,L.sumBy=YL,L.template=tL,L.times=BL,L.toFinite=Wn,L.toInteger=ir,L.toLength=x1,L.toLower=nL,L.toNumber=an,L.toSafeInteger=nO,L.toString=wr,L.toUpper=aL,L.trim=iL,L.trimEnd=oL,L.trimStart=sL,L.truncate=uL,L.unescape=lL,L.uniqueId=kL,L.upperCase=fL,L.upperFirst=Jf,L.each=s1,L.eachRight=u1,L.first=n1,tc(L,(function(){var f={};return _n(L,function(v,m){br.call(L.prototype,m)||(f[m]=v)}),f})(),{chain:!1}),L.VERSION=n,Qt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(f){L[f].placeholder=L}),Qt(["drop","take"],function(f,v){dr.prototype[f]=function(m){m=m===t?1:Jr(ir(m),0);var R=this.__filtered__&&!v?new dr(this):this.clone();return R.__filtered__?R.__takeCount__=wt(m,R.__takeCount__):R.__views__.push({size:wt(m,j),type:f+(R.__dir__<0?"Right":"")}),R},dr.prototype[f+"Right"]=function(m){return this.reverse()[f](m).reverse()}}),Qt(["filter","map","takeWhile"],function(f,v){var m=v+1,R=m==N||m==$;dr.prototype[f]=function(B){var F=this.clone();return F.__iteratees__.push({iteratee:Ze(B,3),type:m}),F.__filtered__=F.__filtered__||R,F}}),Qt(["head","last"],function(f,v){var m="take"+(v?"Right":"");dr.prototype[f]=function(){return this[m](1).value()[0]}}),Qt(["initial","tail"],function(f,v){var m="drop"+(v?"":"Right");dr.prototype[f]=function(){return this.__filtered__?new dr(this):this[m](1)}}),dr.prototype.compact=function(){return this.filter(qt)},dr.prototype.find=function(f){return this.filter(f).head()},dr.prototype.findLast=function(f){return this.reverse().find(f)},dr.prototype.invokeMap=lr(function(f,v){return typeof f=="function"?new dr(this):this.map(function(m){return Co(m,f,v)})}),dr.prototype.reject=function(f){return this.filter(fu(Ze(f)))},dr.prototype.slice=function(f,v){f=ir(f);var m=this;return m.__filtered__&&(f>0||v<0)?new dr(m):(f<0?m=m.takeRight(-f):f&&(m=m.drop(f)),v!==t&&(v=ir(v),m=v<0?m.dropRight(-v):m.take(v-f)),m)},dr.prototype.takeRightWhile=function(f){return this.reverse().takeWhile(f).reverse()},dr.prototype.toArray=function(){return this.take(j)},_n(dr.prototype,function(f,v){var m=/^(?:filter|find|map|reject)|While$/.test(v),R=/^(?:head|last)$/.test(v),B=L[R?"take"+(v=="last"?"Right":""):v],F=R||/^find/.test(v);B&&(L.prototype[v]=function(){var H=this.__wrapped__,J=R?[1]:arguments,ie=H instanceof dr,Te=J[0],Re=ie||tr(H),Ie=function(cr){var vr=B.apply(L,oa([cr],J));return R&&Oe?vr[0]:vr};Re&&m&&typeof Te=="function"&&Te.length!=1&&(ie=Re=!1);var Oe=this.__chain__,Ue=!!this.__actions__.length,Qe=F&&!Oe,sr=ie&&!Ue;if(!F&&Re){H=sr?H:new dr(this);var Je=f.apply(H,J);return Je.__actions__.push({func:ou,args:[Ie],thisArg:t}),new en(Je,Oe)}return Qe&&sr?f.apply(this,J):(Je=this.thru(Ie),Qe?R?Je.value()[0]:Je.value():Je)})}),Qt(["pop","push","shift","sort","splice","unshift"],function(f){var v=Bs[f],m=/^(?:push|sort|unshift)$/.test(f)?"tap":"thru",R=/^(?:pop|shift)$/.test(f);L.prototype[f]=function(){var B=arguments;if(R&&!this.__chain__){var F=this.value();return v.apply(tr(F)?F:[],B)}return this[m](function(H){return v.apply(tr(H)?H:[],B)})}}),_n(dr.prototype,function(f,v){var m=L[v];if(m){var R=m.name+"";br.call(Ai,R)||(Ai[R]=[]),Ai[R].push({name:v,func:m})}}),Ai[Js(t,b).name]=[{name:"wrapper",func:t}],dr.prototype.clone=lD,dr.prototype.reverse=fD,dr.prototype.value=cD,L.prototype.at=zM,L.prototype.chain=$M,L.prototype.commit=VM,L.prototype.next=GM,L.prototype.plant=UM,L.prototype.reverse=HM,L.prototype.toJSON=L.prototype.valueOf=L.prototype.value=KM,L.prototype.first=L.prototype.head,po&&(L.prototype[po]=WM),L}),Si=VI();za?((za.exports=Si)._=Si,ef._=Si):ct._=Si}).call(wW)})(Go,Go.exports)),Go.exports}var hr=xW();const N2=Cl(hr);function EW({cyParams:r,cyInst:e,layoutParams:t,layoutDebounce:n=50,children:a,init:i=()=>{},onCyInit:o}){const[s,l]=Se.useState(!1),u=Se.useRef(null),c=Se.useRef(null),d=Se.useRef(null),h=Se.useRef(!0),g=Se.useCallback(()=>{var y;d.current!==null&&d.current.stop(),c.current&&(d.current=c.current.layout(t),(y=d.current)==null||y.run())},[t]),p=N2.debounce(g,n);Se.useEffect(()=>{if(!u.current)return;const y=un({container:u.current,...r}),b=u.current.querySelector(".cytoscape-react-nodes-and-edges");if(b&&y.domNode({dom_container:b}),c.current=e||y,u.current&&(u.current.cy=c.current),o==null||o(c.current),i(y),u.current&&c.current){const x=u.current.parentElement;let C=0,T=0;x&&(C=x.clientHeight,T=x.clientWidth,C===0&&(C=window.innerHeight-x.getBoundingClientRect().top-100),T===0&&(T=window.innerWidth)),C>0&&T>0&&(u.current.style.width=`${T}px`,u.current.style.height=`${C}px`),c.current.resize(),r.zoom&&r.pan&&c.current.viewport({zoom:r.zoom,pan:r.pan})}l(!0);const w=new ResizeObserver(N2.debounce(()=>{if(u.current&&c.current){const x=u.current.parentElement;let C=0,T=0;x&&(C=x.clientHeight,T=x.clientWidth,C===0&&(C=window.innerHeight-x.getBoundingClientRect().top-100),T===0&&(T=window.innerWidth),C>0&&T>0&&(u.current.style.width=`${T}px`,u.current.style.height=`${C}px`));const S=c.current.zoom()!==void 0?{zoom:c.current.zoom(),pan:c.current.pan()}:null;c.current.resize(),S&&c.current.viewport(S)}},50));return u.current&&w.observe(u.current),()=>{w.disconnect();try{y.destroy()}catch{}c.current=null,l(!1)}},[]),Se.useEffect(()=>{h.current?(h.current=!1,g()):p()},[s,t,p,g]);const E=Se.useMemo(()=>{var y;return c.current!==null?((y=Se.Children.map(a,b=>{var w;return b?Se.cloneElement(b,{key:(w=b==null?void 0:b.props)==null?void 0:w.id,cytoInstance:c.current,layout:p}):null}))==null?void 0:y.filter(Boolean))||[]:[]},[a,s,p]);return ue.jsx("div",{ref:u,className:"cytoscape-react-cy-container",style:{width:"100%",height:"100%",position:"relative",background:"transparent"},children:ue.jsx("div",{className:"cytoscape-react-nodes-and-edges",style:{pointerEvents:"none",position:"absolute",top:0,left:0,transformOrigin:"0 0",zIndex:10},children:E})})}function CW({cytoInstance:r,id:e,parent:t,label:n,children:a,layout:i,classes:o,styleCallback:s}){const l=Se.useRef(null);function u(h){if(s){const g=s(h);h.isParent()&&(h.style("shape","roundrectangle"),h.style(g))}}Se.useEffect(()=>{try{if(l.current){const h={id:e,dom:l.current};t&&(h.parent=t),n&&(h.label=n);const g=r.add({data:h,classes:o});u(g)}}catch{}return()=>{r.getElementById(e).remove()}},[l,t,n]),Se.useEffect(()=>{i();const h=r.getElementById(e);h&&h.isParent()&&u(h)},[e,a]),Se.useEffect(()=>{if(!s)return;const h=r.getElementById(e);h&&h.isParent()&&u(h)},[s]);function c(h){return Se.cloneElement(h,{cytoInstance:r,layout:i})}const d=Se.Children.map(a,c);return ue.jsx("div",{ref:l,className:"cytoscape-react-node",children:d})}const _W={name:"dagre",rankDir:"LR",fit:!1,padding:20,spacingFactor:1.3,animate:!1,nodeDimensionsIncludeLabels:!0,ranker:"network-simplex",rankSep:10,nodeSep:5,edgeSep:10,avoidOverlap:!0,edgeWeight:function(r){return 1},minLen:function(r){return 1},useSimpleEdgeFunction:!0,edgeRouting:!0,controlPoints:!0},GP={padding:20,motionBlur:!1,compound:!0,pixelRatio:"auto",zoomingEnabled:!0,userZoomingEnabled:!0,dragpan:!0,avoidOverlap:!0,panningEnabled:!0,userPanningEnabled:!0,boxSelectionEnabled:!1,selectionType:"additive",minZoom:.01,maxZoom:1.5,autoungrabify:!0,styleEnabled:!0,hideEdgesOnViewport:!1,hideLabelsOnViewport:!0,headless:!1,touchTapThreshold:8,desktopTapThreshold:4,touchHoldDuration:500,desktopHoldDuration:1e3,autolock:!1,autounselectify:!1,wheelPanEnabled:!0,wheelPanThreshold:1,wheelPanDebounce:10,wheelAction:"pan"},WP={...GP,pixelRatio:1,motionBlur:!0,textureOnViewport:!0,wheelPanDebounce:20},SW={...WP,hideEdgesOnViewport:!0,hideLabelsOnViewport:!0},TW=({nodes:r,edges:e})=>{const{themeColor:t,edgeColor:n,direction:a,cyRef:i,callbacks:o,config:s,selectedNodeIds:l,setSelectedNodeIds:u,setSelectedEdgeId:c,setIsPerformanceMode:d,isZoomMode:h,setIsZoomMode:g,isMultiSelectMode:p,setIsMultiSelectMode:E,isDragMode:y,setIsDragMode:b,isEdgeHandlesEnabled:w,isArrayNodeMode:x}=Da(),C=Se.useRef(null),T=Se.useRef(null),S=Se.useRef(x),_=r.length>200;Se.useEffect(()=>{d(_)},[_,d]);const{edgeSep:A,rankSep:P}=Se.useMemo(()=>hq(r.length),[r.length]),{bgColor:I}=ss(t),{background:D,borderSecondary:k}=us(),M=s.backgroundColor||D,N=Se.useCallback(U=>{if(U!=null&&U.includes("gray"))return"whitesmoke";if(!U)return ht(t);switch(U){case"dark":return ht(M);case"light":return ht(k);default:return ht(U)}},[t,M,k]),z=s.colorMode==="dark",$=Se.useMemo(()=>z?N(I):"dark",[z,I,N]),q=n?N(n):$,V=Se.useMemo(()=>vq(N),[N]),Z=s.initialViewport||{pan:{x:0,y:0},zoom:.01},K=Se.useMemo(()=>({..._?SW:r.length>100?WP:GP,style:V,zoom:Z.zoom,pan:Z.pan,minZoom:s.minZoom??.01,maxZoom:s.maxZoom??1.5}),[V,Z,r.length,s.minZoom,s.maxZoom]),j=Se.useRef(!1),ee=Se.useRef();Se.useEffect(()=>()=>{clearTimeout(ee.current)},[]);const le=Se.useMemo(()=>({..._W,...a&&{rankDir:a},edgeSep:A,rankSep:P,get animate(){return j.current&&!_},animationDuration:300,animationEasing:"ease-in-out-cubic",stop:()=>{i.current&&(j.current||setTimeout(()=>{var U;(U=i.current)==null||U.fit(void 0,50)},100),clearTimeout(ee.current),ee.current=setTimeout(()=>{j.current=!0},500))}}),[a,A,P,i,_]),W=Se.useCallback(U=>{const fe=N(U||t);return{"corner-radius":50,"background-color":fe,color:fe,"border-color":fe}},[t,N]),G=Se.useCallback((U,fe,xe,ge)=>{let be={};return ge!=null&&ge.isInverted&&(ge==null?void 0:ge.source)===fe&&(be["target-arrow-shape"]="none",be["source-arrow-shape"]="triangle"),ge!=null&&ge.isEdgeAnimated?(be["line-style"]="dashed",be["line-dash-pattern"]=[32,18],be["line-dash-offset"]=0):ge!=null&&ge.isEdgeDashed?(be["line-style"]="dashed",be["line-dash-pattern"]=[],be["line-dash-offset"]=0):(be["line-style"]="solid",be["line-dash-pattern"]=[],be["line-dash-offset"]=0),a==="TB"&&(be["taxi-direction"]="downward"),a==="BT"&&(be["taxi-direction"]="upward"),a==="LR"&&(be["taxi-direction"]="rightward"),a==="RL"&&(be["taxi-direction"]="leftward"),be["line-color"]=q,be.color=q,be["target-arrow-color"]=q,be["source-arrow-color"]=q,be},[q,a]),Y=Se.useRef(r);Y.current=r;const re=Se.useRef(W);re.current=W;const de=Se.useRef(G);de.current=G,Se.useEffect(()=>{if(!i.current)return;const U=i.current,fe=()=>{U.nodes().forEach(xe=>{var ge,be;if(xe.isParent()){const Ae=Y.current.find(De=>{var Be;return((Be=De.data)==null?void 0:Be.id)===xe.id()});xe.style(re.current((be=(ge=Ae==null?void 0:Ae.data)==null?void 0:ge.viewProps)==null?void 0:be.bgColor))}})};return U.on("add",fe),()=>{U.off("add",fe)}},[]),Se.useEffect(()=>{if(!i.current)return;const U=i.current;U.nodes().forEach(fe=>{var xe,ge;if(fe.isParent()){const be=r.find(Ae=>{var De;return((De=Ae.data)==null?void 0:De.id)===fe.id()});fe.style(W((ge=(xe=be==null?void 0:be.data)==null?void 0:xe.viewProps)==null?void 0:ge.bgColor))}}),e.forEach(({data:fe})=>{const xe=U.getElementById(fe.id);xe!=null&&xe.length&&(xe.data({isEdgeAnimated:fe.isEdgeAnimated,isEdgeDashed:fe.isEdgeDashed}),xe.style(G(xe,fe.source,fe.target,fe)))})},[r,e,q,W,G]);const se=Se.useRef(s);se.current=s;const X=Se.useRef(h);X.current=h;const Q=Se.useRef(w);Q.current=w,S.current=x,Se.useEffect(()=>{if(!i.current||!i.current.container)return;const U=i.current,fe=C.current;if(!fe)return;let xe=null,ge=null,be=0,Ae=0,De=0,Be=0,Le=0;const He=Ve=>{Ve.preventDefault(),Ve.stopPropagation(),X.current||Ve.metaKey||Ve.ctrlKey?(De+=Ve.deltaY,Be=Ve.clientX,Le=Ve.clientY,ge===null&&(ge=requestAnimationFrame(()=>{ge=null;const er=se.current,$e=U.zoom(),ke=De;De=0;let ye=$e-ke*.05/100;ye=Math.max(er.minZoom??.01,Math.min(er.maxZoom??1.5,ye));const O=fe.getBoundingClientRect();U.zoom({level:ye,renderedPosition:{x:Be-O.left,y:Le-O.top}})}))):(be+=Ve.deltaX,Ae+=Ve.deltaY,xe===null&&(xe=requestAnimationFrame(()=>{xe=null;const er=U.pan(),$e=U.zoom(),ke=.35,ye=be,O=Ae;be=0,Ae=0,U.pan({x:er.x+-ye*ke/$e,y:er.y+-O*ke/$e})})))};return fe.addEventListener("wheel",He,{passive:!1}),()=>{fe.removeEventListener("wheel",He),xe!==null&&cancelAnimationFrame(xe),ge!==null&&cancelAnimationFrame(ge)}},[i.current]),Se.useEffect(()=>{i.current&&i.current.userPanningEnabled(y)},[y]),Se.useEffect(()=>{if(!i.current)return;const U=i.current;U.boxSelectionEnabled(!!p),U.selectionType(p?"additive":"single"),U.userPanningEnabled(!p&&y)},[p,y]),Se.useEffect(()=>{T.current&&(w?T.current.enableDrawMode():T.current.disableDrawMode())},[w]);const ae=Se.useRef(l);ae.current=l,Se.useEffect(()=>{if(s.disableKeyboardShortcuts)return;const U=fe=>{var ge,be;const xe=fe.target;if(!(xe.tagName==="INPUT"||xe.tagName==="TEXTAREA"||xe.isContentEditable)&&((fe.key==="z"||fe.key==="Z")&&g(!X.current),(fe.key==="m"||fe.key==="M")&&E(!p),(fe.key==="d"||fe.key==="D")&&b(!y),(fe.key==="Delete"||fe.key==="Backspace")&&ae.current.length>0)){fe.preventDefault();const Ae=ae.current.filter(Be=>Be!=="root");if(Ae.length===0)return;const De=i.current;for(const Be of Ae){const Le=(ge=De==null?void 0:De.getElementById(Be))==null?void 0:ge.data();(be=o.onNodeDelete)==null||be.call(o,Be,Le||{})}u([])}};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[p,y,g,E,b,s.disableKeyboardShortcuts,o,u,i]),Se.useEffect(()=>()=>{if(i.current)try{i.current.removeAllListeners()}catch{}},[]);const te=Se.useMemo(()=>_?300:r.length>50?150:r.length>20?100:50,[r.length,_]),ce=Se.useMemo(()=>{var fe;const U=new Set;for(const xe of r)(fe=xe.data)!=null&&fe.parent&&U.add(xe.data.parent);return U},[r]),_e=Se.useMemo(()=>{var fe;const U=new Map;for(const xe of e)(fe=xe.data)!=null&&fe.source&&!U.has(xe.data.source)&&U.set(xe.data.source,xe.data);return U},[e]),ve=s.backgroundPattern||"dot";return ue.jsx(oq,{pattern:ve,backgroundColor:s.backgroundColor,children:ue.jsx(pe.Box,{ref:C,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:ue.jsxs(EW,{cyParams:K,layoutParams:le,layoutDebounce:te,onCyInit:U=>{var xe;i.current=U,(xe=o.onCyInit)==null||xe.call(o,U);let fe=null;if(U.on("zoom pan",()=>{fe===null&&(fe=requestAnimationFrame(()=>{var ge;fe=null,(ge=o.onViewportChange)==null||ge.call(o,{zoom:U.zoom(),pan:U.pan()})}))}),U.on("select","edge",ge=>{var Ae;const be=ge.target;c(be.id()),(Ae=o.onEdgeSelect)==null||Ae.call(o,be.id(),be.data())}),U.on("unselect","edge",()=>{var ge;c(null),(ge=o.onEdgeDeselect)==null||ge.call(o)}),U.on("remove","edge",ge=>{var Ae;const be=ge.target;(Ae=o.onEdgeRemove)==null||Ae.call(o,be.id(),be.data())}),U.on("tap",":parent",ge=>{var Ae;const be=ge.target;u([be.id()]),(Ae=o.onNodeSelect)==null||Ae.call(o,be.id(),be.data())}),s.edgeHandles!==!1){const ge={canConnect:(Be,Le)=>!Be.same(Le),edgeParams:(Be,Le)=>({data:{source:Be.id(),target:Le.id(),label:""}}),loopAllowed:()=>!1,hoverDelay:500,snap:!1,snapThreshold:10,snapFrequency:5,noEdgeEventsInDraw:!0,disableBrowserGestures:!0,handlePosition:"left",handleNodes:"node",handleSize:20,handleColor:t||"#0ea5e9",handleOutlineColor:"#B92020FF",handleOutlineWidth:2,handleLineType:"ghost",handleLineWidth:2,preview:!0,ghostEdgeParams:()=>({}),edgeType:()=>"flat",nodeParams:()=>({})},be=U.edgehandles(ge);T.current=be,Q.current&&be.enableDrawMode();let Ae=null,De=null;U.on("ehstart",(Be,Le)=>{De=Le;const He=Be.originalEvent||window.event;if(He!=null&&He.clientX&&(He!=null&&He.clientY))Ae={x:He.clientX,y:He.clientY};else{const Ve=Le.renderedPosition();Ae={x:Ve.x,y:Ve.y}}}),U.on("ehcancel",Be=>{if(!Ae||!De)return;const Le=Be.originalEvent||window.event,He=Le==null?void 0:Le.clientX,Ve=Le==null?void 0:Le.clientY;if(He&&Ve&&o.onNodeCreate){const Xe=Math.abs(He-Ae.x),er=Math.abs(Ve-Ae.y);if(Math.max(Xe,er)>30){const $e=U.renderer().projectIntoViewport(He,Ve);o.onNodeCreate({type:"text",sourceNodeId:De.id(),position:{x:$e[0],y:$e[1]},isArrayMode:S.current})}}Ae=null,De=null}),U.on("ehcomplete",(Be,Le,He)=>{var Ve;(Ve=o.onEdgeCreate)==null||Ve.call(o,Le.id(),He.id())}),U.on("ehstop",()=>{Ae=null,De=null})}},children:[(r||[]).map(U=>{var De,Be,Le,He,Ve,Xe,er,$e,ke;const fe=s.customViews||dq,xe=ce.has((De=U.data)==null?void 0:De.id)&&!((Be=U.data)!=null&&Be.parent),ge=xe?((Le=U.data)==null?void 0:Le.label)||((He=U.data)==null?void 0:He.headerTitle)||"Container":void 0,be=xe?fe.parentContainer:fe[U==null?void 0:U.data.type]||fe.text,Ae=_e.get((Ve=U.data)==null?void 0:Ve.id);return ue.jsx(CW,{id:(Xe=U.data)==null?void 0:Xe.id,parent:(er=U.data)==null?void 0:er.parent,label:ge,styleCallback:()=>{var ye,O;return W((O=(ye=U.data)==null?void 0:ye.viewProps)==null?void 0:O.bgColor)},children:Se.createElement(be,{...U,isInverted:Ae==null?void 0:Ae.isInverted,isParent:xe,key:`${($e=U.data)==null?void 0:$e.id}-${t}`})},(ke=U.data)==null?void 0:ke.id)}),(e||[]).map(({data:U})=>ue.jsx(gq,{id:U==null?void 0:U.id,source:U==null?void 0:U.source,target:U==null?void 0:U.target,label:U==null?void 0:U.label,isPerformanceMode:_,styleCallback:(fe,xe,ge)=>G(fe,xe,ge,U)},U==null?void 0:U.id))]})})})},RW=Se.memo(TW);var Wo=(r=>(r.TOP_DOWN="TB",r.BOTTOM_UP="BT",r.LEFT_RIGHT="LR",r.RIGHT_LEFT="RL",r.CENTER="C",r))(Wo||{});const AW=[{value:"BT",label:"Bottom to Up",icon:Dr.PiArrowUpLight,flowType:Wo.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:Dr.PiArrowDownLight,flowType:Wo.TOP_DOWN},{value:"LR",label:"Left to Right",icon:Dr.PiArrowArcRightLight,flowType:Wo.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:Dr.PiArrowArcLeftLight,flowType:Wo.RIGHT_LEFT}],UP=()=>{const{cyRef:r,themeColor:e,direction:t,selectedNodeIds:n,setSelectedNodeIds:a,selectedEdgeId:i,setSelectedEdgeId:o,isZoomMode:s,setIsZoomMode:l,isMultiSelectMode:u,setIsMultiSelectMode:c,isDragMode:d,setIsDragMode:h,isEdgeHandlesEnabled:g,setIsEdgeHandlesEnabled:p,isArrayNodeMode:E,setIsArrayNodeMode:y,isPinned:b,setIsPinned:w,callbacks:x,config:C}=Da(),T=C.colorMode==="dark",{background:S,border:_,colorInactive:A,colorText:P,colorActive:I,darkBackgroundSecondary:D}=us(),[k,M]=Se.useState(!0),[N,z]=Se.useState(!1),[$,q]=Se.useState(!0),[V,Z]=Se.useState(!1),[K,j]=Se.useState(!1);Se.useEffect(()=>{const te=()=>q(window.innerWidth>=768);return te(),window.addEventListener("resize",te),()=>window.removeEventListener("resize",te)},[]),Se.useEffect(()=>{if(!$){M(!0);return}if(!b){M(!1);return}const te=_e=>{M(window.innerHeight-_e.clientY<=250)},ce=()=>M(!1);return window.addEventListener("mousemove",te),window.addEventListener("mouseleave",ce),()=>{window.removeEventListener("mousemove",te),window.removeEventListener("mouseleave",ce)}},[$,b]);const ee=Se.useCallback(te=>{const ce=r.current;if(!ce)return;const _e=C.minZoom??.01,ve=C.maxZoom??1.5,U=.02,fe=ce.zoomingEnabled(),xe=ce.userZoomingEnabled();ce.zoomingEnabled(!0),ce.userZoomingEnabled(!0);let ge=ce.zoom();switch(te){case"increase":ge=Math.min(ve,ge+U),ce.zoom(ge),ce.center();break;case"decrease":ge=Math.max(_e,ge-U),ce.zoom(ge),ce.center();break;case"reset":ce.fit(void 0,50);break}ce.zoomingEnabled(fe),ce.userZoomingEnabled(xe)},[r,C.minZoom,C.maxZoom]),le=k||N,W=C.renderSelectedNodeToolbar,G=n.length>0&&!!W,Y=Se.useMemo(()=>{if(!G)return[];const te=r.current;return te?n.map(ce=>{const _e=te.getElementById(ce);return _e!=null&&_e.length?{..._e.data(),isParent:_e.isParent()}:{id:ce}}):[]},[G,n,r]),re=Se.useCallback(()=>{var te;a([]),(te=x.onNodeDeselect)==null||te.call(x)},[a,x]),de=C.renderSelectedEdgeToolbar,se=!!i&&!!de,X=Se.useMemo(()=>{if(!se||!i)return null;const te=r.current;if(!te)return{id:i};const ce=te.getElementById(i);return ce!=null&&ce.length?ce.data():{id:i}},[se,i,r]),Q=Se.useCallback(()=>{var ce;o(null);const te=r.current;te&&te.edges().unselect(),(ce=x.onEdgeDeselect)==null||ce.call(x)},[o,r,x]),ae=C.renderBottomBar;return ae?ue.jsxs(ue.Fragment,{children:[G&&ue.jsx(pe.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:W({selectedNodeIds:n,selectedNodeData:Y,onDeselect:re})}),se&&X&&ue.jsx(pe.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:de({edgeId:i,edgeData:X,onDeselect:Q})}),ue.jsx(pe.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:ae({zoomIn:()=>ee("increase"),zoomOut:()=>ee("decrease"),resetZoom:()=>ee("reset"),direction:t,isZoomMode:s,setIsZoomMode:l,isMultiSelectMode:u,setIsMultiSelectMode:c,isDragMode:d,setIsDragMode:h,isEdgeHandlesEnabled:g,setIsEdgeHandlesEnabled:p,isArrayNodeMode:E,setIsArrayNodeMode:y,selectedNodeIds:n,selectedNodeData:Y,selectedEdgeId:i,selectedEdgeData:X,onNodeDeselect:re,onEdgeDeselect:Q,callbacks:x})})]}):ue.jsxs(ue.Fragment,{children:[G&&ue.jsx(pe.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:W({selectedNodeIds:n,selectedNodeData:Y,onDeselect:re})}),se&&X&&ue.jsx(pe.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:de({edgeId:i,edgeData:X,onDeselect:Q})}),!b&&ue.jsx(pe.Box,{position:"absolute",bottom:5,left:0,zIndex:101,w:3,children:ue.jsx(pe.Tooltip,{label:"Show Bottom Bar",placement:"top",fontSize:"xs",children:ue.jsx(pe.Flex,{align:"center",bg:S,borderColor:_,borderWidth:1,py:6,px:0,w:4,h:50,borderRadius:"15px",borderLeftRadius:0,onMouseEnter:()=>{z(!0),M(!0)},onMouseLeave:()=>z(!1),_hover:{bg:D},children:ue.jsx(pe.Icon,{ml:-1,as:Dr.PiLineVerticalBold,boxSize:5,color:_})})})}),ue.jsx(pe.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",transition:"opacity 0.3s ease-in, transform 0.3s ease",transform:le?"translateY(0)":"translateY(100%)",pointerEvents:le?"auto":"none",opacity:le?1:0,onMouseEnter:()=>{b||M(!0)},onMouseLeave:()=>{b||(M(!1),z(!1))},children:ue.jsxs(pe.Flex,{w:"100%",px:5,position:"absolute",bottom:5,flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[ue.jsx(pe.Box,{bg:S,alignContent:"center",h:50,borderColor:_,borderWidth:1,borderRadius:"15px",children:ue.jsxs(pe.HStack,{px:2,spacing:1,children:[ue.jsx(pe.Tooltip,{label:b?"Unpin":"Pin",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Pin",icon:ue.jsx(pe.Icon,{as:b?Dr.PiPushPinFill:Dr.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:b?e:A,onClick:()=>{const te=!b;w(te),M(te)}})}),ue.jsx(pe.Icon,{mx:-1,as:Dr.PiLineVerticalThin,boxSize:5,color:_}),ue.jsx(pe.Tooltip,{label:"Zoom Out",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Zoom out",icon:ue.jsx(pe.Icon,{as:tq.HiMinus,boxSize:5}),size:"sm",variant:"ghost",color:P,onClick:()=>ee("decrease")})}),ue.jsx(pe.Tooltip,{label:"Zoom In",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Zoom in",icon:ue.jsx(pe.Icon,{as:hu.VscAdd,boxSize:5}),size:"sm",variant:"ghost",color:P,onClick:()=>ee("increase")})}),ue.jsx(pe.Tooltip,{label:"Reset Zoom",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Reset zoom",icon:ue.jsx(pe.Icon,{as:nq.GrPowerReset,boxSize:5}),size:"sm",variant:"ghost",color:P,onClick:()=>ee("reset")})}),!K&&ue.jsxs(ue.Fragment,{children:[ue.jsx(pe.Icon,{mx:-1,as:Dr.PiLineVerticalThin,boxSize:5,color:_}),ue.jsx(pe.Tooltip,{label:s?"Zoom Mode (z)":"Pan Mode (z)",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Toggle zoom mode",icon:ue.jsx(pe.Icon,{as:s?hu.VscZoomIn:hu.VscMove,boxSize:5}),size:"sm",variant:"ghost",color:s?e:A,onClick:()=>l(!s)})}),ue.jsx(pe.Icon,{mx:-1,as:Dr.PiLineVerticalThin,boxSize:5,color:_}),ue.jsx(pe.Tooltip,{label:u?"Multi-Select On (m)":"Multi-Select Off (m)",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Toggle multi-select",icon:ue.jsx(pe.Icon,{as:hu.VscGroupByRefType,boxSize:5}),size:"sm",variant:"ghost",color:u?e:A,onClick:()=>c(!u)})}),ue.jsx(pe.Icon,{mx:-1,as:Dr.PiLineVerticalThin,boxSize:5,color:_}),ue.jsx(pe.Tooltip,{label:d?"Drag Mode On (d)":"Drag Mode Off (d)",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Toggle drag mode",icon:ue.jsx(pe.Icon,{as:Dr.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:d?e:A,onClick:()=>h(!d)})}),C.edgeHandles!==!1&&ue.jsxs(ue.Fragment,{children:[ue.jsx(pe.Icon,{mx:-1,as:Dr.PiLineVerticalThin,boxSize:5,color:_}),ue.jsx(pe.Tooltip,{label:g?"Draw Mode On":"Draw Mode Off",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Toggle draw mode",icon:ue.jsx(pe.Icon,{as:Dr.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:g?e:A,onClick:()=>p(!g)})})]}),ue.jsx(pe.Icon,{mx:-1,as:Dr.PiLineVerticalThin,boxSize:5,color:_}),ue.jsx(pe.Tooltip,{label:E?"List mode":"Set mode",placement:"top",fontSize:"xs",children:ue.jsx(pe.Flex,{cursor:"pointer",align:"center",onClick:()=>{var ce;const te=!E;y(te),(ce=x.onArrayModeChange)==null||ce.call(x,te)},_hover:{color:e},children:ue.jsx(pe.Text,{fontSize:"23px",color:E?e:A,children:E?"[]":"{}"})})})]}),ue.jsx(pe.Icon,{mx:-1,as:Dr.PiLineVerticalThin,boxSize:5,color:_}),ue.jsx(pe.Tooltip,{label:K?"Expand toolbar":"Collapse toolbar",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Toggle toolbar collapse",icon:ue.jsx(pe.Icon,{as:K?Dr.PiCaretRight:Dr.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:A,onClick:()=>j(!K)})})]})}),ue.jsxs(pe.Box,{position:"relative",ml:"auto",children:[ue.jsx(pe.Box,{bg:S,borderWidth:1,borderColor:_,borderRadius:"15px",h:50,px:3,cursor:"pointer",onClick:()=>Z(!V),children:ue.jsxs(pe.Flex,{align:"center",h:"100%",children:[ue.jsx(pe.Tooltip,{label:"Flow Direction",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Direction",icon:ue.jsx(pe.Icon,{as:Dr.PiCaretUp,boxSize:4}),size:"sm",variant:"ghost",color:A})}),ue.jsx(pe.Text,{fontSize:"xs",color:T?"whiteAlpha.600":"blackAlpha.500",ml:1,children:t})]})}),V&&ue.jsxs(pe.Box,{position:"absolute",bottom:"60px",right:0,bg:S,borderWidth:1,borderColor:_,borderRadius:"15px",p:2,zIndex:200,minW:"180px",shadow:"lg",onMouseLeave:()=>Z(!1),children:[AW.map(te=>ue.jsxs(pe.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"10px",cursor:"pointer",_hover:{bg:T?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var ce;(ce=x.onDirectionChange)==null||ce.call(x,te.value),Z(!1)},children:[ue.jsx(pe.Icon,{as:te.icon,boxSize:5,color:P}),ue.jsx(pe.Text,{fontSize:"sm",color:P,flex:1,whiteSpace:"nowrap",children:te.label}),t===te.value&&ue.jsx(pe.Icon,{as:O1.IoCheckmark,boxSize:4,color:I})]},te.value)),ue.jsxs(pe.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"10px",cursor:"pointer",_hover:{bg:T?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var te;(te=x.onDirectionChange)==null||te.call(x,"LR"),Z(!1)},children:[ue.jsx(pe.Icon,{as:aq.TbAlignCenter,boxSize:5,color:P}),ue.jsx(pe.Text,{fontSize:"sm",color:P,flex:1,whiteSpace:"nowrap",children:"Center"}),t==="C"&&ue.jsx(pe.Icon,{as:O1.IoCheckmark,boxSize:4,color:I})]})]})]})]})})]})};UP.displayName="BottomBar";const PW=Se.memo(UP),$l={label:"Untitled",description:"",isTask:!1,isLocked:!1},h0={id:null,type:"text",data:{...$l,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"}}},F2={id:null,type:"objectView",data:{...$l,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:25,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},IW={id:null,type:"arrayView",data:{...$l,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"}}},z2={id:null,type:"workflowStep",data:{...$l,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}};let Au;const DW=new Uint8Array(16);function BW(){if(!Au&&(Au=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Au))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Au(DW)}const vt=[];for(let r=0;r<256;++r)vt.push((r+256).toString(16).slice(1));function MW(r,e=0){return vt[r[e+0]]+vt[r[e+1]]+vt[r[e+2]]+vt[r[e+3]]+"-"+vt[r[e+4]]+vt[r[e+5]]+"-"+vt[r[e+6]]+vt[r[e+7]]+"-"+vt[r[e+8]]+vt[r[e+9]]+"-"+vt[r[e+10]]+vt[r[e+11]]+vt[r[e+12]]+vt[r[e+13]]+vt[r[e+14]]+vt[r[e+15]]}const kW=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),$2={randomUUID:kW};function OW(r,e,t){if($2.randomUUID&&!r)return $2.randomUUID();r=r||{};const n=r.random||(r.rng||BW)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,MW(n)}const Zt=r=>typeof r=="object",HP=r=>Array.isArray(r),LW=["order","position","selected","locked","grabbed","grabbable","scratch"],Pa=r=>Object.entries(r).reduce((e,[t,n])=>(!Zt(n)&&!t.startsWith("$")&&(e[t]=n),e),{}),g0=(r,e)=>typeof r=="string"&&r.startsWith("$")?nm(r,e):Zt(r)&&!HP(r)?Object.entries(r).reduce((t,[n,a])=>(typeof a=="string"&&a.startsWith("$")&&n==="..."?(delete t["..."],t[n]={...nm(a,e),...r}):typeof a=="string"&&a.startsWith("$")?t[n]=nm(a,e):t[n]=a,t),{}):r,Xn=r=>Object.entries(r).reduce((e,[t,n])=>(Zt(n)&&t&&n&&!t.startsWith("$")&&(LW.includes(t)&&(t=t+"#"),e[t]=n),e),{}),ri=(r,e,{label:t,parent:n=void 0},a,i=null)=>(i!==null&&(Zt(i)||HP(i))&&(i=JSON.stringify(i,null,2)),{data:{parent:n,...r.data,id:e,text:t||"",label:t,code:i||null,type:r.type,description:a}}),wa=(r,e,t=null,n=null,a=null,i=!1,o=null)=>({data:{id:OW(),source:a?e:r,target:a?r:e,label:n||"",isInverted:a,isEdgeAnimated:i,parent:o}}),Ia=(r,e=[])=>{const t={},n={};let a=[];if(r)for(const[i,o]of Object.entries(r))i.startsWith("$")&&i!=="$"?t[i.slice(1)]=o:i!=="$"?n[i]=o:i==="$"&&(a=o);return{newConfig:t,updatedObject:n,arrayObject:a}},Ki=(r,e)=>{let t=F2;const{view:n,borderColor:a,borderRadius:i,bgColor:o,textColor:s,fontSize:l,stepType:u}=e;r=n||r,u?t={...z2}:r==="object"?t=F2:r==="text"?t=h0:r==="array"?t=IW:r==="workflowStep"&&(t={...z2});const c=t.data.viewProps;return t.data.viewProps={...c,borderRadius:i||(u?15:50),bgColor:o,borderColor:a,textColor:s,fontSize:l},t.data.config=e,{config:t}},os=(r,e)=>(r=e.find(n=>{var a;return((a=n.data)==null?void 0:a.id)===r||n===r})?`${r}.#`:r,r),nm=(r,{ids:e,jsnObjct:t})=>{if(typeof r=="string"&&(r!=null&&r.startsWith("$"))){const n=r.replace("$","").replace("*","");r==null||r.endsWith("*");const a=e.find(s=>s.split(".").slice(-1)[0]===n||n===s);if(!a)return r;const i=qW(a,t);return JSON.stringify(i).includes(r)?r:i||r}return r},qW=(r,e)=>{let t=r.split(".").splice(1);return t=t[t.length-1]==="#"||t[t.length-1].includes("{")?t.slice(0,-2):t,(i=>t.reduce((o,s)=>{s=s.replace("[","").replace("]","");const{arrayObject:l}=Ia(o);return o=l.length?l:o,o[s]},i))(e)};function Qi(r,e="root",t=[]){try{const{arrayObject:n}=Ia(r);n.length&&(r=n);const a=Pa(r),i=Xn(r);return Zt(r)?(hr.isArray(r)||hr.isArray(r)&&e==="root"||!hr.isArray(r)&&Object.keys(a).length||e==="root")&&t.push(e):t.push(e),Object.keys(i).length&&!hr.isArray(r)?jo({chldPth:null,itrblObjct:i,nodes:t,path:e}):hr.isArray(r)&&r.forEach((o,s)=>{const l=Pa(o),u=Xn(o),{newConfig:c,arrayObject:d}=Ia(o);let h=`${e}.${s}`;Zt(o)?Object.keys(l).length?(Qi(l,h,t),Object.keys(u).length&&!hr.isArray(o)&&jo({chldPth:h,itrblObjct:u,nodes:t,path:e})):Object.keys(u).length&&!hr.isArray(o)?jo({chldPth:h,itrblObjct:u,nodes:t,path:e}):hr.isArray(o)&&KP({chldPth:h,item:o,nodes:t,path:e}):t.push(h)}),{nodes:t}}catch{return{nodes:t}}}const jo=({chldPth:r,itrblObjct:e,nodes:t,path:n})=>Object.entries(e).forEach(([a,i],o)=>{const s=Pa(i),l=Xn(i),{newConfig:u,arrayObject:c}=Ia(i);c.length&&(i=c);let d=r?`${r}.${a}`:`${n}.${a}`;if(Zt(i)&&!hr.isArray(i)){const h=Object.keys(s).length===0;if(h&&(Ki("array",u),t.push(d)),Object.keys(s).length){const g=hr.isArray(i)?`${i.length||""}`:`{${Object.keys(i).length||""}}`;let p=d;h&&(p=`${d}.${g}`),Qi(i,p,t)}else Object.keys(l).length&&!hr.isArray(i)?jo({chldPth:d,itrblObjct:l,path:d,nodes:t}):Qi(i,d,t)}else hr.isArray(i)&&Qi(i,d,t)}),KP=({chldPth:r,item:e,nodes:t,path:n})=>e.forEach((a,i)=>{let o=`${r}.${i}`;const s=Xn(a),l=Pa(a);Zt(a)?!hr.isArray(a)&&Object.keys(l).length?Qi(a,o,t):Object.keys(s).length&&!hr.isArray(a)?jo({chldPth:o,itrblObjct:s,path:n,nodes:t}):hr.isArray(a)&&KP({chldPth:o,item:a,nodes:t,path:n}):t.push(o)});function ni(r,e="root",t=[],n=[],a="untitled",i={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},o={},s){if(s||(s={invrtdRtPths:[],initalObjIds:null}),!r||typeof r!="object")return{nodes:t,edges:n};const l=r;if(!s.initalObjIds){const{nodes:d}=Qi(r);s.initalObjIds={ids:d,jsnObjct:r}}let{hideDefaultObject:u,sprtObjctKy:c}=i;try{e=os(e,t);const{newConfig:d,arrayObject:h}=Ia(r),g=Object.keys(o).length>0?o:d;h.length&&(r=h);const p=Pa(r),E=Xn(r);g.collapsed===void 0&&(Object.keys(E).length>0||hr.isArray(r))&&(g.collapsed=!1);const{label:y,collapsed:b,parent:w}=g;if(!Zt(r))t.push(ri(h0,e,{label:y||e,parent:w},r,l));else if(hr.isArray(r)||hr.isArray(r)&&e==="root"){const{config:x}=Ki("array",g),C=hr.isArray(r)?`${r.length||""}`:`{${Object.keys(r).length||""}}`,T=e==="root"?a:`${a} ${C}`;t.push(ri(x,e,{label:y||T,parent:w},r,hr.isArray(l)?{[a]:l}:l))}else if(!hr.isArray(r)&&Object.keys(p).length||e==="root"){const{config:x}=Ki(null,g),C=e.split("."),T=C[C.length-1];let S=isNaN(Number(T))?null:Number(T)+1;const _=isNaN(Number(T))?T:C[C.length-2]+" "+S,A=e==="root"?a:_,P=r;if(y){const{config:I}=Ki("object",g);I.data.headerTitle=y,t.push(ri(I,e,{label:y||`${y} ${Object.keys(r).length}`,parent:w},p,P))}else x.data.headerTitle=A,t.push(ri(x,e,{label:y,parent:w},p,P))}return b||(Object.keys(E).length&&!hr.isArray(r)?Yo({flowConfig:i,chldPth:null,edges:n,isInverted:null,itrblObjct:E,nodes:t,path:e,newConfig:g,ctx:s}):hr.isArray(r)&&r.forEach((x,C)=>{x=g0(x,s.initalObjIds);const T=x,S=Pa(x),_=Xn(x),{newConfig:A,arrayObject:P}=Ia(x);P.length&&(x=P);const{config:I}=Ki(typeof x=="string"?"text":"array",A),{hideConfig:D,sourceLabel:k,label:M,isEdgeAnimated:N,parent:z}=A;u=u||D;const $=e==="root"&&i.isCntr,q=e.split(".").slice(0,2).join("."),V=s.invrtdRtPths.includes(q),Z=i.isCntr&&V||C%2===0&&$;let K=`${e}.${C}`;K=os(K,t),Z&&s.invrtdRtPths.push(K),Zt(x)?Object.keys(S).length&&!hr.isArray(x)?(n.push(wa(e,K,null,k,Z,N)),ni(x,K,t,n,M||C,i,A,s)):Object.keys(_).length&&!hr.isArray(x)?Yo({flowConfig:i,chldPth:K,isInverted:Z,edges:n,itrblObjct:_,nodes:t,path:e,newConfig:A,forceIsInverted:!0,ctx:s}):hr.isArray(x)?jP({flowConfig:i,chldPth:K,edges:n,isInverted:Z,item:x,nodes:t,path:e,ctx:s}):Zt(x)&&Yo({flowConfig:i,chldPth:K,isInverted:Z,edges:n,itrblObjct:[x],nodes:t,path:e,newConfig:A,ctx:s}):(n.push(wa(e,K,null,k,Z,N)),t.push(ri(I,K,{label:M||String(x),parent:z},x,T)))})),{nodes:t,edges:n}}catch{return{nodes:t,edges:n}}}const Yo=({chldPth:r,flowConfig:e,edges:t,itrblObjct:n,nodes:a,isInverted:i,path:o,newConfig:s,forceIsInverted:l=!1,ctx:u})=>{let{hideDefaultObject:c,sprtObjctKy:d}=e;return Object.entries(n).forEach(([h,g],p)=>{g=g0(g,u.initalObjIds);const E=g,y=Pa(g),b=Xn(g),{newConfig:w,arrayObject:x}=Ia(g);x.length&&(g=x),w.collapsed===void 0&&(Object.keys(b).length>0||hr.isArray(g))&&(w.collapsed=!1);const{hideConfig:C,sourceLabel:T,label:S,content:_,target:A,targetLabel:P,collapsed:I,isEdgeAnimated:D,parent:k}=w;c=c||C;const M=o==="root"&&e.isCntr,N=o.split(".").slice(0,2).join("."),z=u.invrtdRtPths.includes(N);l||(i=e.isCntr&&z||p%2===0&&M);let $=r?`${r}.${h}`:`${o}.${h}`;if($=os($,a),i&&u.invrtdRtPths.push($),A&&t.push(wa($,A,null,P,i,D)),Zt(g)&&!hr.isArray(g)){t.push(wa(o,$,null,T,i,D));const q=d||Object.keys(y).length===0;if(q){const V=_?"object":"array",{config:Z}=Ki(V,w);Z.data.headerTitle=_?S:null,a.push(ri(Z,$,{label:S||h,parent:k},y,E))}if(Object.keys(y).length&&!c&&!I){let V=$;if(q){const Z=hr.isArray(g)?` ${g.length||""}`:`{${Object.keys(g).length||""}}`;V=`${$}.${Z}`,V=os(V,a),t.push(wa($,V,null,T,i,D))}ni(g,V,a,t,S||h,e,{},u)}else Object.keys(b).length&&!hr.isArray(g)&&!I?Yo({chldPth:$,flowConfig:e,itrblObjct:b,path:$,edges:t,nodes:a,newConfig:{},isInverted:i,ctx:u}):I||ni(g,$,a,t,h,e,{},u)}else hr.isArray(g)&&!I&&(t.push(wa(o,$,null,T,i,D)),ni(g,$,a,t,h,e,{},u))})},jP=({flowConfig:r,chldPth:e,edges:t,isInverted:n,item:a,nodes:i,path:o,ctx:s})=>a.forEach((l,u)=>{let c=`${e}.${u}`;c=os(c,i);const d=l;l=g0(l,s.initalObjIds);const h=Xn(l),g=Pa(l),{newConfig:p}=Ia(l),{collapsed:E,label:y,parent:b,sourceLabel:w,isEdgeAnimated:x,content:C}=p;Zt(l)?!hr.isArray(l)&&Object.keys(g).length&&!E?(t.push(wa(o,c,null,w,n,x)),ni(l,c,i,t,u,r,p,s)):Object.keys(h).length&&!hr.isArray(l)&&!E?Yo({chldPth:c,flowConfig:r,itrblObjct:h,path:o,edges:t,nodes:i,isInverted:n,newConfig:p,ctx:s}):hr.isArray(l)&&!E&&jP({flowConfig:r,chldPth:c,edges:t,isInverted:n,item:l,nodes:i,path:o,ctx:s}):(t.push(wa(o,c,null,w,n,x)),i.push(ri(h0,c,{label:y||String(l),parent:b},l,d)))});function YP(r){let e=0,t=0,n=0;const a=(i,o)=>{if(t=Math.max(t,o),e++,i&&typeof i=="object"){const s=Array.isArray(i)?i.length:Object.keys(i).length;if(n+=s+2,Array.isArray(i))for(const l of i)a(l,o+1);else for(const l in i)i.hasOwnProperty(l)&&a(i[l],o+1)}else n+=1};return a(r,0),{lines:n,depth:t,nodes:e}}function ZP(r,e){const t=(n,a,i=null,o="")=>{if(a>0&&a%e===0&&n&&typeof n=="object")if(Array.isArray(n)){i&&o!==""&&n.length>0&&(i[o]={$:n,$collapsed:!0});return}else{if(n.$collapsed===!1)return;const s=Xn(n);if(Object.keys(s).length>0){n.$collapsed=!0;return}}if(n&&typeof n=="object")if(Array.isArray(n))for(let s=0;s<n.length;s++)n[s]&&typeof n[s]=="object"&&t(n[s],a+1,n,s);else for(const s in n)n.hasOwnProperty(s)&&!s.startsWith("$")&&n[s]&&typeof n[s]=="object"&&t(n[s],a+1,n,s)};if(e>0&&r&&typeof r=="object")if(Array.isArray(r))for(let n=0;n<r.length;n++)r[n]&&typeof r[n]=="object"&&t(r[n],1,r,n);else for(const n in r)r.hasOwnProperty(n)&&!n.startsWith("$")&&r[n]&&typeof r[n]=="object"&&t(r[n],1,r,n);return r}const NW=".cytoscape-react-nodes-and-edges{position:absolute!important;top:0!important;left:0!important;z-index:10!important;pointer-events:none!important;overflow:visible!important;transform-origin:0 0!important}.cytoscape-react-node{z-index:0!important;overflow:visible!important;pointer-events:auto!important;position:absolute!important;transform-origin:0 0!important}.cytoscape-react-node input,.cytoscape-react-node textarea{pointer-events:auto!important;user-select:text!important;cursor:text!important}.cytoscape-react-edge{overflow:visible!important;pointer-events:none!important}.cytoscape-react-cy-container{width:100%!important;height:100%!important;overflow:visible!important;position:relative!important;background:transparent!important}.cytoscape-react-cy-container canvas{display:inline!important;vertical-align:baseline!important;overflow:visible!important}.cytoscape-react-cy-container>div{overflow:visible!important}";let V2=!1;function FW(){if(V2||typeof document>"u")return;const r=document.createElement("style");r.setAttribute("data-flow-sdk",""),r.textContent=NW,document.head.appendChild(r),V2=!0}const zW={nodes:[],edges:[]};function $W({json:r,title:e="untitled",nodes:t,edges:n,config:a={},callbacks:i={},className:o,style:s,showBottomBar:l=!0}){FW();const u=a.direction==="C",c=!!(t&&n),[d,h]=Se.useState(null),g=Se.useRef(e);g.current=e,Se.useEffect(()=>{if(c)return;if(!r){h(zW);return}h(null);const y=requestAnimationFrame(()=>{let b=typeof r=="string"?JSON.parse(r):r;if(a.autoCollapse){const x={minLines:800,minDepth:5,collapseEveryNLevels:3},C=a.autoCollapse===!0?x:{...x,...a.autoCollapse},{lines:T,depth:S}=YP(b);T>C.minLines&&S>C.minDepth&&(b=ZP(JSON.parse(JSON.stringify(b)),C.collapseEveryNLevels))}const w=ni(b,"root",[],[],g.current,{hideDefaultObject:!1,sprtObjctKy:!1,isCntr:u});h(w)});return()=>cancelAnimationFrame(y)},[r,e,u,a.autoCollapse]);const p=c?t:d==null?void 0:d.nodes,E=c?n:d==null?void 0:d.edges;return ue.jsx(iq,{config:a,callbacks:i,children:ue.jsx(pe.Box,{className:o,style:s,width:"100%",height:"100%",position:"relative",overflow:"hidden",children:p?ue.jsxs(ue.Fragment,{children:[ue.jsx(RW,{nodes:p,edges:E}),l&&ue.jsx(PW,{})]}):ue.jsxs(pe.Flex,{width:"100%",height:"100%",align:"center",justify:"center",direction:"column",gap:3,children:[ue.jsx(pe.Spinner,{size:"lg",color:a.themeColor||"blue.500",speed:"0.8s"}),ue.jsx(pe.Text,{fontSize:"sm",opacity:.5,children:"Loading diagram..."})]})})})}exports.DynamicIcon=_m;exports.FlowDiagram=$W;exports.applyAutoCollapse=ZP;exports.contentObjTheme=In;exports.createFlowDiagram=ni;exports.getChakraColorHex=ht;exports.getColorVariant=W2;exports.getDarkerHexColor=Vu;exports.getJsonSize=YP;exports.useCustomColors=us;exports.useStopPropagation=U2;exports.useThemeContentColors=ss;
357
+ }`;var sr=D1(function(){return mr(F,Ue+"return "+Ie).apply(t,H)});if(sr.source=Ie,Yf(sr))throw sr;return sr}function nL(f){return wr(f).toLowerCase()}function aL(f){return wr(f).toUpperCase()}function iL(f,v,m){if(f=wr(f),f&&(m||v===t))return z0(f);if(!f||!(v=Ut(v)))return f;var R=hn(f),B=hn(v),F=$0(R,B),H=V0(R,B)+1;return da(R,F,H).join("")}function oL(f,v,m){if(f=wr(f),f&&(m||v===t))return f.slice(0,W0(f)+1);if(!f||!(v=Ut(v)))return f;var R=hn(f),B=V0(R,hn(v))+1;return da(R,0,B).join("")}function sL(f,v,m){if(f=wr(f),f&&(m||v===t))return f.replace(Nr,"");if(!f||!(v=Ut(v)))return f;var R=hn(f),B=$0(R,hn(v));return da(R,B).join("")}function uL(f,v){var m=I,R=D;if(Fr(v)){var B="separator"in v?v.separator:B;m="length"in v?ir(v.length):m,R="omission"in v?Ut(v.omission):R}f=wr(f);var F=f.length;if(Ci(f)){var H=hn(f);F=H.length}if(m>=F)return f;var J=m-_i(R);if(J<1)return R;var ie=H?da(H,0,J).join(""):f.slice(0,J);if(B===t)return ie+R;if(H&&(J+=ie.length-J),Zf(B)){if(f.slice(J).search(B)){var Te,Re=ie;for(B.global||(B=df(B.source,wr(ft.exec(B))+"g")),B.lastIndex=0;Te=B.exec(Re);)var Ie=Te.index;ie=ie.slice(0,Ie===t?J:Ie)}}else if(f.indexOf(Ut(B),J)!=J){var Oe=ie.lastIndexOf(B);Oe>-1&&(ie=ie.slice(0,Oe))}return ie+R}function lL(f){return f=wr(f),f&&or.test(f)?f.replace(Fe,NI):f}var fL=Di(function(f,v,m){return f+(m?" ":"")+v.toUpperCase()}),Jf=Bb("toUpperCase");function I1(f,v,m){return f=wr(f),v=m?t:v,v===t?MI(f)?$I(f):_I(f):f.match(v)||[]}var D1=lr(function(f,v){try{return Gt(f,t,v)}catch(m){return Yf(m)?m:new rr(m)}}),cL=$n(function(f,v){return Qt(v,function(m){m=Tn(m),Fn(f,m,Kf(f[m],f))}),f});function dL(f){var v=f==null?0:f.length,m=Ze();return f=v?Or(f,function(R){if(typeof R[1]!="function")throw new Jt(o);return[m(R[0]),R[1]]}):[],lr(function(R){for(var B=-1;++B<v;){var F=f[B];if(Gt(F[0],this,R))return Gt(F[1],this,R)}})}function vL(f){return ND(rn(f,d))}function ec(f){return function(){return f}}function hL(f,v){return f==null||f!==f?v:f}var gL=kb(),pL=kb(!0);function qt(f){return f}function rc(f){return fb(typeof f=="function"?f:rn(f,d))}function yL(f){return db(rn(f,d))}function mL(f,v){return vb(f,rn(v,d))}var bL=lr(function(f,v){return function(m){return Co(m,f,v)}}),wL=lr(function(f,v){return function(m){return Co(f,m,v)}});function tc(f,v,m){var R=it(v),B=js(v,R);m==null&&!(Fr(v)&&(B.length||!R.length))&&(m=v,v=f,f=this,B=js(v,it(v)));var F=!(Fr(m)&&"chain"in m)||!!m.chain,H=Gn(f);return Qt(B,function(J){var ie=v[J];f[J]=ie,H&&(f.prototype[J]=function(){var Te=this.__chain__;if(F||Te){var Re=f(this.__wrapped__),Ie=Re.__actions__=kt(this.__actions__);return Ie.push({func:ie,args:arguments,thisArg:f}),Re.__chain__=Te,Re}return ie.apply(f,oa([this.value()],arguments))})}),f}function xL(){return ct._===this&&(ct._=KI),this}function nc(){}function EL(f){return f=ir(f),lr(function(v){return hb(v,f)})}var CL=kf(Or),_L=kf(O0),SL=kf(af);function B1(f){return $f(f)?of(Tn(f)):rB(f)}function TL(f){return function(v){return f==null?t:Ua(f,v)}}var RL=Lb(),AL=Lb(!0);function ac(){return[]}function ic(){return!1}function PL(){return{}}function IL(){return""}function DL(){return!0}function BL(f,v){if(f=ir(f),f<1||f>V)return[];var m=j,R=wt(f,j);v=Ze(v),f-=j;for(var B=lf(R,v);++m<f;)v(m);return B}function ML(f){return tr(f)?Or(f,Tn):Ht(f)?[f]:kt(Qb(wr(f)))}function kL(f){var v=++UI;return wr(f)+v}var OL=eu(function(f,v){return f+v},0),LL=Of("ceil"),qL=eu(function(f,v){return f/v},1),NL=Of("floor");function FL(f){return f&&f.length?Ks(f,qt,wf):t}function zL(f,v){return f&&f.length?Ks(f,Ze(v,2),wf):t}function $L(f){return N0(f,qt)}function VL(f,v){return N0(f,Ze(v,2))}function GL(f){return f&&f.length?Ks(f,qt,_f):t}function WL(f,v){return f&&f.length?Ks(f,Ze(v,2),_f):t}var UL=eu(function(f,v){return f*v},1),HL=Of("round"),KL=eu(function(f,v){return f-v},0);function jL(f){return f&&f.length?uf(f,qt):0}function YL(f,v){return f&&f.length?uf(f,Ze(v,2)):0}return L.after=yk,L.ary=l1,L.assign=aO,L.assignIn=C1,L.assignInWith=vu,L.assignWith=iO,L.at=oO,L.before=f1,L.bind=Kf,L.bindAll=cL,L.bindKey=c1,L.castArray=Pk,L.chain=o1,L.chunk=NB,L.compact=FB,L.concat=zB,L.cond=dL,L.conforms=vL,L.constant=ec,L.countBy=jM,L.create=sO,L.curry=d1,L.curryRight=v1,L.debounce=h1,L.defaults=uO,L.defaultsDeep=lO,L.defer=mk,L.delay=bk,L.difference=$B,L.differenceBy=VB,L.differenceWith=GB,L.drop=WB,L.dropRight=UB,L.dropRightWhile=HB,L.dropWhile=KB,L.fill=jB,L.filter=ZM,L.flatMap=JM,L.flatMapDeep=ek,L.flatMapDepth=rk,L.flatten=t1,L.flattenDeep=YB,L.flattenDepth=ZB,L.flip=wk,L.flow=gL,L.flowRight=pL,L.fromPairs=XB,L.functions=pO,L.functionsIn=yO,L.groupBy=tk,L.initial=JB,L.intersection=eM,L.intersectionBy=rM,L.intersectionWith=tM,L.invert=bO,L.invertBy=wO,L.invokeMap=ak,L.iteratee=rc,L.keyBy=ik,L.keys=it,L.keysIn=Lt,L.map=su,L.mapKeys=EO,L.mapValues=CO,L.matches=yL,L.matchesProperty=mL,L.memoize=lu,L.merge=_O,L.mergeWith=_1,L.method=bL,L.methodOf=wL,L.mixin=tc,L.negate=fu,L.nthArg=EL,L.omit=SO,L.omitBy=TO,L.once=xk,L.orderBy=ok,L.over=CL,L.overArgs=Ek,L.overEvery=_L,L.overSome=SL,L.partial=jf,L.partialRight=g1,L.partition=sk,L.pick=RO,L.pickBy=S1,L.property=B1,L.propertyOf=TL,L.pull=oM,L.pullAll=a1,L.pullAllBy=sM,L.pullAllWith=uM,L.pullAt=lM,L.range=RL,L.rangeRight=AL,L.rearg=Ck,L.reject=fk,L.remove=fM,L.rest=_k,L.reverse=Uf,L.sampleSize=dk,L.set=PO,L.setWith=IO,L.shuffle=vk,L.slice=cM,L.sortBy=pk,L.sortedUniq=mM,L.sortedUniqBy=bM,L.split=JO,L.spread=Sk,L.tail=wM,L.take=xM,L.takeRight=EM,L.takeRightWhile=CM,L.takeWhile=_M,L.tap=FM,L.throttle=Tk,L.thru=ou,L.toArray=w1,L.toPairs=T1,L.toPairsIn=R1,L.toPath=ML,L.toPlainObject=E1,L.transform=DO,L.unary=Rk,L.union=SM,L.unionBy=TM,L.unionWith=RM,L.uniq=AM,L.uniqBy=PM,L.uniqWith=IM,L.unset=BO,L.unzip=Hf,L.unzipWith=i1,L.update=MO,L.updateWith=kO,L.values=ki,L.valuesIn=OO,L.without=DM,L.words=I1,L.wrap=Ak,L.xor=BM,L.xorBy=MM,L.xorWith=kM,L.zip=OM,L.zipObject=LM,L.zipObjectDeep=qM,L.zipWith=NM,L.entries=T1,L.entriesIn=R1,L.extend=C1,L.extendWith=vu,tc(L,L),L.add=OL,L.attempt=D1,L.camelCase=FO,L.capitalize=A1,L.ceil=LL,L.clamp=LO,L.clone=Ik,L.cloneDeep=Bk,L.cloneDeepWith=Mk,L.cloneWith=Dk,L.conformsTo=kk,L.deburr=P1,L.defaultTo=hL,L.divide=qL,L.endsWith=zO,L.eq=pn,L.escape=$O,L.escapeRegExp=VO,L.every=YM,L.find=XM,L.findIndex=e1,L.findKey=fO,L.findLast=QM,L.findLastIndex=r1,L.findLastKey=cO,L.floor=NL,L.forEach=s1,L.forEachRight=u1,L.forIn=dO,L.forInRight=vO,L.forOwn=hO,L.forOwnRight=gO,L.get=Xf,L.gt=Ok,L.gte=Lk,L.has=mO,L.hasIn=Qf,L.head=n1,L.identity=qt,L.includes=nk,L.indexOf=QB,L.inRange=qO,L.invoke=xO,L.isArguments=ja,L.isArray=tr,L.isArrayBuffer=qk,L.isArrayLike=Ot,L.isArrayLikeObject=Ur,L.isBoolean=Nk,L.isBuffer=va,L.isDate=Fk,L.isElement=zk,L.isEmpty=$k,L.isEqual=Vk,L.isEqualWith=Gk,L.isError=Yf,L.isFinite=Wk,L.isFunction=Gn,L.isInteger=p1,L.isLength=cu,L.isMap=y1,L.isMatch=Uk,L.isMatchWith=Hk,L.isNaN=Kk,L.isNative=jk,L.isNil=Zk,L.isNull=Yk,L.isNumber=m1,L.isObject=Fr,L.isObjectLike=Vr,L.isPlainObject=Po,L.isRegExp=Zf,L.isSafeInteger=Xk,L.isSet=b1,L.isString=du,L.isSymbol=Ht,L.isTypedArray=Mi,L.isUndefined=Qk,L.isWeakMap=Jk,L.isWeakSet=eO,L.join=nM,L.kebabCase=GO,L.last=nn,L.lastIndexOf=aM,L.lowerCase=WO,L.lowerFirst=UO,L.lt=rO,L.lte=tO,L.max=FL,L.maxBy=zL,L.mean=$L,L.meanBy=VL,L.min=GL,L.minBy=WL,L.stubArray=ac,L.stubFalse=ic,L.stubObject=PL,L.stubString=IL,L.stubTrue=DL,L.multiply=UL,L.nth=iM,L.noConflict=xL,L.noop=nc,L.now=uu,L.pad=HO,L.padEnd=KO,L.padStart=jO,L.parseInt=YO,L.random=NO,L.reduce=uk,L.reduceRight=lk,L.repeat=ZO,L.replace=XO,L.result=AO,L.round=HL,L.runInContext=ne,L.sample=ck,L.size=hk,L.snakeCase=QO,L.some=gk,L.sortedIndex=dM,L.sortedIndexBy=vM,L.sortedIndexOf=hM,L.sortedLastIndex=gM,L.sortedLastIndexBy=pM,L.sortedLastIndexOf=yM,L.startCase=eL,L.startsWith=rL,L.subtract=KL,L.sum=jL,L.sumBy=YL,L.template=tL,L.times=BL,L.toFinite=Wn,L.toInteger=ir,L.toLength=x1,L.toLower=nL,L.toNumber=an,L.toSafeInteger=nO,L.toString=wr,L.toUpper=aL,L.trim=iL,L.trimEnd=oL,L.trimStart=sL,L.truncate=uL,L.unescape=lL,L.uniqueId=kL,L.upperCase=fL,L.upperFirst=Jf,L.each=s1,L.eachRight=u1,L.first=n1,tc(L,(function(){var f={};return _n(L,function(v,m){br.call(L.prototype,m)||(f[m]=v)}),f})(),{chain:!1}),L.VERSION=n,Qt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(f){L[f].placeholder=L}),Qt(["drop","take"],function(f,v){dr.prototype[f]=function(m){m=m===t?1:Jr(ir(m),0);var R=this.__filtered__&&!v?new dr(this):this.clone();return R.__filtered__?R.__takeCount__=wt(m,R.__takeCount__):R.__views__.push({size:wt(m,j),type:f+(R.__dir__<0?"Right":"")}),R},dr.prototype[f+"Right"]=function(m){return this.reverse()[f](m).reverse()}}),Qt(["filter","map","takeWhile"],function(f,v){var m=v+1,R=m==N||m==$;dr.prototype[f]=function(B){var F=this.clone();return F.__iteratees__.push({iteratee:Ze(B,3),type:m}),F.__filtered__=F.__filtered__||R,F}}),Qt(["head","last"],function(f,v){var m="take"+(v?"Right":"");dr.prototype[f]=function(){return this[m](1).value()[0]}}),Qt(["initial","tail"],function(f,v){var m="drop"+(v?"":"Right");dr.prototype[f]=function(){return this.__filtered__?new dr(this):this[m](1)}}),dr.prototype.compact=function(){return this.filter(qt)},dr.prototype.find=function(f){return this.filter(f).head()},dr.prototype.findLast=function(f){return this.reverse().find(f)},dr.prototype.invokeMap=lr(function(f,v){return typeof f=="function"?new dr(this):this.map(function(m){return Co(m,f,v)})}),dr.prototype.reject=function(f){return this.filter(fu(Ze(f)))},dr.prototype.slice=function(f,v){f=ir(f);var m=this;return m.__filtered__&&(f>0||v<0)?new dr(m):(f<0?m=m.takeRight(-f):f&&(m=m.drop(f)),v!==t&&(v=ir(v),m=v<0?m.dropRight(-v):m.take(v-f)),m)},dr.prototype.takeRightWhile=function(f){return this.reverse().takeWhile(f).reverse()},dr.prototype.toArray=function(){return this.take(j)},_n(dr.prototype,function(f,v){var m=/^(?:filter|find|map|reject)|While$/.test(v),R=/^(?:head|last)$/.test(v),B=L[R?"take"+(v=="last"?"Right":""):v],F=R||/^find/.test(v);B&&(L.prototype[v]=function(){var H=this.__wrapped__,J=R?[1]:arguments,ie=H instanceof dr,Te=J[0],Re=ie||tr(H),Ie=function(cr){var vr=B.apply(L,oa([cr],J));return R&&Oe?vr[0]:vr};Re&&m&&typeof Te=="function"&&Te.length!=1&&(ie=Re=!1);var Oe=this.__chain__,Ue=!!this.__actions__.length,Qe=F&&!Oe,sr=ie&&!Ue;if(!F&&Re){H=sr?H:new dr(this);var Je=f.apply(H,J);return Je.__actions__.push({func:ou,args:[Ie],thisArg:t}),new en(Je,Oe)}return Qe&&sr?f.apply(this,J):(Je=this.thru(Ie),Qe?R?Je.value()[0]:Je.value():Je)})}),Qt(["pop","push","shift","sort","splice","unshift"],function(f){var v=Bs[f],m=/^(?:push|sort|unshift)$/.test(f)?"tap":"thru",R=/^(?:pop|shift)$/.test(f);L.prototype[f]=function(){var B=arguments;if(R&&!this.__chain__){var F=this.value();return v.apply(tr(F)?F:[],B)}return this[m](function(H){return v.apply(tr(H)?H:[],B)})}}),_n(dr.prototype,function(f,v){var m=L[v];if(m){var R=m.name+"";br.call(Ai,R)||(Ai[R]=[]),Ai[R].push({name:v,func:m})}}),Ai[Js(t,b).name]=[{name:"wrapper",func:t}],dr.prototype.clone=lD,dr.prototype.reverse=fD,dr.prototype.value=cD,L.prototype.at=zM,L.prototype.chain=$M,L.prototype.commit=VM,L.prototype.next=GM,L.prototype.plant=UM,L.prototype.reverse=HM,L.prototype.toJSON=L.prototype.valueOf=L.prototype.value=KM,L.prototype.first=L.prototype.head,po&&(L.prototype[po]=WM),L}),Si=VI();za?((za.exports=Si)._=Si,ef._=Si):ct._=Si}).call(wW)})(Go,Go.exports)),Go.exports}var hr=xW();const N2=Cl(hr);function EW({cyParams:r,cyInst:e,layoutParams:t,layoutDebounce:n=50,children:a,init:i=()=>{},onCyInit:o}){const[s,l]=Se.useState(!1),u=Se.useRef(null),c=Se.useRef(null),d=Se.useRef(null),h=Se.useRef(!0),g=Se.useCallback(()=>{var y;d.current!==null&&d.current.stop(),c.current&&(d.current=c.current.layout(t),(y=d.current)==null||y.run())},[t]),p=N2.debounce(g,n);Se.useEffect(()=>{if(!u.current)return;const y=un({container:u.current,...r}),b=u.current.querySelector(".cytoscape-react-nodes-and-edges");if(b&&y.domNode({dom_container:b}),c.current=e||y,u.current&&(u.current.cy=c.current),o==null||o(c.current),i(y),u.current&&c.current){const x=u.current.parentElement;let C=0,T=0;x&&(C=x.clientHeight,T=x.clientWidth,C===0&&(C=window.innerHeight-x.getBoundingClientRect().top-100),T===0&&(T=window.innerWidth)),C>0&&T>0&&(u.current.style.width=`${T}px`,u.current.style.height=`${C}px`),c.current.resize(),r.zoom&&r.pan&&c.current.viewport({zoom:r.zoom,pan:r.pan})}l(!0);const w=new ResizeObserver(N2.debounce(()=>{if(u.current&&c.current){const x=u.current.parentElement;let C=0,T=0;x&&(C=x.clientHeight,T=x.clientWidth,C===0&&(C=window.innerHeight-x.getBoundingClientRect().top-100),T===0&&(T=window.innerWidth),C>0&&T>0&&(u.current.style.width=`${T}px`,u.current.style.height=`${C}px`));const S=c.current.zoom()!==void 0?{zoom:c.current.zoom(),pan:c.current.pan()}:null;c.current.resize(),S&&c.current.viewport(S)}},50));return u.current&&w.observe(u.current),()=>{w.disconnect();try{y.destroy()}catch{}c.current=null,l(!1)}},[]),Se.useEffect(()=>{h.current?(h.current=!1,g()):p()},[s,t,p,g]);const E=Se.useMemo(()=>{var y;return c.current!==null?((y=Se.Children.map(a,b=>{var w;return b?Se.cloneElement(b,{key:(w=b==null?void 0:b.props)==null?void 0:w.id,cytoInstance:c.current,layout:p}):null}))==null?void 0:y.filter(Boolean))||[]:[]},[a,s,p]);return ue.jsx("div",{ref:u,className:"cytoscape-react-cy-container",style:{width:"100%",height:"100%",position:"relative",background:"transparent"},children:ue.jsx("div",{className:"cytoscape-react-nodes-and-edges",style:{pointerEvents:"none",position:"absolute",top:0,left:0,transformOrigin:"0 0",zIndex:10},children:E})})}function CW({cytoInstance:r,id:e,parent:t,label:n,children:a,layout:i,classes:o,styleCallback:s}){const l=Se.useRef(null);function u(h){if(s){const g=s(h);h.isParent()&&(h.style("shape","roundrectangle"),h.style(g))}}Se.useEffect(()=>{try{if(l.current){const h={id:e,dom:l.current};t&&(h.parent=t),n&&(h.label=n);const g=r.add({data:h,classes:o});u(g)}}catch{}return()=>{r.getElementById(e).remove()}},[l,t,n]),Se.useEffect(()=>{i();const h=r.getElementById(e);h&&h.isParent()&&u(h)},[e,a]),Se.useEffect(()=>{if(!s)return;const h=r.getElementById(e);h&&h.isParent()&&u(h)},[s]);function c(h){return Se.cloneElement(h,{cytoInstance:r,layout:i})}const d=Se.Children.map(a,c);return ue.jsx("div",{ref:l,className:"cytoscape-react-node",children:d})}const _W={name:"dagre",rankDir:"LR",fit:!1,padding:20,spacingFactor:1.3,animate:!1,nodeDimensionsIncludeLabels:!0,ranker:"network-simplex",rankSep:10,nodeSep:5,edgeSep:10,avoidOverlap:!0,edgeWeight:function(r){return 1},minLen:function(r){return 1},useSimpleEdgeFunction:!0,edgeRouting:!0,controlPoints:!0},GP={padding:20,motionBlur:!1,compound:!0,pixelRatio:"auto",zoomingEnabled:!0,userZoomingEnabled:!0,dragpan:!0,avoidOverlap:!0,panningEnabled:!0,userPanningEnabled:!0,boxSelectionEnabled:!1,selectionType:"additive",minZoom:.01,maxZoom:1.5,autoungrabify:!0,styleEnabled:!0,hideEdgesOnViewport:!1,hideLabelsOnViewport:!0,headless:!1,touchTapThreshold:8,desktopTapThreshold:4,touchHoldDuration:500,desktopHoldDuration:1e3,autolock:!1,autounselectify:!1,wheelPanEnabled:!0,wheelPanThreshold:1,wheelPanDebounce:10,wheelAction:"pan"},WP={...GP,pixelRatio:1,motionBlur:!0,textureOnViewport:!0,wheelPanDebounce:20},SW={...WP,hideEdgesOnViewport:!0,hideLabelsOnViewport:!0},TW=({nodes:r,edges:e})=>{const{themeColor:t,edgeColor:n,direction:a,cyRef:i,callbacks:o,config:s,selectedNodeIds:l,setSelectedNodeIds:u,setSelectedEdgeId:c,setIsPerformanceMode:d,isZoomMode:h,setIsZoomMode:g,isMultiSelectMode:p,setIsMultiSelectMode:E,isDragMode:y,setIsDragMode:b,isEdgeHandlesEnabled:w,isArrayNodeMode:x}=Da(),C=Se.useRef(null),T=Se.useRef(null),S=Se.useRef(x),_=r.length>200;Se.useEffect(()=>{d(_)},[_,d]);const{edgeSep:A,rankSep:P}=Se.useMemo(()=>hq(r.length),[r.length]),{bgColor:I}=ss(t),{background:D,borderSecondary:k}=us(),M=s.backgroundColor||D,N=Se.useCallback(U=>{if(U!=null&&U.includes("gray"))return"whitesmoke";if(!U)return ht(t);switch(U){case"dark":return ht(M);case"light":return ht(k);default:return ht(U)}},[t,M,k]),z=s.colorMode==="dark",$=Se.useMemo(()=>z?N(I):"dark",[z,I,N]),q=n?N(n):$,V=Se.useMemo(()=>vq(N),[N]),Z=s.initialViewport||{pan:{x:0,y:0},zoom:.01},K=Se.useMemo(()=>({..._?SW:r.length>100?WP:GP,style:V,zoom:Z.zoom,pan:Z.pan,minZoom:s.minZoom??.01,maxZoom:s.maxZoom??1.5}),[V,Z,r.length,s.minZoom,s.maxZoom]),j=Se.useRef(!1),ee=Se.useRef();Se.useEffect(()=>()=>{clearTimeout(ee.current)},[]);const le=Se.useMemo(()=>({..._W,...a&&{rankDir:a},edgeSep:A,rankSep:P,get animate(){return j.current&&!_},animationDuration:300,animationEasing:"ease-in-out-cubic",stop:()=>{i.current&&(j.current||setTimeout(()=>{var U;(U=i.current)==null||U.fit(void 0,50)},100),clearTimeout(ee.current),ee.current=setTimeout(()=>{j.current=!0},500))}}),[a,A,P,i,_]),W=Se.useCallback(U=>{const fe=N(U||t);return{"corner-radius":50,"background-color":fe,color:fe,"border-color":fe}},[t,N]),G=Se.useCallback((U,fe,xe,ge)=>{let be={};return ge!=null&&ge.isInverted&&(ge==null?void 0:ge.source)===fe&&(be["target-arrow-shape"]="none",be["source-arrow-shape"]="triangle"),ge!=null&&ge.isEdgeAnimated?(be["line-style"]="dashed",be["line-dash-pattern"]=[32,18],be["line-dash-offset"]=0):ge!=null&&ge.isEdgeDashed?(be["line-style"]="dashed",be["line-dash-pattern"]=[],be["line-dash-offset"]=0):(be["line-style"]="solid",be["line-dash-pattern"]=[],be["line-dash-offset"]=0),a==="TB"&&(be["taxi-direction"]="downward"),a==="BT"&&(be["taxi-direction"]="upward"),a==="LR"&&(be["taxi-direction"]="rightward"),a==="RL"&&(be["taxi-direction"]="leftward"),be["line-color"]=q,be.color=q,be["target-arrow-color"]=q,be["source-arrow-color"]=q,be},[q,a]),Y=Se.useRef(r);Y.current=r;const re=Se.useRef(W);re.current=W;const de=Se.useRef(G);de.current=G,Se.useEffect(()=>{if(!i.current)return;const U=i.current,fe=()=>{U.nodes().forEach(xe=>{var ge,be;if(xe.isParent()){const Ae=Y.current.find(De=>{var Be;return((Be=De.data)==null?void 0:Be.id)===xe.id()});xe.style(re.current((be=(ge=Ae==null?void 0:Ae.data)==null?void 0:ge.viewProps)==null?void 0:be.bgColor))}})};return U.on("add",fe),()=>{U.off("add",fe)}},[]),Se.useEffect(()=>{if(!i.current)return;const U=i.current;U.nodes().forEach(fe=>{var xe,ge;if(fe.isParent()){const be=r.find(Ae=>{var De;return((De=Ae.data)==null?void 0:De.id)===fe.id()});fe.style(W((ge=(xe=be==null?void 0:be.data)==null?void 0:xe.viewProps)==null?void 0:ge.bgColor))}}),e.forEach(({data:fe})=>{const xe=U.getElementById(fe.id);xe!=null&&xe.length&&(xe.data({isEdgeAnimated:fe.isEdgeAnimated,isEdgeDashed:fe.isEdgeDashed}),xe.style(G(xe,fe.source,fe.target,fe)))})},[r,e,q,W,G]);const se=Se.useRef(s);se.current=s;const X=Se.useRef(h);X.current=h;const Q=Se.useRef(w);Q.current=w,S.current=x,Se.useEffect(()=>{if(!i.current||!i.current.container)return;const U=i.current,fe=C.current;if(!fe)return;let xe=null,ge=null,be=0,Ae=0,De=0,Be=0,Le=0;const He=Ve=>{Ve.preventDefault(),Ve.stopPropagation(),X.current||Ve.metaKey||Ve.ctrlKey?(De+=Ve.deltaY,Be=Ve.clientX,Le=Ve.clientY,ge===null&&(ge=requestAnimationFrame(()=>{ge=null;const er=se.current,$e=U.zoom(),ke=De;De=0;let ye=$e-ke*.05/100;ye=Math.max(er.minZoom??.01,Math.min(er.maxZoom??1.5,ye));const O=fe.getBoundingClientRect();U.zoom({level:ye,renderedPosition:{x:Be-O.left,y:Le-O.top}})}))):(be+=Ve.deltaX,Ae+=Ve.deltaY,xe===null&&(xe=requestAnimationFrame(()=>{xe=null;const er=U.pan(),$e=U.zoom(),ke=.35,ye=be,O=Ae;be=0,Ae=0,U.pan({x:er.x+-ye*ke/$e,y:er.y+-O*ke/$e})})))};return fe.addEventListener("wheel",He,{passive:!1}),()=>{fe.removeEventListener("wheel",He),xe!==null&&cancelAnimationFrame(xe),ge!==null&&cancelAnimationFrame(ge)}},[i.current]),Se.useEffect(()=>{i.current&&i.current.userPanningEnabled(y)},[y]),Se.useEffect(()=>{if(!i.current)return;const U=i.current;U.boxSelectionEnabled(!!p),U.selectionType(p?"additive":"single"),U.userPanningEnabled(!p&&y)},[p,y]),Se.useEffect(()=>{T.current&&(w?T.current.enableDrawMode():T.current.disableDrawMode())},[w]);const ae=Se.useRef(l);ae.current=l,Se.useEffect(()=>{if(s.disableKeyboardShortcuts)return;const U=fe=>{var ge,be;const xe=fe.target;if(!(xe.tagName==="INPUT"||xe.tagName==="TEXTAREA"||xe.isContentEditable)&&((fe.key==="z"||fe.key==="Z")&&g(!X.current),(fe.key==="m"||fe.key==="M")&&E(!p),(fe.key==="d"||fe.key==="D")&&b(!y),(fe.key==="Delete"||fe.key==="Backspace")&&ae.current.length>0)){fe.preventDefault();const Ae=ae.current.filter(Be=>Be!=="root");if(Ae.length===0)return;const De=i.current;for(const Be of Ae){const Le=(ge=De==null?void 0:De.getElementById(Be))==null?void 0:ge.data();(be=o.onNodeDelete)==null||be.call(o,Be,Le||{})}u([])}};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[p,y,g,E,b,s.disableKeyboardShortcuts,o,u,i]),Se.useEffect(()=>()=>{if(i.current)try{i.current.removeAllListeners()}catch{}},[]);const te=Se.useMemo(()=>_?300:r.length>50?150:r.length>20?100:50,[r.length,_]),ce=Se.useMemo(()=>{var fe;const U=new Set;for(const xe of r)(fe=xe.data)!=null&&fe.parent&&U.add(xe.data.parent);return U},[r]),_e=Se.useMemo(()=>{var fe;const U=new Map;for(const xe of e)(fe=xe.data)!=null&&fe.source&&!U.has(xe.data.source)&&U.set(xe.data.source,xe.data);return U},[e]),ve=s.backgroundPattern||"dot";return ue.jsx(oq,{pattern:ve,backgroundColor:s.backgroundColor,children:ue.jsx(pe.Box,{ref:C,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:ue.jsxs(EW,{cyParams:K,layoutParams:le,layoutDebounce:te,onCyInit:U=>{var xe;i.current=U,(xe=o.onCyInit)==null||xe.call(o,U);let fe=null;if(U.on("zoom pan",()=>{fe===null&&(fe=requestAnimationFrame(()=>{var ge;fe=null,(ge=o.onViewportChange)==null||ge.call(o,{zoom:U.zoom(),pan:U.pan()})}))}),U.on("select","edge",ge=>{var Ae;const be=ge.target;c(be.id()),(Ae=o.onEdgeSelect)==null||Ae.call(o,be.id(),be.data())}),U.on("unselect","edge",()=>{var ge;c(null),(ge=o.onEdgeDeselect)==null||ge.call(o)}),U.on("remove","edge",ge=>{var Ae;const be=ge.target;(Ae=o.onEdgeRemove)==null||Ae.call(o,be.id(),be.data())}),U.on("tap",":parent",ge=>{var Ae;const be=ge.target;u([be.id()]),(Ae=o.onNodeSelect)==null||Ae.call(o,be.id(),be.data())}),s.edgeHandles!==!1){const ge={canConnect:(Be,Le)=>!Be.same(Le),edgeParams:(Be,Le)=>({data:{source:Be.id(),target:Le.id(),label:""}}),loopAllowed:()=>!1,hoverDelay:500,snap:!1,snapThreshold:10,snapFrequency:5,noEdgeEventsInDraw:!0,disableBrowserGestures:!0,handlePosition:"left",handleNodes:"node",handleSize:20,handleColor:t||"#0ea5e9",handleOutlineColor:"#B92020FF",handleOutlineWidth:2,handleLineType:"ghost",handleLineWidth:2,preview:!0,ghostEdgeParams:()=>({}),edgeType:()=>"flat",nodeParams:()=>({})},be=U.edgehandles(ge);T.current=be,Q.current&&be.enableDrawMode();let Ae=null,De=null;U.on("ehstart",(Be,Le)=>{De=Le;const He=Be.originalEvent||window.event;if(He!=null&&He.clientX&&(He!=null&&He.clientY))Ae={x:He.clientX,y:He.clientY};else{const Ve=Le.renderedPosition();Ae={x:Ve.x,y:Ve.y}}}),U.on("ehcancel",Be=>{if(!Ae||!De)return;const Le=Be.originalEvent||window.event,He=Le==null?void 0:Le.clientX,Ve=Le==null?void 0:Le.clientY;if(He&&Ve&&o.onNodeCreate){const Xe=Math.abs(He-Ae.x),er=Math.abs(Ve-Ae.y);if(Math.max(Xe,er)>30){const $e=U.renderer().projectIntoViewport(He,Ve);o.onNodeCreate({type:"text",sourceNodeId:De.id(),position:{x:$e[0],y:$e[1]},isArrayMode:S.current})}}Ae=null,De=null}),U.on("ehcomplete",(Be,Le,He)=>{var Ve;(Ve=o.onEdgeCreate)==null||Ve.call(o,Le.id(),He.id())}),U.on("ehstop",()=>{Ae=null,De=null})}},children:[(r||[]).map(U=>{var De,Be,Le,He,Ve,Xe,er,$e,ke;const fe=s.customViews||dq,xe=ce.has((De=U.data)==null?void 0:De.id)&&!((Be=U.data)!=null&&Be.parent),ge=xe?((Le=U.data)==null?void 0:Le.label)||((He=U.data)==null?void 0:He.headerTitle)||"Container":void 0,be=xe?fe.parentContainer:fe[U==null?void 0:U.data.type]||fe.text,Ae=_e.get((Ve=U.data)==null?void 0:Ve.id);return ue.jsx(CW,{id:(Xe=U.data)==null?void 0:Xe.id,parent:(er=U.data)==null?void 0:er.parent,label:ge,styleCallback:()=>{var ye,O;return W((O=(ye=U.data)==null?void 0:ye.viewProps)==null?void 0:O.bgColor)},children:Se.createElement(be,{...U,isInverted:Ae==null?void 0:Ae.isInverted,isParent:xe,key:`${($e=U.data)==null?void 0:$e.id}-${t}`})},(ke=U.data)==null?void 0:ke.id)}),(e||[]).map(({data:U})=>ue.jsx(gq,{id:U==null?void 0:U.id,source:U==null?void 0:U.source,target:U==null?void 0:U.target,label:U==null?void 0:U.label,isPerformanceMode:_,styleCallback:(fe,xe,ge)=>G(fe,xe,ge,U)},U==null?void 0:U.id))]})})})},RW=Se.memo(TW);var Wo=(r=>(r.TOP_DOWN="TB",r.BOTTOM_UP="BT",r.LEFT_RIGHT="LR",r.RIGHT_LEFT="RL",r.CENTER="C",r))(Wo||{});const AW=[{value:"BT",label:"Bottom to Up",icon:Dr.PiArrowUpLight,flowType:Wo.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:Dr.PiArrowDownLight,flowType:Wo.TOP_DOWN},{value:"LR",label:"Left to Right",icon:Dr.PiArrowArcRightLight,flowType:Wo.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:Dr.PiArrowArcLeftLight,flowType:Wo.RIGHT_LEFT}],UP=()=>{const{cyRef:r,themeColor:e,direction:t,selectedNodeIds:n,setSelectedNodeIds:a,selectedEdgeId:i,setSelectedEdgeId:o,isZoomMode:s,setIsZoomMode:l,isMultiSelectMode:u,setIsMultiSelectMode:c,isDragMode:d,setIsDragMode:h,isEdgeHandlesEnabled:g,setIsEdgeHandlesEnabled:p,isArrayNodeMode:E,setIsArrayNodeMode:y,isPinned:b,setIsPinned:w,callbacks:x,config:C}=Da(),T=C.colorMode==="dark",{background:S,border:_,colorInactive:A,colorText:P,colorActive:I,darkBackgroundSecondary:D}=us(),[k,M]=Se.useState(!0),[N,z]=Se.useState(!1),[$,q]=Se.useState(!0),[V,Z]=Se.useState(!1),[K,j]=Se.useState(!1);Se.useEffect(()=>{const te=()=>q(window.innerWidth>=768);return te(),window.addEventListener("resize",te),()=>window.removeEventListener("resize",te)},[]),Se.useEffect(()=>{if(!$){M(!0);return}if(!b){M(!1);return}const te=_e=>{M(window.innerHeight-_e.clientY<=250)},ce=()=>M(!1);return window.addEventListener("mousemove",te),window.addEventListener("mouseleave",ce),()=>{window.removeEventListener("mousemove",te),window.removeEventListener("mouseleave",ce)}},[$,b]);const ee=Se.useCallback(te=>{const ce=r.current;if(!ce)return;const _e=C.minZoom??.01,ve=C.maxZoom??1.5,U=.02,fe=ce.zoomingEnabled(),xe=ce.userZoomingEnabled();ce.zoomingEnabled(!0),ce.userZoomingEnabled(!0);let ge=ce.zoom();switch(te){case"increase":ge=Math.min(ve,ge+U),ce.zoom(ge),ce.center();break;case"decrease":ge=Math.max(_e,ge-U),ce.zoom(ge),ce.center();break;case"reset":ce.fit(void 0,50);break}ce.zoomingEnabled(fe),ce.userZoomingEnabled(xe)},[r,C.minZoom,C.maxZoom]),le=k||N,W=C.renderSelectedNodeToolbar,G=n.length>0&&!!W,Y=Se.useMemo(()=>{if(!G)return[];const te=r.current;return te?n.map(ce=>{const _e=te.getElementById(ce);return _e!=null&&_e.length?{..._e.data(),isParent:_e.isParent()}:{id:ce}}):[]},[G,n,r]),re=Se.useCallback(()=>{var te;a([]),(te=x.onNodeDeselect)==null||te.call(x)},[a,x]),de=C.renderSelectedEdgeToolbar,se=!!i&&!!de,X=Se.useMemo(()=>{if(!se||!i)return null;const te=r.current;if(!te)return{id:i};const ce=te.getElementById(i);return ce!=null&&ce.length?ce.data():{id:i}},[se,i,r]),Q=Se.useCallback(()=>{var ce;o(null);const te=r.current;te&&te.edges().unselect(),(ce=x.onEdgeDeselect)==null||ce.call(x)},[o,r,x]),ae=C.renderBottomBar;return ae?ue.jsxs(ue.Fragment,{children:[G&&ue.jsx(pe.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:W({selectedNodeIds:n,selectedNodeData:Y,onDeselect:re})}),se&&X&&ue.jsx(pe.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:de({edgeId:i,edgeData:X,onDeselect:Q})}),ue.jsx(pe.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:ae({zoomIn:()=>ee("increase"),zoomOut:()=>ee("decrease"),resetZoom:()=>ee("reset"),direction:t,isZoomMode:s,setIsZoomMode:l,isMultiSelectMode:u,setIsMultiSelectMode:c,isDragMode:d,setIsDragMode:h,isEdgeHandlesEnabled:g,setIsEdgeHandlesEnabled:p,isArrayNodeMode:E,setIsArrayNodeMode:y,selectedNodeIds:n,selectedNodeData:Y,selectedEdgeId:i,selectedEdgeData:X,onNodeDeselect:re,onEdgeDeselect:Q,callbacks:x})})]}):ue.jsxs(ue.Fragment,{children:[G&&ue.jsx(pe.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:W({selectedNodeIds:n,selectedNodeData:Y,onDeselect:re})}),se&&X&&ue.jsx(pe.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:de({edgeId:i,edgeData:X,onDeselect:Q})}),!b&&ue.jsx(pe.Box,{position:"absolute",bottom:5,left:0,zIndex:101,w:3,children:ue.jsx(pe.Tooltip,{label:"Show Bottom Bar",placement:"top",fontSize:"xs",children:ue.jsx(pe.Flex,{align:"center",bg:S,borderColor:_,borderWidth:1,py:6,px:0,w:4,h:50,borderRadius:"15px",borderLeftRadius:0,onMouseEnter:()=>{z(!0),M(!0)},onMouseLeave:()=>z(!1),_hover:{bg:D},children:ue.jsx(pe.Icon,{ml:-1,as:Dr.PiLineVerticalBold,boxSize:5,color:_})})})}),ue.jsx(pe.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",transition:"opacity 0.3s ease-in, transform 0.3s ease",transform:le?"translateY(0)":"translateY(100%)",pointerEvents:le?"auto":"none",opacity:le?1:0,onMouseEnter:()=>{b||M(!0)},onMouseLeave:()=>{b||(M(!1),z(!1))},children:ue.jsxs(pe.Flex,{w:"100%",px:5,position:"absolute",bottom:5,flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[ue.jsx(pe.Box,{bg:S,alignContent:"center",h:50,borderColor:_,borderWidth:1,borderRadius:"15px",children:ue.jsxs(pe.HStack,{px:2,spacing:1,children:[ue.jsx(pe.Tooltip,{label:b?"Unpin":"Pin",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Pin",icon:ue.jsx(pe.Icon,{as:b?Dr.PiPushPinFill:Dr.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:b?e:A,onClick:()=>{const te=!b;w(te),M(te)}})}),ue.jsx(pe.Icon,{mx:-1,as:Dr.PiLineVerticalThin,boxSize:5,color:_}),ue.jsx(pe.Tooltip,{label:"Zoom Out",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Zoom out",icon:ue.jsx(pe.Icon,{as:tq.HiMinus,boxSize:5}),size:"sm",variant:"ghost",color:P,onClick:()=>ee("decrease")})}),ue.jsx(pe.Tooltip,{label:"Zoom In",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Zoom in",icon:ue.jsx(pe.Icon,{as:hu.VscAdd,boxSize:5}),size:"sm",variant:"ghost",color:P,onClick:()=>ee("increase")})}),ue.jsx(pe.Tooltip,{label:"Reset Zoom",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Reset zoom",icon:ue.jsx(pe.Icon,{as:nq.GrPowerReset,boxSize:5}),size:"sm",variant:"ghost",color:P,onClick:()=>ee("reset")})}),!K&&ue.jsxs(ue.Fragment,{children:[ue.jsx(pe.Icon,{mx:-1,as:Dr.PiLineVerticalThin,boxSize:5,color:_}),ue.jsx(pe.Tooltip,{label:s?"Zoom Mode (z)":"Pan Mode (z)",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Toggle zoom mode",icon:ue.jsx(pe.Icon,{as:s?hu.VscZoomIn:hu.VscMove,boxSize:5}),size:"sm",variant:"ghost",color:s?e:A,onClick:()=>l(!s)})}),ue.jsx(pe.Icon,{mx:-1,as:Dr.PiLineVerticalThin,boxSize:5,color:_}),ue.jsx(pe.Tooltip,{label:u?"Multi-Select On (m)":"Multi-Select Off (m)",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Toggle multi-select",icon:ue.jsx(pe.Icon,{as:hu.VscGroupByRefType,boxSize:5}),size:"sm",variant:"ghost",color:u?e:A,onClick:()=>c(!u)})}),ue.jsx(pe.Icon,{mx:-1,as:Dr.PiLineVerticalThin,boxSize:5,color:_}),ue.jsx(pe.Tooltip,{label:d?"Drag Mode On (d)":"Drag Mode Off (d)",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Toggle drag mode",icon:ue.jsx(pe.Icon,{as:Dr.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:d?e:A,onClick:()=>h(!d)})}),C.edgeHandles!==!1&&ue.jsxs(ue.Fragment,{children:[ue.jsx(pe.Icon,{mx:-1,as:Dr.PiLineVerticalThin,boxSize:5,color:_}),ue.jsx(pe.Tooltip,{label:g?"Draw Mode On":"Draw Mode Off",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Toggle draw mode",icon:ue.jsx(pe.Icon,{as:Dr.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:g?e:A,onClick:()=>p(!g)})})]}),ue.jsx(pe.Icon,{mx:-1,as:Dr.PiLineVerticalThin,boxSize:5,color:_}),ue.jsx(pe.Tooltip,{label:E?"List mode":"Set mode",placement:"top",fontSize:"xs",children:ue.jsx(pe.Flex,{cursor:"pointer",align:"center",onClick:()=>{var ce;const te=!E;y(te),(ce=x.onArrayModeChange)==null||ce.call(x,te)},_hover:{color:e},children:ue.jsx(pe.Text,{fontSize:"23px",color:E?e:A,children:E?"[]":"{}"})})})]}),ue.jsx(pe.Icon,{mx:-1,as:Dr.PiLineVerticalThin,boxSize:5,color:_}),ue.jsx(pe.Tooltip,{label:K?"Expand toolbar":"Collapse toolbar",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Toggle toolbar collapse",icon:ue.jsx(pe.Icon,{as:K?Dr.PiCaretRight:Dr.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:A,onClick:()=>j(!K)})})]})}),ue.jsxs(pe.Box,{position:"relative",ml:"auto",children:[ue.jsx(pe.Box,{bg:S,borderWidth:1,borderColor:_,borderRadius:"15px",h:50,px:3,cursor:"pointer",onClick:()=>Z(!V),children:ue.jsxs(pe.Flex,{align:"center",h:"100%",children:[ue.jsx(pe.Tooltip,{label:"Flow Direction",placement:"top",fontSize:"xs",children:ue.jsx(pe.IconButton,{"aria-label":"Direction",icon:ue.jsx(pe.Icon,{as:Dr.PiCaretUp,boxSize:4}),size:"sm",variant:"ghost",color:A})}),ue.jsx(pe.Text,{fontSize:"xs",color:T?"whiteAlpha.600":"blackAlpha.500",ml:1,children:t})]})}),V&&ue.jsxs(pe.Box,{position:"absolute",bottom:"60px",right:0,bg:S,borderWidth:1,borderColor:_,borderRadius:"15px",p:2,zIndex:200,minW:"180px",shadow:"lg",onMouseLeave:()=>Z(!1),children:[AW.map(te=>ue.jsxs(pe.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"10px",cursor:"pointer",_hover:{bg:T?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var ce;(ce=x.onDirectionChange)==null||ce.call(x,te.value),Z(!1)},children:[ue.jsx(pe.Icon,{as:te.icon,boxSize:5,color:P}),ue.jsx(pe.Text,{fontSize:"sm",color:P,flex:1,whiteSpace:"nowrap",children:te.label}),t===te.value&&ue.jsx(pe.Icon,{as:O1.IoCheckmark,boxSize:4,color:I})]},te.value)),ue.jsxs(pe.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"10px",cursor:"pointer",_hover:{bg:T?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var te;(te=x.onDirectionChange)==null||te.call(x,"LR"),Z(!1)},children:[ue.jsx(pe.Icon,{as:aq.TbAlignCenter,boxSize:5,color:P}),ue.jsx(pe.Text,{fontSize:"sm",color:P,flex:1,whiteSpace:"nowrap",children:"Center"}),t==="C"&&ue.jsx(pe.Icon,{as:O1.IoCheckmark,boxSize:4,color:I})]})]})]})]})})]})};UP.displayName="BottomBar";const PW=Se.memo(UP),$l={label:"Untitled",description:"",isTask:!1,isLocked:!1},h0={id:null,type:"text",data:{...$l,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"}}},F2={id:null,type:"objectView",data:{...$l,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:25,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},IW={id:null,type:"arrayView",data:{...$l,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"}}},z2={id:null,type:"workflowStep",data:{...$l,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}};let Au;const DW=new Uint8Array(16);function BW(){if(!Au&&(Au=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Au))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Au(DW)}const vt=[];for(let r=0;r<256;++r)vt.push((r+256).toString(16).slice(1));function MW(r,e=0){return vt[r[e+0]]+vt[r[e+1]]+vt[r[e+2]]+vt[r[e+3]]+"-"+vt[r[e+4]]+vt[r[e+5]]+"-"+vt[r[e+6]]+vt[r[e+7]]+"-"+vt[r[e+8]]+vt[r[e+9]]+"-"+vt[r[e+10]]+vt[r[e+11]]+vt[r[e+12]]+vt[r[e+13]]+vt[r[e+14]]+vt[r[e+15]]}const kW=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),$2={randomUUID:kW};function OW(r,e,t){if($2.randomUUID&&!r)return $2.randomUUID();r=r||{};const n=r.random||(r.rng||BW)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,MW(n)}const Zt=r=>typeof r=="object",HP=r=>Array.isArray(r),LW=["order","position","selected","locked","grabbed","grabbable","scratch"],Pa=r=>Object.entries(r).reduce((e,[t,n])=>(!Zt(n)&&!t.startsWith("$")&&(e[t]=n),e),{}),g0=(r,e)=>typeof r=="string"&&r.startsWith("$")?nm(r,e):Zt(r)&&!HP(r)?Object.entries(r).reduce((t,[n,a])=>(typeof a=="string"&&a.startsWith("$")&&n==="..."?(delete t["..."],t[n]={...nm(a,e),...r}):typeof a=="string"&&a.startsWith("$")?t[n]=nm(a,e):t[n]=a,t),{}):r,Xn=r=>Object.entries(r).reduce((e,[t,n])=>(Zt(n)&&t&&n&&!t.startsWith("$")&&(LW.includes(t)&&(t=t+"#"),e[t]=n),e),{}),ri=(r,e,{label:t,parent:n=void 0},a,i=null)=>(i!==null&&(Zt(i)||HP(i))&&(i=JSON.stringify(i,null,2)),{data:{parent:n,...r.data,id:e,text:t||"",label:t,code:i||null,type:r.type,description:a}}),wa=(r,e,t=null,n=null,a=null,i=!1,o=null)=>({data:{id:OW(),source:a?e:r,target:a?r:e,label:n||"",isInverted:a,isEdgeAnimated:i,parent:o}}),Ia=(r,e=[])=>{const t={},n={};let a=[];if(r)for(const[i,o]of Object.entries(r))i.startsWith("$")&&i!=="$"?t[i.slice(1)]=o:i!=="$"?n[i]=o:i==="$"&&(a=o);return{newConfig:t,updatedObject:n,arrayObject:a}},Ki=(r,e)=>{let t=F2;const{view:n,borderColor:a,borderRadius:i,bgColor:o,textColor:s,fontSize:l,stepType:u}=e;r=n||r,u?t={...z2}:r==="object"?t=F2:r==="text"?t=h0:r==="array"?t=IW:r==="workflowStep"&&(t={...z2});const c=t.data.viewProps;return t.data.viewProps={...c,borderRadius:i||(u?15:50),bgColor:o,borderColor:a,textColor:s,fontSize:l},t.data.config=e,{config:t}},os=(r,e)=>(r=e.find(n=>{var a;return((a=n.data)==null?void 0:a.id)===r||n===r})?`${r}.#`:r,r),nm=(r,{ids:e,jsnObjct:t})=>{if(typeof r=="string"&&(r!=null&&r.startsWith("$"))){const n=r.replace("$","").replace("*","");r==null||r.endsWith("*");const a=e.find(s=>s.split(".").slice(-1)[0]===n||n===s);if(!a)return r;const i=qW(a,t);return JSON.stringify(i).includes(r)?r:i||r}return r},qW=(r,e)=>{let t=r.split(".").splice(1);return t=t[t.length-1]==="#"||t[t.length-1].includes("{")?t.slice(0,-2):t,(i=>t.reduce((o,s)=>{s=s.replace("[","").replace("]","");const{arrayObject:l}=Ia(o);return o=l.length?l:o,o[s]},i))(e)};function Qi(r,e="root",t=[]){try{const{arrayObject:n}=Ia(r);n.length&&(r=n);const a=Pa(r),i=Xn(r);return Zt(r)?(hr.isArray(r)||hr.isArray(r)&&e==="root"||!hr.isArray(r)&&Object.keys(a).length||e==="root")&&t.push(e):t.push(e),Object.keys(i).length&&!hr.isArray(r)?jo({chldPth:null,itrblObjct:i,nodes:t,path:e}):hr.isArray(r)&&r.forEach((o,s)=>{const l=Pa(o),u=Xn(o),{newConfig:c,arrayObject:d}=Ia(o);let h=`${e}.${s}`;Zt(o)?Object.keys(l).length?(Qi(l,h,t),Object.keys(u).length&&!hr.isArray(o)&&jo({chldPth:h,itrblObjct:u,nodes:t,path:e})):Object.keys(u).length&&!hr.isArray(o)?jo({chldPth:h,itrblObjct:u,nodes:t,path:e}):hr.isArray(o)&&KP({chldPth:h,item:o,nodes:t,path:e}):t.push(h)}),{nodes:t}}catch{return{nodes:t}}}const jo=({chldPth:r,itrblObjct:e,nodes:t,path:n})=>Object.entries(e).forEach(([a,i],o)=>{const s=Pa(i),l=Xn(i),{newConfig:u,arrayObject:c}=Ia(i);c.length&&(i=c);let d=r?`${r}.${a}`:`${n}.${a}`;if(Zt(i)&&!hr.isArray(i)){const h=Object.keys(s).length===0;if(h&&(Ki("array",u),t.push(d)),Object.keys(s).length){const g=hr.isArray(i)?`${i.length||""}`:`{${Object.keys(i).length||""}}`;let p=d;h&&(p=`${d}.${g}`),Qi(i,p,t)}else Object.keys(l).length&&!hr.isArray(i)?jo({chldPth:d,itrblObjct:l,path:d,nodes:t}):Qi(i,d,t)}else hr.isArray(i)&&Qi(i,d,t)}),KP=({chldPth:r,item:e,nodes:t,path:n})=>e.forEach((a,i)=>{let o=`${r}.${i}`;const s=Xn(a),l=Pa(a);Zt(a)?!hr.isArray(a)&&Object.keys(l).length?Qi(a,o,t):Object.keys(s).length&&!hr.isArray(a)?jo({chldPth:o,itrblObjct:s,path:n,nodes:t}):hr.isArray(a)&&KP({chldPth:o,item:a,nodes:t,path:n}):t.push(o)});function ni(r,e="root",t=[],n=[],a="untitled",i={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},o={},s){if(s||(s={invrtdRtPths:[],initalObjIds:null}),!r||typeof r!="object")return{nodes:t,edges:n};const l=r;if(!s.initalObjIds){const{nodes:d}=Qi(r);s.initalObjIds={ids:d,jsnObjct:r}}let{hideDefaultObject:u,sprtObjctKy:c}=i;try{e=os(e,t);const{newConfig:d,arrayObject:h}=Ia(r),g=Object.keys(o).length>0?o:d;h.length&&(r=h);const p=Pa(r),E=Xn(r);g.collapsed===void 0&&(Object.keys(E).length>0||hr.isArray(r))&&(g.collapsed=!1);const{label:y,collapsed:b,parent:w}=g;if(!Zt(r))t.push(ri(h0,e,{label:y||e,parent:w},r,l));else if(hr.isArray(r)||hr.isArray(r)&&e==="root"){const{config:x}=Ki("array",g),C=hr.isArray(r)?`${r.length||""}`:`{${Object.keys(r).length||""}}`,T=e==="root"?a:`${a} ${C}`;t.push(ri(x,e,{label:y||T,parent:w},r,hr.isArray(l)?{[a]:l}:l))}else if(!hr.isArray(r)&&Object.keys(p).length||e==="root"){const{config:x}=Ki(null,g),C=e.split("."),T=C[C.length-1];let S=isNaN(Number(T))?null:Number(T)+1;const _=isNaN(Number(T))?T:C[C.length-2]+" "+S,A=e==="root"?a:_,P=r;if(y){const{config:I}=Ki("object",g);I.data.headerTitle=y,t.push(ri(I,e,{label:y||`${y} ${Object.keys(r).length}`,parent:w},p,P))}else x.data.headerTitle=A,t.push(ri(x,e,{label:y,parent:w},p,P))}return b||(Object.keys(E).length&&!hr.isArray(r)?Yo({flowConfig:i,chldPth:null,edges:n,isInverted:null,itrblObjct:E,nodes:t,path:e,newConfig:g,ctx:s}):hr.isArray(r)&&r.forEach((x,C)=>{x=g0(x,s.initalObjIds);const T=x,S=Pa(x),_=Xn(x),{newConfig:A,arrayObject:P}=Ia(x);P.length&&(x=P);const{config:I}=Ki(typeof x=="string"?"text":"array",A),{hideConfig:D,sourceLabel:k,label:M,isEdgeAnimated:N,parent:z}=A;u=u||D;const $=e==="root"&&i.isCntr,q=e.split(".").slice(0,2).join("."),V=s.invrtdRtPths.includes(q),Z=i.isCntr&&V||C%2===0&&$;let K=`${e}.${C}`;K=os(K,t),Z&&s.invrtdRtPths.push(K),Zt(x)?Object.keys(S).length&&!hr.isArray(x)?(n.push(wa(e,K,null,k,Z,N)),ni(x,K,t,n,M||C,i,A,s)):Object.keys(_).length&&!hr.isArray(x)?Yo({flowConfig:i,chldPth:K,isInverted:Z,edges:n,itrblObjct:_,nodes:t,path:e,newConfig:A,forceIsInverted:!0,ctx:s}):hr.isArray(x)?jP({flowConfig:i,chldPth:K,edges:n,isInverted:Z,item:x,nodes:t,path:e,ctx:s}):Zt(x)&&Yo({flowConfig:i,chldPth:K,isInverted:Z,edges:n,itrblObjct:[x],nodes:t,path:e,newConfig:A,ctx:s}):(n.push(wa(e,K,null,k,Z,N)),t.push(ri(I,K,{label:M||String(x),parent:z},x,T)))})),{nodes:t,edges:n}}catch{return{nodes:t,edges:n}}}const Yo=({chldPth:r,flowConfig:e,edges:t,itrblObjct:n,nodes:a,isInverted:i,path:o,newConfig:s,forceIsInverted:l=!1,ctx:u})=>{let{hideDefaultObject:c,sprtObjctKy:d}=e;return Object.entries(n).forEach(([h,g],p)=>{g=g0(g,u.initalObjIds);const E=g,y=Pa(g),b=Xn(g),{newConfig:w,arrayObject:x}=Ia(g);x.length&&(g=x),w.collapsed===void 0&&(Object.keys(b).length>0||hr.isArray(g))&&(w.collapsed=!1);const{hideConfig:C,sourceLabel:T,label:S,content:_,target:A,targetLabel:P,collapsed:I,isEdgeAnimated:D,parent:k}=w;c=c||C;const M=o==="root"&&e.isCntr,N=o.split(".").slice(0,2).join("."),z=u.invrtdRtPths.includes(N);l||(i=e.isCntr&&z||p%2===0&&M);let $=r?`${r}.${h}`:`${o}.${h}`;if($=os($,a),i&&u.invrtdRtPths.push($),A&&t.push(wa($,A,null,P,i,D)),Zt(g)&&!hr.isArray(g)){t.push(wa(o,$,null,T,i,D));const q=d||Object.keys(y).length===0;if(q){const V=_?"object":"array",{config:Z}=Ki(V,w);Z.data.headerTitle=_?S:null,a.push(ri(Z,$,{label:S||h,parent:k},y,E))}if(Object.keys(y).length&&!c&&!I){let V=$;if(q){const Z=hr.isArray(g)?` ${g.length||""}`:`{${Object.keys(g).length||""}}`;V=`${$}.${Z}`,V=os(V,a),t.push(wa($,V,null,T,i,D))}ni(g,V,a,t,S||h,e,{},u)}else Object.keys(b).length&&!hr.isArray(g)&&!I?Yo({chldPth:$,flowConfig:e,itrblObjct:b,path:$,edges:t,nodes:a,newConfig:{},isInverted:i,ctx:u}):I||ni(g,$,a,t,h,e,{},u)}else hr.isArray(g)&&!I&&(t.push(wa(o,$,null,T,i,D)),ni(g,$,a,t,h,e,{},u))})},jP=({flowConfig:r,chldPth:e,edges:t,isInverted:n,item:a,nodes:i,path:o,ctx:s})=>a.forEach((l,u)=>{let c=`${e}.${u}`;c=os(c,i);const d=l;l=g0(l,s.initalObjIds);const h=Xn(l),g=Pa(l),{newConfig:p}=Ia(l),{collapsed:E,label:y,parent:b,sourceLabel:w,isEdgeAnimated:x,content:C}=p;Zt(l)?!hr.isArray(l)&&Object.keys(g).length&&!E?(t.push(wa(o,c,null,w,n,x)),ni(l,c,i,t,u,r,p,s)):Object.keys(h).length&&!hr.isArray(l)&&!E?Yo({chldPth:c,flowConfig:r,itrblObjct:h,path:o,edges:t,nodes:i,isInverted:n,newConfig:p,ctx:s}):hr.isArray(l)&&!E&&jP({flowConfig:r,chldPth:c,edges:t,isInverted:n,item:l,nodes:i,path:o,ctx:s}):(t.push(wa(o,c,null,w,n,x)),i.push(ri(h0,c,{label:y||String(l),parent:b},l,d)))});function YP(r){let e=0,t=0,n=0;const a=(i,o)=>{if(t=Math.max(t,o),e++,i&&typeof i=="object"){const s=Array.isArray(i)?i.length:Object.keys(i).length;if(n+=s+2,Array.isArray(i))for(const l of i)a(l,o+1);else for(const l in i)i.hasOwnProperty(l)&&a(i[l],o+1)}else n+=1};return a(r,0),{lines:n,depth:t,nodes:e}}function ZP(r,e){const t=(n,a,i=null,o="")=>{if(a>0&&a%e===0&&n&&typeof n=="object")if(Array.isArray(n)){i&&o!==""&&n.length>0&&(i[o]={$:n,$collapsed:!0});return}else{if(n.$collapsed===!1)return;const s=Xn(n);if(Object.keys(s).length>0){n.$collapsed=!0;return}}if(n&&typeof n=="object")if(Array.isArray(n))for(let s=0;s<n.length;s++)n[s]&&typeof n[s]=="object"&&t(n[s],a+1,n,s);else for(const s in n)n.hasOwnProperty(s)&&!s.startsWith("$")&&n[s]&&typeof n[s]=="object"&&t(n[s],a+1,n,s)};if(e>0&&r&&typeof r=="object")if(Array.isArray(r))for(let n=0;n<r.length;n++)r[n]&&typeof r[n]=="object"&&t(r[n],1,r,n);else for(const n in r)r.hasOwnProperty(n)&&!n.startsWith("$")&&r[n]&&typeof r[n]=="object"&&t(r[n],1,r,n);return r}const NW=".cytoscape-react-nodes-and-edges{position:absolute!important;top:0!important;left:0!important;z-index:10!important;pointer-events:none!important;overflow:visible!important;transform-origin:0 0!important}.cytoscape-react-node{z-index:0!important;overflow:visible!important;pointer-events:auto!important;position:absolute!important;transform-origin:0 0!important}.cytoscape-react-node input,.cytoscape-react-node textarea{pointer-events:auto!important;user-select:text!important;cursor:text!important}.cytoscape-react-edge{overflow:visible!important;pointer-events:none!important}.cytoscape-react-cy-container{width:100%!important;height:100%!important;overflow:visible!important;position:relative!important;background:transparent!important}.cytoscape-react-cy-container canvas{display:inline!important;vertical-align:baseline!important;overflow:visible!important}.cytoscape-react-cy-container>div{overflow:visible!important}";let V2=!1;function FW(){if(V2||typeof document>"u")return;const r=document.createElement("style");r.setAttribute("data-flow-sdk",""),r.textContent=NW,document.head.appendChild(r),V2=!0}const zW={nodes:[],edges:[]};function $W({json:r,title:e="untitled",nodes:t,edges:n,config:a={},callbacks:i={},className:o,style:s,showBottomBar:l=!0}){FW();const u=a.direction==="C",c=!!(t||n),[d,h]=Se.useState(null),g=Se.useRef(e);g.current=e,Se.useEffect(()=>{if(c)return;if(!r){h(zW);return}h(null);const y=requestAnimationFrame(()=>{let b=typeof r=="string"?JSON.parse(r):r;if(a.autoCollapse){const x={minLines:800,minDepth:5,collapseEveryNLevels:3},C=a.autoCollapse===!0?x:{...x,...a.autoCollapse},{lines:T,depth:S}=YP(b);T>C.minLines&&S>C.minDepth&&(b=ZP(JSON.parse(JSON.stringify(b)),C.collapseEveryNLevels))}const w=ni(b,"root",[],[],g.current,{hideDefaultObject:!1,sprtObjctKy:!1,isCntr:u});h(w)});return()=>cancelAnimationFrame(y)},[r,e,u,a.autoCollapse]);const p=c?t:d==null?void 0:d.nodes,E=c?n:d==null?void 0:d.edges;return ue.jsx(iq,{config:a,callbacks:i,children:ue.jsx(pe.Box,{className:o,style:s,width:"100%",height:"100%",position:"relative",overflow:"hidden",children:p?ue.jsxs(ue.Fragment,{children:[ue.jsx(RW,{nodes:p,edges:E}),l&&ue.jsx(PW,{})]}):ue.jsxs(pe.Flex,{width:"100%",height:"100%",align:"center",justify:"center",direction:"column",gap:3,children:[ue.jsx(pe.Spinner,{size:"lg",color:a.themeColor||"blue.500",speed:"0.8s"}),ue.jsx(pe.Text,{fontSize:"sm",opacity:.5,children:"Loading diagram..."})]})})})}exports.DynamicIcon=_m;exports.FlowDiagram=$W;exports.applyAutoCollapse=ZP;exports.contentObjTheme=In;exports.createFlowDiagram=ni;exports.getChakraColorHex=ht;exports.getColorVariant=W2;exports.getDarkerHexColor=Vu;exports.getJsonSize=YP;exports.useCustomColors=us;exports.useStopPropagation=U2;exports.useThemeContentColors=ss;
358
358
  //# sourceMappingURL=index.cjs.map