import{j as e,a as u,b$ as d,bG as O,b7 as _,r as p,gQ as D,gR as F,gS as I,gT as k,gU as R,gV as W,L as b,f as L,cN as P,A as B,gW as E,al as M,bL as H,bM as z,T as G}from"./index-_eM6l4Nf.js";import{H as y,P as j,M as C,R as U,a as q,C as V}from"./index-E_WbQbNt.js";import{s as f}from"./splitAt-BNOQKbGd.js";import{p as Q}from"./project-CRArgp9U.js";const g=300,J=({data:t})=>{const r=t.label==="input";return e.jsxs(e.Fragment,{children:[e.jsx(u,{children:e.jsx(d,{legend:[],hoverable:!1,bordered:!0,standalone:!0,sx:{width:`${g}px`},children:e.jsxs(d.Row,{sx:{bg:t.value.activeFeature?"primaryShade2":"white"},children:[t.value.name&&e.jsx(d.Cell,{children:e.jsx(O,{children:t.value.name})}),e.jsx(d.Cell,{sx:{display:"flex",justifyContent:"end",pt:"16px"},children:e.jsx(_,{children:t.value.type})})]})})}),e.jsx(y,{type:r?"source":"target",position:r?j.Right:j.Left,draggable:!1})]})},K=300,X=({data:t})=>e.jsx(u,{sx:{width:`${K}px`,mt:"12px",bg:"white"},children:e.jsx(Z,{withoutInitialFeature:!0,listData:t.value.nodeNamesAndTypes,onWheelCapture:r=>{r.stopPropagation()},sx:{overflow:"auto"}})}),Y=({listData:t,...r})=>{const[l,i]=p.useState(!1),s=()=>{i(n=>!n)};return e.jsx(u,{...r,children:e.jsxs(D,{isOpen:l,onClose:s,placement:"left",children:[e.jsx(F,{children:e.jsx("div",{style:{margin:"0px"},children:e.jsxs(I,{onClick:()=>i(!0),children:["... view all ",t.length," features"]})})}),e.jsxs(k,{children:[e.jsx(R,{mt:"7px"}),e.jsx(W,{p:"0",children:e.jsx(b,{maxHeight:"300px",overflow:"auto",bg:"white",children:e.jsx(d,{standalone:!0,padded:!1,children:t.map(({name:n,type:c})=>e.jsxs(d.Row,{fontSize:"12px",p:"4px",sx:{p:"4px !important"},children:[e.jsx(d.Cell,{children:e.jsx(L,{children:n})}),c&&e.jsx(d.Cell,{sx:{display:"flex",justifyContent:"end",pt:"16px"},children:e.jsx(_,{children:c})})]},n))})})})]})]})})},Z=p.memo(Y),w=750,ee=({data:t})=>e.jsxs(e.Fragment,{children:[e.jsx(u,{flexDirection:"column",height:"100%",flexGrow:1,children:e.jsx(u,{flexGrow:1,width:`${w}px`,children:e.jsx(P,{title:t.title,readOnly:!0,copyButton:!0,downloadButton:!0,width:"100%",height:"100%",label:"Transformation snippet (Python)",language:"python",content:t.content})})}),e.jsx(y,{type:"target",position:j.Left,isConnectableEnd:!0}),e.jsx(y,{type:"source",position:j.Right,isConnectableEnd:!0})]}),v=2,te=4,T=(t,r)=>{if(t.length<=v+1)return t;const[l,i]=f(v,t),[s,n]=f(i.length-te,i);return[...l,...s.length>0?[{nodeType:"CollapsedNodes",nodeNamesAndTypes:Q(["name","type"],s),name:`collapsed-${r}`}]:[],...n]},se=(t,r)=>{if(!r)return t;const l=t.findIndex(B("name",r)),[i,[s,...n]]=f(l,t),c=T(n,"after");return[...E(T(E(i),"before")),s,...c]},oe={FeatureAndType:J,SourceCode:ee,CollapsedNodes:X},m=150,re=({hopsworksUdf:{name:t,sourceCode:r},inputs:l,outputs:i,featureName:s})=>{const{colorMode:n}=M(),c=(m+g)*2+w,x=p.useMemo(()=>se(i,s),[i,s]),$=p.useMemo(()=>[...l.map(({name:o="",type:a=""},h)=>({id:`input-${o||a}`,position:{x:0,y:h*49},data:{label:"input",value:{name:o,type:a,activeFeature:s===o,featureLess:!s}},type:"FeatureAndType"})),{id:"source_code",position:{x:m+g,y:0},data:{label:"source_code",content:r,title:`${t}.py`},type:"SourceCode"},...H(z(G("type")),x.map(({name:o="",type:a="",nodeType:h,nodeNamesAndTypes:S},A)=>({id:`output-${o||a}`,position:{x:m*2+w+g,y:A*49},data:{label:"output",value:{name:o,type:a,nodeType:h,nodeNamesAndTypes:S,activeFeature:s===o,featureLess:!s}},type:h??"FeatureAndType"})))],[l,x,s,r,t]),N=p.useMemo(()=>[...l.map(({name:o="",type:a=""},h)=>({id:`to-source${o||a}`,source:`input-${o||a}`,target:"source_code",markerEnd:{type:C.ArrowClosed},...o===s?{style:{strokeWidth:5,stroke:`var(--quartz-colors-primaryShade2-_${n})`}}:{}})),...x.map(({name:o="",type:a=""})=>({id:`from-source-${o||a}`,source:"source_code",target:`output-${o||a}`,markerEnd:{type:C.ArrowClosed},...o===s?{style:{strokeWidth:5,stroke:`var(--quartz-colors-primaryShade2-_${n})`}}:{}}))],[l,x,s,n]);return e.jsx(b,{width:"100%",height:"100%",mt:"20px",sx:{".react-flow__attribution":{bg:"white",bottom:"20px"}},children:e.jsx(U,{children:e.jsx(q,{nodes:$,edges:N,nodeTypes:oe,defaultEdgeOptions:ne,onInit:o=>{setTimeout(()=>{o.fitBounds({x:0,y:0,width:c,height:1e3},{padding:.1})})},children:e.jsx(V,{})})})})},ne={style:{strokeWidth:2.5,stroke:"var(--quartz-colors-grayShade2)",zIndex:10}},ce=p.memo(re);export{ce as V};
