"use strict";exports.id=4505,exports.ids=[4505],exports.modules={44505:(e,t,s)=>{s.d(t,{diagram:()=>N});var i=s(90643),r=s(71093),o=s(65531),a=s(66085),l=s(52819);s(85668),s(5442),s(73514),s(57303),s(76963);let d="rect",n="rectWithTitle",c="statediagram",p=`${c}-state`,g="transition",b=`${g} note-edge`,h=`${c}-note`,u=`${c}-cluster`,y=`${c}-cluster-alt`,f="parent",x="note",m="----",w=`${m}${x}`,$=`${m}${f}`,T="fill:none",S="fill: #333",D="text",v="normal",A={},k=0;function B(e="",t=0,s="",i=m){let r=null!==s&&s.length>0?`${i}${s}`:"";return`state-${e}${r}-${t}`}let E=(e,t,s,r,o,l)=>{let c=s.id,g=function(e){return null==e?"":e.classes?e.classes.join(" "):""}(r[c]);if("root"!==c){let t=d;!0===s.start&&(t="start"),!1===s.start&&(t="end"),s.type!==i.D&&(t=s.type),A[c]||(A[c]={id:c,shape:t,description:a.e.sanitizeText(c,(0,a.c)()),classes:`${g} ${p}`});let r=A[c];s.description&&(Array.isArray(r.description)?(r.shape=n,r.description.push(s.description)):r.description.length>0?(r.shape=n,r.description===c?r.description=[s.description]:r.description=[r.description,s.description]):(r.shape=d,r.description=s.description),r.description=a.e.sanitizeTextOrArray(r.description,(0,a.c)())),1===r.description.length&&r.shape===n&&(r.shape=d),!r.type&&s.doc&&(a.l.info("Setting cluster for ",c,R(s)),r.type="group",r.dir=R(s),r.shape=s.type===i.a?"divider":"roundedWithTitle",r.classes=r.classes+" "+u+" "+(l?y:""));let o={labelStyle:"",shape:r.shape,labelText:r.description,classes:r.classes,style:"",id:c,dir:r.dir,domId:B(c,k),type:r.type,padding:15};if(o.centerLabel=!0,s.note){let t={labelStyle:"",shape:"note",labelText:s.note.text,classes:h,style:"",id:c+w+"-"+k,domId:B(c,k,x),type:r.type,padding:15},i={labelStyle:"",shape:"noteGroup",labelText:s.note.text,classes:r.classes,style:"",id:c+$,domId:B(c,k,f),type:"group",padding:0};k++;let a=c+$;e.setNode(a,i),e.setNode(t.id,t),e.setNode(c,o),e.setParent(c,a),e.setParent(t.id,a);let l=c,d=t.id;"left of"===s.note.position&&(l=t.id,d=c),e.setEdge(l,d,{arrowhead:"none",arrowType:"",style:T,labelStyle:"",classes:b,arrowheadStyle:S,labelpos:"c",labelType:D,thickness:v})}else e.setNode(c,o)}t&&"root"!==t.id&&(a.l.trace("Setting node ",c," to be child of its parent ",t.id),e.setParent(c,t.id)),s.doc&&(a.l.trace("Adding nodes children "),L(e,s,s.doc,r,o,!l))},L=(e,t,s,r,o,l)=>{a.l.trace("items",s),s.forEach(s=>{switch(s.stmt){case i.b:case i.D:E(e,t,s,r,o,l);break;case i.S:{E(e,t,s.state1,r,o,l),E(e,t,s.state2,r,o,l);let i={id:"edge"+k,arrowhead:"normal",arrowTypeEnd:"arrow_barb",style:T,labelStyle:"",label:a.e.sanitizeText(s.description,(0,a.c)()),arrowheadStyle:S,labelpos:"c",labelType:D,thickness:v,classes:g};e.setEdge(s.state1.id,s.state2.id,i,k),k++}}})},R=(e,t=i.c)=>{let s=t;if(e.doc)for(let t=0;t<e.doc.length;t++){let i=e.doc[t];"dir"===i.stmt&&(s=i.value)}return s},V=async function(e,t,s,i){let n;a.l.info("Drawing state diagram (v2)",t),A={},i.db.getDirection();let{securityLevel:p,state:g}=(0,a.c)(),b=g.nodeSpacing||50,h=g.rankSpacing||50;a.l.info(i.db.getRootDocV2()),i.db.extract(i.db.getRootDocV2()),a.l.info(i.db.getRootDocV2());let u=i.db.getStates(),y=new r.T({multigraph:!0,compound:!0}).setGraph({rankdir:R(i.db.getRootDocV2()),nodesep:b,ranksep:h,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});E(y,void 0,i.db.getRootDocV2(),u,i.db,!0),"sandbox"===p&&(n=(0,o.Ltv)("#i"+t));let f="sandbox"===p?(0,o.Ltv)(n.nodes()[0].contentDocument.body):(0,o.Ltv)("body"),x=f.select(`[id="${t}"]`),m=f.select("#"+t+" g");await (0,l.r)(m,y,["barb"],c,t),a.u.insertTitle(x,"statediagramTitleText",g.titleTopMargin,i.db.getDiagramTitle());let w=x.node().getBBox(),$=w.width+16,T=w.height+16;x.attr("class",c);let S=x.node().getBBox();(0,a.i)(x,T,$,g.useMaxWidth);let D=`${S.x-8} ${S.y-8} ${$} ${T}`;for(let e of(a.l.debug(`viewBox ${D}`),x.attr("viewBox",D),document.querySelectorAll('[id="'+t+'"] .edgeLabel .label'))){let t=e.getBBox(),s=document.createElementNS("http://www.w3.org/2000/svg",d);s.setAttribute("rx",0),s.setAttribute("ry",0),s.setAttribute("width",t.width),s.setAttribute("height",t.height),e.insertBefore(s,e.firstChild)}},N={parser:i.p,db:i.d,renderer:{setConf:function(e){for(let t of Object.keys(e))e[t]},getClasses:function(e,t){return t.db.extract(t.db.getRootDocV2()),t.db.getClasses()},draw:V},styles:i.s,init:e=>{e.state||(e.state={}),e.state.arrowMarkerAbsolute=e.arrowMarkerAbsolute,i.d.clear()}}}};