UNPKG

node-uci

Version:

Universal Chess Interface protocol implementation for node.js

1 lines 144 kB
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var child_process=require("child_process"),path$1=_interopDefault(require("path")),os=require("os"),os__default=_interopDefault(os),events=require("events"),async_hooks=_interopDefault(require("async_hooks")),tty=_interopDefault(require("tty")),util$1=_interopDefault(require("util")),commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var check=function(e){return e&&e.Math==Math&&e},global_1=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof commonjsGlobal&&commonjsGlobal)||Function("return this")(),fails=function(e){try{return!!e()}catch(e){return!0}},descriptors=!fails((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),nativePropertyIsEnumerable={}.propertyIsEnumerable,getOwnPropertyDescriptor=Object.getOwnPropertyDescriptor,NASHORN_BUG=getOwnPropertyDescriptor&&!nativePropertyIsEnumerable.call({1:2},1),f=NASHORN_BUG?function(e){var t=getOwnPropertyDescriptor(this,e);return!!t&&t.enumerable}:nativePropertyIsEnumerable,objectPropertyIsEnumerable={f:f},createPropertyDescriptor=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},toString={}.toString,classofRaw=function(e){return toString.call(e).slice(8,-1)},split="".split,indexedObject=fails((function(){return!Object("z").propertyIsEnumerable(0)}))?function(e){return"String"==classofRaw(e)?split.call(e,""):Object(e)}:Object,requireObjectCoercible=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},toIndexedObject=function(e){return indexedObject(requireObjectCoercible(e))},isObject=function(e){return"object"==typeof e?null!==e:"function"==typeof e},toPrimitive=function(e,t){if(!isObject(e))return e;var r,n;if(t&&"function"==typeof(r=e.toString)&&!isObject(n=r.call(e)))return n;if("function"==typeof(r=e.valueOf)&&!isObject(n=r.call(e)))return n;if(!t&&"function"==typeof(r=e.toString)&&!isObject(n=r.call(e)))return n;throw TypeError("Can't convert object to primitive value")},hasOwnProperty={}.hasOwnProperty,has=function(e,t){return hasOwnProperty.call(e,t)},document$1=global_1.document,EXISTS=isObject(document$1)&&isObject(document$1.createElement),documentCreateElement=function(e){return EXISTS?document$1.createElement(e):{}},ie8DomDefine=!descriptors&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),nativeGetOwnPropertyDescriptor=Object.getOwnPropertyDescriptor,f$1=descriptors?nativeGetOwnPropertyDescriptor:function(e,t){if(e=toIndexedObject(e),t=toPrimitive(t,!0),ie8DomDefine)try{return nativeGetOwnPropertyDescriptor(e,t)}catch(e){}if(has(e,t))return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(e,t),e[t])},objectGetOwnPropertyDescriptor={f:f$1},anObject=function(e){if(!isObject(e))throw TypeError(String(e)+" is not an object");return e},nativeDefineProperty=Object.defineProperty,f$2=descriptors?nativeDefineProperty:function(e,t,r){if(anObject(e),t=toPrimitive(t,!0),anObject(r),ie8DomDefine)try{return nativeDefineProperty(e,t,r)}catch(e){}if("get"in r||"set"in r)throw TypeError("Accessors not supported");return"value"in r&&(e[t]=r.value),e},objectDefineProperty={f:f$2},createNonEnumerableProperty=descriptors?function(e,t,r){return objectDefineProperty.f(e,t,createPropertyDescriptor(1,r))}:function(e,t,r){return e[t]=r,e},setGlobal=function(e,t){try{createNonEnumerableProperty(global_1,e,t)}catch(r){global_1[e]=t}return t},SHARED="__core-js_shared__",store=global_1[SHARED]||setGlobal(SHARED,{}),sharedStore=store,functionToString=Function.toString;"function"!=typeof sharedStore.inspectSource&&(sharedStore.inspectSource=function(e){return functionToString.call(e)});var set,get,has$1,inspectSource=sharedStore.inspectSource,WeakMap=global_1.WeakMap,nativeWeakMap="function"==typeof WeakMap&&/native code/.test(inspectSource(WeakMap)),shared=createCommonjsModule((function(e){(e.exports=function(e,t){return sharedStore[e]||(sharedStore[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.6.2",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),id=0,postfix=Math.random(),uid=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++id+postfix).toString(36)},keys=shared("keys"),sharedKey=function(e){return keys[e]||(keys[e]=uid(e))},hiddenKeys={},WeakMap$1=global_1.WeakMap,enforce=function(e){return has$1(e)?get(e):set(e,{})},getterFor=function(e){return function(t){var r;if(!isObject(t)||(r=get(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return r}};if(nativeWeakMap){var store$1=new WeakMap$1,wmget=store$1.get,wmhas=store$1.has,wmset=store$1.set;set=function(e,t){return wmset.call(store$1,e,t),t},get=function(e){return wmget.call(store$1,e)||{}},has$1=function(e){return wmhas.call(store$1,e)}}else{var STATE=sharedKey("state");hiddenKeys[STATE]=!0,set=function(e,t){return createNonEnumerableProperty(e,STATE,t),t},get=function(e){return has(e,STATE)?e[STATE]:{}},has$1=function(e){return has(e,STATE)}}var internalState={set:set,get:get,has:has$1,enforce:enforce,getterFor:getterFor},redefine=createCommonjsModule((function(e){var t=internalState.get,r=internalState.enforce,n=String(String).split("String");(e.exports=function(e,t,o,i){var a=!!i&&!!i.unsafe,s=!!i&&!!i.enumerable,c=!!i&&!!i.noTargetGet;"function"==typeof o&&("string"!=typeof t||has(o,"name")||createNonEnumerableProperty(o,"name",t),r(o).source=n.join("string"==typeof t?t:"")),e!==global_1?(a?!c&&e[t]&&(s=!0):delete e[t],s?e[t]=o:createNonEnumerableProperty(e,t,o)):s?e[t]=o:setGlobal(t,o)})(Function.prototype,"toString",(function(){return"function"==typeof this&&t(this).source||inspectSource(this)}))})),path=global_1,aFunction=function(e){return"function"==typeof e?e:void 0},getBuiltIn=function(e,t){return arguments.length<2?aFunction(path[e])||aFunction(global_1[e]):path[e]&&path[e][t]||global_1[e]&&global_1[e][t]},ceil=Math.ceil,floor=Math.floor,toInteger=function(e){return isNaN(e=+e)?0:(e>0?floor:ceil)(e)},min=Math.min,toLength=function(e){return e>0?min(toInteger(e),9007199254740991):0},max=Math.max,min$1=Math.min,toAbsoluteIndex=function(e,t){var r=toInteger(e);return r<0?max(r+t,0):min$1(r,t)},createMethod=function(e){return function(t,r,n){var o,i=toIndexedObject(t),a=toLength(i.length),s=toAbsoluteIndex(n,a);if(e&&r!=r){for(;a>s;)if((o=i[s++])!=o)return!0}else for(;a>s;s++)if((e||s in i)&&i[s]===r)return e||s||0;return!e&&-1}},arrayIncludes={includes:createMethod(!0),indexOf:createMethod(!1)},indexOf=arrayIncludes.indexOf,objectKeysInternal=function(e,t){var r,n=toIndexedObject(e),o=0,i=[];for(r in n)!has(hiddenKeys,r)&&has(n,r)&&i.push(r);for(;t.length>o;)has(n,r=t[o++])&&(~indexOf(i,r)||i.push(r));return i},enumBugKeys=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],hiddenKeys$1=enumBugKeys.concat("length","prototype"),f$3=Object.getOwnPropertyNames||function(e){return objectKeysInternal(e,hiddenKeys$1)},objectGetOwnPropertyNames={f:f$3},f$4=Object.getOwnPropertySymbols,objectGetOwnPropertySymbols={f:f$4},ownKeys=getBuiltIn("Reflect","ownKeys")||function(e){var t=objectGetOwnPropertyNames.f(anObject(e)),r=objectGetOwnPropertySymbols.f;return r?t.concat(r(e)):t},copyConstructorProperties=function(e,t){for(var r=ownKeys(t),n=objectDefineProperty.f,o=objectGetOwnPropertyDescriptor.f,i=0;i<r.length;i++){var a=r[i];has(e,a)||n(e,a,o(t,a))}},replacement=/#|\.prototype\./,isForced=function(e,t){var r=data[normalize(e)];return r==POLYFILL||r!=NATIVE&&("function"==typeof t?fails(t):!!t)},normalize=isForced.normalize=function(e){return String(e).replace(replacement,".").toLowerCase()},data=isForced.data={},NATIVE=isForced.NATIVE="N",POLYFILL=isForced.POLYFILL="P",isForced_1=isForced,getOwnPropertyDescriptor$1=objectGetOwnPropertyDescriptor.f,_export=function(e,t){var r,n,o,i,a,s=e.target,c=e.global,l=e.stat;if(r=c?global_1:l?global_1[s]||setGlobal(s,{}):(global_1[s]||{}).prototype)for(n in t){if(i=t[n],o=e.noTargetGet?(a=getOwnPropertyDescriptor$1(r,n))&&a.value:r[n],!isForced_1(c?n:s+(l?".":"#")+n,e.forced)&&void 0!==o){if(typeof i==typeof o)continue;copyConstructorProperties(i,o)}(e.sham||o&&o.sham)&&createNonEnumerableProperty(i,"sham",!0),redefine(r,n,i,e)}},nativePromiseConstructor=global_1.Promise,redefineAll=function(e,t,r){for(var n in t)redefine(e,n,t[n],r);return e},nativeSymbol=!!Object.getOwnPropertySymbols&&!fails((function(){return!String(Symbol())})),useSymbolAsUid=nativeSymbol&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,WellKnownSymbolsStore=shared("wks"),Symbol$1=global_1.Symbol,createWellKnownSymbol=useSymbolAsUid?Symbol$1:Symbol$1&&Symbol$1.withoutSetter||uid,wellKnownSymbol=function(e){return has(WellKnownSymbolsStore,e)||(nativeSymbol&&has(Symbol$1,e)?WellKnownSymbolsStore[e]=Symbol$1[e]:WellKnownSymbolsStore[e]=createWellKnownSymbol("Symbol."+e)),WellKnownSymbolsStore[e]},defineProperty=objectDefineProperty.f,TO_STRING_TAG=wellKnownSymbol("toStringTag"),setToStringTag=function(e,t,r){e&&!has(e=r?e:e.prototype,TO_STRING_TAG)&&defineProperty(e,TO_STRING_TAG,{configurable:!0,value:t})},SPECIES=wellKnownSymbol("species"),setSpecies=function(e){var t=getBuiltIn(e),r=objectDefineProperty.f;descriptors&&t&&!t[SPECIES]&&r(t,SPECIES,{configurable:!0,get:function(){return this}})},aFunction$1=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e},anInstance=function(e,t,r){if(!(e instanceof t))throw TypeError("Incorrect "+(r?r+" ":"")+"invocation");return e},iterators={},ITERATOR=wellKnownSymbol("iterator"),ArrayPrototype=Array.prototype,isArrayIteratorMethod=function(e){return void 0!==e&&(iterators.Array===e||ArrayPrototype[ITERATOR]===e)},functionBindContext=function(e,t,r){if(aFunction$1(e),void 0===t)return e;switch(r){case 0:return function(){return e.call(t)};case 1:return function(r){return e.call(t,r)};case 2:return function(r,n){return e.call(t,r,n)};case 3:return function(r,n,o){return e.call(t,r,n,o)}}return function(){return e.apply(t,arguments)}},TO_STRING_TAG$1=wellKnownSymbol("toStringTag"),test={};test[TO_STRING_TAG$1]="z";var toStringTagSupport="[object z]"===String(test),TO_STRING_TAG$2=wellKnownSymbol("toStringTag"),CORRECT_ARGUMENTS="Arguments"==classofRaw(function(){return arguments}()),tryGet=function(e,t){try{return e[t]}catch(e){}},classof=toStringTagSupport?classofRaw:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=tryGet(t=Object(e),TO_STRING_TAG$2))?r:CORRECT_ARGUMENTS?classofRaw(t):"Object"==(n=classofRaw(t))&&"function"==typeof t.callee?"Arguments":n},ITERATOR$1=wellKnownSymbol("iterator"),getIteratorMethod=function(e){if(null!=e)return e[ITERATOR$1]||e["@@iterator"]||iterators[classof(e)]},callWithSafeIterationClosing=function(e,t,r,n){try{return n?t(anObject(r)[0],r[1]):t(r)}catch(t){var o=e.return;throw void 0!==o&&anObject(o.call(e)),t}},iterate_1=createCommonjsModule((function(e){var t=function(e,t){this.stopped=e,this.result=t};(e.exports=function(e,r,n,o,i){var a,s,c,l,u,p,f,h=functionBindContext(r,n,o?2:1);if(i)a=e;else{if("function"!=typeof(s=getIteratorMethod(e)))throw TypeError("Target is not iterable");if(isArrayIteratorMethod(s)){for(c=0,l=toLength(e.length);l>c;c++)if((u=o?h(anObject(f=e[c])[0],f[1]):h(e[c]))&&u instanceof t)return u;return new t(!1)}a=s.call(e)}for(p=a.next;!(f=p.call(a)).done;)if("object"==typeof(u=callWithSafeIterationClosing(a,h,f.value,o))&&u&&u instanceof t)return u;return new t(!1)}).stop=function(e){return new t(!0,e)}})),ITERATOR$2=wellKnownSymbol("iterator"),SAFE_CLOSING=!1;try{var called=0,iteratorWithReturn={next:function(){return{done:!!called++}},return:function(){SAFE_CLOSING=!0}};iteratorWithReturn[ITERATOR$2]=function(){return this},Array.from(iteratorWithReturn,(function(){throw 2}))}catch(e){}var defer,channel,port,checkCorrectnessOfIteration=function(e,t){if(!t&&!SAFE_CLOSING)return!1;var r=!1;try{var n={};n[ITERATOR$2]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(e){}return r},SPECIES$1=wellKnownSymbol("species"),speciesConstructor=function(e,t){var r,n=anObject(e).constructor;return void 0===n||null==(r=anObject(n)[SPECIES$1])?t:aFunction$1(r)},html=getBuiltIn("document","documentElement"),engineUserAgent=getBuiltIn("navigator","userAgent")||"",engineIsIos=/(iphone|ipod|ipad).*applewebkit/i.test(engineUserAgent),location=global_1.location,set$1=global_1.setImmediate,clear=global_1.clearImmediate,process$1=global_1.process,MessageChannel=global_1.MessageChannel,Dispatch=global_1.Dispatch,counter=0,queue={},ONREADYSTATECHANGE="onreadystatechange",run=function(e){if(queue.hasOwnProperty(e)){var t=queue[e];delete queue[e],t()}},runner=function(e){return function(){run(e)}},listener=function(e){run(e.data)},post=function(e){global_1.postMessage(e+"",location.protocol+"//"+location.host)};set$1&&clear||(set$1=function(e){for(var t=[],r=1;arguments.length>r;)t.push(arguments[r++]);return queue[++counter]=function(){("function"==typeof e?e:Function(e)).apply(void 0,t)},defer(counter),counter},clear=function(e){delete queue[e]},"process"==classofRaw(process$1)?defer=function(e){process$1.nextTick(runner(e))}:Dispatch&&Dispatch.now?defer=function(e){Dispatch.now(runner(e))}:MessageChannel&&!engineIsIos?(port=(channel=new MessageChannel).port2,channel.port1.onmessage=listener,defer=functionBindContext(port.postMessage,port,1)):!global_1.addEventListener||"function"!=typeof postMessage||global_1.importScripts||fails(post)?defer=ONREADYSTATECHANGE in documentCreateElement("script")?function(e){html.appendChild(documentCreateElement("script"))[ONREADYSTATECHANGE]=function(){html.removeChild(this),run(e)}}:function(e){setTimeout(runner(e),0)}:(defer=post,global_1.addEventListener("message",listener,!1)));var flush,head,last,notify,toggle,node,promise,then,task={set:set$1,clear:clear},getOwnPropertyDescriptor$2=objectGetOwnPropertyDescriptor.f,macrotask=task.set,MutationObserver$1=global_1.MutationObserver||global_1.WebKitMutationObserver,process$2=global_1.process,Promise$1=global_1.Promise,IS_NODE="process"==classofRaw(process$2),queueMicrotaskDescriptor=getOwnPropertyDescriptor$2(global_1,"queueMicrotask"),queueMicrotask=queueMicrotaskDescriptor&&queueMicrotaskDescriptor.value;queueMicrotask||(flush=function(){var e,t;for(IS_NODE&&(e=process$2.domain)&&e.exit();head;){t=head.fn,head=head.next;try{t()}catch(e){throw head?notify():last=void 0,e}}last=void 0,e&&e.enter()},IS_NODE?notify=function(){process$2.nextTick(flush)}:MutationObserver$1&&!engineIsIos?(toggle=!0,node=document.createTextNode(""),new MutationObserver$1(flush).observe(node,{characterData:!0}),notify=function(){node.data=toggle=!toggle}):Promise$1&&Promise$1.resolve?(promise=Promise$1.resolve(void 0),then=promise.then,notify=function(){then.call(promise,flush)}):notify=function(){macrotask.call(global_1,flush)});var match,version,microtask=queueMicrotask||function(e){var t={fn:e,next:void 0};last&&(last.next=t),head||(head=t,notify()),last=t},PromiseCapability=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw TypeError("Bad Promise constructor");t=e,r=n})),this.resolve=aFunction$1(t),this.reject=aFunction$1(r)},f$5=function(e){return new PromiseCapability(e)},newPromiseCapability={f:f$5},promiseResolve=function(e,t){if(anObject(e),isObject(t)&&t.constructor===e)return t;var r=newPromiseCapability.f(e);return(0,r.resolve)(t),r.promise},hostReportErrors=function(e,t){var r=global_1.console;r&&r.error&&(1===arguments.length?r.error(e):r.error(e,t))},perform=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},process$3=global_1.process,versions=process$3&&process$3.versions,v8=versions&&versions.v8;v8?version=(match=v8.split("."))[0]+match[1]:engineUserAgent&&(!(match=engineUserAgent.match(/Edge\/(\d+)/))||match[1]>=74)&&(match=engineUserAgent.match(/Chrome\/(\d+)/))&&(version=match[1]);var Internal,OwnPromiseCapability,PromiseWrapper,nativeThen,engineV8Version=version&&+version,task$1=task.set,SPECIES$2=wellKnownSymbol("species"),PROMISE="Promise",getInternalState=internalState.get,setInternalState=internalState.set,getInternalPromiseState=internalState.getterFor(PROMISE),PromiseConstructor=nativePromiseConstructor,TypeError$1=global_1.TypeError,document$2=global_1.document,process$4=global_1.process,$fetch=getBuiltIn("fetch"),newPromiseCapability$1=newPromiseCapability.f,newGenericPromiseCapability=newPromiseCapability$1,IS_NODE$1="process"==classofRaw(process$4),DISPATCH_EVENT=!!(document$2&&document$2.createEvent&&global_1.dispatchEvent),UNHANDLED_REJECTION="unhandledrejection",REJECTION_HANDLED="rejectionhandled",PENDING=0,FULFILLED=1,REJECTED=2,HANDLED=1,UNHANDLED=2,FORCED=isForced_1(PROMISE,(function(){if(!(inspectSource(PromiseConstructor)!==String(PromiseConstructor))){if(66===engineV8Version)return!0;if(!IS_NODE$1&&"function"!=typeof PromiseRejectionEvent)return!0}if(engineV8Version>=51&&/native code/.test(PromiseConstructor))return!1;var e=PromiseConstructor.resolve(1),t=function(e){e((function(){}),(function(){}))};return(e.constructor={})[SPECIES$2]=t,!(e.then((function(){}))instanceof t)})),INCORRECT_ITERATION=FORCED||!checkCorrectnessOfIteration((function(e){PromiseConstructor.all(e).catch((function(){}))})),isThenable=function(e){var t;return!(!isObject(e)||"function"!=typeof(t=e.then))&&t},notify$1=function(e,t,r){if(!t.notified){t.notified=!0;var n=t.reactions;microtask((function(){for(var o=t.value,i=t.state==FULFILLED,a=0;n.length>a;){var s,c,l,u=n[a++],p=i?u.ok:u.fail,f=u.resolve,h=u.reject,d=u.domain;try{p?(i||(t.rejection===UNHANDLED&&onHandleUnhandled(e,t),t.rejection=HANDLED),!0===p?s=o:(d&&d.enter(),s=p(o),d&&(d.exit(),l=!0)),s===u.promise?h(TypeError$1("Promise-chain cycle")):(c=isThenable(s))?c.call(s,f,h):f(s)):h(o)}catch(e){d&&!l&&d.exit(),h(e)}}t.reactions=[],t.notified=!1,r&&!t.rejection&&onUnhandled(e,t)}))}},dispatchEvent=function(e,t,r){var n,o;DISPATCH_EVENT?((n=document$2.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),global_1.dispatchEvent(n)):n={promise:t,reason:r},(o=global_1["on"+e])?o(n):e===UNHANDLED_REJECTION&&hostReportErrors("Unhandled promise rejection",r)},onUnhandled=function(e,t){task$1.call(global_1,(function(){var r,n=t.value;if(isUnhandled(t)&&(r=perform((function(){IS_NODE$1?process$4.emit("unhandledRejection",n,e):dispatchEvent(UNHANDLED_REJECTION,e,n)})),t.rejection=IS_NODE$1||isUnhandled(t)?UNHANDLED:HANDLED,r.error))throw r.value}))},isUnhandled=function(e){return e.rejection!==HANDLED&&!e.parent},onHandleUnhandled=function(e,t){task$1.call(global_1,(function(){IS_NODE$1?process$4.emit("rejectionHandled",e):dispatchEvent(REJECTION_HANDLED,e,t.value)}))},bind=function(e,t,r,n){return function(o){e(t,r,o,n)}},internalReject=function(e,t,r,n){t.done||(t.done=!0,n&&(t=n),t.value=r,t.state=REJECTED,notify$1(e,t,!0))},internalResolve=function(e,t,r,n){if(!t.done){t.done=!0,n&&(t=n);try{if(e===r)throw TypeError$1("Promise can't be resolved itself");var o=isThenable(r);o?microtask((function(){var n={done:!1};try{o.call(r,bind(internalResolve,e,n,t),bind(internalReject,e,n,t))}catch(r){internalReject(e,n,r,t)}})):(t.value=r,t.state=FULFILLED,notify$1(e,t,!1))}catch(r){internalReject(e,{done:!1},r,t)}}};FORCED&&(PromiseConstructor=function(e){anInstance(this,PromiseConstructor,PROMISE),aFunction$1(e),Internal.call(this);var t=getInternalState(this);try{e(bind(internalResolve,this,t),bind(internalReject,this,t))}catch(e){internalReject(this,t,e)}},(Internal=function(e){setInternalState(this,{type:PROMISE,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:PENDING,value:void 0})}).prototype=redefineAll(PromiseConstructor.prototype,{then:function(e,t){var r=getInternalPromiseState(this),n=newPromiseCapability$1(speciesConstructor(this,PromiseConstructor));return n.ok="function"!=typeof e||e,n.fail="function"==typeof t&&t,n.domain=IS_NODE$1?process$4.domain:void 0,r.parent=!0,r.reactions.push(n),r.state!=PENDING&&notify$1(this,r,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),OwnPromiseCapability=function(){var e=new Internal,t=getInternalState(e);this.promise=e,this.resolve=bind(internalResolve,e,t),this.reject=bind(internalReject,e,t)},newPromiseCapability.f=newPromiseCapability$1=function(e){return e===PromiseConstructor||e===PromiseWrapper?new OwnPromiseCapability(e):newGenericPromiseCapability(e)},"function"==typeof nativePromiseConstructor&&(nativeThen=nativePromiseConstructor.prototype.then,redefine(nativePromiseConstructor.prototype,"then",(function(e,t){var r=this;return new PromiseConstructor((function(e,t){nativeThen.call(r,e,t)})).then(e,t)}),{unsafe:!0}),"function"==typeof $fetch&&_export({global:!0,enumerable:!0,forced:!0},{fetch:function(e){return promiseResolve(PromiseConstructor,$fetch.apply(global_1,arguments))}}))),_export({global:!0,wrap:!0,forced:FORCED},{Promise:PromiseConstructor}),setToStringTag(PromiseConstructor,PROMISE,!1),setSpecies(PROMISE),PromiseWrapper=getBuiltIn(PROMISE),_export({target:PROMISE,stat:!0,forced:FORCED},{reject:function(e){var t=newPromiseCapability$1(this);return t.reject.call(void 0,e),t.promise}}),_export({target:PROMISE,stat:!0,forced:FORCED},{resolve:function(e){return promiseResolve(this,e)}}),_export({target:PROMISE,stat:!0,forced:INCORRECT_ITERATION},{all:function(e){var t=this,r=newPromiseCapability$1(t),n=r.resolve,o=r.reject,i=perform((function(){var r=aFunction$1(t.resolve),i=[],a=0,s=1;iterate_1(e,(function(e){var c=a++,l=!1;i.push(void 0),s++,r.call(t,e).then((function(e){l||(l=!0,i[c]=e,--s||n(i))}),o)})),--s||n(i)}));return i.error&&o(i.value),r.promise},race:function(e){var t=this,r=newPromiseCapability$1(t),n=r.reject,o=perform((function(){var o=aFunction$1(t.resolve);iterate_1(e,(function(e){o.call(t,e).then(r.resolve,n)}))}));return o.error&&n(o.value),r.promise}});var tryCatchTarget,es5=createCommonjsModule((function(e){var t=function(){return void 0===this}();if(t)e.exports={freeze:Object.freeze,defineProperty:Object.defineProperty,getDescriptor:Object.getOwnPropertyDescriptor,keys:Object.keys,names:Object.getOwnPropertyNames,getPrototypeOf:Object.getPrototypeOf,isArray:Array.isArray,isES5:t,propertyIsWritable:function(e,t){var r=Object.getOwnPropertyDescriptor(e,t);return!(r&&!r.writable&&!r.set)}};else{var r={}.hasOwnProperty,n={}.toString,o={}.constructor.prototype,i=function(e){var t=[];for(var n in e)r.call(e,n)&&t.push(n);return t};e.exports={isArray:function(e){try{return"[object Array]"===n.call(e)}catch(e){return!1}},keys:i,names:i,defineProperty:function(e,t,r){return e[t]=r.value,e},getDescriptor:function(e,t){return{value:e[t]}},freeze:function(e){return e},getPrototypeOf:function(e){try{return Object(e).constructor.prototype}catch(e){return o}},isES5:t,propertyIsWritable:function(){return!0}}}})),es5_1=es5.freeze,es5_2=es5.defineProperty,es5_3=es5.getDescriptor,es5_4=es5.keys,es5_5=es5.names,es5_6=es5.getPrototypeOf,es5_7=es5.isArray,es5_8=es5.isES5,es5_9=es5.propertyIsWritable,canEvaluate="undefined"==typeof navigator,errorObj={e:{}},globalObject="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==commonjsGlobal?commonjsGlobal:void 0!==commonjsGlobal?commonjsGlobal:null;function tryCatcher(){try{var e=tryCatchTarget;return tryCatchTarget=null,e.apply(this,arguments)}catch(e){return errorObj.e=e,errorObj}}function tryCatch(e){return tryCatchTarget=e,tryCatcher}var inherits=function(e,t){var r={}.hasOwnProperty;function n(){for(var n in this.constructor=e,this.constructor$=t,t.prototype)r.call(t.prototype,n)&&"$"!==n.charAt(n.length-1)&&(this[n+"$"]=t.prototype[n])}return n.prototype=t.prototype,e.prototype=new n,e.prototype};function isPrimitive(e){return null==e||!0===e||!1===e||"string"==typeof e||"number"==typeof e}function isObject$1(e){return"function"==typeof e||"object"==typeof e&&null!==e}function maybeWrapAsError(e){return isPrimitive(e)?new Error(safeToString(e)):e}function withAppended(e,t){var r,n=e.length,o=new Array(n+1);for(r=0;r<n;++r)o[r]=e[r];return o[r]=t,o}function getDataPropertyOrDefault(e,t,r){if(!es5.isES5)return{}.hasOwnProperty.call(e,t)?e[t]:void 0;var n=Object.getOwnPropertyDescriptor(e,t);return null!=n?null==n.get&&null==n.set?n.value:r:void 0}function notEnumerableProp(e,t,r){if(isPrimitive(e))return e;var n={value:r,configurable:!0,enumerable:!1,writable:!0};return es5.defineProperty(e,t,n),e}function thrower(e){throw e}var inheritedDataKeys=function(){var e=[Array.prototype,Object.prototype,Function.prototype],t=function(t){for(var r=0;r<e.length;++r)if(e[r]===t)return!0;return!1};if(es5.isES5){var r=Object.getOwnPropertyNames;return function(e){for(var n=[],o=Object.create(null);null!=e&&!t(e);){var i;try{i=r(e)}catch(e){return n}for(var a=0;a<i.length;++a){var s=i[a];if(!o[s]){o[s]=!0;var c=Object.getOwnPropertyDescriptor(e,s);null!=c&&null==c.get&&null==c.set&&n.push(s)}}e=es5.getPrototypeOf(e)}return n}}var n={}.hasOwnProperty;return function(r){if(t(r))return[];var o=[];e:for(var i in r)if(n.call(r,i))o.push(i);else{for(var a=0;a<e.length;++a)if(n.call(e[a],i))continue e;o.push(i)}return o}}(),thisAssignmentPattern=/this\s*\.\s*\S+\s*=/;function isClass(e){try{if("function"==typeof e){var t=es5.names(e.prototype),r=es5.isES5&&t.length>1,n=t.length>0&&!(1===t.length&&"constructor"===t[0]),o=thisAssignmentPattern.test(e+"")&&es5.names(e).length>0;if(r||n||o)return!0}return!1}catch(e){return!1}}function toFastProperties(e){return e}var rident=/^[a-z$_][a-z$_0-9]*$/i;function isIdentifier(e){return rident.test(e)}function filledRange(e,t,r){for(var n=new Array(e),o=0;o<e;++o)n[o]=t+o+r;return n}function safeToString(e){try{return e+""}catch(e){return"[no string representation]"}}function isError(e){return e instanceof Error||null!==e&&"object"==typeof e&&"string"==typeof e.message&&"string"==typeof e.name}function markAsOriginatingFromRejection(e){try{notEnumerableProp(e,"isOperational",!0)}catch(e){}}function originatesFromRejection(e){return null!=e&&(e instanceof Error.__BluebirdErrorTypes__.OperationalError||!0===e.isOperational)}function canAttachTrace(e){return isError(e)&&es5.propertyIsWritable(e,"stack")}var ensureErrorObject="stack"in new Error?function(e){return canAttachTrace(e)?e:new Error(safeToString(e))}:function(e){if(canAttachTrace(e))return e;try{throw new Error(safeToString(e))}catch(e){return e}};function classString(e){return{}.toString.call(e)}function copyDescriptors(e,t,r){for(var n=es5.names(e),o=0;o<n.length;++o){var i=n[o];if(r(i))try{es5.defineProperty(t,i,es5.getDescriptor(e,i))}catch(e){}}}var asArray=function(e){return es5.isArray(e)?e:null};if("undefined"!=typeof Symbol&&Symbol.iterator){var ArrayFrom="function"==typeof Array.from?function(e){return Array.from(e)}:function(e){for(var t,r=[],n=e[Symbol.iterator]();!(t=n.next()).done;)r.push(t.value);return r};asArray=function(e){return es5.isArray(e)?e:null!=e&&"function"==typeof e[Symbol.iterator]?ArrayFrom(e):null}}var reflectHandler,isNode="undefined"!=typeof process&&"[object process]"===classString(process).toLowerCase(),hasEnvVariables="undefined"!=typeof process&&void 0!==process.env;function env(e){return hasEnvVariables?process.env[e]:void 0}function getNativePromise(){if("function"==typeof Promise)try{if("[object Promise]"===classString(new Promise((function(){}))))return Promise}catch(e){}}function contextBind(e,t){if(null===e||"function"!=typeof t||t===reflectHandler)return t;null!==e.domain&&(t=e.domain.bind(t));var r=e.async;if(null!==r){var n=t;t=function(){for(var e=arguments.length+2,t=new Array(e),o=2;o<e;++o)t[o]=arguments[o-2];return t[0]=n,t[1]=this,r.runInAsyncScope.apply(r,t)}}return t}var ret={setReflectHandler:function(e){reflectHandler=e},isClass:isClass,isIdentifier:isIdentifier,inheritedDataKeys:inheritedDataKeys,getDataPropertyOrDefault:getDataPropertyOrDefault,thrower:thrower,isArray:es5.isArray,asArray:asArray,notEnumerableProp:notEnumerableProp,isPrimitive:isPrimitive,isObject:isObject$1,isError:isError,canEvaluate:canEvaluate,errorObj:errorObj,tryCatch:tryCatch,inherits:inherits,withAppended:withAppended,maybeWrapAsError:maybeWrapAsError,toFastProperties:toFastProperties,filledRange:filledRange,toString:safeToString,canAttachTrace:canAttachTrace,ensureErrorObject:ensureErrorObject,originatesFromRejection:originatesFromRejection,markAsOriginatingFromRejection:markAsOriginatingFromRejection,classString:classString,copyDescriptors:copyDescriptors,isNode:isNode,hasEnvVariables:hasEnvVariables,env:env,global:globalObject,getNativePromise:getNativePromise,contextBind:contextBind};ret.isRecentNode=ret.isNode&&function(){var e;return process.versions&&process.versions.node?e=process.versions.node.split(".").map(Number):process.version&&(e=process.version.split(".").map(Number)),0===e[0]&&e[1]>10||e[0]>0}(),ret.nodeSupportsAsyncResource=ret.isNode&&function(){var e=!1;try{e="function"==typeof async_hooks.AsyncResource.prototype.runInAsyncScope}catch(t){e=!1}return e}(),ret.isNode&&ret.toFastProperties(process);try{throw new Error}catch(e){ret.lastLineError=e}var schedule,util=ret,noAsyncScheduler=function(){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")},NativePromise=util.getNativePromise();if(util.isNode&&"undefined"==typeof MutationObserver){var GlobalSetImmediate=commonjsGlobal.setImmediate,ProcessNextTick=process.nextTick;schedule=util.isRecentNode?function(e){GlobalSetImmediate.call(commonjsGlobal,e)}:function(e){ProcessNextTick.call(process,e)}}else if("function"==typeof NativePromise&&"function"==typeof NativePromise.resolve){var nativePromise=NativePromise.resolve();schedule=function(e){nativePromise.then(e)}}else schedule="undefined"!=typeof MutationObserver&&("undefined"==typeof window||!window.navigator||!window.navigator.standalone&&!window.cordova)&&"classList"in document.documentElement?function(){var e=document.createElement("div"),t={attributes:!0},r=!1,n=document.createElement("div");new MutationObserver((function(){e.classList.toggle("foo"),r=!1})).observe(n,t);return function(o){var i=new MutationObserver((function(){i.disconnect(),o()}));i.observe(e,t),r||(r=!0,n.classList.toggle("foo"))}}():"undefined"!=typeof setImmediate?function(e){setImmediate(e)}:"undefined"!=typeof setTimeout?function(e){setTimeout(e,0)}:noAsyncScheduler;var schedule_1=schedule;function arrayMove(e,t,r,n,o){for(var i=0;i<o;++i)r[i+n]=e[i+t],e[i+t]=void 0}function Queue(e){this._capacity=e,this._length=0,this._front=0}Queue.prototype._willBeOverCapacity=function(e){return this._capacity<e},Queue.prototype._pushOne=function(e){var t=this.length();this._checkCapacity(t+1),this[this._front+t&this._capacity-1]=e,this._length=t+1},Queue.prototype.push=function(e,t,r){var n=this.length()+3;if(this._willBeOverCapacity(n))return this._pushOne(e),this._pushOne(t),void this._pushOne(r);var o=this._front+n-3;this._checkCapacity(n);var i=this._capacity-1;this[o+0&i]=e,this[o+1&i]=t,this[o+2&i]=r,this._length=n},Queue.prototype.shift=function(){var e=this._front,t=this[e];return this[e]=void 0,this._front=e+1&this._capacity-1,this._length--,t},Queue.prototype.length=function(){return this._length},Queue.prototype._checkCapacity=function(e){this._capacity<e&&this._resizeTo(this._capacity<<1)},Queue.prototype._resizeTo=function(e){var t=this._capacity;this._capacity=e,arrayMove(this,0,this,t,this._front+this._length&t-1)};var firstLineError,queue$1=Queue;try{throw new Error}catch(e){firstLineError=e}function Async(){this._customScheduler=!1,this._isTickUsed=!1,this._lateQueue=new queue$1(16),this._normalQueue=new queue$1(16),this._haveDrainedQueues=!1;var e=this;this.drainQueues=function(){e._drainQueues()},this._schedule=schedule_1}function AsyncInvokeLater(e,t,r){this._lateQueue.push(e,t,r),this._queueTick()}function AsyncInvoke(e,t,r){this._normalQueue.push(e,t,r),this._queueTick()}function AsyncSettlePromises(e){this._normalQueue._pushOne(e),this._queueTick()}function _drainQueue(e){for(;e.length()>0;)_drainQueueStep(e)}function _drainQueueStep(e){var t=e.shift();if("function"!=typeof t)t._settlePromises();else{var r=e.shift(),n=e.shift();t.call(r,n)}}Async.prototype.setScheduler=function(e){var t=this._schedule;return this._schedule=e,this._customScheduler=!0,t},Async.prototype.hasCustomScheduler=function(){return this._customScheduler},Async.prototype.haveItemsQueued=function(){return this._isTickUsed||this._haveDrainedQueues},Async.prototype.fatalError=function(e,t){t?(process.stderr.write("Fatal "+(e instanceof Error?e.stack:e)+"\n"),process.exit(2)):this.throwLater(e)},Async.prototype.throwLater=function(e,t){if(1===arguments.length&&(t=e,e=function(){throw t}),"undefined"!=typeof setTimeout)setTimeout((function(){e(t)}),0);else try{this._schedule((function(){e(t)}))}catch(e){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")}},Async.prototype.invokeLater=AsyncInvokeLater,Async.prototype.invoke=AsyncInvoke,Async.prototype.settlePromises=AsyncSettlePromises,Async.prototype._drainQueues=function(){_drainQueue(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,_drainQueue(this._lateQueue)},Async.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},Async.prototype._reset=function(){this._isTickUsed=!1};var async=Async,firstLineError_1=firstLineError;async.firstLineError=firstLineError_1;var _TypeError,_RangeError,Objectfreeze=es5.freeze,inherits$1=util.inherits,notEnumerableProp$1=util.notEnumerableProp;function subError(e,t){function r(n){if(!(this instanceof r))return new r(n);notEnumerableProp$1(this,"message","string"==typeof n?n:t),notEnumerableProp$1(this,"name",e),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this)}return inherits$1(r,Error),r}var Warning=subError("Warning","warning"),CancellationError=subError("CancellationError","cancellation error"),TimeoutError=subError("TimeoutError","timeout error"),AggregateError=subError("AggregateError","aggregate error");try{_TypeError=TypeError,_RangeError=RangeError}catch(e){_TypeError=subError("TypeError","type error"),_RangeError=subError("RangeError","range error")}for(var methods="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),i=0;i<methods.length;++i)"function"==typeof Array.prototype[methods[i]]&&(AggregateError.prototype[methods[i]]=Array.prototype[methods[i]]);es5.defineProperty(AggregateError.prototype,"length",{value:0,configurable:!1,writable:!0,enumerable:!0}),AggregateError.prototype.isOperational=!0;var level=0;function OperationalError(e){if(!(this instanceof OperationalError))return new OperationalError(e);notEnumerableProp$1(this,"name","OperationalError"),notEnumerableProp$1(this,"message",e),this.cause=e,this.isOperational=!0,e instanceof Error?(notEnumerableProp$1(this,"message",e.message),notEnumerableProp$1(this,"stack",e.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}AggregateError.prototype.toString=function(){var e=Array(4*level+1).join(" "),t="\n"+e+"AggregateError of:\n";level++,e=Array(4*level+1).join(" ");for(var r=0;r<this.length;++r){for(var n=this[r]===this?"[Circular AggregateError]":this[r]+"",o=n.split("\n"),i=0;i<o.length;++i)o[i]=e+o[i];t+=(n=o.join("\n"))+"\n"}return level--,t},inherits$1(OperationalError,Error);var errorTypes=Error.__BluebirdErrorTypes__;errorTypes||(errorTypes=Objectfreeze({CancellationError:CancellationError,TimeoutError:TimeoutError,OperationalError:OperationalError,RejectionError:OperationalError,AggregateError:AggregateError}),es5.defineProperty(Error,"__BluebirdErrorTypes__",{value:errorTypes,writable:!1,enumerable:!1,configurable:!1}));var errors={Error:Error,TypeError:_TypeError,RangeError:_RangeError,CancellationError:errorTypes.CancellationError,OperationalError:errorTypes.OperationalError,TimeoutError:errorTypes.TimeoutError,AggregateError:errorTypes.AggregateError,Warning:Warning},thenables=function(e,t){var r=util,n=r.errorObj,o=r.isObject;var i={}.hasOwnProperty;return function(a,s){if(o(a)){if(a instanceof e)return a;var c=function(e){try{return function(e){return e.then}(e)}catch(e){return n.e=e,n}}(a);if(c===n){s&&s._pushContext();var l=e.reject(c.e);return s&&s._popContext(),l}if("function"==typeof c){if(function(e){try{return i.call(e,"_promise0")}catch(e){return!1}}(a)){l=new e(t);return a._then(l._fulfill,l._reject,void 0,l,null),l}return function(o,i,a){var s=new e(t),c=s;a&&a._pushContext();s._captureStackTrace(),a&&a._popContext();var l=r.tryCatch(i).call(o,(function(e){if(!s)return;s._resolveCallback(e),s=null}),(function(e){if(!s)return;s._rejectCallback(e,!1,!0),s=null}));!1,s&&l===n&&(s._rejectCallback(l.e,!0,!0),s=null);return c}(a,c,s)}}return a}},promise_array=function(e,t,r,n,o){var i=util;function a(r){var n=this._promise=new e(t);r instanceof e&&(n._propagateFrom(r,3),r.suppressUnhandledRejections()),n._setOnCancel(this),this._values=r,this._length=0,this._totalResolved=0,this._init(void 0,-2)}return i.inherits(a,o),a.prototype.length=function(){return this._length},a.prototype.promise=function(){return this._promise},a.prototype._init=function t(o,a){var s=r(this._values,this._promise);if(s instanceof e){var c=(s=s._target())._bitField;if(this._values=s,0==(50397184&c))return this._promise._setAsyncGuaranteed(),s._then(t,this._reject,void 0,this,a);if(0==(33554432&c))return 0!=(16777216&c)?this._reject(s._reason()):this._cancel();s=s._value()}if(null!==(s=i.asArray(s)))0!==s.length?this._iterate(s):-5===a?this._resolveEmptyArray():this._resolve(function(e){switch(e){case-2:return[];case-3:return{};case-6:return new Map}}(a));else{var l=n("expecting an array or an iterable object but got "+i.classString(s)).reason();this._promise._rejectCallback(l,!1)}},a.prototype._iterate=function(t){var n=this.getActualLength(t.length);this._length=n,this._values=this.shouldCopyValues()?new Array(n):this._values;for(var o=this._promise,i=!1,a=null,s=0;s<n;++s){var c=r(t[s],o);a=c instanceof e?(c=c._target())._bitField:null,i?null!==a&&c.suppressUnhandledRejections():null!==a?0==(50397184&a)?(c._proxy(this,s),this._values[s]=c):i=0!=(33554432&a)?this._promiseFulfilled(c._value(),s):0!=(16777216&a)?this._promiseRejected(c._reason(),s):this._promiseCancelled(s):i=this._promiseFulfilled(c,s)}i||o._setAsyncGuaranteed()},a.prototype._isResolved=function(){return null===this._values},a.prototype._resolve=function(e){this._values=null,this._promise._fulfill(e)},a.prototype._cancel=function(){!this._isResolved()&&this._promise._isCancellable()&&(this._values=null,this._promise._cancel())},a.prototype._reject=function(e){this._values=null,this._promise._rejectCallback(e,!1)},a.prototype._promiseFulfilled=function(e,t){return this._values[t]=e,++this._totalResolved>=this._length&&(this._resolve(this._values),!0)},a.prototype._promiseCancelled=function(){return this._cancel(),!0},a.prototype._promiseRejected=function(e){return this._totalResolved++,this._reject(e),!0},a.prototype._resultCancelled=function(){if(!this._isResolved()){var t=this._values;if(this._cancel(),t instanceof e)t.cancel();else for(var r=0;r<t.length;++r)t[r]instanceof e&&t[r].cancel()}},a.prototype.shouldCopyValues=function(){return!0},a.prototype.getActualLength=function(e){return e},a},context=function(e){var t=!1,r=[];function n(){this._trace=new n.CapturedTrace(o())}function o(){var e=r.length-1;if(e>=0)return r[e]}return e.prototype._promiseCreated=function(){},e.prototype._pushContext=function(){},e.prototype._popContext=function(){return null},e._peekContext=e.prototype._peekContext=function(){},n.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,r.push(this._trace))},n.prototype._popContext=function(){if(void 0!==this._trace){var e=r.pop(),t=e._promiseCreated;return e._promiseCreated=null,t}return null},n.CapturedTrace=null,n.create=function(){if(t)return new n},n.deactivateLongStackTraces=function(){},n.activateLongStackTraces=function(){var r=e.prototype._pushContext,i=e.prototype._popContext,a=e._peekContext,s=e.prototype._peekContext,c=e.prototype._promiseCreated;n.deactivateLongStackTraces=function(){e.prototype._pushContext=r,e.prototype._popContext=i,e._peekContext=a,e.prototype._peekContext=s,e.prototype._promiseCreated=c,t=!1},t=!0,e.prototype._pushContext=n.prototype._pushContext,e.prototype._popContext=n.prototype._popContext,e._peekContext=e.prototype._peekContext=o,e.prototype._promiseCreated=function(){var e=this._peekContext();e&&null==e._promiseCreated&&(e._promiseCreated=this)}},n},debuggability=function(e,t,r,n){var o,i,a,s,c=e._async,l=errors.Warning,u=util,p=es5,f=u.canAttachTrace,h=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,d=/\((?:timers\.js):\d+:\d+\)/,_=/[\/<\(](.+?):(\d+):(\d+)\)?\s*$/,y=null,v=null,g=!1,m=!(0==u.env("BLUEBIRD_DEBUG")||!u.env("BLUEBIRD_DEBUG")&&"development"!==u.env("NODE_ENV")),b=!(0==u.env("BLUEBIRD_WARNINGS")||!m&&!u.env("BLUEBIRD_WARNINGS")),C=!(0==u.env("BLUEBIRD_LONG_STACK_TRACES")||!m&&!u.env("BLUEBIRD_LONG_STACK_TRACES")),w=0!=u.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(b||!!u.env("BLUEBIRD_W_FORGOTTEN_RETURN"));!function(){var t=[];function r(){for(var e=0;e<t.length;++e)t[e]._notifyUnhandledRejection();n()}function n(){t.length=0}s=function(e){t.push(e),setTimeout(r,1)},p.defineProperty(e,"_unhandledRejectionCheck",{value:r}),p.defineProperty(e,"_unhandledRejectionClear",{value:n})}(),e.prototype.suppressUnhandledRejections=function(){var e=this._target();e._bitField=-1048577&e._bitField|524288},e.prototype._ensurePossibleRejectionHandled=function(){0==(524288&this._bitField)&&(this._setRejectionIsUnhandled(),s(this))},e.prototype._notifyUnhandledRejectionIsHandled=function(){q("rejectionHandled",o,void 0,this)},e.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},e.prototype._returnedNonUndefined=function(){return 0!=(268435456&this._bitField)},e.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var e=this._settledValue();this._setUnhandledRejectionIsNotified(),q("unhandledRejection",i,e,this)}},e.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},e.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-262145&this._bitField},e.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},e.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},e.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-1048577&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},e.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},e.prototype._warn=function(e,t,r){return U(e,t,r||this)},e.onPossiblyUnhandledRejection=function(t){var r=e._getContext();i=u.contextBind(r,t)},e.onUnhandledRejectionHandled=function(t){var r=e._getContext();o=u.contextBind(r,t)};var E=function(){};e.longStackTraces=function(){if(c.haveItemsQueued()&&!ee.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!ee.longStackTraces&&W()){var r=e.prototype._captureStackTrace,n=e.prototype._attachExtraTrace,o=e.prototype._dereferenceTrace;ee.longStackTraces=!0,E=function(){if(c.haveItemsQueued()&&!ee.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");e.prototype._captureStackTrace=r,e.prototype._attachExtraTrace=n,e.prototype._dereferenceTrace=o,t.deactivateLongStackTraces(),ee.longStackTraces=!1},e.prototype._captureStackTrace=L,e.prototype._attachExtraTrace=G,e.prototype._dereferenceTrace=H,t.activateLongStackTraces()}},e.hasLongStackTraces=function(){return ee.longStackTraces&&W()};var T={unhandledrejection:{before:function(){var e=u.global.onunhandledrejection;return u.global.onunhandledrejection=null,e},after:function(e){u.global.onunhandledrejection=e}},rejectionhandled:{before:function(){var e=u.global.onrejectionhandled;return u.global.onrejectionhandled=null,e},after:function(e){u.global.onrejectionhandled=e}}},j=function(){var e=function(e,t){if(!e)return!u.global.dispatchEvent(t);var r;try{return r=e.before(),!u.global.dispatchEvent(t)}finally{e.after(r)}};try{if("function"==typeof CustomEvent){var t=new CustomEvent("CustomEvent");return u.global.dispatchEvent(t),function(t,r){t=t.toLowerCase();var n=new CustomEvent(t,{detail:r,cancelable:!0});return p.defineProperty(n,"promise",{value:r.promise}),p.defineProperty(n,"reason",{value:r.reason}),e(T[t],n)}}if("function"==typeof Event){t=new Event("CustomEvent");return u.global.dispatchEvent(t),function(t,r){t=t.toLowerCase();var n=new Event(t,{cancelable:!0});return n.detail=r,p.defineProperty(n,"promise",{value:r.promise}),p.defineProperty(n,"reason",{value:r.reason}),e(T[t],n)}}return(t=document.createEvent("CustomEvent")).initCustomEvent("testingtheevent",!1,!0,{}),u.global.dispatchEvent(t),function(t,r){t=t.toLowerCase();var n=document.createEvent("CustomEvent");return n.initCustomEvent(t,!1,!0,r),e(T[t],n)}}catch(e){}return function(){return!1}}(),S=u.isNode?function(){return process.emit.apply(process,arguments)}:u.global?function(e){var t="on"+e.toLowerCase(),r=u.global[t];return!!r&&(r.apply(u.global,[].slice.call(arguments,1)),!0)}:function(){return!1};function O(e,t){return{promise:t}}var P={promiseCreated:O,promiseFulfilled:O,promiseRejected:O,promiseResolved:O,promiseCancelled:O,promiseChained:function(e,t,r){return{promise:t,child:r}},warning:function(e,t){return{warning:t}},unhandledRejection:function(e,t,r){return{reason:t,promise:r}},rejectionHandled:O},F=function(e){var t=!1;try{t=S.apply(null,arguments)}catch(e){c.throwLater(e),t=!0}var r=!1;try{r=j(e,P[e].apply(null,arguments))}catch(e){c.throwLater(e),r=!0}return r||t};function A(){return!1}function k(e,t,r){var n=this;try{e(t,r,(function(e){if("function"!=typeof e)throw new TypeError("onCancel must be a function, got: "+u.toString(e));n._attachCancellationCallback(e)}))}catch(e){return e}}function R(e){if(!this._isCancellable())return this;var t=this._onCancel();void 0!==t?u.isArray(t)?t.push(e):this._setOnCancel([t,e]):this._setOnCancel(e)}function $(){return this._onCancelField}function I(e){this._onCancelField=e}function x(){this._cancellationParent=void 0,this._onCancelField=void 0}function N(e,t){if(0!=(1&t)){this._cancellationParent=e;var r=e._branchesRemainingToCancel;void 0===r&&(r=0),e._branchesRemainingToCancel=r+1}0!=(2&t)&&e._isBound()&&this._setBoundTo(e._boundTo)}e.config=function(t){if("longStackTraces"in(t=Object(t))&&(t.longStackTraces?e.longStackTraces():!t.longStackTraces&&e.hasLongStackTraces()&&E()),"warnings"in t){var o=t.warnings;ee.warnings=!!o,w=ee.warnings,u.isObject(o)&&"wForgottenReturn"in o&&(w=!!o.wForgottenReturn)}if("cancellation"in t&&t.cancellation&&!ee.cancellation){if(c.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");e.prototype._clearCancellationData=x,e.prototype._propagateFrom=N,e.prototype._onCancel=$,e.prototype._setOnCancel=I,e.prototype._attachCancellationCallback=R,e.prototype._execute=k,D=N,ee.cancellation=!0}if("monitoring"in t&&(t.monitoring&&!ee.monitoring?(ee.monitoring=!0,e.prototype._fireEvent=F):!t.monitoring&&ee.monitoring&&(ee.monitoring=!1,e.prototype._fireEvent=A)),"asyncHooks"in t&&u.nodeSupportsAsyncResource){var i=ee.asyncHooks,a=!!t.asyncHooks;i!==a&&(ee.asyncHooks=a,a?r():n())}return e},e.prototype._fireEvent=A,e.prototype._execute=function(e,t,r){try{e(t,r)}catch(e){return e}},e.prototype._onCancel=function(){},e.prototype._setOnCancel=function(e){},e.prototype._attachCancellationCallback=function(e){},e.prototype._captureStackTrace=function(){},e.prototype._attachExtraTrace=function(){},e.prototype._dereferenceTrace=function(){},e.prototype._clearCancellationData=function(){},e.prototype._propagateFrom=function(e,t){};var D=function(e,t){0!=(2&t)&&e._isBound()&&this._setBoundTo(e._boundTo)};function M(){var t=this._boundTo;return void 0!==t&&t instanceof e?t.isFulfilled()?t.value():void 0:t}function L(){this._trace=new Y(this._peekContext())}function G(e,t){if(f(e)){var r=this._trace;if(void 0!==r&&t&&(r=r._parent),void 0!==r)r.attachExtraTrace(e);else if(!e.__stackCleaned__){var n=V(e);u.notEnumerableProp(e,"stack",n.message+"\n"+n.stack.join("\n")),u.notEnumerableProp(e,"__stackCleaned__",!0)}}}function H(){this._trace=void 0}function U(t,r,n){if(ee.warnings){var o,i=new l(t);if(r)n._attachExtraTrace(i);else if(ee.longStackTraces&&(o=e._peekContext()))o.attachExtraTrace(i);else{var a=V(i);i.stack=a.message+"\n"+a.stack.join("\n")}F("warning",i)||K(i,"",!0)}}function B(e){for(var t=[],r=0;r<e.length;++r){var n=e[r],o=" (No stack trace)"===n||y.test(n),i=o&&Q(n);o&&!i&&(g&&" "!==n.charAt(0)&&(n=" "+n),t.push(n))}return t}function V(e){var t=e.stack,r=e.toString();return t="string"==typeof t&&t.length>0?function(e){for(var t=e.stack.replace(/\s+$/g,"").split("\n"),r=0;r<t.length;++r){var n=t[r];if(" (No stack trace)"===n||y.test(n))break}return r>0&&"SyntaxError"!=e.name&&(t=t.slice(r)),t}(e):[" (No stack trace)"],{message:r,stack:"SyntaxError"==e.name?t:B(t)}}function K(e,t,r){if("undefined"!=typeof console){var n;if(u.isObject(e)){var o=e.stack;n=t+v(o,e)}else n=t+String(e);"function"==typeof a?a(n,r):"function"!=typeof console.log&&"object"!=typeof console.log||console.log(n)}}function q(e,t,r,n){v