-
Notifications
You must be signed in to change notification settings - Fork 0
/
miruken-ng-bundle.min.js
7 lines (7 loc) · 199 KB
/
miruken-ng-bundle.min.js
1
2
3
4
5
6
7
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c||a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){b.exports=a("./ng.js"),a("./region.js"),a("./route.js")},{"./ng.js":2,"./region.js":3,"./route.js":4}],2:[function(require,module,exports){(function(global){var miruken=require("../miruken");require("../ioc"),require("../mvc"),require("../error"),new function(){function _instrumentScopes(a){var b=a.constructor.prototype,c=b.$new,d=b.$destroy;b.$new=function(a,b){var d=c.call(this,a,b),e=d.$parent,f=e&&e.context?e.context.newChild():new Context;return $provide(f,"$scope",d),f.onEnded(function(a){d.$destroy()}),d.context=f,d},b.$destroy=function(){var a=this.context;a!==$rootContext&&(a.end(),delete this.context),d.call(this)},$provide(Context,"$scope",function(){var a=this.parent.resolve("$scope");if(null!=a){var b=c.call(a);return b.context=this,$provide(this,"$scope",b),b}}),a.rootContext=a.context=$rootContext,$provide($rootContext,"$scope",a)}function _registerContents(a,b,c){var d=c.slice(),e=Container($appContext);Array2.forEach(c,function(c){var f=a[c];if(f&&f.prototype&&!$isProtocol(f)){var g=f.prototype;if(c=g.$name||c,g instanceof Directive){var h=new ComponentModel;h.key=f,e.addComponent(h);var i=_ngDependencies(h);i.unshift("$rootScope","$injector"),i.push(Shim(f,i.slice())),/Directive$/.test(c)&&(c=c.substring(0,c.length-9)),c=c.charAt(0).toLowerCase()+c.slice(1),b.directive(c,i),Array2.remove(d,c)}else if(g instanceof Controller){var j=new ComponentModel;j.key=[f,c],j.implementation=f,j.lifestyle=new ContextualLifestyle,e.addComponent(j,_controllerPolicies);var i=_ngDependencies(j);i.unshift("$scope","$injector"),i.push(Shim(f,i.slice())),b.controller(c,i),Array2.remove(d,c)}else if(g instanceof Filter){var k=new ComponentModel;k.key=f,e.addComponent(k);var i=_ngDependencies(k);i.unshift("$rootScope","$injector");var l=Shim(f,i.slice());i.push(function(){var a=l.apply(null,arguments);return a.filter.bind(a)}),/Filter$/.test(c)&&(c=c.substring(0,c.length-6)),c=c.charAt(0).toLowerCase()+c.slice(1),b.filter(c,i),Array2.remove(d,c)}}}),e.register($classes.fromPackage(a,d).basedOn(Resolving).withKeys.mostSpecificService())}function _installPackage(a,b,c,d,e,f){var g=Container($appContext);Array2.forEach(c,function(c){var f=a[c];if(f){var h=f.prototype;if(h instanceof Installer||h instanceof Runner){var i=(h.$inject||f.$inject||[]).slice(),j=i.indexOf("$module");j>=0&&i.splice(j,1),i.push(function(){var a=arguments;j>=0&&(a=Array.prototype.slice.call(arguments,0),a.splice(j,0,b));var c=f.new.apply(f,a);c instanceof Installer?g.register(c):c.run()}),h instanceof Installer?d.invoke(i):e.push(i)}}}),f.push($classes.fromPackage(a).basedOn(Starting).withKeys.self())}function Shim(a,b){return function(c,d){var e=c.context;_provideLiteral(e,Array2.combine(b,arguments)),d&&_provideInjector(e,d);var f=e.resolve($instant(a));for(var g in c)if(c[g]===this){c[g]=f;break}return f}}function _provideLiteral(a,b){$provide(a,null,function(a){var c=Modifier.unwrap(a.key);return b[c]})}function _provideInjector(a,b){$provide(a,null,function(a){var c=Modifier.unwrap(a.key);if($isString(c)&&b.has(c))return b.get(c)})}function _ngDependencies(a){var b=a.getDependencies();return b?Array2.filter(Array2.map(b,function(a){return a.dependency}),function(a){return $isString(a)}):[]}if("undefined"==typeof angular)throw new Error("angular not found. Did you forget to include angular.js first?");miruken.package(this,{name:"ng",imports:"miruken,miruken.callback,miruken.context,miruken.validate,miruken.ioc,miruken.mvc",exports:"Runner,Directive,Filter,DynamicControllerDirective,UseModelValidation,DigitsOnly,InhibitFocus,TrustFilter,$appContext,$envContext,$rootContext"}),eval(this.imports);var $appContext=new Context,$envContext=$appContext.newChild(),$rootContext=$envContext.newChild(),appContainer=new IoContainer,mirukenModule=angular.module("miruken.ng",[]);mirukenModule.constant("$appContext",$appContext),mirukenModule.constant("$envContext",$envContext),mirukenModule.constant("$rootContext",$rootContext),Object.defineProperty(this.package,"ngModule",{value:mirukenModule}),$appContext.addHandlers(appContainer,new NavigateCallbackHandler,new miruken.validate.ValidationCallbackHandler,new miruken.validate.ValidateJsCallbackHandler,new miruken.error.ErrorCallbackHandler),angular.module("ng").run(["$rootElement","$rootScope","$injector","$templateRequest","$compile","$q","$timeout",function(a,b,c,d,e,f,g){_instrumentScopes(b,c);var h=new miruken.ng.PartialRegion("app",a,d,e,f,g);$appContext.addHandlers(h,new BootstrapProvider),_provideInjector(appContainer,c)}]);var Runner=Base.extend({run:function(){}}),Directive=Base.extend(),Filter=Base.extend({filter:function(a){return a}}),DynamicControllerDirective=Directive.extend({restrict:"A",terminal:!0,priority:1e5,$inject:["$parse","$compile"],constructor:function(a,b){this.extend({link:function(c,d,e){var f=a(d.attr("dynamic-controller"))(c);c.src&&d.attr("src","'"+c.src+"'"),d.removeAttr("dynamic-controller"),d.attr("ng-controller",f),b(d)(c)}})}}),UseModelValidation=Directive.extend({restrict:"A",require:"ngModel",link:function(a,b,c,d){var e=a.context,f=c.useModelValidation||void 0;d.$validators.modelValidationHook=$debounce(function(){return Validating(e).validateAsync(f).finally(function(){a.$evalAsync()}),!0},100,!1,!0)}}),DigitsOnly=Directive.extend({restrict:"A",require:"?ngModel",link:function(a,b,c,d){d.$parsers.push(function(a){if(d){if(void 0==a)return"";var b=a.replace(/[^0-9]/g,"");return b!=a&&(d.$setViewValue(b),d.$render()),b}})}}),InhibitFocus=Directive.extend({restrict:"A",link:function(a,b,c){b.bind("click",function(){b.blur()})}}),TrustFilter=Filter.extend({$inject:["$sce"],constructor:function(a){this.extend({filter:function(b){return a.trustAsHtml(b)}})}});Package.implement({init:function(){this.base();var a=this.parent,b=this.ngModule;if(b){var c,d=String2.slice(this,7,-1);try{angular.module(d),c=!0}catch(e){}if(c)throw new Error(format("The Angular module '%1' already exists.",d));b.indexOf(mirukenModule.name)<0&&(b=b.slice(),b.push(mirukenModule.name)),b=angular.module(d,b)}else a&&(b=a.ngModule);b&&Object.defineProperty(this,"ngModule",{value:b}),a!==base2||this.name in global||(global[this.name]=this)},exported:function(a){this.base(a);var b=this.ngModule;if(b&&$isFunction(b.config)){var c=this,d=Container($appContext),e=[],f=[];_registerContents(this,b,a),b.config(["$injector",function(d){_installPackage(c,b,a,d,e,f)}]),b.run(["$rootScope","$injector","$q","$log",function(a,b,g,h){c.parent!==base2||c.name in a||(a[c.name]=c),_provideInjector(appContainer,b),Array2.forEach(e,function(a){b.invoke(a)}),d.register(f),g.when(d.resolveAll(Starting)).then(function(a){Array2.invoke(a,"start")},function(a){h.error(format("Startup for package %1 failed: %2",c,a.message))})}])}}}),CallbackHandler.implement({$ngApply:function(){return this.aspect(null,function(a,b){var c=b.resolve("$scope");c&&!c.$root.$$phase&&c.$root.$apply()})},$ngApplyAsync:function(a){return this.aspect(null,function(b,c){var d=c.resolve("$scope");if(d){var e=d.$root;a?setTimeout(e.$evalAsync.bind(e),a):e.$evalAsync()}})}});var _controllerPolicies=[ComponentModelAwarePolicy.Explicit];eval(this.exports)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../error":8,"../ioc":12,"../miruken":14,"../mvc":17}],3:[function(require,module,exports){var miruken=require("../miruken");require("../mvc"),new function(){miruken.package(this,{name:"ng",imports:"miruken,miruken.mvc",exports:"PartialRegion,RegionDirective"}),eval(this.imports);var PartialRegion=Base.extend(ViewRegion,{constructor:function(a,b,c,d,e,f){var g=[];this.extend({show:function(h){function i(a){var c=k.modal;if(c||k.push||0===g.length){var e=Base.extend(ViewLayer,DisposingMixin,{get index(){return g.indexOf($decorated(this,!0))},transitionTo:function(a,d,e,g){var h=this._expandTemplate(d,a);if(h.length>1&&(h=angular.element("<div/>").html(h)),c){var i=c.style||ModalProviding,j=this._layerScope,k=j.context,l=i(g).showModal(b,h,c,k),m=$decorate(this,{get modalContext(){return k},get modalResult(){return l.closed},_dispose:function(){k.end(),o&&o.push&&a.context.end(),this.base()}});return j.layer=m,k.onEnding(function(){m.dispose()}),l.visible.then(function(){return m})}return this._layerScope.layer=this,f(function(){return this._content?this._content.replaceWith(h):b.html(h),this._content=h,this}.bind(this))},transitionFrom:function(){this._content&&(this._content.remove(),this._content=null),this._layerScope&&(this._layerScope.$destroy(),this._layerScope=null)},_expandTemplate:function(a,b){var c=b.context,e=c.resolve("$scope"),f=e.$new();f.ctrl=b;var g=d(a)(f);return this._layerScope&&this._layerScope.$destroy(),this._layerScope=f,g},_dispose:function(){var a=this.index;a<0||(g.splice(a,1),this.transitionFrom())}}),h=new e;g.push(h),l.context.onEnding(function(){h.dispose()})}return g.slice(-1)[0].transitionTo(l,a,k,j)}var j=$composer,k=new RegionPolicy;if(j.handle(k,!0)&&k.tag&&!$equals(k.tag,a))return $NOT_HANDLED;var l=j.resolve(Controller);if(!l)return e.reject(new Error("A Controller could not be inferred"));var m,n,o=j.resolve(Navigation);return $isString(h)?n=h:h&&(m=h.template,n=h.templateUrl),m?i(m):n?(n.lastIndexOf(".")<0&&(n+=".html"),c(n,!0).then(function(a){return i(a)})):e.reject(new Error("A template or templateUrl must be specified"))}})}}),RegionDirective=Directive.extend({restrict:"A",scope:!0,priority:-1e3,$inject:["$templateRequest","$compile","$q","$timeout"],constructor:function(a,b,c,d){this.extend({link:function(e,f,g){var h=g.region,i=e.context,j=i.resolve(Controller),k=this.createRegion(h,f,a,b,c,d);i.addHandlers(k),j&&$isFunction(j.viewRegionCreated)&&j.viewRegionCreated(h,i)}})},createRegion:function(a,b,c,d,e,f){return new PartialRegion(a,b,c,d,e,f)}});eval(this.exports)}},{"../miruken":14,"../mvc":17}],4:[function(require,module,exports){var miruken=require("../miruken");require("../mvc"),require("../error"),new function(){miruken.package(this,{name:"ng",imports:"miruken,miruken.error,miruken.mvc",exports:"RouteRegion,RouteRegionDirective,UiRouter"}),eval(this.imports);var RouteRegion=PartialRegion.extend({constructor:function(){this.base.apply(this,arguments),this.extend({show:function(a){var b=$composer,c=this.base(a),d=b.resolve(Navigation);return d?c.then(function(a){return 0===a.index&&Routing(b).followNavigation(d),a}):c}})}}),UiRouter=Router.extend(context.$contextual,{constructor:function(a,b,c){var d={};a+=".",this.extend({handleRoute:function(a){return b.go(a.name,a.params),this.base(a)},followNavigation:function(e){for(var f=b.get(),g=0;g<f.length;++g){var h=f[g],i=h.name;if(!h.abstract&&0===i.indexOf(a)){var j=d[i];j||(j=c.compile(h.url),d[i]=j);var k=Object.create(h.params||null);if(this.matchesRoute(e,j,k))return void b.go(i,k,{notify:!1})}}}})},rejectRoute:function(a,b){return Errors($composer).handleError(b,"ui-router")},matchesRoute:function(a,b,c){var d=b.params,e=a.action.toLowerCase(),f=c.action;if(!(null!=f&&null!=e&&f.toLowerCase()===e||"action"in d))return!1;c.action=e;var g=a.controller,h=c.controller;if(h){if($isFunction(h)&&!(g instanceof h))return!1;if(!$isString(h))return!1;var i=this.extractControllerKey(h),j=Array2.filter(g.componentModel.key,$isString);if(!Array2.some(j,function(a){return this.extractControllerKey(a)===i}))return!1;c.controller=i}else{if(!("controller"in d))return!1;var j=Array2.filter(g.componentModel.key,$isString);if(0===j.length)return!1;c.controller=this.extractControllerKey(j[0])}var k=a.args;urlKeys=Object.getOwnPropertyNames(d),k&&1===k.length&&(k=k[0]);for(var l=0;l<urlKeys.length;++l){var m=urlKeys[l];if(!(m in c)){if(!(k&&m in k))return!1;c[m]=k[m]}}return!0}},{install:function(a,b){var c=this;return{name:a,abstract:!0,template:"<div route-region></div>",controller:["$scope","$state","$urlMatcherFactory",function(d,e,f){var g=d.context,h=c.new.call(c,a,e,f);h.context=g,g.addHandlers(h),(new Controller).context=g,d.$on("$stateChangeSuccess",function(a,b,c){var d=new Route({name:b.name,pattern:b.url,params:c}),e=[Route,d],f=g.$$provide(e);Routing(f.unwind()).handleRoute(d)}),$isFunction(b)&&b(h)}]}},route:function(a,b){var c={url:a};return b&&(c.params=b),c}}),RouteRegionDirective=RegionDirective.extend({scope:!1,createRegion:function(a,b,c,d,e,f){return new RouteRegion(a,b,c,d,e,f)}});eval(this.exports)}},{"../error":8,"../miruken":14,"../mvc":17}],5:[function(require,module,exports){base2={name:"base2",version:"1.1 (alpha1)",exports:"Base,Package,Abstract,Module,Enumerable,Undefined,Null,This,True,False,assignID,global",namespace:""},new function(_no_shrink_){function assignID(a,b){return b||(b=1==a.nodeType?"uniqueID":"base2ID"),a[b]||(a[b]="b2_"+_counter++),a[b]}function _extendModule(a,b){var c=a.prototype,d=a.toString().slice(1,-1);for(var e in b){var f=b[e],g="";c[e]||(e==e.toUpperCase()?g="var "+e+"="+d+"."+e+";":"function"==typeof f&&f.call&&(g="var "+e+"=base2.lang.bind('"+e+"',"+d+");",c[e]=_createModuleMethod(a,e),c[e]._module=a),-1==a.namespace.indexOf(g)&&(a.namespace+=g))}}function _createStaticModuleMethod(a,b){return function(){return a[b].apply(a,arguments)}}function _createModuleMethod(a,b){return function(){var c=_slice.call(arguments);return c.unshift(this),a[b].apply(a,c)}}function assert(a,b,c){if(!a)throw new(c||Error)(b||"Assertion failed.")}function assertArity(a,b,c){if(null==b&&(b=a.callee.length),a.length<b)throw new SyntaxError(c||"Not enough arguments.")}function assertType(a,b,c){if(b&&("function"==typeof b?!instanceOf(a,b):typeOf(a)!=b))throw new TypeError(c||"Invalid type.")}function copy(a){var b={};for(var c in a)b[c]=a[c];return b}function pcopy(a){return _dummy.prototype=a,new _dummy}function _dummy(){}function extend(a,b){if(a&&b){var c=base2.__prototyping;if(arguments.length>2){var d=b;b={},b[d]=arguments[2],c=!0}var e=global["function"==typeof b?"Function":"Object"].prototype;if(c)for(var d,f=_HIDDEN.length;d=_HIDDEN[--f];){var g=_getPropertyDescriptor(b,d);g.value!=e[d]&&(g=_override(a,d,g))&&Object.defineProperty(a,d,g)}for(d in b)if(void 0===e[d]&&"base"!==d){var g=_getPropertyDescriptor(b,d);g=_override(a,d,g),g&&Object.defineProperty(a,d,g)}}return a}function _ancestorOf(a,b){for(;b;){if(!b.ancestor)return!1;if((b=b.ancestor)==a)return!0}return!1}function _override(a,b,c){var d=c.value;if(d!==_IGNORE){if("function"!=typeof d&&"value"in c)return c;var e=_getPropertyDescriptor(a,b);if(!e)return c;var f=base2.__prototyping;if(f){var g=_getPropertyDescriptor(f,b);!g||g.value==e.value&&g.get==e.get&&g.set==e.set||(f=null)}if(d){var h=e.value;return h&&_BASE.test(d)&&(c.value=function(){var a=this.base;this.base=function(){var a=this.base,c=f&&f[b]||h;this.base=Undefined;var d=c.apply(this,arguments);return this.base=a,d};var c=d.apply(this,arguments);return this.base=a,c}),c}var i=c.get,j=e.get;i?j&&_BASE.test(i)&&(c.get=function(){var a=this.base;this.base=function(){var a=this.base,c=f&&_getPropertyDescriptor(f,b).get||j;this.base=Undefined;var d=c.apply(this,arguments);return this.base=a,d};var c=i.apply(this,arguments);return this.base=a,c}):c.get=f?function(){return _getPropertyDescriptor(f,b).get.apply(this,arguments)}:j;var k=c.set,l=e.set;return k?l&&_BASE.test(k)&&(c.set=function(){var a=this.base;this.base=function(){var a=this.base,c=f&&_getPropertyDescriptor(f,b).set||l;this.base=Undefined;var d=c.apply(this,arguments);return this.base=a,d};var c=k.apply(this,arguments);return this.base=a,c}):c.set=f?function(){return _getPropertyDescriptor(f,b).set.apply(this,arguments)}:l,c}}function _getPropertyDescriptor(a,b){for(var c,d=a;d&&!(c=Object.getOwnPropertyDescriptor(d,b));)d=Object.getPrototypeOf(d);return c}function forEach(a,b,c,d){if(null!=a){if(!d)if("function"==typeof a&&a.call)d=Function;else{if("function"==typeof a.forEach&&a.forEach!=forEach)return void a.forEach(b,c);if("number"==typeof a.length)return void _Array_forEach(a,b,c)}_Function_forEach(d||Object,a,b,c)}}function _Array_forEach(a,b,c){null==a&&(a=global);var d,e=a.length||0;if("string"==typeof a)for(d=0;d<e;d++)b.call(c,a.charAt(d),d,a);else for(d=0;d<e;d++)d in a&&b.call(c,a[d],d,a)}function _Function_forEach(a,b,c,d){var e=function(){this.i=1};e.prototype={i:1};var f=0;for(var g in new e)f++;(_Function_forEach=f>1?function(a,b,c,d){var e={};for(var f in b)e[f]||void 0!==a.prototype[f]||(e[f]=!0,c.call(d,b[f],f,b))}:function(a,b,c,d){for(var e in b)void 0===a.prototype[e]&&c.call(d,b[e],e,b)})(a,b,c,d)}function instanceOf(a,b){if("function"!=typeof b)throw new TypeError("Invalid 'instanceOf' operand.");if(null==a)return!1;if(a.constructor==b)return!0;if(b.ancestorOf)return b.ancestorOf(a.constructor);if(a instanceof b)return!0;if(Base.ancestorOf==b.ancestorOf)return!1;if(Base.ancestorOf==a.constructor.ancestorOf)return b==Object;switch(b){case Array:return"[object Array]"==_toString.call(a);case Date:return"[object Date]"==_toString.call(a);case RegExp:return"[object RegExp]"==_toString.call(a);case Function:return"function"==typeOf(a);case String:case Number:case Boolean:return typeOf(a)==typeof b.prototype.valueOf();case Object:return!0}return!1}function typeOf(a){var b=typeof a;switch(b){case"object":return null==a?"null":"function"==typeof a.constructor&&"[object Date]"!=_toString.call(a)?typeof a.constructor.prototype.valueOf():b;case"function":return"function"==typeof a.call?b:"object";default:return b}}function _createObject2(a,b,c,d){var e=Module.extend(),f=e.toString().slice(1,-1);forEach.csv(c,function(b){e[b]=unbind(a.prototype[b]),e.namespace+=format("var %1=%2.%1;",b,f)}),forEach(_slice.call(arguments,3),e.implement,e);var g=function(){return e(this.constructor==e?b.apply(null,arguments):arguments[0])};g.prototype=e.prototype;for(var h in e){var i=a[h];i&&"prototype"!=h&&"toString"!=h&&i!=Function.prototype[h]&&(e[h]=i,delete e.prototype[h]),g[h]=e[h]}return g.ancestor=Object,delete g.extend,g.namespace=g.namespace.replace(/(var (\w+)=)[^,;]+,([^\)]+)\)/g,"$1$3.$2"),g}function trim(a){return String(a).replace(_LTRIM,"").replace(_RTRIM,"")}function csv(a){return a?(a+"").split(/\s*,\s*/):[]}function format(a){var b=arguments;return(a+"").replace(new RegExp("%([1-"+(arguments.length-1)+"])","g"),function(a,c){return b[c]})}function match(a,b){return(a+"").match(b)||[]}function rescape(a){return(a+"").replace(_RESCAPE,"\\$1")}function I(a){return a}function II(a,b){return b}function K(a){return function(){return a}}function bind(a,b){var c="function"!=typeof a;if(arguments.length>2){var d=_slice.call(arguments,2);return function(){return(c?b[a]:a).apply(b,d.concat.apply(d,arguments))}}return function(){return(c?b[a]:a).apply(b,arguments)}}function compose(){var a=_slice.call(arguments);return function(){for(var b=a.length,c=a[--b].apply(this,arguments);b--;)c=a[b].call(this,c);return c}}function delegate(a,b){return function(){var c=_slice.call(arguments);return c.unshift(this),a.apply(b,c)}}function flip(a){return function(){return a.apply(this,Array2.swap(arguments,0,1))}}function not(a){return function(){return!a.apply(this,arguments)}}function partial(a){var b=_slice.call(arguments,1);return function(){for(var c=b.concat(),d=0,e=0;d<b.length&&e<arguments.length;)void 0===c[d]&&(c[d]=arguments[e++]),d++;for(;e<arguments.length;)c[d++]=arguments[e++];return Array2.contains(c,void 0)?(c.unshift(a),partial.apply(null,c)):a.apply(this,c)}}function unbind(a){return function(b){return a.apply(b,_slice.call(arguments,1))}}var Undefined=K(),Null=K(null),True=K(!0),False=K(!1),This=function(){return this},global=This(),base2=global.base2,_IGNORE=K(),_FORMAT=/%([1-9])/g,_LTRIM=/^\s\s*/,_RTRIM=/\s\s*$/,_RESCAPE=/([\/()[\]{}|*+-.,^$?\\])/g,_BASE=/\bbase\b/,_HIDDEN=["constructor","toString"],_counter=1,_slice=Array.prototype.slice;_Function_forEach();var _subclass=function(a,b){function c(){if(!base2.__prototyping){if(this.constructor!=c&&!this.__constructing){var a=arguments[0];if(a instanceof c)return a;var b=c;do{if(b.coerce){var f=b.coerce.apply(c,arguments);if(f)return f}}while((b=b.ancestor)&&b!=Base);return extend(a,d)}this.__constructing=!0;var g=e.apply(this,arguments);if(delete this.__constructing,g)return g}return this}base2.__prototyping=this.prototype;var d=new this;a&&extend(d,a),d.base=function(){},delete base2.__prototyping;var e=d.constructor;d.constructor=c;for(var f in Base)c[f]=this[f];return b&&extend(c,b),c.ancestor=this,c.ancestorOf=Base.ancestorOf,c.base=d.base,c.prototype=d,c.init&&c.init(),c["#implements"]=[],c["#implemented_by"]=[],c},Base=_subclass.call(Object,{constructor:function(){arguments.length>0&&this.extend(arguments[0])},extend:delegate(extend),toString:function(){return this.constructor.toString==Function.prototype.toString?"[object base2.Base]":"[object "+String2.slice(this.constructor,1,-1)+"]"}},Base={ancestorOf:function(a){return _ancestorOf(this,a)},extend:_subclass,forEach:function(a,b,c){_Function_forEach(this,a,b,c)},implement:function(a){return"function"==typeof a&&(_ancestorOf(Base,a)&&(this["#implements"].push(a),a["#implemented_by"].push(this)),a=a.prototype),extend(this.prototype,a),this}}),Package=Base.extend({constructor:function(a,b){function c(a){a=a.split(".");for(var b=base2,c=0;b&&null!=a[c];)b=b[a[c++]];return b}var d,e=this;if(e.extend(b),e.name&&"base2"!=e.name)if(void 0===b.parent&&(e.parent=base2),d=e.parent&&e.parent[e.name]){if(!(d instanceof Package))throw new Error(format("'%1' is reserved and cannot be used as a package name",e.name));e.namespace=d.namespace}else e.parent&&(e.version=e.version||e.parent.version,e.parent.addName(e.name,e)),e.namespace=format("var %1=%2;",e.name,String2.slice(e,1,-1));if(a){a.__package=this,a.package=d||this;for(var f,g=base2.js?base2.js.namespace:"",h="var base2=(function(){return this.base2})(),_private=base2.toString;"+base2.namespace+g,i=csv(e.imports),j=0;f=i[j];j++){var k=c(f)||c("js."+f);if(!k)throw new ReferenceError(format("Object not found: '%1'.",f));h+=k.namespace}d&&(h+=d.namespace),a.init=function(){e.init&&e.init()},a.imports=h+lang.namespace+"this.init();",h="";for(var l=d||e,m=csv(e.exports),j=0;f=m[j];j++){var n=e.name+"."+f;l.namespace+="var "+f+"="+n+";",h+="if(!"+n+")"+n+"="+f+";"}a.exported=function(){l.exported&&l.exported(m)},a.exports="if(!"+e.name+")var "+e.name+"=this.__package;"+h+"this._label_"+e.name+"();this.exported();";var o=String2.slice(e,1,-1);a["_label_"+e.name]=function(){for(var a in l){var b=l[a];b&&b.ancestorOf==Base.ancestorOf&&"constructor"!=a&&(b.toString=K("["+o+"."+a+"]"))}}}if(d)return d},exports:"",imports:"",name:"",namespace:"",parent:null,open:function(a,b){return b.name=this.name,b.parent=this.parent,new Package(a,b)},addName:function(a,b){this[a]||(this[a]=b,this.exports+=","+a,this.namespace+=format("var %1=%2.%1;",a,this.name),b&&b.ancestorOf==Base.ancestorOf&&"constructor"!=a&&(b.toString=K("["+String2.slice(this,1,-1)+"."+a+"]")),this.exported&&this.exported([a]))},addPackage:function(a){var b=new Package(null,{name:a,parent:this});return this.addName(a,b),b},package:function(a,b){return b.parent=this,new Package(a,b)},toString:function(){return format("[%1]",this.parent?String2.slice(this.parent,1,-1)+"."+this.name:this.name)}}),Abstract=Base.extend({constructor:function(){throw new TypeError("Abstract class cannot be instantiated.")}}),_moduleCount=0,Module=Abstract.extend(null,{namespace:"",extend:function(a,b){var c=this.base(),d=_moduleCount++;return c.namespace="",c.partial=this.partial,c.toString=K("[base2.Module["+d+"]]"),Module[d]=c,c.implement(this),a&&c.implement(a),b&&(extend(c,b),c.init&&c.init()),c},forEach:function(a,b){_Function_forEach(Module,this.prototype,function(c,d){"function"==typeOf(c)&&a.call(b,this[d],d,this)},this)},implement:function(a){var b=this,c=b.toString().slice(1,-1);if("function"==typeof a){if(_ancestorOf(a,b)||this.base(a),_ancestorOf(Module,a)){for(var d in a)if(void 0===b[d]){var e=a[d];"function"==typeof e&&e.call&&a.prototype[d]&&(e=_createStaticModuleMethod(a,d)),b[d]=e}b.namespace+=a.namespace.replace(/base2\.Module\[\d+\]/g,c)}}else extend(b,a),_extendModule(b,a);return b},partial:function(){var a=Module.extend(),b=a.toString().slice(1,-1);return a.namespace=this.namespace.replace(/(\w+)=b[^\)]+\)/g,"$1="+b+".$1"),this.forEach(function(b,c){a[c]=partial(bind(b,a))}),a}});Module.prototype.base=Module.prototype.extend=_IGNORE;var Enumerable=Module.extend({every:function(a,b,c){var d=!0;try{forEach(a,function(e,f){if(!(d=b.call(c,e,f,a)))throw StopIteration})}catch(e){if(e!=StopIteration)throw e}return!!d},filter:function(a,b,c){var d=0;return this.reduce(a,function(e,f,g){return b.call(c,f,g,a)&&(e[d++]=f),e},[])},invoke:function(a,b){var c=_slice.call(arguments,2);return this.map(a,"function"==typeof b?function(a){return null==a?void 0:b.apply(a,c)}:function(a){return null==a?void 0:a[b].apply(a,c)})},map:function(a,b,c){var d=[],e=0;return forEach(a,function(f,g){d[e++]=b.call(c,f,g,a)}),d},pluck:function(a,b){return this.map(a,function(a){return null==a?void 0:a[b]})},reduce:function(a,b,c,d){var e=arguments.length>2;return forEach(a,function(f,g){e?c=b.call(d,c,f,g,a):(c=f,e=!0)}),c},some:function(a,b,c){return!this.every(a,not(b),c)}}),lang={name:"lang",version:base2.version,exports:"assert,assertArity,assertType,bind,copy,extend,forEach,format,instanceOf,match,pcopy,rescape,trim,typeOf",namespace:""};"undefined"==typeof StopIteration&&(StopIteration=new Error("StopIteration")),forEach.csv=function(a,b,c){forEach(csv(a),b,c)};var _toString=Object.prototype.toString,js={name:"js",version:base2.version,exports:"Array2,Date2,Function2,String2",namespace:"",bind:function(a){var b=global;return global=a,forEach.csv(this.exports,function(b){var c=b.slice(0,-1);extend(a[c],this[b]),this[b](a[c].prototype)},this),global=b,a}};(new Date).getYear()>1900&&(Date.prototype.getYear=function(){return this.getFullYear()-1900},Date.prototype.setYear=function(a){return this.setFullYear(a+1900)});var _testDate=new Date(Date.UTC(2006,1,20));_testDate.setUTCDate(15),0!=_testDate.getUTCHours()&&forEach.csv("FullYear,Month,Date,Hours,Minutes,Seconds,Milliseconds",function(a){extend(Date.prototype,"setUTC"+a,function(){var a=this.base.apply(this,arguments);return a>=57722401e3&&(a-=36e5,this.setTime(a)),a})}),Function.prototype.prototype={},"$"=="".replace(/^/,K("$$"))&&extend(String.prototype,"replace",function(a,b){if("function"==typeof b){var c=b;b=function(){return String(c.apply(null,arguments)).split("$").join("$$")}}return this.base(a,b)});var Array2=_createObject2(Array,Array,"concat,join,pop,push,reverse,shift,slice,sort,splice,unshift",Enumerable,{batch:function(a,b,c,d,e){var f=0,g=a.length,h=function(){for(var i=Date2.now(),j=i,k=0;f<g&&i-j<c;)b.call(e,a[f],f++,a),(k++<5||k%50==0)&&(i=Date2.now());f<g?setTimeout(h,10):d&&d.call(e)};setTimeout(h,1)},combine:function(a,b){return b||(b=a),Array2.reduce(a,function(a,c,d){return a[c]=b[d],a},{})},contains:function(a,b){return-1!=Array2.indexOf(a,b)},copy:function(a){var b=_slice.call(a);return b.swap||Array2(b),b},flatten:function(a){var b=0,c=function(a,d){return Array2.like(d)?Array2.reduce(d,c,a):a[b++]=d,a};return Array2.reduce(a,c,[])},forEach:_Array_forEach,indexOf:function(a,b,c){var d=a.length;null==c?c=0:c<0&&(c=Math.max(0,d+c));for(var e=c;e<d;e++)if(a[e]===b)return e;return-1},insertAt:function(a,b,c){Array2.splice(a,b,0,c)},item:function(a,b){return b<0&&(b+=a.length),a[b]},lastIndexOf:function(a,b,c){var d=a.length;null==c?c=d-1:c<0&&(c=Math.max(0,d+c));for(var e=c;e>=0;e--)if(a[e]===b)return e;return-1},map:function(a,b,c){var d=[];return _Array_forEach(a,function(e,f){d[f]=b.call(c,e,f,a)}),d},remove:function(a,b){var c=Array2.indexOf(a,b);-1!=c&&Array2.removeAt(a,c)},removeAt:function(a,b){Array2.splice(a,b,1)},swap:function(a,b,c){b<0&&(b+=a.length),c<0&&(c+=a.length);var d=a[b];return a[b]=a[c],a[c]=d,a}});Array2.forEach=_Array_forEach,Array2.reduce=Enumerable.reduce,Array2.like=function(a){return"object"==typeOf(a)&&"number"==typeof a.length},Enumerable["#implemented_by"].pop(),Enumerable["#implemented_by"].push(Array2);var _DATE_PATTERN=/^((-\d+|\d{4,})(-(\d{2})(-(\d{2}))?)?)?T((\d{2})(:(\d{2})(:(\d{2})(\.(\d{1,3})(\d)?\d*)?)?)?)?(([+-])(\d{2})(:(\d{2}))?|Z)?$/,_DATE_PARTS={FullYear:2,Month:4,Date:6,Hours:8,Minutes:10,Seconds:12,Milliseconds:14},_TIMEZONE_PARTS={Hectomicroseconds:15,UTC:16,Sign:17,Hours:18,Minutes:20},Date2=_createObject2(Date,function(a,b,c,d,e,f,g){switch(arguments.length){case 0:return new Date;case 1:return"string"==typeof a?new Date(Date2.parse(a)):new Date(a.valueOf());default:return new Date(a,b,2==arguments.length?1:c,d||0,e||0,f||0,g||0)}},"",{toISOString:function(a){var b="####-##-##T##:##:##.###";for(var c in _DATE_PARTS)b=b.replace(/#+/,function(b){var d=a["getUTC"+c]();return"Month"==c&&d++,("000"+d).slice(-b.length)});return b+"Z"}});delete Date2.forEach,Date2.now=function(){return(new Date).valueOf()},Date2.parse=function(a,b){arguments.length>1&&assertType(b,"number","Default date should be of type 'number'.");var c=match(a,_DATE_PATTERN);if(c.length){var d=c[_DATE_PARTS.Month];d&&(c[_DATE_PARTS.Month]=String(d-1)),c[_TIMEZONE_PARTS.Hectomicroseconds]>=5&&c[_DATE_PARTS.Milliseconds]++;var e=c[_TIMEZONE_PARTS.UTC]||c[_TIMEZONE_PARTS.Hours]?"UTC":"",f=new Date(b||0);c[_DATE_PARTS.Date]&&f["set"+e+"Date"](14);for(var g in _DATE_PARTS){var h=c[_DATE_PARTS[g]];if(h&&(f["set"+e+g](h),f["get"+e+g]()!=c[_DATE_PARTS[g]]))return NaN}if(c[_TIMEZONE_PARTS.Hours]){var i=Number(c[_TIMEZONE_PARTS.Sign]+c[_TIMEZONE_PARTS.Hours]),j=Number(c[_TIMEZONE_PARTS.Sign]+(c[_TIMEZONE_PARTS.Minutes]||0));f.setUTCMinutes(f.getUTCMinutes()+60*i+j)}return f.valueOf()}return Date.parse(a)};var String2=_createObject2(String,function(a){return new String(0==arguments.length?"":a)},"charAt,charCodeAt,concat,indexOf,lastIndexOf,match,replace,search,slice,split,substr,substring,toLowerCase,toUpperCase",{csv:csv,format:format,rescape:rescape,trim:trim});delete String2.forEach;var Function2=_createObject2(Function,Function,"",{I:I,II:II,K:K,bind:bind,compose:compose,delegate:delegate,flip:flip,not:not,partial:partial,unbind:unbind});base2=global.base2=new Package(this,base2),base2.toString=K("[base2]");var _exports=this.exports;lang=new Package(this,lang),_exports+=this.exports,js=new Package(this,js),eval(_exports+this.exports),lang.extend=extend,base2.JavaScript=pcopy(js),base2.JavaScript.namespace+="var JavaScript=js;",void 0!==exports&&(void 0!==module&&module.exports&&(exports=module.exports=base2),exports.base2=base2)}},{}],6:[function(require,module,exports){(function(global){var miruken=require("./miruken.js"),Promise=require("bluebird");new function(){function RejectedError(a){this.callback=a,Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this)}function TimeoutError(a,b){this.callback=a,this.message=b||"Timeout occurred",Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this)}function _delegateInvocation(a,b,c,d,e,f){var g=!1,h=!1,i=c.conformsTo(Resolving),j=a.handler,k=new InvocationSemantics;j.handle(k,!0)&&(f=!!(f|k.getOption(InvocationOptions.Strict)),g=k.getOption(InvocationOptions.Broadcast),h=k.getOption(InvocationOptions.BestEffort),i=i||k.getOption(InvocationOptions.Resolve));var l=i?new ResolveMethod(b,c,d,e,f,g,!h):new HandleMethod(b,c,d,e,f);if(!j.handle(l,g&&!i)&&!h)throw new TypeError(format("Object %1 has no method '%2'",j,d));return l.returnValue}function _aspectProceed(a,b,c,d,e){var f;try{var g=c();if(g){var h=a.callbackResult;$isPromise(h)&&(f=h,
$isFunction(d)&&f.then(function(c){d(a,b,e)}).catch(function(c){d(a,b,e)}))}return g}finally{!f&&$isFunction(d)&&d(a,b,e)}}function $define(a,b){function c(a,b,c,e){return $isArray(b)?Array2.reduce(b,function(b,f){var g=d(a,f,c,e);return function(a){b(a),g(a)}},Undefined):d(a,b,c,e)}function d(b,c,d,e){if($isNothing(b))throw new TypeError("Definitions must have an owner.");if($isNothing(d)&&(d=c,c=$classOf(Modifier.unwrap(c))),$isNothing(d))throw new TypeError(format("Incomplete '%1' definition: missing handler for constraint %2.",a,c));if(e&&!$isFunction(e))throw new TypeError("The removed argument is not a function.");if(!$isFunction(d))if($copy.test(d)){var f=Modifier.unwrap(d);if(!$isFunction(f.copy))throw new Error("$copy requires the target to have a copy method.");d=f.copy.bind(f)}else{var f=$use.test(d)?Modifier.unwrap(d):d;d=$lift(f)}var h=b.$meta,i=new _Node(c,d,e),j=_createIndex(i.constraint),k=h[a]||(h[a]=new IndexedList(g));return k.insert(i,j),function(c){k.remove(i),k.isEmpty()&&delete h[a],i.removed&&!1!==c&&i.removed(b)}}function e(b,c,d,g,h,i,j,k){for(var l=!1,m=h===Variance.Invariant,n=c&&_createIndex(g);c;){var o=c[a];if(o&&(!m||n))for(var p=o.getIndex(n)||o.head;p;){if(p.match(g,h)){var q=b.base,r=!1;b.base=function(){var a;return r=!0,e(b,c.getParent(),d,g,h,i,!1,function(b){a=b}),a};try{var s=p.handler.call(b,d,i);if(f(s)){if(k&&k.call(d,s),!j)return!0;l=!0}else if(r&&!j)return!1}finally{b.base=q}}else if(m)break;p=p.next}c=c.getParent()}return l}if(!$isString(a)||0===a.length||/\s/.test(a))throw new TypeError("The tag must be a non-empty string with no whitespace.");if(_definitions[a])throw new TypeError(format("'%1' is already defined.",a));var f,g;if(!((b=b||Variance.Contravariant)instanceof Variance))throw new TypeError("Invalid variance type supplied");switch(b){case Variance.Covariant:f=_requiresResult,g=_compareCovariant;break;case Variance.Contravariant:f=_impliesSuccess,g=_compareContravariant;break;case Variance.Invariant:f=_requiresResult,g=_compareInvariant}return c.removeAll=function(b){for(var c=b.$meta,d=c[a],e=d.head;e;)e.removed&&e.removed(b),e=e.next;delete c[a]},c.dispatch=function(a,c,d,f,g,h){var i=b,j=a.delegate;(d=d||c)&&($eq.test(d)&&(i=Variance.Invariant),d=Modifier.unwrap(d),"object"===typeOf(d)&&(d=$classOf(d)));var k=j&&e(j,j.$meta,c,d,i,f,g,h);return k&&!g||(k=k||e(a,a.$meta,c,d,i,f,g,h)),k},_definitions[a]=c,c}function _Node(a,b,c){var d=$eq.test(a);a=Modifier.unwrap(a),this.constraint=a,this.handler=b,$isNothing(a)?this.match=d?False:_matchEverything:$isProtocol(a)?this.match=d?_matchInvariant:_matchProtocol:$isClass(a)?this.match=d?_matchInvariant:_matchClass:$isString(a)?this.match=_matchString:instanceOf(a,RegExp)?this.match=d?False:_matchRegExp:$isFunction(a)?this.match=a:this.match=False,c&&(this.removed=c)}function _createIndex(a){if(a){if($isString(a))return a;if($isFunction(a))return assignID(a)}}function _matchInvariant(a){return this.constraint===a}function _matchEverything(a,b){return b!==Variance.Invariant}function _matchProtocol(a,b){var c=this.constraint;return c===a||(b===Variance.Covariant?c.conformsTo(a):b===Variance.Contravariant&&(a.conformsTo&&a.conformsTo(c)))}function _matchClass(a,b){var c=this.constraint;return c===a||(b===Variance.Contravariant?a.prototype instanceof c:b===Variance.Covariant&&(a.prototype&&(c.prototype instanceof a||$isProtocol(a)&&a.adoptedBy(c))))}function _matchString(a,b){return!!$isString(a)&&(b===Variance.Invariant?this.constraint==a:this.constraint.toLowerCase()==a.toLowerCase())}function _matchRegExp(a,b){return b!==Variance.Invariant&&this.constraint.test(a)}function _compareCovariant(a,b){return b.match(a.constraint,Variance.Invariant)?0:b.match(a.constraint,Variance.Covariant)?-1:1}function _compareContravariant(a,b){return b.match(a.constraint,Variance.Invariant)?0:b.match(a.constraint,Variance.Contravariant)?-1:1}function _compareInvariant(a,b){return b.match(a.constraint,Variance.Invariant)?0:-1}function _requiresResult(a){return null!==a&&void 0!==a&&a!==$NOT_HANDLED}function _impliesSuccess(a){return a?a!==$NOT_HANDLED:void 0===a}function _flattenPrune(a){var b=0,c=function(a,d){return $isArray(d)?Array2.reduce(d,c,a):null!=d&&(a[b++]=d),a};return Array2.reduce(a,c,[])}miruken.package(this,{name:"callback",imports:"miruken",exports:"CallbackHandler,CascadeCallbackHandler,CompositeCallbackHandler,InvocationOptions,Batching,Batcher,Resolution,Composition,HandleMethod,ResolveMethod,RejectedError,TimeoutError,$handle,$callbacks,$define,$provide,$lookup,$NOT_HANDLED"}),eval(this.imports),Promise.onPossiblyUnhandledRejection(Undefined);var _definitions={},$handle=$define("$handle",Variance.Contravariant),$provide=$define("$provide",Variance.Covariant),$lookup=$define("$lookup",Variance.Invariant),$NOT_HANDLED=Object.freeze({}),$callbacks=MetaMacro.extend({execute:function(a,b,c,d){if(!$isNothing(d)){var e=c,f=b.getClass();c===f.prototype&&(c=f);for(var g in _definitions){var h=this.extractProperty(g,e,d);if(h&&0!=h.length)for(var i=_definitions[g],j=0;j<h.length;++j){var k=h[j];if(++j>=h.length)throw new Error(format("Incomplete '%1' definition: missing handler for constraint %2.",g,k));i(c,k,h[j])}}}},shouldInherit:True,isActive:True}),HandleMethod=Base.extend({constructor:function(a,b,c,d,e){if(b&&!$isProtocol(b))throw new TypeError("Invalid protocol supplied.");var f,g;this.extend({get type(){return a},get protocol(){return b},get methodName(){return c},get arguments(){return d},get returnValue(){return f},set returnValue(a){f=a},get exception(){return g},set exception(a){g=a},get callbackResult(){return f},set callbackResult(a){f=a},invokeOn:function(h,i){if(!h||e&&b&&!b.adoptedBy(h))return!1;var j,k;if(a===HandleMethod.Invoke&&(j=h[c],!$isFunction(j)))return!1;var l=global.$composer;try{switch(global.$composer=i,a){case HandleMethod.Get:k=h[c];break;case HandleMethod.Set:k=h[c]=d;break;case HandleMethod.Invoke:k=j.apply(h,d)}return k!==$NOT_HANDLED&&(f=k,!0)}catch(m){throw g=m,m}finally{l?global.$composer=l:delete global.$composer}}})}},{Get:1,Set:2,Invoke:3}),ResolveMethod=HandleMethod.extend({constructor:function(a,b,c,d,e,f,g){this.base(a,b,c,d,e),this.extend({invokeResolve:function(a){function d(b){for(var c=0;c<b.length&&(!(e|=this.invokeOn(b[c],a))||f);++c);}var e=!1,h=a.resolveAll(b);if($isPromise(h)){var i=this;return this.returnValue=new Promise(function(b,f){h.then(function(h){d.call(i,h),i.execption?f(i.exeception):e?b(i.returnValue):g?f(new TypeError(format("Object %1 has no method '%2'",a,c))):b()},f)}),!0}return d.call(this,h),e}})}}),Lookup=Base.extend({constructor:function(a,b){if($isNothing(a))throw new TypeError("The key is required.");b=!!b;var c,d=[],e=$instant.test(a);this.extend({get key(){return a},get isMany(){return b},get results(){return d},get callbackResult(){return void 0===c&&(b?c=e?Array2.flatten(d):Promise.all(d).then(Array2.flatten):d.length>0&&(c=d[0])),c},set callbackResult(a){c=a},addResult:function(a){!b&&0!==d.length||e&&$isPromise(a)||(d.push(a),c=void 0)}})}}),Deferred=Base.extend({constructor:function(a,b){if($isNothing(a))throw new TypeError("The callback is required.");b=!!b;var c,d,e=[];this.extend({get isMany(){return b},get callback(){return a},get pending(){return e},get callbackResult(){return void 0===d&&(d=1===e.length?Promise.resolve(e[0]).then(True):e.length>1?Promise.all(e).then(True):Promise.resolve(c)),d},set callbackResult(a){d=a},track:function(a){(b||0===e.length)&&$isPromise(a)&&(e.push(a),d=void 0),c||(c=!0,d=void 0)}})}}),Resolution=Base.extend({constructor:function(a,b){if($isNothing(a))throw new TypeError("The key is required.");b=!!b;var c,d=[],e=!1,f=$instant.test(a);this.extend({get key(){return a},get isMany(){return b},get instant(){return!e},get resolutions(){return d},get callbackResult(){if(void 0===c)if(b)c=this.instant?_flattenPrune(d):Promise.all(d).then(_flattenPrune);else{var a=_flattenPrune(d);a.length>0&&(c=a[0])}return c},set callbackResult(a){c=a},resolve:function(a){if(b||!(d.length>0)){var g=$isPromise(a);f&&g||(e=e||g,g&&b&&(a=a.catch(Undefined)),d.push(a),c=void 0)}}})}}),Composition=Base.extend({constructor:function(a,b){a&&this.extend({get callback(){return a},get greedy(){return b},get callbackResult(){return a.callbackResult},set callbackResult(b){a.callbackResult=b}})}},{isComposed:function(a,b){return a instanceof this&&a.callback instanceof b}}),compositionScope=$decorator({handleCallback:function(a,b,c){return a.constructor!==Composition&&(a=new Composition(a,b)),this.base(a,b,c)}}),CallbackHandler=Base.extend($callbacks,{constructor:function(a){this.extend({get delegate(){return a}})},handle:function(a,b,c){return!$isNothing(a)&&($isNothing(c)&&(c=compositionScope(this)),!!this.handleCallback(a,!!b,c))},handleCallback:function(a,b,c){return $handle.dispatch(this,a,null,c,b)},$handle:[Lookup,function(a,b){return $lookup.dispatch(this,a,a.key,b,a.isMany,a.addResult)},Deferred,function(a,b){return $handle.dispatch(this,a.callback,null,b,a.isMany,a.track)},Resolution,function(a,b){var c=a.key,d=a.isMany,e=$provide.dispatch(this,a,c,b,d,a.resolve);if(!e){var f=new _Node(c),g=this.delegate;g&&f.match($classOf(g),Variance.Contravariant)&&(a.resolve(g),e=!0),e&&!d||!f.match($classOf(this),Variance.Contravariant)||(a.resolve(this),e=!0)}return e},HandleMethod,function(a,b){return a.invokeOn(this.delegate,b)||a.invokeOn(this,b)},ResolveMethod,function(a,b){return a.invokeResolve(b)},Composition,function(a,b){var c=a.callback,d=a.greedy;return!(!c||!$handle.dispatch(this,c,null,b,d))}],toDelegate:function(){return new InvocationDelegate(this)}},{coerce:function(a){return new this(a)}});Base.implement({toCallbackHandler:function(){return CallbackHandler(this)}}),RejectedError.prototype=new Error,RejectedError.prototype.constructor=RejectedError,TimeoutError.prototype=new Error,TimeoutError.prototype.constructor=TimeoutError;var CascadeCallbackHandler=CallbackHandler.extend({constructor:function(a,b){if($isNothing(a))throw new TypeError("No handler specified.");if($isNothing(b))throw new TypeError("No cascadeToHandler specified.");a=a.toCallbackHandler(),b=b.toCallbackHandler(),this.extend({get handler(){return a},get cascadeToHandler(){return b}})},handleCallback:function(a,b,c){var d=this.base(a,b,c);return!!(b?d|this.handler.handleCallback(a,!0,c)|this.cascadeToHandler.handleCallback(a,!0,c):d||this.handler.handleCallback(a,!1,c)||this.cascadeToHandler.handleCallback(a,!1,c))}}),CompositeCallbackHandler=CallbackHandler.extend({constructor:function(){var a=new Array2;this.extend({getHandlers:function(){return a.copy()},addHandlers:function(){return Array2.flatten(arguments).forEach(function(b){b&&a.push(b.toCallbackHandler())}),this},insertHandlers:function(b){var c=0;return Array2.flatten(arguments).forEach(function(d){d&&a.splice(b+c++,0,d.toCallbackHandler())}),this},removeHandlers:function(){return Array2.flatten(arguments).forEach(function(b){if(b)for(var c=a.length,d=0;d<c;++d){var e=a[d];if(e==b||e.delegate==b)return void a.removeAt(d)}}),this},handleCallback:function(b,c,d){var e=this.base(b,c,d);if(e&&!c)return!0;for(var f=a.length,g=0;g<f;++g){if(a[g].handleCallback(b,c,d)){if(!c)return!0;e=!0}}return e}}),this.addHandlers(arguments)}});CallbackHandler.accepting=function(a,b){var c=new CallbackHandler;return $handle(c,b,a),c},CallbackHandler.providing=function(a,b){var c=new CallbackHandler;return $provide(c,b,a),c},CallbackHandler.implementing=function(a,b){if(!$isString(a)||0===a.length||!a.trim())throw new TypeError("No methodName specified.");if(!$isFunction(b))throw new TypeError(format("Invalid method: %1 is not a function.",b));return(new CallbackHandler).extend({handleCallback:function(c,d,e){if(c instanceof HandleMethod){var f=new Object;return f[a]=b,c.invokeOn(f)}return!1}})};var InvocationOptions=Flags({None:0,Broadcast:1,BestEffort:2,Strict:4,Resolve:8,Notify:3}),InvocationSemantics=Composition.extend({constructor:function(a){var b=InvocationOptions.None.addFlag(a),c=b;this.extend({getOption:function(a){return b.hasFlag(a)},setOption:function(a,d){b=d?b.addFlag(a):b.removeFlag(a),c=c.addFlag(a)},isSpecified:function(a){return c.hasFlag(a)}})},mergeInto:function(a){for(var b=InvocationOptions.items,c=0;c<b.length;++c){var d=+b[c];this.isSpecified(d)&&!a.isSpecified(d)&&a.setOption(d,this.getOption(d))}}}),Batching=StrictProtocol.extend({complete:function(a){}}),BatchingComplete=Batching.extend(),Batcher=CompositeCallbackHandler.extend(BatchingComplete,{constructor:function(a,b){this.base(),b=b&&Array.prototype.concat.apply([],arguments),this.extend({get tag(){return a},shouldBatch:function(a){return!b||a&&b.indexOf(a)>=0}})},complete:function(a){var b=!1,c=Array2.reduce(this.getHandlers(),function(c,d){var e=Batching(d).complete(a);if(e)return b=b||$isPromise(e),c.push(e),c},[]);return b?Promise.all(c):c}}),InvocationDelegate=Delegate.extend({constructor:function(a){this.extend({get handler(){return a}})},get:function(a,b,c){return _delegateInvocation(this,HandleMethod.Get,a,b,null,c)},set:function(a,b,c,d){return _delegateInvocation(this,HandleMethod.Set,a,b,c,d)},invoke:function(a,b,c,d){return _delegateInvocation(this,HandleMethod.Invoke,a,b,c,d)}});CallbackHandler.implement({$strict:function(){return this.$callOptions(InvocationOptions.Strict)},$broadcast:function(){return this.$callOptions(InvocationOptions.Broadcast)},$bestEffort:function(){return this.$callOptions(InvocationOptions.BestEffort)},$notify:function(){return this.$callOptions(InvocationOptions.Notify)},$resolve:function(){return this.$callOptions(InvocationOptions.Resolve)},$callOptions:function(a){var b=new InvocationSemantics(a);return this.decorate({handleCallback:function(a,c,d){var e=!1;if(Composition.isComposed(a,InvocationSemantics))return!1;if(a instanceof InvocationSemantics)b.mergeInto(a),e=!0;else if(!c)if(b.isSpecified(InvocationOptions.Broadcast|InvocationOptions.Resolve))c=b.getOption(InvocationOptions.Broadcast)&&!b.getOption(InvocationOptions.Resolve);else{var f=new InvocationSemantics;this.handle(f,!0)&&f.isSpecified(InvocationOptions.Broadcast)&&(c=f.getOption(InvocationOptions.Broadcast)&&!f.getOption(InvocationOptions.Resolve))}return!c&&e||(e|=this.base(a,c,d)),!!e}})}}),CallbackHandler.implement({defer:function(a){var b=new Deferred(a);return this.handle(b,!1),b.callbackResult},deferAll:function(a){var b=new Deferred(a,!0);return this.handle(b,!0),b.callbackResult},resolve:function(a){var b=a instanceof Resolution?a:new Resolution(a);if(this.handle(b,!1))return b.callbackResult},resolveAll:function(a){var b=a instanceof Resolution?a:new Resolution(a,!0);return this.handle(b,!0)?b.callbackResult:[]},lookup:function(a){var b=a instanceof Lookup?a:new Lookup(a);if(this.handle(b,!1))return b.callbackResult},lookupAll:function(a){var b=a instanceof Lookup?a:new Lookup(a,!0);return this.handle(b,!0)?b.callbackResult:[]},decorate:function(a){return $decorate(this,a)},filter:function(a,b){if(!$isFunction(a))throw new TypeError(format("Invalid filter: %1 is not a function.",a));return this.decorate({handleCallback:function(c,d,e){if(!b&&c instanceof Composition)return this.base(c,d,e);var f=this,g=this.base;return a(c,e,function(){return g.call(f,c,d,e)})}})},aspect:function(a,b,c){return this.filter(function(c,d,e){if($isFunction(a)){var f=a(c,d);if($isPromise(f)){var g="callbackResult"in c,h=f.then(function(a){return!1!==a?(_aspectProceed(c,d,e,b,a),!g||c.callbackResult):Promise.reject(new RejectedError(c))});return g&&(c.callbackResult=h),!0}if(!1===f)throw new RejectedError(c)}return _aspectProceed(c,d,e,b,f)},c)},$$handle:function(a){return this.decorate({$handle:a})},$$provide:function(a){return this.decorate({$provide:a})},when:function(a){var b=new _Node(a),c=function(a){return a instanceof Deferred?b.match($classOf(a.callback),Variance.Contravariant):a instanceof Resolution?b.match(a.key,Variance.Covariant):b.match($classOf(a),Variance.Contravariant)};return this.decorate({handleCallback:function(a,b,d){return c(a)&&this.base(a,b,d)}})},next:function(){switch(arguments.length){case 0:return this;case 1:return new CascadeCallbackHandler(this,arguments[0]);default:return new CompositeCallbackHandler((Array2.unshift(arguments,this),arguments))}},$guard:function(a,b){if(a){var c=!1;b=b||"guarded";var d=b in a;return this.aspect(function(){return!(c=a[b])&&(a[b]=!0,!0)},function(){c||(a[b]=void 0,d||delete a[b])})}return this},$activity:function(a,b,c){c=c||"$$activity";var d=c in a;return this.aspect(function(){var d={enabled:!1};return setTimeout(function(){if("enabled"in d){d.enabled=!0;var b=a[c]||0;a[c]=++b}},$isSomething(b)?b:50),d},function(b,e,f){if(f.enabled){var g=a[c];g&&1!==g?a[c]=--g:(a[c]=void 0,d||delete a[c])}delete f.enabled})},$promise:function(){return this.filter(function(a,b,c){try{var d=c();if(d){var e=a.callbackResult;a.callbackResult=$isPromise(e)?e:Promise.resolve(e)}return d}catch(f){return a.callbackResult=Promise.reject(f),!0}})},$timeout:function(a,b){return this.filter(function(c,d,e){var f=e();if(f){var g=c.callbackResult;$isPromise(g)&&(c.callbackResult=new Promise(function(d,e){var f;g.then(function(a){f&&clearTimeout(f),d(a)},function(a){f&&clearTimeout(f),e(a)}),f=setTimeout(function(){b?$isFunction(b)&&(b=b.new(c)):b=new TimeoutError(c),$isFunction(g.reject)&&g.reject(b),e(b)},a)}))}return f})},$batch:function(a,b){1!==arguments.length||$isString(a)||(b=a,a=void 0);var c=new Batcher(a,b),d=!1,e=[];return this.decorate({$provide:[Batcher,function(){return c}],handleCallback:function(a,b,f){var g=!1;if(c){var h=c;if(!d||a instanceof Composition||(c=null),(g=h.handleCallback(a,b,f))&&!b){if(c){var i=a.callbackResult;$isPromise(i)&&e.push(i)}return!0}}return this.base(a,b,f)||g},dispose:function(){d=!0;var a=BatchingComplete(this).complete(this);return e.length>0?Promise.all(e).then(function(){return a}):a}})},getBatcher:function(a){var b=this.resolve(Batcher);if(b&&(!a||b.shouldBatch(a)))return b}}),void 0!==module&&module.exports&&(module.exports=exports=this.package),eval(this.exports)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./miruken.js":14,bluebird:25}],7:[function(require,module,exports){(function(global){var miruken=require("./miruken.js");require("./graph.js"),require("./callback.js"),new function(){miruken.package(this,{name:"context",imports:"miruken,miruken.graph,miruken.callback",exports:"ContextState,ContextObserver,Context,ContextualHelper,ContextualMixin,$contextual"}),eval(this.imports);var ContextState=Enum({Active:1,Ending:2,Ended:3}),ContextObserver=Protocol.extend({contextEnding:function(a){},contextEnded:function(a){},childContextEnding:function(a){},childContextEnded:function(a){}}),Context=CompositeCallbackHandler.extend(Parenting,Traversing,Disposing,TraversingMixin,{constructor:function(a){function b(){if(f!=ContextState.Active)throw new Error("The context has already ended.")}function c(){return new ContextObserver(d?d.copy():null)}this.base();var d,e=assignID(this),f=ContextState.Active,g=a,h=new Array2;this.extend({get id(){return e},get state(){return f},get parent(){return g},get children(){return h.copy()},get hasChildren(){return h.length>0},get root(){for(var a,b=this;b&&(a=b.parent);)b=a;return b},newChild:function(){b();var a=new($classOf(this))(this).extend({end:function(){var b=c();b.childContextEnding(a),h.remove(a),this.base(),b.childContextEnded(a)}});return h.push(a),a},store:function(a){return $isSomething(a)&&$provide(this,a),this},handleCallback:function(a,b,c){var d=!1,e=this.__axis;return e?(delete this.__axis,e===TraversingAxis.Self?this.base(a,b,c):(this.traverse(e,function(e){return(d|=$equals(e,this)?this.base(a,b,c):e.handleAxis(TraversingAxis.Self,a,b,c))&&!b},this),!!d)):!(!(d=this.base(a,b,c))||b)||(g&&(d|=g.handle(a,b,c)),!!d)},handleAxis:function(a,b,c,d){if(!(a instanceof TraversingAxis))throw new TypeError("Invalid axis type supplied");return this.__axis=a,this.handle(b,c,d)},observe:function(a){if(b(),null!==a&&void 0!==a)return(d||(d=new Array2)).push(a),function(){d.remove(a)}},unwindToRootContext:function(){for(var a=this;a;){var b=a.parent;if(null==b)return a.unwind(),a;a=b}return this},unwind:function(){return this.children.invoke("end"),this},end:function(){if(f==ContextState.Active){var a=c();f=ContextState.Ending,a.contextEnding(this),this.unwind(),f=ContextState.Ended,a.contextEnded(this),d=null}},dispose:function(){this.end()}})},resolveContext:function(a){var b=this.decoratee;return b?b.resolve(a.key):this}});$provide(Context,Context,function(a){return this.resolveContext(a)});var ContextualMixin={get context(){return this.__context},set context(a){var b=this.__context;b!==a&&(b&&b.removeHandlers(this),a?(this.__context=a,a.insertHandlers(0,this)):delete this.__context)},get isActiveContext(){var a=this.__context;return a&&a.state===ContextState.Active},endCallingContext:function(){var a=global.$composer;if(a){var b=a.resolve(Context);b&&b!==this.context&&b.End()}},endContext:function(){var a=this.__context;a&&a.end()}},$contextual=MetaMacro.extend({execute:function(a,b){if(a===MetaStep.Subclass){b.getClass().implement(ContextualMixin)}}}),ContextualHelper=Module.extend({resolveContext:function(a){return $isNothing(a)||a instanceof Context?a:a.context},requireContext:function(a){var b=ContextualHelper.resolveContext(a);if(!(b instanceof Context))throw new Error("The supplied object is not a Context or Contextual object.");return b},clearContext:function(a){var b=a.context;if(b)try{b.end()}finally{a.context=null}},bindContext:function(a,b,c){return!a||!c&&a.context||(a.context=ContextualHelper.resolveContext(b)),a},bindChildContext:function(a,b,c){var d;if(b){if(!c&&(d=b.context)&&d.state===ContextState.Active)return d;for(var e=ContextualHelper.requireContext(a);e&&e.state!==ContextState.Active;)e=e.parent;e&&(d=e.newChild(),ContextualHelper.bindContext(b,d,!0))}return d}});Context.implement({onEnding:function(a){return this.observe({contextEnding:a})},onEnded:function(a){return this.observe({contextEnded:a})},onChildEnding:function(a){return this.observe({childContextEnding:a})},onChildEnded:function(a){return this.observe({childContextEnded:a})}});var axisControl={axis:function(a){return this.decorate({handleCallback:function(b,c,d){return b instanceof Composition||(this.__axis=a),this.base(b,c,d)},equals:function(a){return this===a||$decorated(this)===$decorated(a)}})}},applyAxis=axisControl.axis;Array2.forEach(TraversingAxis.names,function(a){var b="$"+a.charAt(0).toLowerCase()+a.slice(1);axisControl[b]=Function2.partial(applyAxis,TraversingAxis[a])}),CallbackHandler.implement({$publish:function(){var a=this,b=ContextualHelper.resolveContext(a);return b&&(a=b.$descendantOrSelf()),a.$notify()},$publishFromRoot:function(){var a=this,b=ContextualHelper.resolveContext(a);return b&&(a=b.root.$descendantOrSelf()),a.$notify()}}),Context.implement(axisControl),void 0===Function.prototype.newInContext&&(Function.prototype.newInContext=function(){function a(){d.apply(this,b)}var b=Array.prototype.slice.call(arguments),c=b.shift(),d=this;a.prototype=d.prototype;var e=new a;return ContextualHelper.bindContext(e,c),e}),void 0===Function.prototype.newInChildContext&&(Function.prototype.newInChildContext=function(){function a(){d.apply(this,b)}var b=Array.prototype.slice.call(arguments),c=b.shift(),d=this;a.prototype=d.prototype;var e=new a;return ContextualHelper.bindChildContext(c,e),e}),void 0!==module&&module.exports&&(module.exports=exports=this.package),eval(this.exports)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./callback.js":6,"./graph.js":9,"./miruken.js":14}],8:[function(require,module,exports){var miruken=require("./miruken.js"),Promise=require("bluebird");require("./callback.js"),new function(){miruken.package(this,{name:"error",imports:"miruken,miruken.callback",exports:"Errors,ErrorCallbackHandler"}),eval(this.imports);var Errors=Protocol.extend({handleError:function(a,b){},handleException:function(a,b){},reportError:function(a,b){},reportException:function(a,b){},clearErrors:function(a){}}),ErrorCallbackHandler=CallbackHandler.extend(Errors,{handleError:function(a,b){var c=Errors($composer).reportError(a,b);return void 0===c?Promise.reject(a):Promise.resolve(c)},handleException:function(a,b){var c=Errors($composer).reportException(a,b);return void 0===c?Promise.reject(a):Promise.resolve(c)},reportError:function(a,b){return console.error(a),Promise.resolve()},reportException:function(a,b){return console.error(a),Promise.resolve()},clearErrors:function(a){}});CallbackHandler.implement({$recover:function(a){return this.filter(function(b,c,d){try{var e=d();if(e){var f=b.callbackResult;$isPromise(f)&&(b.callbackResult=f.catch(function(b){return Errors(c).handleError(b,a)}))}return e}catch(g){return Errors(c).handleException(g,a),!0}})},$recoverError:function(a){return function(b){return Errors(this).handleError(b,a)}.bind(this)}}),void 0!==module&&module.exports&&(module.exports=exports=this.package),eval(this.exports)}},{"./callback.js":6,"./miruken.js":14,bluebird:25}],9:[function(require,module,exports){var miruken=require("./miruken.js");new function(){function checkCircularity(a,b){if(-1!==a.indexOf(b))throw new Error(format("Circularity detected for node %1",b));return a.push(b),b}function _traverseSelf(a,b){a.call(b,this)}function _traverseRoot(a,b){for(var c,d=this,e=[this];c=d.parent;)checkCircularity(e,c),d=c;a.call(b,d)}function _traverseChildren(a,b,c){if(!b||!a.call(c,this))for(var d=this.children,e=0;e<d.length;++e)if(a.call(c,d[e]))return}function _traverseAncestors(a,b,c){var d=this,e=[this];if(!b||!a.call(c,this))for(;(d=d.parent)&&!a.call(c,d);)checkCircularity(e,d)}function _traverseDescendants(a,b,c){if(b)Traversal.levelOrder(this,a,c);else{var d=this;Traversal.levelOrder(this,function(b){if(!$equals(d,b))return a.call(c,b)},c)}}function _traverseDescendantsReverse(a,b,c){if(b)Traversal.reverseLevelOrder(this,a,c);else{var d=this;Traversal.reverseLevelOrder(this,function(b){if(!$equals(d,b))return a.call(c,b)},c)}}function _traverseAncestorSiblingOrSelf(a,b,c,d){if(!b||!a.call(d,this)){var e=this,f=this.parent;if(f){for(var g=f.children,h=0;h<g.length;++h){var i=g[h];if(!$equals(e,i)&&a.call(d,i))return}c&&_traverseAncestors.call(f,a,!0,d)}}}function _preOrder(a,b,c,d){return checkCircularity(d,a),!(a&&$isFunction(b)&&!b.call(c,a))||($isFunction(a.traverse)&&a.traverse(function(a){return _preOrder(a,b,c,d)}),!1)}function _postOrder(a,b,c,d){return checkCircularity(d,a),!a||!$isFunction(b)||($isFunction(a.traverse)&&a.traverse(function(a){return _postOrder(a,b,c,d)}),b.call(c,a))}function _levelOrder(a,b,c,d){if(a&&$isFunction(b))for(var e=[a];e.length>0;){var f=e.shift();if(checkCircularity(d,f),b.call(c,f))return;$isFunction(f.traverse)&&f.traverse(function(a){a&&e.push(a)})}}function _reverseLevelOrder(a,b,c,d){if(a&&$isFunction(b)){for(var e=[a],f=[];e.length>0;){var g=e.shift();checkCircularity(d,g),f.push(g);var h=[];$isFunction(g.traverse)&&g.traverse(function(a){a&&h.unshift(a)}),e.push.apply(e,h)}for(;f.length>0;)if(b.call(c,f.pop()))return}}miruken.package(this,{name:"graph",imports:"miruken",exports:"TraversingAxis,Traversing,TraversingMixin,Traversal"}),eval(this.imports);var TraversingAxis=Enum({Self:1,Root:2,Child:3,Sibling:4,Ancestor:5,Descendant:6,DescendantReverse:7,ChildOrSelf:8,SiblingOrSelf:9,AncestorOrSelf:10,DescendantOrSelf:11,DescendantOrSelfReverse:12,AncestorSiblingOrSelf:13}),Traversing=Protocol.extend({traverse:function(a,b,c){}}),TraversingMixin=Module.extend({traverse:function(a,b,c,d){if($isFunction(b)&&(d=c,c=b,b=TraversingAxis.Child),$isFunction(c))switch(b){case TraversingAxis.Self:_traverseSelf.call(a,c,d);break;case TraversingAxis.Root:_traverseRoot.call(a,c,d);break;case TraversingAxis.Child:_traverseChildren.call(a,c,!1,d);break;case TraversingAxis.Sibling:_traverseAncestorSiblingOrSelf.call(a,c,!1,!1,d);break;case TraversingAxis.ChildOrSelf:_traverseChildren.call(a,c,!0,d);break;case TraversingAxis.SiblingOrSelf:_traverseAncestorSiblingOrSelf.call(a,c,!0,!1,d);break;case TraversingAxis.Ancestor:_traverseAncestors.call(a,c,!1,d);break;case TraversingAxis.AncestorOrSelf:_traverseAncestors.call(a,c,!0,d);break;case TraversingAxis.Descendant:_traverseDescendants.call(a,c,!1,d);break;case TraversingAxis.DescendantReverse:_traverseDescendantsReverse.call(a,c,!1,d);break;case TraversingAxis.DescendantOrSelf:_traverseDescendants.call(a,c,!0,d);break;case TraversingAxis.DescendantOrSelfReverse:_traverseDescendantsReverse.call(a,c,!0,d);break;case TraversingAxis.AncestorSiblingOrSelf:_traverseAncestorSiblingOrSelf.call(a,c,!0,!0,d);break;default:throw new Error(format("Unrecognized TraversingAxis %1.",b))}}}),Traversal=Abstract.extend({},{preOrder:function(a,b,c){return _preOrder(a,b,c,[])},postOrder:function(a,b,c){return _postOrder(a,b,c,[])},levelOrder:function(a,b,c){return _levelOrder(a,b,c,[])},reverseLevelOrder:function(a,b,c){return _reverseLevelOrder(a,b,c,[])}});eval(this.exports)}},{"./miruken.js":14}],10:[function(a,b,c){b.exports=a("./miruken.js"),a("./graph.js"),a("./callback.js"),a("./context.js"),a("./error.js"),a("./validate"),a("./ioc")},{"./callback.js":6,"./context.js":7,"./error.js":8,"./graph.js":9,"./ioc":12,"./miruken.js":14,"./validate":22}],11:[function(require,module,exports){var miruken=require("../miruken.js"),Promise=require("bluebird");require("./ioc.js"),new function(){function $classes(a,b){if(a instanceof Package)return new FromPackageBuilder(a,b);throw new TypeError(format("Unrecognized $classes from %1.",hint))}function _unregisterBatch(a){return function(){for(var b=0;b<a.length;++b)a[b]()}}function _addMatchingProtocols(a,b,c){for(var d=_toplevelProtocols(a),e=0;e<d.length;++e){var f=d[e];f.$meta.getAllProtocols().indexOf(b)>=0&&c.push(f)}}function _toplevelProtocols(a){for(var b=a.$meta.getAllProtocols(),c=b.slice(0),d=0;d<b.length;++d)for(var e=b[d].$meta.getAllProtocols(),f=0;f<e.length;++f)Array2.remove(c,e[f]);return c}miruken.package(this,{name:"ioc",imports:"miruken,miruken.ioc",exports:"Installer,FromBuilder,FromPackageBuilder,BasedOnBuilder,KeyBuilder,$classes"}),eval(this.imports);var Installer=Base.extend(Registration,{register:function(a,b){}}),FromBuilder=Base.extend(Registration,{constructor:function(){var a;this.extend({getClasses:function(){return[]},basedOn:function(){return a=new BasedOnBuilder(this,Array2.flatten(arguments))},register:function(b,c){var d,e=this.getClasses();return d=a?Array2.filter(Array2.map(e,function(b){return a.builderForClass(b)}),function(a){return a}):Array2.map(Array2.filter(e,function(a){return(a.member||a).prototype instanceof Installer}),function(a){return new(a=a.member||a)}),Promise.all(b.register(d)).then(function(a){return _unregisterBatch(a)})}})}}),FromPackageBuilder=FromBuilder.extend({constructor:function(a,b){this.base(),this.extend({getClasses:function(){var c=[];return a.getClasses(b,function(a){c.push(a)}),c}})}}),BasedOnBuilder=Base.extend(Registration,{constructor:function(a,b){var c,d,e;this.withKeys=new KeyBuilder(this),this.extend({if:function(a){if(c){var b=c;c=function(c){return b(c)&&a(c)}}else c=a;return this},unless:function(a){if(d){var b=d;d=function(c){return b(c)||a(c)}}else d=a;return this},configure:function(a){if(e){var b=e;e=function(c){b(c),a(c)}}else e=a;return this},builderForClass:function(a){var f=[],g=a.member||a,h=a.name;if(!(c&&!c(g)||d&&d(g))){for(var i=0;i<b.length;++i){var j=b[i];if($isProtocol(j)){if(!j.adoptedBy(g))continue}else if($isClass(j)&&!(g.prototype instanceof j))continue;f.indexOf(j)<0&&f.push(j)}if(f.length>0||0===b.length){var k=this.withKeys.getKeys(g,f,h),l=$component(k).boundTo(g);return e&&e(l),l}}},register:function(b,c){return a.register(b,c)}})}}),KeyBuilder=Base.extend({constructor:function(a){function b(b){if(c){var d=c
;c=function(a,c,e,f){d(a,c,e,f),b(a,c,e,f)}}else c=b;return a}var c;this.extend({self:function(){return b(function(a,b){a.push(b)})},basedOn:function(){return b(function(a,b,c){a.push.apply(a,c)})},anyService:function(){return b(function(a,b){var c=b.$meta.getAllProtocols();c.length>0&&a.push(c[0])})},allServices:function(){return b(function(a,b){a.push.apply(a,b.$meta.getAllProtocols())})},mostSpecificService:function(a){return b(function(b,c,d){if($isProtocol(a))_addMatchingProtocols(c,a,b);else for(var e=0;e<d.length;++e){var f=d[e];$isFunction(f)&&_addMatchingProtocols(c,f,b)}if(0===b.length)for(var e=0;e<d.length;++e){var f=d[e];if(f!==Base&&f!==Object)if($isProtocol(f)){if(f.adoptedBy(c)){b.push(f);break}}else if(c===f||c.prototype instanceof f){b.push(f);break}}})},name:function(a){return b(function(b,c,d,e){$isNothing(a)?e&&b.push(e):$isFunction(a)?(e=a(e))&&b.push(String(e)):b.push(String(a))})},getKeys:function(a,b,d){var e=[];if(c&&c(e,a,b,d),e.length>0)return e}})}});$classes.fromPackage=function(a,b){if(!(a instanceof Package))throw new TypeError(format("$classes expected a Package, but received %1 instead.",a));return new FromPackageBuilder(a,b)},void 0!==module&&module.exports&&(module.exports=exports=this.package),eval(this.exports)}},{"../miruken.js":14,"./ioc.js":13,bluebird:25}],12:[function(a,b,c){b.exports=a("./ioc.js"),a("./fluent.js")},{"./fluent.js":11,"./ioc.js":13}],13:[function(require,module,exports){(function(global){var miruken=require("../miruken.js"),Promise=require("bluebird");require("../callback.js"),require("../context.js"),require("../validate"),new function(){function _makeClassFactory(a){return function(b){return a.new.apply(a,b[Facet.Parameters])}}function _makeProxyFactory(a){var b=$proxyBuilder.buildProxy(a);return function(a){return b.new.call(b,a)}}function $component(a){return new ComponentBuilder(a)}function DependencyResolutionError(a,b){this.message=b,this.dependency=a,Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this)}function ComponentModelError(a,b,c){this.message=c||"The component model contains one or more errors",this.componentModel=a,this.validationResults=b,Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this)}function _registerHandler(a,b,c){var d=a.key,e=a.implementation,f=a.lifestyle||new SingletonLifestyle,g=a.factory,h=a.burden;return d=a.invariant?$eq(d):d,$provide(b,d,function b(d,i){return d instanceof DependencyResolution||(d=new DependencyResolution(d.key)),d.claim(b,e)?f.resolve(function(b){function e(d){function e(b){for(var g=b;g<c.length;++g){var h=c[g];if($isFunction(h.componentCreated)){var j=h.componentCreated(f,a,d,i);if($isPromise(j))return j.then(function(){return e(g+1)})}}return f}var f=g.call(i,d);return $isFunction(b)&&(f=b(f,d)||f),e(0)}var f=$instant.test(d.key),j=_resolveBurden(h,f,d,i);return $isPromise(j)?j.then(e):e(j)},i):$NOT_HANDLED},f.dispose.bind(f))}function _resolveBurden(a,b,c,d){var e=[],f={},g=Container(d);for(var h in a){var i=a[h];if(!$isNothing(i)){for(var j=i.slice(0),k=0;k<j.length;++k){var l=j[k];if(void 0!==l){var m=l.test(DependencyModifier.Use),n=l.test(DependencyModifier.Lazy),o=l.test(DependencyModifier.Promise),p=l.test(DependencyModifier.Child),q=l.test(DependencyModifier.Dynamic),r=l.dependency;if(m||q||$isNothing(r))q&&$isFunction(r)&&(r=r(g)),p&&(r=_createChild(r)),o&&(r=Promise.resolve(r));else if(r===$$composer)r=d;else if(r===Container)r=g;else{var s=l.test(DependencyModifier.Every),t=l.test(DependencyModifier.Optional),u=l.test(DependencyModifier.Invariant),v=l.test(DependencyModifier.Container);if(u&&(r=$eq(r)),b&&(r=$instant(r)),n)r=function(a,b,c){return function(){if(!b){b=!0;c=_resolveDependency(a,!1,o,p,s,v?g:d)}return c}}(r);else{var w=new DependencyResolution(r,c,s),x=v?g:d;r=_resolveDependency(w,!t,o,p,s,x),!o&&$isPromise(r)&&(e.push(r),function(a,b,c){a.then(function(a){b[c]=a})}(r,j,k))}}j[k]=r}}f[h]=j}}return 1===e.length?e[0].then(function(){return f}):e.length>1?Promise.all(e).then(function(){return f}):f}function _resolveDependency(a,b,c,d,e,f){var g=e?f.resolveAll(a):f.resolve(a);if(void 0===g){if(b){var h=new DependencyResolutionError(a,format("Dependency %1 could not be resolved.",a.formattedDependencyChain()));if($instant.test(a.key))throw h;return Promise.reject(h)}return g}return d&&!e&&(g=$isPromise(g)?g.then(function(a){return _createChild(a)}):_createChild(g)),c?Promise.resolve(g):g}function _createChild(a){if(!a||!$isFunction(a.newChild))throw new Error(format("Child dependency requested, but %1 is not a parent.",a));return a.newChild()}function _getPropertyDescriptor(a,b){for(var c,d=a;d&&!(c=Object.getOwnPropertyDescriptor(d,b));)d=Object.getPrototypeOf(d);return c}miruken.package(this,{name:"ioc",imports:"miruken,miruken.graph,miruken.callback,miruken.context,miruken.validate",exports:"Container,Registration,ComponentPolicy,Lifestyle,TransientLifestyle,SingletonLifestyle,ContextualLifestyle,DependencyModifier,DependencyModel,DependencyManager,ComponentModel,ComponentBuilder,ComponentModelError,ComponentModelAware,ComponentModelAwarePolicy,IoContainer,DependencyResolution,DependencyResolutionError,$component,$$composer,$container"}),eval(this.imports);var $$composer=Object.freeze({}),$container=$createModifier(),$proxyBuilder=new ProxyBuilder,Container=StrictProtocol.extend(Invoking,Disposing,{register:function(a){},addComponent:function(a,b){},addPolicies:function(a){},resolve:function(a){},resolveAll:function(a){}}),Registration=Protocol.extend({register:function(a,b){}}),ComponentPolicy=Protocol.extend({applyPolicy:function(a,b){},componentCreated:function(a,b,c,d){}}),DependencyModifier=Flags({None:0,Use:1,Lazy:2,Every:4,Dynamic:8,Optional:16,Promise:32,Invariant:64,Container:128,Child:256});DependencyModifier.Use.modifier=$use,DependencyModifier.Lazy.modifier=$lazy,DependencyModifier.Every.modifier=$every,DependencyModifier.Dynamic.modifier=$eval,DependencyModifier.Child.modifier=$child,DependencyModifier.Optional.modifier=$optional,DependencyModifier.Promise.modifier=$promise,DependencyModifier.Container.modifier=$container,DependencyModifier.Invariant.modifier=$eq;var DependencyModel=Base.extend({constructor:function(a,b){b=DependencyModifier.None.addFlag(b),a instanceof Modifier&&(Array2.forEach(DependencyModifier.items,function(c){var d=c.modifier;d&&d.test(a)&&(b=b.addFlag(c))}),a=Modifier.unwrap(a)),this.extend({get dependency(){return a},get modifiers(){return b}})},test:function(a){return this.modifiers.hasFlag(a)}},{coerce:function(a){return void 0===a?void 0:new DependencyModel(a)}}),DependencyManager=ArrayManager.extend({constructor:function(a){this.base(a)},mapItem:function(a){return void 0!==a&&a instanceof DependencyModel?a:DependencyModel(a)}}),ComponentModel=Base.extend($validateThat,{constructor:function(){var a,b,c,d,e=!1,f={};this.extend({get key(){return a||b},set key(b){a=b},get implementation(){var c=b;return!c&&$isClass(a)&&(c=a),c},set implementation(a){if($isSomething(a)&&!$isClass(a))throw new TypeError(format("%1 is not a class.",a));b=a},get invariant(){return e},set invariant(a){e=!!a},get lifestyle(){return c},set lifestyle(a){if(!($isSomething(a)||a instanceof Lifestyle))throw new TypeError(format("%1 is not a Lifestyle.",a));c=a},get factory(){var b=d,c=this.implementation;if(!b){var e=f[Facet.Interceptors];if(e&&e.length>0){var g=[];return c&&g.push(c),$isProtocol(a)&&g.push(a),_makeProxyFactory(g)}if(c)return _makeClassFactory(c)}return b},set factory(a){if($isSomething(a)&&!$isFunction(a))throw new TypeError(format("%1 is not a function.",a));d=a},getDependencies:function(a){return f[a||Facet.Parameters]},setDependencies:function(a,b){if(1===arguments.length&&(b=a,a=Facet.Parameters),$isSomething(b)&&!$isArray(b))throw new TypeError(format("%1 is not an array.",b));f[a]=Array2.map(b,DependencyModel)},manageDependencies:function(a,b){if(1===arguments.length&&(b=a,a=Facet.Parameters),$isFunction(b)){var c=f[a],d=new DependencyManager(c);b(d);var c=d.getItems();c.length>0&&(f[a]=c)}return c},get burden(){return f}})},$validateThat:{keyCanBeDetermined:function(a){this.key||a.results.addKey("key").addError("required",{message:"Key could not be determined for component."})},factoryCanBeDetermined:function(a){this.factory||a.results.addKey("factory").addError("required",{message:"Factory could not be determined for component."})}}}),Lifestyle=Abstract.extend(ComponentPolicy,Disposing,DisposingMixin,{resolve:function(a){return a()},trackInstance:function(a){if(a&&$isFunction(a.dispose)){var b=this;return $decorate(a,{dispose:function(a){(a||b.disposeInstance(this,!0))&&(this.base(),delete this.dispose)}})}return a},disposeInstance:function(a,b){return!b&&a&&$isFunction(a.dispose)&&a.dispose(!0),!b},applyPolicy:function(a){a.lifestyle=new this.constructor}}),TransientLifestyle=Lifestyle.extend({constructor:function(){},applyPolicy:function(a){a.lifestyle=this}}),SingletonLifestyle=Lifestyle.extend({constructor:function(a){this.extend({resolve:function(b){return null==a?b(function(b){if(!a&&b)return a=this.trackInstance(b)}.bind(this)):a=this.trackInstance(a)},disposeInstance:function(b,c){return!(c||b!==a||!this.base(b,c))&&(a=void 0,!0)},_dispose:function(){this.disposeInstance(a)}})}}),ContextualLifestyle=Lifestyle.extend({constructor:function(){var a={};this.extend({resolve:function(b,c){var d=c.resolve(Context);if(d){var e=d.id,f=a[e];return f||b(function(b){return b&&!a[e]&&(f=this.trackInstance(b),f=this.setContext(b,f,d),a[e]=f,d.onEnded(function(){f.context=null})),f}.bind(this))}},setContext:function(a,b,c){var d=this,e=_getPropertyDescriptor(b,"context");return e&&e.set||(b=a===b?$decorate(a,ContextualMixin):b.extend(ContextualMixin)),ContextualHelper.bindContext(b,c,!0),b.extend({set context(a){if(a!=c){if(null!=a)throw new Error("Container managed instances cannot change context");this.base(a),d.disposeInstance(b)}}})},disposeInstance:function(b,c){if(!c)for(contextId in a)if(a[contextId]===b)return this.base(b,c),delete a[contextId],delete b.context,!0;return!1},_dispose:function(){for(contextId in a)this.disposeInstance(a[contextId]);a={}}})}}),InjectionPolicy=Base.extend(ComponentPolicy,{applyPolicy:function(a){var b=a.getDependencies();if(!b||Array2.contains(b,void 0)){var c=a.implementation;a.manageDependencies(function(a){for(;c&&c!==Base;){for(var b=[c.prototype.$inject,c.prototype.inject,c.$inject,c.inject],d=0;d<b.length;++d){var e=b[d];if(void 0!==e&&($isFunction(e)&&(e=e()),a.merge(e),!Array2.contains(e,void 0)))return}c=$ancestorOf(c)}})}}}),InitializationPolicy=Base.extend(ComponentPolicy,{componentCreated:function(a){if($isFunction(a.initialize))return a.initialize()}}),ComponentModelAware=Protocol.extend({set componentModel(a){}}),ComponentModelAwarePolicy=Base.extend(ComponentPolicy,{constructor:function(a){this.extend({componentCreated:function(b,c){a&&!ComponentModelAware.adoptedBy(b)||(b.componentModel=c)}})}},{init:function(){this.Implicit=new this(!0),this.Explicit=new this(!1)}}),ComponentBuilder=Base.extend(Registration,{constructor:function(a){var b,c,d,e=new ComponentModel;e.key=a,this.extend({invariant:function(){return e.setInvariant(),this},boundTo:function(a){return e.implementation=a,this},dependsOn:function(a){return a=Array.prototype.concat.apply([],arguments),e.setDependencies(a),this},usingFactory:function(a){return e.factory=a,this},instance:function(a){return e.lifestyle=new SingletonLifestyle(a),this},singleton:function(){return e.lifestyle=new SingletonLifestyle,this},transient:function(){return e.lifestyle=new TransientLifestyle,this},contextual:function(){return e.lifestyle=new ContextualLifestyle,this},newInContext:function(){return b=!0,this},newInChildContext:function(){return c=!0,this},interceptors:function(a){return a=Array.prototype.concat.apply([],arguments),new InterceptorBuilder(this,e,a)},policies:function(a){return a&&(d=Array.prototype.concat.apply(d||[],arguments)),this},register:function(a){if(b||c){var f=e.factory;e.factory=function(a){var c=f(a),d=this.resolve(Context);return b?ContextualHelper.bindContext(c,d):ContextualHelper.bindChildContext(d,c),c}}return a.addComponent(e,d)}})}}),InterceptorBuilder=Base.extend(Registration,{constructor:function(a,b,c){this.extend({selectWith:function(a){return b.manageDependencies(Facet.InterceptorSelectors,function(b){Array2.forEach(a,function(a){a instanceof InterceptorSelector&&(selecter=$use(a)),b.append(a)})}),this},toFront:function(){return this.atIndex(0)},atIndex:function(a){return b.manageDependencies(Facet.Interceptors,function(b){Array2.forEach(c,function(c){b.insertIndex(a,c)})}),b},register:function(d,e){return b.manageDependencies(Facet.Interceptors,function(a){a.append(c)}),a.register(d,e)}})}}),DependencyResolution=Resolution.extend({constructor:function(a,b,c){var d,e;this.base(a,c),this.extend({claim:function(a,b){return!this.isResolvingDependency(a)&&(e=a,d=b,!0)},isResolvingDependency:function(a){return a===e||b&&b.isResolvingDependency(a)},formattedDependencyChain:function(){var c=$eq.test(a),e=Modifier.unwrap(a),f=c?"`"+e+"`":e,g=d?"("+f+" <- "+d+")":f;return b?g+" <= "+b.formattedDependencyChain():g}})}});DependencyResolutionError.prototype=new Error,DependencyResolutionError.prototype.constructor=DependencyResolutionError,ComponentModelError.prototype=new Error,ComponentModelError.prototype.constructor=ComponentModelError;var DEFAULT_POLICIES=[new InjectionPolicy,ComponentModelAwarePolicy.Implicit,new InitializationPolicy],IoContainer=CallbackHandler.extend(Container,{constructor:function(){var a=DEFAULT_POLICIES;this.extend({addComponent:function(b,c){c=c&&c.length>0?a.concat(c):a;for(var d=0;d<c.length;++d){var e=c[d];$isFunction(e.applyPolicy)&&e.applyPolicy(b,c)}var f=Validator($composer).validate(b);if(!f.valid)throw new ComponentModelError(b,f);return this.registerHandler(b,c)},addPolicies:function(b){b&&(a=a.concat.apply(a,arguments))}})},resolve:function(a){var b=a instanceof Resolution?a:new DependencyResolution(a);if(this.handle(b,!1,global.$composer))return b.callbackResult},resolveAll:function(a){var b=a instanceof Resolution?a:new DependencyResolution(a,null,!0);return this.handle(b,!0,global.$composer)?b.callbackResult:[]},register:function(a){return Array2.flatten(arguments).map(function(a){return a.register(this,$composer)}.bind(this))},registerHandler:function(a,b){return _registerHandler(a,this,b)},invoke:function(a,b,c){var d=a.$inject||a.inject,e=new DependencyManager(b);if(d&&($isFunction(d)&&(d=d()),e.merge(d)),b=e.getItems(),b.length>0){var f={d:b};return deps=_resolveBurden(f,!0,null,$composer),a.apply(c,deps.d)}return a()},dispose:function(){$provide.removeAll(this)}});void 0!==module&&module.exports&&(module.exports=exports=this.package),eval(this.exports)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../callback.js":6,"../context.js":7,"../miruken.js":14,"../validate":22,bluebird:25}],14:[function(require,module,exports){(function(global){require("./base2.js");var Promise=require("bluebird");new function(){function _cleanDescriptor(a){delete a.writable,delete a.value,delete a.get,delete a.set}function $using(a,b,c){if(a&&$isFunction(a.dispose)){if(!$isPromise(b)){var d;try{if(d=$isFunction(b)?b.call(c,a):b,!$isPromise(d))return d}finally{if($isPromise(d))b=d;else{var e=a.dispose();if(void 0!==e)return e}}}return b.then(function(b){var c=a.dispose();return void 0!==c?c:b},function(b){var c=a.dispose();return void 0!==c?c:Promise.reject(b)})}}function Modifier(){}function $createModifier(){function a(c){if(this===global){if(a.test(c))return c;b=!0;var d=new a(c);return b=!1,d}if(!b)throw new Error("Modifiers should not be called with the new operator.");this.getSource=function(){return c}}var b;return a.prototype=new Modifier,a.test=function(b){return b instanceof a||b instanceof Modifier&&a.test(b.getSource())},a}function _buildProxy(a,b,c){var d=c.baseType||a.shift()||Base,e=d.extend(a.concat(b),{constructor:function a(b){var c=a.spec||(a.spec={});c.value=b[Facet.InterceptorSelectors],c.value&&c.value.length>0&&Object.defineProperty(this,"selectors",c),c.value=b[Facet.Interceptors],c.value&&c.value.length>0&&Object.defineProperty(this,"interceptors",c),c.value=b[Facet.Delegate],c.value&&(c.writable=!0,Object.defineProperty(this,"delegate",c)),_proxyMethod("constructor",this.base,d).apply(this,b[Facet.Parameters]),delete c.writable,delete c.value},getInterceptors:function(a,b){var c=this.selectors;return c?Array2.reduce(c,function(c,d){return d.selectInterceptors(a,b,c)},this.interceptors):this.interceptors},extend:_extendProxy},{shouldProxy:c.shouldProxy});return _proxyClass(e,b),e.extend=e.implement=_throwProxiesSealedExeception,e}function _throwProxiesSealedExeception(){throw new TypeError("Proxy classes are sealed and cannot be extended from.")}function _proxyClass(a,b){for(var c=[a].concat(b),d=a.prototype,e={},f=0;f<c.length;++f){var g=c[f],h=g.prototype,i=$isProtocol(g);for(var j in h)if(!(j in e||j in _noProxyMethods)&&(!a.shouldProxy||a.shouldProxy(j,g))){var k=_getPropertyDescriptor(h,j);if("value"in k){var l=i?void 0:k.value;($isNothing(l)||$isFunction(l))&&(d[j]=_proxyMethod(j,l,a)),e[j]=!0}else if(i){var m=j.charAt(0).toUpperCase()+j.slice(1),n="get"+m,o="set"+m,p=_proxyClass.spec||(_proxyClass.spec={enumerable:!0});p.get=function(b){var c;return function(){return b in this?this[b].call(this):(c||(c=_proxyMethod(b,void 0,a)),c.call(this))}}(n),p.set=function(b){var c;return function(d){return b in this?this[b].call(this,d):(c||(c=_proxyMethod(b,void 0,a)),c.call(this,d))}}(o),Object.defineProperty(a.prototype,j,p),e[j]=!0}}}}function _proxyMethod(a,b,c){function d(){var d=this,g=this.delegate,h=-1;e||(e=this.getInterceptors(c,a));var i={args:Array.prototype.slice.call(arguments),useDelegate:function(a){g=a},replaceDelegate:function(a){d.delegate=g=a},proceed:function(){if(++h,e&&h<e.length){return e[h].intercept(i)}if(g){var c=g[a];if($isFunction(c))return c.apply(g,this.args)}else if(b)return b.apply(d,this.args);throw new Error(format("Interceptor cannot proceed without a class or delegate method '%1'.",a))}};return f.value=a,Object.defineProperty(i,"method",f),f.value=c,Object.defineProperty(i,"source",f),delete f.value,f.get=function(){return!!(e&&h+1<e.length)||(g?$isFunction(g(a)):!!b)},Object.defineProperty(i,"canProceed",f),delete f.get,i.proceed()}var e,f=_proxyMethod.spec||(_proxyMethod.spec={});return d.baseMethod=b,d}function _extendProxy(){var a=this.constructor,b=a.prototype,c=1===arguments.length?arguments[0]:{};arguments.length>=2&&(c[arguments[0]]=arguments[1]);for(var d in c)if(!(d in _noProxyMethods)&&(!a.shouldProxy||a.shouldProxy(d,b))){var e=this[d];e&&e.baseMethod&&(this[d]=e.baseMethod),this.base(d,c[d]),this[d]=_proxyMethod(d,this[d],b)}return this}function _listContents(a,b,c){var d=Array.prototype.pop.call(b);if($isFunction(d))for(var e=Array.prototype.pop.call(b)||Object.keys(a),f=0;f<e.length;++f){var g=e[f],h=a[g];!h||c&&!c(h,g)||d({member:h,name:g})}}function $isClass(a){return a&&a.prototype instanceof Base&&!$isProtocol(a)}function $classOf(a){return a&&a.constructor}function $ancestorOf(a){return a&&a.ancestor}function $isString(a){return"string"===typeOf(a)}function $isFunction(a){return a instanceof Function}function $isObject(a){return a===Object(a)}function $isArray(a){return"[object Array]"===Object.prototype.toString.call(a)}function $isPromise(a){return a&&$isFunction(a.then)}function $isNothing(a){return null==a}function $isSomething(a){return null!=a}function $lift(a){return function(){return a}}function $equals(a,b){return a===b||($isFunction(a.equals)?a.equals(b):!!$isFunction(b.equals)&&b.equals(a))}function $decorator(a){return function(b){if($isNothing(b))throw new TypeError("No decoratee specified.");var c=Object.create(b),d=$decorator.spec||($decorator.spec={});return d.value=b,Object.defineProperty(c,"decoratee",d),ClassMeta.createInstanceMeta.call(c,b.$meta),a&&c.extend(a),delete d.value,c}}function $decorate(a,b){return $decorator(b)(a)}function $decorated(a,b){for(var c;a&&(c=a.decoratee);){if(!b)return c;a=c}return a}function $debounce(a,b,c,d){var e;return function(){var f=this,g=arguments,h=function(){if(e=null,!c)return a.apply(f,g)},i=c&&!e;return clearTimeout(e),e=setTimeout(h,b),i?a.apply(f,g):d}}function _getPropertyDescriptor(a,b,c){for(var d,e=a;e&&!(d=Object.getOwnPropertyDescriptor(e,b));)e=c?null:Object.getPrototypeOf(e);return d}base2.package(this,{name:"miruken",exports:"Enum,Flags,Variance,Protocol,StrictProtocol,Delegate,Miruken,MetaStep,MetaMacro,Initializing,Disposing,DisposingMixin,Resolving,Invoking,Parenting,Starting,Startup,Facet,Interceptor,InterceptorSelector,ProxyBuilder,Modifier,ArrayManager,IndexedList,$isProtocol,$isClass,$classOf,$ancestorOf,$isString,$isFunction,$isObject,$isArray,$isPromise,$isNothing,$isSomething,$using,$lift,$equals,$decorator,$decorate,$decorated,$debounce,$eq,$use,$copy,$lazy,$eval,$every,$child,$optional,$promise,$instant,$createModifier,$properties,$inferProperties,$inheritStatic"}),eval(this.imports);var $eq=$createModifier(),$use=$createModifier(),$copy=$createModifier(),$lazy=$createModifier(),$eval=$createModifier(),$every=$createModifier(),$child=$createModifier(),$optional=$createModifier(),$promise=$createModifier(),$instant=$createModifier(),Enum=Base.extend({constructor:function(a,b,c){this.constructing(a,b),Object.defineProperties(this,{value:{value:a,writable:!1,configurable:!1},name:{value:b,writable:!1,configurable:!1},ordinal:{value:c,writable:!1,configurable:!1}})},toString:function(){return this.name},toJSON:function(){var a=this.value;return null!=a&&$isFunction(a.toJSON)?a.toJSON():a},constructing:function(a,b){if(!this.constructor.__defining)throw new TypeError("Enums cannot be instantiated.")}},{coerce:function(a,b){if(this===Enum||this===Flags){var c=this.extend(b,{coerce:function(a){return this.fromValue(a)}});c.__defining=!0;var d=[],e=0;c.names=Object.freeze(Object.keys(a));for(var f in a){var g=c[f]=new c(a[f],f,e++);d.push(g)}return c.items=Object.freeze(d),c.fromValue=this.fromValue,delete c.__defining,Object.freeze(c)}},fromValue:function(a){for(var b=this.names,c=0;c<b.length;++c){var d=this[b[c]];if(d.value==a)return d}throw new TypeError(format("%1 is not a valid value for this Enum.",a))}});Enum.prototype.valueOf=function(){var a=+this.value;return isNaN(a)?this.ordinal:a};var Flags=Enum.extend({hasFlag:function(a){return a=+a,(this&a)===a},addFlag:function(a){return $isSomething(a)?this.constructor.fromValue(this|a):this},removeFlag:function(a){return $isSomething(a)?this.constructor.fromValue(this&~a):this},constructing:function(a,b){}},{fromValue:function(a){a=+a;for(var b,c=this.names,d=0;d<c.length;++d){var e=this[c[d]];if(e.value===a)return e;(a&e.value)===e.value&&(b=b?b+","+e.name:e.name)}return new this(a,b)}}),Variance=Enum({Covariant:1,Contravariant:2,Invariant:3}),Protocol=Base.extend({constructor:function(a,b){if($isNothing(a))a=new Delegate;else if($isFunction(a.toDelegate)){if((a=a.toDelegate())instanceof Delegate==!1)throw new TypeError(format("%1.toDelegate did not return a valid Delegate.",a))}else a instanceof Delegate==!1&&(a=$isArray(a)?new ArrayDelegate(a):new ObjectDelegate(a));Object.defineProperty(this,"delegate",{value:a}),Object.defineProperty(this,"strict",{value:!!b})},__get:function(a){var b=this.delegate;return b&&b.get(this.constructor,a,this.strict)},__set:function(a,b){var c=this.delegate;return c&&c.set(this.constructor,a,b,this.strict)},__invoke:function(a,b){var c=this.delegate;return c&&c.invoke(this.constructor,a,b,this.strict)}},{conformsTo:False,isProtocol:function(a){return a&&a.prototype instanceof Protocol},adoptedBy:function(a){return!(!a||!$isFunction(a.conformsTo))&&a.conformsTo(this)},coerce:function(a,b){return new this(a,b)}}),MetaStep=Enum({Subclass:1,Implement:2,Extend:3}),MetaMacro=Base.extend({inflate:function(a,b,c,d,e){},execute:function(a,b,c,d){},protocolAdded:function(a,b){},extractProperty:function(a,b,c){var d=c[a];return $isFunction(d)&&(d=d()),delete b[a],d},shouldInherit:False,isActive:False},{coerce:function(){return this.new.apply(this,arguments)}}),MetaBase=MetaMacro.extend({constructor:function(a){var b,c=[];this.extend({getParent:function(){return a},getProtocols:function(){return c.slice(0)},getAllProtocols:function(){for(var a=this.getProtocols(),b=a.slice(0),c=0;c<b.length;++c)for(var d=b[c].$meta.getAllProtocols(),e=0;e<d.length;++e){var f=d[e];a.indexOf(f)<0&&a.push(f)}return a},addProtocol:function(a){if(!$isNothing(a)){$isArray(a)||(a=Array.prototype.slice.call(arguments));for(var b=0;b<a.length;++b){var d=a[b];d.prototype instanceof Protocol&&-1===c.indexOf(d)&&(c.push(d),this.protocolAdded(this,d))}}},protocolAdded:function(b,c){a&&a.protocolAdded(b,c)},conformsTo:function(a){if(!(a&&a.prototype instanceof Protocol))return!1;for(var b=0;b<c.length;++b){var d=c[b];if(a===d||d.conformsTo(a))return!0}return!1},inflate:function(b,c,d,e,f){a?a.inflate(b,c,d,e,f):$properties&&$properties.shared.inflate(b,c,d,e,f)},execute:function(b,c,d,e){a?a.execute(b,c,d,e):$properties&&$properties.shared.execute(b,c,d,e)},defineProperty:function(a,b,c,d){d&&(d=copy(d)),a&&Object.defineProperty(a,b,c),d&&this.addDescriptor(b,d)},getDescriptor:function(c){var d;if($isNothing(c))a&&(d=a.getDescriptor(c)),b&&(d=extend(d||{},b));else{if($isString(c))return b&&b[c]||a&&a.getDescriptor(c);a&&(d=a.getDescriptor(c));for(var e in b){var f=b[e];this.matchDescriptor(f,c)&&(d=extend(d||{},e,f))}}return d},addDescriptor:function(a,c){return b=extend(b||{},a,c),this},matchDescriptor:function(a,b){if("object"!==typeOf(a)||"object"!==typeOf(b))return!1;for(var c in b){var d=b[c];if(void 0===d){if(!(c in a))return!1}else{var e=a[c];if($isArray(d)){if(!$isArray(e))return!1;for(var f=0;f<d.length;++f)if(e.indexOf(d[f])<0)return!1}else if(e!==d&&!this.matchDescriptor(e,d))return!1}}return!0},linkBase:function(b){return this[b]||this.extend(b,function(){var c=a&&a[b];if(c)return c.apply(a,arguments)}),this}})}}),ClassMeta=MetaBase.extend({constructor:function(a,b,c,d){var e=d&&d.slice(0),f=b===Protocol||b.prototype instanceof Protocol;this.base(a),this.extend({getClass:function(){return b},isProtocol:function(){return f},getAllProtocols:function(){var b=this.base();if(!f&&a)for(var c=a.getAllProtocols(),d=0;d<c.length;++d){var e=c[d];b.indexOf(e)<0&&b.push(e)}return b},protocolAdded:function(a,b){if(this.base(a,b),e&&0!=e.length)for(var c=0;c<e.length;++c)macro=e[c],$isFunction(macro.protocolAdded)&¯o.protocolAdded(a,b)},conformsTo:function(c){return!!(c&&c.prototype instanceof Protocol)&&(c===b||b.prototype instanceof c||(this.base(c)||!(!a||!a.conformsTo(c))))},inflate:function(a,b,c,d,f){if(this.base(a,b,c,d,f),e&&0!=e.length)for(var g=a!==MetaStep.Subclass,h=0;h<e.length;++h){var i=e[h];$isFunction(i.inflate)&&(!g||i.isActive())&&i.shouldInherit()&&i.inflate(a,b,c,d,f)}},execute:function(a,b,c,d){if(this.base(a,b,c,d),e&&0!=e.length)for(var f=this!==b,g=a!==MetaStep.Subclass,h=0;h<e.length;++h){var i=e[h];g&&!i.isActive()||f&&!i.shouldInherit()||i.execute(a,b,c,d)}},createSubclass:function a(){function c(){return c.x||(c.x=Object.create(m))}var d,e,f,g=Array.prototype.slice.call(arguments),h=g;for(b.prototype instanceof Protocol&&(d=[]).push(b),g.length>0&&$isArray(g[0])&&(h=g.shift());h.length>0;){var i=h[0];if(!i)break;if(i.prototype instanceof Protocol)(d||(d=[])).push(i);else if(i instanceof MetaMacro)(f||(f=[])).push(i);else if($isFunction(i)&&i.prototype instanceof MetaMacro)(f||(f=[])).push(new i);else{if(!i.prototype)break;(e||(e=[])).push(i)}h.shift()}var j=a.u||(a.u={}),k=a.cm||(a.cm={enumerable:!1,configurable:!1,writable:!1}),l=a.im||(a.im={enumerable:!1,configurable:!1,get:ClassMeta.createInstanceMeta}),m=g.shift()||j,n=g.shift()||j;if(this.inflate(MetaStep.Subclass,this,b.prototype,m,c),f)for(var o=0;o<f.length;++o)f[o].inflate(MetaStep.Subclass,this,b.prototype,m,c);m=c.x||m;var p=ClassMeta.baseExtend.call(b,m,n),q=new ClassMeta(this,p,d,f);return k.value=q,Object.defineProperty(p,"$meta",k),Object.defineProperty(p.prototype,"$meta",l),delete k.value,p.conformsTo=q.conformsTo.bind(q),q.execute(MetaStep.Subclass,q,p.prototype,m),e&&Array2.forEach(e,p.implement,p),p},embellishClass:function(a){function c(){return c.x||(c.x=Object.create(a))}return $isFunction(a)&&(a=a.prototype),$isSomething(a)&&(this.inflate(MetaStep.Implement,this,b.prototype,a,c),a=c.x||a,ClassMeta.baseImplement.call(b,a),this.execute(MetaStep.Implement,this,b.prototype,a)),b}}),this.addProtocol(c)}},{init:function(){this.baseExtend=Base.extend,this.baseImplement=Base.implement,Base.$meta=new this(void 0,Base),Abstract.$meta=new this(Base.$meta,Abstract),Base.extend=Abstract.extend=function(){return this.$meta.createSubclass.apply(this.$meta,arguments)},Base.implement=Abstract.implement=function(){return this.$meta.embellishClass.apply(this.$meta,arguments)},Base.prototype.conformsTo=function(a){return this.constructor.$meta.conformsTo(a)}},createInstanceMeta:function a(b){var c=a.spec||(a.spec={enumerable:!1,configurable:!0,writable:!1}),d=new InstanceMeta(b||this.constructor.$meta);return c.value=d,Object.defineProperty(this,"$meta",c),delete c.value,d}}),InstanceMeta=MetaBase.extend({constructor:function(a){this.base(a),this.extend({getClass:function(){return a.getClass()},isProtocol:function(){return a.isProtocol()}})}},{init:function(){var a=Base.prototype.extend;Base.prototype.extend=function(b,c){function d(){return d.x||(d.x=Object.create(f))}var e=arguments.length,f=1===e?b:{};if(e>=2)f[b]=c;else if(0===e)return this;var g=this.$meta;return g&&(g.inflate(MetaStep.Extend,g,this,f,d),f=d.x||f),a.call(this,f),g&&g.execute(MetaStep.Extend,g,this,f),this}}});Enum.$meta=new ClassMeta(Base.$meta,Enum),Enum.extend=Base.extend,Enum.implement=Base.implement;var $proxyProtocol=MetaMacro.extend({inflate:function(a,b,c,d,e){var f,g=Protocol.prototype;for(var h in d)if(!(h in g)){f=f||e();var i=_getPropertyDescriptor(d,h);if($isFunction(i.value))!function(a){i.value=function(){var b=Array.prototype.slice.call(arguments);return this.__invoke(a,b)}}(h);else{if(!i.get&&!i.set)continue;i.get&&function(a){i.get=function(){return this.__get(a)}}(h),i.set&&function(a){i.set=function(b){return this.__set(a,b)}}(h)}Object.defineProperty(f,h,i)}},execute:function(a,b,c,d){if(a===MetaStep.Subclass){b.getClass().adoptedBy=Protocol.adoptedBy}},protocolAdded:function(a,b){var c=b.prototype,d=a.getClass().prototype,e=Protocol.prototype;for(var f in c)if(!(f in e&&f in this)){var g=_getPropertyDescriptor(c,f);Object.defineProperty(d,f,g)}},shouldInherit:True,isActive:True});Protocol.extend=Base.extend,Protocol.implement=Base.implement,Protocol.$meta=new ClassMeta(Base.$meta,Protocol,null,[new $proxyProtocol]);var StrictProtocol=Protocol.extend({constructor:function(a,b){this.base(a,void 0===b||b)}}),GETTER_CONVENTIONS=["get","is"],$properties=MetaMacro.extend({constructor:function(a){if($isNothing(a))throw new Error("$properties requires a tag name");Object.defineProperty(this,"tag",{value:a})},execute:function a(b,c,d,e){var f=this.extractProperty(this.tag,d,e);if(f){var g,h={};for(var i in f){g=h;var j=f[i],k=a.spec||(a.spec={configurable:!0,enumerable:!0});if(($isNothing(j)||$isString(j)||"number"==typeOf(j.length)||"object"!==typeOf(j))&&(j={value:j}),i in e)g=null;else if(j.get||j.set)k.get=j.get,k.set=j.set;else if(d instanceof Protocol)k.get=k.set=Undefined;else if("auto"in j){var l=j.auto;l&&$isString(l)||(l="_"+i),k.get=function(){return this[l]},k.set=function(a){this[l]=a}}else k.writable=!0,k.value=j.value;_cleanDescriptor(j),this.defineProperty(c,g,i,k,j),_cleanDescriptor(k)}b==MetaStep.Extend?d.extend(h):c.getClass().implement(h)}},defineProperty:function(a,b,c,d,e){a.defineProperty(b,c,d,e)},shouldInherit:True,isActive:True},{
init:function(){Object.defineProperty(this,"shared",{enumerable:!1,configurable:!1,writable:!1,value:Object.freeze(new this("$properties"))})}}),$inferProperties=MetaMacro.extend({inflate:function a(b,c,d,e,f){var g;for(var h in e){var i=_getPropertyDescriptor(e,h);if($isFunction(i.value)){var j=a.spec||(a.spec={configurable:!0,enumerable:!0}),k=this.inferProperty(h,i.value,e,j);k&&(g=g||f(),Object.defineProperty(g,k,j),_cleanDescriptor(j))}}},inferProperty:function(a,b,c,d){for(var e=0;e<GETTER_CONVENTIONS.length;++e){var f=GETTER_CONVENTIONS[e];if(0==a.lastIndexOf(f,0)&&0===b.length){d.get=b;var g=a.substring(f.length),h=c["set"+g];return $isFunction(h)&&(d.set=h),g.charAt(0).toLowerCase()+g.slice(1)}}if(0==a.lastIndexOf("set",0)&&1===b.length){d.set=b;var g=a.substring(3),i=c["get"+g];return $isFunction(i)&&(d.get=i),g.charAt(0).toLowerCase()+g.slice(1)}},shouldInherit:True,isActive:True}),$inheritStatic=MetaMacro.extend({constructor:function a(){var b=a.spec||(a.spec={});b.value=Array.prototype.slice.call(arguments),Object.defineProperty(this,"members",b),delete b.value},execute:function(a,b,c){if(a===MetaStep.Subclass){var d=this.members,e=b.getClass(),f=$ancestorOf(e);if(d.length>0)for(var g=0;g<d.length;++g){var h=d[g];h in e||(e[h]=f[h])}else if(f!==Base&&f!==Object)for(var i in f)!f.hasOwnProperty(i)||i in e||(e[i]=f[i])}},shouldInherit:True}),Delegate=Base.extend({get:function(a,b,c){},set:function(a,b,c,d){},invoke:function(a,b,c,d){}}),ObjectDelegate=Delegate.extend({constructor:function(a){Object.defineProperty(this,"object",{value:a})},get:function(a,b,c){var d=this.object;if(d&&(!c||a.adoptedBy(d)))return d[b]},set:function(a,b,c,d){var e=this.object;if(e&&(!d||a.adoptedBy(e)))return e[b]=c},invoke:function(a,b,c,d){var e=this.object;if(e&&(!d||a.adoptedBy(e))){var f=e[b];return f&&f.apply(e,c)}}}),ArrayDelegate=Delegate.extend({constructor:function(a){Object.defineProperty(this,"array",{value:a})},get:function(a,b,c){var d=this.array;return d&&Array2.reduce(d,function(d,e){return!c||a.adoptedBy(e)?e[b]:d},void 0)},set:function(a,b,c,d){var e=this.array;return e&&Array2.reduce(e,function(e,f){return!d||a.adoptedBy(f)?f[b]=c:e},void 0)},invoke:function(a,b,c,d){var e=this.array;return e&&Array2.reduce(e,function(e,f){var g=f[b];return!g||d&&!a.adoptedBy(f)?e:g.apply(f,c)},void 0)}}),Miruken=Base.extend(null,{coerce:function(){return this.new.apply(this,arguments)}}),Initializing=Protocol.extend({initialize:function(){}}),Disposing=Protocol.extend({dispose:function(){}}),DisposingMixin=Module.extend({dispose:function(a){var b=a._dispose;if($isFunction(b))return a.dispose=Undefined,b.call(a)}}),Resolving=Protocol.extend(),Invoking=StrictProtocol.extend({invoke:function(a,b,c){}}),Parenting=Protocol.extend({newChild:function(){}}),Starting=Protocol.extend({start:function(){}}),Startup=Base.extend(Starting,{start:function(){}});Modifier.isModified=function(a){return a instanceof Modifier},Modifier.unwrap=function(a){return a instanceof Modifier?Modifier.unwrap(a.getSource()):a};var ArrayManager=Base.extend({constructor:function(a){var b=[];this.extend({getItems:function(){return b},getIndex:function(a){if(b.length>a)return b[a]},setIndex:function(a,c){return(b.length<=a||void 0===b[a])&&(b[a]=this.mapItem(c)),this},insertIndex:function(a,c){return b.splice(a,0,this.mapItem(c)),this},replaceIndex:function(a,c){return b[a]=this.mapItem(c),this},removeIndex:function(a){return b.length>a&&b.splice(a,1),this},append:function(){var a;if(1===arguments.length&&$isArray(arguments[0])?a=arguments[0]:arguments.length>0&&(a=arguments),a)for(var c=0;c<a.length;++c)b.push(this.mapItem(a[c]));return this},merge:function(a){for(var b=0;b<a.length;++b){var c=a[b];void 0!==c&&this.setIndex(b,c)}return this}}),a&&this.append(a)},mapItem:function(a){return a}}),IndexedList=Base.extend({constructor:function(a){var b={};this.extend({isEmpty:function(){return!this.head},getIndex:function(a){return a&&b[a]},insert:function(c,d){var e=this.getIndex(d),f=e;if(d)for(f=f||this.head;f&&a(c,f)>=0;)f=f.next;if(f){var g=f.prev;c.next=f,c.prev=g,f.prev=c,g&&(g.next=c),this.head===f&&(this.head=c)}else{delete c.next;var h=this.tail;h?(c.prev=h,h.next=c):(this.head=c,delete c.prev),this.tail=c}d&&(c.index=d,e||(b[d]=c))},remove:function(a){var c=a.prev,d=a.next;c?d?(c.next=d,d.prev=c):(this.tail=c,delete c.next):d?(this.head=d,delete d.prev):(delete this.head,delete this.tail);var e=a.index;this.getIndex(e)===a&&(d&&d.index===e?b[e]=d:delete b[e])}})}}),Facet=Object.freeze({Parameters:"parameters",Interceptors:"interceptors",InterceptorSelectors:"interceptorSelectors",Delegate:"delegate"}),Interceptor=Base.extend({intercept:function(a){return a.proceed()}}),InterceptorSelector=Base.extend({selectInterceptors:function(a,b,c){return c}}),ProxyBuilder=Base.extend({buildProxy:function(a,b){if(!$isArray(a))throw new TypeError("ProxyBuilder requires an array of types to proxy.");return _buildProxy(Array2.filter(a,$isClass),Array2.filter(a,$isProtocol),b||{})}}),_noProxyMethods={base:!0,extend:!0,constructor:!0,conformsTo:!0,getInterceptors:!0,getDelegate:!0,setDelegate:!0};Package.implement({export:function(a,b){this.addName(a,b)},getProtocols:function(){_listContents(this,arguments,$isProtocol)},getClasses:function(){_listContents(this,arguments,function(a,b){return $isClass(a)&&"constructor"!=b})},getPackages:function(){_listContents(this,arguments,function(a,b){return a instanceof Package&&"parent"!=b})}});var $isProtocol=Protocol.isProtocol;void 0===Function.prototype.new&&(Function.prototype.new=function(){function a(){c.apply(this,b)}var b=arguments,c=this;return a.prototype=c.prototype,new a}),void 0!==module&&module.exports&&(module.exports=exports=this.package),global.miruken=this.package,global.Miruken=Miruken,eval(this.exports)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./base2.js":5,bluebird:25}],15:[function(require,module,exports){var miruken=require("../miruken.js"),Promise=require("bluebird");require("./view.js"),new function(){function _buildChrome(a){var b="";return b+=format('<div class="modal fade" role="dialog" %1>',a.forceClose?'data-backdrop="static"':""),b+='<div class="modal-dialog" role="document">',b+='<div class="modal-content">',b=_buildHeader(b,a),b+='<div class="modal-body">',b+="</div>",b=_buildFooter(b,a),b+="</div>",b+="</div>",b+="</div>"}function _buildHeader(a,b){return(b.header||b.title)&&(a+='<div class="modal-header">',b.forceClose||(a+='<button type="button" class="close js-close">×</button>'),a+=format('<h4 class="modal-title"> %1  </h4>',b.title),a+="</div>"),a}function _buildFooter(a,b){return(b.footer||b.buttons)&&(a+='<div class="modal-footer text-right">',b.buttons?Array2.forEach(b.buttons,function(b){$isString(b)?a+=format('<button class="btn btn-default btn-sm js-close">%1</button>',b):$isObject(b)&&(a+=format('<button class="btn js-close %1">%2</button>',b.css,b.text))}):a+='<button class="btn btn-primary btn-sm js-close">Close</button>',a+="</div>"),a}miruken.package(this,{name:"mvc",imports:"miruken,miruken.mvc",exports:"Bootstrap,BootstrapProvider"}),eval(this.imports);var Bootstrap=ModalProviding.extend(),BootstrapProvider=Base.extend(Bootstrap,{showModal:function(a,b,c,d){function e(){f.remove(),$(".modal-backdrop").remove(),$("body").removeClass("modal-open"),d.end()}$(".modal").modal("hide"),c.chrome?($("body").append(_buildChrome(c)),$(".modal-body").append(b)):$("body").append(b);var f=$(".modal").modal().on("hidden.bs.modal",e);return{visible:new Promise(function(a,b){f.on("shown.bs.modal",function(){a(f)})}),closed:new Promise(function(a,b){function f(c){a&&(null!=c?a(c):b(),a=null,e())}d&&d.onEnding(function(){f()}),$(".modal .js-close").click(function(a){var b;if("×"!=a.target.innerText){var d=$(a.target).index();c.buttons&&c.buttons.length>d&&(b=new ButtonClicked(c.buttons[d],d))}f(b)})})}}});eval(this.exports)}},{"../miruken.js":14,"./view.js":21,bluebird:25}],16:[function(require,module,exports){var miruken=require("../miruken.js");require("../callback.js"),require("../context.js"),require("../error.js"),require("../validate");var Promise=require("bluebird");new function(){function createTrampoline(a,b,c){if(!(a.prototype instanceof Controller))throw new TypeError(format("%1 is not a Controller",a));var d={},e=Navigate(b),f=a.prototype,g=e[c];do{Array2.forEach(Object.getOwnPropertyNames(f),function(b){if(!(TRAMPOLINE_IGNORE.indexOf(b)>=0||0===b.lastIndexOf("_",0)||b in d)){var h=Object.getOwnPropertyDescriptor(f,b);null!=h&&$isFunction(h.value)&&(d[b]=function(){var d=Array.prototype.slice.call(arguments);return g.call(e,a,function(a){return a[b].apply(a,d)},function(a,e){return a.$$provide([Navigation,new Navigation({push:"push"===c,controller:e,action:b,args:d})])})})}})}while(f=Object.getPrototypeOf(f)&&f instanceof Controller);return d}function ControllerNotFound(a){this.message=format("The controller '%1' could not be resolved",a),this.controller=a,Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this)}function _bindIO(a,b){if(null==(a=_assemble(a||b.context,globalPrepare,b)))return void delete b.io;if(0===globalExecute.length)return void(b.io=a);var c=b.io=a.decorate({toDelegate:function(){var a=_assemble(this,globalExecute,b);return delete c.toDelegate,a.toDelegate()}})}function _assemble(a,b,c){return a&&b?b.reduce(function(a,b){return $isFunction(b)?b.call(c,a)||a:a},a):a}function _validate(a,b,c){var d=this.context;if(!d)throw new Error("Validation requires a context to be available.");var e=Validator(d);return e[b].call(e,a||this,c)}miruken.package(this,{name:"mvc",imports:"miruken,miruken.callback,miruken.context,miruken.validate,miruken.error",exports:"Controller,ControllerNotFound,Navigate,Navigation,NavigateCallbackHandler"}),eval(this.imports);var globalPrepare=new Array2,globalExecute=new Array2,Navigation=Base.extend({push:void 0,controller:void 0,action:void 0,args:void 0}),Navigate=StrictProtocol.extend({next:function(a,b,c){},push:function(a,b,c){}}),Controller=CallbackHandler.extend(DisposingMixin,Validating,$contextual,$validateThat,{get ifValid(){return this.io.$validAsync(this)},show:function(a,b){return a instanceof CallbackHandler?miruken.mvc.ViewRegion(a).show(b):miruken.mvc.ViewRegion(this.io).show(a)},next:function(a,b){return createTrampoline(a,b||this.io||this.context,"next")},push:function(a,b){return createTrampoline(a,b||this.io||this.context,"push")},validate:function(a,b){return _validate.call(this,a,"validate",b)},validateAsync:function(a,b){return _validate.call(this,a,"validateAsync",b)},viewRegionCreated:function(a,b){this[a]=b},_dispose:function(){this.context=null,delete this.io}},{coerce:function(a){var b=this;return{get next(){return createTrampoline(b,a,"next")},get push(){return createTrampoline(b,a,"push")}}},get prepare(){return globalPrepare},get execute(){return globalExecute}}),TRAMPOLINE_IGNORE=["base","constructor","initialize","dispose"];ControllerNotFound.prototype=new Error,ControllerNotFound.prototype.constructor=ControllerNotFound;var NavigateCallbackHandler=CompositeCallbackHandler.extend(Navigate,{next:function(a,b,c){return this.to(a,b,!1,c)},push:function(a,b,c){return this.to(a,b,!0,c)},to:function(a,b,c,d){if(null==b)return Promise.reject(new Error("Missing action"));var e=$composer,f=e.resolve(Context),g=e.resolve(Controller),h=c?f.newChild():f;return c||null==g||g.context!=h||(g.context=null),Promise.resolve(h.resolve(a)).then(function(g){if(!g)return Promise.reject(new ControllerNotFound(a));h.onEnding(function(){g.dispose()});try{c&&(e=e.pushLayer());var i=h===f?e:h.$self().next(e);return $isFunction(d)&&(i=d(i,g)||i),_bindIO(i,g),b(g)}catch(j){return Errors(g.io).handleException(j)}finally{_bindIO(null,g)}})}});eval(this.exports)}},{"../callback.js":6,"../context.js":7,"../error.js":8,"../miruken.js":14,"../validate":22,bluebird:25}],17:[function(a,b,c){b.exports=a("./model.js"),a("./view.js"),a("./controller.js"),a("./master-detail.js"),a("./bootstrap.js"),a("./route.js")},{"./bootstrap.js":15,"./controller.js":16,"./master-detail.js":18,"./model.js":19,"./route.js":20,"./view.js":21}],18:[function(require,module,exports){var miruken=require("../miruken.js");new function(){miruken.package(this,{name:"mvc",imports:"miruken",exports:"MasterDetail,MasterDetailAware"}),eval(this.imports);var MasterDetail=Protocol.extend({getSelectedDetail:function(a){},getSelectedDetails:function(a){},selectDetail:function(a){},deselectDetail:function(a){},hasPreviousDetail:function(a){},hasNextDetail:function(a){},getPreviousDetail:function(a){},getNextDetail:function(a){},addDetail:function(a){},updateDetail:function(a){},removeDetail:function(a,b){}}),MasterDetailAware=Protocol.extend({masterChanged:function(a){},detailSelected:function(a,b){},detailUnselected:function(a,b){},detailAdded:function(a,b){},detailUpdated:function(a,b){},detailRemoved:function(a,b){}});eval(this.exports)}},{"../miruken.js":14}],19:[function(require,module,exports){var miruken=require("../miruken.js");require("../callback.js"),require("../context.js"),require("../validate"),new function(){miruken.package(this,{name:"mvc",imports:"miruken,miruken.validate",exports:"Model"}),eval(this.imports);var Model=Base.extend($inferProperties,$validateThat,{constructor:function(a,b){this.fromData(a,b)},fromData:function(a,b){if($isNothing(a))return this;var c=this.$meta,d=c&&c.getDescriptor(),e=b&&b.dynamic;if(d)for(var f in d){var g=d[f];g&&g.root&&g.map&&(this[f]=g.map(a))}for(var f in a){var g=d&&d[f],h=g&&g.map;if(!(h&&g.root||g&&g.ignore)){var i=a[f];if(void 0!==i)if(f in this)this[f]=Model.map(i,h,b);else{var j=f.toLowerCase(),k=!1;for(var l in this)if(l.toLowerCase()===j){g=d&&d[l],h=g&&g.map,this[l]=Model.map(i,h,b),k=!0;break}!k&&e&&(this[f]=i)}}}return this},toData:function(a,b){b=b||{};var c=this.$meta,d=c&&c.getDescriptor();if(d){var e=!$isObject(a);for(var f in d)if(e||f in a){var g=this[f];if(void 0===g)continue;var h=d[f],i=e?a:a[f];if(!e&&!i||h.ignore)continue;if(h.root){if(g)if($isFunction(g.toData))g.toData(i,b);else if($isFunction(g.toJSON)){var j=g.toJSON();for(var k in j)b[k]=j[k]}}else $isArray(g)?b[f]=Array2.map(g,function(a){if(a)return $isFunction(a.toData)?a.toData(i):$isFunction(a.toJSON)?a.toJSON():a}):(g&&($isFunction(g.toData)?g=g.toData(i):$isFunction(g.toJSON)&&(g=g.toJSON())),b[f]=g)}}return b},toJSON:function(){return this.toData()},mergeInto:function(a){if(!(a instanceof this.constructor))return!1;var b=this.$meta,c=b&&b.getDescriptor();for(var d in c){var e=this[d];if(void 0!==e&&this.hasOwnProperty(d)){var f=a[d];void 0!==f&&a.hasOwnProperty(d)?$isFunction(e.mergeInto)&&e.mergeInto(f):a[d]=e}}return!0}},{map:function(a,b,c){return $isArray(a)?Array2.map(a,function(a){return Model.map(a,b,c)}):b?b(a,c):a},coerce:function(){return this.new.apply(this,arguments)}});eval(this.exports)}},{"../callback.js":6,"../context.js":7,"../miruken.js":14,"../validate":22}],20:[function(require,module,exports){(function(global){var miruken=require("../miruken.js"),Promise=require("bluebird");new function(){function _rejectRoute(a,b){try{return Promise.resolve(this.rejectRoute(a,b))}catch(c){return Promise.reject(c)}}miruken.package(this,{name:"mvc",imports:"miruken",exports:"Route,Routing,Router"}),eval(this.imports);var Route=Base.extend({name:void 0,pattern:void 0,params:void 0}),Routing=StrictProtocol.extend({handleRoute:function(a){},followNavigation:function(a){}}),controllerKeyRegExp=/(.*)controller$/i,Router=Base.extend(Routing,$inheritStatic,{handleRoute:function(a){var b=a.name,c=a.params;try{if(null==c)throw new Error(format("Missing params route '%1'",b));var d=c.controller;if(null==d)throw new Error(format("Missing controller for route '%1'",b));this.validateRoute(a)}catch(k){return _rejectRoute.call(this,a,k)}var e=global.$composer,f=Navigate(e),g=c.action||(c.action="index"),h=function(a){var d=this.selectActionMethod(a,g),e=d&&a[d];return $isFunction(e)?e.call(a,c):Promise.reject(new Error(format("%1 missing action '%2' for route '%3'",a,g,b)))}.bind(this),i=this.expandControllerKey(d),j=this;return f.next(i,h).catch(function(b){return b instanceof ControllerNotFound&&i!==d?f.next(d,h).catch(function(b){return _rejectRoute.call(j,a,b)}):_rejectRoute.call(j,a,b)})},validateRoute:function(a){},rejectRoute:function(a,b){return Promise.reject(b)},extractControllerKey:function(a){var b=a.match&&a.match(controllerKeyRegExp);return b?b[1].toLowerCase():a},expandControllerKey:function(a){return a.match&&!a.match(controllerKeyRegExp)?a+"Controller":a},selectActionMethod:function(a,b){if(b in a)return b;b=b.toLowerCase();for(var c in a)if(b===c.toLowerCase())return c}});eval(this.exports)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../miruken.js":14,bluebird:25}],21:[function(require,module,exports){var miruken=require("../miruken.js");require("../callback.js"),require("../context.js"),require("../validate"),require("./model.js"),new function(){miruken.package(this,{name:"mvc",imports:"miruken,miruken.callback",exports:"ViewLayer,ViewRegion,PresentationPolicy,RegionPolicy,ModalPolicy,ModalProviding,ButtonClicked"}),eval(this.imports);var ViewLayer=Protocol.extend(Disposing,{get index(){}}),ViewRegion=StrictProtocol.extend({show:function(a){}}),PresentationPolicy=Model.extend(),ModalPolicy=PresentationPolicy.extend({$properties:{title:"",style:null,chrome:!0,header:!1,footer:!1,forceClose:!1,buttons:null}}),RegionPolicy=PresentationPolicy.extend({$properties:{tag:void 0,push:!1,modal:void 0}}),ButtonClicked=Base.extend({constructor:function(a,b){this.extend({get button(){return a},get buttonIndex(){return b}})}}),ModalProviding=StrictProtocol.extend({showModal:function(a,b,c,d){}});CallbackHandler.implement({presenting:function(a){return a?this.decorate({$handle:[PresentationPolicy,function(b){return a.mergeInto(b)}]}):this},region:function(a){return this.presenting(new RegionPolicy({tag:a}))},pushLayer:function(){return this.presenting(new RegionPolicy({push:!0}))},modal:function(a){return this.presenting(new RegionPolicy({modal:new ModalPolicy(a)}))}}),eval(this.exports)}},{"../callback.js":6,"../context.js":7,"../miruken.js":14,"../validate":22,"./model.js":19}],22:[function(a,b,c){b.exports=a("./validate.js"),a("./validatejs.js")},{"./validate.js":23,"./validatejs.js":24}],23:[function(require,module,exports){var miruken=require("../miruken.js"),Promise=require("bluebird");require("../callback.js"),new function(){function _validateThat(a,b,c){var d=a.object;for(var e in d)if(0==e.lastIndexOf("validateThat",0)){var f=d[e],g=f.call(d,a,c);b&&$isPromise(g)&&b.push(g)}}function _bindValidationResults(a,b){var c=_bindValidationResults.spec||(_bindValidationResults.spec={enumerable:!1,configurable:!0,writable:!1});c.value=b,Object.defineProperty(a,"$validation",c),delete c.value}miruken.package(this,{name:"validate",imports:"miruken,miruken.callback",exports:"Validating,Validator,Validation,ValidationResult,ValidationCallbackHandler,$validate,$validateThat"}),eval(this.imports);var $validate=$define("$validate"),Validating=Protocol.extend({validate:function(a,b,c){},validateAsync:function(a,b,c){}}),Validator=StrictProtocol.extend(Validating),Validation=Base.extend({constructor:function(a,b,c,d){var e;b=!!b,d=d||new ValidationResult,this.extend({get isAsync(){return b},get object(){return a},get scope(){return c},get results(){return d},get asyncResults(){return e},addAsyncResult:function(a){$isPromise(a)&&(e||(e=[])).push(a)}})}}),IGNORE=["valid","errors","addKey","addError"],ValidationResult=Base.extend({constructor:function(){var a,b;this.extend({get valid(){if(a||b)return!1;for(var c=Object.getOwnPropertyNames(this),d=0;d<c.length;++d){var e=c[d];if(!(IGNORE.indexOf(e)>=0)){var f=this[e];if(f instanceof ValidationResult&&!f.valid)return!1}}return!0},get errors(){if(b)return b;if(a){b={};for(var c in a)b[c]=a[c].slice(0)}for(var d=Object.getOwnPropertyNames(this),e=0;e<d.length;++e){var f=d[e];if(!(IGNORE.indexOf(f)>=0)){var g=this[f],h=g instanceof ValidationResult&&g.errors;if(h){b=b||{};for(c in h)for(var i=h[c],j=b[c],k=0;k<i.length;++k){var l=pcopy(i[k]);l.key=l.key?f+"."+l.key:f,j?j.push(l):b[c]=j=[l]}}}}return b},addKey:function(a){return this[a]||(this[a]=new ValidationResult)},addError:function(c,d){var e=a||(a={}),f=e[c];return f?f.push(d):e[c]=[d],b=null,this},reset:function(){a=b=void 0;for(var c=Object.getOwnPropertyNames(this),d=0;d<c.length;++d){var e=c[d];if(!(IGNORE.indexOf(e)>=0)){this[e]instanceof ValidationResult&&delete this[e]}}return this}})}}),ValidationCallbackHandler=CallbackHandler.extend(Validator,{validate:function(a,b,c){if($isNothing(a))throw new TypeError("Missing object to validate.");var d=new Validation(a,!1,b,c);return $composer.handle(d,!0),c=d.results,_bindValidationResults(a,c),_validateThat(d,null,$composer),c},validateAsync:function(a,b,c){if($isNothing(a))throw new TypeError("Missing object to validate.");var d=new Validation(a,!0,b,c),e=$composer;return e.deferAll(d).then(function(){c=d.results,_bindValidationResults(a,c);var b=[];return _validateThat(d,b,e),b.length>0?Promise.all(b).return(c):c})}});$handle(CallbackHandler,Validation,function(a,b){var c=a.object,d=$classOf(c);if(d){$validate.dispatch(this,a,d,b,!0,a.addAsyncResult);var e=a.asyncResults;if(e)return Promise.all(e)}});var $validateThat=MetaMacro.extend({execute:function(a,b,c,d){var e=this.extractProperty("$validateThat",c,d);if(e){var f={};for(var g in e){var h=e[g];if($isArray(h)){var i=h.slice(0);if(h=i.pop(),!$isFunction(h))continue;i.length>0&&(h=function(a,b,c){return function(a,d){var e=Array2.concat(c,Array2.map(arguments,$use));return Invoking(d).invoke(b,e,this)}}(0,h,i))}$isFunction(h)&&(g="validateThat"+g.charAt(0).toUpperCase()+g.slice(1),f[g]=h),a==MetaStep.Extend?c.extend(f):b.getClass().implement(f)}}},shouldInherit:True,isActive:True});CallbackHandler.implement({$valid:function(a,b){return this.aspect(function(c,d){return Validator(d).validate(a,b).valid})},$validAsync:function(a,b){return this.aspect(function(c,d){return Validator(d).validateAsync(a,b).then(function(a){return a.valid})})}}),void 0!==module&&module.exports&&(module.exports=exports=this.package),eval(this.exports)}},{"../callback.js":6,"../miruken.js":14,bluebird:25}],24:[function(require,module,exports){var miruken=require("../miruken.js"),validate=require("./validate.js"),validatejs=require("validate.js"),Promise=require("bluebird");require("../callback.js"),new function(){function _validateNestedAsync(a,b,c,d){var e=[];for(var f in d){var g,h=d[f];if(h instanceof Array)for(var i=0;i<h.length;++i)g=c.addKey(f+"."+i),g=a.validateAsync(h[i],b,g),e.push(g);else g=c.addKey(f),g=a.validateAsync(h,b,g),e.push(g)}return Promise.all(e)}function _mapResults(a,b){b&&Array2.forEach(b,function(b){a.addKey(b.attribute).addError(b.validator,{message:b.error,value:b.value})})}function _buildConstraints(a,b){var c,d=a.$meta,e=d&&d.getDescriptor(VALIDATABLE);if(e){for(var f in e){var g=e[f],h=g.validate;(c||(c={}))[f]=h;for(name in h)if("nested"===name){var i=a[f];i&&(b[f]=i)}else name in validatejs.validators||(validatejs.validators[name]=function(){var a=$composer&&$composer.resolve(name);if(!a)throw new Error("Unable to resolve validator '"+name+"'.");return a.validate.apply(a,arguments)})}return c}}miruken.package(this,{name:"validate",imports:"miruken,miruken.callback,miruken.validate",exports:"ValidationRegistry,ValidateJsCallbackHandler,$required,$notEmpty,$nested"}),eval(this.imports),validatejs.Promise=Promise;var DETAILED={format:"detailed",cleanAttributes:!1},VALIDATABLE={validate:void 0},$required=Object.freeze({presence:!0}),$notEmpty=Object.freeze({presence:{allowEmpty:!1}}),$nested=Object.freeze({nested:!0});validatejs.validators.nested=Undefined;var $registerValidators=MetaMacro.extend({execute:function(a,b,c,d){if(a===MetaStep.Subclass||a===MetaStep.Implement)for(var e in d){var f=d[e];if($isArray(f)){var g=f.slice(0);if(f=g.pop(),!$isFunction(f))continue;g.length>0&&(f=function(a,b,c){return function(){if(!$composer)throw new Error("Unable to invoke validator '"+a+"'.");var d=Array2.concat(c,Array2.map(arguments,$use));return Invoking($composer).invoke(b,d)}}(e,f,g))}$isFunction(f)&&(validatejs.validators[e]=f)}},shouldInherit:True,isActive:True}),ValidationRegistry=Abstract.extend($registerValidators),ValidateJsCallbackHandler=CallbackHandler.extend({$validate:[null,function(a,b){var c=a.object,d={},e=_buildConstraints(c,d);if(e){var f=a.scope,g=a.results,h=Validator(b);if(a.isAsync)return validatejs.async(c,e,DETAILED).then(function(a){return _validateNestedAsync(h,f,g,d)},function(a){return a instanceof Error?Promise.reject(a):_validateNestedAsync(h,f,g,d).then(function(){_mapResults(g,a)})});var i=validatejs(c,e,DETAILED);for(var j in d){var k=d[j];if(k instanceof Array)for(var l=0;l<k.length;++l)h.validate(k[l],f,g.addKey(j+"."+l));else h.validate(k,f,g.addKey(j))}_mapResults(g,i)}}]});eval(this.exports)}},{"../callback.js":6,"../miruken.js":14,"./validate.js":23,bluebird:25,"validate.js":27}],25:[function(a,b,c){(function(a,d){!function(a){if("object"==typeof c&&void 0!==b)b.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var e;"undefined"!=typeof window?e=window:void 0!==d?e=d:"undefined"!=typeof self&&(e=self),e.Promise=a()}}(function(){var b,c,e;return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof _dereq_&&_dereq_;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c||a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof _dereq_&&_dereq_,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";b.exports=function(a){function b(a){var b=new c(a),d=b.promise();return b.setHowMany(1),b.setUnwrap(),b.init(),d}var c=a._SomePromiseArray;a.any=function(a){return b(a)},a.prototype.any=function(){return b(this)}}},{}],2:[function(a,b,c){"use strict";function d(){this._isTickUsed=!1,this._lateQueue=new j(16),this._normalQueue=new j(16),this._trampolineEnabled=!0;var a=this;this.drainQueues=function(){a._drainQueues()},this._schedule=i.isStatic?i(this.drainQueues):i}function e(a,b,c){this._lateQueue.push(a,b,c),this._queueTick()}function f(a,b,c){this._normalQueue.push(a,b,c),this._queueTick()}function g(a){this._normalQueue._pushOne(a),this._queueTick()}var h;try{throw new Error}catch(l){h=l}var i=a("./schedule.js"),j=a("./queue.js"),k=a("./util.js");d.prototype.disableTrampolineIfNecessary=function(){k.hasDevTools&&(this._trampolineEnabled=!1)},d.prototype.enableTrampoline=function(){this._trampolineEnabled||(this._trampolineEnabled=!0,this._schedule=function(a){setTimeout(a,0)})},d.prototype.haveItemsQueued=function(){return this._normalQueue.length()>0},d.prototype.throwLater=function(a,b){if(1===arguments.length&&(b=a,a=function(){throw b}),"undefined"!=typeof setTimeout)setTimeout(function(){a(b)},0);else try{this._schedule(function(){a(b)})}catch(l){throw new Error("No async scheduler available\n\n See http://goo.gl/m3OTXk\n")}},k.hasDevTools?(i.isStatic&&(i=function(a){setTimeout(a,0)}),d.prototype.invokeLater=function(a,b,c){this._trampolineEnabled?e.call(this,a,b,c):this._schedule(function(){setTimeout(function(){a.call(b,c)},100)})},d.prototype.invoke=function(a,b,c){this._trampolineEnabled?f.call(this,a,b,c):this._schedule(function(){a.call(b,c)})},d.prototype.settlePromises=function(a){this._trampolineEnabled?g.call(this,a):this._schedule(function(){a._settlePromises()})}):(d.prototype.invokeLater=e,d.prototype.invoke=f,d.prototype.settlePromises=g),d.prototype.invokeFirst=function(a,b,c){this._normalQueue.unshift(a,b,c),this._queueTick()},d.prototype._drainQueue=function(a){for(;a.length()>0;){var b=a.shift();if("function"==typeof b){var c=a.shift(),d=a.shift();b.call(c,d)}else b._settlePromises()}},d.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._drainQueue(this._lateQueue)},d.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},d.prototype._reset=function(){this._isTickUsed=!1},b.exports=new d,b.exports.firstLineError=h},{"./queue.js":28,"./schedule.js":31,"./util.js":38}],3:[function(a,b,c){"use strict";b.exports=function(a,b,c){var d=function(a,b){this._reject(b)},e=function(a,b){b.promiseRejectionQueued=!0,b.bindingPromise._then(d,d,null,this,a)},f=function(a,b){this._isPending()&&this._resolveCallback(b.target)},g=function(a,b){b.promiseRejectionQueued||this._reject(a)};a.prototype.bind=function(d){var h=c(d),i=new a(b);i._propagateFrom(this,1);var j=this._target();if(i._setBoundTo(h),h instanceof a){var k={promiseRejectionQueued:!1,promise:i,target:j,bindingPromise:h};j._then(b,e,i._progress,i,k),h._then(f,g,i._progress,i,k)}else i._resolveCallback(j);return i},a.prototype._setBoundTo=function(a){void 0!==a?(this._bitField=131072|this._bitField,this._boundTo=a):this._bitField=-131073&this._bitField},a.prototype._isBound=function(){return 131072==(131072&this._bitField)},a.bind=function(d,e){var f=c(d),g=new a(b);return g._setBoundTo(f),f instanceof a?f._then(function(){g._resolveCallback(e)},g._reject,g._progress,g,null):g._resolveCallback(e),g}}},{}],4:[function(a,b,c){"use strict";function d(){try{Promise===f&&(Promise=e)}catch(a){}return f}var e;"undefined"!=typeof Promise&&(e=Promise);var f=a("./promise.js")();f.noConflict=d,b.exports=f},{"./promise.js":23}],5:[function(a,b,c){"use strict";var d=Object.create;if(d){var e=d(null),f=d(null);e[" size"]=f[" size"]=0}b.exports=function(b){function c(a,c){var d;if(null!=a&&(d=a[c]),"function"!=typeof d){var e="Object "+h.classString(a)+" has no method '"+h.toString(c)+"'";throw new b.TypeError(e)}return d}function d(a){return c(a,this.pop()).apply(a,this)}function e(a){return a[this]}function f(a){var b=+this;return b<0&&(b=Math.max(0,b+a.length)),a[b]}var g,h=a("./util.js"),i=h.canEvaluate;h.isIdentifier;b.prototype.call=function(a){for(var b=arguments.length,c=new Array(b-1),e=1;e<b;++e)c[e-1]=arguments[e];return c.push(a),this._then(d,void 0,void 0,c,void 0)},b.prototype.get=function(a){var b,c="number"==typeof a;if(c)b=f;else if(i){var d=g(a);b=null!==d?d:e}else b=e;return this._then(b,void 0,void 0,a,void 0)}}},{"./util.js":38}],6:[function(a,b,c){"use strict";b.exports=function(b){var c=a("./errors.js"),d=a("./async.js"),e=c.CancellationError;b.prototype._cancel=function(a){if(!this.isCancellable())return this;for(var b,c=this;void 0!==(b=c._cancellationParent)&&b.isCancellable();)c=b;this._unsetCancellable(),c._target()._rejectCallback(a,!1,!0)},b.prototype.cancel=function(a){return this.isCancellable()?(void 0===a&&(a=new e),d.invokeLater(this._cancel,this,a),this):this},b.prototype.cancellable=function(){return this._cancellable()?this:(d.enableTrampoline(),this._setCancellable(),this._cancellationParent=void 0,this)},b.prototype.uncancellable=function(){var a=this.then();return a._unsetCancellable(),a},b.prototype.fork=function(a,b,c){var d=this._then(a,b,c,void 0,void 0);return d._setCancellable(),d._cancellationParent=void 0,d}}},{"./async.js":2,"./errors.js":13}],7:[function(b,c,d){"use strict";c.exports=function(){function c(a){this._parent=a;var b=this._length=1+(void 0===a?0:a._length);v(this,c),b>32&&this.uncycle()}function d(a,b){for(var c=0;c<b.length-1;++c)b[c].push("From previous event:"),b[c]=b[c].join("\n");return c<b.length&&(b[c]=b[c].join("\n")),a+"\n"+b.join("\n")}function e(a){for(var b=0;b<a.length;++b)(0===a[b].length||b+1<a.length&&a[b][0]===a[b+1][0])&&(a.splice(b,1),b--)}function f(a){for(var b=a[0],c=1;c<a.length;++c){
for(var d=a[c],e=b.length-1,f=b[e],g=-1,h=d.length-1;h>=0;--h)if(d[h]===f){g=h;break}for(var h=g;h>=0;--h){var i=d[h];if(b[e]!==i)break;b.pop(),e--}b=d}}function g(a){for(var b=[],c=0;c<a.length;++c){var d=a[c],e=p.test(d)||" (No stack trace)"===d,f=e&&s(d);e&&!f&&(r&&" "!==d.charAt(0)&&(d=" "+d),b.push(d))}return b}function h(a){for(var b=a.stack.replace(/\s+$/g,"").split("\n"),c=0;c<b.length;++c){var d=b[c];if(" (No stack trace)"===d||p.test(d))break}return c>0&&(b=b.slice(c)),b}function i(a){var b;if("function"==typeof a)b="[function "+(a.name||"anonymous")+"]";else{b=a.toString();if(/\[object [a-zA-Z0-9$_]+\]/.test(b))try{b=JSON.stringify(a)}catch(c){}0===b.length&&(b="(empty array)")}return"(<"+j(b)+">, no stack trace)"}function j(a){var b=41;return a.length<b?a:a.substr(0,b-3)+"..."}function k(a){var b=a.match(t);if(b)return{fileName:b[1],line:parseInt(b[2],10)}}var l,m=b("./async.js"),n=b("./util.js"),o=/[\\\/]bluebird[\\\/]js[\\\/](main|debug|zalgo|instrumented)/,p=null,q=null,r=!1;n.inherits(c,Error),c.prototype.uncycle=function(){var a=this._length;if(!(a<2)){for(var b=[],c={},d=0,e=this;void 0!==e;++d)b.push(e),e=e._parent;a=this._length=d;for(var d=a-1;d>=0;--d){var f=b[d].stack;void 0===c[f]&&(c[f]=d)}for(var d=0;d<a;++d){var g=b[d].stack,h=c[g];if(void 0!==h&&h!==d){h>0&&(b[h-1]._parent=void 0,b[h-1]._length=1),b[d]._parent=void 0,b[d]._length=1;var i=d>0?b[d-1]:this;h<a-1?(i._parent=b[h+1],i._parent.uncycle(),i._length=i._parent._length+1):(i._parent=void 0,i._length=1);for(var j=i._length+1,k=d-2;k>=0;--k)b[k]._length=j,j++;return}}}},c.prototype.parent=function(){return this._parent},c.prototype.hasParent=function(){return void 0!==this._parent},c.prototype.attachExtraTrace=function(a){if(!a.__stackCleaned__){this.uncycle();for(var b=c.parseStackAndMessage(a),h=b.message,i=[b.stack],j=this;void 0!==j;)i.push(g(j.stack.split("\n"))),j=j._parent;f(i),e(i),n.notEnumerableProp(a,"stack",d(h,i)),n.notEnumerableProp(a,"__stackCleaned__",!0)}},c.parseStackAndMessage=function(a){var b=a.stack,c=a.toString();return b="string"==typeof b&&b.length>0?h(a):[" (No stack trace)"],{message:c,stack:g(b)}},c.formatAndLogError=function(a,b){if("undefined"!=typeof console){var c;if("object"==typeof a||"function"==typeof a){var d=a.stack;c=b+q(d,a)}else c=b+String(a);"function"==typeof l?l(c):"function"!=typeof console.log&&"object"!=typeof console.log||console.log(c)}},c.unhandledRejection=function(a){c.formatAndLogError(a,"^--- With additional stack trace: ")},c.isSupported=function(){return"function"==typeof v},c.fireRejectionEvent=function(a,b,d,e){var f=!1;try{"function"==typeof b&&(f=!0,"rejectionHandled"===a?b(e):b(d,e))}catch(i){m.throwLater(i)}var g=!1;try{g=w(a,d,e)}catch(i){g=!0,m.throwLater(i)}var h=!1;if(u)try{h=u(a.toLowerCase(),{reason:d,promise:e})}catch(i){h=!0,m.throwLater(i)}g||f||h||"unhandledRejection"!==a||c.formatAndLogError(d,"Unhandled rejection ")};var s=function(){return!1},t=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;c.setBounds=function(a,b){if(c.isSupported()){for(var d,e,f=a.stack.split("\n"),g=b.stack.split("\n"),h=-1,i=-1,j=0;j<f.length;++j){var l=k(f[j]);if(l){d=l.fileName,h=l.line;break}}for(var j=0;j<g.length;++j){var l=k(g[j]);if(l){e=l.fileName,i=l.line;break}}h<0||i<0||!d||!e||d!==e||h>=i||(s=function(a){if(o.test(a))return!0;var b=k(a);return!!(b&&b.fileName===d&&h<=b.line&&b.line<=i)})}};var u,v=function(){var a=/^\s*at\s*/,b=function(a,b){return"string"==typeof a?a:void 0!==b.name&&void 0!==b.message?b.toString():i(b)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit=Error.stackTraceLimit+6,p=a,q=b;var c=Error.captureStackTrace;return s=function(a){return o.test(a)},function(a,b){Error.stackTraceLimit=Error.stackTraceLimit+6,c(a,b),Error.stackTraceLimit=Error.stackTraceLimit-6}}var d=new Error;if("string"==typeof d.stack&&d.stack.split("\n")[0].indexOf("stackDetection@")>=0)return p=/@/,q=b,r=!0,function(a){a.stack=(new Error).stack};var e;try{throw new Error}catch(f){e="stack"in f}return"stack"in d||!e||"number"!=typeof Error.stackTraceLimit?(q=function(a,b){return"string"==typeof a?a:"object"!=typeof b&&"function"!=typeof b||void 0===b.name||void 0===b.message?i(b):b.toString()},null):(p=a,q=b,function(a){Error.stackTraceLimit=Error.stackTraceLimit+6;try{throw new Error}catch(f){a.stack=f.stack}Error.stackTraceLimit=Error.stackTraceLimit-6})}(),w=function(){if(n.isNode)return function(b,c,d){return"rejectionHandled"===b?a.emit(b,d):a.emit(b,c,d)};var b=!1,c=!0;try{var d=new self.CustomEvent("test");b=d instanceof CustomEvent}catch(g){}if(!b)try{var e=document.createEvent("CustomEvent");e.initCustomEvent("testingtheevent",!1,!0,{}),self.dispatchEvent(e)}catch(g){c=!1}c&&(u=function(a,c){var d;return b?d=new self.CustomEvent(a,{detail:c,bubbles:!1,cancelable:!0}):self.dispatchEvent&&(d=document.createEvent("CustomEvent"),d.initCustomEvent(a,!1,!0,c)),!!d&&!self.dispatchEvent(d)});var f={};return f.unhandledRejection="onunhandledRejection".toLowerCase(),f.rejectionHandled="onrejectionHandled".toLowerCase(),function(a,b,c){var d=f[a],e=self[d];return!!e&&("rejectionHandled"===a?e.call(self,c):e.call(self,b,c),!0)}}();return"undefined"!=typeof console&&void 0!==console.warn&&(l=function(a){console.warn(a)},n.isNode&&a.stderr.isTTY?l=function(b){a.stderr.write("[31m"+b+"[39m\n")}:n.isNode||"string"!=typeof(new Error).stack||(l=function(a){console.warn("%c"+a,"color: red")})),c}},{"./async.js":2,"./util.js":38}],8:[function(a,b,c){"use strict";b.exports=function(b){function c(a,b,c){this._instances=a,this._callback=b,this._promise=c}function d(a,b){var c={},d=g(a).call(c,b);return d===h?d:i(c).length?(h.e=new j("Catch filter must inherit from Error or be a simple predicate function\n\n See http://goo.gl/o84o68\n"),h):d}var e=a("./util.js"),f=a("./errors.js"),g=e.tryCatch,h=e.errorObj,i=a("./es5.js").keys,j=f.TypeError;return c.prototype.doFilter=function(a){for(var c=this._callback,e=this._promise,f=e._boundValue(),i=0,j=this._instances.length;i<j;++i){var k=this._instances[i],l=k===Error||null!=k&&k.prototype instanceof Error;if(l&&a instanceof k){var m=g(c).call(f,a);return m===h?(b.e=m.e,b):m}if("function"==typeof k&&!l){var n=d(k,a);if(n===h){a=h.e;break}if(n){var m=g(c).call(f,a);return m===h?(b.e=m.e,b):m}}}return b.e=a,b},c}},{"./errors.js":13,"./es5.js":14,"./util.js":38}],9:[function(a,b,c){"use strict";b.exports=function(a,b,c){function d(){this._trace=new b(f())}function e(){if(c())return new d}function f(){var a=g.length-1;if(a>=0)return g[a]}var g=[];return d.prototype._pushContext=function(){c()&&void 0!==this._trace&&g.push(this._trace)},d.prototype._popContext=function(){c()&&void 0!==this._trace&&g.pop()},a.prototype._peekContext=f,a.prototype._pushContext=d.prototype._pushContext,a.prototype._popContext=d.prototype._popContext,e}},{}],10:[function(b,c,d){"use strict";c.exports=function(c,d){var e,f,g=c._getDomain,h=b("./async.js"),i=b("./errors.js").Warning,j=b("./util.js"),k=j.canAttachTrace,l=j.isNode&&(!!a.env.BLUEBIRD_DEBUG||"development"===a.env.NODE_ENV);return j.isNode&&0==a.env.BLUEBIRD_DEBUG&&(l=!1),l&&h.disableTrampolineIfNecessary(),c.prototype._ignoreRejections=function(){this._unsetRejectionIsUnhandled(),this._bitField=16777216|this._bitField},c.prototype._ensurePossibleRejectionHandled=function(){0==(16777216&this._bitField)&&(this._setRejectionIsUnhandled(),h.invokeLater(this._notifyUnhandledRejection,this,void 0))},c.prototype._notifyUnhandledRejectionIsHandled=function(){d.fireRejectionEvent("rejectionHandled",e,void 0,this)},c.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var a=this._getCarriedStackTrace()||this._settledValue;this._setUnhandledRejectionIsNotified(),d.fireRejectionEvent("unhandledRejection",f,a,this)}},c.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=524288|this._bitField},c.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-524289&this._bitField},c.prototype._isUnhandledRejectionNotified=function(){return(524288&this._bitField)>0},c.prototype._setRejectionIsUnhandled=function(){this._bitField=2097152|this._bitField},c.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-2097153&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},c.prototype._isRejectionUnhandled=function(){return(2097152&this._bitField)>0},c.prototype._setCarriedStackTrace=function(a){this._bitField=1048576|this._bitField,this._fulfillmentHandler0=a},c.prototype._isCarryingStackTrace=function(){return(1048576&this._bitField)>0},c.prototype._getCarriedStackTrace=function(){return this._isCarryingStackTrace()?this._fulfillmentHandler0:void 0},c.prototype._captureStackTrace=function(){return l&&(this._trace=new d(this._peekContext())),this},c.prototype._attachExtraTrace=function(a,b){if(l&&k(a)){var c=this._trace;if(void 0!==c&&b&&(c=c._parent),void 0!==c)c.attachExtraTrace(a);else if(!a.__stackCleaned__){var e=d.parseStackAndMessage(a);j.notEnumerableProp(a,"stack",e.message+"\n"+e.stack.join("\n")),j.notEnumerableProp(a,"__stackCleaned__",!0)}}},c.prototype._warn=function(a){var b=new i(a),c=this._peekContext();if(c)c.attachExtraTrace(b);else{var e=d.parseStackAndMessage(b);b.stack=e.message+"\n"+e.stack.join("\n")}d.formatAndLogError(b,"")},c.onPossiblyUnhandledRejection=function(a){var b=g();f="function"==typeof a?null===b?a:b.bind(a):void 0},c.onUnhandledRejectionHandled=function(a){var b=g();e="function"==typeof a?null===b?a:b.bind(a):void 0},c.longStackTraces=function(){if(h.haveItemsQueued()&&!1===l)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/DT1qyG\n");(l=d.isSupported())&&h.disableTrampolineIfNecessary()},c.hasLongStackTraces=function(){return l&&d.isSupported()},d.isSupported()||(c.longStackTraces=function(){},l=!1),function(){return l}}},{"./async.js":2,"./errors.js":13,"./util.js":38}],11:[function(a,b,c){"use strict";var d=a("./util.js"),e=d.isPrimitive;b.exports=function(a){var b=function(){return this},c=function(){throw this},d=function(){},f=function(){throw void 0},g=function(a,b){return 1===b?function(){throw a}:2===b?function(){return a}:void 0};a.prototype.return=a.prototype.thenReturn=function(c){return void 0===c?this.then(d):e(c)?this._then(g(c,2),void 0,void 0,void 0,void 0):(c instanceof a&&c._ignoreRejections(),this._then(b,void 0,void 0,c,void 0))},a.prototype.throw=a.prototype.thenThrow=function(a){return void 0===a?this.then(f):e(a)?this._then(g(a,1),void 0,void 0,void 0,void 0):this._then(c,void 0,void 0,a,void 0)}}},{"./util.js":38}],12:[function(a,b,c){"use strict";b.exports=function(a,b){var c=a.reduce;a.prototype.each=function(a){return c(this,a,null,b)},a.each=function(a,d){return c(a,d,null,b)}}},{}],13:[function(a,b,c){"use strict";function d(a,b){function c(d){if(!(this instanceof c))return new c(d);l(this,"message","string"==typeof d?d:b),l(this,"name",a),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this)}return k(c,Error),c}function e(a){if(!(this instanceof e))return new e(a);l(this,"name","OperationalError"),l(this,"message",a),this.cause=a,this.isOperational=!0,a instanceof Error?(l(this,"message",a.message),l(this,"stack",a.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}var f,g,h=a("./es5.js"),i=h.freeze,j=a("./util.js"),k=j.inherits,l=j.notEnumerableProp,m=d("Warning","warning"),n=d("CancellationError","cancellation error"),o=d("TimeoutError","timeout error"),p=d("AggregateError","aggregate error");try{f=TypeError,g=RangeError}catch(u){f=d("TypeError","type error"),g=d("RangeError","range error")}for(var q="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),r=0;r<q.length;++r)"function"==typeof Array.prototype[q[r]]&&(p.prototype[q[r]]=Array.prototype[q[r]]);h.defineProperty(p.prototype,"length",{value:0,configurable:!1,writable:!0,enumerable:!0}),p.prototype.isOperational=!0;var s=0;p.prototype.toString=function(){var a=Array(4*s+1).join(" "),b="\n"+a+"AggregateError of:\n";s++,a=Array(4*s+1).join(" ");for(var c=0;c<this.length;++c){for(var d=this[c]===this?"[Circular AggregateError]":this[c]+"",e=d.split("\n"),f=0;f<e.length;++f)e[f]=a+e[f];d=e.join("\n"),b+=d+"\n"}return s--,b},k(e,Error);var t=Error.__BluebirdErrorTypes__;t||(t=i({CancellationError:n,TimeoutError:o,OperationalError:e,RejectionError:e,AggregateError:p}),l(Error,"__BluebirdErrorTypes__",t)),b.exports={Error:Error,TypeError:f,RangeError:g,CancellationError:t.CancellationError,OperationalError:t.OperationalError,TimeoutError:t.TimeoutError,AggregateError:t.AggregateError,Warning:m}},{"./es5.js":14,"./util.js":38}],14:[function(a,b,c){var d=function(){"use strict";return void 0===this}();if(d)b.exports={freeze:Object.freeze,defineProperty:Object.defineProperty,getDescriptor:Object.getOwnPropertyDescriptor,keys:Object.keys,names:Object.getOwnPropertyNames,getPrototypeOf:Object.getPrototypeOf,isArray:Array.isArray,isES5:d,propertyIsWritable:function(a,b){var c=Object.getOwnPropertyDescriptor(a,b);return!(c&&!c.writable&&!c.set)}};else{var e={}.hasOwnProperty,f={}.toString,g={}.constructor.prototype,h=function(a){var b=[];for(var c in a)e.call(a,c)&&b.push(c);return b},i=function(a,b){return{value:a[b]}},j=function(a,b,c){return a[b]=c.value,a},k=function(a){return a},l=function(a){try{return Object(a).constructor.prototype}catch(b){return g}},m=function(a){try{return"[object Array]"===f.call(a)}catch(b){return!1}};b.exports={isArray:m,keys:h,names:h,defineProperty:j,getDescriptor:i,freeze:k,getPrototypeOf:l,isES5:d,propertyIsWritable:function(){return!0}}}},{}],15:[function(a,b,c){"use strict";b.exports=function(a,b){var c=a.map;a.prototype.filter=function(a,d){return c(this,a,d,b)},a.filter=function(a,d,e){return c(a,d,e,b)}}},{}],16:[function(a,b,c){"use strict";b.exports=function(b,c,d){function e(){return this}function f(){throw this}function g(a){return function(){return a}}function h(a){return function(){throw a}}function i(a,b,c){var d;return d=m(b)?c?g(b):h(b):c?e:f,a._then(d,n,void 0,b,void 0)}function j(a){var e=this.promise,f=this.handler,g=e._isBound()?f.call(e._boundValue()):f();if(void 0!==g){var h=d(g,e);if(h instanceof b)return h=h._target(),i(h,a,e.isFulfilled())}return e.isRejected()?(c.e=a,c):a}function k(a){var c=this.promise,e=this.handler,f=c._isBound()?e.call(c._boundValue(),a):e(a);if(void 0!==f){var g=d(f,c);if(g instanceof b)return g=g._target(),i(g,a,!0)}return a}var l=a("./util.js"),m=l.isPrimitive,n=l.thrower;b.prototype._passThroughHandler=function(a,b){if("function"!=typeof a)return this.then();var c={promise:this,handler:a};return this._then(b?j:k,b?j:void 0,void 0,c,void 0)},b.prototype.lastly=b.prototype.finally=function(a){return this._passThroughHandler(a,!0)},b.prototype.tap=function(a){return this._passThroughHandler(a,!1)}}},{"./util.js":38}],17:[function(a,b,c){"use strict";b.exports=function(b,c,d,e){function f(a,c,d){for(var f=0;f<c.length;++f){d._pushContext();var g=l(c[f])(a);if(d._popContext(),g===k){d._pushContext();var h=b.reject(k.e);return d._popContext(),h}var i=e(g,d);if(i instanceof b)return i}return null}function g(a,c,e,f){(this._promise=new b(d))._captureStackTrace(),this._stack=f,this._generatorFunction=a,this._receiver=c,this._generator=void 0,this._yieldHandlers="function"==typeof e?[e].concat(m):m}var h=a("./errors.js"),i=h.TypeError,j=a("./util.js"),k=j.errorObj,l=j.tryCatch,m=[];g.prototype.promise=function(){return this._promise},g.prototype._run=function(){this._generator=this._generatorFunction.call(this._receiver),this._receiver=this._generatorFunction=void 0,this._next(void 0)},g.prototype._continue=function(a){if(a===k)return this._promise._rejectCallback(a.e,!1,!0);var c=a.value;if(!0===a.done)this._promise._resolveCallback(c);else{var d=e(c,this._promise);if(!(d instanceof b)&&null===(d=f(d,this._yieldHandlers,this._promise)))return void this._throw(new i("A value %s was yielded that could not be treated as a promise\n\n See http://goo.gl/4Y4pDk\n\n".replace("%s",c)+"From coroutine:\n"+this._stack.split("\n").slice(1,-7).join("\n")));d._then(this._next,this._throw,void 0,this,null)}},g.prototype._throw=function(a){this._promise._attachExtraTrace(a),this._promise._pushContext();var b=l(this._generator.throw).call(this._generator,a);this._promise._popContext(),this._continue(b)},g.prototype._next=function(a){this._promise._pushContext();var b=l(this._generator.next).call(this._generator,a);this._promise._popContext(),this._continue(b)},b.coroutine=function(a,b){if("function"!=typeof a)throw new i("generatorFunction must be a function\n\n See http://goo.gl/6Vqhm0\n");var c=Object(b).yieldHandler,d=g,e=(new Error).stack;return function(){var b=a.apply(this,arguments),f=new d(void 0,void 0,c,e);return f._generator=b,f._next(void 0),f.promise()}},b.coroutine.addYieldHandler=function(a){if("function"!=typeof a)throw new i("fn must be a function\n\n See http://goo.gl/916lJJ\n");m.push(a)},b.spawn=function(a){if("function"!=typeof a)return c("generatorFunction must be a function\n\n See http://goo.gl/6Vqhm0\n");var d=new g(a,this),e=d.promise();return d._run(b.spawn),e}}},{"./errors.js":13,"./util.js":38}],18:[function(a,b,c){"use strict";b.exports=function(b,c,d,e){var f=a("./util.js");f.canEvaluate,f.tryCatch,f.errorObj;b.join=function(){var a,b=arguments.length-1;if(b>0&&"function"==typeof arguments[b]){a=arguments[b];var d}for(var e=arguments.length,f=new Array(e),g=0;g<e;++g)f[g]=arguments[g];a&&f.pop();var d=new c(f).promise();return void 0!==a?d.spread(a):d}}},{"./util.js":38}],19:[function(a,b,c){"use strict";b.exports=function(b,c,d,e,f){function g(a,b,c,d){this.constructor$(a),this._promise._captureStackTrace();var e=j();this._callback=null===e?b:e.bind(b),this._preservedValues=d===f?new Array(this.length()):null,this._limit=c,this._inFlight=0,this._queue=c>=1?[]:p,k.invoke(h,this,void 0)}function h(){this._init$(void 0,-2)}function i(a,b,c,d){var e="object"==typeof c&&null!==c?c.concurrency:0;return e="number"==typeof e&&isFinite(e)&&e>=1?e:0,new g(a,b,e,d)}var j=b._getDomain,k=a("./async.js"),l=a("./util.js"),m=l.tryCatch,n=l.errorObj,o={},p=[];l.inherits(g,c),g.prototype._init=function(){},g.prototype._promiseFulfilled=function(a,c){var d=this._values,f=this.length(),g=this._preservedValues,h=this._limit;if(d[c]===o){if(d[c]=a,h>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return}else{if(h>=1&&this._inFlight>=h)return d[c]=a,void this._queue.push(c);null!==g&&(g[c]=a);var i=this._callback,j=this._promise._boundValue();this._promise._pushContext();var k=m(i).call(j,a,c,f);if(this._promise._popContext(),k===n)return this._reject(k.e);var l=e(k,this._promise);if(l instanceof b){if(l=l._target(),l._isPending())return h>=1&&this._inFlight++,d[c]=o,l._proxyPromiseArray(this,c);if(!l._isFulfilled())return this._reject(l._reason());k=l._value()}d[c]=k}++this._totalResolved>=f&&(null!==g?this._filter(d,g):this._resolve(d))},g.prototype._drainQueue=function(){for(var a=this._queue,b=this._limit,c=this._values;a.length>0&&this._inFlight<b;){if(this._isResolved())return;var d=a.pop();this._promiseFulfilled(c[d],d)}},g.prototype._filter=function(a,b){for(var c=b.length,d=new Array(c),e=0,f=0;f<c;++f)a[f]&&(d[e++]=b[f]);d.length=e,this._resolve(d)},g.prototype.preservedValues=function(){return this._preservedValues},b.prototype.map=function(a,b){return"function"!=typeof a?d("fn must be a function\n\n See http://goo.gl/916lJJ\n"):i(this,a,b,null).promise()},b.map=function(a,b,c,e){return"function"!=typeof b?d("fn must be a function\n\n See http://goo.gl/916lJJ\n"):i(a,b,c,e).promise()}}},{"./async.js":2,"./util.js":38}],20:[function(a,b,c){"use strict";b.exports=function(b,c,d,e){var f=a("./util.js"),g=f.tryCatch;b.method=function(a){if("function"!=typeof a)throw new b.TypeError("fn must be a function\n\n See http://goo.gl/916lJJ\n");return function(){var d=new b(c);d._captureStackTrace(),d._pushContext();var e=g(a).apply(this,arguments);return d._popContext(),d._resolveFromSyncValue(e),d}},b.attempt=b.try=function(a,d,h){if("function"!=typeof a)return e("fn must be a function\n\n See http://goo.gl/916lJJ\n");var i=new b(c);i._captureStackTrace(),i._pushContext();var j=f.isArray(d)?g(a).apply(h,d):g(a).call(h,d);return i._popContext(),i._resolveFromSyncValue(j),i},b.prototype._resolveFromSyncValue=function(a){a===f.errorObj?this._rejectCallback(a.e,!1,!0):this._resolveCallback(a,!0)}}},{"./util.js":38}],21:[function(a,b,c){"use strict";b.exports=function(b){function c(a,b){var c=this;if(!f.isArray(a))return d.call(c,a,b);var e=h(b).apply(c._boundValue(),[null].concat(a));e===i&&g.throwLater(e.e)}function d(a,b){var c=this,d=c._boundValue(),e=void 0===a?h(b).call(d,null):h(b).call(d,null,a);e===i&&g.throwLater(e.e)}function e(a,b){var c=this;if(!a){var d=c._target(),e=d._getCarriedStackTrace();e.cause=a,a=e}var f=h(b).call(c._boundValue(),a);f===i&&g.throwLater(f.e)}var f=a("./util.js"),g=a("./async.js"),h=f.tryCatch,i=f.errorObj;b.prototype.asCallback=b.prototype.nodeify=function(a,b){if("function"==typeof a){var f=d;void 0!==b&&Object(b).spread&&(f=c),this._then(f,e,void 0,this,a)}return this}}},{"./async.js":2,"./util.js":38}],22:[function(a,b,c){"use strict";b.exports=function(b,c){var d=a("./util.js"),e=a("./async.js"),f=d.tryCatch,g=d.errorObj;b.prototype.progressed=function(a){return this._then(void 0,void 0,a,void 0,void 0)},b.prototype._progress=function(a){this._isFollowingOrFulfilledOrRejected()||this._target()._progressUnchecked(a)},b.prototype._progressHandlerAt=function(a){return 0===a?this._progressHandler0:this[(a<<2)+a-5+2]},b.prototype._doProgressWith=function(a){var c=a.value,e=a.handler,h=a.promise,i=a.receiver,j=f(e).call(i,c);if(j===g){if(null!=j.e&&"StopProgressPropagation"!==j.e.name){var k=d.canAttachTrace(j.e)?j.e:new Error(d.toString(j.e));h._attachExtraTrace(k),h._progress(j.e)}}else j instanceof b?j._then(h._progress,null,null,h,void 0):h._progress(j)},b.prototype._progressUnchecked=function(a){for(var d=this._length(),f=this._progress,g=0;g<d;g++){var h=this._progressHandlerAt(g),i=this._promiseAt(g);if(i instanceof b)"function"==typeof h?e.invoke(this._doProgressWith,this,{handler:h,promise:i,receiver:this._receiverAt(g),value:a}):e.invoke(f,i,a);else{var j=this._receiverAt(g);"function"==typeof h?h.call(j,a,i):j instanceof c&&!j._isResolved()&&j._promiseProgressed(a,i)}}}}},{"./async.js":2,"./util.js":38}],23:[function(b,c,d){"use strict";c.exports=function(){function d(a){if("function"!=typeof a)throw new n("the promise constructor requires a resolver function\n\n See http://goo.gl/EC22Yn\n");if(this.constructor!==d)throw new n("the promise constructor cannot be invoked directly\n\n See http://goo.gl/KsIlge\n");this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._progressHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,this._settledValue=void 0,a!==o&&this._resolveFromResolver(a)}function e(a){var b=new d(o);b._fulfillmentHandler0=a,b._rejectionHandler0=a,b._progressHandler0=a,b._promise0=a,b._receiver0=a,b._settledValue=a}var f,g=function(){return new n("circular promise resolution chain\n\n See http://goo.gl/LhFpo0\n")},h=function(){return new d.PromiseInspection(this._target())},i=function(a){return d.reject(new n(a))},j=b("./util.js");f=j.isNode?function(){var b=a.domain;return void 0===b&&(b=null),b}:function(){return null},j.notEnumerableProp(d,"_getDomain",f);var k={},l=b("./async.js"),m=b("./errors.js"),n=d.TypeError=m.TypeError;d.RangeError=m.RangeError,d.CancellationError=m.CancellationError,d.TimeoutError=m.TimeoutError,d.OperationalError=m.OperationalError,d.RejectionError=m.OperationalError,d.AggregateError=m.AggregateError;var o=function(){},p={},q={e:null},r=b("./thenables.js")(d,o),s=b("./promise_array.js")(d,o,r,i),t=b("./captured_trace.js")(),u=b("./debuggability.js")(d,t),v=b("./context.js")(d,t,u),w=b("./catch_filter.js")(q),x=b("./promise_resolver.js"),y=x._nodebackForPromise,z=j.errorObj,A=j.tryCatch;return d.prototype.toString=function(){return"[object Promise]"},d.prototype.caught=d.prototype.catch=function(a){var b=arguments.length;if(b>1){var c,e=new Array(b-1),f=0;for(c=0;c<b-1;++c){var g=arguments[c];if("function"!=typeof g)return d.reject(new n("Catch filter must inherit from Error or be a simple predicate function\n\n See http://goo.gl/o84o68\n"));e[f++]=g}e.length=f,a=arguments[c];var h=new w(e,a,this);return this._then(void 0,h.doFilter,void 0,h,void 0)}return this._then(void 0,a,void 0,void 0,void 0)},d.prototype.reflect=function(){return this._then(h,h,void 0,this,void 0)},d.prototype.then=function(a,b,c){if(u()&&arguments.length>0&&"function"!=typeof a&&"function"!=typeof b){var d=".then() only accepts functions but was passed: "+j.classString(a);arguments.length>1&&(d+=", "+j.classString(b)),this._warn(d)}return this._then(a,b,c,void 0,void 0)},d.prototype.done=function(a,b,c){this._then(a,b,c,void 0,void 0)._setIsFinal()},d.prototype.spread=function(a,b){return this.all()._then(a,b,void 0,p,void 0)},d.prototype.isCancellable=function(){return!this.isResolved()&&this._cancellable()},d.prototype.toJSON=function(){var a={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(a.fulfillmentValue=this.value(),a.isFulfilled=!0):this.isRejected()&&(a.rejectionReason=this.reason(),a.isRejected=!0),a},d.prototype.all=function(){return new s(this).promise()},d.prototype.error=function(a){return this.caught(j.originatesFromRejection,a)},d.getNewLibraryCopy=c.exports,d.is=function(a){return a instanceof d},d.fromNode=function(a){var b=new d(o),c=A(a)(y(b));return c===z&&b._rejectCallback(c.e,!0,!0),b},d.all=function(a){return new s(a).promise()},d.defer=d.pending=function(){var a=new d(o);return new x(a)},d.cast=function(a){var b=r(a);if(!(b instanceof d)){var c=b;b=new d(o),b._fulfillUnchecked(c)}return b},d.resolve=d.fulfilled=d.cast,d.reject=d.rejected=function(a){var b=new d(o);return b._captureStackTrace(),b._rejectCallback(a,!0),b},d.setScheduler=function(a){if("function"!=typeof a)throw new n("fn must be a function\n\n See http://goo.gl/916lJJ\n");var b=l._schedule;return l._schedule=a,b},d.prototype._then=function(a,b,c,e,g){var h=void 0!==g,i=h?g:new d(o);h||(i._propagateFrom(this,5),i._captureStackTrace());var j=this._target();j!==this&&(void 0===e&&(e=this._boundTo),h||i._setIsMigrated());var k=j._addCallbacks(a,b,c,i,e,f());return j._isResolved()&&!j._isSettlePromisesQueued()&&l.invoke(j._settlePromiseAtPostResolution,j,k),i},d.prototype._settlePromiseAtPostResolution=function(a){this._isRejectionUnhandled()&&this._unsetRejectionIsUnhandled(),this._settlePromiseAt(a)},d.prototype._length=function(){return 131071&this._bitField},d.prototype._isFollowingOrFulfilledOrRejected=function(){return(939524096&this._bitField)>0},d.prototype._isFollowing=function(){return 536870912==(536870912&this._bitField)},d.prototype._setLength=function(a){this._bitField=-131072&this._bitField|131071&a},d.prototype._setFulfilled=function(){this._bitField=268435456|this._bitField},d.prototype._setRejected=function(){this._bitField=134217728|this._bitField},d.prototype._setFollowing=function(){this._bitField=536870912|this._bitField},d.prototype._setIsFinal=function(){this._bitField=33554432|this._bitField},d.prototype._isFinal=function(){return(33554432&this._bitField)>0},d.prototype._cancellable=function(){return(67108864&this._bitField)>0},d.prototype._setCancellable=function(){this._bitField=67108864|this._bitField},d.prototype._unsetCancellable=function(){this._bitField=-67108865&this._bitField},d.prototype._setIsMigrated=function(){this._bitField=4194304|this._bitField},d.prototype._unsetIsMigrated=function(){this._bitField=-4194305&this._bitField},d.prototype._isMigrated=function(){return(4194304&this._bitField)>0},d.prototype._receiverAt=function(a){var b=0===a?this._receiver0:this[5*a-5+4];if(b!==k)return void 0===b&&this._isBound()?this._boundValue():b},d.prototype._promiseAt=function(a){return 0===a?this._promise0:this[5*a-5+3]},d.prototype._fulfillmentHandlerAt=function(a){return 0===a?this._fulfillmentHandler0:this[5*a-5+0]},d.prototype._rejectionHandlerAt=function(a){return 0===a?this._rejectionHandler0:this[5*a-5+1]},d.prototype._boundValue=function(){var a=this._boundTo;return void 0!==a&&a instanceof d?a.isFulfilled()?a.value():void 0:a},d.prototype._migrateCallbacks=function(a,b){var c=a._fulfillmentHandlerAt(b),e=a._rejectionHandlerAt(b),f=a._progressHandlerAt(b),g=a._promiseAt(b),h=a._receiverAt(b);g instanceof d&&g._setIsMigrated(),void 0===h&&(h=k),this._addCallbacks(c,e,f,g,h,null)},d.prototype._addCallbacks=function(a,b,c,d,e,f){var g=this._length();if(g>=131066&&(g=0,this._setLength(0)),0===g)this._promise0=d,void 0!==e&&(this._receiver0=e),"function"!=typeof a||this._isCarryingStackTrace()||(this._fulfillmentHandler0=null===f?a:f.bind(a)),"function"==typeof b&&(this._rejectionHandler0=null===f?b:f.bind(b)),"function"==typeof c&&(this._progressHandler0=null===f?c:f.bind(c));else{var h=5*g-5;this[h+3]=d,this[h+4]=e,"function"==typeof a&&(this[h+0]=null===f?a:f.bind(a)),"function"==typeof b&&(this[h+1]=null===f?b:f.bind(b)),"function"==typeof c&&(this[h+2]=null===f?c:f.bind(c))}return this._setLength(g+1),g},d.prototype._setProxyHandlers=function(a,b){var c=this._length();if(c>=131066&&(c=0,this._setLength(0)),0===c)this._promise0=b,this._receiver0=a;else{var d=5*c-5;this[d+3]=b,this[d+4]=a}this._setLength(c+1)},d.prototype._proxyPromiseArray=function(a,b){this._setProxyHandlers(a,b)},d.prototype._resolveCallback=function(a,b){if(!this._isFollowingOrFulfilledOrRejected()){if(a===this)return this._rejectCallback(g(),!1,!0);var c=r(a,this);if(!(c instanceof d))return this._fulfill(a);var e=1|(b?4:0);this._propagateFrom(c,e);var f=c._target();if(f._isPending()){for(var h=this._length(),i=0;i<h;++i)f._migrateCallbacks(this,i);this._setFollowing(),this._setLength(0),this._setFollowee(f)}else f._isFulfilled()?this._fulfillUnchecked(f._value()):this._rejectUnchecked(f._reason(),f._getCarriedStackTrace())}},d.prototype._rejectCallback=function(a,b,c){c||j.markAsOriginatingFromRejection(a);var d=j.ensureErrorObject(a),e=d===a;this._attachExtraTrace(d,!!b&&e),this._reject(a,e?void 0:d)},d.prototype._resolveFromResolver=function(a){var b=this;this._captureStackTrace(),this._pushContext();var c=!0,d=A(a)(function(a){null!==b&&(b._resolveCallback(a),b=null)},function(a){null!==b&&(b._rejectCallback(a,c),b=null)});c=!1,this._popContext(),void 0!==d&&d===z&&null!==b&&(b._rejectCallback(d.e,!0,!0),b=null)},d.prototype._settlePromiseFromHandler=function(a,b,c,d){if(!d._isRejected()){d._pushContext();var e;if(e=b!==p||this._isRejected()?A(a).call(b,c):A(a).apply(this._boundValue(),c),d._popContext(),e===z||e===d||e===q){var f=e===d?g():e.e;d._rejectCallback(f,!1,!0)}else d._resolveCallback(e)}},d.prototype._target=function(){for(var a=this;a._isFollowing();)a=a._followee();return a},d.prototype._followee=function(){return this._rejectionHandler0},d.prototype._setFollowee=function(a){this._rejectionHandler0=a},d.prototype._cleanValues=function(){this._cancellable()&&(this._cancellationParent=void 0)},d.prototype._propagateFrom=function(a,b){(1&b)>0&&a._cancellable()&&(this._setCancellable(),this._cancellationParent=a),(4&b)>0&&a._isBound()&&this._setBoundTo(a._boundTo)},d.prototype._fulfill=function(a){this._isFollowingOrFulfilledOrRejected()||this._fulfillUnchecked(a)},d.prototype._reject=function(a,b){this._isFollowingOrFulfilledOrRejected()||this._rejectUnchecked(a,b)},d.prototype._settlePromiseAt=function(a){var b=this._promiseAt(a),c=b instanceof d;if(c&&b._isMigrated())return b._unsetIsMigrated(),
l.invoke(this._settlePromiseAt,this,a);var e=this._isFulfilled()?this._fulfillmentHandlerAt(a):this._rejectionHandlerAt(a),f=this._isCarryingStackTrace()?this._getCarriedStackTrace():void 0,g=this._settledValue,h=this._receiverAt(a);this._clearCallbackDataAtIndex(a),"function"==typeof e?c?this._settlePromiseFromHandler(e,h,g,b):e.call(h,g,b):h instanceof s?h._isResolved()||(this._isFulfilled()?h._promiseFulfilled(g,b):h._promiseRejected(g,b)):c&&(this._isFulfilled()?b._fulfill(g):b._reject(g,f)),a>=4&&4==(31&a)&&l.invokeLater(this._setLength,this,0)},d.prototype._clearCallbackDataAtIndex=function(a){if(0===a)this._isCarryingStackTrace()||(this._fulfillmentHandler0=void 0),this._rejectionHandler0=this._progressHandler0=this._receiver0=this._promise0=void 0;else{var b=5*a-5;this[b+3]=this[b+4]=this[b+0]=this[b+1]=this[b+2]=void 0}},d.prototype._isSettlePromisesQueued=function(){return-1073741824==(-1073741824&this._bitField)},d.prototype._setSettlePromisesQueued=function(){this._bitField=-1073741824|this._bitField},d.prototype._unsetSettlePromisesQueued=function(){this._bitField=1073741823&this._bitField},d.prototype._queueSettlePromises=function(){l.settlePromises(this),this._setSettlePromisesQueued()},d.prototype._fulfillUnchecked=function(a){if(a===this){var b=g();return this._attachExtraTrace(b),this._rejectUnchecked(b,void 0)}this._setFulfilled(),this._settledValue=a,this._cleanValues(),this._length()>0&&this._queueSettlePromises()},d.prototype._rejectUncheckedCheckError=function(a){var b=j.ensureErrorObject(a);this._rejectUnchecked(a,b===a?void 0:b)},d.prototype._rejectUnchecked=function(a,b){if(a===this){var c=g();return this._attachExtraTrace(c),this._rejectUnchecked(c)}if(this._setRejected(),this._settledValue=a,this._cleanValues(),this._isFinal())return void l.throwLater(function(a){throw"stack"in a&&l.invokeFirst(t.unhandledRejection,void 0,a),a},void 0===b?a:b);void 0!==b&&b!==a&&this._setCarriedStackTrace(b),this._length()>0?this._queueSettlePromises():this._ensurePossibleRejectionHandled()},d.prototype._settlePromises=function(){this._unsetSettlePromisesQueued();for(var a=this._length(),b=0;b<a;b++)this._settlePromiseAt(b)},j.notEnumerableProp(d,"_makeSelfResolutionError",g),b("./progress.js")(d,s),b("./method.js")(d,o,r,i),b("./bind.js")(d,o,r),b("./finally.js")(d,q,r),b("./direct_resolve.js")(d),b("./synchronous_inspection.js")(d),b("./join.js")(d,s,r,o),d.version="2.11.0",d.Promise=d,b("./map.js")(d,s,i,r,o),b("./cancel.js")(d),b("./using.js")(d,i,r,v),b("./generators.js")(d,i,o,r),b("./nodeify.js")(d),b("./call_get.js")(d),b("./props.js")(d,s,r,i),b("./race.js")(d,o,r,i),b("./reduce.js")(d,s,i,r,o),b("./settle.js")(d,s),b("./some.js")(d,s,i),b("./promisify.js")(d,o),b("./any.js")(d),b("./each.js")(d,o),b("./timers.js")(d,o),b("./filter.js")(d,o),j.toFastProperties(d),j.toFastProperties(d.prototype),e({a:1}),e({b:2}),e({c:3}),e(1),e(function(){}),e(void 0),e(!1),e(new d(o)),t.setBounds(l.firstLineError,j.lastLineError),d}},{"./any.js":1,"./async.js":2,"./bind.js":3,"./call_get.js":5,"./cancel.js":6,"./captured_trace.js":7,"./catch_filter.js":8,"./context.js":9,"./debuggability.js":10,"./direct_resolve.js":11,"./each.js":12,"./errors.js":13,"./filter.js":15,"./finally.js":16,"./generators.js":17,"./join.js":18,"./map.js":19,"./method.js":20,"./nodeify.js":21,"./progress.js":22,"./promise_array.js":24,"./promise_resolver.js":25,"./promisify.js":26,"./props.js":27,"./race.js":29,"./reduce.js":30,"./settle.js":32,"./some.js":33,"./synchronous_inspection.js":34,"./thenables.js":35,"./timers.js":36,"./using.js":37,"./util.js":38}],24:[function(a,b,c){"use strict";b.exports=function(b,c,d,e){function f(a){switch(a){case-2:return[];case-3:return{}}}function g(a){var d,e=this._promise=new b(c);a instanceof b&&(d=a,e._propagateFrom(d,5)),this._values=a,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var h=a("./util.js"),i=h.isArray;return g.prototype.length=function(){return this._length},g.prototype.promise=function(){return this._promise},g.prototype._init=function a(c,g){var h=d(this._values,this._promise);if(h instanceof b){if(h=h._target(),this._values=h,!h._isFulfilled())return h._isPending()?void h._then(a,this._reject,void 0,this,g):void this._reject(h._reason());if(h=h._value(),!i(h)){var j=new b.TypeError("expecting an array, a promise or a thenable\n\n See http://goo.gl/s8MMhc\n");return void this.__hardReject__(j)}}else if(!i(h))return void this._promise._reject(e("expecting an array, a promise or a thenable\n\n See http://goo.gl/s8MMhc\n")._reason());if(0===h.length)return void(-5===g?this._resolveEmptyArray():this._resolve(f(g)));var k=this.getActualLength(h.length);this._length=k,this._values=this.shouldCopyValues()?new Array(k):this._values;for(var l=this._promise,m=0;m<k;++m){var n=this._isResolved(),o=d(h[m],l);o instanceof b?(o=o._target(),n?o._ignoreRejections():o._isPending()?o._proxyPromiseArray(this,m):o._isFulfilled()?this._promiseFulfilled(o._value(),m):this._promiseRejected(o._reason(),m)):n||this._promiseFulfilled(o,m)}},g.prototype._isResolved=function(){return null===this._values},g.prototype._resolve=function(a){this._values=null,this._promise._fulfill(a)},g.prototype.__hardReject__=g.prototype._reject=function(a){this._values=null,this._promise._rejectCallback(a,!1,!0)},g.prototype._promiseProgressed=function(a,b){this._promise._progress({index:b,value:a})},g.prototype._promiseFulfilled=function(a,b){this._values[b]=a,++this._totalResolved>=this._length&&this._resolve(this._values)},g.prototype._promiseRejected=function(a,b){this._totalResolved++,this._reject(a)},g.prototype.shouldCopyValues=function(){return!0},g.prototype.getActualLength=function(a){return a},g}},{"./util.js":38}],25:[function(a,b,c){"use strict";function d(a){return a instanceof Error&&n.getPrototypeOf(a)===Error.prototype}function e(a){var b;if(d(a)){b=new l(a),b.name=a.name,b.message=a.message,b.stack=a.stack;for(var c=n.keys(a),e=0;e<c.length;++e){var f=c[e];o.test(f)||(b[f]=a[f])}return b}return h.markAsOriginatingFromRejection(a),a}function f(a){return function(b,c){if(null!==a){if(b){var d=e(i(b));a._attachExtraTrace(d),a._reject(d)}else if(arguments.length>2){for(var f=arguments.length,g=new Array(f-1),h=1;h<f;++h)g[h-1]=arguments[h];a._fulfill(g)}else a._fulfill(c);a=null}}}var g,h=a("./util.js"),i=h.maybeWrapAsError,j=a("./errors.js"),k=j.TimeoutError,l=j.OperationalError,m=h.haveGetters,n=a("./es5.js"),o=/^(?:name|message|stack|cause)$/;if(g=m?function(a){this.promise=a}:function(a){this.promise=a,this.asCallback=f(a),this.callback=this.asCallback},m){var p={get:function(){return f(this.promise)}};n.defineProperty(g.prototype,"asCallback",p),n.defineProperty(g.prototype,"callback",p)}g._nodebackForPromise=f,g.prototype.toString=function(){return"[object PromiseResolver]"},g.prototype.resolve=g.prototype.fulfill=function(a){if(!(this instanceof g))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._resolveCallback(a)},g.prototype.reject=function(a){if(!(this instanceof g))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._rejectCallback(a)},g.prototype.progress=function(a){if(!(this instanceof g))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._progress(a)},g.prototype.cancel=function(a){this.promise.cancel(a)},g.prototype.timeout=function(){this.reject(new k("timeout"))},g.prototype.isResolved=function(){return this.promise.isResolved()},g.prototype.toJSON=function(){return this.promise.toJSON()},b.exports=g},{"./errors.js":13,"./es5.js":14,"./util.js":38}],26:[function(a,b,c){"use strict";b.exports=function(b,c){function d(a){return!w.test(a)}function e(a){try{return!0===a.__isPromisified__}catch(b){return!1}}function f(a,b,c){var d=n.getDataPropertyOrDefault(a,b+c,u);return!!d&&e(d)}function g(a,b,c){for(var d=0;d<a.length;d+=2){var e=a[d];if(c.test(e))for(var f=e.replace(c,""),g=0;g<a.length;g+=2)if(a[g]===f)throw new s("Cannot promisify an API that has normal methods with '%s'-suffix\n\n See http://goo.gl/iWrZbw\n".replace("%s",b))}}function h(a,b,c,d){for(var h=n.inheritedDataKeys(a),i=[],j=0;j<h.length;++j){var k=h[j],l=a[k],m=d===x||x(k,l,a);"function"!=typeof l||e(l)||f(a,k,b)||!d(k,l,a,m)||i.push(k,l)}return g(i,b,c),i}function i(a,d,e,f){function g(){var e=d;d===m&&(e=this);var f=new b(c);f._captureStackTrace();var g="string"==typeof i&&this!==h?this[i]:a,j=o(f);try{g.apply(e,p(arguments,j))}catch(k){f._rejectCallback(q(k),!0,!0)}return f}var h=function(){return this}(),i=a;return"string"==typeof i&&(a=f),n.notEnumerableProp(g,"__isPromisified__",!0),g}function j(a,b,c,d){for(var e=new RegExp(y(b)+"$"),f=h(a,b,e,c),g=0,i=f.length;g<i;g+=2){var j=f[g],k=f[g+1],l=j+b;if(d===z)a[l]=z(j,m,j,k,b);else{var o=d(k,function(){return z(j,m,j,k,b)});n.notEnumerableProp(o,"__isPromisified__",!0),a[l]=o}}return n.toFastProperties(a),a}function k(a,b){return z(a,b,void 0,a)}var l,m={},n=a("./util.js"),o=a("./promise_resolver.js")._nodebackForPromise,p=n.withAppended,q=n.maybeWrapAsError,r=n.canEvaluate,s=a("./errors").TypeError,t="Async",u={__isPromisified__:!0},v=["arity","length","name","arguments","caller","callee","prototype","__isPromisified__"],w=new RegExp("^(?:"+v.join("|")+")$"),x=function(a){return n.isIdentifier(a)&&"_"!==a.charAt(0)&&"constructor"!==a},y=function(a){return a.replace(/([$])/,"\\$")},z=r?l:i;b.promisify=function(a,b){if("function"!=typeof a)throw new s("fn must be a function\n\n See http://goo.gl/916lJJ\n");if(e(a))return a;var c=k(a,arguments.length<2?m:b);return n.copyDescriptors(a,c,d),c},b.promisifyAll=function(a,b){if("function"!=typeof a&&"object"!=typeof a)throw new s("the target of promisifyAll must be an object or a function\n\n See http://goo.gl/9ITlV0\n");b=Object(b);var c=b.suffix;"string"!=typeof c&&(c=t);var d=b.filter;"function"!=typeof d&&(d=x);var e=b.promisifier;if("function"!=typeof e&&(e=z),!n.isIdentifier(c))throw new RangeError("suffix must be a valid identifier\n\n See http://goo.gl/8FZo5V\n");for(var f=n.inheritedDataKeys(a),g=0;g<f.length;++g){var h=a[f[g]];"constructor"!==f[g]&&n.isClass(h)&&(j(h.prototype,c,d,e),j(h,c,d,e))}return j(a,c,d,e)}}},{"./errors":13,"./promise_resolver.js":25,"./util.js":38}],27:[function(a,b,c){"use strict";b.exports=function(b,c,d,e){function f(a){for(var b=j.keys(a),c=b.length,d=new Array(2*c),e=0;e<c;++e){var f=b[e];d[e]=a[f],d[e+c]=f}this.constructor$(d)}function g(a){var c,g=d(a);return i(g)?(c=g instanceof b?g._then(b.props,void 0,void 0,void 0,void 0):new f(g).promise(),g instanceof b&&c._propagateFrom(g,4),c):e("cannot await properties of a non-object\n\n See http://goo.gl/OsFKC8\n")}var h=a("./util.js"),i=h.isObject,j=a("./es5.js");h.inherits(f,c),f.prototype._init=function(){this._init$(void 0,-3)},f.prototype._promiseFulfilled=function(a,b){if(this._values[b]=a,++this._totalResolved>=this._length){for(var c={},d=this.length(),e=0,f=this.length();e<f;++e)c[this._values[e+d]]=this._values[e];this._resolve(c)}},f.prototype._promiseProgressed=function(a,b){this._promise._progress({key:this._values[b+this.length()],value:a})},f.prototype.shouldCopyValues=function(){return!1},f.prototype.getActualLength=function(a){return a>>1},b.prototype.props=function(){return g(this)},b.props=function(a){return g(a)}}},{"./es5.js":14,"./util.js":38}],28:[function(a,b,c){"use strict";function d(a,b,c,d,e){for(var f=0;f<e;++f)c[f+d]=a[f+b],a[f+b]=void 0}function e(a){this._capacity=a,this._length=0,this._front=0}e.prototype._willBeOverCapacity=function(a){return this._capacity<a},e.prototype._pushOne=function(a){var b=this.length();this._checkCapacity(b+1),this[this._front+b&this._capacity-1]=a,this._length=b+1},e.prototype._unshiftOne=function(a){var b=this._capacity;this._checkCapacity(this.length()+1);var c=this._front,d=(c-1&b-1^b)-b;this[d]=a,this._front=d,this._length=this.length()+1},e.prototype.unshift=function(a,b,c){this._unshiftOne(c),this._unshiftOne(b),this._unshiftOne(a)},e.prototype.push=function(a,b,c){var d=this.length()+3;if(this._willBeOverCapacity(d))return this._pushOne(a),this._pushOne(b),void this._pushOne(c);var e=this._front+d-3;this._checkCapacity(d);var f=this._capacity-1;this[e+0&f]=a,this[e+1&f]=b,this[e+2&f]=c,this._length=d},e.prototype.shift=function(){var a=this._front,b=this[a];return this[a]=void 0,this._front=a+1&this._capacity-1,this._length--,b},e.prototype.length=function(){return this._length},e.prototype._checkCapacity=function(a){this._capacity<a&&this._resizeTo(this._capacity<<1)},e.prototype._resizeTo=function(a){var b=this._capacity;this._capacity=a,d(this,0,this,b,this._front+this._length&b-1)},b.exports=e},{}],29:[function(a,b,c){"use strict";b.exports=function(b,c,d,e){function f(a,f){var i=d(a);if(i instanceof b)return h(i);if(!g(a))return e("expecting an array, a promise or a thenable\n\n See http://goo.gl/s8MMhc\n");var j=new b(c);void 0!==f&&j._propagateFrom(f,5);for(var k=j._fulfill,l=j._reject,m=0,n=a.length;m<n;++m){var o=a[m];(void 0!==o||m in a)&&b.cast(o)._then(k,l,void 0,j,null)}return j}var g=a("./util.js").isArray,h=function(a){return a.then(function(b){return f(b,a)})};b.race=function(a){return f(a,void 0)},b.prototype.race=function(){return f(this,void 0)}}},{"./util.js":38}],30:[function(a,b,c){"use strict";b.exports=function(b,c,d,e,f){function g(a,c,d,g){this.constructor$(a),this._promise._captureStackTrace(),this._preservedValues=g===f?[]:null,this._zerothIsAccum=void 0===d,this._gotAccum=!1,this._reducingIndex=this._zerothIsAccum?1:0,this._valuesPhase=void 0;var i=e(d,this._promise),l=!1,m=i instanceof b;m&&(i=i._target(),i._isPending()?i._proxyPromiseArray(this,-1):i._isFulfilled()?(d=i._value(),this._gotAccum=!0):(this._reject(i._reason()),l=!0)),m||this._zerothIsAccum||(this._gotAccum=!0);var n=j();this._callback=null===n?c:n.bind(c),this._accum=d,l||k.invoke(h,this,void 0)}function h(){this._init$(void 0,-5)}function i(a,b,c,e){return"function"!=typeof b?d("fn must be a function\n\n See http://goo.gl/916lJJ\n"):new g(a,b,c,e).promise()}var j=b._getDomain,k=a("./async.js"),l=a("./util.js"),m=l.tryCatch,n=l.errorObj;l.inherits(g,c),g.prototype._init=function(){},g.prototype._resolveEmptyArray=function(){(this._gotAccum||this._zerothIsAccum)&&this._resolve(null!==this._preservedValues?[]:this._accum)},g.prototype._promiseFulfilled=function(a,c){var d=this._values;d[c]=a;var f,g=this.length(),h=this._preservedValues,i=null!==h,j=this._gotAccum,k=this._valuesPhase;if(!k)for(k=this._valuesPhase=new Array(g),f=0;f<g;++f)k[f]=0;if(f=k[c],0===c&&this._zerothIsAccum?(this._accum=a,this._gotAccum=j=!0,k[c]=0===f?1:2):-1===c?(this._accum=a,this._gotAccum=j=!0):0===f?k[c]=1:(k[c]=2,this._accum=a),j){for(var l,o=this._callback,p=this._promise._boundValue(),q=this._reducingIndex;q<g;++q)if(2!==(f=k[q])){if(1!==f)return;if(a=d[q],this._promise._pushContext(),i?(h.push(a),l=m(o).call(p,a,q,g)):l=m(o).call(p,this._accum,a,q,g),this._promise._popContext(),l===n)return this._reject(l.e);var r=e(l,this._promise);if(r instanceof b){if(r=r._target(),r._isPending())return k[q]=4,r._proxyPromiseArray(this,q);if(!r._isFulfilled())return this._reject(r._reason());l=r._value()}this._reducingIndex=q+1,this._accum=l}else this._reducingIndex=q+1;this._resolve(i?h:this._accum)}},b.prototype.reduce=function(a,b){return i(this,a,b,null)},b.reduce=function(a,b,c,d){return i(a,b,c,d)}}},{"./async.js":2,"./util.js":38}],31:[function(b,c,e){"use strict";var f,g=b("./util"),h=function(){throw new Error("No async scheduler available\n\n See http://goo.gl/m3OTXk\n")};if(g.isNode&&"undefined"==typeof MutationObserver){var i=d.setImmediate,j=a.nextTick;f=g.isRecentNode?function(a){i.call(d,a)}:function(b){j.call(a,b)}}else"undefined"==typeof MutationObserver||"undefined"!=typeof window&&window.navigator&&window.navigator.standalone?f="undefined"!=typeof setImmediate?function(a){setImmediate(a)}:"undefined"!=typeof setTimeout?function(a){setTimeout(a,0)}:h:(f=function(a){var b=document.createElement("div");return new MutationObserver(a).observe(b,{attributes:!0}),function(){b.classList.toggle("foo")}},f.isStatic=!0);c.exports=f},{"./util":38}],32:[function(a,b,c){"use strict";b.exports=function(b,c){function d(a){this.constructor$(a)}var e=b.PromiseInspection;a("./util.js").inherits(d,c),d.prototype._promiseResolved=function(a,b){this._values[a]=b,++this._totalResolved>=this._length&&this._resolve(this._values)},d.prototype._promiseFulfilled=function(a,b){var c=new e;c._bitField=268435456,c._settledValue=a,this._promiseResolved(b,c)},d.prototype._promiseRejected=function(a,b){var c=new e;c._bitField=134217728,c._settledValue=a,this._promiseResolved(b,c)},b.settle=function(a){return new d(a).promise()},b.prototype.settle=function(){return new d(this).promise()}}},{"./util.js":38}],33:[function(a,b,c){"use strict";b.exports=function(b,c,d){function e(a){this.constructor$(a),this._howMany=0,this._unwrap=!1,this._initialized=!1}function f(a,b){if((0|b)!==b||b<0)return d("expecting a positive integer\n\n See http://goo.gl/1wAmHx\n");var c=new e(a),f=c.promise();return c.setHowMany(b),c.init(),f}var g=a("./util.js"),h=a("./errors.js").RangeError,i=a("./errors.js").AggregateError,j=g.isArray;g.inherits(e,c),e.prototype._init=function(){if(this._initialized){if(0===this._howMany)return void this._resolve([]);this._init$(void 0,-5);var a=j(this._values);!this._isResolved()&&a&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}},e.prototype.init=function(){this._initialized=!0,this._init()},e.prototype.setUnwrap=function(){this._unwrap=!0},e.prototype.howMany=function(){return this._howMany},e.prototype.setHowMany=function(a){this._howMany=a},e.prototype._promiseFulfilled=function(a){this._addFulfilled(a),this._fulfilled()===this.howMany()&&(this._values.length=this.howMany(),1===this.howMany()&&this._unwrap?this._resolve(this._values[0]):this._resolve(this._values))},e.prototype._promiseRejected=function(a){if(this._addRejected(a),this.howMany()>this._canPossiblyFulfill()){for(var b=new i,c=this.length();c<this._values.length;++c)b.push(this._values[c]);this._reject(b)}},e.prototype._fulfilled=function(){return this._totalResolved},e.prototype._rejected=function(){return this._values.length-this.length()},e.prototype._addRejected=function(a){this._values.push(a)},e.prototype._addFulfilled=function(a){this._values[this._totalResolved++]=a},e.prototype._canPossiblyFulfill=function(){return this.length()-this._rejected()},e.prototype._getRangeError=function(a){var b="Input array must contain at least "+this._howMany+" items but contains only "+a+" items";return new h(b)},e.prototype._resolveEmptyArray=function(){this._reject(this._getRangeError(0))},b.some=function(a,b){return f(a,b)},b.prototype.some=function(a){return f(this,a)},b._SomePromiseArray=e}},{"./errors.js":13,"./util.js":38}],34:[function(a,b,c){"use strict";b.exports=function(a){function b(a){void 0!==a?(a=a._target(),this._bitField=a._bitField,this._settledValue=a._settledValue):(this._bitField=0,this._settledValue=void 0)}b.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/hc1DLj\n");return this._settledValue},b.prototype.error=b.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/hPuiwB\n");return this._settledValue},b.prototype.isFulfilled=a.prototype._isFulfilled=function(){return(268435456&this._bitField)>0},b.prototype.isRejected=a.prototype._isRejected=function(){return(134217728&this._bitField)>0},b.prototype.isPending=a.prototype._isPending=function(){return 0==(402653184&this._bitField)},b.prototype.isResolved=a.prototype._isResolved=function(){return(402653184&this._bitField)>0},a.prototype.isPending=function(){return this._target()._isPending()},a.prototype.isRejected=function(){return this._target()._isRejected()},a.prototype.isFulfilled=function(){return this._target()._isFulfilled()},a.prototype.isResolved=function(){return this._target()._isResolved()},a.prototype._value=function(){return this._settledValue},a.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue},a.prototype.value=function(){var a=this._target();if(!a.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/hc1DLj\n");return a._settledValue},a.prototype.reason=function(){var a=this._target();if(!a.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/hPuiwB\n");return a._unsetRejectionIsUnhandled(),a._settledValue},a.PromiseInspection=b}},{}],35:[function(a,b,c){"use strict";b.exports=function(b,c){function d(a,d){if(j(a)){if(a instanceof b)return a;if(f(a)){var k=new b(c);return a._then(k._fulfillUnchecked,k._rejectUncheckedCheckError,k._progressUnchecked,k,null),k}var l=h.tryCatch(e)(a);if(l===i){d&&d._pushContext();var k=b.reject(l.e);return d&&d._popContext(),k}if("function"==typeof l)return g(a,l,d)}return a}function e(a){return a.then}function f(a){return k.call(a,"_promise0")}function g(a,d,e){function f(a){k&&(k._resolveCallback(a),k=null)}function g(a){k&&(k._rejectCallback(a,m,!0),k=null)}function j(a){k&&"function"==typeof k._progress&&k._progress(a)}var k=new b(c),l=k;e&&e._pushContext(),k._captureStackTrace(),e&&e._popContext();var m=!0,n=h.tryCatch(d).call(a,f,g,j);return m=!1,k&&n===i&&(k._rejectCallback(n.e,!0,!0),k=null),l}var h=a("./util.js"),i=h.errorObj,j=h.isObject,k={}.hasOwnProperty;return d}},{"./util.js":38}],36:[function(a,b,c){"use strict";b.exports=function(b,c){function d(a){var b=this;return b instanceof Number&&(b=+b),clearTimeout(b),a}function e(a){var b=this;throw b instanceof Number&&(b=+b),clearTimeout(b),a}var f=a("./util.js"),g=b.TimeoutError,h=function(a,b){if(a.isPending()){var c;!f.isPrimitive(b)&&b instanceof Error?c=b:("string"!=typeof b&&(b="operation timed out"),c=new g(b)),f.markAsOriginatingFromRejection(c),a._attachExtraTrace(c),a._cancel(c)}},i=function(a){return j(+this).thenReturn(a)},j=b.delay=function(a,d){if(void 0===d){d=a,a=void 0;var e=new b(c);return setTimeout(function(){e._fulfill()},d),e}return d=+d,b.resolve(a)._then(i,null,null,d,void 0)};b.prototype.delay=function(a){return j(this,a)},b.prototype.timeout=function(a,b){a=+a;var c=this.then().cancellable();c._cancellationParent=this;var f=setTimeout(function(){h(c,b)},a);return c._then(d,e,void 0,f,void 0)}}},{"./util.js":38}],37:[function(a,b,c){"use strict";b.exports=function(b,c,d,e){function f(a){for(var c=a.length,d=0;d<c;++d){var e=a[d];if(e.isRejected())return b.reject(e.error());a[d]=e._settledValue}return a}function g(a){setTimeout(function(){throw a},0)}function h(a){var b=d(a);return b!==a&&"function"==typeof a._isDisposable&&"function"==typeof a._getDisposer&&a._isDisposable()&&b._setDisposable(a._getDisposer()),b}function i(a,c){function e(){if(f>=i)return j.resolve();var k=h(a[f++]);if(k instanceof b&&k._isDisposable()){try{k=d(k._getDisposer().tryDispose(c),a.promise)}catch(l){return g(l)}if(k instanceof b)return k._then(e,g,null,null,null)}e()}var f=0,i=a.length,j=b.defer();return e(),j.promise}function j(a){var b=new q;return b._settledValue=a,b._bitField=268435456,i(this,b).thenReturn(a)}function k(a){var b=new q;return b._settledValue=a,b._bitField=134217728,i(this,b).thenThrow(a)}function l(a,b,c){this._data=a,this._promise=b,this._context=c}function m(a,b,c){this.constructor$(a,b,c)}function n(a){return l.isDisposer(a)?(this.resources[this.index]._setDisposable(a),a.promise()):a}var o=a("./errors.js").TypeError,p=a("./util.js").inherits,q=b.PromiseInspection;l.prototype.data=function(){return this._data},l.prototype.promise=function(){return this._promise},l.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():null},l.prototype.tryDispose=function(a){var b=this.resource(),c=this._context;void 0!==c&&c._pushContext();var d=null!==b?this.doDispose(b,a):null;return void 0!==c&&c._popContext(),this._promise._unsetDisposable(),this._data=null,d},l.isDisposer=function(a){return null!=a&&"function"==typeof a.resource&&"function"==typeof a.tryDispose},p(m,l),m.prototype.doDispose=function(a,b){return this.data().call(a,a,b)},b.using=function(){var a=arguments.length;if(a<2)return c("you must pass at least 2 arguments to Promise.using");var e=arguments[a-1];if("function"!=typeof e)return c("fn must be a function\n\n See http://goo.gl/916lJJ\n");var g,h=!0;2===a&&Array.isArray(arguments[0])?(g=arguments[0],a=g.length,h=!1):(g=arguments,a--);for(var i=new Array(a),m=0;m<a;++m){var o=g[m];if(l.isDisposer(o)){var p=o;o=o.promise(),o._setDisposable(p)}else{var q=d(o);q instanceof b&&(o=q._then(n,null,null,{resources:i,index:m},void 0))}i[m]=o}var r=b.settle(i).then(f).then(function(a){r._pushContext();var b;try{b=h?e.apply(void 0,a):e.call(void 0,a)}finally{r._popContext()}return b})._then(j,k,void 0,i,void 0);return i.promise=r,r},b.prototype._setDisposable=function(a){this._bitField=262144|this._bitField,this._disposer=a},b.prototype._isDisposable=function(){return(262144&this._bitField)>0},b.prototype._getDisposer=function(){return this._disposer},b.prototype._unsetDisposable=function(){this._bitField=-262145&this._bitField,this._disposer=void 0},b.prototype.disposer=function(a){if("function"==typeof a)return new m(a,this,e());throw new o}}},{"./errors.js":13,"./util.js":38}],38:[function(b,c,d){"use strict";function e(){try{var a=B;return B=null,a.apply(this,arguments)}catch(b){return A.e=b,A}}function f(a){return B=a,e}function g(a){return null==a||!0===a||!1===a||"string"==typeof a||"number"==typeof a}function h(a){return!g(a)}function i(a){return g(a)?new Error(r(a)):a}function j(a,b){var c,d=a.length,e=new Array(d+1);for(c=0;c<d;++c)e[c]=a[c];return e[c]=b,e}function k(a,b,c){if(!x.isES5)return{}.hasOwnProperty.call(a,b)?a[b]:void 0;var d=Object.getOwnPropertyDescriptor(a,b);return null!=d?null==d.get&&null==d.set?d.value:c:void 0}function l(a,b,c){if(g(a))return a;var d={value:c,configurable:!0,enumerable:!1,writable:!0};return x.defineProperty(a,b,d),a}function m(a){throw a}function n(a){try{if("function"==typeof a){var b=x.names(a.prototype),c=x.isES5&&b.length>1,d=b.length>0&&!(1===b.length&&"constructor"===b[0]),e=E.test(a+"")&&x.names(a).length>0;if(c||d||e)return!0}return!1}catch(f){return!1}}function o(a){function b(){}b.prototype=a;for(var c=8;c--;)new b;return a}function p(a){return F.test(a)}function q(a,b,c){for(var d=new Array(a),e=0;e<a;++e)d[e]=b+e+c;return d}function r(a){try{return a+""}catch(b){return"[no string representation]"}}function s(a){try{l(a,"isOperational",!0)}catch(b){}}function t(a){return null!=a&&(a instanceof Error.__BluebirdErrorTypes__.OperationalError||!0===a.isOperational)}function u(a){return a instanceof Error&&x.propertyIsWritable(a,"stack")}function v(a){return{}.toString.call(a)}function w(a,b,c){for(var d=x.names(a),e=0;e<d.length;++e){var f=d[e];if(c(f))try{x.defineProperty(b,f,x.getDescriptor(a,f))}catch(g){}}}var x=b("./es5.js"),y="undefined"==typeof navigator,z=function(){try{var a={};return x.defineProperty(a,"f",{get:function(){return 3}}),3===a.f}catch(b){return!1}}(),A={e:{}},B,C=function(a,b){function c(){this.constructor=a,this.constructor$=b;for(var c in b.prototype)d.call(b.prototype,c)&&"$"!==c.charAt(c.length-1)&&(this[c+"$"]=b.prototype[c])}var d={}.hasOwnProperty;return c.prototype=b.prototype,a.prototype=new c,a.prototype},D=function(){var a=[Array.prototype,Object.prototype,Function.prototype],b=function(b){for(var c=0;c<a.length;++c)if(a[c]===b)return!0;return!1};if(x.isES5){var c=Object.getOwnPropertyNames;return function(a){for(var d=[],e=Object.create(null);null!=a&&!b(a);){var f;try{f=c(a)}catch(j){return d}for(var g=0;g<f.length;++g){var h=f[g];if(!e[h]){e[h]=!0;var i=Object.getOwnPropertyDescriptor(a,h);null!=i&&null==i.get&&null==i.set&&d.push(h)}}a=x.getPrototypeOf(a)}return d}}var d={}.hasOwnProperty;return function(c){if(b(c))return[];var e=[];a:for(var f in c)if(d.call(c,f))e.push(f);else{for(var g=0;g<a.length;++g)if(d.call(a[g],f))continue a;e.push(f)}return e}}(),E=/this\s*\.\s*\S+\s*=/,F=/^[a-z$_][a-z$_0-9]*$/i,G=function(){return"stack"in new Error?function(a){return u(a)?a:new Error(r(a))}:function(a){if(u(a))return a;try{throw new Error(r(a))}catch(b){return b}}}(),H={isClass:n,isIdentifier:p,inheritedDataKeys:D,getDataPropertyOrDefault:k,thrower:m,isArray:x.isArray,haveGetters:z,notEnumerableProp:l,isPrimitive:g,isObject:h,canEvaluate:y,errorObj:A,tryCatch:f,inherits:C,withAppended:j,maybeWrapAsError:i,toFastProperties:o,filledRange:q,toString:r,canAttachTrace:u,ensureErrorObject:G,originatesFromRejection:t,markAsOriginatingFromRejection:s,classString:v,copyDescriptors:w,hasDevTools:"undefined"!=typeof chrome&&chrome&&"function"==typeof chrome.loadTimes,isNode:void 0!==a&&"[object process]"===v(a).toLowerCase()};H.isRecentNode=H.isNode&&function(){var b=a.versions.node.split(".").map(Number);return 0===b[0]&&b[1]>10||b[0]>0}(),H.isNode&&H.toFastProperties(a);try{throw new Error}catch(I){H.lastLineError=I}c.exports=H},{"./es5.js":14}]},{},[4])(4)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise)}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:26}],26:[function(a,b,c){function d(){throw new Error("setTimeout has not been defined")}function e(){throw new Error("clearTimeout has not been defined")}function f(a){if(l===setTimeout)return setTimeout(a,0);if((l===d||!l)&&setTimeout)return l=setTimeout,setTimeout(a,0);try{return l(a,0)}catch(b){try{return l.call(null,a,0)}catch(b){return l.call(this,a,0)}}}function g(a){if(m===clearTimeout)return clearTimeout(a);if((m===e||!m)&&clearTimeout)return m=clearTimeout,clearTimeout(a);try{return m(a)}catch(b){try{return m.call(null,a)}catch(b){return m.call(this,a)}}}function h(){q&&o&&(q=!1,o.length?p=o.concat(p):r=-1,p.length&&i())}function i(){if(!q){var a=f(h);q=!0;for(var b=p.length;b;){for(o=p,p=[];++r<b;)o&&o[r].run();r=-1,b=p.length}o=null,q=!1,g(a)}}function j(a,b){this.fun=a,this.array=b}function k(){}var l,m,n=b.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:d}catch(a){l=d}try{m="function"==typeof clearTimeout?clearTimeout:e}catch(a){m=e}}();var o,p=[],q=!1,r=-1;n.nextTick=function(a){var b=new Array(arguments.length-1);if(arguments.length>1)for(var c=1;c<arguments.length;c++)b[c-1]=arguments[c];p.push(new j(a,b)),1!==p.length||q||f(i)},j.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=k,n.addListener=k,n.once=k,n.off=k,n.removeListener=k,n.removeAllListeners=k,n.emit=k,n.prependListener=k,n.prependOnceListener=k,n.listeners=function(a){return[]},n.binding=function(a){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(a){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},{}],27:[function(a,b,c){(function(a,b,c){"use strict";var d=function(a,b,c){c=e.extend({},e.options,c);var f,g,h=e.runValidations(a,b,c);for(f in h)for(g in h[f])if(e.isPromise(h[f][g]))throw new Error("Use validate.async if you want support for promises");return d.processValidationResults(h,c)},e=d;e.extend=function(a){
return[].slice.call(arguments,1).forEach(function(b){for(var c in b)a[c]=b[c]}),a},e.extend(d,{version:{major:0,minor:10,patch:0,metadata:null,toString:function(){var a=e.format("%{major}.%{minor}.%{patch}",e.version);return e.isEmpty(e.version.metadata)||(a+="+"+e.version.metadata),a}},Promise:"undefined"!=typeof Promise?Promise:null,EMPTY_STRING_REGEXP:/^\s*$/,runValidations:function(a,b,c){var d,f,g,h,i,j,k,l=[];(e.isDomElement(a)||e.isJqueryElement(a))&&(a=e.collectFormValues(a));for(d in b){g=e.getDeepObjectValue(a,d),h=e.result(b[d],g,a,d,c,b);for(f in h){if(!(i=e.validators[f]))throw k=e.format("Unknown validator %{name}",{name:f}),new Error(k);j=h[f],j=e.result(j,g,a,d,c,b),j&&l.push({attribute:d,value:g,validator:f,globalOptions:c,attributes:a,options:j,error:i.call(i,g,j,d,a,c)})}}return l},processValidationResults:function(a,b){var c;switch(a=e.pruneEmptyErrors(a,b),a=e.expandMultipleErrors(a,b),a=e.convertErrorMessages(a,b),b.format||"grouped"){case"detailed":break;case"flat":a=e.flattenErrorsToArray(a);break;case"grouped":a=e.groupErrorsByAttribute(a);for(c in a)a[c]=e.flattenErrorsToArray(a[c]);break;default:throw new Error(e.format("Unknown format %{format}",b))}return e.isEmpty(a)?void 0:a},async:function(a,b,c){c=e.extend({},e.async.options,c);var d=c.wrapErrors||function(a){return a};!1!==c.cleanAttributes&&(a=e.cleanAttributes(a,b));var f=e.runValidations(a,b,c);return new e.Promise(function(g,h){e.waitForResults(f).then(function(){var i=e.processValidationResults(f,c);i?h(new d(i,c,a,b)):g(a)},function(a){h(a)})})},single:function(a,b,c){return c=e.extend({},e.single.options,c,{format:"flat",fullMessages:!1}),e({single:a},{single:b},c)},waitForResults:function(a){return a.reduce(function(a,b){return e.isPromise(b.error)?a.then(function(){return b.error.then(function(a){b.error=a||null},function(a){if(a instanceof Error)throw a;e.error("Rejecting promises with the result is deprecated. Please use the resolve callback instead."),b.error=a})}):a},new e.Promise(function(a){a()}))},result:function(a){var b=[].slice.call(arguments,1);return"function"==typeof a&&(a=a.apply(null,b)),a},isNumber:function(a){return"number"==typeof a&&!isNaN(a)},isFunction:function(a){return"function"==typeof a},isInteger:function(a){return e.isNumber(a)&&a%1==0},isBoolean:function(a){return"boolean"==typeof a},isObject:function(a){return a===Object(a)},isDate:function(a){return a instanceof Date},isDefined:function(a){return null!==a&&void 0!==a},isPromise:function(a){return!!a&&e.isFunction(a.then)},isJqueryElement:function(a){return a&&e.isString(a.jquery)},isDomElement:function(a){return!!a&&(!(!a.querySelectorAll||!a.querySelector)&&(!(!e.isObject(document)||a!==document)||("object"==typeof HTMLElement?a instanceof HTMLElement:a&&"object"==typeof a&&null!==a&&1===a.nodeType&&"string"==typeof a.nodeName)))},isEmpty:function(a){var b;if(!e.isDefined(a))return!0;if(e.isFunction(a))return!1;if(e.isString(a))return e.EMPTY_STRING_REGEXP.test(a);if(e.isArray(a))return 0===a.length;if(e.isDate(a))return!1;if(e.isObject(a)){for(b in a)return!1;return!0}return!1},format:e.extend(function(a,b){return e.isString(a)?a.replace(e.format.FORMAT_REGEXP,function(a,c,d){return"%"===c?"%{"+d+"}":String(b[d])}):a},{FORMAT_REGEXP:/(%?)%\{([^\}]+)\}/g}),prettify:function(a){return e.isNumber(a)?100*a%1==0?""+a:parseFloat(Math.round(100*a)/100).toFixed(2):e.isArray(a)?a.map(function(a){return e.prettify(a)}).join(", "):e.isObject(a)?a.toString():(a=""+a,a.replace(/([^\s])\.([^\s])/g,"$1 $2").replace(/\\+/g,"").replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,function(a,b,c){return b+" "+c.toLowerCase()}).toLowerCase())},stringifyValue:function(a){return e.prettify(a)},isString:function(a){return"string"==typeof a},isArray:function(a){return"[object Array]"==={}.toString.call(a)},isHash:function(a){return e.isObject(a)&&!e.isArray(a)&&!e.isFunction(a)},contains:function(a,b){return!!e.isDefined(a)&&(e.isArray(a)?-1!==a.indexOf(b):b in a)},unique:function(a){return e.isArray(a)?a.filter(function(a,b,c){return c.indexOf(a)==b}):a},forEachKeyInKeypath:function(a,b,c){if(e.isString(b)){var d,f="",g=!1;for(d=0;d<b.length;++d)switch(b[d]){case".":g?(g=!1,f+="."):(a=c(a,f,!1),f="");break;case"\\":g?(g=!1,f+="\\"):g=!0;break;default:g=!1,f+=b[d]}return c(a,f,!0)}},getDeepObjectValue:function(a,b){if(e.isObject(a))return e.forEachKeyInKeypath(a,b,function(a,b){if(e.isObject(a))return a[b]})},collectFormValues:function(a,b){var c,d,f,g,h={};if(e.isJqueryElement(a)&&(a=a[0]),!a)return h;for(b=b||{},f=a.querySelectorAll("input[name], textarea[name]"),c=0;c<f.length;++c)d=f.item(c),e.isDefined(d.getAttribute("data-ignored"))||(g=e.sanitizeFormValue(d.value,b),"number"===d.type?g=g?+g:null:"checkbox"===d.type?d.attributes.value?d.checked||(g=h[d.name]||null):g=d.checked:"radio"===d.type&&(d.checked||(g=h[d.name]||null)),h[d.name]=g);for(f=a.querySelectorAll("select[name]"),c=0;c<f.length;++c)d=f.item(c),g=e.sanitizeFormValue(d.options[d.selectedIndex].value,b),h[d.name]=g;return h},sanitizeFormValue:function(a,b){return b.trim&&e.isString(a)&&(a=a.trim()),!1!==b.nullify&&""===a?null:a},capitalize:function(a){return e.isString(a)?a[0].toUpperCase()+a.slice(1):a},pruneEmptyErrors:function(a){return a.filter(function(a){return!e.isEmpty(a.error)})},expandMultipleErrors:function(a){var b=[];return a.forEach(function(a){e.isArray(a.error)?a.error.forEach(function(c){b.push(e.extend({},a,{error:c}))}):b.push(a)}),b},convertErrorMessages:function(a,b){b=b||{};var c=[];return a.forEach(function(a){var d=e.result(a.error,a.value,a.attribute,a.options,a.attributes,a.globalOptions);if(!e.isString(d))return void c.push(a);"^"===d[0]?d=d.slice(1):!1!==b.fullMessages&&(d=e.capitalize(e.prettify(a.attribute))+" "+d),d=d.replace(/\\\^/g,"^"),d=e.format(d,{value:e.stringifyValue(a.value)}),c.push(e.extend({},a,{error:d}))}),c},groupErrorsByAttribute:function(a){var b={};return a.forEach(function(a){var c=b[a.attribute];c?c.push(a):b[a.attribute]=[a]}),b},flattenErrorsToArray:function(a){return a.map(function(a){return a.error})},cleanAttributes:function(a,b){function c(a,b,c){return e.isObject(a[b])?a[b]:a[b]=!!c||{}}function d(a){var b,d={};for(b in a)a[b]&&e.forEachKeyInKeypath(d,b,c);return d}function f(a,b){if(!e.isObject(a))return a;var c,d,g=e.extend({},a);for(d in a)c=b[d],e.isObject(c)?g[d]=f(g[d],c):c||delete g[d];return g}return e.isObject(b)&&e.isObject(a)?(b=d(b),f(a,b)):{}},exposeModule:function(a,b,c,d,e){c?(d&&d.exports&&(c=d.exports=a),c.validate=a):(b.validate=a,a.isFunction(e)&&e.amd&&e([],function(){return a}))},warn:function(a){"undefined"!=typeof console&&console.warn&&console.warn("[validate.js] "+a)},error:function(a){"undefined"!=typeof console&&console.error&&console.error("[validate.js] "+a)}}),d.validators={presence:function(a,b){if(b=e.extend({},this.options,b),e.isEmpty(a))return b.message||this.message||"can't be blank"},length:function(a,b,c){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var d,f=b.is,g=b.maximum,h=b.minimum,i=b.tokenizer||function(a){return a},j=[];a=i(a);var k=a.length;return e.isNumber(k)?(e.isNumber(f)&&k!==f&&(d=b.wrongLength||this.wrongLength||"is the wrong length (should be %{count} characters)",j.push(e.format(d,{count:f}))),e.isNumber(h)&&k<h&&(d=b.tooShort||this.tooShort||"is too short (minimum is %{count} characters)",j.push(e.format(d,{count:h}))),e.isNumber(g)&&k>g&&(d=b.tooLong||this.tooLong||"is too long (maximum is %{count} characters)",j.push(e.format(d,{count:g}))),j.length>0?b.message||j:void 0):(e.error(e.format("Attribute %{attr} has a non numeric value for `length`",{attr:c})),b.message||this.notValid||"has an incorrect length")}},numericality:function(a,b){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c,d,f=[],g={greaterThan:function(a,b){return a>b},greaterThanOrEqualTo:function(a,b){return a>=b},equalTo:function(a,b){return a===b},lessThan:function(a,b){return a<b},lessThanOrEqualTo:function(a,b){return a<=b},divisibleBy:function(a,b){return a%b==0}};if(e.isString(a)&&b.strict){var h="^(0|[1-9]\\d*)";if(b.onlyInteger||(h+="(\\.\\d+)?"),h+="$",!new RegExp(h).test(a))return b.message||b.notValid||this.notValid||"must be a valid number"}if(!0!==b.noStrings&&e.isString(a)&&(a=+a),!e.isNumber(a))return b.message||b.notValid||this.notValid||"is not a number";if(b.onlyInteger&&!e.isInteger(a))return b.message||b.notInteger||this.notInteger||"must be an integer";for(c in g)if(d=b[c],e.isNumber(d)&&!g[c](a,d)){var i="not"+e.capitalize(c),j=b[i]||this[i]||"must be %{type} %{count}";f.push(e.format(j,{count:d,type:e.prettify(c)}))}return b.odd&&a%2!=1&&f.push(b.notOdd||this.notOdd||"must be odd"),b.even&&a%2!=0&&f.push(b.notEven||this.notEven||"must be even"),f.length?b.message||f:void 0}},datetime:e.extend(function(a,b){if(!e.isFunction(this.parse)||!e.isFunction(this.format))throw new Error("Both the parse and format functions needs to be set to use the datetime/date validator");if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c,d=[],f=b.earliest?this.parse(b.earliest,b):NaN,g=b.latest?this.parse(b.latest,b):NaN;return a=this.parse(a,b),isNaN(a)||b.dateOnly&&a%864e5!=0?(c=b.notValid||b.message||this.notValid||"must be a valid date",e.format(c,{value:arguments[0]})):(!isNaN(f)&&a<f&&(c=b.tooEarly||b.message||this.tooEarly||"must be no earlier than %{date}",c=e.format(c,{value:this.format(a,b),date:this.format(f,b)}),d.push(c)),!isNaN(g)&&a>g&&(c=b.tooLate||b.message||this.tooLate||"must be no later than %{date}",c=e.format(c,{date:this.format(g,b),value:this.format(a,b)}),d.push(c)),d.length?e.unique(d):void 0)}},{parse:null,format:null}),date:function(a,b){return b=e.extend({},b,{dateOnly:!0}),e.validators.datetime.call(e.validators.datetime,a,b)},format:function(a,b){(e.isString(b)||b instanceof RegExp)&&(b={pattern:b}),b=e.extend({},this.options,b);var c,d=b.message||this.message||"is invalid",f=b.pattern;if(!e.isEmpty(a))return e.isString(a)?(e.isString(f)&&(f=new RegExp(b.pattern,b.flags)),c=f.exec(a),c&&c[0].length==a.length?void 0:d):d},inclusion:function(a,b){if(!e.isEmpty(a)&&(e.isArray(b)&&(b={within:b}),b=e.extend({},this.options,b),!e.contains(b.within,a))){var c=b.message||this.message||"^%{value} is not included in the list";return e.format(c,{value:a})}},exclusion:function(a,b){if(!e.isEmpty(a)&&(e.isArray(b)&&(b={within:b}),b=e.extend({},this.options,b),e.contains(b.within,a))){var c=b.message||this.message||"^%{value} is restricted";return e.format(c,{value:a})}},email:e.extend(function(a,b){b=e.extend({},this.options,b);var c=b.message||this.message||"is not a valid email";if(!e.isEmpty(a))return e.isString(a)&&this.PATTERN.exec(a)?void 0:c},{PATTERN:/^[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/i}),equality:function(a,b,c,d){if(!e.isEmpty(a)){e.isString(b)&&(b={attribute:b}),b=e.extend({},this.options,b);var f=b.message||this.message||"is not equal to %{attribute}";if(e.isEmpty(b.attribute)||!e.isString(b.attribute))throw new Error("The attribute must be a non empty string");var g=e.getDeepObjectValue(d,b.attribute);return(b.comparator||function(a,b){return a===b})(a,g,b,c,d)?void 0:e.format(f,{attribute:e.prettify(b.attribute)})}},url:function(a,b){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c=b.message||this.message||"is not a valid url",d=b.schemes||this.schemes||["http","https"],f=b.allowLocal||this.allowLocal||!1;if(!e.isString(a))return c;var g="^(?:(?:"+d.join("|")+"):\\/\\/)(?:\\S+(?::\\S*)?@)?";g+="(?:";var h="(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))";f?h+="?":g+="(?!10(?:\\.\\d{1,3}){3})(?!127(?:\\.\\d{1,3}){3})(?!169\\.254(?:\\.\\d{1,3}){2})(?!192\\.168(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})";g+="(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|"+("(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*"+h+")")+"(?::\\d{2,5})?(?:\\/[^\\s]*)?$";return new RegExp(g,"i").exec(a)?void 0:c}}},d.exposeModule(d,this,a,b,c)}).call(this,void 0!==c?c:null,void 0!==b?b:null,"undefined"!=typeof define?define:null)},{}]},{},[10,17,1]);