@galaxyproject/galaxy-client
Version:
Galaxy client application build system
1 lines • 4.9 kB
JavaScript
;(self.webpackChunk_galaxyproject_galaxy_client=self.webpackChunk_galaxyproject_galaxy_client||[]).push([[994],{45518:(t,e,o)=>{o.d(e,{autoLayout:()=>l});var n=o(62954),i=o.n(n),s=o(31953),c=o(16234),r=(o(74610),o(62348)),a=o(65516),p=o(65248);const d=new(i());function m(t){return`[${Object.entries(t).map((([t,e])=>{const o=typeof e;return`${t}=${(0,a.YW)(o,{number:()=>`${e}`,string:()=>`"${e}"`,boolean:()=>`${e}`,object:()=>m(e)})}`})).join(", ")}]`}function h(t=0,e=0,o=0,n=0){return m({left:t,top:e,right:o,bottom:n})}async function l(t,e,o){const n=(0,s.dQ)(t),i=(0,c.h)(t),a=10,m=Math.max(20,100),l=Math.max(a,50),g={"elk.layered.spacing.nodeNodeBetweenLayers":""+m/2,"elk.portConstraints":"FIXED_POS"},$={id:"",layoutOptions:{"elk.padding":h(0,0),"elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.layered.spacing.baseValue":`${m}`,"elk.algorithm":"layered","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.spacing.nodeNode":`${l}`},children:[],edges:[]},x=[],w=[];o.forEach((t=>{"freehand"===t.type?x.push(t):w.push(t)}));const b=Object.entries(e).map((([t,e])=>{const o=i.stepPosition[e.id];return(0,r.iY)(o,`No StepPosition with step id ${e.id} found in workflowStateStore`),{id:t,step:e,rect:{x:e.position?.left??0,y:e.position?.top??0,width:o.width,height:o.height}}})),_=function(t){const e=t.map((t=>{const e=new p.dO;return e.fitRectangle({x:t.position[0],y:t.position[1],width:t.size[0],height:t.size[1]}),{aabb:e,comments:[t]}})),o=new Set(e),n=t=>{const e=o.values();for(const o of e)if(t!==o&&t.aabb.intersects(o.aabb)){i(t,o);break}},i=(t,e)=>{const i=new p.dO;i.fitRectangle(t.aabb),i.fitRectangle(e.aabb),o.delete(t),o.delete(e);const s={aabb:i,comments:[...t.comments,...e.comments]};o.add(s),n(s)},s=o.values();for(const t of s)n(t);return[...o.values()]}(x);!function(t,e){t.forEach((t=>{let o=1/0;e.forEach((e=>{const n=(0,p.M$)(t.aabb,e.rect);n<o&&(o=n,t.closestStepId=e.id,t.positionFrom={x:e.rect.x,y:e.rect.y})}))}))}(_,b),$.children=function(t,e,o,n,i){const s=new Map(e.map((t=>[t.id,{comment:t,root:!0,children:[]}]))),c=new Map(Object.entries(t));s.forEach((t=>{t.comment.child_comments&&t.comment.child_comments.forEach((e=>{const o=s.get(e);o&&(o.root=!1,t.children.push(o))})),t.comment.child_steps&&t.comment.child_steps.forEach((e=>{const o=`${e}`,n=c.get(o);c.delete(o),t.children.push(n)}))}));const r=[...s.values()].filter((t=>t.root)),a=[...c.values()].map((t=>u(t,o,n))),p=r.map((t=>f(t,o,n,i)));return[...a,...p]}(e,w,i,(t=>Math.ceil(t/a-1e-4)*a),g);const E=n.connections.map((t=>({id:`e_${t.input.stepId}_${t.output.stepId}`,sources:[`${t.output.stepId}/out/${t.output.name}`],targets:[`${t.input.stepId}/in/${t.input.name}`]}))),k=function(t,e){const o=[];return t.forEach((t=>{if("freehand"===t.type)return;let n=1/0,i=null;const s={x:t.position[0],y:t.position[1],width:t.size[0],height:t.size[1]};if(e.forEach((t=>{const e=(0,p.M$)(t.rect,s);e<n&&(n=e,i=t.id)})),i){const e={id:`comment_edge_${i}_${t.id}`,sources:[i],targets:[`comment_${t.id}`]};o.push(e)}})),o}(w,b);$.edges=[...E,...k];const S=t=>Math.round(t/a)*a;try{const t=y((await d.layout($)).children,S),e=function(t,e){const o=[],n=new Map(e.map((t=>[t.id,t])));return t.forEach((t=>{if(!t.closestStepId)return;const e=n.get(t.closestStepId);if(e){const n={x:e.x-(t.positionFrom?.x??0),y:e.y-(t.positionFrom?.y??0)};t.comments.forEach((t=>{o.push({id:`${t.id}`,x:t.position[0]+n.x,y:t.position[1]+n.y,w:t.size[0],h:t.size[1]})}))}})),o}(_,t.steps);return t.comments=t.comments.concat(e),t}catch(t){console.error(t)}}function u(t,e,o){const n=Object.values(t.inputs).map(((e,o)=>({id:`${t.id}/in/${e.name}`,properties:{"port.side":"WEST","port.index":`${o}`},x:0,y:20*o}))),i=e.stepPosition[t.id];(0,r.iY)(i,`No StepPosition with step id ${t.id} found in workflowStateStore`);const s=Object.values(t.outputs).map(((e,o)=>({id:`${t.id}/out/${e.name}`,properties:{"port.side":"EAST","port.index":`${o}`},x:i.width,y:20*o})));return{id:`${t.id}`,height:o(i.height),width:o(i.width),x:t.position?.left,y:t.position?.top,layoutOptions:{"elk.portConstraints":"FIXED_POS"},ports:n.concat(s)}}function f(t,e,o,n){const i={id:`comment_${t.comment.id}`,x:t.comment.position[0],y:t.comment.position[1],width:t.comment.size[0],height:t.comment.size[1],layoutOptions:{"elk.commentBox":"frame"===t.comment.type?"false":"true",...n,"elk.padding":h(20,40,20,20)}},s=t.children?.map((t=>"comment"in t?f(t,e,o,n):u(t,e,o)));return{...i,children:s}}function y(t,e,o){const n={steps:[],comments:[]};if(!t)return n;const i=o??{x:0,y:0};return t.forEach((t=>{if(t.id.startsWith("comment_")){const o=t.id.slice(8),s={x:e(t.x??0)+i.x,y:e(t.y??0)+i.y};if(n.comments.push({id:o,...s,w:t.width??0,h:t.height??0}),t.children){const o=y(t.children,e,s);n.steps=n.steps.concat(o.steps),n.comments=n.comments.concat(o.comments)}}else n.steps.push({id:t.id,x:e(t.x??0)+i.x,y:e(t.y??0)+i.y})})),n}}}]);