import{p as Q,d as O,s as X,D as M,a as Z,S as j,b as F,c as I}from"./styles-f626f8de-167c7b7a.js";import{G as tt}from"./layout-2e0fbc67.js";import{l,c as g,h as x,u as et,i as ot,j as w}from"./intro.stories-2707f0d7.js";import{r as st}from"./index-4c4adb72-305cfaaa.js";import"./dayjs.min-1b995edc.js";import"./_baseSet-db0c20a6.js";import"./_getTag-edecb89a.js";import"./isSymbol-50749e90.js";import"./isObject-32699ff3.js";import"./toString-25ea340b.js";import"./parseCss-8f2248e6.js";import"./index-2ea0b3cc.js";import"./index-28a69ec7.js";import"./iframe-892f1e35.js";import"../sb-preview/runtime.js";import"./_commonjsHelpers-de833af9.js";import"./index-d37d4223.js";import"./now-bd49f550.js";import"./chunk-S4VUQJ4A-36ba17aa.js";import"./index-e04ae519.js";import"./index-356e4a49.js";import"./jsx-runtime-6fa9561d.js";import"./Table-acc1ff8d.js";import"./_color-087aa1f8.js";import"./index-173ee924.js";import"./edges-b00f0ec2-4a286a23.js";import"./createText-285e50b4-28eea7d2.js";import"./svgDraw-5d8a058e-35e42658.js";import"./line-b50add47.js";import"./array-9f3ba611.js";import"./path-53f90ab3.js";const A="rect",C="rectWithTitle",nt="start",it="end",rt="divider",ct="roundedWithTitle",lt="note",at="noteGroup",_="statediagram",dt="state",pt=`${_}-${dt}`,H="transition",Et="note",St="note-edge",Tt=`${H} ${St}`,_t=`${_}-${Et}`,ut="cluster",Dt=`${_}-${ut}`,ft="cluster-alt",bt=`${_}-${ft}`,U="parent",V="note",ht="state",m="----",At=`${m}${V}`,B=`${m}${U}`,Y="fill:none",W="fill: #333",z="c",q="text",K="normal";let y={},p=0;const yt=function(t){const n=Object.keys(t);for(const e of n)t[e]},gt=function(t,n){l.trace("Extracting classes"),n.db.clear();try{return n.parser.parse(t),n.db.extract(n.db.getRootDocV2()),n.db.getClasses()}catch(e){return e}};function $t(t){return t==null?"":t.classes?t.classes.join(" "):""}function R(t="",n=0,e="",i=m){const r=e!==null&&e.length>0?`${i}${e}`:"";return`${ht}-${t}${r}-${n}`}const h=(t,n,e,i,r,c)=>{const o=e.id,u=$t(i[o]);if(o!=="root"){let S=A;e.start===!0&&(S=nt),e.start===!1&&(S=it),e.type!==M&&(S=e.type),y[o]||(y[o]={id:o,shape:S,description:w.sanitizeText(o,g()),classes:`${u} ${pt}`});const s=y[o];e.description&&(Array.isArray(s.description)?(s.shape=C,s.description.push(e.description)):s.description.length>0?(s.shape=C,s.description===o?s.description=[e.description]:s.description=[s.description,e.description]):(s.shape=A,s.description=e.description),s.description=w.sanitizeTextOrArray(s.description,g())),s.description.length===1&&s.shape===C&&(s.shape=A),!s.type&&e.doc&&(l.info("Setting cluster for ",o,G(e)),s.type="group",s.dir=G(e),s.shape=e.type===Z?rt:ct,s.classes=s.classes+" "+Dt+" "+(c?bt:""));const T={labelStyle:"",shape:s.shape,labelText:s.description,classes:s.classes,style:"",id:o,dir:s.dir,domId:R(o,p),type:s.type,padding:15};if(T.centerLabel=!0,e.note){const a={labelStyle:"",shape:lt,labelText:e.note.text,classes:_t,style:"",id:o+At+"-"+p,domId:R(o,p,V),type:s.type,padding:15},d={labelStyle:"",shape:at,labelText:e.note.text,classes:s.classes,style:"",id:o+B,domId:R(o,p,U),type:"group",padding:0};p++;const D=o+B;t.setNode(D,d),t.setNode(a.id,a),t.setNode(o,T),t.setParent(o,D),t.setParent(a.id,D);let E=o,f=a.id;e.note.position==="left of"&&(E=a.id,f=o),t.setEdge(E,f,{arrowhead:"none",arrowType:"",style:Y,labelStyle:"",classes:Tt,arrowheadStyle:W,labelpos:z,labelType:q,thickness:K})}else t.setNode(o,T)}n&&n.id!=="root"&&(l.trace("Setting node ",o," to be child of its parent ",n.id),t.setParent(o,n.id)),e.doc&&(l.trace("Adding nodes children "),xt(t,e,e.doc,i,r,!c))},xt=(t,n,e,i,r,c)=>{l.trace("items",e),e.forEach(o=>{switch(o.stmt){case F:h(t,n,o,i,r,c);break;case M:h(t,n,o,i,r,c);break;case j:{h(t,n,o.state1,i,r,c),h(t,n,o.state2,i,r,c);const u={id:"edge"+p,arrowhead:"normal",arrowTypeEnd:"arrow_barb",style:Y,labelStyle:"",label:w.sanitizeText(o.description,g()),arrowheadStyle:W,labelpos:z,labelType:q,thickness:K,classes:H};t.setEdge(o.state1.id,o.state2.id,u,p),p++}break}})},G=(t,n=I)=>{let e=n;if(t.doc)for(let i=0;i{t.state||(t.state={}),t.state.arrowMarkerAbsolute=t.arrowMarkerAbsolute,O.clear()}};export{ie as diagram}; //# sourceMappingURL=stateDiagram-v2-7c93469e-e554e35c.js.map