@theclearsky/react-blender-nodes 0.0.7 → 0.0.8
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.
|
@@ -84,7 +84,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
84
84
|
`:`;
|
|
85
85
|
`)+le+`return __p
|
|
86
86
|
}`;var Oe=bw(function(){return Be(I,we+"return "+le).apply(n,F)});if(Oe.source=le,Id(Oe))throw Oe;return Oe}function WL(r){return Fe(r).toLowerCase()}function jL(r){return Fe(r).toUpperCase()}function UL(r,i,u){if(r=Fe(r),r&&(u||i===n))return Ov(r);if(!r||!(i=$t(i)))return r;var y=on(r),S=on(i),I=Pv(y,S),F=kv(y,S)+1;return mr(y,I,F).join("")}function GL(r,i,u){if(r=Fe(r),r&&(u||i===n))return r.slice(0,Rv(r)+1);if(!r||!(i=$t(i)))return r;var y=on(r),S=kv(y,on(i))+1;return mr(y,0,S).join("")}function YL(r,i,u){if(r=Fe(r),r&&(u||i===n))return r.replace(Wi,"");if(!r||!(i=$t(i)))return r;var y=on(r),S=Pv(y,on(i));return mr(y,S).join("")}function XL(r,i){var u=K,y=Z;if(Ke(i)){var S="separator"in i?i.separator:S;u="length"in i?Ie(i.length):u,y="omission"in i?$t(i.omission):y}r=Fe(r);var I=r.length;if(Ao(r)){var F=on(r);I=F.length}if(u>=I)return r;var j=u-Io(y);if(j<1)return y;var X=F?mr(F,0,j).join(""):r.slice(0,j);if(S===n)return X+y;if(F&&(j+=X.length-j),Od(S)){if(r.slice(j).search(S)){var oe,ie=X;for(S.global||(S=Gf(S.source,Fe(ji.exec(S))+"g")),S.lastIndex=0;oe=S.exec(ie);)var le=oe.index;X=X.slice(0,le===n?j:le)}}else if(r.indexOf($t(S),j)!=j){var he=X.lastIndexOf(S);he>-1&&(X=X.slice(0,he))}return X+y}function qL(r){return r=Fe(r),r&&of.test(r)?r.replace(Ba,Ek):r}var KL=Lo(function(r,i,u){return r+(u?" ":"")+i.toUpperCase()}),Md=_x("toUpperCase");function ww(r,i,u){return r=Fe(r),i=u?n:i,i===n?xk(r)?Tk(r):uk(r):r.match(i)||[]}var bw=ke(function(r,i){try{return Dt(r,n,i)}catch(u){return Id(u)?u:new Te(u)}}),ZL=Un(function(r,i){return Wt(i,function(u){u=Nn(u),Wn(r,u,Td(r[u],r))}),r});function QL(r){var i=r==null?0:r.length,u=Se();return r=i?Xe(r,function(y){if(typeof y[1]!="function")throw new jt(l);return[u(y[0]),y[1]]}):[],ke(function(y){for(var S=-1;++S<i;){var I=r[S];if(Dt(I[0],this,y))return Dt(I[1],this,y)}})}function JL(r){return EM(Gt(r,g))}function Rd(r){return function(){return r}}function e$(r,i){return r==null||r!==r?i:r}var t$=Ex(),n$=Ex(!0);function Tt(r){return r}function Dd(r){return ex(typeof r=="function"?r:Gt(r,g))}function r$(r){return nx(Gt(r,g))}function o$(r,i){return rx(r,Gt(i,g))}var i$=ke(function(r,i){return function(u){return ns(u,r,i)}}),s$=ke(function(r,i){return function(u){return ns(r,u,i)}});function Ld(r,i,u){var y=ct(i),S=wl(i,y);u==null&&!(Ke(i)&&(S.length||!y.length))&&(u=i,i=r,r=this,S=wl(i,ct(i)));var I=!(Ke(u)&&"chain"in u)||!!u.chain,F=Yn(r);return Wt(S,function(j){var X=i[j];r[j]=X,F&&(r.prototype[j]=function(){var oe=this.__chain__;if(I||oe){var ie=r(this.__wrapped__),le=ie.__actions__=Et(this.__actions__);return le.push({func:X,args:arguments,thisArg:r}),ie.__chain__=oe,ie}return X.apply(r,ur([this.value()],arguments))})}),r}function a$(){return ft._===this&&(ft._=Mk),this}function $d(){}function l$(r){return r=Ie(r),ke(function(i){return ox(i,r)})}var c$=pd(Xe),u$=pd(Cv),f$=pd(Ff);function _w(r){return bd(r)?Hf(Nn(r)):zM(r)}function d$(r){return function(i){return r==null?n:Vr(r,i)}}var h$=Nx(),p$=Nx(!0);function Bd(){return[]}function Fd(){return!1}function g$(){return{}}function m$(){return""}function y$(){return!0}function v$(r,i){if(r=Ie(r),r<1||r>P)return[];var u=G,y=gt(r,G);i=Se(i),r-=G;for(var S=Wf(y,i);++u<r;)i(u);return S}function x$(r){return Ae(r)?Xe(r,Nn):Bt(r)?[r]:Et(Vx(Fe(r)))}function w$(r){var i=++Pk;return Fe(r)+i}var b$=Nl(function(r,i){return r+i},0),_$=gd("ceil"),S$=Nl(function(r,i){return r/i},1),E$=gd("floor");function C$(r){return r&&r.length?xl(r,Tt,ed):n}function N$(r,i){return r&&r.length?xl(r,Se(i,2),ed):n}function T$(r){return Av(r,Tt)}function A$(r,i){return Av(r,Se(i,2))}function I$(r){return r&&r.length?xl(r,Tt,od):n}function O$(r,i){return r&&r.length?xl(r,Se(i,2),od):n}var P$=Nl(function(r,i){return r*i},1),k$=gd("round"),M$=Nl(function(r,i){return r-i},0);function R$(r){return r&&r.length?Vf(r,Tt):0}function D$(r,i){return r&&r.length?Vf(r,Se(i,2)):0}return A.after=r2,A.ary=Jx,A.assign=j2,A.assignIn=hw,A.assignInWith=Fl,A.assignWith=U2,A.at=G2,A.before=ew,A.bind=Td,A.bindAll=ZL,A.bindKey=tw,A.castArray=g2,A.chain=Kx,A.chunk=ER,A.compact=CR,A.concat=NR,A.cond=QL,A.conforms=JL,A.constant=Rd,A.countBy=RD,A.create=Y2,A.curry=nw,A.curryRight=rw,A.debounce=ow,A.defaults=X2,A.defaultsDeep=q2,A.defer=o2,A.delay=i2,A.difference=TR,A.differenceBy=AR,A.differenceWith=IR,A.drop=OR,A.dropRight=PR,A.dropRightWhile=kR,A.dropWhile=MR,A.fill=RR,A.filter=LD,A.flatMap=FD,A.flatMapDeep=HD,A.flatMapDepth=zD,A.flatten=Gx,A.flattenDeep=DR,A.flattenDepth=LR,A.flip=s2,A.flow=t$,A.flowRight=n$,A.fromPairs=$R,A.functions=nL,A.functionsIn=rL,A.groupBy=VD,A.initial=FR,A.intersection=HR,A.intersectionBy=zR,A.intersectionWith=VR,A.invert=iL,A.invertBy=sL,A.invokeMap=jD,A.iteratee=Dd,A.keyBy=UD,A.keys=ct,A.keysIn=Nt,A.map=Ml,A.mapKeys=lL,A.mapValues=cL,A.matches=r$,A.matchesProperty=o$,A.memoize=Dl,A.merge=uL,A.mergeWith=pw,A.method=i$,A.methodOf=s$,A.mixin=Ld,A.negate=Ll,A.nthArg=l$,A.omit=fL,A.omitBy=dL,A.once=a2,A.orderBy=GD,A.over=c$,A.overArgs=l2,A.overEvery=u$,A.overSome=f$,A.partial=Ad,A.partialRight=iw,A.partition=YD,A.pick=hL,A.pickBy=gw,A.property=_w,A.propertyOf=d$,A.pull=GR,A.pullAll=Xx,A.pullAllBy=YR,A.pullAllWith=XR,A.pullAt=qR,A.range=h$,A.rangeRight=p$,A.rearg=c2,A.reject=KD,A.remove=KR,A.rest=u2,A.reverse=Cd,A.sampleSize=QD,A.set=gL,A.setWith=mL,A.shuffle=JD,A.slice=ZR,A.sortBy=n2,A.sortedUniq=oD,A.sortedUniqBy=iD,A.split=FL,A.spread=f2,A.tail=sD,A.take=aD,A.takeRight=lD,A.takeRightWhile=cD,A.takeWhile=uD,A.tap=CD,A.throttle=d2,A.thru=kl,A.toArray=uw,A.toPairs=mw,A.toPairsIn=yw,A.toPath=x$,A.toPlainObject=dw,A.transform=yL,A.unary=h2,A.union=fD,A.unionBy=dD,A.unionWith=hD,A.uniq=pD,A.uniqBy=gD,A.uniqWith=mD,A.unset=vL,A.unzip=Nd,A.unzipWith=qx,A.update=xL,A.updateWith=wL,A.values=Fo,A.valuesIn=bL,A.without=yD,A.words=ww,A.wrap=p2,A.xor=vD,A.xorBy=xD,A.xorWith=wD,A.zip=bD,A.zipObject=_D,A.zipObjectDeep=SD,A.zipWith=ED,A.entries=mw,A.entriesIn=yw,A.extend=hw,A.extendWith=Fl,Ld(A,A),A.add=b$,A.attempt=bw,A.camelCase=CL,A.capitalize=vw,A.ceil=_$,A.clamp=_L,A.clone=m2,A.cloneDeep=v2,A.cloneDeepWith=x2,A.cloneWith=y2,A.conformsTo=w2,A.deburr=xw,A.defaultTo=e$,A.divide=S$,A.endsWith=NL,A.eq=an,A.escape=TL,A.escapeRegExp=AL,A.every=DD,A.find=$D,A.findIndex=jx,A.findKey=K2,A.findLast=BD,A.findLastIndex=Ux,A.findLastKey=Z2,A.floor=E$,A.forEach=Zx,A.forEachRight=Qx,A.forIn=Q2,A.forInRight=J2,A.forOwn=eL,A.forOwnRight=tL,A.get=Pd,A.gt=b2,A.gte=_2,A.has=oL,A.hasIn=kd,A.head=Yx,A.identity=Tt,A.includes=WD,A.indexOf=BR,A.inRange=SL,A.invoke=aL,A.isArguments=Ur,A.isArray=Ae,A.isArrayBuffer=S2,A.isArrayLike=Ct,A.isArrayLikeObject=et,A.isBoolean=E2,A.isBuffer=yr,A.isDate=C2,A.isElement=N2,A.isEmpty=T2,A.isEqual=A2,A.isEqualWith=I2,A.isError=Id,A.isFinite=O2,A.isFunction=Yn,A.isInteger=sw,A.isLength=$l,A.isMap=aw,A.isMatch=P2,A.isMatchWith=k2,A.isNaN=M2,A.isNative=R2,A.isNil=L2,A.isNull=D2,A.isNumber=lw,A.isObject=Ke,A.isObjectLike=Qe,A.isPlainObject=ls,A.isRegExp=Od,A.isSafeInteger=$2,A.isSet=cw,A.isString=Bl,A.isSymbol=Bt,A.isTypedArray=Bo,A.isUndefined=B2,A.isWeakMap=F2,A.isWeakSet=H2,A.join=WR,A.kebabCase=IL,A.last=Xt,A.lastIndexOf=jR,A.lowerCase=OL,A.lowerFirst=PL,A.lt=z2,A.lte=V2,A.max=C$,A.maxBy=N$,A.mean=T$,A.meanBy=A$,A.min=I$,A.minBy=O$,A.stubArray=Bd,A.stubFalse=Fd,A.stubObject=g$,A.stubString=m$,A.stubTrue=y$,A.multiply=P$,A.nth=UR,A.noConflict=a$,A.noop=$d,A.now=Rl,A.pad=kL,A.padEnd=ML,A.padStart=RL,A.parseInt=DL,A.random=EL,A.reduce=XD,A.reduceRight=qD,A.repeat=LL,A.replace=$L,A.result=pL,A.round=k$,A.runInContext=Y,A.sample=ZD,A.size=e2,A.snakeCase=BL,A.some=t2,A.sortedIndex=QR,A.sortedIndexBy=JR,A.sortedIndexOf=eD,A.sortedLastIndex=tD,A.sortedLastIndexBy=nD,A.sortedLastIndexOf=rD,A.startCase=HL,A.startsWith=zL,A.subtract=M$,A.sum=R$,A.sumBy=D$,A.template=VL,A.times=v$,A.toFinite=Xn,A.toInteger=Ie,A.toLength=fw,A.toLower=WL,A.toNumber=qt,A.toSafeInteger=W2,A.toString=Fe,A.toUpper=jL,A.trim=UL,A.trimEnd=GL,A.trimStart=YL,A.truncate=XL,A.unescape=qL,A.uniqueId=w$,A.upperCase=KL,A.upperFirst=Md,A.each=Zx,A.eachRight=Qx,A.first=Yx,Ld(A,function(){var r={};return En(A,function(i,u){He.call(A.prototype,u)||(r[u]=i)}),r}(),{chain:!1}),A.VERSION=o,Wt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(r){A[r].placeholder=A}),Wt(["drop","take"],function(r,i){De.prototype[r]=function(u){u=u===n?1:lt(Ie(u),0);var y=this.__filtered__&&!i?new De(this):this.clone();return y.__filtered__?y.__takeCount__=gt(u,y.__takeCount__):y.__views__.push({size:gt(u,G),type:r+(y.__dir__<0?"Right":"")}),y},De.prototype[r+"Right"]=function(u){return this.reverse()[r](u).reverse()}}),Wt(["filter","map","takeWhile"],function(r,i){var u=i+1,y=u==C||u==B;De.prototype[r]=function(S){var I=this.clone();return I.__iteratees__.push({iteratee:Se(S,3),type:u}),I.__filtered__=I.__filtered__||y,I}}),Wt(["head","last"],function(r,i){var u="take"+(i?"Right":"");De.prototype[r]=function(){return this[u](1).value()[0]}}),Wt(["initial","tail"],function(r,i){var u="drop"+(i?"":"Right");De.prototype[r]=function(){return this.__filtered__?new De(this):this[u](1)}}),De.prototype.compact=function(){return this.filter(Tt)},De.prototype.find=function(r){return this.filter(r).head()},De.prototype.findLast=function(r){return this.reverse().find(r)},De.prototype.invokeMap=ke(function(r,i){return typeof r=="function"?new De(this):this.map(function(u){return ns(u,r,i)})}),De.prototype.reject=function(r){return this.filter(Ll(Se(r)))},De.prototype.slice=function(r,i){r=Ie(r);var u=this;return u.__filtered__&&(r>0||i<0)?new De(u):(r<0?u=u.takeRight(-r):r&&(u=u.drop(r)),i!==n&&(i=Ie(i),u=i<0?u.dropRight(-i):u.take(i-r)),u)},De.prototype.takeRightWhile=function(r){return this.reverse().takeWhile(r).reverse()},De.prototype.toArray=function(){return this.take(G)},En(De.prototype,function(r,i){var u=/^(?:filter|find|map|reject)|While$/.test(i),y=/^(?:head|last)$/.test(i),S=A[y?"take"+(i=="last"?"Right":""):i],I=y||/^find/.test(i);S&&(A.prototype[i]=function(){var F=this.__wrapped__,j=y?[1]:arguments,X=F instanceof De,oe=j[0],ie=X||Ae(F),le=function(Me){var $e=S.apply(A,ur([Me],j));return y&&he?$e[0]:$e};ie&&u&&typeof oe=="function"&&oe.length!=1&&(X=ie=!1);var he=this.__chain__,we=!!this.__actions__.length,Ee=I&&!he,Oe=X&&!we;if(!I&&ie){F=Oe?F:new De(this);var Ce=r.apply(F,j);return Ce.__actions__.push({func:kl,args:[le],thisArg:n}),new Ut(Ce,he)}return Ee&&Oe?r.apply(this,j):(Ce=this.thru(le),Ee?y?Ce.value()[0]:Ce.value():Ce)})}),Wt(["pop","push","shift","sort","splice","unshift"],function(r){var i=ol[r],u=/^(?:push|sort|unshift)$/.test(r)?"tap":"thru",y=/^(?:pop|shift)$/.test(r);A.prototype[r]=function(){var S=arguments;if(y&&!this.__chain__){var I=this.value();return i.apply(Ae(I)?I:[],S)}return this[u](function(F){return i.apply(Ae(F)?F:[],S)})}}),En(De.prototype,function(r,i){var u=A[i];if(u){var y=u.name+"";He.call(Mo,y)||(Mo[y]=[]),Mo[y].push({name:i,func:u})}}),Mo[Cl(n,_).name]=[{name:"wrapper",func:n}],De.prototype.clone=qk,De.prototype.reverse=Kk,De.prototype.value=Zk,A.prototype.at=ND,A.prototype.chain=TD,A.prototype.commit=AD,A.prototype.next=ID,A.prototype.plant=PD,A.prototype.reverse=kD,A.prototype.toJSON=A.prototype.valueOf=A.prototype.value=MD,A.prototype.first=A.prototype.head,qi&&(A.prototype[qi]=OD),A},Oo=Ak();$r?(($r.exports=Oo)._=Oo,Df._=Oo):ft._=Oo}).call(DT)}(bi,bi.exports)),bi.exports}var $T=LT();const BT=Vd($T);function Am(e,t,n=!0){let o;if(t?.handle){const{id:l,name:c,dataType:f,inferredDataType:d,...h}=t.handle;o=h}const s=(t?.handle?.inferredDataType||t?.handle?.dataType)&&!t?.resetInferredType?t?.handle?.inferredDataType||t?.handle?.dataType:void 0,a=BT.cloneDeep({inferredDataType:s,...t?.overrideDataType?{dataType:s}:{},...t?.handle?.dataType?.dataTypeObject&&t?.handle?.dataType?.dataTypeUniqueId&&o?o:{},...t?.overrideName&&t?.handle?.name?{name:t.handle.name}:{}});return n?(Object.assign(e,a),e):Yo(e,l=>(Object.assign(l,a),l))}function eu(e,t,n,o=!0){return o?Cm(e,s=>{s.dataType?.dataTypeUniqueId===t&&Am(s,n)}):Yo(e,s=>(Cm(s,a=>{a.dataType?.dataTypeUniqueId===t&&Am(a,n)}),s))}function FT(e,t,n,o,s,a,l,c,f){if(!a.sourceHandle||!a.targetHandle)return{validation:{isValid:!1,reason:"Source or target handle not found"}};const d=e.nodes[t].data,h=e.nodes[n].data,g=gn(o,d)?.value,p=gn(s,h)?.value,m=g?.dataType,x=p?.dataType,v=g?.inferredDataType,b=p?.inferredDataType,_=m?.dataTypeObject.underlyingType==="inferFromConnection",N=x?.dataTypeObject.underlyingType==="inferFromConnection";if(!m||!x)return{validation:{isValid:!1,reason:"Source or target handle data type not found"}};const w=!!l&&a.source===l,E=!!c&&a.target===c,O=e.openedNodeGroupStack?.[e.openedNodeGroupStack.length-1];if(!_&&!N)return{validation:{isValid:!0}};let k,M,D,V=!1,K=!1,Z=!1;if(_&&N){if(!v&&!b)return{validation:{isValid:!1,reason:"None of the handles are inferred, inference has no information to work with"}};if(v&&b)return{validation:{isValid:!0}};v?(k=n,M=x.dataTypeUniqueId,D=g,V=!1,K=E,Z=E):b&&(k=t,M=m.dataTypeUniqueId,D=p,V=!1,K=w,Z=w)}else if(_){if(v)return{validation:{isValid:!0}};k=t,M=m.dataTypeUniqueId,D=p,V=!1,K=w,Z=w}else if(N){if(b)return{validation:{isValid:!0}};k=n,M=x.dataTypeUniqueId,D=g,V=!1,K=E,Z=E}if(k===void 0||M===void 0||D===void 0)return{validation:{isValid:!1,reason:"Index of node to update, data type to infer for, or connected handle not found"}};eu(e.nodes[k].data,M,{handle:D,resetInferredType:V,overrideDataType:K,overrideName:Z});//!== is basically xor for boolean, we are checking if one is true and the other is false
|
|
87
|
-
if(O&&(_&&w)!==(N&&E)){const U=E?n:t,q=E?"input":"output",C=sa(e.dataTypes,e.nodes[U].data.nodeTypeUniqueId,e.typeOfNodes,{type:q,index1:0,index2:void 0}),H=E?p.name:g.name,B=E?p.inferredDataType?.dataTypeUniqueId:g.inferredDataType?.dataTypeUniqueId,R=E?p.inferredDataType?.dataTypeObject.allowInput:g.inferredDataType?.dataTypeObject.allowInput;if(!H||!B)return{validation:{isValid:!1,reason:"Handle to add name, data type, or allow input not found"}};if(!C)return{validation:{isValid:!1,reason:"New duplicate handle not found"}};Jc(e.nodes[U].data,{type:q,index1:-1,index2:void 0},0,C,!0,"after"),Mm(f,O.nodeType,{name:H,dataType:B,allowInput:R},{type:E?"output":"input",index1:-1,index2:void 0},"after")}return{validation:{isValid:!0}}}function HT(e,t,n,o,s,a){if(!a.sourceHandle||!a.targetHandle)return{validation:{isValid:!1,reason:"Source or target handle not found"}};const l=e.nodes[t].data,c=e.nodes[n].data,f=gn(o,l)?.value,d=gn(s,c)?.value,h=_i(f),g=_i(d);if(!h||!g)return{validation:{isValid:!1,reason:"Source or target handle data type not found"}};const p=h?.dataTypeObject.underlyingType==="complex",m=g?.dataTypeObject.underlyingType==="complex";return!p&&!m?{validation:{isValid:!0}}:p!==m?{validation:{isValid:!1,reason:"Can't connect complex types with non-complex types"}}:p&&m?h.dataTypeUniqueId===g.dataTypeUniqueId||JSON.stringify(h.dataTypeObject.complexSchema)===JSON.stringify(g.dataTypeObject.complexSchema)?{validation:{isValid:!0}}:{validation:{isValid:!1,reason:"Can't connect complex types with different types"}}:{validation:{isValid:!0}}}function zT(e,t,n,o,s,a){if(!a.sourceHandle||!a.targetHandle)return{validation:{isValid:!1,reason:"Source or target handle not found"}};const l=e.nodes[t].data,c=e.nodes[n].data,f=gn(o,l)?.value,d=gn(s,c)?.value,h=_i(f),g=_i(d);if(!h||!g)return{validation:{isValid:!1,reason:"Source or target handle data type not found"}};if(h.dataTypeUniqueId===g.dataTypeUniqueId)return{validation:{isValid:!0}};const m=e.allowedConversionsBetweenDataTypes?.[h.dataTypeUniqueId]?.[g.dataTypeUniqueId],x=h.dataTypeObject.underlyingType==="complex"&&g.dataTypeObject.underlyingType==="complex";return m||x&&e.allowConversionBetweenComplexTypesUnlessDisallowedByComplexTypeChecking?{validation:{isValid:!0}}:{validation:{isValid:!1,reason:`${h.dataTypeUniqueId} to ${g.dataTypeUniqueId} conversion is not allowed`}}}function VT(e,t,n,o,s,a){const l=e.nodes[t],c=e.nodes[n],f=gn(o,l.data)?.value,d=gn(s,c.data)?.value,h=f?.dataType,g=d?.dataType;if(!h||!g)return{updatedNodes:e.nodes,validation:{isValid:!1,reason:"Source or target handle data type not found"}};if(h.dataTypeObject.underlyingType!=="inferFromConnection"&&g.dataTypeObject.underlyingType!=="inferFromConnection")return{updatedNodes:e.nodes,validation:{isValid:!0}};let p=e.nodes;if(h.dataTypeObject.underlyingType==="inferFromConnection"){const m=Cc([l],e.edges),{inputsAndIndices:x,outputsAndIndices:v}=Dm(l.data),b={};for(const N of x)N.value.dataType?.dataTypeUniqueId===h.dataTypeUniqueId&&(b[N.value.id]=!0);for(const N of v)N.value.dataType?.dataTypeUniqueId===h.dataTypeUniqueId&&(b[N.value.id]=!0);let _=!1;for(const N of m)if(N.id!==a.id&&!(!N.sourceHandle||!N.targetHandle)){if(b[N.sourceHandle]){_=!0;break}if(b[N.targetHandle]){_=!0;break}}_||(p=[...p],p[t]={...p[t],data:eu(p[t].data,h.dataTypeUniqueId,{handle:sa(e.dataTypes,p[t].data.nodeTypeUniqueId,e.typeOfNodes,o),resetInferredType:!0})})}if(g.dataTypeObject.underlyingType==="inferFromConnection"){const m=Cc([c],e.edges),{inputsAndIndices:x,outputsAndIndices:v}=Dm(c.data),b={};for(const N of x)N.value.dataType?.dataTypeUniqueId===g.dataTypeUniqueId&&(b[N.value.id]=!0);for(const N of v)N.value.dataType?.dataTypeUniqueId===g.dataTypeUniqueId&&(b[N.value.id]=!0);let _=!1;for(const N of m)if(N.id!==a.id&&!(!N.sourceHandle||!N.targetHandle)){if(b[N.sourceHandle]){_=!0;break}if(b[N.targetHandle]){_=!0;break}}_||(p=[...p],p[n]={...p[n],data:eu(p[n].data,g.dataTypeUniqueId,{handle:sa(e.dataTypes,p[n].data.nodeTypeUniqueId,e.typeOfNodes,s),resetInferredType:!0})})}return{updatedNodes:p,validation:{isValid:!0}}}const WT=20;function Im(e,t,n,o,s,a,l,c){const f={id:un(WT),source:e,target:n,sourceHandle:t,targetHandle:o,type:"configurableEdge"};if(Wp(f,s.edges)===s.edges)return{validation:{isValid:!1,reason:"Edge already exists or was rejected by reactflow"}};if(!(s.enableTypeInference||s.enableComplexTypeChecking||s.allowedConversionsBetweenDataTypes))return s.edges.push(f),{validation:{isValid:!0}};const h=s.nodes.findIndex(_=>_.id===e),g=s.nodes.findIndex(_=>_.id===n);if(h===-1||g===-1)return{validation:{isValid:!1,reason:"Source or target node not found"}};const p=s.nodes[h],m=s.nodes[g],x=Rn(t,p.data)?.handleIndices,v=Rn(o,m.data)?.handleIndices;if(!x||!v)return{validation:{isValid:!1,reason:"Source or target handle not found"}};let b={isValid:!0};if(s.enableTypeInference){const{validation:_}=FT(s,h,g,x,v,f,a,l,c);b=_}if(s.enableComplexTypeChecking&&b.isValid){const{validation:_}=HT({...s,nodes:s.nodes},h,g,x,v,f);b=_}if(s.allowedConversionsBetweenDataTypes&&b.isValid){const{validation:_}=zT({...s,nodes:s.nodes},h,g,x,v,f);b=_}return s.edges.push(f),{validation:b}}function Om(e,t,n){if(gi([n],t.edges)===t.edges)return{updatedNodes:t.nodes,updatedEdges:t.edges,validation:{isValid:!1,reason:"Edge already exists or was rejected by reactflow"}};if(!(t.enableTypeInference||t.enableComplexTypeChecking||t.allowedConversionsBetweenDataTypes))return{updatedNodes:t.nodes,updatedEdges:gi([n],t.edges),validation:{isValid:!0}};const s=t.nodes.findIndex(p=>p.id===e.source),a=t.nodes.findIndex(p=>p.id===e.target);if(s===-1||a===-1)return{updatedNodes:t.nodes,updatedEdges:t.edges,validation:{isValid:!1,reason:"Source or target node not found"}};if(!e.sourceHandle||!e.targetHandle)return{updatedNodes:t.nodes,updatedEdges:t.edges,validation:{isValid:!1,reason:"Source or target handle not found"}};const l=t.nodes[s],c=t.nodes[a],f=Rn(e.sourceHandle,l.data)?.handleIndices,d=Rn(e.targetHandle,c.data)?.handleIndices;if(!f||!d)return{updatedNodes:t.nodes,updatedEdges:t.edges,validation:{isValid:!1,reason:"Source or target handle not found"}};let h=t.nodes,g={isValid:!0};if(t.enableTypeInference){const{updatedNodes:p,validation:m}=VT(t,s,a,f,d,e);h=p,g=m}return{updatedNodes:h,updatedEdges:gi([n],t.edges),validation:g}}function _i(e){const t=e?.dataType,n=e?.inferredDataType;if(t)return t.dataTypeObject.underlyingType!=="inferFromConnection"?t:n||void 0}function Pm(e,t,n){const o=e.nodes.find(a=>a.id===n);if(!o)return!1;if(o.id===t)return!0;const s=(a,l=new Set)=>{if(l.has(a.id))return!1;l.add(a.id);for(const c of dE(a,e.nodes,e.edges))if(c.id===t||s(c,l))return!0;return!1};return s(o)}function km(e,t,n,o,s,a){const l=[],c=[];for(const f of t.nodes){if(f.data.nodeTypeUniqueId!==n){l.push(f);continue}Jc(f.data,s,0,tr(o,e),void 0,a),l.push(f)}for(const f of t.edges)c.push(f);return{...t,nodes:l,edges:c}}function Mm(e,t,n,o,s="before"){const a=e.typeOfNodes[t];if(!a)return e;Jc(a,o,0,n,void 0,s);const l=Kc(e,t);for(const d of l){const h=e.typeOfNodes[d];h&&h.subtree&&(e.typeOfNodes[d]={...h,subtree:{...h.subtree,...km(e.dataTypes,h.subtree,t,n,o,s)}})}const{nodes:c,edges:f}=km(e.dataTypes,{nodes:e.nodes,edges:e.edges},t,n,o,s);return{typeOfNodes:e.typeOfNodes,nodes:c,edges:f}}const Si=["newGroupInput","newGroupOutput"],Ei={[Si[0]]:Si[0],[Si[1]]:Si[1]},Ci=["groupInput","groupOutput"],Ni={[Ci[0]]:Ci[0],[Ci[1]]:Ci[1]},jT={[Ei.newGroupInput]:{name:"New Group Input",underlyingType:"inferFromConnection",color:"#333333"},[Ei.newGroupOutput]:{name:"New Group Output",underlyingType:"inferFromConnection",color:"#333333"}},UT={[Ni.groupInput]:{name:"Group Input",headerColor:"#1d1d1d",inputs:[],outputs:[{name:"",dataType:Ei.newGroupInput}]},[Ni.groupOutput]:{name:"Group Output",headerColor:"#1d1d1d",inputs:[{name:"",dataType:Ei.newGroupOutput}],outputs:[]}},Ti=20,rt=["ADD_NODE","ADD_NODE_AND_SELECT","UPDATE_NODE_BY_REACT_FLOW","UPDATE_EDGES_BY_REACT_FLOW","ADD_EDGE_BY_REACT_FLOW","UPDATE_INPUT_VALUE","OPEN_NODE_GROUP","CLOSE_NODE_GROUP","ADD_NODE_GROUP","SET_VIEWPORT"],st={[rt[0]]:rt[0],[rt[1]]:rt[1],[rt[2]]:rt[2],[rt[3]]:rt[3],[rt[4]]:rt[4],[rt[5]]:rt[5],[rt[6]]:rt[6],[rt[7]]:rt[7],[rt[8]]:rt[8],[rt[9]]:rt[9]};function Rm(e,t){return Yo(e,o=>{switch(t.type){case st.ADD_NODE:const s=t.payload.type,a=un(Ti),l=t.payload.position,c=xi(o.dataTypes,s,o.typeOfNodes,a,l);o=Or(o,[...Pt(o).nodes,c]);break;case st.ADD_NODE_AND_SELECT:const f=t.payload.type,d=un(Ti),h=t.payload.position,g=xi(o.dataTypes,f,o.typeOfNodes,d,h);o=Or(o,Pt(o).nodes.map(C=>({...C,selected:!1}))),o=Or(o,[...Pt(o).nodes,{...g,selected:!0}]);break;case st.UPDATE_NODE_BY_REACT_FLOW:const p=t.payload.changes;o=Or(o,Pg(p,Pt(o).nodes));break;case st.UPDATE_EDGES_BY_REACT_FLOW:const m=t.payload.changes;for(const C of m){if(C.type!=="remove"){o=Or(o,void 0,gi([C],Pt(o).edges));continue}const{id:H}=C,B=Pt(o).edges.find(P=>P.id===H);if(!B)continue;const R=Om(B,{...o,nodes:Pt(o).nodes,edges:Pt(o).edges},C);R.validation.isValid&&(o=Or(o,R.updatedNodes,R.updatedEdges))}break;case st.ADD_EDGE_BY_REACT_FLOW:const x=t.payload.edge,{sourceHandle:v,targetHandle:b,source:_,target:N}=x,w=Pt(o);if(o.enableCycleChecking&&Pm({...o,nodes:w.nodes,edges:w.edges},_,N)||!_||!N||!v||!b)break;const E=Pt(o);if(!Im(_,v,N,b,{...o,nodes:E.nodes,edges:E.edges},E.inputNodeId,E.outputNodeId,o).validation.isValid)break;break;case st.OPEN_NODE_GROUP:if("nodeId"in t.payload){const C=t.payload.nodeId,H=Pt(o).nodes.find(P=>P.id===C);if(!H)break;const B=H.data.nodeTypeUniqueId;if(!B)break;const R=o.typeOfNodes[B];if(!R||!R.subtree)break;o.openedNodeGroupStack=[...o.openedNodeGroupStack||[],{nodeType:B,nodeId:C,previousViewport:o.viewport}]}else{const C=t.payload.nodeType,H=o.typeOfNodes[C];if(!H||!H.subtree)break;o.openedNodeGroupStack=[{nodeType:C,previousViewport:o.openedNodeGroupStack?.[0]?.previousViewport||o.viewport}]}o.viewport=void 0;break;case st.CLOSE_NODE_GROUP:const k=o.openedNodeGroupStack?.[o.openedNodeGroupStack.length-1];k&&"previousViewport"in k&&(o.viewport=k.previousViewport),o.openedNodeGroupStack=o.openedNodeGroupStack?.slice(0,-1);break;case st.ADD_NODE_GROUP:const M=un(Ti),D=un(Ti),V=xi(o.dataTypes,Ni.groupInput,o.typeOfNodes,D,{x:-500,y:0}),K=un(Ti),Z=xi(o.dataTypes,Ni.groupOutput,o.typeOfNodes,K,{x:500,y:0}),q={name:"Node Group "+(Object.keys(o.typeOfNodes).filter(C=>o.typeOfNodes[C].subtree).length+1).toString(),headerColor:"#344621",inputs:[],outputs:[],subtree:{nodes:[V,Z],edges:[],numberOfReferences:0,inputNodeId:D,outputNodeId:K}};o.typeOfNodes[M]=q,o.openedNodeGroupStack=[{nodeType:M,previousViewport:o.openedNodeGroupStack?.[0]?.previousViewport||o.viewport}],o.viewport=void 0;break;case st.SET_VIEWPORT:o.viewport=t.payload.viewport;break}})}function Rn(e,t,n=!0,o=!0){if(n){const s=t?.inputs instanceof Array?t?.inputs:[],l=Pr(s,"input").find(({value:c})=>c?.id===e);if(l)return l}if(o){const s=t?.outputs instanceof Array?t?.outputs:[],l=Pr(s,"output").find(({value:c})=>c?.id===e);if(l)return l}}function gn(e,t){if(!e)return;const n=e.type==="input"?t.inputs:t.outputs;if(!n)return;const s=Pr(n,e.type,{index1:e.index1,index2:e.index2}).next();return s.value&&s.value.handleIndices.index1===e.index1&&s.value.handleIndices.index2===e.index2?s.value:{value:void 0,handleIndices:e,parentArray:n,parentArrayIndex:s.value.parentArrayIndex}}function Dm(e,t=!0,n=!0){let o=[],s=[];return t&&e.inputs&&(o=Array.from(Pr(e.inputs,"input"))),n&&e.outputs&&(s=Array.from(Pr(e.outputs,"output"))),{inputsAndIndices:o,outputsAndIndices:s}}const tu=z.forwardRef(({id:e,sourceX:t,sourceY:n,targetX:o,targetY:s,sourcePosition:a,targetPosition:l,...c},f)=>{const[d]=qs({sourceX:t,sourceY:n,sourcePosition:a,targetX:o,targetY:s,targetPosition:l}),h=je(),[g,p]=z.useState(!0),m=z.useRef(null);z.useEffect(()=>{const M=h.getState().domNode;if(!M)return;const D=document.getElementById(e);if(!D)return;const V=new IntersectionObserver(K=>{const Z=K.find(U=>U.target.id===e);Z&&p(U=>Z.isIntersecting)},{root:M,threshold:1,rootMargin:"20px"});return V.observe(D),m.current=V,()=>{m.current&&(m.current.disconnect(),m.current=null)}},[h.getState().domNode]);const x=Yc(c.source||""),v=z.useMemo(()=>!c.source||!x?void 0:Rn(c.sourceHandleId||"",x?.data)?.value?.handleColor??"#A1A1A1",[c.source,x]),b=Yc(c.target||""),_=z.useMemo(()=>!c.target||!b?void 0:Rn(c.targetHandleId||"",b?.data)?.value?.handleColor??"#A1A1A1",[c.target,b]),{label:N,labelStyle:w,markerStart:E,markerEnd:O,interactionWidth:k}=c;return T.jsxs(T.Fragment,{children:[T.jsx("defs",{children:T.jsxs("linearGradient",{id:`linear-gradient-edge-${e}`,x1:t,y1:n,x2:o,y2:s,gradientUnits:"userSpaceOnUse",children:[T.jsx("stop",{stopColor:v,offset:"0"}),T.jsx("stop",{stopColor:_,offset:"1"})]})}),T.jsx(co,{id:e,path:d,label:N,labelStyle:w,markerEnd:O,markerStart:E,interactionWidth:k,className:Ne("!stroke-7 in-[g.selected]:brightness-150",!g&&"opacity-25"),style:{stroke:`url(#${`linear-gradient-edge-${e}`})`},focusable:!0})]})});tu.displayName="ConfigurableEdge";function Lm(e,t,n=!0,o=!1){const s=e!==null?"current"in e?e.current:e:null,a=z.useCallback(l=>{if(!s)return;let c=!0;if(n&&l.target instanceof Node&&!s.contains(l.target))c=!1;else if(o){const f="clientX"in l?{x:l.clientX,y:l.clientY}:{x:l.touches[0].clientX,y:l.touches[0].clientY},d=s.getBoundingClientRect();dh(f,d)||(c=!1)}c||t()},[s,t,n,o]);z.useEffect(()=>(document.addEventListener("mousedown",a),document.addEventListener("touchstart",a),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("touchstart",a)}),[s,a])}const Ai=z.forwardRef(({placeholder:e="Input",className:t,...n},o)=>{const s=z.useMemo(()=>n.allowOnlyNumbers&&n.value!==void 0?Yl(n.value,n.numberOfDecimals??5):n.value?.toString(),[n.value,n.allowOnlyNumbers,n.numberOfDecimals]),[a,l]=z.useState(s??""),[c,f]=z.useState(null),d=n.value??a,[h,g]=z.useState(d.toString());function p(x){n.allowOnlyNumbers&&/[^0-9\.\-]/.test(x)||g(x)}function m(){if(n.allowOnlyNumbers){const x=hh(h||d.toString()),v=Yl(x,n.numberOfDecimals??5);l(v),n.onChange?.(x),g(v)}else l(h),n.onChange?.(h),g(h)}return Lm(c,()=>m()),T.jsx("input",{type:"text",className:Ne("h-[44px] rounded-md text-primary-white bg-primary-black font-main px-4 text-[27px] leading-[27px] outline-none focus-visible:!outline-none border-secondary-dark-gray border w-max min-w-0 placeholder:text-[#6B6B6B]",t),placeholder:e,size:5,ref:x=>{f(x),typeof o=="function"?o(x):o&&(o.current=x)},value:h,onChange:x=>p(x.target.value),onKeyDown:x=>{x.key==="Enter"&&m()},onMouseMove:x=>{x.preventDefault(),x.stopPropagation()},onBlur:x=>{x.preventDefault(),x.stopPropagation(),m()}})});Ai.displayName="Input";function $m({nodeId:e,isVisible:t=!0,handleClassName:n,handleStyle:o,lineClassName:s,lineStyle:a,color:l,minWidth:c=10,minHeight:f=10,maxWidth:d=Number.MAX_VALUE,maxHeight:h=Number.MAX_VALUE,keepAspectRatio:g=!1,autoScale:p=!0,shouldResize:m,onResizeStart:x,onResize:v,onResizeEnd:b,linePosition:_=["left","right"],handlePosition:N=[],resizeDirection:w="horizontal"}){return t?T.jsxs(T.Fragment,{children:[_.map(E=>T.jsx(bm,{className:Ne("!border-none",E==="left"||E==="right"?"!w-4":"!h-4",s),style:a,nodeId:e,position:E,variant:Ar.Line,color:l,minWidth:c,minHeight:f,maxWidth:d,maxHeight:h,onResizeStart:x,keepAspectRatio:g,autoScale:p,shouldResize:m,onResize:v,onResizeEnd:b,resizeDirection:w},E)),N.map(E=>T.jsx(bm,{className:n,style:o,nodeId:e,position:E,color:l,minWidth:c,minHeight:f,maxWidth:d,maxHeight:h,onResizeStart:x,keepAspectRatio:g,autoScale:p,shouldResize:m,onResize:v,onResizeEnd:b,resizeDirection:w},E))]}):null}/**
|
|
87
|
+
if(O&&(_&&w)!==(N&&E)){const U=E?n:t,q=E?"input":"output",C=sa(e.dataTypes,e.nodes[U].data.nodeTypeUniqueId,e.typeOfNodes,{type:q,index1:0,index2:void 0}),H=E?p.name:g.name,B=E?p.inferredDataType?.dataTypeUniqueId:g.inferredDataType?.dataTypeUniqueId,R=E?p.inferredDataType?.dataTypeObject.allowInput:g.inferredDataType?.dataTypeObject.allowInput;if(!H||!B)return{validation:{isValid:!1,reason:"Handle to add name, data type, or allow input not found"}};if(!C)return{validation:{isValid:!1,reason:"New duplicate handle not found"}};Jc(e.nodes[U].data,{type:q,index1:-1,index2:void 0},0,C,!0,"after"),Mm(f,O.nodeType,{name:H,dataType:B,allowInput:R},{type:E?"output":"input",index1:-1,index2:void 0},"after")}return{validation:{isValid:!0}}}function HT(e,t,n,o,s,a){if(!a.sourceHandle||!a.targetHandle)return{validation:{isValid:!1,reason:"Source or target handle not found"}};const l=e.nodes[t].data,c=e.nodes[n].data,f=gn(o,l)?.value,d=gn(s,c)?.value,h=_i(f),g=_i(d);if(!h||!g)return{validation:{isValid:!1,reason:"Source or target handle data type not found"}};const p=h?.dataTypeObject.underlyingType==="complex",m=g?.dataTypeObject.underlyingType==="complex";return!p&&!m?{validation:{isValid:!0}}:p!==m?{validation:{isValid:!1,reason:"Can't connect complex types with non-complex types"}}:p&&m?h.dataTypeUniqueId===g.dataTypeUniqueId||JSON.stringify(h.dataTypeObject.complexSchema)===JSON.stringify(g.dataTypeObject.complexSchema)?{validation:{isValid:!0}}:{validation:{isValid:!1,reason:"Can't connect complex types with different types"}}:{validation:{isValid:!0}}}function zT(e,t,n,o,s,a){if(!a.sourceHandle||!a.targetHandle)return{validation:{isValid:!1,reason:"Source or target handle not found"}};const l=e.nodes[t].data,c=e.nodes[n].data,f=gn(o,l)?.value,d=gn(s,c)?.value,h=_i(f),g=_i(d);if(!h||!g)return{validation:{isValid:!1,reason:"Source or target handle data type not found"}};if(h.dataTypeUniqueId===g.dataTypeUniqueId)return{validation:{isValid:!0}};const m=e.allowedConversionsBetweenDataTypes?.[h.dataTypeUniqueId]?.[g.dataTypeUniqueId],x=h.dataTypeObject.underlyingType==="complex"&&g.dataTypeObject.underlyingType==="complex";return m||x&&e.allowConversionBetweenComplexTypesUnlessDisallowedByComplexTypeChecking?{validation:{isValid:!0}}:{validation:{isValid:!1,reason:`${h.dataTypeUniqueId} to ${g.dataTypeUniqueId} conversion is not allowed`}}}function VT(e,t,n,o,s,a){const l=e.nodes[t],c=e.nodes[n],f=gn(o,l.data)?.value,d=gn(s,c.data)?.value,h=f?.dataType,g=d?.dataType;if(!h||!g)return{updatedNodes:e.nodes,validation:{isValid:!1,reason:"Source or target handle data type not found"}};if(h.dataTypeObject.underlyingType!=="inferFromConnection"&&g.dataTypeObject.underlyingType!=="inferFromConnection")return{updatedNodes:e.nodes,validation:{isValid:!0}};let p=e.nodes;if(h.dataTypeObject.underlyingType==="inferFromConnection"){const m=Cc([l],e.edges),{inputsAndIndices:x,outputsAndIndices:v}=Dm(l.data),b={};for(const N of x)N.value.dataType?.dataTypeUniqueId===h.dataTypeUniqueId&&(b[N.value.id]=!0);for(const N of v)N.value.dataType?.dataTypeUniqueId===h.dataTypeUniqueId&&(b[N.value.id]=!0);let _=!1;for(const N of m)if(N.id!==a.id&&!(!N.sourceHandle||!N.targetHandle)){if(b[N.sourceHandle]){_=!0;break}if(b[N.targetHandle]){_=!0;break}}_||(p=[...p],p[t]={...p[t],data:eu(p[t].data,h.dataTypeUniqueId,{handle:sa(e.dataTypes,p[t].data.nodeTypeUniqueId,e.typeOfNodes,o),resetInferredType:!0})})}if(g.dataTypeObject.underlyingType==="inferFromConnection"){const m=Cc([c],e.edges),{inputsAndIndices:x,outputsAndIndices:v}=Dm(c.data),b={};for(const N of x)N.value.dataType?.dataTypeUniqueId===g.dataTypeUniqueId&&(b[N.value.id]=!0);for(const N of v)N.value.dataType?.dataTypeUniqueId===g.dataTypeUniqueId&&(b[N.value.id]=!0);let _=!1;for(const N of m)if(N.id!==a.id&&!(!N.sourceHandle||!N.targetHandle)){if(b[N.sourceHandle]){_=!0;break}if(b[N.targetHandle]){_=!0;break}}_||(p=[...p],p[n]={...p[n],data:eu(p[n].data,g.dataTypeUniqueId,{handle:sa(e.dataTypes,p[n].data.nodeTypeUniqueId,e.typeOfNodes,s),resetInferredType:!0})})}return{updatedNodes:p,validation:{isValid:!0}}}const WT=20;function Im(e,t,n,o,s,a,l,c){const f={id:un(WT),source:e,target:n,sourceHandle:t,targetHandle:o,type:"configurableEdge"};if(Wp(f,s.edges)===s.edges)return{validation:{isValid:!1,reason:"Edge already exists or was rejected by reactflow"}};if(!(s.enableTypeInference||s.enableComplexTypeChecking||s.allowedConversionsBetweenDataTypes))return s.edges.push(f),{validation:{isValid:!0}};const h=s.nodes.findIndex(_=>_.id===e),g=s.nodes.findIndex(_=>_.id===n);if(h===-1||g===-1)return{validation:{isValid:!1,reason:"Source or target node not found"}};const p=s.nodes[h],m=s.nodes[g],x=Rn(t,p.data)?.handleIndices,v=Rn(o,m.data)?.handleIndices;if(!x||!v)return{validation:{isValid:!1,reason:"Source or target handle not found"}};let b={isValid:!0};if(s.enableTypeInference){const{validation:_}=FT(s,h,g,x,v,f,a,l,c);b=_}if(s.enableComplexTypeChecking&&b.isValid){const{validation:_}=HT({...s,nodes:s.nodes},h,g,x,v,f);b=_}if(s.allowedConversionsBetweenDataTypes&&b.isValid){const{validation:_}=zT({...s,nodes:s.nodes},h,g,x,v,f);b=_}return b.isValid?(s.edges.push(f),{validation:b}):{validation:b}}function Om(e,t,n){if(gi([n],t.edges)===t.edges)return{updatedNodes:t.nodes,updatedEdges:t.edges,validation:{isValid:!1,reason:"Edge already exists or was rejected by reactflow"}};if(!(t.enableTypeInference||t.enableComplexTypeChecking||t.allowedConversionsBetweenDataTypes))return{updatedNodes:t.nodes,updatedEdges:gi([n],t.edges),validation:{isValid:!0}};const s=t.nodes.findIndex(p=>p.id===e.source),a=t.nodes.findIndex(p=>p.id===e.target);if(s===-1||a===-1)return{updatedNodes:t.nodes,updatedEdges:t.edges,validation:{isValid:!1,reason:"Source or target node not found"}};if(!e.sourceHandle||!e.targetHandle)return{updatedNodes:t.nodes,updatedEdges:t.edges,validation:{isValid:!1,reason:"Source or target handle not found"}};const l=t.nodes[s],c=t.nodes[a],f=Rn(e.sourceHandle,l.data)?.handleIndices,d=Rn(e.targetHandle,c.data)?.handleIndices;if(!f||!d)return{updatedNodes:t.nodes,updatedEdges:t.edges,validation:{isValid:!1,reason:"Source or target handle not found"}};let h=t.nodes,g={isValid:!0};if(t.enableTypeInference){const{updatedNodes:p,validation:m}=VT(t,s,a,f,d,e);h=p,g=m}return{updatedNodes:h,updatedEdges:gi([n],t.edges),validation:g}}function _i(e){const t=e?.dataType,n=e?.inferredDataType;if(t)return t.dataTypeObject.underlyingType!=="inferFromConnection"?t:n||void 0}function Pm(e,t,n){const o=e.nodes.find(a=>a.id===n);if(!o)return!1;if(o.id===t)return!0;const s=(a,l=new Set)=>{if(l.has(a.id))return!1;l.add(a.id);for(const c of dE(a,e.nodes,e.edges))if(c.id===t||s(c,l))return!0;return!1};return s(o)}function km(e,t,n,o,s,a){const l=[],c=[];for(const f of t.nodes){if(f.data.nodeTypeUniqueId!==n){l.push(f);continue}Jc(f.data,s,0,tr(o,e),void 0,a),l.push(f)}for(const f of t.edges)c.push(f);return{...t,nodes:l,edges:c}}function Mm(e,t,n,o,s="before"){const a=e.typeOfNodes[t];if(!a)return e;Jc(a,o,0,n,void 0,s);const l=Kc(e,t);for(const d of l){const h=e.typeOfNodes[d];h&&h.subtree&&(e.typeOfNodes[d]={...h,subtree:{...h.subtree,...km(e.dataTypes,h.subtree,t,n,o,s)}})}const{nodes:c,edges:f}=km(e.dataTypes,{nodes:e.nodes,edges:e.edges},t,n,o,s);return{typeOfNodes:e.typeOfNodes,nodes:c,edges:f}}const Si=["newGroupInput","newGroupOutput"],Ei={[Si[0]]:Si[0],[Si[1]]:Si[1]},Ci=["groupInput","groupOutput"],Ni={[Ci[0]]:Ci[0],[Ci[1]]:Ci[1]},jT={[Ei.newGroupInput]:{name:"New Group Input",underlyingType:"inferFromConnection",color:"#333333"},[Ei.newGroupOutput]:{name:"New Group Output",underlyingType:"inferFromConnection",color:"#333333"}},UT={[Ni.groupInput]:{name:"Group Input",headerColor:"#1d1d1d",inputs:[],outputs:[{name:"",dataType:Ei.newGroupInput}]},[Ni.groupOutput]:{name:"Group Output",headerColor:"#1d1d1d",inputs:[{name:"",dataType:Ei.newGroupOutput}],outputs:[]}},Ti=20,rt=["ADD_NODE","ADD_NODE_AND_SELECT","UPDATE_NODE_BY_REACT_FLOW","UPDATE_EDGES_BY_REACT_FLOW","ADD_EDGE_BY_REACT_FLOW","UPDATE_INPUT_VALUE","OPEN_NODE_GROUP","CLOSE_NODE_GROUP","ADD_NODE_GROUP","SET_VIEWPORT"],st={[rt[0]]:rt[0],[rt[1]]:rt[1],[rt[2]]:rt[2],[rt[3]]:rt[3],[rt[4]]:rt[4],[rt[5]]:rt[5],[rt[6]]:rt[6],[rt[7]]:rt[7],[rt[8]]:rt[8],[rt[9]]:rt[9]};function Rm(e,t){return Yo(e,o=>{switch(t.type){case st.ADD_NODE:const s=t.payload.type,a=un(Ti),l=t.payload.position,c=xi(o.dataTypes,s,o.typeOfNodes,a,l);o=Or(o,[...Pt(o).nodes,c]);break;case st.ADD_NODE_AND_SELECT:const f=t.payload.type,d=un(Ti),h=t.payload.position,g=xi(o.dataTypes,f,o.typeOfNodes,d,h);o=Or(o,Pt(o).nodes.map(C=>({...C,selected:!1}))),o=Or(o,[...Pt(o).nodes,{...g,selected:!0}]);break;case st.UPDATE_NODE_BY_REACT_FLOW:const p=t.payload.changes;o=Or(o,Pg(p,Pt(o).nodes));break;case st.UPDATE_EDGES_BY_REACT_FLOW:const m=t.payload.changes;for(const C of m){if(C.type!=="remove"){o=Or(o,void 0,gi([C],Pt(o).edges));continue}const{id:H}=C,B=Pt(o).edges.find(P=>P.id===H);if(!B)continue;const R=Om(B,{...o,nodes:Pt(o).nodes,edges:Pt(o).edges},C);R.validation.isValid&&(o=Or(o,R.updatedNodes,R.updatedEdges))}break;case st.ADD_EDGE_BY_REACT_FLOW:const x=t.payload.edge,{sourceHandle:v,targetHandle:b,source:_,target:N}=x,w=Pt(o);if(o.enableCycleChecking&&Pm({...o,nodes:w.nodes,edges:w.edges},_,N)||!_||!N||!v||!b)break;const E=Pt(o);if(!Im(_,v,N,b,{...o,nodes:E.nodes,edges:E.edges},E.inputNodeId,E.outputNodeId,o).validation.isValid)break;break;case st.OPEN_NODE_GROUP:if("nodeId"in t.payload){const C=t.payload.nodeId,H=Pt(o).nodes.find(P=>P.id===C);if(!H)break;const B=H.data.nodeTypeUniqueId;if(!B)break;const R=o.typeOfNodes[B];if(!R||!R.subtree)break;o.openedNodeGroupStack=[...o.openedNodeGroupStack||[],{nodeType:B,nodeId:C,previousViewport:o.viewport}]}else{const C=t.payload.nodeType,H=o.typeOfNodes[C];if(!H||!H.subtree)break;o.openedNodeGroupStack=[{nodeType:C,previousViewport:o.openedNodeGroupStack?.[0]?.previousViewport||o.viewport}]}o.viewport=void 0;break;case st.CLOSE_NODE_GROUP:const k=o.openedNodeGroupStack?.[o.openedNodeGroupStack.length-1];k&&"previousViewport"in k&&(o.viewport=k.previousViewport),o.openedNodeGroupStack=o.openedNodeGroupStack?.slice(0,-1);break;case st.ADD_NODE_GROUP:const M=un(Ti),D=un(Ti),V=xi(o.dataTypes,Ni.groupInput,o.typeOfNodes,D,{x:-500,y:0}),K=un(Ti),Z=xi(o.dataTypes,Ni.groupOutput,o.typeOfNodes,K,{x:500,y:0}),q={name:"Node Group "+(Object.keys(o.typeOfNodes).filter(C=>o.typeOfNodes[C].subtree).length+1).toString(),headerColor:"#344621",inputs:[],outputs:[],subtree:{nodes:[V,Z],edges:[],numberOfReferences:0,inputNodeId:D,outputNodeId:K}};o.typeOfNodes[M]=q,o.openedNodeGroupStack=[{nodeType:M,previousViewport:o.openedNodeGroupStack?.[0]?.previousViewport||o.viewport}],o.viewport=void 0;break;case st.SET_VIEWPORT:o.viewport=t.payload.viewport;break}})}function Rn(e,t,n=!0,o=!0){if(n){const s=t?.inputs instanceof Array?t?.inputs:[],l=Pr(s,"input").find(({value:c})=>c?.id===e);if(l)return l}if(o){const s=t?.outputs instanceof Array?t?.outputs:[],l=Pr(s,"output").find(({value:c})=>c?.id===e);if(l)return l}}function gn(e,t){if(!e)return;const n=e.type==="input"?t.inputs:t.outputs;if(!n)return;const s=Pr(n,e.type,{index1:e.index1,index2:e.index2}).next();return s.value&&s.value.handleIndices.index1===e.index1&&s.value.handleIndices.index2===e.index2?s.value:{value:void 0,handleIndices:e,parentArray:n,parentArrayIndex:s.value.parentArrayIndex}}function Dm(e,t=!0,n=!0){let o=[],s=[];return t&&e.inputs&&(o=Array.from(Pr(e.inputs,"input"))),n&&e.outputs&&(s=Array.from(Pr(e.outputs,"output"))),{inputsAndIndices:o,outputsAndIndices:s}}const tu=z.forwardRef(({id:e,sourceX:t,sourceY:n,targetX:o,targetY:s,sourcePosition:a,targetPosition:l,...c},f)=>{const[d]=qs({sourceX:t,sourceY:n,sourcePosition:a,targetX:o,targetY:s,targetPosition:l}),h=je(),[g,p]=z.useState(!0),m=z.useRef(null);z.useEffect(()=>{const M=h.getState().domNode;if(!M)return;const D=document.getElementById(e);if(!D)return;const V=new IntersectionObserver(K=>{const Z=K.find(U=>U.target.id===e);Z&&p(U=>Z.isIntersecting)},{root:M,threshold:1,rootMargin:"20px"});return V.observe(D),m.current=V,()=>{m.current&&(m.current.disconnect(),m.current=null)}},[h.getState().domNode]);const x=Yc(c.source||""),v=z.useMemo(()=>!c.source||!x?void 0:Rn(c.sourceHandleId||"",x?.data)?.value?.handleColor??"#A1A1A1",[c.source,x]),b=Yc(c.target||""),_=z.useMemo(()=>!c.target||!b?void 0:Rn(c.targetHandleId||"",b?.data)?.value?.handleColor??"#A1A1A1",[c.target,b]),{label:N,labelStyle:w,markerStart:E,markerEnd:O,interactionWidth:k}=c;return T.jsxs(T.Fragment,{children:[T.jsx("defs",{children:T.jsxs("linearGradient",{id:`linear-gradient-edge-${e}`,x1:t,y1:n,x2:o,y2:s,gradientUnits:"userSpaceOnUse",children:[T.jsx("stop",{stopColor:v,offset:"0"}),T.jsx("stop",{stopColor:_,offset:"1"})]})}),T.jsx(co,{id:e,path:d,label:N,labelStyle:w,markerEnd:O,markerStart:E,interactionWidth:k,className:Ne("!stroke-7 in-[g.selected]:brightness-150",!g&&"opacity-25"),style:{stroke:`url(#${`linear-gradient-edge-${e}`})`},focusable:!0})]})});tu.displayName="ConfigurableEdge";function Lm(e,t,n=!0,o=!1){const s=e!==null?"current"in e?e.current:e:null,a=z.useCallback(l=>{if(!s)return;let c=!0;if(n&&l.target instanceof Node&&!s.contains(l.target))c=!1;else if(o){const f="clientX"in l?{x:l.clientX,y:l.clientY}:{x:l.touches[0].clientX,y:l.touches[0].clientY},d=s.getBoundingClientRect();dh(f,d)||(c=!1)}c||t()},[s,t,n,o]);z.useEffect(()=>(document.addEventListener("mousedown",a),document.addEventListener("touchstart",a),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("touchstart",a)}),[s,a])}const Ai=z.forwardRef(({placeholder:e="Input",className:t,...n},o)=>{const s=z.useMemo(()=>n.allowOnlyNumbers&&n.value!==void 0?Yl(n.value,n.numberOfDecimals??5):n.value?.toString(),[n.value,n.allowOnlyNumbers,n.numberOfDecimals]),[a,l]=z.useState(s??""),[c,f]=z.useState(null),d=n.value??a,[h,g]=z.useState(d.toString());function p(x){n.allowOnlyNumbers&&/[^0-9\.\-]/.test(x)||g(x)}function m(){if(n.allowOnlyNumbers){const x=hh(h||d.toString()),v=Yl(x,n.numberOfDecimals??5);l(v),n.onChange?.(x),g(v)}else l(h),n.onChange?.(h),g(h)}return Lm(c,()=>m()),T.jsx("input",{type:"text",className:Ne("h-[44px] rounded-md text-primary-white bg-primary-black font-main px-4 text-[27px] leading-[27px] outline-none focus-visible:!outline-none border-secondary-dark-gray border w-max min-w-0 placeholder:text-[#6B6B6B]",t),placeholder:e,size:5,ref:x=>{f(x),typeof o=="function"?o(x):o&&(o.current=x)},value:h,onChange:x=>p(x.target.value),onKeyDown:x=>{x.key==="Enter"&&m()},onMouseMove:x=>{x.preventDefault(),x.stopPropagation()},onBlur:x=>{x.preventDefault(),x.stopPropagation(),m()}})});Ai.displayName="Input";function $m({nodeId:e,isVisible:t=!0,handleClassName:n,handleStyle:o,lineClassName:s,lineStyle:a,color:l,minWidth:c=10,minHeight:f=10,maxWidth:d=Number.MAX_VALUE,maxHeight:h=Number.MAX_VALUE,keepAspectRatio:g=!1,autoScale:p=!0,shouldResize:m,onResizeStart:x,onResize:v,onResizeEnd:b,linePosition:_=["left","right"],handlePosition:N=[],resizeDirection:w="horizontal"}){return t?T.jsxs(T.Fragment,{children:[_.map(E=>T.jsx(bm,{className:Ne("!border-none",E==="left"||E==="right"?"!w-4":"!h-4",s),style:a,nodeId:e,position:E,variant:Ar.Line,color:l,minWidth:c,minHeight:f,maxWidth:d,maxHeight:h,onResizeStart:x,keepAspectRatio:g,autoScale:p,shouldResize:m,onResize:v,onResizeEnd:b,resizeDirection:w},E)),N.map(E=>T.jsx(bm,{className:n,style:o,nodeId:e,position:E,color:l,minWidth:c,minHeight:f,maxWidth:d,maxHeight:h,onResizeStart:x,keepAspectRatio:g,autoScale:p,shouldResize:m,onResize:v,onResizeEnd:b,resizeDirection:w},E))]}):null}/**
|
|
88
88
|
* @license lucide-react v0.542.0 - ISC
|
|
89
89
|
*
|
|
90
90
|
* This source code is licensed under the ISC license.
|