import{j as e,q as x,cc as i,bl as A,b8 as S,r as p,hL as k,hM as I,gS as R,hN as M,hO as P,hP as B,F as T,d as W,bU as q,D as H,hQ as w,aj as U,hR as z,hS as L,bZ as G,b_ as V,Q,c as J}from"./index-Cox3ZWL0.js";import{H as f,P as j,M as E,R as X,b as Z,B as K}from"./index-Ck37e_Tb.js";import{s as y}from"./splitAt-B2oa5W04.js";import{p as Y}from"./project-BhVxAOrV.js";import{C as ee}from"./index-Dnj59z1-.js";const m=300,se=({data:s})=>{const n=s.label==="input";return e.jsxs(e.Fragment,{children:[e.jsx(x,{children:e.jsx(i,{legend:[],hoverable:!1,bordered:!0,standalone:!0,sx:{width:`${m}px`},children:e.jsxs(i.Row,{sx:{bg:s.value.activeFeature?"primaryShade2":"white"},children:[s.value.name&&e.jsx(i.Cell,{children:e.jsx(A,{children:s.value.name})}),e.jsx(i.Cell,{sx:{display:"flex",justifyContent:"end",pt:"16px"},children:e.jsx(S,{children:s.value.type})})]})})}),e.jsx(f,{type:n?"source":"target",position:n?j.Right:j.Left,draggable:!1})]})},te=300,oe=({data:s})=>e.jsx(x,{sx:{width:`${te}px`,mt:"12px",bg:"white"},children:e.jsx(re,{withoutInitialFeature:!0,listData:s.value.nodeNamesAndTypes,onWheelCapture:n=>{n.stopPropagation()},sx:{overflow:"auto"}})}),ne=({listData:s,...n})=>{const[l,d]=p.useState(!1),t=()=>{d(r=>!r)};return e.jsx(x,{...n,children:e.jsxs(k,{isOpen:l,onClose:t,placement:"left",children:[e.jsx(I,{children:e.jsx("div",{style:{margin:"0px"},children:e.jsxs(R,{onClick:()=>d(!0),children:["... view all ",s.length," features"]})})}),e.jsxs(M,{children:[e.jsx(P,{mt:"7px"}),e.jsx(B,{p:"0",children:e.jsx(T,{maxHeight:"300px",overflow:"auto",bg:"white",children:e.jsx(i,{standalone:!0,padded:!1,children:s.map(({name:r,type:c})=>e.jsxs(i.Row,{fontSize:"12px",p:"4px",sx:{p:"4px !important"},children:[e.jsx(i.Cell,{children:e.jsx(W,{children:r})}),c&&e.jsx(i.Cell,{sx:{display:"flex",justifyContent:"end",pt:"16px"},children:e.jsx(S,{children:c})})]},r))})})})]})]})})},re=p.memo(ne),C=750,ae=({data:s})=>e.jsxs(e.Fragment,{children:[e.jsx(x,{flexDirection:"column",height:"100%",flexGrow:1,children:e.jsx(x,{className:"nodrag nopan",flexGrow:1,width:`${C}px`,sx:{cursor:"auto"},children:e.jsx(q,{title:s.title,readOnly:!0,copyButton:!0,downloadButton:!0,width:"100%",height:"100%",label:"Transformation snippet (Python)",language:"py",content:s.content})})}),e.jsx(f,{type:"target",position:j.Left,isConnectableEnd:!0}),e.jsx(f,{type:"source",position:j.Right,isConnectableEnd:!0})]}),_=2,le=4,v=(s,n)=>{if(s.length<=_+1)return s;const[l,d]=y(_,s),[t,r]=y(d.length-le,d);return[...l,...t.length>0?[{nodeType:"CollapsedNodes",nodeNamesAndTypes:Y(["name","type"],t),name:`collapsed-${n}`}]:[],...r]},de=(s,n)=>{if(!n)return s;const l=s.findIndex(H("name",n)),[d,[t,...r]]=y(l,s),c=v(r,"after");return[...w(v(w(d),"before")),t,...c]},ie={FeatureAndType:se,SourceCode:ae,CollapsedNodes:oe},g=150,ce=({hopsworksUdf:{name:s,sourceCode:n},inputs:l,outputs:d,featureName:t})=>{const{colorMode:r}=U(),{name:c}=z(),b=p.useMemo(()=>c===L.MAC?"Cmd ⌘":"Ctrl",[c]),N=(g+m)*2+C,u=p.useMemo(()=>de(d,t),[d,t]),O=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:t===o,featureLess:!t}},type:"FeatureAndType"})),{id:"source_code",position:{x:g+m,y:0},data:{label:"source_code",content:n,title:`${s}.py`},type:"SourceCode"},...G(V(Q("type")),u.map(({name:o="",type:a="",nodeType:h,nodeNamesAndTypes:D},F)=>({id:`output-${o||a}`,position:{x:g*2+C+m,y:F*49},data:{label:"output",value:{name:o,type:a,nodeType:h,nodeNamesAndTypes:D,activeFeature:t===o,featureLess:!t}},type:h??"FeatureAndType"})))],[l,u,t,n,s]),$=p.useMemo(()=>[...l.map(({name:o="",type:a=""},h)=>({id:`to-source${o||a}`,source:`input-${o||a}`,target:"source_code",markerEnd:{type:E.ArrowClosed},...o===t?{style:{strokeWidth:5,stroke:`var(--quartz-colors-primaryShade2-_${r})`}}:{}})),...u.map(({name:o="",type:a=""})=>({id:`from-source-${o||a}`,source:"source_code",target:`output-${o||a}`,markerEnd:{type:E.ArrowClosed},...o===t?{style:{strokeWidth:5,stroke:`var(--quartz-colors-primaryShade2-_${r})`}}:{}}))],[l,u,t,r]);return e.jsxs(x,{flexDirection:"column",width:"100%",height:"100%",children:[e.jsx(T,{width:"100%",height:"100%",mt:"20px",sx:{".react-flow__attribution":{bg:"white",bottom:"20px"}},children:e.jsx(X,{children:e.jsxs(Z,{nodes:O,edges:$,nodeTypes:ie,defaultEdgeOptions:pe,nodesDraggable:!1,nodesConnectable:!1,panOnScroll:!0,onInit:o=>{setTimeout(()=>{o.fitBounds({x:0,y:0,width:N,height:1e3},{padding:.1})})},children:[e.jsx(K,{}),e.jsx(ee,{})]})})}),e.jsx(x,{mt:"10px",justifyContent:"center",children:e.jsxs(J,{gray:!0,children:["Hold ",e.jsx("b",{children:b})," and scroll to zoom in/out"]})})]})},pe={style:{strokeWidth:2.5,stroke:"var(--quartz-colors-grayShade2)",zIndex:10}},ge=p.memo(ce);export{ge as V};
