UNPKG

@wiz-code/async-fsm

Version:

Finite StateMachine JavaScript Library

1 lines 77.3 kB
require=function s(o,a,u){function c(n,t){if(!a[n]){if(!o[n]){var e="function"==typeof require&&require;if(!t&&e)return e(n,!0);if(h)return h(n,!0);var i=new Error("Cannot find module '"+n+"'");throw i.code="MODULE_NOT_FOUND",i}var r=a[n]={exports:{}};o[n][0].call(r.exports,function(t){var e=o[n][1][t];return c(e||t)},r,r.exports,s,o,a,u)}return a[n].exports}for(var h="function"==typeof require&&require,t=0;t<u.length;t++)c(u[t]);return c}({1:[function($,n,i){(function(B,q){var t,e;t=this,e=function(){"use strict";function c(t){return"function"==typeof t}var n=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=0,e=void 0,r=void 0,a=function(t,e){f[i]=t,f[i+1]=e,2===(i+=2)&&(r?r(d):g())};var t="undefined"!=typeof window?window:void 0,s=t||{},o=s.MutationObserver||s.WebKitMutationObserver,u="undefined"==typeof self&&void 0!==B&&"[object process]"==={}.toString.call(B),h="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function l(){var t=setTimeout;return function(){return t(d,1)}}var f=new Array(1e3);function d(){for(var t=0;t<i;t+=2){(0,f[t])(f[t+1]),f[t]=void 0,f[t+1]=void 0}i=0}var p,v,_,y,g=void 0;function m(t,e){var n=this,i=new this.constructor(P);void 0===i[S]&&D(i);var r=n._state;if(r){var s=arguments[r-1];a(function(){return R(r,i,s,n._result)})}else E(n,i,t,e);return i}function b(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var e=new this(P);return k(e,t),e}u?g=function(){return B.nextTick(d)}:o?(v=0,_=new o(d),y=document.createTextNode(""),_.observe(y,{characterData:!0}),g=function(){y.data=v=++v%2}):h?((p=new MessageChannel).port1.onmessage=d,g=function(){return p.port2.postMessage(0)}):g=void 0===t&&"function"==typeof $?function(){try{var t=Function("return this")().require("vertx");return void 0!==(e=t.runOnLoop||t.runOnContext)?function(){e(d)}:l()}catch(t){return l()}}():l();var S=Math.random().toString(36).substring(2);function P(){}var A=void 0,x=1,w=2,T={error:null};function O(t){try{return t.then}catch(t){return T.error=t,T}}function N(t,e,n){var i,r,s,o;e.constructor===t.constructor&&n===m&&e.constructor.resolve===b?(s=t,(o=e)._state===x?M(s,o._result):o._state===w?j(s,o._result):E(o,void 0,function(t){return k(s,t)},function(t){return j(s,t)})):n===T?(j(t,T.error),T.error=null):void 0===n?M(t,e):c(n)?(i=e,r=n,a(function(e){var n=!1,t=function(t,e,n,i){try{t.call(e,n,i)}catch(t){return t}}(r,i,function(t){n||(n=!0,i!==t?k(e,t):M(e,t))},function(t){n||(n=!0,j(e,t))},e._label);!n&&t&&(n=!0,j(e,t))},t)):M(t,e)}function k(t,e){var n,i;t===e?j(t,new TypeError("You cannot resolve a promise with itself")):(i=typeof(n=e),null===n||"object"!==i&&"function"!==i?M(t,e):N(t,e,O(e)))}function U(t){t._onerror&&t._onerror(t._result),F(t)}function M(t,e){t._state===A&&(t._result=e,t._state=x,0!==t._subscribers.length&&a(F,t))}function j(t,e){t._state===A&&(t._state=w,t._result=e,a(U,t))}function E(t,e,n,i){var r=t._subscribers,s=r.length;t._onerror=null,r[s]=e,r[s+x]=n,r[s+w]=i,0===s&&t._state&&a(F,t)}function F(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var i=void 0,r=void 0,s=t._result,o=0;o<e.length;o+=3)i=e[o],r=e[o+n],i?R(n,i,r,s):r(s);t._subscribers.length=0}}function R(t,e,n,i){var r=c(n),s=void 0,o=void 0,a=void 0,u=void 0;if(r){if((s=function(t,e){try{return t(e)}catch(t){return T.error=t,T}}(n,i))===T?(u=!0,o=s.error,s.error=null):a=!0,e===s)return void j(e,new TypeError("A promises callback cannot return that same promise."))}else s=i,a=!0;e._state!==A||(r&&a?k(e,s):u?j(e,o):t===x?M(e,s):t===w&&j(e,s))}var I=0;function D(t){t[S]=I++,t._state=void 0,t._result=void 0,t._subscribers=[]}var C=function(){function t(t,e){this._instanceConstructor=t,this.promise=new t(P),this.promise[S]||D(this.promise),n(e)?(this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?M(this.promise,this._result):(this.length=this.length||0,this._enumerate(e),0===this._remaining&&M(this.promise,this._result))):j(this.promise,new Error("Array Methods must be provided an Array"))}return t.prototype._enumerate=function(t){for(var e=0;this._state===A&&e<t.length;e++)this._eachEntry(t[e],e)},t.prototype._eachEntry=function(e,t){var n=this._instanceConstructor,i=n.resolve;if(i===b){var r=O(e);if(r===m&&e._state!==A)this._settledAt(e._state,t,e._result);else if("function"!=typeof r)this._remaining--,this._result[t]=e;else if(n===L){var s=new n(P);N(s,e,r),this._willSettleAt(s,t)}else this._willSettleAt(new n(function(t){return t(e)}),t)}else this._willSettleAt(i(e),t)},t.prototype._settledAt=function(t,e,n){var i=this.promise;i._state===A&&(this._remaining--,t===w?j(i,n):this._result[e]=n),0===this._remaining&&M(i,this._result)},t.prototype._willSettleAt=function(t,e){var n=this;E(t,void 0,function(t){return n._settledAt(x,e,t)},function(t){return n._settledAt(w,e,t)})},t}();var L=function(){function e(t){this[S]=I++,this._result=this._state=void 0,this._subscribers=[],P!==t&&("function"!=typeof t&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof e?function(e,t){try{t(function(t){k(e,t)},function(t){j(e,t)})}catch(t){j(e,t)}}(this,t):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return e.prototype.catch=function(t){return this.then(null,t)},e.prototype.finally=function(e){var n=this.constructor;return this.then(function(t){return n.resolve(e()).then(function(){return t})},function(t){return n.resolve(e()).then(function(){throw t})})},e}();return L.prototype.then=m,L.all=function(t){return new C(this,t).promise},L.race=function(r){var s=this;return n(r)?new s(function(t,e){for(var n=r.length,i=0;i<n;i++)s.resolve(r[i]).then(t,e)}):new s(function(t,e){return e(new TypeError("You must pass an array to race."))})},L.resolve=b,L.reject=function(t){var e=new this(P);return j(e,t),e},L._setScheduler=function(t){r=t},L._setAsap=function(t){a=t},L._asap=a,L.polyfill=function(){var t=void 0;if(void 0!==q)t=q;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var e=t.Promise;if(e){var n=null;try{n=Object.prototype.toString.call(e.resolve())}catch(t){}if("[object Promise]"===n&&!e.cast)return}t.Promise=L},L.Promise=L},"object"==typeof i&&void 0!==n?n.exports=e():"function"==typeof define&&define.amd?define(e):t.ES6Promise=e()}).call(this,$("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:2}],2:[function(t,e,n){var i,r,s=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(e){if(i===setTimeout)return setTimeout(e,0);if((i===o||!i)&&setTimeout)return i=setTimeout,setTimeout(e,0);try{return i(e,0)}catch(t){try{return i.call(null,e,0)}catch(t){return i.call(this,e,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:o}catch(t){i=o}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(t){r=a}}();var c,h=[],l=!1,f=-1;function d(){l&&c&&(l=!1,c.length?h=c.concat(h):f=-1,h.length&&p())}function p(){if(!l){var t=u(d);l=!0;for(var e=h.length;e;){for(c=h,h=[];++f<e;)c&&c[f].run();f=-1,e=h.length}c=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(t)}}function v(t,e){this.fun=t,this.array=e}function _(){}s.nextTick=function(t){var e=new Array(arguments.length-1);if(1<arguments.length)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];h.push(new v(t,e)),1!==h.length||l||u(p)},v.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=_,s.addListener=_,s.once=_,s.off=_,s.removeListener=_,s.removeAllListeners=_,s.emit=_,s.prependListener=_,s.prependOnceListener=_,s.listeners=function(t){return[]},s.binding=function(t){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(t){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},{}],3:[function(t,Y,J){(function(G){!function(){var t="object"==typeof self&&self.self===self&&self||"object"==typeof G&&G.global===G&&G||this||{},e=t._,i=Array.prototype,o=Object.prototype,l="undefined"!=typeof Symbol?Symbol.prototype:null,r=i.push,u=i.slice,f=o.toString,s=o.hasOwnProperty,n=Array.isArray,a=Object.keys,c=Object.create,h=function(){},d=function(t){return t instanceof d?t:this instanceof d?void(this._wrapped=t):new d(t)};void 0===J||J.nodeType?t._=d:(void 0!==Y&&!Y.nodeType&&Y.exports&&(J=Y.exports=d),J._=d),d.VERSION="1.9.0";var p,v=function(r,s,t){if(void 0===s)return r;switch(null==t?3:t){case 1:return function(t){return r.call(s,t)};case 3:return function(t,e,n){return r.call(s,t,e,n)};case 4:return function(t,e,n,i){return r.call(s,t,e,n,i)}}return function(){return r.apply(s,arguments)}},_=function(t,e,n){return d.iteratee!==p?d.iteratee(t,e):null==t?d.identity:d.isFunction(t)?v(t,e,n):d.isObject(t)&&!d.isArray(t)?d.matcher(t):d.property(t)};d.iteratee=p=function(t,e){return _(t,e,1/0)};var y=function(r,s){return s=null==s?r.length-1:+s,function(){for(var t=Math.max(arguments.length-s,0),e=Array(t),n=0;n<t;n++)e[n]=arguments[n+s];switch(s){case 0:return r.call(this,e);case 1:return r.call(this,arguments[0],e);case 2:return r.call(this,arguments[0],arguments[1],e)}var i=Array(s+1);for(n=0;n<s;n++)i[n]=arguments[n];return i[s]=e,r.apply(this,i)}},g=function(t){if(!d.isObject(t))return{};if(c)return c(t);h.prototype=t;var e=new h;return h.prototype=null,e},m=function(e){return function(t){return null==t?void 0:t[e]}},b=function(t,e){for(var n=e.length,i=0;i<n;i++){if(null==t)return;t=t[e[i]]}return n?t:void 0},S=Math.pow(2,53)-1,P=m("length"),A=function(t){var e=P(t);return"number"==typeof e&&0<=e&&e<=S};d.each=d.forEach=function(t,e,n){var i,r;if(e=v(e,n),A(t))for(i=0,r=t.length;i<r;i++)e(t[i],i,t);else{var s=d.keys(t);for(i=0,r=s.length;i<r;i++)e(t[s[i]],s[i],t)}return t},d.map=d.collect=function(t,e,n){e=_(e,n);for(var i=!A(t)&&d.keys(t),r=(i||t).length,s=Array(r),o=0;o<r;o++){var a=i?i[o]:o;s[o]=e(t[a],a,t)}return s};var x=function(u){return function(t,e,n,i){var r=3<=arguments.length;return function(t,e,n,i){var r=!A(t)&&d.keys(t),s=(r||t).length,o=0<u?0:s-1;for(i||(n=t[r?r[o]:o],o+=u);0<=o&&o<s;o+=u){var a=r?r[o]:o;n=e(n,t[a],a,t)}return n}(t,v(e,i,4),n,r)}};d.reduce=d.foldl=d.inject=x(1),d.reduceRight=d.foldr=x(-1),d.find=d.detect=function(t,e,n){var i=(A(t)?d.findIndex:d.findKey)(t,e,n);if(void 0!==i&&-1!==i)return t[i]},d.filter=d.select=function(t,i,e){var r=[];return i=_(i,e),d.each(t,function(t,e,n){i(t,e,n)&&r.push(t)}),r},d.reject=function(t,e,n){return d.filter(t,d.negate(_(e)),n)},d.every=d.all=function(t,e,n){e=_(e,n);for(var i=!A(t)&&d.keys(t),r=(i||t).length,s=0;s<r;s++){var o=i?i[s]:s;if(!e(t[o],o,t))return!1}return!0},d.some=d.any=function(t,e,n){e=_(e,n);for(var i=!A(t)&&d.keys(t),r=(i||t).length,s=0;s<r;s++){var o=i?i[s]:s;if(e(t[o],o,t))return!0}return!1},d.contains=d.includes=d.include=function(t,e,n,i){return A(t)||(t=d.values(t)),("number"!=typeof n||i)&&(n=0),0<=d.indexOf(t,e,n)},d.invoke=y(function(t,n,i){var r,s;return d.isFunction(n)?s=n:d.isArray(n)&&(r=n.slice(0,-1),n=n[n.length-1]),d.map(t,function(t){var e=s;if(!e){if(r&&r.length&&(t=b(t,r)),null==t)return;e=t[n]}return null==e?e:e.apply(t,i)})}),d.pluck=function(t,e){return d.map(t,d.property(e))},d.where=function(t,e){return d.filter(t,d.matcher(e))},d.findWhere=function(t,e){return d.find(t,d.matcher(e))},d.max=function(t,i,e){var n,r,s=-1/0,o=-1/0;if(null==i||"number"==typeof i&&"object"!=typeof t[0]&&null!=t)for(var a=0,u=(t=A(t)?t:d.values(t)).length;a<u;a++)null!=(n=t[a])&&s<n&&(s=n);else i=_(i,e),d.each(t,function(t,e,n){r=i(t,e,n),(o<r||r===-1/0&&s===-1/0)&&(s=t,o=r)});return s},d.min=function(t,i,e){var n,r,s=1/0,o=1/0;if(null==i||"number"==typeof i&&"object"!=typeof t[0]&&null!=t)for(var a=0,u=(t=A(t)?t:d.values(t)).length;a<u;a++)null!=(n=t[a])&&n<s&&(s=n);else i=_(i,e),d.each(t,function(t,e,n){((r=i(t,e,n))<o||r===1/0&&s===1/0)&&(s=t,o=r)});return s},d.shuffle=function(t){return d.sample(t,1/0)},d.sample=function(t,e,n){if(null==e||n)return A(t)||(t=d.values(t)),t[d.random(t.length-1)];var i=A(t)?d.clone(t):d.values(t),r=P(i);e=Math.max(Math.min(e,r),0);for(var s=r-1,o=0;o<e;o++){var a=d.random(o,s),u=i[o];i[o]=i[a],i[a]=u}return i.slice(0,e)},d.sortBy=function(t,i,e){var r=0;return i=_(i,e),d.pluck(d.map(t,function(t,e,n){return{value:t,index:r++,criteria:i(t,e,n)}}).sort(function(t,e){var n=t.criteria,i=e.criteria;if(n!==i){if(i<n||void 0===n)return 1;if(n<i||void 0===i)return-1}return t.index-e.index}),"value")};var w=function(o,e){return function(i,r,t){var s=e?[[],[]]:{};return r=_(r,t),d.each(i,function(t,e){var n=r(t,e,i);o(s,t,n)}),s}};d.groupBy=w(function(t,e,n){d.has(t,n)?t[n].push(e):t[n]=[e]}),d.indexBy=w(function(t,e,n){t[n]=e}),d.countBy=w(function(t,e,n){d.has(t,n)?t[n]++:t[n]=1});var T=/[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;d.toArray=function(t){return t?d.isArray(t)?u.call(t):d.isString(t)?t.match(T):A(t)?d.map(t,d.identity):d.values(t):[]},d.size=function(t){return null==t?0:A(t)?t.length:d.keys(t).length},d.partition=w(function(t,e,n){t[n?0:1].push(e)},!0),d.first=d.head=d.take=function(t,e,n){if(!(null==t||t.length<1))return null==e||n?t[0]:d.initial(t,t.length-e)},d.initial=function(t,e,n){return u.call(t,0,Math.max(0,t.length-(null==e||n?1:e)))},d.last=function(t,e,n){if(!(null==t||t.length<1))return null==e||n?t[t.length-1]:d.rest(t,Math.max(0,t.length-e))},d.rest=d.tail=d.drop=function(t,e,n){return u.call(t,null==e||n?1:e)},d.compact=function(t){return d.filter(t,Boolean)};var O=function(t,e,n,i){for(var r=(i=i||[]).length,s=0,o=P(t);s<o;s++){var a=t[s];if(A(a)&&(d.isArray(a)||d.isArguments(a)))if(e)for(var u=0,c=a.length;u<c;)i[r++]=a[u++];else O(a,e,n,i),r=i.length;else n||(i[r++]=a)}return i};d.flatten=function(t,e){return O(t,e,!1)},d.without=y(function(t,e){return d.difference(t,e)}),d.uniq=d.unique=function(t,e,n,i){d.isBoolean(e)||(i=n,n=e,e=!1),null!=n&&(n=_(n,i));for(var r=[],s=[],o=0,a=P(t);o<a;o++){var u=t[o],c=n?n(u,o,t):u;e&&!n?(o&&s===c||r.push(u),s=c):n?d.contains(s,c)||(s.push(c),r.push(u)):d.contains(r,u)||r.push(u)}return r},d.union=y(function(t){return d.uniq(O(t,!0,!0))}),d.intersection=function(t){for(var e=[],n=arguments.length,i=0,r=P(t);i<r;i++){var s=t[i];if(!d.contains(e,s)){var o;for(o=1;o<n&&d.contains(arguments[o],s);o++);o===n&&e.push(s)}}return e},d.difference=y(function(t,e){return e=O(e,!0,!0),d.filter(t,function(t){return!d.contains(e,t)})}),d.unzip=function(t){for(var e=t&&d.max(t,P).length||0,n=Array(e),i=0;i<e;i++)n[i]=d.pluck(t,i);return n},d.zip=y(d.unzip),d.object=function(t,e){for(var n={},i=0,r=P(t);i<r;i++)e?n[t[i]]=e[i]:n[t[i][0]]=t[i][1];return n};var N=function(s){return function(t,e,n){e=_(e,n);for(var i=P(t),r=0<s?0:i-1;0<=r&&r<i;r+=s)if(e(t[r],r,t))return r;return-1}};d.findIndex=N(1),d.findLastIndex=N(-1),d.sortedIndex=function(t,e,n,i){for(var r=(n=_(n,i,1))(e),s=0,o=P(t);s<o;){var a=Math.floor((s+o)/2);n(t[a])<r?s=a+1:o=a}return s};var k=function(s,o,a){return function(t,e,n){var i=0,r=P(t);if("number"==typeof n)0<s?i=0<=n?n:Math.max(n+r,i):r=0<=n?Math.min(n+1,r):n+r+1;else if(a&&n&&r)return t[n=a(t,e)]===e?n:-1;if(e!=e)return 0<=(n=o(u.call(t,i,r),d.isNaN))?n+i:-1;for(n=0<s?i:r-1;0<=n&&n<r;n+=s)if(t[n]===e)return n;return-1}};d.indexOf=k(1,d.findIndex,d.sortedIndex),d.lastIndexOf=k(-1,d.findLastIndex),d.range=function(t,e,n){null==e&&(e=t||0,t=0),n||(n=e<t?-1:1);for(var i=Math.max(Math.ceil((e-t)/n),0),r=Array(i),s=0;s<i;s++,t+=n)r[s]=t;return r},d.chunk=function(t,e){if(null==e||e<1)return[];for(var n=[],i=0,r=t.length;i<r;)n.push(u.call(t,i,i+=e));return n};var U=function(t,e,n,i,r){if(!(i instanceof e))return t.apply(n,r);var s=g(t.prototype),o=t.apply(s,r);return d.isObject(o)?o:s};d.bind=y(function(e,n,i){if(!d.isFunction(e))throw new TypeError("Bind must be called on a function");var r=y(function(t){return U(e,r,n,this,i.concat(t))});return r}),d.partial=y(function(r,s){var o=d.partial.placeholder,a=function(){for(var t=0,e=s.length,n=Array(e),i=0;i<e;i++)n[i]=s[i]===o?arguments[t++]:s[i];for(;t<arguments.length;)n.push(arguments[t++]);return U(r,a,this,this,n)};return a}),(d.partial.placeholder=d).bindAll=y(function(t,e){var n=(e=O(e,!1,!1)).length;if(n<1)throw new Error("bindAll must be passed function names");for(;n--;){var i=e[n];t[i]=d.bind(t[i],t)}}),d.memoize=function(i,r){var s=function(t){var e=s.cache,n=""+(r?r.apply(this,arguments):t);return d.has(e,n)||(e[n]=i.apply(this,arguments)),e[n]};return s.cache={},s},d.delay=y(function(t,e,n){return setTimeout(function(){return t.apply(null,n)},e)}),d.defer=d.partial(d.delay,d,1),d.throttle=function(n,i,r){var s,o,a,u,c=0;r||(r={});var h=function(){c=!1===r.leading?0:d.now(),s=null,u=n.apply(o,a),s||(o=a=null)},t=function(){var t=d.now();c||!1!==r.leading||(c=t);var e=i-(t-c);return o=this,a=arguments,e<=0||i<e?(s&&(clearTimeout(s),s=null),c=t,u=n.apply(o,a),s||(o=a=null)):s||!1===r.trailing||(s=setTimeout(h,e)),u};return t.cancel=function(){clearTimeout(s),c=0,s=o=a=null},t},d.debounce=function(n,i,r){var s,o,a=function(t,e){s=null,e&&(o=n.apply(t,e))},t=y(function(t){if(s&&clearTimeout(s),r){var e=!s;s=setTimeout(a,i),e&&(o=n.apply(this,t))}else s=d.delay(a,i,this,t);return o});return t.cancel=function(){clearTimeout(s),s=null},t},d.wrap=function(t,e){return d.partial(e,t)},d.negate=function(t){return function(){return!t.apply(this,arguments)}},d.compose=function(){var n=arguments,i=n.length-1;return function(){for(var t=i,e=n[i].apply(this,arguments);t--;)e=n[t].call(this,e);return e}},d.after=function(t,e){return function(){if(--t<1)return e.apply(this,arguments)}},d.before=function(t,e){var n;return function(){return 0<--t&&(n=e.apply(this,arguments)),t<=1&&(e=null),n}},d.once=d.partial(d.before,2),d.restArguments=y;var M=!{toString:null}.propertyIsEnumerable("toString"),j=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],E=function(t,e){var n=j.length,i=t.constructor,r=d.isFunction(i)&&i.prototype||o,s="constructor";for(d.has(t,s)&&!d.contains(e,s)&&e.push(s);n--;)(s=j[n])in t&&t[s]!==r[s]&&!d.contains(e,s)&&e.push(s)};d.keys=function(t){if(!d.isObject(t))return[];if(a)return a(t);var e=[];for(var n in t)d.has(t,n)&&e.push(n);return M&&E(t,e),e},d.allKeys=function(t){if(!d.isObject(t))return[];var e=[];for(var n in t)e.push(n);return M&&E(t,e),e},d.values=function(t){for(var e=d.keys(t),n=e.length,i=Array(n),r=0;r<n;r++)i[r]=t[e[r]];return i},d.mapObject=function(t,e,n){e=_(e,n);for(var i=d.keys(t),r=i.length,s={},o=0;o<r;o++){var a=i[o];s[a]=e(t[a],a,t)}return s},d.pairs=function(t){for(var e=d.keys(t),n=e.length,i=Array(n),r=0;r<n;r++)i[r]=[e[r],t[e[r]]];return i},d.invert=function(t){for(var e={},n=d.keys(t),i=0,r=n.length;i<r;i++)e[t[n[i]]]=n[i];return e},d.functions=d.methods=function(t){var e=[];for(var n in t)d.isFunction(t[n])&&e.push(n);return e.sort()};var F=function(u,c){return function(t){var e=arguments.length;if(c&&(t=Object(t)),e<2||null==t)return t;for(var n=1;n<e;n++)for(var i=arguments[n],r=u(i),s=r.length,o=0;o<s;o++){var a=r[o];c&&void 0!==t[a]||(t[a]=i[a])}return t}};d.extend=F(d.allKeys),d.extendOwn=d.assign=F(d.keys),d.findKey=function(t,e,n){e=_(e,n);for(var i,r=d.keys(t),s=0,o=r.length;s<o;s++)if(e(t[i=r[s]],i,t))return i};var R,I,D=function(t,e,n){return e in n};d.pick=y(function(t,e){var n={},i=e[0];if(null==t)return n;d.isFunction(i)?(1<e.length&&(i=v(i,e[1])),e=d.allKeys(t)):(i=D,e=O(e,!1,!1),t=Object(t));for(var r=0,s=e.length;r<s;r++){var o=e[r],a=t[o];i(a,o,t)&&(n[o]=a)}return n}),d.omit=y(function(t,n){var e,i=n[0];return d.isFunction(i)?(i=d.negate(i),1<n.length&&(e=n[1])):(n=d.map(O(n,!1,!1),String),i=function(t,e){return!d.contains(n,e)}),d.pick(t,i,e)}),d.defaults=F(d.allKeys,!0),d.create=function(t,e){var n=g(t);return e&&d.extendOwn(n,e),n},d.clone=function(t){return d.isObject(t)?d.isArray(t)?t.slice():d.extend({},t):t},d.tap=function(t,e){return e(t),t},d.isMatch=function(t,e){var n=d.keys(e),i=n.length;if(null==t)return!i;for(var r=Object(t),s=0;s<i;s++){var o=n[s];if(e[o]!==r[o]||!(o in r))return!1}return!0},R=function(t,e,n,i){if(t===e)return 0!==t||1/t==1/e;if(null==t||null==e)return!1;if(t!=t)return e!=e;var r=typeof t;return("function"===r||"object"===r||"object"==typeof e)&&I(t,e,n,i)},I=function(t,e,n,i){t instanceof d&&(t=t._wrapped),e instanceof d&&(e=e._wrapped);var r=f.call(t);if(r!==f.call(e))return!1;switch(r){case"[object RegExp]":case"[object String]":return""+t==""+e;case"[object Number]":return+t!=+t?+e!=+e:0==+t?1/+t==1/e:+t==+e;case"[object Date]":case"[object Boolean]":return+t==+e;case"[object Symbol]":return l.valueOf.call(t)===l.valueOf.call(e)}var s="[object Array]"===r;if(!s){if("object"!=typeof t||"object"!=typeof e)return!1;var o=t.constructor,a=e.constructor;if(o!==a&&!(d.isFunction(o)&&o instanceof o&&d.isFunction(a)&&a instanceof a)&&"constructor"in t&&"constructor"in e)return!1}i=i||[];for(var u=(n=n||[]).length;u--;)if(n[u]===t)return i[u]===e;if(n.push(t),i.push(e),s){if((u=t.length)!==e.length)return!1;for(;u--;)if(!R(t[u],e[u],n,i))return!1}else{var c,h=d.keys(t);if(u=h.length,d.keys(e).length!==u)return!1;for(;u--;)if(c=h[u],!d.has(e,c)||!R(t[c],e[c],n,i))return!1}return n.pop(),i.pop(),!0},d.isEqual=function(t,e){return R(t,e)},d.isEmpty=function(t){return null==t||(A(t)&&(d.isArray(t)||d.isString(t)||d.isArguments(t))?0===t.length:0===d.keys(t).length)},d.isElement=function(t){return!(!t||1!==t.nodeType)},d.isArray=n||function(t){return"[object Array]"===f.call(t)},d.isObject=function(t){var e=typeof t;return"function"===e||"object"===e&&!!t},d.each(["Arguments","Function","String","Number","Date","RegExp","Error","Symbol","Map","WeakMap","Set","WeakSet"],function(e){d["is"+e]=function(t){return f.call(t)==="[object "+e+"]"}}),d.isArguments(arguments)||(d.isArguments=function(t){return d.has(t,"callee")});var C=t.document&&t.document.childNodes;"function"!=typeof/./&&"object"!=typeof Int8Array&&"function"!=typeof C&&(d.isFunction=function(t){return"function"==typeof t||!1}),d.isFinite=function(t){return!d.isSymbol(t)&&isFinite(t)&&!isNaN(parseFloat(t))},d.isNaN=function(t){return d.isNumber(t)&&isNaN(t)},d.isBoolean=function(t){return!0===t||!1===t||"[object Boolean]"===f.call(t)},d.isNull=function(t){return null===t},d.isUndefined=function(t){return void 0===t},d.has=function(t,e){if(!d.isArray(e))return null!=t&&s.call(t,e);for(var n=e.length,i=0;i<n;i++){var r=e[i];if(null==t||!s.call(t,r))return!1;t=t[r]}return!!n},d.noConflict=function(){return t._=e,this},d.identity=function(t){return t},d.constant=function(t){return function(){return t}},d.noop=function(){},d.property=function(e){return d.isArray(e)?function(t){return b(t,e)}:m(e)},d.propertyOf=function(e){return null==e?function(){}:function(t){return d.isArray(t)?b(e,t):e[t]}},d.matcher=d.matches=function(e){return e=d.extendOwn({},e),function(t){return d.isMatch(t,e)}},d.times=function(t,e,n){var i=Array(Math.max(0,t));e=v(e,n,1);for(var r=0;r<t;r++)i[r]=e(r);return i},d.random=function(t,e){return null==e&&(e=t,t=0),t+Math.floor(Math.random()*(e-t+1))},d.now=Date.now||function(){return(new Date).getTime()};var L={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},B=d.invert(L),q=function(e){var n=function(t){return e[t]},t="(?:"+d.keys(e).join("|")+")",i=RegExp(t),r=RegExp(t,"g");return function(t){return t=null==t?"":""+t,i.test(t)?t.replace(r,n):t}};d.escape=q(L),d.unescape=q(B),d.result=function(t,e,n){d.isArray(e)||(e=[e]);var i=e.length;if(!i)return d.isFunction(n)?n.call(t):n;for(var r=0;r<i;r++){var s=null==t?void 0:t[e[r]];void 0===s&&(s=n,r=i),t=d.isFunction(s)?s.call(t):s}return t};var $=0;d.uniqueId=function(t){var e=++$+"";return t?t+e:e},d.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var H=/(.)^/,V={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},K=/\\|'|\r|\n|\u2028|\u2029/g,W=function(t){return"\\"+V[t]};d.template=function(s,t,e){!t&&e&&(t=e),t=d.defaults({},t,d.templateSettings);var n,i=RegExp([(t.escape||H).source,(t.interpolate||H).source,(t.evaluate||H).source].join("|")+"|$","g"),o=0,a="__p+='";s.replace(i,function(t,e,n,i,r){return a+=s.slice(o,r).replace(K,W),o=r+t.length,e?a+="'+\n((__t=("+e+"))==null?'':_.escape(__t))+\n'":n?a+="'+\n((__t=("+n+"))==null?'':__t)+\n'":i&&(a+="';\n"+i+"\n__p+='"),t}),a+="';\n",t.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{n=new Function(t.variable||"obj","_",a)}catch(t){throw t.source=a,t}var r=function(t){return n.call(this,t,d)},u=t.variable||"obj";return r.source="function("+u+"){\n"+a+"}",r},d.chain=function(t){var e=d(t);return e._chain=!0,e};var z=function(t,e){return t._chain?d(e).chain():e};d.mixin=function(n){return d.each(d.functions(n),function(t){var e=d[t]=n[t];d.prototype[t]=function(){var t=[this._wrapped];return r.apply(t,arguments),z(this,e.apply(d,t))}}),d},d.mixin(d),d.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var n=i[e];d.prototype[e]=function(){var t=this._wrapped;return n.apply(t,arguments),"shift"!==e&&"splice"!==e||0!==t.length||delete t[0],z(this,t)}}),d.each(["concat","join","slice"],function(t){var e=i[t];d.prototype[t]=function(){return z(this,e.apply(this._wrapped,arguments))}}),d.prototype.value=function(){return this._wrapped},d.prototype.valueOf=d.prototype.toJSON=d.prototype.value,d.prototype.toString=function(){return String(this._wrapped)},"function"==typeof define&&define.amd&&define("underscore",[],function(){return d})}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(t,e,n){for(var r=[],i=0;i<256;++i)r[i]=(i+256).toString(16).substr(1);e.exports=function(t,e){var n=e||0,i=r;return i[t[n++]]+i[t[n++]]+i[t[n++]]+i[t[n++]]+"-"+i[t[n++]]+i[t[n++]]+"-"+i[t[n++]]+i[t[n++]]+"-"+i[t[n++]]+i[t[n++]]+"-"+i[t[n++]]+i[t[n++]]+i[t[n++]]+i[t[n++]]+i[t[n++]]+i[t[n++]]}},{}],5:[function(t,e,n){var i="undefined"!=typeof crypto&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&msCrypto.getRandomValues.bind(msCrypto);if(i){var r=new Uint8Array(16);e.exports=function(){return i(r),r}}else{var s=new Array(16);e.exports=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),s[e]=t>>>((3&e)<<3)&255;return s}}},{}],6:[function(t,e,n){var o=t("./lib/rng"),a=t("./lib/bytesToUuid");e.exports=function(t,e,n){var i=e&&n||0;"string"==typeof t&&(e="binary"===t?new Array(16):null,t=null);var r=(t=t||{}).random||(t.rng||o)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e)for(var s=0;s<16;++s)e[i+s]=r[s];return e||a(r)}},{"./lib/bytesToUuid":4,"./lib/rng":5}],7:[function(t,e,n){"use strict";var i=t("underscore"),r=t("./elem"),s=t("./region"),o=t("./logger"),a=function(t){r.call(this,t),this._type="state",this.container=null,this.region=null,this.children=[],this.setObserverType("container")};a.prototype=i.create(r.prototype,{constructor:a,_cname:"ProtoState",getRegion:function(t){return i.isNumber(t)?this.children[t]:this.region},getRegionByName:function(e){return i.find(this.children,function(t){return t.getName()===e})},getRegionById:function(e){return i.find(this.children,function(t){return t.getId()===e})},filterActiveRegion:function(){return i.filter(this.children,function(t){return t.isActive()})},completion:function(){this.isActive()||o.error(this._cname+'インスタンス"'+this._name+'"はすでに非アクティブ化されています。'),this._async(function(){this._exit(),i.isNull(this.container)||this.notify("container","completion")})},_getParentState:function(){var t=null;return i.isNull(this.container)||i.isNull(this.container.parent)||(t=this.container.parent),t},_hasSubState:function(){return i.some(this.children,function(t){return 0<t.children.states.length})},update:function(t){var e=i.toArray(arguments).slice(1);switch(t){case"entry":this._entry.apply(this,e);break;case"exit":this._exit.apply(this,e);break;case"refresh":this._refresh.apply(this,e);break;case"completion":this.completion.apply(this,e)}},_refresh:function(t){this._depth=t,this.parent=this._getParentState(),this.notify("children","refresh",t)},_entry:function(t){this.isActive()||(this._activate(),this.notify("children","entry",t))},addState:function(){var t=i.toArray(arguments);return i.isNull(this.region)&&this.appendRegion(),this.region.addState.apply(this.region,t)},removeState:function(){var t=i.toArray(arguments);return i.isNull(this.region)&&o.error("デフォルトのRegionインスタンスが存在しません。"),this.region.removeState.apply(this.region,t)},addTransition:function(){var t=i.toArray(arguments);return i.isNull(this.region)&&this.appendRegion(),this.region.addTransition.apply(this.region,t)},removeTransition:function(){var t=i.toArray(arguments);return i.isNull(this.region)&&o.error("デフォルトのRegionインスタンスが存在しません。"),this.region.removeTransition.apply(this.region,t)},appendRegion:function(t){return this._attached&&o.error("デプロイ後は要素の追加/削除はできません。Machineクラスのundeploy()メソッドでデプロイを取り消してください。"),i.isNull(this.region)?(i.isUndefined(t)?(t=new s("default-region-of-"+this._name),o.info(this._cname+'インスタンス"'+this._name+'"のRegionインスタンスが自動作成されました。')):t instanceof s||o.error("Regionインスタンスを指定してください。"),this.region=t):i.isUndefined(t)?t=new s(!1):t instanceof s||o.error("Regionインスタンスを指定してください。"),(t.parent=this).children.push(t),this.addObserver("children",t),t.addObserver("parent",this),t._originalName||(t.setName("region-index-"+t.getIndex()+"-of-"+this._name,!0),t._setDefaultStateName()),t._refresh(this._depth),t},removeRegion:function(t){var e;return this._attached&&o.error("デプロイ後は要素の追加/削除はできません。Machineクラスのundeploy()メソッドでデプロイを取り消してください。"),t instanceof s||o.error("Regionインスタンスを指定してください。"),-1<(e=i.indexOf(this.children,t))?this.children.splice(e,1):o.error("削除対象のRegionインスタンスが見つかりません。"),t.parent=null,this.region===t&&(this.region=null),t._refresh(),this.removeObserver("children",t),t.removeObserver("parent",this),t._originalName||(t.setName(t.getId(),!0),t._setDefaultStateName()),t}}),e.exports=a},{"./elem":8,"./logger":10,"./region":16,underscore:3}],8:[function(t,e,n){"use strict";var i=t("es6-promise").Promise,r=t("underscore"),s=t("./entity"),o=t("./mixin"),a=function(t){s.call(this,t),this._type="element",this.root=null,this.parent=null,this.children=null,this._attached=!1,this._depth=0,this.setObserverType("root","parent","children"),Object.defineProperties(this,o.descriptor)};a.prototype=r.create(s.prototype,r.extend({constructor:a,_cname:"Elem",getCurrentDepth:function(){return this._depth},_async:function(t){t=r.bind(t,this),this.notify("root","async",function(){return t(),i.resolve()})},_entry:function(){this.isActive()||(this._activate(),this.notify("children","entry"))},_exit:function(){this.isActive()&&(this.notify("children","exit"),this._deactivate())}},o.helper)),e.exports=a},{"./entity":9,"./mixin":12,"es6-promise":1,underscore:3}],9:[function(t,e,n){"use strict";var i=t("uuid/v4"),r=t("underscore"),s=t("./subject"),o=t("./model"),a=t("./logger"),u=t("./util"),c=t("./mixin"),h=function(t){s.call(this),this._id=i(),u.isFalsy(t)?(this._name=this._id,this._originalName=!1):this._name=this._originalName=t,this._type="entity",this._status="inactive",this.model=new o};h.prototype=r.create(s.prototype,r.extend({constructor:h,_cname:"Entity",getId:function(){return this._id},getName:function(){return this._name},setName:function(t,e){return this._name=t,!this._originalName&&u.isFalsy(e)&&(this._originalName=t),t},isActive:function(){return"active"===this._status},_activate:function(){this.isActive()||(this._status="active",a.info(this._cname+'インスタンス"'+this._name+'"がアクティブ化されました。'))},_deactivate:function(){this.isActive()&&(this._status="inactive",a.info(this._cname+'インスタンス"'+this._name+'"が非アクティブ化されました。'))},update:r.noop},c.accessor)),e.exports=h},{"./logger":10,"./mixin":12,"./model":13,"./subject":18,"./util":20,underscore:3,"uuid/v4":6}],10:[function(t,e,n){"use strict";var i=t("underscore"),r={config:{logLevel:"DEBUG",debuggable:!0},logLevelData:["DEBUG","INFO","WARN","ERROR"],enable:function(){this.config.debuggable||(this.config.debuggable=!0)},disable:function(){this.config.debuggable&&(this.config.debuggable=!1)},setLogLevel:function(t){t=t.toUpperCase(),-1!==i.indexOf(this.logLevelData,t)&&(this.config.logLevel=t)},debug:function(t){this.config.debuggable&&i.indexOf(this.logLevelData,this.config.logLevel)<=0&&console.log("DEBUG: ",t)},info:function(t){this.config.debuggable&&i.indexOf(this.logLevelData,this.config.logLevel)<=1&&console.log("INFO: ",t)},warn:function(t){this.config.debuggable&&i.indexOf(this.logLevelData,this.config.logLevel)<=2&&console.log("WARN: ",t)},error:function(t){if(this.config.debuggable&&i.indexOf(this.logLevelData,this.config.logLevel)<=3)throw console.error("ERROR: ",t),new Error("ERROR: "+t)}};e.exports=r},{underscore:3}],11:[function(t,e,n){"use strict";var i=t("es6-promise").Promise,s=t("underscore"),r=t("./base-state"),o=t("./logger"),a=t("./util"),u=function(t,e){r.call(this,t,e),e=e||{},s.isUndefined(e.data)||this.set(e.data),this.save(),s.isUndefined(e.props)||this.setProp(e.props),s.isUndefined(e.methods)||this.setMethod(e.methods),this._deployed=!1,this._chain={main:null,activities:[],counter:0},this.appendRegion(),this.setObserverType("outer-machine")};u.prototype=s.create(r.prototype,{constructor:u,_cname:"Machine",deploy:function(){var e,n;return e=t("./transition"),n=t("./pseudo-states").ConnectionPointPseudoState,this._deployed=!0,this._chain.main=i.resolve(),this._refresh(this._depth),a.eachElem(this,s.bind(function(t){t._attached=!0,t.root=this,t instanceof u||(t.addObserver("root",this),(t instanceof r||t instanceof e)&&t.addObserver("parent",t.parent)),t instanceof n&&t.parent===this&&(t._isConnector=!0)},this)),this},undeploy:function(){var e=t("./transition");return this._deployed=!1,this._chain.main=null,a.eachElem(this,s.bind(function(t){t._attached=!1,t.root=null,t instanceof u||(t.removeObserver("root",this),(t instanceof r||t instanceof e)&&t.removeObserver("parent",t.parent))},this)),this._refresh(this._depth),this},start:function(t){var e={priority:null,deepHistory:!1};return s.isUndefined(t)||(e.priority=t),this._deployed||o.error("start()の前にdeploy()メソッドを実行してください。"),this.isActive()?o.warn('Machineインスタンス"'+this._name+'"はすでに起動しています。'):(o.info('Machineインスタンス"'+this._name+'"が動作を開始しました。'),this._addChain(s.bind(function(){return this._entry(e),i.resolve()},this))),this},finish:function(){return this._deployed||o.error("deploy()メソッドがまだ実行されていません。"),this.isActive()?this.completion():o.warn('Machineインスタンス"'+this._name+'"はすでに動作を終了しています。'),this},completion:function(){this.isActive()||o.error(this._cname+'インスタンス"'+this._name+'"はすでに非アクティブ化されています。'),this._addChain(s.bind(function(){return this._exit(),o.info('Machineインスタンス"'+this._name+'"が動作を終了しました。'),i.resolve()},this))},_addChain:function(t){this._chain.main=this._chain.main.then(t).catch(this._onRejected)},_addActivity:function(t){this._chain.activities.push(t)},_prevActivity:function(t){s.isNull(this._chain.resolve)&&(this._chain.counter+=t.children.length)},_afterActivity:function(t){var n=this;t._hasSubState()||(this._chain.counter-=1,this._chain.counter<=0&&(this._chain.main=s.reduce(this._chain.activities,function(t,e){return t.then(e).catch(n._onRejected)},this._chain.main),this._chain.activities.length=0,this._chain.counter=0))},_onAborted:function(){o.info('Machineインスタンス"'+this._name+'"は処理を停止しました。')},_onRejected:function(t){return o.info(t),i.reject(t)},_inboundTransit:function(t){var e,n,i;if(s.isUndefined(t))this.start();else{for(s.isEmpty(t)&&o.error("リンク先のEntryPointPseudoStateインスタンスに対応するキーが指定されてません。"),e=0,n=this.children.length;e<n;e+=1)if(i=this.children[e].children.states[t],!s.isUndefined(i))return void this.start(i);o.error("エンドポイントのEntryPointPseudoStateインスタンスが指定されてません。")}},_outboundTransit:function(t){this.completion(),this._addChain(s.bind(function(){return this.notify("outer-machine","link-back",t.getId()),i.resolve()},this))},update:function(t,e){var n=s.toArray(arguments).slice(1);switch(t){case"async":this._addChain(e);break;case"async-activity":this._addActivity(e);break;case"prev-activity":this._prevActivity.apply(this,n);break;case"after-activity":this._afterActivity.apply(this,n);break;case"entry":this._entry.apply(this,n);break;case"exit":this._exit.apply(this,n);break;case"completion":this.completion.apply(this,n);break;case"termination":this._onAborted.apply(this,n);break;case"link-forward":this._inboundTransit.apply(this,n);break;case"exit-point":this._outboundTransit.apply(this,n)}}});var c=function(t){r.call(this,t),this._linkedMachine=null,this._deployed=!1,this.appendRegion(),this.setObserverType("inner-machine")};c.prototype=s.create(r.prototype,{constructor:c,_cname:"SubMachine",deploy:function(){var e,n,i,r;return e=t("./region"),n=t("./pseudo-states").ConnectionPointPseudoState,i=t("./pseudo-states").InitialPseudoState,r=t("./states").FinalState,this._deployed=!0,a.eachElem(this,s.bind(function(t){t instanceof n?(t.addObserver("sub-root",this),t.parent===this?t._isMediator=!0:o.error("ConnectionPointPseudoStateインスタンスはサブマシン直下のサブ状態でなければなりません。")):t instanceof e||t instanceof c||t instanceof i||t instanceof r||o.error("SubMachineインスタンスはConnectionPointPseudoStateクラス以外の状態を追加できません。")},this)),this},undeploy:function(){var e;return e=t("./pseudo-states").ConnectionPointPseudoState,t("./pseudo-states").InitialPseudoState,t("./states").FinalState,this._deployed=!1,a.eachElem(this,s.bind(function(t){t instanceof e&&(t.removeObserver("sub-root",this),t._isMediator=!1)},this)),this},link:function(t){t instanceof u||o.error("Machineインスタンスを指定してください。"),this._linkedMachine=t,this.addObserver("inner-machine",t),t.addObserver("outer-machine",this)},unlink:function(){this.removeObserver("inner-machine",this._linkedMachine),this._linkedMachine.removeObserver("outer-machine",this),this._linkedMachine=null},update:function(t){var e=s.toArray(arguments).slice(1);switch(t){case"entry-point":this._linkForward.apply(this,e);break;case"link-back":this._linkBack.apply(this,e);break;case"entry":this._entry.apply(this,e);break;case"exit":this._exit.apply(this,e)}},_linkForward:function(t){this._async(function(){t._exit(),this.notify("inner-machine","link-forward",t._key)})},_linkBack:function(t){var e,n,i,r;for(n=0,i=this.children.length;n<i;n+=1)if(r=this.children[n],e=s.findWhere(r.children.states,{_key:t}),!s.isUndefined(e))return void e._entry();o.error("リンク先のEntryPointPseudoStateインスタンスに対応するキーが指定されてません。")},_entry:function(t){this._deployed||o.error("SubMachineインスタンスのdeploy()メソッドを実行してください。"),this.isActive()||(this._activate(),this.notify("children","entry",t))},_exit:function(){this._deployed||o.error("SubMachineインスタンスのdeploy()メソッドを実行してください。"),this.isActive()&&(this.notify("children","exit"),this._deactivate())}}),e.exports={Machine:u,SubMachine:c}},{"./base-state":7,"./logger":10,"./pseudo-states":15,"./region":16,"./states":17,"./transition":19,"./util":20,"es6-promise":1,underscore:3}],12:[function(t,e,n){"use strict";var a=t("underscore"),u=t("./logger"),i={accessor:{has:function(t){return this.model.has(t)},get:function(t){return this.model.get(t)},set:function(t,e){return this.model.set(t,e)},unset:function(t){return this.model.unset(t)},save:function(){this.model.save()},restore:function(){this.model.restore()},clear:function(){this.model.clear()},getProp:function(t){return this.model.getProp(t)},setProp:function(t,e){return this.model.setProp(t,e)},getMethod:function(t){return this.model.getMethod(t)},setMethod:function(t,e,n){return a.isString(t)?(n=a.isUndefined(n)?this:n,this.model.setMethod(t,e,n)):(e=a.isUndefined(e)?this:e,this.model.setMethod(t,e))},mergeProp:function(t,e){return this.model.mergeProp(t,e)},mergeMethod:function(t,e,n){return a.isString(t)?(n=a.isUndefined(n)?this:n,this.model.mergeMethod(t,e,n)):(e=a.isUndefined(e)?this:e,this.model.mergeMethod(t,e))},watch:function(t,e){this.model.watch(t,e)},unwatch:function(t,e){this.model.unwatch(t,e)}},helper:{$has:function(t){return function t(e,n){var i,r;i=n.has(e);i||(r="region"===n._type?n.parent:n.container,a.isNull(r)||(i=t(e,r)));return i}(t,this)},$get:function(t){return function t(e,n){var i,r;i=n.get(e);a.isUndefined(i)&&(r="region"===n._type?n.parent:n.container,a.isNull(r)||(i=t(e,r)));return i}(t,this)},$set:function(t,e){return function t(e,n,i){var r,s;r=i.get(e);a.isUndefined(r)?(s="region"===i._type?i.parent:i.container,a.isNull(s)||(r=t(e,n,s))):r=i.set(e,n);return r}(t,e,this)},$unset:function(t){return function t(e,n){var i,r;i=n.get(e);a.isUndefined(i)?(r="region"===n._type?n.parent:n.container,a.isNull(r)||(i=t(e,r))):i=n.unset(e);return i}(t,this)},$getProp:function(t){return function t(e,n){var i,r;i=n.getProp(e);a.isUndefined(i)&&(r="region"===n._type?n.parent:n.container,a.isNull(r)||(i=t(e,r)));return i}(t,this)},$getMethod:function(t){return function t(e,n){var i,r;i=n.getMethod(e);a.isUndefined(i)&&(r="region"===n._type?n.parent:n.container,a.isNull(r)||(i=t(e,r)));return i}(t,this)},$setProp:function(t,e){return function t(e,n,i){var r,s;a.isFunction(n)&&u.error("Functionはプロパティに登録できません。");r=i.getProp(e);a.isUndefined(r)?(s="region"===i._type?i.parent:i.container,a.isNull(s)||t(e,n,s)):i.setProp(e,n);return n}(t,e,this)},$setMethod:function(t,e,n){return function t(e,n,i,r){var s,o;a.isFunction(n)||u.error("Function以外はメソッドに登録できません。");s=r.getMethod(e);a.isUndefined(s)?(o="region"===r._type?r.parent:r.container,a.isNull(o)||t(e,n,i,o)):r.setMethod(e,n,i);return n}(t,e,n,this)}},disable:{has:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},get:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},set:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},unset:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},save:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},restore:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},clear:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},getProp:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},setProp:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},getMethod:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},setMethod:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},watch:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},unwatch:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},$getProp:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},$getMethod:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},$setProp:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},$setMethod:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},$has:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},$get:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},$set:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},$unset:function(){u.error(this._cname+"インスタンスは内部データを保持できません。")},addState:function(){u.error(this._cname+"インスタンスはサブ状態を持てません。")},removeState:function(){u.error(this._cname+"インスタンスはサブ状態を持てません。")},addTransition:function(){u.error(this._cname+"インスタンスは遷移を持てません。")},removeTransition:function(){u.error(this._cname+"インスタンスは遷移を持てません。")},appendRegion:function(){u.error(this._cname+"インスタンスは領域を持てません。")},removeRegion:function(){u.error(this._cname+"インスタンスは領域を持てません。")}},descriptor:{props:{enumerable:!1,get:function(){return this.model.props}},methods:{enumerable:!1,get:function(){return this.model.methods}}}};e.exports=i},{"./logger":10,underscore:3}],13:[function(t,e,n){"use strict";var p,i,l,v,r,s,o,a,u,c;function _(i,t,r,s){return r=r||[],p.each(t,function(t){var e,n;n=(e=P(t)).length?p.property(e)(i):i,"create"===s&&b(n,"json"),r.push([t,s,n])}),r}function h(n,i){return p.isArray(n)||A(n)?p.each(n,function(t,e){n[e]=h(t,i)}):n=p.bind(n,i),n}function y(t,n,i){return n=p.isUndefined(n)?v:n,i=p.isUndefined(i)?[]:i,p.isObject(t)&&p.each(t,function(t,e){y(t,n!==v?n+v+e:e,i)}),i.push(n),i}function g(t,e){var n=P(t);if(e=p.isUndefined(e)?[]:e,n.length){for(n=p.initial(n);n.length;)e.push(n.join(v)),n.pop();e.push(v)}return e}function m(t,e){var n,i,r,s,o;if(p.isArray(e))for(t=t||[],n=0,i=e.length;n<i;n+=1)o=p.isObject(e[n])?m(void 0,e[n]):e[n],t.push(o);else if(A(e))for(t=t||{},n=0,i=(r=p.keys(e)).length;n<i;n+=1)s=r[n],o=p.isObject(e[s])?m(t[s],e[s]):e[s],t[s]=o;else t=e;return t}function f(e){var t=p.toArray(arguments).slice(1);return p.each(t,function(t){e=m(e,t)}),e}function d(t,e){return p.isArray(t)||A(t)?p.every(t,function(t){return d(t,e)}):b(t,e)}function b(t,e){var n=!1;switch(e){case"json":A(t)||p.isArray(t)||p.isNull(t)||p.isString(t)||p.isNumber(t)||p.isBoolean(t)?n=!0:l.error("JSONデータ型以外はデータに登録できません。");break;case"function-only":p.isFunction(t)?n=!0:l.error("Function以外はメソッドに登録できません。");break;case"not-function":p.isFunction(t)?l.error("Functionはプロパティに登録できません。"):n=!0}return n}function S(t){return p.isUndefined(t)?t=v:p.isString(t)||l.error("クエリは文字列で指定してください。"),t!==v&&(t=r(t)),t}function P(t){return(t=p.isString(t)?t:""+t)!==v?t.split(v):[]}function A(t){var e,n;if(e=!1,"[object Object]"===s.call(t)){for(n=t;!p.isNull(o(n));)n=o(n);e=o(t)===n}return e}p=t("underscore"),i=t("./observable"),l=t("./logger"),u=(v="/").replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),c=new RegExp("^"+u+"+|"+u+"+$","g"),r=function(t){return t.replace(c,"")},s=Object.prototype.toString,o=Object.getPrototypeOf,(a=function(t){i.call(this),this._data=this._savedData=this.props=this.methods=this._temp=void 0,this._cache={},p.isUndefined(t)||this.set(t)}).prototype=p.create(i.prototype,{constructor:a,_cname:"Model",has:function(t){return!p.isUndefined(this.get(t))},get:function(t){var e,n;return e=P(t=S(t)),n=this._cache[t],p.isUndefined(n)&&(n=e.length?p.property(e)(this._data):this._data,p.isUndefined(n)||(this._cache[t]=n)),n},set:function(t,e){var n,i,r,s,o,a,u,c,h,l,f,d;if(p.isUndefined(e)&&(e=t,t=v),n=[],i=g(t),r=[],s=[],c=P(t=S(t)),h=this.get(t),!p.isUndefined(h)){if(p.isEqual(h,e))return e;y(h,t,r)}return y(e,t,s),o=p.difference(r,s),a=p.intersection(r,s).concat(i),u=p.difference(s,r),l=m(void 0,this._data),this._temp=m(void 0,this._data),this._set("_temp",t,m(void 0,e)),f=this._temp,delete this._temp,_(l,o,n,"delete"),_(l,a,n,"delete"),_(f,a,n,"create"),_(f,u,n,"create"),c.length?((d=p.initial(c)).length?p.property(d)(this._data):this._data)[p.last(c)]=e:this._data=e,p.each(p.compact(p.map(p.groupBy(n,"0"),function(t){var e,n,i;return 1<t.length?(e=t[0],n=t[1],p.isEqual(e[2],n[2])?void 0:{target:e[0],event:"update",value:n[2],oldValue:e[2]}):{target:(i=t[0])[0],event:i[1],value:i[2]}})),function(t){p.isUndefined(this._cache[t.target])||("delete"===t.event?delete this._cache[t.target]:this._cache[t.target]=t.value),this._bubbling(t)},this),e},unset:function(t){var e,n,i,r,s,o,a,u;return e=P(t=S(t)),n=this.get(t),i=[],r=[],s=g(t),p.isUndefined(n)||(y(n,t,r),o=m(void 0,this._data),this._temp=m(void 0,this._data),this._unset("_temp",t),a=this._temp,delete this._temp,_(o,r,i,"delete"),_(o,s,i,"delete"),_(a,s,i,"create"),e.length?delete((u=p.initial(e)).length?p.property(u)(this._data):this._data)[p.last(e)]:delete this._data,p.each(p.compact(p.map(p.groupBy(i,"0"),function(t){var e,n;return 1<t.length?(e=t[0],n=t[1],{event:"update",target:e[0],value:n[2],oldValue:e[2]}):{target:(e=t[0])[0],event:e[1],value:e[2]}})),function(t){p.isUndefined(this._cache[t.target])||("delete"===t.event?delete this._cache[t.target]:this._cache[t.target]=t.value),this._bubbling(t)},this)),n},merge:function(u){var c,t,h;return t=p.toArray(arguments),p.isString(u)?1<t.length?t=t.slice(1):(u=v,t=t[0]):u=v,u=S(u),c=this.get(u),h=[],p.each(t,function(t){var e,n,i,r,s,o,a;p.isObject(t)||l.error("マージ元は配列か連想配列を指定してください。"),e=g(u),n=y(c,u).concat(e),i=function r(s,t,o,a){var i;o=p.isUndefined(o)?v:o;a=p.isUndefined(a)?[]:a;p.isArray(t)?(i=p.isArray(s)?s.length:0,p.each(t,function(t,e){var n;n=""+(i+e),r(void 0,t,o!==v?o+v+n:n,a)})):A(t)&&p.each(t,function(t,e){var n,i;n=o!==v?o+v+e:e,i=A(s)?s[e]:void 0,r(i,t,n,a)});a.push(o);return a}(c,t,u).concat(e),r=p.intersection(n,i),s=p.difference(i,n),o=m(void 0,this._data),this._temp=m(void 0,this._data),this._merge("_temp",u,m(void 0,t)),a=this._temp,delete this._temp,_(o,r,h,"delete"),_(a,r,h,"create"),_(a,s,h,"create"),c=f(c,t),p.each(p.compact(p.map(p.groupBy(h,"0"),function(t,e){var n,i;return 1<t.length?(n=t[0],i=t[1],p.isEqual(n[2],i[2])?void 0:{event:"update",target:n[0],value:i[2],oldValue:n[2]}):{target:e,event:(i=t[0])[1],value:i[2]}})),function(t){p.isUndefined(this._cache[t.target])||(this._cache[t.target]=t.value),this._bubbling(t)},this)},this),c},save:function(){this._savedData=m(void 0,this._data)},restore:function(){p.isUndefined(this._savedData)||(this.clear(),this.set(this._savedData))},clear:function(){delete this._data,p.each(p.keys(this._cache),function(t){delete this._cache[t]},this)},_get:function(t,e){var n;return(n=P(e=S(e))).length?p.property(n)(this[t]):this[t]},_set:function(t,e,n){var i,r;return(i=P(e=S(e))).length?((r=p.initial(i)).length?p.property(r)(this[t]):this[t])[p.last(i)]=n:this[t]=n,n},_unset:function(t,e){var n,i,r;return n=P(e=S(e)),i=this._get(t,e),n.length?delete((r=p.initial(n)).length?p.property(r)(this[t]):this[t])[p.last(n)]:delete this[t],i},_merge:function(t,e,n){var i;return P(e=S(e)),i=f(this._get(t,e),n),this._set(t,e,i),i},getProp:function(t){return this._get("props",t)},setProp:function(t,