import{j as e,$ as u,b$ as d,bG as A,b7 as _,r as p,gL as F,gM as D,gN as k,gO as I,gP as R,gQ as L,L as T,f as P,cN as W,A as M,gR as E,al as B,bL as H,bM as z,U as G}from"./index-Cc-6WbPt.js";import{H as f,P as j,M as C,R as U,a as q,C as V}from"./index-RxMbRJol.js";import{s as y}from"./splitAt-M1OTtC4J.js";import{p as Q}from"./project-BdhY6ntx.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(A,{children:t.value.name})}),e.jsx(d.Cell,{sx:{display:"flex",justifyContent:"end",pt:"16px"},children:e.jsx(_,{children:t.value.type})})]})})}),e.jsx(f,{type:r?"source":"target",position:r?j.Right:j.Left,draggable:!1})]})},X=300,K=({data:t})=>e.jsx(u,{sx:{width:`${X}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[a,i]=p.useState(!1),s=()=>{i(n=>!n)};return e.jsx(u,{...r,children:e.jsxs(F,{isOpen:a,onClose:s,placement:"left",children:[e.jsx(D,{children:e.jsx("div",{style:{margin:"0px"},children:e.jsxs(k,{onClick:()=>i(!0),children:["... view all ",t.length," features"]})})}),e.jsxs(I,{children:[e.jsx(R,{mt:"7px"}),e.jsx(L,{p:"0",children:e.jsx(T,{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(P,{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(W,{title:t.title,readOnly:!0,copyButton:!0,downloadButton:!0,width:"100%",height:"100%",label:"Transformation snippet (Python)",language:"python",content:t.content})})}),e.jsx(f,{type:"target",position:j.Left,isConnectableEnd:!0}),e.jsx(f,{type:"source",position:j.Right,isConnectableEnd:!0})]}),v=2,te=4,b=(t,r)=>{if(t.length<=v+1)return t;const[a,i]=y(v,t),[s,n]=y(i.length-te,i);return[...a,...s.length>0?[{nodeType:"CollapsedNodes",nodeNamesAndTypes:Q(["name","type"],s),name:`collapsed-${r}`}]:[],...n]},se=(t,r)=>{if(!r)return t;const a=t.findIndex(M("name",r)),[i,[s,...n]]=y(a,t),c=b(n,"after");return[...E(b(E(i),"before")),s,...c]},oe={FeatureAndType:J,SourceCode:ee,CollapsedNodes:K},m=150,re=({hopsworksUdf:{name:t,sourceCode:r},inputs:a,outputs:i,featureName:s})=>{const{colorMode:n}=B(),c=(m+g)*2+w,x=p.useMemo(()=>se(i,s),[i,s]),$=p.useMemo(()=>[...a.map(({name:o="",type:l=""},h)=>({id:`input-${o||l}`,position:{x:0,y:h*49},data:{label:"input",value:{name:o,type:l,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:l="",nodeType:h,nodeNamesAndTypes:O},S)=>({id:`output-${o||l}`,position:{x:m*2+w+g,y:S*49},data:{label:"output",value:{name:o,type:l,nodeType:h,nodeNamesAndTypes:O,activeFeature:s===o,featureLess:!s}},type:h??"FeatureAndType"})))],[a,x,s,r,t]),N=p.useMemo(()=>[...a.map(({name:o="",type:l=""},h)=>({id:`to-source${o||l}`,source:`input-${o||l}`,target:"source_code",markerEnd:{type:C.ArrowClosed},...o===s?{style:{strokeWidth:5,stroke:`var(--quartz-colors-primaryShade2-_${n})`}}:{}})),...x.map(({name:o="",type:l=""})=>({id:`from-source-${o||l}`,source:"source_code",target:`output-${o||l}`,markerEnd:{type:C.ArrowClosed},...o===s?{style:{strokeWidth:5,stroke:`var(--quartz-colors-primaryShade2-_${n})`}}:{}}))],[a,x,s,n]);return e.jsx(T,{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};
