Files
fad_oa/ruoyi-ui/public/file-viewer/assets/stateDiagram-AJRCARHV-CBylKBpj.js

1 line
10 KiB
JavaScript

import{n as e,r as t}from"./chunk-AGHRB4JF-Fz9kp2Fp.js";import{O as n,c as r,s as i,x as a}from"./chunk-CSCIHK7Q-VDPd5eNJ.js";import{Q as o,_ as s,v as c}from"./src-BrOGWJpF.js";import{g as l}from"./chunk-5ZQYHXKU-D-OgLpMs.js";import"./chunk-BSJP7CBP-BkJdmh17.js";import"./chunk-L5ZTLDWV-CzNJ_8is.js";import"./chunk-NZK2D7GU-Cte2JwiA.js";import"./chunk-O5CBEL6O-Bu7jDUJy.js";import"./chunk-3OPIFGDE-BBTvqaNI.js";import"./chunk-KSCS5N6A-BuXf0YOu.js";import"./chunk-LZXEDZCA-n9zJSIw5.js";import{t as u}from"./graphlib-B8gBHxth.js";import{t as d}from"./dagre-Bx709z4p.js";import"./chunk-55IACEB6-BXXbpqd4.js";import"./chunk-2J33WTMH-CruGLWY_.js";import{i as f,n as p,t as m}from"./chunk-AQP2D5EJ-B3sX7UtP.js";var h=e(e=>e.append(`circle`).attr(`class`,`start-state`).attr(`r`,a().state.sizeUnit).attr(`cx`,a().state.padding+a().state.sizeUnit).attr(`cy`,a().state.padding+a().state.sizeUnit),`drawStartState`),g=e(e=>e.append(`line`).style(`stroke`,`grey`).style(`stroke-dasharray`,`3`).attr(`x1`,a().state.textHeight).attr(`class`,`divider`).attr(`x2`,a().state.textHeight*2).attr(`y1`,0).attr(`y2`,0),`drawDivider`),_=e((e,t)=>{let n=e.append(`text`).attr(`x`,2*a().state.padding).attr(`y`,a().state.textHeight+2*a().state.padding).attr(`font-size`,a().state.fontSize).attr(`class`,`state-title`).text(t.id),r=n.node().getBBox();return e.insert(`rect`,`:first-child`).attr(`x`,a().state.padding).attr(`y`,a().state.padding).attr(`width`,r.width+2*a().state.padding).attr(`height`,r.height+2*a().state.padding).attr(`rx`,a().state.radius),n},`drawSimpleState`),v=e((t,n)=>{let r=e(function(e,t,n){let r=e.append(`tspan`).attr(`x`,2*a().state.padding).text(t);n||r.attr(`dy`,a().state.textHeight)},`addTspan`),i=t.append(`text`).attr(`x`,2*a().state.padding).attr(`y`,a().state.textHeight+1.3*a().state.padding).attr(`font-size`,a().state.fontSize).attr(`class`,`state-title`).text(n.descriptions[0]).node().getBBox(),o=i.height,s=t.append(`text`).attr(`x`,a().state.padding).attr(`y`,o+a().state.padding*.4+a().state.dividerMargin+a().state.textHeight).attr(`class`,`state-description`),c=!0,l=!0;n.descriptions.forEach(function(e){c||(r(s,e,l),l=!1),c=!1});let u=t.append(`line`).attr(`x1`,a().state.padding).attr(`y1`,a().state.padding+o+a().state.dividerMargin/2).attr(`y2`,a().state.padding+o+a().state.dividerMargin/2).attr(`class`,`descr-divider`),d=s.node().getBBox(),f=Math.max(d.width,i.width);return u.attr(`x2`,f+3*a().state.padding),t.insert(`rect`,`:first-child`).attr(`x`,a().state.padding).attr(`y`,a().state.padding).attr(`width`,f+2*a().state.padding).attr(`height`,d.height+o+2*a().state.padding).attr(`rx`,a().state.radius),t},`drawDescrState`),y=e((e,t,n)=>{let r=a().state.padding,i=2*a().state.padding,o=e.node().getBBox(),s=o.width,c=o.x,l=e.append(`text`).attr(`x`,0).attr(`y`,a().state.titleShift).attr(`font-size`,a().state.fontSize).attr(`class`,`state-title`).text(t.id),u=l.node().getBBox().width+i,d=Math.max(u,s);d===s&&(d+=i);let f,p=e.node().getBBox();t.doc,f=c-r,u>s&&(f=(s-d)/2+r),Math.abs(c-p.x)<r&&u>s&&(f=c-(u-s)/2);let m=1-a().state.textHeight;return e.insert(`rect`,`:first-child`).attr(`x`,f).attr(`y`,m).attr(`class`,n?`alt-composit`:`composit`).attr(`width`,d).attr(`height`,p.height+a().state.textHeight+a().state.titleShift+1).attr(`rx`,`0`),l.attr(`x`,f+r),u<=s&&l.attr(`x`,c+(d-i)/2-u/2+r),e.insert(`rect`,`:first-child`).attr(`x`,f).attr(`y`,a().state.titleShift-a().state.textHeight-a().state.padding).attr(`width`,d).attr(`height`,a().state.textHeight*3).attr(`rx`,a().state.radius),e.insert(`rect`,`:first-child`).attr(`x`,f).attr(`y`,a().state.titleShift-a().state.textHeight-a().state.padding).attr(`width`,d).attr(`height`,p.height+3+2*a().state.textHeight).attr(`rx`,a().state.radius),e},`addTitleAndBox`),b=e(e=>(e.append(`circle`).attr(`class`,`end-state-outer`).attr(`r`,a().state.sizeUnit+a().state.miniPadding).attr(`cx`,a().state.padding+a().state.sizeUnit+a().state.miniPadding).attr(`cy`,a().state.padding+a().state.sizeUnit+a().state.miniPadding),e.append(`circle`).attr(`class`,`end-state-inner`).attr(`r`,a().state.sizeUnit).attr(`cx`,a().state.padding+a().state.sizeUnit+2).attr(`cy`,a().state.padding+a().state.sizeUnit+2)),`drawEndState`),x=e((e,t)=>{let n=a().state.forkWidth,r=a().state.forkHeight;if(t.parentId){let e=n;n=r,r=e}return e.append(`rect`).style(`stroke`,`black`).style(`fill`,`black`).attr(`width`,n).attr(`height`,r).attr(`x`,a().state.padding).attr(`y`,a().state.padding)},`drawForkJoinState`),S=e((e,t,n,r)=>{let o=0,s=r.append(`text`);s.style(`text-anchor`,`start`),s.attr(`class`,`noteText`);let c=e.replace(/\r\n/g,`<br/>`);c=c.replace(/\n/g,`<br/>`);let l=c.split(i.lineBreakRegex),u=1.25*a().state.noteMargin;for(let e of l){let r=e.trim();if(r.length>0){let e=s.append(`tspan`);if(e.text(r),u===0){let t=e.node().getBBox();u+=t.height}o+=u,e.attr(`x`,t+a().state.noteMargin),e.attr(`y`,n+o+1.25*a().state.noteMargin)}}return{textWidth:s.node().getBBox().width,textHeight:o}},`_drawLongText`),C=e((e,t)=>{t.attr(`class`,`state-note`);let n=t.append(`rect`).attr(`x`,0).attr(`y`,a().state.padding),{textWidth:r,textHeight:i}=S(e,0,0,t.append(`g`));return n.attr(`height`,i+2*a().state.noteMargin),n.attr(`width`,r+a().state.noteMargin*2),n},`drawNote`),w=e(function(e,t){let n=t.id,r={id:n,label:t.id,width:0,height:0},i=e.append(`g`).attr(`id`,n).attr(`class`,`stateGroup`);t.type===`start`&&h(i),t.type===`end`&&b(i),(t.type===`fork`||t.type===`join`)&&x(i,t),t.type===`note`&&C(t.note.text,i),t.type===`divider`&&g(i),t.type==="default"&&t.descriptions.length===0&&_(i,t),t.type==="default"&&t.descriptions.length>0&&v(i,t);let o=i.node().getBBox();return r.width=o.width+2*a().state.padding,r.height=o.height+2*a().state.padding,r},`drawState`),T=0,E=e(function(r,o,u){let d=e(function(e){switch(e){case m.relationType.AGGREGATION:return`aggregation`;case m.relationType.EXTENSION:return`extension`;case m.relationType.COMPOSITION:return`composition`;case m.relationType.DEPENDENCY:return`dependency`}},`getRelationType`);o.points=o.points.filter(e=>!Number.isNaN(e.y));let f=o.points,p=c().x(function(e){return e.x}).y(function(e){return e.y}).curve(s),h=r.append(`path`).attr(`d`,p(f)).attr(`id`,`edge`+T).attr(`class`,`transition`),g=``;if(a().state.arrowMarkerAbsolute&&(g=n(!0)),h.attr(`marker-end`,`url(`+g+`#`+d(m.relationType.DEPENDENCY)+`End)`),u.title!==void 0){let e=r.append(`g`).attr(`class`,`stateLabel`),{x:n,y:s}=l.calcLabelPosition(o.points),c=i.getRows(u.title),d=0,f=[],p=0,m=0;for(let r=0;r<=c.length;r++){let i=e.append(`text`).attr(`text-anchor`,`middle`).text(c[r]).attr(`x`,n).attr(`y`,s+d),a=i.node().getBBox();p=Math.max(p,a.width),m=Math.min(m,a.x),t.info(a.x,n,s+d),d===0&&(d=i.node().getBBox().height,t.info(`Title height`,d,s)),f.push(i)}let h=d*c.length;if(c.length>1){let e=(c.length-1)*d*.5;f.forEach((t,n)=>t.attr(`y`,s+n*d-e)),h=d*c.length}let g=e.node().getBBox();e.insert(`rect`,`:first-child`).attr(`class`,`box`).attr(`x`,n-p/2-a().state.padding/2).attr(`y`,s-h/2-a().state.padding/2-3.5).attr(`width`,p+a().state.padding).attr(`height`,h+a().state.padding),t.info(g)}T++},`drawEdge`),D,O={},k=e(function(){},`setConf`),A=e(function(e){e.append(`defs`).append(`marker`).attr(`id`,`dependencyEnd`).attr(`refX`,19).attr(`refY`,7).attr(`markerWidth`,20).attr(`markerHeight`,28).attr(`orient`,`auto`).append(`path`).attr(`d`,`M 19,7 L9,13 L14,7 L9,1 Z`)},`insertMarkers`),j=e(function(e,n,i,s){D=a().state;let c=a().securityLevel,l;c===`sandbox`&&(l=o(`#i`+n));let u=o(c===`sandbox`?l.nodes()[0].contentDocument.body:`body`),d=c===`sandbox`?l.nodes()[0].contentDocument:document;t.debug(`Rendering diagram `+e);let f=u.select(`[id='${n}']`);A(f),N(s.db.getRootDoc(),f.append(`g`).attr(`id`,n+`-root`),void 0,!1,u,d,s);let p=D.padding,m=f.node().getBBox(),h=m.width+p*2,g=m.height+p*2;r(f,g,h*1.75,D.useMaxWidth),f.attr(`viewBox`,`${m.x-D.padding} ${m.y-D.padding} `+h+` `+g)},`draw`),M=e(e=>e?e.length*D.fontSizeFactor:1,`getLabelWidth`),N=e((e,n,r,a,o,s,c)=>{let l=new u({compound:!0,multigraph:!0}),f,p=!0;for(f=0;f<e.length;f++)if(e[f].stmt===`relation`){p=!1;break}r?l.setGraph({rankdir:`LR`,multigraph:!0,compound:!0,ranker:`tight-tree`,ranksep:p?1:D.edgeLengthFactor,nodeSep:p?1:50,isMultiGraph:!0}):l.setGraph({rankdir:`TB`,multigraph:!0,compound:!0,ranksep:p?1:D.edgeLengthFactor,nodeSep:p?1:50,ranker:`tight-tree`,isMultiGraph:!0}),l.setDefaultEdgeLabel(function(){return{}});let m=c.db.getStates(),h=c.db.getRelations(),g=Object.keys(m);for(let e of g){let t=m[e];r&&(t.parentId=r);let i;if(t.doc){let e=n.append(`g`).attr(`id`,t.id).attr(`class`,`stateGroup`);i=N(t.doc,e,t.id,!a,o,s,c);{e=y(e,t,a);let n=e.node().getBBox();i.width=n.width,i.height=n.height+D.padding/2,O[t.id]={y:D.compositTitleSize}}}else i=w(n,t,l);if(t.note){let e=w(n,{descriptions:[],id:t.id+`-note`,note:t.note,type:`note`},l);t.note.position===`left of`?(l.setNode(i.id+`-note`,e),l.setNode(i.id,i)):(l.setNode(i.id,i),l.setNode(i.id+`-note`,e)),l.setParent(i.id,i.id+`-group`),l.setParent(i.id+`-note`,i.id+`-group`)}else l.setNode(i.id,i)}t.debug(`Count=`,l.nodeCount(),l);let _=0;h.forEach(function(e){_++,t.debug(`Setting edge`,e),l.setEdge(e.id1,e.id2,{relation:e,width:M(e.title),height:D.labelHeight*i.getRows(e.title).length,labelpos:`c`},`id`+_)}),d(l),t.debug(`Graph after layout`,l.nodes());let v=n.node();l.nodes().forEach(function(e){e!==void 0&&l.node(e)!==void 0?(t.warn(`Node `+e+`: `+JSON.stringify(l.node(e))),o.select(`#`+v.id+` #`+e).attr(`transform`,`translate(`+(l.node(e).x-l.node(e).width/2)+`,`+(l.node(e).y+(O[e]?O[e].y:0)-l.node(e).height/2)+` )`),o.select(`#`+v.id+` #`+e).attr(`data-x-shift`,l.node(e).x-l.node(e).width/2),s.querySelectorAll(`#`+v.id+` #`+e+` .divider`).forEach(e=>{let t=e.parentElement,n=0,r=0;t&&(t.parentElement&&(n=t.parentElement.getBBox().width),r=parseInt(t.getAttribute(`data-x-shift`),10),Number.isNaN(r)&&(r=0)),e.setAttribute(`x1`,0-r+8),e.setAttribute(`x2`,n-r-8)})):t.debug(`No Node `+e+`: `+JSON.stringify(l.node(e)))});let b=v.getBBox();l.edges().forEach(function(e){e!==void 0&&l.edge(e)!==void 0&&(t.debug(`Edge `+e.v+` -> `+e.w+`: `+JSON.stringify(l.edge(e))),E(n,l.edge(e),l.edge(e).relation))}),b=v.getBBox();let x={id:r||`root`,label:r||`root`,width:0,height:0};return x.width=b.width+2*D.padding,x.height=b.height+2*D.padding,t.debug(`Doc rendered`,x,l),x},`renderDoc`),P={parser:p,get db(){return new m(1)},renderer:{setConf:k,draw:j},styles:f,init:e(e=>{e.state||={},e.state.arrowMarkerAbsolute=e.arrowMarkerAbsolute},`init`)};export{P as diagram};