var t,e;t=this,e=function(t){"use strict";var e,r,n=function(){return(n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}function o(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,a,o=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(t){a={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i}function i(){for(var t=[],e=0;e0)try{for(var x=a(l(e.states)),m=x.next();!m.done;m=x.next())g=m.value,p.push.apply(p,i(t(e.states[g],{depth:d-1})))}catch(t){s={error:t}}finally{try{m&&!m.done&&(u=x.return)&&u.call(x)}finally{if(s)throw s.error}}try{for(var w=a(l(e.on)),E=w.next();!E.done;E=w.next()){var b=E.value;p.push.apply(p,i(v(e,b)))}}catch(t){c={error:t}}finally{try{E&&!E.done&&(f=w.return)&&f.call(w)}finally{if(c)throw c.error}}return p},t.adjacencyMap=function(t,e){var r={},n=t.events;return function o(i){var l,s,u=JSON.stringify(i);if(!r[u]){r[u]={};try{for(var c=a(n),f=c.next();!f.done;f=c.next()){var v=f.value,y=t.transition(i,v,e);r[u][v]={state:y.value},o(y.value)}}catch(t){l={error:t}}finally{try{f&&!f.done&&(s=c.return)&&s.call(c)}finally{if(l)throw l.error}}}}(t.initialState.value),r},t.deserializeStateString=function(t){var e=o(t.split(" | "),2),r=e[0],n=e[1];return{value:JSON.parse(r),context:void 0===n?void 0:JSON.parse(n)}},t.serializeState=y,t.serializeEvent=d,t.deserializeEventString=p,t.getValueAdjacencyMap=S,t.getShortestPaths=function(t,e){var r,i,s,u;if(!t.states)return f;var c=n({events:{},stateSerializer:y,eventSerializer:d},e),v=S(t,c),h=new Map,g=new Map,x=c.stateSerializer(t.initialState);g.set(x,t.initialState),h.set(x,[0,void 0,void 0]);var m=new Set,w=new Set;for(m.add(x);m.size>0;)try{for(var E=a(m),b=E.next();!b.done;b=E.next()){var O=b.value,z=o(h.get(O),1)[0];try{for(var N=a(l(v[O])),j=N.next();!j.done;j=N.next()){var P=j.value,A=v[O][P],J=c.stateSerializer(A);g.set(J,A),h.has(J)?o(h.get(J),1)[0]>z+1&&h.set(J,[z+1,O,P]):h.set(J,[z+1,O,P]),w.has(J)||m.add(J)}}catch(t){s={error:t}}finally{try{j&&!j.done&&(u=N.return)&&u.call(N)}finally{if(s)throw s.error}}w.add(O),m.delete(O)}}catch(t){r={error:t}}finally{try{b&&!b.done&&(i=E.return)&&i.call(E)}finally{if(r)throw r.error}}var k={};return h.forEach(function(t,e){var r=o(t,3),n=r[0],a=r[1],i=r[2];k[e]={state:g.get(e),weight:n,path:a?k[a].path.concat({state:g.get(a),event:p(i)}):[]}}),k},t.getSimplePaths=g,t.getSimplePathsAsArray=function(t,e){var r=g(t,e);return l(r).map(function(t){return r[t]})},Object.defineProperty(t,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).XStateGraph={});